Skip to content

Commit

Permalink
stuffs
Browse files Browse the repository at this point in the history
  • Loading branch information
PinkGoosik committed Feb 25, 2024
1 parent ab119c0 commit c3ab2fa
Show file tree
Hide file tree
Showing 11 changed files with 89 additions and 40 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/publish-modrinth.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
fabric/build/libs/winterly-fabric-${{ github.event.release.tag_name }}.jar
fabric/build/libs/winterly-fabric-${{ github.event.release.tag_name }}-sources.jar
name: Winterly Fabric ${{ github.event.release.tag_name }}
name: ${{ github.event.release.tag_name }}+fabric
version: ${{ github.event.release.tag_name }}+fabric

version-type: release
Expand Down Expand Up @@ -67,7 +67,7 @@ jobs:
neoforge/build/libs/winterly-neoforge-${{ github.event.release.tag_name }}.jar
neoforge/build/libs/winterly-neoforge-${{ github.event.release.tag_name }}-sources.jar
name: Winterly NeoForge ${{ github.event.release.tag_name }}
name: ${{ github.event.release.tag_name }}+neoforge
version: ${{ github.event.release.tag_name }}+neoforge

version-type: alpha
Expand Down
13 changes: 4 additions & 9 deletions common/src/main/java/winterly/registry/CommonWinterlyItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,9 @@
public class CommonWinterlyItems {
public static final Map<ResourceLocation, Item> ITEMS = new LinkedHashMap<>();

// public static final Item GINGERBREAD_MAN = add("gingerbread_man", new Item(settings().food(new FoodComponent.Builder().hunger(3).saturationModifier(0.5F).build())));
// public static final Item EDIBLE_SNOW = add("edible_snow", new Item(settings().food(new FoodComponent.Builder().hunger(1).saturationModifier(0.1F).statusEffect(new StatusEffectInstance(StatusEffects.NAUSEA, 120, 0), 0.5F).statusEffect(new StatusEffectInstance(StatusEffects.SLOWNESS, 120, 1), 0.5F).build())));
// public static final Item PISS_SNOW = add("yellow_snow", new Item(settings().food(new FoodComponent.Builder().hunger(1).saturationModifier(0F).statusEffect(new StatusEffectInstance(StatusEffects.NAUSEA, 200, 0), 0.9F).statusEffect(new StatusEffectInstance(StatusEffects.POISON, 80, 1), 0.8F).build())));
public static Item RED_CANDY_CANE;
public static Item GREEN_CANDY_CANE;
public static Item BLUE_CANDY_CANE;
// public static final Item YELLOW_CANDY_CANE = add("yellow_candy_cane", new Item(settings().food(new FoodComponent.Builder().hunger(2).saturationModifier(0.1F).snack().build())));
// public static final Item CANDY_CANE = add("candy_cane", new Item(settings().food(new FoodComponent.Builder().hunger(2).saturationModifier(0.1F).snack().build())));
// public static final Item MULLED_WINE = add("mulled_wine", new Item(settings().food(new FoodComponent.Builder().hunger(4).saturationModifier(0.2F).build())));
// public static final Item EGGNOG = add("eggnog", new Item(settings().food(new FoodComponent.Builder().hunger(2).saturationModifier(0.4F).statusEffect(new StatusEffectInstance(StatusEffects.NAUSEA, 200, 0), 0.2F).build())));
// public static final Item COCOA = add("cocoa", new Item(settings().food(new FoodComponent.Builder().hunger(4).saturationModifier(0.5F).build())));
// public static final Item KIDS_CHAMPAGNE = add("kids_champagne", new Item(settings().food(new FoodComponent.Builder().hunger(10).saturationModifier(0.1F).statusEffect(new StatusEffectInstance(StatusEffects.REGENERATION, 100, 0), 0.3F).statusEffect(new StatusEffectInstance(StatusEffects.ABSORPTION, 400, 0), 0.3F).statusEffect(new StatusEffectInstance(StatusEffects.INSTANT_HEALTH, 0, 0), 0.3F).build())));

public static Item CRYOMARBLE_SHARD;
public static Item CRYOMARBLE;
Expand All @@ -40,5 +31,9 @@ public class CommonWinterlyItems {
public static Item GREEN_SCARF;
public static Item BLUE_SCARF;
public static Item RAINBOW_SCARF;

public static Item.Properties settings() {
return new Item.Properties();
}
}

1 change: 0 additions & 1 deletion fabric/src/main/java/winterly/fabric/WinterlyFabric.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.CreativeModeTab;
import winterly.Winterly;
import winterly.config.WinterlyClothConfig;
import winterly.fabric.compat.WinterlyOwoLibIntegration;
import winterly.fabric.registry.WinterlyBlockEntities;
import winterly.fabric.registry.WinterlyBlocks;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

public class WinterlyTrinketsIntegration {


public static void registerTrinket(Item item) {
TrinketsApi.registerTrinket(item, new Trinket() {});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package winterly.fabric.registry;

import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.food.FoodProperties;
Expand Down Expand Up @@ -46,8 +45,4 @@ private static <T extends Item> T add(String name, T item) {
ITEMS.put(Winterly.id(name), item);
return item;
}

private static FabricItemSettings settings() {
return new FabricItemSettings();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
public class WinterlyNeoforge {
public static final DeferredRegister<CreativeModeTab> CREATIVE_MODE_TABS = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, "winterly");

public static Supplier<CreativeModeTab> WINTERLY_TAB = CREATIVE_MODE_TABS.register("winterly", () -> CreativeModeTab.builder().icon(CommonWinterlyBlocks.SNOWGUY.asItem()::getDefaultInstance).title(Component.literal("Winterly")).build());
public static final Supplier<CreativeModeTab> WINTERLY_TAB = CREATIVE_MODE_TABS.register("winterly", () -> CreativeModeTab.builder().icon(CommonWinterlyBlocks.SNOWGUY.asItem()::getDefaultInstance).title(Component.translatable("itemGroup.winterly.items")).build());

public WinterlyNeoforge(IEventBus bus) {
CREATIVE_MODE_TABS.register(bus);
Expand All @@ -41,7 +41,7 @@ public WinterlyNeoforge(IEventBus bus) {
bus.addListener(this::commonSetup);

if(FMLEnvironment.dist.isClient()) {
new WinterlyNeoforgeClient().init(bus);
WinterlyNeoforgeClient.init(bus);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@
@OnlyIn(Dist.CLIENT)
public class WinterlyNeoforgeClient {

public void init(IEventBus bus) {
bus.addListener(this::clientSetup);
bus.addListener(this::registerModelLayers);
bus.addListener(this::registerRenderLayers);
public static void init(IEventBus bus) {
bus.addListener(WinterlyNeoforgeClient::clientSetup);
bus.addListener(WinterlyNeoforgeClient::registerModelLayers);
bus.addListener(WinterlyNeoforgeClient::registerRenderLayers);
}

private void registerModelLayers(EntityRenderersEvent.RegisterLayerDefinitions event) {
private static void registerModelLayers(EntityRenderersEvent.RegisterLayerDefinitions event) {
event.registerLayerDefinition(WinterlyModelLayers.SANTA_HAT_LAYER, SantaHatModel::getTexturedModelData);
event.registerLayerDefinition(WinterlyModelLayers.SCARF_LAYER, ScarfModel::getTexturedModelData);
}

private void registerRenderLayers(EntityRenderersEvent.AddLayers event) {
private static void registerRenderLayers(EntityRenderersEvent.AddLayers event) {
event.getContext().getEntityRenderDispatcher().renderers.forEach((entityType, entityRenderer) -> {
if(entityRenderer instanceof ZombieRenderer renderer) {
renderer.addLayer(new DecorationFeatureRenderer<>(renderer));
Expand All @@ -50,7 +50,7 @@ private void registerRenderLayers(EntityRenderersEvent.AddLayers event) {
});
}

private void clientSetup(FMLClientSetupEvent event) {
private static void clientSetup(FMLClientSetupEvent event) {
if(ModList.get().isLoaded("curios")) {
CommonWinterlyItems.ITEMS.forEach((resourceLocation, item) -> {
if(item instanceof CommonScarfItem scarf) WinterlyCuriosIntegration.registerScarfRenderer(scarf);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,65 @@
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.entity.RenderLayerParent;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.core.NonNullList;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import top.theillusivec4.curios.api.CuriosApi;
import top.theillusivec4.curios.api.SlotContext;
import top.theillusivec4.curios.api.client.CuriosRendererRegistry;
import top.theillusivec4.curios.api.client.ICurioRenderer;
import top.theillusivec4.curios.api.type.capability.ICurioItem;
import top.theillusivec4.curios.api.type.inventory.ICurioStacksHandler;
import top.theillusivec4.curios.api.type.inventory.IDynamicStackHandler;
import winterly.Winterly;
import winterly.client.model.WinterlyModels;
import winterly.item.CommonSantaHatItem;
import winterly.item.CommonScarfItem;

import java.util.Map;

public class WinterlyCuriosIntegration {

public static void registerCurio(Item item) {
CuriosApi.registerCurio(item, new ICurioItem() {});
}

public static boolean hasVisibleHat(Player player) {
var curiosItemHandler = CuriosApi.getCuriosInventory(player);
if(curiosItemHandler.isPresent()) {
for (Map.Entry<String, ICurioStacksHandler> entry : curiosItemHandler.get().getCurios().entrySet()) {
IDynamicStackHandler stackHandler = entry.getValue().getStacks();
IDynamicStackHandler cosmeticStacksHandler = entry.getValue().getCosmeticStacks();

for(int i = 0; i < stackHandler.getSlots(); ++i) {
ItemStack stack = cosmeticStacksHandler.getStackInSlot(i);

NonNullList<Boolean> renderStates = entry.getValue().getRenders();
boolean renderable = renderStates.size() > i && renderStates.get(i);

if (stack.isEmpty() && renderable) {
stack = stackHandler.getStackInSlot(i);
}

if (!stack.isEmpty() && stack.getItem() instanceof CommonSantaHatItem) {
return true;
}
}
}
}

return false;
}

public static void registerScarfRenderer(CommonScarfItem scarf) {
CuriosRendererRegistry.register(scarf, () -> {
return new ICurioRenderer() {
@Override
public <T extends LivingEntity, M extends EntityModel<T>> void render(ItemStack stack, SlotContext slotContext, PoseStack matrices, RenderLayerParent<T, M> renderLayerParent, MultiBufferSource renderTypeBuffer, int light, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) {
if(renderLayerParent.getModel() instanceof HumanoidModel<? extends LivingEntity> biped){
WinterlyModels.SCARF_MODEL.scarf.copyFrom(biped.body);
if(renderLayerParent.getModel() instanceof HumanoidModel<? extends LivingEntity> humanoid) {
WinterlyModels.SCARF_MODEL.scarf.copyFrom(humanoid.body);
VertexConsumer vertexConsumer = renderTypeBuffer.getBuffer(RenderType.entityCutout(Winterly.id("textures/entity/" + scarf.color + "_scarf.png")));
WinterlyModels.SCARF_MODEL.renderToBuffer(matrices, vertexConsumer, light, OverlayTexture.NO_OVERLAY, 1.0F, 1.0F, 1.0F, 1.0F);
}
Expand All @@ -47,8 +80,8 @@ public static void registerSantaHatRenderer(CommonSantaHatItem hat) {
return new ICurioRenderer() {
@Override
public <T extends LivingEntity, M extends EntityModel<T>> void render(ItemStack stack, SlotContext slotContext, PoseStack matrices, RenderLayerParent<T, M> renderLayerParent, MultiBufferSource renderTypeBuffer, int light, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) {
if(renderLayerParent.getModel() instanceof HumanoidModel<? extends LivingEntity> biped) {
WinterlyModels.SANTA_HAT_MODEL.hat.copyFrom(biped.head);
if(renderLayerParent.getModel() instanceof HumanoidModel<? extends LivingEntity> humanoid) {
WinterlyModels.SANTA_HAT_MODEL.hat.copyFrom(humanoid.head);
VertexConsumer vertexConsumer = renderTypeBuffer.getBuffer(RenderType.entityCutout(Winterly.id("textures/entity/" + hat.color + "_santa_hat.png")));
WinterlyModels.SANTA_HAT_MODEL.renderToBuffer(matrices, vertexConsumer, light, OverlayTexture.NO_OVERLAY, 1.0F, 1.0F, 1.0F, 1.0F);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package winterly.neoforge.mixin.client;

import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.model.HumanoidModel;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.entity.RenderLayerParent;
import net.minecraft.client.renderer.entity.layers.HumanoidArmorLayer;
import net.minecraft.client.renderer.entity.layers.RenderLayer;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.neoforged.fml.ModList;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import winterly.neoforge.compat.WinterlyCuriosIntegration;

@Mixin(HumanoidArmorLayer.class)
public abstract class ArmorRendererMixin<T extends LivingEntity, M extends HumanoidModel<T>, A extends HumanoidModel<T>> extends RenderLayer<T, M> {

public ArmorRendererMixin(RenderLayerParent<T, M> context) {
super(context);
}

@Inject(method = "renderArmorPiece", at = @At("HEAD"), cancellable = true)
void render(PoseStack matrices, MultiBufferSource vertexConsumers, T entity, EquipmentSlot armorSlot, int light, A model, CallbackInfo ci) {
if(entity instanceof Player player) {
if(ModList.get().isLoaded("curios") && armorSlot.equals(EquipmentSlot.HEAD)) {
if(WinterlyCuriosIntegration.hasVisibleHat(player)) ci.cancel();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,14 @@ public static void init(IEventBus eventBus) {
add("blue_scarf", () -> BLUE_SCARF = new ScarfItem(settings(), "blue"));
add("rainbow_scarf", () -> RAINBOW_SCARF = new ScarfItem(settings(), "rainbow"));

// ITEMS.forEach((id, item) -> Registry.register(BuiltInRegistries.ITEM, id, item));
ITEMS_REGISTERER.register(eventBus);
}

private static <T extends Item> T add(String name, Supplier<? extends T> sup) {
// ITEMS.put(Winterly.id(name), null);
private static <T extends Item> void add(String name, Supplier<? extends T> sup) {
ITEMS_REGISTERER.register(name, () -> {
var item = sup.get();
ITEMS.put(Winterly.id(name), item);
return item;
});
return null;
}

private static Item.Properties settings() {
return new Item.Properties();
}
}
3 changes: 2 additions & 1 deletion neoforge/src/main/resources/winterly.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
"compatibilityLevel": "JAVA_17",
"minVersion": "0.8",
"client": [
"client.ArmorRendererMixin"
],
"mixins": [
],
"injectors": {
"defaultRequire": 1
}
}
}

0 comments on commit c3ab2fa

Please sign in to comment.