Original CNPC Branch

This commit is contained in:
KAMKEEL committed 2022-02-05 18:02:35 -05:00
1 parent 6d6daeb345
commit 39b7f805b3
1227 files changed
+2259 -39282

No files matched your search

+147 -150
View File
@@ -21,14 +21,12 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.item.Item;
import net.minecraft.stats.Achievement;
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.CustomNpcs;
import noppes.npcs.LogWriter;
@@ -64,8 +62,16 @@ import noppes.npcs.client.controllers.PresetController;
import noppes.npcs.client.fx.EntityElementalStaffFX;
import noppes.npcs.client.fx.EntityEnderFX;
import noppes.npcs.client.fx.EntityRainbowFX;
import noppes.npcs.client.gui.*;
import noppes.npcs.client.gui.custom.GuiCustom;
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;
import noppes.npcs.client.gui.global.GuiNPCManageBanks;
import noppes.npcs.client.gui.global.GuiNPCManageDialogs;
import noppes.npcs.client.gui.global.GuiNPCManageFactions;
@@ -99,9 +105,19 @@ 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.GuiScriptGlobal;
import noppes.npcs.client.model.*;
import noppes.npcs.client.renderer.*;
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;
@@ -129,11 +145,31 @@ import noppes.npcs.client.renderer.blocks.BlockWallBannerRenderer;
import noppes.npcs.client.renderer.blocks.BlockWeaponRackRenderer;
import noppes.npcs.config.StringCache;
import noppes.npcs.constants.EnumGuiType;
import noppes.npcs.containers.*;
import noppes.npcs.controllers.PlayerData;
import noppes.npcs.entity.*;
import noppes.npcs.containers.ContainerCarpentryBench;
import noppes.npcs.containers.ContainerCrate;
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.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.scripted.interfaces.IWorld;
import org.lwjgl.input.Keyboard;
import tconstruct.client.tabs.InventoryTabFactions;
@@ -147,9 +183,9 @@ import cpw.mods.fml.common.ObfuscationReflectionHelper;
public class ClientProxy extends CommonProxy {
public static KeyBinding QuestLog;
public static FontContainer Font;
public void load() {
Font = new FontContainer(CustomNpcs.FontType, CustomNpcs.FontSize);
createFolders();
@@ -162,10 +198,7 @@ public class ClientProxy extends CommonProxy {
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());
RenderingRegistry.registerEntityRenderingHandler(EntityCustomNpc.class, new RenderCustomNpc());
RenderingRegistry.registerEntityRenderingHandler(EntityNPCGolem.class, new RenderNPCHumanMale(
new ModelNPCGolem(0), new ModelNPCGolem(1F), new ModelNPCGolem(0.5F)));
FMLCommonHandler.instance().bus().register(new ClientTickHandler());
@@ -173,7 +206,7 @@ public class ClientProxy extends CommonProxy {
ClientRegistry.bindTileEntitySpecialRenderer(TileBlockAnvil.class, new BlockCarpentryBenchRenderer());
ClientRegistry.bindTileEntitySpecialRenderer(TileMailbox.class, new BlockMailboxRenderer());
RenderingRegistry.registerBlockHandler(new BlockBorderRenderer());
if(!CustomNpcs.DisableExtraBlock){
ClientRegistry.bindTileEntitySpecialRenderer(TileBanner.class, new BlockBannerRenderer());
ClientRegistry.bindTileEntitySpecialRenderer(TileWallBanner.class, new BlockWallBannerRenderer());
@@ -199,47 +232,43 @@ public class ClientProxy extends CommonProxy {
RenderingRegistry.registerBlockHandler(new BlockBloodRenderer());
}
Minecraft mc = Minecraft.getMinecraft();
QuestLog = new KeyBinding("Quest Log", Keyboard.KEY_L, "key.categories.gameplay");
ClientRegistry.registerKeyBinding(QuestLog);
mc.gameSettings.loadOptions();
new PresetController(CustomNpcs.Dir);
if(CustomNpcs.EnableUpdateChecker){
VersionChecker checker = new VersionChecker();
checker.start();
}
ClientCloneController.Instance = new ClientCloneController();
MinecraftForge.EVENT_BUS.register(new ClientEventHandler());
if(CustomNpcs.InventoryGuiEnabled){
MinecraftForge.EVENT_BUS.register(new TabRegistry());
if (TabRegistry.getTabList().size() < 2){
TabRegistry.registerTab(new InventoryTabVanilla());
}
TabRegistry.registerTab(new InventoryTabFactions());
TabRegistry.registerTab(new InventoryTabQuests());
}
}
public FakePlayer getCommandPlayer(IWorld world) {
return (FakePlayer)(new EntityCustomNpc(world.getMCWorld())).getFakePlayer();
MinecraftForge.EVENT_BUS.register(new ClientEventHandler());
if(CustomNpcs.InventoryGuiEnabled){
MinecraftForge.EVENT_BUS.register(new TabRegistry());
if (TabRegistry.getTabList().size() < 2){
TabRegistry.registerTab(new InventoryTabVanilla());
}
TabRegistry.registerTab(new InventoryTabFactions());
TabRegistry.registerTab(new InventoryTabQuests());
}
}
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 {
@@ -254,30 +283,16 @@ public class ClientProxy extends CommonProxy {
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());
}
public static PlayerData playerData = new PlayerData();
@Override
public PlayerData getPlayerData(EntityPlayer player) {
if (player.getUniqueID() == Minecraft.getMinecraft().thePlayer.getUniqueID()) {
if (playerData.player != player) {
playerData.player = player;
}
return playerData;
} else {
return null;
}
}
@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];
@@ -286,8 +301,6 @@ public class ClientProxy extends CommonProxy {
return getGui(npc, gui, container, x, y, z);
}
private GuiScreen getGui(EntityNPCInterface npc, EnumGuiType gui, Container container, int x, int y, int z) {
if (gui == EnumGuiType.MainMenuDisplay){
if(npc != null)
@@ -306,16 +319,16 @@ public class ClientProxy extends CommonProxy {
else if(gui == EnumGuiType.QuestReward)
return new GuiNpcQuestReward(npc, (ContainerNpcQuestReward) container);
else if(gui == EnumGuiType.QuestItem)
return new GuiNpcQuestTypeItem(npc, (ContainerNpcQuestTypeItem) container);
else if (gui == EnumGuiType.MovingPath)
return new GuiNpcPather(npc);
else if (gui == EnumGuiType.ManageFactions)
return new GuiNPCManageFactions(npc);
else if (gui == EnumGuiType.ManageLinked)
return new GuiNPCManageLinkedNpc(npc);
@@ -324,15 +337,15 @@ public class ClientProxy extends CommonProxy {
else if (gui == EnumGuiType.ManageRecipes)
return new GuiNpcManageRecipes(npc,(ContainerManageRecipes) container);
else if (gui == EnumGuiType.ManageDialogs)
return new GuiNPCManageDialogs(npc);
else if (gui == EnumGuiType.ManageQuests)
return new GuiNPCManageQuest(npc);
else if(gui == EnumGuiType.ManageBanks)
return new GuiNPCManageBanks(npc,(ContainerManageBanks) container);
return new GuiNPCManageBanks(npc,(ContainerManageBanks) container);
else if (gui == EnumGuiType.MainMenuGlobal)
return new GuiNPCGlobalMainMenu(npc);
@@ -345,91 +358,84 @@ public class ClientProxy extends CommonProxy {
else if (gui == EnumGuiType.PlayerFollower)
return new GuiNpcFollower(npc, (ContainerNPCFollower) container);
else if(gui == EnumGuiType.PlayerTrader)
return new GuiNPCTrader(npc, (ContainerNPCTrader) container);
else if(gui == EnumGuiType.PlayerBankSmall || gui == EnumGuiType.PlayerBankUnlock || gui == EnumGuiType.PlayerBankUprade || gui == EnumGuiType.PlayerBankLarge)
return new GuiNPCBankChest(npc, (ContainerNPCBankInterface) container);
else if(gui == EnumGuiType.PlayerTransporter)
return new GuiTransportSelection(npc);
else if(gui == EnumGuiType.Script)
return new GuiScript(npc);
else if(gui == EnumGuiType.PlayerAnvil)
return new GuiNpcCarpentryBench((ContainerCarpentryBench) container);
else if (gui == EnumGuiType.SetupFollower)
return new GuiNpcFollowerSetup(npc, (ContainerNPCFollowerSetup) container);
else if (gui == EnumGuiType.SetupItemGiver)
return new GuiNpcItemGiver(npc, (ContainerNpcItemGiver) container);
else if(gui == EnumGuiType.SetupTrader)
return new GuiNpcTraderSetup(npc, (ContainerNPCTraderSetup) container);
else if(gui == EnumGuiType.SetupTransporter)
return new GuiNpcTransporter(npc);
else if(gui == EnumGuiType.SetupBank)
return new GuiNpcBankSetup(npc);
else if(gui == EnumGuiType.NpcRemote && Minecraft.getMinecraft().currentScreen == null)
return new GuiNpcRemoteEditor();
else if(gui == EnumGuiType.ScriptEvent && Minecraft.getMinecraft().currentScreen == null)
return new GuiScriptGlobal();
else if(gui == EnumGuiType.PlayerMailman)
return new GuiMailmanWrite((ContainerMail) container, x == 1, y == 1);
else if(gui == EnumGuiType.PlayerMailbox)
return new GuiMailbox();
else if(gui == EnumGuiType.MerchantAdd)
return new GuiMerchantAdd();
else if(gui == EnumGuiType.Crate)
return new GuiCrate((ContainerCrate)container);
else if(gui == EnumGuiType.NpcDimensions)
return new GuiNpcDimension();
else if(gui == EnumGuiType.Border)
return new GuiBorderBlock(x, y, z);
else if(gui == EnumGuiType.BigSign)
return new GuiBigSign(x, y, z);
else if (gui == EnumGuiType.RedstoneBlock)
return new GuiNpcRedstoneBlock(x, y, z);
else if(gui == EnumGuiType.MobSpawner)
return new GuiNpcMobSpawner(x, y, z);
else if(gui == EnumGuiType.MobSpawnerMounter)
return new GuiNpcMobSpawnerMounter(x, y, z);
else if (gui == EnumGuiType.Waypoint)
return new GuiNpcWaypoint(x, y, z);
else if (gui == EnumGuiType.Companion)
return new GuiNpcCompanionStats(npc);
else if (gui == EnumGuiType.CompanionTalent)
return new GuiNpcCompanionTalents(npc);
else if (gui == EnumGuiType.CompanionInv)
return new GuiNpcCompanionInv(npc, (ContainerNPCCompanion) container);
else if (gui == EnumGuiType.CustomGui)
return new GuiCustom((ContainerCustomGui)container);
return null;
}
@Override
public void openGui(int i, int j, int k, EnumGuiType gui, EntityPlayer player) {
Minecraft minecraft = Minecraft.getMinecraft();
@@ -437,7 +443,7 @@ public class ClientProxy extends CommonProxy {
return;
GuiScreen guiscreen = getGui(null, gui, null, i, j, k);
if (guiscreen != null) {
minecraft.displayGuiScreen(guiscreen);
@@ -468,7 +474,7 @@ public class ClientProxy extends CommonProxy {
if (guiscreen != null) {
minecraft.displayGuiScreen((GuiScreen)guiscreen);
}
}
@Override
@@ -476,18 +482,18 @@ public class ClientProxy extends CommonProxy {
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;
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));
}
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];
@@ -501,21 +507,21 @@ public class ClientProxy extends CommonProxy {
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));
}
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));
}
}
}
}
@@ -528,7 +534,7 @@ public class ClientProxy extends CommonProxy {
public boolean hasClient() {
return true;
}
public EntityPlayer getPlayer() {
return Minecraft.getMinecraft().thePlayer;
}
@@ -543,63 +549,54 @@ public class ClientProxy extends CommonProxy {
try{
if(location == null)
return;
TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
if(location != null)
texturemanager.bindTexture((ResourceLocation) location);
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) {
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);
}
}
@Override
public String getAchievementDesc(Achievement achievement) {
return achievement.getDescription();
}
@Override
public boolean isGUIOpen(){
return Minecraft.getMinecraft().currentScreen != null;
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);
}
}
public static class FontContainer {
private 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);
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");
}
@@ -610,7 +607,7 @@ public class ClientProxy extends CommonProxy {
return textFont.fontHeight;
return Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT;
}
public int width(String text){
if(useCustomFont)
return textFont.getStringWidth(text);
@@ -640,4 +637,4 @@ public class ClientProxy extends CommonProxy {
return textFont.usedFont().getFontName();
}
}
}
}