Crashy crashy fixit fixit!

This commit is contained in:
mDiyo 2013-06-18 02:57:36 -07:00
parent 1b338fe6fa
commit d3cfea578f
61 changed files with 886 additions and 1022 deletions

View File

@ -38,7 +38,7 @@ import cpw.mods.fml.common.registry.VillagerRegistry;
* @dependencies: IC2 API, MFR API * @dependencies: IC2 API, MFR API
*/ */
@Mod(modid = "TConstruct", name = "TConstruct", version = "1.5.1_1.3.dev.61", dependencies = "required-after:Forge@[7.7.1.675,)") @Mod(modid = "TConstruct", name = "TConstruct", version = "1.5.1_1.3.dev.63", dependencies = "required-after:Forge@[7.7.1.675,)")
@NetworkMod(serverSideRequired = false, clientSideRequired = true, channels = { "TConstruct" }, packetHandler = mods.tinker.tconstruct.util.network.TPacketHandler.class) @NetworkMod(serverSideRequired = false, clientSideRequired = true, channels = { "TConstruct" }, packetHandler = mods.tinker.tconstruct.util.network.TPacketHandler.class)
public class TConstruct public class TConstruct
{ {

View File

@ -54,15 +54,15 @@ public class GravelOre extends BlockSand
@Override @Override
public int damageDropped (int meta) public int damageDropped (int meta)
{ {
if (meta == 1) /*if (meta == 1)
return 0; return 0;*/
return meta; return meta;
} }
public int idDropped(int par1, Random par2Random, int par3) public int idDropped(int par1, Random par2Random, int par3)
{ {
if (par1 == 1) /*if (par1 == 1)
return Item.goldNugget.itemID; return Item.goldNugget.itemID;*/
return this.blockID; return this.blockID;
} }

View File

@ -13,7 +13,7 @@ import net.minecraft.world.World;
/* Simple class for storing items in the block /* Simple class for storing items in the block
*/ */
public class ToolForgeLogic extends InventoryLogic public class ToolForgeLogic extends ToolStationLogic
implements ISidedInventory implements ISidedInventory
{ {
ItemStack previousTool; ItemStack previousTool;
@ -25,18 +25,6 @@ public class ToolForgeLogic extends InventoryLogic
toolName = ""; toolName = "";
} }
public boolean canDropInventorySlot(int slot)
{
if (slot == 0)
return false;
return true;
}
@Override
public ItemStack getStackInSlotOnClosing (int var1)
{
return null;
}
@Override @Override
public String getDefaultName () public String getDefaultName ()
@ -50,16 +38,6 @@ public class ToolForgeLogic extends InventoryLogic
return new ToolForgeContainer(inventoryplayer, this); return new ToolForgeContainer(inventoryplayer, this);
} }
public void onInventoryChanged ()
{
buildTool(toolName);
if (this.worldObj != null)
{
this.blockMetadata = this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord);
this.worldObj.updateTileEntityChunkAndDoNothing(this.xCoord, this.yCoord, this.zCoord, this);
}
}
public void buildTool (String name) public void buildTool (String name)
{ {
toolName = name; toolName = name;
@ -75,33 +53,4 @@ public class ToolForgeLogic extends InventoryLogic
} }
} }
} }
public void setToolname (String name)
{
toolName = name;
buildTool (name);
}
public boolean canUpdate()
{
return false;
}
@Override
public int[] getAccessibleSlotsFromSide (int side)
{
return new int[0];
}
@Override
public boolean canInsertItem (int i, ItemStack itemstack, int j)
{
return false;
}
@Override
public boolean canExtractItem (int i, ItemStack itemstack, int j)
{
return false;
}
} }

View File

@ -16,8 +16,8 @@ import net.minecraft.world.World;
public class ToolStationLogic extends InventoryLogic public class ToolStationLogic extends InventoryLogic
implements ISidedInventory implements ISidedInventory
{ {
ItemStack previousTool; public ItemStack previousTool;
String toolName; public String toolName;
public ToolStationLogic() public ToolStationLogic()
{ {
@ -25,6 +25,12 @@ public class ToolStationLogic extends InventoryLogic
toolName = ""; toolName = "";
} }
public ToolStationLogic(int slots)
{
super(slots);
toolName = "";
}
public boolean canDropInventorySlot(int slot) public boolean canDropInventorySlot(int slot)
{ {
if (slot == 0) if (slot == 0)

View File

@ -27,32 +27,13 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public class ToolForgeGui extends NewContainerGui public class ToolForgeGui extends ToolStationGui
{ {
ToolForgeLogic logic;
ToolForgeContainer toolSlots;
GuiTextField text;
String toolName;
int selectedButton; int selectedButton;
int[] slotX, slotY, iconX, iconY;
boolean active;
String title, body = "";
public ToolForgeGui(InventoryPlayer inventoryplayer, ToolForgeLogic stationlogic, World world, int x, int y, int z) public ToolForgeGui(InventoryPlayer inventoryplayer, ToolForgeLogic stationlogic, World world, int x, int y, int z)
{ {
super((ActiveContainer) stationlogic.getGuiContainer(inventoryplayer, world, x, y, z)); super(inventoryplayer, stationlogic, world, x, y, z);
this.logic = stationlogic;
toolSlots = (ToolForgeContainer) container;
text = new GuiTextField(this.fontRenderer, this.xSize / 2 - 5, 8, 30, 12);
this.text.setMaxStringLength(40);
this.text.setEnableBackgroundDrawing(false);
this.text.setVisible(true);
this.text.setCanLoseFocus(false);
this.text.setFocused(true);
this.text.setTextColor(0xffffff);
toolName = "";
resetGui();
Keyboard.enableRepeatEvents(true);
} }
protected void mouseClicked (int mouseX, int mouseY, int mouseButton) protected void mouseClicked (int mouseX, int mouseY, int mouseButton)
@ -68,17 +49,6 @@ public class ToolForgeGui extends NewContainerGui
} }
} }
void resetGui ()
{
this.text.setText("");
selectedButton = 0;
setSlotType(0);
iconX = new int[] { 0, 1, 2, 13 };
iconY = new int[] { 13, 13, 13, 13 };
title = "\u00A7nRepair and Modification";
body = "The main way to repair or change your tools. Place a tool and a material on the left to get started.";
}
public void initGui () public void initGui ()
{ {
super.initGui(); super.initGui();
@ -122,6 +92,18 @@ public class ToolForgeGui extends NewContainerGui
body = b.element.body; body = b.element.body;
} }
@Override
void resetGui ()
{
this.text.setText("");
selectedButton = 0;
setSlotType(0);
iconX = new int[] { 0, 1, 2, 13 };
iconY = new int[] { 13, 13, 13, 13 };
title = "\u00A7nRepair and Modification";
body = "The main way to repair or change your tools. Place a tool and a material on the left to get started.";
}
void setSlotType (int type) void setSlotType (int type)
{ {
switch (type) switch (type)
@ -157,280 +139,4 @@ public class ToolForgeGui extends NewContainerGui
} }
toolSlots.resetSlots(slotX, slotY); toolSlots.resetSlots(slotX, slotY);
} }
public void updateScreen ()
{
super.updateScreen();
this.text.updateCursorCounter();
}
/**
* Draw the foreground layer for the GuiContainer (everything in front of the items)
*/
protected void drawGuiContainerForegroundLayer (int par1, int par2)
{
this.fontRenderer.drawString(StatCollector.translateToLocal("crafters.ToolForge"), 6, 8, 0x000000);
this.fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 0x000000);
this.fontRenderer.drawString(toolName + "_", this.xSize / 2 - 18, 8, 0xffffff);
if (logic.isStackInSlot(0))
drawToolStats();
else
drawToolInformation();
//this.fontRenderer.drawString("Namebox active: "+active, this.xSize / 2 - 18, -10, 0xffffff);
}
void drawToolStats ()
{
ItemStack stack = logic.getStackInSlot(0);
ToolCore tool = (ToolCore) stack.getItem();
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
this.drawCenteredString(fontRenderer, "\u00A7n" + tool.getToolName(), xSize + 63, 8, 0xffffff);
if (tool instanceof Weapon)
drawWeaponStats(stack, tool, tags);
else if (tool.getHeadType() == 3)
drawDualStats(stack, tool, tags);
else
drawHarvestStats(stack, tool, tags);
}
void drawWeaponStats (ItemStack stack, ToolCore tool, NBTTagCompound tags)
{
int dur = tags.getInteger("Damage");
int maxDur = tags.getInteger("TotalDurability");
dur = maxDur - dur;
fontRenderer.drawString("Durability: " + dur + "/" + maxDur, xSize + 8, 24, 0xffffff);
int attack = (int) (tags.getInteger("Attack") * tool.getDamageModifier());
int durability = tags.getInteger("Damage");
float stonebound = tags.getFloat("Shoddy");
float stoneboundDamage = -stonebound * durability / 65f;
if (stonebound > 0)
stoneboundDamage = -stonebound * durability / 100f;
attack += stoneboundDamage;
if (attack < 1)
attack = 1;
String heart = attack == 2 ? " Heart" : " Hearts";
if (attack % 2 == 0)
this.fontRenderer.drawString("Attack: " + attack / 2 + heart, xSize + 8, 35, 0xffffff);
else
this.fontRenderer.drawString("Attack: " + attack / 2f + heart, xSize + 8, 35, 0xffffff);
//fontRenderer.drawString("Attack: " + damage, xSize + 8, 35, 0xffffff);
if (stoneboundDamage != 0)
{
heart = stoneboundDamage == 2 ? " Heart" : " Hearts";
String bloss = stoneboundDamage > 0 ? "Bonus: " : "Loss: ";
this.fontRenderer.drawString(bloss + (int) stoneboundDamage / 2 + heart, xSize + 8, 46, 0xffffff);
}
fontRenderer.drawString("Modifiers remaining: " + tags.getInteger("Modifiers"), xSize + 8, 57, 0xffffff);
if (tags.hasKey("Tooltip1"))
fontRenderer.drawString("Modifiers:", xSize + 8, 68, 0xffffff);
boolean displayToolTips = true;
int tipNum = 0;
while (displayToolTips)
{
tipNum++;
String tooltip = "ModifierTip" + tipNum;
if (tags.hasKey(tooltip))
{
String tipName = tags.getString(tooltip);
fontRenderer.drawString("- " + tipName, xSize + 8, 68 + tipNum * 11, 0xffffff);
}
else
displayToolTips = false;
}
}
void drawHarvestStats (ItemStack stack, ToolCore tool, NBTTagCompound tags)
{
int dur = tags.getInteger("Damage");
int maxDur = tags.getInteger("TotalDurability");
dur = maxDur - dur;
fontRenderer.drawString("Durability: " + dur + "/" + maxDur, xSize + 8, 24, 0xffffff);
int attack = tags.getInteger("Attack");
String heart = attack == 2 ? " Heart" : " Hearts";
if (attack % 2 == 0)
this.fontRenderer.drawString("Attack: " + attack / 2 + heart, xSize + 8, 35, 0xffffff);
else
this.fontRenderer.drawString("Attack: " + attack / 2f + heart, xSize + 8, 35, 0xffffff);
/*int damage = tags.getInteger("Attack");
fontRenderer.drawString("Damage: " + damage, xSize + 8, 35, 0xffffff);*/
float mineSpeed = tags.getInteger("MiningSpeed") / 100f;
fontRenderer.drawString("Mining Speed: " + mineSpeed, xSize + 8, 46, 0xffffff);
fontRenderer.drawString("Mining Level: " + getHarvestLevelName(tags.getInteger("HarvestLevel")), xSize + 8, 57, 0xffffff);
fontRenderer.drawString("Modifiers remaining: " + tags.getInteger("Modifiers"), xSize + 8, 79, 0xffffff);
if (tags.hasKey("Tooltip1"))
fontRenderer.drawString("Modifiers:", xSize + 8, 90, 0xffffff);
boolean displayToolTips = true;
int tipNum = 0;
while (displayToolTips)
{
tipNum++;
String tooltip = "ModifierTip" + tipNum;
if (tags.hasKey(tooltip))
{
String tipName = tags.getString(tooltip);
fontRenderer.drawString("- " + tipName, xSize + 8, 90 + tipNum * 11, 0xffffff);
}
else
displayToolTips = false;
}
}
void drawDualStats (ItemStack stack, ToolCore tool, NBTTagCompound tags)
{
int dur = tags.getInteger("Damage");
int maxDur = tags.getInteger("TotalDurability");
dur = maxDur - dur;
fontRenderer.drawString("Durability: " + dur + "/" + maxDur, xSize + 8, 24, 0xffffff);
float mineSpeed = tags.getInteger("MiningSpeed") / 100f;
float mineSpeed2 = tags.getInteger("MiningSpeed2") / 100f;
fontRenderer.drawString("Mining Speeds: ", xSize + 8, 35, 0xffffff);
fontRenderer.drawString("- " + mineSpeed + ", " + mineSpeed2, xSize + 8, 46, 0xffffff);
fontRenderer.drawString("Harvest Levels:", xSize + 8, 57, 0xffffff);
fontRenderer.drawString("- " + getHarvestLevelName(tags.getInteger("HarvestLevel")), xSize + 8, 68, 0xffffff);
fontRenderer.drawString("- " + getHarvestLevelName(tags.getInteger("HarvestLevel2")), xSize + 8, 79, 0xffffff);
fontRenderer.drawString("Modifiers remaining: " + tags.getInteger("Modifiers"), xSize + 8, 90, 0xffffff);
if (tags.hasKey("Tooltip1"))
fontRenderer.drawString("Modifiers:", xSize + 8, 101, 0xffffff);
boolean displayToolTips = true;
int tipNum = 0;
while (displayToolTips)
{
tipNum++;
String tooltip = "ModifierTip" + tipNum;
if (tags.hasKey(tooltip))
{
String tipName = tags.getString(tooltip);
fontRenderer.drawString("- " + tipName, xSize + 8, 101 + tipNum * 11, 0xffffff);
}
else
displayToolTips = false;
}
}
void drawToolInformation ()
{
this.drawCenteredString(fontRenderer, title, xSize + 63, 8, 0xffffff);
fontRenderer.drawSplitString(body, xSize + 8, 24, 115, 0xffffff);
}
String getHarvestLevelName (int num)
{
switch (num)
{
case 0:
return "Stone";
case 1:
return "Iron";
case 2:
return "Redstone";
case 3:
return "Obsidian"; //Mithril
case 4:
return "Cobalt";
case 5:
return "Manyullyn";
default:
return String.valueOf(num);
}
}
/**
* Draw the background layer for the GuiContainer (everything behind the items)
*/
protected void drawGuiContainerBackgroundLayer (float par1, int par2, int par3)
{
// Draw the background
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.renderEngine.bindTexture("/mods/tinker/textures/gui/toolstation.png");
int cornerX = (this.width - this.xSize) / 2;
int cornerY = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(cornerX, cornerY, 0, 0, this.xSize, this.ySize);
if (active)
{
this.drawTexturedModalRect(cornerX + 62, cornerY, 0, this.ySize, 112, 22);
}
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.renderEngine.bindTexture("/mods/tinker/textures/gui/icons.png");
// Draw the slots
for (int i = 0; i < slotX.length; i++)
{
this.drawTexturedModalRect(cornerX + slotX[i] - 4, cornerY + slotY[i] - 4, 140, 212, 28, 28);
if (!logic.isStackInSlot(i + 1))
{
this.drawTexturedModalRect(cornerX + slotX[i], cornerY + slotY[i], 18 * iconX[i], 18 * iconY[i], 18, 18);
}
}
// Draw description
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.renderEngine.bindTexture("/mods/tinker/textures/gui/description.png");
cornerX = (this.width + this.xSize) / 2;
cornerY = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(cornerX, cornerY, 0, 0, 126, this.ySize + 30);
}
protected void keyTyped (char par1, int keyCode)
{
if (keyCode == 1 || (!active && keyCode == this.mc.gameSettings.keyBindInventory.keyCode))
{
logic.setToolname("");
updateServer("");
Keyboard.enableRepeatEvents(false);
this.mc.thePlayer.closeScreen();
}
else if (active)
{
text.textboxKeyTyped(par1, keyCode);
toolName = text.getText().trim();
logic.setToolname(toolName);
updateServer(toolName);
}
}
void updateServer (String name)
{
ByteArrayOutputStream bos = new ByteArrayOutputStream(8);
DataOutputStream outputStream = new DataOutputStream(bos);
try
{
outputStream.writeByte(1);
outputStream.writeInt(logic.worldObj.provider.dimensionId);
outputStream.writeInt(logic.xCoord);
outputStream.writeInt(logic.yCoord);
outputStream.writeInt(logic.zCoord);
outputStream.writeUTF(name);
}
catch (Exception ex)
{
ex.printStackTrace();
}
Packet250CustomPayload packet = new Packet250CustomPayload();
packet.channel = "TConstruct";
packet.data = bos.toByteArray();
packet.length = bos.size();
PacketDispatcher.sendPacketToServer(packet);
}
/*protected void mouseClicked(int par1, int par2, int par3)
{
super.mouseClicked(par1, par2, par3);
text.mouseClicked(par1, par2, par3);
}*/
} }

View File

@ -2,6 +2,10 @@ package mods.tinker.tconstruct.client.gui;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.List;
import mods.tinker.tconstruct.blocks.logic.ToolStationLogic; import mods.tinker.tconstruct.blocks.logic.ToolStationLogic;
import mods.tinker.tconstruct.inventory.ActiveContainer; import mods.tinker.tconstruct.inventory.ActiveContainer;
@ -9,7 +13,6 @@ import mods.tinker.tconstruct.inventory.ToolStationContainer;
import mods.tinker.tconstruct.library.client.TConstructClientRegistry; import mods.tinker.tconstruct.library.client.TConstructClientRegistry;
import mods.tinker.tconstruct.library.client.ToolGuiElement; import mods.tinker.tconstruct.library.client.ToolGuiElement;
import mods.tinker.tconstruct.library.tools.ToolCore; import mods.tinker.tconstruct.library.tools.ToolCore;
import mods.tinker.tconstruct.library.tools.Weapon;
import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiTextField; import net.minecraft.client.gui.GuiTextField;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
@ -29,14 +32,14 @@ import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public class ToolStationGui extends NewContainerGui public class ToolStationGui extends NewContainerGui
{ {
ToolStationLogic logic; public ToolStationLogic logic;
ToolStationContainer toolSlots; public ToolStationContainer toolSlots;
GuiTextField text; public GuiTextField text;
String toolName; public String toolName;
int guiType; public int guiType;
int[] slotX, slotY, iconX, iconY; public int[] slotX, slotY, iconX, iconY;
boolean active; public boolean active;
String title, body = ""; public String title, body = "";
public ToolStationGui(InventoryPlayer inventoryplayer, ToolStationLogic stationlogic, World world, int x, int y, int z) public ToolStationGui(InventoryPlayer inventoryplayer, ToolStationLogic stationlogic, World world, int x, int y, int z)
{ {
@ -133,10 +136,6 @@ public class ToolStationGui extends NewContainerGui
slotX = new int[] { 38, 47, 56 }; // Double head slotX = new int[] { 38, 47, 56 }; // Double head
slotY = new int[] { 28, 46, 28 }; slotY = new int[] { 28, 46, 28 };
break; break;
case 4:
slotX = new int[] { 47, 47, 38, 56 }; // Four parts
slotY = new int[] { 19, 55, 37, 37 };
break;
} }
toolSlots.resetSlots(slotX, slotY); toolSlots.resetSlots(slotX, slotY);
} }
@ -170,12 +169,163 @@ public class ToolStationGui extends NewContainerGui
ToolCore tool = (ToolCore) stack.getItem(); ToolCore tool = (ToolCore) stack.getItem();
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool"); NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
this.drawCenteredString(fontRenderer, "\u00A7n" + tool.getToolName(), xSize + 63, 8, 0xffffff); this.drawCenteredString(fontRenderer, "\u00A7n" + tool.getToolName(), xSize + 63, 8, 0xffffff);
if (tool instanceof Weapon)
drawModularToolStats(stack, tool, tags);
/*if (tool instanceof Weapon)
drawWeaponStats(stack, tool, tags); drawWeaponStats(stack, tool, tags);
else if (tool.getHeadType() == 3) else if (tool.getHeadType() == 3)
drawDualStats(stack, tool, tags); drawDualStats(stack, tool, tags);
else else
drawHarvestStats(stack, tool, tags); drawHarvestStats(stack, tool, tags);*/
}
void drawModularToolStats (ItemStack stack, ToolCore tool, NBTTagCompound tags)
{
List categories = Arrays.asList(tool.toolCategories());
final int durability = tags.getInteger("Damage");
final int maxDur = tags.getInteger("TotalDurability");
int availableDurability = maxDur - durability;
//Durability
int base = 24;
int offset = 0;
if (maxDur >= 10000)
{
fontRenderer.drawString("Durability:", xSize + 8, base + offset * 11, 0xffffff);
offset++;
fontRenderer.drawString("- " + availableDurability + "/" + maxDur, xSize + 8, base + offset * 10, 0xffffff);
offset++;
}
else
{
fontRenderer.drawString("Durability: " + availableDurability + "/" + maxDur, xSize + 8, base + offset * 10, 0xffffff);
offset++;
}
final float stonebound = tags.getFloat("Shoddy");
//Attack
if (categories.contains("weapon"))
{
int attack = tags.getInteger("Attack");
float stoneboundDamage = (float) Math.log(durability / 72f + 1) * -2 * stonebound;
attack += stoneboundDamage;
if (attack < 1)
attack = 1;
String heart = attack == 2 ? " Heart" : " Hearts";
if (attack % 2 == 0)
this.fontRenderer.drawString("Attack: " + attack / 2 + heart, xSize + 8, base + offset * 10, 0xffffff);
else
this.fontRenderer.drawString("Attack: " + attack / 2f + heart, xSize + 8, base + offset * 10, 0xffffff);
offset++;
if (stoneboundDamage != 0)
{
heart = stoneboundDamage == 2 ? " Heart" : " Hearts";
String bloss = stoneboundDamage > 0 ? "Bonus: " : "Loss: ";
this.fontRenderer.drawString(bloss + (int) stoneboundDamage / 2 + heart, xSize + 8, base + offset * 10, 0xffffff);
offset++;
}
offset++;
}
//Mining
if (categories.contains("dualharvest"))
{
float mineSpeed = tags.getInteger("MiningSpeed") / 100f;
float mineSpeed2 = tags.getInteger("MiningSpeed2") / 100f;
float stoneboundSpeed = (float) Math.log(durability / 90f + 1) * 2 * stonebound;
DecimalFormat df = new DecimalFormat("##.##");
df.setRoundingMode(RoundingMode.DOWN);
float trueSpeed = mineSpeed + stoneboundSpeed;
float trueSpeed2 = mineSpeed + stoneboundSpeed;
fontRenderer.drawString("Mining Speeds: ", xSize + 8, base + offset * 10, 0xffffff);
offset++;
fontRenderer.drawString("- " + df.format(trueSpeed) + ", " + df.format(trueSpeed2), xSize + 8, base + offset * 10, 0xffffff);
offset++;
if (stoneboundSpeed != 0)
{
String bloss = stoneboundSpeed > 0 ? "Bonus: " : "Loss: ";
fontRenderer.drawString(bloss + df.format(stoneboundSpeed), xSize + 8, base + offset * 10, 0xffffff);
offset++;
}
offset++;
fontRenderer.drawString("Harvest Levels:", xSize + 8, base + offset * 10, 0xffffff);
offset++;
fontRenderer.drawString("- " + getHarvestLevelName(tags.getInteger("HarvestLevel"))+", " + getHarvestLevelName(tags.getInteger("HarvestLevel2")), xSize + 8, base + offset * 10, 0xffffff);
offset++;
offset++;
}
else if (categories.contains("harvest"))
{
float mineSpeed = tags.getInteger("MiningSpeed");
int heads = 1;
if (tags.hasKey("MiningSpeed2"))
{
mineSpeed += tags.getInteger("MiningSpeed2");
heads++;
}
if (tags.hasKey("MiningSpeedHandle"))
{
mineSpeed += tags.getInteger("MiningSpeedHandle");
heads++;
}
if (tags.hasKey("MiningSpeedExtra"))
{
mineSpeed += tags.getInteger("MiningSpeedExtra");
heads++;
}
float trueSpeed = mineSpeed / (heads * 100f);
float stoneboundSpeed = (float) Math.log(durability / 90f + 1) * 2 * stonebound;
DecimalFormat df = new DecimalFormat("##.##");
df.setRoundingMode(RoundingMode.DOWN);
trueSpeed += stoneboundSpeed;
if (trueSpeed < 0)
trueSpeed = 0;
fontRenderer.drawString("Mining Speed: " + df.format(trueSpeed), xSize + 8, base + offset * 10, 0xffffff);
offset++;
if (stoneboundSpeed != 0)
{
String bloss = stoneboundSpeed > 0 ? "Bonus: " : "Loss: ";
fontRenderer.drawString(bloss + df.format(stoneboundSpeed), xSize + 8, base + offset * 10, 0xffffff);
offset++;
}
fontRenderer.drawString("Mining Level: " + getHarvestLevelName(tags.getInteger("HarvestLevel")), xSize + 8, base + offset * 10, 0xffffff);
offset++;
offset++;
}
int modifiers = tags.getInteger("Modifiers");
if (modifiers > 0)
{
fontRenderer.drawString("Modifiers remaining: " + tags.getInteger("Modifiers"), xSize + 8, base + offset * 10, 0xffffff);
offset++;
}
if (tags.hasKey("Tooltip1"))
{
fontRenderer.drawString("Modifiers:", xSize + 8, base + offset * 10, 0xffffff);
}
boolean displayToolTips = true;
int tipNum = 0;
while (displayToolTips)
{
tipNum++;
String tooltip = "ModifierTip" + tipNum;
if (tags.hasKey(tooltip))
{
String tipName = tags.getString(tooltip);
fontRenderer.drawString("- " + tipName, xSize + 8, base + (offset + tipNum) * 10, 0xffffff);
}
else
displayToolTips = false;
}
} }
void drawWeaponStats (ItemStack stack, ToolCore tool, NBTTagCompound tags) void drawWeaponStats (ItemStack stack, ToolCore tool, NBTTagCompound tags)
@ -183,24 +333,23 @@ public class ToolStationGui extends NewContainerGui
int dur = tags.getInteger("Damage"); int dur = tags.getInteger("Damage");
int maxDur = tags.getInteger("TotalDurability"); int maxDur = tags.getInteger("TotalDurability");
dur = maxDur - dur; dur = maxDur - dur;
fontRenderer.drawString("Durability: " + dur + "/" + maxDur, xSize + 8, 24, 0xffffff); fontRenderer.drawString("Durability: ", xSize + 8, 24, 0xffffff);
fontRenderer.drawString("- " + dur + "/" + maxDur, xSize + 8, 35, 0xffffff);
int attack = (int) (tags.getInteger("Attack") * tool.getDamageModifier()); int attack = (int) (tags.getInteger("Attack") * tool.getDamageModifier());
int durability = tags.getInteger("Damage"); int durability = tags.getInteger("Damage");
float stonebound = tags.getFloat("Shoddy"); float stonebound = tags.getFloat("Shoddy");
float stoneboundDamage = -stonebound * durability / 65f; float stoneboundDamage = (float) Math.log(durability / 72f + 1) * -2 * stonebound;
if (stonebound > 0)
stoneboundDamage = -stonebound * durability / 100f;
attack += stoneboundDamage; attack += stoneboundDamage;
if (attack < 1) if (attack < 1)
attack = 1; attack = 1;
String heart = attack == 2 ? " Heart" : " Hearts"; String heart = attack == 2 ? " Heart" : " Hearts";
if (attack % 2 == 0) if (attack % 2 == 0)
this.fontRenderer.drawString("Attack: " + attack / 2 + heart, xSize + 8, 35, 0xffffff); this.fontRenderer.drawString("Attack: " + attack / 2 + heart, xSize + 8, 46, 0xffffff);
else else
this.fontRenderer.drawString("Attack: " + attack / 2f + heart, xSize + 8, 35, 0xffffff); this.fontRenderer.drawString("Attack: " + attack / 2f + heart, xSize + 8, 46, 0xffffff);
//fontRenderer.drawString("Attack: " + damage, xSize + 8, 35, 0xffffff);
if (stoneboundDamage != 0) if (stoneboundDamage != 0)
{ {
heart = stoneboundDamage == 2 ? " Heart" : " Hearts"; heart = stoneboundDamage == 2 ? " Heart" : " Hearts";
@ -208,7 +357,7 @@ public class ToolStationGui extends NewContainerGui
this.fontRenderer.drawString(bloss + (int) stoneboundDamage / 2 + heart, xSize + 8, 46, 0xffffff); this.fontRenderer.drawString(bloss + (int) stoneboundDamage / 2 + heart, xSize + 8, 46, 0xffffff);
} }
fontRenderer.drawString("Modifiers remaining: " + tags.getInteger("Modifiers"), xSize + 8, 57, 0xffffff); fontRenderer.drawString("Modifiers remaining: " + tags.getInteger("Modifiers"), xSize + 8, 68, 0xffffff);
if (tags.hasKey("Tooltip1")) if (tags.hasKey("Tooltip1"))
fontRenderer.drawString("Modifiers:", xSize + 8, 68, 0xffffff); fontRenderer.drawString("Modifiers:", xSize + 8, 68, 0xffffff);
@ -233,23 +382,24 @@ public class ToolStationGui extends NewContainerGui
int dur = tags.getInteger("Damage"); int dur = tags.getInteger("Damage");
int maxDur = tags.getInteger("TotalDurability"); int maxDur = tags.getInteger("TotalDurability");
dur = maxDur - dur; dur = maxDur - dur;
fontRenderer.drawString("Durability: " + dur + "/" + maxDur, xSize + 8, 24, 0xffffff); fontRenderer.drawString("Durability:", xSize + 8, 24, 0xffffff);
fontRenderer.drawString("- " + dur + "/" + maxDur, xSize + 8, 35, 0xffffff);
int attack = tags.getInteger("Attack"); int attack = tags.getInteger("Attack");
String heart = attack == 2 ? " Heart" : " Hearts"; String heart = attack == 2 ? " Heart" : " Hearts";
if (attack % 2 == 0) if (attack % 2 == 0)
this.fontRenderer.drawString("Attack: " + attack / 2 + heart, xSize + 8, 35, 0xffffff); this.fontRenderer.drawString("Attack: " + attack / 2 + heart, xSize + 8, 46, 0xffffff);
else else
this.fontRenderer.drawString("Attack: " + attack / 2f + heart, xSize + 8, 35, 0xffffff); this.fontRenderer.drawString("Attack: " + attack / 2f + heart, xSize + 8, 46, 0xffffff);
/*int damage = tags.getInteger("Attack"); /*int damage = tags.getInteger("Attack");
fontRenderer.drawString("Damage: " + damage, xSize + 8, 35, 0xffffff);*/ fontRenderer.drawString("Damage: " + damage, xSize + 8, 35, 0xffffff);*/
float mineSpeed = tags.getInteger("MiningSpeed") / 100f; float mineSpeed = tags.getInteger("MiningSpeed") / 100f;
fontRenderer.drawString("Mining Speed: " + mineSpeed, xSize + 8, 46, 0xffffff); fontRenderer.drawString("Mining Speed: " + mineSpeed, xSize + 8, 57, 0xffffff);
fontRenderer.drawString("Mining Level: " + getHarvestLevelName(tags.getInteger("HarvestLevel")), xSize + 8, 57, 0xffffff); fontRenderer.drawString("Mining Level: " + getHarvestLevelName(tags.getInteger("HarvestLevel")), xSize + 8, 68, 0xffffff);
fontRenderer.drawString("Modifiers remaining: " + tags.getInteger("Modifiers"), xSize + 8, 79, 0xffffff); fontRenderer.drawString("Modifiers remaining: " + tags.getInteger("Modifiers"), xSize + 8, 90, 0xffffff);
if (tags.hasKey("Tooltip1")) if (tags.hasKey("Tooltip1"))
fontRenderer.drawString("Modifiers:", xSize + 8, 90, 0xffffff); fontRenderer.drawString("Modifiers:", xSize + 8, 101, 0xffffff);
boolean displayToolTips = true; boolean displayToolTips = true;
int tipNum = 0; int tipNum = 0;
@ -260,7 +410,7 @@ public class ToolStationGui extends NewContainerGui
if (tags.hasKey(tooltip)) if (tags.hasKey(tooltip))
{ {
String tipName = tags.getString(tooltip); String tipName = tags.getString(tooltip);
fontRenderer.drawString("- " + tipName, xSize + 8, 90 + tipNum * 11, 0xffffff); fontRenderer.drawString("- " + tipName, xSize + 8, 101 + tipNum * 11, 0xffffff);
} }
else else
displayToolTips = false; displayToolTips = false;

View File

@ -72,6 +72,7 @@ public class TContent implements IFuelHandler
public static ToolCore longsword; public static ToolCore longsword;
public static ToolCore rapier; public static ToolCore rapier;
public static ToolCore dagger; public static ToolCore dagger;
public static ToolCore cutlass;
public static ToolCore frypan; public static ToolCore frypan;
public static ToolCore battlesign; public static ToolCore battlesign;
@ -112,6 +113,7 @@ public class TContent implements IFuelHandler
public static Item wideGuard; public static Item wideGuard;
public static Item handGuard; public static Item handGuard;
public static Item crossbar; public static Item crossbar;
public static Item fullGuard;
//Crafting blocks //Crafting blocks
public static Block toolStationWood; public static Block toolStationWood;
@ -399,6 +401,7 @@ public class TContent implements IFuelHandler
longsword = new Longsword(PHConstruct.longsword); longsword = new Longsword(PHConstruct.longsword);
rapier = new Rapier(PHConstruct.rapier); rapier = new Rapier(PHConstruct.rapier);
dagger = new Dagger(PHConstruct.dagger); dagger = new Dagger(PHConstruct.dagger);
cutlass = new Cutlass(PHConstruct.cutlass);
frypan = new FryingPan(PHConstruct.frypan); frypan = new FryingPan(PHConstruct.frypan);
battlesign = new BattleSign(PHConstruct.battlesign); battlesign = new BattleSign(PHConstruct.battlesign);
@ -427,6 +430,7 @@ public class TContent implements IFuelHandler
handGuard = new ToolPart(PHConstruct.medGuard, "MediumGuard", "_medium_guard").setUnlocalizedName("tconstruct.MediumGuard"); handGuard = new ToolPart(PHConstruct.medGuard, "MediumGuard", "_medium_guard").setUnlocalizedName("tconstruct.MediumGuard");
crossbar = new ToolPart(PHConstruct.crossbar, "Crossbar", "_crossbar").setUnlocalizedName("tconstruct.Crossbar"); crossbar = new ToolPart(PHConstruct.crossbar, "Crossbar", "_crossbar").setUnlocalizedName("tconstruct.Crossbar");
knifeBlade = new ToolPart(PHConstruct.knifeBlade, "KnifeBlade", "_knife_blade").setUnlocalizedName("tconstruct.KnifeBlade"); knifeBlade = new ToolPart(PHConstruct.knifeBlade, "KnifeBlade", "_knife_blade").setUnlocalizedName("tconstruct.KnifeBlade");
fullGuard = new ToolPartHidden(PHConstruct.fullGuard, "FullGuard", "_full_guard").setUnlocalizedName("tconstruct.FullGuard");
frypanHead = new ToolPart(PHConstruct.frypanHead, "FrypanHead", "_frypan_head").setUnlocalizedName("tconstruct.FrypanHead"); frypanHead = new ToolPart(PHConstruct.frypanHead, "FrypanHead", "_frypan_head").setUnlocalizedName("tconstruct.FrypanHead");
signHead = new ToolPart(PHConstruct.signHead, "SignHead", "_battlesign_head").setUnlocalizedName("tconstruct.SignHead"); signHead = new ToolPart(PHConstruct.signHead, "SignHead", "_battlesign_head").setUnlocalizedName("tconstruct.SignHead");
@ -477,7 +481,7 @@ public class TContent implements IFuelHandler
TConstructRegistry.addToolMaterial(8, "Slime", 1, 3, 1500, 150, 0, 2.0F, 0, 0f, "\u00A7a", ""); TConstructRegistry.addToolMaterial(8, "Slime", 1, 3, 1500, 150, 0, 2.0F, 0, 0f, "\u00A7a", "");
TConstructRegistry.addToolMaterial(9, "Paper", 1, 0, 30, 200, 0, 0.3F, 0, 0f, "\u00A7f", "Writable"); TConstructRegistry.addToolMaterial(9, "Paper", 1, 0, 30, 200, 0, 0.3F, 0, 0f, "\u00A7f", "Writable");
TConstructRegistry.addToolMaterial(10, "Cobalt", 2, 4, 800, 1100, 3, 1.75F, 2, 0f, "\u00A73", ""); TConstructRegistry.addToolMaterial(10, "Cobalt", 2, 4, 800, 1100, 3, 1.75F, 2, 0f, "\u00A73", "");
TConstructRegistry.addToolMaterial(11, "Ardite", 2, 4, 600, 800, 3, 2.0F, 0, 3f, "\u00A74", "Stonebound"); TConstructRegistry.addToolMaterial(11, "Ardite", 2, 4, 600, 800, 3, 2.0F, 0, 2f, "\u00A74", "Stonebound");
TConstructRegistry.addToolMaterial(12, "Manyullyn", 2, 5, 1200, 900, 4, 2.5F, 0, 0f, "\u00A75", ""); TConstructRegistry.addToolMaterial(12, "Manyullyn", 2, 5, 1200, 900, 4, 2.5F, 0, 0f, "\u00A75", "");
TConstructRegistry.addToolMaterial(13, "Copper", 1, 1, 180, 500, 2, 1.15F, 0, 0f, "\u00A7c", ""); TConstructRegistry.addToolMaterial(13, "Copper", 1, 1, 180, 500, 2, 1.15F, 0, 0f, "\u00A7c", "");
TConstructRegistry.addToolMaterial(14, "Bronze", 1, 2, 350, 700, 2, 1.3F, 1, 0f, "\u00A76", ""); TConstructRegistry.addToolMaterial(14, "Bronze", 1, 2, 350, 700, 2, 1.3F, 1, 0f, "\u00A76", "");
@ -556,7 +560,7 @@ public class TContent implements IFuelHandler
{ {
/* Tools */ /* Tools */
patternOutputs = new Item[] { toolRod, pickaxeHead, shovelHead, axeHead, swordBlade, wideGuard, handGuard, crossbar, binding, frypanHead, signHead, knifeBlade, chiselHead, patternOutputs = new Item[] { toolRod, pickaxeHead, shovelHead, axeHead, swordBlade, wideGuard, handGuard, crossbar, binding, frypanHead, signHead, knifeBlade, chiselHead,
toughRod, toughBinding, heavyPlate, broadAxeHead, scytheBlade, excavatorHead, largeSwordBlade, hammerHead}; toughRod, toughBinding, heavyPlate, broadAxeHead, scytheBlade, excavatorHead, largeSwordBlade, hammerHead };
ToolBuilder tb = ToolBuilder.instance; ToolBuilder tb = ToolBuilder.instance;
tb.addToolRecipe(pickaxe, pickaxeHead, binding); tb.addToolRecipe(pickaxe, pickaxeHead, binding);
@ -569,6 +573,7 @@ public class TContent implements IFuelHandler
tb.addToolRecipe(battlesign, signHead); tb.addToolRecipe(battlesign, signHead);
tb.addToolRecipe(mattock, axeHead, shovelHead); tb.addToolRecipe(mattock, axeHead, shovelHead);
tb.addToolRecipe(dagger, knifeBlade, crossbar); tb.addToolRecipe(dagger, knifeBlade, crossbar);
tb.addToolRecipe(cutlass, swordBlade, fullGuard);
tb.addToolRecipe(chisel, chiselHead); tb.addToolRecipe(chisel, chiselHead);
tb.addCustomToolRecipe(scythe, scytheBlade, toughRod, toughBinding, toughRod); tb.addCustomToolRecipe(scythe, scytheBlade, toughRod, toughBinding, toughRod);
tb.addCustomToolRecipe(lumberaxe, broadAxeHead, toughRod, heavyPlate, toughBinding); tb.addCustomToolRecipe(lumberaxe, broadAxeHead, toughRod, heavyPlate, toughBinding);
@ -985,6 +990,7 @@ public class TContent implements IFuelHandler
{ {
tinkerHousePatterns.addItem(new WeightedRandomChestContent(new ItemStack(woodPattern, 1, i+1), 1, 3, 20)); tinkerHousePatterns.addItem(new WeightedRandomChestContent(new ItemStack(woodPattern, 1, i+1), 1, 3, 20));
} }
tinkerHousePatterns.addItem(new WeightedRandomChestContent(new ItemStack(woodPattern, 1, 22), 1, 3, 40));
} }
public static LiquidStack[] liquidIcons = new LiquidStack[0]; public static LiquidStack[] liquidIcons = new LiquidStack[0];
@ -999,7 +1005,7 @@ public class TContent implements IFuelHandler
OreDictionary.registerOre("oreNaturalAluminum", new ItemStack(oreSlag, 1, 5)); OreDictionary.registerOre("oreNaturalAluminum", new ItemStack(oreSlag, 1, 5));
OreDictionary.registerOre("oreIron", new ItemStack(oreGravel, 1, 0)); OreDictionary.registerOre("oreIron", new ItemStack(oreGravel, 1, 0));
//OreDictionary.registerOre("oreGold", new ItemStack(oreGravel, 1, 1)); OreDictionary.registerOre("oreGold", new ItemStack(oreGravel, 1, 1));
OreDictionary.registerOre("oreCobalt", new ItemStack(oreGravel, 1, 5)); OreDictionary.registerOre("oreCobalt", new ItemStack(oreGravel, 1, 5));
OreDictionary.registerOre("oreCopper", new ItemStack(oreGravel, 1, 2)); OreDictionary.registerOre("oreCopper", new ItemStack(oreGravel, 1, 2));
OreDictionary.registerOre("oreTin", new ItemStack(oreGravel, 1, 3)); OreDictionary.registerOre("oreTin", new ItemStack(oreGravel, 1, 3));

View File

@ -163,6 +163,7 @@ public class TProxyCommon implements IGuiHandler
LanguageRegistry.addName(TContent.excavator, "Excavator"); LanguageRegistry.addName(TContent.excavator, "Excavator");
LanguageRegistry.addName(TContent.hammer, "Hammer"); LanguageRegistry.addName(TContent.hammer, "Hammer");
LanguageRegistry.addName(TContent.battleaxe, "Battleaxe"); LanguageRegistry.addName(TContent.battleaxe, "Battleaxe");
LanguageRegistry.addName(TContent.cutlass, "Cutlass");
} }
@ -191,15 +192,15 @@ public class TProxyCommon implements IGuiHandler
"Copper", "Bronze", "Alumite", "Steel", "Blue Slime" }; "Copper", "Bronze", "Alumite", "Steel", "Blue Slime" };
public static final String[] materialTypes = new String[] { "ToolRod", "PickaxeHead", "ShovelHead", "AxeHead", "SwordBlade", "LargeGuard", "MediumGuard", "Crossbar", "Binding", "FrypanHead", public static final String[] materialTypes = new String[] { "ToolRod", "PickaxeHead", "ShovelHead", "AxeHead", "SwordBlade", "LargeGuard", "MediumGuard", "Crossbar", "Binding", "FrypanHead",
"SignHead", "LumberHead", "KnifeBlade", "ChiselHead", "ScytheBlade", "LumberHead", "ThickRod", "ThickBinding", "LargeSwordBlade", "LargePlate", "ExcavatorHead", "HammerHead" }; "SignHead", "LumberHead", "KnifeBlade", "ChiselHead", "ScytheBlade", "LumberHead", "ThickRod", "ThickBinding", "LargeSwordBlade", "LargePlate", "ExcavatorHead", "HammerHead", "FullGuard" };
public static final String[] materialNames = new String[] { " Rod", " Pickaxe Head", " Shovel Head", " Axe Head", " Sword Blade", " Wide Guard", " Hand Guard", " Crossbar", " Binding", " Pan", public static final String[] materialNames = new String[] { " Rod", " Pickaxe Head", " Shovel Head", " Axe Head", " Sword Blade", " Wide Guard", " Hand Guard", " Crossbar", " Binding", " Pan",
" Board", " Broad Axe Head", " Knife Blade", " Chisel Head", " Scythe Blade", " Broad Axe Head", " Tough Tool Rod", " Tough Binding", " Large Sword Blade", " Large Plate", " Excavator Head", " Board", " Broad Axe Head", " Knife Blade", " Chisel Head", " Scythe Blade", " Broad Axe Head", " Tough Tool Rod", " Tough Binding", " Large Sword Blade", " Large Plate", " Excavator Head",
" Hammer Head"}; " Hammer Head", " Full Guard"};
public static final String[] patterns = new String[] { "ingot", "rod", "pickaxe", "shovel", "axe", "swordblade", "largeguard", "mediumguard", "crossbar", "binding", "frypan", "sign", "knifeblade", "chisel", public static final String[] patterns = new String[] { "ingot", "rod", "pickaxe", "shovel", "axe", "swordblade", "largeguard", "mediumguard", "crossbar", "binding", "frypan", "sign", "knifeblade", "chisel",
"largerod", "toughbinding", "largeplate", "broadaxe", "scythe", "excavator", "largeblade", "hammerhead"}; "largerod", "toughbinding", "largeplate", "broadaxe", "scythe", "excavator", "largeblade", "hammerhead", "fullguard"};
public static final String[] patternNames = new String[] { "Ingot", "Tool Rod", "Pickaxe Head", "Shovel Head", "Axe Head", "Sword Blade", "Wide Guard", "Hand Guard", "Crossbar", "Tool Binding", public static final String[] patternNames = new String[] { "Ingot", "Tool Rod", "Pickaxe Head", "Shovel Head", "Axe Head", "Sword Blade", "Wide Guard", "Hand Guard", "Crossbar", "Tool Binding",
"Pan", "Board", "Knife Blade", "Chisel Head", "Tough Tool Rod", "Tough Binding", "Large Plate", "Broad Axe Head", "Scythe Head", "Broad Shovel Head", "Large Blade", "Hammer Head" }; "Pan", "Board", "Knife Blade", "Chisel Head", "Tough Tool Rod", "Tough Binding", "Large Plate", "Broad Axe Head", "Scythe Head", "Broad Shovel Head", "Large Blade", "Hammer Head", "Full Guard" };
} }

View File

@ -12,7 +12,7 @@ import net.minecraft.nbt.NBTTagCompound;
public class SlotTool extends Slot public class SlotTool extends Slot
{ {
/** The player that is using the GUI where this slot resides. */ /** The player that is using the GUI where this slot resides. */
private EntityPlayer player; public EntityPlayer player;
Random random = new Random(); Random random = new Random();
public SlotTool(EntityPlayer entityplayer, IInventory builder, int par3, int par4, int par5) public SlotTool(EntityPlayer entityplayer, IInventory builder, int par3, int par4, int par5)

View File

@ -9,47 +9,15 @@ import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
public class SlotToolForge extends Slot public class SlotToolForge extends SlotTool
{ {
/** The player that is using the GUI where this slot resides. */ /** The player that is using the GUI where this slot resides. */
private EntityPlayer player;
Random random = new Random(); Random random = new Random();
public SlotToolForge(EntityPlayer entityplayer, IInventory builder, int par3, int par4, int par5) public SlotToolForge(EntityPlayer entityplayer, IInventory builder, int par3, int par4, int par5)
{ {
super(builder, par3, par4, par5); super(entityplayer, builder, par3, par4, par5);
this.player = entityplayer;
} }
/**
* Check if the stack is a valid item for this slot. Always true beside for the armor slots.
*/
public boolean isItemValid (ItemStack stack)
{
return false;
//return stack.getItem() instanceof ToolCore;
}
public void onPickupFromSlot (EntityPlayer par1EntityPlayer, ItemStack stack)
{
this.onCrafting(stack);
//stack.setUnlocalizedName("\u00A7f" + toolName);
super.onPickupFromSlot(par1EntityPlayer, stack);
}
/**
* the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood. Typically increases an
* internal count then calls onCrafting(item).
*/
protected void onCrafting (ItemStack stack, int par2)
{
//this.field_75228_b += par2;
this.onCrafting(stack);
}
/**
* the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood.
*/
protected void onCrafting (ItemStack stack) protected void onCrafting (ItemStack stack)
{ {
NBTTagCompound tags = stack.getTagCompound(); NBTTagCompound tags = stack.getTagCompound();

View File

@ -1,23 +1,26 @@
package mods.tinker.tconstruct.inventory; package mods.tinker.tconstruct.inventory;
import mods.tinker.tconstruct.blocks.logic.ToolForgeLogic; import mods.tinker.tconstruct.blocks.logic.ToolForgeLogic;
import mods.tinker.tconstruct.blocks.logic.ToolStationLogic;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot; import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
public class ToolForgeContainer extends ActiveContainer public class ToolForgeContainer extends ToolStationContainer
{ {
InventoryPlayer invPlayer;
ToolForgeLogic logic;
Slot[] slots;
SlotToolForge toolSlot;
public ToolForgeContainer(InventoryPlayer inventoryplayer, ToolForgeLogic logic) public ToolForgeContainer(InventoryPlayer inventoryplayer, ToolForgeLogic logic)
{
super(inventoryplayer, logic);
}
public void initializeContainer(InventoryPlayer inventoryplayer, ToolStationLogic builderlogic)
{ {
invPlayer = inventoryplayer; invPlayer = inventoryplayer;
this.logic = logic; this.logic = builderlogic;
toolSlot = new SlotToolForge(inventoryplayer.player, logic, 0, 115, 38); toolSlot = new SlotToolForge(inventoryplayer.player, logic, 0, 115, 38);
this.addSlotToContainer(toolSlot); this.addSlotToContainer(toolSlot);
@ -68,53 +71,6 @@ public class ToolForgeContainer extends ActiveContainer
} }
} }
@Override
public boolean canInteractWith (EntityPlayer var1)
{
return true;
}
public ItemStack transferStackInSlot (EntityPlayer player, int slotID)
{
ItemStack stack = null;
Slot slot = (Slot) this.inventorySlots.get(slotID);
if (slot != null && slot.getHasStack())
{
ItemStack slotStack = slot.getStack();
stack = slotStack.copy();
if (slotID < logic.getSizeInventory())
{
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(), false))
{
return null;
}
if (slotStack.stackSize == 0)
{
slot.putStack((ItemStack) null);
}
else
{
slot.onSlotChanged();
}
}
return stack;
}
protected void craftTool (ItemStack stack) protected void craftTool (ItemStack stack)
{ {
NBTTagCompound tags = stack.getTagCompound(); NBTTagCompound tags = stack.getTagCompound();
@ -127,100 +83,4 @@ public class ToolForgeContainer extends ActiveContainer
logic.worldObj.playAuxSFX(1021, (int)logic.xCoord, (int)logic.yCoord, (int)logic.zCoord, 0); logic.worldObj.playAuxSFX(1021, (int)logic.xCoord, (int)logic.yCoord, (int)logic.zCoord, 0);
} }
} }
protected boolean mergeCraftedStack (ItemStack stack, int slotsStart, int slotsTotal, boolean playerInventory, EntityPlayer player)
{
boolean failedToMerge = false;
int slotIndex = slotsStart;
if (playerInventory)
{
slotIndex = slotsTotal - 1;
}
Slot otherInventorySlot;
ItemStack copyStack = null;
/*if (stack.isStackable())
{
while (stack.stackSize > 0 && (!playerInventory && slotIndex < slotsTotal || playerInventory && slotIndex >= slotsStart))
{
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))
{
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;
}
}
}*/
if (stack.stackSize > 0)
{
if (playerInventory)
{
slotIndex = slotsTotal - 1;
}
else
{
slotIndex = slotsStart;
}
while (!playerInventory && slotIndex < slotsTotal || playerInventory && slotIndex >= slotsStart)
{
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;
}
}
}
/*boolean emptySlots = ( ((Slot) inventorySlots.get(2)).getStack() == null && ((Slot) inventorySlots.get(3)).getStack() == null );
System.out.println("Empty slots");
if (!failedToMerge && emptySlots)
player.worldObj.playAuxSFX(1021, (int)player.posX, (int)player.posY, (int)player.posZ, 0);*/
return failedToMerge;
}
} }

View File

@ -12,38 +12,43 @@ import net.minecraft.nbt.NBTTagCompound;
public class ToolStationContainer extends ActiveContainer public class ToolStationContainer extends ActiveContainer
{ {
InventoryPlayer invPlayer; public InventoryPlayer invPlayer;
ToolStationLogic logic; public ToolStationLogic logic;
Slot[] slots; public Slot[] slots;
SlotTool toolSlot; public SlotTool toolSlot;
Random random = new Random(); public Random random = new Random();
public ToolStationContainer(InventoryPlayer inventoryplayer, ToolStationLogic builderlogic) public ToolStationContainer(InventoryPlayer inventoryplayer, ToolStationLogic builderlogic)
{ {
invPlayer = inventoryplayer; initializeContainer(inventoryplayer, builderlogic);
logic = builderlogic; }
toolSlot = new SlotTool(inventoryplayer.player, builderlogic, 0, 115, 38); public void initializeContainer(InventoryPlayer inventoryplayer, ToolStationLogic builderlogic)
this.addSlotToContainer(toolSlot); {
slots = new Slot[] { new Slot(builderlogic, 1, 57, 29), new Slot(builderlogic, 2, 39, 38), new Slot(builderlogic, 3, 57, 47) }; invPlayer = inventoryplayer;
logic = builderlogic;
for (int iter = 0; iter < 3; iter ++) toolSlot = new SlotTool(inventoryplayer.player, builderlogic, 0, 115, 38);
this.addSlotToContainer(slots[iter]); this.addSlotToContainer(toolSlot);
slots = new Slot[] { new Slot(builderlogic, 1, 57, 29), new Slot(builderlogic, 2, 39, 38), new Slot(builderlogic, 3, 57, 47) };
/* Player inventory */ for (int iter = 0; iter < 3; iter ++)
for (int column = 0; column < 3; column++) this.addSlotToContainer(slots[iter]);
/* Player inventory */
for (int column = 0; column < 3; column++)
{ {
for (int row = 0; row < 9; row++) for (int row = 0; row < 9; row++)
{ {
this.addSlotToContainer(new Slot(inventoryplayer, row + column * 9 + 9, 8 + row * 18, 84 + column * 18)); this.addSlotToContainer(new Slot(inventoryplayer, row + column * 9 + 9, 8 + row * 18, 84 + column * 18));
} }
} }
for (int column = 0; column < 9; column++) for (int column = 0; column < 9; column++)
{ {
this.addSlotToContainer(new Slot(inventoryplayer, column, 8 + column * 18, 142)); this.addSlotToContainer(new Slot(inventoryplayer, column, 8 + column * 18, 142));
} }
} }
//posX and posY must be the same length //posX and posY must be the same length
public void resetSlots(int[] posX, int[] posY) public void resetSlots(int[] posX, int[] posY)

View File

@ -34,7 +34,7 @@ public class Pattern extends CraftingItem
public static final String[] patternName = new String[] { public static final String[] patternName = new String[] {
"ingot", "rod", "pickaxe", "shovel", "axe", "swordblade", "largeguard", "mediumguard", "crossbar", "binding", "frypan", "sign", "knifeblade", "chisel", "largerod", "toughbinding", "largeplate", "ingot", "rod", "pickaxe", "shovel", "axe", "swordblade", "largeguard", "mediumguard", "crossbar", "binding", "frypan", "sign", "knifeblade", "chisel", "largerod", "toughbinding", "largeplate",
"broadaxe", "scythe", "excavator", "largeblade", "hammerhead" }; "broadaxe", "scythe", "excavator", "largeblade", "hammerhead", "fullguard" };
/*@SideOnly(Side.CLIENT) /*@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister) public void registerIcons(IconRegister iconRegister)
@ -49,7 +49,7 @@ public class Pattern extends CraftingItem
public void getSubItems (int id, CreativeTabs tab, List list) public void getSubItems (int id, CreativeTabs tab, List list)
{ {
for (int i = 1; i < patternName.length; i++) for (int i = 1; i < patternName.length-1; i++)
list.add(new ItemStack(id, 1, i)); list.add(new ItemStack(id, 1, i));
} }
@ -105,6 +105,7 @@ public class Pattern extends CraftingItem
case 19: return 16; case 19: return 16;
case 20: return 16; case 20: return 16;
case 21: return 16; case 21: return 16;
case 22: return 2;
default: return 0; default: return 0;
} }
} }

View File

@ -0,0 +1,19 @@
package mods.tinker.tconstruct.items;
import java.util.List;
import net.minecraft.creativetab.CreativeTabs;
public class ToolPartHidden extends ToolPart
{
public ToolPartHidden(int id, String partType, String textureType)
{
super(id, partType, textureType);
}
public void getSubItems (int id, CreativeTabs tab, List list)
{
}
}

View File

@ -0,0 +1,70 @@
package mods.tinker.tconstruct.items.tools;
import java.util.List;
import mods.tinker.tconstruct.common.TContent;
import mods.tinker.tconstruct.library.tools.Weapon;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
public class Cutlass extends Weapon
{
public Cutlass(int itemID)
{
super(itemID, 4);
this.setUnlocalizedName("InfiTool.Cutlass");
}
@Override
public Item getHeadItem ()
{
return TContent.swordBlade;
}
@Override
public Item getAccessoryItem ()
{
return TContent.fullGuard;
}
@Override
public String getIconSuffix (int partType)
{
switch (partType)
{
case 0:
return "_cutlass_blade";
case 1:
return "_cutlass_blade_broken";
case 2:
return "_cutlass_handle";
case 3:
return "_cutlass_guard";
default:
return "";
}
}
@Override
public String getEffectSuffix ()
{
return "_cutlass_effect";
}
@Override
public String getDefaultFolder ()
{
return "cutlass";
}
@Override
public int durabilityTypeAccessory ()
{
return 1;
}
public void getSubItems (int id, CreativeTabs tab, List list)
{
}
}

View File

@ -45,11 +45,6 @@ public class Hammer extends HarvestTool
return 4; return 4;
} }
public int durabilityTypeHandle ()
{
return 2;
}
public int durabilityTypeAccessory () public int durabilityTypeAccessory ()
{ {
return 2; return 2;
@ -57,7 +52,7 @@ public class Hammer extends HarvestTool
public int durabilityTypeExtra () public int durabilityTypeExtra ()
{ {
return 1; return 2;
} }
@Override @Override

View File

@ -7,6 +7,7 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import mods.tinker.tconstruct.common.TContent;
import mods.tinker.tconstruct.library.ActiveToolMod; import mods.tinker.tconstruct.library.ActiveToolMod;
import mods.tinker.tconstruct.library.TConstructRegistry; import mods.tinker.tconstruct.library.TConstructRegistry;
import mods.tinker.tconstruct.library.util.PiercingEntityDamage; import mods.tinker.tconstruct.library.util.PiercingEntityDamage;
@ -74,9 +75,8 @@ public class AbilityHelper
int durability = tags.getCompoundTag("InfiTool").getInteger("Damage"); int durability = tags.getCompoundTag("InfiTool").getInteger("Damage");
float stonebound = tags.getCompoundTag("InfiTool").getFloat("Shoddy"); float stonebound = tags.getCompoundTag("InfiTool").getFloat("Shoddy");
float stoneboundDamage = -stonebound * durability / 65f;
if (stonebound > 0) float stoneboundDamage = (float) Math.log(durability / 72f + 1) * -2 * stonebound;
stoneboundDamage = -stonebound * durability / 100f;
int earlyModDamage = 0; int earlyModDamage = 0;
for (ActiveToolMod mod : TConstructRegistry.activeModifiers) for (ActiveToolMod mod : TConstructRegistry.activeModifiers)
@ -138,6 +138,9 @@ public class AbilityHelper
boolean criticalHit = player.fallDistance > 0.0F && !player.onGround && !player.isOnLadder() && !player.isInWater() && !player.isPotionActive(Potion.blindness) boolean criticalHit = player.fallDistance > 0.0F && !player.onGround && !player.isOnLadder() && !player.isInWater() && !player.isPotionActive(Potion.blindness)
&& player.ridingEntity == null && entity instanceof EntityLiving; && player.ridingEntity == null && entity instanceof EntityLiving;
if (tool == TContent.cutlass && random.nextInt(10) == 0)
criticalHit = true;
if (criticalHit) if (criticalHit)
{ {
damage += random.nextInt(damage / 2 + 2); damage += random.nextInt(damage / 2 + 2);
@ -172,7 +175,7 @@ public class AbilityHelper
tool.onEntityDamaged(player.worldObj, player, entity); tool.onEntityDamaged(player.worldObj, player, entity);
int drain = toolTags.getInteger("Necrotic") * 2; int drain = toolTags.getInteger("Necrotic") * 2;
if (drain > 0) if (drain > 0)
player.heal(random.nextInt(drain)); player.heal(random.nextInt(drain+1));
if (knockback > 0) if (knockback > 0)
{ {

View File

@ -67,16 +67,35 @@ public abstract class HarvestTool extends ToolCore
{ {
if (materials[i] == block.blockMaterial) if (materials[i] == block.blockMaterial)
{ {
float speed = tags.getInteger("MiningSpeed"); float mineSpeed = tags.getInteger("MiningSpeed");
speed /= 100f; int heads = 1;
if (tags.hasKey("MiningSpeed2"))
{
mineSpeed += tags.getInteger("MiningSpeed2");
heads++;
}
if (tags.hasKey("MiningSpeedHandle"))
{
mineSpeed += tags.getInteger("MiningSpeedHandle");
heads++;
}
if (tags.hasKey("MiningSpeedExtra"))
{
mineSpeed += tags.getInteger("MiningSpeedExtra");
heads++;
}
float trueSpeed = mineSpeed / (heads * 100f);
int hlvl = MinecraftForge.getBlockHarvestLevel(block, meta, getHarvestType()); int hlvl = MinecraftForge.getBlockHarvestLevel(block, meta, getHarvestType());
int durability = tags.getInteger("Damage"); int durability = tags.getInteger("Damage");
float shoddy = tags.getFloat("Shoddy"); float stonebound = tags.getFloat("Shoddy");
speed += shoddy * durability / 100f; float bonusLog = (float) Math.log(durability / 72f + 1) * 2 * stonebound;
trueSpeed += bonusLog;
if (hlvl <= tags.getInteger("HarvestLevel")) if (hlvl <= tags.getInteger("HarvestLevel"))
return speed; return trueSpeed;
return 0.1f; return 0.1f;
} }
} }

View File

@ -156,9 +156,53 @@ public abstract class ToolMod
tags.setString(modTip, modifierTip); tags.setString(modTip, modifierTip);
return tipNum; return tipNum;
} }
else
{
String tag = tags.getString(tip);
if (tag.contains(tooltip))
{
tags.setString(tip, getProperName(tooltip, tag));
String modTip = "ModifierTip" + tipNum;
tag = tags.getString(modTip);
tags.setString(modTip, getProperName(modifierTip, tag));
return tipNum;
}
}
} }
} }
protected String getProperName(String tooltip, String tag)
{
if (tag.equals(tooltip))
return tooltip + " II";
if (tag.equals(tooltip + " II"))
return tooltip + " III";
if (tag.equals(tooltip + " III"))
return tooltip + " IV";
if (tag.equals(tooltip + " IV"))
return tooltip + " V";
if (tag.equals(tooltip + " V"))
return tooltip + " VI";
if (tag.equals(tooltip + " VI"))
return tooltip + " VII";
if (tag.equals(tooltip + " VII"))
return tooltip + " VIII";
if (tag.equals(tooltip + " VIII"))
return tooltip + " IX";
if (tag.equals(tooltip + " IX"))
return tooltip + " X";
return tooltip + " X+";
}
public boolean validType(ToolCore tool) public boolean validType(ToolCore tool)
{ {
return true; return true;

View File

@ -33,5 +33,38 @@ public class ModReinforced extends ModInteger
int reinforced = tags.getInteger("Unbreaking"); int reinforced = tags.getInteger("Unbreaking");
reinforced += 1; reinforced += 1;
tags.setInteger("Unbreaking", reinforced); tags.setInteger("Unbreaking", reinforced);
addToolTip(tool, color+tooltipName, color+key);
}
protected int addToolTip (ItemStack tool, String tooltip, String modifierTip)
{
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
int tipNum = 0;
while (true)
{
tipNum++;
String tip = "Tooltip" + tipNum;
if (!tags.hasKey(tip))
{
//tags.setString(tip, tooltip);
String modTip = "ModifierTip" + tipNum;
String tag = tags.getString(modTip);
tags.setString(modTip, getProperName(modifierTip, tag));
return tipNum;
}
else
{
String modTip = "ModifierTip" + tipNum;
String tag = tags.getString(modTip);
if (tag.contains(modifierTip))
{
//tags.setString(tip, getProperName(tooltip, tag));
tag = tags.getString(modTip);
tags.setString(modTip, getProperName(modifierTip, tag));
return tipNum;
}
}
}
} }
} }

View File

@ -13,6 +13,7 @@ import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EnumCreatureAttribute;
import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.item.EntityXPOrb; import net.minecraft.entity.item.EntityXPOrb;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -25,162 +26,172 @@ import net.minecraft.world.World;
public class TActiveOmniMod extends ActiveToolMod public class TActiveOmniMod extends ActiveToolMod
{ {
Random random = new Random(); Random random = new Random();
/* Updating */ /* Updating */
@Override @Override
public void updateTool (ToolCore tool, ItemStack stack, World world, Entity entity) public void updateTool (ToolCore tool, ItemStack stack, World world, Entity entity)
{ {
if (!world.isRemote && entity instanceof EntityLiving && !((EntityLiving) entity).isSwingInProgress && stack.getTagCompound() != null) if (!world.isRemote && entity instanceof EntityLiving && !((EntityLiving) entity).isSwingInProgress && stack.getTagCompound() != null)
{ {
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool"); NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
if (tags.hasKey("Moss")) if (tags.hasKey("Moss"))
{ {
int chance = tags.getInteger("Moss"); int chance = tags.getInteger("Moss");
int check = world.canBlockSeeTheSky((int) entity.posX, (int) entity.posY, (int) entity.posZ) ? 350 : 1150; int check = world.canBlockSeeTheSky((int) entity.posX, (int) entity.posY, (int) entity.posZ) ? 350 : 1150;
if (random.nextInt(check) < chance) if (random.nextInt(check) < chance)
{ {
AbilityHelper.healTool(stack, 1, (EntityLiving) entity, true); AbilityHelper.healTool(stack, 1, (EntityLiving) entity, true);
} }
} }
} }
} }
/* Harvesting */ /* Harvesting */
@Override @Override
public boolean beforeBlockBreak (ToolCore tool, ItemStack stack, int x, int y, int z, EntityLiving entity) public boolean beforeBlockBreak (ToolCore tool, ItemStack stack, int x, int y, int z, EntityLiving entity)
{ {
if (entity instanceof EntityPlayer && ((EntityPlayer)entity).capabilities.isCreativeMode) if (entity instanceof EntityPlayer && ((EntityPlayer) entity).capabilities.isCreativeMode)
return false; return false;
if (tool instanceof HarvestTool) if (tool instanceof HarvestTool)
TContent.modL.midStreamModify(stack); TContent.modL.midStreamModify(stack);
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool"); NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
World world = entity.worldObj; World world = entity.worldObj;
int bID = entity.worldObj.getBlockId(x, y, z); int bID = entity.worldObj.getBlockId(x, y, z);
int meta = world.getBlockMetadata(x, y, z); int meta = world.getBlockMetadata(x, y, z);
Block block = Block.blocksList[bID]; Block block = Block.blocksList[bID];
if (block == null || bID < 1 || bID > 4095) if (block == null || bID < 1 || bID > 4095)
return false; return false;
if (tags.getBoolean("Lava") && block.quantityDropped(meta, 0, random) != 0) if (tags.getBoolean("Lava") && block.quantityDropped(meta, 0, random) != 0)
{ {
ItemStack smeltStack = new ItemStack(block.idDropped(meta, random, 0), 1, block.damageDropped(meta)); ItemStack smeltStack = new ItemStack(block.idDropped(meta, random, 0), 1, block.damageDropped(meta));
if (smeltStack.itemID < 0 || smeltStack.itemID >= 32000 || smeltStack.getItem() == null) if (smeltStack.itemID < 0 || smeltStack.itemID >= 32000 || smeltStack.getItem() == null)
return false; return false;
ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(smeltStack); ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(smeltStack);
if (result != null) if (result != null)
{ {
world.setBlockToAir(x, y, z); world.setBlockToAir(x, y, z);
if (entity instanceof EntityPlayer && !((EntityPlayer)entity).capabilities.isCreativeMode) if (entity instanceof EntityPlayer && !((EntityPlayer) entity).capabilities.isCreativeMode)
tool.onBlockDestroyed(stack, world, bID, x, y, z, entity); tool.onBlockDestroyed(stack, world, bID, x, y, z, entity);
if (!world.isRemote) if (!world.isRemote)
{ {
ItemStack spawnme = result.copy(); ItemStack spawnme = result.copy();
if (!(result.getItem() instanceof ItemBlock)) if (!(result.getItem() instanceof ItemBlock))
{ {
int loot = EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, stack); int loot = EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, stack);
if (loot > 0) if (loot > 0)
{ {
spawnme.stackSize *= (random.nextInt(loot + 1) + 1); spawnme.stackSize *= (random.nextInt(loot + 1) + 1);
} }
} }
EntityItem entityitem = new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, spawnme); EntityItem entityitem = new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, spawnme);
entityitem.delayBeforeCanPickup = 10; entityitem.delayBeforeCanPickup = 10;
world.spawnEntityInWorld(entityitem); world.spawnEntityInWorld(entityitem);
world.playAuxSFX(2001, x, y, z, bID + (meta << 12)); world.playAuxSFX(2001, x, y, z, bID + (meta << 12));
int i = spawnme.stackSize; int i = spawnme.stackSize;
float f = FurnaceRecipes.smelting().getExperience(spawnme); float f = FurnaceRecipes.smelting().getExperience(spawnme);
int j; int j;
if (f == 0.0F) if (f == 0.0F)
{ {
i = 0; i = 0;
} }
else if (f < 1.0F) else if (f < 1.0F)
{ {
j = MathHelper.floor_float((float) i * f); j = MathHelper.floor_float((float) i * f);
if (j < MathHelper.ceiling_float_int((float) i * f) && (float) Math.random() < (float) i * f - (float) j) if (j < MathHelper.ceiling_float_int((float) i * f) && (float) Math.random() < (float) i * f - (float) j)
{ {
++j; ++j;
} }
i = j; i = j;
} }
while (i > 0) while (i > 0)
{ {
j = EntityXPOrb.getXPSplit(i); j = EntityXPOrb.getXPSplit(i);
i -= j; i -= j;
entity.worldObj.spawnEntityInWorld(new EntityXPOrb(world, x, y + 0.5, z, j)); entity.worldObj.spawnEntityInWorld(new EntityXPOrb(world, x, y + 0.5, z, j));
} }
} }
for (int i = 0; i < 6; i++) for (int i = 0; i < 6; i++)
{ {
float f = (float) x + random.nextFloat(); float f = (float) x + random.nextFloat();
float f1 = (float) y + random.nextFloat(); float f1 = (float) y + random.nextFloat();
float f2 = (float) z + random.nextFloat(); float f2 = (float) z + random.nextFloat();
float f3 = 0.52F; float f3 = 0.52F;
float f4 = random.nextFloat() * 0.6F - 0.3F; float f4 = random.nextFloat() * 0.6F - 0.3F;
world.spawnParticle("smoke", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D); world.spawnParticle("smoke", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D); world.spawnParticle("flame", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
world.spawnParticle("smoke", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D); world.spawnParticle("smoke", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D); world.spawnParticle("flame", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
world.spawnParticle("smoke", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D); world.spawnParticle("smoke", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D); world.spawnParticle("flame", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D);
world.spawnParticle("smoke", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D); world.spawnParticle("smoke", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D); world.spawnParticle("flame", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D);
} }
return true; return true;
} }
} }
return false; return false;
} }
/* Attacking */ /* Attacking */
@Override
public int baseAttackDamage (int earlyModDamage, int damage, ToolCore tool, NBTTagCompound tags, NBTTagCompound toolTags, ItemStack stack, EntityPlayer player, Entity entity)
{
if (tool instanceof Weapon)
TContent.modL.midStreamModify(stack);
return 0;
}
@Override @Override
public int attackDamage(int modDamage, int currentDamage, ToolCore tool, NBTTagCompound tags, NBTTagCompound toolTags, ItemStack stack, EntityPlayer player, Entity entity) public int baseAttackDamage (int earlyModDamage, int damage, ToolCore tool, NBTTagCompound tags, NBTTagCompound toolTags, ItemStack stack, EntityPlayer player, Entity entity)
{
if (tool instanceof Weapon)
TContent.modL.midStreamModify(stack);
return 0;
}
@Override
public int attackDamage (int modDamage, int currentDamage, ToolCore tool, NBTTagCompound tags, NBTTagCompound toolTags, ItemStack stack, EntityPlayer player, Entity entity)
{ {
int bonus = 0; int bonus = 0;
if (tool == TContent.hammer) if (entity instanceof EntityLiving)
{ {
int level = 2; EnumCreatureAttribute attribute = ((EntityLiving) entity).getCreatureAttribute();
bonus += random.nextInt(level*2+1) + level*2; if (attribute == EnumCreatureAttribute.UNDEAD)
} {
if (toolTags.hasKey("ModSmite")) if (tool == TContent.hammer)
{ {
int[] array = toolTags.getIntArray("ModSmite"); int level = 2;
int base = array[0] / 18; bonus += random.nextInt(level * 2 + 1) + level * 2;
bonus += 1 + base + random.nextInt(base+1); }
} if (toolTags.hasKey("ModSmite"))
if (toolTags.hasKey("ModAntiSpider")) {
{ int[] array = toolTags.getIntArray("ModSmite");
int[] array = toolTags.getIntArray("ModAntiSpider"); int base = array[0] / 18;
int base = array[0] / 2; bonus += 1 + base + random.nextInt(base + 1);
bonus += 1 + base + random.nextInt(base+1); }
}
if (attribute == EnumCreatureAttribute.ARTHROPOD)
{
if (toolTags.hasKey("ModAntiSpider"))
{
int[] array = toolTags.getIntArray("ModAntiSpider");
int base = array[0] / 2;
bonus += 1 + base + random.nextInt(base + 1);
}
}
} }
return bonus; return bonus;
} }
@Override @Override
public float knockback(float modKnockback, float currentKnockback, ToolCore tool, NBTTagCompound tags, NBTTagCompound toolTags, ItemStack stack, EntityPlayer player, Entity entity) public float knockback (float modKnockback, float currentKnockback, ToolCore tool, NBTTagCompound tags, NBTTagCompound toolTags, ItemStack stack, EntityPlayer player, Entity entity)
{ {
float bonus = 0f; float bonus = 0f;
if (toolTags.hasKey("Knockback")) if (toolTags.hasKey("Knockback"))

View File

@ -124,6 +124,7 @@ public class PHConstruct
largePlate = config.getItem("Tool Parts", "Large Plate", 14044).getInt(14044); largePlate = config.getItem("Tool Parts", "Large Plate", 14044).getInt(14044);
excavatorHead = config.getItem("Tool Parts", "Excavator Head", 14045).getInt(14045); excavatorHead = config.getItem("Tool Parts", "Excavator Head", 14045).getInt(14045);
hammerHead = config.getItem("Tool Parts", "Hammer Head", 14046).getInt(14046); hammerHead = config.getItem("Tool Parts", "Hammer Head", 14046).getInt(14046);
fullGuard = config.getItem("Tool Parts", "Full Guard", 14047).getInt(14047);
pickaxe = config.getItem("Tools", "Pickaxe", 14051).getInt(14051); pickaxe = config.getItem("Tools", "Pickaxe", 14051).getInt(14051);
shovel = config.getItem("Tools", "Shovel", 14052).getInt(14052); shovel = config.getItem("Tools", "Shovel", 14052).getInt(14052);
@ -150,6 +151,8 @@ public class PHConstruct
hammer = config.getItem("Tools", "Hammer", 14070).getInt(14070); hammer = config.getItem("Tools", "Hammer", 14070).getInt(14070);
battleaxe = config.getItem("Tools", "Battleaxe", 14071).getInt(14071); battleaxe = config.getItem("Tools", "Battleaxe", 14071).getInt(14071);
cutlass = config.getItem("Tools", "Cutlass", 14072).getInt(14072);
buckets = config.getItem("Patterns and Misc", "Buckets", 14101).getInt(14101); buckets = config.getItem("Patterns and Misc", "Buckets", 14101).getInt(14101);
uselessItem = config.getItem("Patterns and Misc", "Title Icon", 14102).getInt(14102); uselessItem = config.getItem("Patterns and Misc", "Title Icon", 14102).getInt(14102);
slimefood = config.getItem("Patterns and Misc", "Strange Food", 14103).getInt(14103); slimefood = config.getItem("Patterns and Misc", "Strange Food", 14103).getInt(14103);
@ -314,6 +317,7 @@ public class PHConstruct
public static int longsword; public static int longsword;
public static int rapier; public static int rapier;
public static int dagger; public static int dagger;
public static int cutlass;
public static int frypan; public static int frypan;
public static int battlesign; public static int battlesign;
@ -337,6 +341,7 @@ public class PHConstruct
public static int medGuard; public static int medGuard;
public static int crossbar; public static int crossbar;
public static int knifeBlade; public static int knifeBlade;
public static int fullGuard;
public static int pickaxeHead; public static int pickaxeHead;
public static int axeHead; public static int axeHead;

View File

@ -28,11 +28,14 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.EnumMovingObjectType; import net.minecraft.util.EnumMovingObjectType;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.event.Event.Result; import net.minecraftforge.event.Event.Result;
import net.minecraftforge.event.ForgeSubscribe; import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.entity.living.LivingDropsEvent; import net.minecraftforge.event.entity.living.LivingDropsEvent;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
import net.minecraftforge.event.entity.living.LivingSpawnEvent; import net.minecraftforge.event.entity.living.LivingSpawnEvent;
import net.minecraftforge.event.entity.player.FillBucketEvent; import net.minecraftforge.event.entity.player.FillBucketEvent;
import net.minecraftforge.liquids.LiquidStack; import net.minecraftforge.liquids.LiquidStack;
@ -76,15 +79,24 @@ public class TEventHandler
/*@ForgeSubscribe /*@ForgeSubscribe
public void onHurt (LivingHurtEvent event) public void onHurt (LivingHurtEvent event)
{ {*/
if (event.source instanceof EntityDamageSource && event.source.damageType.equals("explosion.player") && ((EntityDamageSource) event.source).getEntity() instanceof NitroCreeper) /*if (event.entityLiving instanceof EntityPlayer)
{
EntityPlayer player = (EntityPlayer) event.entityLiving;
ItemStack stack = player.getItemInUse();
if (stack != null && stack.getItem() == TContent.cutlass)
{
player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 3*20, 1));
}
}*/
/*if (event.source instanceof EntityDamageSource && event.source.damageType.equals("explosion.player") && ((EntityDamageSource) event.source).getEntity() instanceof NitroCreeper)
{ {
if (event.entityLiving.worldObj.difficultySetting == 3) if (event.entityLiving.worldObj.difficultySetting == 3)
event.ammount /= 2.3; event.ammount /= 2.3;
else else
event.ammount /= 1.5; event.ammount /= 1.5;
} }*/
}*/ //}
/* Drops */ /* Drops */
@ForgeSubscribe @ForgeSubscribe
@ -141,7 +153,7 @@ public class TEventHandler
{ {
EntityPlayer player = (EntityPlayer) event.source.getEntity(); EntityPlayer player = (EntityPlayer) event.source.getEntity();
ItemStack stack = player.getCurrentEquippedItem(); ItemStack stack = player.getCurrentEquippedItem();
if (stack.hasTagCompound() && stack.getItem() instanceof ToolCore) if (stack != null && stack.hasTagCompound() && stack.getItem() instanceof ToolCore)
{ {
int beheading = stack.getTagCompound().getCompoundTag("InfiTool").getInteger("Beheading"); int beheading = stack.getTagCompound().getCompoundTag("InfiTool").getInteger("Beheading");
if (beheading > 0 && random.nextInt(100) < beheading * 10) if (beheading > 0 && random.nextInt(100) < beheading * 10)
@ -165,7 +177,7 @@ public class TEventHandler
EntityPlayer player = (EntityPlayer) event.source.getEntity(); EntityPlayer player = (EntityPlayer) event.source.getEntity();
ItemStack stack = player.getCurrentEquippedItem(); ItemStack stack = player.getCurrentEquippedItem();
if (stack.hasTagCompound() && stack.getItem() instanceof ToolCore) if (stack != null && stack.hasTagCompound() && stack.getItem() instanceof ToolCore)
{ {
int beheading = stack.getTagCompound().getCompoundTag("InfiTool").getInteger("Beheading"); int beheading = stack.getTagCompound().getCompoundTag("InfiTool").getInteger("Beheading");
if (beheading > 0 && random.nextInt(100) < beheading * 10) if (beheading > 0 && random.nextInt(100) < beheading * 10)
@ -188,7 +200,7 @@ public class TEventHandler
{ {
EntityPlayer player = (EntityPlayer) event.source.getEntity(); EntityPlayer player = (EntityPlayer) event.source.getEntity();
ItemStack stack = player.getCurrentEquippedItem(); ItemStack stack = player.getCurrentEquippedItem();
if (stack.hasTagCompound() && stack.getItem() instanceof ToolCore) if (stack != null && stack.hasTagCompound() && stack.getItem() instanceof ToolCore)
{ {
int beheading = stack.getTagCompound().getCompoundTag("InfiTool").getInteger("Beheading"); int beheading = stack.getTagCompound().getCompoundTag("InfiTool").getInteger("Beheading");
if (beheading > 0 && random.nextInt(100) < beheading * 5) if (beheading > 0 && random.nextInt(100) < beheading * 5)
@ -207,7 +219,7 @@ public class TEventHandler
{ {
EntityPlayer player = (EntityPlayer) event.source.getEntity(); EntityPlayer player = (EntityPlayer) event.source.getEntity();
ItemStack stack = player.getCurrentEquippedItem(); ItemStack stack = player.getCurrentEquippedItem();
if (stack.hasTagCompound() && stack.getItem() instanceof ToolCore) if (stack != null && stack.hasTagCompound() && stack.getItem() instanceof ToolCore)
{ {
int beheading = stack.getTagCompound().getCompoundTag("InfiTool").getInteger("Beheading"); int beheading = stack.getTagCompound().getCompoundTag("InfiTool").getInteger("Beheading");
if (beheading > 0 && random.nextInt(100) < beheading * 50) if (beheading > 0 && random.nextInt(100) < beheading * 50)

View File

@ -158,7 +158,7 @@ public class ArmorExtended implements IInventory
player.maxHealth = 20 + bonusHP; player.maxHealth = 20 + bonusHP;
} }
} }
else else if (parent != null && parent.get() != null)
{ {
parent.get().maxHealth = 20; parent.get().maxHealth = 20;
} }

View File

@ -29,290 +29,291 @@ import cpw.mods.fml.relauncher.Side;
public class TPlayerHandler implements IPlayerTracker public class TPlayerHandler implements IPlayerTracker
{ {
/* Player */ /* Player */
//public int hunger; //public int hunger;
public ConcurrentHashMap<String, TPlayerStats> playerStats = new ConcurrentHashMap<String, TPlayerStats>(); public ConcurrentHashMap<String, TPlayerStats> playerStats = new ConcurrentHashMap<String, TPlayerStats>();
@Override @Override
public void onPlayerLogin (EntityPlayer entityplayer) public void onPlayerLogin (EntityPlayer entityplayer)
{ {
//System.out.println("Player: "+entityplayer); //System.out.println("Player: "+entityplayer);
//Lookup player //Lookup player
TFoodStats food = new TFoodStats(); TFoodStats food = new TFoodStats();
food.readStats(entityplayer.foodStats); food.readStats(entityplayer.foodStats);
entityplayer.foodStats = food; entityplayer.foodStats = food;
NBTTagCompound tags = entityplayer.getEntityData(); NBTTagCompound tags = entityplayer.getEntityData();
if (!tags.hasKey("TConstruct")) if (!tags.hasKey("TConstruct"))
{ {
tags.setCompoundTag("TConstruct", new NBTTagCompound()); tags.setCompoundTag("TConstruct", new NBTTagCompound());
} }
TPlayerStats stats = new TPlayerStats(); TPlayerStats stats = new TPlayerStats();
stats.player = new WeakReference<EntityPlayer>(entityplayer); stats.player = new WeakReference<EntityPlayer>(entityplayer);
stats.armor = new ArmorExtended(); stats.armor = new ArmorExtended();
stats.armor.init(entityplayer); stats.armor.init(entityplayer);
stats.armor.readFromNBT(entityplayer); stats.armor.readFromNBT(entityplayer);
stats.knapsack = new KnapsackInventory(); stats.knapsack = new KnapsackInventory();
stats.knapsack.init(entityplayer); stats.knapsack.init(entityplayer);
stats.knapsack.readFromNBT(entityplayer); stats.knapsack.readFromNBT(entityplayer);
stats.level = entityplayer.experienceLevel; stats.level = entityplayer.experienceLevel;
stats.hunger = entityplayer.getFoodStats().getFoodLevel(); stats.hunger = entityplayer.getFoodStats().getFoodLevel();
stats.beginnerManual = tags.getCompoundTag("TConstruct").getBoolean("beginnerManual"); stats.beginnerManual = tags.getCompoundTag("TConstruct").getBoolean("beginnerManual");
stats.materialManual = tags.getCompoundTag("TConstruct").getBoolean("materialManual"); stats.materialManual = tags.getCompoundTag("TConstruct").getBoolean("materialManual");
stats.smelteryManual = tags.getCompoundTag("TConstruct").getBoolean("smelteryManual"); stats.smelteryManual = tags.getCompoundTag("TConstruct").getBoolean("smelteryManual");
if (!stats.beginnerManual) if (!stats.beginnerManual)
{ {
stats.beginnerManual = true; stats.beginnerManual = true;
tags.getCompoundTag("TConstruct").setBoolean("beginnerManual", true); tags.getCompoundTag("TConstruct").setBoolean("beginnerManual", true);
if (PHConstruct.beginnerBook) if (PHConstruct.beginnerBook)
{ {
ItemStack diary = new ItemStack(TContent.manualBook); ItemStack diary = new ItemStack(TContent.manualBook);
if (!entityplayer.inventory.addItemStackToInventory(diary)) if (!entityplayer.inventory.addItemStackToInventory(diary))
{ {
AbilityHelper.spawnItemAtPlayer(entityplayer, diary); AbilityHelper.spawnItemAtPlayer(entityplayer, diary);
} }
} }
} }
stats.skillList = new ArrayList<Skill>(); stats.skillList = new ArrayList<Skill>();
//stats.armor.recalculateSkills(entityplayer, stats); //stats.armor.recalculateSkills(entityplayer, stats);
playerStats.put(entityplayer.username, stats); playerStats.put(entityplayer.username, stats);
//sendSkills(entityplayer, stats); //sendSkills(entityplayer, stats);
} }
void sendSkills (EntityPlayer entityplayer, TPlayerStats stats) void sendSkills (EntityPlayer entityplayer, TPlayerStats stats)
{ {
ByteArrayOutputStream bos = new ByteArrayOutputStream(8); ByteArrayOutputStream bos = new ByteArrayOutputStream(8);
DataOutputStream outputStream = new DataOutputStream(bos); DataOutputStream outputStream = new DataOutputStream(bos);
List<Skill> skills = stats.skillList; List<Skill> skills = stats.skillList;
try try
{ {
outputStream.writeByte(1); outputStream.writeByte(1);
outputStream.writeInt(skills.size()); outputStream.writeInt(skills.size());
for (Skill skill : stats.skillList) for (Skill skill : stats.skillList)
{ {
outputStream.writeInt(skill.getSkillID()); outputStream.writeInt(skill.getSkillID());
outputStream.writeBoolean(skill.getActive()); outputStream.writeBoolean(skill.getActive());
} }
//outputStream.writeByte(key); //outputStream.writeByte(key);
} }
catch (Exception ex) catch (Exception ex)
{ {
ex.printStackTrace(); ex.printStackTrace();
} }
updateClientPlayer(bos, entityplayer); updateClientPlayer(bos, entityplayer);
} }
void updateClientPlayer (ByteArrayOutputStream bos, EntityPlayer player) void updateClientPlayer (ByteArrayOutputStream bos, EntityPlayer player)
{ {
Packet250CustomPayload packet = new Packet250CustomPayload(); Packet250CustomPayload packet = new Packet250CustomPayload();
packet.channel = "TConstruct"; packet.channel = "TConstruct";
packet.data = bos.toByteArray(); packet.data = bos.toByteArray();
packet.length = bos.size(); packet.length = bos.size();
PacketDispatcher.sendPacketToPlayer(packet, (Player) player); PacketDispatcher.sendPacketToPlayer(packet, (Player) player);
} }
public void activateSkill (EntityPlayer player, int slot) public void activateSkill (EntityPlayer player, int slot)
{ {
TPlayerStats stats = getPlayerStats(player.username); TPlayerStats stats = getPlayerStats(player.username);
if (stats.skillList.size() > slot) if (stats.skillList.size() > slot)
{ {
Skill skill = stats.skillList.get(slot); Skill skill = stats.skillList.get(slot);
if (skill != null) if (skill != null)
{ {
skill.activate(player, player.worldObj); skill.activate(player, player.worldObj);
} }
} }
} }
@Override @Override
public void onPlayerLogout (EntityPlayer entityplayer) public void onPlayerLogout (EntityPlayer entityplayer)
{ {
savePlayerStats(entityplayer, true); savePlayerStats(entityplayer, true);
} }
@Override @Override
public void onPlayerChangedDimension (EntityPlayer entityplayer) public void onPlayerChangedDimension (EntityPlayer entityplayer)
{ {
savePlayerStats(entityplayer, false); savePlayerStats(entityplayer, false);
} }
void savePlayerStats (EntityPlayer player, boolean clean) void savePlayerStats (EntityPlayer player, boolean clean)
{ {
if (player != null) if (player != null)
{ {
TPlayerStats stats = getPlayerStats(player.username); TPlayerStats stats = getPlayerStats(player.username);
if (stats != null && stats.armor != null) if (stats != null && stats.armor != null)
{ {
stats.armor.saveToNBT(player); stats.armor.saveToNBT(player);
if (clean) stats.knapsack.saveToNBT(player);
playerStats.remove(player.username); if (clean)
} playerStats.remove(player.username);
else }
//Revalidate all players else
{ //Revalidate all players
{
} }
} }
} }
@Override @Override
public void onPlayerRespawn (EntityPlayer entityplayer) public void onPlayerRespawn (EntityPlayer entityplayer)
{ {
//Boom! //Boom!
TPlayerStats stats = getPlayerStats(entityplayer.username); TPlayerStats stats = getPlayerStats(entityplayer.username);
stats.player = new WeakReference<EntityPlayer>(entityplayer); stats.player = new WeakReference<EntityPlayer>(entityplayer);
stats.armor.recalculateHealth(entityplayer, stats); stats.armor.recalculateHealth(entityplayer, stats);
TFoodStats food = new TFoodStats(); TFoodStats food = new TFoodStats();
entityplayer.foodStats = food; entityplayer.foodStats = food;
if (PHConstruct.keepLevels) if (PHConstruct.keepLevels)
entityplayer.experienceLevel = stats.level; entityplayer.experienceLevel = stats.level;
if (PHConstruct.keepHunger) if (PHConstruct.keepHunger)
entityplayer.getFoodStats().addStats(-1 * (20 - stats.hunger), 0); entityplayer.getFoodStats().addStats(-1 * (20 - stats.hunger), 0);
NBTTagCompound tags = entityplayer.getEntityData(); NBTTagCompound tags = entityplayer.getEntityData();
NBTTagCompound tTag = new NBTTagCompound(); NBTTagCompound tTag = new NBTTagCompound();
tTag.setBoolean("beginnerManual", stats.beginnerManual); tTag.setBoolean("beginnerManual", stats.beginnerManual);
tTag.setBoolean("materialManual", stats.materialManual); tTag.setBoolean("materialManual", stats.materialManual);
tTag.setBoolean("smelteryManual", stats.smelteryManual); tTag.setBoolean("smelteryManual", stats.smelteryManual);
tags.setCompoundTag("TConstruct", tTag); tags.setCompoundTag("TConstruct", tTag);
Side side = FMLCommonHandler.instance().getEffectiveSide(); Side side = FMLCommonHandler.instance().getEffectiveSide();
if (side == Side.CLIENT) if (side == Side.CLIENT)
{ {
//TProxyClient.controlInstance.resetControls(); //TProxyClient.controlInstance.resetControls();
if (PHConstruct.keepHunger) if (PHConstruct.keepHunger)
entityplayer.getFoodStats().setFoodLevel(stats.hunger); entityplayer.getFoodStats().setFoodLevel(stats.hunger);
} }
} }
@ForgeSubscribe @ForgeSubscribe
public void livingFall (LivingFallEvent evt) //Only for negating fall damage public void livingFall (LivingFallEvent evt) //Only for negating fall damage
{ {
if (evt.entityLiving instanceof EntityPlayer) if (evt.entityLiving instanceof EntityPlayer)
{ {
evt.distance -= 1; evt.distance -= 1;
} }
} }
/*@ForgeSubscribe /*@ForgeSubscribe
public void livingUpdate (LivingUpdateEvent evt) public void livingUpdate (LivingUpdateEvent evt)
{ {
Side side = FMLCommonHandler.instance().getEffectiveSide(); Side side = FMLCommonHandler.instance().getEffectiveSide();
if (side == Side.CLIENT && evt.entityLiving instanceof EntityPlayer) if (side == Side.CLIENT && evt.entityLiving instanceof EntityPlayer)
{ {
EntityPlayer player = (EntityPlayer) evt.entityLiving; EntityPlayer player = (EntityPlayer) evt.entityLiving;
TPlayerStats stats = playerStats.get(player.username); TPlayerStats stats = playerStats.get(player.username);
if (player.onGround != stats.prevOnGround) if (player.onGround != stats.prevOnGround)
{ {
if (player.onGround)// && -stats.prevMotionY > 0.1) if (player.onGround)// && -stats.prevMotionY > 0.1)
//player.motionY = 0.5; //player.motionY = 0.5;
player.motionY = -stats.prevMotionY * 0.8; player.motionY = -stats.prevMotionY * 0.8;
//player.motionY *= -1.2; //player.motionY *= -1.2;
stats.prevOnGround = player.onGround; stats.prevOnGround = player.onGround;
//if () //if ()
//System.out.println("Fall: "+player.fallDistance); //System.out.println("Fall: "+player.fallDistance);
} }
} }
}*/ }*/
@ForgeSubscribe @ForgeSubscribe
public void playerDrops (PlayerDropsEvent evt) public void playerDrops (PlayerDropsEvent evt)
{ {
TPlayerStats stats = getPlayerStats(evt.entityPlayer.username); TPlayerStats stats = getPlayerStats(evt.entityPlayer.username);
stats.level = evt.entityPlayer.experienceLevel / 2; stats.level = evt.entityPlayer.experienceLevel / 2;
//stats.health = 20; //stats.health = 20;
int hunger = evt.entityPlayer.getFoodStats().getFoodLevel(); int hunger = evt.entityPlayer.getFoodStats().getFoodLevel();
if (hunger < 6) if (hunger < 6)
stats.hunger = 6; stats.hunger = 6;
else else
stats.hunger = evt.entityPlayer.getFoodStats().getFoodLevel(); stats.hunger = evt.entityPlayer.getFoodStats().getFoodLevel();
} }
/* Find the right player */ /* Find the right player */
public TPlayerStats getPlayerStats (String username) public TPlayerStats getPlayerStats (String username)
{ {
TPlayerStats stats = playerStats.get(username); TPlayerStats stats = playerStats.get(username);
//System.out.println("Stats: "+stats); //System.out.println("Stats: "+stats);
if (stats == null) if (stats == null)
{ {
stats = new TPlayerStats(); stats = new TPlayerStats();
playerStats.put(username, stats); playerStats.put(username, stats);
} }
return stats; return stats;
} }
public EntityPlayer getEntityPlayer (String username) public EntityPlayer getEntityPlayer (String username)
{ {
TPlayerStats stats = playerStats.get(username); TPlayerStats stats = playerStats.get(username);
if (stats == null) if (stats == null)
{ {
return null; return null;
} }
else else
{ {
return stats.player.get(); return stats.player.get();
} }
} }
/* Modify Player */ /* Modify Player */
public void updateSize (String user, float offset) public void updateSize (String user, float offset)
{ {
/*EntityPlayer player = getEntityPlayer(user); /*EntityPlayer player = getEntityPlayer(user);
setEntitySize(0.6F, offset, player); setEntitySize(0.6F, offset, player);
player.yOffset = offset - 0.18f;*/ player.yOffset = offset - 0.18f;*/
} }
public static void setEntitySize (float width, float height, Entity entity) public static void setEntitySize (float width, float height, Entity entity)
{ {
//System.out.println("Size: " + height); //System.out.println("Size: " + height);
if (width != entity.width || height != entity.height) if (width != entity.width || height != entity.height)
{ {
entity.width = width; entity.width = width;
entity.height = height; entity.height = height;
entity.boundingBox.maxX = entity.boundingBox.minX + (double) entity.width; entity.boundingBox.maxX = entity.boundingBox.minX + (double) entity.width;
entity.boundingBox.maxZ = entity.boundingBox.minZ + (double) entity.width; entity.boundingBox.maxZ = entity.boundingBox.minZ + (double) entity.width;
entity.boundingBox.maxY = entity.boundingBox.minY + (double) entity.height; entity.boundingBox.maxY = entity.boundingBox.minY + (double) entity.height;
} }
float que = width % 2.0F; float que = width % 2.0F;
if ((double) que < 0.375D) if ((double) que < 0.375D)
{ {
entity.myEntitySize = EnumEntitySize.SIZE_1; entity.myEntitySize = EnumEntitySize.SIZE_1;
} }
else if ((double) que < 0.75D) else if ((double) que < 0.75D)
{ {
entity.myEntitySize = EnumEntitySize.SIZE_2; entity.myEntitySize = EnumEntitySize.SIZE_2;
} }
else if ((double) que < 1.0D) else if ((double) que < 1.0D)
{ {
entity.myEntitySize = EnumEntitySize.SIZE_3; entity.myEntitySize = EnumEntitySize.SIZE_3;
} }
else if ((double) que < 1.375D) else if ((double) que < 1.375D)
{ {
entity.myEntitySize = EnumEntitySize.SIZE_4; entity.myEntitySize = EnumEntitySize.SIZE_4;
} }
else if ((double) que < 1.75D) else if ((double) que < 1.75D)
{ {
entity.myEntitySize = EnumEntitySize.SIZE_5; entity.myEntitySize = EnumEntitySize.SIZE_5;
} }
else else
{ {
entity.myEntitySize = EnumEntitySize.SIZE_6; entity.myEntitySize = EnumEntitySize.SIZE_6;
} }
//entity.yOffset = height; //entity.yOffset = height;
} }
Random rand = new Random(); Random rand = new Random();
} }

View File

@ -116,7 +116,7 @@ public class ComponentToolWorkshop extends ComponentVillage
this.placeBlockAtCurrentPosition(world, Block.ladder.blockID, i, 3, 4, 5, sbb); this.placeBlockAtCurrentPosition(world, Block.ladder.blockID, i, 3, 4, 5, sbb);
this.placeBlockAtCurrentPosition(world, TContent.toolStationWood.blockID, 0, 1, 1, 1, sbb); //Inside this.placeBlockAtCurrentPosition(world, TContent.toolStationWood.blockID, 0, 1, 1, 1, sbb); //Inside
this.generateStructureChestContents(world, sbb, random, 1, 1, 2, TContent.tinkerHousePatterns.getItems(random), TContent.tinkerHousePatterns.getCount(random)); this.generateStructurePatternChestContents(world, sbb, random, 1, 1, 2, TContent.tinkerHousePatterns.getItems(random), TContent.tinkerHousePatterns.getCount(random));
//this.placeBlockAtCurrentPosition(world, TContent.toolStationWood.blockID, 5, 1, 1, 2, sbb); //this.placeBlockAtCurrentPosition(world, TContent.toolStationWood.blockID, 5, 1, 1, 2, sbb);
this.placeBlockAtCurrentPosition(world, TContent.toolStationWood.blockID, 1, 1, 1, 3, sbb); this.placeBlockAtCurrentPosition(world, TContent.toolStationWood.blockID, 1, 1, 1, 3, sbb);
this.placeBlockAtCurrentPosition(world, Block.workbench.blockID, 0, 1, 1, 4, sbb); this.placeBlockAtCurrentPosition(world, Block.workbench.blockID, 0, 1, 1, 4, sbb);

Binary file not shown.

After

Width:  |  Height:  |  Size: 237 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 419 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 401 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 163 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 B

View File

Before

Width:  |  Height:  |  Size: 207 B

After

Width:  |  Height:  |  Size: 207 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 276 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 378 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 381 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 163 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 288 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 195 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 269 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 254 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 552 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 442 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 249 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 247 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 250 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 256 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 389 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 254 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 253 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 241 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 253 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 303 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 253 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 296 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 254 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 244 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 244 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 253 B