From d512d67679c51ffd224801daaccce8fad54bfc1a Mon Sep 17 00:00:00 2001 From: mDiyo Date: Sun, 28 Jul 2013 19:56:01 -0700 Subject: [PATCH] Fix blue slimes, heart canisters --- .../tinker/sounds}/frypan_hit.ogg | Bin .../tinker/sounds}/launcher_clank.ogg | Bin .../tinker/sounds}/little_saw.ogg | Bin tconstruct/TConstruct.java | 3 +- tconstruct/client/TClientEvents.java | 39 ++++++++----- tconstruct/client/TClientTickHandler.java | 17 ++++-- tconstruct/client/TProxyClient.java | 4 ++ tconstruct/client/entity/SlimeRender.java | 12 ++-- tconstruct/inventory/SlotTool.java | 2 +- .../inventory/ToolStationContainer.java | 2 +- tconstruct/items/DiamondApple.java | 5 ++ tconstruct/items/tools/FryingPan.java | 4 +- tconstruct/items/tools/PotionLauncher.java | 2 +- tconstruct/util/player/ArmorExtended.java | 52 ++++++++++++++++-- tconstruct/util/player/TPlayerStats.java | 2 +- 15 files changed, 108 insertions(+), 36 deletions(-) rename {sounds => assets/tinker/sounds}/frypan_hit.ogg (100%) rename {sounds => assets/tinker/sounds}/launcher_clank.ogg (100%) rename {sounds => assets/tinker/sounds}/little_saw.ogg (100%) diff --git a/sounds/frypan_hit.ogg b/assets/tinker/sounds/frypan_hit.ogg similarity index 100% rename from sounds/frypan_hit.ogg rename to assets/tinker/sounds/frypan_hit.ogg diff --git a/sounds/launcher_clank.ogg b/assets/tinker/sounds/launcher_clank.ogg similarity index 100% rename from sounds/launcher_clank.ogg rename to assets/tinker/sounds/launcher_clank.ogg diff --git a/sounds/little_saw.ogg b/assets/tinker/sounds/little_saw.ogg similarity index 100% rename from sounds/little_saw.ogg rename to assets/tinker/sounds/little_saw.ogg diff --git a/tconstruct/TConstruct.java b/tconstruct/TConstruct.java index 15ef184a..cdfcce31 100644 --- a/tconstruct/TConstruct.java +++ b/tconstruct/TConstruct.java @@ -41,7 +41,7 @@ import cpw.mods.fml.common.registry.VillagerRegistry; * @dependencies: IC2 API, MFR API */ -@Mod(modid = "TConstruct", name = "TConstruct", version = "1.6.2_1.4.3", dependencies = "required-after:Forge@[7.7.1.687,)") +@Mod(modid = "TConstruct", name = "TConstruct", version = "1.6.2_1.4.dev.24", dependencies = "required-after:Forge@[7.7.1.687,)") @NetworkMod(serverSideRequired = false, clientSideRequired = true, channels = { "TConstruct" }, packetHandler = tconstruct.util.network.TPacketHandler.class) public class TConstruct { @@ -102,7 +102,6 @@ public class TConstruct GameRegistry.registerCraftingHandler(new TCraftingHandler()); NetworkRegistry.instance().registerGuiHandler(instance, proxy); - VillagerRegistry.instance().registerVillagerSkin(78943, new ResourceLocation("/mods/tinker/textures/mob/villagertools.png")); VillagerRegistry.instance().registerVillageTradeHandler(78943, new TVillageTrades()); if (PHConstruct.addToVillages) { diff --git a/tconstruct/client/TClientEvents.java b/tconstruct/client/TClientEvents.java index 21d70db4..9f701aec 100644 --- a/tconstruct/client/TClientEvents.java +++ b/tconstruct/client/TClientEvents.java @@ -2,6 +2,7 @@ package tconstruct.client; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; +import net.minecraft.client.audio.SoundPool; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.model.ModelBiped; import net.minecraft.client.renderer.Tessellator; @@ -44,19 +45,27 @@ public class TClientEvents }*/ /* Sounds */ - /*@ForgeSubscribe + + /*boolean initSounds; + + @ForgeSubscribe public void onSound (SoundLoadEvent event) { - try + if (!initSounds) { - event.manager.soundPoolSounds.addSound("sounds/frypan_hit.ogg", TConstruct.class.getResource("/sounds/frypan_hit.ogg")); - event.manager.soundPoolSounds.addSound("sounds/little_saw.ogg", TConstruct.class.getResource("/sounds/little_saw.ogg")); - event.manager.soundPoolSounds.addSound("sounds/launcher_clank.ogg", TConstruct.class.getResource("/sounds/launcher_clank.ogg")); - System.out.println("[TConstruct] Successfully loaded sounds."); - } - catch (Exception e) - { - System.err.println("[TConstruct] Failed to register one or more sounds"); + initSounds = true; + try + { + SoundPool soundpool = event.manager.soundPoolSounds; + soundpool.addSound("tinker:frypan_hit.ogg"); + soundpool.addSound("tinker:little_saw.ogg"); + soundpool.addSound("tinker:launcher_clank.ogg"); + System.out.println("[TConstruct] Successfully loaded sounds."); + } + catch (Exception e) + { + System.err.println("[TConstruct] Failed to register one or more sounds"); + } } }*/ @@ -77,7 +86,9 @@ public class TClientEvents lava.setIcons(Block.waterStill.getIcon(0, 0), Block.waterStill.getIcon(2, 0)); } } - private static final ResourceLocation background = new ResourceLocation("tinker", "textures/gui/newhearts.png"); + + private static final ResourceLocation hearts = new ResourceLocation("tinker", "textures/gui/newhearts.png"); + private static final ResourceLocation icons = new ResourceLocation("textures/gui/icons.png"); /* HUD */ @ForgeSubscribe @@ -99,9 +110,9 @@ public class TClientEvents /*if (event.type == RenderGameOverlayEvent.ElementType.HEALTH) { - this.mc.func_110434_K().func_110577_a(background); + this.mc.func_110434_K().func_110577_a(hearts); - int hp = mc.thePlayer.getHealth(); + int hp = MathHelper.ceiling_float_int(this.mc.thePlayer.func_110143_aJ()); for (int iter = 0; iter < hp / 20; iter++) { int renderHearts = (hp - 20 * (iter + 1)) / 2; @@ -117,7 +128,7 @@ public class TClientEvents } } - this.mc.renderEngine.bindTexture("/gui/icons.png"); + this.mc.func_110434_K().func_110577_a(icons); }*/ /*if (event.type == RenderGameOverlayEvent.ElementType.HOTBAR) diff --git a/tconstruct/client/TClientTickHandler.java b/tconstruct/client/TClientTickHandler.java index 255aebdd..069525d9 100644 --- a/tconstruct/client/TClientTickHandler.java +++ b/tconstruct/client/TClientTickHandler.java @@ -2,12 +2,15 @@ package tconstruct.client; import java.util.EnumSet; -import tconstruct.common.TContent; - import net.minecraft.block.Block; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.Tessellator; +import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import tconstruct.common.TContent; import cpw.mods.fml.common.ITickHandler; import cpw.mods.fml.common.TickType; @@ -18,6 +21,8 @@ public class TClientTickHandler implements ITickHandler int zLevel = 0; int ticks = 0; + private static final ResourceLocation hearts = new ResourceLocation("tinker", "textures/gui/newhearts.png"); + @Override public void tickEnd (EnumSet type, Object... tickData) { @@ -33,9 +38,11 @@ public class TClientTickHandler implements ITickHandler int scaledHeight = scaledresolution.getScaledHeight(); int xBasePos = scaledWidth / 2 - 91; int yBasePos = scaledHeight - 39; - this.mc.renderEngine.bindTexture("/mods/tinker/textures/gui/newhearts.png"); - - int hp = player.getHealth(); + this.mc.func_110434_K().func_110577_a(hearts); + //this.mc.renderEngine.bindTexture("/mods/tinker/textures/gui/newhearts.png"); + + int hp = MathHelper.ceiling_float_int(this.mc.thePlayer.func_110143_aJ());//(int) player.func_110148_a(SharedMonsterAttributes.field_111267_a).func_111125_b();//player.getHealth(); + //System.out.println("hp: "+hp); for (int iter = 0; iter < hp / 20; iter++) { int renderHearts = (hp - 20*(iter+1)) / 2; diff --git a/tconstruct/client/TProxyClient.java b/tconstruct/client/TProxyClient.java index 6455a6b9..0cce7159 100644 --- a/tconstruct/client/TProxyClient.java +++ b/tconstruct/client/TProxyClient.java @@ -150,12 +150,14 @@ import tconstruct.library.crafting.ToolBuilder; import tconstruct.library.tools.ToolCore; import tconstruct.util.player.ArmorExtended; import tconstruct.util.player.KnapsackInventory; +import tconstruct.util.player.TPlayerStats; import com.google.common.collect.Lists; import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.common.registry.TickRegistry; +import cpw.mods.fml.common.registry.VillagerRegistry; import cpw.mods.fml.relauncher.Side; public class TProxyClient extends TProxyCommon @@ -167,6 +169,7 @@ public class TProxyClient extends TProxyCommon public static ArmorExtended armorExtended = new ArmorExtended(); public static KnapsackInventory knapsack = new KnapsackInventory(); + public static TPlayerStats stats = new TPlayerStats(); @Override public Object getClientGuiElement (int ID, EntityPlayer player, World world, int x, int y, int z) @@ -406,6 +409,7 @@ public class TProxyClient extends TProxyCommon //RenderingRegistry.registerEntityRenderingHandler(net.minecraft.entity.player.EntityPlayer.class, new PlayerArmorRender()); // <-- Works, woo! MinecraftForgeClient.registerItemRenderer(TContent.shortbow.itemID, new CustomBowRenderer()); + VillagerRegistry.instance().registerVillagerSkin(78943, new ResourceLocation("/mods/tinker/textures/mob/villagertools.png")); addRenderMappings(); addToolButtons(); diff --git a/tconstruct/client/entity/SlimeRender.java b/tconstruct/client/entity/SlimeRender.java index a1a286c7..fe96fddf 100644 --- a/tconstruct/client/entity/SlimeRender.java +++ b/tconstruct/client/entity/SlimeRender.java @@ -4,19 +4,20 @@ import net.minecraft.client.model.ModelBase; import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.boss.BossStatus; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; import tconstruct.entity.BlueSlime; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class SlimeRender extends RenderLiving { + static final ResourceLocation texture = new ResourceLocation("tinker", "textures/mob/slimeedible.png"); private ModelBase scaleAmount; public SlimeRender(ModelBase par1ModelBase, ModelBase par2ModelBase, float par3) @@ -25,6 +26,7 @@ public class SlimeRender extends RenderLiving this.scaleAmount = par2ModelBase; } + @Override public void doRenderLiving (EntityLiving par1EntityLiving, double par2, double par4, double par6, float par8, float par9) { super.doRenderLiving(par1EntityLiving, par2, par4, par6, par8, par9); @@ -81,7 +83,8 @@ public class SlimeRender extends RenderLiving * Allows the render to do any OpenGL state modifications necessary before the model is rendered. Args: * entityLiving, partialTickTime */ - protected void preRenderCallback (EntityLiving par1EntityLiving, float par2) + @Override + protected void preRenderCallback (EntityLivingBase par1EntityLiving, float par2) { this.scaleSlime((BlueSlime) par1EntityLiving, par2); } @@ -89,7 +92,8 @@ public class SlimeRender extends RenderLiving /** * Queries whether should render the specified pass or not. */ - protected int shouldRenderPass (EntityLiving par1EntityLiving, int par2, float par3) + @Override + protected int shouldRenderPass (EntityLivingBase par1EntityLiving, int par2, float par3) { return this.shouldSlimeRenderPass((BlueSlime) par1EntityLiving, par2, par3); } @@ -99,6 +103,4 @@ public class SlimeRender extends RenderLiving { return texture; } - - static final ResourceLocation texture = new ResourceLocation("tinker", "textures/mob/slimeedible.png"); } diff --git a/tconstruct/inventory/SlotTool.java b/tconstruct/inventory/SlotTool.java index 14b32038..d7d6ab63 100644 --- a/tconstruct/inventory/SlotTool.java +++ b/tconstruct/inventory/SlotTool.java @@ -64,7 +64,7 @@ public class SlotTool extends Slot int amount = inventory.getStackInSlot(1).getItem() instanceof ToolCore ? stack.stackSize : 1; inventory.decrStackSize(1, amount); if (!player.worldObj.isRemote && full) - player.worldObj.playSoundEffect(player.posX, player.posY, player.posZ, "sounds.little_saw", 1.0F, (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F); + player.worldObj.playSoundEffect(player.posX, player.posY, player.posZ, "tinker:little_saw", 1.0F, (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F); //player.worldObj.playAuxSFX(1021, (int)player.posX, (int)player.posY, (int)player.posZ, 0); } } diff --git a/tconstruct/inventory/ToolStationContainer.java b/tconstruct/inventory/ToolStationContainer.java index 2e04f749..064e8fcc 100644 --- a/tconstruct/inventory/ToolStationContainer.java +++ b/tconstruct/inventory/ToolStationContainer.java @@ -138,7 +138,7 @@ public class ToolStationContainer extends ActiveContainer int amount = logic.getStackInSlot(1).getItem() instanceof ToolCore ? stack.stackSize : 1; logic.decrStackSize(1, amount); - logic.worldObj.playSoundEffect(logic.xCoord, logic.yCoord, logic.zCoord, "sounds.little_saw", 1.0F, (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F); + logic.worldObj.playSoundEffect(logic.xCoord, logic.yCoord, logic.zCoord, "tinker:little_saw", 1.0F, (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F); /*if (!player.worldObj.isRemote) player.worldObj.playAuxSFX(1021, (int)player.posX, (int)player.posY, (int)player.posZ, 0);*/ } diff --git a/tconstruct/items/DiamondApple.java b/tconstruct/items/DiamondApple.java index 6475ae42..5539f083 100644 --- a/tconstruct/items/DiamondApple.java +++ b/tconstruct/items/DiamondApple.java @@ -32,6 +32,11 @@ public class DiamondApple extends ItemFood int duration = 0; PotionEffect potion; + potion = player.getActivePotionEffect(Potion.resistance); + if (potion != null) + duration = potion.duration; + player.addPotionEffect(new PotionEffect(Potion.field_76444_x.id, duration + 60 * 40, 4)); + potion = player.getActivePotionEffect(Potion.resistance); if (potion != null) duration = potion.duration; diff --git a/tconstruct/items/tools/FryingPan.java b/tconstruct/items/tools/FryingPan.java index f5c7ea16..d17f5f1c 100644 --- a/tconstruct/items/tools/FryingPan.java +++ b/tconstruct/items/tools/FryingPan.java @@ -49,7 +49,7 @@ public class FryingPan extends Weapon @Override public void onEntityDamaged (World world, EntityLivingBase player, Entity entity) { - world.playSoundEffect(entity.posX, entity.posY, entity.posZ, "sounds.frypan_hit", 1.0F, (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F); + world.playSoundEffect(entity.posX, entity.posY, entity.posZ, "tinker:frypan_hit", 1.0F, (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F); } public String getToolName () @@ -128,7 +128,7 @@ public class FryingPan extends Weapon else { world.setBlock(x, y, z, TContent.heldItemBlock.blockID, 0, 3); - world.playSoundEffect(x, y, z, "sounds.frypan_hit", 1.0F, (random.nextFloat() - random.nextFloat()) * 0.2F + 0.65F); + world.playSoundEffect(x, y, z, "tinker:frypan_hit", 1.0F, (random.nextFloat() - random.nextFloat()) * 0.2F + 0.65F); EquipLogic logic = (EquipLogic) world.getBlockTileEntity(x, y, z); logic.setEquipmentItem(stack); diff --git a/tconstruct/items/tools/PotionLauncher.java b/tconstruct/items/tools/PotionLauncher.java index b91fd2fe..d2d8a5e0 100644 --- a/tconstruct/items/tools/PotionLauncher.java +++ b/tconstruct/items/tools/PotionLauncher.java @@ -53,7 +53,7 @@ public class PotionLauncher extends Item player.inventory.setInventorySlotContents(slotID, null); } - world.playSoundEffect(player.posX, player.posY, player.posZ, "sounds.launcher_clank", 1.0F, (world.rand.nextFloat() - world.rand.nextFloat()) * 0.15F + 1.0F); + world.playSoundEffect(player.posX, player.posY, player.posZ, "tinker:launcher_clank", 1.0F, (world.rand.nextFloat() - world.rand.nextFloat()) * 0.15F + 1.0F); } return stack; } diff --git a/tconstruct/util/player/ArmorExtended.java b/tconstruct/util/player/ArmorExtended.java index 0b851412..fe853808 100644 --- a/tconstruct/util/player/ArmorExtended.java +++ b/tconstruct/util/player/ArmorExtended.java @@ -2,14 +2,17 @@ package tconstruct.util.player; import java.lang.ref.WeakReference; -import tconstruct.TConstruct; -import tconstruct.common.TContent; - +import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.MathHelper; +import tconstruct.TConstruct; +import tconstruct.common.TContent; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.relauncher.Side; public class ArmorExtended implements IInventory { @@ -146,19 +149,60 @@ public class ArmorExtended implements IInventory public void recalculateHealth (EntityPlayer player, TPlayerStats stats) { + Side side = FMLCommonHandler.instance().getEffectiveSide(); + if (inventory[6] != null && inventory[6].getItem() == TContent.heartCanister) { + //System.out.println("Calculating HP on side " + FMLCommonHandler.instance().getEffectiveSide()); ItemStack stack = inventory[6]; int meta = stack.getItemDamage(); + //System.out.println("Calculating HP on side " + FMLCommonHandler.instance().getEffectiveSide()); if (meta == 2) { + int prevHealth = stats.bonusHealth; + if (side == Side.CLIENT) + prevHealth = stats.bonusHealthClient; int bonusHP = stack.stackSize * 2; - stats.bonusHealth = bonusHP; + if (side == Side.CLIENT) + stats.bonusHealthClient = bonusHP; + else + stats.bonusHealth = bonusHP; + int healthChange = bonusHP - prevHealth; + if (healthChange != 0) + { + double playerHP = player.func_110148_a(SharedMonsterAttributes.field_111267_a).func_111125_b(); + playerHP += healthChange; + player.func_110148_a(SharedMonsterAttributes.field_111267_a).func_111128_a(playerHP); + } + /*public void setEntityHealth(float par1) + { + this.dataWatcher.updateObject(6, Float.valueOf(MathHelper.clamp_float(par1, 0.0F, this.func_110138_aP()))); + }*/ + //player.func_110148_a(SharedMonsterAttributes.field_111267_a).func_111128_a(40); + //System.out.println("Health: "+player.func_110148_a(SharedMonsterAttributes.field_111267_a).func_111125_b()); + //player.setEntityHealth(40); //player.maxHealth = 20 + bonusHP; } } else if (parent != null && parent.get() != null) { + int prevHealth = stats.bonusHealth; + if (side == Side.CLIENT) + prevHealth = stats.bonusHealthClient; + int bonusHP = 0; + if (side == Side.CLIENT) + stats.bonusHealthClient = bonusHP; + else + stats.bonusHealth = bonusHP; + int healthChange = bonusHP - prevHealth; + if (healthChange != 0) + { + double playerHP = player.func_110148_a(SharedMonsterAttributes.field_111267_a).func_111125_b(); + playerHP += healthChange; + player.func_110148_a(SharedMonsterAttributes.field_111267_a).func_111128_a(playerHP); + } + //player.func_110148_a(SharedMonsterAttributes.field_111267_a).func_111128_a(20); + //player.setEntityHealth(20); //parent.get().maxHealth = 20; } } diff --git a/tconstruct/util/player/TPlayerStats.java b/tconstruct/util/player/TPlayerStats.java index d224fa98..812ffe6a 100644 --- a/tconstruct/util/player/TPlayerStats.java +++ b/tconstruct/util/player/TPlayerStats.java @@ -11,8 +11,8 @@ public class TPlayerStats { public WeakReference player; public int level; - public int levelHealth; public int bonusHealth; + public int bonusHealthClient; public int hunger; public boolean beginnerManual; public boolean materialManual;