mirror of
https://github.com/KAMKEEL/CustomNPC-Gecko-Addon.git
synced 2026-11-19 03:49:11 +00:00
Formatting Cleanup
This commit is contained in:
1 parent
66e2066fcc
commit
40b07df4a5
31 files changed
+7646
-3493
No files matched your search
@@ -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];
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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<EntityNPCInterface> npc, String model);
|
||||
|
||||
public abstract void setTexture(ICustomNpc<EntityNPCInterface> npc, String texture);
|
||||
|
||||
public abstract void setAnimationFile(ICustomNpc<EntityNPCInterface> npc, String animation);
|
||||
|
||||
public abstract void setIdleAnimation(ICustomNpc<EntityNPCInterface> npc, String animation);
|
||||
|
||||
public abstract void syncAnimForPlayer(ICustomNpc<EntityNPCInterface> npc, AnimationBuilder builder, IPlayer<EntityPlayerMP> player);
|
||||
|
||||
public abstract void syncAnimForAll(ICustomNpc<EntityNPCInterface> 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<EntityPlayerMP> player);
|
||||
|
||||
public abstract void syncAnimForAll(IBlockScripted scriptedBlock, AnimationBuilder builder);
|
||||
|
||||
// TODO: Fix ScriptCustomItem
|
||||
|
||||
@@ -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<EntityNPCInterface> 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<EntityNPCInterface> npc, String animation) {
|
||||
((IDataDisplay)npc.getMCEntity().display).getCustomModelData().setAnimFile(animation);
|
||||
((IDataDisplay) npc.getMCEntity().display).getCustomModelData().setAnimFile(animation);
|
||||
npc.updateClient();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIdleAnimation(ICustomNpc<EntityNPCInterface> npc, String animation) {
|
||||
((IDataDisplay)npc.getMCEntity().display).getCustomModelData().setIdleAnim(animation);
|
||||
((IDataDisplay) npc.getMCEntity().display).getCustomModelData().setIdleAnim(animation);
|
||||
npc.updateClient();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncAnimForPlayer(ICustomNpc<EntityNPCInterface> npc, AnimationBuilder builder, IPlayer<EntityPlayerMP> player) {
|
||||
NetworkHandler.sendToPlayer(new CPacketSyncManualAnim(npc.getMCEntity(),builder), player.getMCEntity());
|
||||
NetworkHandler.sendToPlayer(new CPacketSyncManualAnim(npc.getMCEntity(), builder), player.getMCEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncAnimForAll(ICustomNpc<EntityNPCInterface> 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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,40 +11,40 @@ import software.bernie.geckolib3.resource.GeckoLibCache;
|
||||
public class ModelCustom extends AnimatedGeoModel<EntityCustomModel> {
|
||||
@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
|
||||
|
||||
@@ -8,30 +8,30 @@ import software.bernie.geckolib3.resource.GeckoLibCache;
|
||||
public class TileModelCustom extends AnimatedGeoModel<TileEntityCustomModel> {
|
||||
@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;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ public class RenderCustomModel extends GeoEntityRenderer<EntityCustomModel> {
|
||||
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<EntityCustomModel> {
|
||||
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<EntityCustomModel> {
|
||||
|
||||
public GeoBone[] getPathFromRoot(GeoBone bone) {
|
||||
ArrayList<GeoBone> 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<EntityCustomModel> {
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
@@ -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<TileEntityCustomModel> {
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
@@ -15,8 +15,8 @@ public class ItemCustomModelPredicate {
|
||||
public static <P extends Item & IAnimatable> PlayState predicate(AnimationEvent<P> 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;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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<NBTTagCompound> 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<String> 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);
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
// TODO: Fix ScriptCustomItem
|
||||
//package com.goodbird.npcgecko.mixin.impl;
|
||||
//
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -14,9 +14,11 @@ import noppes.npcs.entity.EntityNPCInterface;
|
||||
public final class CPacketSyncAutoAnim implements IMessage, IMessageHandler<CPacketSyncAutoAnim, IMessage> {
|
||||
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<CPac
|
||||
@Override
|
||||
public IMessage onMessage(CPacketSyncAutoAnim message, MessageContext ctx) {
|
||||
Entity entity = Minecraft.getMinecraft().theWorld.getEntityByID(message.entityId);
|
||||
if(!(entity instanceof EntityCustomNpc)) return null;
|
||||
if (!(entity instanceof EntityCustomNpc)) return null;
|
||||
EntityCustomNpc npc = (EntityCustomNpc) entity;
|
||||
if(npc.modelData==null || !(npc.modelData.getEntity(npc) instanceof EntityCustomModel)) return null;
|
||||
if (npc.modelData == null || !(npc.modelData.getEntity(npc) instanceof EntityCustomModel)) return null;
|
||||
EntityCustomModel entityCustomModel = (EntityCustomModel) npc.modelData.getEntity(npc);
|
||||
entityCustomModel.activateReceivedAnim(message.animType);
|
||||
return null;
|
||||
|
||||
@@ -10,7 +10,6 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import noppes.npcs.Server;
|
||||
import noppes.npcs.entity.EntityCustomNpc;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import software.bernie.geckolib3.core.builder.AnimationBuilder;
|
||||
@@ -22,9 +21,11 @@ import java.io.IOException;
|
||||
public final class CPacketSyncManualAnim implements IMessage, IMessageHandler<CPacketSyncManualAnim, IMessage> {
|
||||
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<CP
|
||||
public void toBytes(ByteBuf buf) {
|
||||
try {
|
||||
writeAnimBuilder(buf, builder);
|
||||
}catch (Exception ignored){ }
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
buf.writeInt(entityId);
|
||||
}
|
||||
|
||||
@@ -42,32 +44,33 @@ public final class CPacketSyncManualAnim implements IMessage, IMessageHandler<CP
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
try {
|
||||
builder = readAnimBuilder(buf);
|
||||
}catch (Exception ignored){ }
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
entityId = buf.readInt();
|
||||
}
|
||||
|
||||
public static void writeAnimBuilder(ByteBuf buffer, AnimationBuilder builder) throws IOException {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
NBTTagList animList = new NBTTagList();
|
||||
for(RawAnimation anim: builder.getRawAnimationList()){
|
||||
for (RawAnimation anim : builder.getRawAnimationList()) {
|
||||
NBTTagCompound animTag = new NBTTagCompound();
|
||||
animTag.setString("name", anim.animationName);
|
||||
if(anim.loopType!=null) {
|
||||
if (anim.loopType != null) {
|
||||
animTag.setInteger("loop", ((ILoopType.EDefaultLoopTypes) anim.loopType).ordinal());
|
||||
}else{
|
||||
animTag.setInteger("loop",1);
|
||||
} else {
|
||||
animTag.setInteger("loop", 1);
|
||||
}
|
||||
animList.appendTag(animTag);
|
||||
}
|
||||
compound.setTag("anims",animList);
|
||||
ByteBufUtils.writeNBT(buffer,compound);
|
||||
compound.setTag("anims", animList);
|
||||
ByteBufUtils.writeNBT(buffer, compound);
|
||||
}
|
||||
|
||||
public static AnimationBuilder readAnimBuilder(ByteBuf buffer) throws IOException {
|
||||
AnimationBuilder builder = new AnimationBuilder();
|
||||
NBTTagCompound compound = ByteBufUtils.readNBT(buffer);
|
||||
NBTTagList animList = compound.getTagList("anims",10);
|
||||
for(int i=0;i<animList.tagCount();i++){
|
||||
NBTTagList animList = compound.getTagList("anims", 10);
|
||||
for (int i = 0; i < animList.tagCount(); i++) {
|
||||
NBTTagCompound animTag = animList.getCompoundTagAt(i);
|
||||
builder.addAnimation(animTag.getString("name"),
|
||||
ILoopType.EDefaultLoopTypes.values()[animTag.getInteger("loop")]);
|
||||
@@ -78,9 +81,9 @@ public final class CPacketSyncManualAnim implements IMessage, IMessageHandler<CP
|
||||
@Override
|
||||
public IMessage onMessage(CPacketSyncManualAnim message, MessageContext ctx) {
|
||||
Entity entity = Minecraft.getMinecraft().theWorld.getEntityByID(message.entityId);
|
||||
if(!(entity instanceof EntityCustomNpc)) return null;
|
||||
if (!(entity instanceof EntityCustomNpc)) return null;
|
||||
EntityCustomNpc npc = (EntityCustomNpc) entity;
|
||||
if(npc.modelData==null || !(npc.modelData.getEntity(npc) instanceof EntityCustomModel)) return null;
|
||||
if (npc.modelData == null || !(npc.modelData.getEntity(npc) instanceof EntityCustomModel)) return null;
|
||||
EntityCustomModel entityCustomModel = (EntityCustomModel) npc.modelData.getEntity(npc);
|
||||
entityCustomModel.manualAnim = message.builder;
|
||||
return null;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.goodbird.npcgecko.network;
|
||||
|
||||
import com.goodbird.npcgecko.entity.EntityCustomModel;
|
||||
import com.goodbird.npcgecko.tile.TileEntityCustomModel;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
@@ -8,15 +7,10 @@ import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import kamkeel.npcs.util.ByteBufUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import noppes.npcs.Server;
|
||||
import noppes.npcs.blocks.tiles.TileScripted;
|
||||
import noppes.npcs.entity.EntityCustomNpc;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import software.bernie.geckolib3.core.builder.AnimationBuilder;
|
||||
import software.bernie.geckolib3.core.builder.ILoopType;
|
||||
import software.bernie.geckolib3.core.builder.RawAnimation;
|
||||
@@ -26,9 +20,11 @@ import java.io.IOException;
|
||||
public class CPacketSyncTileManualAnim implements IMessage, IMessageHandler<CPacketSyncTileManualAnim, IMessage> {
|
||||
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<CPac
|
||||
public void toBytes(ByteBuf buf) {
|
||||
try {
|
||||
writeAnimBuilder(buf, builder);
|
||||
}catch (Exception ignored){ }
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
buf.writeInt(x);
|
||||
buf.writeInt(y);
|
||||
buf.writeInt(z);
|
||||
@@ -50,7 +47,8 @@ public class CPacketSyncTileManualAnim implements IMessage, IMessageHandler<CPac
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
try {
|
||||
builder = readAnimBuilder(buf);
|
||||
}catch (Exception ignored){ }
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
x = buf.readInt();
|
||||
y = buf.readInt();
|
||||
z = buf.readInt();
|
||||
@@ -60,25 +58,25 @@ public class CPacketSyncTileManualAnim implements IMessage, IMessageHandler<CPac
|
||||
public static void writeAnimBuilder(ByteBuf buffer, AnimationBuilder builder) throws IOException {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
NBTTagList animList = new NBTTagList();
|
||||
for(RawAnimation anim: builder.getRawAnimationList()){
|
||||
for (RawAnimation anim : builder.getRawAnimationList()) {
|
||||
NBTTagCompound animTag = new NBTTagCompound();
|
||||
animTag.setString("name", anim.animationName);
|
||||
if(anim.loopType!=null) {
|
||||
if (anim.loopType != null) {
|
||||
animTag.setInteger("loop", ((ILoopType.EDefaultLoopTypes) anim.loopType).ordinal());
|
||||
}else{
|
||||
animTag.setInteger("loop",1);
|
||||
} else {
|
||||
animTag.setInteger("loop", 1);
|
||||
}
|
||||
animList.appendTag(animTag);
|
||||
}
|
||||
compound.setTag("anims",animList);
|
||||
ByteBufUtils.writeNBT(buffer,compound);
|
||||
compound.setTag("anims", animList);
|
||||
ByteBufUtils.writeNBT(buffer, compound);
|
||||
}
|
||||
|
||||
public static AnimationBuilder readAnimBuilder(ByteBuf buffer) throws IOException {
|
||||
AnimationBuilder builder = new AnimationBuilder();
|
||||
NBTTagCompound compound = ByteBufUtils.readNBT(buffer);
|
||||
NBTTagList animList = compound.getTagList("anims",10);
|
||||
for(int i=0;i<animList.tagCount();i++){
|
||||
NBTTagList animList = compound.getTagList("anims", 10);
|
||||
for (int i = 0; i < animList.tagCount(); i++) {
|
||||
NBTTagCompound animTag = animList.getCompoundTagAt(i);
|
||||
builder.addAnimation(animTag.getString("name"),
|
||||
ILoopType.EDefaultLoopTypes.values()[animTag.getInteger("loop")]);
|
||||
@@ -89,9 +87,9 @@ public class CPacketSyncTileManualAnim implements IMessage, IMessageHandler<CPac
|
||||
@Override
|
||||
public IMessage onMessage(CPacketSyncTileManualAnim message, MessageContext ctx) {
|
||||
TileEntity entity = Minecraft.getMinecraft().theWorld.getTileEntity(message.x, message.y, message.z);
|
||||
if(!(entity instanceof TileScripted)) return null;
|
||||
if (!(entity instanceof TileScripted)) return null;
|
||||
TileScripted tile = (TileScripted) entity;
|
||||
if(tile.renderTile==null){
|
||||
if (tile.renderTile == null) {
|
||||
tile.renderTile = new TileEntityCustomModel();
|
||||
}
|
||||
TileEntityCustomModel geckoTile = (TileEntityCustomModel) tile.renderTile;
|
||||
|
||||
@@ -21,10 +21,11 @@ public class TileEntityCustomModel extends TileEntity implements IAnimatable {
|
||||
public String idleAnimName = "";
|
||||
public AnimationBuilder manualAnim = null;
|
||||
|
||||
public TileEntityCustomModel(){
|
||||
public TileEntityCustomModel() {
|
||||
|
||||
}
|
||||
public TileEntityCustomModel(TileEntity other){
|
||||
|
||||
public TileEntityCustomModel(TileEntity other) {
|
||||
setWorldObj(other.getWorldObj());
|
||||
xCoord = other.xCoord;
|
||||
yCoord = other.yCoord;
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.security.MessageDigest;
|
||||
import java.util.Map;
|
||||
|
||||
public class NpcTextureUtils {
|
||||
public static ResourceLocation getNpcTexture(EntityNPCInterface npc){
|
||||
public static ResourceLocation getNpcTexture(EntityNPCInterface npc) {
|
||||
if (npc.textureLocation == null) {
|
||||
if (npc.display.skinType == 0) {
|
||||
if (npc instanceof EntityCustomNpc && ((EntityCustomNpc) npc).modelData.entityClass == null) {
|
||||
@@ -37,22 +37,22 @@ public class NpcTextureUtils {
|
||||
} else {
|
||||
npc.textureLocation = new ResourceLocation(npc.display.texture);
|
||||
}
|
||||
} else if(RenderNPCInterface.LastTextureTick < 5) { //fixes request flood somewhat
|
||||
} else if (RenderNPCInterface.LastTextureTick < 5) { //fixes request flood somewhat
|
||||
return AbstractClientPlayer.locationStevePng;
|
||||
} else if(npc.display.skinType == 1 && npc.display.playerProfile != null) {
|
||||
} else if (npc.display.skinType == 1 && npc.display.playerProfile != null) {
|
||||
Minecraft minecraft = Minecraft.getMinecraft();
|
||||
Map map = minecraft.func_152342_ad().func_152788_a(npc.display.playerProfile);
|
||||
if (map.containsKey(MinecraftProfileTexture.Type.SKIN)){
|
||||
npc.textureLocation = minecraft.func_152342_ad().func_152792_a((MinecraftProfileTexture)map.get(MinecraftProfileTexture.Type.SKIN), MinecraftProfileTexture.Type.SKIN);
|
||||
if (map.containsKey(MinecraftProfileTexture.Type.SKIN)) {
|
||||
npc.textureLocation = minecraft.func_152342_ad().func_152792_a((MinecraftProfileTexture) map.get(MinecraftProfileTexture.Type.SKIN), MinecraftProfileTexture.Type.SKIN);
|
||||
}
|
||||
RenderNPCInterface.LastTextureTick = 0;
|
||||
} else if (npc.display.skinType == 2 || npc.display.skinType == 3) {
|
||||
try {
|
||||
MessageDigest digest = MessageDigest.getInstance("MD5");
|
||||
byte[] hash = digest.digest(npc.display.url.getBytes(StandardCharsets.UTF_8));
|
||||
StringBuilder sb = new StringBuilder(2*hash.length);
|
||||
StringBuilder sb = new StringBuilder(2 * hash.length);
|
||||
for (byte b : hash) {
|
||||
sb.append(String.format("%02x", b&0xff));
|
||||
sb.append(String.format("%02x", b & 0xff));
|
||||
}
|
||||
if (npc.display.skinType == 2) {
|
||||
npc.textureLocation = new ResourceLocation("skins/" + sb);
|
||||
@@ -62,7 +62,8 @@ public class NpcTextureUtils {
|
||||
ClientCacheHandler.getNPCTexture(npc.display.url, true, npc.textureLocation);
|
||||
}
|
||||
RenderNPCInterface.LastTextureTick = 0;
|
||||
} catch(Exception ignored){}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
} else {
|
||||
return AbstractClientPlayer.locationStevePng;
|
||||
}
|
||||
@@ -86,7 +87,7 @@ public class NpcTextureUtils {
|
||||
bufferedimage = bufferedimage.getSubimage(0, 0, totalWidth, 32);
|
||||
}
|
||||
|
||||
ImageDownloadAlt object = new ImageDownloadAlt((File)null, npc.display.texture, SkinManager.field_152793_a, new ImageBufferDownloadAlt(false));
|
||||
ImageDownloadAlt object = new ImageDownloadAlt((File) null, npc.display.texture, SkinManager.field_152793_a, new ImageBufferDownloadAlt(false));
|
||||
object.setBufferedImage(bufferedimage);
|
||||
|
||||
try {
|
||||
@@ -96,7 +97,7 @@ public class NpcTextureUtils {
|
||||
byte[] var13 = hash;
|
||||
int var14 = hash.length;
|
||||
|
||||
for(int var15 = 0; var15 < var14; ++var15) {
|
||||
for (int var15 = 0; var15 < var14; ++var15) {
|
||||
byte b = var13[var15];
|
||||
sb.append(String.format("%02x", b & 255));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user