From 40b07df4a5f0f9980b06f7278f7241f8d0ac53c4 Mon Sep 17 00:00:00 2001 From: Kam Date: Wed, 11 Mar 2026 05:05:39 -0400 Subject: [PATCH] Formatting Cleanup --- .../com/goodbird/npcgecko/CommonProxy.java | 7 +- .../goodbird/npcgecko/CustomNpcPlusGecko.java | 1 + .../npcgecko/api/AbstractGeckoAPI.java | 12 +- .../com/goodbird/npcgecko/api/GeckoAPI.java | 25 +- .../goodbird/npcgecko/client/ClientProxy.java | 2 +- .../client/gui/SubGuiModelAnimation.java | 87 +- .../client/gui/SubGuiModelExtras.java | 31 +- .../npcgecko/client/model/ModelCustom.java | 24 +- .../client/model/TileModelCustom.java | 20 +- .../client/renderer/RenderCustomModel.java | 37 +- .../renderer/RenderTileCustomModel.java | 1 - .../npcgecko/data/CustomItemModelData.java | 4 +- .../npcgecko/data/CustomModelData.java | 5 +- .../npcgecko/entity/EntityCustomModel.java | 15 +- .../npcgecko/handler/EventHandler.java | 12 +- .../item/ItemCustomModelPredicate.java | 4 +- .../impl/MixinBlockScriptedRenderer.java | 28 +- .../npcgecko/mixin/impl/MixinDataDisplay.java | 9 +- .../npcgecko/mixin/impl/MixinGeckoAddon.java | 9 +- .../mixin/impl/MixinGeckoAddonClient.java | 74 +- .../mixin/impl/MixinScriptCustomItem.java | 1 - .../mixin/impl/TileScriptedMixin.java | 13 +- .../npcgecko/network/CPacketSyncAutoAnim.java | 8 +- .../network/CPacketSyncManualAnim.java | 31 +- .../network/CPacketSyncTileManualAnim.java | 36 +- .../npcgecko/tile/TileEntityCustomModel.java | 5 +- .../npcgecko/utils/NpcTextureUtils.java | 21 +- .../animations/geo_npc.animation.json | 7548 +++++++++++------ .../npcgecko/geo/animfilenotfound.geo.json | 1848 +++- .../npcgecko/geo/modelnotfound.geo.json | 1178 ++- src/main/resources/mcmod.info | 43 +- 31 files changed, 7646 insertions(+), 3493 deletions(-) diff --git a/src/main/java/com/goodbird/npcgecko/CommonProxy.java b/src/main/java/com/goodbird/npcgecko/CommonProxy.java index 5e9f5d0..ff1bd03 100644 --- a/src/main/java/com/goodbird/npcgecko/CommonProxy.java +++ b/src/main/java/com/goodbird/npcgecko/CommonProxy.java @@ -12,22 +12,21 @@ import cpw.mods.fml.common.registry.GameRegistry; import net.minecraft.server.MinecraftServer; import net.minecraft.world.World; import noppes.npcs.scripted.NpcAPI; -import software.bernie.example.block.tile.BotariumTileEntity; public class CommonProxy { - public void preInit(FMLPreInitializationEvent ev){ + public void preInit(FMLPreInitializationEvent ev) { EntityRegistry.registerModEntity(EntityCustomModel.class, "CustomModelEntity", 0, CustomNpcPlusGecko.instance, 64, 10, false); NpcAPI.EVENT_BUS.register(new EventHandler()); } - public void init(FMLInitializationEvent ev){ + public void init(FMLInitializationEvent ev) { NetworkHandler.init(); GameRegistry.registerTileEntity(TileEntityCustomModel.class, "custommodeltile"); NpcAPI.Instance().addGlobalObject("GeckoAPI", AbstractGeckoAPI.Instance()); } - public World getWorldById(int id){ + public World getWorldById(int id) { return MinecraftServer.getServer().worldServers[id]; } } diff --git a/src/main/java/com/goodbird/npcgecko/CustomNpcPlusGecko.java b/src/main/java/com/goodbird/npcgecko/CustomNpcPlusGecko.java index 995a9e8..cd04e5e 100644 --- a/src/main/java/com/goodbird/npcgecko/CustomNpcPlusGecko.java +++ b/src/main/java/com/goodbird/npcgecko/CustomNpcPlusGecko.java @@ -21,6 +21,7 @@ public class CustomNpcPlusGecko { public void preInit(FMLPreInitializationEvent ev) { proxy.preInit(ev); } + @Mod.EventHandler public void init(FMLInitializationEvent ev) { proxy.init(ev); diff --git a/src/main/java/com/goodbird/npcgecko/api/AbstractGeckoAPI.java b/src/main/java/com/goodbird/npcgecko/api/AbstractGeckoAPI.java index 1344147..f09b6c6 100644 --- a/src/main/java/com/goodbird/npcgecko/api/AbstractGeckoAPI.java +++ b/src/main/java/com/goodbird/npcgecko/api/AbstractGeckoAPI.java @@ -1,13 +1,11 @@ package com.goodbird.npcgecko.api; -import com.goodbird.npcgecko.data.CustomItemModelData; import cpw.mods.fml.common.Loader; import net.minecraft.entity.player.EntityPlayerMP; import noppes.npcs.api.block.IBlockScripted; import noppes.npcs.api.entity.ICustomNpc; import noppes.npcs.api.entity.IPlayer; import noppes.npcs.entity.EntityNPCInterface; -import noppes.npcs.scripted.item.ScriptCustomItem; import software.bernie.geckolib3.core.builder.AnimationBuilder; public abstract class AbstractGeckoAPI { @@ -36,17 +34,27 @@ public abstract class AbstractGeckoAPI { public abstract AnimationBuilder createAnimationBuilder(); public abstract void setModel(ICustomNpc npc, String model); + public abstract void setTexture(ICustomNpc npc, String texture); + public abstract void setAnimationFile(ICustomNpc npc, String animation); + public abstract void setIdleAnimation(ICustomNpc npc, String animation); + public abstract void syncAnimForPlayer(ICustomNpc npc, AnimationBuilder builder, IPlayer player); + public abstract void syncAnimForAll(ICustomNpc npc, AnimationBuilder builder); public abstract void setModel(IBlockScripted scriptedBlock, String model); + public abstract void setTexture(IBlockScripted scriptedBlock, String texture); + public abstract void setAnimationFile(IBlockScripted scriptedBlock, String animation); + public abstract void setIdleAnimation(IBlockScripted scriptedBlock, String animation); + public abstract void syncAnimForPlayer(IBlockScripted scriptedBlock, AnimationBuilder builder, IPlayer player); + public abstract void syncAnimForAll(IBlockScripted scriptedBlock, AnimationBuilder builder); // TODO: Fix ScriptCustomItem diff --git a/src/main/java/com/goodbird/npcgecko/api/GeckoAPI.java b/src/main/java/com/goodbird/npcgecko/api/GeckoAPI.java index 1e1e0b0..ffd8bde 100644 --- a/src/main/java/com/goodbird/npcgecko/api/GeckoAPI.java +++ b/src/main/java/com/goodbird/npcgecko/api/GeckoAPI.java @@ -1,15 +1,10 @@ package com.goodbird.npcgecko.api; -import com.goodbird.npcgecko.client.renderer.RenderTileCustomModel; -import com.goodbird.npcgecko.data.CustomItemModelData; import com.goodbird.npcgecko.mixin.IDataDisplay; -import com.goodbird.npcgecko.mixin.IScriptCustomItem; import com.goodbird.npcgecko.network.CPacketSyncManualAnim; import com.goodbird.npcgecko.network.CPacketSyncTileManualAnim; import com.goodbird.npcgecko.network.NetworkHandler; import com.goodbird.npcgecko.tile.TileEntityCustomModel; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.relauncher.Side; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.util.ResourceLocation; import noppes.npcs.api.block.IBlockScripted; @@ -17,14 +12,13 @@ import noppes.npcs.api.entity.ICustomNpc; import noppes.npcs.api.entity.IPlayer; import noppes.npcs.blocks.tiles.TileScripted; import noppes.npcs.entity.EntityNPCInterface; -import noppes.npcs.scripted.BlockScriptedWrapper; -import noppes.npcs.scripted.item.ScriptCustomItem; import software.bernie.geckolib3.core.builder.AnimationBuilder; public class GeckoAPI extends AbstractGeckoAPI { private static AbstractGeckoAPI Instance; - private GeckoAPI() {} + private GeckoAPI() { + } public static AbstractGeckoAPI Instance() { if (GeckoAPI.Instance == null) { @@ -40,7 +34,7 @@ public class GeckoAPI extends AbstractGeckoAPI { @Override public void setModel(ICustomNpc npc, String model) { - ((IDataDisplay)npc.getMCEntity().display).getCustomModelData().setModel(model); + ((IDataDisplay) npc.getMCEntity().display).getCustomModelData().setModel(model); npc.updateClient(); } @@ -52,31 +46,30 @@ public class GeckoAPI extends AbstractGeckoAPI { @Override public void setAnimationFile(ICustomNpc npc, String animation) { - ((IDataDisplay)npc.getMCEntity().display).getCustomModelData().setAnimFile(animation); + ((IDataDisplay) npc.getMCEntity().display).getCustomModelData().setAnimFile(animation); npc.updateClient(); } @Override public void setIdleAnimation(ICustomNpc npc, String animation) { - ((IDataDisplay)npc.getMCEntity().display).getCustomModelData().setIdleAnim(animation); + ((IDataDisplay) npc.getMCEntity().display).getCustomModelData().setIdleAnim(animation); npc.updateClient(); } @Override public void syncAnimForPlayer(ICustomNpc npc, AnimationBuilder builder, IPlayer player) { - NetworkHandler.sendToPlayer(new CPacketSyncManualAnim(npc.getMCEntity(),builder), player.getMCEntity()); + NetworkHandler.sendToPlayer(new CPacketSyncManualAnim(npc.getMCEntity(), builder), player.getMCEntity()); } @Override public void syncAnimForAll(ICustomNpc npc, AnimationBuilder builder) { - NetworkHandler.sendToAll(new CPacketSyncManualAnim(npc.getMCEntity(),builder)); + NetworkHandler.sendToAll(new CPacketSyncManualAnim(npc.getMCEntity(), builder)); } - - private TileEntityCustomModel getOrCreateTECM(IBlockScripted scriptedBlock){ + private TileEntityCustomModel getOrCreateTECM(IBlockScripted scriptedBlock) { TileScripted tile = (TileScripted) scriptedBlock.getMCTileEntity(); - if(!(tile.renderTile instanceof TileEntityCustomModel)){ + if (!(tile.renderTile instanceof TileEntityCustomModel)) { tile.renderTile = new TileEntityCustomModel(tile); } return (TileEntityCustomModel) tile.renderTile; diff --git a/src/main/java/com/goodbird/npcgecko/client/ClientProxy.java b/src/main/java/com/goodbird/npcgecko/client/ClientProxy.java index e622c12..71741c1 100644 --- a/src/main/java/com/goodbird/npcgecko/client/ClientProxy.java +++ b/src/main/java/com/goodbird/npcgecko/client/ClientProxy.java @@ -21,7 +21,7 @@ public class ClientProxy extends CommonProxy { ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCustomModel.class, new RenderTileCustomModel()); } - public World getWorldById(int id){ + public World getWorldById(int id) { return Minecraft.getMinecraft().theWorld; } } diff --git a/src/main/java/com/goodbird/npcgecko/client/gui/SubGuiModelAnimation.java b/src/main/java/com/goodbird/npcgecko/client/gui/SubGuiModelAnimation.java index 2f905a7..aaf7a76 100644 --- a/src/main/java/com/goodbird/npcgecko/client/gui/SubGuiModelAnimation.java +++ b/src/main/java/com/goodbird/npcgecko/client/gui/SubGuiModelAnimation.java @@ -5,12 +5,17 @@ import com.goodbird.npcgecko.mixin.IDataDisplay; import com.goodbird.npcgecko.utils.AnimationFileUtil; import net.minecraft.client.gui.GuiButton; import net.minecraft.util.ResourceLocation; -import noppes.npcs.client.gui.util.*; +import noppes.npcs.client.gui.util.GuiNpcButton; +import noppes.npcs.client.gui.util.GuiNpcLabel; +import noppes.npcs.client.gui.util.GuiNpcTextField; +import noppes.npcs.client.gui.util.ISubGuiListener; +import noppes.npcs.client.gui.util.ITextfieldListener; +import noppes.npcs.client.gui.util.SubGuiInterface; import noppes.npcs.entity.EntityNPCInterface; import software.bernie.geckolib3.resource.GeckoLibCache; public class SubGuiModelAnimation extends SubGuiInterface implements ITextfieldListener, ISubGuiListener { - public SubGuiModelAnimation(EntityNPCInterface npc){ + public SubGuiModelAnimation(EntityNPCInterface npc) { this.npc = npc; closeOnEsc = true; } @@ -19,92 +24,92 @@ public class SubGuiModelAnimation extends SubGuiInterface implements ITextfieldL public void initGui() { super.initGui(); int y = guiTop + 44; - addSelectionBlock(1,y,"Animation File:",getModelData(npc).getAnimFile()); - addSelectionBlock(2,y+=23,"Idle:",getModelData(npc).getIdleAnim()); - addSelectionBlock(3,y+=23,"Walk:",getModelData(npc).getWalkAnim()); - addSelectionBlock(4,y+=23,"Melee Attack:",getModelData(npc).getMeleeAttackAnim()); - addSelectionBlock(5,y+=23,"Ranged Attack:",getModelData(npc).getRangedAttackAnim()); - addSelectionBlock(6,y+23,"Hurt:",getModelData(npc).getHurtAnim()); + addSelectionBlock(1, y, "Animation File:", getModelData(npc).getAnimFile()); + addSelectionBlock(2, y += 23, "Idle:", getModelData(npc).getIdleAnim()); + addSelectionBlock(3, y += 23, "Walk:", getModelData(npc).getWalkAnim()); + addSelectionBlock(4, y += 23, "Melee Attack:", getModelData(npc).getMeleeAttackAnim()); + addSelectionBlock(5, y += 23, "Ranged Attack:", getModelData(npc).getRangedAttackAnim()); + addSelectionBlock(6, y + 23, "Hurt:", getModelData(npc).getHurtAnim()); addButton(new GuiNpcButton(670, width - 22, 2, 20, 20, "X")); } - public void addSelectionBlock(int id, int y, String label, String value){ - addLabel(new GuiNpcLabel(id,label, guiLeft - 85, y + 5,0xffffff)); - addTextField(new GuiNpcTextField(id,this, fontRendererObj, guiLeft - 10, y, 200, 20, value)); + public void addSelectionBlock(int id, int y, String label, String value) { + addLabel(new GuiNpcLabel(id, label, guiLeft - 85, y + 5, 0xffffff)); + addTextField(new GuiNpcTextField(id, this, fontRendererObj, guiLeft - 10, y, 200, 20, value)); this.addButton(new GuiNpcButton(id, guiLeft + 193, y, 80, 20, "gui.select")); } - public CustomModelData getModelData(EntityNPCInterface npc){ - return ((IDataDisplay)npc.display).getCustomModelData(); + public CustomModelData getModelData(EntityNPCInterface npc) { + return ((IDataDisplay) npc.display).getCustomModelData(); } @Override protected void actionPerformed(GuiButton button) { super.actionPerformed(button); - if(button.id == 670){ + if (button.id == 670) { close(); } - if(button.id==1){ - setSubGui(new GuiStringSelection(this,"Selecting geckolib animation file:", - AnimationFileUtil.getAnimationFileList(), (name)-> getModelData(npc).setAnimFile(name))); + if (button.id == 1) { + setSubGui(new GuiStringSelection(this, "Selecting geckolib animation file:", + AnimationFileUtil.getAnimationFileList(), (name) -> getModelData(npc).setAnimFile(name))); } - if(button.id==2){ - setSubGui(new GuiStringSelection(this,"Selecting geckolib idle animation:", + if (button.id == 2) { + setSubGui(new GuiStringSelection(this, "Selecting geckolib idle animation:", AnimationFileUtil.getAnimationList(getModelData(npc).getAnimFile()), - (name)-> getModelData(npc).setIdleAnim(name))); + (name) -> getModelData(npc).setIdleAnim(name))); } - if(button.id==3){ - setSubGui(new GuiStringSelection(this,"Selecting geckolib walk animation:", + if (button.id == 3) { + setSubGui(new GuiStringSelection(this, "Selecting geckolib walk animation:", AnimationFileUtil.getAnimationList(getModelData(npc).getAnimFile()), - (name)-> getModelData(npc).setWalkAnim(name))); + (name) -> getModelData(npc).setWalkAnim(name))); } - if(button.id==4){ - setSubGui(new GuiStringSelection(this,"Selecting geckolib melee attack animation:", + if (button.id == 4) { + setSubGui(new GuiStringSelection(this, "Selecting geckolib melee attack animation:", AnimationFileUtil.getAnimationList(getModelData(npc).getAnimFile()), - (name)-> getModelData(npc).setMeleeAttackAnim(name))); + (name) -> getModelData(npc).setMeleeAttackAnim(name))); } - if(button.id==5){ - setSubGui(new GuiStringSelection(this,"Selecting geckolib ranged attack animation:", + if (button.id == 5) { + setSubGui(new GuiStringSelection(this, "Selecting geckolib ranged attack animation:", AnimationFileUtil.getAnimationList(getModelData(npc).getAnimFile()), - (name)-> getModelData(npc).setRangedAttackAnim(name))); + (name) -> getModelData(npc).setRangedAttackAnim(name))); } - if(button.id==6){ - setSubGui(new GuiStringSelection(this,"Selecting geckolib hurt animation:", + if (button.id == 6) { + setSubGui(new GuiStringSelection(this, "Selecting geckolib hurt animation:", AnimationFileUtil.getAnimationList(getModelData(npc).getAnimFile()), - (name)-> getModelData(npc).setHurtAnim(name))); + (name) -> getModelData(npc).setHurtAnim(name))); } } - public boolean isValidAnimFile(String name){ + public boolean isValidAnimFile(String name) { return GeckoLibCache.getInstance().getAnimations().containsKey(new ResourceLocation(name)); } - public boolean isValidAnimation(String name){ + public boolean isValidAnimation(String name) { return AnimationFileUtil.getAnimationList(getModelData(npc).getAnimFile()).contains(name); } @Override public void unFocused(GuiNpcTextField textfield) { - if(textfield.id == 1 && isValidAnimFile(textfield.getText())){ - if(!textfield.isEmpty()) + if (textfield.id == 1 && isValidAnimFile(textfield.getText())) { + if (!textfield.isEmpty()) getModelData(npc).setAnimFile(textfield.getText()); else textfield.setText(getModelData(npc).getAnimFile()); } - if(textfield.id == 2 && (isValidAnimation(textfield.getText()) || textfield.getText().isEmpty())){ + if (textfield.id == 2 && (isValidAnimation(textfield.getText()) || textfield.getText().isEmpty())) { getModelData(npc).setIdleAnim(textfield.getText()); } - if(textfield.id == 3 && (isValidAnimation(textfield.getText()) || textfield.getText().isEmpty())){ + if (textfield.id == 3 && (isValidAnimation(textfield.getText()) || textfield.getText().isEmpty())) { getModelData(npc).setWalkAnim(textfield.getText()); } - if(textfield.id == 4 && (isValidAnimation(textfield.getText()) || textfield.getText().isEmpty())){ + if (textfield.id == 4 && (isValidAnimation(textfield.getText()) || textfield.getText().isEmpty())) { getModelData(npc).setMeleeAttackAnim(textfield.getText()); } - if(textfield.id == 5 && (isValidAnimation(textfield.getText()) || textfield.getText().isEmpty())){ + if (textfield.id == 5 && (isValidAnimation(textfield.getText()) || textfield.getText().isEmpty())) { getModelData(npc).setRangedAttackAnim(textfield.getText()); } - if(textfield.id == 6 && (isValidAnimation(textfield.getText()) || textfield.getText().isEmpty())){ + if (textfield.id == 6 && (isValidAnimation(textfield.getText()) || textfield.getText().isEmpty())) { getModelData(npc).setHurtAnim(textfield.getText()); } } diff --git a/src/main/java/com/goodbird/npcgecko/client/gui/SubGuiModelExtras.java b/src/main/java/com/goodbird/npcgecko/client/gui/SubGuiModelExtras.java index 0fa54dc..080a843 100644 --- a/src/main/java/com/goodbird/npcgecko/client/gui/SubGuiModelExtras.java +++ b/src/main/java/com/goodbird/npcgecko/client/gui/SubGuiModelExtras.java @@ -3,11 +3,16 @@ package com.goodbird.npcgecko.client.gui; import com.goodbird.npcgecko.data.CustomModelData; import com.goodbird.npcgecko.mixin.IDataDisplay; import net.minecraft.client.gui.GuiButton; -import noppes.npcs.client.gui.util.*; +import noppes.npcs.client.gui.util.GuiNpcButton; +import noppes.npcs.client.gui.util.GuiNpcLabel; +import noppes.npcs.client.gui.util.GuiNpcTextField; +import noppes.npcs.client.gui.util.ISubGuiListener; +import noppes.npcs.client.gui.util.ITextfieldListener; +import noppes.npcs.client.gui.util.SubGuiInterface; import noppes.npcs.entity.EntityNPCInterface; public class SubGuiModelExtras extends SubGuiInterface implements ITextfieldListener, ISubGuiListener { - public SubGuiModelExtras(EntityNPCInterface npc){ + public SubGuiModelExtras(EntityNPCInterface npc) { this.npc = npc; closeOnEsc = true; } @@ -16,36 +21,36 @@ public class SubGuiModelExtras extends SubGuiInterface implements ITextfieldList public void initGui() { super.initGui(); int y = guiTop + 44; - addLabel(new GuiNpcLabel(1,"Head Bone Name", guiLeft - 85, y + 5,0xffffff)); - addTextField(new GuiNpcTextField(1,this, fontRendererObj, guiLeft + 50, y, 200, 20, getModelData(npc).getHeadBoneName())); - y+=23; - addLabel(new GuiNpcLabel(2,"Transition Length (ticks)", guiLeft - 85, y + 5,0xffffff)); - GuiNpcTextField transitionLength = new GuiNpcTextField(2,this, fontRendererObj, guiLeft + 50, y, - 200, 20, ""+getModelData(npc).getTransitionLengthTicks()); + addLabel(new GuiNpcLabel(1, "Head Bone Name", guiLeft - 85, y + 5, 0xffffff)); + addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft + 50, y, 200, 20, getModelData(npc).getHeadBoneName())); + y += 23; + addLabel(new GuiNpcLabel(2, "Transition Length (ticks)", guiLeft - 85, y + 5, 0xffffff)); + GuiNpcTextField transitionLength = new GuiNpcTextField(2, this, fontRendererObj, guiLeft + 50, y, + 200, 20, "" + getModelData(npc).getTransitionLengthTicks()); transitionLength.setIntegersOnly(); transitionLength.setMinMaxDefault(0, Integer.MAX_VALUE, getModelData(npc).getTransitionLengthTicks()); addTextField(transitionLength); addButton(new GuiNpcButton(670, width - 22, 2, 20, 20, "X")); } - public CustomModelData getModelData(EntityNPCInterface npc){ - return ((IDataDisplay)npc.display).getCustomModelData(); + public CustomModelData getModelData(EntityNPCInterface npc) { + return ((IDataDisplay) npc.display).getCustomModelData(); } @Override protected void actionPerformed(GuiButton button) { super.actionPerformed(button); - if(button.id == 670){ + if (button.id == 670) { close(); } } @Override public void unFocused(GuiNpcTextField textfield) { - if(textfield.id == 1){ + if (textfield.id == 1) { getModelData(npc).setHeadBoneName(textfield.getText()); } - if(textfield.id == 2){ + if (textfield.id == 2) { getModelData(npc).setTransitionLengthTicks(textfield.getInteger()); } } diff --git a/src/main/java/com/goodbird/npcgecko/client/model/ModelCustom.java b/src/main/java/com/goodbird/npcgecko/client/model/ModelCustom.java index 482c529..87a35a2 100644 --- a/src/main/java/com/goodbird/npcgecko/client/model/ModelCustom.java +++ b/src/main/java/com/goodbird/npcgecko/client/model/ModelCustom.java @@ -11,40 +11,40 @@ import software.bernie.geckolib3.resource.GeckoLibCache; public class ModelCustom extends AnimatedGeoModel { @Override public ResourceLocation getAnimationFileLocation(EntityCustomModel entity) { - if(!GeckoLibCache.getInstance().getAnimations().containsKey(entity.animResLoc)){ - return new ResourceLocation("npcgecko","animations/none.animations.json"); + if (!GeckoLibCache.getInstance().getAnimations().containsKey(entity.animResLoc)) { + return new ResourceLocation("npcgecko", "animations/none.animations.json"); } return entity.animResLoc; } @Override public ResourceLocation getModelLocation(EntityCustomModel entity) { - if(!GeckoLibCache.getInstance().getGeoModels().containsKey(entity.modelResLoc)){ - return new ResourceLocation("npcgecko","geo/modelnotfound.geo.json"); + if (!GeckoLibCache.getInstance().getGeoModels().containsKey(entity.modelResLoc)) { + return new ResourceLocation("npcgecko", "geo/modelnotfound.geo.json"); } - if(!GeckoLibCache.getInstance().getAnimations().containsKey(entity.animResLoc)){ - return new ResourceLocation("npcgecko","geo/animfilenotfound.geo.json"); + if (!GeckoLibCache.getInstance().getAnimations().containsKey(entity.animResLoc)) { + return new ResourceLocation("npcgecko", "geo/animfilenotfound.geo.json"); } return entity.modelResLoc; } @Override public ResourceLocation getTextureLocation(EntityCustomModel entity) { - if(!GeckoLibCache.getInstance().getGeoModels().containsKey(entity.modelResLoc)){ - return new ResourceLocation("npcgecko","textures/model/alphabet.png"); + if (!GeckoLibCache.getInstance().getGeoModels().containsKey(entity.modelResLoc)) { + return new ResourceLocation("npcgecko", "textures/model/alphabet.png"); } - if(!GeckoLibCache.getInstance().getAnimations().containsKey(entity.animResLoc)){ - return new ResourceLocation("npcgecko","textures/model/alphabet.png"); + if (!GeckoLibCache.getInstance().getAnimations().containsKey(entity.animResLoc)) { + return new ResourceLocation("npcgecko", "textures/model/alphabet.png"); } return entity.textureResLoc; } - @SuppressWarnings({ "rawtypes", "unchecked" }) + @SuppressWarnings({"rawtypes", "unchecked"}) @Override public void setLivingAnimations(EntityCustomModel entity, Integer uniqueID, AnimationEvent animationEvent) { super.setLivingAnimations(entity, uniqueID, animationEvent); //We call the super-function IBone head = this.getAnimationProcessor().getBone(entity.headBoneName); //Then we take the head bone - if(head!=null) { + if (head != null) { //We get the model data for an entity EntityModelData extraData = (EntityModelData) animationEvent.getExtraDataOfType(EntityModelData.class).get(0); //And we set the head bone rotation to the interpolated pitch and yaw rotations of an entity diff --git a/src/main/java/com/goodbird/npcgecko/client/model/TileModelCustom.java b/src/main/java/com/goodbird/npcgecko/client/model/TileModelCustom.java index e695611..49133c3 100644 --- a/src/main/java/com/goodbird/npcgecko/client/model/TileModelCustom.java +++ b/src/main/java/com/goodbird/npcgecko/client/model/TileModelCustom.java @@ -8,30 +8,30 @@ import software.bernie.geckolib3.resource.GeckoLibCache; public class TileModelCustom extends AnimatedGeoModel { @Override public ResourceLocation getAnimationFileLocation(TileEntityCustomModel entity) { - if(!GeckoLibCache.getInstance().getAnimations().containsKey(entity.animResLoc)){ - return new ResourceLocation("npcgecko","animations/none.animations.json"); + if (!GeckoLibCache.getInstance().getAnimations().containsKey(entity.animResLoc)) { + return new ResourceLocation("npcgecko", "animations/none.animations.json"); } return entity.animResLoc; } @Override public ResourceLocation getModelLocation(TileEntityCustomModel animatable) { - if(!GeckoLibCache.getInstance().getGeoModels().containsKey(animatable.modelResLoc)){ - return new ResourceLocation("npcgecko","geo/modelnotfound.geo.json"); + if (!GeckoLibCache.getInstance().getGeoModels().containsKey(animatable.modelResLoc)) { + return new ResourceLocation("npcgecko", "geo/modelnotfound.geo.json"); } - if(!GeckoLibCache.getInstance().getAnimations().containsKey(animatable.animResLoc)){ - return new ResourceLocation("npcgecko","geo/animfilenotfound.geo.json"); + if (!GeckoLibCache.getInstance().getAnimations().containsKey(animatable.animResLoc)) { + return new ResourceLocation("npcgecko", "geo/animfilenotfound.geo.json"); } return animatable.modelResLoc; } @Override public ResourceLocation getTextureLocation(TileEntityCustomModel entity) { - if(!GeckoLibCache.getInstance().getGeoModels().containsKey(entity.modelResLoc)){ - return new ResourceLocation("npcgecko","textures/model/alphabet.png"); + if (!GeckoLibCache.getInstance().getGeoModels().containsKey(entity.modelResLoc)) { + return new ResourceLocation("npcgecko", "textures/model/alphabet.png"); } - if(!GeckoLibCache.getInstance().getAnimations().containsKey(entity.animResLoc)){ - return new ResourceLocation("npcgecko","textures/model/alphabet.png"); + if (!GeckoLibCache.getInstance().getAnimations().containsKey(entity.animResLoc)) { + return new ResourceLocation("npcgecko", "textures/model/alphabet.png"); } return entity.textureResLoc; } diff --git a/src/main/java/com/goodbird/npcgecko/client/renderer/RenderCustomModel.java b/src/main/java/com/goodbird/npcgecko/client/renderer/RenderCustomModel.java index 72d0624..1bd9928 100644 --- a/src/main/java/com/goodbird/npcgecko/client/renderer/RenderCustomModel.java +++ b/src/main/java/com/goodbird/npcgecko/client/renderer/RenderCustomModel.java @@ -22,6 +22,7 @@ public class RenderCustomModel extends GeoEntityRenderer { public RenderCustomModel() { super(new ModelCustom()); } + public void renderAfter(GeoModel model, EntityCustomModel animatable, float ticks, float red, float green, float blue, float alpha) { super.renderAfter(model, animatable, ticks, red, green, blue, alpha); if (model.getBone("held_item").isPresent() && animatable.getHeldItem() != null) { @@ -39,7 +40,7 @@ public class RenderCustomModel extends GeoEntityRenderer { GlStateManager.rotate(-180, 0.0F, 1.0F, 0.0F); } if (entityLiving.deathTime > 0) { - float f = ((float)entityLiving.deathTime + partialTicks - 1.0F) / 20.0F * 1.6F; + float f = ((float) entityLiving.deathTime + partialTicks - 1.0F) / 20.0F * 1.6F; f = net.minecraft.util.MathHelper.sqrt_float(f); if (f > 1.0F) { f = 1.0F; @@ -56,7 +57,7 @@ public class RenderCustomModel extends GeoEntityRenderer { public GeoBone[] getPathFromRoot(GeoBone bone) { ArrayList bones; - for(bones = new ArrayList<>(); bone != null; bone = bone.parent) { + for (bones = new ArrayList<>(); bone != null; bone = bone.parent) { bones.add(0, bone); } @@ -108,30 +109,30 @@ public class RenderCustomModel extends GeoEntityRenderer { } public Color getRenderColor(EntityCustomModel animatable, float partialTicks) { - if(animatable.hurtTime>0 || animatable.deathTime > 0){ - if(animatable.tintData!=null && animatable.tintData.isTintEnabled() && animatable.tintData.isHurtTintEnabled()){ + if (animatable.hurtTime > 0 || animatable.deathTime > 0) { + if (animatable.tintData != null && animatable.tintData.isTintEnabled() && animatable.tintData.isHurtTintEnabled()) { int hurtTint = animatable.tintData.getHurtTint(); - int r = (int) ((float)(hurtTint >> 16 & 255)); - int g = (int) ((float)(hurtTint >> 8 & 255)); - int b = (int) ((float)(hurtTint & 255)); - return Color.ofRGBA(r,g,b, 255); + int r = (int) ((float) (hurtTint >> 16 & 255)); + int g = (int) ((float) (hurtTint >> 8 & 255)); + int b = (int) ((float) (hurtTint & 255)); + return Color.ofRGBA(r, g, b, 255); } return Color.ofRGBA(255, 153, 153, 255); - }else{ + } else { int r = 255; int g = 255; int b = 255; - if(animatable.tintData!=null && animatable.tintData.isTintEnabled() && animatable.tintData.isGeneralTintEnabled()){ + if (animatable.tintData != null && animatable.tintData.isTintEnabled() && animatable.tintData.isGeneralTintEnabled()) { int hurtTint = animatable.tintData.getGeneralTint(); - int tintR = (int) ((float)(hurtTint >> 16 & 255)); - int tintG = (int) ((float)(hurtTint >> 8 & 255)); - int tintB = (int) ((float)(hurtTint & 255)); - double alpha = ((double)animatable.tintData.getGeneralAlpha() / 100.0); - r = (int) (alpha*tintR + r*(1-alpha)); - g = (int) (alpha*tintG + g*(1-alpha)); - b = (int) (alpha*tintB + b*(1-alpha)); + int tintR = (int) ((float) (hurtTint >> 16 & 255)); + int tintG = (int) ((float) (hurtTint >> 8 & 255)); + int tintB = (int) ((float) (hurtTint & 255)); + double alpha = ((double) animatable.tintData.getGeneralAlpha() / 100.0); + r = (int) (alpha * tintR + r * (1 - alpha)); + g = (int) (alpha * tintG + g * (1 - alpha)); + b = (int) (alpha * tintB + b * (1 - alpha)); } - if(animatable.isSemiVisible){ + if (animatable.isSemiVisible) { return Color.ofRGBA(r, g, b, 100); } return Color.ofRGBA(r, g, b, 255); diff --git a/src/main/java/com/goodbird/npcgecko/client/renderer/RenderTileCustomModel.java b/src/main/java/com/goodbird/npcgecko/client/renderer/RenderTileCustomModel.java index db86d35..e2b23d1 100644 --- a/src/main/java/com/goodbird/npcgecko/client/renderer/RenderTileCustomModel.java +++ b/src/main/java/com/goodbird/npcgecko/client/renderer/RenderTileCustomModel.java @@ -3,7 +3,6 @@ package com.goodbird.npcgecko.client.renderer; import com.goodbird.npcgecko.client.model.TileModelCustom; import com.goodbird.npcgecko.tile.TileEntityCustomModel; import net.minecraft.tileentity.TileEntity; -import software.bernie.example.client.model.tile.BotariumModel; import software.bernie.geckolib3.renderers.geo.GeoBlockRenderer; public class RenderTileCustomModel extends GeoBlockRenderer { diff --git a/src/main/java/com/goodbird/npcgecko/data/CustomItemModelData.java b/src/main/java/com/goodbird/npcgecko/data/CustomItemModelData.java index 163cd84..42ee911 100644 --- a/src/main/java/com/goodbird/npcgecko/data/CustomItemModelData.java +++ b/src/main/java/com/goodbird/npcgecko/data/CustomItemModelData.java @@ -22,12 +22,12 @@ public class CustomItemModelData { } public void readFromNBT(NBTTagCompound nbttagcompound) { - if(nbttagcompound.hasKey("Model")) { + if (nbttagcompound.hasKey("Model")) { model = nbttagcompound.getString("Model"); animFile = nbttagcompound.getString("AnimFile"); idleAnim = nbttagcompound.getString("IdleAnim"); texture = nbttagcompound.getString("Texture"); - if(nbttagcompound.hasKey("TransitionLengthTicks")){ + if (nbttagcompound.hasKey("TransitionLengthTicks")) { transitionLengthTicks = nbttagcompound.getInteger("TransitionLengthTicks"); } } diff --git a/src/main/java/com/goodbird/npcgecko/data/CustomModelData.java b/src/main/java/com/goodbird/npcgecko/data/CustomModelData.java index 0e2689e..bc4fef8 100644 --- a/src/main/java/com/goodbird/npcgecko/data/CustomModelData.java +++ b/src/main/java/com/goodbird/npcgecko/data/CustomModelData.java @@ -12,6 +12,7 @@ public class CustomModelData { private String rangedAttackAnim = ""; private String headBoneName = "head"; private int transitionLengthTicks = 10; + public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) { nbttagcompound.setString("Model", model); nbttagcompound.setString("AnimFile", animFile); @@ -26,7 +27,7 @@ public class CustomModelData { } public void readFromNBT(NBTTagCompound nbttagcompound) { - if(nbttagcompound.hasKey("Model")) { + if (nbttagcompound.hasKey("Model")) { model = nbttagcompound.getString("Model"); animFile = nbttagcompound.getString("AnimFile"); idleAnim = nbttagcompound.getString("IdleAnim"); @@ -35,7 +36,7 @@ public class CustomModelData { meleeAttackAnim = nbttagcompound.getString("MeleeAttackAnim"); rangedAttackAnim = nbttagcompound.getString("RangedAttackAnim"); headBoneName = nbttagcompound.getString("HeadBoneName"); - if(nbttagcompound.hasKey("TransitionLengthTicks")){ + if (nbttagcompound.hasKey("TransitionLengthTicks")) { transitionLengthTicks = nbttagcompound.getInteger("TransitionLengthTicks"); } } diff --git a/src/main/java/com/goodbird/npcgecko/entity/EntityCustomModel.java b/src/main/java/com/goodbird/npcgecko/entity/EntityCustomModel.java index 7f1fa87..0bcc845 100644 --- a/src/main/java/com/goodbird/npcgecko/entity/EntityCustomModel.java +++ b/src/main/java/com/goodbird/npcgecko/entity/EntityCustomModel.java @@ -2,8 +2,6 @@ package com.goodbird.npcgecko.entity; import com.goodbird.npcgecko.constants.EnumSyncAutoAnim; import net.minecraft.entity.EntityCreature; -import net.minecraft.entity.ai.EntityAIWatchClosest; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; @@ -97,15 +95,16 @@ public class EntityCustomModel extends EntityCreature implements IAnimatable, IA public void setDialogAnim(String name) { dialogAnim = new AnimationBuilder().playOnce(name); } + public void activateReceivedAnim(EnumSyncAutoAnim type) { - if(type == EnumSyncAutoAnim.HURT){ - if(!hurtAnimName.isEmpty()) + if (type == EnumSyncAutoAnim.HURT) { + if (!hurtAnimName.isEmpty()) hurtAnim = new AnimationBuilder().playOnce(hurtAnimName); - }else if(type == EnumSyncAutoAnim.MELEE_ATTACK){ - if(!meleeAttackAnimName.isEmpty()) + } else if (type == EnumSyncAutoAnim.MELEE_ATTACK) { + if (!meleeAttackAnimName.isEmpty()) attackAnim = new AnimationBuilder().playOnce(meleeAttackAnimName); - }else if(type == EnumSyncAutoAnim.RANGED_ATTACK){ - if(!rangedAttackAnimName.isEmpty()) + } else if (type == EnumSyncAutoAnim.RANGED_ATTACK) { + if (!rangedAttackAnimName.isEmpty()) attackAnim = new AnimationBuilder().playOnce(rangedAttackAnimName); } } diff --git a/src/main/java/com/goodbird/npcgecko/handler/EventHandler.java b/src/main/java/com/goodbird/npcgecko/handler/EventHandler.java index 119baab..65aba2f 100644 --- a/src/main/java/com/goodbird/npcgecko/handler/EventHandler.java +++ b/src/main/java/com/goodbird/npcgecko/handler/EventHandler.java @@ -9,20 +9,20 @@ import noppes.npcs.scripted.event.NpcEvent; public class EventHandler { @SubscribeEvent - public void onNpcMeleeAttack(NpcEvent.SwingEvent event){ - if(event != null && event.npc != null && event.npc.getMCEntity() != null) + public void onNpcMeleeAttack(NpcEvent.SwingEvent event) { + if (event != null && event.npc != null && event.npc.getMCEntity() != null) NetworkHandler.sendToAll(new CPacketSyncAutoAnim((EntityNPCInterface) event.npc.getMCEntity(), EnumSyncAutoAnim.MELEE_ATTACK)); } @SubscribeEvent - public void onNpcRanged(NpcEvent.RangedLaunchedEvent event){ - if(event != null && event.npc != null && event.npc.getMCEntity() != null) + public void onNpcRanged(NpcEvent.RangedLaunchedEvent event) { + if (event != null && event.npc != null && event.npc.getMCEntity() != null) NetworkHandler.sendToAll(new CPacketSyncAutoAnim((EntityNPCInterface) event.npc.getMCEntity(), EnumSyncAutoAnim.RANGED_ATTACK)); } @SubscribeEvent - public void onNpcDamaged(NpcEvent.DamagedEvent event){ - if(event != null && event.npc != null && event.npc.getMCEntity() != null) + public void onNpcDamaged(NpcEvent.DamagedEvent event) { + if (event != null && event.npc != null && event.npc.getMCEntity() != null) NetworkHandler.sendToAll(new CPacketSyncAutoAnim((EntityNPCInterface) event.npc.getMCEntity(), EnumSyncAutoAnim.HURT)); } } diff --git a/src/main/java/com/goodbird/npcgecko/item/ItemCustomModelPredicate.java b/src/main/java/com/goodbird/npcgecko/item/ItemCustomModelPredicate.java index fc42c05..2ec6e73 100644 --- a/src/main/java/com/goodbird/npcgecko/item/ItemCustomModelPredicate.java +++ b/src/main/java/com/goodbird/npcgecko/item/ItemCustomModelPredicate.java @@ -15,8 +15,8 @@ public class ItemCustomModelPredicate { public static

PlayState predicate(AnimationEvent

event) { ItemStack stack = (ItemStack) event.getExtraData().get(0); IItemStack istack = NpcAPI.Instance().getIItemStack(stack); - if(!(istack instanceof ScriptCustomItem)) return PlayState.STOP; - IScriptCustomItem item = (IScriptCustomItem)istack; + if (!(istack instanceof ScriptCustomItem)) return PlayState.STOP; + IScriptCustomItem item = (IScriptCustomItem) istack; event.getController().setAnimation(new AnimationBuilder().loop(item.getCustomModelData().getIdleAnim())); return PlayState.CONTINUE; } diff --git a/src/main/java/com/goodbird/npcgecko/mixin/impl/MixinBlockScriptedRenderer.java b/src/main/java/com/goodbird/npcgecko/mixin/impl/MixinBlockScriptedRenderer.java index 91c93be..768c8d2 100644 --- a/src/main/java/com/goodbird/npcgecko/mixin/impl/MixinBlockScriptedRenderer.java +++ b/src/main/java/com/goodbird/npcgecko/mixin/impl/MixinBlockScriptedRenderer.java @@ -11,7 +11,6 @@ import noppes.npcs.blocks.tiles.TileScripted; import noppes.npcs.client.renderer.blocks.BlockScriptedRenderer; import org.lwjgl.opengl.GL11; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @@ -25,10 +24,11 @@ public abstract class MixinBlockScriptedRenderer { @Inject(method = "renderTileEntityAt", at = @At(value = "INVOKE", target = "Lnoppes/npcs/client/renderer/blocks/BlockScriptedRenderer;renderItem(Lnet/minecraft/tileentity/TileEntity;Lnet/minecraft/item/ItemStack;)V", remap = false)) public void geckoModelRendering(TileEntity te, double x, double y, double z, float partialTicks, CallbackInfo ci) { - if(!(te instanceof TileScripted)) return; + if (!(te instanceof TileScripted)) return; TileScripted tileScripted = (TileScripted) te; - if(tileScripted.itemModel == null) return; - if(!(MinecraftForgeClient.getItemRenderer(tileScripted.itemModel, ENTITY) instanceof RenderBlockItem) || BlockScriptedRenderer.overrideModel()) return; + if (tileScripted.itemModel == null) return; + if (!(MinecraftForgeClient.getItemRenderer(tileScripted.itemModel, ENTITY) instanceof RenderBlockItem) || BlockScriptedRenderer.overrideModel()) + return; GL11.glTranslated(0, -0.5, 0); GL11.glScaled(2, 2, 2); } @@ -46,19 +46,19 @@ public abstract class MixinBlockScriptedRenderer { @Inject(method = "renderTileEntityAt", at = @At(value = "HEAD"), cancellable = true) public void customGeckoModelRendering(TileEntity te, double x, double y, double z, float partialTicks, CallbackInfo ci) { - if(BlockScriptedRenderer.overrideModel()) return; - if(!(te instanceof TileScripted)) return; + if (BlockScriptedRenderer.overrideModel()) return; + if (!(te instanceof TileScripted)) return; TileScripted tileScripted = (TileScripted) te; - if(!(tileScripted.renderTile instanceof TileEntityCustomModel)) return; + if (!(tileScripted.renderTile instanceof TileEntityCustomModel)) return; GL11.glPushMatrix(); - GL11.glTranslated(x,y,z); - GL11.glTranslated(0.5,0.5, 0.5); - GL11.glRotatef((float)tileScripted.rotationY, 0.0F, 1.0F, 0.0F); - GL11.glRotatef((float)tileScripted.rotationX, 1.0F, 0.0F, 0.0F); - GL11.glRotatef((float)tileScripted.rotationZ, 0.0F, 0.0F, 1.0F); + GL11.glTranslated(x, y, z); + GL11.glTranslated(0.5, 0.5, 0.5); + GL11.glRotatef((float) tileScripted.rotationY, 0.0F, 1.0F, 0.0F); + GL11.glRotatef((float) tileScripted.rotationX, 1.0F, 0.0F, 0.0F); + GL11.glRotatef((float) tileScripted.rotationZ, 0.0F, 0.0F, 1.0F); GL11.glScalef(tileScripted.scaleX, tileScripted.scaleY, tileScripted.scaleZ); - GL11.glTranslated(-0.5,-0.5/tileScripted.scaleY, -0.5); - GL11.glTranslated(-x,-y,-z); + GL11.glTranslated(-0.5, -0.5 / tileScripted.scaleY, -0.5); + GL11.glTranslated(-x, -y, -z); TileEntityRendererDispatcher.instance.renderTileEntityAt(tileScripted.renderTile, x, y, z, partialTicks); GL11.glPopMatrix(); ci.cancel(); diff --git a/src/main/java/com/goodbird/npcgecko/mixin/impl/MixinDataDisplay.java b/src/main/java/com/goodbird/npcgecko/mixin/impl/MixinDataDisplay.java index 035bcae..2fa6768 100644 --- a/src/main/java/com/goodbird/npcgecko/mixin/impl/MixinDataDisplay.java +++ b/src/main/java/com/goodbird/npcgecko/mixin/impl/MixinDataDisplay.java @@ -18,23 +18,24 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(DataDisplay.class) public class MixinDataDisplay implements IDataDisplay { - @Shadow(remap = false) public EntityNPCInterface npc; + @Shadow(remap = false) + public EntityNPCInterface npc; @Unique private final CustomModelData customNPC_Gecko_Addon$customModelData = new CustomModelData(); @Inject(method = "writeToNBT", at = @At("HEAD"), remap = false) public void writeToNBT(NBTTagCompound nbttagcompound, CallbackInfoReturnable cir) { - if(hasCustomModel()) + if (hasCustomModel()) customNPC_Gecko_Addon$customModelData.writeToNBT(nbttagcompound); } @Inject(method = "readToNBT", at = @At("HEAD"), remap = false) - public void readFromNBT(NBTTagCompound nbttagcompound, CallbackInfo ci){ + public void readFromNBT(NBTTagCompound nbttagcompound, CallbackInfo ci) { customNPC_Gecko_Addon$customModelData.readFromNBT(nbttagcompound); } @Unique - public CustomModelData getCustomModelData(){ + public CustomModelData getCustomModelData() { return customNPC_Gecko_Addon$customModelData; } diff --git a/src/main/java/com/goodbird/npcgecko/mixin/impl/MixinGeckoAddon.java b/src/main/java/com/goodbird/npcgecko/mixin/impl/MixinGeckoAddon.java index 619118e..c29c208 100644 --- a/src/main/java/com/goodbird/npcgecko/mixin/impl/MixinGeckoAddon.java +++ b/src/main/java/com/goodbird/npcgecko/mixin/impl/MixinGeckoAddon.java @@ -16,7 +16,8 @@ import software.bernie.geckolib3.core.manager.AnimationData; @Mixin(GeckoAddon.class) public class MixinGeckoAddon { - @Shadow(remap = false) public boolean supportEnabled; + @Shadow(remap = false) + public boolean supportEnabled; /** * @author Goodbird @@ -24,11 +25,11 @@ public class MixinGeckoAddon { */ @Overwrite(remap = false) public void geckoCopyData(EntityLivingBase copied, EntityLivingBase entity) { - if(!supportEnabled) + if (!supportEnabled) return; if (entity instanceof EntityCustomModel && copied instanceof EntityNPCInterface) { - EntityCustomModel modelEntity = (EntityCustomModel) entity; + EntityCustomModel modelEntity = (EntityCustomModel) entity; EntityNPCInterface npc = (EntityNPCInterface) copied; IDataDisplay display = (IDataDisplay) npc.display; modelEntity.textureResLoc = NpcTextureUtils.getNpcTexture((EntityNPCInterface) copied); @@ -45,7 +46,7 @@ public class MixinGeckoAddon { modelEntity.tintData = npc.display.tintData; modelEntity.headBoneName = display.getCustomModelData().getHeadBoneName(); AnimationData animationData = modelEntity.getFactory().getOrCreateAnimationData(modelEntity.getUniqueID().hashCode()); - for(AnimationController controller : animationData.getAnimationControllers().values()){ + for (AnimationController controller : animationData.getAnimationControllers().values()) { controller.transitionLengthTicks = display.getCustomModelData().getTransitionLengthTicks(); } } diff --git a/src/main/java/com/goodbird/npcgecko/mixin/impl/MixinGeckoAddonClient.java b/src/main/java/com/goodbird/npcgecko/mixin/impl/MixinGeckoAddonClient.java index f5c857e..c5c7ea0 100644 --- a/src/main/java/com/goodbird/npcgecko/mixin/impl/MixinGeckoAddonClient.java +++ b/src/main/java/com/goodbird/npcgecko/mixin/impl/MixinGeckoAddonClient.java @@ -29,20 +29,21 @@ import java.util.Vector; @Mixin(GeckoAddonClient.class) public class MixinGeckoAddonClient { - @Shadow(remap = false) public boolean supportEnabled; + @Shadow(remap = false) + public boolean supportEnabled; /** * @author Goodbird * @reason Show Custom Model Selection button for Custom Entities */ @Overwrite(remap = false) - public void showGeckoButtons(GuiCreationScreen creationScreen, EntityLivingBase entity){ - if(!supportEnabled) + public void showGeckoButtons(GuiCreationScreen creationScreen, EntityLivingBase entity) { + if (!supportEnabled) return; - if(entity instanceof EntityCustomModel){ - creationScreen.addButton(new GuiNpcButton(202, creationScreen.guiLeft-60, creationScreen.guiTop+40, 180, 20, ((IDataDisplay)creationScreen.npc.display).getCustomModelData().getModel())); - creationScreen.addButton(new GuiNpcButton(203, creationScreen.guiLeft-60, creationScreen.guiTop+62, 180, 20, "Extras")); + if (entity instanceof EntityCustomModel) { + creationScreen.addButton(new GuiNpcButton(202, creationScreen.guiLeft - 60, creationScreen.guiTop + 40, 180, 20, ((IDataDisplay) creationScreen.npc.display).getCustomModelData().getModel())); + creationScreen.addButton(new GuiNpcButton(203, creationScreen.guiLeft - 60, creationScreen.guiTop + 62, 180, 20, "Extras")); } } @@ -51,21 +52,21 @@ public class MixinGeckoAddonClient { * @reason Add support for new showGeckoButtons() in GuiCreationScreen */ @Overwrite(remap = false) - public void geckoGuiCreationScreenActionPerformed(GuiCreationScreen creationScreen, GuiNpcButton button){ - if(!supportEnabled) + public void geckoGuiCreationScreenActionPerformed(GuiCreationScreen creationScreen, GuiNpcButton button) { + if (!supportEnabled) return; - if(button.id == 202){ + if (button.id == 202) { Vector list = new Vector<>(); - for(ResourceLocation resLoc : GeckoLibCache.getInstance().getGeoModels().keySet()){ + for (ResourceLocation resLoc : GeckoLibCache.getInstance().getGeoModels().keySet()) { list.add(resLoc.toString()); } - creationScreen.setSubGui(new GuiStringSelection(creationScreen,"Selecting GeckoLib Model:", list, name -> { - ((IDataDisplay)creationScreen.npc.display).getCustomModelData().setModel(name); + creationScreen.setSubGui(new GuiStringSelection(creationScreen, "Selecting GeckoLib Model:", list, name -> { + ((IDataDisplay) creationScreen.npc.display).getCustomModelData().setModel(name); creationScreen.getButton(202).setDisplayText(name); })); } - if(button.id == 203){ + if (button.id == 203) { creationScreen.setSubGui(new SubGuiModelExtras(creationScreen.npc)); } } @@ -75,15 +76,15 @@ public class MixinGeckoAddonClient { * @reason Init Model Animation Button for NPCs */ @Overwrite(remap = false) - public void geckoNpcDisplayInitGui(GuiNPCInterface2 gui){ - if(!supportEnabled) + public void geckoNpcDisplayInitGui(GuiNPCInterface2 gui) { + if (!supportEnabled) return; int y = gui.guiTop + 188; - gui.addLabel(new GuiNpcLabel(212,"Model Animation", gui.guiLeft + 185, y + 5)); + gui.addLabel(new GuiNpcLabel(212, "Model Animation", gui.guiLeft + 185, y + 5)); gui.addButton(new GuiNpcButton(212, gui.guiLeft + 300, y, 100, 20, "selectServer.edit")); - if (!((IDataDisplay)gui.npc.display).hasCustomModel()) { - gui.getLabel(212).enabled=false; + if (!((IDataDisplay) gui.npc.display).hasCustomModel()) { + gui.getLabel(212).enabled = false; gui.getButton(212).setVisible(false); gui.getButton(212).setEnabled(false); } @@ -94,11 +95,11 @@ public class MixinGeckoAddonClient { * @reason Add Support for Model Animation button on Npc Display */ @Overwrite(remap = false) - public void geckoNpcDisplayActionPerformed(GuiNPCInterface2 gui, GuiNpcButton btn){ - if(!supportEnabled) + public void geckoNpcDisplayActionPerformed(GuiNPCInterface2 gui, GuiNpcButton btn) { + if (!supportEnabled) return; - if(btn.id == 212){ + if (btn.id == 212) { gui.setSubGui(new SubGuiModelAnimation(gui.npc)); } } @@ -108,8 +109,8 @@ public class MixinGeckoAddonClient { * @reason Check if Entity is a Gecko Model */ @Overwrite(remap = false) - public boolean isGeckoModel(ModelBase mainModel){ - if(!supportEnabled) + public boolean isGeckoModel(ModelBase mainModel) { + if (!supportEnabled) return false; return (mainModel instanceof ModelMPM && ((ModelMPM) mainModel).entity instanceof IAnimatable); @@ -120,23 +121,20 @@ public class MixinGeckoAddonClient { * @reason Render Gecko Model Support */ @Overwrite(remap = false) - public void geckoRenderModel(ModelMPM mainModel, EntityNPCInterface npc, float rot, float partial){ - GL11.glRotatef(180, 1,0,0); - GL11.glTranslated(0, -1.5,0); + public void geckoRenderModel(ModelMPM mainModel, EntityNPCInterface npc, float rot, float partial) { + GL11.glRotatef(180, 1, 0, 0); + GL11.glTranslated(0, -1.5, 0); - if (!npc.isInvisible()) - { - if(mainModel.entity instanceof EntityCustomModel){ - ((EntityCustomModel)mainModel.entity).isSemiVisible = false; + if (!npc.isInvisible()) { + if (mainModel.entity instanceof EntityCustomModel) { + ((EntityCustomModel) mainModel.entity).isSemiVisible = false; } - RenderManager.instance.renderEntityWithPosYaw(mainModel.entity, 0,0,0,rot,partial); - } - else if (!npc.isInvisibleToPlayer(Minecraft.getMinecraft().thePlayer)) - { - if(mainModel.entity instanceof EntityCustomModel){ - ((EntityCustomModel)mainModel.entity).isSemiVisible = true; - RenderManager.instance.renderEntityWithPosYaw(mainModel.entity, 0,0,0,rot,partial); - }else { + RenderManager.instance.renderEntityWithPosYaw(mainModel.entity, 0, 0, 0, rot, partial); + } else if (!npc.isInvisibleToPlayer(Minecraft.getMinecraft().thePlayer)) { + if (mainModel.entity instanceof EntityCustomModel) { + ((EntityCustomModel) mainModel.entity).isSemiVisible = true; + RenderManager.instance.renderEntityWithPosYaw(mainModel.entity, 0, 0, 0, rot, partial); + } else { GL11.glPushMatrix(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.15F); GL11.glDepthMask(false); diff --git a/src/main/java/com/goodbird/npcgecko/mixin/impl/MixinScriptCustomItem.java b/src/main/java/com/goodbird/npcgecko/mixin/impl/MixinScriptCustomItem.java index 45bfb94..56b0ec5 100644 --- a/src/main/java/com/goodbird/npcgecko/mixin/impl/MixinScriptCustomItem.java +++ b/src/main/java/com/goodbird/npcgecko/mixin/impl/MixinScriptCustomItem.java @@ -1,4 +1,3 @@ - // TODO: Fix ScriptCustomItem //package com.goodbird.npcgecko.mixin.impl; // diff --git a/src/main/java/com/goodbird/npcgecko/mixin/impl/TileScriptedMixin.java b/src/main/java/com/goodbird/npcgecko/mixin/impl/TileScriptedMixin.java index 0aa04f9..2d62e95 100644 --- a/src/main/java/com/goodbird/npcgecko/mixin/impl/TileScriptedMixin.java +++ b/src/main/java/com/goodbird/npcgecko/mixin/impl/TileScriptedMixin.java @@ -3,10 +3,7 @@ package com.goodbird.npcgecko.mixin.impl; import com.goodbird.npcgecko.CustomNpcPlusGecko; import com.goodbird.npcgecko.tile.TileEntityCustomModel; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.server.MinecraftServer; import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; -import net.minecraftforge.common.MinecraftForge; import noppes.npcs.blocks.tiles.TileScripted; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -22,12 +19,12 @@ public class TileScriptedMixin { @Inject(method = "setDisplayNBT", at = @At("TAIL"), remap = false) public void setDisplayNBT(NBTTagCompound compound, CallbackInfo ci) { - if(compound.hasKey("renderTileTag")){ + if (compound.hasKey("renderTileTag")) { renderTile = new TileEntityCustomModel(); NBTTagCompound saveTag = compound.getCompoundTag("renderTileTag"); - if(saveTag.hasKey("dimID")){ + if (saveTag.hasKey("dimID")) { renderTile.setWorldObj(CustomNpcPlusGecko.proxy.getWorldById(saveTag.getInteger("dimID"))); - }else{ + } else { renderTile.setWorldObj(CustomNpcPlusGecko.proxy.getWorldById(0)); } renderTile.readFromNBT(saveTag); @@ -36,10 +33,10 @@ public class TileScriptedMixin { @Inject(method = "getDisplayNBT", at = @At("TAIL"), remap = false) public void getDisplayNBT(NBTTagCompound compound, CallbackInfo ci) { - if(renderTile!=null) { + if (renderTile != null) { NBTTagCompound saveTag = new NBTTagCompound(); renderTile.writeToNBT(saveTag); - if(renderTile.getWorldObj()!=null && renderTile.getWorldObj().provider!=null) + if (renderTile.getWorldObj() != null && renderTile.getWorldObj().provider != null) saveTag.setInteger("dimID", renderTile.getWorldObj().provider.dimensionId); compound.setTag("renderTileTag", saveTag); } diff --git a/src/main/java/com/goodbird/npcgecko/network/CPacketSyncAutoAnim.java b/src/main/java/com/goodbird/npcgecko/network/CPacketSyncAutoAnim.java index 8e8c336..aff5cef 100644 --- a/src/main/java/com/goodbird/npcgecko/network/CPacketSyncAutoAnim.java +++ b/src/main/java/com/goodbird/npcgecko/network/CPacketSyncAutoAnim.java @@ -14,9 +14,11 @@ import noppes.npcs.entity.EntityNPCInterface; public final class CPacketSyncAutoAnim implements IMessage, IMessageHandler { public EnumSyncAutoAnim animType; public int entityId; - public CPacketSyncAutoAnim(){ + + public CPacketSyncAutoAnim() { } + public CPacketSyncAutoAnim(EntityNPCInterface npc, EnumSyncAutoAnim animType) { this.animType = animType; this.entityId = npc.getEntityId(); @@ -37,9 +39,9 @@ public final class CPacketSyncAutoAnim implements IMessage, IMessageHandler { public AnimationBuilder builder; public int entityId; - public CPacketSyncManualAnim(){ + + public CPacketSyncManualAnim() { } + public CPacketSyncManualAnim(EntityNPCInterface npc, AnimationBuilder builder) { this.builder = builder; this.entityId = npc.getEntityId(); @@ -34,7 +35,8 @@ public final class CPacketSyncManualAnim implements IMessage, IMessageHandler { public AnimationBuilder builder; public int x, y, z; - public CPacketSyncTileManualAnim(){ + + public CPacketSyncTileManualAnim() { } + public CPacketSyncTileManualAnim(TileEntity tile, AnimationBuilder builder) { this.builder = builder; this.x = tile.xCoord; @@ -40,7 +36,8 @@ public class CPacketSyncTileManualAnim implements IMessage, IMessageHandler