diff --git a/resources/tinkertextures/armory.png b/resources/tinkertextures/armory.png new file mode 100644 index 00000000..06316b1e Binary files /dev/null and b/resources/tinkertextures/armory.png differ diff --git a/resources/tinkertextures/entity/wagon.png b/resources/tinkertextures/entity/wagon.png new file mode 100644 index 00000000..e67e29e4 Binary files /dev/null and b/resources/tinkertextures/entity/wagon.png differ diff --git a/resources/tinkertextures/mob/armorstandtexture.png b/resources/tinkertextures/mob/armorstandtexture.png new file mode 100644 index 00000000..29812668 Binary files /dev/null and b/resources/tinkertextures/mob/armorstandtexture.png differ diff --git a/tinker/armory/Armory.java b/tinker/armory/Armory.java new file mode 100644 index 00000000..dabab4ee --- /dev/null +++ b/tinker/armory/Armory.java @@ -0,0 +1,78 @@ +package tinker.armory; + +import tinker.armory.content.ArmorStandItem; +import tinker.armory.content.Toolrack; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import cpw.mods.fml.common.Mod; +import cpw.mods.fml.common.Mod.Init; +import cpw.mods.fml.common.Mod.Instance; +import cpw.mods.fml.common.Mod.PreInit; +import cpw.mods.fml.common.SidedProxy; +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.network.NetworkMod; +import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.common.registry.EntityRegistry; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.registry.LanguageRegistry; + +/** + * Tinkering with the Armory + * Every good castle has a place to put its tools + * Armor stands are entites! + * @author: mDiyo + */ + +@Mod(modid = "Armory", name = "Tinker's Armory", version = "1.4.7_A3") +@NetworkMod(clientSideRequired = true, serverSideRequired = false) +public class Armory +{ + /* Proxies for sides, used for client-only processing */ + @SidedProxy(clientSide = "tinker.armory.client.ArmoryProxyClient", serverSide = "tinker.armory.ArmoryProxyCommon") + public static ArmoryProxyCommon proxy; + + /* Instance of this mod, used for grabbing prototype fields */ + @Instance("Armory") + public static Armory instance; + + @PreInit + public void preInit(FMLPreInitializationEvent evt) + { + PHArmory.initProps(); + stoneRack = new Toolrack(PHArmory.rackBlock, Material.rock); + GameRegistry.registerBlock(stoneRack, tinker.armory.content.ToolrackItem.class, "ToolRack"); + GameRegistry.registerTileEntity(tinker.armory.content.ToolrackLogic.class, "InfiToolrack"); + /*armorStand = new ArmorStand(1501, Material.rock); + GameRegistry.registerBlock(armorStand, mDiyo.inficraft.armory.ArmorStandItem.class); + GameRegistry.registerTileEntity(mDiyo.inficraft.armory.ArmorStandLogic.class, "InfiArmorStand");*/ + + armorStandItem = new ArmorStandItem(PHArmory.armorItem).setItemName("armorstand"); + LanguageRegistry.instance().addName(armorStandItem, "Armor Stand"); + + EntityRegistry.registerModEntity(tinker.armory.content.ArmorStandEntity.class, "Armor Stand", 0, this, 32, 5, true); + NetworkRegistry.instance().registerGuiHandler(instance, new ArmoryGuiHandler()); + + GameRegistry.addRecipe(new ItemStack(Armory.instance.armorStandItem, 1, 0), " c ", "csc", " b ", 's', Item.stick, 'c', Block.cobblestone, 'b', Block.stoneSingleSlab); + } + + @Init + public void init(FMLInitializationEvent evt) + { + proxy.registerRenderer(); + proxy.addNames(); + proxy.addRecipes(); + } + + /* Prototype fields, used elsewhere */ + public static Block stoneRack; + public static Block woodRack; + public static Block armorStand; + public static Block pedestal; + + public static Item armorStandItem; + + public static String texture = "/tinkertextures/armory.png"; +} diff --git a/tinker/armory/ArmoryGuiHandler.java b/tinker/armory/ArmoryGuiHandler.java new file mode 100644 index 00000000..f4c1992b --- /dev/null +++ b/tinker/armory/ArmoryGuiHandler.java @@ -0,0 +1,46 @@ +package tinker.armory; + +import java.util.List; + +import tinker.armory.client.ArmorStandGui; +import tinker.armory.content.EntityEquipment; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; +import cpw.mods.fml.common.network.IGuiHandler; + +public class ArmoryGuiHandler implements IGuiHandler +{ + + + @Override + public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) + { + List list = world.getLoadedEntityList(); + for (Entity entity : list) + { + if (ID == entity.entityId) + { + return ((EntityEquipment)entity).getContainer(player); + } + } + System.out.println("Returning a null server entity"); + return null; + } + + @Override + public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) + { + List list = world.getLoadedEntityList(); + for (Entity entity : list) + { + if (ID == entity.entityId) + { + return new ArmorStandGui(player, (EntityEquipment)entity); + } + } + System.out.println("Returning a null client entity"); + return null; + } +} diff --git a/tinker/armory/ArmoryProxyCommon.java b/tinker/armory/ArmoryProxyCommon.java new file mode 100644 index 00000000..c6feb373 --- /dev/null +++ b/tinker/armory/ArmoryProxyCommon.java @@ -0,0 +1,15 @@ +package tinker.armory; + +import java.io.File; + +public class ArmoryProxyCommon +{ + public void registerRenderer() {} + public void addNames() {} + public void addRecipes() {} + + public File getMinecraftDir() + { + return new File("."); + } +} diff --git a/tinker/armory/PHArmory.java b/tinker/armory/PHArmory.java new file mode 100644 index 00000000..a704a724 --- /dev/null +++ b/tinker/armory/PHArmory.java @@ -0,0 +1,88 @@ +package tinker.armory; + +import java.io.File; +import java.io.IOException; + +import net.minecraftforge.common.Configuration; + +public class PHArmory +{ + + public static void initProps() + { + /* Here we will set up the config file for the mod + * First: Create a folder inside the config folder + * Second: Create the actual config file + * Note: Configs are a pain, but absolutely necessary for every mod. + */ + + File file = new File(Armory.proxy.getMinecraftDir() + "/config/InfiCraft"); + file.mkdir(); + File newFile = new File(Armory.proxy.getMinecraftDir() + "/config/InfiCraft/Armory.txt"); + + /* Some basic debugging will go a long way */ + try + { + newFile.createNewFile(); + System.out.println("Successfully read configuration file for mod_FloraBerries"); + } + catch (IOException e) + { + System.out.println("Could not read configuration file for mod_FloraBerries. Reason:"); + System.out.println(e); + } + + /* [Forge] Configuration class, used as config method */ + Configuration config = new Configuration(newFile); + + /* Load the configuration file */ + config.load(); + + /* Define the mod's IDs. + * Avoid values below 4096 for items and in the 250-450 and 2216-2226 range for blocks + */ + + armorBlock = config.getBlock("Armor Stand", 3257).getInt(3257); + rackBlock = config.getBlock("Tool Rack", 3257).getInt(3257); + armorItem = config.getItem("Armor Stand Item", 4570).getInt(4570); + /*berryBlockID = config.getBlock("Berry_Bush", 3257).getInt(3257); + berryItemID = config.getItem("Berry_Food", 12402).getInt(12402); + + raspSpawnDensity = config.get("general", "Raspberry_Spawn_Density", 14).getInt(14); + raspSpawnHeight = config.get("general", "Raspberry_Spawn_Height", 64).getInt(64); + raspSpawnRange = config.get("general", "Raspberry_Spawn_Range", 128).getInt(128); + blueSpawnDensity = config.get("general", "Blueberry_Spawn_Density", 12).getInt(12); + blueSpawnHeight = config.get("general", "Blueberry_Spawn_Height", 64).getInt(64); + blueSpawnRange = config.get("general", "Blueberry_Spawn_Range", 128).getInt(128); + blackSpawnDensity = config.get("general", "Blackberry_Spawn_Density", 10).getInt(10); + blackSpawnHeight = config.get("general", "Blackberry_Spawn_Height", 64).getInt(64); + blackSpawnRange = config.get("general", "Blackberry_Spawn_Range", 128).getInt(128); + geoSpawnDensity = config.get("general", "Geoberry_Spawn_Density", 14).getInt(14); + geoSpawnHeight = config.get("general", "Geoberry_Spawn_Height", 64).getInt(64); + geoSpawnRange = config.get("general", "Geoberry_Spawn_Range", 128).getInt(128);*/ + + /* Save the configuration file */ + config.save(); + } + + /* Prototype fields, used elsewhere */ + public static int armorBlock; + public static int armorItem; + public static int rackBlock; + /*public static int raspSpawnDensity; + public static int raspSpawnHeight; + public static int raspSpawnRange; + public static int blueSpawnDensity; + public static int blueSpawnHeight; + public static int blueSpawnRange; + public static int blackSpawnDensity; + public static int blackSpawnHeight; + public static int blackSpawnRange; + public static int geoSpawnDensity; + public static int geoSpawnHeight; + public static int geoSpawnRange; + + public static int berryItemID; + public static int berryBlockID;*/ + +} diff --git a/tinker/armory/client/ArmorStandContainer.java b/tinker/armory/client/ArmorStandContainer.java new file mode 100644 index 00000000..47cc8314 --- /dev/null +++ b/tinker/armory/client/ArmorStandContainer.java @@ -0,0 +1,83 @@ +package tinker.armory.client; + +import tinker.armory.content.EntityEquipment; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class ArmorStandContainer extends Container +{ + EntityEquipment stand; + InventoryPlayer player; + + public ArmorStandContainer(InventoryPlayer inventoryplayer, EntityEquipment equipment) + { + stand = equipment; + player = inventoryplayer; + this.addSlotToContainer(new Slot(equipment, 0, 62, 26)); + + for (int slot = 0; slot < 4; ++slot) + { + this.addSlotToContainer(new SlotArmorCopy(this, equipment, slot + 1, 80, 8 + (3-slot) * 18, 3-slot)); + } + + // Slot: inventory, slot index, xDisplay, yDisplay + + int var3; + + for (var3 = 0; var3 < 3; ++var3) + { + for (int var4 = 0; var4 < 9; ++var4) + { + this.addSlotToContainer(new Slot(player, var4 + var3 * 9 + 9, 8 + var4 * 18, 84 + var3 * 18)); + } + } + + for (var3 = 0; var3 < 9; ++var3) + { + this.addSlotToContainer(new Slot(player, var3, 8 + var3 * 18, 142)); + } + } + + @Override + public boolean canInteractWith(EntityPlayer player) + { + return true; + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer entityplayer, int slot) + { + ItemStack var3 = null; + Slot var4 = (Slot) this.inventorySlots.get(slot); + + if (var4 != null && var4.getHasStack()) + { + ItemStack var5 = var4.getStack(); + var3 = var5.copy(); + + if (slot < 5) + { + if (!this.mergeItemStack(var5, 5, this.inventorySlots.size(), true)) + { + return null; + } + } else if (!this.mergeItemStack(var5, 0, 5, false)) + { + return null; + } + + if (var5.stackSize == 0) + { + var4.putStack((ItemStack) null); + } else + { + var4.onSlotChanged(); + } + } + + return var3; + } +} diff --git a/tinker/armory/client/ArmorStandGui.java b/tinker/armory/client/ArmorStandGui.java new file mode 100644 index 00000000..9f6ed52f --- /dev/null +++ b/tinker/armory/client/ArmorStandGui.java @@ -0,0 +1,40 @@ +package tinker.armory.client; + +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.entity.player.EntityPlayer; + +import org.lwjgl.opengl.GL11; + +import tinker.armory.content.EntityEquipment; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class ArmorStandGui extends GuiContainer +{ + public ArmorStandGui(EntityPlayer player, EntityEquipment equipment) + { + super(equipment.getContainer(player)); + this.allowUserInput = true; + } + + /** + * Draw the foreground layer for the GuiContainer (everything in front of the items) + */ + protected void drawGuiContainerForegroundLayer(int par1, int par2) + { + this.fontRenderer.drawString("Armor Stand", 8, 8, 4210752); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) + { + int var4 = this.mc.renderEngine.getTexture("/infitextures/gui/armorstand.png"); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(var4); + int var5 = this.guiLeft; + int var6 = this.guiTop; + this.drawTexturedModalRect(var5, var6, 0, 0, this.xSize, this.ySize); + } +} diff --git a/tinker/armory/client/ArmorStandModelStatue.java b/tinker/armory/client/ArmorStandModelStatue.java new file mode 100644 index 00000000..a628c363 --- /dev/null +++ b/tinker/armory/client/ArmorStandModelStatue.java @@ -0,0 +1,96 @@ +/* + * Armor stand model by Fudgy_Fetus + */ +package tinker.armory.client; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.entity.Entity; + +public class ArmorStandModelStatue extends ModelBase +{ + ModelRenderer head; + ModelRenderer body; + ModelRenderer rightarm; + ModelRenderer leftarm; + ModelRenderer bottompedestal; + ModelRenderer toppedestal; + ModelRenderer standstick; + + public ArmorStandModelStatue() + { + textureWidth = 128; + textureHeight = 64; + + head = new ModelRenderer(this, 0, 0); + head.addBox(-4F, -8F, -4F, 8, 8, 8); + head.setRotationPoint(0F, 0F, 0F); + head.setTextureSize(128, 64); + head.mirror = true; + setRotation(head, 0F, 0F, 0F); + body = new ModelRenderer(this, 16, 16); + body.addBox(-4F, 0F, -2F, 8, 12, 4); + body.setRotationPoint(0F, 0F, 0F); + body.setTextureSize(128, 64); + body.mirror = true; + setRotation(body, 0F, 0F, 0F); + rightarm = new ModelRenderer(this, 40, 16); + rightarm.addBox(-3F, -2F, -2F, 4, 7, 4); + rightarm.setRotationPoint(-5F, 2F, 0F); + rightarm.setTextureSize(128, 64); + rightarm.mirror = true; + setRotation(rightarm, 0F, 0F, 0F); + leftarm = new ModelRenderer(this, 40, 16); + leftarm.addBox(-1F, -2F, -2F, 4, 7, 4); + leftarm.setRotationPoint(5F, 2F, 0F); + leftarm.setTextureSize(128, 64); + leftarm.mirror = true; + setRotation(leftarm, 0F, 0F, 0F); + bottompedestal = new ModelRenderer(this, 56, 15); + bottompedestal.addBox(0F, 0F, 0F, 16, 2, 16); + bottompedestal.setRotationPoint(-8F, 26F, -8F); + bottompedestal.setTextureSize(128, 64); + bottompedestal.mirror = true; + setRotation(bottompedestal, 0F, 0F, 0F); + toppedestal = new ModelRenderer(this, 60, 0); + toppedestal.addBox(0F, 0F, 0F, 14, 1, 14); + toppedestal.setRotationPoint(-7F, 25F, -7F); + toppedestal.setTextureSize(128, 64); + toppedestal.mirror = true; + setRotation(toppedestal, 0F, 0F, 0F); + standstick = new ModelRenderer(this, 0, 16); + standstick.addBox(0F, 0F, 0F, 2, 13, 2); + standstick.setRotationPoint(-1F, 12F, -1F); + standstick.setTextureSize(128, 64); + standstick.mirror = true; + setRotation(standstick, 0F, 0F, 0F); + } + + @Override + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float rotation) + { + super.render(entity, f, f1, f2, f3, f4, rotation); + setRotationAngles(f, f1, f2, f3, f4, rotation, entity); + head.render(rotation); + body.render(rotation); + rightarm.render(rotation); + leftarm.render(rotation); + bottompedestal.render(rotation); + toppedestal.render(rotation); + standstick.render(rotation); + } + + void setRotation(ModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + + @Override + public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity par7Entity) + { + super.setRotationAngles(f, f1, f2, f3, f4, f5, par7Entity); + } + +} diff --git a/tinker/armory/client/ArmoryProxyClient.java b/tinker/armory/client/ArmoryProxyClient.java new file mode 100644 index 00000000..969aaa86 --- /dev/null +++ b/tinker/armory/client/ArmoryProxyClient.java @@ -0,0 +1,28 @@ +package tinker.armory.client; + +import java.io.File; + +import tinker.armory.ArmoryProxyCommon; +import tinker.armory.content.ArmorStandEntity; +import tinker.armory.content.ToolrackLogic; + +import net.minecraft.client.Minecraft; +import cpw.mods.fml.client.registry.ClientRegistry; +import cpw.mods.fml.client.registry.RenderingRegistry; + +public class ArmoryProxyClient extends ArmoryProxyCommon +{ + @Override + public void registerRenderer() + { + RenderingRegistry.registerBlockHandler(new RenderToolrack()); + ClientRegistry.bindTileEntitySpecialRenderer(ToolrackLogic.class, new ToolrackSpecialRender()); + RenderingRegistry.registerEntityRenderingHandler(tinker.armory.content.ArmorStandEntity.class, new RenderArmorStandEntity(new ArmorStandModelStatue(), 0)); + } + + @Override + public File getMinecraftDir() + { + return Minecraft.getMinecraftDir(); + } +} diff --git a/tinker/armory/client/RenderArmorStandEntity.java b/tinker/armory/client/RenderArmorStandEntity.java new file mode 100644 index 00000000..3e95bf12 --- /dev/null +++ b/tinker/armory/client/RenderArmorStandEntity.java @@ -0,0 +1,512 @@ +package tinker.armory.client; + +import static net.minecraftforge.client.IItemRenderer.ItemRenderType.EQUIPPED; +import static net.minecraftforge.client.IItemRenderer.ItemRendererHelper.BLOCK_3D; +import net.minecraft.block.Block; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelBiped; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.entity.RenderLiving; +import net.minecraft.client.renderer.tileentity.TileEntitySkullRenderer; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.item.EnumArmorMaterial; +import net.minecraft.item.Item; +import net.minecraft.item.ItemArmor; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraftforge.client.ForgeHooksClient; +import net.minecraftforge.client.IItemRenderer; +import net.minecraftforge.client.MinecraftForgeClient; + +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class RenderArmorStandEntity extends RenderLiving +{ + protected ModelBase mainModel; + protected float sizeIncrease; + protected ModelBiped armorChestplate; + protected ModelBiped armorBody; + + /** List of armor texture filenames. */ + public static String[] bipedArmorFilenamePrefix = new String[] {"cloth", "chain", "iron", "diamond", "gold"}; + + public RenderArmorStandEntity(ModelBase model, float par2) + { + this(model, par2, 1.0F); + } + + public RenderArmorStandEntity(ModelBase model, float par2, float par3) + { + super(model, par2); + this.mainModel = model; + this.sizeIncrease = par3; + this.func_82421_b(); + } + + protected void func_82421_b() + { + this.armorChestplate = new ModelBiped(1.0F); + this.armorBody = new ModelBiped(0.5F); + } + + /** + * Queries whether should render the specified pass or not. + */ + protected int shouldRenderPass(EntityLiving par1EntityLiving, int par2, float par3) + { + ItemStack stack = par1EntityLiving.getCurrentArmor(3 - par2); + + if (stack != null) + { + Item item = stack.getItem(); + + if (item instanceof ItemArmor) + { + ItemArmor itemarmor = (ItemArmor)item; + this.loadTexture(ForgeHooksClient.getArmorTexture(stack, "/armor/" + bipedArmorFilenamePrefix[itemarmor.renderIndex%4] + "_" + (par2 == 2 ? 2 : 1) + ".png")); + ModelBiped biped = par2 == 2 ? this.armorBody : this.armorChestplate; + biped.bipedHead.showModel = par2 == 0; + biped.bipedHeadwear.showModel = par2 == 0; + biped.bipedBody.showModel = par2 == 1 || par2 == 2; + biped.bipedRightArm.showModel = par2 == 1; + biped.bipedLeftArm.showModel = par2 == 1; + biped.bipedRightLeg.showModel = par2 == 2 || par2 == 3; + biped.bipedLeftLeg.showModel = par2 == 2 || par2 == 3; + this.setRenderPassModel(biped); + + if (biped != null) + { + biped.onGround = this.mainModel.onGround; + } + + if (biped != null) + { + biped.isRiding = this.mainModel.isRiding; + } + + if (biped != null) + { + biped.isChild = this.mainModel.isChild; + } + + float var8 = 1.0F; + + if (itemarmor.getArmorMaterial() == EnumArmorMaterial.CLOTH) + { + int var9 = itemarmor.getColor(stack); + float var10 = (float)(var9 >> 16 & 255) / 255.0F; + float var11 = (float)(var9 >> 8 & 255) / 255.0F; + float var12 = (float)(var9 & 255) / 255.0F; + GL11.glColor3f(var8 * var10, var8 * var11, var8 * var12); + + if (stack.isItemEnchanted()) + { + return 31; + } + + return 16; + } + + GL11.glColor3f(var8, var8, var8); + + if (stack.isItemEnchanted()) + { + return 15; + } + + return 1; + } + } + + return -1; + } + + protected void func_82408_c(EntityLiving par1EntityLiving, int par2, float par3) + { + ItemStack var4 = par1EntityLiving.getCurrentArmor(3 - par2); + + if (var4 != null) + { + Item var5 = var4.getItem(); + + if (var5 instanceof ItemArmor) + { + ItemArmor var6 = (ItemArmor)var5; + this.loadTexture("/armor/" + bipedArmorFilenamePrefix[var6.renderIndex] + "_" + (par2 == 2 ? 2 : 1) + "_b.png"); + float var7 = 1.0F; + GL11.glColor3f(var7, var7, var7); + } + } + } + + public void doRenderLiving(EntityLiving par1EntityLiving, double posX, double posY, double posZ, float par8, float par9) + { + float var10 = 1.0F; + GL11.glColor3f(var10, var10, var10); + ItemStack var11 = par1EntityLiving.getHeldItem(); + this.func_82420_a(par1EntityLiving, var11); + double var12 = posY - (double)par1EntityLiving.yOffset+0.25; + + //Insert super here + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_CULL_FACE); + this.mainModel.onGround = this.renderSwingProgress(par1EntityLiving, par9); + + if (this.renderPassModel != null) + { + this.renderPassModel.onGround = this.mainModel.onGround; + } + + this.mainModel.isRiding = par1EntityLiving.isRiding(); + + if (this.renderPassModel != null) + { + this.renderPassModel.isRiding = this.mainModel.isRiding; + } + + this.mainModel.isChild = par1EntityLiving.isChild(); + + if (this.renderPassModel != null) + { + this.renderPassModel.isChild = this.mainModel.isChild; + } + + try + { + //float rotate1 = this.interRotation(par1EntityLiving.prevRenderYawOffset, par1EntityLiving.renderYawOffset, par9); + float rotate2 = this.interRotation(par1EntityLiving.prevRotationYawHead, par1EntityLiving.rotationYawHead, par9); + float rotate1 = rotate2; + //float rotate2 = rotate1; + float rotate3 = par1EntityLiving.prevRotationPitch + (par1EntityLiving.rotationPitch - par1EntityLiving.prevRotationPitch) * par9; + this.renderLivingAt(par1EntityLiving, posX, posY, posZ); + //float rotationExisted = this.handleRotationFloat(par1EntityLiving, par9); // Makes the armor breathe + float rotationExisted = 0; + this.rotateCorpse(par1EntityLiving, rotationExisted, rotate1, par9); + float var14 = 0.0625F; + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glScalef(-1.0F, -1.0F, 1.0F); + this.preRenderCallback(par1EntityLiving, par9); + GL11.glTranslatef(0.0F, -24.0F * var14 - 0.0078125F - 0.25F, 0.0F); + float var15 = par1EntityLiving.prevLegYaw + (par1EntityLiving.legYaw - par1EntityLiving.prevLegYaw) * par9; + float var16 = par1EntityLiving.legSwing - par1EntityLiving.legYaw * (1.0F - par9); + + if (par1EntityLiving.isChild()) + { + var16 *= 3.0F; + } + + if (var15 > 1.0F) + { + var15 = 1.0F; + } + + GL11.glEnable(GL11.GL_ALPHA_TEST); + this.mainModel.setLivingAnimations(par1EntityLiving, var16, var15, par9); + this.renderModel(par1EntityLiving, var16, var15, rotationExisted, rotate2 - rotate1, rotate3, var14); + float var19; + int var18; + float var20; + float var22; + + for (int armorIter = 0; armorIter < 4; ++armorIter) //Armor + { + var18 = this.shouldRenderPass(par1EntityLiving, armorIter, par9); + + if (var18 > 0) + { + this.renderPassModel.setLivingAnimations(par1EntityLiving, var16, var15, par9); + this.renderPassModel.render(par1EntityLiving, 0, 0, rotationExisted, rotate2 - rotate1, rotate3, var14); + + if ((var18 & 240) == 16) + { + this.func_82408_c(par1EntityLiving, armorIter, par9); + this.renderPassModel.render(par1EntityLiving, var16, var15, rotationExisted, rotate2 - rotate1, rotate3, var14); + } + + if ((var18 & 15) == 15) + { + var19 = (float)par1EntityLiving.ticksExisted + par9; + this.loadTexture("%blur%/misc/glint.png"); + GL11.glEnable(GL11.GL_BLEND); + var20 = 0.5F; + GL11.glColor4f(var20, var20, var20, 1.0F); + GL11.glDepthFunc(GL11.GL_EQUAL); + GL11.glDepthMask(false); + + for (int var21 = 0; var21 < 2; ++var21) + { + GL11.glDisable(GL11.GL_LIGHTING); + var22 = 0.76F; + GL11.glColor4f(0.5F * var22, 0.25F * var22, 0.8F * var22, 1.0F); + GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glLoadIdentity(); + float var23 = var19 * (0.001F + (float)var21 * 0.003F) * 20.0F; + float var24 = 0.33333334F; + GL11.glScalef(var24, var24, var24); + GL11.glRotatef(30.0F - (float)var21 * 60.0F, 0.0F, 0.0F, 1.0F); + GL11.glTranslatef(0.0F, var23, 0.0F); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + this.renderPassModel.render(par1EntityLiving, var16, var15, rotationExisted, rotate2 - rotate1, rotate3, var14); + } + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glDepthMask(true); + GL11.glLoadIdentity(); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDepthFunc(GL11.GL_LEQUAL); + } + + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_ALPHA_TEST); + } + } + + GL11.glDepthMask(true); + this.renderEquippedItems(par1EntityLiving, par9); + float var26 = par1EntityLiving.getBrightness(par9); + var18 = this.getColorMultiplier(par1EntityLiving, var26, par9); + OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); + GL11.glDisable(GL11.GL_TEXTURE_2D); + OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); + + if ((var18 >> 24 & 255) > 0 || par1EntityLiving.hurtTime > 0 || par1EntityLiving.deathTime > 0) + { + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glDepthFunc(GL11.GL_EQUAL); + + if (par1EntityLiving.hurtTime > 0 || par1EntityLiving.deathTime > 0) + { + GL11.glColor4f(var26, 0.0F, 0.0F, 0.4F); + this.mainModel.render(par1EntityLiving, var16, var15, rotationExisted, rotate2 - rotate1, rotate3, var14); + + for (int var27 = 0; var27 < 4; ++var27) + { + if (this.inheritRenderPass(par1EntityLiving, var27, par9) >= 0) + { + GL11.glColor4f(var26, 0.0F, 0.0F, 0.4F); + this.renderPassModel.render(par1EntityLiving, var16, var15, rotationExisted, rotate2 - rotate1, rotate3, var14); + } + } + } + + if ((var18 >> 24 & 255) > 0) + { + var19 = (float)(var18 >> 16 & 255) / 255.0F; + var20 = (float)(var18 >> 8 & 255) / 255.0F; + float var29 = (float)(var18 & 255) / 255.0F; + var22 = (float)(var18 >> 24 & 255) / 255.0F; + GL11.glColor4f(var19, var20, var29, var22); + this.mainModel.render(par1EntityLiving, var16, var15, rotationExisted, rotate2 - rotate1, rotate3, var14); + + for (int var28 = 0; var28 < 4; ++var28) + { + if (this.inheritRenderPass(par1EntityLiving, var28, par9) >= 0) + { + GL11.glColor4f(var19, var20, var29, var22); + this.renderPassModel.render(par1EntityLiving, var16, var15, rotationExisted, rotate2 - rotate1, rotate3, var14); + } + } + } + + GL11.glDepthFunc(GL11.GL_LEQUAL); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } + + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + } + catch (Exception var25) + { + var25.printStackTrace(); + } + + OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); + GL11.glEnable(GL11.GL_TEXTURE_2D); + OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glPopMatrix(); + this.passSpecialRender(par1EntityLiving, posX, posY, posZ); + } + + public float interRotation(float par1, float par2, float par3) + { + float var4; + + for (var4 = par2 - par1; var4 < -180.0F; var4 += 360.0F) + { + ; + } + + while (var4 >= 180.0F) + { + var4 -= 360.0F; + } + + return par1 + par3 * var4; + } + + @Override + protected float renderSwingProgress(EntityLiving par1EntityLiving, float par2) + { + return 0; + } + + protected void func_82420_a(EntityLiving par1EntityLiving, ItemStack par2ItemStack) + { + this.armorChestplate.heldItemRight = this.armorBody.heldItemRight = par2ItemStack != null ? 1 : 0; + } + + protected void renderEquippedItems(EntityLiving par1EntityLiving, float par2) + { + float var3 = 1.0F; + GL11.glColor3f(var3, var3, var3); + super.renderEquippedItems(par1EntityLiving, par2); + ItemStack var4 = par1EntityLiving.getHeldItem(); + ItemStack var5 = par1EntityLiving.getCurrentArmor(3); + float var6; + + if (var5 != null) + { + GL11.glPushMatrix(); + //this.mainModel.head.postRender(0.0625F); + + IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(var5, EQUIPPED); + boolean is3D = (customRenderer != null && customRenderer.shouldUseRenderHelper(EQUIPPED, var5, BLOCK_3D)); + + if (var5.getItem() instanceof ItemBlock) + { + if (is3D || RenderBlocks.renderItemIn3d(Block.blocksList[var5.itemID].getRenderType())) + { + var6 = 0.625F; + GL11.glTranslatef(0.0F, -0.25F, 0.0F); + GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); + GL11.glScalef(var6, -var6, -var6); + } + + this.renderManager.itemRenderer.renderItem(par1EntityLiving, var5, 0); + } + else if (var5.getItem().itemID == Item.skull.itemID) + { + var6 = 1.0625F; + GL11.glScalef(var6, -var6, -var6); + String var7 = ""; + + if (var5.hasTagCompound() && var5.getTagCompound().hasKey("SkullOwner")) + { + var7 = var5.getTagCompound().getString("SkullOwner"); + } + + TileEntitySkullRenderer.skullRenderer.func_82393_a(-0.5F, 0.0F, -0.5F, 1, 180.0F, var5.getItemDamage(), var7); + } + + GL11.glPopMatrix(); + } + + if (var4 != null) + { + GL11.glPushMatrix(); + + if (this.mainModel.isChild) + { + var6 = 0.5F; + GL11.glTranslatef(0.0F, 0.625F, 0.0F); + GL11.glRotatef(-20.0F, -1.0F, 0.0F, 0.0F); + GL11.glScalef(var6, var6, var6); + } + + //this.mainModel.bipedRightArm.postRender(0.0625F); + GL11.glTranslatef(-0.0625F, 0.4375F, 0.0625F); + + IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(var4, EQUIPPED); + boolean is3D = (customRenderer != null && customRenderer.shouldUseRenderHelper(EQUIPPED, var4, BLOCK_3D)); + + if (var4.getItem() instanceof ItemBlock && (is3D || RenderBlocks.renderItemIn3d(Block.blocksList[var4.itemID].getRenderType()))) + { + var6 = 0.5F; + GL11.glTranslatef(-0.4325F, 0.1875F, -0.3125F); + var6 *= 0.75F; + GL11.glRotatef(20.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); + GL11.glScalef(-var6, -var6, var6); + } + else if (var4.itemID == Item.bow.itemID) + { + var6 = 0.625F; + GL11.glTranslatef(-0.5F, 0.125F, 0.3125F); + GL11.glRotatef(-20.0F, 0.0F, 1.0F, 0.0F); + GL11.glScalef(var6, -var6, var6); + GL11.glRotatef(-100.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); + } + else if (Item.itemsList[var4.itemID].isFull3D()) + { + var6 = 0.625F; + + if (Item.itemsList[var4.itemID].shouldRotateAroundWhenRendering()) + { + GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); + GL11.glTranslatef(0.0F, -0.125F, 0.0F); + } + + this.func_82422_c(); + GL11.glScalef(var6, -var6, var6); + GL11.glTranslatef(-0.5F, 0.0F, 0.0F); + GL11.glRotatef(-100.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); + } + else + { + var6 = 0.375F; + GL11.glTranslatef(-0.125F, 0.1875F, -0.1875F); + GL11.glScalef(var6, var6, var6); + GL11.glRotatef(60.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(-90.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(20.0F, 0.0F, 0.0F, 1.0F); + } + + this.renderManager.itemRenderer.renderItem(par1EntityLiving, var4, 0); + + if (var4.getItem().requiresMultipleRenderPasses()) + { + for (int x = 1; x < var4.getItem().getRenderPasses(var4.getItemDamage()); x++) + { + this.renderManager.itemRenderer.renderItem(par1EntityLiving, var4, x); + } + } + + GL11.glPopMatrix(); + } + } + + protected void func_82422_c() + { + GL11.glTranslatef(0.0F, 0.1875F, 0.0F); + } + + /** + * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then + * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic + * (Render> 16 & 255) / 255.0F; + float var2 = (float)(var0 >> 8 & 255) / 255.0F; + float var3 = (float)(var0 & 255) / 255.0F; + GL11.glColor4f(var1, var2, var3, 1.0F); + } +} diff --git a/tinker/armory/content/ArmorStandBlock.java b/tinker/armory/content/ArmorStandBlock.java new file mode 100644 index 00000000..84a22ab0 --- /dev/null +++ b/tinker/armory/content/ArmorStandBlock.java @@ -0,0 +1,5 @@ +package tinker.armory.content; + +public class ArmorStandBlock { + +} diff --git a/tinker/armory/content/ArmorStandEntity.java b/tinker/armory/content/ArmorStandEntity.java new file mode 100644 index 00000000..1f12be7d --- /dev/null +++ b/tinker/armory/content/ArmorStandEntity.java @@ -0,0 +1,157 @@ +package tinker.armory.content; + +import tinker.armory.Armory; +import tinker.armory.client.ArmorStandContainer; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + +public class ArmorStandEntity extends EntityEquipment +{ + //Container inventory; + public ArmorStandEntity(World world) + { + super(world); + this.texture = "/tinkertextures/mob/armorstandtexture.png"; + //inventory = new ArmorStandContainer(this); + } + + public boolean interact (EntityPlayer player) + { + //if (player.getCurrentEquippedItem() == null) + if (player.isSneaking()) + { + //faceEntity(player, 10.0F, (float)this.getVerticalFaceSpeed()); + //int facing = (int) ((player.rotationYawHead + 225) * 16 / 360) % 16; + int facing = (int) (player.rotationYawHead + 191) % 360; + facing = (int) (facing / 22.5f); + //System.out.println("Facing: "+facing); + //System.out.println("Facing: "+facing + " Angle: "+facing*22.5f); + setRotation(facing * 22.5f, 0); + } + else + player.openGui(Armory.instance, entityId, worldObj, (int) posX, (int) posY, (int) posZ); + return true; + } + + @Override + protected void setRotation (float rotation, float vertical) + { + this.rotationYaw = rotation; + this.rotationYawHead = rotation; + this.rotationPitch = vertical; + } + + @Override + public Container getContainer (EntityPlayer player) + { + return new ArmorStandContainer(player.inventory, this); + } + + @Override + public int getSizeInventory () + { + return 5; + } + + @Override + public ItemStack getStackInSlot (int slot) + { + return getCurrentItemOrArmor(slot); + } + + @Override + public ItemStack decrStackSize (int slot, int stackSize) + { + if (getCurrentItemOrArmor(slot) != null) + { + if (getCurrentItemOrArmor(slot).stackSize <= stackSize) + { + ItemStack itemstack = getCurrentItemOrArmor(slot); + setCurrentItemOrArmor(slot, null); + return itemstack; + } + ItemStack itemstack1 = getCurrentItemOrArmor(slot).splitStack(stackSize); + if (getCurrentItemOrArmor(slot).stackSize == 0) + { + setCurrentItemOrArmor(slot, null); + } + return itemstack1; + } + else + { + return null; + } + } + + @Override + public ItemStack getStackInSlotOnClosing (int var1) + { + return null; + } + + @Override + public void setInventorySlotContents (int slot, ItemStack itemstack) + { + setCurrentItemOrArmor(slot, itemstack); + if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) + { + itemstack.stackSize = getInventoryStackLimit(); + } + } + + @Override + public String getInvName () + { + return "Inventory"; + } + + @Override + public int getInventoryStackLimit () + { + return 1; + } + + @Override + public void onInventoryChanged () + { + + } + + @Override + public boolean isUseableByPlayer (EntityPlayer var1) + { + return true; + } + + public void openChest () + { + } + + public void closeChest () + { + } + + protected int getDropItemId() + { + return Armory.armorStandItem.itemID; + } + + @Override + public void writeEntityToNBT(NBTTagCompound tags) + { + super.writeEntityToNBT(tags); + tags.setFloat("rotationYaw", rotationYaw); + tags.setFloat("rotationYawHead", rotationYawHead); + } + + @Override + public void readEntityFromNBT(NBTTagCompound tags) + { + super.readEntityFromNBT(tags); + rotationYaw = tags.getFloat("rotationYaw"); + rotationYawHead = tags.getFloat("rotationYawHead"); + } +} diff --git a/tinker/armory/content/ArmorStandItem.java b/tinker/armory/content/ArmorStandItem.java new file mode 100644 index 00000000..5b6b2f7f --- /dev/null +++ b/tinker/armory/content/ArmorStandItem.java @@ -0,0 +1,83 @@ +package tinker.armory.content; + +import tinker.armory.Armory; +import net.minecraft.block.Block; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public class ArmorStandItem extends Item +{ + public ArmorStandItem(int id) + { + super(id); + setCreativeTab(CreativeTabs.tabMisc); + } + + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float clickX, float clickY, float clickZ) + { + int var11 = world.getBlockId(x, y, z); + + if (var11 == Block.snow.blockID) + { + side = 1; + } + else if (var11 != Block.vine.blockID && var11 != Block.tallGrass.blockID && var11 != Block.deadBush.blockID + && (Block.blocksList[var11] == null || !Block.blocksList[var11].isBlockReplaceable(world, x, y, z))) + { + if (side == 0) + --y; + + if (side == 1) + ++y; + + if (side == 2) + --z; + + if (side == 3) + ++z; + + if (side == 4) + --x; + + if (side == 5) + ++x; + } + + if (stack.stackSize == 0) + { + return false; + } + else if (!player.canPlayerEdit(x, y, z, side, stack)) + { + return false; + } + if (spawnEntity(x, y, z, new ArmorStandEntity(world), world, player) ) + { + stack.stackSize--; + return true; + } + player.swingItem(); + return false; + } + + public static boolean spawnEntity(double x, double y, double z, Entity entity, World world, EntityPlayer player) + { + if (!world.isRemote) + { + entity.setPosition(x+0.5, y, z+0.5); + world.spawnEntityInWorld(entity); + world.playAuxSFX(2001, (int)x, (int)y, (int)z, Block.stone.blockID); + return true; + } + return false; + } + + public String getTextureFile() + { + return Armory.texture; + } +} diff --git a/tinker/armory/content/EntityEquipment.java b/tinker/armory/content/EntityEquipment.java new file mode 100644 index 00000000..6d77b1b1 --- /dev/null +++ b/tinker/armory/content/EntityEquipment.java @@ -0,0 +1,97 @@ +package tinker.armory.content; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.DamageSource; +import net.minecraft.world.World; + +/* + * Dummy class, used for rendering equipment and nothing else! + */ + +public abstract class EntityEquipment extends EntityLiving + implements IInventory +{ + public EntityEquipment(World par1World) + { + super(par1World); + equipmentDropChances = new float[] { 1f, 1f, 1f, 1f, 1f }; + } + + public abstract Container getContainer(EntityPlayer player); + + public String getTexture() + { + return this.texture; + } + + protected void kill() + { + this.attackEntityFrom(DamageSource.outOfWorld, 1000); + } + + protected void dropFewItems(boolean par1, int par2) + { + this.dropItem(this.getDropItemId(), 1); + } + + protected void dropEquipment(boolean par1, int par2) + { + for (int var3 = 0; var3 < this.getLastActiveItems().length; ++var3) + { + ItemStack var4 = this.getCurrentItemOrArmor(var3); + boolean var5 = this.equipmentDropChances[var3] > 1.0F; + + if (var4 != null && (par1 || var5) && this.rand.nextFloat() - (float)par2 * 0.01F < this.equipmentDropChances[var3]) + { + if (!var5 && var4.isItemStackDamageable()) + { + int var6 = Math.max(var4.getMaxDamage() - 25, 1); + int var7 = var4.getMaxDamage() - this.rand.nextInt(this.rand.nextInt(var6) + 1); + + if (var7 > var6) + { + var7 = var6; + } + + if (var7 < 1) + { + var7 = 1; + } + + //var4.setItemDamage(var7); + } + + this.entityDropItem(var4, 0.0F); + } + } + } + + public int getMaxHealth() { return 5; } + public boolean canBePushed() { return false; } + protected int decreaseAirSupply(int par1) { return 0; } + //public boolean attackEntityFrom(DamageSource par1DamageSource, int par2) { return false; } + //protected void damageEntity(DamageSource par1DamageSource, int par2) { super.damageEntity(par1DamageSource, par2); } + protected void updateFallState(double par1, boolean par3) {} + public void knockBack(Entity par1Entity, int par2, double par3, double par5) {} + protected void fall(float par1) {} + public void moveEntityWithHeading(float par1, float par2) {} + public boolean canBreatheUnderwater() { return true; } + public void onLivingUpdate() { } + public boolean isBlocking() { return true; } + protected void jump() {} + protected boolean canDespawn() { return true; } + //protected void despawnEntity() { super.despawnEntity(); } + protected void updateAITasks() {} + protected void updateEntityActionState() {} + protected void updateArmSwingProgress() {} + public boolean getCanSpawnHere() { return false; } + protected void updatePotionEffects() {} + public void addPotionEffect(PotionEffect par1PotionEffect) {} + public boolean isPotionApplicable(PotionEffect par1PotionEffect) { return false; } +} diff --git a/tinker/armory/content/Toolrack.java b/tinker/armory/content/Toolrack.java new file mode 100644 index 00000000..c0edd817 --- /dev/null +++ b/tinker/armory/content/Toolrack.java @@ -0,0 +1,192 @@ +package tinker.armory.content; + +import java.util.List; + +import tinker.armory.client.RenderToolrack; + +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class Toolrack extends BlockContainer +{ + public Toolrack(int id, Material material) + { + super(id, material); + } + + @Override + public boolean renderAsNormalBlock() + { + return false; + } + + @Override + public boolean isOpaqueCube() + { + return false; + } + + public int getRenderType() + { + return RenderToolrack.rackModel; + } + + @Override + public TileEntity createNewTileEntity(World world) + { + return new ToolrackLogic(); + } + + public int getBlockTextureFromSideAndMetadata(int side, int meta) + { + return 6; + } + + public void addCollidingBlockToList(World var1, int var2, int var3, int var4, AxisAlignedBB var5, List var6, Entity var7) + { + this.setBounds(var1.getBlockMetadata(var2, var3, var4)); + super.addCollidingBlockToList(var1, var2, var3, var4, var5, var6, var7); + } + + public void setBlockBoundsBasedOnState(IBlockAccess var1, int var2, int var3, int var4) + { + this.setBounds(var1.getBlockMetadata(var2, var3, var4)); + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int size, float hitX, float hitY, float hitZ) + { + System.out.println("Activating tool rack"); + if (world.isRemote) + { + System.out.println("World's remote"); + return true; + } + else + { + ToolrackLogic logic = (ToolrackLogic)world.getBlockTileEntity(x, y, z); + + //if (logic != null && player instanceof EntityPlayerMP) + if (logic != null) + { + System.out.println("Logic exists"); + int facing = world.getBlockMetadata(x, y, z) / 4; + byte slot = 0; + double var13 = (double)x + 0.5D - player.posX; + double var15 = (double)z + 0.5D - player.posZ; + + if (facing == 0) + { + var15 -= 0.25D; + } + else if (facing == 1) + { + var13 -= 0.25D; + } + else if (facing == 2) + { + var15 += 0.25D; + } + else if (facing == 3) + { + var13 += 0.25D; + } + + double var17 = var13 + var15 * Math.tan(Math.toRadians((double)player.rotationYaw)); + double var19 = var15 - var13 * Math.tan(Math.toRadians((double)(player.rotationYaw + 90.0F))); + + if (facing == 0 && var17 < 0.0D || facing == 1 && var19 > 0.0D || facing == 2 && var17 > 0.0D || facing == 3 && var19 < 0.0D) + { + slot = 1; + } + + ItemStack stack = player.getCurrentEquippedItem(); + + if (!logic.isItemInColumn(slot) && stack != null && logic.canHoldItem(stack)) + { + //logic.setInventorySlotContents(slot, stack); + stack = player.inventory.decrStackSize(player.inventory.currentItem, 1); + logic.setInventorySlotContents(slot, stack); + } + else + { + ItemStack insideStack = logic.takeItemInColumn(slot); + + if (insideStack == null) + { + insideStack = logic.takeItemInColumn(1 - slot); + } + + if (insideStack != null) + { + this.spawnItem(world, x, y, z, insideStack); + } + } + + world.markBlockForUpdate(x, y, z); + } + + return true; + } + } + + protected void spawnItem(World world, int x, int y, int z, ItemStack stack) + { + if (!world.isRemote) + { + EntityItem var6 = new EntityItem(world, (double)x + 0.5D, (double)y + 0.5D, (double)z + 0.5D, stack); + var6.delayBeforeCanPickup = 5; + int var7 = world.getBlockMetadata(x, y, z) & 3; + var6.motionX = var6.motionY = var6.motionZ = 0.0D; + + if (var7 == 0) + { + var6.motionZ = 0.05D; + } + else if (var7 == 1) + { + var6.motionX = 0.05D; + } + else if (var7 == 2) + { + var6.motionZ = -0.05D; + } + else if (var7 == 3) + { + var6.motionX = -0.05D; + } + + world.spawnEntityInWorld(var6); + } + } + + public void setBounds(int metadata) + { + int facing = metadata / 4; + + if (facing == 0) + { + this.setBlockBounds(0.0F, 0.2F, 0.0F, 1.0F, 0.9F, 0.25F); + } + else if (facing == 1) + { + this.setBlockBounds(0.0F, 0.2F, 0.0F, 0.25F, 0.9F, 1.0F); + } + else if (facing == 2) + { + this.setBlockBounds(0.0F, 0.2F, 0.75F, 1.0F, 0.9F, 1.0F); + } + else if (facing == 3) + { + this.setBlockBounds(0.75F, 0.2F, 0.0F, 1.0F, 0.9F, 1.0F); + } + } +} diff --git a/tinker/armory/content/ToolrackItem.java b/tinker/armory/content/ToolrackItem.java new file mode 100644 index 00000000..d7b81760 --- /dev/null +++ b/tinker/armory/content/ToolrackItem.java @@ -0,0 +1,29 @@ +package tinker.armory.content; + +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; + +public class ToolrackItem extends ItemBlock +{ + public ToolrackItem(int id) + { + super(id); + setMaxDamage(0); + setHasSubtypes(true); + } + + @Override + public int getMetadata(int md) + { + return md; + } + + public String getItemNameIS(ItemStack itemstack) + { + return (new StringBuilder()).append("block.").append(blockType[itemstack.getItemDamage()]).append("Toolrack").toString(); + } + public static final String blockType[] = + { + "stone", "stonebrick", "brick", "obsidian" + }; +} diff --git a/tinker/armory/content/ToolrackLogic.java b/tinker/armory/content/ToolrackLogic.java new file mode 100644 index 00000000..876aa1b6 --- /dev/null +++ b/tinker/armory/content/ToolrackLogic.java @@ -0,0 +1,201 @@ +package tinker.armory.content; + +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.network.INetworkManager; +import net.minecraft.network.packet.Packet; +import net.minecraft.network.packet.Packet132TileEntityData; +import net.minecraft.tileentity.TileEntity; + +public class ToolrackLogic extends TileEntity + implements IInventory +{ + ItemStack[] tools; + + public ToolrackLogic() + { + tools = new ItemStack[2]; + } + + @Override + public int getSizeInventory() + { + return 2; + } + + @Override + public ItemStack getStackInSlot(int slot) + { + return tools[slot]; + } + + @Override + public ItemStack decrStackSize(int slot, int quantity) + { + if (this.tools[slot] == null) + return null; + + else + { + ItemStack stack; + + if (this.tools[slot].stackSize <= quantity) + { + stack = this.tools[slot]; + this.tools[slot] = null; + } + else + { + stack = this.tools[slot].splitStack(quantity); + + if (this.tools[slot].stackSize == 0) + { + this.tools[slot] = null; + } + } + + this.onInventoryChanged(); + return stack; + } + } + + @Override + public ItemStack getStackInSlotOnClosing(int var1) + { + return null; + } + + @Override + public void setInventorySlotContents(int slot, ItemStack stack) + { + this.updateItem(slot, stack); + + if (stack != null && stack.stackSize > this.getInventoryStackLimit()) + { + stack.stackSize = this.getInventoryStackLimit(); + } + + this.onInventoryChanged(); + } + + void updateItem(int slot, ItemStack stack) + { + this.tools[slot] = stack.copy(); + //System.out.println("Item name: "+tools[slot].getItemName()); + //float var3 = 45.0F; + + /*if (mod_ToolRack.reversedItems.contains(Integer.valueOf(var2.itemID))) + { + var3 = -45.0F; + } + else if (mod_ToolRack.straightItems.contains(Integer.valueOf(var2.itemID))) + { + var3 = 0.0F; + }*/ + + //this.rotations[var1] = var3; + } + + public boolean canHoldItem(ItemStack stack) + { + return stack.getMaxStackSize() == 1; + //return var1.getMaxStackSize() == 1 || mod_ToolRack.additionalTools.contains(Integer.valueOf(var1.itemID)); + } + + public boolean isItemInColumn(int var1) + { + return this.tools[var1] != null; + } + + public ItemStack takeItemInColumn(int var1) + { + return this.tools[var1] != null ? this.decrStackSize(var1, 1) : null; + } + + + @Override + public String getInvName() + { + return "Toolrack"; + } + + @Override + public int getInventoryStackLimit() + { + return 1; + } + + @Override + public boolean isUseableByPlayer(EntityPlayer player) + { + return true; + } + + @Override + public void openChest() + { + + } + + @Override + public void closeChest() + { + + } + + @Override + public void readFromNBT(NBTTagCompound var1) + { + super.readFromNBT(var1); + NBTTagList tagList = var1.getTagList("Items"); + this.tools = new ItemStack[this.getSizeInventory()]; + + for (int iter = 0; iter < tagList.tagCount(); ++iter) + { + NBTTagCompound tagCompund = (NBTTagCompound)tagList.tagAt(iter); + int slot = tagCompund.getByte("Slot"); + + if (slot >= 0 && slot < this.tools.length) + { + this.updateItem(slot, ItemStack.loadItemStackFromNBT(tagCompund)); + } + } + } + + @Override + public void writeToNBT(NBTTagCompound var1) + { + super.writeToNBT(var1); + NBTTagList tagList = new NBTTagList(); + + for (byte iter = 0; iter < this.tools.length; ++iter) + { + if (this.tools[iter] != null) + { + NBTTagCompound tagCompound = new NBTTagCompound(); + tagCompound.setByte("Slot", iter); + this.tools[iter].writeToNBT(tagCompound); + tagList.appendTag(tagCompound); + } + } + + var1.setTag("Items", tagList); + } + + @Override + public Packet getDescriptionPacket() + { + NBTTagCompound compound = new NBTTagCompound(); + this.writeToNBT(compound); + return new Packet132TileEntityData(this.xCoord, this.yCoord, this.zCoord, 1, compound); + } + + @Override + public void onDataPacket(INetworkManager net, Packet132TileEntityData pkt) + { + readFromNBT(pkt.customParam1); + } +} diff --git a/tinker/common/IFacingLogic.java b/tinker/common/IFacingLogic.java index 28f14f0d..288be79d 100644 --- a/tinker/common/IFacingLogic.java +++ b/tinker/common/IFacingLogic.java @@ -1,8 +1,5 @@ package tinker.common; -import net.minecraftforge.common.ForgeDirection; -import net.minecraftforge.common.ISidedInventory; - public interface IFacingLogic { public boolean canFaceVertical(); diff --git a/tinker/common/IMechanicalLogic.java b/tinker/common/IMechanicalLogic.java new file mode 100644 index 00000000..2b9136a9 --- /dev/null +++ b/tinker/common/IMechanicalLogic.java @@ -0,0 +1,6 @@ +package tinker.common; + +public interface IMechanicalLogic +{ + +} \ No newline at end of file diff --git a/tinker/tconstruct/EnumMaterial.java b/tinker/tconstruct/EnumMaterial.java index c44c5d3a..179cd94f 100644 --- a/tinker/tconstruct/EnumMaterial.java +++ b/tinker/tconstruct/EnumMaterial.java @@ -17,8 +17,8 @@ public enum EnumMaterial Cobalt (4, 800, 800, 3, 1.8F, 2, 0), Ardite (4, 800, 800, 3, 1.8F, 0, 0), Manyullyn (5, 1200, 1000, 4, 2.5F, 0, 0), - Copper (1, 180, 500, 2, 1.8F, 0, 0), - Bronze (2, 250, 600, 2, 2.5F, 1, 0), + Copper (1, 180, 500, 2, 1.15F, 0, 0), + Bronze (2, 250, 600, 2, 1.3F, 1, 0), Demonite (5, 1790, 900, 5, 1.66F, 0, 0), Holyshell (5, 1000, 700, 1, 1.5F, 0, 0); diff --git a/tinker/tconstruct/PHConstruct.java b/tinker/tconstruct/PHConstruct.java index c5bd818f..1e93340d 100644 --- a/tinker/tconstruct/PHConstruct.java +++ b/tinker/tconstruct/PHConstruct.java @@ -47,6 +47,7 @@ public class PHConstruct { ores = config.getBlock("Ore Block", 1475).getInt(1475); craftedSoil = config.getBlock("Special Soil", 1476).getInt(1476); searedBrick = config.getBlock("Seared Brick", 1477).getInt(1477); + axle = config.getBlock("Axle", 1478).getInt(1478); blankPattern = config.getItem("Patterns and Misc", "Blank Patterns", 14019).getInt(14019); materials = config.getItem("Patterns and Misc", "Materials", 14020).getInt(14020); @@ -92,18 +93,17 @@ public class PHConstruct { } //Blocks - public static int blankPattern; public static int woodCrafter; - public static int stoneCrafter; - public static int netherCrafter; public static int heldItemBlock; public static int ores; public static int lavaTank; public static int smeltery; public static int craftedSoil; public static int searedBrick; + public static int axle; //Patterns and misc + public static int blankPattern; public static int materials; public static int toolRod; public static int toolShard; diff --git a/tinker/tconstruct/TConstruct.java b/tinker/tconstruct/TConstruct.java index 094e39de..c7fcd4c5 100644 --- a/tinker/tconstruct/TConstruct.java +++ b/tinker/tconstruct/TConstruct.java @@ -27,7 +27,7 @@ import cpw.mods.fml.common.network.NetworkRegistry; * @author: mDiyo */ -@Mod(modid = "TConstruct", name = "TConstruct", version = "mc1.4.7_1.0.3") +@Mod(modid = "TConstruct", name = "TConstruct", version = "mc1.4.7_1.0.6") @NetworkMod(serverSideRequired = false, clientSideRequired = true, channels={"TConstruct"}, packetHandler = tinker.tconstruct.TConstructPacketHandler.class) public class TConstruct { diff --git a/tinker/tconstruct/TConstructContent.java b/tinker/tconstruct/TConstructContent.java index a8270888..459a07ab 100644 --- a/tinker/tconstruct/TConstructContent.java +++ b/tinker/tconstruct/TConstructContent.java @@ -38,6 +38,7 @@ import tinker.tconstruct.tools.Rapier; import tinker.tconstruct.tools.Shovel; import tinker.tconstruct.tools.ToolCore; import cpw.mods.fml.common.IFuelHandler; +import cpw.mods.fml.common.registry.EntityRegistry; import cpw.mods.fml.common.registry.GameRegistry; public class TConstructContent @@ -85,20 +86,20 @@ public class TConstructContent //Crafting blocks public static Block woodCrafter; public static Block smeltery; - //public static Block stoneCrafter; - //public static Block netherCrafter; public static Block heldItemBlock; public static Block ores; public static Block lavaTank; public static Block craftedSoil; public static Block searedBrick; + //public static Block axle; //Tool modifiers public static ModElectric modE; public TConstructContent() { + createEntities(); createItems(); registerMaterials(); addToolRecipes(); @@ -107,6 +108,11 @@ public class TConstructContent GameRegistry.registerFuelHandler(this); } + void createEntities() + { + EntityRegistry.registerModEntity(tinker.tconstruct.entity.EntityWagon.class, "Small Wagon", 0, TConstruct.instance, 32, 5, true); + } + void createItems () { woodCrafter = new ToolStationBlock(PHConstruct.woodCrafter, Material.wood); diff --git a/tinker/tconstruct/blocks/Axle.java b/tinker/tconstruct/blocks/Axle.java new file mode 100644 index 00000000..feb6c86f --- /dev/null +++ b/tinker/tconstruct/blocks/Axle.java @@ -0,0 +1,89 @@ +package tinker.tconstruct.blocks; + +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import tinker.tconstruct.client.AxleRender; + +public class Axle extends Block +{ + + public Axle(int id, Material material) + { + super(id, material); + this.setHardness(0.3f); + this.setBlockBounds(0, 0, 0, 1, 0.25f, 1); + //this.setCreativeTab(ToolConstruct.materialTab); + } + + /*public String getTextureFile() + { + return "/tinkertextures/ConstructBlocks.png"; + }*/ + + public int getBlockTextureFromSideAndMetadata (int side, int meta) + { + //return 22 + meta*6 + side; + return 18; + } + + @Override + public boolean renderAsNormalBlock () + { + return false; + } + + @Override + public boolean isOpaqueCube () + { + return false; + } + + @Override + public int getRenderType () + { + return AxleRender.axleModelID; + } + + @Override + public int idDropped (int par1, Random par2Random, int par3) + { + return 0; + } + + /*public TileEntity createNewTileEntity (World world, int metadata) + { + return new FrypanLogic(); + }*/ + + /*public void randomDisplayTick (World world, int x, int y, int z, Random random) + { + if (isActive(world, x, y, z)) + { + float f = (float) x + 0.5F; + float f1 = (float) y + 0.25F + (random.nextFloat() * 6F) / 16F; + float f2 = (float) z + 0.5F; + float f4 = random.nextFloat() * 0.6F - 0.3F; + world.spawnParticle("smoke", f, f1, f2 + f4, 0.0D, 0.0D, 0.0D); + world.spawnParticle("flame", f, f1, f2 + f4, 0.0D, 0.0D, 0.0D); + } + } + + public int getLightValue (IBlockAccess world, int x, int y, int z) + { + return !isActive(world, x, y, z) ? 0 : 9; + } + + @Override + public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer) + { + return TConstructGuiHandler.frypanID; + } + + @Override + public Object getModInstance () + { + return TConstruct.instance; + }*/ +} diff --git a/tinker/tconstruct/client/AxleRender.java b/tinker/tconstruct/client/AxleRender.java new file mode 100644 index 00000000..5f79be5a --- /dev/null +++ b/tinker/tconstruct/client/AxleRender.java @@ -0,0 +1,72 @@ +package tinker.tconstruct.client; + +import org.lwjgl.opengl.GL11; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.world.IBlockAccess; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import cpw.mods.fml.client.registry.RenderingRegistry; + +public class AxleRender implements ISimpleBlockRenderingHandler +{ + public static int axleModelID = RenderingRegistry.getNextAvailableRenderId(); + @Override + public void renderInventoryBlock (Block block, int metadata, int modelID, RenderBlocks renderer) + { + renderer.setRenderBounds(0.375F, 0.0F, 0.375F, 0.625F, 1.0F, 0.625F); + renderDo(renderer, block, metadata); + } + + @Override + public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelID, RenderBlocks renderer) + { + renderer.setRenderBounds(0.375F, 0.0F, 0.375F, 0.625F, 1.0F, 0.625F); + renderer.renderStandardBlock(block, x, y, z); + return false; + } + + @Override + public boolean shouldRender3DInInventory () + { + return true; + } + + @Override + public int getRenderId () + { + return axleModelID; + } + + private void renderDo(RenderBlocks renderblocks, Block block, int meta) + { + Tessellator tessellator = Tessellator.instance; + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, -1F, 0.0F); + renderblocks.renderBottomFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(0, meta)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + renderblocks.renderTopFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(1, meta)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, -1F); + renderblocks.renderEastFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(2, meta)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + renderblocks.renderWestFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(3, meta)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(-1F, 0.0F, 0.0F); + renderblocks.renderNorthFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(4, meta)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(1.0F, 0.0F, 0.0F); + renderblocks.renderSouthFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(5, meta)); + tessellator.draw(); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + } +} diff --git a/tinker/tconstruct/client/RenderWagon.java b/tinker/tconstruct/client/RenderWagon.java new file mode 100644 index 00000000..dee11706 --- /dev/null +++ b/tinker/tconstruct/client/RenderWagon.java @@ -0,0 +1,135 @@ +package tinker.tconstruct.client; + +import net.minecraft.block.Block; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelMinecart; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.entity.Render; +import net.minecraft.entity.Entity; +import net.minecraft.util.MathHelper; +import net.minecraft.util.Vec3; + +import org.lwjgl.opengl.GL11; + +import tinker.tconstruct.entity.EntityWagon; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class RenderWagon extends Render +{ + /** instance of ModelMinecart for rendering */ + protected ModelBase modelMinecart; + + public RenderWagon() + { + this.shadowSize = 0.5F; + this.modelMinecart = new ModelMinecart(); + } + + /** + * Renders the Minecart. + */ + public void renderTheMinecart(EntityWagon wagon, double par2, double par4, double par6, float par8, float par9) + { + GL11.glPushMatrix(); + long var10 = (long)wagon.entityId * 493286711L; + var10 = var10 * var10 * 4392167121L + var10 * 98761L; + float var12 = (((float)(var10 >> 16 & 7L) + 0.5F) / 8.0F - 0.5F) * 0.004F; + float var13 = (((float)(var10 >> 20 & 7L) + 0.5F) / 8.0F - 0.5F) * 0.004F; + float var14 = (((float)(var10 >> 24 & 7L) + 0.5F) / 8.0F - 0.5F) * 0.004F; + GL11.glTranslatef(var12, var13, var14); + double var15 = wagon.lastTickPosX + (wagon.posX - wagon.lastTickPosX) * (double)par9; + double var17 = wagon.lastTickPosY + (wagon.posY - wagon.lastTickPosY) * (double)par9; + double var19 = wagon.lastTickPosZ + (wagon.posZ - wagon.lastTickPosZ) * (double)par9; + double var21 = 0.30000001192092896D; + Vec3 var23 = wagon.func_70489_a(var15, var17, var19); + float var24 = wagon.prevRotationPitch + (wagon.rotationPitch - wagon.prevRotationPitch) * par9; + + if (var23 != null) + { + Vec3 var25 = wagon.func_70495_a(var15, var17, var19, var21); + Vec3 var26 = wagon.func_70495_a(var15, var17, var19, -var21); + + if (var25 == null) + { + var25 = var23; + } + + if (var26 == null) + { + var26 = var23; + } + + par2 += var23.xCoord - var15; + par4 += (var25.yCoord + var26.yCoord) / 2.0D - var17; + par6 += var23.zCoord - var19; + Vec3 var27 = var26.addVector(-var25.xCoord, -var25.yCoord, -var25.zCoord); + + if (var27.lengthVector() != 0.0D) + { + var27 = var27.normalize(); + par8 = (float)(Math.atan2(var27.zCoord, var27.xCoord) * 180.0D / Math.PI); + var24 = (float)(Math.atan(var27.yCoord) * 73.0D); + } + } + + GL11.glTranslatef((float)par2, (float)par4, (float)par6); + GL11.glRotatef(180.0F - par8, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-var24, 0.0F, 0.0F, 1.0F); + float var28 = (float)wagon.func_70496_j() - par9; + float var30 = (float)wagon.getDamage() - par9; + + if (var30 < 0.0F) + { + var30 = 0.0F; + } + + if (var28 > 0.0F) + { + GL11.glRotatef(MathHelper.sin(var28) * var28 * var30 / 10.0F * (float)wagon.func_70493_k(), 1.0F, 0.0F, 0.0F); + } + + if (wagon.minecartType != 0) + { + this.loadTexture("/terrain.png"); + float var29 = 0.75F; + GL11.glScalef(var29, var29, var29); + + if (wagon.minecartType == 1) + { + GL11.glTranslatef(0.0F, 0.5F, 0.0F); + (new RenderBlocks()).renderBlockAsItem(Block.chest, 0, wagon.getBrightness(par9)); + GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(0.5F, 0.0F, -0.5F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + } + else if (wagon.minecartType == 2) + { + GL11.glTranslatef(0.0F, 0.3125F, 0.0F); + (new RenderBlocks()).renderBlockAsItem(Block.stoneOvenIdle, 0, wagon.getBrightness(par9)); + GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(0.0F, -0.3125F, 0.0F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + } + + GL11.glScalef(1.0F / var29, 1.0F / var29, 1.0F / var29); + } + + this.loadTexture("/tinkertextures/entity/wagon.png"); + GL11.glScalef(-1.0F, -1.0F, 1.0F); + this.modelMinecart.render(wagon, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); + GL11.glPopMatrix(); + } + + /** + * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then + * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic + * (Render= 10 && i < 37) - { - if (!mergeItemStack(itemstack1, 37, 46, false)) - { - return null; - } - } - else if (i >= 37 && i < 46) - { - if (!mergeItemStack(itemstack1, 10, 37, false)) - { - return null; - } - } - else if (!mergeItemStack(itemstack1, 10, 46, false)) + else if (!this.mergeItemStack(slotStack, 0, logic.getSizeInventory()-1, false)) { return null; } - if (itemstack1.stackSize == 0) + + if (slotStack.stackSize == 0) { - slot.putStack(null); + slot.putStack((ItemStack)null); } else { slot.onSlotChanged(); } - if (itemstack1.stackSize != itemstack.stackSize) - { - slot.onPickupFromSlot(entityplayer, itemstack1); - } - else - { - return null; - } } - return itemstack;*/ + + return stack;*/ } + } diff --git a/tinker/tconstruct/client/gui/PatternShaperGui.java b/tinker/tconstruct/client/gui/PatternShaperGui.java index 1c5e232f..7f83fdb4 100644 --- a/tinker/tconstruct/client/gui/PatternShaperGui.java +++ b/tinker/tconstruct/client/gui/PatternShaperGui.java @@ -84,7 +84,7 @@ public class PatternShaperGui extends GuiContainer if (button.id == 0) { patternIndex++; - if (patternIndex > TConstructContent.patternOutputs.length) + if (patternIndex > TConstructContent.patternOutputs.length - 1) patternIndex = 0; } else if (button.id == 1) @@ -109,13 +109,12 @@ public class PatternShaperGui extends GuiContainer try { outputStream.writeByte(2); - outputStream.writeInt(logic.worldObj.getWorldInfo().getDimension()); + outputStream.writeInt(logic.worldObj.provider.dimensionId); outputStream.writeInt(logic.xCoord); outputStream.writeInt(logic.yCoord); outputStream.writeInt(logic.zCoord); outputStream.writeShort(stack.itemID); outputStream.writeShort(stack.getItemDamage()); - //outputStream.writeUTF(toolName); } catch (Exception ex) { diff --git a/tinker/tconstruct/client/gui/ToolStationContainer.java b/tinker/tconstruct/client/gui/ToolStationContainer.java index 5fbea25f..772fd7b0 100644 --- a/tinker/tconstruct/client/gui/ToolStationContainer.java +++ b/tinker/tconstruct/client/gui/ToolStationContainer.java @@ -5,7 +5,9 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import tinker.tconstruct.logic.ToolStationLogic; +import tinker.tconstruct.tools.ToolCore; public class ToolStationContainer extends Container { @@ -87,20 +89,25 @@ public class ToolStationContainer extends Container { ItemStack slotStack = slot.getStack(); stack = slotStack.copy(); - if (slotID < logic.getSizeInventory()) { - System.out.println("Merging itemstack, true"); - if (!this.mergeItemStack(slotStack, logic.getSizeInventory(), this.inventorySlots.size(), true)) + if (slotID == 0) + { + if (!this.mergeCraftedStack(slotStack, logic.getSizeInventory(), this.inventorySlots.size(), true, player)) + { + return null; + } + } + else if (!this.mergeItemStack(slotStack, logic.getSizeInventory(), this.inventorySlots.size(), true)) { return null; } } - else if (!this.mergeItemStack(slotStack, 1, logic.getSizeInventory() - 1, false)) + else if (!this.mergeItemStack(slotStack, 1, logic.getSizeInventory(), false)) { return null; } - + if (slotStack.stackSize == 0) { slot.putStack((ItemStack)null); @@ -114,58 +121,110 @@ public class ToolStationContainer extends Container return stack; } - /*@Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) + protected void craftTool(ItemStack stack) { - //this.mergeItemStack(slotStack, logic.getSizeInventory(), this.inventorySlots.size(), true) - ItemStack itemstack = null; - Slot slot = (Slot)inventorySlots.get(slotID); - if (slot != null && slot.getHasStack()) + NBTTagCompound tags = stack.getTagCompound(); + if (!tags.getCompoundTag("InfiTool").hasKey("Built")) + { + tags.getCompoundTag("InfiTool").setBoolean("Built", true); + for (int i = 1; i <= 3; i++) + logic.decrStackSize(i, 1); + /*if (!player.worldObj.isRemote) + player.worldObj.playAuxSFX(1021, (int)player.posX, (int)player.posY, (int)player.posZ, 0);*/ + } + } + + protected boolean mergeCraftedStack(ItemStack stack, int slotsStart, int slotsTotal, boolean playerInventory, EntityPlayer player) + { + boolean failedToMerge = false; + int slotIndex = slotsStart; + + if (playerInventory) { - ItemStack slotStack = slot.getStack(); - itemstack = slotStack.copy(); - if (slotID == 0) + slotIndex = slotsTotal - 1; + } + + Slot otherInventorySlot; + ItemStack copyStack = null; + + /*if (stack.isStackable()) + { + while (stack.stackSize > 0 && (!playerInventory && slotIndex < slotsTotal || playerInventory && slotIndex >= slotsStart)) { - if (!mergeItemStack(slotStack, 4, 40, true)) //10 = size of crafting grid, 46 = total, 0 == output slot + otherInventorySlot = (Slot)this.inventorySlots.get(slotIndex); + copyStack = otherInventorySlot.getStack(); + + if (copyStack != null && copyStack.itemID == stack.itemID && (!stack.getHasSubtypes() || stack.getItemDamage() == copyStack.getItemDamage()) && ItemStack.areItemStackTagsEqual(stack, copyStack)) { - return null; + int totalSize = copyStack.stackSize + stack.stackSize; + + if (totalSize <= stack.getMaxStackSize()) + { + stack.stackSize = 0; + copyStack.stackSize = totalSize; + otherInventorySlot.onSlotChanged(); + failedToMerge = true; + } + else if (copyStack.stackSize < stack.getMaxStackSize()) + { + stack.stackSize -= stack.getMaxStackSize() - copyStack.stackSize; + copyStack.stackSize = stack.getMaxStackSize(); + otherInventorySlot.onSlotChanged(); + failedToMerge = true; + } + } + + if (playerInventory) + { + --slotIndex; + } + else + { + ++slotIndex; } } - else if (slotID >= 4 && slotID < 37) + }*/ + + if (stack.stackSize > 0) + { + if (playerInventory) { - if (!mergeItemStack(slotStack, 37, 40, false)) - { - return null; - } - } - else if (slotID >= 37 && slotID < 40) - { - if (!mergeItemStack(slotStack, 4, 37, false)) - { - return null; - } - } - else if (!mergeItemStack(slotStack, 4, 40, false)) - { - return null; - } - if (slotStack.stackSize == 0) - { - slot.putStack(null); + slotIndex = slotsTotal - 1; } else { - slot.onSlotChanged(); + slotIndex = slotsStart; } - if (slotStack.stackSize != itemstack.stackSize) + + while (!playerInventory && slotIndex < slotsTotal || playerInventory && slotIndex >= slotsStart) { - slot.onPickupFromSlot(player, slotStack); - } - else - { - return null; + otherInventorySlot = (Slot)this.inventorySlots.get(slotIndex); + copyStack = otherInventorySlot.getStack(); + + if (copyStack == null) + { + craftTool(stack); + otherInventorySlot.putStack(stack.copy()); + otherInventorySlot.onSlotChanged(); + stack.stackSize = 0; + failedToMerge = true; + break; + } + + if (playerInventory) + { + --slotIndex; + } + else + { + ++slotIndex; + } } } - return itemstack; - }*/ + + if (!failedToMerge) + player.worldObj.playAuxSFX(1021, (int)player.posX, (int)player.posY, (int)player.posZ, 0); + + return failedToMerge; + } } diff --git a/tinker/tconstruct/client/gui/ToolStationGui.java b/tinker/tconstruct/client/gui/ToolStationGui.java index ac3c814c..cf4bd9b0 100644 --- a/tinker/tconstruct/client/gui/ToolStationGui.java +++ b/tinker/tconstruct/client/gui/ToolStationGui.java @@ -343,7 +343,7 @@ public class ToolStationGui extends GuiContainer try { outputStream.writeByte(1); - outputStream.writeInt(logic.worldObj.getWorldInfo().getDimension()); + outputStream.writeInt(logic.worldObj.provider.dimensionId); outputStream.writeInt(logic.xCoord); outputStream.writeInt(logic.yCoord); outputStream.writeInt(logic.zCoord); diff --git a/tinker/tconstruct/crafting/ToolBuilder.java b/tinker/tconstruct/crafting/ToolBuilder.java index 140560b6..a0efece4 100644 --- a/tinker/tconstruct/crafting/ToolBuilder.java +++ b/tinker/tconstruct/crafting/ToolBuilder.java @@ -60,7 +60,7 @@ public class ToolBuilder //System.out.println("Tool name: "+item.getToolName()); int head = headStack.getItemDamage(); - System.out.println("Head:"+head); + //System.out.println("Head:"+head); int handle = handleStack.getItemDamage(); int accessory = -1; if (accessoryStack != null) diff --git a/tinker/tconstruct/entity/EntityWagon.java b/tinker/tconstruct/entity/EntityWagon.java new file mode 100644 index 00000000..28d1ab1a --- /dev/null +++ b/tinker/tconstruct/entity/EntityWagon.java @@ -0,0 +1,1492 @@ +package tinker.tconstruct.entity; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockRail; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.monster.EntityIronGolem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; +import net.minecraft.world.WorldServer; +import net.minecraftforge.common.IMinecartCollisionHandler; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.minecart.MinecartCollisionEvent; +import net.minecraftforge.event.entity.minecart.MinecartInteractEvent; +import net.minecraftforge.event.entity.minecart.MinecartUpdateEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class EntityWagon extends Entity implements IInventory +{ + /** Array of item stacks stored in minecart (for storage minecarts). */ + protected ItemStack[] cargoItems; + protected int fuel; + protected boolean field_70499_f; + + /** The type of minecart, 2 for powered, 1 for storage. */ + public int minecartType; + public double pushX; + public double pushZ; + protected boolean field_82345_h; + + /** Minecart rotational logic matrix */ + protected static final int[][][] matrix = new int[][][] {{{0, 0, -1}, {0, 0, 1}}, {{ -1, 0, 0}, {1, 0, 0}}, {{ -1, -1, 0}, {1, 0, 0}}, {{ -1, 0, 0}, {1, -1, 0}}, {{0, 0, -1}, {0, -1, 1}}, {{0, -1, -1}, {0, 0, 1}}, {{0, 0, 1}, {1, 0, 0}}, {{0, 0, 1}, { -1, 0, 0}}, {{0, 0, -1}, { -1, 0, 0}}, {{0, 0, -1}, {1, 0, 0}}}; + + /** appears to be the progress of the turn */ + protected int turnProgress; + protected double minecartX; + protected double minecartY; + protected double minecartZ; + protected double minecartYaw; + protected double minecartPitch; + @SideOnly(Side.CLIENT) + protected double velocityX; + @SideOnly(Side.CLIENT) + protected double velocityY; + @SideOnly(Side.CLIENT) + protected double velocityZ; + + /* Forge: Minecart Compatibility Layer Integration. */ + public static float defaultMaxSpeedRail = 0.4f; + public static float defaultMaxSpeedGround = 0.4f; + public static float defaultMaxSpeedAirLateral = 0.4f; + public static float defaultMaxSpeedAirVertical = -1f; + public static double defaultDragRidden = 0.996999979019165D; + public static double defaultDragEmpty = 0.9599999785423279D; + public static double defaultDragAir = 0.94999998807907104D; + protected boolean canUseRail = true; + protected boolean canBePushed = true; + private static IMinecartCollisionHandler collisionHandler = null; + + /* Instance versions of the above physics properties */ + protected float maxSpeedRail; + protected float maxSpeedGround; + protected float maxSpeedAirLateral; + protected float maxSpeedAirVertical; + protected double dragAir; + + public EntityWagon(World par1World) + { + super(par1World); + this.cargoItems = new ItemStack[36]; + this.fuel = 0; + this.field_70499_f = false; + this.field_82345_h = true; + this.preventEntitySpawning = true; + this.setSize(0.98F, 0.7F); + this.yOffset = this.height / 2.0F; + + maxSpeedRail = defaultMaxSpeedRail; + maxSpeedGround = defaultMaxSpeedGround; + maxSpeedAirLateral = defaultMaxSpeedAirLateral; + maxSpeedAirVertical = defaultMaxSpeedAirVertical; + dragAir = defaultDragAir; + } + + public EntityWagon(World world, int type) + { + this(world); + minecartType = type; + } + + /** + * returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to + * prevent them from trampling crops + */ + protected boolean canTriggerWalking() + { + return false; + } + + protected void entityInit() + { + this.dataWatcher.addObject(16, new Byte((byte)0)); + this.dataWatcher.addObject(17, new Integer(0)); + this.dataWatcher.addObject(18, new Integer(1)); + this.dataWatcher.addObject(19, new Integer(0)); + } + + /** + * Returns a boundingBox used to collide the entity with other entities and blocks. This enables the entity to be + * pushable on contact, like boats or minecarts. + */ + public AxisAlignedBB getCollisionBox(Entity par1Entity) + { + return par1Entity.boundingBox; + } + + /** + * returns the bounding box for this entity + */ + public AxisAlignedBB getBoundingBox() + { + return this.boundingBox; + } + + /** + * Returns true if this entity should push and be pushed by other entities when colliding. + */ + public boolean canBePushed() + { + return canBePushed; + } + + public EntityWagon(World par1World, double par2, double par4, double par6, int par8) + { + this(par1World); + this.setPosition(par2, par4 + (double)this.yOffset, par6); + this.motionX = 0.0D; + this.motionY = 0.0D; + this.motionZ = 0.0D; + this.prevPosX = par2; + this.prevPosY = par4; + this.prevPosZ = par6; + this.minecartType = par8; + } + + /** + * Returns the Y offset from the entity's position for any entity riding this one. + */ + public double getMountedYOffset() + { + return (double)this.height * 0.0D - 0.30000001192092896D; + } + + /** + * Called when the entity is attacked. + */ + public boolean attackEntityFrom(DamageSource par1DamageSource, int par2) + { + if (!this.worldObj.isRemote && !this.isDead) + { + if (this.isEntityInvulnerable()) + { + return false; + } + else + { + this.func_70494_i(-this.func_70493_k()); + this.func_70497_h(10); + this.setBeenAttacked(); + this.setDamage(this.getDamage() + par2 * 10); + + if (par1DamageSource.getEntity() instanceof EntityPlayer && ((EntityPlayer)par1DamageSource.getEntity()).capabilities.isCreativeMode) + { + this.setDamage(100); + } + + if (this.getDamage() > 40) + { + if (this.riddenByEntity != null) + { + this.riddenByEntity.mountEntity(this); + } + + this.setDead(); + dropCartAsItem(); + } + + return true; + } + } + else + { + return true; + } + } + + @SideOnly(Side.CLIENT) + + /** + * Setups the entity to do the hurt animation. Only used by packets in multiplayer. + */ + public void performHurtAnimation() + { + this.func_70494_i(-this.func_70493_k()); + this.func_70497_h(10); + this.setDamage(this.getDamage() + this.getDamage() * 10); + } + + /** + * Returns true if other Entities should be prevented from moving through this Entity. + */ + public boolean canBeCollidedWith() + { + return !this.isDead; + } + + /** + * Will get destroyed next tick. + */ + public void setDead() + { + if (this.field_82345_h) + { + for (int var1 = 0; var1 < this.getSizeInventory(); ++var1) + { + ItemStack var2 = this.getStackInSlot(var1); + + if (var2 != null) + { + float var3 = this.rand.nextFloat() * 0.8F + 0.1F; + float var4 = this.rand.nextFloat() * 0.8F + 0.1F; + float var5 = this.rand.nextFloat() * 0.8F + 0.1F; + + while (var2.stackSize > 0) + { + int var6 = this.rand.nextInt(21) + 10; + + if (var6 > var2.stackSize) + { + var6 = var2.stackSize; + } + + var2.stackSize -= var6; + EntityItem var7 = new EntityItem(this.worldObj, this.posX + (double)var3, this.posY + (double)var4, this.posZ + (double)var5, new ItemStack(var2.itemID, var6, var2.getItemDamage())); + + if (var2.hasTagCompound()) + { + var7.func_92014_d().setTagCompound((NBTTagCompound)var2.getTagCompound().copy()); + } + + float var8 = 0.05F; + var7.motionX = (double)((float)this.rand.nextGaussian() * var8); + var7.motionY = (double)((float)this.rand.nextGaussian() * var8 + 0.2F); + var7.motionZ = (double)((float)this.rand.nextGaussian() * var8); + this.worldObj.spawnEntityInWorld(var7); + } + } + } + } + + super.setDead(); + } + + /** + * Teleports the entity to another dimension. Params: Dimension number to teleport to + */ + public void travelToDimension(int par1) + { + this.field_82345_h = false; + super.travelToDimension(par1); + } + + /** + * Called to update the entity's position/logic. + */ + public void onUpdate() + { + + if (this.func_70496_j() > 0) + { + this.func_70497_h(this.func_70496_j() - 1); + } + + if (this.getDamage() > 0) + { + this.setDamage(this.getDamage() - 1); + } + + if (this.posY < -64.0D) + { + this.kill(); + } + + if (this.isMinecartPowered() && this.rand.nextInt(4) == 0 && minecartType == 2 && getClass() == EntityWagon.class) + { + this.worldObj.spawnParticle("largesmoke", this.posX, this.posY + 0.8D, this.posZ, 0.0D, 0.0D, 0.0D); + } + + int var2; + + if (!this.worldObj.isRemote && this.worldObj instanceof WorldServer) + { + this.worldObj.theProfiler.startSection("portal"); + MinecraftServer var1 = ((WorldServer)this.worldObj).getMinecraftServer(); + var2 = this.getMaxInPortalTime(); + + if (this.inPortal) + { + if (var1.getAllowNether()) + { + if (this.ridingEntity == null && this.field_82153_h++ >= var2) + { + this.field_82153_h = var2; + this.timeUntilPortal = this.getPortalCooldown(); + byte var3; + + if (this.worldObj.provider.dimensionId == -1) + { + var3 = 0; + } + else + { + var3 = -1; + } + + this.travelToDimension(var3); + } + + this.inPortal = false; + } + } + else + { + if (this.field_82153_h > 0) + { + this.field_82153_h -= 4; + } + + if (this.field_82153_h < 0) + { + this.field_82153_h = 0; + } + } + + if (this.timeUntilPortal > 0) + { + --this.timeUntilPortal; + } + + this.worldObj.theProfiler.endSection(); + } + + if (this.worldObj.isRemote) + { + if (this.turnProgress > 0) + { + double var46 = this.posX + (this.minecartX - this.posX) / (double)this.turnProgress; + double var48 = this.posY + (this.minecartY - this.posY) / (double)this.turnProgress; + double var5 = this.posZ + (this.minecartZ - this.posZ) / (double)this.turnProgress; + double var7 = MathHelper.wrapAngleTo180_double(this.minecartYaw - (double)this.rotationYaw); + this.rotationYaw = (float)((double)this.rotationYaw + var7 / (double)this.turnProgress); + this.rotationPitch = (float)((double)this.rotationPitch + (this.minecartPitch - (double)this.rotationPitch) / (double)this.turnProgress); + --this.turnProgress; + this.setPosition(var46, var48, var5); + this.setRotation(this.rotationYaw, this.rotationPitch); + } + else + { + this.setPosition(this.posX, this.posY, this.posZ); + this.setRotation(this.rotationYaw, this.rotationPitch); + } + } + else + { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + this.motionY -= 0.03999999910593033D; + int var45 = MathHelper.floor_double(this.posX); + var2 = MathHelper.floor_double(this.posY); + int var47 = MathHelper.floor_double(this.posZ); + + if (BlockRail.isRailBlockAt(this.worldObj, var45, var2 - 1, var47)) + { + --var2; + } + + double var4 = 0.4D; + double var6 = 0.0078125D; + int var8 = this.worldObj.getBlockId(var45, var2, var47); + + /*if (canUseRail() && BlockRail.isRailBlock(var8)) + { + this.fallDistance = 0.0F; + Vec3 var9 = this.func_70489_a(this.posX, this.posY, this.posZ); + int var10 = ((BlockRail)Block.blocksList[var8]).getBasicRailMetadata(worldObj, this, var45, var2, var47); + this.posY = (double)var2; + boolean var11 = false; + boolean var12 = false; + + if (var8 == Block.railPowered.blockID) + { + var11 = (worldObj.getBlockMetadata(var45, var2, var47) & 8) != 0; + var12 = !var11; + } + + if (((BlockRail)Block.blocksList[var8]).isPowered()) + { + var10 &= 7; + } + + if (var10 >= 2 && var10 <= 5) + { + this.posY = (double)(var2 + 1); + } + + adjustSlopeVelocities(var10); + + int[][] var13 = matrix[var10]; + double var14 = (double)(var13[1][0] - var13[0][0]); + double var16 = (double)(var13[1][2] - var13[0][2]); + double var18 = Math.sqrt(var14 * var14 + var16 * var16); + double var20 = this.motionX * var14 + this.motionZ * var16; + + if (var20 < 0.0D) + { + var14 = -var14; + var16 = -var16; + } + + double var22 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ); + this.motionX = var22 * var14 / var18; + this.motionZ = var22 * var16 / var18; + double var24; + double var26; + + if (this.riddenByEntity != null) + { + var24 = this.riddenByEntity.motionX * this.riddenByEntity.motionX + this.riddenByEntity.motionZ * this.riddenByEntity.motionZ; + var26 = this.motionX * this.motionX + this.motionZ * this.motionZ; + + if (var24 > 1.0E-4D && var26 < 0.01D) + { + this.motionX += this.riddenByEntity.motionX * 0.1D; + this.motionZ += this.riddenByEntity.motionZ * 0.1D; + var12 = false; + } + } + + if (var12 && shouldDoRailFunctions()) + { + var24 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ); + + if (var24 < 0.03D) + { + this.motionX *= 0.0D; + this.motionY *= 0.0D; + this.motionZ *= 0.0D; + } + else + { + this.motionX *= 0.5D; + this.motionY *= 0.0D; + this.motionZ *= 0.5D; + } + } + + var24 = 0.0D; + var26 = (double)var45 + 0.5D + (double)var13[0][0] * 0.5D; + double var28 = (double)var47 + 0.5D + (double)var13[0][2] * 0.5D; + double var30 = (double)var45 + 0.5D + (double)var13[1][0] * 0.5D; + double var32 = (double)var47 + 0.5D + (double)var13[1][2] * 0.5D; + var14 = var30 - var26; + var16 = var32 - var28; + double var34; + double var36; + + if (var14 == 0.0D) + { + this.posX = (double)var45 + 0.5D; + var24 = this.posZ - (double)var47; + } + else if (var16 == 0.0D) + { + this.posZ = (double)var47 + 0.5D; + var24 = this.posX - (double)var45; + } + else + { + var34 = this.posX - var26; + var36 = this.posZ - var28; + var24 = (var34 * var14 + var36 * var16) * 2.0D; + } + + this.posX = var26 + var14 * var24; + this.posZ = var28 + var16 * var24; + this.setPosition(this.posX, this.posY + (double)this.yOffset, this.posZ); + + moveMinecartOnRail(var45, var2, var47); + + if (var13[0][1] != 0 && MathHelper.floor_double(this.posX) - var45 == var13[0][0] && MathHelper.floor_double(this.posZ) - var47 == var13[0][2]) + { + this.setPosition(this.posX, this.posY + (double)var13[0][1], this.posZ); + } + else if (var13[1][1] != 0 && MathHelper.floor_double(this.posX) - var45 == var13[1][0] && MathHelper.floor_double(this.posZ) - var47 == var13[1][2]) + { + this.setPosition(this.posX, this.posY + (double)var13[1][1], this.posZ); + } + + applyDragAndPushForces(); + + Vec3 var54 = this.func_70489_a(this.posX, this.posY, this.posZ); + + if (var54 != null && var9 != null) + { + double var39 = (var9.yCoord - var54.yCoord) * 0.05D; + var22 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ); + + if (var22 > 0.0D) + { + this.motionX = this.motionX / var22 * (var22 + var39); + this.motionZ = this.motionZ / var22 * (var22 + var39); + } + + this.setPosition(this.posX, var54.yCoord, this.posZ); + } + + int var53 = MathHelper.floor_double(this.posX); + int var55 = MathHelper.floor_double(this.posZ); + + if (var53 != var45 || var55 != var47) + { + var22 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ); + this.motionX = var22 * (double)(var53 - var45); + this.motionZ = var22 * (double)(var55 - var47); + } + + double var41; + + updatePushForces(); + + if(shouldDoRailFunctions()) + { + ((BlockRail)Block.blocksList[var8]).onMinecartPass(worldObj, this, var45, var2, var47); + } + + if (var11 && shouldDoRailFunctions()) + { + var41 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ); + + if (var41 > 0.01D) + { + double var43 = 0.06D; + this.motionX += this.motionX / var41 * var43; + this.motionZ += this.motionZ / var41 * var43; + } + else if (var10 == 1) + { + if (this.worldObj.isBlockNormalCube(var45 - 1, var2, var47)) + { + this.motionX = 0.02D; + } + else if (this.worldObj.isBlockNormalCube(var45 + 1, var2, var47)) + { + this.motionX = -0.02D; + } + } + else if (var10 == 0) + { + if (this.worldObj.isBlockNormalCube(var45, var2, var47 - 1)) + { + this.motionZ = 0.02D; + } + else if (this.worldObj.isBlockNormalCube(var45, var2, var47 + 1)) + { + this.motionZ = -0.02D; + } + } + } + }*/ + moveMinecartOffRail(var45, var2, var47); + + this.doBlockCollisions(); + this.rotationPitch = 0.0F; + double var49 = this.prevPosX - this.posX; + double var50 = this.prevPosZ - this.posZ; + + if (var49 * var49 + var50 * var50 > 0.001D) + { + this.rotationYaw = (float)(Math.atan2(var50, var49) * 180.0D / Math.PI); + + if (this.field_70499_f) + { + this.rotationYaw += 180.0F; + } + } + + double var51 = (double)MathHelper.wrapAngleTo180_float(this.rotationYaw - this.prevRotationYaw); + + if (var51 < -170.0D || var51 >= 170.0D) + { + this.rotationYaw += 180.0F; + this.field_70499_f = !this.field_70499_f; + } + + this.setRotation(this.rotationYaw, this.rotationPitch); + + AxisAlignedBB box = boundingBox.expand(0.2D, 0.0D, 0.2D); + + List var15 = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, box); + + if (var15 != null && !var15.isEmpty()) + { + for (int var52 = 0; var52 < var15.size(); ++var52) + { + Entity var17 = (Entity)var15.get(var52); + + if (var17 != this.riddenByEntity && var17.canBePushed() && var17 instanceof EntityWagon) + { + var17.applyEntityCollision(this); + } + } + } + + if (this.riddenByEntity != null && this.riddenByEntity.isDead) + { + if (this.riddenByEntity.ridingEntity == this) + { + this.riddenByEntity.ridingEntity = null; + } + + this.riddenByEntity = null; + } + + updateFuel(); + } + } + + @SideOnly(Side.CLIENT) + public Vec3 func_70495_a(double par1, double par3, double par5, double par7) + { + int var9 = MathHelper.floor_double(par1); + int var10 = MathHelper.floor_double(par3); + int var11 = MathHelper.floor_double(par5); + + if (BlockRail.isRailBlockAt(this.worldObj, var9, var10 - 1, var11)) + { + --var10; + } + + int var12 = this.worldObj.getBlockId(var9, var10, var11); + + return null; + } + + public Vec3 func_70489_a(double par1, double par3, double par5) + { + int var7 = MathHelper.floor_double(par1); + int var8 = MathHelper.floor_double(par3); + int var9 = MathHelper.floor_double(par5); + + if (BlockRail.isRailBlockAt(this.worldObj, var7, var8 - 1, var9)) + { + --var8; + } + + int var10 = this.worldObj.getBlockId(var7, var8, var9); + + if (BlockRail.isRailBlock(var10)) + { + int var11 = 0; + par3 = (double)var8; + + if (var11 >= 2 && var11 <= 5) + { + par3 = (double)(var8 + 1); + } + + int[][] var12 = matrix[var11]; + double var13 = 0.0D; + double var15 = (double)var7 + 0.5D + (double)var12[0][0] * 0.5D; + double var17 = (double)var8 + 0.5D + (double)var12[0][1] * 0.5D; + double var19 = (double)var9 + 0.5D + (double)var12[0][2] * 0.5D; + double var21 = (double)var7 + 0.5D + (double)var12[1][0] * 0.5D; + double var23 = (double)var8 + 0.5D + (double)var12[1][1] * 0.5D; + double var25 = (double)var9 + 0.5D + (double)var12[1][2] * 0.5D; + double var27 = var21 - var15; + double var29 = (var23 - var17) * 2.0D; + double var31 = var25 - var19; + + if (var27 == 0.0D) + { + par1 = (double)var7 + 0.5D; + var13 = par5 - (double)var9; + } + else if (var31 == 0.0D) + { + par5 = (double)var9 + 0.5D; + var13 = par1 - (double)var7; + } + else + { + double var33 = par1 - var15; + double var35 = par5 - var19; + var13 = (var33 * var27 + var35 * var31) * 2.0D; + } + + par1 = var15 + var27 * var13; + par3 = var17 + var29 * var13; + par5 = var19 + var31 * var13; + + if (var29 < 0.0D) + { + ++par3; + } + + if (var29 > 0.0D) + { + par3 += 0.5D; + } + + return this.worldObj.getWorldVec3Pool().getVecFromPool(par1, par3, par5); + } + else + { + return null; + } + } + + /** + * (abstract) Protected helper method to write subclass entity data to NBT. + */ + protected void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + par1NBTTagCompound.setInteger("Type", this.minecartType); + + if (isPoweredCart()) + { + par1NBTTagCompound.setDouble("PushX", this.pushX); + par1NBTTagCompound.setDouble("PushZ", this.pushZ); + par1NBTTagCompound.setInteger("Fuel", this.fuel); + } + + if (getSizeInventory() > 0) + { + NBTTagList var2 = new NBTTagList(); + + for (int var3 = 0; var3 < this.cargoItems.length; ++var3) + { + if (this.cargoItems[var3] != null) + { + NBTTagCompound var4 = new NBTTagCompound(); + var4.setByte("Slot", (byte)var3); + this.cargoItems[var3].writeToNBT(var4); + var2.appendTag(var4); + } + } + + par1NBTTagCompound.setTag("Items", var2); + } + } + + /** + * (abstract) Protected helper method to read subclass entity data from NBT. + */ + protected void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + this.minecartType = par1NBTTagCompound.getInteger("Type"); + + if (isPoweredCart()) + { + this.pushX = par1NBTTagCompound.getDouble("PushX"); + this.pushZ = par1NBTTagCompound.getDouble("PushZ"); + try + { + this.fuel = par1NBTTagCompound.getInteger("Fuel"); + } + catch (ClassCastException e) + { + this.fuel = par1NBTTagCompound.getShort("Fuel"); + } + } + + if (getSizeInventory() > 0) + { + NBTTagList var2 = par1NBTTagCompound.getTagList("Items"); + this.cargoItems = new ItemStack[this.getSizeInventory()]; + + for (int var3 = 0; var3 < var2.tagCount(); ++var3) + { + NBTTagCompound var4 = (NBTTagCompound)var2.tagAt(var3); + int var5 = var4.getByte("Slot") & 255; + + if (var5 >= 0 && var5 < this.cargoItems.length) + { + this.cargoItems[var5] = ItemStack.loadItemStackFromNBT(var4); + } + } + } + } + + @SideOnly(Side.CLIENT) + public float getShadowSize() + { + return 0.0F; + } + + /** + * Applies a velocity to each of the entities pushing them away from each other. Args: entity + */ + public void applyEntityCollision(Entity par1Entity) + { + if (!this.worldObj.isRemote) + { + if (par1Entity != this.riddenByEntity) + { + if (par1Entity instanceof EntityLiving && !(par1Entity instanceof EntityPlayer) && !(par1Entity instanceof EntityIronGolem) && canBeRidden() && this.motionX * this.motionX + this.motionZ * this.motionZ > 0.01D && this.riddenByEntity == null && par1Entity.ridingEntity == null) + { + par1Entity.mountEntity(this); + } + + double var2 = par1Entity.posX - this.posX; + double var4 = par1Entity.posZ - this.posZ; + double var6 = var2 * var2 + var4 * var4; + + if (var6 >= 9.999999747378752E-5D) + { + var6 = (double)MathHelper.sqrt_double(var6); + var2 /= var6; + var4 /= var6; + double var8 = 1.0D / var6; + + if (var8 > 1.0D) + { + var8 = 1.0D; + } + + var2 *= var8; + var4 *= var8; + var2 *= 0.10000000149011612D; + var4 *= 0.10000000149011612D; + var2 *= (double)(1.0F - this.entityCollisionReduction); + var4 *= (double)(1.0F - this.entityCollisionReduction); + var2 *= 0.5D; + var4 *= 0.5D; + + if (par1Entity instanceof EntityWagon) + { + double var10 = par1Entity.posX - this.posX; + double var12 = par1Entity.posZ - this.posZ; + Vec3 var14 = this.worldObj.getWorldVec3Pool().getVecFromPool(var10, 0.0D, var12).normalize(); + Vec3 var15 = this.worldObj.getWorldVec3Pool().getVecFromPool((double)MathHelper.cos(this.rotationYaw * (float)Math.PI / 180.0F), 0.0D, (double)MathHelper.sin(this.rotationYaw * (float)Math.PI / 180.0F)).normalize(); + double var16 = Math.abs(var14.dotProduct(var15)); + + if (var16 < 0.800000011920929D) + { + return; + } + + double var18 = par1Entity.motionX + this.motionX; + double var20 = par1Entity.motionZ + this.motionZ; + + if (((EntityWagon)par1Entity).isPoweredCart() && !isPoweredCart()) + { + this.motionX *= 0.20000000298023224D; + this.motionZ *= 0.20000000298023224D; + this.addVelocity(par1Entity.motionX - var2, 0.0D, par1Entity.motionZ - var4); + par1Entity.motionX *= 0.949999988079071D; + par1Entity.motionZ *= 0.949999988079071D; + } + else if (!((EntityWagon)par1Entity).isPoweredCart() && isPoweredCart()) + { + par1Entity.motionX *= 0.20000000298023224D; + par1Entity.motionZ *= 0.20000000298023224D; + par1Entity.addVelocity(this.motionX + var2, 0.0D, this.motionZ + var4); + this.motionX *= 0.949999988079071D; + this.motionZ *= 0.949999988079071D; + } + else + { + var18 /= 2.0D; + var20 /= 2.0D; + this.motionX *= 0.20000000298023224D; + this.motionZ *= 0.20000000298023224D; + this.addVelocity(var18 - var2, 0.0D, var20 - var4); + par1Entity.motionX *= 0.20000000298023224D; + par1Entity.motionZ *= 0.20000000298023224D; + par1Entity.addVelocity(var18 + var2, 0.0D, var20 + var4); + } + } + else + { + this.addVelocity(-var2, 0.0D, -var4); + par1Entity.addVelocity(var2 / 4.0D, 0.0D, var4 / 4.0D); + } + } + } + } + } + + /** + * Returns the number of slots in the inventory. + */ + public int getSizeInventory() + { + return (minecartType == 1 && getClass() == EntityWagon.class ? 27 : 0); + } + + /** + * Returns the stack in slot i + */ + public ItemStack getStackInSlot(int par1) + { + return this.cargoItems[par1]; + } + + /** + * Removes from an inventory slot (first arg) up to a specified number (second arg) of items and returns them in a + * new stack. + */ + public ItemStack decrStackSize(int par1, int par2) + { + if (this.cargoItems[par1] != null) + { + ItemStack var3; + + if (this.cargoItems[par1].stackSize <= par2) + { + var3 = this.cargoItems[par1]; + this.cargoItems[par1] = null; + return var3; + } + else + { + var3 = this.cargoItems[par1].splitStack(par2); + + if (this.cargoItems[par1].stackSize == 0) + { + this.cargoItems[par1] = null; + } + + return var3; + } + } + else + { + return null; + } + } + + /** + * When some containers are closed they call this on each slot, then drop whatever it returns as an EntityItem - + * like when you close a workbench GUI. + */ + public ItemStack getStackInSlotOnClosing(int par1) + { + if (this.cargoItems[par1] != null) + { + ItemStack var2 = this.cargoItems[par1]; + this.cargoItems[par1] = null; + return var2; + } + else + { + return null; + } + } + + /** + * Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections). + */ + public void setInventorySlotContents(int par1, ItemStack par2ItemStack) + { + this.cargoItems[par1] = par2ItemStack; + + if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit()) + { + par2ItemStack.stackSize = this.getInventoryStackLimit(); + } + } + + /** + * Returns the name of the inventory. + */ + public String getInvName() + { + return "container.minecart"; + } + + /** + * Returns the maximum stack size for a inventory slot. Seems to always be 64, possibly will be extended. *Isn't + * this more of a set than a get?* + */ + public int getInventoryStackLimit() + { + return 64; + } + + /** + * Called when an the contents of an Inventory change, usually + */ + public void onInventoryChanged() {} + + /** + * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig. + */ + public boolean interact(EntityPlayer par1EntityPlayer) + { + + if (canBeRidden()) + { + if (this.riddenByEntity != null && this.riddenByEntity instanceof EntityPlayer && this.riddenByEntity != par1EntityPlayer) + { + return true; + } + + if (!this.worldObj.isRemote) + { + par1EntityPlayer.mountEntity(this); + } + } + else if (getSizeInventory() > 0) + { + if (!this.worldObj.isRemote) + { + par1EntityPlayer.displayGUIChest(this); + } + } + else if (this.minecartType == 2 && getClass() == EntityWagon.class) + { + ItemStack var2 = par1EntityPlayer.inventory.getCurrentItem(); + + if (var2 != null && var2.itemID == Item.coal.itemID) + { + if (--var2.stackSize == 0) + { + par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, (ItemStack)null); + } + + this.fuel += 3600; + } + + this.pushX = this.posX - par1EntityPlayer.posX; + this.pushZ = this.posZ - par1EntityPlayer.posZ; + } + + return true; + } + + @SideOnly(Side.CLIENT) + + /** + * Sets the position and rotation. Only difference from the other one is no bounding on the rotation. Args: posX, + * posY, posZ, yaw, pitch + */ + public void setPositionAndRotation2(double par1, double par3, double par5, float par7, float par8, int par9) + { + this.minecartX = par1; + this.minecartY = par3; + this.minecartZ = par5; + this.minecartYaw = (double)par7; + this.minecartPitch = (double)par8; + this.turnProgress = par9 + 2; + this.motionX = this.velocityX; + this.motionY = this.velocityY; + this.motionZ = this.velocityZ; + } + + @SideOnly(Side.CLIENT) + + /** + * Sets the velocity to the args. Args: x, y, z + */ + public void setVelocity(double par1, double par3, double par5) + { + this.velocityX = this.motionX = par1; + this.velocityY = this.motionY = par3; + this.velocityZ = this.motionZ = par5; + } + + /** + * Do not make give this method the name canInteractWith because it clashes with Container + */ + public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer) + { + return this.isDead ? false : par1EntityPlayer.getDistanceSqToEntity(this) <= 64.0D; + } + + /** + * Is this minecart powered (Fuel > 0) + */ + public boolean isMinecartPowered() + { + return (this.dataWatcher.getWatchableObjectByte(16) & 1) != 0; + } + + /** + * Set if this minecart is powered (Fuel > 0) + */ + protected void setMinecartPowered(boolean par1) + { + if (par1) + { + this.dataWatcher.updateObject(16, Byte.valueOf((byte)(this.dataWatcher.getWatchableObjectByte(16) | 1))); + } + else + { + this.dataWatcher.updateObject(16, Byte.valueOf((byte)(this.dataWatcher.getWatchableObjectByte(16) & -2))); + } + } + + public void openChest() {} + + public void closeChest() {} + + /** + * Sets the current amount of damage the minecart has taken. Decreases over time. The cart breaks when this is over + * 40. + */ + public void setDamage(int par1) + { + this.dataWatcher.updateObject(19, Integer.valueOf(par1)); + } + + /** + * Gets the current amount of damage the minecart has taken. Decreases over time. The cart breaks when this is over + * 40. + */ + public int getDamage() + { + return this.dataWatcher.getWatchableObjectInt(19); + } + + public void func_70497_h(int par1) + { + this.dataWatcher.updateObject(17, Integer.valueOf(par1)); + } + + public int func_70496_j() + { + return this.dataWatcher.getWatchableObjectInt(17); + } + + public void func_70494_i(int par1) + { + this.dataWatcher.updateObject(18, Integer.valueOf(par1)); + } + + public int func_70493_k() + { + return this.dataWatcher.getWatchableObjectInt(18); + } + + /** + * Drops the cart as a item. The exact item dropped is defined by getItemDropped(). + */ + public void dropCartAsItem() + { + for(ItemStack item : getItemsDropped()) + { + entityDropItem(item, 0); + } + } + + /** + * Override this to define which items your cart drops when broken. + * This does not include items contained in the inventory, + * that is handled elsewhere. + * @return A list of items dropped. + */ + public List getItemsDropped() + { + List items = new ArrayList(); + items.add(new ItemStack(Item.minecartEmpty)); + + switch(minecartType) + { + case 1: + items.add(new ItemStack(Block.chest)); + break; + case 2: + items.add(new ItemStack(Block.stoneOvenIdle)); + break; + } + return items; + } + + /** + * This function returns an ItemStack that represents this cart. + * This should be an ItemStack that can be used by the player to place the cart. + * This is the item that was registered with the cart via the registerMinecart function, + * but is not necessary the item the cart drops when destroyed. + * @return An ItemStack that can be used to place the cart. + */ + public ItemStack getCartItem() + { + return null; + //return MinecartRegistry.getItemForCart(this); + } + + /** + * Returns true if this cart is self propelled. + * @return True if powered. + */ + public boolean isPoweredCart() + { + return minecartType == 2 && getClass() == EntityWagon.class; + } + + /** + * Returns true if this cart is a storage cart + * Some carts may have inventories but not be storage carts + * and some carts without inventories may be storage carts. + * @return True if this cart should be classified as a storage cart. + */ + public boolean isStorageCart() + { + return minecartType == 1 && getClass() == EntityWagon.class; + } + + /** + * Returns true if this cart can be ridden by an Entity. + * @return True if this cart can be ridden. + */ + public boolean canBeRidden() + { + if(minecartType == 0 && getClass() == EntityWagon.class) + { + return true; + } + return false; + } + + /** + * Returns true if this cart can currently use rails. + * This function is mainly used to gracefully detach a minecart from a rail. + * @return True if the minecart can use rails. + */ + public boolean canUseRail() + { + return canUseRail; + } + + /** + * Set whether the minecart can use rails. + * This function is mainly used to gracefully detach a minecart from a rail. + * @param use Whether the minecart can currently use rails. + */ + public void setCanUseRail(boolean use) + { + canUseRail = use; + } + + /** + * Return false if this cart should not call IRail.onMinecartPass() and should ignore Powered Rails. + * @return True if this cart should call IRail.onMinecartPass(). + */ + public boolean shouldDoRailFunctions() + { + return true; + } + + /** + * Simply returns the minecartType variable. + * @return minecartType + */ + public int getMinecartType() + { + return minecartType; + } + + /** + * Carts should return their drag factor here + * @return The drag rate. + */ + protected double getDrag() + { + return riddenByEntity != null ? defaultDragRidden : defaultDragEmpty; + } + + /** + * Moved to allow overrides. + * This code applies drag and updates push forces. + */ + protected void applyDragAndPushForces() + { + if(isPoweredCart()) + { + double d27 = MathHelper.sqrt_double(pushX * pushX + pushZ * pushZ); + if(d27 > 0.01D) + { + pushX /= d27; + pushZ /= d27; + double d29 = 0.04; + motionX *= 0.8D; + motionY *= 0.0D; + motionZ *= 0.8D; + motionX += pushX * d29; + motionZ += pushZ * d29; + } + else + { + motionX *= 0.9D; + motionY *= 0.0D; + motionZ *= 0.9D; + } + } + motionX *= getDrag(); + motionY *= 0.0D; + motionZ *= getDrag(); + } + + /** + * Moved to allow overrides. + * This code updates push forces. + */ + protected void updatePushForces() + { + if(isPoweredCart()) + { + double push = MathHelper.sqrt_double(pushX * pushX + pushZ * pushZ); + if(push > 0.01D && motionX * motionX + motionZ * motionZ > 0.001D) + { + pushX /= push; + pushZ /= push; + if(pushX * motionX + pushZ * motionZ < 0.0D) + { + pushX = 0.0D; + pushZ = 0.0D; + } + else + { + pushX = motionX; + pushZ = motionZ; + } + } + } + } + + /** + * Moved to allow overrides. + * This code handles minecart movement and speed capping when not on a rail. + */ + protected void moveMinecartOffRail(int i, int j, int k) + { + double d2 = getMaxSpeedGround(); + if(!onGround) + { + d2 = getMaxSpeedAirLateral(); + } + if(motionX < -d2) motionX = -d2; + if(motionX > d2) motionX = d2; + if(motionZ < -d2) motionZ = -d2; + if(motionZ > d2) motionZ = d2; + double moveY = motionY; + if(getMaxSpeedAirVertical() > 0 && motionY > getMaxSpeedAirVertical()) + { + moveY = getMaxSpeedAirVertical(); + if(Math.abs(motionX) < 0.3f && Math.abs(motionZ) < 0.3f) + { + moveY = 0.15f; + motionY = moveY; + } + } + if(onGround) + { + motionX *= 0.5D; + motionY *= 0.5D; + motionZ *= 0.5D; + } + moveEntity(motionX, moveY, motionZ); + if(!onGround) + { + motionX *= getDragAir(); + motionY *= getDragAir(); + motionZ *= getDragAir(); + } + } + + /** + * Moved to allow overrides. + * This code applies fuel consumption. + */ + protected void updateFuel() + { + if (fuel > 0) fuel--; + if (fuel <= 0) pushX = pushZ = 0.0D; + setMinecartPowered(fuel > 0); + } + + /** + * Moved to allow overrides, This code handle slopes affecting velocity. + * @param metadata The blocks position metadata + */ + protected void adjustSlopeVelocities(int metadata) + { + double acceleration = 0.0078125D; + if (metadata == 2) + { + motionX -= acceleration; + } + else if (metadata == 3) + { + motionX += acceleration; + } + else if (metadata == 4) + { + motionZ += acceleration; + } + else if (metadata == 5) + { + motionZ -= acceleration; + } + } + + /** + * Getters/setters for physics variables + */ + + /** + * Returns the carts max speed. + * Carts going faster than 1.1 cause issues with chunk loading. + * Carts cant traverse slopes or corners at greater than 0.5 - 0.6. + * This value is compared with the rails max speed to determine + * the carts current max speed. A normal rails max speed is 0.4. + * @return Carts max speed. + */ + public float getMaxSpeedRail() + { + return maxSpeedRail; + } + + public void setMaxSpeedRail(float value) + { + maxSpeedRail = value; + } + + public float getMaxSpeedGround() + { + return maxSpeedGround; + } + + public void setMaxSpeedGround(float value) + { + maxSpeedGround = value; + } + + public float getMaxSpeedAirLateral() + { + return maxSpeedAirLateral; + } + + public void setMaxSpeedAirLateral(float value) + { + maxSpeedAirLateral = value; + } + + public float getMaxSpeedAirVertical() + { + return maxSpeedAirVertical; + } + + public void setMaxSpeedAirVertical(float value) + { + maxSpeedAirVertical = value; + } + + public double getDragAir() + { + return dragAir; + } + + public void setDragAir(double value) + { + dragAir = value; + } +} diff --git a/tinker/tconstruct/logic/FrypanLogic.java b/tinker/tconstruct/logic/FrypanLogic.java index 42619810..d439d852 100644 --- a/tinker/tconstruct/logic/FrypanLogic.java +++ b/tinker/tconstruct/logic/FrypanLogic.java @@ -133,11 +133,11 @@ public class FrypanLogic extends EquipLogic public void cookItems () { - System.out.println("Trying to cook"); + //System.out.println("Trying to cook"); if (!canCook()) return; - System.out.println("Can cook"); + //System.out.println("Can cook"); for (int id = 2; id < 10; id++) //Check every slot { if (canCook()) diff --git a/tinker/tconstruct/logic/PartCrafterLogic.java b/tinker/tconstruct/logic/PartCrafterLogic.java index f0e0a357..d9a1deff 100644 --- a/tinker/tconstruct/logic/PartCrafterLogic.java +++ b/tinker/tconstruct/logic/PartCrafterLogic.java @@ -44,7 +44,7 @@ public class PartCrafterLogic extends InventoryLogic //return ((PatternHolderLogic) tile).getGuiContainer(player.inventory, world, x, y, z); } } - System.out.println("Regular container"); + //System.out.println("Regular container"); return new PartCrafterContainer(inventoryplayer, this); } @@ -64,7 +64,7 @@ public class PartCrafterLogic extends InventoryLogic int decrease = cost / value; if (cost % value != 0) decrease++; - super.decrStackSize(1, decrease); //Call super to avoid crafting again + super.decrStackSize(2, decrease); //Call super to avoid crafting again } } diff --git a/tinker/tconstruct/logic/PatternShaperLogic.java b/tinker/tconstruct/logic/PatternShaperLogic.java index d1d77cf2..4108e80b 100644 --- a/tinker/tconstruct/logic/PatternShaperLogic.java +++ b/tinker/tconstruct/logic/PatternShaperLogic.java @@ -27,6 +27,14 @@ public class PatternShaperLogic extends InventoryLogic return new PatternShaperContainer(inventoryplayer, this); } + /*@Override + public void onInventoryChanged() + { + if (inventory[0] == null) + inventory[1] = null; + super.onInventoryChanged(); + }*/ + @Override public void setInventorySlotContents(int slot, ItemStack itemstack) { @@ -39,10 +47,13 @@ public class PatternShaperLogic extends InventoryLogic public ItemStack decrStackSize(int slot, int quantity) { if (slot == 1) - { - super.decrStackSize(0, 1); + { if (getStackInSlot(0) != null) - return super.decrStackSize(slot, 0); + { + ItemStack ret = super.decrStackSize(slot, 0); + decrStackSize(0, 1); + return ret; + } } else if (slot == 0) { diff --git a/tinker/tconstruct/modifiers/ModBlaze.java b/tinker/tconstruct/modifiers/ModBlaze.java index b62f9f51..f476b351 100644 --- a/tinker/tconstruct/modifiers/ModBlaze.java +++ b/tinker/tconstruct/modifiers/ModBlaze.java @@ -40,7 +40,7 @@ public class ModBlaze extends ToolMod @Override public void modify (ItemStack[] input, ItemStack tool) { - System.out.println("Moood"); + //System.out.println("Moood"); NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); if (tags.hasKey(key)) { diff --git a/tinker/tconstruct/modifiers/ModBoolean.java b/tinker/tconstruct/modifiers/ModBoolean.java index 7f002c30..fe0bc98b 100644 --- a/tinker/tconstruct/modifiers/ModBoolean.java +++ b/tinker/tconstruct/modifiers/ModBoolean.java @@ -30,7 +30,7 @@ public class ModBoolean extends ToolMod NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool"); tags.setBoolean(key, true); - System.out.println("Key: "+key+" "+tags.getBoolean(key)); + //System.out.println("Key: "+key+" "+tags.getBoolean(key)); int modifiers = tags.getInteger("Modifiers"); modifiers -= 1; diff --git a/tinker/tconstruct/modifiers/ToolMod.java b/tinker/tconstruct/modifiers/ToolMod.java index c90eef21..109b24ee 100644 --- a/tinker/tconstruct/modifiers/ToolMod.java +++ b/tinker/tconstruct/modifiers/ToolMod.java @@ -98,17 +98,17 @@ public abstract class ToolMod else if (tags.hasKey("Effect2")) { - System.out.println("Adding Effect 3"); + //System.out.println("Adding Effect 3"); tags.setInteger("Effect3", effectIndex); } else if (tags.hasKey("Effect1")) { - System.out.println("Adding Effect 2"); + //System.out.println("Adding Effect 2"); tags.setInteger("Effect2", effectIndex); } else { - System.out.println("Adding Effect 1"); + //System.out.println("Adding Effect 1"); tags.setInteger("Effect1", effectIndex); } } diff --git a/tinker/tconstruct/tools/Broadsword.java b/tinker/tconstruct/tools/Broadsword.java index 9345458f..ca4b3936 100644 --- a/tinker/tconstruct/tools/Broadsword.java +++ b/tinker/tconstruct/tools/Broadsword.java @@ -31,6 +31,6 @@ public class Broadsword extends Weapon public float getDurabilityModifier () { - return 1.3f; + return 1.2f; } } diff --git a/tinker/tconstruct/tools/DualHarvestTool.java b/tinker/tconstruct/tools/DualHarvestTool.java index aba5ebcc..2b0ac0cb 100644 --- a/tinker/tconstruct/tools/DualHarvestTool.java +++ b/tinker/tconstruct/tools/DualHarvestTool.java @@ -44,7 +44,7 @@ public abstract class DualHarvestTool extends HarvestTool ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(new ItemStack(block.idDropped(bID, random, 0), 1, block.damageDropped(meta))); if (result != null) { - System.out.println("Woo~"); + //System.out.println("Woo~"); world.setBlockWithNotify(x, y, z, 0); if (!player.capabilities.isCreativeMode) onBlockDestroyed(stack, world, bID, x, y, z, player); diff --git a/tinker/tconstruct/tools/HarvestTool.java b/tinker/tconstruct/tools/HarvestTool.java index c4d6c18b..43cb9edc 100644 --- a/tinker/tconstruct/tools/HarvestTool.java +++ b/tinker/tconstruct/tools/HarvestTool.java @@ -37,7 +37,7 @@ public abstract class HarvestTool extends ToolCore ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(new ItemStack(block.idDropped(bID, random, 0), 1, block.damageDropped(meta))); if (result != null) { - System.out.println("Woo~"); + //System.out.println("Woo~"); world.setBlockWithNotify(x, y, z, 0); if (!player.capabilities.isCreativeMode) onBlockDestroyed(stack, world, bID, x, y, z, player); diff --git a/tinker/tconstruct/tools/ToolCore.java b/tinker/tconstruct/tools/ToolCore.java index 87e7a277..8ccbf945 100644 --- a/tinker/tconstruct/tools/ToolCore.java +++ b/tinker/tconstruct/tools/ToolCore.java @@ -285,6 +285,10 @@ public abstract class ToolCore extends Item return colorCode + "4"; //Ardite case 13: return colorCode + "5"; //Manyullyn + case 14: + return colorCode + "c"; //Copper + case 15: + return colorCode + "6"; //Bronze } return colorCode; } @@ -319,6 +323,10 @@ public abstract class ToolCore extends Item return ""; //Ardite case 13: return "Awareness"; //Manyullyn + case 14: + return ""; //Copper + case 15: + return ""; //Bronze default: return ""; } @@ -333,17 +341,19 @@ public abstract class ToolCore extends Item return "\u00A73Reinforced II"; else if (head == 3 || handle == 3 || accessory == 3) return "\u00A7fReinforced I"; + else if (head == 15 || handle == 15 || accessory == 15) + return "\u00A76Reinforced I"; return ""; } static String[] toolMaterialNames = { - "Wooden ", "Stone ", "Iron ", "Flint ", "Cactus ", "Bone ", "Obsidian ", "Nethrrack ", "Slime ", "Paper ", "Cobalt ", "Ardite ", "Manyullyn " + "Wooden ", "Stone ", "Iron ", "Flint ", "Cactus ", "Bone ", "Obsidian ", "Nethrrack ", "Slime ", "Paper ", "Cobalt ", "Ardite ", "Manyullyn " , "Copper ", "Bronze " }; /* Creative mode tools */ public void getSubItems (int id, CreativeTabs tab, List list) { - for (int i = 0; i < 13; i++) + for (int i = 0; i < 15; i++) { Item accessory = getAccessoryItem(); ItemStack accessoryStack = accessory != null ? new ItemStack(getAccessoryItem(), 1, i) : null; @@ -369,7 +379,7 @@ public abstract class ToolCore extends Item if (tags.hasKey("Moss")) { int chance = tags.getInteger("Moss"); - if (random.nextInt(200) < chance) + if (random.nextInt(800) < chance) { AbilityHelper.damageTool(stack, -1, (EntityLiving)entity, true); } @@ -392,7 +402,7 @@ public abstract class ToolCore extends Item ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(new ItemStack(block.idDropped(bID, random, 0), 1, block.damageDropped(meta))); if (result != null) { - System.out.println("Woo~"); + //System.out.println("Woo~"); world.setBlockWithNotify(x, y, z, 0); if (!player.capabilities.isCreativeMode) onBlockDestroyed(stack, world, bID, x, y, z, player);