diff options
Diffstat (limited to 'src/main/java/lance5057/tDefense/core')
64 files changed, 5821 insertions, 1794 deletions
diff --git a/src/main/java/lance5057/tDefense/core/blocks/ArmorStationBlock.java b/src/main/java/lance5057/tDefense/core/blocks/ArmorStationBlock.java index 71abf9f..b7d61ab 100644 --- a/src/main/java/lance5057/tDefense/core/blocks/ArmorStationBlock.java +++ b/src/main/java/lance5057/tDefense/core/blocks/ArmorStationBlock.java @@ -25,6 +25,8 @@ public class ArmorStationBlock extends BlockTable implements ITinkerStationBlock public ArmorStationBlock() { super(Material.WOOD); + this.setUnlocalizedName("armorstation"); + this.setRegistryName("armorstation"); this.setCreativeTab(TinkerRegistry.tabGeneral); this.setSoundType(SoundType.WOOD); this.setResistance(5f); diff --git a/src/main/java/lance5057/tDefense/core/gui/ArmorStationContainer.java b/src/main/java/lance5057/tDefense/core/gui/ArmorStationContainer.java index c0b7016..2216ed1 100644 --- a/src/main/java/lance5057/tDefense/core/gui/ArmorStationContainer.java +++ b/src/main/java/lance5057/tDefense/core/gui/ArmorStationContainer.java @@ -1,6 +1,353 @@ package lance5057.tDefense.core.gui; -public class ArmorStationContainer -{ +import java.util.List; +import java.util.Set; -} +import lance5057.tDefense.core.library.ArmorBuilder; +import lance5057.tDefense.core.library.TDRegistry; +import lance5057.tDefense.core.network.ArmorStationSelectionPacket; +import lance5057.tDefense.core.tileentities.ArmorStationTile; +import lance5057.tDefense.core.tools.bases.ArmorBase; +import lance5057.tDefense.core.tools.bases.ArmorCore; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; +import net.minecraft.util.StringUtils; +import net.minecraft.world.WorldServer; +import slimeknights.mantle.inventory.BaseContainer; +import slimeknights.mantle.util.ItemStackList; +import slimeknights.tconstruct.TConstruct; +import slimeknights.tconstruct.common.Sounds; +import slimeknights.tconstruct.common.TinkerNetwork; +import slimeknights.tconstruct.library.Util; +import slimeknights.tconstruct.library.events.TinkerCraftingEvent; +import slimeknights.tconstruct.library.modifiers.TinkerGuiException; +import slimeknights.tconstruct.library.tinkering.IModifyable; +import slimeknights.tconstruct.library.tinkering.IRepairable; +import slimeknights.tconstruct.library.tinkering.PartMaterialType; +import slimeknights.tconstruct.library.utils.TagUtil; +import slimeknights.tconstruct.library.utils.ToolBuilder; +import slimeknights.tconstruct.tools.common.client.GuiToolStation; +import slimeknights.tconstruct.tools.common.inventory.ContainerTinkerStation; +import slimeknights.tconstruct.tools.common.inventory.SlotToolStationIn; +import slimeknights.tconstruct.tools.common.network.ToolStationSelectionPacket; +import slimeknights.tconstruct.tools.common.network.ToolStationTextPacket; + +// also tool forge +public class ArmorStationContainer extends ContainerTinkerStation<ArmorStationTile> { + + private final EntityPlayer player; + protected ArmorStationSlotOut out; + protected ArmorCore selectedTool; // needed for newly opened containers to sync + protected int activeSlots; + public String toolName; + + public ArmorStationContainer(InventoryPlayer playerInventory, ArmorStationTile tile) { + super(tile); + + // input slots + int i; + for(i = 0; i < tile.getSizeInventory(); i++) { + addSlotToContainer(new SlotToolStationIn(tile, i, 0, 0, this)); + } + + // output slot + out = new ArmorStationSlotOut(i, 124, 38, this); + addSlotToContainer(out); + this.addPlayerInventory(playerInventory, 8, 84 + 8); + onCraftMatrixChanged(null); + + this.player = playerInventory.player; + } + + public ItemStack getResult() { + return out.getStack(); + } + + @Override + protected void syncNewContainer(EntityPlayerMP player) { + this.activeSlots = tile.getSizeInventory(); + TinkerNetwork.sendTo(new ToolStationSelectionPacket(null, tile.getSizeInventory()), player); + } + + @Override + protected void syncWithOtherContainer(BaseContainer<ArmorStationTile> otherContainer, EntityPlayerMP player) { + this.syncWithOtherContainer((ArmorStationContainer) otherContainer, player); + } + + protected void syncWithOtherContainer(ArmorStationContainer otherContainer, EntityPlayerMP player) { + // set same selection as other container + this.setToolSelection(otherContainer.selectedTool, otherContainer.activeSlots); + this.setToolName(otherContainer.toolName); + // also send the data to the player + TinkerNetwork.sendTo(new ArmorStationSelectionPacket(otherContainer.selectedTool, otherContainer.activeSlots), player); + if(otherContainer.toolName != null && !otherContainer.toolName.isEmpty()) { + TinkerNetwork.sendTo(new ToolStationTextPacket(otherContainer.toolName), player); + } + } + + public void setToolSelection(ArmorCore selectedTool2, int activeSlots) { + if(activeSlots > tile.getSizeInventory()) { + activeSlots = tile.getSizeInventory(); + } + + this.activeSlots = activeSlots; + this.selectedTool = selectedTool2; + + for(int i = 0; i < tile.getSizeInventory(); i++) { + Slot slot = inventorySlots.get(i); + // set part info for the slot + if(slot instanceof SlotToolStationIn) { + SlotToolStationIn slotToolPart = (SlotToolStationIn) slot; + + slotToolPart.setRestriction(null); + + // deactivate not needed slots + if(i >= activeSlots) { + slotToolPart.deactivate(); + } + // activate the other slots and set toolpart if possible + else { + slotToolPart.activate(); + if(selectedTool2 != null) { + List<PartMaterialType> pmts = selectedTool2.getToolBuildComponents(); + if(i < pmts.size()) { + slotToolPart.setRestriction(pmts.get(i)); + } + } + } + + if(world.isRemote) { + slotToolPart.updateIcon(); + } + } + } + } + + public void setToolName(String name) { + this.toolName = name; + + if(world.isRemote) { + GuiScreen screen = Minecraft.getMinecraft().currentScreen; + if(screen instanceof GuiToolStation) { + ((GuiToolStation) screen).textField.setText(name); + } + } + + onCraftMatrixChanged(tile); + if(out.getHasStack()) { + if(name != null && !name.isEmpty()) { + out.inventory.getStackInSlot(0).setStackDisplayName(name); + } + else { + out.inventory.getStackInSlot(0).clearCustomName(); + } + } + } + + // update crafting - called whenever the content of an input slot changes + @Override + public void onCraftMatrixChanged(IInventory inventoryIn) { + // reset gui state + updateGUI(); + try { + ItemStack result; + // 1. try repairing + result = repairTool(false); + // 2. try swapping tool parts + if(result.isEmpty()) { + result = replaceToolParts(false); + } + // 3. try modifying + if(result.isEmpty()) { + result = modifyTool(false); + } + // 4. try renaming + if(result.isEmpty()) { + result = renameTool(); + } + // 5. try building a new tool + if(result.isEmpty()) { + result = buildTool(); + } + + out.inventory.setInventorySlotContents(0, result); + updateGUI(); + } catch(TinkerGuiException e) { + // error ;( + out.inventory.setInventorySlotContents(0, ItemStack.EMPTY); + this.error(e.getMessage()); + } + // sync output with other open containers on the server + if(!this.world.isRemote) { + WorldServer server = (WorldServer) this.world; + for(EntityPlayer player : server.playerEntities) { + if(player.openContainer != this && player.openContainer instanceof ArmorStationContainer && this.sameGui((ArmorStationContainer) player.openContainer)) { + ((ArmorStationContainer) player.openContainer).out.inventory.setInventorySlotContents(0, out.getStack()); + } + } + } + } + + // Called when the crafting result is taken out of its slot + public void onResultTaken(EntityPlayer playerIn, ItemStack stack) { + boolean resultTaken = false; + + try { + resultTaken = !repairTool(true).isEmpty() || + !replaceToolParts(true).isEmpty() || + !modifyTool(true).isEmpty() || + !renameTool().isEmpty(); + } catch(TinkerGuiException e) { + // no error updating needed + e.printStackTrace(); + } + + if(resultTaken) { + updateSlotsAfterToolAction(); + } + else { + // calculate the result again (serverside) + try { + ItemStack tool = buildTool(); + + // we built a tool + if(!tool.isEmpty()) { + // remove 1 of each in the slots + // it's guaranteed that each slot that has an item has used exactly 1 item to build the tool + for(int i = 0; i < tile.getSizeInventory(); i++) { + tile.decrStackSize(i, 1); + } + + setToolName(""); + } + } catch(TinkerGuiException e) { + // no error updating needed + e.printStackTrace(); + } + } + onCraftMatrixChanged(null); + + this.playCraftSound(playerIn); + } + + protected void playCraftSound(EntityPlayer player) { + Sounds.playSoundForAll(player, Sounds.saw, 0.8f, 0.8f + 0.4f * TConstruct.random.nextFloat()); + } + + private ItemStack repairTool(boolean remove) { + ItemStack repairable = getToolStack(); + + // modifying possible? + if(repairable.isEmpty() || !(repairable.getItem() instanceof IRepairable)) { + return ItemStack.EMPTY; + } + + return ToolBuilder.tryRepairTool(getInputs(), repairable, remove); + } + + private ItemStack replaceToolParts(boolean remove) throws TinkerGuiException { + ItemStack tool = getToolStack(); + + if(tool.isEmpty() || !(tool.getItem() instanceof ArmorBase)) { + return ItemStack.EMPTY; + } + + NonNullList<ItemStack> inputs = getInputs(); + ItemStack result = ToolBuilder.tryReplaceToolParts(tool, inputs, remove); + if(!result.isEmpty()) { + TinkerCraftingEvent.ToolPartReplaceEvent.fireEvent(result, player, inputs); + } + return result; + } + + private ItemStack modifyTool(boolean remove) throws TinkerGuiException { + ItemStack modifyable = getToolStack(); + + // modifying possible? + if(modifyable.isEmpty() || !(modifyable.getItem() instanceof IModifyable)) { + return ItemStack.EMPTY; + } + + ItemStack result = ToolBuilder.tryModifyTool(getInputs(), modifyable, remove); + if(!result.isEmpty()) { + TinkerCraftingEvent.ToolModifyEvent.fireEvent(result, player, modifyable.copy()); + } + return result; + } + + private ItemStack renameTool() throws TinkerGuiException { + ItemStack tool = getToolStack(); + + // modifying possible? + if(tool.isEmpty() || + !(tool.getItem() instanceof ArmorBase) || + StringUtils.isNullOrEmpty(toolName) || + tool.getDisplayName().equals(toolName)) { + return ItemStack.EMPTY; + } + + ItemStack result = tool.copy(); + if(TagUtil.getNoRenameFlag(result)) { + throw new TinkerGuiException(Util.translate("gui.error.no_rename")); + } + + result.setStackDisplayName(toolName); + + return result; + } + + private ItemStack buildTool() throws TinkerGuiException { + NonNullList<ItemStack> input = ItemStackList.withSize(tile.getSizeInventory()); + for(int i = 0; i < input.size(); i++) { + input.set(i, tile.getStackInSlot(i)); + } + + ItemStack result = ArmorBuilder.tryBuildArmor(input, toolName, getBuildableTools()); + if(!result.isEmpty()) { + TinkerCraftingEvent.ToolCraftingEvent.fireEvent(result, player, input); + } + return result; + } + + protected Set<ArmorCore> getBuildableTools() { + return TDRegistry.getArmorStationCrafting(); + } + + private ItemStack getToolStack() { + return inventorySlots.get(0).getStack(); + } + + /** + * Removes the tool in the input slot and fixes all stacks that have stacksize 0 after being used up. + */ + private void updateSlotsAfterToolAction() { +// perfect, items already got removed but we still have to clean up 0-stacks and remove the tool + tile.setInventorySlotContents(0, ItemStack.EMPTY); // slot where the tool was + for(int i = 1; i < tile.getSizeInventory(); i++) { + if(!tile.getStackInSlot(i).isEmpty() && tile.getStackInSlot(i).getCount() == 0) { + tile.setInventorySlotContents(i, ItemStack.EMPTY); + } + } + } + + private NonNullList<ItemStack> getInputs() { + NonNullList<ItemStack> input = NonNullList.withSize(tile.getSizeInventory() - 1, ItemStack.EMPTY); + for(int i = 1; i < tile.getSizeInventory(); i++) { + input.set(i - 1, tile.getStackInSlot(i)); + } + + return input; + } + + @Override + public boolean canMergeSlot(ItemStack stack, Slot slot) { + return slot != out && super.canMergeSlot(stack, slot); + } +}
\ No newline at end of file diff --git a/src/main/java/lance5057/tDefense/core/gui/ArmorStationGui.java b/src/main/java/lance5057/tDefense/core/gui/ArmorStationGui.java index 8bcea9c..0de5ced 100644 --- a/src/main/java/lance5057/tDefense/core/gui/ArmorStationGui.java +++ b/src/main/java/lance5057/tDefense/core/gui/ArmorStationGui.java @@ -9,10 +9,13 @@ import org.lwjgl.util.Point; import com.google.common.collect.Lists; +import lance5057.tDefense.core.library.ArmorBuildGuiInfo; +import lance5057.tDefense.core.library.TDClientRegistry; +import lance5057.tDefense.core.library.TDRegistry; +import lance5057.tDefense.core.network.ArmorStationSelectionPacket; +import lance5057.tDefense.core.tileentities.ArmorStationTile; +import lance5057.tDefense.core.tools.bases.ArmorBase; import lance5057.tDefense.core.tools.bases.ArmorCore; -import lance5057.tDefense.util.ArmorBuildGuiInfo; -import lance5057.tDefense.util.TDClientRegistry; -import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiTextField; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.RenderHelper; @@ -31,32 +34,21 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import slimeknights.mantle.client.gui.GuiElement; import slimeknights.mantle.client.gui.GuiElementScalable; -import slimeknights.mantle.client.gui.GuiModule; import slimeknights.tconstruct.common.TinkerNetwork; import slimeknights.tconstruct.library.TinkerRegistry; -import slimeknights.tconstruct.library.TinkerRegistryClient; import slimeknights.tconstruct.library.Util; import slimeknights.tconstruct.library.client.Icons; -import slimeknights.tconstruct.library.client.ToolBuildGuiInfo; import slimeknights.tconstruct.library.modifiers.IModifier; import slimeknights.tconstruct.library.modifiers.ModifierNBT; import slimeknights.tconstruct.library.tinkering.IModifyable; import slimeknights.tconstruct.library.tinkering.IToolStationDisplay; import slimeknights.tconstruct.library.tinkering.PartMaterialType; -import slimeknights.tconstruct.library.tinkering.TinkersItem; import slimeknights.tconstruct.library.tools.IToolPart; -import slimeknights.tconstruct.library.tools.ToolCore; import slimeknights.tconstruct.library.utils.TagUtil; -import slimeknights.tconstruct.tools.common.client.GuiButtonRepair; import slimeknights.tconstruct.tools.common.client.GuiTinkerStation; -import slimeknights.tconstruct.tools.common.client.module.GuiButtonsToolStation; import slimeknights.tconstruct.tools.common.client.module.GuiInfoPanel; -import slimeknights.tconstruct.tools.common.inventory.ContainerTinkerStation; -import slimeknights.tconstruct.tools.common.inventory.ContainerToolStation; import slimeknights.tconstruct.tools.common.inventory.SlotToolStationIn; -import slimeknights.tconstruct.tools.common.network.ToolStationSelectionPacket; import slimeknights.tconstruct.tools.common.network.ToolStationTextPacket; -import slimeknights.tconstruct.tools.common.tileentity.TileToolStation; @SideOnly(Side.CLIENT) public class ArmorStationGui extends GuiTinkerStation { @@ -99,8 +91,8 @@ public class ArmorStationGui extends GuiTinkerStation { public ArmorBuildGuiInfo currentInfo = ArmorStationGuiButtonRepair.info; - public ArmorStationGui(InventoryPlayer playerInv, World world, BlockPos pos, TileToolStation tile) { - super(world, pos, (ContainerTinkerStation) tile.createContainer(playerInv, world, pos)); + public ArmorStationGui(InventoryPlayer playerInv, World world, BlockPos pos, ArmorStationTile armorStationTile) { + super(world, pos, (ArmorStationContainer) armorStationTile.createContainer(playerInv, world, pos)); buttons = new ArmorStationGuiButtons(this, inventorySlots); this.addModule(buttons); @@ -152,32 +144,32 @@ public class ArmorStationGui extends GuiTinkerStation { Keyboard.enableRepeatEvents(false); } - public Set<ToolCore> getBuildableItems() { - return TinkerRegistry.getToolStationCrafting(); + public Set<ArmorCore> getBuildableItems() { + return TDRegistry.getArmorStationCrafting(); } public void onToolSelection(ArmorBuildGuiInfo data) { activeSlots = Math.min(data.positions.size(), Table_slot_count); currentInfo = data; - ToolCore tool = null; + ArmorCore tool = null; - if(data.armor.getItem() instanceof ToolCore) { - tool = (ToolCore) data.armor.getItem(); + if(data.armor.getItem() instanceof ArmorCore) { + tool = (ArmorCore) data.armor.getItem(); } - ((ContainerToolStation) inventorySlots).setToolSelection(tool, activeSlots); + ((ArmorStationContainer) inventorySlots).setToolSelection(tool, activeSlots); // update the server (and others) - TinkerNetwork.sendToServer(new ToolStationSelectionPacket(tool, activeSlots)); + TinkerNetwork.sendToServer(new ArmorStationSelectionPacket(tool, activeSlots)); updateGUI(); } - public void onToolSelectionPacket(ToolStationSelectionPacket packet) { - ArmorBuildGuiInfo info = TDClientRegistry.getArmorBuildInfoForArmor(packet.tool); + public void onToolSelectionPacket(ArmorStationSelectionPacket armorStationSelectionPacket) { + ArmorBuildGuiInfo info = TDClientRegistry.getArmorBuildInfoForArmor(armorStationSelectionPacket.armor); if(info == null) { info = ArmorStationGuiButtonRepair.info; } - activeSlots = packet.activeSlots; + activeSlots = armorStationSelectionPacket.activeSlots; currentInfo = info; buttons.setSelectedButtonByTool(currentInfo.armor); @@ -218,7 +210,7 @@ public class ArmorStationGui extends GuiTinkerStation { @Override public void updateDisplay() { // tool info of existing or tool to build - ContainerToolStation container = (ContainerToolStation) inventorySlots; + ArmorStationContainer container = (ArmorStationContainer) inventorySlots; ItemStack toolStack = container.getResult(); if(toolStack.isEmpty()) { toolStack = inventorySlots.getSlot(0).getStack(); @@ -282,7 +274,7 @@ public class ArmorStationGui extends GuiTinkerStation { // tool build info else { ArmorCore tool = (ArmorCore) currentInfo.armor.getItem(); - toolInfo.setCaption(tool.getLocalizedToolName()); + toolInfo.setCaption(tool.getLocalizedToolName()); toolInfo.setText(tool.getLocalizedDescription()); // Components @@ -338,7 +330,7 @@ public class ArmorStationGui extends GuiTinkerStation { textField.textboxKeyTyped(typedChar, keyCode); TinkerNetwork.sendToServer(new ToolStationTextPacket(textField.getText())); - ((ContainerToolStation) container).setToolName(textField.getText()); + ((ArmorStationContainer) container).setToolName(textField.getText()); } } @@ -434,7 +426,7 @@ public class ArmorStationGui extends GuiTinkerStation { if(currentInfo == ArmorStationGuiButtonRepair.info) { drawRepairSlotIcons(); } - else if(currentInfo.armor.getItem() instanceof TinkersItem) { + else if(currentInfo.armor.getItem() instanceof ArmorBase) { for(int i = 0; i < activeSlots; i++) { Slot slot = inventorySlots.getSlot(i); if(!(slot instanceof SlotToolStationIn)) { @@ -555,7 +547,7 @@ public class ArmorStationGui extends GuiTinkerStation { buttons.metal(); beamL = BeamLeft.shift(0, BeamLeft.h); - beamR = BeamRight.shift(0, BeamRight.h); + beamR = BeamRight.shift(0, BeamRight.h); beamC = BeamCenter.shift(0, BeamCenter.h); } diff --git a/src/main/java/lance5057/tDefense/core/gui/ArmorStationGuiButtonRepair.java b/src/main/java/lance5057/tDefense/core/gui/ArmorStationGuiButtonRepair.java index dba33e8..1dddfa8 100644 --- a/src/main/java/lance5057/tDefense/core/gui/ArmorStationGuiButtonRepair.java +++ b/src/main/java/lance5057/tDefense/core/gui/ArmorStationGuiButtonRepair.java @@ -1,6 +1,6 @@ package lance5057.tDefense.core.gui; -import lance5057.tDefense.util.ArmorBuildGuiInfo; +import lance5057.tDefense.core.library.ArmorBuildGuiInfo; import net.minecraft.client.Minecraft; import net.minecraft.util.text.translation.I18n; import slimeknights.tconstruct.library.client.Icons; diff --git a/src/main/java/lance5057/tDefense/core/gui/ArmorStationGuiButtons.java b/src/main/java/lance5057/tDefense/core/gui/ArmorStationGuiButtons.java index d89b002..2e047b4 100644 --- a/src/main/java/lance5057/tDefense/core/gui/ArmorStationGuiButtons.java +++ b/src/main/java/lance5057/tDefense/core/gui/ArmorStationGuiButtons.java @@ -2,16 +2,14 @@ package lance5057.tDefense.core.gui; import java.io.IOException; -import lance5057.tDefense.util.ArmorBuildGuiInfo; -import lance5057.tDefense.util.TDClientRegistry; +import lance5057.tDefense.core.library.ArmorBuildGuiInfo; +import lance5057.tDefense.core.library.TDClientRegistry; import net.minecraft.client.gui.GuiButton; import net.minecraft.inventory.Container; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import slimeknights.tconstruct.library.client.Icons; -import slimeknights.tconstruct.library.client.ToolBuildGuiInfo; import slimeknights.tconstruct.tools.common.client.GuiButtonItem; -import slimeknights.tconstruct.tools.common.client.GuiToolStation; import slimeknights.tconstruct.tools.common.client.module.GuiSideButtons; public class ArmorStationGuiButtons extends GuiSideButtons { @@ -19,7 +17,7 @@ public class ArmorStationGuiButtons extends GuiSideButtons { protected final ArmorStationGui parent; public ArmorStationGuiButtons(ArmorStationGui parent, Container container) { - super(parent, container, GuiToolStation.Column_Count); + super(parent, container, ArmorStationGui.Column_Count); this.parent = parent; } @@ -65,8 +63,8 @@ public class ArmorStationGuiButtons extends GuiSideButtons { for(Object o : buttonList) { if(o instanceof GuiButtonItem) { @SuppressWarnings("unchecked") - GuiButtonItem<ToolBuildGuiInfo> btn = (GuiButtonItem<ToolBuildGuiInfo>) o; - btn.pressed = ItemStack.areItemStacksEqual(btn.data.tool, stack); + GuiButtonItem<ArmorBuildGuiInfo> btn = (GuiButtonItem<ArmorBuildGuiInfo>) o; + btn.pressed = ItemStack.areItemStacksEqual(btn.data.armor, stack); } } } diff --git a/src/main/java/lance5057/tDefense/core/gui/ArmorStationSlotOut.java b/src/main/java/lance5057/tDefense/core/gui/ArmorStationSlotOut.java new file mode 100644 index 0000000..b3187a4 --- /dev/null +++ b/src/main/java/lance5057/tDefense/core/gui/ArmorStationSlotOut.java @@ -0,0 +1,36 @@ +package lance5057.tDefense.core.gui; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.InventoryCraftResult; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.common.FMLCommonHandler; +import slimeknights.tconstruct.tools.common.inventory.ContainerToolStation; + +import javax.annotation.Nonnull; + +public class ArmorStationSlotOut extends Slot { + + public ArmorStationContainer parent; + + public ArmorStationSlotOut(int index, int xPosition, int yPosition, ArmorStationContainer container) { + super(new InventoryCraftResult(), index, xPosition, yPosition); + + this.parent = container; + } + + @Override + public boolean isItemValid(ItemStack stack) { + return false; + } + + @Nonnull + @Override + public ItemStack onTake(EntityPlayer playerIn, @Nonnull ItemStack stack) { + FMLCommonHandler.instance().firePlayerCraftingEvent(playerIn, stack, parent.getTile()); + parent.onResultTaken(playerIn, stack); + stack.onCrafting(playerIn.getEntityWorld(), playerIn, 1); + + return super.onTake(playerIn, stack); + } +}
\ No newline at end of file diff --git a/src/main/java/lance5057/tDefense/core/library/ArmorBuildGuiInfo.java b/src/main/java/lance5057/tDefense/core/library/ArmorBuildGuiInfo.java new file mode 100644 index 0000000..cf9f522 --- /dev/null +++ b/src/main/java/lance5057/tDefense/core/library/ArmorBuildGuiInfo.java @@ -0,0 +1,48 @@ +package lance5057.tDefense.core.library; + +import java.util.List; + +import javax.annotation.Nonnull; + +import org.lwjgl.util.Point; + +import com.google.common.collect.Lists; + +import lance5057.tDefense.core.tools.bases.ArmorBase; +import net.minecraft.item.ItemStack; + +public class ArmorBuildGuiInfo { + + @Nonnull + public final ItemStack armor; + // the positions where the slots are located + public final List<Point> positions = Lists.newArrayList(); + + public ArmorBuildGuiInfo() { + // for repairing + this.armor = ItemStack.EMPTY; + } + + public ArmorBuildGuiInfo(@Nonnull ArmorBase tool) { + this.armor = tool.buildItemForRenderingInGui(); + } + + public static ArmorBuildGuiInfo default3Part(@Nonnull ArmorBase tool) { + ArmorBuildGuiInfo info = new ArmorBuildGuiInfo(tool); + info.addSlotPosition(33 - 20, 42 + 20); + info.addSlotPosition(33 + 20, 42 - 20); + info.addSlotPosition(33, 42); + return info; + } + + /** + * Add another slot at the specified position for the tool. + * The positions are usually located between: + * X: 7 - 69 + * Y: 18 - 64 + */ + public void addSlotPosition(int x, int y) { + positions.add(new Point(x, y)); + } + +}
\ No newline at end of file diff --git a/src/main/java/lance5057/tDefense/core/library/ArmorBuilder.java b/src/main/java/lance5057/tDefense/core/library/ArmorBuilder.java new file mode 100644 index 0000000..2edb3fe --- /dev/null +++ b/src/main/java/lance5057/tDefense/core/library/ArmorBuilder.java @@ -0,0 +1,595 @@ +package lance5057.tDefense.core.library; + +import java.util.Collection; +import java.util.List; +import java.util.Optional; +import java.util.Set; + +import javax.annotation.Nonnull; + +import org.apache.logging.log4j.Logger; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Sets; + +import gnu.trove.map.TIntIntMap; +import gnu.trove.map.hash.TIntIntHashMap; +import lance5057.tDefense.core.tools.bases.ArmorBase; +import lance5057.tDefense.core.tools.bases.ArmorCore; +import net.minecraft.enchantment.Enchantment; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.nbt.NBTTagString; +import net.minecraft.util.NonNullList; +import net.minecraft.util.text.translation.I18n; +import slimeknights.mantle.util.ItemStackList; +import slimeknights.mantle.util.RecipeMatch; +import slimeknights.tconstruct.library.TinkerRegistry; +import slimeknights.tconstruct.library.Util; +import slimeknights.tconstruct.library.events.TinkerEvent; +import slimeknights.tconstruct.library.materials.Material; +import slimeknights.tconstruct.library.modifiers.IModifier; +import slimeknights.tconstruct.library.modifiers.TinkerGuiException; +import slimeknights.tconstruct.library.tinkering.IRepairable; +import slimeknights.tconstruct.library.tinkering.MaterialItem; +import slimeknights.tconstruct.library.tinkering.PartMaterialType; +import slimeknights.tconstruct.library.tools.IToolPart; +import slimeknights.tconstruct.library.tools.Pattern; +import slimeknights.tconstruct.library.traits.AbstractTrait; +import slimeknights.tconstruct.library.traits.ITrait; +import slimeknights.tconstruct.library.utils.ListUtil; +import slimeknights.tconstruct.library.utils.TagUtil; +import slimeknights.tconstruct.library.utils.Tags; +import slimeknights.tconstruct.library.utils.TinkerUtil; + +public final class ArmorBuilder { + + private static Logger log = Util.getLogger("ArmorBuilder"); + + private ArmorBuilder() { + } + + @Nonnull + public static ItemStack tryBuildTool(NonNullList<ItemStack> stacks, String name) { + return tryBuildArmor(stacks, name, TDRegistry.getArmor()); + } + + /** + * Takes an array of Itemstacks and tries to build a tool with it. Amount of itemstacks has to match exactly. + * + * @param stacks Input. + * @return The built tool or null if none could be built. + */ + @Nonnull + public static ItemStack tryBuildArmor(NonNullList<ItemStack> stacks, String name, Collection<ArmorCore> possibleTools) { + int length = -1; + NonNullList<ItemStack> input; + // remove trailing empty slots + for(int i = 0; i < stacks.size(); i++) { + if(stacks.get(i).isEmpty()) { + if(length < 0) { + length = i; + } + } + else if(length >= 0) { + // incorrect input. gap with null in the stacks passed + return ItemStack.EMPTY; + } + } + + if(length < 0) { + return ItemStack.EMPTY; + } + + input = ItemStackList.of(stacks); + + for(Item item : possibleTools) { + if(!(item instanceof ArmorCore)) { + continue; + } + ItemStack output = ((ArmorCore) item).buildItemFromStacks(input); + if(!output.isEmpty()) { + // name the item + if(name != null && !name.isEmpty()) { + output.setStackDisplayName(name); + } + + return output; + } + } + + return ItemStack.EMPTY; + } + + /** + * Adds the trait to the tag, taking max-count and already existing traits into account. + * + * @param rootCompound The root compound of the item + * @param trait The trait to add. + * @param color The color used on the tooltip. Will not be used if the trait already exists on the tool. + */ + public static void addTrait(NBTTagCompound rootCompound, ITrait trait, int color) { + // only registered traits allowed + if(TinkerRegistry.getTrait(trait.getIdentifier()) == null) { + log.error("addTrait: Trying to apply unregistered Trait {}", trait.getIdentifier()); + return; + } + + IModifier modifier = TinkerRegistry.getModifier(trait.getIdentifier()); + + if(modifier == null || !(modifier instanceof AbstractTrait)) { + log.error("addTrait: No matching modifier for the Trait {} present", trait.getIdentifier()); + return; + } + + AbstractTrait traitModifier = (AbstractTrait) modifier; + + NBTTagCompound tag = new NBTTagCompound(); + NBTTagList tagList = TagUtil.getModifiersTagList(rootCompound); + int index = TinkerUtil.getIndexInList(tagList, traitModifier.getModifierIdentifier()); + if(index < 0) { + traitModifier.updateNBTforTrait(tag, color); + tagList.appendTag(tag); + TagUtil.setModifiersTagList(rootCompound, tagList); + } + else { + tag = tagList.getCompoundTagAt(index); + } + + traitModifier.applyEffect(rootCompound, tag); + } + + @Nonnull + public static ItemStack tryRepairTool(NonNullList<ItemStack> stacks, ItemStack toolStack, boolean removeItems) { + if(toolStack == null || !(toolStack.getItem() instanceof IRepairable)) { + return ItemStack.EMPTY; + } + + // obtain a working copy of the items if the originals shouldn't be modified + if(!removeItems) { + stacks = Util.deepCopyFixedNonNullList(stacks); + } + + return ((IRepairable) toolStack.getItem()).repair(toolStack, stacks); + } + + /** + * Takes a tool and an array of itemstacks and tries to modify the tool with those. + * If removeItems is true, the items used in the process will be removed from the array. + * + * @param input Items to modify the tool with + * @param toolStack The tool + * @param removeItems If true the applied items will be removed from the array + * @return The modified tool or null if something went wrong or no modifier applied. + * @throws TinkerGuiException Thrown when not matching modifiers could be applied. Contains extra-information why the process failed. + */ + @Nonnull + public static ItemStack tryModifyTool(NonNullList<ItemStack> input, ItemStack toolStack, boolean removeItems) + throws TinkerGuiException { + ItemStack copy = toolStack.copy(); + + // obtain a working copy of the items if the originals shouldn't be modified + NonNullList<ItemStack> stacks = Util.deepCopyFixedNonNullList(input); + NonNullList<ItemStack> usedStacks = Util.deepCopyFixedNonNullList(input); + + Set<IModifier> appliedModifiers = Sets.newHashSet(); + for(IModifier modifier : TinkerRegistry.getAllModifiers()) { + Optional<RecipeMatch.Match> matchOptional; + do { + matchOptional = modifier.matches(stacks); + ItemStack backup = copy.copy(); + + // found a modifier that is applicable. Try to apply the match + if(matchOptional.isPresent()) { + RecipeMatch.Match match = matchOptional.get(); + // we need to apply the whole match + while(match.amount > 0) { + TinkerGuiException caughtException = null; + boolean canApply = false; + try { + canApply = modifier.canApply(copy, toolStack); + } catch(TinkerGuiException e) { + caughtException = e; + } + + // but can it be applied? + if(canApply) { + modifier.apply(copy); + + appliedModifiers.add(modifier); + match.amount--; + } + else { + // materials would allow another application, but modifier doesn't + // if we have already applied another modifier we cancel the whole thing to prevent situations where + // only a part of the modifiers gets applied. either all or none. + // if we have a reason, rather tell the player that + if(caughtException != null && !appliedModifiers.contains(modifier)) { + throw caughtException; + } + + copy = backup; + RecipeMatch.removeMatch(stacks, match); + break; + } + } + + if(match.amount == 0) { + RecipeMatch.removeMatch(stacks, match); + RecipeMatch.removeMatch(usedStacks, match); + } + } + } while(matchOptional.isPresent()); + } + + // check if all itemstacks were touched - otherwise there's an invalid item in the input + for(int i = 0; i < input.size(); i++) { + if(!input.get(i).isEmpty() && ItemStack.areItemStacksEqual(input.get(i), stacks.get(i))) { + if(!appliedModifiers.isEmpty()) { + String error = I18n.translateToLocalFormatted("gui.error.no_modifier_for_item", input.get(i).getDisplayName()); + throw new TinkerGuiException(error); + } + return ItemStack.EMPTY; + } + } + + // update output itemstacks + if(removeItems) { + for(int i = 0; i < input.size(); i++) { + // stacks might be null because stacksize got 0 during processing, we have to reflect that in the input + // so the caller can identify that + if(usedStacks.get(i).isEmpty()) { + input.get(i).setCount(0); + } + else { + input.get(i).setCount(usedStacks.get(i).getCount()); + } + } + } + + if(!appliedModifiers.isEmpty()) { + // always rebuild tinkers items to ensure consistency and find problems earlier + if(copy.getItem() instanceof ArmorBase) { + NBTTagCompound root = TagUtil.getTagSafe(copy); + rebuildArmor(root, (ArmorBase) copy.getItem()); + copy.setTagCompound(root); + } + return copy; + } + + return ItemStack.EMPTY; + } + + /** + * Takes a tool and toolparts and replaces the parts inside the tool with the given ones. + * Toolparts have to be applicable to the tool. Toolparts must not be duplicates of currently used parts. + * + * @param toolStack The tool to replace the parts in + * @param toolPartsIn The toolparts. + * @param removeItems If true the applied items will be removed from the array + * @return The tool with the replaced parts or null if the conditions have not been met. + */ + @Nonnull + public static ItemStack tryReplaceToolParts(ItemStack toolStack, final NonNullList<ItemStack> toolPartsIn, final boolean removeItems) + throws TinkerGuiException { + if(toolStack == null || !(toolStack.getItem() instanceof ArmorBase)) { + return ItemStack.EMPTY; + } + + // we never modify the original. Caller can remove all of them if we return a result + NonNullList<ItemStack> inputItems = ItemStackList.of(Util.deepCopyFixedNonNullList(toolPartsIn)); + if(!TinkerEvent.OnToolPartReplacement.fireEvent(inputItems, toolStack)) { + // event cancelled + return ItemStack.EMPTY; + } + // technically we don't need a deep copy here, but meh. less code. + final NonNullList<ItemStack> toolParts = Util.deepCopyFixedNonNullList(inputItems); + + TIntIntMap assigned = new TIntIntHashMap(); + ArmorBase tool = (ArmorBase) toolStack.getItem(); + // materiallist has to be copied because it affects the actual NBT on the tool if it's changed + final NBTTagList materialList = TagUtil.getBaseMaterialsTagList(toolStack).copy(); + + // assing each toolpart to a slot in the tool + for(int i = 0; i < toolParts.size(); i++) { + ItemStack part = toolParts.get(i); + if(part.isEmpty()) { + continue; + } + if(!(part.getItem() instanceof IToolPart)) { + // invalid item for toolpart replacement + return ItemStack.EMPTY; + } + + int candidate = -1; + // find an applicable slot in the tool structure corresponding to the toolparts position + List<PartMaterialType> pms = tool.getRequiredComponents(); + for(int j = 0; j < pms.size(); j++) { + PartMaterialType pmt = pms.get(j); + String partMat = ((IToolPart) part.getItem()).getMaterial(part).getIdentifier(); + String currentMat = materialList.getStringTagAt(j); + // is valid and not the same material? + if(pmt.isValid(part) && !partMat.equals(currentMat)) { + // part not taken up by previous part already? + if(!assigned.valueCollection().contains(j)) { + candidate = j; + // if a tool has multiple of the same parts we may want to replace another one as the currently selected + // for that purpose we only allow to overwrite the current selection if the input slot is a later one than the current one + if(i <= j) { + break; + } + } + } + } + + // no assignment found for a part. Invalid input. + if(candidate < 0) { + return ItemStack.EMPTY; + } + assigned.put(i, candidate); + } + + // did we assign nothing? + if(assigned.isEmpty()) { + return ItemStack.EMPTY; + } + + // We now know which parts to replace with which inputs. Yay. Now we only have to do so. + // to do so we simply switch out the materials used and rebuild the tool + assigned.forEachEntry((i, j) -> { + String mat = ((IToolPart) toolParts.get(i).getItem()).getMaterial(toolParts.get(i)).getIdentifier(); + materialList.set(j, new NBTTagString(mat)); + if(removeItems) { + if(i < toolPartsIn.size() && !toolPartsIn.get(i).isEmpty()) { + toolPartsIn.get(i).shrink(1); + } + } + return true; + }); + + // check that each material is still compatible with each modifier + ArmorBase ArmorBase = (ArmorBase) toolStack.getItem(); + ItemStack copyToCheck = ArmorBase.buildItem(TinkerUtil.getMaterialsFromTagList(materialList)); + // this includes traits + NBTTagList modifiers = TagUtil.getBaseModifiersTagList(toolStack); + for(int i = 0; i < modifiers.tagCount(); i++) { + String id = modifiers.getStringTagAt(i); + IModifier mod = TinkerRegistry.getModifier(id); + + // will throw an exception if it can't apply + if(mod != null && !mod.canApply(copyToCheck, copyToCheck)) { + throw new TinkerGuiException(); + } + } + + ItemStack output = toolStack.copy(); + TagUtil.setBaseMaterialsTagList(output, materialList); + NBTTagCompound tag = TagUtil.getTagSafe(output); + rebuildArmor(tag, (ArmorBase) output.getItem()); + output.setTagCompound(tag); + + // check if the output has enough durability. we only allow it if the result would not be broken + if(output.getItemDamage() > output.getMaxDamage()) { + String error = I18n.translateToLocalFormatted("gui.error.not_enough_durability", output.getItemDamage() - output.getMaxDamage()); + throw new TinkerGuiException(error); + } + + return output; + } + + /** + * Takes a pattern and itemstacks and crafts the materialitem of the pattern out of it. + * The output consists of an ItemStack[2] array that contains the part in the first slot and eventual leftover output in the 2nd one. + * The itemstacks have to match at least 1 material. + * If multiple materials match, matches with multiple items are preferred. + * Otherwise the first match will be taken. + * + * @param pattern Input-pattern. Has to be a Pattern. + * @param materialItems The Itemstacks to craft the item out of + * @param removeItems If true the match will be removed from the passed items + * @return ItemStack[2] Array containing the built item in the first slot and eventual secondary output in the second one. Null if no item could be built. + */ + public static NonNullList<ItemStack> tryBuildToolPart(ItemStack pattern, NonNullList<ItemStack> materialItems, boolean removeItems) + throws TinkerGuiException { + Item itemPart = Pattern.getPartFromTag(pattern); + if(itemPart == null || !(itemPart instanceof MaterialItem) || !(itemPart instanceof IToolPart)) { + String error = I18n.translateToLocalFormatted("gui.error.invalid_pattern"); + throw new TinkerGuiException(error); + } + + IToolPart part = (IToolPart) itemPart; + + if(!removeItems) { + materialItems = Util.deepCopyFixedNonNullList(materialItems); + } + + // find the material from the input + Optional<RecipeMatch.Match> match = Optional.empty(); + Material foundMaterial = null; + for(Material material : TinkerRegistry.getAllMaterials()) { + // craftable? + if(!material.isCraftable()) { + continue; + } + Optional<RecipeMatch.Match> newMatch = material.matches(materialItems, part.getCost()); + if(!newMatch.isPresent()) { + continue; + } + + // we found a match, yay + if(!match.isPresent()) { + match = newMatch; + foundMaterial = material; + // is it more complex than the old one? + } + } + + // nope, no material + if(!match.isPresent()) { + return null; + } + + ItemStack output = ((MaterialItem) itemPart).getItemstackWithMaterial(foundMaterial); + if(output.isEmpty()) { + return null; + } + if(output.getItem() instanceof IToolPart && !((IToolPart) output.getItem()).canUseMaterial(foundMaterial)) { + return null; + } + + RecipeMatch.removeMatch(materialItems, match.get()); + + // check if we have secondary output + ItemStack secondary = ItemStack.EMPTY; + int leftover = (match.get().amount - part.getCost()) / Material.VALUE_Shard; + if(leftover > 0) { + secondary = TinkerRegistry.getShard(foundMaterial); + secondary.setCount(leftover); + } + + // build an item with this + return ListUtil.getListFrom(output, secondary); + } + + /** + * Rebuilds a tool from its raw data, material info and applied modifiers + * + * @param rootNBT The root NBT tag compound of the tool to to rebuild. The NBT will be modified, overwriting old + * data. + */ + public static void rebuildArmor(NBTTagCompound rootNBT, ArmorBase armor) throws TinkerGuiException { + boolean broken = TagUtil.getToolTag(rootNBT).getBoolean(Tags.BROKEN); + // Recalculate tool base stats from material stats + NBTTagList materialTag = TagUtil.getBaseMaterialsTagList(rootNBT); + List<Material> materials = TinkerUtil.getMaterialsFromTagList(materialTag); + List<PartMaterialType> pms = armor.getRequiredComponents(); + + // ensure all needed Stats are present + while(materials.size() < pms.size()) { + materials.add(Material.UNKNOWN); + } + for(int i = 0; i < pms.size(); i++) { + if(!pms.get(i).isValidMaterial(materials.get(i))) { + materials.set(i, Material.UNKNOWN); + } + } + + // the base stats of the tool + NBTTagCompound toolTag = armor.buildTag(materials); + TagUtil.setToolTag(rootNBT, toolTag); + // and its copy for reference + rootNBT.setTag(Tags.TOOL_DATA_ORIG, toolTag.copy()); + + // save the old modifiers list and clean up all tags that get set by modifiers/traits + NBTTagList modifiersTagOld = TagUtil.getModifiersTagList(rootNBT); + rootNBT.removeTag(Tags.TOOL_MODIFIERS); // the active-modifiers tag + rootNBT.setTag(Tags.TOOL_MODIFIERS, new NBTTagList()); + rootNBT.removeTag("ench"); // and the enchantments tag + rootNBT.removeTag(Tags.ENCHANT_EFFECT); // enchant effect too, will be readded by a trait either way + + // clean up traits + rootNBT.removeTag(Tags.TOOL_TRAITS); + armor.addMaterialTraits(rootNBT, materials); + + // fire event + ArmorEvent.OnItemBuilding.fireEvent(rootNBT, ImmutableList.copyOf(materials), armor); + + // reapply modifiers + NBTTagList modifiers = TagUtil.getBaseModifiersTagList(rootNBT); + NBTTagList modifiersTag = TagUtil.getModifiersTagList(rootNBT); + // copy over and reapply all relevant modifiers + for(int i = 0; i < modifiers.tagCount(); i++) { + String identifier = modifiers.getStringTagAt(i); + IModifier modifier = TinkerRegistry.getModifier(identifier); + if(modifier == null) { + log.debug("Missing modifier: {}", identifier); + continue; + } + + NBTTagCompound tag; + int index = TinkerUtil.getIndexInList(modifiersTagOld, modifier.getIdentifier()); + + if(index >= 0) { + tag = modifiersTagOld.getCompoundTagAt(index); + } + else { + tag = new NBTTagCompound(); + } + + modifier.applyEffect(rootNBT, tag); + if(!tag.hasNoTags()) { + int indexNew = TinkerUtil.getIndexInList(modifiersTag, modifier.getIdentifier()); + if(indexNew >= 0) { + modifiersTag.set(indexNew, tag); + } + else { + modifiersTag.appendTag(tag); + } + } + } + + // remaining info, get updated toolTag + toolTag = TagUtil.getToolTag(rootNBT); + // adjust free modifiers + int freeModifiers = toolTag.getInteger(Tags.FREE_MODIFIERS); + freeModifiers -= TagUtil.getBaseModifiersUsed(rootNBT); + toolTag.setInteger(Tags.FREE_MODIFIERS, Math.max(0, freeModifiers)); + + // broken? + if(broken) { + toolTag.setBoolean(Tags.BROKEN, true); + } + + TagUtil.setToolTag(rootNBT, toolTag); + + if(freeModifiers < 0) { + throw new TinkerGuiException(Util.translateFormatted("gui.error.not_enough_modifiers", -freeModifiers)); + } + } + + public static short getEnchantmentLevel(NBTTagCompound rootTag, Enchantment enchantment) { + NBTTagList enchantments = rootTag.getTagList("ench", 10); + + int id = Enchantment.getEnchantmentID(enchantment); + + for(int i = 0; i < enchantments.tagCount(); i++) { + if(enchantments.getCompoundTagAt(i).getShort("id") == id) { + return enchantments.getCompoundTagAt(i).getShort("lvl"); + } + } + + return 0; + } + + public static void addEnchantment(NBTTagCompound rootTag, Enchantment enchantment) { + NBTTagList enchantments = rootTag.getTagList("ench", 10); + + NBTTagCompound enchTag = new NBTTagCompound(); + int enchId = Enchantment.getEnchantmentID(enchantment); + + int id = -1; + for(int i = 0; i < enchantments.tagCount(); i++) { + if(enchantments.getCompoundTagAt(i).getShort("id") == enchId) { + enchTag = enchantments.getCompoundTagAt(i); + id = i; + break; + } + } + + int level = enchTag.getShort("lvl") + 1; + level = Math.min(level, enchantment.getMaxLevel()); + enchTag.setShort("id", (short) enchId); + enchTag.setShort("lvl", (short) level); + + if(id < 0) { + enchantments.appendTag(enchTag); + } + else { + enchantments.set(id, enchTag); + } + + rootTag.setTag("ench", enchantments); + } +}
\ No newline at end of file diff --git a/src/main/java/lance5057/tDefense/core/library/ArmorEvent.java b/src/main/java/lance5057/tDefense/core/library/ArmorEvent.java new file mode 100644 index 0000000..c1e98f7 --- /dev/null +++ b/src/main/java/lance5057/tDefense/core/library/ArmorEvent.java @@ -0,0 +1,65 @@ +package lance5057.tDefense.core.library; + +import com.google.common.collect.ImmutableList; + +import lance5057.tDefense.core.tools.bases.ArmorBase; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.NonNullList; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.fml.common.eventhandler.Event; +import slimeknights.tconstruct.library.materials.Material; + +/** + * Base class for all tinkers events + */ +public abstract class ArmorEvent extends Event { + + /** + * Fired when a tool is built. + * This happens every time a tool is loaded as well as when the player actually builds the tool. + * You can make changes to the tag compound and it'll land on the resulting tool, but its itemstack is not available. + */ + public static class OnItemBuilding extends ArmorEvent { + + public NBTTagCompound tag; + public final ImmutableList<Material> materials; + public final ArmorBase tool; + + public OnItemBuilding(NBTTagCompound tag, ImmutableList<Material> materials, ArmorBase tool) { + this.tag = tag; + this.materials = materials; + this.tool = tool; + } + + public static OnItemBuilding fireEvent(NBTTagCompound tag, ImmutableList<Material> materials, ArmorBase tool) { + OnItemBuilding event = new OnItemBuilding(tag, materials, tool); + MinecraftForge.EVENT_BUS.post(event); + return event; + } + } + + /** + * Fired when the player tries to replace a toolpart. + * You can modify the input items to achieve different results, this will not modify the actual items in the game. + * If you're modifying the list itself, make sure to put new items into originally empty indices to prevent the usage of other items in the input. Just append to the list. + * You can not modify the tool that's getting modified + */ + @Cancelable + public static class OnToolPartReplacement extends ArmorEvent { + + /** The items in the tool station. Can be manipulated. */ + public NonNullList<ItemStack> replacementParts; + public ItemStack toolStack; + + public OnToolPartReplacement(NonNullList<ItemStack> replacementParts, ItemStack toolStack) { + this.replacementParts = replacementParts; + this.toolStack = toolStack.copy(); + } + + public static boolean fireEvent(NonNullList<ItemStack> replacementParts, ItemStack toolStack) { + return !MinecraftForge.EVENT_BUS.post(new OnToolPartReplacement(replacementParts, toolStack)); + } + } +}
\ No newline at end of file diff --git a/src/main/java/lance5057/tDefense/core/library/ArmorNBT.java b/src/main/java/lance5057/tDefense/core/library/ArmorNBT.java new file mode 100644 index 0000000..cac62ae --- /dev/null +++ b/src/main/java/lance5057/tDefense/core/library/ArmorNBT.java @@ -0,0 +1,144 @@ +package lance5057.tDefense.core.library; + +import lance5057.tDefense.core.materials.stats.ArmorMaterialStats; +import net.minecraft.nbt.NBTTagCompound; +import slimeknights.tconstruct.library.materials.ExtraMaterialStats; +import slimeknights.tconstruct.library.materials.HandleMaterialStats; +import slimeknights.tconstruct.library.tools.ToolNBT; +import slimeknights.tconstruct.library.utils.Tags; + +public class ArmorNBT { + + public int durability; + public int armorRating; + public int armorToughness; + public int modifiers; // free modifiers + private final NBTTagCompound parent; + + public ArmorNBT() { + durability = 0; + armorRating = 0; + armorToughness = 0; + modifiers = 5; + parent = new NBTTagCompound(); + } + + public ArmorNBT(NBTTagCompound tag) { + read(tag); + parent = tag; + } + + /** Initialize the stats with the heads. CALL THIS FIRST */ + public ArmorNBT head(ArmorMaterialStats... heads) { + durability = 0; + armorRating = 0; + armorToughness = 0; + + // average all stats + for(ArmorMaterialStats head : heads) { + if(head != null) { + durability += head.durability; + armorRating += head.rating; + armorToughness += head.toughness; + } + } + + durability = Math.max(1, durability / heads.length); + armorRating /= (float) heads.length; + armorToughness /= (float) heads.length; + + return this; + } + + /** Add stats from the accessoires. Call this second! */ + public ArmorNBT extra(ExtraMaterialStats... extras) { + int dur = 0; + for(ExtraMaterialStats extra : extras) { + if(extra != null) { + dur += extra.extraDurability; + } + } + this.durability += Math.round((float) dur / (float) extras.length); + + return this; + } + + /** Calculate in handles. call this last! */ + public ArmorNBT handle(HandleMaterialStats... handles) { + // (Average Head Durability + Average Extra Durability) * Average Handle Modifier + Average Handle Durability + + int dur = 0; + float modifier = 0f; + for(HandleMaterialStats handle : handles) { + if(handle != null) { + dur += handle.durability; + modifier += handle.modifier; + } + } + + modifier /= (float) handles.length; + this.durability = Math.round((float) this.durability * modifier); + + // add in handle durability change + this.durability += Math.round((float) dur / (float) handles.length); + + this.durability = Math.max(1, this.durability); + + return this; + } + + public void read(NBTTagCompound tag) { + durability = tag.getInteger(Tags.DURABILITY); + armorRating = tag.getInteger("ArmorRating"); + armorToughness = tag.getInteger("ArmorToughness"); + modifiers = tag.getInteger(Tags.FREE_MODIFIERS); + } + + public void write(NBTTagCompound tag) { + tag.setInteger(Tags.DURABILITY, durability); + tag.setInteger("ArmorRating", armorRating); + tag.setInteger("ArmorToughness", armorToughness); + tag.setInteger(Tags.FREE_MODIFIERS, modifiers); + } + + public NBTTagCompound get() { + NBTTagCompound tag = parent.copy(); + write(tag); + + return tag; + } + + // AUtogenerated equals and hashcode + @Override + public boolean equals(Object o) { + if(this == o) { + return true; + } + if(o == null || getClass() != o.getClass()) { + return false; + } + + ArmorNBT toolNBT = (ArmorNBT) o; + + if(durability != toolNBT.durability) { + return false; + } + if(Float.compare(toolNBT.armorRating, armorRating) != 0) { + return false; + } + if(Float.compare(toolNBT.armorToughness, armorToughness) != 0) { + return false; + } + return modifiers == toolNBT.modifiers; + + } + + @Override + public int hashCode() { + int result = durability; + result = 31 * result + (armorRating != +0.0f ? Float.floatToIntBits(armorRating) : 0); + result = 31 * result + (armorToughness != +0.0f ? Float.floatToIntBits(armorToughness) : 0); + result = 31 * result + modifiers; + return result; + } +}
\ No newline at end of file diff --git a/src/main/java/lance5057/tDefense/core/library/ArmorPart.java b/src/main/java/lance5057/tDefense/core/library/ArmorPart.java new file mode 100644 index 0000000..24f8c86 --- /dev/null +++ b/src/main/java/lance5057/tDefense/core/library/ArmorPart.java @@ -0,0 +1,258 @@ +package lance5057.tDefense.core.library; + +import java.util.List; +import java.util.ListIterator; +import java.util.Map; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; + +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.util.ITooltipFlag; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.NonNullList; +import net.minecraft.util.text.TextFormatting; +import net.minecraft.util.text.translation.I18n; +import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import slimeknights.mantle.util.LocUtils; +import slimeknights.tconstruct.common.ClientProxy; +import slimeknights.tconstruct.common.config.Config; +import slimeknights.tconstruct.library.TinkerRegistry; +import slimeknights.tconstruct.library.Util; +import slimeknights.tconstruct.library.materials.IMaterialStats; +import slimeknights.tconstruct.library.materials.Material; +import slimeknights.tconstruct.library.tinkering.MaterialItem; +import slimeknights.tconstruct.library.tinkering.PartMaterialType; +import slimeknights.tconstruct.library.tools.IToolPart; +import slimeknights.tconstruct.library.tools.ToolCore; +import slimeknights.tconstruct.library.traits.ITrait; +import slimeknights.tconstruct.library.utils.TagUtil; +import slimeknights.tconstruct.library.utils.Tags; + +public class ArmorPart extends MaterialItem implements IToolPart { + + protected int cost; + + public ArmorPart(int cost) { + this.setCreativeTab(TinkerRegistry.tabParts); + this.cost = cost; + } + + @Override + public int getCost() { + return cost; + } + + @Override + public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> subItems) { + if(this.isInCreativeTab(tab)) { + for(Material mat : TinkerRegistry.getAllMaterials()) { + // check if the material makes sense for this item (is it usable to build stuff?) + if(canUseMaterial(mat)) { + subItems.add(getItemstackWithMaterial(mat)); + if(!Config.listAllMaterials) { + break; + } + } + } + } + } + + @Override + public boolean canUseMaterial(Material mat) { + for(ToolCore tool : TinkerRegistry.getTools()) { + for(PartMaterialType pmt : tool.getRequiredComponents()) { + if(pmt.isValid(this, mat)) { + return true; + } + } + } + + return false; + } + + @SideOnly(Side.CLIENT) + @Override + public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) { + Material material = getMaterial(stack); + + // Material traits/info + boolean shift = Util.isShiftKeyDown(); + + if(!checkMissingMaterialTooltip(stack, tooltip)) { + tooltip.addAll(getTooltipTraitInfo(material)); + } + + // Stats + if(Config.extraTooltips) { + if(!shift) { + // info tooltip for detailed and component info + tooltip.add(""); + tooltip.add(Util.translate("tooltip.tool.holdShift")); + } + else { + tooltip.addAll(getTooltipStatsInfo(material)); + } + } + + tooltip.addAll(getAddedByInfo(material)); + } + + public List<String> getTooltipTraitInfo(Material material) { + // We build a map with Stat -> Traits mappings that allows us to group or not group depending on what's available + Map<String, List<ITrait>> mapping = Maps.newConcurrentMap(); + + // go through all stats of the material, and check if they have a use, build the map from them + for(IMaterialStats stat : material.getAllStats()) { + if(hasUseForStat(stat.getIdentifier())) { + List<ITrait> traits = material.getAllTraitsForStats(stat.getIdentifier()); + if(!traits.isEmpty()) { + boolean unified = false; + for(Map.Entry<String, List<ITrait>> entry : mapping.entrySet()) { + // group together if identical + if(entry.getValue().equals(traits)) { + mapping.put(entry.getKey() + ", " + stat.getLocalizedName(), entry.getValue()); + mapping.remove(entry.getKey()); + unified = true; + break; + } + } + + if(!unified) { + mapping.put(stat.getLocalizedName(), traits); + } + } + } + } + + List<String> tooltips = Lists.newLinkedList(); + boolean withType = mapping.size() > 1; + + // convert the entries into tooltips + for(Map.Entry<String, List<ITrait>> entry : mapping.entrySet()) { + // add the traits in "Stattype: Trait1, Trait2,..." style + StringBuilder sb = new StringBuilder(); + if(withType) { + sb.append(TextFormatting.ITALIC.toString()); + sb.append(entry.getKey()); + sb.append(": "); + sb.append(TextFormatting.RESET.toString()); + } + sb.append(material.getTextColor()); + List<ITrait> traits = entry.getValue(); + if(!traits.isEmpty()) { + ListIterator<ITrait> iter = traits.listIterator(); + + sb.append(iter.next().getLocalizedName()); + while(iter.hasNext()) { + sb.append(", ").append(iter.next().getLocalizedName()); + } + + tooltips.add(sb.toString()); + } + } + + return tooltips; + } + + public List<String> getTooltipStatsInfo(Material material) { + ImmutableList.Builder<String> builder = ImmutableList.builder(); + + for(IMaterialStats stat : material.getAllStats()) { + if(hasUseForStat(stat.getIdentifier())) { + List<String> text = stat.getLocalizedInfo(); + if(!text.isEmpty()) { + builder.add(""); + builder.add(TextFormatting.WHITE.toString() + TextFormatting.UNDERLINE + stat.getLocalizedName()); + builder.addAll(stat.getLocalizedInfo()); + } + } + } + + return builder.build(); + } + + public List<String> getAddedByInfo(Material material) { + ImmutableList.Builder<String> builder = ImmutableList.builder(); + if(TinkerRegistry.getTrace(material) != null) { + String materialInfo = I18n.translateToLocalFormatted("tooltip.part.material_added_by", + TinkerRegistry.getTrace(material).getName()); + builder.add(""); + builder.add(materialInfo); + } + return builder.build(); + } + + @Nonnull + @Override + public String getItemStackDisplayName(@Nonnull ItemStack stack) { + Material material = getMaterial(stack); + + String locString = getUnlocalizedName() + "." + material.getIdentifier(); + + // custom name? + if(I18n.canTranslate(locString)) { + return Util.translate(locString); + } + + // no, create the default name combo + return material.getLocalizedItemName(super.getItemStackDisplayName(stack)); + } + + @Nonnull + @SideOnly(Side.CLIENT) + @Override + public FontRenderer getFontRenderer(ItemStack stack) { + return ClientProxy.fontRenderer; + } + + @Override + public boolean hasUseForStat(String stat) { + for(ToolCore tool : TinkerRegistry.getTools()) { + for(PartMaterialType pmt : tool.getRequiredComponents()) { + if(pmt.isValidItem(this) && pmt.usesStat(stat)) { + return true; + } + } + } + + return false; + } + + public boolean checkMissingMaterialTooltip(ItemStack stack, List<String> tooltip) { + return checkMissingMaterialTooltip(stack, tooltip, null); + } + + public boolean checkMissingMaterialTooltip(ItemStack stack, List<String> tooltip, String statIdentifier) { + Material material = getMaterial(stack); + + if(material == Material.UNKNOWN) { + NBTTagCompound tag = TagUtil.getTagSafe(stack); + String materialID = tag.getString(Tags.PART_MATERIAL); + + String error; + if(!materialID.isEmpty()) { + error = I18n.translateToLocalFormatted("tooltip.part.missing_material", materialID); + } + else { + error = I18n.translateToLocal("tooltip.part.missing_info"); + } + tooltip.addAll(LocUtils.getTooltips(error)); + return true; + } + else if(statIdentifier != null && material.getStats(statIdentifier) == null) { + tooltip.addAll(LocUtils.getTooltips(Util.translateFormatted("tooltip.part.missing_stats", material.getLocalizedName(), statIdentifier))); + return true; + } + + return false; + } +}
\ No newline at end of file diff --git a/src/main/java/lance5057/tDefense/core/library/ArmorTags.java b/src/main/java/lance5057/tDefense/core/library/ArmorTags.java new file mode 100644 index 0000000..c9cff2f --- /dev/null +++ b/src/main/java/lance5057/tDefense/core/library/ArmorTags.java @@ -0,0 +1,8 @@ +package lance5057.tDefense.core.library; + +public final class ArmorTags +{ + /** The stored dynamic texture location for this piece of armor */ + public static final String DynTex = "DynTex"; + public static final String TexLoc = "TexLoc"; +} diff --git a/src/main/java/lance5057/tDefense/core/library/ArmorTextureBuilder.java b/src/main/java/lance5057/tDefense/core/library/ArmorTextureBuilder.java new file mode 100644 index 0000000..7dee0b0 --- /dev/null +++ b/src/main/java/lance5057/tDefense/core/library/ArmorTextureBuilder.java @@ -0,0 +1,94 @@ +package lance5057.tDefense.core.library; + +import java.awt.AlphaComposite; +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.image.BufferedImage; +import java.util.ArrayList; +import java.util.List; + +import lance5057.tDefense.Reference; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.texture.DynamicTexture; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import slimeknights.tconstruct.library.client.MaterialRenderInfo; +import slimeknights.tconstruct.library.materials.Material; + +@SideOnly(Side.CLIENT) +public class ArmorTextureBuilder +{ + @SideOnly(Side.CLIENT) + public static ResourceLocation createArmorTexture(String type, String[] parts, List<Material> materials) + { + List<BufferedImage> looseTex = new ArrayList<BufferedImage>(); + + TextureMap map = Minecraft.getMinecraft().getTextureMapBlocks(); + + for (int i = 0; i < materials.size(); i++) + { + BufferedImage bi = null; + if (materials.get(i).renderInfo instanceof MaterialRenderInfo.Default) + { + MaterialRenderInfo.Default render = (MaterialRenderInfo.Default)materials.get(i).renderInfo; + TextureAtlasSprite tex = map.getTextureExtry(String.format("tinkerscompendium:armor/%s/_%s_%s", type, type, parts[i])); + bi = new BufferedImage(tex.getIconWidth(), tex.getIconHeight(), BufferedImage.TYPE_4BYTE_ABGR); + + Graphics2D g2d = bi.createGraphics(); + int vert = render.getVertexColor(); + Color c = new Color(vert); + g2d.drawImage(createBufferedImage(tex), 0, 0, null); + g2d.setPaint(c); + g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, 0.9f)); + g2d.fillRect(0, 0, tex.getIconWidth(), tex.getIconHeight()); + + g2d.dispose(); + + } else + { + String s = String.format("tinkerscompendium:armor/%s/_%s_%s_%s", type, type, parts[i], materials.get(i).identifier); + bi = createBufferedImage(map.getTextureExtry(s)); + } + + if (bi != null) + looseTex.add(bi); + } + + if (looseTex.size() != 0) + { + BufferedImage fullTex = new BufferedImage(looseTex.get(0).getWidth(), looseTex.get(0).getHeight(), BufferedImage.TYPE_4BYTE_ABGR); + Graphics2D g2d = fullTex.createGraphics(); + + for (BufferedImage tex : looseTex) + g2d.drawImage(tex, 0, 0, null); + g2d.dispose(); + + return Minecraft.getMinecraft().getTextureManager().getDynamicTextureLocation(Reference.MOD_ID, new DynamicTexture(fullTex)); + } + return null; + } + + @SideOnly(Side.CLIENT) + private static BufferedImage createBufferedImage(TextureAtlasSprite sprite) + { + if (sprite != null) + { + int w = sprite.getIconWidth(); + int h = sprite.getIconHeight(); + int count = sprite.getFrameCount(); + + BufferedImage buff = new BufferedImage(w, h * count, BufferedImage.TYPE_4BYTE_ABGR); + + for (int i = 0; i < count; i++) + { + buff.setRGB(0, i * h, w, h, sprite.getFrameTextureData(i)[0], 0, w); + } + + return buff; + } + return null; + } +} diff --git a/src/main/java/lance5057/tDefense/core/library/BlocksBase.java b/src/main/java/lance5057/tDefense/core/library/BlocksBase.java new file mode 100644 index 0000000..98e07f1 --- /dev/null +++ b/src/main/java/lance5057/tDefense/core/library/BlocksBase.java @@ -0,0 +1,53 @@ +package lance5057.tDefense.core.library; + +import java.util.ArrayList; + +import lance5057.tDefense.Reference; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; + +public abstract class BlocksBase { + protected static ArrayList<Block> blockList = new ArrayList<Block>(); + protected static ArrayList<Item> itemList = new ArrayList<Item>(); + public BlocksBase() + { + + } + + public abstract void preInit(FMLPreInitializationEvent e); + + public abstract void init(FMLInitializationEvent e); + + public abstract void postInit(FMLPostInitializationEvent e); + + protected Block setupRegister(String name, CreativeTabs tabName, float hardness) + { + Block block = new Block(Material.IRON).setCreativeTab(tabName).setUnlocalizedName(name).setRegistryName(Reference.MOD_ID, name).setHardness(hardness); + blockList.add(block); + return block; + } + + protected ItemBlock setupRegister(String name, int size, CreativeTabs tabName, Block block) + { + ItemBlock item = new ItemBlock(block); + item.setCreativeTab(tabName).setMaxStackSize(size).setUnlocalizedName(name).setRegistryName(Reference.MOD_ID, name).setCreativeTab(tabName); + itemList.add(item); + return item; + } + + +} + +// protected MetaItem registerMeta(String name, String[] names,int size) +// { +// Item item = new MetaItem(names).setCreativeTab(tabName).setMaxStackSize(size).setUnlocalizedName(name).setRegistryName(Reference.MOD_ID, name); +// +// GameRegistry.register(item); +// return (MetaItem) item; +// }
\ No newline at end of file diff --git a/src/main/java/lance5057/tDefense/core/library/CustomArmorTextureCreator.java b/src/main/java/lance5057/tDefense/core/library/CustomArmorTextureCreator.java new file mode 100644 index 0000000..67c9661 --- /dev/null +++ b/src/main/java/lance5057/tDefense/core/library/CustomArmorTextureCreator.java @@ -0,0 +1,304 @@ +package lance5057.tDefense.core.library; + +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.client.resources.IResourceManager; +import net.minecraft.client.resources.IResourceManagerReloadListener; +import net.minecraft.item.Item; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.event.TextureStitchEvent; +import net.minecraftforge.client.model.IModel; +import net.minecraftforge.client.model.ModelLoaderRegistry; +import net.minecraftforge.fml.common.eventhandler.EventPriority; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +import org.apache.logging.log4j.Logger; + +import java.io.IOException; +import java.lang.reflect.Constructor; +import java.util.Collection; +import java.util.Map; +import java.util.Optional; +import java.util.Set; + +import javax.annotation.Nonnull; + +import slimeknights.tconstruct.library.TinkerRegistry; +import slimeknights.tconstruct.library.Util; +import slimeknights.tconstruct.library.client.MaterialRenderInfo; +import slimeknights.tconstruct.library.client.material.MaterialRenderInfoLoader; +import slimeknights.tconstruct.library.client.model.IPatternOffset; +import slimeknights.tconstruct.library.client.model.MaterialModelLoader; +import slimeknights.tconstruct.library.client.texture.CastTexture; +import slimeknights.tconstruct.library.client.texture.GuiOutlineTexture; +import slimeknights.tconstruct.library.client.texture.PatternTexture; +import slimeknights.tconstruct.library.client.texture.TextureColoredTexture; +import slimeknights.tconstruct.library.client.texture.TinkerTexture; +import slimeknights.tconstruct.library.materials.Material; +import slimeknights.tconstruct.library.materials.MaterialGUI; +import slimeknights.tconstruct.library.tools.IToolPart; +import slimeknights.tconstruct.library.tools.Pattern; + +/** + * Textures registered with this creator will get a texture created/loaded for each material. + */ +public class CustomArmorTextureCreator implements IResourceManagerReloadListener { + + public static final CustomArmorTextureCreator INSTANCE = new CustomArmorTextureCreator(); + + private static Logger log = Util.getLogger("ArmorTextureGen"); + + /** + * Holds all sprites built from the base-texture used as the key. + */ + public static Map<String, Map<String, TextureAtlasSprite>> sprites = Maps.newHashMap(); + + private static Set<ResourceLocation> baseTextures = Sets.newHashSet(); + + //private static Map<ResourceLocation, Set<IToolPart>> texturePartMapping = Maps.newHashMap(); + + public static void registerTextures(Collection<ResourceLocation> textures) { + baseTextures.addAll(textures); + } + + public static void registerTexture(ResourceLocation texture) { + baseTextures.add(texture); + } + +// public static void registerTextureForPart(ResourceLocation texture, IToolPart toolPart) { +// if(!texturePartMapping.containsKey(texture)) { +// texturePartMapping.put(texture, Sets.newHashSet()); +// } +// texturePartMapping.get(texture).add(toolPart); +// registerTexture(texture); +// } + + // set these to the pattern/cast model to generate part-textures for them +// public static ResourceLocation patternModelLocation; +// public static ResourceLocation castModelLocation; +// public static String patternLocString; +// public static String castLocString; + + public static final Material guiMaterial; + + private int createdTextures; + + // low since other event-handlers might want to register textures beforehand + @SubscribeEvent(priority = EventPriority.LOW) + public void createCustomTextures(TextureStitchEvent.Pre event) { + // get the material info at this point, to override hardcoded material rendering with resources + MaterialRenderInfoLoader.INSTANCE.onResourceManagerReload(Minecraft.getMinecraft().getResourceManager()); + + createdTextures = 0; + // create textures for each material where needed + createMaterialTextures(event.getMap()); + + // add stencil and cast textures for all used toolparts + //createPatterntextures(event.getMap()); + + log.debug("Generated " + createdTextures + " Textures for Materials"); + } + + private void createMaterialTextures(TextureMap map) { + // Create textures for toolparts and tools - Textures that need 1 per material + for(ResourceLocation baseTexture : baseTextures) { + // exclude missingno :I + if(baseTexture.toString().equals("minecraft:missingno")) { + continue; + } + + //Set<IToolPart> parts = texturePartMapping.get(baseTexture); + + Map<String, TextureAtlasSprite> builtSprites = Maps.newHashMap(); + Collection<Material> mats = TinkerRegistry.getAllMaterials(); + for(Material material : mats) { + boolean usable; +// if(parts == null || material instanceof MaterialGUI) { +// usable = true; +// } +// else { +// usable = false; +// for(IToolPart toolPart : parts) { +// usable |= toolPart.canUseMaterialForRendering(material); +// } +// } + +// if(usable) { + TextureAtlasSprite sprite = createTexture(material, baseTexture, map); + if(sprite != null) { + builtSprites.put(material.identifier, sprite); + } + } +// } +// +// if(belongsToToolPart(baseTexture)) { +// TextureAtlasSprite sprite = createTexture(guiMaterial, baseTexture, map); +// if(sprite != null) { +// builtSprites.put(guiMaterial.identifier, sprite); +// } +// } + + sprites.put(baseTexture.toString(), builtSprites); + } + } + + private TextureAtlasSprite createTexture(Material material, ResourceLocation baseTexture, TextureMap map) { + String location = baseTexture.toString() + "_" + material.identifier; + TextureAtlasSprite sprite; + + if(exists(location)) { + sprite = map.registerSprite(new ResourceLocation(location)); + } + else { + // material does not need a special generated texture + if(material.renderInfo == null) { + return null; + } + + // different base texture? + if(material.renderInfo.getTextureSuffix() != null) { + String loc2 = baseTexture.toString() + "_" + material.renderInfo.getTextureSuffix(); + TextureAtlasSprite base2 = map.getTextureExtry(loc2); + // can we manually load it? + if(base2 == null && exists(loc2)) { + base2 = TinkerTexture.loadManually(new ResourceLocation(loc2)); + // save in the map so it's getting reused by the others and is available + map.setTextureEntry(base2); + } + if(base2 != null) { + baseTexture = new ResourceLocation(base2.getIconName()); + } + } + + sprite = material.renderInfo.getTexture(baseTexture, location); + createdTextures++; + } + + // stitch new textures + if(sprite != null && material.renderInfo.isStitched()) { + map.setTextureEntry(sprite); + } + return sprite; + } + +// private void createPatterntextures(TextureMap map) { +// // create Pattern textures +// if(patternModelLocation != null) { +// patternLocString = createPatternTexturesFor(map, patternModelLocation, TinkerRegistry.getPatternItems(), PatternTexture.class); +// } +// // create cast textures +// if(castModelLocation != null) { +// castLocString = createPatternTexturesFor(map, castModelLocation, TinkerRegistry.getCastItems(), CastTexture.class); +// } +// } + +// public String createPatternTexturesFor(TextureMap map, ResourceLocation baseTextureLoc, Iterable<Item> items, Class<? extends TextureColoredTexture> clazz) { +// Constructor<? extends TextureColoredTexture> constructor; +// String baseTextureString; +// ResourceLocation patternLocation; +// try { +// constructor = clazz.getConstructor(ResourceLocation.class, ResourceLocation.class, String.class); +// IModel patternModel = ModelLoaderRegistry.getModel(baseTextureLoc); +// patternLocation = patternModel.getTextures().iterator().next(); +// baseTextureString = patternLocation.toString(); +// } catch(Exception e) { +// log.error(e); +// return null; +// } +// +// for(Item item : items) { +// try { +// // get id +// String identifier = Pattern.getTextureIdentifier(item); +// String partPatternLocation = baseTextureString + identifier; +// TextureAtlasSprite partPatternTexture; +// if(exists(partPatternLocation)) { +// partPatternTexture = map.registerSprite(new ResourceLocation(partPatternLocation)); +// map.setTextureEntry(partPatternTexture); +// } +// else { +// ResourceLocation modelLocation = item.getRegistryName(); +// IModel partModel = ModelLoaderRegistry.getModel(new ResourceLocation(modelLocation.getResourceDomain(), +// "item/parts/" + modelLocation +// .getResourcePath() +// + MaterialModelLoader.EXTENSION)); +// ResourceLocation partTexture = partModel.getTextures().iterator().next(); +// +// if(partModel != ModelLoaderRegistry.getMissingModel()) { +// partPatternTexture = constructor.newInstance(partTexture, patternLocation, partPatternLocation); +// if(partModel instanceof IPatternOffset) { +// IPatternOffset offset = (IPatternOffset) partModel; +// ((TextureColoredTexture) partPatternTexture).setOffset(offset.getXOffset(), offset.getYOffset()); +// } +// map.setTextureEntry(partPatternTexture); +// } +// } +// } catch(Exception e) { +// log.error(e); +// } +// } +// +// return baseTextureString; +// } + + public static boolean exists(String res) { + try { + ResourceLocation loc = new ResourceLocation(res); + loc = new ResourceLocation(loc.getResourceDomain(), "textures/" + loc.getResourcePath() + ".png"); + Minecraft.getMinecraft().getResourceManager().getAllResources(loc); + return true; + } catch(IOException e) { + return false; + } + } + + @Override + public void onResourceManagerReload(@Nonnull IResourceManager resourceManager) { + // clear cache + baseTextures.clear(); + for(Map map : sprites.values()) { + // safety in case there are some references lying around + map.clear(); + } + sprites.clear(); + } + + public static boolean belongsToToolPart(ResourceLocation location) { + for(IToolPart toolpart : TinkerRegistry.getToolParts()) { + if(!(toolpart instanceof Item)) { + continue; // WHY?! + } + try { + Optional<ResourceLocation> storedResourceLocation = MaterialModelLoader.getToolPartModelLocation(toolpart); + if(storedResourceLocation.isPresent()) { + ResourceLocation stored = storedResourceLocation.get(); + ResourceLocation modelLocation = new ResourceLocation(stored.getResourceDomain(), "item/" + stored.getResourcePath()); + IModel partModel = ModelLoaderRegistry.getModel(modelLocation); + + // the actual texture of the part + ResourceLocation baseTexture = partModel.getTextures().iterator().next(); + if(baseTexture.toString().equals(location.toString())) { + return true; + } + } + } catch(Exception e) { + return false; + } + } + return false; + } + + static { + guiMaterial = new MaterialGUI("_internal_gui"); + guiMaterial.setRenderInfo(new MaterialRenderInfo.AbstractMaterialRenderInfo() { + @Override + public TextureAtlasSprite getTexture(ResourceLocation baseTexture, String location) { + return new GuiOutlineTexture(baseTexture, location); + } + }); + } +}
\ No newline at end of file diff --git a/src/main/java/lance5057/tDefense/core/library/ItemsBase.java b/src/main/java/lance5057/tDefense/core/library/ItemsBase.java new file mode 100644 index 0000000..ce802fd --- /dev/null +++ b/src/main/java/lance5057/tDefense/core/library/ItemsBase.java @@ -0,0 +1,50 @@ +package lance5057.tDefense.core.library; + +import java.util.ArrayList; + +import lance5057.tDefense.Reference; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraftforge.event.RegistryEvent; +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.registries.IForgeRegistry; + +public abstract class ItemsBase { + protected static ArrayList<Item> itemList = new ArrayList<Item>(); + public ItemsBase() + { + + } + + public abstract void preInit(FMLPreInitializationEvent e); + + public abstract void init(FMLInitializationEvent e); + + public abstract void postInit(FMLPostInitializationEvent e); + + @SubscribeEvent + public static void registerItems(final RegistryEvent.Register<Item> event) + { + final IForgeRegistry registry = event.getRegistry(); + + registry.registerAll((Item[]) itemList.toArray()); + } + + protected Item register(String name, int size, CreativeTabs tabName) + { + Item item = new Item().setCreativeTab(tabName).setMaxStackSize(size).setUnlocalizedName(name).setRegistryName(Reference.MOD_ID, name); + itemList.add(item); + return item; + } + + protected MetaItem registerMeta(String name, String[] names,int size, CreativeTabs tabName) + { + Item item = new MetaItem(names).setCreativeTab(tabName).setMaxStackSize(size).setUnlocalizedName(name).setRegistryName(Reference.MOD_ID, name); + + itemList.add(item); + return (MetaItem) item; + } +} diff --git a/src/main/java/lance5057/tDefense/core/library/MetaItem.java b/src/main/java/lance5057/tDefense/core/library/MetaItem.java new file mode 100644 index 0000000..cc75e17 --- /dev/null +++ b/src/main/java/lance5057/tDefense/core/library/MetaItem.java @@ -0,0 +1,31 @@ +package lance5057.tDefense.core.library; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; + +public class MetaItem extends Item +{ + String[] items; + public MetaItem(String[] items) { + super(); + this.setHasSubtypes(true); + setMaxDamage(0); + this.items = items; + } + + @Override + public String getUnlocalizedName(ItemStack stack) { + return super.getUnlocalizedName() + "." + items[stack.getItemDamage()]; + } + + @Override + public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> subItems) + { + for(int i = 0; i < items.length; i++) + { + subItems.add(new ItemStack(this, 1, i)); + } + } +} diff --git a/src/main/java/lance5057/tDefense/core/library/ModuleBase.java b/src/main/java/lance5057/tDefense/core/library/ModuleBase.java new file mode 100644 index 0000000..9e8a506 --- /dev/null +++ b/src/main/java/lance5057/tDefense/core/library/ModuleBase.java @@ -0,0 +1,14 @@ +package lance5057.tDefense.core.library; + +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; + +public abstract class ModuleBase +{ + public abstract void preInit(FMLPreInitializationEvent e); + + public abstract void init(FMLInitializationEvent e); + + public abstract void postInit(FMLPostInitializationEvent e); +} diff --git a/src/main/java/lance5057/tDefense/core/library/RegEvents.java b/src/main/java/lance5057/tDefense/core/library/RegEvents.java new file mode 100644 index 0000000..0c9f942 --- /dev/null +++ b/src/main/java/lance5057/tDefense/core/library/RegEvents.java @@ -0,0 +1,5 @@ +package lance5057.tDefense.core.library; + +public class RegEvents { + +} diff --git a/src/main/java/lance5057/tDefense/core/library/TDClientRegistry.java b/src/main/java/lance5057/tDefense/core/library/TDClientRegistry.java new file mode 100644 index 0000000..7e0a482 --- /dev/null +++ b/src/main/java/lance5057/tDefense/core/library/TDClientRegistry.java @@ -0,0 +1,46 @@ +package lance5057.tDefense.core.library; + +import java.util.Map; + +import org.apache.logging.log4j.Logger; + +import com.google.common.collect.Maps; + +import net.minecraft.item.Item; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import slimeknights.tconstruct.library.Util; +import slimeknights.tconstruct.library.client.texture.AbstractColoredTexture; + +@SideOnly(Side.CLIENT) +public final class TDClientRegistry { + + // the logger for the library + public static final Logger log = Util.getLogger("API-Client"); + + private TDClientRegistry() { + } + + /*--------------------------------------------------------------------------- + | GUI & CRAFTING | + ---------------------------------------------------------------------------*/ + private static final Map<Item, ArmorBuildGuiInfo> armorBuildInfo = Maps.newLinkedHashMap(); + + public static void addArmorBuilding(ArmorBuildGuiInfo info) { + armorBuildInfo.put(info.armor.getItem(), info); + } + + public static ArmorBuildGuiInfo getArmorBuildInfoForArmor(Item armor) { + return armorBuildInfo.get(armor); + } + + public static void clear() { + armorBuildInfo.clear(); + } + + /*--------------------------------------------------------------------------- + | MATERIAL TEXTURE CREATION | + ---------------------------------------------------------------------------*/ + private static final Map<String, AbstractColoredTexture> textureProcessors = Maps.newHashMap(); + +}
\ No newline at end of file diff --git a/src/main/java/lance5057/tDefense/core/library/TDMatHelper.java b/src/main/java/lance5057/tDefense/core/library/TDMatHelper.java new file mode 100644 index 0000000..d0cfa54 --- /dev/null +++ b/src/main/java/lance5057/tDefense/core/library/TDMatHelper.java @@ -0,0 +1,210 @@ +package lance5057.tDefense.core.library; + +import javax.annotation.Nullable; + +import lance5057.tDefense.core.materials.stats.ChestMaterialStats; +import lance5057.tDefense.core.materials.stats.FabricMaterialStats; +import lance5057.tDefense.core.materials.stats.FeetMaterialStats; +import lance5057.tDefense.core.materials.stats.HelmMaterialStats; +import lance5057.tDefense.core.materials.stats.LegsMaterialStats; +import lance5057.tDefense.core.materials.stats.ShieldMaterialStats; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import slimeknights.tconstruct.library.fluid.FluidMolten; +import slimeknights.tconstruct.library.materials.ArrowShaftMaterialStats; +import slimeknights.tconstruct.library.materials.BowMaterialStats; +import slimeknights.tconstruct.library.materials.BowStringMaterialStats; +import slimeknights.tconstruct.library.materials.ExtraMaterialStats; +import slimeknights.tconstruct.library.materials.FletchingMaterialStats; +import slimeknights.tconstruct.library.materials.HandleMaterialStats; +import slimeknights.tconstruct.library.materials.HeadMaterialStats; + +public class TDMatHelper +{ + public String name; + public int color; + public FluidMolten fluid; + + public boolean isGem; + + public HeadMaterialStats head; + public ShieldMaterialStats shield; + public BowMaterialStats bow; + public ExtraMaterialStats extra; + public FletchingMaterialStats fletching; + public BowStringMaterialStats bowstring; + public HandleMaterialStats handle; + public ArrowShaftMaterialStats shaft; + public HelmMaterialStats helm; + public ChestMaterialStats chest; + public LegsMaterialStats legs; + public FeetMaterialStats boots; + public FabricMaterialStats cloth; + + public ItemStack gem; + public ItemStack ingot; + public ItemStack dust; + public ItemStack nugget; + public ItemStack grain; + + public boolean createMat = true; + public boolean createParts = true; + + public TDMatHelper(String n, int c, FluidMolten f, boolean doMat) + { + name = n; + color = c; + fluid = f; + createMat = doMat; + } + + public TDMatHelper(String n, int c, boolean doMat) + { + init(n, c, null, false, doMat, true); + } + + public TDMatHelper(String n, int c, boolean o, boolean doMat) + { + init(n, c, null, o, doMat, true); + } + + public TDMatHelper(String n, int c, @Nullable FluidMolten f, boolean o, boolean doMat) + { + init(n, c, f, o, doMat, true); + } + + public TDMatHelper(String n, int c, @Nullable FluidMolten f, boolean o, boolean doMat, boolean doParts) + { + init(n, c, f, o, doMat, doParts); + } + + public TDMatHelper(String n, int c) + { + init(n, c, null, false, true, true); + } + + private void init(String n, int c, @Nullable FluidMolten f, boolean o, boolean doMat, boolean doParts) + { + name = n; + color = c; + fluid = f; + + isGem = o; + createMat = doMat; + createParts = doParts; + } + + public TDMatHelper setHead(HeadMaterialStats h) + { + head = h; + return this; + } + + public TDMatHelper setHandle(HandleMaterialStats h) + { + handle = h; + return this; + } + + public TDMatHelper setShield(ShieldMaterialStats h) + { + shield = h; + return this; + } + + public TDMatHelper setExtra(ExtraMaterialStats h) + { + extra = h; + return this; + } + + public TDMatHelper setBow(BowMaterialStats h) + { + bow = h; + return this; + } + + public TDMatHelper setFletching(FletchingMaterialStats h) + { + fletching = h; + return this; + } + + public TDMatHelper setString(BowStringMaterialStats h) + { + bowstring = h; + return this; + } + + public TDMatHelper setShaft(ArrowShaftMaterialStats h) + { + shaft = h; + return this; + } + + public TDMatHelper setHelm(HelmMaterialStats h) + { + helm = h; + return this; + } + + public TDMatHelper setChest(ChestMaterialStats h) + { + chest = h; + return this; + } + + public TDMatHelper setLegs(LegsMaterialStats h) + { + legs = h; + return this; + } + + public TDMatHelper setBoots(FeetMaterialStats h) + { + boots = h; + return this; + } + + public TDMatHelper setCloth(FabricMaterialStats h) + { + cloth = h; + return this; + } + + public TDMatHelper setGem(Item i) + { + gem = new ItemStack(i); + return this; + } + + public TDMatHelper setGem(ItemStack i) + { + gem = i; + return this; + } + + public TDMatHelper setIngot(Item i) + { + ingot = new ItemStack(i); + return this; + } + + public TDMatHelper setDust(Item i) + { + dust = new ItemStack(i); + return this; + } + + public TDMatHelper setGrain(Item i) + { + grain = new ItemStack(i); + return this; + } + + public TDMatHelper setNugget(Item i) + { + nugget = new ItemStack(i); + return this; + } +} diff --git a/src/main/java/lance5057/tDefense/core/library/TDModelLoader.java b/src/main/java/lance5057/tDefense/core/library/TDModelLoader.java new file mode 100644 index 0000000..fd57081 --- /dev/null +++ b/src/main/java/lance5057/tDefense/core/library/TDModelLoader.java @@ -0,0 +1,204 @@ +package lance5057.tDefense.core.library; + +import java.io.IOException; +import java.util.List; +import java.util.Map; + +import javax.annotation.Nonnull; + +import org.apache.commons.io.FilenameUtils; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; + +import gnu.trove.map.hash.TIntObjectHashMap; +import lance5057.tDefense.core.tools.bases.ArmorCore; +import net.minecraft.client.renderer.block.model.ItemCameraTransforms; +import net.minecraft.client.resources.IResourceManager; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.model.ICustomModelLoader; +import net.minecraftforge.client.model.IModel; +import net.minecraftforge.client.model.ModelLoaderRegistry; +import net.minecraftforge.common.model.TRSRTransformation; +import slimeknights.tconstruct.library.TinkerRegistry; +import slimeknights.tconstruct.library.client.CustomTextureCreator; +import slimeknights.tconstruct.library.client.model.MaterialModel; +import slimeknights.tconstruct.library.client.model.MaterialModelLoader; +import slimeknights.tconstruct.library.client.model.ModelHelper; +import slimeknights.tconstruct.library.client.model.ModifierModel; +import slimeknights.tconstruct.library.client.model.ModifierModelLoader; +import slimeknights.tconstruct.library.client.model.ToolModel; +import slimeknights.tconstruct.library.client.model.format.AmmoPosition; +import slimeknights.tconstruct.library.client.model.format.ToolModelOverride; +import slimeknights.tconstruct.library.tools.IToolPart; + +public class TDModelLoader implements ICustomModelLoader { + + public static String EXTENSION = ".td"; + + // used to create only actually needed textures in the texturegenerator instead of ALL materials for all parts + private static final Map<ResourceLocation, ArmorCore> modelItemMap = Maps.newHashMap(); + + public static void addPartMapping(ResourceLocation resourceLocation, ArmorCore tool) { + modelItemMap.put(resourceLocation, tool); + } + + @Override + public boolean accepts(ResourceLocation modelLocation) { + return modelLocation.getResourcePath().endsWith(EXTENSION); // tinkertoolmodel extension. Foo.tcon.json + } + + @Override + public IModel loadModel(ResourceLocation modelLocation) { + try { + // Modelblock is used since our format is compatible to the vanilla format + // and we don't have to write our own json deserializer + // it also provides us with the textures + Map<String, String> textures = ModelHelper.loadTexturesFromJson(modelLocation); + ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> transforms = ModelHelper.loadTransformFromJson(modelLocation); + ImmutableList<ToolModelOverride> overrides = ModelHelper.loadToolModelOverridesFromJson(modelLocation); + AmmoPosition ammoPosition = ModelHelper.loadAmmoPositionFromJson(modelLocation); + Float[] rotations = ModelHelper.loadLayerRotations(modelLocation); + + if(rotations.length > 0 && textures.size() != rotations.length) { + TinkerRegistry.log.error("Toolmodel {} has invalid layerrotation entry: Size should be {} but is {}; Skipping rotations.", modelLocation, textures.size(), rotations.length); + rotations = new Float[0]; + } + + ImmutableList.Builder<ResourceLocation> defaultTextureListBuilder = ImmutableList.builder(); + List<MaterialModel> parts = Lists.newArrayList(); + List<MaterialModel> brokenParts = Lists.newArrayList(); + + ArmorCore ArmorCore = modelItemMap.get(MaterialModelLoader.getReducedPath(modelLocation)); + + for(Map.Entry<String, String> entry : textures.entrySet()) { + String name = entry.getKey(); + try { + int i; + List<MaterialModel> listToAdd; + + if(name.startsWith("layer")) { + i = Integer.valueOf(name.substring(5)); + listToAdd = parts; + } + else if(name.startsWith("broken")) { + i = Integer.valueOf(name.substring(6)); + listToAdd = brokenParts; + } + // invalid entry, ignore + else { + TinkerRegistry.log.warn("Toolmodel {} has invalid texture entry {}; Skipping layer.", modelLocation, name); + continue; + } + + ResourceLocation location = new ResourceLocation(entry.getValue()); + MaterialModel partModel = new MaterialModel(ImmutableList.of(location)); + while(listToAdd.size() <= i) { + listToAdd.add(null); + } + listToAdd.set(i, partModel); + + defaultTextureListBuilder.add(location); + registerCustomTextures(i, location, ArmorCore); + } catch(NumberFormatException e) { + TinkerRegistry.log.error("Toolmodel {} has invalid texture entry {}; Skipping layer.", modelLocation, name); + } + } + + // create overrides + for(ToolModelOverride override : overrides) { + for(Map.Entry<String, String> entry : override.textures.entrySet()) { + String name = entry.getKey(); + try { + int i; + TIntObjectHashMap<MaterialModel> mapToAdd; + + if(name.startsWith("layer")) { + i = Integer.valueOf(name.substring(5)); + mapToAdd = override.partModelReplacement; + } + else if(name.startsWith("broken")) { + i = Integer.valueOf(name.substring(6)); + mapToAdd = override.brokenPartModelReplacement; + } + // invalid entry, ignore + else { + TinkerRegistry.log.warn("Toolmodel {} has invalid texture override entry {}; Skipping layer.", modelLocation, name); + continue; + } + + ResourceLocation location = new ResourceLocation(entry.getValue()); + MaterialModel partModel = new MaterialModel(ImmutableList.of(location)); + mapToAdd.put(i, partModel); + + registerCustomTextures(i, location, ArmorCore); + } catch(NumberFormatException e) { + TinkerRegistry.log.error("Toolmodel {} has invalid texture entry {}; Skipping layer.", modelLocation, name); + } + } + } + + // remove models/item/ and .tcon + String toolName = FilenameUtils.removeExtension(modelLocation.getResourcePath().substring(12)); + IModel mods; + ModifierModel modifiers = null; + try { + mods = ModelLoaderRegistry.getModel(ModifierModelLoader.getLocationForToolModifiers(modelLocation.getResourceDomain(), toolName)); + + if(mods == null || !(mods instanceof ModifierModel)) { + TinkerRegistry.log.trace( + "Toolmodel {} does not have any modifiers associated with it. Be sure that the Tools internal name, the Toolmodels filename and the name used inside the Modifier Model Definition match!", + modelLocation); + } + else { + modifiers = (ModifierModel) mods; + + for(ToolModelOverride toolModelOverride : overrides) { + if(toolModelOverride.modifierSuffix != null) { + String modifierName = toolName + toolModelOverride.modifierSuffix; + IModel extraModel = ModelLoaderRegistry.getModel(ModifierModelLoader.getLocationForToolModifiers(modelLocation.getResourceDomain(), modifierName)); + if(extraModel instanceof ModifierModel) { + ModifierModel overriddenModifierModel = new ModifierModel(); + // fill in non-overridden modifiers + for(Map.Entry<String, String> entry : modifiers.getModels().entrySet()) { + overriddenModifierModel.addModelForModifier(entry.getKey(), entry.getValue()); + } + // overwrite overridden modifiers + for(Map.Entry<String, String> entry : ((ModifierModel) extraModel).getModels().entrySet()) { + overriddenModifierModel.addModelForModifier(entry.getKey(), entry.getValue()); + } + toolModelOverride.overrideModifierModel = overriddenModifierModel; + } + } + } + } + } catch(Exception e) { + TinkerRegistry.log.error(e); + modifiers = null; + } + + return new ToolModel(defaultTextureListBuilder.build(), parts, brokenParts, rotations, modifiers, transforms, overrides, ammoPosition); + } catch(IOException e) { + TinkerRegistry.log.error("Could not load multimodel {}", modelLocation.toString()); + } + return ModelLoaderRegistry.getMissingModel(); + } + + private void registerCustomTextures(int i, ResourceLocation resourceLocation, ArmorCore ArmorCore) { + if(ArmorCore == null) { + CustomTextureCreator.registerTexture(resourceLocation); + } + else { + for(IToolPart part : ArmorCore.getRequiredComponents().get(i).getPossibleParts()) { + CustomTextureCreator.registerTextureForPart(resourceLocation, part); + } + } + } + + @Override + public void onResourceManagerReload(@Nonnull IResourceManager resourceManager) { + + } +}
\ No newline at end of file diff --git a/src/main/java/lance5057/tDefense/core/library/TDModelRegistar.java b/src/main/java/lance5057/tDefense/core/library/TDModelRegistar.java new file mode 100644 index 0000000..8043307 --- /dev/null +++ b/src/main/java/lance5057/tDefense/core/library/TDModelRegistar.java @@ -0,0 +1,60 @@ +package lance5057.tDefense.core.library; + +import javax.annotation.Nonnull; + +import lance5057.tDefense.core.tools.bases.ArmorCore; +import net.minecraft.client.renderer.ItemMeshDefinition; +import net.minecraft.client.renderer.block.model.ModelResourceLocation; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.model.ModelLoader; +import slimeknights.tconstruct.TConstruct; + +public class TDModelRegistar { + public static ResourceLocation registerToolModel(ArmorCore armor) { + if (armor == null || armor.getRegistryName() == null) { + return null; + } + ResourceLocation itemLocation = armor.getRegistryName(); + String path = "tools/" + itemLocation.getResourcePath() + TDModelLoader.EXTENSION; + + ResourceLocation location = new ResourceLocation(itemLocation.getResourceDomain(), path); + TDModelLoader.addPartMapping(location, armor); + + return registerToolModel(armor, location); + } + + /** + * Manual registration of a tool model. You probably shouldn't be using this. + */ + public static ResourceLocation registerToolModel(Item item, final ResourceLocation location) { + if (!location.getResourcePath().endsWith(TDModelLoader.EXTENSION)) { + TConstruct.log.error("The material-model " + location.toString() + " does not end with '" + + TDModelLoader.EXTENSION + "' and will therefore not be loaded by the custom model loader!"); + } + + return registerIt(item, location); + } + + private static ResourceLocation registerIt(Item item, final ResourceLocation location) { + // plop it in. + // This here is needed for the model to be found ingame when the game looks for + // a model to render an Itemstack + // we use an ItemMeshDefinition because it allows us to do it no matter what + // metadata we use + ModelLoader.setCustomMeshDefinition(item, new ItemMeshDefinition() { + @Nonnull + @Override + public ModelResourceLocation getModelLocation(@Nonnull ItemStack stack) { + return new ModelResourceLocation(location, "inventory"); + } + }); + + // We have to readd the default variant if we have custom variants, since it + // wont be added otherwise and therefore not loaded + ModelLoader.registerItemVariants(item, location); + + return location; + } +} diff --git a/src/main/java/lance5057/tDefense/core/library/TDRegistry.java b/src/main/java/lance5057/tDefense/core/library/TDRegistry.java new file mode 100644 index 0000000..74b4cba --- /dev/null +++ b/src/main/java/lance5057/tDefense/core/library/TDRegistry.java @@ -0,0 +1,62 @@ +package lance5057.tDefense.core.library; + +import java.util.List; +import java.util.Set; + +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; +import com.google.common.collect.Sets; + +import akka.japi.Pair; +import gnu.trove.set.hash.TLinkedHashSet; +import lance5057.tDefense.core.tools.bases.ArmorCore; +import net.minecraft.item.Item; +import slimeknights.tconstruct.library.TinkerRegistry; +import slimeknights.tconstruct.library.tinkering.PartMaterialType; +import slimeknights.tconstruct.library.tools.IToolPart; + +public class TDRegistry { + private static final Set<ArmorCore> armor = new TLinkedHashSet<>(); + private static final Set<IToolPart> armorParts = new TLinkedHashSet<>(); + private static final Set<ArmorCore> armorStationCrafting = Sets.newLinkedHashSet(); + private static final Set<ArmorCore> armorForgeCrafting = Sets.newLinkedHashSet(); + public static List<Pair<Item, ArmorPart>> armorPartPatterns = Lists.newLinkedList(); + + public static void registerTool(ArmorCore tool) { + armor.add(tool); + + for(PartMaterialType pmt : tool.getRequiredComponents()) { + for(IToolPart tp : pmt.getPossibleParts()) { + TinkerRegistry.registerToolPart(tp); + } + } + } + + /** Adds a armor to the Crafting UI of both the armor Station as well as the armor Forge */ + public static void registerArmorCrafting(ArmorCore armor) { + registerArmorStationCrafting(armor); + registerArmorForgeCrafting(armor); + } + + /** Adds a armor to the Crafting UI of the armor Station */ + public static void registerArmorStationCrafting(ArmorCore armor) { + armorStationCrafting.add(armor); + } + + public static ImmutableSet<ArmorCore> getArmorStationCrafting() { + return ImmutableSet.copyOf(armorStationCrafting); + } + + /** Adds a armor to the Crafting UI of the armor Forge */ + public static void registerArmorForgeCrafting(ArmorCore armor) { + armorForgeCrafting.add(armor); + } + + public static ImmutableSet<ArmorCore> getArmorForgeCrafting() { + return ImmutableSet.copyOf(armorForgeCrafting); + } + + public static Set<ArmorCore> getArmor() { + return ImmutableSet.copyOf(armor); + } +} diff --git a/src/main/java/lance5057/tDefense/core/library/TDToolHelper.java b/src/main/java/lance5057/tDefense/core/library/TDToolHelper.java new file mode 100644 index 0000000..f0ce30f --- /dev/null +++ b/src/main/java/lance5057/tDefense/core/library/TDToolHelper.java @@ -0,0 +1,45 @@ +package lance5057.tDefense.core.library; + +import lance5057.tDefense.core.tools.bases.ArmorCore; +import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemTool; +import net.minecraft.nbt.NBTTagList; +import slimeknights.tconstruct.library.TinkerRegistry; +import slimeknights.tconstruct.library.materials.Material; +import slimeknights.tconstruct.library.utils.TagUtil; + +public class TDToolHelper { + + public static boolean checkIfMetal(ItemStack item) { + + if(item.getItem() instanceof ArmorCore) + { + NBTTagList list = TagUtil.getBaseMaterialsTagList(item); + + for (int i = 0; i < list.tagCount(); i++) { + String s = list.getStringTagAt(i); + if (s != "obsidian") { + Material m = TinkerRegistry.getMaterial(s); + if(m.hasFluid()) + return true; + } + } + } + else + { + if(item.getItem() instanceof ItemTool) + { + ItemTool i = (ItemTool) item.getItem(); + + if(i.getToolMaterialName() != "WOOD" || + i.getToolMaterialName() != "STONE") + { + + } + } + } + + return false; + } + +} diff --git a/src/main/java/lance5057/tDefense/core/materials/TDMaterials.java b/src/main/java/lance5057/tDefense/core/materials/TDMaterials.java index 47afb76..f66e916 100644 --- a/src/main/java/lance5057/tDefense/core/materials/TDMaterials.java +++ b/src/main/java/lance5057/tDefense/core/materials/TDMaterials.java @@ -5,6 +5,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.List; import java.util.Map; +import java.util.Set; import org.apache.commons.lang3.StringUtils; @@ -15,7 +16,15 @@ import gnu.trove.set.hash.THashSet; import lance5057.tDefense.Reference; import lance5057.tDefense.TinkersDefense; import lance5057.tDefense.core.items.TDOreDictItem; -import lance5057.tDefense.util.TDMatHelper; +import lance5057.tDefense.core.library.TDMatHelper; +import lance5057.tDefense.core.materials.stats.ArmorMaterialStats; +import lance5057.tDefense.core.materials.stats.BaubleMaterialStats; +import lance5057.tDefense.core.materials.stats.ChestMaterialStats; +import lance5057.tDefense.core.materials.stats.FabricMaterialStats; +import lance5057.tDefense.core.materials.stats.FeetMaterialStats; +import lance5057.tDefense.core.materials.stats.HelmMaterialStats; +import lance5057.tDefense.core.materials.stats.LegsMaterialStats; +import lance5057.tDefense.core.materials.stats.ShieldMaterialStats; import net.minecraft.block.Block; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.init.Blocks; @@ -46,8 +55,8 @@ import slimeknights.tconstruct.library.materials.ExtraMaterialStats; import slimeknights.tconstruct.library.materials.HandleMaterialStats; import slimeknights.tconstruct.library.materials.HeadMaterialStats; import slimeknights.tconstruct.library.materials.Material; -//import slimeknights.tconstruct.library.materials.Material; import slimeknights.tconstruct.library.materials.MaterialTypes; +import slimeknights.tconstruct.library.tools.IToolPart; import slimeknights.tconstruct.library.utils.HarvestLevels; import slimeknights.tconstruct.shared.TinkerCommons; import slimeknights.tconstruct.shared.TinkerFluids; @@ -55,239 +64,245 @@ import slimeknights.tconstruct.smeltery.block.BlockMolten; import slimeknights.tconstruct.tools.TinkerMaterials; @Mod.EventBusSubscriber(modid = Reference.MOD_ID) -public class TDMaterials { +public class TDMaterials +{ // public static final List<Material> materials = Lists.newArrayList(); ArmorMaterialStats ams = new ArmorMaterialStats(0, 0, 0, 0, ""); - String SHIELD = ShieldMaterialStats.TYPE; - String HELM = ArmorMaterialStats.HelmMaterialStats.TYPE; - String CHEST = ArmorMaterialStats.ChestMaterialStats.TYPE; - String LEGS = ArmorMaterialStats.LegsMaterialStats.TYPE; - String BOOTS = ArmorMaterialStats.FeetMaterialStats.TYPE; - String BAUBLE = BaubleMaterialStats.TYPE; - - public static final Map<String, Material> materials = new THashMap<>(); - public static final Map<String, MaterialIntegration> materialIntegrations = new THashMap<>(); - public static final Collection<String> deferredMaterials = new THashSet<>(); - - public static final Map<String, Integer> colors = new THashMap(); - public static final Map<String, FluidMolten> fluids = new THashMap(); - - public static Material black; - public static Material red; - public static Material green; - public static Material brown; - public static Material blue; - public static Material purple; - public static Material cyan; - public static Material lightgray; - public static Material gray; - public static Material pink; - public static Material lime; - public static Material yellow; - public static Material lightblue; - public static Material magenta; - public static Material orange; - public static Material white; - - public static FluidMolten fluidVile = fluids.put("vile", - (FluidMolten) new FluidMolten("vile", 0x111111).setTemperature(0)); - public static FluidMolten fluidVibrant = fluids.put("vibrant", new FluidMolten("vibrant", 0x76ff00)); - public static FluidMolten fluidSlush = fluids.put("slush", - (FluidMolten) new FluidMolten("slush", 0xbfefff).setTemperature(0)); - public static FluidMolten fluidQuartz = fluids.put("quartz", - (FluidMolten) new FluidMolten("quartz", 0xdddddd).setTemperature(75)); - public static FluidMolten fluidChorusJuice = fluids.put("chorusjuice", new FluidMolten("chorusjuice", 0xd982ff)); - public static FluidMolten fluidDragonsBreath = fluids.put("dragonsbreath", - new FluidMolten("dragonsbreath", 0x7f00b7)); + String SHIELD = ShieldMaterialStats.TYPE; + String HELM = HelmMaterialStats.TYPE; + String CHEST = ChestMaterialStats.TYPE; + String LEGS = LegsMaterialStats.TYPE; + String BOOTS = FeetMaterialStats.TYPE; + String BAUBLE = BaubleMaterialStats.TYPE; + + public static final Map<String, Material> materials = new THashMap<>(); + public static final Map<String, MaterialIntegration> materialIntegrations = new THashMap<>(); + public static final Collection<String> deferredMaterials = new THashSet<>(); + + public static final Map<String, Integer> colors = new THashMap(); + public static final Map<String, FluidMolten> fluids = new THashMap(); + + public static Material black; + public static Material red; + public static Material green; + public static Material brown; + public static Material blue; + public static Material purple; + public static Material cyan; + public static Material lightgray; + public static Material gray; + public static Material pink; + public static Material lime; + public static Material yellow; + public static Material lightblue; + public static Material magenta; + public static Material orange; + public static Material white; + + public static FluidMolten fluidVile = fluids.put("vile", (FluidMolten) new FluidMolten("vile", 0x111111).setTemperature(0)); + public static FluidMolten fluidVibrant = fluids.put("vibrant", new FluidMolten("vibrant", 0x76ff00)); + public static FluidMolten fluidSlush = fluids.put("slush", (FluidMolten) new FluidMolten("slush", 0xbfefff).setTemperature(0)); + public static FluidMolten fluidQuartz = fluids.put("quartz", (FluidMolten) new FluidMolten("quartz", 0xdddddd).setTemperature(75)); + public static FluidMolten fluidChorusJuice = fluids.put("chorusjuice", new FluidMolten("chorusjuice", 0xd982ff)); + public static FluidMolten fluidDragonsBreath = fluids.put("dragonsbreath", new FluidMolten("dragonsbreath", 0x7f00b7)); List<TDMatHelper> materials_master = new ArrayList<>(); // Base List<TDMatHelper> materials_base = new ArrayList<>(Arrays.asList( - new TDMatHelper("aeonsteel", 0xa470e0, fluids.put("aeonsteel", new FluidMolten("aeonsteel", 0xa470e0)), - true).setHead(new HeadMaterialStats(500, 15.00f, 4.0f, HarvestLevels.COBALT)) - .setHandle(new HandleMaterialStats(1.1f, 0)).setExtra(new ExtraMaterialStats(50)) - .setShield(new ShieldMaterialStats(500 / 4, 85)) - .setBow(new BowMaterialStats(0.75f, 1.0f, 2.5f)) - .setHelm(ams.new HelmMaterialStats(500, 2, 2, 0f)) - .setChest(ams.new ChestMaterialStats(500, 6, 3, 0f)) - .setLegs(ams.new LegsMaterialStats(500, 5, 3, 0f)) - .setBoots(ams.new FeetMaterialStats(500, 3, 2, 0f)), - new TDMatHelper("queensgold", 0xdcff00, fluids.put("queensgold", new FluidMolten("queensgold", 0xdcff00)), - true).setHead(new HeadMaterialStats(70, 3.00f, 3.00f, HarvestLevels.IRON)) - .setHandle(new HandleMaterialStats(1.05f, -45)).setExtra(new ExtraMaterialStats(20)) - .setShield(new ShieldMaterialStats(70 / 4, 57)) - .setBow(new BowMaterialStats(1.1f, 1.0f, 0.5f)) - .setHelm(ams.new HelmMaterialStats(70, 2, 1, 20f)) - .setChest(ams.new ChestMaterialStats(70, 6, 2, 30f)) - .setLegs(ams.new LegsMaterialStats(70, 5, 2, 20f)) - .setBoots(ams.new FeetMaterialStats(70, 2, 1, 15f)), - new TDMatHelper("dogbearium", 0x6d3300, fluids.put("dogbearium", new FluidMolten("dogbearium", 0x6d3300)), - true).setHead(new HeadMaterialStats(150, 5.00f, 9.00f, HarvestLevels.DIAMOND)) - .setHandle(new HandleMaterialStats(0.85f, 75)).setExtra(new ExtraMaterialStats(75)) - .setShield(new ShieldMaterialStats(150 / 4, 75)) - .setBow(new BowMaterialStats(0.1f, 0.5f, 5.5f)) - .setHelm(ams.new HelmMaterialStats(150, 3, 3, -60f)) - .setChest(ams.new ChestMaterialStats(150, 8, 4, -60f)) - .setLegs(ams.new LegsMaterialStats(150, 6, 4, -60f)) - .setBoots(ams.new FeetMaterialStats(150, 3, 3, -60f)), - new TDMatHelper("sinisterium", 0x210000, - fluids.put("sinisterium", new FluidMolten("sinisterium", 0x210000)), true) - .setHead(new HeadMaterialStats(224, 5.00f, 5.00f, HarvestLevels.DIAMOND)) - .setHandle(new HandleMaterialStats(0.75f, 99)).setExtra(new ExtraMaterialStats(99)) - .setShield(new ShieldMaterialStats(224 / 4, 55)) - .setBow(new BowMaterialStats(2.1f, 1.6f, 7.2f)) - .setHelm(ams.new HelmMaterialStats(224, 2, 0, 9.5f)) - .setChest(ams.new ChestMaterialStats(224, 6, 0, 10.5f)) - .setLegs(ams.new LegsMaterialStats(224, 5, 0, 10.0f)) - .setBoots(ams.new FeetMaterialStats(224, 2, 0, 9.5f)), - new TDMatHelper("nihilite", 0x000021, fluids.put("nihilite", new FluidMolten("nihilite", 0x000021)), true) - .setHead(new HeadMaterialStats(400, 9.7f, 7.1f, HarvestLevels.COBALT)) - .setHandle(new HandleMaterialStats(0.9f, 70)).setExtra(new ExtraMaterialStats(74)) - .setShield(new ShieldMaterialStats(400 / 4, 95)).setBow(new BowMaterialStats(0.9f, 1.7f, -1f)) - .setHelm(ams.new HelmMaterialStats(400, 2, 0, 19)) - .setChest(ams.new ChestMaterialStats(400, 5, 0, 15)) - .setLegs(ams.new LegsMaterialStats(400, 4, 0, 15)) - .setBoots(ams.new FeetMaterialStats(400, 2, 0, 19)), - new TDMatHelper("orichalcum", 0xffc700, fluids.put("orichalcum", new FluidMolten("orichalcum", 0xffc700)), - true).setHead(new HeadMaterialStats(180, 5.3f, 6.23f, HarvestLevels.OBSIDIAN)) - .setHandle(new HandleMaterialStats(1.1f, 25)).setExtra(new ExtraMaterialStats(35)) - .setShield(new ShieldMaterialStats(180 / 4, 70)) - .setBow(new BowMaterialStats(1.9f, 1.9f, 2.3f)) - .setHelm(ams.new HelmMaterialStats(180, 2, 2, 20.5f)) - .setChest(ams.new ChestMaterialStats(180, 6, 3, 20.5f)) - .setLegs(ams.new LegsMaterialStats(180, 5, 3, 20.5f)) - .setBoots(ams.new FeetMaterialStats(180, 2, 3, 20.5f)), - new TDMatHelper("pandorium", 0x7f6a00, fluids.put("pandorium", new FluidMolten("pandorium", 0x7f6a00)), - true).setHead(new HeadMaterialStats(999, 10.2f, 8.72f, HarvestLevels.OBSIDIAN)) - .setHandle(new HandleMaterialStats(0.4f, 999)).setExtra(new ExtraMaterialStats(99)) - .setShield(new ShieldMaterialStats(999 / 4, 100)).setBow(new BowMaterialStats(3f, 0.9f, 9f)) - .setHelm(ams.new HelmMaterialStats(999, 3, 3, -70.0f)) - .setChest(ams.new ChestMaterialStats(999, 8, 4, -70.0f)) - .setLegs(ams.new LegsMaterialStats(999, 6, 4, -70.0f)) - .setBoots(ams.new FeetMaterialStats(999, 3, 3, -70.0f)), - new TDMatHelper("rosegold", 0xff9b84, fluids.put("rosegold", new FluidMolten("rosegold", 0xff9b84)), true) - .setHead(new HeadMaterialStats(99, 4f, 1f, HarvestLevels.STONE)) - .setHandle(new HandleMaterialStats(1.5f, -90)).setExtra(new ExtraMaterialStats(-90)) - .setShield(new ShieldMaterialStats(99 / 4, 24)).setBow(new BowMaterialStats(0.1f, 0.1f, -2f)) - .setHelm(ams.new HelmMaterialStats(99, 1, 0, 23.0f)) - .setChest(ams.new ChestMaterialStats(99, 4, 0, 23.0f)) - .setLegs(ams.new LegsMaterialStats(99, 3, 0, 23.0f)) - .setBoots(ams.new FeetMaterialStats(99, 1, 0, 23.0f)), - new TDMatHelper("platinum", 0xe8e8e8, fluids.put("platinum", new FluidMolten("platinum", 0xe8e8e8)), true) - .setHead(new HeadMaterialStats(99, 3.7f, 4f, HarvestLevels.IRON)) - .setHandle(new HandleMaterialStats(1.5f, -90)).setExtra(new ExtraMaterialStats(-90)) - .setShield(new ShieldMaterialStats(99 / 4, 14)).setBow(new BowMaterialStats(0.1f, 0.1f, -2f)) - .setHelm(ams.new HelmMaterialStats(99, 1, 1, 19.0f)) - .setChest(ams.new ChestMaterialStats(99, 4, 1, 19.0f)) - .setLegs(ams.new LegsMaterialStats(99, 3, 1, 19.0f)) - .setBoots(ams.new FeetMaterialStats(99, 1, 1, 19.0f)), - new TDMatHelper("brass", 0xdbb332, fluids.put("brass", new FluidMolten("brass", 0xdbb332)), true) - .setHead(new HeadMaterialStats(380, 5f, 3f, HarvestLevels.IRON)) - .setHandle(new HandleMaterialStats(0.85f, 90)).setExtra(new ExtraMaterialStats(75)) - .setShield(new ShieldMaterialStats(380 / 4, 50)).setBow(new BowMaterialStats(0.1f, 0.5f, -1f)) - .setHelm(ams.new HelmMaterialStats(380, 2, 1, 4.5f)) - .setChest(ams.new ChestMaterialStats(380, 3, 2, 4.5f)) - .setLegs(ams.new LegsMaterialStats(380, 2, 2, 4.5f)) - .setBoots(ams.new FeetMaterialStats(380, 2, 2, 4.5f)), - new TDMatHelper("silver", 0x9e9e9e, new FluidMolten("silver", 0x9e9e9e), false), - new TDMatHelper("gold", 0xfff428, TinkerFluids.gold, true).setIngot(Items.GOLD_INGOT) - .setNugget(Items.GOLD_NUGGET).setHead(new HeadMaterialStats(100, 1f, 1f, HarvestLevels.STONE)) - .setHandle(new HandleMaterialStats(0.25f, 10)).setExtra(new ExtraMaterialStats(25)) - .setShield(new ShieldMaterialStats(100 / 4, 14)).setBow(new BowMaterialStats(0.2f, 0.4f, -1f)) - .setHelm(ams.new HelmMaterialStats(100, 1, 0, 33f)) - .setChest(ams.new ChestMaterialStats(100, 4, 0, 33f)) - .setLegs(ams.new LegsMaterialStats(100, 3, 0, 33f)) - .setBoots(ams.new FeetMaterialStats(100, 1, 0, 33f)), - new TDMatHelper("valyriansteel", 0xe2d9e2, - fluids.put("valyriansteel", new FluidMolten("valyriansteel", 0xe2d9e2)), true) - .setHead(new HeadMaterialStats(610, 7f, 7f, HarvestLevels.OBSIDIAN)) - .setHandle(new HandleMaterialStats(0.9f, 180)).setExtra(new ExtraMaterialStats(125)) - .setShield(new ShieldMaterialStats(610 / 4, 85)) - .setBow(new BowMaterialStats(1.6f, 1.5f, 3f)) - .setHelm(ams.new HelmMaterialStats(610, 3, 3, 0)) - .setChest(ams.new ChestMaterialStats(610, 7, 4, 0)) - .setLegs(ams.new LegsMaterialStats(610, 6, 2, 0)) - .setBoots(ams.new FeetMaterialStats(610, 3, 3, 0)), - new TDMatHelper("froststeel", 0xc6dcff, fluids.put("froststeel", new FluidMolten("froststeel", 0xc6dcff)), - true).setHead(new HeadMaterialStats(610, 7f, 7f, HarvestLevels.OBSIDIAN)) - .setHandle(new HandleMaterialStats(1.1f, 110)).setExtra(new ExtraMaterialStats(125)) - .setShield(new ShieldMaterialStats(610 / 4, 85)) - .setBow(new BowMaterialStats(1.6f, 1.5f, 3f)) - .setHelm(ams.new HelmMaterialStats(610, 2, 2, 0)) - .setChest(ams.new ChestMaterialStats(610, 6, 3, 0)) - .setLegs(ams.new LegsMaterialStats(610, 5, 2, 0)) - .setBoots(ams.new FeetMaterialStats(610, 3, 1, 0)), - new TDMatHelper("pureardite", 0xff4300, fluids.put("pureardite", new FluidMolten("pureardite", 0xff4300)), - true).setHead(new HeadMaterialStats(1200, 3.5f, 3.6f, HarvestLevels.COBALT)) - .setHandle(new HandleMaterialStats(1.4f, -200)).setExtra(new ExtraMaterialStats(450)) - .setShield(new ShieldMaterialStats(1200 / 4, 33)) - .setBow(new BowMaterialStats(0.45f, 0.8f, 1f)), - new TDMatHelper("purecobalt", 0x547eff, fluids.put("purecobalt", new FluidMolten("purecobalt", 0x547eff)), - true).setHead(new HeadMaterialStats(780, 13f, 4.1f, HarvestLevels.COBALT)) - .setHandle(new HandleMaterialStats(1.4f, 100)).setExtra(new ExtraMaterialStats(300)) - .setShield(new ShieldMaterialStats(780 / 4, 33)) - .setBow(new BowMaterialStats(0.3f, 1.3f, 3f)), - new TDMatHelper("puremanyullyn", 0xd044ff, - fluids.put("puremanyullyn", new FluidMolten("puremanyullyn", 0xd044ff)), true) - .setHead(new HeadMaterialStats(820, 7.02f, 9.1f, HarvestLevels.COBALT)) - .setHandle(new HandleMaterialStats(0.5f, 350)).setExtra(new ExtraMaterialStats(350)) - .setShield(new ShieldMaterialStats(820 / 4, 33)) - .setBow(new BowMaterialStats(0.65f, 1.2f, 4f)), - new TDMatHelper("glass", 0xffffff, TinkerFluids.glass, true) - .setHead(new HeadMaterialStats(6, 4f, 7f, HarvestLevels.STONE)) - .setHandle(new HandleMaterialStats(0.1f, -45)).setExtra(new ExtraMaterialStats(-45)) - .setShield(new ShieldMaterialStats(6 / 4, 33)).setBow(new BowMaterialStats(0.1f, 0.1f, -2f)), - new TDMatHelper("ice", 0xdcff00, false), - new TDMatHelper("purifiedgold", 0xffe242, - fluids.put("purifiedgold", new FluidMolten("purifiedgold", 0xffe242)), true), - new TDMatHelper("purifiedsilver", 0xefefef, - fluids.put("purifiedsilver", new FluidMolten("purifiedsilver", 0xefefef)), true))); + new TDMatHelper("aeonsteel", 0xa470e0, fluids.put("aeonsteel", new FluidMolten("aeonsteel", 0xa470e0)), true).setHead(new HeadMaterialStats(500, 15.00f, 4.0f, HarvestLevels.COBALT)) + .setHandle(new HandleMaterialStats(1.1f, 0)) + .setExtra(new ExtraMaterialStats(50)) + .setShield(new ShieldMaterialStats(500 / 4, 85)) + .setBow(new BowMaterialStats(0.75f, 1.0f, 2.5f)) + .setHelm(new HelmMaterialStats(500, 2, 2, 0f)) + .setChest(new ChestMaterialStats(500, 6, 3, 0f)) + .setLegs(new LegsMaterialStats(500, 5, 3, 0f)) + .setBoots(new FeetMaterialStats(500, 3, 2, 0f)), + new TDMatHelper("queensgold", 0xdcff00, fluids.put("queensgold", new FluidMolten("queensgold", 0xdcff00)), true).setHead(new HeadMaterialStats(70, 3.00f, 3.00f, HarvestLevels.IRON)) + .setHandle(new HandleMaterialStats(1.05f, -45)) + .setExtra(new ExtraMaterialStats(20)) + .setShield(new ShieldMaterialStats(70 / 4, 57)) + .setBow(new BowMaterialStats(1.1f, 1.0f, 0.5f)) + .setHelm(new HelmMaterialStats(70, 2, 1, 20f)) + .setChest(new ChestMaterialStats(70, 6, 2, 30f)) + .setLegs(new LegsMaterialStats(70, 5, 2, 20f)) + .setBoots(new FeetMaterialStats(70, 2, 1, 15f)), + new TDMatHelper("dogbearium", 0x6d3300, fluids.put("dogbearium", new FluidMolten("dogbearium", 0x6d3300)), true).setHead(new HeadMaterialStats(150, 5.00f, 9.00f, HarvestLevels.DIAMOND)) + .setHandle(new HandleMaterialStats(0.85f, 75)) + .setExtra(new ExtraMaterialStats(75)) + .setShield(new ShieldMaterialStats(150 / 4, 75)) + .setBow(new BowMaterialStats(0.1f, 0.5f, 5.5f)) + .setHelm(new HelmMaterialStats(150, 3, 3, -60f)) + .setChest(new ChestMaterialStats(150, 8, 4, -60f)) + .setLegs(new LegsMaterialStats(150, 6, 4, -60f)) + .setBoots(new FeetMaterialStats(150, 3, 3, -60f)), + new TDMatHelper("sinisterium", 0x210000, fluids.put("sinisterium", new FluidMolten("sinisterium", 0x210000)), true).setHead(new HeadMaterialStats(224, 5.00f, 5.00f, HarvestLevels.DIAMOND)) + .setHandle(new HandleMaterialStats(0.75f, 99)) + .setExtra(new ExtraMaterialStats(99)) + .setShield(new ShieldMaterialStats(224 / 4, 55)) + .setBow(new BowMaterialStats(2.1f, 1.6f, 7.2f)) + .setHelm(new HelmMaterialStats(224, 2, 0, 9.5f)) + .setChest(new ChestMaterialStats(224, 6, 0, 10.5f)) + .setLegs(new LegsMaterialStats(224, 5, 0, 10.0f)) + .setBoots(new FeetMaterialStats(224, 2, 0, 9.5f)), + new TDMatHelper("nihilite", 0x000021, fluids.put("nihilite", new FluidMolten("nihilite", 0x000021)), true).setHead(new HeadMaterialStats(400, 9.7f, 7.1f, HarvestLevels.COBALT)) + .setHandle(new HandleMaterialStats(0.9f, 70)) + .setExtra(new ExtraMaterialStats(74)) + .setShield(new ShieldMaterialStats(400 / 4, 95)) + .setBow(new BowMaterialStats(0.9f, 1.7f, -1f)) + .setHelm(new HelmMaterialStats(400, 2, 0, 19)) + .setChest(new ChestMaterialStats(400, 5, 0, 15)) + .setLegs(new LegsMaterialStats(400, 4, 0, 15)) + .setBoots(new FeetMaterialStats(400, 2, 0, 19)), + new TDMatHelper("orichalcum", 0xffc700, fluids.put("orichalcum", new FluidMolten("orichalcum", 0xffc700)), true).setHead(new HeadMaterialStats(180, 5.3f, 6.23f, HarvestLevels.OBSIDIAN)) + .setHandle(new HandleMaterialStats(1.1f, 25)) + .setExtra(new ExtraMaterialStats(35)) + .setShield(new ShieldMaterialStats(180 / 4, 70)) + .setBow(new BowMaterialStats(1.9f, 1.9f, 2.3f)) + .setHelm(new HelmMaterialStats(180, 2, 2, 20.5f)) + .setChest(new ChestMaterialStats(180, 6, 3, 20.5f)) + .setLegs(new LegsMaterialStats(180, 5, 3, 20.5f)) + .setBoots(new FeetMaterialStats(180, 2, 3, 20.5f)), + new TDMatHelper("pandorium", 0x7f6a00, fluids.put("pandorium", new FluidMolten("pandorium", 0x7f6a00)), true).setHead(new HeadMaterialStats(999, 10.2f, 8.72f, HarvestLevels.OBSIDIAN)) + .setHandle(new HandleMaterialStats(0.4f, 999)) + .setExtra(new ExtraMaterialStats(99)) + .setShield(new ShieldMaterialStats(999 / 4, 100)) + .setBow(new BowMaterialStats(3f, 0.9f, 9f)) + .setHelm(new HelmMaterialStats(999, 3, 3, -70.0f)) + .setChest(new ChestMaterialStats(999, 8, 4, -70.0f)) + .setLegs(new LegsMaterialStats(999, 6, 4, -70.0f)) + .setBoots(new FeetMaterialStats(999, 3, 3, -70.0f)), + new TDMatHelper("rosegold", 0xff9b84, fluids.put("rosegold", new FluidMolten("rosegold", 0xff9b84)), true).setHead(new HeadMaterialStats(99, 4f, 1f, HarvestLevels.STONE)) + .setHandle(new HandleMaterialStats(1.5f, -90)) + .setExtra(new ExtraMaterialStats(-90)) + .setShield(new ShieldMaterialStats(99 / 4, 24)) + .setBow(new BowMaterialStats(0.1f, 0.1f, -2f)) + .setHelm(new HelmMaterialStats(99, 1, 0, 23.0f)) + .setChest(new ChestMaterialStats(99, 4, 0, 23.0f)) + .setLegs(new LegsMaterialStats(99, 3, 0, 23.0f)) + .setBoots(new FeetMaterialStats(99, 1, 0, 23.0f)), + new TDMatHelper("platinum", 0xe8e8e8, fluids.put("platinum", new FluidMolten("platinum", 0xe8e8e8)), true).setHead(new HeadMaterialStats(99, 3.7f, 4f, HarvestLevels.IRON)) + .setHandle(new HandleMaterialStats(1.5f, -90)) + .setExtra(new ExtraMaterialStats(-90)) + .setShield(new ShieldMaterialStats(99 / 4, 14)) + .setBow(new BowMaterialStats(0.1f, 0.1f, -2f)) + .setHelm(new HelmMaterialStats(99, 1, 1, 19.0f)) + .setChest(new ChestMaterialStats(99, 4, 1, 19.0f)) + .setLegs(new LegsMaterialStats(99, 3, 1, 19.0f)) + .setBoots(new FeetMaterialStats(99, 1, 1, 19.0f)), + new TDMatHelper("brass", 0xdbb332, fluids.put("brass", new FluidMolten("brass", 0xdbb332)), true).setHead(new HeadMaterialStats(380, 5f, 3f, HarvestLevels.IRON)) + .setHandle(new HandleMaterialStats(0.85f, 90)) + .setExtra(new ExtraMaterialStats(75)) + .setShield(new ShieldMaterialStats(380 / 4, 50)) + .setBow(new BowMaterialStats(0.1f, 0.5f, -1f)) + .setHelm(new HelmMaterialStats(380, 2, 1, 4.5f)) + .setChest(new ChestMaterialStats(380, 3, 2, 4.5f)) + .setLegs(new LegsMaterialStats(380, 2, 2, 4.5f)) + .setBoots(new FeetMaterialStats(380, 2, 2, 4.5f)), + new TDMatHelper("silver", 0x9e9e9e, new FluidMolten("silver", 0x9e9e9e), false), + new TDMatHelper("gold", 0xfff428, TinkerFluids.gold, true).setIngot(Items.GOLD_INGOT) + .setNugget(Items.GOLD_NUGGET) + .setHead(new HeadMaterialStats(100, 1f, 1f, HarvestLevels.STONE)) + .setHandle(new HandleMaterialStats(0.25f, 10)) + .setExtra(new ExtraMaterialStats(25)) + .setShield(new ShieldMaterialStats(100 / 4, 14)) + .setBow(new BowMaterialStats(0.2f, 0.4f, -1f)) + .setHelm(new HelmMaterialStats(100, 1, 0, 33f)) + .setChest(new ChestMaterialStats(100, 4, 0, 33f)) + .setLegs(new LegsMaterialStats(100, 3, 0, 33f)) + .setBoots(new FeetMaterialStats(100, 1, 0, 33f)), + new TDMatHelper("valyriansteel", 0xe2d9e2, fluids.put("valyriansteel", new FluidMolten("valyriansteel", 0xe2d9e2)), true).setHead(new HeadMaterialStats(610, 7f, 7f, HarvestLevels.OBSIDIAN)) + .setHandle(new HandleMaterialStats(0.9f, 180)) + .setExtra(new ExtraMaterialStats(125)) + .setShield(new ShieldMaterialStats(610 / 4, 85)) + .setBow(new BowMaterialStats(1.6f, 1.5f, 3f)) + .setHelm(new HelmMaterialStats(610, 3, 3, 0)) + .setChest(new ChestMaterialStats(610, 7, 4, 0)) + .setLegs(new LegsMaterialStats(610, 6, 2, 0)) + .setBoots(new FeetMaterialStats(610, 3, 3, 0)), + new TDMatHelper("froststeel", 0xc6dcff, fluids.put("froststeel", new FluidMolten("froststeel", 0xc6dcff)), true).setHead(new HeadMaterialStats(610, 7f, 7f, HarvestLevels.OBSIDIAN)) + .setHandle(new HandleMaterialStats(1.1f, 110)) + .setExtra(new ExtraMaterialStats(125)) + .setShield(new ShieldMaterialStats(610 / 4, 85)) + .setBow(new BowMaterialStats(1.6f, 1.5f, 3f)) + .setHelm(new HelmMaterialStats(610, 2, 2, 0)) + .setChest(new ChestMaterialStats(610, 6, 3, 0)) + .setLegs(new LegsMaterialStats(610, 5, 2, 0)) + .setBoots(new FeetMaterialStats(610, 3, 1, 0)), + new TDMatHelper("pureardite", 0xff4300, fluids.put("pureardite", new FluidMolten("pureardite", 0xff4300)), true).setHead(new HeadMaterialStats(1200, 3.5f, 3.6f, HarvestLevels.COBALT)) + .setHandle(new HandleMaterialStats(1.4f, -200)) + .setExtra(new ExtraMaterialStats(450)) + .setShield(new ShieldMaterialStats(1200 / 4, 33)) + .setBow(new BowMaterialStats(0.45f, 0.8f, 1f)), + new TDMatHelper("purecobalt", 0x547eff, fluids.put("purecobalt", new FluidMolten("purecobalt", 0x547eff)), true).setHead(new HeadMaterialStats(780, 13f, 4.1f, HarvestLevels.COBALT)) + .setHandle(new HandleMaterialStats(1.4f, 100)) + .setExtra(new ExtraMaterialStats(300)) + .setShield(new ShieldMaterialStats(780 / 4, 33)) + .setBow(new BowMaterialStats(0.3f, 1.3f, 3f)), + new TDMatHelper("puremanyullyn", 0xd044ff, fluids.put("puremanyullyn", new FluidMolten("puremanyullyn", 0xd044ff)), true).setHead(new HeadMaterialStats(820, 7.02f, 9.1f, HarvestLevels.COBALT)) + .setHandle(new HandleMaterialStats(0.5f, 350)) + .setExtra(new ExtraMaterialStats(350)) + .setShield(new ShieldMaterialStats(820 / 4, 33)) + .setBow(new BowMaterialStats(0.65f, 1.2f, 4f)), + new TDMatHelper("glass", 0xffffff, TinkerFluids.glass, true).setHead(new HeadMaterialStats(6, 4f, 7f, HarvestLevels.STONE)) + .setHandle(new HandleMaterialStats(0.1f, -45)) + .setExtra(new ExtraMaterialStats(-45)) + .setShield(new ShieldMaterialStats(6 / 4, 33)) + .setBow(new BowMaterialStats(0.1f, 0.1f, -2f)), + new TDMatHelper("ice", 0xdcff00, false), + new TDMatHelper("purifiedgold", 0xffe242, fluids.put("purifiedgold", new FluidMolten("purifiedgold", 0xffe242)), true), + new TDMatHelper("purifiedsilver", 0xefefef, fluids.put("purifiedsilver", new FluidMolten("purifiedsilver", 0xefefef)), true))); + // + // new TDMatHelper("white cloth", 0xDDDDDD, null, true, true, + // false).setGem(new ItemStack(Blocks.WOOL, 0, 1)).setCloth(new + // ClothMaterialStats(100, 0, 0, 25)), + // new TDMatHelper("orange cloth", 0xDB7D3E, null, true, true, + // false).setGem(new ItemStack(Blocks.WOOL, 0, 1)).setCloth(new + // ClothMaterialStats(100, 0, 0, 25)) // Jokes - List<TDMatHelper> materials_joke = new ArrayList<>(Arrays.asList( - new TDMatHelper("cheese", 0xffe900, fluids.put("cheese", new FluidMolten("cheese", 0xffe900)), true), - new TDMatHelper("bread", 0x89732a), new TDMatHelper("melon", 0xff77a4))); + List<TDMatHelper> materials_joke = new ArrayList<>(Arrays.asList(new TDMatHelper("cheese", 0xffe900, fluids.put("cheese", new FluidMolten("cheese", 0xffe900)), true), + new TDMatHelper("bread", 0x89732a), + new TDMatHelper("melon", 0xff77a4))); // Holiday - List<TDMatHelper> materials_xmas = new ArrayList<>( - Arrays.asList(new TDMatHelper("redcandy", 0xff0000).setNugget(TinkersDefense.holiday.item_redmintcane), - new TDMatHelper("greencandy", 0x00ff00).setNugget(TinkersDefense.holiday.item_greenmintcane))); + List<TDMatHelper> materials_xmas = new ArrayList<>(Arrays.asList(new TDMatHelper("redcandy", 0xff0000).setNugget(TinkersDefense.holiday.item_redmintcane), + new TDMatHelper("greencandy", 0x00ff00).setNugget(TinkersDefense.holiday.item_greenmintcane))); // Gems List<TDMatHelper> materials_gems = new ArrayList<>(Arrays.asList(new TDMatHelper("sapphire", 0x6e00ff), - new TDMatHelper("ruby", 0xff0061, true, true), - new TDMatHelper("emerald", 0x16cc4f, true, true).setGem(Items.EMERALD), - new TDMatHelper("diamond", 0x96ecf2, true, true).setGem(Items.DIAMOND), - new TDMatHelper("starsapphire", 0x6e00ff, true, true), new TDMatHelper("starruby", 0xff0061, true, true), - new TDMatHelper("citrine", 0xffe877, true, true), new TDMatHelper("ghasttear", 0xe8fbff, true, true), - new TDMatHelper("quartz", 0xede8e8, true, true), new TDMatHelper("glowstonecrystal", 0xfff956, true, true), - new TDMatHelper("enderpearl", 0x2bad3a, true, true), new TDMatHelper("amethyst", 0xb436e2, true, true), - new TDMatHelper("lapis", 0x4349bc, true, true).setGem(new ItemStack(Items.DYE, 1, 4)), - new TDMatHelper("topaz", 0xffc551, true, true), new TDMatHelper("garnet", 0x9e1c1c, true, true), - new TDMatHelper("opal", 0xe2e2e2, true, true), new TDMatHelper("tanzanite", 0x8860e5, true, true), - new TDMatHelper("amber", 0xdba827, true, true))); + new TDMatHelper("ruby", 0xff0061, true, true), + new TDMatHelper("emerald", 0x16cc4f, true, true).setGem(Items.EMERALD), + new TDMatHelper("diamond", 0x96ecf2, true, true).setGem(Items.DIAMOND), + new TDMatHelper("starsapphire", 0x6e00ff, true, true), + new TDMatHelper("starruby", 0xff0061, true, true), + new TDMatHelper("citrine", 0xffe877, true, true), + new TDMatHelper("ghasttear", 0xe8fbff, true, true), + new TDMatHelper("quartz", 0xede8e8, true, true), + new TDMatHelper("glowstonecrystal", 0xfff956, true, true), + new TDMatHelper("enderpearl", 0x2bad3a, true, true), + new TDMatHelper("amethyst", 0xb436e2, true, true), + new TDMatHelper("lapis", 0x4349bc, true, true).setGem(new ItemStack(Items.DYE, 1, 4)), + new TDMatHelper("topaz", 0xffc551, true, true), + new TDMatHelper("garnet", 0x9e1c1c, true, true), + new TDMatHelper("opal", 0xe2e2e2, true, true), + new TDMatHelper("tanzanite", 0x8860e5, true, true), + new TDMatHelper("amber", 0xdba827, true, true))); // Cornucopia - List<TDMatHelper> materials_cornucopia = new ArrayList<>(Arrays.asList( - new TDMatHelper("gallite", 0x198c09, fluids.put("gallite", new FluidMolten("gallite", 0x198c09)), true), - new TDMatHelper("sundrop", 0xfff987, fluids.put("sundrop", new FluidMolten("sundrop", 0xfff987)), true), - new TDMatHelper("voidite", 0x450059, fluids.put("voidite", new FluidMolten("voidite", 0x450059)), true), - new TDMatHelper("solarium", 0xffff31, fluids.put("solarium", new FluidMolten("solarium", 0xffff31)), true), - new TDMatHelper("dragonsteel", 0x55914d, - fluids.put("dragonsteel", new FluidMolten("dragonsteel", 0x55914d)), true), - new TDMatHelper("blacksteel", 0x383838, fluids.put("blacksteel", new FluidMolten("blacksteel", 0x383838)), - true), - new TDMatHelper("abyssalium", 0x000633, fluids.put("abyssalium", new FluidMolten("abyssalium", 0x000633)), - true), - new TDMatHelper("depthsilver", 0x646782, - fluids.put("depthsilver", new FluidMolten("depthsilver", 0x646782)), true), - new TDMatHelper("moonsilver", 0x777777, fluids.put("moonsilver", new FluidMolten("moonsilver", 0x777777)), - true), - new TDMatHelper("novagold", 0xffc300, fluids.put("novagold", new FluidMolten("novagold", 0xffc300)), - true))); + List<TDMatHelper> materials_cornucopia = new ArrayList<>(Arrays.asList(new TDMatHelper("gallite", 0x198c09, fluids.put("gallite", new FluidMolten("gallite", 0x198c09)), true), + new TDMatHelper("sundrop", 0xfff987, fluids.put("sundrop", new FluidMolten("sundrop", 0xfff987)), true), + new TDMatHelper("voidite", 0x450059, fluids.put("voidite", new FluidMolten("voidite", 0x450059)), true), + new TDMatHelper("solarium", 0xffff31, fluids.put("solarium", new FluidMolten("solarium", 0xffff31)), true), + new TDMatHelper("dragonsteel", 0x55914d, fluids.put("dragonsteel", new FluidMolten("dragonsteel", 0x55914d)), true), + new TDMatHelper("blacksteel", 0x383838, fluids.put("blacksteel", new FluidMolten("blacksteel", 0x383838)), true), + new TDMatHelper("abyssalium", 0x000633, fluids.put("abyssalium", new FluidMolten("abyssalium", 0x000633)), true), + new TDMatHelper("depthsilver", 0x646782, fluids.put("depthsilver", new FluidMolten("depthsilver", 0x646782)), true), + new TDMatHelper("moonsilver", 0x777777, fluids.put("moonsilver", new FluidMolten("moonsilver", 0x777777)), true), + new TDMatHelper("novagold", 0xffc300, fluids.put("novagold", new FluidMolten("novagold", 0xffc300)), true))); // // Blood Magic // List<String> materials_bm = new ArrayList<>( // Arrays.asList("blankslate", "reinforcedslate", "imbued", "demonic", @@ -302,11 +317,11 @@ public class TDMaterials { // List<String> materials_pam = new // ArrayList<>(Arrays.asList("hardenedleather")); - public static TDOreDictItem ingot; - public static TDOreDictItem dust; - public static TDOreDictItem nugget; - public static TDOreDictItem grain; - public static TDOreDictItem gem; + public static TDOreDictItem ingot; + public static TDOreDictItem dust; + public static TDOreDictItem nugget; + public static TDOreDictItem grain; + public static TDOreDictItem gem; // public static final AbstractTrait axelover = new TraitAxeLover(); // public static final AbstractTrait dulling = new TraitDulling(); @@ -314,39 +329,46 @@ public class TDMaterials { // public static final AbstractTrait barbed = new TraitBarbed(); // public static final AbstractTrait dogtoy = new TraitDogToy(); - static ArrayList<Item> itemList = new ArrayList<Item>(); - static ArrayList<Block> blockList = new ArrayList<Block>(); + static ArrayList<Item> itemList = new ArrayList<Item>(); + static ArrayList<Block> blockList = new ArrayList<Block>(); - private static Material mat(String name, int color) { + private static Material mat(String name, int color) + { Material mat = new Material(name, color); // materials.add(mat); return mat; } - List<String> getMatNames(List<TDMatHelper> mats) { + List<String> getMatNames(List<TDMatHelper> mats) + { List<String> r = new ArrayList<String>(); - for (TDMatHelper m : mats) { + for (TDMatHelper m : mats) + { r.add(m.name); } return r; } - List<Integer> getMatColors(List<TDMatHelper> mats) { + List<Integer> getMatColors(List<TDMatHelper> mats) + { List<Integer> r = new ArrayList<Integer>(); - for (TDMatHelper m : mats) { + for (TDMatHelper m : mats) + { r.add(m.color); } return r; } - List<FluidMolten> getMatFluids(List<TDMatHelper> mats) { + List<FluidMolten> getMatFluids(List<TDMatHelper> mats) + { List<FluidMolten> r = new ArrayList<FluidMolten>(); - for (TDMatHelper m : mats) { + for (TDMatHelper m : mats) + { r.add(m.fluid); } @@ -354,18 +376,19 @@ public class TDMaterials { } @Subscribe - public void preInit(FMLPreInitializationEvent event) { + public void preInit(FMLPreInitializationEvent event) + { if (TinkersDefense.config.materials.enableBaseMaterials) this.materials_master.addAll(materials_base); -// if (TinkersDefense.config.materials.enableJokeMaterials) -// this.materials_master.addAll(this.materials_joke); -// if (TinkersDefense.config.materials.enableHolidayMaterials) -// this.materials_master.addAll(materials_xmas); -// if (TinkersDefense.config.materials.enableGemMaterials) -// this.materials_master.addAll(materials_gems); -// if (TinkersDefense.config.materials.enableCornucopiaMaterials) -// this.materials_master.addAll(materials_cornucopia); + // if (TinkersDefense.config.materials.enableJokeMaterials) + // this.materials_master.addAll(this.materials_joke); + // if (TinkersDefense.config.materials.enableHolidayMaterials) + // this.materials_master.addAll(materials_xmas); + // if (TinkersDefense.config.materials.enableGemMaterials) + // this.materials_master.addAll(materials_gems); + // if (TinkersDefense.config.materials.enableCornucopiaMaterials) + // this.materials_master.addAll(materials_cornucopia); // if (TinkersDefense.config.materials.enableTwilightForestMaterials) // this.materials_master.addAll(materials_tf); // if (TinkersDefense.config.materials.enableBloodMagicMaterials) @@ -373,281 +396,283 @@ public class TDMaterials { // if (TinkersDefense.config.materials.enableHarvestCraftMaterials) // this.materials_master.addAll(materials_pam); - nugget = new TDOreDictItem("nugget", getMatNames(materials_master), getMatColors(materials_master)); - dust = new TDOreDictItem("dust", getMatNames(materials_master), getMatColors(materials_master)); - grain = new TDOreDictItem("grain", getMatNames(materials_master), getMatColors(materials_master)); - - List<TDMatHelper> gemMaster = new ArrayList<TDMatHelper>(); - List<TDMatHelper> ingotMaster = new ArrayList<TDMatHelper>(); - - for (TDMatHelper i : materials_master) { - if (i.isGem) - gemMaster.add(i); - else - ingotMaster.add(i); - } - - gem = new TDOreDictItem("gem", getMatNames(gemMaster), getMatColors(gemMaster)); - ingot = new TDOreDictItem("ingot", getMatNames(ingotMaster), getMatColors(ingotMaster)); - - registerClothMaterials(); - Material.UNKNOWN.addStats(new ShieldMaterialStats(35, 33)); - Material.UNKNOWN.addStats(ams.new HelmMaterialStats(35, 1, 0, 0)); - Material.UNKNOWN.addStats(ams.new ChestMaterialStats(35, 1, 0, 0)); - Material.UNKNOWN.addStats(ams.new LegsMaterialStats(35, 1, 0, 0)); - Material.UNKNOWN.addStats(ams.new FeetMaterialStats(35, 1, 0, 0)); - Material.UNKNOWN.addStats(ams.new ClothMaterialStats(35, 0, 0, 0)); + Material.UNKNOWN.addStats(new HelmMaterialStats(35, 1, 0, 0)); + Material.UNKNOWN.addStats(new ChestMaterialStats(35, 1, 0, 0)); + Material.UNKNOWN.addStats(new LegsMaterialStats(35, 1, 0, 0)); + Material.UNKNOWN.addStats(new FeetMaterialStats(35, 1, 0, 0)); + Material.UNKNOWN.addStats(new FabricMaterialStats(35, 0, 0, 0)); Material.UNKNOWN.addStats(new BaubleMaterialStats(35)); - TinkerRegistry.addMaterialStats(this.white, ams.new ClothMaterialStats(100, 10, 0, 25)); - TinkerRegistry.addMaterialStats(this.black, ams.new ClothMaterialStats(100, 10, 0, 25)); - TinkerRegistry.addMaterialStats(this.blue, ams.new ClothMaterialStats(100, 10, 0, 25)); - TinkerRegistry.addMaterialStats(this.brown, ams.new ClothMaterialStats(100, 10, 0, 25)); - TinkerRegistry.addMaterialStats(this.cyan, ams.new ClothMaterialStats(100, 10, 0, 25)); - TinkerRegistry.addMaterialStats(this.gray, ams.new ClothMaterialStats(100, 10, 0, 25)); - TinkerRegistry.addMaterialStats(this.green, ams.new ClothMaterialStats(100, 10, 0, 25)); - TinkerRegistry.addMaterialStats(this.lightblue, ams.new ClothMaterialStats(100, 10, 0, 25)); - TinkerRegistry.addMaterialStats(this.lightgray, ams.new ClothMaterialStats(100, 10, 0, 25)); - TinkerRegistry.addMaterialStats(this.lime, ams.new ClothMaterialStats(100, 10, 0, 25)); - TinkerRegistry.addMaterialStats(this.magenta, ams.new ClothMaterialStats(100, 10, 0, 25)); - TinkerRegistry.addMaterialStats(this.orange, ams.new ClothMaterialStats(100, 10, 0, 25)); - TinkerRegistry.addMaterialStats(this.pink, ams.new ClothMaterialStats(100, 10, 0, 25)); - TinkerRegistry.addMaterialStats(this.purple, ams.new ClothMaterialStats(100, 10, 0, 25)); - TinkerRegistry.addMaterialStats(this.red, ams.new ClothMaterialStats(100, 10, 0, 25)); - TinkerRegistry.addMaterialStats(this.yellow, ams.new ClothMaterialStats(100, 10, 0, 25)); + registerClothMaterials(); TinkerRegistry.addMaterialStats(TinkerMaterials.wood, new ShieldMaterialStats(35, 25)); - TinkerRegistry.addMaterialStats(TinkerMaterials.wood, ams.new HelmMaterialStats(35, 1, 0, 0)); - TinkerRegistry.addMaterialStats(TinkerMaterials.wood, ams.new ChestMaterialStats(35, 3, 0, 0)); - TinkerRegistry.addMaterialStats(TinkerMaterials.wood, ams.new LegsMaterialStats(35, 2, 0, 0)); - TinkerRegistry.addMaterialStats(TinkerMaterials.wood, ams.new FeetMaterialStats(35, 1, 0, 0)); + TinkerRegistry.addMaterialStats(TinkerMaterials.wood, new HelmMaterialStats(35, 1, 0, 0)); + TinkerRegistry.addMaterialStats(TinkerMaterials.wood, new ChestMaterialStats(35, 3, 0, 0)); + TinkerRegistry.addMaterialStats(TinkerMaterials.wood, new LegsMaterialStats(35, 2, 0, 0)); + TinkerRegistry.addMaterialStats(TinkerMaterials.wood, new FeetMaterialStats(35, 1, 0, 0)); // TinkerMaterials.wood.addTrait(axelover, SHIELD); TinkerRegistry.addMaterialStats(TinkerMaterials.stone, new ShieldMaterialStats(120, 30)); - TinkerRegistry.addMaterialStats(TinkerMaterials.stone, ams.new HelmMaterialStats(120, 2, 0, 0)); - TinkerRegistry.addMaterialStats(TinkerMaterials.stone, ams.new ChestMaterialStats(120, 4, 0, 0)); - TinkerRegistry.addMaterialStats(TinkerMaterials.stone, ams.new LegsMaterialStats(120, 3, 0, 0)); - TinkerRegistry.addMaterialStats(TinkerMaterials.stone, ams.new FeetMaterialStats(120, 2, 0, 0)); - //TinkerRegistry.addMaterialTrait(TinkerMaterials.stone, dulling, SHIELD); + TinkerRegistry.addMaterialStats(TinkerMaterials.stone, new HelmMaterialStats(120, 2, 0, 0)); + TinkerRegistry.addMaterialStats(TinkerMaterials.stone, new ChestMaterialStats(120, 4, 0, 0)); + TinkerRegistry.addMaterialStats(TinkerMaterials.stone, new LegsMaterialStats(120, 3, 0, 0)); + TinkerRegistry.addMaterialStats(TinkerMaterials.stone, new FeetMaterialStats(120, 2, 0, 0)); + // TinkerRegistry.addMaterialTrait(TinkerMaterials.stone, dulling, + // SHIELD); // TinkerMaterials.stone.addTrait(dulling, SHIELD); TinkerRegistry.addMaterialStats(TinkerMaterials.flint, new ShieldMaterialStats(150, 30)); - TinkerRegistry.addMaterialStats(TinkerMaterials.flint, ams.new HelmMaterialStats(150, 2, 0, 0)); - TinkerRegistry.addMaterialStats(TinkerMaterials.flint, ams.new ChestMaterialStats(150, 4, 0, 0)); - TinkerRegistry.addMaterialStats(TinkerMaterials.flint, ams.new LegsMaterialStats(150, 3, 0, 0)); - TinkerRegistry.addMaterialStats(TinkerMaterials.flint, ams.new FeetMaterialStats(150, 2, 0, 0)); - // TinkerRegistry.addMaterialTrait(TinkerMaterials.flint, firestarter, + TinkerRegistry.addMaterialStats(TinkerMaterials.flint, new HelmMaterialStats(150, 2, 0, 0)); + TinkerRegistry.addMaterialStats(TinkerMaterials.flint, new ChestMaterialStats(150, 4, 0, 0)); + TinkerRegistry.addMaterialStats(TinkerMaterials.flint, new LegsMaterialStats(150, 3, 0, 0)); + TinkerRegistry.addMaterialStats(TinkerMaterials.flint, new FeetMaterialStats(150, 2, 0, 0)); + // TinkerRegistry.addMaterialTrait(TinkerMaterials.flint, + // firestarter, // SHIELD); TinkerRegistry.addMaterialStats(TinkerMaterials.cactus, new ShieldMaterialStats(210, 25)); - TinkerRegistry.addMaterialStats(TinkerMaterials.cactus, ams.new HelmMaterialStats(210, 1, 0, 0)); - TinkerRegistry.addMaterialStats(TinkerMaterials.cactus, ams.new ChestMaterialStats(210, 3, 0, 0)); - TinkerRegistry.addMaterialStats(TinkerMaterials.cactus, ams.new LegsMaterialStats(210, 2, 0, 0)); - TinkerRegistry.addMaterialStats(TinkerMaterials.cactus, ams.new FeetMaterialStats(210, 1, 0, 0)); + TinkerRegistry.addMaterialStats(TinkerMaterials.cactus, new HelmMaterialStats(210, 1, 0, 0)); + TinkerRegistry.addMaterialStats(TinkerMaterials.cactus, new ChestMaterialStats(210, 3, 0, 0)); + TinkerRegistry.addMaterialStats(TinkerMaterials.cactus, new LegsMaterialStats(210, 2, 0, 0)); + TinkerRegistry.addMaterialStats(TinkerMaterials.cactus, new FeetMaterialStats(210, 1, 0, 0)); // TinkerRegistry.addMaterialTrait(TinkerMaterials.cactus, barbed, // SHIELD); TinkerRegistry.addMaterialStats(TinkerMaterials.bone, new ShieldMaterialStats(200, 40)); - TinkerRegistry.addMaterialStats(TinkerMaterials.bone, ams.new HelmMaterialStats(200, 2, 0, 0)); - TinkerRegistry.addMaterialStats(TinkerMaterials.bone, ams.new ChestMaterialStats(200, 4, 0, 0)); - TinkerRegistry.addMaterialStats(TinkerMaterials.bone, ams.new LegsMaterialStats(200, 4, 0, 0)); - TinkerRegistry.addMaterialStats(TinkerMaterials.bone, ams.new FeetMaterialStats(200, 2, 0, 0)); + TinkerRegistry.addMaterialStats(TinkerMaterials.bone, new HelmMaterialStats(200, 2, 0, 0)); + TinkerRegistry.addMaterialStats(TinkerMaterials.bone, new ChestMaterialStats(200, 4, 0, 0)); + TinkerRegistry.addMaterialStats(TinkerMaterials.bone, new LegsMaterialStats(200, 4, 0, 0)); + TinkerRegistry.addMaterialStats(TinkerMaterials.bone, new FeetMaterialStats(200, 2, 0, 0)); // TinkerRegistry.addMaterialTrait(TinkerMaterials.bone, dogtoy, // SHIELD); TinkerRegistry.addMaterialStats(TinkerMaterials.obsidian, new ShieldMaterialStats(139, 50)); - TinkerRegistry.addMaterialStats(TinkerMaterials.obsidian, ams.new HelmMaterialStats(139, 2, 0, 0)); - TinkerRegistry.addMaterialStats(TinkerMaterials.obsidian, ams.new ChestMaterialStats(139, 6, 0, 0)); - TinkerRegistry.addMaterialStats(TinkerMaterials.obsidian, ams.new LegsMaterialStats(139, 5, 0, 0)); - TinkerRegistry.addMaterialStats(TinkerMaterials.obsidian, ams.new FeetMaterialStats(139, 2, 0, 0)); + TinkerRegistry.addMaterialStats(TinkerMaterials.obsidian, new HelmMaterialStats(139, 2, 0, 0)); + TinkerRegistry.addMaterialStats(TinkerMaterials.obsidian, new ChestMaterialStats(139, 6, 0, 0)); + TinkerRegistry.addMaterialStats(TinkerMaterials.obsidian, new LegsMaterialStats(139, 5, 0, 0)); + TinkerRegistry.addMaterialStats(TinkerMaterials.obsidian, new FeetMaterialStats(139, 2, 0, 0)); TinkerRegistry.addMaterialStats(TinkerMaterials.prismarine, new ShieldMaterialStats(430, 45)); - TinkerRegistry.addMaterialStats(TinkerMaterials.prismarine, ams.new HelmMaterialStats(430, 2, 0, 2.5f)); - TinkerRegistry.addMaterialStats(TinkerMaterials.prismarine, ams.new ChestMaterialStats(430, 5, 0, 3.5f)); - TinkerRegistry.addMaterialStats(TinkerMaterials.prismarine, ams.new LegsMaterialStats(430, 5, 0, 3.0f)); - TinkerRegistry.addMaterialStats(TinkerMaterials.prismarine, ams.new FeetMaterialStats(430, 2, 0, 2.5f)); + TinkerRegistry.addMaterialStats(TinkerMaterials.prismarine, new HelmMaterialStats(430, 2, 0, 2.5f)); + TinkerRegistry.addMaterialStats(TinkerMaterials.prismarine, new ChestMaterialStats(430, 5, 0, 3.5f)); + TinkerRegistry.addMaterialStats(TinkerMaterials.prismarine, new LegsMaterialStats(430, 5, 0, 3.0f)); + TinkerRegistry.addMaterialStats(TinkerMaterials.prismarine, new FeetMaterialStats(430, 2, 0, 2.5f)); TinkerRegistry.addMaterialStats(TinkerMaterials.endstone, new ShieldMaterialStats(420, 50)); - TinkerRegistry.addMaterialStats(TinkerMaterials.endstone, ams.new HelmMaterialStats(420, 3, 1, 0)); - TinkerRegistry.addMaterialStats(TinkerMaterials.endstone, ams.new ChestMaterialStats(420, 6, 1, 0)); - TinkerRegistry.addMaterialStats(TinkerMaterials.endstone, ams.new LegsMaterialStats(420, 5, 1, 0)); - TinkerRegistry.addMaterialStats(TinkerMaterials.endstone, ams.new FeetMaterialStats(420, 3, 1, 0)); + TinkerRegistry.addMaterialStats(TinkerMaterials.endstone, new HelmMaterialStats(420, 3, 1, 0)); + TinkerRegistry.addMaterialStats(TinkerMaterials.endstone, new ChestMaterialStats(420, 6, 1, 0)); + TinkerRegistry.addMaterialStats(TinkerMaterials.endstone, new LegsMaterialStats(420, 5, 1, 0)); + TinkerRegistry.addMaterialStats(TinkerMaterials.endstone, new FeetMaterialStats(420, 3, 1, 0)); TinkerRegistry.addMaterialStats(TinkerMaterials.paper, new ShieldMaterialStats(12, 10)); - TinkerRegistry.addMaterialStats(TinkerMaterials.paper, ams.new HelmMaterialStats(12, 1, 0, 4)); - TinkerRegistry.addMaterialStats(TinkerMaterials.paper, ams.new ChestMaterialStats(12, 2, 0, 5.5f)); - TinkerRegistry.addMaterialStats(TinkerMaterials.paper, ams.new LegsMaterialStats(12, 1, 0, 5)); - TinkerRegistry.addMaterialStats(TinkerMaterials.paper, ams.new FeetMaterialStats(12, 1, 0, 4)); + TinkerRegistry.addMaterialStats(TinkerMaterials.paper, new HelmMaterialStats(12, 1, 0, 4)); + TinkerRegistry.addMaterialStats(TinkerMaterials.paper, new ChestMaterialStats(12, 2, 0, 5.5f)); + TinkerRegistry.addMaterialStats(TinkerMaterials.paper, new LegsMaterialStats(12, 1, 0, 5)); + TinkerRegistry.addMaterialStats(TinkerMaterials.paper, new FeetMaterialStats(12, 1, 0, 4)); TinkerRegistry.addMaterialStats(TinkerMaterials.sponge, new ShieldMaterialStats(550, 20)); - TinkerRegistry.addMaterialStats(TinkerMaterials.sponge, ams.new HelmMaterialStats(550, 1, 0, 0)); - TinkerRegistry.addMaterialStats(TinkerMaterials.sponge, ams.new ChestMaterialStats(550, 2, 0, 0)); - TinkerRegistry.addMaterialStats(TinkerMaterials.sponge, ams.new LegsMaterialStats(550, 2, 0, 0)); - TinkerRegistry.addMaterialStats(TinkerMaterials.sponge, ams.new FeetMaterialStats(550, 1, 0, 0)); + TinkerRegistry.addMaterialStats(TinkerMaterials.sponge, new HelmMaterialStats(550, 1, 0, 0)); + TinkerRegistry.addMaterialStats(TinkerMaterials.sponge, new ChestMaterialStats(550, 2, 0, 0)); + TinkerRegistry.addMaterialStats(TinkerMaterials.sponge, new LegsMaterialStats(550, 2, 0, 0)); + TinkerRegistry.addMaterialStats(TinkerMaterials.sponge, new FeetMaterialStats(550, 1, 0, 0)); + // TinkerRegistry.addMaterialStats(TinkerMaterials.sponge, new + // FabricMaterialStats(550, 0, 0, 0)); TinkerRegistry.addMaterialStats(TinkerMaterials.firewood, new ShieldMaterialStats(550, 25)); - TinkerRegistry.addMaterialStats(TinkerMaterials.firewood, ams.new HelmMaterialStats(550, 1, 0, 0)); - TinkerRegistry.addMaterialStats(TinkerMaterials.firewood, ams.new ChestMaterialStats(550, 3, 0, 0)); - TinkerRegistry.addMaterialStats(TinkerMaterials.firewood, ams.new LegsMaterialStats(550, 2, 0, 0)); - TinkerRegistry.addMaterialStats(TinkerMaterials.firewood, ams.new FeetMaterialStats(550, 1, 0, 0)); + TinkerRegistry.addMaterialStats(TinkerMaterials.firewood, new HelmMaterialStats(550, 1, 0, 0)); + TinkerRegistry.addMaterialStats(TinkerMaterials.firewood, new ChestMaterialStats(550, 3, 0, 0)); + TinkerRegistry.addMaterialStats(TinkerMaterials.firewood, new LegsMaterialStats(550, 2, 0, 0)); + TinkerRegistry.addMaterialStats(TinkerMaterials.firewood, new FeetMaterialStats(550, 1, 0, 0)); // Slime TinkerRegistry.addMaterialStats(TinkerMaterials.slime, new ShieldMaterialStats(1000, 5)); - TinkerRegistry.addMaterialStats(TinkerMaterials.slime, ams.new HelmMaterialStats(1000, 1, 0, 0)); - TinkerRegistry.addMaterialStats(TinkerMaterials.slime, ams.new ChestMaterialStats(1000, 2, 0, 0)); - TinkerRegistry.addMaterialStats(TinkerMaterials.slime, ams.new LegsMaterialStats(1000, 2, 0, 0)); - TinkerRegistry.addMaterialStats(TinkerMaterials.slime, ams.new FeetMaterialStats(1000, 1, 0, 0)); + TinkerRegistry.addMaterialStats(TinkerMaterials.slime, new HelmMaterialStats(1000, 1, 0, 0)); + TinkerRegistry.addMaterialStats(TinkerMaterials.slime, new ChestMaterialStats(1000, 2, 0, 0)); + TinkerRegistry.addMaterialStats(TinkerMaterials.slime, new LegsMaterialStats(1000, 2, 0, 0)); + TinkerRegistry.addMaterialStats(TinkerMaterials.slime, new FeetMaterialStats(1000, 1, 0, 0)); TinkerRegistry.addMaterialStats(TinkerMaterials.blueslime, new ShieldMaterialStats(780, 7)); - TinkerRegistry.addMaterialStats(TinkerMaterials.blueslime, ams.new HelmMaterialStats(780, 1, 0, 0)); - TinkerRegistry.addMaterialStats(TinkerMaterials.blueslime, ams.new ChestMaterialStats(780, 2, 0, 0)); - TinkerRegistry.addMaterialStats(TinkerMaterials.blueslime, ams.new LegsMaterialStats(780, 2, 0, 0)); - TinkerRegistry.addMaterialStats(TinkerMaterials.blueslime, ams.new FeetMaterialStats(780, 1, 0, 0)); + TinkerRegistry.addMaterialStats(TinkerMaterials.blueslime, new HelmMaterialStats(780, 1, 0, 0)); + TinkerRegistry.addMaterialStats(TinkerMaterials.blueslime, new ChestMaterialStats(780, 2, 0, 0)); + TinkerRegistry.addMaterialStats(TinkerMaterials.blueslime, new LegsMaterialStats(780, 2, 0, 0)); + TinkerRegistry.addMaterialStats(TinkerMaterials.blueslime, new FeetMaterialStats(780, 1, 0, 0)); TinkerRegistry.addMaterialStats(TinkerMaterials.knightslime, new ShieldMaterialStats(850, 27)); - TinkerRegistry.addMaterialStats(TinkerMaterials.knightslime, ams.new HelmMaterialStats(850, 2, 1, 1.5f)); - TinkerRegistry.addMaterialStats(TinkerMaterials.knightslime, ams.new ChestMaterialStats(850, 6, 1, 2.5f)); - TinkerRegistry.addMaterialStats(TinkerMaterials.knightslime, ams.new LegsMaterialStats(850, 5, 1, 2.0f)); - TinkerRegistry.addMaterialStats(TinkerMaterials.knightslime, ams.new FeetMaterialStats(850, 2, 1, 1.5f)); + TinkerRegistry.addMaterialStats(TinkerMaterials.knightslime, new HelmMaterialStats(850, 2, 1, 1.5f)); + TinkerRegistry.addMaterialStats(TinkerMaterials.knightslime, new ChestMaterialStats(850, 6, 1, 2.5f)); + TinkerRegistry.addMaterialStats(TinkerMaterials.knightslime, new LegsMaterialStats(850, 5, 1, 2.0f)); + TinkerRegistry.addMaterialStats(TinkerMaterials.knightslime, new FeetMaterialStats(850, 2, 1, 1.5f)); TinkerRegistry.addMaterialStats(TinkerMaterials.magmaslime, new ShieldMaterialStats(600, 6)); - TinkerRegistry.addMaterialStats(TinkerMaterials.magmaslime, ams.new HelmMaterialStats(600, 1, 0, 0)); - TinkerRegistry.addMaterialStats(TinkerMaterials.magmaslime, ams.new ChestMaterialStats(600, 2, 0, 0)); - TinkerRegistry.addMaterialStats(TinkerMaterials.magmaslime, ams.new LegsMaterialStats(600, 2, 0, 0)); - TinkerRegistry.addMaterialStats(TinkerMaterials.magmaslime, ams.new FeetMaterialStats(600, 1, 0, 0)); + TinkerRegistry.addMaterialStats(TinkerMaterials.magmaslime, new HelmMaterialStats(600, 1, 0, 0)); + TinkerRegistry.addMaterialStats(TinkerMaterials.magmaslime, new ChestMaterialStats(600, 2, 0, 0)); + TinkerRegistry.addMaterialStats(TinkerMaterials.magmaslime, new LegsMaterialStats(600, 2, 0, 0)); + TinkerRegistry.addMaterialStats(TinkerMaterials.magmaslime, new FeetMaterialStats(600, 1, 0, 0)); // Nether TinkerRegistry.addMaterialStats(TinkerMaterials.netherrack, new ShieldMaterialStats(270, 20)); - TinkerRegistry.addMaterialStats(TinkerMaterials.netherrack, ams.new HelmMaterialStats(270, 1, 0, -12)); - TinkerRegistry.addMaterialStats(TinkerMaterials.netherrack, ams.new ChestMaterialStats(270, 3, 0, -12)); - TinkerRegistry.addMaterialStats(TinkerMaterials.netherrack, ams.new LegsMaterialStats(270, 2, 0, -12)); - TinkerRegistry.addMaterialStats(TinkerMaterials.netherrack, ams.new FeetMaterialStats(270, 1, 0, -12)); + TinkerRegistry.addMaterialStats(TinkerMaterials.netherrack, new HelmMaterialStats(270, 1, 0, -12)); + TinkerRegistry.addMaterialStats(TinkerMaterials.netherrack, new ChestMaterialStats(270, 3, 0, -12)); + TinkerRegistry.addMaterialStats(TinkerMaterials.netherrack, new LegsMaterialStats(270, 2, 0, -12)); + TinkerRegistry.addMaterialStats(TinkerMaterials.netherrack, new FeetMaterialStats(270, 1, 0, -12)); TinkerRegistry.addMaterialStats(TinkerMaterials.cobalt, new ShieldMaterialStats(780, 55)); - TinkerRegistry.addMaterialStats(TinkerMaterials.cobalt, ams.new HelmMaterialStats(780, 3, 0, 5)); - TinkerRegistry.addMaterialStats(TinkerMaterials.cobalt, ams.new ChestMaterialStats(780, 7, 0, 5)); - TinkerRegistry.addMaterialStats(TinkerMaterials.cobalt, ams.new LegsMaterialStats(780, 5, 0, 5)); - TinkerRegistry.addMaterialStats(TinkerMaterials.cobalt, ams.new FeetMaterialStats(780, 3, 0, 5)); + TinkerRegistry.addMaterialStats(TinkerMaterials.cobalt, new HelmMaterialStats(780, 3, 0, 5)); + TinkerRegistry.addMaterialStats(TinkerMaterials.cobalt, new ChestMaterialStats(780, 7, 0, 5)); + TinkerRegistry.addMaterialStats(TinkerMaterials.cobalt, new LegsMaterialStats(780, 5, 0, 5)); + TinkerRegistry.addMaterialStats(TinkerMaterials.cobalt, new FeetMaterialStats(780, 3, 0, 5)); TinkerRegistry.addMaterialStats(TinkerMaterials.ardite, new ShieldMaterialStats(990, 75)); - TinkerRegistry.addMaterialStats(TinkerMaterials.ardite, ams.new HelmMaterialStats(990, 3, 3, -100)); - TinkerRegistry.addMaterialStats(TinkerMaterials.ardite, ams.new ChestMaterialStats(990, 8, 4, -100)); - TinkerRegistry.addMaterialStats(TinkerMaterials.ardite, ams.new LegsMaterialStats(990, 6, 4, -100)); - TinkerRegistry.addMaterialStats(TinkerMaterials.ardite, ams.new FeetMaterialStats(990, 3, 3, -100)); + TinkerRegistry.addMaterialStats(TinkerMaterials.ardite, new HelmMaterialStats(990, 3, 3, -100)); + TinkerRegistry.addMaterialStats(TinkerMaterials.ardite, new ChestMaterialStats(990, 8, 4, -100)); + TinkerRegistry.addMaterialStats(TinkerMaterials.ardite, new LegsMaterialStats(990, 6, 4, -100)); + TinkerRegistry.addMaterialStats(TinkerMaterials.ardite, new FeetMaterialStats(990, 3, 3, -100)); TinkerRegistry.addMaterialStats(TinkerMaterials.manyullyn, new ShieldMaterialStats(820, 60)); - TinkerRegistry.addMaterialStats(TinkerMaterials.manyullyn, ams.new HelmMaterialStats(820, 3, 2, 0)); - TinkerRegistry.addMaterialStats(TinkerMaterials.manyullyn, ams.new ChestMaterialStats(820, 8, 2, 0)); - TinkerRegistry.addMaterialStats(TinkerMaterials.manyullyn, ams.new LegsMaterialStats(820, 6, 2, 0)); - TinkerRegistry.addMaterialStats(TinkerMaterials.manyullyn, ams.new FeetMaterialStats(820, 3, 2, 0)); + TinkerRegistry.addMaterialStats(TinkerMaterials.manyullyn, new HelmMaterialStats(820, 3, 2, 0)); + TinkerRegistry.addMaterialStats(TinkerMaterials.manyullyn, new ChestMaterialStats(820, 8, 2, 0)); + TinkerRegistry.addMaterialStats(TinkerMaterials.manyullyn, new LegsMaterialStats(820, 6, 2, 0)); + TinkerRegistry.addMaterialStats(TinkerMaterials.manyullyn, new FeetMaterialStats(820, 3, 2, 0)); // Metals TinkerRegistry.addMaterialStats(TinkerMaterials.iron, new ShieldMaterialStats(204, 50)); - TinkerRegistry.addMaterialStats(TinkerMaterials.iron, ams.new HelmMaterialStats(204, 2, 0, -4)); - TinkerRegistry.addMaterialStats(TinkerMaterials.iron, ams.new ChestMaterialStats(204, 6, 0, -5)); - TinkerRegistry.addMaterialStats(TinkerMaterials.iron, ams.new LegsMaterialStats(204, 5, 0, -4)); - TinkerRegistry.addMaterialStats(TinkerMaterials.iron, ams.new FeetMaterialStats(204, 2, 0, -3)); + TinkerRegistry.addMaterialStats(TinkerMaterials.iron, new HelmMaterialStats(204, 2, 0, -4)); + TinkerRegistry.addMaterialStats(TinkerMaterials.iron, new ChestMaterialStats(204, 6, 0, -5)); + TinkerRegistry.addMaterialStats(TinkerMaterials.iron, new LegsMaterialStats(204, 5, 0, -4)); + TinkerRegistry.addMaterialStats(TinkerMaterials.iron, new FeetMaterialStats(204, 2, 0, -3)); TinkerRegistry.addMaterialStats(TinkerMaterials.pigiron, new ShieldMaterialStats(380, 52)); - TinkerRegistry.addMaterialStats(TinkerMaterials.pigiron, ams.new HelmMaterialStats(380, 2, 0, 0.5f)); - TinkerRegistry.addMaterialStats(TinkerMaterials.pigiron, ams.new ChestMaterialStats(380, 6, 0, 1.5f)); - TinkerRegistry.addMaterialStats(TinkerMaterials.pigiron, ams.new LegsMaterialStats(380, 5, 0, 1)); - TinkerRegistry.addMaterialStats(TinkerMaterials.pigiron, ams.new FeetMaterialStats(380, 2, 0, 0.5f)); + TinkerRegistry.addMaterialStats(TinkerMaterials.pigiron, new HelmMaterialStats(380, 2, 0, 0.5f)); + TinkerRegistry.addMaterialStats(TinkerMaterials.pigiron, new ChestMaterialStats(380, 6, 0, 1.5f)); + TinkerRegistry.addMaterialStats(TinkerMaterials.pigiron, new LegsMaterialStats(380, 5, 0, 1)); + TinkerRegistry.addMaterialStats(TinkerMaterials.pigiron, new FeetMaterialStats(380, 2, 0, 0.5f)); // Mod Integration TinkerRegistry.addMaterialStats(TinkerMaterials.copper, new ShieldMaterialStats(210, 34)); - TinkerRegistry.addMaterialStats(TinkerMaterials.copper, ams.new HelmMaterialStats(210, 1, 0, 3)); - TinkerRegistry.addMaterialStats(TinkerMaterials.copper, ams.new ChestMaterialStats(210, 4, 0, 3)); - TinkerRegistry.addMaterialStats(TinkerMaterials.copper, ams.new LegsMaterialStats(210, 3, 0, 3)); - TinkerRegistry.addMaterialStats(TinkerMaterials.copper, ams.new FeetMaterialStats(210, 1, 0, 3)); + TinkerRegistry.addMaterialStats(TinkerMaterials.copper, new HelmMaterialStats(210, 1, 0, 3)); + TinkerRegistry.addMaterialStats(TinkerMaterials.copper, new ChestMaterialStats(210, 4, 0, 3)); + TinkerRegistry.addMaterialStats(TinkerMaterials.copper, new LegsMaterialStats(210, 3, 0, 3)); + TinkerRegistry.addMaterialStats(TinkerMaterials.copper, new FeetMaterialStats(210, 1, 0, 3)); TinkerRegistry.addMaterialStats(TinkerMaterials.bronze, new ShieldMaterialStats(430, 50)); - TinkerRegistry.addMaterialStats(TinkerMaterials.bronze, ams.new HelmMaterialStats(430, 2, 0, 0.5f)); - TinkerRegistry.addMaterialStats(TinkerMaterials.bronze, ams.new ChestMaterialStats(430, 6, 0, 0.5f)); - TinkerRegistry.addMaterialStats(TinkerMaterials.bronze, ams.new LegsMaterialStats(430, 5, 0, 0.5f)); - TinkerRegistry.addMaterialStats(TinkerMaterials.bronze, ams.new FeetMaterialStats(430, 2, 0, 0.5f)); + TinkerRegistry.addMaterialStats(TinkerMaterials.bronze, new HelmMaterialStats(430, 2, 0, 0.5f)); + TinkerRegistry.addMaterialStats(TinkerMaterials.bronze, new ChestMaterialStats(430, 6, 0, 0.5f)); + TinkerRegistry.addMaterialStats(TinkerMaterials.bronze, new LegsMaterialStats(430, 5, 0, 0.5f)); + TinkerRegistry.addMaterialStats(TinkerMaterials.bronze, new FeetMaterialStats(430, 2, 0, 0.5f)); TinkerRegistry.addMaterialStats(TinkerMaterials.lead, new ShieldMaterialStats(334, 42)); - TinkerRegistry.addMaterialStats(TinkerMaterials.lead, ams.new HelmMaterialStats(334, 1, 0, -20)); - TinkerRegistry.addMaterialStats(TinkerMaterials.lead, ams.new ChestMaterialStats(334, 5, 0, -20)); - TinkerRegistry.addMaterialStats(TinkerMaterials.lead, ams.new LegsMaterialStats(334, 4, 0, -20)); - TinkerRegistry.addMaterialStats(TinkerMaterials.lead, ams.new FeetMaterialStats(334, 1, 0, -20)); + TinkerRegistry.addMaterialStats(TinkerMaterials.lead, new HelmMaterialStats(334, 1, 0, -20)); + TinkerRegistry.addMaterialStats(TinkerMaterials.lead, new ChestMaterialStats(334, 5, 0, -20)); + TinkerRegistry.addMaterialStats(TinkerMaterials.lead, new LegsMaterialStats(334, 4, 0, -20)); + TinkerRegistry.addMaterialStats(TinkerMaterials.lead, new FeetMaterialStats(334, 1, 0, -20)); TinkerRegistry.addMaterialStats(TinkerMaterials.silver, new ShieldMaterialStats(250, 33)); - TinkerRegistry.addMaterialStats(TinkerMaterials.silver, ams.new HelmMaterialStats(250, 1, 0, 1.5f)); - TinkerRegistry.addMaterialStats(TinkerMaterials.silver, ams.new ChestMaterialStats(250, 3, 0, 1.5f)); - TinkerRegistry.addMaterialStats(TinkerMaterials.silver, ams.new LegsMaterialStats(250, 2, 0, 1.5f)); - TinkerRegistry.addMaterialStats(TinkerMaterials.silver, ams.new FeetMaterialStats(250, 1, 0, 1.5f)); + TinkerRegistry.addMaterialStats(TinkerMaterials.silver, new HelmMaterialStats(250, 1, 0, 1.5f)); + TinkerRegistry.addMaterialStats(TinkerMaterials.silver, new ChestMaterialStats(250, 3, 0, 1.5f)); + TinkerRegistry.addMaterialStats(TinkerMaterials.silver, new LegsMaterialStats(250, 2, 0, 1.5f)); + TinkerRegistry.addMaterialStats(TinkerMaterials.silver, new FeetMaterialStats(250, 1, 0, 1.5f)); TinkerRegistry.addMaterialStats(TinkerMaterials.electrum, new ShieldMaterialStats(50, 22)); - TinkerRegistry.addMaterialStats(TinkerMaterials.electrum, ams.new HelmMaterialStats(50, 1, 0, 2.5f)); - TinkerRegistry.addMaterialStats(TinkerMaterials.electrum, ams.new ChestMaterialStats(50, 3, 0, 2.5f)); - TinkerRegistry.addMaterialStats(TinkerMaterials.electrum, ams.new LegsMaterialStats(50, 2, 0, 2.5f)); - TinkerRegistry.addMaterialStats(TinkerMaterials.electrum, ams.new FeetMaterialStats(50, 1, 0, 2.5f)); + TinkerRegistry.addMaterialStats(TinkerMaterials.electrum, new HelmMaterialStats(50, 1, 0, 2.5f)); + TinkerRegistry.addMaterialStats(TinkerMaterials.electrum, new ChestMaterialStats(50, 3, 0, 2.5f)); + TinkerRegistry.addMaterialStats(TinkerMaterials.electrum, new LegsMaterialStats(50, 2, 0, 2.5f)); + TinkerRegistry.addMaterialStats(TinkerMaterials.electrum, new FeetMaterialStats(50, 1, 0, 2.5f)); TinkerRegistry.addMaterialStats(TinkerMaterials.steel, new ShieldMaterialStats(540, 55)); - TinkerRegistry.addMaterialStats(TinkerMaterials.steel, ams.new HelmMaterialStats(540, 3, 1, -12)); - TinkerRegistry.addMaterialStats(TinkerMaterials.steel, ams.new ChestMaterialStats(540, 7, 1, -12)); - TinkerRegistry.addMaterialStats(TinkerMaterials.steel, ams.new LegsMaterialStats(540, 6, 1, -12)); - TinkerRegistry.addMaterialStats(TinkerMaterials.steel, ams.new FeetMaterialStats(540, 3, 1, -12)); + TinkerRegistry.addMaterialStats(TinkerMaterials.steel, new HelmMaterialStats(540, 3, 1, -12)); + TinkerRegistry.addMaterialStats(TinkerMaterials.steel, new ChestMaterialStats(540, 7, 1, -12)); + TinkerRegistry.addMaterialStats(TinkerMaterials.steel, new LegsMaterialStats(540, 6, 1, -12)); + TinkerRegistry.addMaterialStats(TinkerMaterials.steel, new FeetMaterialStats(540, 3, 1, -12)); - for (String s : fluids.keySet()) { + for (String s : fluids.keySet()) + { createFluid(s, fluids.get(s)); FluidRegistry.registerFluid(fluids.get(s)); FluidRegistry.addBucketForFluid(fluids.get(s)); } - for (TDMatHelper m : materials_master) { - Material test = TinkerRegistry.getMaterial(m.name); - if (m.createMat && test.getIdentifier() == "unknown" - && !TinkersDefense.config.materials.isBlacklisted(m.name)) - createMaterial(m); - } + // TAIGA TEST - // Collection<Material> mats = TinkerRegistry.getAllMaterials(); - for (Material m : TinkerRegistry.getAllMaterials()) { - if (!m.hasStats(SHIELD)) { - if (m.hasStats(MaterialTypes.HEAD)) { + Collection<Material> mats = TinkerRegistry.getAllMaterials(); + for (Material m : TinkerRegistry.getAllMaterials()) + { + if (!m.hasStats(SHIELD)) + { + if (m.hasStats(MaterialTypes.HEAD)) + { int dur = ((HeadMaterialStats) m.getStats(MaterialTypes.HEAD)).durability; m.addStats(new ShieldMaterialStats(dur, 33)); + m.addStats(new HelmMaterialStats(dur, 1, 0, 0)); + m.addStats(new ChestMaterialStats(dur, 1, 0, 0)); + m.addStats(new LegsMaterialStats(dur, 1, 0, 0)); + m.addStats(new FeetMaterialStats(dur, 1, 0, 0)); + // m.addStats(new ClothMaterialStats(dur, 1, 0, 0)); } } } + // Collection<Material> mats = TinkerRegistry.getAllMaterials(); + // mats.isEmpty(); + // + // Set<IToolPart> parts = TinkerRegistry.getToolParts(); + // parts.size(); } - void createMaterial(TDMatHelper tdmat) { + void createMaterial(TDMatHelper tdmat) + { Material mat = new Material(tdmat.name, tdmat.color); - if (tdmat.isGem) { - if (tdmat.gem == null) { - mat.addItem("gem" + tdmat.name.substring(0, 1).toUpperCase() + tdmat.name.substring(1)); - mat.addItem(gem.getItembyName(tdmat.name), 1, Material.VALUE_Ingot); + if (tdmat.isGem) + { + if (tdmat.gem == null) + { + if (tdmat.createParts) + { + mat.addItem("gem" + tdmat.name.substring(0, 1).toUpperCase() + tdmat.name.substring(1)); + mat.addItem(gem.getItembyName(tdmat.name), 1, Material.VALUE_Ingot); + } } else mat.addItem(tdmat.gem, 1, Material.VALUE_Ingot); - } else { - if (tdmat.ingot == null) { - mat.addItem("ingot" + tdmat.name.substring(0, 1).toUpperCase() + tdmat.name.substring(1)); - mat.addItem(ingot.getItembyName(tdmat.name), 1, Material.VALUE_Ingot); + } else + { + if (tdmat.ingot == null) + { + if (tdmat.createParts) + { + mat.addItem("ingot" + tdmat.name.substring(0, 1).toUpperCase() + tdmat.name.substring(1)); + mat.addItem(ingot.getItembyName(tdmat.name), 1, Material.VALUE_Ingot); + } } else mat.addItem(tdmat.ingot, 1, Material.VALUE_Ingot); } - if (tdmat.nugget == null) { - mat.addItem("nugget" + tdmat.name.substring(0, 1).toUpperCase() + tdmat.name.substring(1)); - mat.addItem(nugget.getItembyName(tdmat.name), 1, Material.VALUE_Nugget); + if (tdmat.nugget == null) + { + if (tdmat.createParts) + { + mat.addItem("nugget" + tdmat.name.substring(0, 1).toUpperCase() + tdmat.name.substring(1)); + mat.addItem(nugget.getItembyName(tdmat.name), 1, Material.VALUE_Nugget); + } } else mat.addItem(tdmat.nugget, 1, Material.VALUE_Nugget); - if (tdmat.dust == null) { - mat.addItem("dust" + tdmat.name.substring(0, 1).toUpperCase() + tdmat.name.substring(1)); - mat.addItem(nugget.getItembyName(tdmat.name), 1, Material.VALUE_Ingot); + if (tdmat.dust == null) + { + if (tdmat.createParts) + { + mat.addItem("dust" + tdmat.name.substring(0, 1).toUpperCase() + tdmat.name.substring(1)); + mat.addItem(nugget.getItembyName(tdmat.name), 1, Material.VALUE_Ingot); + } } else mat.addItem(tdmat.nugget, 1, Material.VALUE_Ingot); - if (tdmat.grain == null) { - mat.addItem("grain" + tdmat.name.substring(0, 1).toUpperCase() + tdmat.name.substring(1)); - mat.addItem(nugget.getItembyName(tdmat.name), 1, Material.VALUE_Ingot / 4); + if (tdmat.grain == null) + { + if (tdmat.createParts) + { + mat.addItem("grain" + tdmat.name.substring(0, 1).toUpperCase() + tdmat.name.substring(1)); + mat.addItem(nugget.getItembyName(tdmat.name), 1, Material.VALUE_Ingot / 4); + } } else mat.addItem(tdmat.grain, 1, Material.VALUE_Nugget / 4); @@ -681,21 +706,16 @@ public class TDMaterials { TinkerRegistry.integrate(new MaterialIntegration(mat).toolforge()).preInit(); } - void setStats(Material m, TDMatHelper tdm) { + void setStats(Material m, TDMatHelper tdm) + { if (tdm.head != null) TinkerRegistry.addMaterialStats(m, tdm.head); - else - TinkerRegistry.addMaterialStats(m, new HeadMaterialStats(0, 0, 0, 0)); if (tdm.handle != null) TinkerRegistry.addMaterialStats(m, tdm.handle); - else - TinkerRegistry.addMaterialStats(m, new HandleMaterialStats(0, 0)); if (tdm.extra != null) TinkerRegistry.addMaterialStats(m, tdm.extra); - else - TinkerRegistry.addMaterialStats(m, new ExtraMaterialStats(0)); if (tdm.bow != null) TinkerRegistry.addMaterialStats(m, tdm.bow); @@ -720,40 +740,60 @@ public class TDMaterials { if (tdm.boots != null) TinkerRegistry.addMaterialStats(m, tdm.boots); + + if (tdm.cloth != null) + TinkerRegistry.addMaterialStats(m, tdm.cloth); } - public void registerItems(final RegistryEvent.Register<Item> event) { + public void registerItems(final RegistryEvent.Register<Item> event) + { final IForgeRegistry registry = event.getRegistry(); + nugget = new TDOreDictItem("nugget", getMatNames(materials_master), getMatColors(materials_master)); + dust = new TDOreDictItem("dust", getMatNames(materials_master), getMatColors(materials_master)); + grain = new TDOreDictItem("grain", getMatNames(materials_master), getMatColors(materials_master)); + + List<TDMatHelper> gemMaster = new ArrayList<TDMatHelper>(); + List<TDMatHelper> ingotMaster = new ArrayList<TDMatHelper>(); + + for (TDMatHelper i : materials_master) + { + if (i.isGem) + gemMaster.add(i); + else + ingotMaster.add(i); + } + + gem = new TDOreDictItem("gem", getMatNames(gemMaster), getMatColors(gemMaster)); + ingot = new TDOreDictItem("ingot", getMatNames(ingotMaster), getMatColors(ingotMaster)); registry.register(ingot); registry.register(dust); registry.register(nugget); registry.register(grain); registry.register(gem); + + for (TDMatHelper m : materials_master) + { + Material test = TinkerRegistry.getMaterial(m.name); + if (m.createMat && test.getIdentifier() == "unknown" && !TinkersDefense.config.materials.isBlacklisted(m.name)) + createMaterial(m); + } } @Subscribe - public void init(FMLInitializationEvent event) { + public void init(FMLInitializationEvent event) + { + for (int i = 0; i < ingot.mats.size(); i++) - OreDictionary.registerOre( - "ingot" + ingot.mats.get(i).substring(0, 1).toUpperCase() + ingot.mats.get(i).substring(1), - new ItemStack(ingot, 1, i)); + OreDictionary.registerOre("ingot" + ingot.mats.get(i).substring(0, 1).toUpperCase() + ingot.mats.get(i).substring(1), new ItemStack(ingot, 1, i)); for (int i = 0; i < nugget.mats.size(); i++) - OreDictionary.registerOre( - "nugget" + nugget.mats.get(i).substring(0, 1).toUpperCase() + nugget.mats.get(i).substring(1), - new ItemStack(nugget, 1, i)); + OreDictionary.registerOre("nugget" + nugget.mats.get(i).substring(0, 1).toUpperCase() + nugget.mats.get(i).substring(1), new ItemStack(nugget, 1, i)); for (int i = 0; i < dust.mats.size(); i++) - OreDictionary.registerOre( - "dust" + dust.mats.get(i).substring(0, 1).toUpperCase() + dust.mats.get(i).substring(1), - new ItemStack(dust, 1, i)); + OreDictionary.registerOre("dust" + dust.mats.get(i).substring(0, 1).toUpperCase() + dust.mats.get(i).substring(1), new ItemStack(dust, 1, i)); for (int i = 0; i < grain.mats.size(); i++) - OreDictionary.registerOre( - "grain" + grain.mats.get(i).substring(0, 1).toUpperCase() + grain.mats.get(i).substring(1), - new ItemStack(grain, 1, i)); + OreDictionary.registerOre("grain" + grain.mats.get(i).substring(0, 1).toUpperCase() + grain.mats.get(i).substring(1), new ItemStack(grain, 1, i)); for (int i = 0; i < gem.mats.size(); i++) - OreDictionary.registerOre( - "gem" + gem.mats.get(i).substring(0, 1).toUpperCase() + gem.mats.get(i).substring(1), - new ItemStack(gem, 1, i)); + OreDictionary.registerOre("gem" + gem.mats.get(i).substring(0, 1).toUpperCase() + gem.mats.get(i).substring(1), new ItemStack(gem, 1, i)); TinkerRegistry.registerMelting(Items.CHORUS_FRUIT, fluids.get("chorusjuice"), Material.VALUE_Nugget); TinkerRegistry.registerMelting(Items.DRAGON_BREATH, fluids.get("dragonsbreath"), Material.VALUE_Ingot); @@ -765,112 +805,109 @@ public class TDMaterials { TinkerRegistry.registerMelting(Blocks.QUARTZ_BLOCK, fluids.get("quartz"), Material.VALUE_Ingot * 4); TinkerRegistry.registerMelting(Items.QUARTZ, fluids.get("quartz"), Material.VALUE_Ingot); - TinkerRegistry.registerTableCasting(new ItemStack(Items.QUARTZ, 1, 0), ItemStack.EMPTY, - (Fluid) fluids.get("quartz"), Material.VALUE_Ingot); - - TinkerRegistry.registerBasinCasting(new ItemStack(Blocks.QUARTZ_BLOCK, 1, 0), ItemStack.EMPTY, - (Fluid) fluids.get("quartz"), Material.VALUE_Ingot * 4); - TinkerRegistry.registerBasinCasting(new ItemStack(Blocks.ICE, 1, 0), ItemStack.EMPTY, - (Fluid) fluids.get("slush"), Material.VALUE_Ingot); - - TinkerRegistry.registerAlloy(new FluidStack(fluids.get("aeonsteel"), 4), - new FluidStack(fluids.get("chorusjuice"), 1), new FluidStack(TinkerFluids.cobalt, 3)); - TinkerRegistry.registerAlloy(new FluidStack(fluids.get("queensgold"), 2), new FluidStack(TinkerFluids.gold, 1), - new FluidStack(TinkerFluids.knightslime, 1)); - TinkerRegistry.registerAlloy(new FluidStack(fluids.get("dogbearium"), 4), - new FluidStack(TinkerFluids.ardite, 1), new FluidStack(fluids.get("dragonsbreath"), 3)); - TinkerRegistry.registerAlloy(new FluidStack(fluids.get("sinisterium"), 6), - new FluidStack(TinkerFluids.blood, 1), new FluidStack(fluids.get("vile"), 2), - new FluidStack(TinkerFluids.iron, 4)); - TinkerRegistry.registerAlloy(new FluidStack(fluids.get("nihilite"), 3), new FluidStack(TinkerFluids.cobalt, 1), - new FluidStack(fluids.get("vile"), 2)); + TinkerRegistry.registerTableCasting(new ItemStack(Items.QUARTZ, 1, 0), ItemStack.EMPTY, (Fluid) fluids.get("quartz"), Material.VALUE_Ingot); + + TinkerRegistry.registerBasinCasting(new ItemStack(Blocks.QUARTZ_BLOCK, 1, 0), ItemStack.EMPTY, (Fluid) fluids.get("quartz"), Material.VALUE_Ingot * 4); + TinkerRegistry.registerBasinCasting(new ItemStack(Blocks.ICE, 1, 0), ItemStack.EMPTY, (Fluid) fluids.get("slush"), Material.VALUE_Ingot); + + TinkerRegistry.registerAlloy(new FluidStack(fluids.get("aeonsteel"), 4), new FluidStack(fluids.get("chorusjuice"), 1), new FluidStack(TinkerFluids.cobalt, 3)); + TinkerRegistry.registerAlloy(new FluidStack(fluids.get("queensgold"), 2), new FluidStack(TinkerFluids.gold, 1), new FluidStack(TinkerFluids.knightslime, 1)); + TinkerRegistry.registerAlloy(new FluidStack(fluids.get("dogbearium"), 4), new FluidStack(TinkerFluids.ardite, 1), new FluidStack(fluids.get("dragonsbreath"), 3)); + TinkerRegistry.registerAlloy(new FluidStack(fluids.get("sinisterium"), 6), new FluidStack(TinkerFluids.blood, 1), new FluidStack(fluids.get("vile"), 2), new FluidStack(TinkerFluids.iron, 4)); + TinkerRegistry.registerAlloy(new FluidStack(fluids.get("nihilite"), 3), new FluidStack(TinkerFluids.cobalt, 1), new FluidStack(fluids.get("vile"), 2)); TinkerRegistry.registerAlloy(new FluidStack(fluids.get("orichalcum"), 6), - new FluidStack(TinkerFluids.bronze, 4), new FluidStack(fluids.get("vibrant"), 2), - new FluidStack(TinkerFluids.gold, 1)); - TinkerRegistry.registerAlloy(new FluidStack(fluids.get("pandorium"), 3), new FluidStack(TinkerFluids.ardite, 1), - new FluidStack(fluids.get("vibrant"), 2)); - TinkerRegistry.registerAlloy(new FluidStack(fluids.get("rosegold"), 4), new FluidStack(TinkerFluids.gold, 1), - new FluidStack(TinkerFluids.copper, 3)); - TinkerRegistry.registerAlloy(new FluidStack(fluids.get("brass"), 3), new FluidStack(TinkerFluids.copper, 2), - new FluidStack(TinkerFluids.zinc, 2)); + new FluidStack(TinkerFluids.bronze, 4), + new FluidStack(fluids.get("vibrant"), 2), + new FluidStack(TinkerFluids.gold, 1)); + TinkerRegistry.registerAlloy(new FluidStack(fluids.get("pandorium"), 3), new FluidStack(TinkerFluids.ardite, 1), new FluidStack(fluids.get("vibrant"), 2)); + TinkerRegistry.registerAlloy(new FluidStack(fluids.get("rosegold"), 4), new FluidStack(TinkerFluids.gold, 1), new FluidStack(TinkerFluids.copper, 3)); + TinkerRegistry.registerAlloy(new FluidStack(fluids.get("brass"), 3), new FluidStack(TinkerFluids.copper, 2), new FluidStack(TinkerFluids.zinc, 2)); TinkerRegistry.registerAlloy(new FluidStack(fluids.get("valyriansteel"), 4), - new FluidStack(TinkerFluids.steel, 2), new FluidStack(TinkerFluids.obsidian, 2), - new FluidStack(fluids.get("dragonsbreath"), 1)); - TinkerRegistry.registerAlloy(new FluidStack(fluids.get("froststeel"), 4), new FluidStack(TinkerFluids.steel, 2), - new FluidStack(TinkerFluids.cobalt, 2), new FluidStack(fluids.get("slush"), 1)); + new FluidStack(TinkerFluids.steel, 2), + new FluidStack(TinkerFluids.obsidian, 2), + new FluidStack(fluids.get("dragonsbreath"), 1)); + TinkerRegistry.registerAlloy(new FluidStack(fluids.get("froststeel"), 4), + new FluidStack(TinkerFluids.steel, 2), + new FluidStack(TinkerFluids.cobalt, 2), + new FluidStack(fluids.get("slush"), 1)); TinkerRegistry.registerAlloy(new FluidStack(fluids.get("pureardite"), 1), - new FluidStack(TinkerFluids.ardite, 1), new FluidStack(fluids.get("dragonsbreath"), 2), - new FluidStack(TinkerFluids.blood, 2), new FluidStack(fluids.get("purifiedgold"), 2)); + new FluidStack(TinkerFluids.ardite, 1), + new FluidStack(fluids.get("dragonsbreath"), 2), + new FluidStack(TinkerFluids.blood, 2), + new FluidStack(fluids.get("purifiedgold"), 2)); TinkerRegistry.registerAlloy(new FluidStack(fluids.get("purecobalt"), 1), - new FluidStack(TinkerFluids.cobalt, 1), new FluidStack(fluids.get("dragonsbreath"), 2), - new FluidStack(fluids.get("slush"), 2), new FluidStack(fluids.get("purifiedsilver"), 2)); - TinkerRegistry.registerAlloy(new FluidStack(fluids.get("puremanyullyn"), 2), - new FluidStack(fluids.get("pureardite"), 1), new FluidStack(fluids.get("purecobalt"), 1)); + new FluidStack(TinkerFluids.cobalt, 1), + new FluidStack(fluids.get("dragonsbreath"), 2), + new FluidStack(fluids.get("slush"), 2), + new FluidStack(fluids.get("purifiedsilver"), 2)); + TinkerRegistry.registerAlloy(new FluidStack(fluids.get("puremanyullyn"), 2), new FluidStack(fluids.get("pureardite"), 1), new FluidStack(fluids.get("purecobalt"), 1)); TinkerRegistry.registerAlloy(new FluidStack(fluids.get("purifiedgold"), 1), - new FluidStack(TinkerFluids.gold, 1), new FluidStack(fluids.get("quartz"), 8), - new FluidStack(TinkerFluids.glass, 2), new FluidStack(TinkerFluids.purpleSlime, 2)); + new FluidStack(TinkerFluids.gold, 1), + new FluidStack(fluids.get("quartz"), 8), + new FluidStack(TinkerFluids.glass, 2), + new FluidStack(TinkerFluids.purpleSlime, 2)); TinkerRegistry.registerAlloy(new FluidStack(fluids.get("purifiedsilver"), 1), - new FluidStack(TinkerFluids.silver, 1), new FluidStack(fluids.get("quartz"), 8), - new FluidStack(TinkerFluids.glass, 2), new FluidStack(TinkerFluids.purpleSlime, 2)); - TinkerRegistry.registerAlloy(new FluidStack(fluids.get("solarium"), 1), new FluidStack(TinkerFluids.steel, 1), - new FluidStack(fluids.get("sundrop"), 1)); - TinkerRegistry.registerAlloy(new FluidStack(fluids.get("dragonsteel"), 1), - new FluidStack(TinkerFluids.steel, 1), new FluidStack(fluids.get("gallite"), 1)); - TinkerRegistry.registerAlloy(new FluidStack(fluids.get("blacksteel"), 1), new FluidStack(TinkerFluids.steel, 1), - new FluidStack(fluids.get("voidite"), 1)); - TinkerRegistry.registerAlloy(new FluidStack(fluids.get("abyssalium"), 1), - new FluidStack(fluids.get("voidite"), 1), new FluidStack(fluids.get("sundrop"), 1)); - TinkerRegistry.registerAlloy(new FluidStack(fluids.get("depthsilver"), 1), - new FluidStack(TinkerFluids.silver, 1), new FluidStack(fluids.get("abyssalium"), 1)); - TinkerRegistry.registerAlloy(new FluidStack(fluids.get("moonsilver"), 1), - new FluidStack(TinkerFluids.silver, 1), new FluidStack(fluids.get("voidite"), 1)); - TinkerRegistry.registerAlloy(new FluidStack(fluids.get("novagold"), 1), new FluidStack(TinkerFluids.gold, 1), - new FluidStack(fluids.get("sundrop"), 1)); + new FluidStack(TinkerFluids.silver, 1), + new FluidStack(fluids.get("quartz"), 8), + new FluidStack(TinkerFluids.glass, 2), + new FluidStack(TinkerFluids.purpleSlime, 2)); + TinkerRegistry.registerAlloy(new FluidStack(fluids.get("solarium"), 1), new FluidStack(TinkerFluids.steel, 1), new FluidStack(fluids.get("sundrop"), 1)); + TinkerRegistry.registerAlloy(new FluidStack(fluids.get("dragonsteel"), 1), new FluidStack(TinkerFluids.steel, 1), new FluidStack(fluids.get("gallite"), 1)); + TinkerRegistry.registerAlloy(new FluidStack(fluids.get("blacksteel"), 1), new FluidStack(TinkerFluids.steel, 1), new FluidStack(fluids.get("voidite"), 1)); + TinkerRegistry.registerAlloy(new FluidStack(fluids.get("abyssalium"), 1), new FluidStack(fluids.get("voidite"), 1), new FluidStack(fluids.get("sundrop"), 1)); + TinkerRegistry.registerAlloy(new FluidStack(fluids.get("depthsilver"), 1), new FluidStack(TinkerFluids.silver, 1), new FluidStack(fluids.get("abyssalium"), 1)); + TinkerRegistry.registerAlloy(new FluidStack(fluids.get("moonsilver"), 1), new FluidStack(TinkerFluids.silver, 1), new FluidStack(fluids.get("voidite"), 1)); + TinkerRegistry.registerAlloy(new FluidStack(fluids.get("novagold"), 1), new FluidStack(TinkerFluids.gold, 1), new FluidStack(fluids.get("sundrop"), 1)); } @Subscribe - public void postInit(FMLPostInitializationEvent event) { + public void postInit(FMLPostInitializationEvent event) + { } @SideOnly(Side.CLIENT) @SubscribeEvent - public static void registerModels(ModelRegistryEvent event) { - for (int i = 0; i < dust.mats.size(); i++) { - ModelLoader.setCustomModelResourceLocation(dust, i, - new ModelResourceLocation(Reference.MOD_ID + ":dust", "inventory")); + public static void registerModels(ModelRegistryEvent event) + { + for (int i = 0; i < dust.mats.size(); i++) + { + ModelLoader.setCustomModelResourceLocation(dust, i, new ModelResourceLocation(Reference.MOD_ID + ":dust", "inventory")); } - for (int i = 0; i < ingot.mats.size(); i++) { - ModelLoader.setCustomModelResourceLocation(ingot, i, - new ModelResourceLocation(Reference.MOD_ID + ":ingot", "inventory")); + for (int i = 0; i < ingot.mats.size(); i++) + { + ModelLoader.setCustomModelResourceLocation(ingot, i, new ModelResourceLocation(Reference.MOD_ID + ":ingot", "inventory")); } - for (int i = 0; i < gem.mats.size(); i++) { - ModelLoader.setCustomModelResourceLocation(gem, i, - new ModelResourceLocation(Reference.MOD_ID + ":gem", "inventory")); + for (int i = 0; i < gem.mats.size(); i++) + { + ModelLoader.setCustomModelResourceLocation(gem, i, new ModelResourceLocation(Reference.MOD_ID + ":gem", "inventory")); } - for (int i = 0; i < nugget.mats.size(); i++) { - ModelLoader.setCustomModelResourceLocation(nugget, i, - new ModelResourceLocation(Reference.MOD_ID + ":nugget", "inventory")); + for (int i = 0; i < nugget.mats.size(); i++) + { + ModelLoader.setCustomModelResourceLocation(nugget, i, new ModelResourceLocation(Reference.MOD_ID + ":nugget", "inventory")); } - for (int i = 0; i < grain.mats.size(); i++) { - ModelLoader.setCustomModelResourceLocation(grain, i, - new ModelResourceLocation(Reference.MOD_ID + ":grain", "inventory")); + for (int i = 0; i < grain.mats.size(); i++) + { + ModelLoader.setCustomModelResourceLocation(grain, i, new ModelResourceLocation(Reference.MOD_ID + ":grain", "inventory")); } } @SubscribeEvent - public static void registerBlocks(final RegistryEvent.Register<Block> event) { - for (Block i : blockList) { + public static void registerBlocks(final RegistryEvent.Register<Block> event) + { + for (Block i : blockList) + { event.getRegistry().register(i); } } - static void createFluid(String name, FluidMolten fluid) { + static void createFluid(String name, FluidMolten fluid) + { FluidRegistry.registerFluid(fluid); BlockMolten block = new BlockMolten(fluid); @@ -886,23 +923,40 @@ public class TDMaterials { FluidRegistry.addBucketForFluid(fluid); } - private void registerClothMaterials() { - black = new Material("blackCloth", 0x191616); - red = new Material("redCloth", 0x963430); - green = new Material("greeCloth", 0x35461B); - brown = new Material("brownCloth", 0x4F321F); - blue = new Material("blueCloth", 0x2E388D); - purple = new Material("purpleCloth", 0x7E3DB5); - cyan = new Material("cyanCloth", 0x2E6E89); - lightgray = new Material("lightgrayCloth", 0x9AA1A1); - gray = new Material("grayCloth", 0x404040); - pink = new Material("pinkCloth", 0xD08499); - lime = new Material("limeCloth", 0x41AE38); - yellow = new Material("yellowCloth", 0xB1A627); - lightblue = new Material("lightblueCloth", 0x6B8AC9); - magenta = new Material("magentaCloth", 0xB350BC); - orange = new Material("orangeCloth", 0xDB7D3E); - white = new Material("whiteCloth", 0xDDDDDD); + private void registerClothMaterials() + { + black = new Material("blackCloth", 0x191616).setCraftable(true).setCastable(false); + ; + red = new Material("redCloth", 0x963430).setCraftable(true).setCastable(false); + ; + green = new Material("greeCloth", 0x35461B).setCraftable(true).setCastable(false); + ; + brown = new Material("brownCloth", 0x4F321F).setCraftable(true).setCastable(false); + ; + blue = new Material("blueCloth", 0x2E388D).setCraftable(true).setCastable(false); + ; + purple = new Material("purpleCloth", 0x7E3DB5).setCraftable(true).setCastable(false); + ; + cyan = new Material("cyanCloth", 0x2E6E89).setCraftable(true).setCastable(false); + ; + lightgray = new Material("lightgrayCloth", 0x9AA1A1).setCraftable(true).setCastable(false); + ; + gray = new Material("grayCloth", 0x404040).setCraftable(true).setCastable(false); + ; + pink = new Material("pinkCloth", 0xD08499).setCraftable(true).setCastable(false); + ; + lime = new Material("limeCloth", 0x41AE38).setCraftable(true).setCastable(false); + ; + yellow = new Material("yellowCloth", 0xB1A627).setCraftable(true).setCastable(false); + ; + lightblue = new Material("lightblueCloth", 0x6B8AC9).setCraftable(true).setCastable(false); + ; + magenta = new Material("magentaCloth", 0xB350BC).setCraftable(true).setCastable(false); + ; + orange = new Material("orangeCloth", 0xDB7D3E).setCraftable(true).setCastable(false); + ; + white = new Material("whiteCloth", 0xDDDDDD).setCraftable(true).setCastable(false); + ; // Material.UNKNOWN.addStats(new MaterialCloth(100)); black.addItem(new ItemStack(Blocks.WOOL, 1, 15), 1, Material.VALUE_Ingot); @@ -939,22 +993,54 @@ public class TDMaterials { orange.setRepresentativeItem(new ItemStack(Blocks.WOOL, 1, 1)); white.setRepresentativeItem(new ItemStack(Blocks.WOOL, 1, 0)); - // TinkerRegistry.addMaterial(black); - // TinkerRegistry.addMaterial(red); - // TinkerRegistry.addMaterial(green); - // TinkerRegistry.addMaterial(brown); - // TinkerRegistry.addMaterial(blue); - // TinkerRegistry.addMaterial(purple); - // TinkerRegistry.addMaterial(cyan); - // TinkerRegistry.addMaterial(lightgray); - // TinkerRegistry.addMaterial(gray); - // TinkerRegistry.addMaterial(pink); - // TinkerRegistry.addMaterial(lime); - // TinkerRegistry.addMaterial(yellow); - // TinkerRegistry.addMaterial(lightblue); - // TinkerRegistry.addMaterial(magenta); - // TinkerRegistry.addMaterial(orange); - // TinkerRegistry.addMaterial(white); + TinkerRegistry.addMaterialStats(this.white, new FabricMaterialStats(100, 10, 0, 25)); + TinkerRegistry.addMaterialStats(this.black, new FabricMaterialStats(100, 10, 0, 25)); + TinkerRegistry.addMaterialStats(this.blue, new FabricMaterialStats(100, 10, 0, 25)); + TinkerRegistry.addMaterialStats(this.brown, new FabricMaterialStats(100, 10, 0, 25)); + TinkerRegistry.addMaterialStats(this.cyan, new FabricMaterialStats(100, 10, 0, 25)); + TinkerRegistry.addMaterialStats(this.gray, new FabricMaterialStats(100, 10, 0, 25)); + TinkerRegistry.addMaterialStats(this.green, new FabricMaterialStats(100, 10, 0, 25)); + TinkerRegistry.addMaterialStats(this.lightblue, new FabricMaterialStats(100, 10, 0, 25)); + TinkerRegistry.addMaterialStats(this.lightgray, new FabricMaterialStats(100, 10, 0, 25)); + TinkerRegistry.addMaterialStats(this.lime, new FabricMaterialStats(100, 10, 0, 25)); + TinkerRegistry.addMaterialStats(this.magenta, new FabricMaterialStats(100, 10, 0, 25)); + TinkerRegistry.addMaterialStats(this.orange, new FabricMaterialStats(100, 10, 0, 25)); + TinkerRegistry.addMaterialStats(this.pink, new FabricMaterialStats(100, 10, 0, 25)); + TinkerRegistry.addMaterialStats(this.purple, new FabricMaterialStats(100, 10, 0, 25)); + TinkerRegistry.addMaterialStats(this.red, new FabricMaterialStats(100, 10, 0, 25)); + TinkerRegistry.addMaterialStats(this.yellow, new FabricMaterialStats(100, 10, 0, 25)); + + // TinkerRegistry.addMaterialStats(this.white, new + // ExtraMaterialStats(5)); + // TinkerRegistry.addMaterialStats(this.black, new + // ExtraMaterialStats(5)); + // TinkerRegistry.addMaterialStats(this.blue, new + // ExtraMaterialStats(5)); + // TinkerRegistry.addMaterialStats(this.brown, new + // ExtraMaterialStats(5)); + // TinkerRegistry.addMaterialStats(this.cyan, new + // ExtraMaterialStats(5)); + // TinkerRegistry.addMaterialStats(this.gray, new + // ExtraMaterialStats(5)); + // TinkerRegistry.addMaterialStats(this.green, new + // ExtraMaterialStats(5)); + // TinkerRegistry.addMaterialStats(this.lightblue, new + // ExtraMaterialStats(5)); + // TinkerRegistry.addMaterialStats(this.lightgray, new + // ExtraMaterialStats(5)); + // TinkerRegistry.addMaterialStats(this.lime, new + // ExtraMaterialStats(5)); + // TinkerRegistry.addMaterialStats(this.magenta, new + // ExtraMaterialStats(5)); + // TinkerRegistry.addMaterialStats(this.orange, new + // ExtraMaterialStats(5)); + // TinkerRegistry.addMaterialStats(this.pink, new + // ExtraMaterialStats(5)); + // TinkerRegistry.addMaterialStats(this.purple, new + // ExtraMaterialStats(5)); + // TinkerRegistry.addMaterialStats(this.red, new ExtraMaterialStats(5)); + // TinkerRegistry.addMaterialStats(this.yellow, new + // ExtraMaterialStats(5)); materials.put("white", white); materials.put("orange", orange); @@ -1009,14 +1095,18 @@ public class TDMaterials { } // PlusTIC to the rescue - public static void integrate(Map<String, Material> materials, Map<String, MaterialIntegration> materialIntegrations, - Collection<String> excludedMaterials) { - materials.forEach((k, v) -> { - if (!materialIntegrations.containsKey(k) && !excludedMaterials.contains(k)) { + public static void integrate(Map<String, Material> materials, Map<String, MaterialIntegration> materialIntegrations, Collection<String> excludedMaterials) + { + materials.forEach((k, v) -> + { + if (!materialIntegrations.containsKey(k) && !excludedMaterials.contains(k)) + { MaterialIntegration mi; - if (v.getFluid() != null && v.getFluid() != TinkerFluids.emerald) { + if (v.getFluid() != null && v.getFluid() != TinkerFluids.emerald) + { mi = new MaterialIntegration(v, v.getFluid(), StringUtils.capitalize(k)).toolforge(); - } else { + } else + { mi = new MaterialIntegration(v); } mi.integrate(); diff --git a/src/main/java/lance5057/tDefense/core/materials/TDTraits.java b/src/main/java/lance5057/tDefense/core/materials/TDTraits.java index 1ed655c..9ab8007 100644 --- a/src/main/java/lance5057/tDefense/core/materials/TDTraits.java +++ b/src/main/java/lance5057/tDefense/core/materials/TDTraits.java @@ -1,9 +1,9 @@ package lance5057.tDefense.core.materials; -import lance5057.tDefense.core.materials.ArmorMaterialStats.ChestMaterialStats; -import lance5057.tDefense.core.materials.ArmorMaterialStats.FeetMaterialStats; -import lance5057.tDefense.core.materials.ArmorMaterialStats.HelmMaterialStats; -import lance5057.tDefense.core.materials.ArmorMaterialStats.LegsMaterialStats; +import lance5057.tDefense.core.materials.stats.ChestMaterialStats; +import lance5057.tDefense.core.materials.stats.FeetMaterialStats; +import lance5057.tDefense.core.materials.stats.HelmMaterialStats; +import lance5057.tDefense.core.materials.stats.LegsMaterialStats; import lance5057.tDefense.core.materials.traits.armor.TraitDamageSourceAlteration; import lance5057.tDefense.core.materials.traits.armor.TraitPhotosynthetic; import lance5057.tDefense.core.materials.traits.armor.TraitReduceKnockback; diff --git a/src/main/java/lance5057/tDefense/core/materials/ArmorMaterialStats.java b/src/main/java/lance5057/tDefense/core/materials/stats/ArmorMaterialStats.java index 031384f..da48d32 100644 --- a/src/main/java/lance5057/tDefense/core/materials/ArmorMaterialStats.java +++ b/src/main/java/lance5057/tDefense/core/materials/stats/ArmorMaterialStats.java @@ -1,4 +1,4 @@ -package lance5057.tDefense.core.materials; +package lance5057.tDefense.core.materials.stats; import java.util.List; @@ -75,7 +75,7 @@ public class ArmorMaterialStats extends AbstractMaterialStats { @Override public List<String> getLocalizedDesc() { - List<String> info = Lists.newArrayList(); + List<String> info = Lists.newArrayList(); info.add(Util.translate(LOC_DurabilityDesc)); info.add(Util.translate(LOC_ArmorRatingDesc)); @@ -84,49 +84,4 @@ public class ArmorMaterialStats extends AbstractMaterialStats { return info; } - - public class HelmMaterialStats extends ArmorMaterialStats { - public final static String TYPE = "helm"; - - public HelmMaterialStats(int durability, int rating, int toughness, float potency) { - super(durability, rating, toughness,potency, TYPE); - } - - } - - public class ChestMaterialStats extends ArmorMaterialStats { - public final static String TYPE = "chest"; - - public ChestMaterialStats(int durability, int rating, int toughness, float potency) { - super(durability, rating, toughness,potency, TYPE); - } - - } - - public class LegsMaterialStats extends ArmorMaterialStats { - public final static String TYPE = "legs"; - - public LegsMaterialStats(int durability, int rating, int toughness, float potency) { - super(durability, rating, toughness,potency, TYPE); - } - - } - - public class FeetMaterialStats extends ArmorMaterialStats { - public final static String TYPE = "feet"; - - public FeetMaterialStats(int durability, int rating, int toughness, float potency) { - super(durability, rating, toughness,potency, TYPE); - } - - } - - public class ClothMaterialStats extends ArmorMaterialStats { - public final static String TYPE = "cloth"; - - public ClothMaterialStats(int durability, int rating, int toughness, float potency) { - super(durability, rating, toughness,potency, TYPE); - } - - } } diff --git a/src/main/java/lance5057/tDefense/core/materials/BaubleMaterialStats.java b/src/main/java/lance5057/tDefense/core/materials/stats/BaubleMaterialStats.java index aa28dc1..b99022f 100644 --- a/src/main/java/lance5057/tDefense/core/materials/BaubleMaterialStats.java +++ b/src/main/java/lance5057/tDefense/core/materials/stats/BaubleMaterialStats.java @@ -1,4 +1,4 @@ -package lance5057.tDefense.core.materials; +package lance5057.tDefense.core.materials.stats; import java.util.List; diff --git a/src/main/java/lance5057/tDefense/core/materials/stats/ChestMaterialStats.java b/src/main/java/lance5057/tDefense/core/materials/stats/ChestMaterialStats.java new file mode 100644 index 0000000..689f742 --- /dev/null +++ b/src/main/java/lance5057/tDefense/core/materials/stats/ChestMaterialStats.java @@ -0,0 +1,10 @@ +package lance5057.tDefense.core.materials.stats; + +public class ChestMaterialStats extends ArmorMaterialStats { + public final static String TYPE = "chest"; + + public ChestMaterialStats(int durability, int rating, int toughness, float potency) { + super(durability, rating, toughness,potency, TYPE); + } + +}
\ No newline at end of file diff --git a/src/main/java/lance5057/tDefense/core/materials/stats/FabricMaterialStats.java b/src/main/java/lance5057/tDefense/core/materials/stats/FabricMaterialStats.java new file mode 100644 index 0000000..c80c61d --- /dev/null +++ b/src/main/java/lance5057/tDefense/core/materials/stats/FabricMaterialStats.java @@ -0,0 +1,10 @@ +package lance5057.tDefense.core.materials.stats; + +public class FabricMaterialStats extends ArmorMaterialStats { + public final static String TYPE = "fabric"; + + public FabricMaterialStats(int durability, int rating, int toughness, float potency) { + super(durability, rating, toughness,potency, TYPE); + } + +}
\ No newline at end of file diff --git a/src/main/java/lance5057/tDefense/core/materials/stats/FeetMaterialStats.java b/src/main/java/lance5057/tDefense/core/materials/stats/FeetMaterialStats.java new file mode 100644 index 0000000..1afe1dd --- /dev/null +++ b/src/main/java/lance5057/tDefense/core/materials/stats/FeetMaterialStats.java @@ -0,0 +1,10 @@ +package lance5057.tDefense.core.materials.stats; + +public class FeetMaterialStats extends ArmorMaterialStats { + public final static String TYPE = "feet"; + + public FeetMaterialStats(int durability, int rating, int toughness, float potency) { + super(durability, rating, toughness,potency, TYPE); + } + +}
\ No newline at end of file diff --git a/src/main/java/lance5057/tDefense/core/materials/stats/HelmMaterialStats.java b/src/main/java/lance5057/tDefense/core/materials/stats/HelmMaterialStats.java new file mode 100644 index 0000000..2bd8526 --- /dev/null +++ b/src/main/java/lance5057/tDefense/core/materials/stats/HelmMaterialStats.java @@ -0,0 +1,10 @@ +package lance5057.tDefense.core.materials.stats; + +public class HelmMaterialStats extends ArmorMaterialStats { + public final static String TYPE = "helm"; + + public HelmMaterialStats(int durability, int rating, int toughness, float potency) { + super(durability, rating, toughness,potency, TYPE); + } + + }
\ No newline at end of file diff --git a/src/main/java/lance5057/tDefense/core/materials/stats/LegsMaterialStats.java b/src/main/java/lance5057/tDefense/core/materials/stats/LegsMaterialStats.java new file mode 100644 index 0000000..911a610 --- /dev/null +++ b/src/main/java/lance5057/tDefense/core/materials/stats/LegsMaterialStats.java @@ -0,0 +1,10 @@ +package lance5057.tDefense.core.materials.stats; + +public class LegsMaterialStats extends ArmorMaterialStats { + public final static String TYPE = "legs"; + + public LegsMaterialStats(int durability, int rating, int toughness, float potency) { + super(durability, rating, toughness,potency, TYPE); + } + +}
\ No newline at end of file diff --git a/src/main/java/lance5057/tDefense/core/materials/ShieldMaterialStats.java b/src/main/java/lance5057/tDefense/core/materials/stats/ShieldMaterialStats.java index bad520d..664777b 100644 --- a/src/main/java/lance5057/tDefense/core/materials/ShieldMaterialStats.java +++ b/src/main/java/lance5057/tDefense/core/materials/stats/ShieldMaterialStats.java @@ -1,4 +1,4 @@ -package lance5057.tDefense.core.materials; +package lance5057.tDefense.core.materials.stats; import java.util.List; diff --git a/src/main/java/lance5057/tDefense/core/materials/traits/armor/TraitDamageSourceAlteration.java b/src/main/java/lance5057/tDefense/core/materials/traits/armor/TraitDamageSourceAlteration.java index e40fdff..e17b112 100644 --- a/src/main/java/lance5057/tDefense/core/materials/traits/armor/TraitDamageSourceAlteration.java +++ b/src/main/java/lance5057/tDefense/core/materials/traits/armor/TraitDamageSourceAlteration.java @@ -1,6 +1,7 @@ package lance5057.tDefense.core.materials.traits.armor; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import lance5057.tDefense.core.materials.traits.AbstractTDTrait; @@ -10,7 +11,6 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.DamageSource; import net.minecraftforge.event.entity.living.LivingHurtEvent; -import scala.actors.threadpool.Arrays; import slimeknights.tconstruct.library.traits.AbstractTrait; public class TraitDamageSourceAlteration extends AbstractTDTrait { diff --git a/src/main/java/lance5057/tDefense/core/materials/traits/armor/TraitReduceKnockback.java b/src/main/java/lance5057/tDefense/core/materials/traits/armor/TraitReduceKnockback.java index f20b4fc..d0f08f8 100644 --- a/src/main/java/lance5057/tDefense/core/materials/traits/armor/TraitReduceKnockback.java +++ b/src/main/java/lance5057/tDefense/core/materials/traits/armor/TraitReduceKnockback.java @@ -1,6 +1,7 @@ package lance5057.tDefense.core.materials.traits.armor; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.UUID; @@ -14,7 +15,6 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import scala.actors.threadpool.Arrays; import slimeknights.tconstruct.library.traits.AbstractTrait; public class TraitReduceKnockback extends AbstractTrait { diff --git a/src/main/java/lance5057/tDefense/core/materials/traits/shields/TraitFirestarter.java b/src/main/java/lance5057/tDefense/core/materials/traits/shields/TraitFirestarter.java index 310b07e..feb59a6 100644 --- a/src/main/java/lance5057/tDefense/core/materials/traits/shields/TraitFirestarter.java +++ b/src/main/java/lance5057/tDefense/core/materials/traits/shields/TraitFirestarter.java @@ -2,7 +2,7 @@ package lance5057.tDefense.core.materials.traits.shields; import java.util.Optional; -import lance5057.tDefense.util.TDToolHelper; +import lance5057.tDefense.core.library.TDToolHelper; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; diff --git a/src/main/java/lance5057/tDefense/core/network/ArmorNetwork.java b/src/main/java/lance5057/tDefense/core/network/ArmorNetwork.java new file mode 100644 index 0000000..8aadb48 --- /dev/null +++ b/src/main/java/lance5057/tDefense/core/network/ArmorNetwork.java @@ -0,0 +1,5 @@ +package lance5057.tDefense.core.network; + +public class ArmorNetwork +{ +} diff --git a/src/main/java/lance5057/tDefense/core/network/ArmorStationSelectionPacket.java b/src/main/java/lance5057/tDefense/core/network/ArmorStationSelectionPacket.java new file mode 100644 index 0000000..e76d1df --- /dev/null +++ b/src/main/java/lance5057/tDefense/core/network/ArmorStationSelectionPacket.java @@ -0,0 +1,90 @@ +package lance5057.tDefense.core.network; + +import io.netty.buffer.ByteBuf; +import lance5057.tDefense.core.gui.ArmorStationContainer; +import lance5057.tDefense.core.gui.ArmorStationGui; +import lance5057.tDefense.core.tools.bases.ArmorCore; +import net.minecraft.client.Minecraft; +import net.minecraft.client.network.NetHandlerPlayClient; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.inventory.Container; +import net.minecraft.item.Item; +import net.minecraft.network.NetHandlerPlayServer; +import net.minecraft.world.WorldServer; +import slimeknights.mantle.inventory.BaseContainer; +import slimeknights.mantle.network.AbstractPacketThreadsafe; +import slimeknights.tconstruct.common.TinkerNetwork; + +public class ArmorStationSelectionPacket extends AbstractPacketThreadsafe { + + public ArmorCore armor; + public int activeSlots; + + public ArmorStationSelectionPacket() { + } + + public ArmorStationSelectionPacket(ArmorCore tool, int activeSlots) { + this.armor = tool; + this.activeSlots = activeSlots; + } + + @Override + public void handleClientSafe(NetHandlerPlayClient netHandler) { + Container container = Minecraft.getMinecraft().player.openContainer; + if(container instanceof ArmorStationContainer) { + ((ArmorStationContainer) container).setToolSelection(armor, activeSlots); + if(Minecraft.getMinecraft().currentScreen instanceof ArmorStationGui) { + ((ArmorStationGui) Minecraft.getMinecraft().currentScreen).onToolSelectionPacket(this); + } + } + } + + @Override + public void handleServerSafe(NetHandlerPlayServer netHandler) { + Container container = netHandler.player.openContainer; + if(container instanceof ArmorStationContainer) { + ((ArmorStationContainer) container).setToolSelection(armor, activeSlots); + + // find all people who also have the same gui open and update them too + WorldServer server = netHandler.player.getServerWorld(); + for(EntityPlayer player : server.playerEntities) { + if(player == netHandler.player) { + continue; + } + if(player.openContainer instanceof ArmorStationContainer) { + if(((BaseContainer) container).sameGui((BaseContainer) player.openContainer)) { + ((ArmorStationContainer) player.openContainer).setToolSelection(armor, activeSlots); + // same gui, send him an update + TinkerNetwork.sendTo(this, (EntityPlayerMP) player); + } + } + } + } + } + + @Override + public void fromBytes(ByteBuf buf) { + int id = buf.readShort(); + if(id > -1) { + Item item = Item.getItemById(id); + if(item instanceof ArmorCore) { + armor = (ArmorCore) item; + } + } + + activeSlots = buf.readInt(); + } + + @Override + public void toBytes(ByteBuf buf) { + if(armor == null) { + buf.writeShort(-1); + } + else { + buf.writeShort(Item.getIdFromItem(armor)); + } + + buf.writeInt(activeSlots); + } +}
\ No newline at end of file diff --git a/src/main/java/lance5057/tDefense/core/parts/TDParts.java b/src/main/java/lance5057/tDefense/core/parts/TDParts.java index af0d8f4..c0fff8f 100644 --- a/src/main/java/lance5057/tDefense/core/parts/TDParts.java +++ b/src/main/java/lance5057/tDefense/core/parts/TDParts.java @@ -1,12 +1,19 @@ package lance5057.tDefense.core.parts; import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.lang3.tuple.Pair; + +import com.google.common.collect.Lists; import lance5057.tDefense.Reference; import lance5057.tDefense.TinkersDefense; -import lance5057.tDefense.util.ModuleBase; +import lance5057.tDefense.core.library.ArmorPart; +import lance5057.tDefense.core.library.ModuleBase; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.event.FMLInitializationEvent; @@ -16,53 +23,62 @@ import net.minecraftforge.registries.IForgeRegistry; import slimeknights.tconstruct.library.TinkerRegistry; import slimeknights.tconstruct.library.materials.Material; import slimeknights.tconstruct.library.tinkering.PartMaterialType; +import slimeknights.tconstruct.library.tools.IToolPart; import slimeknights.tconstruct.library.tools.Pattern; +import slimeknights.tconstruct.library.tools.ToolCore; import slimeknights.tconstruct.library.tools.ToolPart; import slimeknights.tconstruct.tools.TinkerTools; @Mod.EventBusSubscriber(modid = Reference.MOD_ID) -public class TDParts extends ModuleBase { - public static PartMaterialType ShieldMat; - - public static PartMaterialType ArmorplateMat; - public static PartMaterialType ChainmailMat; - public static PartMaterialType RivetMat; - public static PartMaterialType ClaspMat; - public static PartMaterialType ClothMat; - - public static ToolPart armorPlate; - public static ToolPart chainmail; - public static ToolPart cloth; - public static ToolPart rivets; - public static ToolPart clasp; - - public static ToolPart ringShank; - public static ToolPart setting; - public static ToolPart wire; - public static ToolPart filigree; - - public static ToolPart armor_hoodCloth; +public class TDParts extends ModuleBase +{ + private static final List<IToolPart> toolParts = new ArrayList<>(); + static List<Pair<Item, ToolPart>> toolPartPatterns = Lists.newLinkedList(); + static List<Pair<Item, ArmorPart>> armorPartPatterns = Lists.newLinkedList(); + // public static PartMaterialType ShieldMat; + + // public static PartMaterialType ArmorplateMat; + // public static PartMaterialType ChainmailMat; + // public static PartMaterialType RivetMat; + // public static PartMaterialType ClaspMat; + // public static PartMaterialType ClothMat; + + public static ToolPart armorPlate; + public static ArmorPart chainmail; + public static ArmorPart fabric; + public static ToolPart rivets; + public static ToolPart clasp; + + public static ToolPart ringShank; + public static ToolPart setting; + public static ToolPart wire; + public static ToolPart filigree; + + // public static ToolPart armor_hoodCloth; protected static ArrayList<Item> itemList = new ArrayList<Item>(); @Override - public void preInit(FMLPreInitializationEvent e) { + public void preInit(FMLPreInitializationEvent e) + { } @Override - public void init(FMLInitializationEvent e) { + public void init(FMLInitializationEvent e) + { } @Override - public void postInit(FMLPostInitializationEvent e) { + public void postInit(FMLPostInitializationEvent e) + { // TODO Auto-generated method stub - + } - public void registerItems(final RegistryEvent.Register<Item> event) { - + public void registerItems(final RegistryEvent.Register<Item> event) + { final IForgeRegistry registry = event.getRegistry(); armorPlate = regToolPart(Material.VALUE_Ingot * 4, "armor_plate", event); @@ -73,39 +89,130 @@ public class TDParts extends ModuleBase { // TinkerRegistry.registerStencilTableCrafting(Pattern.setTagForPart(new // ItemStack(TinkerTools.pattern), armorPlate)); // - chainmail = regToolPart(Material.VALUE_Ingot * 3, "chainmail", event); - cloth = regToolPart(Material.VALUE_Ingot * 3, "cloth", event); + chainmail = regArmorPart(Material.VALUE_Ingot * 3, "chainmail", event); + + fabric = regArmorPart(Material.VALUE_Ingot * 3, "fabric", event); + rivets = regToolPart(Material.VALUE_Ingot * 1, "rivets", event); clasp = regToolPart(Material.VALUE_Ingot * 1, "clasp", event); - - ringShank = regToolPart(Material.VALUE_Ingot * 2, "ringShank", event); - setting = regToolPart(Material.VALUE_Ingot * 1, "setting", event); - wire = regToolPart(Material.VALUE_Ingot * 1, "wire", event); +// +// ringShank = regToolPart(Material.VALUE_Ingot * 2, "ringShank", event); +// setting = regToolPart(Material.VALUE_Ingot * 1, "setting", event); +// wire = regToolPart(Material.VALUE_Ingot * 1, "wire", event); filigree = regToolPart(Material.VALUE_Ingot * 1, "filigree", event); - - //ShieldMat = new PartMaterialType(TDParts.armorPlate, ShieldMaterialStats.TYPE); -// ArmorplateMat = new PartMaterialType(armorPlate, MaterialArmor.TYPE); -// ChainmailMat = new PartMaterialType(chainmail, MaterialArmor.TYPE); -// RivetMat = new PartMaterialType(rivets, MaterialTypes.EXTRA); -// ClaspMat = new PartMaterialType(clasp, MaterialTypes.EXTRA); -// ClothMat = new PartMaterialType(cloth, MaterialCloth.TYPE); + // ShieldMat = new PartMaterialType(TDParts.armorPlate, + // ShieldMaterialStats.TYPE); + + // ArmorplateMat = new PartMaterialType(armorPlate, MaterialArmor.TYPE); + // ChainmailMat = new PartMaterialType(chainmail, MaterialArmor.TYPE); + // RivetMat = new PartMaterialType(rivets, MaterialTypes.EXTRA); + // ClaspMat = new PartMaterialType(clasp, MaterialTypes.EXTRA); + // ClothMat = new PartMaterialType(cloth, MaterialCloth.TYPE); - //registry.registerAll((Item[]) itemList.toArray()); + // registry.registerAll((Item[]) itemList.toArray()); + + // armor_hoodCloth = regToolPart(Material.VALUE_Ingot * 1, + // "armor_hood_cloth", event); + for(Pair<Item, ToolPart> toolPartPattern : toolPartPatterns) { + registerStencil(toolPartPattern.getLeft(), toolPartPattern.getRight()); + } + + for(Pair<Item, ArmorPart> toolPartPattern : armorPartPatterns) { + registerStencil(toolPartPattern.getLeft(), toolPartPattern.getRight()); + } - armor_hoodCloth = regToolPart(Material.VALUE_Ingot * 1, "armor_hood_cloth", event); +// for (final IToolPart part : toolParts) +// { +// for (final ToolCore tool : TDTools.tools) +// { +// for (final PartMaterialType pmt : tool.getRequiredComponents()) +// { +// if (pmt.getPossibleParts().contains(part)) +// { +// TinkerRegistry.registerStencilTableCrafting(Pattern.setTagForPart(new ItemStack(TinkerTools.pattern), (Item) part)); +// } +// } +// } +// +// for (final ArmorCore armor : TDTools.armors) +// { +// for (final PartMaterialType pmt : armor.getRequiredComponents()) +// { +// if (pmt.getPossibleParts().contains(part)) +// { +// TinkerRegistry.registerStencilTableCrafting(Pattern.setTagForPart(new ItemStack(TinkerTools.pattern), (Item) part)); +// } +// } +// } +// } } - private static ToolPart regToolPart(int castVolume, String name, RegistryEvent.Register<Item> event) { + private static ToolPart regToolPart(int castVolume, String name, RegistryEvent.Register<Item> event) + { ToolPart part = new ToolPart(castVolume); - part.setUnlocalizedName(name).setRegistryName("tinkersdefense:" + name); + part.setUnlocalizedName(name).setRegistryName(new ResourceLocation(Reference.MOD_ID,name)); event.getRegistry().register(part); - TinkerRegistry.registerStencilTableCrafting(Pattern.setTagForPart(new ItemStack(TinkerTools.pattern), part)); + + if(TinkerTools.pattern != null) { + toolPartPatterns.add(Pair.of(TinkerTools.pattern, part)); + } + + TinkerRegistry.registerToolPart(part); TinkersDefense.proxy.registerPartModel(part); + TinkerRegistry.registerStencilTableCrafting(Pattern.setTagForPart(new ItemStack(TinkerTools.pattern), (Item) part)); + // TinkerRegistry.registerTableCasting(output, cast, fluid, amount); + toolParts.add(part); itemList.add(part); + + return part; + } + + private void registerStencil(Item pattern, ToolPart toolPart) { + for(ToolCore toolCore : TinkerRegistry.getTools()) { + for(PartMaterialType partMaterialType : toolCore.getRequiredComponents()) { + if(partMaterialType.getPossibleParts().contains(toolPart)) { + ItemStack stencil = new ItemStack(pattern); + Pattern.setTagForPart(stencil, toolPart); + TinkerRegistry.registerStencilTableCrafting(stencil); + return; + } + } + } + } + + private static ArmorPart regArmorPart(int castVolume, String name, RegistryEvent.Register<Item> event) + { + ArmorPart part = new ArmorPart(castVolume); + part.setUnlocalizedName(name).setRegistryName(new ResourceLocation(Reference.MOD_ID,name)); + event.getRegistry().register(part); + + if(TinkerTools.pattern != null) { + armorPartPatterns.add(Pair.of(TinkerTools.pattern, part)); + } + TinkerRegistry.registerToolPart(part); + TinkersDefense.proxy.registerArmorPartModel(part); + TinkerRegistry.registerStencilTableCrafting(Pattern.setTagForPart(new ItemStack(TinkerTools.pattern), (Item) part)); + + // TinkerRegistry.registerTableCasting(output, cast, fluid, amount); + toolParts.add(part); + itemList.add(part); + return part; } + private void registerStencil(Item pattern, ArmorPart toolPart) { + for(ToolCore toolCore : TinkerRegistry.getTools()) { + for(PartMaterialType partMaterialType : toolCore.getRequiredComponents()) { + if(partMaterialType.getPossibleParts().contains(toolPart)) { + ItemStack stencil = new ItemStack(pattern); + Pattern.setTagForPart(stencil, toolPart); + TinkerRegistry.registerStencilTableCrafting(stencil); + return; + } + } + } + } } diff --git a/src/main/java/lance5057/tDefense/core/tileentities/ArmorStationTile.java b/src/main/java/lance5057/tDefense/core/tileentities/ArmorStationTile.java index e2d3654..901a772 100644 --- a/src/main/java/lance5057/tDefense/core/tileentities/ArmorStationTile.java +++ b/src/main/java/lance5057/tDefense/core/tileentities/ArmorStationTile.java @@ -1,29 +1,83 @@ package lance5057.tDefense.core.tileentities; +import lance5057.tDefense.core.gui.ArmorStationContainer; import lance5057.tDefense.core.gui.ArmorStationGui; +import net.minecraft.block.Block; +import net.minecraft.block.BlockPane; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import net.minecraftforge.common.property.IExtendedBlockState; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import slimeknights.tconstruct.tools.common.tileentity.TileToolStation; -public class ArmorStationTile extends TileToolStation { +import slimeknights.mantle.common.IInventoryGui; +import slimeknights.tconstruct.library.client.ToolBuildGuiInfo; +import slimeknights.tconstruct.shared.block.BlockTable; +import slimeknights.tconstruct.shared.block.PropertyTableItem; +import slimeknights.tconstruct.shared.inventory.ConfigurableInvWrapperCapability; +import slimeknights.tconstruct.shared.tileentity.TileTable; +import slimeknights.tconstruct.tools.common.client.GuiButtonRepair; +import slimeknights.tconstruct.tools.common.client.GuiToolStation; +import slimeknights.tconstruct.tools.common.inventory.ContainerToolStation; - public ArmorStationTile() { - inventoryTitle = "armorstation.name"; - } +public class ArmorStationTile extends TileTable implements IInventoryGui { - @Override - @SideOnly(Side.CLIENT) - public GuiContainer createGui(InventoryPlayer inventoryPlayer, World world, BlockPos pos) { - return new ArmorStationGui(inventoryPlayer, world, pos, this); - } + public ArmorStationTile() { + super("gui.toolstation.name", 6); + this.itemHandler = new ConfigurableInvWrapperCapability(this, false, false); + } + + @Override + public Container createContainer(InventoryPlayer inventoryplayer, World world, BlockPos pos) { + return new ArmorStationContainer(inventoryplayer, this); + } + + @Override + @SideOnly(Side.CLIENT) + public GuiContainer createGui(InventoryPlayer inventoryplayer, World world, BlockPos pos) { + return new ArmorStationGui(inventoryplayer, world, pos, this); + } + + @Override + protected IExtendedBlockState setInventoryDisplay(IExtendedBlockState state) { + PropertyTableItem.TableItems toDisplay = new PropertyTableItem.TableItems(); - @Override - public Container createContainer(InventoryPlayer inventoryPlayer, World world, BlockPos pos) { - return new ArmorStationContainer(inventoryPlayer, this, false); + ToolBuildGuiInfo info = GuiButtonRepair.info; + /* Disabled for now + // todo: evaluate this again + if(Minecraft.getMinecraft().currentScreen instanceof GuiToolStation) { + info = ((GuiToolStation) Minecraft.getMinecraft().currentScreen).currentInfo; + }*/ + float s = 0.46875f; + + for(int i = 0; i < info.positions.size(); i++) { + ItemStack stackInSlot = getStackInSlot(i); + PropertyTableItem.TableItem item = getTableItem(stackInSlot, this.getWorld(), null); + if(item != null) { + item.x = (33 - info.positions.get(i).getX()) / 61f; + item.z = (42 - info.positions.get(i).getY()) / 61f; + item.s *= s; + + if(i == 0 || info != GuiButtonRepair.info) { + item.s *= 1.3f; + } + + // correct itemblock because scaling + if(stackInSlot.getItem() instanceof ItemBlock && !(Block.getBlockFromItem(stackInSlot.getItem()) instanceof BlockPane)) { + item.y = -(1f - item.s) / 2f; + } + + //item.s *= 2/5f; + toDisplay.items.add(item); + } } + + // add inventory if needed + return state.withProperty(BlockTable.INVENTORY, toDisplay); + } }
\ No newline at end of file diff --git a/src/main/java/lance5057/tDefense/core/tools/TDTools.java b/src/main/java/lance5057/tDefense/core/tools/TDTools.java index bfa650c..b93e92b 100644 --- a/src/main/java/lance5057/tDefense/core/tools/TDTools.java +++ b/src/main/java/lance5057/tDefense/core/tools/TDTools.java @@ -1,11 +1,17 @@ package lance5057.tDefense.core.tools; import java.util.ArrayList; +import java.util.List; import com.google.common.eventbus.Subscribe; import lance5057.tDefense.Reference; import lance5057.tDefense.TinkersDefense; +import lance5057.tDefense.core.blocks.ArmorStationBlock; +import lance5057.tDefense.core.library.CustomArmorTextureCreator; +import lance5057.tDefense.core.library.TDRegistry; +import lance5057.tDefense.core.network.ArmorStationSelectionPacket; +import lance5057.tDefense.core.tileentities.ArmorStationTile; import lance5057.tDefense.core.tools.armor.cloth.TinkersHood; import lance5057.tDefense.core.tools.armor.cloth.TinkersRobe; import lance5057.tDefense.core.tools.armor.cloth.TinkersShawl; @@ -21,11 +27,10 @@ import lance5057.tDefense.core.tools.basic.RoundShield; import lance5057.tDefense.core.tools.basic.Shears; import lance5057.tDefense.core.tools.basic.TowerShield; import lance5057.tDefense.core.tools.basic.Zweihander; -import lance5057.tDefense.core.tools.baubles.Amulet; -import lance5057.tDefense.core.tools.baubles.Ring; import lance5057.tDefense.core.tools.baubles.Sheathe; -import lance5057.tDefense.util.TDRegistry; +import net.minecraft.block.Block; import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.RegistryEvent; @@ -33,45 +38,54 @@ import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; +import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.registries.IForgeRegistry; +import slimeknights.tconstruct.common.TinkerNetwork; import slimeknights.tconstruct.library.TinkerRegistry; import slimeknights.tconstruct.library.client.CustomTextureCreator; import slimeknights.tconstruct.library.tools.ToolCore; @Mod.EventBusSubscriber(modid = Reference.MOD_ID) -//@Pulse(id = TDTools.PulseId, description = "All the tools and everything related to it.") -public class TDTools { - +// @Pulse(id = TDTools.PulseId, description = "All the tools and everything +// related to it.") +public class TDTools +{ + public static final List<ToolCore> tools = new ArrayList<>(); + public static final List<ArmorCore> armors = new ArrayList<>(); TDToolEvents events = new TDToolEvents(); - // Tools - public static ToolCore roundshield; - public static ToolCore heatershield; - public static ToolCore towershield; - public static ToolCore zweihander; - public static ToolCore shears; - public static ToolCore fishingRod; - - public static ArmorCore hood; - public static ArmorCore shawl; - public static ArmorCore robe; - public static ArmorCore shoes; - - public static ArmorCore coif; - public static ArmorCore hauberk; - public static ArmorCore chausses; - //public static ToolCore boots; - - public static ArmorCore helm; - public static ArmorCore breastplate; - public static ArmorCore grieves; - public static ArmorCore sabatons; - - //baubles - public static ToolCore sheathe; - public static ToolCore ring; - public static ToolCore amulet; + public static ArmorStationBlock station; + public static Item stationItem; + + // Tools + public static ToolCore roundshield; + public static ToolCore heatershield; + public static ToolCore towershield; + public static ToolCore zweihander; + public static ToolCore shears; + public static ToolCore fishingRod; + + public static ArmorCore hood; + public static ArmorCore shawl; + public static ArmorCore robe; + public static ArmorCore shoes; + + public static ArmorCore coif; + public static ArmorCore hauberk; + public static ArmorCore chausses; + // public static ToolCore boots; + + public static ArmorCore helm; + public static ArmorCore breastplate; + public static ArmorCore grieves; + public static ArmorCore sabatons; + + // baubles + public static ToolCore sheathe; +// public static ToolCore ring; +// public static ToolCore amulet; + static ArrayList<Item> itemList = new ArrayList<Item>(); // Tool Parts @@ -88,42 +102,46 @@ public class TDTools { // PRE-INITIALIZATION @Subscribe - public void preInit(FMLPreInitializationEvent event) { + public void preInit(FMLPreInitializationEvent event) + { } - private void regTools() { + private void regTools() + { } - + public void registerItems(final RegistryEvent.Register<Item> event) { + stationItem = new ItemBlock(station).setUnlocalizedName("stationitem").setRegistryName("stationitem"); + roundshield = new RoundShield(); heatershield = new HeaterShield(); towershield = new TowerShield(); zweihander = new Zweihander(); shears = new Shears(); fishingRod = new FishingRod(); - + hood = new TinkersHood(); shawl = new TinkersShawl(); robe = new TinkersRobe(); shoes = new TinkersShoes(); - -// coif = new TinkersCoif(); -// hauberk = new TinkersHauberk(); -// chausses = new TinkersChausses(); - //boots = new TinkersBoots(); - + + // coif = new TinkersCoif(); + // hauberk = new TinkersHauberk(); + // chausses = new TinkersChausses(); + // boots = new TinkersBoots(); + helm = new TinkersHelm(); breastplate = new TinkersBreastplate(); grieves = new TinkersGrieves(); sabatons = new TinkersSabatons(); - + sheathe = new Sheathe(); - ring = new Ring(); - amulet = new Amulet(); - +// ring = new Ring(); +// amulet = new Amulet(); + regTool(roundshield, "roundshield", event); regTool(heatershield, "heatershield", event); regTool(towershield, "towershield", event); @@ -132,72 +150,118 @@ public class TDTools { regTool(fishingRod, "fishingRod", event); regArmor(hood, "hood", event); + CustomArmorTextureCreator.registerTexture(new ResourceLocation(Reference.MOD_ID, "armor/hood/_hood_cloth")); + CustomArmorTextureCreator.registerTexture(new ResourceLocation(Reference.MOD_ID, "armor/hood/_hood_trim")); + CustomArmorTextureCreator.registerTexture(new ResourceLocation(Reference.MOD_ID, "armor/hood/_hood_metal")); + regArmor(shawl, "shawl", event); - regArmor(robe, "robe", event); - regArmor(shoes, "shoes", event); + CustomArmorTextureCreator.registerTexture(new ResourceLocation(Reference.MOD_ID, "armor/shawl/_shawl_cloth")); + CustomArmorTextureCreator.registerTexture(new ResourceLocation(Reference.MOD_ID, "armor/shawl/_shawl_trim")); + CustomArmorTextureCreator.registerTexture(new ResourceLocation(Reference.MOD_ID, "armor/shawl/_shawl_metal")); - //regTool(boots, "boots", event); + regArmor(robe, "robe", event); + CustomArmorTextureCreator.registerTexture(new ResourceLocation(Reference.MOD_ID, "armor/robe/_robe_cloth")); + CustomArmorTextureCreator.registerTexture(new ResourceLocation(Reference.MOD_ID, "armor/robe/_robe_trim")); + CustomArmorTextureCreator.registerTexture(new ResourceLocation(Reference.MOD_ID, "armor/robe/_robe_metal")); + regArmor(shoes, "shoes", event); + CustomArmorTextureCreator.registerTexture(new ResourceLocation(Reference.MOD_ID, "armor/shoes/_shoes_cloth")); + CustomArmorTextureCreator.registerTexture(new ResourceLocation(Reference.MOD_ID, "armor/shoes/_shoes_trim")); + CustomArmorTextureCreator.registerTexture(new ResourceLocation(Reference.MOD_ID, "armor/shoes/_shoes_metal")); + CustomArmorTextureCreator.registerTexture(new ResourceLocation(Reference.MOD_ID, "armor/shoes/_shoes_string")); + + // regTool(boots, "boots", event); + regArmor(helm, "helm", event); + CustomArmorTextureCreator.registerTexture(new ResourceLocation(Reference.MOD_ID, "armor/helm/_helm_chain")); + CustomArmorTextureCreator.registerTexture(new ResourceLocation(Reference.MOD_ID, "armor/helm/_helm_plate")); + CustomArmorTextureCreator.registerTexture(new ResourceLocation(Reference.MOD_ID, "armor/helm/_helm_top")); + CustomArmorTextureCreator.registerTexture(new ResourceLocation(Reference.MOD_ID, "armor/helm/_helm_visor")); + regArmor(breastplate, "breastplate", event); + CustomArmorTextureCreator.registerTexture(new ResourceLocation(Reference.MOD_ID, "armor/breastplate/_breastplate_chain")); + CustomArmorTextureCreator.registerTexture(new ResourceLocation(Reference.MOD_ID, "armor/breastplate/_breastplate_plate")); + CustomArmorTextureCreator.registerTexture(new ResourceLocation(Reference.MOD_ID, "armor/breastplate/_breastplate_smallplate")); + CustomArmorTextureCreator.registerTexture(new ResourceLocation(Reference.MOD_ID, "armor/breastplate/_breastplate_trim")); + regArmor(grieves, "grieves", event); regArmor(sabatons, "sabatons", event); - -// CustomTextureCreator.registerTexture(new ResourceLocation("tinkersdefense", "items/battleaxe/_halbard_accessory")); - CustomTextureCreator.registerTexture(new ResourceLocation("tinkersdefense", "armor/helm/_helm_chain")); - CustomTextureCreator.registerTexture(new ResourceLocation("tinkersdefense", "armor/helm/_helm_plate")); - CustomTextureCreator.registerTexture(new ResourceLocation("tinkersdefense", "armor/helm/_helm_top")); - CustomTextureCreator.registerTexture(new ResourceLocation("tinkersdefense", "armor/helm/_helm_visor")); -// - regTool(sheathe, "sheathe", event); - regTool(ring, "ring", event); - regTool(amulet, "amulet", event); + // CustomTextureCreator.registerTexture(new + // ResourceLocation("tinkersdefense", + // "items/battleaxe/_halbard_accessory")); + + // + regTool(sheathe, "sheathe", event); +// regTool(ring, "ring", event); +// regTool(amulet, "amulet", event); + final IForgeRegistry registry = event.getRegistry(); - for (Item i : itemList) { + for (Item i : itemList) + { registry.register(i); } + + registry.register(stationItem); } - private static void regTool(ToolCore tool, String name, RegistryEvent.Register<Item> event) { - tool.setRegistryName(new ResourceLocation("tinkersdefense:" + name)); + public void registerBlocks(final RegistryEvent.Register<Block> event) + { + IForgeRegistry<Block> registry = event.getRegistry(); + + station = new ArmorStationBlock(); + + registry.register(station); + + GameRegistry.registerTileEntity(ArmorStationTile.class, "armorstationtile"); + + } + + private static void regTool(ToolCore tool, String name, RegistryEvent.Register<Item> event) + { + tool.setRegistryName(new ResourceLocation(Reference.MOD_ID,name)); event.getRegistry().register(tool); TinkerRegistry.registerTool(tool); TinkersDefense.proxy.registerToolModel(tool); - //itemList.add(tool); - } + tools.add(tool); + } - private static void regArmor(ArmorCore armor, String name, RegistryEvent.Register<Item> event) { - armor.setRegistryName(new ResourceLocation("tinkersdefense:" + name)); + private static void regArmor(ArmorCore armor, String name, RegistryEvent.Register<Item> event) + { + armor.setRegistryName(new ResourceLocation(Reference.MOD_ID,name)); event.getRegistry().register(armor); TDRegistry.registerTool(armor); TinkersDefense.proxy.registerArmorModel(armor); - //itemList.add(tool); - } - - private void registerModifiers() { + armors.add(armor); + } + + private void registerModifiers() + { } // INITIALIZATION @Subscribe - public void init(FMLInitializationEvent event) { + public void init(FMLInitializationEvent event) + { // register items - - // register blocks + // register blocks - // register entities + // register entities - // proxy.preInit(); + // proxy.preInit(); regToolBuilding(); regRecipies(); // proxy.init(); + + TinkerNetwork.instance.registerPacket(ArmorStationSelectionPacket.class); } - private void regToolBuilding() { + private void regToolBuilding() + { TinkerRegistry.registerToolCrafting(roundshield); TinkerRegistry.registerToolForgeCrafting(heatershield); TinkerRegistry.registerToolForgeCrafting(towershield); @@ -209,28 +273,29 @@ public class TDTools { TDRegistry.registerArmorCrafting(shawl); TDRegistry.registerArmorCrafting(robe); TDRegistry.registerArmorCrafting(shoes); - - //TinkerRegistry.registerToolCrafting(boots); - - TDRegistry.registerArmorForgeCrafting(helm); + + // TinkerRegistry.registerToolCrafting(boots); + + TDRegistry.registerArmorCrafting(helm); TDRegistry.registerArmorForgeCrafting(breastplate); TDRegistry.registerArmorForgeCrafting(grieves); TDRegistry.registerArmorForgeCrafting(sabatons); - + TinkerRegistry.registerToolCrafting(sheathe); - TinkerRegistry.registerToolCrafting(ring); - TinkerRegistry.registerToolCrafting(amulet); +// TinkerRegistry.registerToolCrafting(ring); +// TinkerRegistry.registerToolCrafting(amulet); } - private void regRecipies() { + private void regRecipies() + { } // POST-INITIALIZATION @Subscribe - public void postInit(FMLPostInitializationEvent event) { + public void postInit(FMLPostInitializationEvent event) + { // proxy.postInit(); - MinecraftForge.EVENT_BUS.register(events); diff --git a/src/main/java/lance5057/tDefense/core/tools/armor/cloth/TinkersHood.java b/src/main/java/lance5057/tDefense/core/tools/armor/cloth/TinkersHood.java index 482055b..a5f576a 100644 --- a/src/main/java/lance5057/tDefense/core/tools/armor/cloth/TinkersHood.java +++ b/src/main/java/lance5057/tDefense/core/tools/armor/cloth/TinkersHood.java @@ -1,15 +1,18 @@ package lance5057.tDefense.core.tools.armor.cloth; -import java.util.ArrayList; import java.util.List; -import lance5057.tDefense.core.materials.ArmorMaterialStats.ClothMaterialStats; -import lance5057.tDefense.core.materials.ArmorMaterialStats.HelmMaterialStats; +import lance5057.tDefense.core.library.ArmorNBT; +import lance5057.tDefense.core.library.ArmorTags; +import lance5057.tDefense.core.library.ArmorTextureBuilder; +import lance5057.tDefense.core.materials.stats.ArmorMaterialStats; +import lance5057.tDefense.core.materials.stats.FabricMaterialStats; import lance5057.tDefense.core.parts.TDParts; -import lance5057.tDefense.core.tools.armor.renderers.ArmorRenderer; import lance5057.tDefense.core.tools.armor.renderers.cloth.ModelTinkersHood; import lance5057.tDefense.core.tools.bases.ArmorCore; -import lance5057.tDefense.util.ArmorNBT; +import net.minecraft.client.Minecraft; +import net.minecraft.client.model.ModelBiped; +import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -17,83 +20,131 @@ import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.DamageSource; +import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import slimeknights.tconstruct.library.materials.ExtraMaterialStats; import slimeknights.tconstruct.library.materials.Material; +import slimeknights.tconstruct.library.materials.MaterialTypes; import slimeknights.tconstruct.library.tinkering.PartMaterialType; +import slimeknights.tconstruct.library.utils.TagUtil; -public class TinkersHood extends ArmorCore { +public class TinkersHood extends ArmorCore +{ int induceDamage = 0; - public TinkersHood() { - super(EntityEquipmentSlot.HEAD, new PartMaterialType(TDParts.cloth, ClothMaterialStats.TYPE), - new PartMaterialType(TDParts.cloth, ClothMaterialStats.TYPE), PartMaterialType.extra(TDParts.rivets)); + public TinkersHood() + { + super(EntityEquipmentSlot.HEAD, new PartMaterialType(TDParts.fabric, FabricMaterialStats.TYPE), new PartMaterialType(TDParts.fabric, FabricMaterialStats.TYPE), PartMaterialType + .extra(TDParts.rivets)); setUnlocalizedName("tinkerhood"); } @Override - public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) { + public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) + { super.onUpdate(stack, world, entity, par4, par5); } @SideOnly(Side.CLIENT) @Override - public List<String> getArmorTexture(ItemStack stack) { - List<String> textures = new ArrayList(); - textures.add("textures/armor/hood/_hood_cloth.png"); - textures.add("textures/armor/hood/_hood_trim.png"); - textures.add("textures/armor/hood/_hood_metal.png"); + public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, EntityEquipmentSlot armorSlot, ModelBiped _default) + { + return new ModelTinkersHood(itemStack); + } - return textures; + @Override + public NBTTagCompound buildTag(List<Material> materials) + { + ArmorNBT data = buildDefaultTag(materials); + return data.get(); } - @SideOnly(Side.CLIENT) @Override - public ArmorRenderer getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack) { - return new ModelTinkersHood(itemStack); + public EntityEquipmentSlot getArmorSlot(ItemStack stack, EntityEquipmentSlot armorType) + { + return EntityEquipmentSlot.HEAD; } @Override - public NBTTagCompound buildTag(List<Material> materials) { - ArmorNBT data = buildDefaultArmorTag(materials, HelmMaterialStats.TYPE); - return data.get(); + protected ArmorNBT buildDefaultTag(List<Material> materials) + { + ArmorNBT data = new ArmorNBT(); + + if (materials.size() >= 2) + { + ArmorMaterialStats handle = materials.get(0).getStatsOrUnknown(FabricMaterialStats.TYPE); + ArmorMaterialStats head = materials.get(1).getStatsOrUnknown(FabricMaterialStats.TYPE); + // start with head + data.head(head, handle); + + // add in accessoires if present + if (materials.size() >= 3) + { + ExtraMaterialStats binding = materials.get(2).getStatsOrUnknown(MaterialTypes.EXTRA); + data.extra(binding); + } + + // calculate handle impact + // data.head(handle); + } + + // 3 free modifiers + data.modifiers = DEFAULT_MODIFIERS; + + return data; } @Override - public EntityEquipmentSlot getArmorSlot(ItemStack stack, EntityEquipmentSlot armorType) { - return EntityEquipmentSlot.HEAD; + @SideOnly(Side.CLIENT) + public NBTTagCompound setupTexture(List<Material> materials) + { + NBTTagCompound base = new NBTTagCompound(); + + ResourceLocation rc = ArmorTextureBuilder.createArmorTexture("hood", new String[] { "cloth", "trim", "metal" }, materials); + + if (rc != null) + { + base.setString(ArmorTags.TexLoc, rc.toString()); + return base; + } + return null; } @Override - public void getTooltipDetailed(ItemStack stack, List<String> tooltips) { + public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) + { // TODO Auto-generated method stub - + return null; } @Override - public void getTooltipComponents(ItemStack stack, List<String> tooltips) { + public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) + { // TODO Auto-generated method stub - + return 0; } @Override - public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, - int slot) { + public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) + { // TODO Auto-generated method stub - return null; + } @Override - public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) { + public float damagePotential() + { // TODO Auto-generated method stub return 0; } @Override - public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) { + public double attackSpeed() + { // TODO Auto-generated method stub - + return 0; } } diff --git a/src/main/java/lance5057/tDefense/core/tools/armor/cloth/TinkersRobe.java b/src/main/java/lance5057/tDefense/core/tools/armor/cloth/TinkersRobe.java index 6703fd6..37e9b6e 100644 --- a/src/main/java/lance5057/tDefense/core/tools/armor/cloth/TinkersRobe.java +++ b/src/main/java/lance5057/tDefense/core/tools/armor/cloth/TinkersRobe.java @@ -3,25 +3,35 @@ package lance5057.tDefense.core.tools.armor.cloth; import java.util.ArrayList; import java.util.List; -import lance5057.tDefense.core.materials.ArmorMaterialStats.ClothMaterialStats; -import lance5057.tDefense.core.materials.ArmorMaterialStats.LegsMaterialStats; +import lance5057.tDefense.core.library.ArmorNBT; +import lance5057.tDefense.core.library.ArmorTags; +import lance5057.tDefense.core.library.ArmorTextureBuilder; +import lance5057.tDefense.core.materials.stats.ArmorMaterialStats; +import lance5057.tDefense.core.materials.stats.FabricMaterialStats; +import lance5057.tDefense.core.materials.stats.LegsMaterialStats; import lance5057.tDefense.core.parts.TDParts; import lance5057.tDefense.core.tools.armor.renderers.ArmorRenderer; import lance5057.tDefense.core.tools.armor.renderers.cloth.ModelTinkersRobe; import lance5057.tDefense.core.tools.bases.ArmorCore; -import lance5057.tDefense.util.ArmorNBT; +import net.minecraft.client.model.ModelBiped; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; import net.minecraft.util.DamageSource; +import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; +import net.minecraftforge.common.ISpecialArmor.ArmorProperties; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import slimeknights.tconstruct.library.materials.ExtraMaterialStats; import slimeknights.tconstruct.library.materials.Material; +import slimeknights.tconstruct.library.materials.MaterialTypes; import slimeknights.tconstruct.library.tinkering.PartMaterialType; +import slimeknights.tconstruct.library.utils.TagUtil; public class TinkersRobe extends ArmorCore { @@ -30,11 +40,13 @@ public class TinkersRobe extends ArmorCore public TinkersRobe() { - super(EntityEquipmentSlot.CHEST,new PartMaterialType(TDParts.cloth, ClothMaterialStats.TYPE), - new PartMaterialType(TDParts.cloth, ClothMaterialStats.TYPE), + super(EntityEquipmentSlot.LEGS,new PartMaterialType(TDParts.fabric, FabricMaterialStats.TYPE), + new PartMaterialType(TDParts.fabric, FabricMaterialStats.TYPE), PartMaterialType.extra(TDParts.clasp)); setUnlocalizedName("tinkerrobe"); } + + @Override public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) @@ -43,27 +55,32 @@ public class TinkersRobe extends ArmorCore } - @SideOnly(Side.CLIENT) @Override - public List<String> getArmorTexture(ItemStack stack) { - List<String> textures = new ArrayList(); - textures.add("textures/armor/robe/_robe_cloth.png"); - textures.add("textures/armor/robe/_robe_trim.png"); - textures.add("textures/armor/robe/_robe_metal.png"); + @SideOnly(Side.CLIENT) + public NBTTagCompound setupTexture(List<Material> materials) + { + NBTTagCompound base = new NBTTagCompound(); - return textures; - } + ResourceLocation rc = ArmorTextureBuilder.createArmorTexture("robe", new String[] { "cloth", "trim", "metal" }, materials); + if (rc != null) + { + base.setString(ArmorTags.TexLoc, rc.toString()); + return base; + } + return null; + } + @SideOnly(Side.CLIENT) @Override - public ArmorRenderer getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack) + public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, EntityEquipmentSlot armorSlot, ModelBiped _default) { return new ModelTinkersRobe(itemStack); } @Override public NBTTagCompound buildTag(List<Material> materials) { - ArmorNBT data = buildDefaultArmorTag(materials, LegsMaterialStats.TYPE); + ArmorNBT data = buildDefaultTag(materials); return data.get(); } @@ -71,35 +88,68 @@ public class TinkersRobe extends ArmorCore public EntityEquipmentSlot getArmorSlot(ItemStack stack, EntityEquipmentSlot armorType) { return EntityEquipmentSlot.LEGS; } + + @Override + protected ArmorNBT buildDefaultTag(List<Material> materials) + { + ArmorNBT data = new ArmorNBT(); + + if (materials.size() >= 2) + { + ArmorMaterialStats handle = materials.get(0).getStatsOrUnknown(FabricMaterialStats.TYPE); + ArmorMaterialStats head = materials.get(1).getStatsOrUnknown(FabricMaterialStats.TYPE); + // start with head + data.head(head, handle); + + // add in accessoires if present + if (materials.size() >= 3) + { + ExtraMaterialStats binding = materials.get(2).getStatsOrUnknown(MaterialTypes.EXTRA); + data.extra(binding); + } + + // calculate handle impact + //data.head(handle); + } + + // 3 free modifiers + data.modifiers = DEFAULT_MODIFIERS; + + return data; + } @Override - public void getTooltipDetailed(ItemStack stack, List<String> tooltips) { + public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) + { // TODO Auto-generated method stub - + return null; } @Override - public void getTooltipComponents(ItemStack stack, List<String> tooltips) { + public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) + { // TODO Auto-generated method stub - + return 0; } @Override - public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, - int slot) { + public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) + { // TODO Auto-generated method stub - return null; + } @Override - public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) { + public float damagePotential() + { // TODO Auto-generated method stub return 0; } @Override - public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) { + public double attackSpeed() + { // TODO Auto-generated method stub - + return 0; } } diff --git a/src/main/java/lance5057/tDefense/core/tools/armor/cloth/TinkersShawl.java b/src/main/java/lance5057/tDefense/core/tools/armor/cloth/TinkersShawl.java index 825d5e4..eb1e1b6 100644 --- a/src/main/java/lance5057/tDefense/core/tools/armor/cloth/TinkersShawl.java +++ b/src/main/java/lance5057/tDefense/core/tools/armor/cloth/TinkersShawl.java @@ -3,13 +3,16 @@ package lance5057.tDefense.core.tools.armor.cloth; import java.util.ArrayList; import java.util.List; -import lance5057.tDefense.core.materials.ArmorMaterialStats.ChestMaterialStats; -import lance5057.tDefense.core.materials.ArmorMaterialStats.ClothMaterialStats; +import lance5057.tDefense.core.library.ArmorNBT; +import lance5057.tDefense.core.library.ArmorTags; +import lance5057.tDefense.core.library.ArmorTextureBuilder; +import lance5057.tDefense.core.materials.stats.ArmorMaterialStats; +import lance5057.tDefense.core.materials.stats.ChestMaterialStats; +import lance5057.tDefense.core.materials.stats.FabricMaterialStats; import lance5057.tDefense.core.parts.TDParts; import lance5057.tDefense.core.tools.armor.renderers.ArmorRenderer; import lance5057.tDefense.core.tools.armor.renderers.cloth.ModelTinkersShawl; import lance5057.tDefense.core.tools.bases.ArmorCore; -import lance5057.tDefense.util.ArmorNBT; import net.minecraft.client.model.ModelBiped; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; @@ -17,12 +20,18 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; import net.minecraft.util.DamageSource; +import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; +import net.minecraftforge.common.ISpecialArmor.ArmorProperties; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import slimeknights.tconstruct.library.materials.ExtraMaterialStats; import slimeknights.tconstruct.library.materials.Material; +import slimeknights.tconstruct.library.materials.MaterialTypes; import slimeknights.tconstruct.library.tinkering.PartMaterialType; +import slimeknights.tconstruct.library.utils.TagUtil; public class TinkersShawl extends ArmorCore { @@ -30,7 +39,7 @@ public class TinkersShawl extends ArmorCore public TinkersShawl() { - super(EntityEquipmentSlot.LEGS,new PartMaterialType(TDParts.cloth, ClothMaterialStats.TYPE), new PartMaterialType(TDParts.cloth, ClothMaterialStats.TYPE), PartMaterialType.extra(TDParts.armorPlate)); + super(EntityEquipmentSlot.CHEST,new PartMaterialType(TDParts.fabric, FabricMaterialStats.TYPE), new PartMaterialType(TDParts.fabric, FabricMaterialStats.TYPE), PartMaterialType.extra(TDParts.armorPlate)); setUnlocalizedName("tinkershawl"); } @@ -41,27 +50,32 @@ public class TinkersShawl extends ArmorCore } - @SideOnly(Side.CLIENT) @Override - public List<String> getArmorTexture(ItemStack stack) { - List<String> textures = new ArrayList(); - textures.add("textures/armor/shawl/_shawl_cloth.png"); - textures.add("textures/armor/shawl/_shawl_trim.png"); - textures.add("textures/armor/shawl/_shawl_metal.png"); + @SideOnly(Side.CLIENT) + public NBTTagCompound setupTexture(List<Material> materials) + { + NBTTagCompound base = new NBTTagCompound(); + + ResourceLocation rc = ArmorTextureBuilder.createArmorTexture("shawl", new String[] { "cloth", "trim", "metal" }, materials); - return textures; + if (rc != null) + { + base.setString(ArmorTags.TexLoc, rc.toString()); + return base; + } + return null; } @SideOnly(Side.CLIENT) @Override - public ArmorRenderer getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack) + public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, EntityEquipmentSlot armorSlot, ModelBiped _default) { return new ModelTinkersShawl(itemStack); } @Override public NBTTagCompound buildTag(List<Material> materials) { - ArmorNBT data = buildDefaultArmorTag(materials, ChestMaterialStats.TYPE); + ArmorNBT data = buildDefaultTag(materials); return data.get(); } @@ -71,33 +85,64 @@ public class TinkersShawl extends ArmorCore } @Override - public void getTooltipDetailed(ItemStack stack, List<String> tooltips) { + public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, + int slot) { // TODO Auto-generated method stub - + return null; } @Override - public void getTooltipComponents(ItemStack stack, List<String> tooltips) { + public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) { // TODO Auto-generated method stub - + return 0; } @Override - public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, - int slot) { + public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) { // TODO Auto-generated method stub - return null; + } @Override - public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) { + public float damagePotential() + { // TODO Auto-generated method stub return 0; } @Override - public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) { + public double attackSpeed() + { // TODO Auto-generated method stub - + return 0; + } + + @Override + protected ArmorNBT buildDefaultTag(List<Material> materials) + { + ArmorNBT data = new ArmorNBT(); + + if (materials.size() >= 2) + { + ArmorMaterialStats handle = materials.get(0).getStatsOrUnknown(FabricMaterialStats.TYPE); + ArmorMaterialStats head = materials.get(1).getStatsOrUnknown(FabricMaterialStats.TYPE); + // start with head + data.head(head, handle); + + // add in accessoires if present + if (materials.size() >= 3) + { + ExtraMaterialStats binding = materials.get(2).getStatsOrUnknown(MaterialTypes.EXTRA); + data.extra(binding); + } + + // calculate handle impact + //data.head(handle); + } + + // 3 free modifiers + data.modifiers = DEFAULT_MODIFIERS; + + return data; } } diff --git a/src/main/java/lance5057/tDefense/core/tools/armor/cloth/TinkersShoes.java b/src/main/java/lance5057/tDefense/core/tools/armor/cloth/TinkersShoes.java index c7c8606..0c3c85d 100644 --- a/src/main/java/lance5057/tDefense/core/tools/armor/cloth/TinkersShoes.java +++ b/src/main/java/lance5057/tDefense/core/tools/armor/cloth/TinkersShoes.java @@ -1,15 +1,16 @@ package lance5057.tDefense.core.tools.armor.cloth; -import java.util.ArrayList; import java.util.List; -import lance5057.tDefense.core.materials.ArmorMaterialStats.ClothMaterialStats; -import lance5057.tDefense.core.materials.ArmorMaterialStats.FeetMaterialStats; +import lance5057.tDefense.core.library.ArmorNBT; +import lance5057.tDefense.core.library.ArmorTags; +import lance5057.tDefense.core.library.ArmorTextureBuilder; +import lance5057.tDefense.core.materials.stats.ArmorMaterialStats; +import lance5057.tDefense.core.materials.stats.FabricMaterialStats; import lance5057.tDefense.core.parts.TDParts; import lance5057.tDefense.core.tools.armor.renderers.ArmorRenderer; import lance5057.tDefense.core.tools.armor.renderers.cloth.ModelTinkersShoes; import lance5057.tDefense.core.tools.bases.ArmorCore; -import lance5057.tDefense.util.ArmorNBT; import net.minecraft.client.model.ModelBiped; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; @@ -17,12 +18,17 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; import net.minecraft.util.DamageSource; +import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import slimeknights.tconstruct.library.materials.ExtraMaterialStats; import slimeknights.tconstruct.library.materials.Material; +import slimeknights.tconstruct.library.materials.MaterialTypes; import slimeknights.tconstruct.library.tinkering.PartMaterialType; +import slimeknights.tconstruct.library.utils.TagUtil; import slimeknights.tconstruct.tools.TinkerTools; public class TinkersShoes extends ArmorCore @@ -32,9 +38,9 @@ public class TinkersShoes extends ArmorCore public TinkersShoes() { - super(EntityEquipmentSlot.FEET,new PartMaterialType(TDParts.cloth, ClothMaterialStats.TYPE), + super(EntityEquipmentSlot.FEET,new PartMaterialType(TDParts.fabric, FabricMaterialStats.TYPE), PartMaterialType.extra(TDParts.rivets), - new PartMaterialType(TDParts.cloth, ClothMaterialStats.TYPE), + new PartMaterialType(TDParts.fabric, FabricMaterialStats.TYPE), PartMaterialType.bowstring(TinkerTools.bowString)); setUnlocalizedName("tinkershoes"); } @@ -46,27 +52,32 @@ public class TinkersShoes extends ArmorCore } - @SideOnly(Side.CLIENT) @Override - public List<String> getArmorTexture(ItemStack stack) { - List<String> textures = new ArrayList(); - textures.add("textures/armor/shoes/_shoes_cloth.png"); - textures.add("textures/armor/shoes/_shoes_trim.png"); - textures.add("textures/armor/shoes/_shoes_metal.png"); + @SideOnly(Side.CLIENT) + public NBTTagCompound setupTexture(List<Material> materials) + { + NBTTagCompound base = new NBTTagCompound(); + + ResourceLocation rc = ArmorTextureBuilder.createArmorTexture("shoes", new String[] { "cloth", "trim", "metal", "string" }, materials); - return textures; + if (rc != null) + { + base.setString(ArmorTags.TexLoc, rc.toString()); + return base; + } + return null; } @SideOnly(Side.CLIENT) @Override - public ArmorRenderer getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack) + public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, EntityEquipmentSlot armorSlot, ModelBiped _default) { return new ModelTinkersShoes(itemStack); } @Override public NBTTagCompound buildTag(List<Material> materials) { - ArmorNBT data = buildDefaultArmorTag(materials, FeetMaterialStats.TYPE); + ArmorNBT data = buildDefaultTag(materials); return data.get(); } @@ -76,33 +87,64 @@ public class TinkersShoes extends ArmorCore } @Override - public void getTooltipDetailed(ItemStack stack, List<String> tooltips) { + public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, + int slot) { // TODO Auto-generated method stub - + return null; } @Override - public void getTooltipComponents(ItemStack stack, List<String> tooltips) { + public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) { // TODO Auto-generated method stub - + return 0; } @Override - public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, - int slot) { + public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) { // TODO Auto-generated method stub - return null; + } @Override - public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) { + public float damagePotential() + { // TODO Auto-generated method stub return 0; } @Override - public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) { + public double attackSpeed() + { // TODO Auto-generated method stub - + return 0; + } + + @Override + protected ArmorNBT buildDefaultTag(List<Material> materials) + { + ArmorNBT data = new ArmorNBT(); + + if (materials.size() >= 2) + { + ArmorMaterialStats handle = materials.get(0).getStatsOrUnknown(FabricMaterialStats.TYPE); + ArmorMaterialStats head = materials.get(1).getStatsOrUnknown(FabricMaterialStats.TYPE); + // start with head + data.head(head, handle); + + // add in accessoires if present + if (materials.size() >= 3) + { + ExtraMaterialStats binding = materials.get(2).getStatsOrUnknown(MaterialTypes.EXTRA); + data.extra(binding); + } + + // calculate handle impact + //data.head(handle); + } + + // 3 free modifiers + data.modifiers = DEFAULT_MODIFIERS; + + return data; } } diff --git a/src/main/java/lance5057/tDefense/core/tools/armor/heavy/TinkersBreastplate.java b/src/main/java/lance5057/tDefense/core/tools/armor/heavy/TinkersBreastplate.java index a7df0f0..b64d130 100644 --- a/src/main/java/lance5057/tDefense/core/tools/armor/heavy/TinkersBreastplate.java +++ b/src/main/java/lance5057/tDefense/core/tools/armor/heavy/TinkersBreastplate.java @@ -1,91 +1,132 @@ package lance5057.tDefense.core.tools.armor.heavy; -import java.util.ArrayList; import java.util.List; -import lance5057.tDefense.core.materials.ArmorMaterialStats.ChestMaterialStats; +import lance5057.tDefense.core.library.ArmorNBT; +import lance5057.tDefense.core.materials.stats.ArmorMaterialStats; +import lance5057.tDefense.core.materials.stats.ChestMaterialStats; +import lance5057.tDefense.core.materials.stats.FabricMaterialStats; import lance5057.tDefense.core.parts.TDParts; -import lance5057.tDefense.core.tools.armor.renderers.ArmorRenderer; import lance5057.tDefense.core.tools.armor.renderers.heavy.ModelTinkersBreastplate; import lance5057.tDefense.core.tools.bases.ArmorCore; -import lance5057.tDefense.util.ArmorNBT; import net.minecraft.client.model.ModelBiped; +import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; import net.minecraft.util.DamageSource; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import slimeknights.tconstruct.library.materials.ExtraMaterialStats; import slimeknights.tconstruct.library.materials.Material; +import slimeknights.tconstruct.library.materials.MaterialTypes; import slimeknights.tconstruct.library.tinkering.PartMaterialType; +import slimeknights.tconstruct.library.utils.TagUtil; import slimeknights.tconstruct.tools.TinkerTools; -public class TinkersBreastplate extends ArmorCore { - public TinkersBreastplate() { - super(EntityEquipmentSlot.CHEST, new PartMaterialType(TinkerTools.largePlate, ChestMaterialStats.TYPE), - new PartMaterialType(TDParts.armorPlate, ChestMaterialStats.TYPE), - PartMaterialType.handle(TDParts.filigree), PartMaterialType.extra(TDParts.chainmail)); +public class TinkersBreastplate extends ArmorCore +{ + public TinkersBreastplate() + { + super(EntityEquipmentSlot.CHEST, new PartMaterialType(TinkerTools.largePlate, ChestMaterialStats.TYPE), new PartMaterialType(TDParts.armorPlate, ChestMaterialStats.TYPE), PartMaterialType + .handle(TDParts.filigree), PartMaterialType.extra(TDParts.chainmail)); setUnlocalizedName("tinkersbreastplate"); } @SideOnly(Side.CLIENT) @Override - public List<String> getArmorTexture(ItemStack stack) { - List<String> textures = new ArrayList(); - textures.add("textures/armor/breastplate/_breastplate_plate.png"); - textures.add("textures/armor/breastplate/_breastplate_smallplate.png"); - textures.add("textures/armor/breastplate/_breastplate_trim.png"); - textures.add("textures/armor/breastplate/_breastplate_chain.png"); - return textures; + public String getArmorTexture(ItemStack stack, Entity entity, EntityEquipmentSlot slot, String type) + { + String texture; + NBTTagList t = TagUtil.getBaseMaterialsTagList(stack); + texture = "textures/armor/breastplate/_breastplate_plate_" + t.getStringTagAt(0); + return texture; } @SideOnly(Side.CLIENT) @Override - public ArmorRenderer getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack) { + public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, EntityEquipmentSlot armorSlot, ModelBiped _default) + { return new ModelTinkersBreastplate(itemStack); } @Override - public NBTTagCompound buildTag(List<Material> materials) { - ArmorNBT data = buildDefaultArmorTag(materials, ChestMaterialStats.TYPE); + public NBTTagCompound buildTag(List<Material> materials) + { + ArmorNBT data = buildDefaultTag(materials); return data.get(); } @Override - public EntityEquipmentSlot getArmorSlot(ItemStack stack, EntityEquipmentSlot armorType) { + public EntityEquipmentSlot getArmorSlot(ItemStack stack, EntityEquipmentSlot armorType) + { return EntityEquipmentSlot.CHEST; } @Override - public void getTooltipDetailed(ItemStack stack, List<String> tooltips) { + public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) + { // TODO Auto-generated method stub - + return null; } @Override - public void getTooltipComponents(ItemStack stack, List<String> tooltips) { + public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) + { // TODO Auto-generated method stub - + return 0; } @Override - public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, - int slot) { + public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) + { // TODO Auto-generated method stub - return null; + } @Override - public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) { + public float damagePotential() + { // TODO Auto-generated method stub return 0; } @Override - public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) { + public double attackSpeed() + { // TODO Auto-generated method stub - + return 0; + } + + @Override + protected ArmorNBT buildDefaultTag(List<Material> materials) + { + ArmorNBT data = new ArmorNBT(); + + if (materials.size() >= 2) + { + ArmorMaterialStats handle = materials.get(0).getStatsOrUnknown(FabricMaterialStats.TYPE); + ArmorMaterialStats head = materials.get(1).getStatsOrUnknown(FabricMaterialStats.TYPE); + // start with head + data.head(head); + + // add in accessoires if present + if (materials.size() >= 3) + { + ExtraMaterialStats binding = materials.get(2).getStatsOrUnknown(MaterialTypes.EXTRA); + data.extra(binding); + } + + // calculate handle impact + data.head(handle); + } + + // 3 free modifiers + data.modifiers = DEFAULT_MODIFIERS; + + return data; } } diff --git a/src/main/java/lance5057/tDefense/core/tools/armor/heavy/TinkersGrieves.java b/src/main/java/lance5057/tDefense/core/tools/armor/heavy/TinkersGrieves.java index ccefbf7..88047a1 100644 --- a/src/main/java/lance5057/tDefense/core/tools/armor/heavy/TinkersGrieves.java +++ b/src/main/java/lance5057/tDefense/core/tools/armor/heavy/TinkersGrieves.java @@ -1,26 +1,31 @@ package lance5057.tDefense.core.tools.armor.heavy; -import java.util.ArrayList; import java.util.List; -import lance5057.tDefense.core.materials.ArmorMaterialStats.ClothMaterialStats; -import lance5057.tDefense.core.materials.ArmorMaterialStats.LegsMaterialStats; +import lance5057.tDefense.core.library.ArmorNBT; +import lance5057.tDefense.core.materials.stats.ArmorMaterialStats; +import lance5057.tDefense.core.materials.stats.FabricMaterialStats; +import lance5057.tDefense.core.materials.stats.LegsMaterialStats; import lance5057.tDefense.core.parts.TDParts; import lance5057.tDefense.core.tools.armor.renderers.ArmorRenderer; import lance5057.tDefense.core.tools.armor.renderers.heavy.ModelTinkersGrieves; import lance5057.tDefense.core.tools.bases.ArmorCore; -import lance5057.tDefense.util.ArmorNBT; import net.minecraft.client.model.ModelBiped; +import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; import net.minecraft.util.DamageSource; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import slimeknights.tconstruct.library.materials.ExtraMaterialStats; import slimeknights.tconstruct.library.materials.Material; +import slimeknights.tconstruct.library.materials.MaterialTypes; import slimeknights.tconstruct.library.tinkering.PartMaterialType; +import slimeknights.tconstruct.library.utils.TagUtil; public class TinkersGrieves extends ArmorCore { @@ -29,32 +34,29 @@ public class TinkersGrieves extends ArmorCore super(EntityEquipmentSlot.LEGS,new PartMaterialType(TDParts.armorPlate, LegsMaterialStats.TYPE), new PartMaterialType(TDParts.chainmail, LegsMaterialStats.TYPE), PartMaterialType.handle(TDParts.filigree), - new PartMaterialType(TDParts.cloth, ClothMaterialStats.TYPE)); + new PartMaterialType(TDParts.fabric, FabricMaterialStats.TYPE)); setUnlocalizedName("tinkersgrieves"); } @SideOnly(Side.CLIENT) @Override - public List<String> getArmorTexture(ItemStack stack) - { - List<String> textures = new ArrayList(); - textures.add("textures/armor/grieves/_grieves_plate.png"); - textures.add("textures/armor/grieves/_grieves_chain.png"); - textures.add("textures/armor/grieves/_grieves_trim.png"); - textures.add("textures/armor/grieves/_grieves_cloth.png"); - return textures; + public String getArmorTexture(ItemStack stack, Entity entity, EntityEquipmentSlot slot, String type) { + String texture; + NBTTagList t = TagUtil.getBaseMaterialsTagList(stack); + texture = "textures/armor/grieves/_grieves_plate_" + t.getStringTagAt(0); + return texture; } @SideOnly(Side.CLIENT) @Override - public ArmorRenderer getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack) + public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, EntityEquipmentSlot armorSlot, ModelBiped _default) { return new ModelTinkersGrieves(itemStack); } @Override public NBTTagCompound buildTag(List<Material> materials) { - ArmorNBT data = buildDefaultArmorTag(materials, LegsMaterialStats.TYPE); + ArmorNBT data = buildDefaultTag(materials); return data.get(); } @@ -64,33 +66,64 @@ public class TinkersGrieves extends ArmorCore } @Override - public void getTooltipDetailed(ItemStack stack, List<String> tooltips) { + public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, + int slot) { // TODO Auto-generated method stub - + return null; } @Override - public void getTooltipComponents(ItemStack stack, List<String> tooltips) { + public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) { // TODO Auto-generated method stub - + return 0; } @Override - public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, - int slot) { + public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) { // TODO Auto-generated method stub - return null; + } @Override - public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) { + public float damagePotential() + { // TODO Auto-generated method stub return 0; } @Override - public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) { + public double attackSpeed() + { // TODO Auto-generated method stub - + return 0; + } + + @Override + protected ArmorNBT buildDefaultTag(List<Material> materials) + { + ArmorNBT data = new ArmorNBT(); + + if (materials.size() >= 2) + { + ArmorMaterialStats handle = materials.get(0).getStatsOrUnknown(FabricMaterialStats.TYPE); + ArmorMaterialStats head = materials.get(1).getStatsOrUnknown(FabricMaterialStats.TYPE); + // start with head + data.head(head); + + // add in accessoires if present + if (materials.size() >= 3) + { + ExtraMaterialStats binding = materials.get(2).getStatsOrUnknown(MaterialTypes.EXTRA); + data.extra(binding); + } + + // calculate handle impact + data.head(handle); + } + + // 3 free modifiers + data.modifiers = DEFAULT_MODIFIERS; + + return data; } } diff --git a/src/main/java/lance5057/tDefense/core/tools/armor/heavy/TinkersHelm.java b/src/main/java/lance5057/tDefense/core/tools/armor/heavy/TinkersHelm.java index 3b1973d..37fc148 100644 --- a/src/main/java/lance5057/tDefense/core/tools/armor/heavy/TinkersHelm.java +++ b/src/main/java/lance5057/tDefense/core/tools/armor/heavy/TinkersHelm.java @@ -3,12 +3,18 @@ package lance5057.tDefense.core.tools.armor.heavy; import java.util.ArrayList; import java.util.List; -import lance5057.tDefense.core.materials.ArmorMaterialStats.HelmMaterialStats; +import lance5057.tDefense.core.library.ArmorNBT; +import lance5057.tDefense.core.library.ArmorTags; +import lance5057.tDefense.core.library.ArmorTextureBuilder; +import lance5057.tDefense.core.materials.stats.ArmorMaterialStats; +import lance5057.tDefense.core.materials.stats.FabricMaterialStats; +import lance5057.tDefense.core.materials.stats.HelmMaterialStats; import lance5057.tDefense.core.parts.TDParts; import lance5057.tDefense.core.tools.armor.renderers.ArmorRenderer; import lance5057.tDefense.core.tools.armor.renderers.heavy.ModelTinkersHelm; import lance5057.tDefense.core.tools.bases.ArmorCore; -import lance5057.tDefense.util.ArmorNBT; +import net.minecraft.client.model.ModelBiped; +import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.EntityEquipmentSlot; @@ -16,42 +22,54 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.util.DamageSource; +import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import slimeknights.tconstruct.library.materials.ExtraMaterialStats; import slimeknights.tconstruct.library.materials.Material; +import slimeknights.tconstruct.library.materials.MaterialTypes; import slimeknights.tconstruct.library.tinkering.PartMaterialType; import slimeknights.tconstruct.library.utils.TagUtil; +import slimeknights.tconstruct.library.utils.TinkerUtil; import slimeknights.tconstruct.tools.TinkerTools; -public class TinkersHelm extends ArmorCore { +public class TinkersHelm extends ArmorCore { public TinkersHelm() { super(EntityEquipmentSlot.HEAD,new PartMaterialType(TinkerTools.panHead, HelmMaterialStats.TYPE), new PartMaterialType(TDParts.armorPlate, HelmMaterialStats.TYPE), - PartMaterialType.handle(TDParts.filigree), PartMaterialType.extra(TDParts.chainmail)); + PartMaterialType.handle(TDParts.filigree), PartMaterialType.extra(TDParts.rivets)); setUnlocalizedName("tinkershelm"); } + + @SideOnly(Side.CLIENT) @Override - public List<String> getArmorTexture(ItemStack stack) { - List<String> textures = new ArrayList(); - NBTTagList t = TagUtil.getBaseMaterialsTagList(stack); - textures.add("textures/armor/helm/_helm_top_" + t.getStringTagAt(0)); - textures.add("textures/armor/helm/_helm_plate_" + t.getStringTagAt(1)); - textures.add("textures/armor/helm/_helm_visor_" + t.getStringTagAt(2)); - textures.add("textures/armor/helm/_helm_chain_" + t.getStringTagAt(3)); - return textures; + public NBTTagCompound setupTexture(List<Material> materials) + { + NBTTagCompound base = new NBTTagCompound(); + + ResourceLocation rc = ArmorTextureBuilder.createArmorTexture("helm", new String[] { "top", "plate", "visor", "chain" }, materials); + + if (rc != null) + { + base.setString(ArmorTags.TexLoc, rc.toString()); + return base; + } + return null; } + @SideOnly(Side.CLIENT) @Override - public ArmorRenderer getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack) { + public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, EntityEquipmentSlot armorSlot, ModelBiped _default) + { return new ModelTinkersHelm(itemStack); } @Override public NBTTagCompound buildTag(List<Material> materials) { - ArmorNBT data = buildDefaultArmorTag(materials, HelmMaterialStats.TYPE); + ArmorNBT data = buildDefaultTag(materials); return data.get(); } @@ -61,33 +79,64 @@ public class TinkersHelm extends ArmorCore { } @Override - public void getTooltipDetailed(ItemStack stack, List<String> tooltips) { + public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, + int slot) { // TODO Auto-generated method stub - + return null; } @Override - public void getTooltipComponents(ItemStack stack, List<String> tooltips) { + public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) { // TODO Auto-generated method stub - + return 0; } @Override - public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, - int slot) { + public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) { // TODO Auto-generated method stub - return null; + } @Override - public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) { + public float damagePotential() + { // TODO Auto-generated method stub return 0; } @Override - public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) { + public double attackSpeed() + { // TODO Auto-generated method stub - + return 0; + } + + @Override + protected ArmorNBT buildDefaultTag(List<Material> materials) + { + ArmorNBT data = new ArmorNBT(); + + if (materials.size() >= 2) + { + ArmorMaterialStats handle = materials.get(0).getStatsOrUnknown(FabricMaterialStats.TYPE); + ArmorMaterialStats head = materials.get(1).getStatsOrUnknown(FabricMaterialStats.TYPE); + // start with head + data.head(head); + + // add in accessoires if present + if (materials.size() >= 3) + { + ExtraMaterialStats binding = materials.get(2).getStatsOrUnknown(MaterialTypes.EXTRA); + data.extra(binding); + } + + // calculate handle impact + data.head(handle); + } + + // 3 free modifiers + data.modifiers = DEFAULT_MODIFIERS; + + return data; } } diff --git a/src/main/java/lance5057/tDefense/core/tools/armor/heavy/TinkersSabatons.java b/src/main/java/lance5057/tDefense/core/tools/armor/heavy/TinkersSabatons.java index 7172492..331dda6 100644 --- a/src/main/java/lance5057/tDefense/core/tools/armor/heavy/TinkersSabatons.java +++ b/src/main/java/lance5057/tDefense/core/tools/armor/heavy/TinkersSabatons.java @@ -1,56 +1,60 @@ package lance5057.tDefense.core.tools.armor.heavy; -import java.util.ArrayList; import java.util.List; -import lance5057.tDefense.core.materials.ArmorMaterialStats.ClothMaterialStats; -import lance5057.tDefense.core.materials.ArmorMaterialStats.FeetMaterialStats; +import lance5057.tDefense.core.library.ArmorNBT; +import lance5057.tDefense.core.materials.stats.ArmorMaterialStats; +import lance5057.tDefense.core.materials.stats.FabricMaterialStats; +import lance5057.tDefense.core.materials.stats.FeetMaterialStats; import lance5057.tDefense.core.parts.TDParts; import lance5057.tDefense.core.tools.armor.renderers.ArmorRenderer; import lance5057.tDefense.core.tools.armor.renderers.heavy.ModelTinkersSabatons; import lance5057.tDefense.core.tools.bases.ArmorCore; -import lance5057.tDefense.util.ArmorNBT; import net.minecraft.client.model.ModelBiped; +import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; import net.minecraft.util.DamageSource; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import slimeknights.tconstruct.library.materials.ExtraMaterialStats; import slimeknights.tconstruct.library.materials.Material; +import slimeknights.tconstruct.library.materials.MaterialTypes; import slimeknights.tconstruct.library.tinkering.PartMaterialType; +import slimeknights.tconstruct.library.utils.TagUtil; public class TinkersSabatons extends ArmorCore { public TinkersSabatons() { super(EntityEquipmentSlot.FEET,new PartMaterialType(TDParts.armorPlate, FeetMaterialStats.TYPE), new PartMaterialType(TDParts.armorPlate, FeetMaterialStats.TYPE), PartMaterialType.handle(TDParts.filigree), - new PartMaterialType(TDParts.cloth, ClothMaterialStats.TYPE)); + new PartMaterialType(TDParts.fabric, FabricMaterialStats.TYPE)); setUnlocalizedName("tinkerssabatons"); } @SideOnly(Side.CLIENT) @Override - public List<String> getArmorTexture(ItemStack stack) { - List<String> textures = new ArrayList(); - textures.add("textures/armor/sabatons/_sabatons_plates.png"); - textures.add("textures/armor/sabatons/_sabatons_caps.png"); - textures.add("textures/armor/sabatons/_sabatons_trim.png"); - textures.add("textures/armor/sabatons/_sabatons_soles.png"); - return textures; + public String getArmorTexture(ItemStack stack, Entity entity, EntityEquipmentSlot slot, String type) { + String texture; + NBTTagList t = TagUtil.getBaseMaterialsTagList(stack); + texture = "textures/armor/sabatons/_sabatons_plate_" + t.getStringTagAt(0); + return texture; } @SideOnly(Side.CLIENT) @Override - public ArmorRenderer getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack) { + public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, EntityEquipmentSlot armorSlot, ModelBiped _default) + { return new ModelTinkersSabatons(itemStack); } @Override public NBTTagCompound buildTag(List<Material> materials) { - ArmorNBT data = buildDefaultArmorTag(materials, FeetMaterialStats.TYPE); + ArmorNBT data = buildDefaultTag(materials); return data.get(); } @@ -60,33 +64,64 @@ public class TinkersSabatons extends ArmorCore { } @Override - public void getTooltipDetailed(ItemStack stack, List<String> tooltips) { + public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, + int slot) { // TODO Auto-generated method stub - + return null; } @Override - public void getTooltipComponents(ItemStack stack, List<String> tooltips) { + public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) { // TODO Auto-generated method stub - + return 0; } @Override - public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, - int slot) { + public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) { // TODO Auto-generated method stub - return null; + } @Override - public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) { + public float damagePotential() + { // TODO Auto-generated method stub return 0; } @Override - public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) { + public double attackSpeed() + { // TODO Auto-generated method stub - + return 0; + } + + @Override + protected ArmorNBT buildDefaultTag(List<Material> materials) + { + ArmorNBT data = new ArmorNBT(); + + if (materials.size() >= 2) + { + ArmorMaterialStats handle = materials.get(0).getStatsOrUnknown(FabricMaterialStats.TYPE); + ArmorMaterialStats head = materials.get(1).getStatsOrUnknown(FabricMaterialStats.TYPE); + // start with head + data.head(head); + + // add in accessoires if present + if (materials.size() >= 3) + { + ExtraMaterialStats binding = materials.get(2).getStatsOrUnknown(MaterialTypes.EXTRA); + data.extra(binding); + } + + // calculate handle impact + data.head(handle); + } + + // 3 free modifiers + data.modifiers = DEFAULT_MODIFIERS; + + return data; } } diff --git a/src/main/java/lance5057/tDefense/core/tools/armor/renderers/cloth/ModelTinkersHood.java b/src/main/java/lance5057/tDefense/core/tools/armor/renderers/cloth/ModelTinkersHood.java index 54b2c6d..b5cf2c2 100644 --- a/src/main/java/lance5057/tDefense/core/tools/armor/renderers/cloth/ModelTinkersHood.java +++ b/src/main/java/lance5057/tDefense/core/tools/armor/renderers/cloth/ModelTinkersHood.java @@ -15,10 +15,10 @@ public class ModelTinkersHood extends ArmorRenderer { public ModelRenderer ScarfNeck; public ModelTinkersHood(ItemStack stack) { - super(0.25f, 0, 96, 64, stack); + super(0.25f, 0, 96, 96, stack); this.textureWidth = 96; - this.textureHeight = 64; - + this.textureHeight = 96; + this.Flop_1 = new ModelRenderer(this, 77, 9); this.Flop_1.setRotationPoint(0.0F, 0.0F, 0.0F); this.Flop_1.addBox(-2.0F, -6.8F, -0.1F, 4, 4, 5, 0.5F); diff --git a/src/main/java/lance5057/tDefense/core/tools/armor/renderers/cloth/ModelTinkersRobe.java b/src/main/java/lance5057/tDefense/core/tools/armor/renderers/cloth/ModelTinkersRobe.java index e5f179a..bdf11c6 100644 --- a/src/main/java/lance5057/tDefense/core/tools/armor/renderers/cloth/ModelTinkersRobe.java +++ b/src/main/java/lance5057/tDefense/core/tools/armor/renderers/cloth/ModelTinkersRobe.java @@ -21,9 +21,9 @@ public class ModelTinkersRobe extends ArmorRenderer { public ModelRenderer LeftFrontL; public ModelTinkersRobe(ItemStack stack) { - super(0.25f, 0, 96, 64, stack); + super(0.25f, 0, 96, 96, stack); this.textureWidth = 96; - this.textureHeight = 64; + this.textureHeight = 96; this.BeltStraight = new ModelRenderer(this, 66, 24); this.BeltStraight.setRotationPoint(0.0F, 10.0F, 0.0F); diff --git a/src/main/java/lance5057/tDefense/core/tools/armor/renderers/cloth/ModelTinkersShawl.java b/src/main/java/lance5057/tDefense/core/tools/armor/renderers/cloth/ModelTinkersShawl.java index 1dc721f..b2f8f6c 100644 --- a/src/main/java/lance5057/tDefense/core/tools/armor/renderers/cloth/ModelTinkersShawl.java +++ b/src/main/java/lance5057/tDefense/core/tools/armor/renderers/cloth/ModelTinkersShawl.java @@ -17,9 +17,9 @@ public class ModelTinkersShawl extends ArmorRenderer { public ModelRenderer ShawlRightTrimLong; public ModelTinkersShawl(ItemStack stack) { - super(0.25f, 0, 96, 64, stack); + super(0.25f, 0, 96, 96, stack); this.textureWidth = 96; - this.textureHeight = 64; + this.textureHeight = 96; this.TrimNeck = new ModelRenderer(this, 68, 49); this.TrimNeck.setRotationPoint(0.0F, 0.0F, 0.0F); diff --git a/src/main/java/lance5057/tDefense/core/tools/armor/renderers/heavy/ModelTinkersHelm.java b/src/main/java/lance5057/tDefense/core/tools/armor/renderers/heavy/ModelTinkersHelm.java index 937bcc4..c74e4af 100644 --- a/src/main/java/lance5057/tDefense/core/tools/armor/renderers/heavy/ModelTinkersHelm.java +++ b/src/main/java/lance5057/tDefense/core/tools/armor/renderers/heavy/ModelTinkersHelm.java @@ -15,9 +15,9 @@ public class ModelTinkersHelm extends ArmorRenderer { public ModelRenderer MouthGuard; public ModelTinkersHelm(ItemStack stack) { - super(0.25f, 0, 96, 64, stack); + super(0.25f, 0, 96, 96, stack); this.textureWidth = 96; - this.textureHeight = 64; + this.textureHeight = 96; this.MouthGuard = new ModelRenderer(this, 64, 32); this.MouthGuard.setRotationPoint(0.0F, 0.0F, 0.0F); diff --git a/src/main/java/lance5057/tDefense/core/tools/armor/renderers/layers/LayerTDArmor.java b/src/main/java/lance5057/tDefense/core/tools/armor/renderers/layers/LayerTDArmor.java index 14c3fc1..d45d64b 100644 --- a/src/main/java/lance5057/tDefense/core/tools/armor/renderers/layers/LayerTDArmor.java +++ b/src/main/java/lance5057/tDefense/core/tools/armor/renderers/layers/LayerTDArmor.java @@ -1,6 +1,6 @@ package lance5057.tDefense.core.tools.armor.renderers.layers; -import java.util.List; +import java.util.List; import java.util.Map; import com.google.common.collect.Maps; diff --git a/src/main/java/lance5057/tDefense/core/tools/armor/renderers/layers/LayerTDBipedArmor.java b/src/main/java/lance5057/tDefense/core/tools/armor/renderers/layers/LayerTDBipedArmor.java index 890ba1f..2ba5720 100644 --- a/src/main/java/lance5057/tDefense/core/tools/armor/renderers/layers/LayerTDBipedArmor.java +++ b/src/main/java/lance5057/tDefense/core/tools/armor/renderers/layers/LayerTDBipedArmor.java @@ -1,6 +1,6 @@ package lance5057.tDefense.core.tools.armor.renderers.layers; -import java.util.List; +import java.util.List; import lance5057.tDefense.core.tools.bases.ArmorCore; import net.minecraft.client.model.ModelBiped; @@ -59,8 +59,8 @@ public class LayerTDBipedArmor extends LayerTDArmor<ModelBiped> { if (entity instanceof EntityPlayer) { EntityPlayer p = (EntityPlayer) entity; ItemStack armor = p.inventory.armorItemInSlot(slot.getIndex()); - List<String> l = ((ArmorCore)armor.getItem()).getArmorTexture(armor); - return l; + //List<String> l = ((ArmorCore)armor.getItem()).getArmorTexture(armor); + //return l; } return null; } diff --git a/src/main/java/lance5057/tDefense/core/tools/armor/renderers/shaders/ArmorShader.java b/src/main/java/lance5057/tDefense/core/tools/armor/renderers/shaders/ArmorShader.java deleted file mode 100644 index 5a1e803..0000000 --- a/src/main/java/lance5057/tDefense/core/tools/armor/renderers/shaders/ArmorShader.java +++ /dev/null @@ -1,183 +0,0 @@ -package lance5057.tDefense.core.tools.armor.renderers.shaders; - -import static org.lwjgl.opengl.GL11.GL_BLEND; -import static org.lwjgl.opengl.GL11.GL_ONE_MINUS_SRC_ALPHA; -import static org.lwjgl.opengl.GL11.GL_QUADS; -import static org.lwjgl.opengl.GL11.GL_SRC_ALPHA; -import static org.lwjgl.opengl.GL11.glBegin; -import static org.lwjgl.opengl.GL11.glBlendFunc; -import static org.lwjgl.opengl.GL11.glColor3d; -import static org.lwjgl.opengl.GL11.glColor4f; -import static org.lwjgl.opengl.GL11.glEnable; -import static org.lwjgl.opengl.GL11.glEnd; -import static org.lwjgl.opengl.GL11.glTexCoord2f; - -import java.awt.Color; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.image.BufferedImage; -import java.io.IOException; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; - -import javax.imageio.ImageIO; - -import lance5057.tDefense.util.Color16Util; -import net.minecraft.client.Minecraft; -import net.minecraft.client.resources.IResourceManager; -import net.minecraft.util.ResourceLocation; -import slimeknights.tconstruct.library.client.MaterialRenderInfo; -import slimeknights.tconstruct.library.client.texture.TextureColoredTexture; - -public class ArmorShader { - - public static BufferedImage colorize(ResourceLocation r1, int color) { - IResourceManager manager = Minecraft.getMinecraft().getResourceManager(); - try { - BufferedImage buff = ImageIO.read(manager.getResource(r1).getInputStream()); - BufferedImage tint = new BufferedImage(buff.getWidth(), buff.getHeight(), BufferedImage.TYPE_INT_ARGB); - - Graphics2D graphics = tint.createGraphics(); - - graphics.setPaint(new Color(color)); - graphics.fillRect(0, 0, tint.getWidth(), tint.getHeight()); - graphics.dispose(); - - return multiply(buff, tint); - - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - return null; - } - - public static void metalTexture(ResourceLocation r1, ResourceLocation r2, int color) { - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - Minecraft.getMinecraft().getTextureManager().bindTexture(r1); - - int[] colors = Color16Util.hexToRGB(Integer.toHexString(color)); - // glColor3d((float) colors[0] / 255, (float) colors[1] / 255, (float) - // colors[2] / 255); - - Minecraft.getMinecraft().getTextureManager().bindTexture(r1); - glColor4f((float) colors[0] / 255, (float) colors[1] / 255, (float) colors[2] / 255, 1.0f); - glBegin(GL_QUADS); - glTexCoord2f(0.0f, 0.0f); - glTexCoord2f(1.0f, 0.0f); - glTexCoord2f(1.0f, 1.0f); - glTexCoord2f(0.0f, 1.0f); - glEnd(); - - Minecraft.getMinecraft().getTextureManager().bindTexture(r2); - glColor4f((float) colors[0] / 255, (float) colors[1] / 255, (float) colors[2] / 255, 1.0f); - glBegin(GL_QUADS); - glTexCoord2f(0.0f, 0.0f); - glTexCoord2f(1.0f, 0.0f); - glTexCoord2f(1.0f, 1.0f); - glTexCoord2f(0.0f, 1.0f); - glEnd(); - } - - public static BufferedImage blockTexture(TextureColoredTexture sprite) { - - List<ResourceLocation> l = (List<ResourceLocation>) sprite.getDependencies(); - String s = l.get(1).toString(); - - IResourceManager manager = Minecraft.getMinecraft().getResourceManager(); - if (s.contains("minecraft:")) { - s = s.substring(s.indexOf(":") + 1); - s = "textures/" + s + ".png"; - } else { - s = l.get(1).getResourceDomain() + ":textures/" + l.get(1).getResourcePath() + ".png"; - } - try { - BufferedImage buff = ImageIO.read(manager.getResource(l.get(0)).getInputStream()); - BufferedImage buff2 = ImageIO.read(manager.getResource(new ResourceLocation(s)).getInputStream()); - - return multiply(buff, buff2); - } catch (IOException e) { - Logger.getAnonymousLogger().log(Level.SEVERE, "Somethings Fucky - TinkersDefense:ArmorShader - Line 107"); - } - return null; - - } - - public static void selectRenderer(BufferedImage b, MaterialRenderInfo info, ResourceLocation r1) { - - Graphics g = b.getGraphics(); - - if (info instanceof MaterialRenderInfo.MetalTextured) - metalTexture(r1, r1, ((MaterialRenderInfo.MetalTextured) info).color); - else if (info instanceof MaterialRenderInfo.Metal) - g.drawImage(colorize(r1, ((MaterialRenderInfo.Metal) info).color), 0, 0, null); - else if (info instanceof MaterialRenderInfo.MultiColor) - g.drawImage(colorize(r1, ((MaterialRenderInfo.MultiColor) info).getVertexColor()), 0, 0, null); - else if (info instanceof MaterialRenderInfo.InverseMultiColor) - g.drawImage(colorize(r1, ((MaterialRenderInfo.InverseMultiColor) info).getVertexColor()), 0, 0, null); - else if (info instanceof MaterialRenderInfo.BlockTexture) - g.drawImage( - blockTexture((TextureColoredTexture) ((MaterialRenderInfo.BlockTexture) info).getTexture(r1, "")), - 0, 0, null); - else - g.drawImage(colorize(r1, ((MaterialRenderInfo.Default) info).color), 0, 0, null); - - g.dispose(); - - } - - public static BufferedImage multiply(BufferedImage buff, BufferedImage buff2) { - BufferedImage buffImg = new BufferedImage(buff.getWidth(), buff.getHeight(), BufferedImage.TYPE_INT_ARGB); - - for (int i = 0; i < buff.getWidth(); i++) - for (int j = 0; j < buff.getHeight(); j++) { - Color c1 = new Color(buff.getRGB(i, j), true); - int x = i % buff2.getWidth(); - int y = j % buff2.getHeight(); - Color c2 = new Color(buff2.getRGB(x, y), true); - float r, g, b, a; - Color out; - - // multiply here - r = (((float) c1.getRed()) / 255) * (((float) c2.getRed()) / 255); - g = (((float) c1.getGreen()) / 255) * (((float) c2.getGreen()) / 255); - b = (((float) c1.getBlue()) / 255) * (((float) c2.getBlue()) / 255); - - // transparency always comes from the first buffer - int a2 = c1.getAlpha(); - a = ((float) c1.getAlpha()) / 255; - - out = new Color(r, g, b, a); - buffImg.setRGB(i, j, out.getRGB()); - } - - return buffImg; - } - - public static BufferedImage Invert(BufferedImage buff) { - BufferedImage buffImg = new BufferedImage(buff.getWidth(), buff.getHeight(), BufferedImage.TYPE_INT_ARGB); - - for (int i = 0; i < buff.getWidth(); i++) - for (int j = 0; j < buff.getHeight(); j++) { - Color c1 = new Color(buff.getRGB(i, j), true); - float r, g, b, a; - Color out; - - // invert here - r = Math.abs((((float) c1.getRed()) / 255) - 1.0f); - g = Math.abs((((float) c1.getGreen()) / 255) - 1.0f); - b = Math.abs((((float) c1.getBlue()) / 255) - 1.0f); - - // transparency always comes from the first buffer - int a2 = c1.getAlpha(); - a = ((float) c1.getAlpha()) / 255; - - out = new Color(r, g, b, a); - buffImg.setRGB(i, j, out.getRGB()); - } - - return buffImg; - } -} diff --git a/src/main/java/lance5057/tDefense/core/tools/bases/ArmorBase.java b/src/main/java/lance5057/tDefense/core/tools/bases/ArmorBase.java index 4c3d876..e6c86d0 100644 --- a/src/main/java/lance5057/tDefense/core/tools/bases/ArmorBase.java +++ b/src/main/java/lance5057/tDefense/core/tools/bases/ArmorBase.java @@ -15,8 +15,10 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.Sets; import gnu.trove.set.hash.THashSet; -import lance5057.tDefense.util.ArmorBuilder; -import lance5057.tDefense.util.ArmorEvent; +import jline.internal.Log; +import lance5057.tDefense.core.library.ArmorBuilder; +import lance5057.tDefense.core.library.ArmorEvent; +import lance5057.tDefense.core.library.ArmorTags; import net.minecraft.client.Minecraft; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.Entity; @@ -58,459 +60,543 @@ import slimeknights.tconstruct.library.utils.ToolBuilder; import slimeknights.tconstruct.library.utils.ToolHelper; import slimeknights.tconstruct.library.utils.TooltipBuilder; -public abstract class ArmorBase extends ItemArmor implements ITinkerable, IModifyable, IRepairable, ISpecialArmor{ +public abstract class ArmorBase extends ItemArmor implements ITinkerable, IModifyable, IRepairable, ISpecialArmor +{ protected final PartMaterialType[] requiredComponents; - // used to classify what the thing can do - protected final Set<Category> categories = new THashSet<>(); - - public ArmorBase(EntityEquipmentSlot slot, PartMaterialType... requiredComponents) { - super(ItemArmor.ArmorMaterial.LEATHER, 0, slot); - this.requiredComponents = requiredComponents; - - this.setMaxStackSize(1); - //this.setHasSubtypes(true); - } - - /* Tool Information */ - public List<PartMaterialType> getRequiredComponents() { - return ImmutableList.copyOf(requiredComponents); - } - - public List<PartMaterialType> getToolBuildComponents() { - return getRequiredComponents(); - } - - protected void addCategory(Category... categories) { - Collections.addAll(this.categories, categories); - } - - public boolean hasCategory(Category category) { - return categories.contains(category); - } - - protected Category[] getCategories() { - Category[] out = new Category[categories.size()]; - int i = 0; - for(Category category : categories) { - out[i++] = category; - } - - return out; - } - - /* INDESTRUCTIBLE */ - - @Override - public boolean hasCustomEntity(ItemStack stack) { - return true; - } - - @Nonnull - @Override - public Entity createEntity(World world, Entity location, ItemStack itemstack) { - EntityItem entity = new IndestructibleEntityItem(world, location.posX, location.posY, location.posZ, itemstack); - if(location instanceof EntityItem) { - // workaround for private access on that field >_> - NBTTagCompound tag = new NBTTagCompound(); - location.writeToNBT(tag); - entity.setPickupDelay(tag.getShort("PickupDelay")); - } - entity.motionX = location.motionX; - entity.motionY = location.motionY; - entity.motionZ = location.motionZ; - return entity; - } - - /* Building the Item */ - public boolean validComponent(int slot, ItemStack stack) { - if(slot > requiredComponents.length || slot < 0) { - return false; - } - - return requiredComponents[slot].isValid(stack); - } - - /** - * Builds an Itemstack of this tool with the given materials, if applicable. - * - * @param stacks Items to build with. Have to be in the correct order and have exact length. No nulls! - * @return The built item or null if invalid input. - */ - @Nonnull - public ItemStack buildItemFromStacks(NonNullList<ItemStack> stacks) { - long itemCount = stacks.stream().filter(stack -> !stack.isEmpty()).count(); - List<Material> materials = new ArrayList<>(stacks.size()); - - if(itemCount != requiredComponents.length) { - return ItemStack.EMPTY; - } - - // not a valid part arrangement for this tool - for(int i = 0; i < itemCount; i++) { - if(!validComponent(i, stacks.get(i))) { - return ItemStack.EMPTY; - } - - materials.add(TinkerUtil.getMaterialFromStack(stacks.get(i))); - } - - return buildItem(materials); - } - - /** - * Builds an Itemstack of this tool with the given materials. - * - * @param materials Materials to build with. Have to be in the correct order. No nulls! - * @return The built item or null if invalid input. - */ - @Nonnull - public ItemStack buildItem(List<Material> materials) { - ItemStack tool = new ItemStack(this); - tool.setTagCompound(buildItemNBT(materials)); - - return tool; - } - - /** - * Builds the NBT for a new tinker item with the given data. - * - * @param materials Materials to build with. Have to be in the correct order. No nulls! - * @return The built nbt - */ - public NBTTagCompound buildItemNBT(List<Material> materials) { - NBTTagCompound basetag = new NBTTagCompound(); - NBTTagCompound toolTag = buildTag(materials); - NBTTagCompound dataTag = buildData(materials); - - basetag.setTag(Tags.BASE_DATA, dataTag); - basetag.setTag(Tags.TOOL_DATA, toolTag); - // copy of the original tool data - basetag.setTag(Tags.TOOL_DATA_ORIG, toolTag.copy()); - - // save categories on the tool - TagUtil.setCategories(basetag, getCategories()); - - // add traits - addMaterialTraits(basetag, materials); - - // fire toolbuilding event - ArmorEvent.OnItemBuilding.fireEvent(basetag, ImmutableList.copyOf(materials), this); - - return basetag; - } - - /** - * Creates an NBT Tag with the materials that were used to build the item. - */ - private NBTTagCompound buildData(List<Material> materials) { - NBTTagCompound base = new NBTTagCompound(); - NBTTagList materialList = new NBTTagList(); - - for(Material material : materials) { - materialList.appendTag(new NBTTagString(material.identifier)); - } - - // pre-type base-modifier list - NBTTagList modifierList = new NBTTagList(); - // we cannot set the type directly, but it gets typed by adding a tag, so we add and remove one - modifierList.appendTag(new NBTTagString()); - modifierList.removeTag(0); - - base.setTag(Tags.BASE_MATERIALS, materialList); - base.setTag(Tags.BASE_MODIFIERS, modifierList); - - return base; - } - - /** - * Builds an unusable tool that only has the rendering info - */ - @Nonnull - public ItemStack buildItemForRendering(List<Material> materials) { - ItemStack tool = new ItemStack(this); - NBTTagCompound base = new NBTTagCompound(); - base.setTag(Tags.BASE_DATA, buildData(materials)); - tool.setTagCompound(base); - - return tool; - } - - @Nonnull - public ItemStack buildItemForRenderingInGui() { - List<Material> materials = IntStream.range(0, getRequiredComponents().size()) - .mapToObj(this::getMaterialForPartForGuiRendering) - .collect(Collectors.toList()); - - return buildItemForRendering(materials); - } - - @SideOnly(Side.CLIENT) - public Material getMaterialForPartForGuiRendering(int index) { - return ClientProxy.RenderMaterials[index % ClientProxy.RenderMaterials.length]; - } - - public abstract NBTTagCompound buildTag(List<Material> materials); - - /** Checks whether an Item built from materials has only valid materials. Uses the standard NBT to determine materials. */ - public boolean hasValidMaterials(ItemStack stack) { - // checks if the materials used support all stats needed - NBTTagList list = TagUtil.getBaseMaterialsTagList(stack); - List<Material> materials = TinkerUtil.getMaterialsFromTagList(list); - - // something went wrooooong - if(materials.size() != requiredComponents.length) { - return false; - } - - // check if all materials used have the stats needed - for(int i = 0; i < materials.size(); i++) { - Material material = materials.get(i); - PartMaterialType required = requiredComponents[i]; - if(!required.isValidMaterial(material)) { - return false; - } - } - - return true; - } - - public void addMaterialTraits(NBTTagCompound root, List<Material> materials) { - int size = requiredComponents.length; - // safety - if(materials.size() < size) { - size = materials.size(); - } - // add corresponding traits per material usage - for(int i = 0; i < size; i++) { - PartMaterialType required = requiredComponents[i]; - Material material = materials.get(i); - for(ITrait trait : required.getApplicableTraitsForMaterial(material)) { - ToolBuilder.addTrait(root, trait, material.materialTextColor); - } - } - } - - /* Repairing */ - - /** Returns indices of the parts that are used for repairing */ - public int[] getRepairParts() { - return new int[] { 1 }; // index 1 usually is the head. 0 is handle. - } - - public float getRepairModifierForPart(int index) { - return 1f; - } - - @Nonnull - @Override - public ItemStack repair(ItemStack repairable, NonNullList<ItemStack> repairItems) { - if(repairable.getItemDamage() == 0 && !ToolHelper.isBroken(repairable)) { - // undamaged and not broken - no need to repair - return ItemStack.EMPTY; - } - - // we assume the first required part exclusively determines repair material - List<Material> materials = TinkerUtil.getMaterialsFromTagList(TagUtil.getBaseMaterialsTagList(repairable)); - if(materials.isEmpty()) { - return ItemStack.EMPTY; - } - - // ensure the items only contain valid items - NonNullList<ItemStack> items = Util.deepCopyFixedNonNullList(repairItems); - boolean foundMatch = false; - for(int index : getRepairParts()) { - Material material = materials.get(index); - - if(repairCustom(material, items) > 0) { - foundMatch = true; - } - - Optional<RecipeMatch.Match> match = material.matches(items); - - // not a single match -> nothing to repair with - if(!match.isPresent()) { - continue; - } - foundMatch = true; - - while((match = material.matches(items)).isPresent()) { - RecipeMatch.removeMatch(items, match.get()); - } - } - - if(!foundMatch) { - return ItemStack.EMPTY; - } - - // check if all items were used - for(int i = 0; i < repairItems.size(); i++) { - // was non-null and did not get modified (stacksize changed or null now, usually) - if(!repairItems.get(i).isEmpty() && ItemStack.areItemStacksEqual(repairItems.get(i), items.get(i))) { - // found an item that was not touched - return ItemStack.EMPTY; - } - } - - // now do it all over again with the real items, to actually repair \o/ - ItemStack item = repairable.copy(); - - while(item.getItemDamage() > 0) { - int amount = calculateRepairAmount(materials, repairItems); - - // nothing to repair with, we're therefore done - if(amount <= 0) { - break; - } - - ToolHelper.repairTool(item, calculateRepair(item, amount)); - // save that we repaired it :I - NBTTagCompound tag = TagUtil.getExtraTag(item); - tag.setInteger(Tags.REPAIR_COUNT, tag.getInteger(Tags.REPAIR_COUNT) + 1); - TagUtil.setExtraTag(item, tag); - } - - return item; - } - - /** Allows for custom repair items. Remove used items from the array. */ - protected int repairCustom(Material material, NonNullList<ItemStack> repairItems) { - return 0; - } - - protected int calculateRepairAmount(List<Material> materials, NonNullList<ItemStack> repairItems) { - Set<Material> materialsMatched = Sets.newHashSet(); - float durability = 0f; - // try to match each material once - for(int index : getRepairParts()) { - Material material = materials.get(index); - - if(materialsMatched.contains(material)) { - continue; - } - - // custom repairing - durability += repairCustom(material, repairItems) * getRepairModifierForPart(index); - - Optional<RecipeMatch.Match> matchOptional = material.matches(repairItems); - if(matchOptional.isPresent()) { - RecipeMatch.Match match = matchOptional.get(); - HeadMaterialStats stats = material.getStats(MaterialTypes.HEAD); - if(stats != null) { - materialsMatched.add(material); - durability += ((float) stats.durability * (float) match.amount * getRepairModifierForPart(index)) / 144f; - RecipeMatch.removeMatch(repairItems, match); - } - } - } - - durability *= 1f + ((float) materialsMatched.size() - 1) / 9f; - - return (int) durability; - } - - protected int calculateRepair(ItemStack tool, int amount) { - float origDur = TagUtil.getOriginalToolStats(tool).durability; - float actualDur = ToolHelper.getDurabilityStat(tool); - - // calculate in modifiers that change the total durability of a tool, like diamond - // they should not punish the player with higher repair costs - float durabilityFactor = actualDur / origDur; - float increase = amount * Math.min(10f, durabilityFactor); - - increase = Math.max(increase, actualDur / 64f); - //increase = Math.max(50, increase); - - int modifiersUsed = TagUtil.getBaseModifiersUsed(tool.getTagCompound()); - float mods = 1.0f; - if(modifiersUsed == 1) { - mods = 0.95f; - } - else if(modifiersUsed == 2) { - mods = 0.9f; - } - else if(modifiersUsed >= 3) { - mods = 0.85f; - } - - increase *= mods; - - NBTTagCompound tag = TagUtil.getExtraTag(tool); - int repair = tag.getInteger(Tags.REPAIR_COUNT); - float repairDimishingReturns = (100 - repair / 2) / 100f; - if(repairDimishingReturns < 0.5f) { - repairDimishingReturns = 0.5f; - } - increase *= repairDimishingReturns; - - return (int) Math.ceil(increase); - } - - /* Information */ - - @Override - @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) { - boolean shift = Util.isShiftKeyDown(); - boolean ctrl = Util.isCtrlKeyDown(); - // modifiers - if(!shift && !ctrl) { - getTooltip(stack, tooltip); - - tooltip.add(""); - // info tooltip for detailed and componend info - tooltip.add(Util.translate("tooltip.tool.holdShift")); - tooltip.add(Util.translate("tooltip.tool.holdCtrl")); - -// if(worldIn != null) { -// tooltip.add(TextFormatting.BLUE + -// I18n.translateToLocalFormatted("attribute.modifier.plus.0", -// Util.df.format(ToolHelper.getActualDamage(stack, Minecraft.getMinecraft().player)), -// I18n.translateToLocal("attribute.name.generic.attackDamage"))); -// } - } - // detailed data - else if(Config.extraTooltips && shift) { - getTooltipDetailed(stack, tooltip); - } - // component data - else if(Config.extraTooltips && ctrl) { - getTooltipComponents(stack, tooltip); - } - } - - @Override - public void getTooltip(ItemStack stack, List<String> tooltips) { - // Default tooltip: modifiers - TooltipBuilder.addModifierTooltips(stack, tooltips); - } - - @Nonnull - @Override - public EnumRarity getRarity(ItemStack stack) { - // prevents enchanted items to have a different name color - return EnumRarity.COMMON; - } - - @Override - public boolean isBookEnchantable(ItemStack stack, ItemStack book) { - return false; - } - - /* NBT loading */ - - @Override - public boolean updateItemStackNBT(NBTTagCompound nbt) { - // when the itemstack is loaded from NBT we recalculate all the data - if(nbt.hasKey(Tags.BASE_DATA)) { - try { - ArmorBuilder.rebuildArmor(nbt, this); - } - catch(TinkerGuiException e) { - // nothing to do - } - } - - // return value shouldn't matter since it's never checked - return true; - } + // used to classify what the thing can do + protected final Set<Category> categories = new THashSet<>(); + + public ArmorBase(EntityEquipmentSlot slot, PartMaterialType... requiredComponents) + { + super(ItemArmor.ArmorMaterial.LEATHER, 0, slot); + this.requiredComponents = requiredComponents; + + this.setMaxStackSize(1); + // this.setHasSubtypes(true); + } + + /* Tool Information */ + public List<PartMaterialType> getRequiredComponents() + { + return ImmutableList.copyOf(requiredComponents); + } + + public List<PartMaterialType> getToolBuildComponents() + { + return getRequiredComponents(); + } + + protected void addCategory(Category... categories) + { + Collections.addAll(this.categories, categories); + } + + public boolean hasCategory(Category category) + { + return categories.contains(category); + } + + protected Category[] getCategories() + { + Category[] out = new Category[categories.size()]; + int i = 0; + for (Category category : categories) + { + out[i++] = category; + } + + return out; + } + + /* INDESTRUCTIBLE */ + + @Override + public boolean hasCustomEntity(ItemStack stack) + { + return true; + } + + @Nonnull + @Override + public Entity createEntity(World world, Entity location, ItemStack itemstack) + { + EntityItem entity = new IndestructibleEntityItem(world, location.posX, location.posY, location.posZ, itemstack); + if (location instanceof EntityItem) + { + // workaround for private access on that field >_> + NBTTagCompound tag = new NBTTagCompound(); + location.writeToNBT(tag); + entity.setPickupDelay(tag.getShort("PickupDelay")); + } + entity.motionX = location.motionX; + entity.motionY = location.motionY; + entity.motionZ = location.motionZ; + return entity; + } + + /* Building the Item */ + public boolean validComponent(int slot, ItemStack stack) + { + if (slot > requiredComponents.length || slot < 0) + { + return false; + } + + return requiredComponents[slot].isValid(stack); + } + + /** + * Builds an Itemstack of this tool with the given materials, if applicable. + * + * @param stacks + * Items to build with. Have to be in the correct order and have + * exact length. No nulls! + * @return The built item or null if invalid input. + */ + @Nonnull + public ItemStack buildItemFromStacks(NonNullList<ItemStack> stacks) + { + long itemCount = stacks.stream().filter(stack -> !stack.isEmpty()).count(); + List<Material> materials = new ArrayList<>(stacks.size()); + + if (itemCount != requiredComponents.length) + { + return ItemStack.EMPTY; + } + + // not a valid part arrangement for this tool + for (int i = 0; i < itemCount; i++) + { + if (!validComponent(i, stacks.get(i))) + { + return ItemStack.EMPTY; + } + + materials.add(TinkerUtil.getMaterialFromStack(stacks.get(i))); + } + + return buildItem(materials); + } + + /** + * Builds an Itemstack of this tool with the given materials. + * + * @param materials + * Materials to build with. Have to be in the correct order. No + * nulls! + * @return The built item or null if invalid input. + */ + @Nonnull + public ItemStack buildItem(List<Material> materials) + { + ItemStack tool = new ItemStack(this); + tool.setTagCompound(buildItemNBT(materials)); + + return tool; + } + + /** + * Builds the NBT for a new tinker item with the given data. + * + * @param materials + * Materials to build with. Have to be in the correct order. No + * nulls! + * @return The built nbt + */ + public NBTTagCompound buildItemNBT(List<Material> materials) + { + NBTTagCompound basetag = new NBTTagCompound(); + NBTTagCompound toolTag = buildTag(materials); + NBTTagCompound dataTag = buildData(materials); + + basetag.setTag(Tags.BASE_DATA, dataTag); + basetag.setTag(Tags.TOOL_DATA, toolTag); + // copy of the original tool data + basetag.setTag(Tags.TOOL_DATA_ORIG, toolTag.copy()); + // save categories on the tool + TagUtil.setCategories(basetag, getCategories()); + + // add traits + addMaterialTraits(basetag, materials); + + // fire toolbuilding event + ArmorEvent.OnItemBuilding.fireEvent(basetag, ImmutableList.copyOf(materials), this); + + return basetag; + } + + + + @SideOnly(Side.CLIENT) + public NBTTagCompound setupTexture(List<Material> materials) + { + return null; + } + + /** + * Creates an NBT Tag with the materials that were used to build the item. + */ + private NBTTagCompound buildData(List<Material> materials) + { + NBTTagCompound base = new NBTTagCompound(); + NBTTagList materialList = new NBTTagList(); + + for (Material material : materials) + { + materialList.appendTag(new NBTTagString(material.identifier)); + } + + // pre-type base-modifier list + NBTTagList modifierList = new NBTTagList(); + // we cannot set the type directly, but it gets typed by adding a tag, + // so we add and remove one + modifierList.appendTag(new NBTTagString()); + modifierList.removeTag(0); + + base.setTag(Tags.BASE_MATERIALS, materialList); + base.setTag(Tags.BASE_MODIFIERS, modifierList); + + return base; + } + + /** + * Builds an unusable tool that only has the rendering info + */ + @Nonnull + public ItemStack buildItemForRendering(List<Material> materials) + { + ItemStack tool = new ItemStack(this); + NBTTagCompound base = new NBTTagCompound(); + base.setTag(Tags.BASE_DATA, buildData(materials)); + tool.setTagCompound(base); + + return tool; + } + + @Nonnull + public ItemStack buildItemForRenderingInGui() + { + List<Material> materials = IntStream.range(0, getRequiredComponents().size()).mapToObj(this::getMaterialForPartForGuiRendering).collect(Collectors.toList()); + + return buildItemForRendering(materials); + } + + @SideOnly(Side.CLIENT) + public Material getMaterialForPartForGuiRendering(int index) + { + return ClientProxy.RenderMaterials[index % ClientProxy.RenderMaterials.length]; + } + + public abstract NBTTagCompound buildTag(List<Material> materials); + + /** + * Checks whether an Item built from materials has only valid materials. + * Uses the standard NBT to determine materials. + */ + public boolean hasValidMaterials(ItemStack stack) + { + // checks if the materials used support all stats needed + NBTTagList list = TagUtil.getBaseMaterialsTagList(stack); + List<Material> materials = TinkerUtil.getMaterialsFromTagList(list); + + // something went wrooooong + if (materials.size() != requiredComponents.length) + { + return false; + } + + // check if all materials used have the stats needed + for (int i = 0; i < materials.size(); i++) + { + Material material = materials.get(i); + PartMaterialType required = requiredComponents[i]; + if (!required.isValidMaterial(material)) + { + return false; + } + } + + return true; + } + + public void addMaterialTraits(NBTTagCompound root, List<Material> materials) + { + int size = requiredComponents.length; + // safety + if (materials.size() < size) + { + size = materials.size(); + } + // add corresponding traits per material usage + for (int i = 0; i < size; i++) + { + PartMaterialType required = requiredComponents[i]; + Material material = materials.get(i); + for (ITrait trait : required.getApplicableTraitsForMaterial(material)) + { + ToolBuilder.addTrait(root, trait, material.materialTextColor); + } + } + } + + /* Repairing */ + + /** Returns indices of the parts that are used for repairing */ + public int[] getRepairParts() + { + return new int[] { 1 }; // index 1 usually is the head. 0 is handle. + } + + public float getRepairModifierForPart(int index) + { + return 1f; + } + + @Nonnull + @Override + public ItemStack repair(ItemStack repairable, NonNullList<ItemStack> repairItems) + { + if (repairable.getItemDamage() == 0 && !ToolHelper.isBroken(repairable)) + { + // undamaged and not broken - no need to repair + return ItemStack.EMPTY; + } + + // we assume the first required part exclusively determines repair + // material + List<Material> materials = TinkerUtil.getMaterialsFromTagList(TagUtil.getBaseMaterialsTagList(repairable)); + if (materials.isEmpty()) + { + return ItemStack.EMPTY; + } + + // ensure the items only contain valid items + NonNullList<ItemStack> items = Util.deepCopyFixedNonNullList(repairItems); + boolean foundMatch = false; + for (int index : getRepairParts()) + { + Material material = materials.get(index); + + if (repairCustom(material, items) > 0) + { + foundMatch = true; + } + + Optional<RecipeMatch.Match> match = material.matches(items); + + // not a single match -> nothing to repair with + if (!match.isPresent()) + { + continue; + } + foundMatch = true; + + while ((match = material.matches(items)).isPresent()) + { + RecipeMatch.removeMatch(items, match.get()); + } + } + + if (!foundMatch) + { + return ItemStack.EMPTY; + } + + // check if all items were used + for (int i = 0; i < repairItems.size(); i++) + { + // was non-null and did not get modified (stacksize changed or null + // now, usually) + if (!repairItems.get(i).isEmpty() && ItemStack.areItemStacksEqual(repairItems.get(i), items.get(i))) + { + // found an item that was not touched + return ItemStack.EMPTY; + } + } + + // now do it all over again with the real items, to actually repair \o/ + ItemStack item = repairable.copy(); + + while (item.getItemDamage() > 0) + { + int amount = calculateRepairAmount(materials, repairItems); + + // nothing to repair with, we're therefore done + if (amount <= 0) + { + break; + } + + ToolHelper.repairTool(item, calculateRepair(item, amount)); + // save that we repaired it :I + NBTTagCompound tag = TagUtil.getExtraTag(item); + tag.setInteger(Tags.REPAIR_COUNT, tag.getInteger(Tags.REPAIR_COUNT) + 1); + TagUtil.setExtraTag(item, tag); + } + + return item; + } + + /** Allows for custom repair items. Remove used items from the array. */ + protected int repairCustom(Material material, NonNullList<ItemStack> repairItems) + { + return 0; + } + + protected int calculateRepairAmount(List<Material> materials, NonNullList<ItemStack> repairItems) + { + Set<Material> materialsMatched = Sets.newHashSet(); + float durability = 0f; + // try to match each material once + for (int index : getRepairParts()) + { + Material material = materials.get(index); + + if (materialsMatched.contains(material)) + { + continue; + } + + // custom repairing + durability += repairCustom(material, repairItems) * getRepairModifierForPart(index); + + Optional<RecipeMatch.Match> matchOptional = material.matches(repairItems); + if (matchOptional.isPresent()) + { + RecipeMatch.Match match = matchOptional.get(); + HeadMaterialStats stats = material.getStats(MaterialTypes.HEAD); + if (stats != null) + { + materialsMatched.add(material); + durability += ((float) stats.durability * (float) match.amount * getRepairModifierForPart(index)) / 144f; + RecipeMatch.removeMatch(repairItems, match); + } + } + } + + durability *= 1f + ((float) materialsMatched.size() - 1) / 9f; + + return (int) durability; + } + + protected int calculateRepair(ItemStack tool, int amount) + { + float origDur = TagUtil.getOriginalToolStats(tool).durability; + float actualDur = ToolHelper.getDurabilityStat(tool); + + // calculate in modifiers that change the total durability of a tool, + // like diamond + // they should not punish the player with higher repair costs + float durabilityFactor = actualDur / origDur; + float increase = amount * Math.min(10f, durabilityFactor); + + increase = Math.max(increase, actualDur / 64f); + // increase = Math.max(50, increase); + + int modifiersUsed = TagUtil.getBaseModifiersUsed(tool.getTagCompound()); + float mods = 1.0f; + if (modifiersUsed == 1) + { + mods = 0.95f; + } else if (modifiersUsed == 2) + { + mods = 0.9f; + } else if (modifiersUsed >= 3) + { + mods = 0.85f; + } + + increase *= mods; + + NBTTagCompound tag = TagUtil.getExtraTag(tool); + int repair = tag.getInteger(Tags.REPAIR_COUNT); + float repairDimishingReturns = (100 - repair / 2) / 100f; + if (repairDimishingReturns < 0.5f) + { + repairDimishingReturns = 0.5f; + } + increase *= repairDimishingReturns; + + return (int) Math.ceil(increase); + } + + /* Information */ + + @Override + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) + { + boolean shift = Util.isShiftKeyDown(); + boolean ctrl = Util.isCtrlKeyDown(); + // modifiers + if (!shift && !ctrl) + { + getTooltip(stack, tooltip); + + tooltip.add(""); + // info tooltip for detailed and componend info + tooltip.add(Util.translate("tooltip.tool.holdShift")); + tooltip.add(Util.translate("tooltip.tool.holdCtrl")); + + // if(worldIn != null) { + // tooltip.add(TextFormatting.BLUE + + // I18n.translateToLocalFormatted("attribute.modifier.plus.0", + // Util.df.format(ToolHelper.getActualDamage(stack, + // Minecraft.getMinecraft().player)), + // I18n.translateToLocal("attribute.name.generic.attackDamage"))); + // } + } + // detailed data + else if (Config.extraTooltips && shift) + { + getTooltipDetailed(stack, tooltip); + } + // component data + else if (Config.extraTooltips && ctrl) + { + getTooltipComponents(stack, tooltip); + } + } + + @Override + public void getTooltip(ItemStack stack, List<String> tooltips) + { + // Default tooltip: modifiers + TooltipBuilder.addModifierTooltips(stack, tooltips); + } + + @Nonnull + @Override + public EnumRarity getRarity(ItemStack stack) + { + // prevents enchanted items to have a different name color + return EnumRarity.COMMON; + } + + @Override + public boolean isBookEnchantable(ItemStack stack, ItemStack book) + { + return false; + } + + /* NBT loading */ + + @Override + public boolean updateItemStackNBT(NBTTagCompound nbt) + { + // when the itemstack is loaded from NBT we recalculate all the data + if (nbt.hasKey(Tags.BASE_DATA)) + { + try + { + ArmorBuilder.rebuildArmor(nbt, this); + } catch (TinkerGuiException e) + { + // nothing to do + } + } + + // return value shouldn't matter since it's never checked + return true; + } } diff --git a/src/main/java/lance5057/tDefense/core/tools/bases/ArmorCore.java b/src/main/java/lance5057/tDefense/core/tools/bases/ArmorCore.java index 44ca576..1355b97 100644 --- a/src/main/java/lance5057/tDefense/core/tools/bases/ArmorCore.java +++ b/src/main/java/lance5057/tDefense/core/tools/bases/ArmorCore.java @@ -1,179 +1,867 @@ package lance5057.tDefense.core.tools.bases; +import java.util.ArrayList; +import java.util.Collections; import java.util.Iterator; import java.util.List; +import java.util.Optional; import java.util.Set; +import javax.annotation.Nonnull; import javax.annotation.Nullable; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Multimap; import com.google.common.collect.Sets; -import lance5057.tDefense.core.materials.ArmorMaterialStats; +import lance5057.tDefense.core.library.ArmorNBT; +import lance5057.tDefense.core.library.ArmorTags; import lance5057.tDefense.core.tools.armor.renderers.ArmorRenderer; -import lance5057.tDefense.util.ArmorNBT; +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.attributes.AttributeModifier; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.DamageSource; +import net.minecraft.util.EnumHand; +import net.minecraft.util.NonNullList; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.text.TextFormatting; +import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import slimeknights.mantle.util.RecipeMatch; +import slimeknights.tconstruct.common.ClientProxy; +import slimeknights.tconstruct.common.config.Config; +import slimeknights.tconstruct.library.TinkerRegistry; import slimeknights.tconstruct.library.Util; -import slimeknights.tconstruct.library.materials.ExtraMaterialStats; -import slimeknights.tconstruct.library.materials.HandleMaterialStats; +import slimeknights.tconstruct.library.materials.HeadMaterialStats; import slimeknights.tconstruct.library.materials.IMaterialStats; import slimeknights.tconstruct.library.materials.Material; import slimeknights.tconstruct.library.materials.MaterialTypes; +import slimeknights.tconstruct.library.modifiers.IModifier; +import slimeknights.tconstruct.library.modifiers.ModifierNBT; import slimeknights.tconstruct.library.tinkering.Category; +import slimeknights.tconstruct.library.tinkering.IToolStationDisplay; import slimeknights.tconstruct.library.tinkering.PartMaterialType; +import slimeknights.tconstruct.library.tools.DualToolHarvestUtils; +import slimeknights.tconstruct.library.tools.IAoeTool; import slimeknights.tconstruct.library.tools.IToolPart; import slimeknights.tconstruct.library.traits.ITrait; import slimeknights.tconstruct.library.utils.TagUtil; import slimeknights.tconstruct.library.utils.TinkerUtil; import slimeknights.tconstruct.library.utils.ToolHelper; import slimeknights.tconstruct.library.utils.TooltipBuilder; +import slimeknights.tconstruct.tools.TinkerMaterials; +import slimeknights.tconstruct.tools.TinkerTools; +import slimeknights.tconstruct.tools.traits.InfiTool; -public abstract class ArmorCore extends ArmorBase { - public ArmorCore(EntityEquipmentSlot slot, PartMaterialType... requiredComponents) { +/** + * Intermediate abstraction layer for all tools/melee weapons. This class has + * all the callbacks for blocks and enemies so tools and weapons can share + * behaviour. + */ +public abstract class ArmorCore extends ArmorBase implements IToolStationDisplay +{ + + public final static int DEFAULT_MODIFIERS = 3; + public static final String TAG_SWITCHED_HAND_HAX = "SwitchedHand"; + + public ArmorCore(EntityEquipmentSlot slot, PartMaterialType... requiredComponents) + { super(slot, requiredComponents); + + this.setCreativeTab(TinkerRegistry.tabTools); + this.setNoRepair(); // >_> + + // TinkerRegistry.registerTool(this); + addCategory(Category.TOOL); } - protected String getHarvestType() { - return null; + @Override + public int getMaxDamage(ItemStack stack) + { + return ToolHelper.getDurabilityStat(stack); + } + + @Override + public void setDamage(ItemStack stack, int damage) + { + int max = getMaxDamage(stack); + super.setDamage(stack, Math.min(max, damage)); + + if (getDamage(stack) == max) + { + ToolHelper.breakTool(stack, null); + } + } + + @Override + public boolean isDamageable() + { + return true; + } + + @Override + public boolean showDurabilityBar(ItemStack stack) + { + return super.showDurabilityBar(stack) && !ToolHelper.isBroken(stack); + } + + /* Tool and Weapon specific properties */ + + /** + * Multiplier applied to the actual mining speed of the tool Internally a + * hammer and pick have the same speed, but a hammer is 2/3 slower + */ + public float miningSpeedModifier() + { + return 1f; + } + + /** Multiplier for damage from materials. Should be fixed per tool. */ + public abstract float damagePotential(); + + /** + * A fixed damage value where the calculations start to apply dimishing + * returns. Basically if you'd hit more than that damage with this tool, the + * damage is gradually reduced depending on how much the cutoff is exceeded. + */ + public float damageCutoff() + { + return 15.0f; // in general this should be sufficient and only needs + // increasing if it's a stronger weapon + // fun fact: diamond sword with sharpness V has 15 damage + } + + /** + * Allows you set the base attack speed, can be changed by modifiers. + * Equivalent to the vanilla attack speed. 4 is equal to any standard item. + * Value has to be greater than zero. + */ + public abstract double attackSpeed(); + + /** + * Knockback modifier. Basically this takes the vanilla knockback on hit and + * modifies it by this factor. + */ + public float knockback() + { + return 1.0f; + } + + /** + * Actually deal damage to the entity we hit. Can be overridden for special + * behaviour + * + * @return True if the entity was hit. Usually the return value of + * {@link Entity#attackEntityFrom(DamageSource, float)} + */ + public boolean dealDamage(ItemStack stack, EntityLivingBase player, Entity entity, float damage) + { + if (player instanceof EntityPlayer) + { + return entity.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) player), damage); + } + return entity.attackEntityFrom(DamageSource.causeMobDamage(player), damage); + } + + protected boolean readyForSpecialAttack(EntityLivingBase player) + { + return player instanceof EntityPlayer && ((EntityPlayer) player).getCooledAttackStrength(0.5f) > 0.9f; + } + + /** + * Called when an entity is getting damaged with the tool. Reduce the tools + * durability accordingly player can be null! + */ + public void reduceDurabilityOnHit(ItemStack stack, EntityPlayer player, float damage) + { + damage = Math.max(1f, damage / 10f); + if (!hasCategory(Category.WEAPON)) + { + damage *= 2; + } + ToolHelper.damageTool(stack, (int) damage, player); + } + + // @Override + // public float getStrVsBlock(ItemStack stack, IBlockState state) { + // if(isEffective(state) || ToolHelper.isToolEffective(stack, state)) { + // return ToolHelper.calcDigSpeed(stack, state); + // } + // return super.getStrVsBlock(stack, state); + // } + + public boolean isEffective(IBlockState state) + { + return false; + } + + @Override + public boolean canHarvestBlock(@Nonnull IBlockState state, ItemStack stack) + { + return isEffective(state); + } + + @Override + public boolean onBlockStartBreak(ItemStack itemstack, BlockPos pos, EntityPlayer player) + { + if (!ToolHelper.isBroken(itemstack) && this instanceof IAoeTool && ((IAoeTool) this).isAoeHarvestTool()) + { + for (BlockPos extraPos : ((IAoeTool) this).getAOEBlocks(itemstack, player.getEntityWorld(), player, pos)) + { + breakExtraBlock(itemstack, player.getEntityWorld(), player, extraPos, pos); + } + } + + // this is a really dumb hack. + // Basically when something with silktouch harvests a block from the + // offhand + // the game can't detect that. so we have to switch around the items in + // the hands for the break call + // it's switched back in onBlockDestroyed + if (DualToolHarvestUtils.shouldUseOffhand(player, pos, player.getHeldItemMainhand())) + { + ItemStack off = player.getHeldItemOffhand(); + switchItemsInHands(player); + // remember, off is in the mainhand now + NBTTagCompound tag = TagUtil.getTagSafe(off); + tag.setLong(TAG_SWITCHED_HAND_HAX, player.getEntityWorld().getTotalWorldTime()); + off.setTagCompound(tag); + } + + return breakBlock(itemstack, pos, player); + } + + /** + * Called to break the base block, return false to perform no breaking + * + * @param itemstack + * Tool ItemStack + * @param pos + * Current position + * @param player + * Player instance + * @return true if the normal block break code should be skipped + */ + protected boolean breakBlock(ItemStack itemstack, BlockPos pos, EntityPlayer player) + { + return super.onBlockStartBreak(itemstack, pos, player); + } + + /** + * Called when an AOE block is broken by the tool. Use to oveerride the + * block breaking logic + * + * @param tool + * Tool ItemStack + * @param world + * World instance + * @param player + * Player instance + * @param pos + * Current position + * @param refPos + * Base position + */ + protected void breakExtraBlock(ItemStack tool, World world, EntityPlayer player, BlockPos pos, BlockPos refPos) + { + ToolHelper.breakExtraBlock(tool, world, player, pos, refPos); + } + + // @Override + // public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, + // Entity entity) { + // return ToolHelper.attackEntity(stack, this, player, entity); + // } + + @Override + public boolean onEntitySwing(EntityLivingBase entityLiving, ItemStack stack) + { + /* + * if(attackSpeed() > 0) { int speed = Math.min(5, attackSpeed()); + * ToolHelper.swingItem(speed, entityLiving); return true; } + */ + return super.onEntitySwing(entityLiving, stack); + } + + @Override + public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) + { + float speed = ToolHelper.getActualAttackSpeed(stack); + int time = Math.round(20f / speed); + if (time < target.hurtResistantTime / 2) + { + target.hurtResistantTime = (target.hurtResistantTime + time) / 2; + target.hurtTime = (target.hurtTime + time) / 2; + } + return super.hitEntity(stack, target, attacker); } + @Nonnull @Override - public abstract NBTTagCompound buildTag(List<slimeknights.tconstruct.library.materials.Material> materials); + public Multimap<String, AttributeModifier> getAttributeModifiers(@Nonnull EntityEquipmentSlot slot, ItemStack stack) + { + Multimap<String, AttributeModifier> multimap = super.getAttributeModifiers(slot, stack); + + if (slot == EntityEquipmentSlot.MAINHAND && !ToolHelper.isBroken(stack)) + { + multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", ToolHelper.getActualAttack(stack), 0)); + multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", ToolHelper.getActualAttackSpeed(stack) - 4d, 0)); + } + + NBTTagList traitsTagList = TagUtil.getTraitsTagList(stack); + for (int i = 0; i < traitsTagList.tagCount(); i++) + { + ITrait trait = TinkerRegistry.getTrait(traitsTagList.getStringTagAt(i)); + if (trait != null) + { + trait.getAttributeModifiers(slot, stack, multimap); + } + } - public int getArmorDisplay(ItemStack stack) { - return TagUtil.getToolStats(stack).get().getInteger("ArmorRating"); + return multimap; + } + + @Override + public List<String> getInformation(ItemStack stack) + { + return getInformation(stack, true); + } + + @Override + public void getTooltip(ItemStack stack, List<String> tooltips) + { + if (ToolHelper.isBroken(stack)) + { + tooltips.add("" + TextFormatting.DARK_RED + TextFormatting.BOLD + getBrokenTooltip(stack)); + } + super.getTooltip(stack, tooltips); + } + + protected String getBrokenTooltip(ItemStack itemStack) + { + return Util.translate(TooltipBuilder.LOC_Broken); + } + + @Override + public void getTooltipDetailed(ItemStack stack, List<String> tooltips) + { + tooltips.addAll(getInformation(stack, false)); + } + + public List<String> getInformation(ItemStack stack, boolean detailed) + { + TooltipBuilder info = new TooltipBuilder(stack); + + info.addDurability(!detailed); + if (hasCategory(Category.HARVEST)) + { + info.addHarvestLevel(); + info.addMiningSpeed(); + } + if (hasCategory(Category.LAUNCHER)) + { + info.addDrawSpeed(); + info.addRange(); + info.addProjectileBonusDamage(); + } + info.addAttack(); + + if (ToolHelper.getFreeModifiers(stack) > 0) + { + info.addFreeModifiers(); + } + + if (detailed) + { + info.addModifierInfo(); + } + + return info.getTooltip(); + } + + @Override + public void getTooltipComponents(ItemStack stack, List<String> tooltips) + { + List<Material> materials = TinkerUtil.getMaterialsFromTagList(TagUtil.getBaseMaterialsTagList(stack)); + List<PartMaterialType> component = getRequiredComponents(); + + if (materials.size() < component.size()) + { + return; + } + + for (int i = 0; i < component.size(); i++) + { + PartMaterialType pmt = component.get(i); + Material material = materials.get(i); + + // get (one possible) toolpart used to craft the thing + Iterator<IToolPart> partIter = pmt.getPossibleParts().iterator(); + if (!partIter.hasNext()) + { + continue; + } + + IToolPart part = partIter.next(); + ItemStack partStack = part.getItemstackWithMaterial(material); + if (partStack != null) + { + // we have the part, add it + tooltips.add(material.getTextColor() + TextFormatting.UNDERLINE + partStack.getDisplayName()); + + Set<ITrait> usedTraits = Sets.newHashSet(); + // find out which stats and traits it contributes and add it to + // the tooltip + for (IMaterialStats stats : material.getAllStats()) + { + if (pmt.usesStat(stats.getIdentifier())) + { + tooltips.addAll(stats.getLocalizedInfo()); + for (ITrait trait : pmt.getApplicableTraitsForMaterial(material)) + { + if (!usedTraits.contains(trait)) + { + tooltips.add(material.getTextColor() + trait.getLocalizedName()); + usedTraits.add(trait); + } + } + } + } + tooltips.add(""); + } + } + } + + @Nonnull + @SideOnly(Side.CLIENT) + @Override + public FontRenderer getFontRenderer(ItemStack stack) + { + return ClientProxy.fontRenderer; } @SideOnly(Side.CLIENT) - public abstract List<String> getArmorTexture(ItemStack stack); + @Override + public boolean hasEffect(ItemStack stack) + { + return TagUtil.hasEnchantEffect(stack); + } + + @Nonnull + @Override + public String getItemStackDisplayName(@Nonnull ItemStack stack) + { + // if the tool is not named we use the repair tools for a prefix like + // thing + List<Material> materials = TinkerUtil.getMaterialsFromTagList(TagUtil.getBaseMaterialsTagList(stack)); + // we save all the ones for the name in a set so we don't have the same + // material in it twice + Set<Material> nameMaterials = Sets.newLinkedHashSet(); + + for (int index : getRepairParts()) + { + if (index < materials.size()) + { + nameMaterials.add(materials.get(index)); + } + } + + return Material.getCombinedItemName(super.getItemStackDisplayName(stack), nameMaterials); + } + + // Creative tab items + @Override + public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> subItems) + { + if (this.isInCreativeTab(tab)) + { + addDefaultSubItems(subItems); + } + } + + protected void addDefaultSubItems(List<ItemStack> subItems, Material... fixedMaterials) + { + for (Material head : TinkerRegistry.getAllMaterials()) + { + List<Material> mats = new ArrayList<>(requiredComponents.length); + + for (int i = 0; i < requiredComponents.length; i++) + { + if (fixedMaterials.length > i && fixedMaterials[i] != null && requiredComponents[i].isValidMaterial(fixedMaterials[i])) + { + mats.add(fixedMaterials[i]); + } else + { + // todo: check for applicability with stats + mats.add(head); + } + } + + ItemStack tool = buildItem(mats); + // only valid ones + if (hasValidMaterials(tool)) + { + subItems.add(tool); + if (!Config.listAllMaterials) + { + break; + } + } + } + } + + protected void addInfiTool(List<ItemStack> subItems, String name) + { + ItemStack tool = getInfiTool(name); + if (hasValidMaterials(tool)) + { + subItems.add(tool); + } + } + + protected ItemStack getInfiTool(String name) + { + // The InfiHarvester! + List<Material> materials = ImmutableList.of(TinkerMaterials.slime, TinkerMaterials.cobalt, TinkerMaterials.ardite, TinkerMaterials.ardite); + materials = materials.subList(0, requiredComponents.length); + ItemStack tool = buildItem(materials); + tool.setStackDisplayName(name); + InfiTool.INSTANCE.apply(tool); + + return tool; + } + + @Override + public int getHarvestLevel(ItemStack stack, String toolClass, @Nullable EntityPlayer player, @Nullable IBlockState blockState) + { + if (ToolHelper.isBroken(stack)) + { + return -1; + } + + if (this.getToolClasses(stack).contains(toolClass)) + { + // will return 0 if the tag has no info anyway + return ToolHelper.getHarvestLevelStat(stack); + } + + return super.getHarvestLevel(stack, toolClass, player, blockState); + } + + @Override + public Set<String> getToolClasses(ItemStack stack) + { + // no classes if broken + if (ToolHelper.isBroken(stack)) + { + return Collections.emptySet(); + } + return super.getToolClasses(stack); + } + + /** + * A simple string identifier for the tool, used for identification in + * texture generation etc. + */ + public String getIdentifier() + { + return getRegistryName().getResourcePath(); + } + + /** The tools name completely without material information */ + @Override + public String getLocalizedToolName() + { + return Util.translate(getUnlocalizedName() + ".name"); + } + + /** The tools name with the given material. e.g. "Wooden Pickaxe" */ + public String getLocalizedToolName(Material material) + { + return material.getLocalizedItemName(getLocalizedToolName()); + } + + /** Returns info about the Tool. Displayed in the tool stations etc. */ + public String getLocalizedDescription() + { + return Util.translate(getUnlocalizedName() + ".desc"); + } + + @Override + protected int repairCustom(Material material, NonNullList<ItemStack> repairItems) + { + Optional<RecipeMatch.Match> matchOptional = RecipeMatch.of(TinkerTools.sharpeningKit).matches(repairItems); + if (!matchOptional.isPresent()) + { + return 0; + } + + RecipeMatch.Match match = matchOptional.get(); + for (ItemStack stacks : match.stacks) + { + // invalid material? + if (TinkerTools.sharpeningKit.getMaterial(stacks) != material) + { + return 0; + } + } + + RecipeMatch.removeMatch(repairItems, match); + HeadMaterialStats stats = material.getStats(MaterialTypes.HEAD); + float durability = stats.durability * match.amount * TinkerTools.sharpeningKit.getCost(); + durability /= Material.VALUE_Ingot; + return (int) (durability); + } + + /* Additional Trait callbacks */ + + @Override + public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) + { + super.onUpdate(stack, worldIn, entityIn, itemSlot, isSelected); + + onUpdateTraits(stack, worldIn, entityIn, itemSlot, isSelected); + } + + protected void onUpdateTraits(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) + { + if (!isSelected && entityIn instanceof EntityPlayer && ((EntityPlayer) entityIn).getHeldItemOffhand() == stack) + { + isSelected = true; + } + NBTTagList list = TagUtil.getTraitsTagList(stack); + for (int i = 0; i < list.tagCount(); i++) + { + ITrait trait = TinkerRegistry.getTrait(list.getStringTagAt(i)); + if (trait != null) + { + trait.onUpdate(stack, worldIn, entityIn, itemSlot, isSelected); + } + } + } + + @Override + public boolean onBlockDestroyed(ItemStack stack, World worldIn, IBlockState state, BlockPos pos, EntityLivingBase entityLiving) + { + // move item back into offhand. See onBlockBreakStart + if (stack != null && entityLiving != null && stack.hasTagCompound()) + { + NBTTagCompound tag = stack.getTagCompound(); + assert tag != null; + if (tag.getLong(TAG_SWITCHED_HAND_HAX) == entityLiving.getEntityWorld().getTotalWorldTime()) + { + tag.removeTag(TAG_SWITCHED_HAND_HAX); + stack.setTagCompound(tag); + + switchItemsInHands(entityLiving); + } + } + if (ToolHelper.isBroken(stack)) + { + return false; + } + + boolean effective = isEffective(state) || ToolHelper.isToolEffective(stack, worldIn.getBlockState(pos)); + int damage = effective ? 1 : 2; + + afterBlockBreak(stack, worldIn, state, pos, entityLiving, damage, effective); + + return hasCategory(Category.TOOL); + } + + protected void switchItemsInHands(EntityLivingBase entityLiving) + { + ItemStack main = entityLiving.getHeldItemMainhand(); + ItemStack off = entityLiving.getHeldItemOffhand(); + entityLiving.setHeldItem(EnumHand.OFF_HAND, main); + entityLiving.setHeldItem(EnumHand.MAIN_HAND, off); + } + + public void afterBlockBreak(ItemStack stack, World world, IBlockState state, BlockPos pos, EntityLivingBase player, int damage, boolean wasEffective) + { + NBTTagList list = TagUtil.getTraitsTagList(stack); + for (int i = 0; i < list.tagCount(); i++) + { + ITrait trait = TinkerRegistry.getTrait(list.getStringTagAt(i)); + if (trait != null) + { + trait.afterBlockBreak(stack, world, state, pos, player, wasEffective); + } + } + + ToolHelper.damageTool(stack, damage, player); + } + + // elevate to public + @Override + public RayTraceResult rayTrace(@Nonnull World worldIn, @Nonnull EntityPlayer playerIn, boolean useLiquids) + { + return super.rayTrace(worldIn, playerIn, useLiquids); + } + + protected void preventSlowDown(Entity entityIn, float originalSpeed) + { + TinkerTools.proxy.preventPlayerSlowdown(entityIn, originalSpeed, this); + } + + @Override + public boolean shouldCauseBlockBreakReset(ItemStack oldStack, ItemStack newStack) + { + return shouldCauseReequipAnimation(oldStack, newStack, false); + } @SideOnly(Side.CLIENT) - @Nullable - public abstract ArmorRenderer getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack); - - public ArmorNBT buildDefaultArmorTag(List<Material> materials, String type) { - ArmorNBT data = new ArmorNBT(); - - if (materials.size() >= 2) { - HandleMaterialStats handle = materials.get(0).getStatsOrUnknown(MaterialTypes.HANDLE); - ArmorMaterialStats head = materials.get(1).getStatsOrUnknown(type); - // start with head - data.head(head); - - // add in accessories if present - if (materials.size() >= 3) { - ExtraMaterialStats binding = materials.get(2).getStatsOrUnknown(MaterialTypes.EXTRA); - data.extra(binding); + @Override + public boolean shouldCauseReequipAnimation(ItemStack oldStack, @Nonnull ItemStack newStack, boolean slotChanged) + { + if (TagUtil.getResetFlag(newStack)) + { + TagUtil.setResetFlag(newStack, false); + return true; + } + if (oldStack == newStack) + { + return false; + } + if (slotChanged) + { + return true; + } + + if (oldStack.hasEffect() != newStack.hasEffect()) + { + return true; + } + + Multimap<String, AttributeModifier> attributesNew = newStack.getAttributeModifiers(EntityEquipmentSlot.MAINHAND); + Multimap<String, AttributeModifier> attributesOld = oldStack.getAttributeModifiers(EntityEquipmentSlot.MAINHAND); + + if (attributesNew.size() != attributesOld.size()) + { + return true; + } + for (String key : attributesOld.keySet()) + { + if (!attributesNew.containsKey(key)) + { + return true; + } + Iterator<AttributeModifier> iter1 = attributesNew.get(key).iterator(); + Iterator<AttributeModifier> iter2 = attributesOld.get(key).iterator(); + while (iter1.hasNext() && iter2.hasNext()) + { + if (!iter1.next().equals(iter2.next())) + { + return true; + } } + } + + if (oldStack.getItem() == newStack.getItem() && newStack.getItem() instanceof ArmorCore) + { + return !isEqualTinkersItem(oldStack, newStack); + } + return !ItemStack.areItemStacksEqual(oldStack, newStack); + } + + /** + * Builds a default tool from: 1. Handle 2. Head 3. Accessoire (if present) + */ + protected ArmorNBT buildDefaultTag(List<Material> materials) + { + return null; + + } + + public static boolean isEqualTinkersItem(ItemStack item1, ItemStack item2) + { + if (item1 == null || item2 == null || item1.getItem() != item2.getItem()) + { + return false; + } + if (!(item1.getItem() instanceof ArmorCore)) + { + return false; + } + + NBTTagCompound tag1 = TagUtil.getTagSafe(item1); + NBTTagCompound tag2 = TagUtil.getTagSafe(item2); + + NBTTagList mods1 = TagUtil.getModifiersTagList(tag1); + NBTTagList mods2 = TagUtil.getModifiersTagList(tag2); - // calculate handle impact - data.handle(handle); + if (mods1.tagCount() != mods1.tagCount()) + { + return false; } - // 3 free modifiers - data.modifiers = 5; + // check modifiers + for (int i = 0; i < mods1.tagCount(); i++) + { + NBTTagCompound tag = mods1.getCompoundTagAt(i); + ModifierNBT data = ModifierNBT.readTag(tag); + IModifier modifier = TinkerRegistry.getModifier(data.identifier); + if (modifier != null && !modifier.equalModifier(tag, mods2.getCompoundTagAt(i))) + { + return false; + } + } + + return TagUtil.getBaseMaterialsTagList(tag1).equals(TagUtil.getBaseMaterialsTagList(tag2)) && // materials + // used + TagUtil.getBaseModifiersUsed(tag1) == TagUtil.getBaseModifiersUsed(tag2) && // number + // of + // free + // modifiers + // used + TagUtil.getOriginalToolStats(tag1).equals(TagUtil.getOriginalToolStats(tag2)); // unmodified + // base + // stats + } + + public EntityEquipmentSlot getArmorSlot(ItemStack stack, EntityEquipmentSlot armorType) + { + return null; + } - return data; + @SideOnly(Side.CLIENT) + public ArmorRenderer getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack) + { + return null; } @Override - public boolean isValidArmor(ItemStack stack, EntityEquipmentSlot armorType, Entity entity) - { - return armorType == getArmorSlot(stack, armorType); - } - - public abstract EntityEquipmentSlot getArmorSlot(ItemStack stack, EntityEquipmentSlot armorType); + public String getArmorTexture(ItemStack stack, Entity entity, EntityEquipmentSlot slot, String type) + { + String s = TagUtil.getTagSafe(TagUtil.getTagSafe(stack), ArmorTags.DynTex).getString(ArmorTags.TexLoc); + if((s == "" || s == null) || !checkForTexture(s)) + { + NBTTagCompound texTag = setupTexture(TinkerUtil.getMaterialsFromTagList(TagUtil.getBaseMaterialsTagList(stack))); + if (texTag != null) + TagUtil.getTagSafe(stack).setTag(ArmorTags.DynTex, texTag); + NBTTagCompound n = TagUtil.getTagSafe(TagUtil.getTagSafe(stack), ArmorTags.DynTex); + s = n.getString(ArmorTags.TexLoc); + } + return s; + } - @Override - public void getTooltip(ItemStack stack, List<String> tooltips) { - if(ToolHelper.isBroken(stack)) { - tooltips.add("" + TextFormatting.DARK_RED + TextFormatting.BOLD + getBrokenTooltip(stack)); - } - super.getTooltip(stack, tooltips); - } - - protected String getBrokenTooltip(ItemStack itemStack) { - return Util.translate(TooltipBuilder.LOC_Broken); - } - - @Override - public void getTooltipDetailed(ItemStack stack, List<String> tooltips) { - tooltips.addAll(getInformation(stack, false)); - } - - public List<String> getInformation(ItemStack stack, boolean detailed) { - TooltipBuilder info = new TooltipBuilder(stack); - - info.addDurability(!detailed); - if(hasCategory(Category.HARVEST)) { - info.addHarvestLevel(); - info.addMiningSpeed(); - } - if(hasCategory(Category.LAUNCHER)) { - info.addDrawSpeed(); - info.addRange(); - info.addProjectileBonusDamage(); - } - info.addAttack(); - - if(ToolHelper.getFreeModifiers(stack) > 0) { - info.addFreeModifiers(); - } - - if(detailed) { - info.addModifierInfo(); - } - - return info.getTooltip(); - } - - @Override - public void getTooltipComponents(ItemStack stack, List<String> tooltips) { - List<Material> materials = TinkerUtil.getMaterialsFromTagList(TagUtil.getBaseMaterialsTagList(stack)); - List<PartMaterialType> component = getRequiredComponents(); - - if(materials.size() < component.size()) { - return; - } - - for(int i = 0; i < component.size(); i++) { - PartMaterialType pmt = component.get(i); - Material material = materials.get(i); - - // get (one possible) toolpart used to craft the thing - Iterator<IToolPart> partIter = pmt.getPossibleParts().iterator(); - if(!partIter.hasNext()) { - continue; - } - - IToolPart part = partIter.next(); - ItemStack partStack = part.getItemstackWithMaterial(material); - if(partStack != null) { - // we have the part, add it - tooltips.add(material.getTextColor() + TextFormatting.UNDERLINE + partStack.getDisplayName()); - - Set<ITrait> usedTraits = Sets.newHashSet(); - // find out which stats and traits it contributes and add it to the tooltip - for(IMaterialStats stats : material.getAllStats()) { - if(pmt.usesStat(stats.getIdentifier())) { - tooltips.addAll(stats.getLocalizedInfo()); - for(ITrait trait : pmt.getApplicableTraitsForMaterial(material)) { - if(!usedTraits.contains(trait)) { - tooltips.add(material.getTextColor() + trait.getLocalizedName()); - usedTraits.add(trait); - } - } - } - } - tooltips.add(""); - } - } - } - -} + private boolean checkForTexture(String s) + { + if(Minecraft.getMinecraft().getTextureManager().getTexture(new ResourceLocation(s)) != null) + return true; + return false; + } +}
\ No newline at end of file diff --git a/src/main/java/lance5057/tDefense/core/tools/basic/HeaterShield.java b/src/main/java/lance5057/tDefense/core/tools/basic/HeaterShield.java index f70dca9..e3f9253 100644 --- a/src/main/java/lance5057/tDefense/core/tools/basic/HeaterShield.java +++ b/src/main/java/lance5057/tDefense/core/tools/basic/HeaterShield.java @@ -1,6 +1,6 @@ package lance5057.tDefense.core.tools.basic; -import lance5057.tDefense.core.materials.ShieldMaterialStats; +import lance5057.tDefense.core.materials.stats.ShieldMaterialStats; import lance5057.tDefense.core.parts.TDParts; import lance5057.tDefense.core.tools.bases.Shield; import slimeknights.tconstruct.library.tinkering.PartMaterialType; diff --git a/src/main/java/lance5057/tDefense/core/tools/basic/RoundShield.java b/src/main/java/lance5057/tDefense/core/tools/basic/RoundShield.java index ff4388a..ddfd7f4 100644 --- a/src/main/java/lance5057/tDefense/core/tools/basic/RoundShield.java +++ b/src/main/java/lance5057/tDefense/core/tools/basic/RoundShield.java @@ -1,6 +1,6 @@ package lance5057.tDefense.core.tools.basic; -import lance5057.tDefense.core.materials.ShieldMaterialStats; +import lance5057.tDefense.core.materials.stats.ShieldMaterialStats; import lance5057.tDefense.core.parts.TDParts; import lance5057.tDefense.core.tools.bases.Shield; import slimeknights.tconstruct.library.tinkering.PartMaterialType; diff --git a/src/main/java/lance5057/tDefense/core/tools/basic/TowerShield.java b/src/main/java/lance5057/tDefense/core/tools/basic/TowerShield.java index ebaf791..d5bd9e8 100644 --- a/src/main/java/lance5057/tDefense/core/tools/basic/TowerShield.java +++ b/src/main/java/lance5057/tDefense/core/tools/basic/TowerShield.java @@ -1,6 +1,6 @@ package lance5057.tDefense.core.tools.basic; -import lance5057.tDefense.core.materials.ShieldMaterialStats; +import lance5057.tDefense.core.materials.stats.ShieldMaterialStats; import lance5057.tDefense.core.parts.TDParts; import lance5057.tDefense.core.tools.bases.Shield; import slimeknights.tconstruct.library.tinkering.PartMaterialType; diff --git a/src/main/java/lance5057/tDefense/core/tools/baubles/Sheathe.java b/src/main/java/lance5057/tDefense/core/tools/baubles/Sheathe.java index f6f2c3b..8c84171 100644 --- a/src/main/java/lance5057/tDefense/core/tools/baubles/Sheathe.java +++ b/src/main/java/lance5057/tDefense/core/tools/baubles/Sheathe.java @@ -2,6 +2,8 @@ package lance5057.tDefense.core.tools.baubles; import baubles.api.BaubleType; import lance5057.tDefense.Reference; +import lance5057.tDefense.core.materials.stats.FabricMaterialStats; +import lance5057.tDefense.core.parts.TDParts; import lance5057.tDefense.core.tools.bases.BaubleTool; import lance5057.tDefense.proxy.ClientProxy; import net.minecraft.client.Minecraft; @@ -16,8 +18,9 @@ public class Sheathe extends BaubleTool { private static final ResourceLocation texture = new ResourceLocation(Reference.MOD_ID, "textures/model/sheathe.png"); public Sheathe(PartMaterialType... requiredComponents) { - super(PartMaterialType.head(TinkerTools.largePlate), PartMaterialType.handle(TinkerTools.toolRod), - PartMaterialType.bowstring(TinkerTools.bowString)); + super(PartMaterialType.head(TDParts.armorPlate), PartMaterialType.handle(TDParts.clasp), + new PartMaterialType(TDParts.fabric, FabricMaterialStats.TYPE), + PartMaterialType.extra(TDParts.filigree)); } |
