Files
CustomNPC-Plus/src/main/java/noppes/npcs/client/ClientProxy.java
T

804 lines
35 KiB
Java
Raw Normal View History

2018-09-13 12:03:28 -04:00
package noppes.npcs.client;
2023-01-12 21:33:06 -05:00
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.ObfuscationReflectionHelper;
2025-01-29 13:20:04 -05:00
import kamkeel.npcs.addon.client.DBCClient;
2018-09-13 12:03:28 -04:00
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.particle.EntityFlameFX;
import net.minecraft.client.particle.EntitySmokeFX;
import net.minecraft.client.renderer.RenderGlobal;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.resources.IReloadableResourceManager;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.entity.Entity;
2018-09-13 12:03:28 -04:00
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.item.Item;
2021-10-19 02:49:46 -05:00
import net.minecraft.stats.Achievement;
2018-09-13 12:03:28 -04:00
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ReportedException;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.FakePlayer;
import noppes.npcs.CommonProxy;
import noppes.npcs.CustomItems;
import noppes.npcs.CustomNpcs;
import noppes.npcs.LogWriter;
2023-01-12 21:33:06 -05:00
import noppes.npcs.api.IWorld;
2025-07-23 14:22:52 -04:00
import noppes.npcs.blocks.tiles.TileBanner;
import noppes.npcs.blocks.tiles.TileBarrel;
import noppes.npcs.blocks.tiles.TileBeam;
import noppes.npcs.blocks.tiles.TileBigSign;
import noppes.npcs.blocks.tiles.TileBlockAnvil;
import noppes.npcs.blocks.tiles.TileBook;
import noppes.npcs.blocks.tiles.TileCampfire;
import noppes.npcs.blocks.tiles.TileCandle;
import noppes.npcs.blocks.tiles.TileChair;
import noppes.npcs.blocks.tiles.TileCouchWood;
import noppes.npcs.blocks.tiles.TileCouchWool;
import noppes.npcs.blocks.tiles.TileCrate;
import noppes.npcs.blocks.tiles.TileLamp;
import noppes.npcs.blocks.tiles.TileMailbox;
import noppes.npcs.blocks.tiles.TilePedestal;
import noppes.npcs.blocks.tiles.TileScripted;
import noppes.npcs.blocks.tiles.TileShelf;
import noppes.npcs.blocks.tiles.TileShortLamp;
import noppes.npcs.blocks.tiles.TileSign;
import noppes.npcs.blocks.tiles.TileStool;
import noppes.npcs.blocks.tiles.TileTable;
import noppes.npcs.blocks.tiles.TileTallLamp;
import noppes.npcs.blocks.tiles.TileTombstone;
import noppes.npcs.blocks.tiles.TileWallBanner;
import noppes.npcs.blocks.tiles.TileWeaponRack;
import noppes.npcs.client.controllers.ClientCloneController;
import noppes.npcs.client.controllers.ClientTagMapController;
import noppes.npcs.client.controllers.MusicController;
import noppes.npcs.client.controllers.PresetController;
import noppes.npcs.client.controllers.ScriptSoundController;
2025-01-26 16:48:53 -05:00
import noppes.npcs.client.fx.EntityBigSmokeFX;
2018-09-13 12:03:28 -04:00
import noppes.npcs.client.fx.EntityElementalStaffFX;
import noppes.npcs.client.fx.EntityEnderFX;
import noppes.npcs.client.fx.EntityRainbowFX;
2025-07-23 14:22:52 -04:00
import noppes.npcs.client.gui.GuiBorderBlock;
import noppes.npcs.client.gui.GuiMerchantAdd;
import noppes.npcs.client.gui.GuiNpcDimension;
import noppes.npcs.client.gui.GuiNpcMobSpawner;
import noppes.npcs.client.gui.GuiNpcMobSpawnerMounter;
import noppes.npcs.client.gui.GuiNpcPather;
import noppes.npcs.client.gui.GuiNpcRedstoneBlock;
import noppes.npcs.client.gui.GuiNpcRemoteEditor;
import noppes.npcs.client.gui.GuiNpcWaypoint;
import noppes.npcs.client.gui.GuiScript;
2022-01-12 04:44:08 -06:00
import noppes.npcs.client.gui.custom.GuiCustom;
2025-07-23 14:22:52 -04:00
import noppes.npcs.client.gui.global.GuiNPCManageAnimations;
import noppes.npcs.client.gui.global.GuiNPCManageBanks;
import noppes.npcs.client.gui.global.GuiNPCManageDialogs;
import noppes.npcs.client.gui.global.GuiNPCManageEffects;
import noppes.npcs.client.gui.global.GuiNPCManageFactions;
import noppes.npcs.client.gui.global.GuiNPCManageLinked;
import noppes.npcs.client.gui.global.GuiNPCManageQuest;
import noppes.npcs.client.gui.global.GuiNPCManageTags;
import noppes.npcs.client.gui.global.GuiNPCManageTransporters;
import noppes.npcs.client.gui.global.GuiNpcManageMagic;
import noppes.npcs.client.gui.global.GuiNpcManageRecipes;
import noppes.npcs.client.gui.global.GuiNpcQuestReward;
2025-03-14 20:32:26 -04:00
import noppes.npcs.client.gui.item.GuiNpcMagicBook;
2025-02-13 02:09:50 -05:00
import noppes.npcs.client.gui.item.GuiNpcPaintbrush;
2025-07-23 14:22:52 -04:00
import noppes.npcs.client.gui.mainmenu.GuiNPCGlobalMainMenu;
import noppes.npcs.client.gui.mainmenu.GuiNPCInv;
import noppes.npcs.client.gui.mainmenu.GuiNpcAI;
import noppes.npcs.client.gui.mainmenu.GuiNpcAdvanced;
import noppes.npcs.client.gui.mainmenu.GuiNpcDisplay;
import noppes.npcs.client.gui.mainmenu.GuiNpcStats;
import noppes.npcs.client.gui.player.GuiBigSign;
import noppes.npcs.client.gui.player.GuiCrate;
import noppes.npcs.client.gui.player.GuiMailbox;
import noppes.npcs.client.gui.player.GuiMailmanWrite;
import noppes.npcs.client.gui.player.GuiNPCBankChest;
import noppes.npcs.client.gui.player.GuiNPCTrader;
import noppes.npcs.client.gui.player.GuiNpcAnvil;
import noppes.npcs.client.gui.player.GuiNpcCarpentryBench;
import noppes.npcs.client.gui.player.GuiNpcFollower;
import noppes.npcs.client.gui.player.GuiNpcFollowerHire;
import noppes.npcs.client.gui.player.GuiTransportSelection;
2018-09-13 12:03:28 -04:00
import noppes.npcs.client.gui.player.companion.GuiNpcCompanionInv;
import noppes.npcs.client.gui.player.companion.GuiNpcCompanionStats;
import noppes.npcs.client.gui.player.companion.GuiNpcCompanionTalents;
2025-03-20 02:52:18 -04:00
import noppes.npcs.client.gui.player.modern.BlurEventHandler;
2018-09-13 12:03:28 -04:00
import noppes.npcs.client.gui.questtypes.GuiNpcQuestTypeItem;
2025-07-23 14:22:52 -04:00
import noppes.npcs.client.gui.roles.GuiNpcBankSetup;
import noppes.npcs.client.gui.roles.GuiNpcFollowerSetup;
import noppes.npcs.client.gui.roles.GuiNpcItemGiver;
import noppes.npcs.client.gui.roles.GuiNpcTraderSetup;
import noppes.npcs.client.gui.roles.GuiNpcTransporter;
import noppes.npcs.client.gui.script.GuiScriptBlock;
import noppes.npcs.client.gui.script.GuiScriptGlobal;
2022-05-11 01:10:31 -05:00
import noppes.npcs.client.gui.script.GuiScriptItem;
import noppes.npcs.client.gui.util.script.PackageFinder;
import noppes.npcs.client.gui.util.script.interpreter.type.ClassIndex;
2025-07-23 14:22:52 -04:00
import noppes.npcs.client.model.ModelNPCGolem;
import noppes.npcs.client.model.ModelNpcCrystal;
import noppes.npcs.client.model.ModelNpcDragon;
import noppes.npcs.client.model.ModelNpcSlime;
import noppes.npcs.client.model.ModelSkirtArmor;
import noppes.npcs.client.renderer.NpcItemRenderer;
import noppes.npcs.client.renderer.RenderCustomNpc;
import noppes.npcs.client.renderer.RenderNPCHumanMale;
import noppes.npcs.client.renderer.RenderNPCPony;
import noppes.npcs.client.renderer.RenderNpcCrystal;
import noppes.npcs.client.renderer.RenderNpcDragon;
import noppes.npcs.client.renderer.RenderNpcSlime;
import noppes.npcs.client.renderer.RenderProjectile;
import noppes.npcs.client.renderer.blocks.BlockBannerRenderer;
import noppes.npcs.client.renderer.blocks.BlockBarrelRenderer;
import noppes.npcs.client.renderer.blocks.BlockBeamRenderer;
import noppes.npcs.client.renderer.blocks.BlockBigSignRenderer;
import noppes.npcs.client.renderer.blocks.BlockBloodRenderer;
import noppes.npcs.client.renderer.blocks.BlockBookRenderer;
import noppes.npcs.client.renderer.blocks.BlockBorderRenderer;
import noppes.npcs.client.renderer.blocks.BlockCampfireRenderer;
import noppes.npcs.client.renderer.blocks.BlockCandleRenderer;
import noppes.npcs.client.renderer.blocks.BlockCarpentryBenchRenderer;
import noppes.npcs.client.renderer.blocks.BlockChairRenderer;
import noppes.npcs.client.renderer.blocks.BlockCouchWoodRenderer;
import noppes.npcs.client.renderer.blocks.BlockCouchWoolRenderer;
import noppes.npcs.client.renderer.blocks.BlockCrateRenderer;
import noppes.npcs.client.renderer.blocks.BlockLanternRenderer;
import noppes.npcs.client.renderer.blocks.BlockMailboxRenderer;
import noppes.npcs.client.renderer.blocks.BlockPedestalRenderer;
import noppes.npcs.client.renderer.blocks.BlockScriptedRenderer;
import noppes.npcs.client.renderer.blocks.BlockShelfRenderer;
import noppes.npcs.client.renderer.blocks.BlockShortLampRenderer;
import noppes.npcs.client.renderer.blocks.BlockSignRenderer;
import noppes.npcs.client.renderer.blocks.BlockStoolRenderer;
import noppes.npcs.client.renderer.blocks.BlockTableRenderer;
import noppes.npcs.client.renderer.blocks.BlockTallLampRenderer;
import noppes.npcs.client.renderer.blocks.BlockTombstoneRenderer;
import noppes.npcs.client.renderer.blocks.BlockWallBannerRenderer;
import noppes.npcs.client.renderer.blocks.BlockWeaponRackRenderer;
import noppes.npcs.client.renderer.items.ItemBannerRenderer;
import noppes.npcs.client.renderer.items.ItemBannerWallRenderer;
import noppes.npcs.client.renderer.items.ItemCouchWoolRenderer;
import noppes.npcs.client.renderer.items.ItemCustomRenderer;
import noppes.npcs.client.renderer.items.ItemShortLampRenderer;
import noppes.npcs.client.renderer.items.ItemTallLampRenderer;
import noppes.npcs.client.renderer.items.ItemToolRenderer;
import noppes.npcs.client.renderer.items.ScriptedBlockItemRenderer;
2023-01-07 00:21:08 -05:00
import noppes.npcs.config.ConfigClient;
2025-03-12 05:00:21 -04:00
import noppes.npcs.config.ConfigItem;
2023-01-07 00:21:08 -05:00
import noppes.npcs.config.ConfigMain;
2018-09-13 12:03:28 -04:00
import noppes.npcs.config.StringCache;
import noppes.npcs.constants.EnumGuiType;
2025-07-23 14:22:52 -04:00
import noppes.npcs.containers.ContainerAnvilRepair;
import noppes.npcs.containers.ContainerCarpentryBench;
import noppes.npcs.containers.ContainerCrate;
import noppes.npcs.containers.ContainerCustomGui;
import noppes.npcs.containers.ContainerMail;
import noppes.npcs.containers.ContainerManageBanks;
import noppes.npcs.containers.ContainerManageRecipes;
import noppes.npcs.containers.ContainerNPCBankInterface;
import noppes.npcs.containers.ContainerNPCCompanion;
import noppes.npcs.containers.ContainerNPCFollower;
import noppes.npcs.containers.ContainerNPCFollowerHire;
import noppes.npcs.containers.ContainerNPCFollowerSetup;
import noppes.npcs.containers.ContainerNPCInv;
import noppes.npcs.containers.ContainerNPCTrader;
import noppes.npcs.containers.ContainerNPCTraderSetup;
import noppes.npcs.containers.ContainerNpcItemGiver;
import noppes.npcs.containers.ContainerNpcQuestReward;
import noppes.npcs.containers.ContainerNpcQuestTypeItem;
import noppes.npcs.controllers.data.AnimationData;
import noppes.npcs.controllers.data.PlayerData;
2025-07-23 14:22:52 -04:00
import noppes.npcs.entity.EntityCustomNpc;
import noppes.npcs.entity.EntityNPCGolem;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.entity.EntityNpcCrystal;
import noppes.npcs.entity.EntityNpcDragon;
import noppes.npcs.entity.EntityNpcPony;
import noppes.npcs.entity.EntityNpcSlime;
import noppes.npcs.entity.EntityProjectile;
import noppes.npcs.entity.data.ModelData;
import noppes.npcs.entity.data.ModelPartData;
2025-02-14 12:28:17 -06:00
import noppes.npcs.items.ItemLinked;
2025-02-20 21:40:39 -05:00
import noppes.npcs.items.ItemNpcTool;
2022-05-11 01:10:31 -05:00
import noppes.npcs.items.ItemScripted;
2018-09-13 12:03:28 -04:00
import org.lwjgl.input.Keyboard;
import tconstruct.client.tabs.InventoryTabCustomNpc;
2018-09-13 12:03:28 -04:00
import tconstruct.client.tabs.InventoryTabVanilla;
import tconstruct.client.tabs.TabRegistry;
2023-01-12 21:33:06 -05:00
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Random;
2018-09-13 12:03:28 -04:00
public class ClientProxy extends CommonProxy {
2025-03-13 17:14:45 -04:00
public static KeyBinding NPCButton;
2025-01-26 16:48:53 -05:00
public static final Random RAND = new Random();
2025-03-13 17:14:45 -04:00
public static FontContainer Font;
2021-10-19 02:49:46 -05:00
2025-03-13 17:14:45 -04:00
public void load() {
Font = new FontContainer(ConfigClient.FontType, ConfigClient.FontSize);
createFolders();
new MusicController();
new ScriptSoundController();
2018-09-13 12:03:28 -04:00
2025-03-13 17:14:45 -04:00
RenderingRegistry.registerEntityRenderingHandler(EntityNpcPony.class, new RenderNPCPony());
RenderingRegistry.registerEntityRenderingHandler(EntityNpcCrystal.class, new RenderNpcCrystal(new ModelNpcCrystal(0.5F)));
RenderingRegistry.registerEntityRenderingHandler(EntityNpcDragon.class, new RenderNpcDragon(new ModelNpcDragon(0.0F), 0.5F));
RenderingRegistry.registerEntityRenderingHandler(EntityNpcSlime.class, new RenderNpcSlime(new ModelNpcSlime(16), new ModelNpcSlime(0), 0.25F));
RenderingRegistry.registerEntityRenderingHandler(EntityProjectile.class, new RenderProjectile());
2021-04-27 21:05:00 -04:00
2025-03-13 17:14:45 -04:00
RenderingRegistry.registerEntityRenderingHandler(EntityCustomNpc.class, new RenderCustomNpc());
2021-04-27 21:05:00 -04:00
2025-03-13 17:14:45 -04:00
RenderingRegistry.registerEntityRenderingHandler(EntityNPCGolem.class, new RenderNPCHumanMale(
new ModelNPCGolem(0), new ModelNPCGolem(1F), new ModelNPCGolem(0.5F)));
FMLCommonHandler.instance().bus().register(new ClientTickHandler());
2018-09-13 12:03:28 -04:00
2025-03-13 17:14:45 -04:00
ClientRegistry.bindTileEntitySpecialRenderer(TileBlockAnvil.class, new BlockCarpentryBenchRenderer());
ClientRegistry.bindTileEntitySpecialRenderer(TileMailbox.class, new BlockMailboxRenderer());
2024-03-15 18:22:44 -04:00
ClientRegistry.bindTileEntitySpecialRenderer(TileScripted.class, new BlockScriptedRenderer());
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(CustomItems.scripted), new ScriptedBlockItemRenderer());
2024-03-15 18:22:44 -04:00
RenderingRegistry.registerBlockHandler(new BlockBorderRenderer());
2025-03-20 02:52:18 -04:00
BlurEventHandler blurEventHandler = new BlurEventHandler();
MinecraftForge.EVENT_BUS.register(blurEventHandler);
FMLCommonHandler.instance().bus().register(blurEventHandler);
2025-03-13 17:14:45 -04:00
if (!ConfigItem.DisableExtraBlock) {
ClientRegistry.bindTileEntitySpecialRenderer(TileBanner.class, new BlockBannerRenderer());
ClientRegistry.bindTileEntitySpecialRenderer(TileWallBanner.class, new BlockWallBannerRenderer());
ClientRegistry.bindTileEntitySpecialRenderer(TileTallLamp.class, new BlockTallLampRenderer());
2025-02-12 21:44:14 -05:00
ClientRegistry.bindTileEntitySpecialRenderer(TileShortLamp.class, new BlockShortLampRenderer());
2025-03-13 17:14:45 -04:00
ClientRegistry.bindTileEntitySpecialRenderer(TileChair.class, new BlockChairRenderer());
ClientRegistry.bindTileEntitySpecialRenderer(TileWeaponRack.class, new BlockWeaponRackRenderer());
ClientRegistry.bindTileEntitySpecialRenderer(TileCrate.class, new BlockCrateRenderer());
ClientRegistry.bindTileEntitySpecialRenderer(TileCouchWool.class, new BlockCouchWoolRenderer());
ClientRegistry.bindTileEntitySpecialRenderer(TileCouchWood.class, new BlockCouchWoodRenderer());
ClientRegistry.bindTileEntitySpecialRenderer(TileTable.class, new BlockTableRenderer());
ClientRegistry.bindTileEntitySpecialRenderer(TileCandle.class, new BlockCandleRenderer());
ClientRegistry.bindTileEntitySpecialRenderer(TileLamp.class, new BlockLanternRenderer());
ClientRegistry.bindTileEntitySpecialRenderer(TileStool.class, new BlockStoolRenderer());
ClientRegistry.bindTileEntitySpecialRenderer(TileBigSign.class, new BlockBigSignRenderer());
ClientRegistry.bindTileEntitySpecialRenderer(TileBarrel.class, new BlockBarrelRenderer());
ClientRegistry.bindTileEntitySpecialRenderer(TileCampfire.class, new BlockCampfireRenderer());
ClientRegistry.bindTileEntitySpecialRenderer(TileTombstone.class, new BlockTombstoneRenderer());
ClientRegistry.bindTileEntitySpecialRenderer(TileShelf.class, new BlockShelfRenderer());
ClientRegistry.bindTileEntitySpecialRenderer(TileSign.class, new BlockSignRenderer());
ClientRegistry.bindTileEntitySpecialRenderer(TileBeam.class, new BlockBeamRenderer());
ClientRegistry.bindTileEntitySpecialRenderer(TileBook.class, new BlockBookRenderer());
ClientRegistry.bindTileEntitySpecialRenderer(TilePedestal.class, new BlockPedestalRenderer());
RenderingRegistry.registerBlockHandler(new BlockBloodRenderer());
// Tile Item Renderers
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(CustomItems.couchWool), new ItemCouchWoolRenderer());
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(CustomItems.banner), new ItemBannerRenderer());
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(CustomItems.wallBanner), new ItemBannerWallRenderer());
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(CustomItems.shortLamp), new ItemShortLampRenderer());
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(CustomItems.tallLamp), new ItemTallLampRenderer());
2025-03-13 17:14:45 -04:00
}
Minecraft mc = Minecraft.getMinecraft();
2025-08-27 15:48:10 -04:00
NPCButton = new KeyBinding("NPC Inventory", Keyboard.KEY_N, "key.categories.customnpc");
2025-03-13 17:14:45 -04:00
ClientRegistry.registerKeyBinding(NPCButton);
new PresetController(CustomNpcs.Dir);
if (ConfigMain.EnableUpdateChecker) {
VersionChecker checker = new VersionChecker();
checker.start();
}
ClientCloneController.Instance = new ClientCloneController();
ClientTagMapController.Instance = new ClientTagMapController();
MinecraftForge.EVENT_BUS.register(new ClientEventHandler());
if (ConfigClient.InventoryGuiEnabled) {
MinecraftForge.EVENT_BUS.register(new TabRegistry());
if (TabRegistry.getTabList().isEmpty()) {
TabRegistry.registerTab(new InventoryTabVanilla());
}
TabRegistry.registerTab(new InventoryTabCustomNpc());
}
}
public FakePlayer getCommandPlayer(IWorld world) {
return (FakePlayer) (new EntityCustomNpc(world.getMCWorld())).getFakePlayer();
}
private void createFolders() {
File file = new File(CustomNpcs.Dir, "assets/customnpcs");
if (!file.exists())
file.mkdirs();
File check = new File(file, "sounds");
if (!check.exists())
check.mkdir();
File json = new File(file, "sounds.json");
if (!json.exists()) {
try {
json.createNewFile();
BufferedWriter writer = new BufferedWriter(new FileWriter(json));
writer.write("{\n\n}");
writer.close();
} catch (IOException e) {
}
}
check = new File(file, "textures");
if (!check.exists())
check.mkdir();
File cache = new File(check, "cache");
if (!cache.exists())
cache.mkdir();
((IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager()).registerReloadListener(new CustomNpcResourceListener());
}
@Override
public PlayerData getPlayerData(EntityPlayer player) {
if (player.getUniqueID() == Minecraft.getMinecraft().thePlayer.getUniqueID()) {
if (ClientCacheHandler.playerData != null) {
2024-03-13 13:47:33 -04:00
if (ClientCacheHandler.playerData.player != player) {
ClientCacheHandler.playerData.player = player;
}
2024-03-13 13:47:33 -04:00
return ClientCacheHandler.playerData;
}
2025-03-13 17:14:45 -04:00
}
2024-03-13 13:47:33 -04:00
return null;
2025-03-13 17:14:45 -04:00
}
public AnimationData getClientAnimationData(Entity entity) {
if (entity instanceof EntityPlayer) {
return ClientCacheHandler.playerAnimations.get(entity.getUniqueID());
} else if (entity instanceof EntityNPCInterface) {
return ((EntityNPCInterface) entity).display.animationData;
}
return null;
}
2025-03-13 17:14:45 -04:00
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
if (ID > EnumGuiType.values().length)
return null;
EnumGuiType gui = EnumGuiType.values()[ID];
EntityNPCInterface npc = NoppesUtil.getLastNpc();
Container container = this.getContainer(gui, player, x, y, z, npc);
return getGui(npc, gui, container, x, y, z);
}
2021-10-19 02:49:46 -05:00
2025-03-13 17:14:45 -04:00
private GuiScreen getGui(EntityNPCInterface npc, EnumGuiType gui, Container container, int x, int y, int z) {
if (gui == EnumGuiType.MainMenuDisplay) {
if (npc != null)
return new GuiNpcDisplay(npc);
else
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Unable to find npc"));
} else if (gui == EnumGuiType.MainMenuStats)
return new GuiNpcStats(npc);
2018-09-13 12:03:28 -04:00
2025-03-13 17:14:45 -04:00
else if (gui == EnumGuiType.MainMenuInv)
return new GuiNPCInv(npc, (ContainerNPCInv) container);
2018-09-13 12:03:28 -04:00
2025-03-13 17:14:45 -04:00
else if (gui == EnumGuiType.MainMenuAdvanced)
return new GuiNpcAdvanced(npc);
2018-09-13 12:03:28 -04:00
2025-03-13 17:14:45 -04:00
else if (gui == EnumGuiType.QuestReward)
return new GuiNpcQuestReward(npc, (ContainerNpcQuestReward) container);
2021-10-19 02:49:46 -05:00
2025-03-13 17:14:45 -04:00
else if (gui == EnumGuiType.QuestItem)
return new GuiNpcQuestTypeItem(npc, (ContainerNpcQuestTypeItem) container);
2021-10-19 02:49:46 -05:00
2025-03-13 17:14:45 -04:00
else if (gui == EnumGuiType.MovingPath)
return new GuiNpcPather(npc);
2018-09-13 12:03:28 -04:00
2025-03-13 17:14:45 -04:00
else if (gui == EnumGuiType.ManageFactions)
2025-02-16 04:54:21 -05:00
return new GuiNPCManageFactions(npc);
2021-10-19 02:49:46 -05:00
2024-04-16 02:00:59 -04:00
else if (gui == EnumGuiType.ManageCustomForms)
return DBCClient.Instance.manageCustomForms(npc);
2024-05-31 12:13:17 -04:00
else if (gui == EnumGuiType.ManageCustomAuras)
return DBCClient.Instance.manageCustomAuras(npc);
2025-03-13 17:14:45 -04:00
else if (gui == EnumGuiType.ManageTags)
return new GuiNPCManageTags(npc);
else if (gui == EnumGuiType.ManageAnimations) {
EntityCustomNpc animNpc;
boolean save;
if (npc != null) {
animNpc = new EntityCustomNpc(npc.worldObj);
animNpc.copyDataFrom(npc, true);
animNpc.display.showName = 1;
animNpc.display.showBossBar = 0;
save = true;
} else {
animNpc = new EntityCustomNpc(Minecraft.getMinecraft().theWorld);
animNpc.display.texture = "customnpcs:textures/entity/humanmale/AnimationBody.png";
save = false;
}
return new GuiNPCManageAnimations(animNpc, save);
} else if (gui == EnumGuiType.ManageLinked)
return new GuiNPCManageLinked(npc);
2018-09-13 12:03:28 -04:00
2025-03-03 05:13:07 -05:00
else if (gui == EnumGuiType.ManageMagic)
return new GuiNpcManageMagic(npc);
2025-03-13 17:14:45 -04:00
else if (gui == EnumGuiType.ManageTransport)
return new GuiNPCManageTransporters(npc);
2018-09-13 12:03:28 -04:00
2025-03-13 17:14:45 -04:00
else if (gui == EnumGuiType.ManageRecipes)
return new GuiNpcManageRecipes(npc, (ContainerManageRecipes) container);
2021-10-19 02:49:46 -05:00
2025-03-13 17:14:45 -04:00
else if (gui == EnumGuiType.ManageDialogs)
return new GuiNPCManageDialogs(npc);
2021-10-19 02:49:46 -05:00
2025-03-13 17:14:45 -04:00
else if (gui == EnumGuiType.ManageQuests)
return new GuiNPCManageQuest(npc);
2021-10-19 02:49:46 -05:00
2025-03-13 17:14:45 -04:00
else if (gui == EnumGuiType.ManageBanks)
return new GuiNPCManageBanks(npc, (ContainerManageBanks) container);
2018-09-13 12:03:28 -04:00
2025-02-10 16:38:50 -05:00
else if (gui == EnumGuiType.ManageEffects)
return new GuiNPCManageEffects(npc);
2025-03-13 17:14:45 -04:00
else if (gui == EnumGuiType.MainMenuGlobal)
return new GuiNPCGlobalMainMenu(npc);
2018-09-13 12:03:28 -04:00
2025-03-13 17:14:45 -04:00
else if (gui == EnumGuiType.MainMenuAI)
return new GuiNpcAI(npc);
2018-09-13 12:03:28 -04:00
2025-03-13 17:14:45 -04:00
else if (gui == EnumGuiType.PlayerFollowerHire)
return new GuiNpcFollowerHire(npc, (ContainerNPCFollowerHire) container);
2018-09-13 12:03:28 -04:00
2025-03-13 17:14:45 -04:00
else if (gui == EnumGuiType.PlayerFollower)
return new GuiNpcFollower(npc, (ContainerNPCFollower) container);
2021-10-19 02:49:46 -05:00
2025-03-13 17:14:45 -04:00
else if (gui == EnumGuiType.PlayerTrader)
return new GuiNPCTrader(npc, (ContainerNPCTrader) container);
2021-10-19 02:49:46 -05:00
2025-03-13 17:14:45 -04:00
else if (gui == EnumGuiType.PlayerBankSmall || gui == EnumGuiType.PlayerBankUnlock || gui == EnumGuiType.PlayerBankUprade || gui == EnumGuiType.PlayerBankLarge)
return new GuiNPCBankChest(npc, (ContainerNPCBankInterface) container);
2018-09-13 12:03:28 -04:00
2025-03-13 17:14:45 -04:00
else if (gui == EnumGuiType.PlayerTransporter)
return new GuiTransportSelection(npc);
2021-10-19 02:49:46 -05:00
2025-03-13 17:14:45 -04:00
else if (gui == EnumGuiType.Script)
return new GuiScript(npc);
2021-10-19 02:49:46 -05:00
2025-03-13 17:14:45 -04:00
else if (gui == EnumGuiType.ScriptItem)
return new GuiScriptItem();
2022-05-11 01:10:31 -05:00
2025-03-13 17:14:45 -04:00
else if (gui == EnumGuiType.PlayerCarpentryBench)
return new GuiNpcCarpentryBench((ContainerCarpentryBench) container);
2021-10-19 02:49:46 -05:00
2025-02-09 20:49:45 -05:00
else if (gui == EnumGuiType.PlayerAnvil)
return new GuiNpcAnvil((ContainerAnvilRepair) container);
2025-03-13 17:14:45 -04:00
else if (gui == EnumGuiType.SetupFollower)
return new GuiNpcFollowerSetup(npc, (ContainerNPCFollowerSetup) container);
2021-10-19 02:49:46 -05:00
2025-03-13 17:14:45 -04:00
else if (gui == EnumGuiType.SetupItemGiver)
return new GuiNpcItemGiver(npc, (ContainerNpcItemGiver) container);
2021-10-19 02:49:46 -05:00
2025-03-13 17:14:45 -04:00
else if (gui == EnumGuiType.SetupTrader)
return new GuiNpcTraderSetup(npc, (ContainerNPCTraderSetup) container);
2018-09-13 12:03:28 -04:00
2025-03-13 17:14:45 -04:00
else if (gui == EnumGuiType.SetupTransporter)
return new GuiNpcTransporter(npc);
2021-10-19 02:49:46 -05:00
2025-03-13 17:14:45 -04:00
else if (gui == EnumGuiType.SetupBank)
return new GuiNpcBankSetup(npc);
2021-10-19 02:49:46 -05:00
2025-03-13 17:14:45 -04:00
else if (gui == EnumGuiType.NpcRemote && Minecraft.getMinecraft().currentScreen == null)
return new GuiNpcRemoteEditor();
2018-09-13 12:03:28 -04:00
2025-03-13 17:14:45 -04:00
else if (gui == EnumGuiType.ScriptEvent && Minecraft.getMinecraft().currentScreen == null)
return new GuiScriptGlobal();
2025-03-13 17:14:45 -04:00
else if (gui == EnumGuiType.PlayerMailman)
return new GuiMailmanWrite((ContainerMail) container, x == 1, y == 1);
2021-10-19 02:49:46 -05:00
2025-03-13 17:14:45 -04:00
else if (gui == EnumGuiType.PlayerMailbox)
return new GuiMailbox();
2021-10-19 02:49:46 -05:00
2025-03-13 17:14:45 -04:00
else if (gui == EnumGuiType.MerchantAdd)
return new GuiMerchantAdd();
2021-10-19 02:49:46 -05:00
2025-03-13 17:14:45 -04:00
else if (gui == EnumGuiType.Crate)
return new GuiCrate((ContainerCrate) container);
2018-09-13 12:03:28 -04:00
2025-03-13 17:14:45 -04:00
else if (gui == EnumGuiType.NpcDimensions)
return new GuiNpcDimension();
2021-10-19 02:49:46 -05:00
2025-03-13 17:14:45 -04:00
else if (gui == EnumGuiType.Border)
return new GuiBorderBlock(x, y, z);
2018-09-13 12:03:28 -04:00
2025-03-13 17:14:45 -04:00
else if (gui == EnumGuiType.BigSign)
return new GuiBigSign(x, y, z);
2021-10-19 02:49:46 -05:00
2025-03-13 17:14:45 -04:00
else if (gui == EnumGuiType.RedstoneBlock)
return new GuiNpcRedstoneBlock(x, y, z);
2021-10-19 02:49:46 -05:00
2025-03-13 17:14:45 -04:00
else if (gui == EnumGuiType.Cloner)
return new GuiNpcMobSpawner(x, y, z);
2021-10-19 02:49:46 -05:00
2025-03-13 17:14:45 -04:00
else if (gui == EnumGuiType.MobSpawnerMounter)
return new GuiNpcMobSpawnerMounter(x, y, z);
2018-09-13 12:03:28 -04:00
2025-03-13 17:14:45 -04:00
else if (gui == EnumGuiType.Waypoint)
return new GuiNpcWaypoint(x, y, z);
2021-10-19 02:49:46 -05:00
2025-03-13 17:14:45 -04:00
else if (gui == EnumGuiType.Companion)
return new GuiNpcCompanionStats(npc);
2021-10-19 02:49:46 -05:00
2025-03-13 17:14:45 -04:00
else if (gui == EnumGuiType.CompanionTalent)
return new GuiNpcCompanionTalents(npc);
2021-10-19 02:49:46 -05:00
2025-03-13 17:14:45 -04:00
else if (gui == EnumGuiType.CompanionInv)
return new GuiNpcCompanionInv(npc, (ContainerNPCCompanion) container);
2022-01-12 04:44:08 -06:00
2025-03-13 17:14:45 -04:00
else if (gui == EnumGuiType.CustomGui)
return new GuiCustom((ContainerCustomGui) container);
2022-01-12 04:44:08 -06:00
2025-03-13 17:14:45 -04:00
else if (gui == EnumGuiType.ScriptBlock)
return new GuiScriptBlock(x, y, z);
2025-02-13 02:09:50 -05:00
else if (gui == EnumGuiType.Paintbrush)
return new GuiNpcPaintbrush();
2025-03-14 20:32:26 -04:00
else if (gui == EnumGuiType.MagicBook)
return new GuiNpcMagicBook();
2024-02-19 19:14:51 -05:00
else if (gui == EnumGuiType.GlobalRemote)
return new GuiNPCGlobalMainMenu(null);
2025-03-13 17:14:45 -04:00
return null;
}
@Override
public void openGui(int i, int j, int k, EnumGuiType gui, EntityPlayer player) {
Minecraft minecraft = Minecraft.getMinecraft();
if (minecraft.thePlayer != player)
return;
GuiScreen guiscreen = getGui(null, gui, null, i, j, k);
if (guiscreen != null) {
minecraft.displayGuiScreen(guiscreen);
}
}
@Override
public void openGui(EntityNPCInterface npc, EnumGuiType gui) {
openGui(npc, gui, 0, 0, 0);
}
public void openGui(EntityNPCInterface npc, EnumGuiType gui, int x, int y, int z) {
Minecraft minecraft = Minecraft.getMinecraft();
Container container = this.getContainer(gui, minecraft.thePlayer, x, y, z, npc);
GuiScreen guiscreen = getGui(npc, gui, container, x, y, z);
if (guiscreen != null) {
minecraft.displayGuiScreen(guiscreen);
}
}
public void openGui(EntityPlayer player, Object guiscreen) {
Minecraft minecraft = Minecraft.getMinecraft();
if (!player.worldObj.isRemote || !(guiscreen instanceof GuiScreen))
return;
if (guiscreen != null) {
minecraft.displayGuiScreen((GuiScreen) guiscreen);
}
}
@Override
public void spawnParticle(EntityLivingBase player, String string, Object... ob) {
if (string.equals("Spell")) {
int color = (Integer) ob[0];
int number = (Integer) ob[1];
for (int i = 0; i < number; i++) {
Random rand = player.worldObj.rand;
double x = (rand.nextDouble() - 0.5D) * (double) player.width;
double y = player.getEyeHeight();
double z = (rand.nextDouble() - 0.5D) * (double) player.width;
double f = (rand.nextDouble() - 0.5D) * 2D;
double f1 = -rand.nextDouble();
double f2 = (rand.nextDouble() - 0.5D) * 2D;
Minecraft.getMinecraft().effectRenderer.addEffect(new EntityElementalStaffFX(player, x, y, z, f, f1, f2, color));
}
} else if (string.equals("ModelData")) {
ModelData data = (ModelData) ob[0];
ModelPartData particles = (ModelPartData) ob[1];
EntityCustomNpc npc = (EntityCustomNpc) player;
Minecraft minecraft = Minecraft.getMinecraft();
double height = npc.getYOffset() + data.getBodyY();
Random rand = npc.getRNG();
if (particles.type == 0) {
for (int i = 0; i < 2; i++) {
EntityEnderFX fx = new EntityEnderFX(npc, (rand.nextDouble() - 0.5D) * (double) player.width, (rand.nextDouble() * (double) player.height) - height - 0.25D, (rand.nextDouble() - 0.5D) * (double) player.width, (rand.nextDouble() - 0.5D) * 2D, -rand.nextDouble(), (rand.nextDouble() - 0.5D) * 2D, particles);
minecraft.effectRenderer.addEffect(fx);
}
} else if (particles.type == 1) {
for (int i = 0; i < 2; i++) {
double x = player.posX + (rand.nextDouble() - 0.5D) * 0.9;
double y = (player.posY + rand.nextDouble() * 1.9) - 0.25D - height;
double z = player.posZ + (rand.nextDouble() - 0.5D) * 0.9;
double f = (rand.nextDouble() - 0.5D) * 2D;
double f1 = -rand.nextDouble();
double f2 = (rand.nextDouble() - 0.5D) * 2D;
minecraft.effectRenderer.addEffect(new EntityRainbowFX(player.worldObj, x, y, z, f, f1, f2));
}
}
}
}
private ModelSkirtArmor model = new ModelSkirtArmor();
public ModelBiped getSkirtModel() {
return model;
}
public boolean hasClient() {
return true;
}
public EntityPlayer getPlayer() {
return Minecraft.getMinecraft().thePlayer;
}
@Override
public void registerItem(Item item) {
2025-02-14 12:28:17 -06:00
if (item instanceof ItemScripted || item instanceof ItemLinked) {
2025-03-13 17:14:45 -04:00
MinecraftForgeClient.registerItemRenderer(item, new ItemCustomRenderer());
} else if (item instanceof ItemNpcTool) {
2025-02-22 01:21:35 -05:00
MinecraftForgeClient.registerItemRenderer(item, new ItemToolRenderer());
2025-03-13 17:14:45 -04:00
} else {
MinecraftForgeClient.registerItemRenderer(item, new NpcItemRenderer());
}
}
public static void bindTexture(ResourceLocation location) {
try {
if (location == null)
return;
TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
if (location != null)
texturemanager.bindTexture((ResourceLocation) location);
} catch (NullPointerException ex) {
} catch (ReportedException ex) {
}
}
@Override
public void spawnParticle(String particle, double x, double y, double z,
double motionX, double motionY, double motionZ, float scale) {
RenderGlobal render = Minecraft.getMinecraft().renderGlobal;
EntityFX fx = render.doSpawnParticle(particle, x, y, z, motionX, motionY, motionZ);
if (fx == null)
return;
if (particle.equals("flame")) {
ObfuscationReflectionHelper.setPrivateValue(EntityFlameFX.class, (EntityFlameFX) fx, scale, 0);
} else if (particle.equals("smoke")) {
ObfuscationReflectionHelper.setPrivateValue(EntitySmokeFX.class, (EntitySmokeFX) fx, scale, 0);
}
}
2021-10-19 02:49:46 -05:00
2025-01-26 16:48:53 -05:00
@Override
2025-03-13 17:14:45 -04:00
public void generateBigSmokeParticles(World world, int x, int y, int z, boolean signalFire) {
if (RAND.nextFloat() < 0.11F) {
2025-01-26 16:48:53 -05:00
float[] colours = new float[0];
for (int i = 0; i < RAND.nextInt(2) + 1; ++i)
Minecraft.getMinecraft().effectRenderer.addEffect(new EntityBigSmokeFX(world, x, y, z, signalFire, colours));
}
}
2025-03-13 17:14:45 -04:00
@Override
public String getAchievementDesc(Achievement achievement) {
return achievement.getDescription();
}
@Override
public boolean isGUIOpen() {
return Minecraft.getMinecraft().currentScreen != null;
}
public void buildPackageIndex() {
try {
PackageFinder.init(Thread.currentThread().getContextClassLoader());
ClassIndex.init();
} catch (IOException e) {
}
}
2025-03-13 17:14:45 -04:00
public static class FontContainer {
public StringCache textFont = null;
public boolean useCustomFont = true;
private FontContainer() {
}
public FontContainer(String fontType, int fontSize) {
textFont = new StringCache();
textFont.setDefaultFont("Arial", fontSize, true);
useCustomFont = !fontType.equalsIgnoreCase("minecraft");
try {
if (!useCustomFont || fontType.isEmpty() || fontType.equalsIgnoreCase("default"))
textFont.setCustomFont(new ResourceLocation("customnpcs", "OpenSans.ttf"), fontSize, true);
else
textFont.setDefaultFont(fontType, fontSize, true);
} catch (Exception e) {
LogWriter.info("Failed loading font so using Arial");
}
}
public int height() {
if (useCustomFont)
return textFont.fontHeight;
return Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT;
}
public int width(String text) {
if (useCustomFont)
return textFont.getStringWidth(text);
return Minecraft.getMinecraft().fontRenderer.getStringWidth(text);
}
public FontContainer copy() {
FontContainer font = new FontContainer();
font.textFont = textFont;
font.useCustomFont = useCustomFont;
return font;
}
public void drawString(String text, int x, int y, int color) {
if (useCustomFont) {
textFont.renderString(text, x, y, color, true);
textFont.renderString(text, x, y, color, false);
} else {
Minecraft.getMinecraft().fontRenderer.drawStringWithShadow(text, x, y, color);
}
}
public String getName() {
if (!useCustomFont)
return "Minecraft";
return textFont.usedFont().getFontName();
}
}
2024-02-15 17:54:28 -05:00
}