mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-18 09:09:08 +00:00
Server-side compatibility changes
This commit is contained in:
1 parent
c8f917d8fb
commit
f88cbb8b51
9 files changed
+230
-212
No files matched your search
@@ -21,6 +21,7 @@ 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;
|
||||
@@ -158,9 +159,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();
|
||||
@@ -210,43 +211,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());
|
||||
}
|
||||
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 {
|
||||
@@ -261,7 +262,7 @@ 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();
|
||||
@@ -284,7 +285,7 @@ public class ClientProxy extends CommonProxy {
|
||||
|
||||
@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];
|
||||
@@ -293,6 +294,8 @@ 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)
|
||||
@@ -311,16 +314,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);
|
||||
|
||||
@@ -329,15 +332,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);
|
||||
@@ -350,37 +353,37 @@ 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();
|
||||
|
||||
@@ -389,48 +392,48 @@ public class ClientProxy extends CommonProxy {
|
||||
|
||||
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);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void openGui(int i, int j, int k, EnumGuiType gui, EntityPlayer player) {
|
||||
Minecraft minecraft = Minecraft.getMinecraft();
|
||||
@@ -438,7 +441,7 @@ public class ClientProxy extends CommonProxy {
|
||||
return;
|
||||
|
||||
GuiScreen guiscreen = getGui(null, gui, null, i, j, k);
|
||||
|
||||
|
||||
|
||||
if (guiscreen != null) {
|
||||
minecraft.displayGuiScreen(guiscreen);
|
||||
@@ -469,7 +472,7 @@ public class ClientProxy extends CommonProxy {
|
||||
if (guiscreen != null) {
|
||||
minecraft.displayGuiScreen((GuiScreen)guiscreen);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -477,18 +480,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];
|
||||
@@ -502,21 +505,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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -529,7 +532,7 @@ public class ClientProxy extends CommonProxy {
|
||||
public boolean hasClient() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public EntityPlayer getPlayer() {
|
||||
return Minecraft.getMinecraft().thePlayer;
|
||||
}
|
||||
@@ -544,54 +547,58 @@ 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);
|
||||
}
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
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");
|
||||
}
|
||||
@@ -602,7 +609,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);
|
||||
@@ -632,4 +639,4 @@ public class ClientProxy extends CommonProxy {
|
||||
return textFont.usedFont().getFontName();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user