mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-19 03:49:29 +00:00
Reorganize folders for modules
This commit is contained in:
1 parent
2c14f315de
commit
e2f0558b6f
370 files changed
+4274
-4788
No files matched your search
@@ -0,0 +1,38 @@
|
||||
package tconstruct.tools;
|
||||
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import tconstruct.library.crafting.ToolRecipe;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
|
||||
public class BowRecipe extends ToolRecipe
|
||||
{
|
||||
|
||||
public BowRecipe(Item head, Item handle, ToolCore tool)
|
||||
{
|
||||
super(head, handle, tool);
|
||||
}
|
||||
|
||||
public BowRecipe(Item head, Item handle, Item accessory, ToolCore tool)
|
||||
{
|
||||
super(head, handle, accessory, tool);
|
||||
}
|
||||
|
||||
public BowRecipe(Item head, Item handle, Item accessory, Item extra, ToolCore tool)
|
||||
{
|
||||
super(head, handle, accessory, extra, tool);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validHead (Item input)
|
||||
{
|
||||
for (Item part : headList)
|
||||
{
|
||||
if (part == input)
|
||||
return true;
|
||||
if (toolRod != null && part == toolRod && (input == Items.stick || input == Items.bone))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,962 @@
|
||||
package tconstruct.tools;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import mantle.items.abstracts.CraftingItem;
|
||||
import mantle.utils.RecipeRemover;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.armor.TinkerArmor;
|
||||
import tconstruct.armor.modifiers.AModDamageBoost;
|
||||
import tconstruct.armor.modifiers.AModDoubleJump;
|
||||
import tconstruct.armor.modifiers.AModHealthBoost;
|
||||
import tconstruct.armor.modifiers.AModKnockbackResistance;
|
||||
import tconstruct.armor.modifiers.AModMoveSpeed;
|
||||
import tconstruct.armor.modifiers.AModProtection;
|
||||
import tconstruct.common.itemblocks.MetadataItemBlock;
|
||||
import tconstruct.items.tools.Arrow;
|
||||
import tconstruct.items.tools.BattleSign;
|
||||
import tconstruct.items.tools.Battleaxe;
|
||||
import tconstruct.items.tools.Broadsword;
|
||||
import tconstruct.items.tools.Chisel;
|
||||
import tconstruct.items.tools.Cleaver;
|
||||
import tconstruct.items.tools.Cutlass;
|
||||
import tconstruct.items.tools.Dagger;
|
||||
import tconstruct.items.tools.Excavator;
|
||||
import tconstruct.items.tools.FryingPan;
|
||||
import tconstruct.items.tools.Hammer;
|
||||
import tconstruct.items.tools.Hatchet;
|
||||
import tconstruct.items.tools.Longsword;
|
||||
import tconstruct.items.tools.LumberAxe;
|
||||
import tconstruct.items.tools.Mattock;
|
||||
import tconstruct.items.tools.Pickaxe;
|
||||
import tconstruct.items.tools.PotionLauncher;
|
||||
import tconstruct.items.tools.Rapier;
|
||||
import tconstruct.items.tools.Scythe;
|
||||
import tconstruct.items.tools.Shortbow;
|
||||
import tconstruct.items.tools.Shovel;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.armor.EnumArmorPart;
|
||||
import tconstruct.library.client.TConstructClientRegistry;
|
||||
import tconstruct.library.crafting.Detailing;
|
||||
import tconstruct.library.crafting.PatternBuilder;
|
||||
import tconstruct.library.crafting.ToolBuilder;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
import tconstruct.library.util.IPattern;
|
||||
import tconstruct.smeltery.TinkerSmeltery;
|
||||
import tconstruct.tools.blocks.CraftingSlab;
|
||||
import tconstruct.tools.blocks.CraftingStationBlock;
|
||||
import tconstruct.tools.blocks.EquipBlock;
|
||||
import tconstruct.tools.blocks.FurnaceSlab;
|
||||
import tconstruct.tools.blocks.ToolForgeBlock;
|
||||
import tconstruct.tools.blocks.ToolStationBlock;
|
||||
import tconstruct.tools.itemblocks.CraftingSlabItemBlock;
|
||||
import tconstruct.tools.itemblocks.ToolStationItemBlock;
|
||||
import tconstruct.tools.items.Bowstring;
|
||||
import tconstruct.tools.items.CreativeModifier;
|
||||
import tconstruct.tools.items.Fletching;
|
||||
import tconstruct.tools.items.Manual;
|
||||
import tconstruct.tools.items.MaterialItem;
|
||||
import tconstruct.tools.items.Pattern;
|
||||
import tconstruct.tools.items.TitleIcon;
|
||||
import tconstruct.tools.items.ToolPart;
|
||||
import tconstruct.tools.items.ToolPartHidden;
|
||||
import tconstruct.tools.items.ToolShard;
|
||||
import tconstruct.tools.logic.CraftingStationLogic;
|
||||
import tconstruct.tools.logic.FrypanLogic;
|
||||
import tconstruct.tools.logic.FurnaceLogic;
|
||||
import tconstruct.tools.logic.PartBuilderLogic;
|
||||
import tconstruct.tools.logic.PatternChestLogic;
|
||||
import tconstruct.tools.logic.StencilTableLogic;
|
||||
import tconstruct.tools.logic.ToolForgeLogic;
|
||||
import tconstruct.tools.logic.ToolStationLogic;
|
||||
import tconstruct.tools.modifiers.ModAntiSpider;
|
||||
import tconstruct.tools.modifiers.ModAttack;
|
||||
import tconstruct.tools.modifiers.ModAutoSmelt;
|
||||
import tconstruct.tools.modifiers.ModBlaze;
|
||||
import tconstruct.tools.modifiers.ModButtertouch;
|
||||
import tconstruct.tools.modifiers.ModCreativeToolModifier;
|
||||
import tconstruct.tools.modifiers.ModDurability;
|
||||
import tconstruct.tools.modifiers.ModExtraModifier;
|
||||
import tconstruct.tools.modifiers.ModFlux;
|
||||
import tconstruct.tools.modifiers.ModInteger;
|
||||
import tconstruct.tools.modifiers.ModLapis;
|
||||
import tconstruct.tools.modifiers.ModPiston;
|
||||
import tconstruct.tools.modifiers.ModRedstone;
|
||||
import tconstruct.tools.modifiers.ModReinforced;
|
||||
import tconstruct.tools.modifiers.ModRepair;
|
||||
import tconstruct.tools.modifiers.ModSmite;
|
||||
import tconstruct.tools.modifiers.TActiveOmniMod;
|
||||
import tconstruct.util.ItemHelper;
|
||||
import tconstruct.util.config.PHConstruct;
|
||||
import tconstruct.world.TinkerWorld;
|
||||
import tconstruct.world.blocks.SoilBlock;
|
||||
import tconstruct.world.itemblocks.CraftedSoilItemBlock;
|
||||
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.Mod.EventHandler;
|
||||
import cpw.mods.fml.common.Mod.Instance;
|
||||
import cpw.mods.fml.common.SidedProxy;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
@Mod(modid = "TinkerTools", name = "TinkerTools", version = "${tinkertoolversion}")
|
||||
public class TinkerTools
|
||||
{
|
||||
/* Proxies for sides, used for graphics processing */
|
||||
@SidedProxy(clientSide = "tconstruct.tools.ToolProxyClient", serverSide = "tconstruct.tools.ToolProxyCommon")
|
||||
public static ToolProxyCommon proxy;
|
||||
|
||||
@Instance("TinkerTools")
|
||||
public static TinkerTools instance;
|
||||
|
||||
// Crafting blocks
|
||||
public static Block toolStationWood;
|
||||
public static Block toolStationStone;
|
||||
public static Block toolForge;
|
||||
public static Block craftingStationWood;
|
||||
public static Block craftingSlabWood;
|
||||
public static Block furnaceSlab;
|
||||
public static Block heldItemBlock;
|
||||
public static Block battlesignBlock;
|
||||
|
||||
// Tool parts
|
||||
public static Item binding;
|
||||
public static Item toughBinding;
|
||||
public static Item toughRod;
|
||||
public static Item largePlate;
|
||||
public static Item pickaxeHead;
|
||||
public static Item shovelHead;
|
||||
public static Item hatchetHead;
|
||||
public static Item frypanHead;
|
||||
public static Item signHead;
|
||||
public static Item chiselHead;
|
||||
public static Item scytheBlade;
|
||||
public static Item broadAxeHead;
|
||||
public static Item excavatorHead;
|
||||
public static Item hammerHead;
|
||||
public static Item swordBlade;
|
||||
public static Item largeSwordBlade;
|
||||
public static Item knifeBlade;
|
||||
public static Item wideGuard;
|
||||
|
||||
// Supresses console spam when iguana's tweaks remove stuff
|
||||
public static boolean supressMissingToolLogs = false;
|
||||
|
||||
// Patterns and other materials
|
||||
public static Item blankPattern;
|
||||
public static Item materials; //TODO: Untwine this item
|
||||
public static Item toolRod;
|
||||
public static Item toolShard;
|
||||
public static Item titleIcon;
|
||||
|
||||
// Tools
|
||||
public static ToolCore pickaxe;
|
||||
public static ToolCore shovel;
|
||||
public static ToolCore hatchet;
|
||||
public static ToolCore broadsword;
|
||||
public static ToolCore longsword;
|
||||
public static ToolCore rapier;
|
||||
public static ToolCore dagger;
|
||||
public static ToolCore cutlass;
|
||||
public static ToolCore frypan;
|
||||
public static ToolCore battlesign;
|
||||
public static ToolCore chisel;
|
||||
public static ToolCore mattock;
|
||||
public static ToolCore scythe;
|
||||
public static ToolCore lumberaxe;
|
||||
public static ToolCore cleaver;
|
||||
public static ToolCore hammer;
|
||||
public static ToolCore battleaxe;
|
||||
public static ToolCore shortbow;
|
||||
public static ToolCore arrow;
|
||||
public static Item potionLauncher;
|
||||
public static Item handGuard;
|
||||
public static Item crossbar;
|
||||
public static Item fullGuard;
|
||||
public static Item bowstring;
|
||||
public static Item arrowhead;
|
||||
public static Item fletching;
|
||||
public static Block craftedSoil;
|
||||
public static Block multiBrick;
|
||||
public static Block multiBrickFancy;
|
||||
// Tool modifiers
|
||||
public static ModFlux modFlux;
|
||||
public static ModLapis modLapis;
|
||||
public static ModAttack modAttack;
|
||||
public static Item[] patternOutputs;
|
||||
public static Item woodPattern;
|
||||
public static Item manualBook;
|
||||
public static ToolCore excavator;
|
||||
public static Item creativeModifier;
|
||||
public static Item goldHead;
|
||||
|
||||
// recipe stuff
|
||||
public static boolean thaumcraftAvailable;
|
||||
|
||||
@EventHandler
|
||||
public void preInit (FMLPreInitializationEvent event)
|
||||
{
|
||||
//Blocks
|
||||
TinkerTools.toolStationWood = new ToolStationBlock(Material.wood).setBlockName("ToolStation");
|
||||
TinkerTools.toolForge = new ToolForgeBlock(Material.iron).setBlockName("ToolForge");
|
||||
TinkerTools.craftingStationWood = new CraftingStationBlock(Material.wood).setBlockName("CraftingStation");
|
||||
TinkerTools.craftingSlabWood = new CraftingSlab(Material.wood).setBlockName("CraftingSlab");
|
||||
TinkerTools.furnaceSlab = new FurnaceSlab(Material.rock).setBlockName("FurnaceSlab");
|
||||
|
||||
TinkerTools.heldItemBlock = new EquipBlock(Material.wood).setBlockName("Frypan");
|
||||
|
||||
/* battlesignBlock = new BattlesignBlock(PHConstruct.battlesignBlock).setUnlocalizedName("Battlesign");
|
||||
GameRegistry.registerBlock(battlesignBlock, "BattlesignBlock");
|
||||
ameRegistry.registerTileEntity(BattlesignLogic.class, "BattlesignLogic");*/
|
||||
|
||||
TinkerTools.craftedSoil = new SoilBlock().setLightOpacity(0).setBlockName("TConstruct.Soil");
|
||||
TinkerTools.craftedSoil.stepSound = Block.soundTypeGravel;
|
||||
|
||||
GameRegistry.registerBlock(TinkerTools.toolStationWood, ToolStationItemBlock.class, "ToolStationBlock");
|
||||
GameRegistry.registerTileEntity(ToolStationLogic.class, "ToolStation");
|
||||
GameRegistry.registerTileEntity(PartBuilderLogic.class, "PartCrafter");
|
||||
GameRegistry.registerTileEntity(PatternChestLogic.class, "PatternHolder");
|
||||
GameRegistry.registerTileEntity(StencilTableLogic.class, "PatternShaper");
|
||||
GameRegistry.registerBlock(TinkerTools.toolForge, MetadataItemBlock.class, "ToolForgeBlock");
|
||||
GameRegistry.registerTileEntity(ToolForgeLogic.class, "ToolForge");
|
||||
GameRegistry.registerBlock(TinkerTools.craftingStationWood, "CraftingStation");
|
||||
GameRegistry.registerTileEntity(CraftingStationLogic.class, "CraftingStation");
|
||||
GameRegistry.registerBlock(TinkerTools.craftingSlabWood, CraftingSlabItemBlock.class, "CraftingSlab");
|
||||
GameRegistry.registerBlock(TinkerTools.furnaceSlab, "FurnaceSlab");
|
||||
GameRegistry.registerTileEntity(FurnaceLogic.class, "TConstruct.Furnace");
|
||||
GameRegistry.registerBlock(TinkerTools.heldItemBlock, "HeldItemBlock");
|
||||
GameRegistry.registerTileEntity(FrypanLogic.class, "FrypanLogic");
|
||||
|
||||
GameRegistry.registerBlock(TinkerTools.craftedSoil, CraftedSoilItemBlock.class, "CraftedSoil");
|
||||
|
||||
//Items
|
||||
TinkerTools.titleIcon = new TitleIcon().setUnlocalizedName("tconstruct.titleicon");
|
||||
GameRegistry.registerItem(TinkerTools.titleIcon, "titleIcon");
|
||||
String[] blanks = new String[] { "blank_pattern", "blank_cast", "blank_cast" };
|
||||
TinkerTools.blankPattern = new CraftingItem(blanks, blanks, "materials/", "tinker", TConstructRegistry.materialTab).setUnlocalizedName("tconstruct.Pattern");
|
||||
GameRegistry.registerItem(TinkerTools.blankPattern, "blankPattern");
|
||||
|
||||
TinkerTools.materials = new MaterialItem().setUnlocalizedName("tconstruct.Materials");
|
||||
TinkerTools.toolRod = new ToolPart("_rod", "ToolRod").setUnlocalizedName("tconstruct.ToolRod");
|
||||
TinkerTools.toolShard = new ToolShard("_chunk").setUnlocalizedName("tconstruct.ToolShard");
|
||||
TinkerTools.woodPattern = new Pattern("pattern_", "materials/").setUnlocalizedName("tconstruct.Pattern");
|
||||
GameRegistry.registerItem(TinkerTools.materials, "materials");
|
||||
GameRegistry.registerItem(TinkerTools.woodPattern, "woodPattern");
|
||||
TConstructRegistry.addItemToDirectory("blankPattern", TinkerTools.blankPattern);
|
||||
TConstructRegistry.addItemToDirectory("woodPattern", TinkerTools.woodPattern);
|
||||
|
||||
String[] patternTypes = { "ingot", "toolRod", "pickaxeHead", "shovelHead", "hatchetHead", "swordBlade", "wideGuard", "handGuard", "crossbar", "binding", "frypanHead", "signHead",
|
||||
"knifeBlade", "chiselHead", "toughRod", "toughBinding", "largePlate", "broadAxeHead", "scytheHead", "excavatorHead", "largeBlade", "hammerHead", "fullGuard" };
|
||||
|
||||
for (int i = 1; i < patternTypes.length; i++)
|
||||
{
|
||||
TConstructRegistry.addItemStackToDirectory(patternTypes[i] + "Pattern", new ItemStack(TinkerTools.woodPattern, 1, i));
|
||||
}
|
||||
|
||||
TinkerTools.manualBook = new Manual();
|
||||
GameRegistry.registerItem(TinkerTools.manualBook, "manualBook");
|
||||
|
||||
|
||||
TinkerTools.pickaxe = new Pickaxe();
|
||||
TinkerTools.shovel = new Shovel();
|
||||
TinkerTools.hatchet = new Hatchet();
|
||||
TinkerTools.broadsword = new Broadsword();
|
||||
TinkerTools.longsword = new Longsword();
|
||||
TinkerTools.rapier = new Rapier();
|
||||
TinkerTools.dagger = new Dagger();
|
||||
TinkerTools.cutlass = new Cutlass();
|
||||
|
||||
TinkerTools.frypan = new FryingPan();
|
||||
TinkerTools.battlesign = new BattleSign();
|
||||
TinkerTools.mattock = new Mattock();
|
||||
TinkerTools.chisel = new Chisel();
|
||||
|
||||
TinkerTools.lumberaxe = new LumberAxe();
|
||||
TinkerTools.cleaver = new Cleaver();
|
||||
TinkerTools.scythe = new Scythe();
|
||||
TinkerTools.excavator = new Excavator();
|
||||
TinkerTools.hammer = new Hammer();
|
||||
TinkerTools.battleaxe = new Battleaxe();
|
||||
|
||||
TinkerTools.shortbow = new Shortbow();
|
||||
TinkerTools.arrow = new Arrow();
|
||||
|
||||
Item[] tools = { TinkerTools.pickaxe, TinkerTools.shovel, TinkerTools.hatchet, TinkerTools.broadsword, TinkerTools.longsword, TinkerTools.rapier, TinkerTools.dagger, TinkerTools.cutlass, TinkerTools.frypan, TinkerTools.battlesign, TinkerTools.mattock,
|
||||
TinkerTools.chisel, TinkerTools.lumberaxe, TinkerTools.cleaver, TinkerTools.scythe, TinkerTools.excavator, TinkerTools.hammer, TinkerTools.battleaxe, TinkerTools.shortbow, TinkerTools.arrow };
|
||||
String[] toolStrings = { "pickaxe", "shovel", "hatchet", "broadsword", "longsword", "rapier", "dagger", "cutlass", "frypan", "battlesign", "mattock", "chisel", "lumberaxe", "cleaver",
|
||||
"scythe", "excavator", "hammer", "battleaxe", "shortbow", "arrow" };
|
||||
|
||||
for (int i = 0; i < tools.length; i++)
|
||||
{
|
||||
GameRegistry.registerItem(tools[i], toolStrings[i]); // 1.7 compat
|
||||
TConstructRegistry.addItemToDirectory(toolStrings[i], tools[i]);
|
||||
}
|
||||
|
||||
TinkerTools.potionLauncher = new PotionLauncher().setUnlocalizedName("tconstruct.PotionLauncher");
|
||||
GameRegistry.registerItem(TinkerTools.potionLauncher, "potionLauncher");
|
||||
|
||||
TinkerTools.pickaxeHead = new ToolPart("_pickaxe_head", "PickHead").setUnlocalizedName("tconstruct.PickaxeHead");
|
||||
TinkerTools.shovelHead = new ToolPart("_shovel_head", "ShovelHead").setUnlocalizedName("tconstruct.ShovelHead");
|
||||
TinkerTools.hatchetHead = new ToolPart("_axe_head", "AxeHead").setUnlocalizedName("tconstruct.AxeHead");
|
||||
TinkerTools.binding = new ToolPart("_binding", "Binding").setUnlocalizedName("tconstruct.Binding");
|
||||
TinkerTools.toughBinding = new ToolPart("_toughbind", "ToughBind").setUnlocalizedName("tconstruct.ThickBinding");
|
||||
TinkerTools.toughRod = new ToolPart("_toughrod", "ToughRod").setUnlocalizedName("tconstruct.ThickRod");
|
||||
TinkerTools.largePlate = new ToolPart("_largeplate", "LargePlate").setUnlocalizedName("tconstruct.LargePlate");
|
||||
|
||||
TinkerTools.swordBlade = new ToolPart("_sword_blade", "SwordBlade").setUnlocalizedName("tconstruct.SwordBlade");
|
||||
TinkerTools.wideGuard = new ToolPart("_large_guard", "LargeGuard").setUnlocalizedName("tconstruct.LargeGuard");
|
||||
TinkerTools.handGuard = new ToolPart("_medium_guard", "MediumGuard").setUnlocalizedName("tconstruct.MediumGuard");
|
||||
TinkerTools.crossbar = new ToolPart("_crossbar", "Crossbar").setUnlocalizedName("tconstruct.Crossbar");
|
||||
TinkerTools.knifeBlade = new ToolPart("_knife_blade", "KnifeBlade").setUnlocalizedName("tconstruct.KnifeBlade");
|
||||
TinkerTools.fullGuard = new ToolPartHidden("_full_guard", "FullGuard").setUnlocalizedName("tconstruct.FullGuard");
|
||||
|
||||
TinkerTools.frypanHead = new ToolPart("_frypan_head", "FrypanHead").setUnlocalizedName("tconstruct.FrypanHead");
|
||||
TinkerTools.signHead = new ToolPart("_battlesign_head", "SignHead").setUnlocalizedName("tconstruct.SignHead");
|
||||
TinkerTools.chiselHead = new ToolPart("_chisel_head", "ChiselHead").setUnlocalizedName("tconstruct.ChiselHead");
|
||||
|
||||
TinkerTools.scytheBlade = new ToolPart("_scythe_head", "ScytheHead").setUnlocalizedName("tconstruct.ScytheBlade");
|
||||
TinkerTools.broadAxeHead = new ToolPart("_lumberaxe_head", "LumberHead").setUnlocalizedName("tconstruct.LumberHead");
|
||||
TinkerTools.excavatorHead = new ToolPart("_excavator_head", "ExcavatorHead").setUnlocalizedName("tconstruct.ExcavatorHead");
|
||||
TinkerTools.largeSwordBlade = new ToolPart("_large_sword_blade", "LargeSwordBlade").setUnlocalizedName("tconstruct.LargeSwordBlade");
|
||||
TinkerTools.hammerHead = new ToolPart("_hammer_head", "HammerHead").setUnlocalizedName("tconstruct.HammerHead");
|
||||
|
||||
TinkerTools.bowstring = new Bowstring().setUnlocalizedName("tconstruct.Bowstring");
|
||||
TinkerTools.arrowhead = new ToolPart("_arrowhead", "ArrowHead").setUnlocalizedName("tconstruct.Arrowhead");
|
||||
TinkerTools.fletching = new Fletching().setUnlocalizedName("tconstruct.Fletching");
|
||||
|
||||
Item[] toolParts = { TinkerTools.toolRod, TinkerTools.toolShard, TinkerTools.pickaxeHead, TinkerTools.shovelHead, TinkerTools.hatchetHead, TinkerTools.binding, TinkerTools.toughBinding, TinkerTools.toughRod, TinkerTools.largePlate,
|
||||
TinkerTools.swordBlade, TinkerTools.wideGuard, TinkerTools.handGuard, TinkerTools.crossbar, TinkerTools.knifeBlade, TinkerTools.fullGuard, TinkerTools.frypanHead, TinkerTools.signHead, TinkerTools.chiselHead, TinkerTools.scytheBlade,
|
||||
TinkerTools.broadAxeHead, TinkerTools.excavatorHead, TinkerTools.largeSwordBlade, TinkerTools.hammerHead, TinkerTools.bowstring, TinkerTools.fletching, TinkerTools.arrowhead };
|
||||
String[] toolPartStrings = { "toolRod", "toolShard", "pickaxeHead", "shovelHead", "hatchetHead", "binding", "toughBinding", "toughRod", "heavyPlate", "swordBlade", "wideGuard", "handGuard",
|
||||
"crossbar", "knifeBlade", "fullGuard", "frypanHead", "signHead", "chiselHead", "scytheBlade", "broadAxeHead", "excavatorHead", "largeSwordBlade", "hammerHead", "bowstring",
|
||||
"fletching", "arrowhead" };
|
||||
|
||||
for (int i = 0; i < toolParts.length; i++)
|
||||
{
|
||||
GameRegistry.registerItem(toolParts[i], toolPartStrings[i]); // 1.7
|
||||
// compat
|
||||
TConstructRegistry.addItemToDirectory(toolPartStrings[i], toolParts[i]);
|
||||
}
|
||||
GameRegistry.registerItem(TinkerTools.goldHead, "goldHead");
|
||||
|
||||
TinkerTools.creativeModifier = new CreativeModifier().setUnlocalizedName("tconstruct.modifier.creative");
|
||||
GameRegistry.registerItem(TinkerTools.creativeModifier, "creativeModifier");
|
||||
|
||||
String[] materialStrings = { "paperStack", "greenSlimeCrystal", "searedBrick", "ingotCobalt", "ingotArdite", "ingotManyullyn", "mossBall", "lavaCrystal", "necroticBone", "ingotCopper",
|
||||
"ingotTin", "ingotAluminum", "rawAluminum", "ingotBronze", "ingotAluminumBrass", "ingotAlumite", "ingotSteel", "blueSlimeCrystal", "ingotObsidian", "nuggetIron", "nuggetCopper",
|
||||
"nuggetTin", "nuggetAluminum", "nuggetSilver", "nuggetAluminumBrass", "silkyCloth", "silkyJewel", "nuggetObsidian", "nuggetCobalt", "nuggetArdite", "nuggetManyullyn", "nuggetBronze",
|
||||
"nuggetAlumite", "nuggetSteel", "ingotPigIron", "nuggetPigIron", "glueball" };
|
||||
|
||||
for (int i = 0; i < materialStrings.length; i++)
|
||||
{
|
||||
TConstructRegistry.addItemStackToDirectory(materialStrings[i], new ItemStack(TinkerTools.materials, 1, i));
|
||||
}
|
||||
|
||||
registerMaterials();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void setupToolTabs ()
|
||||
{
|
||||
TConstructRegistry.materialTab.init(new ItemStack(TinkerTools.manualBook, 1, 0));
|
||||
TConstructRegistry.partTab.init(new ItemStack(TinkerTools.titleIcon, 1, 255));
|
||||
TConstructRegistry.blockTab.init(new ItemStack(TinkerTools.toolStationWood));
|
||||
ItemStack tool = new ItemStack(TinkerTools.longsword, 1, 0);
|
||||
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setTag("InfiTool", new NBTTagCompound());
|
||||
compound.getCompoundTag("InfiTool").setInteger("RenderHead", 2);
|
||||
compound.getCompoundTag("InfiTool").setInteger("RenderHandle", 0);
|
||||
compound.getCompoundTag("InfiTool").setInteger("RenderAccessory", 10);
|
||||
tool.setTagCompound(compound);
|
||||
|
||||
// TConstruct.
|
||||
TConstructRegistry.toolTab.init(tool);
|
||||
}
|
||||
|
||||
//@Override
|
||||
public int getBurnTime (ItemStack fuel)
|
||||
{
|
||||
if (fuel.getItem() == TinkerTools.materials && fuel.getItemDamage() == 7)
|
||||
return 26400;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void init (FMLInitializationEvent event)
|
||||
{
|
||||
addPartMapping();
|
||||
addRecipesForToolBuilder();
|
||||
addRecipesForChisel();
|
||||
craftingTableRecipes();
|
||||
setupToolTabs();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void postInit (FMLPostInitializationEvent evt)
|
||||
{
|
||||
vanillaToolRecipes();
|
||||
}
|
||||
|
||||
private void addPartMapping ()
|
||||
{
|
||||
/* Tools */
|
||||
TinkerTools.patternOutputs = new Item[] { TinkerTools.toolRod, TinkerTools.pickaxeHead, TinkerTools.shovelHead, TinkerTools.hatchetHead, TinkerTools.swordBlade, TinkerTools.wideGuard,
|
||||
TinkerTools.handGuard, TinkerTools.crossbar, TinkerTools.binding, TinkerTools.frypanHead, TinkerTools.signHead, TinkerTools.knifeBlade, TinkerTools.chiselHead, TinkerTools.toughRod,
|
||||
TinkerTools.toughBinding, TinkerTools.largePlate, TinkerTools.broadAxeHead, TinkerTools.scytheBlade, TinkerTools.excavatorHead, TinkerTools.largeSwordBlade, TinkerTools.hammerHead,
|
||||
TinkerTools.fullGuard, null, null, TinkerTools.arrowhead, null };
|
||||
|
||||
int[] nonMetals = { 0, 1, 3, 4, 5, 6, 7, 8, 9, 17 };
|
||||
|
||||
if (PHConstruct.craftMetalTools)
|
||||
{
|
||||
for (int mat = 0; mat < 18; mat++)
|
||||
{
|
||||
for (int meta = 0; meta < TinkerTools.patternOutputs.length; meta++)
|
||||
{
|
||||
if (TinkerTools.patternOutputs[meta] != null)
|
||||
TConstructRegistry.addPartMapping(TinkerTools.woodPattern, meta + 1, mat, new ItemStack(TinkerTools.patternOutputs[meta], 1, mat));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int mat = 0; mat < nonMetals.length; mat++)
|
||||
{
|
||||
for (int meta = 0; meta < TinkerTools.patternOutputs.length; meta++)
|
||||
{
|
||||
if (TinkerTools.patternOutputs[meta] != null)
|
||||
TConstructRegistry.addPartMapping(TinkerTools.woodPattern, meta + 1, nonMetals[mat], new ItemStack(TinkerTools.patternOutputs[meta], 1, nonMetals[mat]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
registerPatternMaterial("plankWood", 2, "Wood");
|
||||
registerPatternMaterial("stickWood", 1, "Wood");
|
||||
registerPatternMaterial("slabWood", 1, "Wood");
|
||||
registerPatternMaterial("compressedCobblestone1x", 18, "Stone");
|
||||
}
|
||||
|
||||
private void addRecipesForToolBuilder ()
|
||||
{
|
||||
ToolBuilder tb = ToolBuilder.instance;
|
||||
tb.addNormalToolRecipe(TinkerTools.pickaxe, TinkerTools.pickaxeHead, TinkerTools.toolRod, TinkerTools.binding);
|
||||
tb.addNormalToolRecipe(TinkerTools.broadsword, TinkerTools.swordBlade, TinkerTools.toolRod, TinkerTools.wideGuard);
|
||||
tb.addNormalToolRecipe(TinkerTools.hatchet, TinkerTools.hatchetHead, TinkerTools.toolRod);
|
||||
tb.addNormalToolRecipe(TinkerTools.shovel, TinkerTools.shovelHead, TinkerTools.toolRod);
|
||||
tb.addNormalToolRecipe(TinkerTools.longsword, TinkerTools.swordBlade, TinkerTools.toolRod, TinkerTools.handGuard);
|
||||
tb.addNormalToolRecipe(TinkerTools.rapier, TinkerTools.swordBlade, TinkerTools.toolRod, TinkerTools.crossbar);
|
||||
tb.addNormalToolRecipe(TinkerTools.frypan, TinkerTools.frypanHead, TinkerTools.toolRod);
|
||||
tb.addNormalToolRecipe(TinkerTools.battlesign, TinkerTools.signHead, TinkerTools.toolRod);
|
||||
tb.addNormalToolRecipe(TinkerTools.mattock, TinkerTools.hatchetHead, TinkerTools.toolRod, TinkerTools.shovelHead);
|
||||
tb.addNormalToolRecipe(TinkerTools.dagger, TinkerTools.knifeBlade, TinkerTools.toolRod, TinkerTools.crossbar);
|
||||
tb.addNormalToolRecipe(TinkerTools.cutlass, TinkerTools.swordBlade, TinkerTools.toolRod, TinkerTools.fullGuard);
|
||||
tb.addNormalToolRecipe(TinkerTools.chisel, TinkerTools.chiselHead, TinkerTools.toolRod);
|
||||
|
||||
tb.addNormalToolRecipe(TinkerTools.scythe, TinkerTools.scytheBlade, TinkerTools.toughRod, TinkerTools.toughBinding, TinkerTools.toughRod);
|
||||
tb.addNormalToolRecipe(TinkerTools.lumberaxe, TinkerTools.broadAxeHead, TinkerTools.toughRod, TinkerTools.largePlate, TinkerTools.toughBinding);
|
||||
tb.addNormalToolRecipe(TinkerTools.cleaver, TinkerTools.largeSwordBlade, TinkerTools.toughRod, TinkerTools.largePlate, TinkerTools.toughRod);
|
||||
tb.addNormalToolRecipe(TinkerTools.excavator, TinkerTools.excavatorHead, TinkerTools.toughRod, TinkerTools.largePlate, TinkerTools.toughBinding);
|
||||
tb.addNormalToolRecipe(TinkerTools.hammer, TinkerTools.hammerHead, TinkerTools.toughRod, TinkerTools.largePlate, TinkerTools.largePlate);
|
||||
tb.addNormalToolRecipe(TinkerTools.battleaxe, TinkerTools.broadAxeHead, TinkerTools.toughRod, TinkerTools.broadAxeHead, TinkerTools.toughBinding);
|
||||
|
||||
BowRecipe recipe = new BowRecipe(TinkerTools.toolRod, TinkerTools.bowstring, TinkerTools.toolRod, TinkerTools.shortbow);
|
||||
tb.addCustomToolRecipe(recipe);
|
||||
tb.addNormalToolRecipe(TinkerTools.arrow, TinkerTools.arrowhead, TinkerTools.toolRod, TinkerTools.fletching);
|
||||
|
||||
ItemStack diamond = new ItemStack(Items.diamond);
|
||||
tb.registerToolMod(new ModRepair());
|
||||
tb.registerToolMod(new ModDurability(new ItemStack[] { diamond }, 0, 500, 0f, 3, StatCollector.translateToLocal("gui.modifier.diamond"), "\u00a7b"
|
||||
+ StatCollector.translateToLocal("modifier.tool.diamond"), "\u00a7b"));
|
||||
tb.registerToolMod(new ModDurability(new ItemStack[] { new ItemStack(Items.emerald) }, 1, 0, 0.5f, 2, StatCollector.translateToLocal("gui.modifier.emerald"), "\u00a72"
|
||||
+ StatCollector.translateToLocal("modifier.tool.emerald"), "\u00a72"));
|
||||
|
||||
TinkerTools.modFlux = new ModFlux();
|
||||
tb.registerToolMod(TinkerTools.modFlux);
|
||||
|
||||
ItemStack redstoneItem = new ItemStack(Items.redstone);
|
||||
ItemStack redstoneBlock = new ItemStack(Blocks.redstone_block);
|
||||
tb.registerToolMod(new ModRedstone(2, new ItemStack[] { redstoneItem, redstoneBlock }, new int[] { 1, 9 }));
|
||||
|
||||
ItemStack lapisItem = new ItemStack(Items.dye, 1, 4);
|
||||
ItemStack lapisBlock = new ItemStack(Blocks.lapis_block);
|
||||
TinkerTools.modLapis = new ModLapis(10, new ItemStack[] { lapisItem, lapisBlock }, new int[] { 1, 9 });
|
||||
tb.registerToolMod(TinkerTools.modLapis);
|
||||
|
||||
tb.registerToolMod(new ModInteger(new ItemStack[] { new ItemStack(TinkerTools.materials, 1, 6) }, 4, StatCollector.translateToLocal("gui.modifier.moss"), 3, "\u00a72", StatCollector
|
||||
.translateToLocal("modifier.tool.moss")));
|
||||
ItemStack blazePowder = new ItemStack(Items.blaze_powder);
|
||||
tb.registerToolMod(new ModBlaze(7, new ItemStack[] { blazePowder }, new int[] { 1 }));
|
||||
tb.registerToolMod(new ModAutoSmelt(new ItemStack[] { new ItemStack(TinkerTools.materials, 1, 7) }, 6, StatCollector.translateToLocal("gui.modifier.lava"), "\u00a74", StatCollector
|
||||
.translateToLocal("modifier.tool.lava")));
|
||||
tb.registerToolMod(new ModInteger(new ItemStack[] { new ItemStack(TinkerTools.materials, 1, 8) }, 8, StatCollector.translateToLocal("gui.modifier.necro"), 1, "\u00a78", StatCollector
|
||||
.translateToLocal("modifier.tool.necro")));
|
||||
|
||||
TinkerTools.modAttack = new ModAttack(StatCollector.translateToLocal("gui.modifier.quartz"), 11, new ItemStack[] { new ItemStack(Items.quartz),
|
||||
new ItemStack(Blocks.quartz_block, 1, Short.MAX_VALUE) }, new int[] { 1, 4 });
|
||||
tb.registerToolMod(TinkerTools.modAttack);
|
||||
|
||||
tb.registerToolMod(new ModExtraModifier(new ItemStack[] { diamond, new ItemStack(Blocks.gold_block) }, "Tier1Free"));
|
||||
tb.registerToolMod(new ModExtraModifier(new ItemStack[] { new ItemStack(Blocks.diamond_block), new ItemStack(Items.golden_apple, 1, 1) }, "Tier1.5Free"));
|
||||
tb.registerToolMod(new ModExtraModifier(new ItemStack[] { new ItemStack(Items.nether_star) }, "Tier2Free"));
|
||||
tb.registerToolMod(new ModCreativeToolModifier(new ItemStack[] { new ItemStack(TinkerTools.creativeModifier) }));
|
||||
|
||||
ItemStack silkyJewel = new ItemStack(TinkerTools.materials, 1, 26);
|
||||
tb.registerToolMod(new ModButtertouch(new ItemStack[] { silkyJewel }, 12));
|
||||
|
||||
ItemStack piston = new ItemStack(Blocks.piston);
|
||||
tb.registerToolMod(new ModPiston(3, new ItemStack[] { piston }, new int[] { 1 }));
|
||||
|
||||
tb.registerToolMod(new ModInteger(new ItemStack[] { new ItemStack(Blocks.obsidian), new ItemStack(Items.ender_pearl) }, 13, StatCollector.translateToLocal("modifier.tool.beheading"), 1,
|
||||
"\u00a7d", StatCollector.translateToLocal("modifier.tool.beheading")));
|
||||
|
||||
ItemStack holySoil = new ItemStack(TinkerTools.craftedSoil, 1, 4);
|
||||
tb.registerToolMod(new ModSmite(StatCollector.translateToLocal("modifier.tool.smite"), 14, new ItemStack[] { holySoil }, new int[] { 1 }));
|
||||
|
||||
ItemStack spidereyeball = new ItemStack(Items.fermented_spider_eye);
|
||||
tb.registerToolMod(new ModAntiSpider(StatCollector.translateToLocal("gui.modifier.spider"), 15, new ItemStack[] { spidereyeball }, new int[] { 1 }));
|
||||
|
||||
ItemStack obsidianPlate = new ItemStack(TinkerTools.largePlate, 1, 6);
|
||||
tb.registerToolMod(new ModReinforced(new ItemStack[] { obsidianPlate }, 16, 1));
|
||||
|
||||
EnumSet<EnumArmorPart> allArmors = EnumSet.of(EnumArmorPart.HELMET, EnumArmorPart.CHEST, EnumArmorPart.PANTS, EnumArmorPart.SHOES);
|
||||
EnumSet<EnumArmorPart> chest = EnumSet.of(EnumArmorPart.CHEST);
|
||||
tb.registerArmorMod(new AModMoveSpeed(0, allArmors, new ItemStack[] { redstoneItem, redstoneBlock }, new int[] { 1, 9 }, false));
|
||||
tb.registerArmorMod(new AModKnockbackResistance(1, allArmors, new ItemStack[] { new ItemStack(Items.gold_ingot), new ItemStack(Blocks.gold_block) }, new int[] { 1, 9 }, false));
|
||||
tb.registerArmorMod(new AModHealthBoost(2, allArmors, new ItemStack[] { new ItemStack(TinkerArmor.heartCanister, 1, 2) }, new int[] { 2 }, true));
|
||||
tb.registerArmorMod(new AModDamageBoost(3, allArmors, new ItemStack[] { new ItemStack(Items.diamond), new ItemStack(Blocks.diamond_block) }, new int[] { 1, 9 }, false, 3, 0.05));
|
||||
tb.registerArmorMod(new AModDamageBoost(4, chest, new ItemStack[] { new ItemStack(Blocks.quartz_block, 1, Short.MAX_VALUE) }, new int[] { 1 }, true, 5, 1));
|
||||
tb.registerArmorMod(new AModProtection(5, allArmors, new ItemStack[] { new ItemStack(TinkerTools.largePlate, 1, 2) }, new int[] { 2 }));
|
||||
|
||||
tb.registerArmorMod(new AModDoubleJump(new ItemStack[] { new ItemStack(Items.ghast_tear), new ItemStack(TinkerWorld.slimeGel, 1, 0), new ItemStack(TinkerWorld.slimeGel, 1, 1) }));
|
||||
|
||||
TConstructRegistry.registerActiveToolMod(new TActiveOmniMod());
|
||||
}
|
||||
|
||||
private void addRecipesForChisel ()
|
||||
{
|
||||
/* Detailing */
|
||||
Detailing chiseling = TConstructRegistry.getChiselDetailing();
|
||||
chiseling.addDetailing(Blocks.stone, 0, Blocks.stonebrick, 0, TinkerTools.chisel);
|
||||
chiseling.addDetailing(TinkerSmeltery.speedBlock, 0, TinkerSmeltery.speedBlock, 1, TinkerTools.chisel);
|
||||
chiseling.addDetailing(TinkerSmeltery.speedBlock, 2, TinkerSmeltery.speedBlock, 3, TinkerTools.chisel);
|
||||
chiseling.addDetailing(TinkerSmeltery.speedBlock, 3, TinkerSmeltery.speedBlock, 4, TinkerTools.chisel);
|
||||
chiseling.addDetailing(TinkerSmeltery.speedBlock, 4, TinkerSmeltery.speedBlock, 5, TinkerTools.chisel);
|
||||
chiseling.addDetailing(TinkerSmeltery.speedBlock, 5, TinkerSmeltery.speedBlock, 6, TinkerTools.chisel);
|
||||
|
||||
chiseling.addDetailing(Blocks.obsidian, 0, TinkerTools.multiBrick, 0, TinkerTools.chisel);
|
||||
chiseling.addDetailing(Blocks.sandstone, 0, Blocks.sandstone, 2, TinkerTools.chisel);
|
||||
chiseling.addDetailing(Blocks.sandstone, 2, Blocks.sandstone, 1, TinkerTools.chisel);
|
||||
chiseling.addDetailing(Blocks.sandstone, 1, TinkerTools.multiBrick, 1, TinkerTools.chisel);
|
||||
// chiseling.addDetailing(Block.netherrack, 0, TRepo.multiBrick, 2,
|
||||
// TRepo.chisel);
|
||||
// chiseling.addDetailing(Block.stone_refined, 0, TRepo.multiBrick, 3,
|
||||
// TRepo.chisel);
|
||||
chiseling.addDetailing(Items.iron_ingot, 0, TinkerTools.multiBrick, 4, TinkerTools.chisel);
|
||||
chiseling.addDetailing(Items.gold_ingot, 0, TinkerTools.multiBrick, 5, TinkerTools.chisel);
|
||||
chiseling.addDetailing(Items.dye, 4, TinkerTools.multiBrick, 6, TinkerTools.chisel);
|
||||
chiseling.addDetailing(Items.diamond, 0, TinkerTools.multiBrick, 7, TinkerTools.chisel);
|
||||
chiseling.addDetailing(Items.redstone, 0, TinkerTools.multiBrick, 8, TinkerTools.chisel);
|
||||
chiseling.addDetailing(Items.bone, 0, TinkerTools.multiBrick, 9, TinkerTools.chisel);
|
||||
chiseling.addDetailing(Items.slime_ball, 0, TinkerTools.multiBrick, 10, TinkerTools.chisel);
|
||||
chiseling.addDetailing(TinkerWorld.strangeFood, 0, TinkerTools.multiBrick, 11, TinkerTools.chisel);
|
||||
chiseling.addDetailing(Blocks.end_stone, 0, TinkerTools.multiBrick, 12, TinkerTools.chisel);
|
||||
chiseling.addDetailing(TinkerTools.materials, 18, TinkerTools.multiBrick, 13, TinkerTools.chisel);
|
||||
|
||||
// adding multiBrick / multiBrickFanxy meta 0-13 to list
|
||||
for (int sc = 0; sc < 14; sc++)
|
||||
{
|
||||
chiseling.addDetailing(TinkerTools.multiBrick, sc, TinkerTools.multiBrickFancy, sc, TinkerTools.chisel);
|
||||
}
|
||||
|
||||
chiseling.addDetailing(Blocks.stonebrick, 0, TinkerTools.multiBrickFancy, 15, TinkerTools.chisel);
|
||||
chiseling.addDetailing(TinkerTools.multiBrickFancy, 15, TinkerTools.multiBrickFancy, 14, TinkerTools.chisel);
|
||||
chiseling.addDetailing(TinkerTools.multiBrickFancy, 14, Blocks.stonebrick, 3, TinkerTools.chisel);
|
||||
/*
|
||||
* chiseling.addDetailing(TRepo.multiBrick, 14, TRepo.multiBrickFancy,
|
||||
* 14, TRepo.chisel); chiseling.addDetailing(TRepo.multiBrick, 15,
|
||||
* TRepo.multiBrickFancy, 15, TRepo.chisel);
|
||||
*/
|
||||
|
||||
chiseling.addDetailing(TinkerSmeltery.smeltery, 4, TinkerSmeltery.smeltery, 6, TinkerTools.chisel);
|
||||
chiseling.addDetailing(TinkerSmeltery.smeltery, 6, TinkerSmeltery.smeltery, 11, TinkerTools.chisel);
|
||||
chiseling.addDetailing(TinkerSmeltery.smeltery, 11, TinkerSmeltery.smeltery, 2, TinkerTools.chisel);
|
||||
chiseling.addDetailing(TinkerSmeltery.smeltery, 2, TinkerSmeltery.smeltery, 8, TinkerTools.chisel);
|
||||
chiseling.addDetailing(TinkerSmeltery.smeltery, 8, TinkerSmeltery.smeltery, 9, TinkerTools.chisel);
|
||||
chiseling.addDetailing(TinkerSmeltery.smeltery, 9, TinkerSmeltery.smeltery, 10, TinkerTools.chisel);
|
||||
}
|
||||
|
||||
public void vanillaToolRecipes ()
|
||||
{
|
||||
if (PHConstruct.removeVanillaToolRecipes)
|
||||
{
|
||||
RecipeRemover.removeAnyRecipe(new ItemStack(Items.wooden_pickaxe));
|
||||
RecipeRemover.removeAnyRecipe(new ItemStack(Items.wooden_axe));
|
||||
RecipeRemover.removeAnyRecipe(new ItemStack(Items.wooden_shovel));
|
||||
RecipeRemover.removeAnyRecipe(new ItemStack(Items.wooden_hoe));
|
||||
RecipeRemover.removeAnyRecipe(new ItemStack(Items.wooden_sword));
|
||||
|
||||
RecipeRemover.removeAnyRecipe(new ItemStack(Items.stone_pickaxe));
|
||||
RecipeRemover.removeAnyRecipe(new ItemStack(Items.stone_axe));
|
||||
RecipeRemover.removeAnyRecipe(new ItemStack(Items.stone_shovel));
|
||||
RecipeRemover.removeAnyRecipe(new ItemStack(Items.stone_hoe));
|
||||
RecipeRemover.removeAnyRecipe(new ItemStack(Items.stone_sword));
|
||||
|
||||
RecipeRemover.removeAnyRecipe(new ItemStack(Items.iron_pickaxe));
|
||||
RecipeRemover.removeAnyRecipe(new ItemStack(Items.iron_axe));
|
||||
RecipeRemover.removeAnyRecipe(new ItemStack(Items.iron_shovel));
|
||||
RecipeRemover.removeAnyRecipe(new ItemStack(Items.iron_hoe));
|
||||
RecipeRemover.removeAnyRecipe(new ItemStack(Items.iron_sword));
|
||||
|
||||
RecipeRemover.removeAnyRecipe(new ItemStack(Items.diamond_pickaxe));
|
||||
RecipeRemover.removeAnyRecipe(new ItemStack(Items.diamond_axe));
|
||||
RecipeRemover.removeAnyRecipe(new ItemStack(Items.diamond_shovel));
|
||||
RecipeRemover.removeAnyRecipe(new ItemStack(Items.diamond_hoe));
|
||||
RecipeRemover.removeAnyRecipe(new ItemStack(Items.diamond_sword));
|
||||
|
||||
RecipeRemover.removeAnyRecipe(new ItemStack(Items.golden_pickaxe));
|
||||
RecipeRemover.removeAnyRecipe(new ItemStack(Items.golden_axe));
|
||||
RecipeRemover.removeAnyRecipe(new ItemStack(Items.golden_shovel));
|
||||
RecipeRemover.removeAnyRecipe(new ItemStack(Items.golden_hoe));
|
||||
RecipeRemover.removeAnyRecipe(new ItemStack(Items.golden_sword));
|
||||
}
|
||||
|
||||
if (PHConstruct.labotimizeVanillaTools)
|
||||
{
|
||||
Items.wooden_pickaxe.setMaxDamage(1);
|
||||
Items.wooden_axe.setMaxDamage(1);
|
||||
Items.wooden_shovel.setMaxDamage(1);
|
||||
Items.wooden_hoe.setMaxDamage(1);
|
||||
Items.wooden_sword.setMaxDamage(1);
|
||||
|
||||
Items.stone_pickaxe.setMaxDamage(1);
|
||||
Items.stone_axe.setMaxDamage(1);
|
||||
Items.stone_shovel.setMaxDamage(1);
|
||||
Items.stone_hoe.setMaxDamage(1);
|
||||
Items.stone_sword.setMaxDamage(1);
|
||||
|
||||
Items.iron_pickaxe.setMaxDamage(1);
|
||||
Items.iron_axe.setMaxDamage(1);
|
||||
Items.iron_shovel.setMaxDamage(1);
|
||||
Items.iron_hoe.setMaxDamage(1);
|
||||
Items.iron_sword.setMaxDamage(1);
|
||||
|
||||
Items.diamond_pickaxe.setMaxDamage(1);
|
||||
Items.diamond_axe.setMaxDamage(1);
|
||||
Items.diamond_shovel.setMaxDamage(1);
|
||||
Items.diamond_hoe.setMaxDamage(1);
|
||||
Items.diamond_sword.setMaxDamage(1);
|
||||
|
||||
Items.golden_pickaxe.setMaxDamage(1);
|
||||
Items.golden_axe.setMaxDamage(1);
|
||||
Items.golden_shovel.setMaxDamage(1);
|
||||
Items.golden_hoe.setMaxDamage(1);
|
||||
Items.golden_sword.setMaxDamage(1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerPatternMaterial (String oreName, int value, String materialName)
|
||||
{
|
||||
for (ItemStack ore : OreDictionary.getOres(oreName))
|
||||
{
|
||||
PatternBuilder.instance.registerMaterial(ore, value, materialName);
|
||||
}
|
||||
}
|
||||
|
||||
private void craftingTableRecipes()
|
||||
{
|
||||
String[] patBlock = { "###", "###", "###" };
|
||||
String[] patSurround = { "###", "#m#", "###" };
|
||||
|
||||
Object[] toolForgeBlocks = { "blockIron", "blockGold", Blocks.diamond_block, Blocks.emerald_block, "blockCobalt", "blockArdite", "blockManyullyn", "blockCopper", "blockBronze", "blockTin",
|
||||
"blockAluminum", "blockAluminumBrass", "blockAlumite", "blockSteel" };
|
||||
|
||||
// ToolForge Recipes (Metal Version)
|
||||
for (int sc = 0; sc < toolForgeBlocks.length; sc++)
|
||||
{
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(TinkerTools.toolForge, 1, sc), "bbb", "msm", "m m", 'b', new ItemStack(TinkerSmeltery.smeltery, 1, 2), 's', new ItemStack(
|
||||
TinkerTools.toolStationWood, 1, 0), 'm', toolForgeBlocks[sc]));
|
||||
// adding slab version recipe
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(TinkerTools.craftingSlabWood, 1, 5), "bbb", "msm", "m m", 'b', new ItemStack(TinkerSmeltery.smeltery, 1, 2), 's', new ItemStack(
|
||||
TinkerTools.craftingSlabWood, 1, 1), 'm', toolForgeBlocks[sc]));
|
||||
}
|
||||
|
||||
// ToolStation Recipes (Wooden Version)
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(TinkerTools.toolStationWood, 1, 0), "p", "w", 'p', new ItemStack(TinkerTools.blankPattern, 1, 0), 'w', "crafterWood"));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(TinkerTools.toolStationWood, 1, 0), "p", "w", 'p', new ItemStack(TinkerTools.blankPattern, 1, 0), 'w', "craftingTableWood"));
|
||||
GameRegistry.addRecipe(new ItemStack(TinkerTools.toolStationWood, 1, 0), "p", "w", 'p', new ItemStack(TinkerTools.blankPattern, 1, 0), 'w',
|
||||
new ItemStack(TinkerTools.craftingStationWood, 1, 0));
|
||||
GameRegistry.addRecipe(new ItemStack(TinkerTools.toolStationWood, 1, 0), "p", "w", 'p', new ItemStack(TinkerTools.blankPattern, 1, 0), 'w', new ItemStack(TinkerTools.craftingSlabWood, 1, 0));
|
||||
GameRegistry.addRecipe(new ItemStack(TinkerTools.toolStationWood, 1, 2), "p", "w", 'p', new ItemStack(TinkerTools.blankPattern, 1, 0), 'w', new ItemStack(Blocks.log, 1, 1));
|
||||
GameRegistry.addRecipe(new ItemStack(TinkerTools.toolStationWood, 1, 3), "p", "w", 'p', new ItemStack(TinkerTools.blankPattern, 1, 0), 'w', new ItemStack(Blocks.log, 1, 2));
|
||||
GameRegistry.addRecipe(new ItemStack(TinkerTools.toolStationWood, 1, 4), "p", "w", 'p', new ItemStack(TinkerTools.blankPattern, 1, 0), 'w', new ItemStack(Blocks.log, 1, 3));
|
||||
GameRegistry.addRecipe(new ItemStack(TinkerTools.toolStationWood, 1, 5), "p", "w", 'p', new ItemStack(TinkerTools.blankPattern, 1, 0), 'w', Blocks.chest);
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(TinkerTools.toolStationWood, 1, 1), "p", "w", 'p', new ItemStack(TinkerTools.blankPattern, 1, 0), 'w', "logWood"));
|
||||
GameRegistry.addRecipe(new ItemStack(TinkerTools.toolStationWood, 1, 10), "p", "w", 'p', new ItemStack(TinkerTools.blankPattern, 1, 0), 'w', new ItemStack(Blocks.planks, 1, 0));
|
||||
GameRegistry.addRecipe(new ItemStack(TinkerTools.toolStationWood, 1, 11), "p", "w", 'p', new ItemStack(TinkerTools.blankPattern, 1, 0), 'w', new ItemStack(Blocks.planks, 1, 1));
|
||||
GameRegistry.addRecipe(new ItemStack(TinkerTools.toolStationWood, 1, 12), "p", "w", 'p', new ItemStack(TinkerTools.blankPattern, 1, 0), 'w', new ItemStack(Blocks.planks, 1, 2));
|
||||
GameRegistry.addRecipe(new ItemStack(TinkerTools.toolStationWood, 1, 13), "p", "w", 'p', new ItemStack(TinkerTools.blankPattern, 1, 0), 'w', new ItemStack(Blocks.planks, 1, 3));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(TinkerTools.toolStationWood, 1, 10), "p", "w", 'p', new ItemStack(TinkerTools.blankPattern, 1, 0), 'w', "plankWood"));
|
||||
GameRegistry.addRecipe(new ItemStack(TinkerTools.furnaceSlab, 1, 0), "###", "# #", "###", '#', new ItemStack(Blocks.stone_slab, 1, 3));
|
||||
|
||||
// Blank Pattern Recipe
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(TinkerTools.blankPattern, 1, 0), "ps", "sp", 'p', "plankWood", 's', "stickWood"));
|
||||
// Manual Book Recipes
|
||||
GameRegistry.addRecipe(new ItemStack(TinkerTools.manualBook), "wp", 'w', new ItemStack(TinkerTools.blankPattern, 1, 0), 'p', Items.paper);
|
||||
GameRegistry.addShapelessRecipe(new ItemStack(TinkerTools.manualBook, 2, 0), new ItemStack(TinkerTools.manualBook, 1, 0), Items.book);
|
||||
GameRegistry.addShapelessRecipe(new ItemStack(TinkerTools.manualBook, 1, 1), new ItemStack(TinkerTools.manualBook, 1, 0));
|
||||
GameRegistry.addShapelessRecipe(new ItemStack(TinkerTools.manualBook, 2, 1), new ItemStack(TinkerTools.manualBook, 1, 1), Items.book);
|
||||
GameRegistry.addShapelessRecipe(new ItemStack(TinkerTools.manualBook, 1, 2), new ItemStack(TinkerTools.manualBook, 1, 1));
|
||||
GameRegistry.addShapelessRecipe(new ItemStack(TinkerTools.manualBook, 2, 2), new ItemStack(TinkerTools.manualBook, 1, 2), Items.book);
|
||||
GameRegistry.addShapelessRecipe(new ItemStack(TinkerTools.manualBook, 1, 3), new ItemStack(TinkerTools.manualBook, 1, 2));
|
||||
// alternative Vanilla Book Recipe
|
||||
GameRegistry.addShapelessRecipe(new ItemStack(Items.book), Items.paper, Items.paper, Items.paper, Items.string, TinkerTools.blankPattern, TinkerTools.blankPattern);
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(Items.name_tag), "P~ ", "~O ", " ~", '~', Items.string, 'P', Items.paper, 'O', "slimeball"));
|
||||
|
||||
// Paperstack Recipe
|
||||
GameRegistry.addRecipe(new ItemStack(TinkerTools.materials, 1, 0), "pp", "pp", 'p', Items.paper);
|
||||
// Mossball Recipe
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(TinkerTools.materials, 1, 6), patBlock, '#', "stoneMossy"));
|
||||
// LavaCrystal Recipes -Auto-smelt
|
||||
GameRegistry.addRecipe(new ItemStack(TinkerTools.materials, 1, 7), "xcx", "cbc", "xcx", 'b', Items.lava_bucket, 'c', Items.fire_charge, 'x', Items.blaze_rod);
|
||||
GameRegistry.addRecipe(new ItemStack(TinkerTools.materials, 1, 7), "xcx", "cbc", "xcx", 'b', Items.lava_bucket, 'x', Items.fire_charge, 'c', Items.blaze_rod);
|
||||
// Slimy sand Recipes
|
||||
GameRegistry.addShapelessRecipe(new ItemStack(TinkerTools.craftedSoil, 1, 0), Items.slime_ball, Items.slime_ball, Items.slime_ball, Items.slime_ball, Blocks.sand, Blocks.dirt);
|
||||
GameRegistry.addShapelessRecipe(new ItemStack(TinkerTools.craftedSoil, 1, 2), TinkerWorld.strangeFood, TinkerWorld.strangeFood, TinkerWorld.strangeFood, TinkerWorld.strangeFood, Blocks.sand,
|
||||
Blocks.dirt);
|
||||
// Grout Recipes
|
||||
GameRegistry.addShapelessRecipe(new ItemStack(TinkerTools.craftedSoil, 2, 1), Items.clay_ball, Blocks.sand, Blocks.gravel);
|
||||
GameRegistry.addShapelessRecipe(new ItemStack(TinkerTools.craftedSoil, 8, 1), new ItemStack(Blocks.clay, 1, Short.MAX_VALUE), Blocks.sand, Blocks.sand, Blocks.sand, Blocks.sand,
|
||||
Blocks.gravel, Blocks.gravel, Blocks.gravel, Blocks.gravel);
|
||||
GameRegistry.addShapelessRecipe(new ItemStack(TinkerTools.craftedSoil, 2, 6), Items.nether_wart, Blocks.soul_sand, Blocks.gravel);
|
||||
// Graveyard Soil Recipes
|
||||
GameRegistry.addShapelessRecipe(new ItemStack(TinkerTools.craftedSoil, 1, 3), Blocks.dirt, Items.rotten_flesh, new ItemStack(Items.dye, 1, 15));
|
||||
// Silky Cloth Recipes
|
||||
GameRegistry.addRecipe(new ItemStack(TinkerTools.materials, 1, 25), patSurround, 'm', new ItemStack(TinkerTools.materials, 1, 24), '#', new ItemStack(Items.string));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(TinkerTools.materials, 1, 25), patSurround, 'm', "nuggetGold", '#', new ItemStack(Items.string)));
|
||||
// Silky Jewel Recipes
|
||||
GameRegistry.addRecipe(new ItemStack(TinkerTools.materials, 1, 26), " c ", "cec", " c ", 'c', new ItemStack(TinkerTools.materials, 1, 25), 'e', new ItemStack(Items.emerald));
|
||||
|
||||
// Advanced WorkBench Recipes
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(TinkerTools.craftingStationWood, 1, 0), "b", 'b', "crafterWood"));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(TinkerTools.craftingStationWood, 1, 0), "b", 'b', "craftingTableWood"));
|
||||
// Slab crafters
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(TinkerTools.craftingSlabWood, 6, 0), "bbb", 'b', "crafterWood"));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(TinkerTools.craftingSlabWood, 6, 0), "bbb", 'b', "craftingTableWood"));
|
||||
GameRegistry.addRecipe(new ItemStack(TinkerTools.craftingSlabWood, 1, 0), "b", 'b', new ItemStack(TinkerTools.craftingStationWood, 1, 0));
|
||||
GameRegistry.addRecipe(new ItemStack(TinkerTools.craftingSlabWood, 1, 1), "b", 'b', new ItemStack(TinkerTools.toolStationWood, 1, 0));
|
||||
GameRegistry.addRecipe(new ItemStack(TinkerTools.craftingSlabWood, 1, 2), "b", 'b', new ItemStack(TinkerTools.toolStationWood, 1, 1));
|
||||
GameRegistry.addRecipe(new ItemStack(TinkerTools.craftingSlabWood, 1, 2), "b", 'b', new ItemStack(TinkerTools.toolStationWood, 1, 2));
|
||||
GameRegistry.addRecipe(new ItemStack(TinkerTools.craftingSlabWood, 1, 2), "b", 'b', new ItemStack(TinkerTools.toolStationWood, 1, 3));
|
||||
GameRegistry.addRecipe(new ItemStack(TinkerTools.craftingSlabWood, 1, 2), "b", 'b', new ItemStack(TinkerTools.toolStationWood, 1, 4));
|
||||
GameRegistry.addRecipe(new ItemStack(TinkerTools.craftingSlabWood, 1, 4), "b", 'b', new ItemStack(TinkerTools.toolStationWood, 1, 5));
|
||||
GameRegistry.addRecipe(new ItemStack(TinkerTools.craftingSlabWood, 1, 3), "b", 'b', new ItemStack(TinkerTools.toolStationWood, 1, 10));
|
||||
GameRegistry.addRecipe(new ItemStack(TinkerTools.craftingSlabWood, 1, 3), "b", 'b', new ItemStack(TinkerTools.toolStationWood, 1, 11));
|
||||
GameRegistry.addRecipe(new ItemStack(TinkerTools.craftingSlabWood, 1, 3), "b", 'b', new ItemStack(TinkerTools.toolStationWood, 1, 12));
|
||||
GameRegistry.addRecipe(new ItemStack(TinkerTools.craftingSlabWood, 1, 3), "b", 'b', new ItemStack(TinkerTools.toolStationWood, 1, 13));
|
||||
GameRegistry.addRecipe(new ItemStack(TinkerTools.craftingSlabWood, 1, 5), "b", 'b', new ItemStack(TinkerTools.toolForge, 1, Short.MAX_VALUE));
|
||||
|
||||
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(TinkerTools.materials, 1, 41), "dustArdite", "dustCobalt"));
|
||||
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(TinkerTools.materials, 4, 42), "dustAluminium", "dustCopper", "dustCopper", "dustCopper"));
|
||||
}
|
||||
|
||||
private void modIntegration()
|
||||
{
|
||||
|
||||
/* TE3 Flux */
|
||||
ItemStack batHardened = GameRegistry.findItemStack("ThermalExpansion", "capacitorHardened", 1);
|
||||
if (batHardened != null)
|
||||
{
|
||||
TinkerTools.modFlux.batteries.add(batHardened);
|
||||
}
|
||||
ItemStack basicCell = GameRegistry.findItemStack("ThermalExpansion", "cellBasic", 1);
|
||||
if (basicCell != null)
|
||||
{
|
||||
TinkerTools.modFlux.batteries.add(basicCell);
|
||||
}
|
||||
|
||||
ItemStack ironpick = ToolBuilder.instance.buildTool(new ItemStack(TinkerTools.pickaxeHead, 1, 6), new ItemStack(TinkerTools.toolRod, 1, 2), new ItemStack(TinkerTools.binding, 1, 6), "");
|
||||
if (batHardened != null)
|
||||
TConstructClientRegistry.registerManualModifier("fluxmod", ironpick.copy(), (ItemStack) batHardened);
|
||||
if (basicCell != null)
|
||||
TConstructClientRegistry.registerManualModifier("fluxmod2", ironpick.copy(), (ItemStack) basicCell);
|
||||
|
||||
/* Thaumcraft */
|
||||
Object obj = ItemHelper.getStaticItem("itemResource", "thaumcraft.common.config.ConfigItems");
|
||||
if (obj != null)
|
||||
{
|
||||
TConstruct.logger.info("Thaumcraft detected. Adding thaumium tools.");
|
||||
TinkerTools.thaumcraftAvailable = true;
|
||||
TConstructClientRegistry.addMaterialRenderMapping(31, "tinker", "thaumium", true);
|
||||
TConstructRegistry.addToolMaterial(31, "Thaumium", 3, 400, 700, 2, 1.3F, 0, 0f, "\u00A75", StatCollector.translateToLocal("materialtraits.thaumic"));
|
||||
PatternBuilder.instance.registerFullMaterial(new ItemStack((Item) obj, 1, 2), 2, StatCollector.translateToLocal("gui.partbuilder.material.thaumium"), new ItemStack(TinkerTools.toolShard,
|
||||
1, 31), new ItemStack(TinkerTools.toolRod, 1, 31), 31);
|
||||
for (int meta = 0; meta < TinkerTools.patternOutputs.length; meta++)
|
||||
{
|
||||
if (TinkerTools.patternOutputs[meta] != null)
|
||||
TConstructRegistry.addPartMapping(TinkerTools.woodPattern, meta + 1, 31, new ItemStack(TinkerTools.patternOutputs[meta], 1, 31));
|
||||
}
|
||||
|
||||
TConstructRegistry.addBowstringMaterial(1, 2, new ItemStack((Item) obj, 1, 7), new ItemStack(TinkerTools.bowstring, 1, 1), 1F, 1F, 0.9f);
|
||||
TConstructRegistry.addBowMaterial(31, 576, 40, 1.2f);
|
||||
TConstructRegistry.addArrowMaterial(31, 1.8F, 0.5F, 100F);
|
||||
}
|
||||
else
|
||||
{
|
||||
TConstruct.logger.warn("Thaumcraft not detected.");
|
||||
}
|
||||
|
||||
if (Loader.isModLoaded("Natura"))
|
||||
{
|
||||
try
|
||||
{
|
||||
Object plantItem = ItemHelper.getStaticItem("plantItem", "mods.natura.common.NContent");
|
||||
TConstructRegistry.addBowstringMaterial(2, 2, new ItemStack((Item) plantItem, 1, 7), new ItemStack(TinkerTools.bowstring, 1, 2), 1.2F, 0.8F, 1.3f);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
} // No need to handle
|
||||
}
|
||||
}
|
||||
|
||||
void registerMaterials ()
|
||||
{
|
||||
TConstructRegistry.addToolMaterial(0, "Wood", "Wooden ", 0, 59, 200, 0, 1.0F, 0, 0f, "\u00A7e", "");
|
||||
TConstructRegistry.addToolMaterial(1, "Stone", 1, 131, 400, 1, 0.5F, 0, 1f, "", StatCollector.translateToLocal("materialtraits.stonebound"));
|
||||
TConstructRegistry.addToolMaterial(2, "Iron", 2, 250, 600, 2, 1.3F, 1, 0f, "\u00A7f", "");
|
||||
TConstructRegistry.addToolMaterial(3, "Flint", 1, 171, 525, 2, 0.7F, 0, 0f, "\u00A78", "");
|
||||
TConstructRegistry.addToolMaterial(4, "Cactus", 1, 150, 500, 2, 1.0F, 0, -1f, "\u00A72", StatCollector.translateToLocal("materialtraits.jagged"));
|
||||
TConstructRegistry.addToolMaterial(5, "Bone", 1, 200, 400, 1, 1.0F, 0, 0f, "\u00A7e", "");
|
||||
TConstructRegistry.addToolMaterial(6, "Obsidian", 3, 89, 700, 2, 0.8F, 3, 0f, "\u00A7d", "");
|
||||
TConstructRegistry.addToolMaterial(7, "Netherrack", 2, 131, 400, 1, 1.2F, 0, 1f, "\u00A74", StatCollector.translateToLocal("materialtraits.stonebound"));
|
||||
TConstructRegistry.addToolMaterial(8, "Slime", 0, 500, 150, 0, 1.5F, 0, 0f, "\u00A7a", "");
|
||||
TConstructRegistry.addToolMaterial(9, "Paper", 0, 30, 200, 0, 0.3F, 0, 0f, "\u00A7f", StatCollector.translateToLocal("materialtraits.writable"));
|
||||
TConstructRegistry.addToolMaterial(10, "Cobalt", 4, 800, 1100, 3, 1.75F, 2, 0f, "\u00A73", "");
|
||||
TConstructRegistry.addToolMaterial(11, "Ardite", 4, 600, 800, 3, 2.0F, 0, 2f, "\u00A74", StatCollector.translateToLocal("materialtraits.stonebound"));
|
||||
TConstructRegistry.addToolMaterial(12, "Manyullyn", 5, 1200, 900, 4, 2.5F, 0, 0f, "\u00A75", "");
|
||||
TConstructRegistry.addToolMaterial(13, "Copper", 1, 180, 500, 2, 1.15F, 0, 0f, "\u00A7c", "");
|
||||
TConstructRegistry.addToolMaterial(14, "Bronze", 2, 350, 700, 2, 1.3F, 1, 0f, "\u00A76", "");
|
||||
TConstructRegistry.addToolMaterial(15, "Alumite", 4, 550, 800, 3, 1.3F, 2, 0f, "\u00A7d", "");
|
||||
TConstructRegistry.addToolMaterial(16, "Steel", 4, 750, 800, 3, 1.3F, 2, 0f, "", "");
|
||||
TConstructRegistry.addToolMaterial(17, "BlueSlime", "Slime ", 0, 1200, 150, 0, 2.0F, 0, 0f, "\u00A7b", "");
|
||||
TConstructRegistry.addToolMaterial(18, "PigIron", "Pig Iron ", 3, 250, 600, 2, 1.3F, 1, 0f, "\u00A7c", StatCollector.translateToLocal("materialtraits.tasty"));
|
||||
|
||||
TConstructRegistry.addBowMaterial(0, 384, 20, 1.0f); // Wood
|
||||
TConstructRegistry.addBowMaterial(1, 10, 80, 0.2f); // Stone
|
||||
TConstructRegistry.addBowMaterial(2, 576, 40, 1.2f); // Iron
|
||||
TConstructRegistry.addBowMaterial(3, 10, 80, 0.2f); // Flint
|
||||
TConstructRegistry.addBowMaterial(4, 384, 20, 1.0f); // Cactus
|
||||
TConstructRegistry.addBowMaterial(5, 192, 30, 1.0f); // Bone
|
||||
TConstructRegistry.addBowMaterial(6, 10, 80, 0.2f); // Obsidian
|
||||
TConstructRegistry.addBowMaterial(7, 10, 80, 0.2f); // Netherrack
|
||||
TConstructRegistry.addBowMaterial(8, 1536, 20, 1.2f); // Slime
|
||||
TConstructRegistry.addBowMaterial(9, 48, 25, 0.5f); // Paper
|
||||
TConstructRegistry.addBowMaterial(10, 1152, 40, 1.2f); // Cobalt
|
||||
TConstructRegistry.addBowMaterial(11, 960, 40, 1.2f); // Ardite
|
||||
TConstructRegistry.addBowMaterial(12, 1536, 40, 1.2f); // Manyullyn
|
||||
TConstructRegistry.addBowMaterial(13, 384, 40, 1.2f); // Copper
|
||||
TConstructRegistry.addBowMaterial(14, 576, 40, 1.2f); // Bronze
|
||||
TConstructRegistry.addBowMaterial(15, 768, 40, 1.2f); // Alumite
|
||||
TConstructRegistry.addBowMaterial(16, 768, 40, 1.2f); // Steel
|
||||
TConstructRegistry.addBowMaterial(17, 576, 20, 1.2f); // Blue Slime
|
||||
TConstructRegistry.addBowMaterial(18, 384, 20, 1.2f); // Slime
|
||||
|
||||
// Material ID, mass, fragility
|
||||
TConstructRegistry.addArrowMaterial(0, 0.69F, 1.0F, 100F); // Wood
|
||||
TConstructRegistry.addArrowMaterial(1, 2.5F, 5.0F, 100F); // Stone
|
||||
TConstructRegistry.addArrowMaterial(2, 7.2F, 0.5F, 100F); // Iron
|
||||
TConstructRegistry.addArrowMaterial(3, 2.65F, 1.0F, 100F); // Flint
|
||||
TConstructRegistry.addArrowMaterial(4, 0.76F, 1.0F, 100F); // Cactus
|
||||
TConstructRegistry.addArrowMaterial(5, 0.69F, 1.0F, 100); // Bone
|
||||
TConstructRegistry.addArrowMaterial(6, 2.4F, 1.0F, 100F); // Obsidian
|
||||
TConstructRegistry.addArrowMaterial(7, 3.5F, 1.0F, 100F); // Netherrack
|
||||
TConstructRegistry.addArrowMaterial(8, 0.42F, 0.0F, 100F); // Slime
|
||||
TConstructRegistry.addArrowMaterial(9, 1.1F, 3.0F, 90F); // Paper
|
||||
TConstructRegistry.addArrowMaterial(10, 8.9F, 0.25F, 100F); // Cobalt
|
||||
TConstructRegistry.addArrowMaterial(11, 7.2F, 0.25F, 100F); // Ardite
|
||||
TConstructRegistry.addArrowMaterial(12, 10.6F, 0.1F, 100F); // Manyullyn
|
||||
TConstructRegistry.addArrowMaterial(13, 8.96F, 0.5F, 100F); // Copper
|
||||
TConstructRegistry.addArrowMaterial(14, 7.9F, 0.25F, 100F); // Bronze
|
||||
TConstructRegistry.addArrowMaterial(15, 4.7F, 0.25F, 100F); // Alumite
|
||||
TConstructRegistry.addArrowMaterial(16, 7.6F, 0.25F, 100F); // Steel
|
||||
TConstructRegistry.addArrowMaterial(17, 0.42F, 0.0F, 100F); // Blue
|
||||
// Slime
|
||||
TConstructRegistry.addArrowMaterial(18, 6.8F, 0.5F, 100F); // Iron
|
||||
|
||||
TConstructRegistry.addBowstringMaterial(0, 2, new ItemStack(Items.string), new ItemStack(TinkerTools.bowstring, 1, 0), 1F, 1F, 1f); // String
|
||||
TConstructRegistry.addFletchingMaterial(0, 2, new ItemStack(Items.feather), new ItemStack(TinkerTools.fletching, 1, 0), 100F, 0F, 0.05F); // Feather
|
||||
for (int i = 0; i < 4; i++)
|
||||
TConstructRegistry.addFletchingMaterial(1, 2, new ItemStack(Blocks.leaves, 1, i), new ItemStack(TinkerTools.fletching, 1, 1), 75F, 0F, 0.2F); // All four vanialla Leaves
|
||||
TConstructRegistry.addFletchingMaterial(2, 2, new ItemStack(TinkerTools.materials, 1, 1), new ItemStack(TinkerTools.fletching, 1, 2), 100F, 0F, 0.12F); // Slime
|
||||
TConstructRegistry.addFletchingMaterial(3, 2, new ItemStack(TinkerTools.materials, 1, 17), new ItemStack(TinkerTools.fletching, 1, 3), 100F, 0F, 0.12F); // BlueSlime
|
||||
|
||||
PatternBuilder pb = PatternBuilder.instance;
|
||||
if (PHConstruct.enableTWood)
|
||||
pb.registerFullMaterial(Blocks.planks, 2, StatCollector.translateToLocal("gui.partbuilder.material.wood"), new ItemStack(Items.stick), new ItemStack(Items.stick), 0);
|
||||
else
|
||||
pb.registerMaterialSet(StatCollector.translateToLocal("gui.partbuilder.material.wood"), new ItemStack(Items.stick, 2), new ItemStack(Items.stick), 0);
|
||||
if (PHConstruct.enableTStone)
|
||||
{
|
||||
pb.registerFullMaterial(Blocks.stone, 2, StatCollector.translateToLocal("gui.partbuilder.material.stone"), new ItemStack(TinkerTools.toolShard, 1, 1), new ItemStack(TinkerTools.toolRod, 1, 1), 1);
|
||||
pb.registerMaterial(Blocks.cobblestone, 2, StatCollector.translateToLocal("gui.partbuilder.material.stone"));
|
||||
}
|
||||
else
|
||||
pb.registerMaterialSet(StatCollector.translateToLocal("gui.partbuilder.material.stone"), new ItemStack(TinkerTools.toolShard, 1, 1), new ItemStack(TinkerTools.toolRod, 1, 1), 0);
|
||||
pb.registerFullMaterial(Items.iron_ingot, 2, StatCollector.translateToLocal("gui.partbuilder.material.iron"), new ItemStack(TinkerTools.toolShard, 1, 2), new ItemStack(TinkerTools.toolRod, 1, 2), 2);
|
||||
if (PHConstruct.enableTFlint)
|
||||
pb.registerFullMaterial(Items.flint, 2, StatCollector.translateToLocal("gui.partbuilder.material.flint"), new ItemStack(TinkerTools.toolShard, 1, 3), new ItemStack(TinkerTools.toolRod, 1, 3), 3);
|
||||
else
|
||||
pb.registerMaterialSet(StatCollector.translateToLocal("gui.partbuilder.material.flint"), new ItemStack(TinkerTools.toolShard, 1, 3), new ItemStack(TinkerTools.toolRod, 1, 3), 3);
|
||||
if (PHConstruct.enableTCactus)
|
||||
pb.registerFullMaterial(Blocks.cactus, 2, StatCollector.translateToLocal("gui.partbuilder.material.cactus"), new ItemStack(TinkerTools.toolShard, 1, 4), new ItemStack(TinkerTools.toolRod, 1, 4), 4);
|
||||
else
|
||||
pb.registerMaterialSet(StatCollector.translateToLocal("gui.partbuilder.material.cactus"), new ItemStack(TinkerTools.toolShard, 1, 4), new ItemStack(TinkerTools.toolRod, 1, 4), 4);
|
||||
if (PHConstruct.enableTBone)
|
||||
pb.registerFullMaterial(Items.bone, 2, StatCollector.translateToLocal("gui.partbuilder.material.bone"), new ItemStack(Items.dye, 1, 15), new ItemStack(Items.bone), 5);
|
||||
else
|
||||
pb.registerMaterialSet(StatCollector.translateToLocal("gui.partbuilder.material.bone"), new ItemStack(Items.dye, 1, 15), new ItemStack(Items.bone), 5);
|
||||
pb.registerFullMaterial(Blocks.obsidian, 2, StatCollector.translateToLocal("gui.partbuilder.material.obsidian"), new ItemStack(TinkerTools.toolShard, 1, 6), new ItemStack(TinkerTools.toolRod, 1, 6), 6);
|
||||
pb.registerMaterial(new ItemStack(TinkerTools.materials, 1, 18), 2, StatCollector.translateToLocal("gui.partbuilder.material.obsidian"));
|
||||
if (PHConstruct.enableTNetherrack)
|
||||
pb.registerFullMaterial(Blocks.netherrack, 2, StatCollector.translateToLocal("gui.partbuilder.material.netherrack"), new ItemStack(TinkerTools.toolShard, 1, 7), new ItemStack(TinkerTools.toolRod, 1, 7), 7);
|
||||
else
|
||||
pb.registerMaterialSet(StatCollector.translateToLocal("gui.partbuilder.material.netherrack"), new ItemStack(TinkerTools.toolShard, 1, 7), new ItemStack(TinkerTools.toolRod, 1, 7), 7);
|
||||
if (PHConstruct.enableTSlime)
|
||||
pb.registerFullMaterial(new ItemStack(TinkerTools.materials, 1, 1), 2, StatCollector.translateToLocal("gui.partbuilder.material.slime"), new ItemStack(TinkerTools.toolShard, 1, 8), new ItemStack(TinkerTools.toolRod, 1, 8), 8);
|
||||
else
|
||||
pb.registerMaterialSet(StatCollector.translateToLocal("gui.partbuilder.material.slime"), new ItemStack(TinkerTools.toolShard, 1, 8), new ItemStack(TinkerTools.toolRod, 1, 17), 8);
|
||||
if (PHConstruct.enableTPaper)
|
||||
pb.registerFullMaterial(new ItemStack(TinkerTools.materials, 1, 0), 2, StatCollector.translateToLocal("gui.partbuilder.material.paper"), new ItemStack(Items.paper, 2), new ItemStack(TinkerTools.toolRod, 1, 9), 9);
|
||||
else
|
||||
pb.registerMaterialSet(StatCollector.translateToLocal("gui.partbuilder.material.blueslime"), new ItemStack(Items.paper, 2), new ItemStack(TinkerTools.toolRod, 1, 9), 9);
|
||||
pb.registerMaterialSet(StatCollector.translateToLocal("gui.partbuilder.material.cobalt"), new ItemStack(TinkerTools.toolShard, 1, 10), new ItemStack(TinkerTools.toolRod, 1, 10), 10);
|
||||
pb.registerMaterialSet(StatCollector.translateToLocal("gui.partbuilder.material.ardite"), new ItemStack(TinkerTools.toolShard, 1, 11), new ItemStack(TinkerTools.toolRod, 1, 11), 11);
|
||||
pb.registerMaterialSet(StatCollector.translateToLocal("gui.partbuilder.material.manyullyn"), new ItemStack(TinkerTools.toolShard, 1, 12), new ItemStack(TinkerTools.toolRod, 1, 12), 12);
|
||||
pb.registerMaterialSet(StatCollector.translateToLocal("gui.partbuilder.material.copper"), new ItemStack(TinkerTools.toolShard, 1, 13), new ItemStack(TinkerTools.toolRod, 1, 13), 13);
|
||||
pb.registerMaterialSet(StatCollector.translateToLocal("gui.partbuilder.material.bronze"), new ItemStack(TinkerTools.toolShard, 1, 14), new ItemStack(TinkerTools.toolRod, 1, 14), 14);
|
||||
pb.registerMaterialSet(StatCollector.translateToLocal("gui.partbuilder.material.alumite"), new ItemStack(TinkerTools.toolShard, 1, 15), new ItemStack(TinkerTools.toolRod, 1, 15), 15);
|
||||
pb.registerMaterialSet(StatCollector.translateToLocal("gui.partbuilder.material.steel"), new ItemStack(TinkerTools.toolShard, 1, 16), new ItemStack(TinkerTools.toolRod, 1, 16), 16);
|
||||
if (PHConstruct.enableTBlueSlime)
|
||||
pb.registerFullMaterial(new ItemStack(TinkerTools.materials, 1, 17), 2, StatCollector.translateToLocal("gui.partbuilder.material.blueslime"), new ItemStack(TinkerTools.toolShard, 1, 17), new ItemStack(TinkerTools.toolRod, 1, 17), 17);
|
||||
else
|
||||
pb.registerMaterialSet(StatCollector.translateToLocal("gui.partbuilder.material.blueslime"), new ItemStack(TinkerTools.toolShard, 1, 17), new ItemStack(TinkerTools.toolRod, 1, 17), 17);
|
||||
pb.registerFullMaterial(new ItemStack(TinkerTools.materials, 1, 34), 2, StatCollector.translateToLocal("gui.partbuilder.material.pigiron"), new ItemStack(TinkerTools.toolShard, 1, 18), new ItemStack(TinkerTools.toolRod, 1, 18), 18);
|
||||
|
||||
pb.addToolPattern((IPattern) TinkerTools.woodPattern);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package tconstruct.tools;
|
||||
|
||||
import cpw.mods.fml.common.Mod.EventHandler;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
|
||||
public class ToolProxyClient extends ToolProxyCommon
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package tconstruct.tools;
|
||||
|
||||
public class ToolProxyCommon
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,185 @@
|
||||
package tconstruct.tools.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mantle.blocks.abstracts.InventorySlab;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.common.TProxyCommon;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import tconstruct.tools.logic.CraftingStationLogic;
|
||||
import tconstruct.tools.logic.PartBuilderLogic;
|
||||
import tconstruct.tools.logic.PatternChestLogic;
|
||||
import tconstruct.tools.logic.StencilTableLogic;
|
||||
import tconstruct.tools.logic.ToolForgeLogic;
|
||||
import tconstruct.tools.logic.ToolStationLogic;
|
||||
import tconstruct.util.config.PHConstruct;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class CraftingSlab extends InventorySlab
|
||||
{
|
||||
public CraftingSlab(Material material)
|
||||
{
|
||||
super(material);
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
this.setHardness(2f);
|
||||
this.stepSound = Block.soundTypeWood;
|
||||
}
|
||||
|
||||
/* Rendering */
|
||||
@Override
|
||||
public String[] getTextureNames ()
|
||||
{
|
||||
String[] textureNames = { "craftingstation_top", "craftingstation_slab_side", "craftingstation_bottom", "toolstation_top", "toolstation_slab_side", "toolstation_bottom",
|
||||
"partbuilder_oak_top", "partbuilder_slab_side", "partbuilder_oak_bottom", "stenciltable_oak_top", "stenciltable_slab_side", "stenciltable_oak_bottom", "patternchest_top",
|
||||
"patternchest_slab_side", "patternchest_bottom", "toolforge_top", "toolforge_slab_side", "toolforge_top" };
|
||||
|
||||
return textureNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTextureDomain (int textureNameIndex)
|
||||
{
|
||||
return "tinker";
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon (int side, int meta)
|
||||
{
|
||||
return icons[(meta % 8) * 3 + getTextureIndex(side)];
|
||||
}
|
||||
|
||||
public int getTextureIndex (int side)
|
||||
{
|
||||
if (side == 0)
|
||||
return 2;
|
||||
if (side == 1)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getSelectedBoundingBoxFromPool (World world, int x, int y, int z)
|
||||
{
|
||||
int metadata = world.getBlockMetadata(x, y, z);
|
||||
if (metadata == 5)
|
||||
return AxisAlignedBB.getAABBPool().getAABB((double) x + this.minX, (double) y + this.minY, (double) z + this.minZ, (double) x + this.maxX, (double) y + this.maxY - 0.125,
|
||||
(double) z + this.maxZ);
|
||||
return AxisAlignedBB.getAABBPool().getAABB((double) x + this.minX, (double) y + this.minY, (double) z + this.minZ, (double) x + this.maxX, (double) y + this.maxY, (double) z + this.maxZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity (World world, int metadata)
|
||||
{
|
||||
switch (metadata % 8)
|
||||
{
|
||||
case 0:
|
||||
return new CraftingStationLogic();
|
||||
case 1:
|
||||
return new ToolStationLogic();
|
||||
case 2:
|
||||
return new PartBuilderLogic();
|
||||
case 3:
|
||||
return new StencilTableLogic();
|
||||
case 4:
|
||||
return new PatternChestLogic();
|
||||
case 5:
|
||||
return new ToolForgeLogic();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z) % 8;
|
||||
switch (meta)
|
||||
{
|
||||
case 0:
|
||||
return TProxyCommon.craftingStationID;
|
||||
case 1:
|
||||
return TProxyCommon.toolStationID;
|
||||
case 2:
|
||||
return TProxyCommon.partBuilderID;
|
||||
case 3:
|
||||
return TProxyCommon.stencilTableID;
|
||||
case 4:
|
||||
return TProxyCommon.patternChestID;
|
||||
case 5:
|
||||
return TProxyCommon.toolForgeID;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getModInstance ()
|
||||
{
|
||||
return TConstruct.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks (Item b, CreativeTabs tab, List list)
|
||||
{
|
||||
for (int iter = 0; iter < 6; iter++)
|
||||
{
|
||||
list.add(new ItemStack(b, 1, iter));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy (World world, int x, int y, int z, EntityLivingBase entityliving, ItemStack stack)
|
||||
{
|
||||
if (PHConstruct.freePatterns)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta == 4)
|
||||
{
|
||||
PatternChestLogic logic = (PatternChestLogic) world.getTileEntity(x, y, z);
|
||||
for (int i = 1; i <= 13; i++)
|
||||
{
|
||||
logic.setInventorySlotContents(i - 1, new ItemStack(TinkerTools.woodPattern, 1, i));
|
||||
}
|
||||
logic.setInventorySlotContents(13, new ItemStack(TinkerTools.woodPattern, 1, 22));
|
||||
}
|
||||
}
|
||||
super.onBlockPlacedBy(world, x, y, z, entityliving, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity (World var1, int metadata)
|
||||
{
|
||||
switch (metadata % 8)
|
||||
{
|
||||
case 0:
|
||||
return new CraftingStationLogic();
|
||||
case 1:
|
||||
return new ToolStationLogic();
|
||||
case 2:
|
||||
return new PartBuilderLogic();
|
||||
case 3:
|
||||
return new StencilTableLogic();
|
||||
case 4:
|
||||
return new PatternChestLogic();
|
||||
case 5:
|
||||
return new ToolForgeLogic();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package tconstruct.tools.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mantle.blocks.abstracts.InventoryBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.common.TProxyCommon;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.tools.logic.CraftingStationLogic;
|
||||
import tconstruct.tools.model.TableRender;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class CraftingStationBlock extends InventoryBlock
|
||||
{
|
||||
public CraftingStationBlock(Material material)
|
||||
{
|
||||
super(material);
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
this.setHardness(2f);
|
||||
this.setStepSound(Block.soundTypeWood);
|
||||
}
|
||||
|
||||
//Block.hasComparatorInputOverride and Block.getComparatorInputOverride
|
||||
|
||||
/* Rendering */
|
||||
@Override
|
||||
public String[] getTextureNames ()
|
||||
{
|
||||
String[] textureNames = { "craftingstation_top", "craftingstation_side", "craftingstation_bottom" };
|
||||
|
||||
return textureNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTextureDomain (int textureNameIndex)
|
||||
{
|
||||
return "tinker";
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon (int side, int meta)
|
||||
{
|
||||
return icons[getTextureIndex(side)];
|
||||
}
|
||||
|
||||
public int getTextureIndex (int side)
|
||||
{
|
||||
if (side == 0)
|
||||
return 2;
|
||||
if (side == 1)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType ()
|
||||
{
|
||||
return TableRender.tabelModelID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldSideBeRendered (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer)
|
||||
{
|
||||
return TProxyCommon.craftingStationID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getModInstance ()
|
||||
{
|
||||
return TConstruct.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks (Item id, CreativeTabs tab, List list)
|
||||
{
|
||||
for (int iter = 0; iter < 1; iter++)
|
||||
{
|
||||
list.add(new ItemStack(id, 1, iter));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity (World arg0, int arg1)
|
||||
{
|
||||
return new CraftingStationLogic();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,209 @@
|
||||
package tconstruct.tools.blocks;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import mantle.blocks.abstracts.InventoryBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.tools.logic.EquipLogic;
|
||||
import tconstruct.tools.logic.FrypanLogic;
|
||||
import tconstruct.tools.model.FrypanRender;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class EquipBlock extends InventoryBlock
|
||||
{
|
||||
|
||||
public EquipBlock(Material material)
|
||||
{
|
||||
super(material);
|
||||
this.setHardness(0.3f);
|
||||
this.setBlockBounds(0, 0, 0, 1, 0.25f, 1);
|
||||
// this.setCreativeTab(ToolConstruct.materialTab);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTextureNames ()
|
||||
{
|
||||
return new String[] { "toolstation_top" };
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTextureDomain (int textureNameIndex)
|
||||
{
|
||||
return "tinker";
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon (int side, int meta)
|
||||
{
|
||||
return Blocks.iron_block.getIcon(side, meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons (IIconRegister par1IconRegister)
|
||||
{
|
||||
// this.blockIcon =
|
||||
// par1iconRegister.registerIcon(Block.blockIron.getUnlocalizedName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType ()
|
||||
{
|
||||
return FrypanRender.frypanModelID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemDropped (int par1, Random par2Random, int par3)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity (World world, int metadata)
|
||||
{
|
||||
return new FrypanLogic();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void randomDisplayTick (World world, int x, int y, int z, Random random)
|
||||
{
|
||||
if (isActive(world, x, y, z))
|
||||
{
|
||||
float f = (float) x + 0.5F;
|
||||
float f1 = (float) y + 0.25F + (random.nextFloat() * 6F) / 16F;
|
||||
float f2 = (float) z + 0.5F;
|
||||
float f4 = random.nextFloat() * 0.6F - 0.3F;
|
||||
world.spawnParticle("smoke", f, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("flame", f, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy (World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack)
|
||||
{
|
||||
super.onBlockPlacedBy(par1World, par2, par3, par4, par5EntityLivingBase, par6ItemStack);
|
||||
int i3 = MathHelper.floor_double((par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
|
||||
|
||||
int newMeta = 0;
|
||||
|
||||
switch (i3)
|
||||
{
|
||||
case 3:
|
||||
newMeta = 0;
|
||||
break;
|
||||
case 0:
|
||||
newMeta = 3;
|
||||
break;
|
||||
case 1:
|
||||
newMeta = 1;
|
||||
break;
|
||||
case 2:
|
||||
newMeta = 2;
|
||||
break;
|
||||
}
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, newMeta, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock (World par1World, int x, int y, int z, Block par5, int meta)
|
||||
{
|
||||
TileEntity te = par1World.getTileEntity(x, y, z);
|
||||
|
||||
if (te != null && te instanceof EquipLogic)
|
||||
{
|
||||
EquipLogic logic = (EquipLogic) te;
|
||||
for (int iter = 0; iter < logic.getSizeInventory(); ++iter)
|
||||
{
|
||||
ItemStack stack = iter == 0 ? logic.getEquipmentItem() : logic.getStackInSlot(iter);
|
||||
|
||||
if (stack != null && logic.canDropInventorySlot(iter))
|
||||
{
|
||||
float jumpX = rand.nextFloat() * 0.8F + 0.1F;
|
||||
float jumpY = rand.nextFloat() * 0.8F + 0.1F;
|
||||
float jumpZ = rand.nextFloat() * 0.8F + 0.1F;
|
||||
|
||||
while (stack.stackSize > 0)
|
||||
{
|
||||
int itemSize = rand.nextInt(21) + 10;
|
||||
|
||||
if (itemSize > stack.stackSize)
|
||||
{
|
||||
itemSize = stack.stackSize;
|
||||
}
|
||||
|
||||
stack.stackSize -= itemSize;
|
||||
EntityItem entityitem = new EntityItem(par1World, (double) ((float) x + jumpX), (double) ((float) y + jumpY), (double) ((float) z + jumpZ), new ItemStack(stack.getItem(),
|
||||
itemSize, stack.getItemDamage()));
|
||||
|
||||
if (stack.hasTagCompound())
|
||||
{
|
||||
entityitem.getEntityItem().setTagCompound((NBTTagCompound) stack.getTagCompound().copy());
|
||||
}
|
||||
|
||||
float offset = 0.05F;
|
||||
entityitem.motionX = (double) ((float) rand.nextGaussian() * offset);
|
||||
entityitem.motionY = (double) ((float) rand.nextGaussian() * offset + 0.2F);
|
||||
entityitem.motionZ = (double) ((float) rand.nextGaussian() * offset);
|
||||
par1World.spawnEntityInWorld(entityitem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
super.breakBlock(par1World, x, y, z, par5, meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue (IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
return !isActive(world, x, y, z) ? 0 : 9;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer)
|
||||
{
|
||||
return TConstruct.proxy.frypanGuiID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getModInstance ()
|
||||
{
|
||||
return TConstruct.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity (World world, int metadata)
|
||||
{
|
||||
return new FrypanLogic();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
package tconstruct.tools.blocks;
|
||||
|
||||
import mantle.blocks.abstracts.InventorySlab;
|
||||
import mantle.blocks.iface.IActiveLogic;
|
||||
import mantle.blocks.iface.IFacingLogic;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.common.TProxyCommon;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.tools.logic.FurnaceLogic;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class FurnaceSlab extends InventorySlab
|
||||
{
|
||||
|
||||
public FurnaceSlab(Material material)
|
||||
{
|
||||
super(material);
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
this.setHardness(3.5f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity (World world, int metadata)
|
||||
{
|
||||
switch (metadata % 8)
|
||||
{
|
||||
case 0:
|
||||
return new FurnaceLogic();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer)
|
||||
{
|
||||
return TProxyCommon.furnaceID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getModInstance ()
|
||||
{
|
||||
return TConstruct.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTextureNames ()
|
||||
{
|
||||
String[] textureNames = { "furnaceslab_front", "furnaceslab_front_active", "furnaceslab_side", "furnace_top" };
|
||||
|
||||
return textureNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon (int side, int meta)
|
||||
{
|
||||
return icons[(meta % 8) * 3 + getTextureIndex(side)];
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon (IBlockAccess world, int x, int y, int z, int side)
|
||||
{
|
||||
TileEntity logic = world.getTileEntity(x, y, z);
|
||||
short direction = (logic instanceof IFacingLogic) ? ((IFacingLogic) logic).getRenderDirection() : 0;
|
||||
int meta = world.getBlockMetadata(x, y, z) % 8;
|
||||
|
||||
if (meta == 0)
|
||||
{
|
||||
if (side == direction)
|
||||
{
|
||||
if (((IActiveLogic) logic).getActive())
|
||||
return icons[1];
|
||||
else
|
||||
return icons[0];
|
||||
}
|
||||
else if (side > 1)
|
||||
{
|
||||
return icons[2];
|
||||
}
|
||||
return icons[3];
|
||||
}
|
||||
return icons[0];
|
||||
}
|
||||
|
||||
public int getTextureIndex (int side)
|
||||
{
|
||||
if (side == 0 || side == 1)
|
||||
return 3;
|
||||
if (side == 3)
|
||||
return 0;
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTextureDomain (int textureNameIndex)
|
||||
{
|
||||
return "tinker";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons (IIconRegister iconRegister)
|
||||
{
|
||||
String[] textureNames = getTextureNames();
|
||||
this.icons = new IIcon[textureNames.length];
|
||||
|
||||
for (int i = 0; i < this.icons.length; ++i)
|
||||
{
|
||||
if (i == 3)
|
||||
this.icons[i] = iconRegister.registerIcon("minecraft:" + textureNames[i]);
|
||||
else
|
||||
this.icons[i] = iconRegister.registerIcon("tinker:" + textureNames[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity (World var1, int metadata)
|
||||
{
|
||||
switch (metadata % 8)
|
||||
{
|
||||
case 0:
|
||||
return new FurnaceLogic();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
package tconstruct.tools.blocks;
|
||||
|
||||
import tconstruct.blocks.TConstructBlock;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class MultiBrick extends TConstructBlock
|
||||
{
|
||||
static String blockTextures[] = { "brick_obsidian", "brick_sandstone", "brick_netherrack", "brick_stone_refined", "brick_iron", "brick_gold", "brick_lapis", "brick_diamond", "brick_redstone",
|
||||
"brick_bone", "brick_slime", "brick_blueslime", "brick_endstone", "brick_obsidian_ingot" };
|
||||
|
||||
public MultiBrick()
|
||||
{
|
||||
super(Material.rock, 3f, blockTextures);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBlockHardness (World world, int x, int y, int z)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
switch (meta)
|
||||
{
|
||||
case 0:
|
||||
return Blocks.obsidian.getBlockHardness(world, x, y, z);
|
||||
case 1:
|
||||
return Blocks.sandstone.getBlockHardness(world, x, y, z);
|
||||
case 2:
|
||||
return Blocks.netherrack.getBlockHardness(world, x, y, z);
|
||||
case 3:
|
||||
return Blocks.stone.getBlockHardness(world, x, y, z);
|
||||
case 4:
|
||||
return Blocks.iron_block.getBlockHardness(world, x, y, z);
|
||||
case 5:
|
||||
return Blocks.gold_block.getBlockHardness(world, x, y, z);
|
||||
case 6:
|
||||
return Blocks.lapis_block.getBlockHardness(world, x, y, z);
|
||||
case 7:
|
||||
return Blocks.diamond_block.getBlockHardness(world, x, y, z);
|
||||
case 8:
|
||||
return Blocks.redstone_block.getBlockHardness(world, x, y, z);
|
||||
case 9:
|
||||
return 1.0F;
|
||||
case 10:
|
||||
return 1.5F;
|
||||
case 11:
|
||||
return 1.5F;
|
||||
case 12:
|
||||
return Blocks.end_stone.getBlockHardness(world, x, y, z);
|
||||
case 13:
|
||||
return Blocks.obsidian.getBlockHardness(world, x, y, z);
|
||||
default:
|
||||
return blockHardness;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExplosionResistance (Entity entity, World world, int x, int y, int z, double explosionX, double explosionY, double explosionZ)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
switch (meta)
|
||||
{
|
||||
case 0:
|
||||
return Blocks.obsidian.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
|
||||
case 1:
|
||||
return Blocks.sandstone.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
|
||||
case 2:
|
||||
return Blocks.netherrack.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
|
||||
case 3:
|
||||
return Blocks.stone.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
|
||||
case 4:
|
||||
return Blocks.iron_block.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
|
||||
case 5:
|
||||
return Blocks.gold_block.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
|
||||
case 6:
|
||||
return Blocks.lapis_block.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
|
||||
case 7:
|
||||
return Blocks.diamond_block.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
|
||||
case 8:
|
||||
return Blocks.redstone_block.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
|
||||
case 9:
|
||||
return 1.0F;
|
||||
case 10:
|
||||
return 1.5F;
|
||||
case 11:
|
||||
return 1.5F;
|
||||
case 12:
|
||||
return Blocks.end_stone.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
|
||||
case 13:
|
||||
return Blocks.obsidian.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
|
||||
default:
|
||||
return getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock (World world, int x, int y, int z, Entity entity)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta == 10 || meta == 11)
|
||||
{
|
||||
if (entity.motionY < 0)
|
||||
entity.motionY *= -1.2F;
|
||||
entity.fallDistance = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO getCollisionBoundingBoxFromPool
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool (World world, int x, int y, int z)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta == 10 || meta == 11)
|
||||
return AxisAlignedBB.getBoundingBox(x, y, z, (double) x + 1.0D, (double) y + 0.625D, (double) z + 1.0D);
|
||||
return super.getCollisionBoundingBoxFromPool(world, x, y, z);
|
||||
}
|
||||
|
||||
/*
|
||||
* @Override public int getRenderType () { return BrickRender.model; }
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean canProvidePower ()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int isProvidingWeakPower (IBlockAccess world, int x, int y, int z, int side)
|
||||
{
|
||||
if (world.getBlockMetadata(x, y, z) == 8)
|
||||
return 4;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons (IIconRegister iconRegister)
|
||||
{
|
||||
this.icons = new IIcon[textureNames.length];
|
||||
|
||||
for (int i = 0; i < this.icons.length; ++i)
|
||||
{
|
||||
this.icons[i] = iconRegister.registerIcon("tinker:bricks/" + textureNames[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
package tconstruct.tools.blocks;
|
||||
|
||||
import tconstruct.blocks.TConstructBlock;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class MultiBrickFancy extends TConstructBlock
|
||||
{
|
||||
static String blockTextures[] = { "fancybrick_obsidian", "fancybrick_sandstone", "fancybrick_netherrack", "fancybrick_stone_refined", "fancybrick_iron", "fancybrick_gold", "fancybrick_lapis",
|
||||
"fancybrick_diamond", "fancybrick_redstone", "fancybrick_bone", "fancybrick_slime", "fancybrick_blueslime", "fancybrick_endstone", "fancybrick_obsidian_ingot", "fancybrick_stone",
|
||||
"road_stone" };
|
||||
|
||||
public MultiBrickFancy()
|
||||
{
|
||||
super(Material.rock, 3f, blockTextures);
|
||||
}
|
||||
|
||||
// TODO getBlockHardness
|
||||
@Override
|
||||
public float getBlockHardness (World world, int x, int y, int z)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
switch (meta)
|
||||
{
|
||||
case 0:
|
||||
return Blocks.obsidian.getBlockHardness(world, x, y, z);
|
||||
case 1:
|
||||
return Blocks.sandstone.getBlockHardness(world, x, y, z);
|
||||
case 2:
|
||||
return Blocks.netherrack.getBlockHardness(world, x, y, z);
|
||||
case 4:
|
||||
return Blocks.iron_block.getBlockHardness(world, x, y, z);
|
||||
case 5:
|
||||
return Blocks.gold_block.getBlockHardness(world, x, y, z);
|
||||
case 6:
|
||||
return Blocks.lapis_block.getBlockHardness(world, x, y, z);
|
||||
case 7:
|
||||
return Blocks.diamond_block.getBlockHardness(world, x, y, z);
|
||||
case 8:
|
||||
return Blocks.redstone_block.getBlockHardness(world, x, y, z);
|
||||
case 9:
|
||||
return 1.0F;
|
||||
case 10:
|
||||
return 1.5F;
|
||||
case 11:
|
||||
return 1.5F;
|
||||
case 12:
|
||||
return Blocks.end_stone.getBlockHardness(world, x, y, z);
|
||||
case 13:
|
||||
return Blocks.obsidian.getBlockHardness(world, x, y, z);
|
||||
case 3:
|
||||
case 14:
|
||||
case 15:
|
||||
return Blocks.stone.getBlockHardness(world, x, y, z);
|
||||
default:
|
||||
return blockHardness;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExplosionResistance (Entity entity, World world, int x, int y, int z, double explosionX, double explosionY, double explosionZ)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
switch (meta)
|
||||
{
|
||||
case 0:
|
||||
return Blocks.obsidian.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
|
||||
case 1:
|
||||
return Blocks.sandstone.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
|
||||
case 2:
|
||||
return Blocks.netherrack.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
|
||||
case 4:
|
||||
return Blocks.iron_block.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
|
||||
case 5:
|
||||
return Blocks.gold_block.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
|
||||
case 6:
|
||||
return Blocks.lapis_block.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
|
||||
case 7:
|
||||
return Blocks.diamond_block.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
|
||||
case 8:
|
||||
return Blocks.redstone_block.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
|
||||
case 9:
|
||||
return 1.0F;
|
||||
case 10:
|
||||
return 1.5F;
|
||||
case 11:
|
||||
return 1.5F;
|
||||
case 12:
|
||||
return Blocks.end_stone.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
|
||||
case 13:
|
||||
return Blocks.obsidian.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
|
||||
case 3:
|
||||
case 14:
|
||||
case 15:
|
||||
return Blocks.stone.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
|
||||
default:
|
||||
return getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO onEntityCollidedWithBlock
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock (World world, int x, int y, int z, Entity entity)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta == 10 || meta == 11)
|
||||
{
|
||||
if (entity.motionY < 0)
|
||||
entity.motionY *= -1.2F;
|
||||
entity.fallDistance = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool (World world, int x, int y, int z)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta == 10 || meta == 11)
|
||||
return AxisAlignedBB.getBoundingBox(x, y, z, (double) x + 1.0D, (double) y + 0.625D, (double) z + 1.0D);
|
||||
return super.getCollisionBoundingBoxFromPool(world, x, y, z);
|
||||
}
|
||||
|
||||
/*
|
||||
* @Override public int getRenderType () { return BrickRender.model; }
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean canProvidePower ()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public int isProvidingWeakPower (IBlockAccess world, int x, int y, int z, int side)
|
||||
{
|
||||
if (world.getBlockMetadata(x, y, z) == 8)
|
||||
return 4;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons (IIconRegister iconRegister)
|
||||
{
|
||||
this.icons = new IIcon[textureNames.length];
|
||||
|
||||
for (int i = 0; i < this.icons.length; ++i)
|
||||
{
|
||||
this.icons[i] = iconRegister.registerIcon("tinker:bricks/" + textureNames[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
package tconstruct.tools.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mantle.blocks.abstracts.InventoryBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.common.TProxyCommon;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.smeltery.TinkerSmeltery;
|
||||
import tconstruct.tools.logic.ToolForgeLogic;
|
||||
import tconstruct.tools.model.TableForgeRender;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ToolForgeBlock extends InventoryBlock
|
||||
{
|
||||
|
||||
public ToolForgeBlock(Material material)
|
||||
{
|
||||
super(material);
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
this.setHardness(2f);
|
||||
this.setStepSound(Block.soundTypeMetal);
|
||||
}
|
||||
|
||||
String[] textureNames = { "toolforge_iron", "toolforge_gold", "toolforge_diamond", "toolforge_emerald", "toolforge_cobalt", "toolforge_ardite", "toolforge_manyullyn", "toolforge_copper",
|
||||
"toolforge_bronze", "toolforge_tin", "toolforge_aluminum", "toolforge_alubrass", "toolforge_alumite", "toolforge_steel" };
|
||||
|
||||
/* Rendering */
|
||||
@Override
|
||||
public String[] getTextureNames ()
|
||||
{
|
||||
return textureNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTextureDomain (int textureNameIndex)
|
||||
{
|
||||
return "tinker";
|
||||
}
|
||||
|
||||
IIcon textureTop;
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons (IIconRegister iconRegister)
|
||||
{
|
||||
super.registerBlockIcons(iconRegister);
|
||||
textureTop = iconRegister.registerIcon("tinker:toolforge_top");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon (int side, int meta)
|
||||
{
|
||||
if (side == 1)
|
||||
{
|
||||
return textureTop;
|
||||
}
|
||||
if (side == 0)
|
||||
{
|
||||
switch (meta)
|
||||
{
|
||||
case 0:
|
||||
return Blocks.iron_block.getIcon(side, 0);
|
||||
case 1:
|
||||
return Blocks.gold_block.getIcon(side, 0);
|
||||
case 2:
|
||||
return Blocks.diamond_block.getIcon(side, 0);
|
||||
case 3:
|
||||
return Blocks.emerald_block.getIcon(side, 0);
|
||||
default:
|
||||
return TinkerSmeltery.metalBlock.getIcon(side, meta - 4);
|
||||
}
|
||||
}
|
||||
|
||||
return this.icons[meta];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSideSolid (IBlockAccess world, int x, int y, int z, ForgeDirection side)
|
||||
{
|
||||
return side == ForgeDirection.UP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType ()
|
||||
{
|
||||
return TableForgeRender.model;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldSideBeRendered (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity (World world, int metadata)
|
||||
{
|
||||
return new ToolForgeLogic();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer)
|
||||
{
|
||||
int md = world.getBlockMetadata(x, y, z);
|
||||
return TProxyCommon.toolForgeID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getModInstance ()
|
||||
{
|
||||
return TConstruct.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks (Item b, CreativeTabs tab, List list)
|
||||
{
|
||||
for (int iter = 0; iter < textureNames.length; iter++)
|
||||
{
|
||||
list.add(new ItemStack(b, 1, iter));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,224 @@
|
||||
package tconstruct.tools.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mantle.blocks.abstracts.InventoryBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import tconstruct.tools.logic.PartBuilderLogic;
|
||||
import tconstruct.tools.logic.PatternChestLogic;
|
||||
import tconstruct.tools.logic.StencilTableLogic;
|
||||
import tconstruct.tools.logic.ToolStationLogic;
|
||||
import tconstruct.tools.model.TableRender;
|
||||
import tconstruct.util.config.PHConstruct;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ToolStationBlock extends InventoryBlock
|
||||
{
|
||||
public ToolStationBlock(Material material)
|
||||
{
|
||||
super(material);
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
this.setHardness(2f);
|
||||
this.setStepSound(Block.soundTypeWood);
|
||||
}
|
||||
|
||||
//Block.hasComparatorInputOverride and Block.getComparatorInputOverride
|
||||
|
||||
/* Rendering */
|
||||
@Override
|
||||
public String[] getTextureNames ()
|
||||
{
|
||||
String[] textureNames = { "toolstation_top", "toolstation_side", "toolstation_bottom", "partbuilder_oak_top", "partbuilder_oak_side", "partbuilder_oak_bottom", "partbuilder_spruce_top",
|
||||
"partbuilder_spruce_side", "partbuilder_spruce_bottom", "partbuilder_birch_top", "partbuilder_birch_side", "partbuilder_birch_bottom", "partbuilder_jungle_top",
|
||||
"partbuilder_jungle_side", "partbuilder_jungle_bottom", "patternchest_top", "patternchest_side", "patternchest_bottom", "stenciltable_oak_top", "stenciltable_oak_side",
|
||||
"stenciltable_oak_bottom", "stenciltable_spruce_top", "stenciltable_spruce_side", "stenciltable_spruce_bottom", "stenciltable_birch_top", "stenciltable_birch_side",
|
||||
"stenciltable_birch_bottom", "stenciltable_jungle_top", "stenciltable_jungle_side", "stenciltable_jungle_bottom" };
|
||||
|
||||
return textureNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon (int side, int meta)
|
||||
{
|
||||
if (meta <= 4)
|
||||
{
|
||||
return icons[meta * 3 + getTextureIndex(side)];
|
||||
}
|
||||
else if (meta <= 9)
|
||||
{
|
||||
return icons[15 + getTextureIndex(side)];
|
||||
}
|
||||
else
|
||||
{
|
||||
return icons[meta * 3 + getTextureIndex(side) - 12];
|
||||
}
|
||||
}
|
||||
|
||||
public int getTextureIndex (int side)
|
||||
{
|
||||
if (side == 0)
|
||||
return 2;
|
||||
if (side == 1)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSideSolid (IBlockAccess world, int x, int y, int z, ForgeDirection side)
|
||||
{
|
||||
return side == ForgeDirection.UP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType ()
|
||||
{
|
||||
return TableRender.tabelModelID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldSideBeRendered (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getSelectedBoundingBoxFromPool (World world, int x, int y, int z)
|
||||
{
|
||||
int metadata = world.getBlockMetadata(x, y, z);
|
||||
if (metadata == 5)
|
||||
return AxisAlignedBB.getAABBPool().getAABB((double) x + this.minX, (double) y + this.minY, (double) z + this.minZ, (double) x + this.maxX, (double) y + this.maxY - 0.125,
|
||||
(double) z + this.maxZ);
|
||||
return AxisAlignedBB.getAABBPool().getAABB((double) x + this.minX, (double) y + this.minY, (double) z + this.minZ, (double) x + this.maxX, (double) y + this.maxY, (double) z + this.maxZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity (World world, int metadata)
|
||||
{
|
||||
switch (metadata)
|
||||
{
|
||||
case 0:
|
||||
return new ToolStationLogic();
|
||||
case 1:
|
||||
return new PartBuilderLogic();
|
||||
case 2:
|
||||
return new PartBuilderLogic();
|
||||
case 3:
|
||||
return new PartBuilderLogic();
|
||||
case 4:
|
||||
return new PartBuilderLogic();
|
||||
case 5:
|
||||
return new PatternChestLogic();
|
||||
case 6:
|
||||
return new PatternChestLogic();
|
||||
case 7:
|
||||
return new PatternChestLogic();
|
||||
case 8:
|
||||
return new PatternChestLogic();
|
||||
case 9:
|
||||
return new PatternChestLogic();
|
||||
case 10:
|
||||
return new StencilTableLogic();
|
||||
case 11:
|
||||
return new StencilTableLogic();
|
||||
case 12:
|
||||
return new StencilTableLogic();
|
||||
case 13:
|
||||
return new StencilTableLogic();
|
||||
/*case 14:
|
||||
return new CastingTableLogic();*/
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer)
|
||||
{
|
||||
int md = world.getBlockMetadata(x, y, z);
|
||||
if (md == 0)
|
||||
return 0;
|
||||
else if (md < 5)
|
||||
return 1;
|
||||
else if (md < 10)
|
||||
return 2;
|
||||
else
|
||||
return 3;
|
||||
|
||||
//return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getModInstance ()
|
||||
{
|
||||
return TConstruct.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks (Item id, CreativeTabs tab, List list)
|
||||
{
|
||||
for (int iter = 0; iter < 6; iter++)
|
||||
{
|
||||
list.add(new ItemStack(id, 1, iter));
|
||||
}
|
||||
|
||||
for (int iter = 10; iter < 14; iter++)
|
||||
{
|
||||
list.add(new ItemStack(id, 1, iter));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy (World world, int x, int y, int z, EntityLivingBase par5EntityLiving, ItemStack par6ItemStack)
|
||||
{
|
||||
if (PHConstruct.freePatterns)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta == 5)
|
||||
{
|
||||
PatternChestLogic logic = (PatternChestLogic) world.getTileEntity(x, y, z);
|
||||
for (int i = 1; i <= 13; i++)
|
||||
{
|
||||
logic.setInventorySlotContents(i - 1, new ItemStack(TinkerTools.woodPattern, 1, i));
|
||||
}
|
||||
logic.setInventorySlotContents(13, new ItemStack(TinkerTools.woodPattern, 1, 22));
|
||||
}
|
||||
}
|
||||
super.onBlockPlacedBy(world, x, y, z, par5EntityLiving, par6ItemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTextureDomain (int textureNameIndex)
|
||||
{
|
||||
return "tinker";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,675 @@
|
||||
package tconstruct.tools.entity;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.crash.CrashReport;
|
||||
import net.minecraft.crash.CrashReportCategory;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.monster.EntityEnderman;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.projectile.EntityArrow;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.play.server.S2BPacketChangeGameState;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.ReportedException;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.common.network.ByteBufUtils;
|
||||
import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData;
|
||||
|
||||
public class ArrowEntity extends EntityArrow implements IEntityAdditionalSpawnData
|
||||
{
|
||||
public ItemStack returnStack;
|
||||
public float mass;
|
||||
public int baseDamage;
|
||||
private float knockbackStrengthMod;
|
||||
Random random = new Random();
|
||||
|
||||
public ArrowEntity(World par1World)
|
||||
{
|
||||
super(par1World);
|
||||
}
|
||||
|
||||
public ArrowEntity(World world, EntityLivingBase living, float baseSpeed, ItemStack stack)
|
||||
{
|
||||
super(world, living, baseSpeed);
|
||||
this.returnStack = stack;
|
||||
NBTTagCompound toolTag = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
this.mass = toolTag.getFloat("Mass");
|
||||
this.baseDamage = toolTag.getInteger("Attack");
|
||||
}
|
||||
|
||||
public ArrowEntity(World world, double x, double y, double z, ItemStack stack)
|
||||
{
|
||||
super(world, x, y, z);
|
||||
this.returnStack = stack;
|
||||
NBTTagCompound toolTag = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
this.mass = toolTag.getFloat("Mass");
|
||||
this.baseDamage = toolTag.getInteger("Attack");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCollideWithPlayer (EntityPlayer par1EntityPlayer)
|
||||
{
|
||||
if (!this.worldObj.isRemote && this.inGround && this.arrowShake <= 0)
|
||||
{
|
||||
boolean flag = this.canBePickedUp == 1 || this.canBePickedUp == 2 && par1EntityPlayer.capabilities.isCreativeMode;
|
||||
|
||||
if (this.canBePickedUp == 1 && !par1EntityPlayer.inventory.addItemStackToInventory(returnStack))
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
|
||||
if (flag)
|
||||
{
|
||||
this.playSound("random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
|
||||
par1EntityPlayer.onItemPickup(this, 1);
|
||||
this.setDead();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate ()
|
||||
{
|
||||
this.onEntityUpdate();
|
||||
if (returnStack == null || returnStack.stackSize < 1)
|
||||
{
|
||||
this.setDead();
|
||||
}
|
||||
|
||||
if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F)
|
||||
{
|
||||
float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
|
||||
this.prevRotationYaw = this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
|
||||
this.prevRotationPitch = this.rotationPitch = (float) (Math.atan2(this.motionY, (double) f) * 180.0D / Math.PI);
|
||||
}
|
||||
|
||||
Block i = this.worldObj.getBlock(this.field_145791_d, this.field_145792_e, this.field_145789_f);
|
||||
|
||||
i.setBlockBoundsBasedOnState(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f);
|
||||
AxisAlignedBB axisalignedbb = i.getCollisionBoundingBoxFromPool(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f);
|
||||
|
||||
if (axisalignedbb != null && axisalignedbb.isVecInside(this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ)))
|
||||
{
|
||||
this.inGround = true;
|
||||
}
|
||||
|
||||
if (this.arrowShake > 0)
|
||||
{
|
||||
--this.arrowShake;
|
||||
}
|
||||
|
||||
if (this.inGround)
|
||||
{
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
Block j = this.worldObj.getBlock(this.field_145791_d, this.field_145792_e, this.field_145789_f);
|
||||
int k = this.worldObj.getBlockMetadata(this.field_145791_d, this.field_145792_e, this.field_145789_f);
|
||||
|
||||
if (j == this.field_145790_g && k == this.inData)
|
||||
{
|
||||
++this.ticksInGround;
|
||||
|
||||
if (this.ticksInGround == 120000)
|
||||
{
|
||||
this.setDead();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.inGround = false;
|
||||
this.motionX *= (double) (this.rand.nextFloat() * 0.2F);
|
||||
this.motionY *= (double) (this.rand.nextFloat() * 0.2F);
|
||||
this.motionZ *= (double) (this.rand.nextFloat() * 0.2F);
|
||||
this.ticksInGround = 0;
|
||||
this.ticksInAir = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
++this.ticksInAir;
|
||||
Vec3 vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ);
|
||||
Vec3 vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
|
||||
MovingObjectPosition movingobjectposition = this.worldObj.func_147447_a(vec3, vec31, false, true, false);
|
||||
vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ);
|
||||
vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
|
||||
|
||||
if (movingobjectposition != null)
|
||||
{
|
||||
vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord);
|
||||
}
|
||||
|
||||
Entity entity = null;
|
||||
List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D));
|
||||
double d0 = 0.0D;
|
||||
int l;
|
||||
float ySpeed;
|
||||
|
||||
for (l = 0; l < list.size(); ++l)
|
||||
{
|
||||
Entity entity1 = (Entity) list.get(l);
|
||||
|
||||
if (entity1.canBeCollidedWith() && (entity1 != this.shootingEntity || this.ticksInAir >= 5))
|
||||
{
|
||||
ySpeed = 0.3F;
|
||||
AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand((double) ySpeed, (double) ySpeed, (double) ySpeed);
|
||||
MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept(vec3, vec31);
|
||||
|
||||
if (movingobjectposition1 != null)
|
||||
{
|
||||
double d1 = vec3.distanceTo(movingobjectposition1.hitVec);
|
||||
|
||||
if (d1 < d0 || d0 == 0.0D)
|
||||
{
|
||||
entity = entity1;
|
||||
d0 = d1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (entity != null)
|
||||
{
|
||||
movingobjectposition = new MovingObjectPosition(entity);
|
||||
}
|
||||
|
||||
if (movingobjectposition != null && movingobjectposition.entityHit != null && movingobjectposition.entityHit instanceof EntityPlayer)
|
||||
{
|
||||
EntityPlayer entityplayer = (EntityPlayer) movingobjectposition.entityHit;
|
||||
|
||||
if (entityplayer.capabilities.disableDamage || this.shootingEntity instanceof EntityPlayer && !((EntityPlayer) this.shootingEntity).canAttackPlayer(entityplayer))
|
||||
{
|
||||
movingobjectposition = null;
|
||||
}
|
||||
}
|
||||
|
||||
float speed;
|
||||
float f3;
|
||||
|
||||
if (movingobjectposition != null)
|
||||
{
|
||||
if (movingobjectposition.entityHit != null)
|
||||
{
|
||||
speed = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
|
||||
double damageSpeed = (double) speed * this.getDamage();
|
||||
damageSpeed *= baseDamage;
|
||||
damageSpeed /= 5D;
|
||||
int damageInflicted = MathHelper.ceiling_double_int(damageSpeed);
|
||||
|
||||
if (this.getIsCritical())
|
||||
{
|
||||
damageInflicted += this.rand.nextInt(damageInflicted / 2 + 2);
|
||||
}
|
||||
|
||||
DamageSource damagesource = null;
|
||||
|
||||
if (this.shootingEntity == null)
|
||||
{
|
||||
damagesource = DamageSource.causeArrowDamage(this, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
damagesource = DamageSource.causeArrowDamage(this, this.shootingEntity);
|
||||
}
|
||||
|
||||
if (this.isBurning() && !(movingobjectposition.entityHit instanceof EntityEnderman))
|
||||
{
|
||||
movingobjectposition.entityHit.setFire(5);
|
||||
}
|
||||
|
||||
if (returnStack.hasTagCompound())
|
||||
{
|
||||
int fireAspect = 0;
|
||||
NBTTagCompound toolTags = returnStack.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (toolTags.hasKey("Fiery") || toolTags.hasKey("Lava"))
|
||||
{
|
||||
fireAspect *= 4;
|
||||
if (toolTags.hasKey("Fiery"))
|
||||
{
|
||||
fireAspect += toolTags.getInteger("Fiery") / 5 + 1;
|
||||
}
|
||||
if (toolTags.getBoolean("Lava"))
|
||||
{
|
||||
fireAspect += 3;
|
||||
}
|
||||
entity.setFire(fireAspect);
|
||||
}
|
||||
|
||||
int drain = toolTags.getInteger("Necrotic") * 2;
|
||||
if (drain > 0 && shootingEntity != null && shootingEntity instanceof EntityLiving)
|
||||
((EntityLiving) shootingEntity).heal(random.nextInt(drain + 1));
|
||||
}
|
||||
|
||||
if (movingobjectposition.entityHit.attackEntityFrom(damagesource, damageInflicted))
|
||||
{
|
||||
if (movingobjectposition.entityHit instanceof EntityLivingBase)
|
||||
{
|
||||
EntityLivingBase entityliving = (EntityLivingBase) movingobjectposition.entityHit;
|
||||
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
entityliving.setArrowCountInEntity(entityliving.getArrowCountInEntity() + 1);
|
||||
}
|
||||
|
||||
if (this.knockbackStrength > 0 || this.knockbackStrengthMod > 0)
|
||||
{
|
||||
f3 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
|
||||
|
||||
if (f3 > 0.0F)
|
||||
{
|
||||
float knockback = knockbackStrength + knockbackStrengthMod;
|
||||
movingobjectposition.entityHit.addVelocity(this.motionX * (double) this.knockbackStrength * 0.6000000238418579D / (double) f3, 0.1D, this.motionZ
|
||||
* (double) knockback * 0.6000000238418579D / (double) f3);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.shootingEntity != null)
|
||||
{
|
||||
damagesource = DamageSource.causeArrowDamage(this, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
damagesource = DamageSource.causeArrowDamage(this, this.shootingEntity);
|
||||
}
|
||||
|
||||
if (this.shootingEntity != null && movingobjectposition.entityHit != this.shootingEntity && movingobjectposition.entityHit instanceof EntityPlayer
|
||||
&& this.shootingEntity instanceof EntityPlayerMP)
|
||||
{
|
||||
((EntityPlayerMP) this.shootingEntity).playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(6, 0));
|
||||
// TConstruct.packetPipeline.sendTo(new
|
||||
// S2BPacketChangeGameState(6, 0),
|
||||
// (EntityPlayerMP) this.shootingEntity);
|
||||
}
|
||||
}
|
||||
|
||||
this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
|
||||
|
||||
if (!(movingobjectposition.entityHit instanceof EntityEnderman))
|
||||
{
|
||||
this.motionX = 0;
|
||||
this.motionZ = 0;
|
||||
if (movingobjectposition.entityHit instanceof EntityPlayer)
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer) movingobjectposition.entityHit;
|
||||
if (canBePickedUp == 2 || player.inventory.addItemStackToInventory(returnStack))
|
||||
this.setDead();
|
||||
}
|
||||
else if (movingobjectposition.entityHit instanceof EntityLivingBase)
|
||||
{
|
||||
EntityLivingBase living = (EntityLivingBase) movingobjectposition.entityHit;
|
||||
if (canBePickedUp == 2 || addItemStackToInventory(returnStack, living))
|
||||
this.setDead();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.motionX *= -0.10000000149011612D;
|
||||
this.motionY *= -0.10000000149011612D;
|
||||
this.motionZ *= -0.10000000149011612D;
|
||||
this.rotationYaw += 180.0F;
|
||||
this.prevRotationYaw += 180.0F;
|
||||
this.ticksInAir = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.field_145791_d = movingobjectposition.blockX;
|
||||
this.field_145792_e = movingobjectposition.blockY;
|
||||
this.field_145789_f = movingobjectposition.blockZ;
|
||||
this.field_145790_g = this.worldObj.getBlock(this.field_145791_d, this.field_145792_e, this.field_145789_f);
|
||||
this.inData = this.worldObj.getBlockMetadata(this.field_145791_d, this.field_145792_e, this.field_145789_f);
|
||||
this.motionX = (double) ((float) (movingobjectposition.hitVec.xCoord - this.posX));
|
||||
this.motionY = (double) ((float) (movingobjectposition.hitVec.yCoord - this.posY));
|
||||
this.motionZ = (double) ((float) (movingobjectposition.hitVec.zCoord - this.posZ));
|
||||
speed = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
|
||||
this.posX -= this.motionX / (double) speed * 0.05000000074505806D;
|
||||
this.posY -= this.motionY / (double) speed * 0.05000000074505806D;
|
||||
this.posZ -= this.motionZ / (double) speed * 0.05000000074505806D;
|
||||
this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
|
||||
this.inGround = true;
|
||||
this.arrowShake = 0;
|
||||
this.setIsCritical(false);
|
||||
|
||||
if (this.field_145790_g != Blocks.air)
|
||||
{
|
||||
this.field_145790_g.onEntityCollidedWithBlock(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.getIsCritical())
|
||||
{
|
||||
for (l = 0; l < 4; ++l)
|
||||
{
|
||||
this.worldObj.spawnParticle("crit", this.posX + this.motionX * (double) l / 4.0D, this.posY + this.motionY * (double) l / 4.0D, this.posZ + this.motionZ * (double) l / 4.0D,
|
||||
-this.motionX, -this.motionY + 0.2D, -this.motionZ);
|
||||
}
|
||||
}
|
||||
|
||||
this.posX += this.motionX;
|
||||
this.posY += this.motionY;
|
||||
this.posZ += this.motionZ;
|
||||
speed = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
|
||||
this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
|
||||
|
||||
for (this.rotationPitch = (float) (Math.atan2(this.motionY, (double) speed) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
while (this.rotationPitch - this.prevRotationPitch >= 180.0F)
|
||||
{
|
||||
this.prevRotationPitch += 360.0F;
|
||||
}
|
||||
|
||||
while (this.rotationYaw - this.prevRotationYaw < -180.0F)
|
||||
{
|
||||
this.prevRotationYaw -= 360.0F;
|
||||
}
|
||||
|
||||
while (this.rotationYaw - this.prevRotationYaw >= 180.0F)
|
||||
{
|
||||
this.prevRotationYaw += 360.0F;
|
||||
}
|
||||
|
||||
this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F;
|
||||
this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;
|
||||
float dropSpeed = 0.99F;
|
||||
float speedMod = 1.05f + (mass / 1.26F) / 6F;
|
||||
ySpeed = 0.05F * speedMod;
|
||||
|
||||
if (this.isInWater())
|
||||
{
|
||||
for (int j1 = 0; j1 < 4; ++j1)
|
||||
{
|
||||
f3 = 0.25F;
|
||||
this.worldObj.spawnParticle("bubble", this.posX - this.motionX * (double) f3, this.posY - this.motionY * (double) f3, this.posZ - this.motionZ * (double) f3, this.motionX,
|
||||
this.motionY, this.motionZ);
|
||||
}
|
||||
|
||||
dropSpeed = 0.8F;
|
||||
}
|
||||
|
||||
this.motionX *= (double) dropSpeed;
|
||||
this.motionY *= (double) dropSpeed;
|
||||
this.motionZ *= (double) dropSpeed;
|
||||
this.motionY -= (double) ySpeed;
|
||||
this.setPosition(this.posX, this.posY, this.posZ);
|
||||
this.func_145775_I();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean addItemStackToInventory (ItemStack par1ItemStack, EntityLivingBase living)
|
||||
{
|
||||
if (par1ItemStack == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
int stackSize;
|
||||
|
||||
/*
|
||||
* if (par1ItemStack.isItemDamaged()) { slotID =
|
||||
* this.getFirstEmptyStack(living);
|
||||
*
|
||||
* if (slotID >= 0) { living.setCurrentItemOrArmor(slotID,
|
||||
* par1ItemStack); living.setEquipmentDropChance(slotID, 2.0f);
|
||||
* par1ItemStack.stackSize = 0; return true; } else { return
|
||||
* false; } } else
|
||||
*/
|
||||
{
|
||||
do
|
||||
{
|
||||
stackSize = par1ItemStack.stackSize;
|
||||
par1ItemStack.stackSize = this.storePartialItemStack(par1ItemStack, living);
|
||||
} while (par1ItemStack.stackSize > 0 && par1ItemStack.stackSize < stackSize);
|
||||
|
||||
return par1ItemStack.stackSize < stackSize;
|
||||
}
|
||||
}
|
||||
catch (Throwable throwable)
|
||||
{
|
||||
CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Adding item to inventory");
|
||||
CrashReportCategory crashreportcategory = crashreport.makeCategory("Item being added");
|
||||
// TODO is this needed???
|
||||
// crashreportcategory.addCrashSection("Item ID",
|
||||
// Integer.valueOf(par1ItemStack.itemID));
|
||||
crashreportcategory.addCrashSection("Item data", Integer.valueOf(par1ItemStack.getItemDamage()));
|
||||
// crashreportcategory.addCrashSectionCallable("Item name", new
|
||||
// CallableItemName(this, par1ItemStack));
|
||||
throw new ReportedException(crashreport);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getFirstEmptyStack (EntityLivingBase living)
|
||||
{
|
||||
for (int i = 0; i < 5; ++i)
|
||||
{
|
||||
if (living.getEquipmentInSlot(i) == null)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
private int storePartialItemStack (ItemStack par1ItemStack, EntityLivingBase living)
|
||||
{
|
||||
Item i = par1ItemStack.getItem();
|
||||
int j = par1ItemStack.stackSize;
|
||||
int slotID;
|
||||
|
||||
if (par1ItemStack.getMaxStackSize() == 1)
|
||||
{
|
||||
slotID = this.getFirstEmptyStack(living);
|
||||
|
||||
if (slotID < 0)
|
||||
{
|
||||
return j;
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* if (this.mainInventory[k] == null) { this.mainInventory[k] =
|
||||
* par1ItemStack; }
|
||||
*/
|
||||
if (living.getEquipmentInSlot(slotID) == null)
|
||||
{
|
||||
living.setCurrentItemOrArmor(slotID, par1ItemStack);
|
||||
if (living instanceof EntityLiving)
|
||||
((EntityLiving) living).setEquipmentDropChance(slotID, 2.0f);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
slotID = this.storeItemStack(par1ItemStack, living);
|
||||
|
||||
if (slotID < 0)
|
||||
{
|
||||
slotID = this.getFirstEmptyStack(living);
|
||||
}
|
||||
|
||||
if (slotID < 0)
|
||||
{
|
||||
return j;
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemStack stack = living.getEquipmentInSlot(slotID);
|
||||
if (stack == null)
|
||||
{
|
||||
living.setCurrentItemOrArmor(slotID, par1ItemStack);
|
||||
if (living instanceof EntityLiving)
|
||||
((EntityLiving) living).setEquipmentDropChance(slotID, 2.0f);
|
||||
return par1ItemStack.stackSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
int l = j;
|
||||
|
||||
if (j > stack.getMaxStackSize() - stack.stackSize)
|
||||
{
|
||||
l = stack.getMaxStackSize() - stack.stackSize;
|
||||
}
|
||||
|
||||
if (l > 64 - stack.stackSize)
|
||||
{
|
||||
l = 64 - stack.stackSize;
|
||||
}
|
||||
|
||||
if (l == 0)
|
||||
{
|
||||
return j;
|
||||
}
|
||||
else
|
||||
{
|
||||
j -= l;
|
||||
stack.stackSize++;
|
||||
living.setCurrentItemOrArmor(slotID, stack);
|
||||
if (living instanceof EntityLiving)
|
||||
((EntityLiving) living).setEquipmentDropChance(slotID, 2.0f);
|
||||
return j;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int storeItemStack (ItemStack par1ItemStack, EntityLivingBase living)
|
||||
{
|
||||
for (int slotID = 0; slotID < 5; ++slotID)
|
||||
{
|
||||
ItemStack stack = living.getEquipmentInSlot(slotID);
|
||||
if (stack != null && ItemStack.areItemStacksEqual(stack, par1ItemStack) && stack.isStackable() && stack.stackSize < stack.getMaxStackSize())
|
||||
{
|
||||
return slotID;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void setKnockbackModStrength (float par1)
|
||||
{
|
||||
this.knockbackStrengthMod = par1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeEntityToNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.writeEntityToNBT(tags);
|
||||
tags.setTag("Throwable", this.returnStack.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readEntityFromNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.readEntityFromNBT(tags);
|
||||
this.returnStack = ItemStack.loadItemStackFromNBT(tags.getCompoundTag("Throwable"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSpawnData (ByteBuf data)
|
||||
{
|
||||
if (!returnStack.hasTagCompound())
|
||||
this.kill();
|
||||
NBTTagCompound tags = returnStack.getTagCompound().getCompoundTag("InfiTool");
|
||||
ByteBufUtils.writeItemStack(data, returnStack);
|
||||
data.writeFloat(rotationYaw);
|
||||
data.writeFloat(mass);
|
||||
data.writeInt(tags.getInteger("RenderHandle"));
|
||||
data.writeInt(tags.getInteger("RenderHead"));
|
||||
data.writeInt(tags.getInteger("RenderAccessory"));
|
||||
|
||||
int effects = 0;
|
||||
if (tags.hasKey("Effect1"))
|
||||
effects++;
|
||||
if (tags.hasKey("Effect2"))
|
||||
effects++;
|
||||
if (tags.hasKey("Effect3"))
|
||||
effects++;
|
||||
if (tags.hasKey("Effect4"))
|
||||
effects++;
|
||||
if (tags.hasKey("Effect5"))
|
||||
effects++;
|
||||
if (tags.hasKey("Effect6"))
|
||||
effects++;
|
||||
data.writeInt(effects);
|
||||
|
||||
switch (effects)
|
||||
{
|
||||
case 6:
|
||||
data.writeInt(tags.getInteger("Effect6"));
|
||||
case 5:
|
||||
data.writeInt(tags.getInteger("Effect5"));
|
||||
case 4:
|
||||
data.writeInt(tags.getInteger("Effect4"));
|
||||
case 3:
|
||||
data.writeInt(tags.getInteger("Effect3"));
|
||||
case 2:
|
||||
data.writeInt(tags.getInteger("Effect2"));
|
||||
case 1:
|
||||
data.writeInt(tags.getInteger("Effect1"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSpawnData (ByteBuf data)
|
||||
{
|
||||
returnStack = ByteBufUtils.readItemStack(data);
|
||||
rotationYaw = data.readFloat();
|
||||
mass = data.readFloat();
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
NBTTagCompound toolTag = new NBTTagCompound();
|
||||
toolTag.setInteger("RenderHandle", data.readInt());
|
||||
toolTag.setInteger("RenderHead", data.readInt());
|
||||
toolTag.setInteger("RenderAccessory", data.readInt());
|
||||
switch (data.readInt())
|
||||
{
|
||||
case 6:
|
||||
toolTag.setInteger("Effect6", data.readInt());
|
||||
case 5:
|
||||
toolTag.setInteger("Effect5", data.readInt());
|
||||
case 4:
|
||||
toolTag.setInteger("Effect4", data.readInt());
|
||||
case 3:
|
||||
toolTag.setInteger("Effect3", data.readInt());
|
||||
case 2:
|
||||
toolTag.setInteger("Effect2", data.readInt());
|
||||
case 1:
|
||||
toolTag.setInteger("Effect1", data.readInt());
|
||||
}
|
||||
compound.setTag("InfiTool", toolTag);
|
||||
returnStack.setTagCompound(compound);
|
||||
}
|
||||
|
||||
public ItemStack getEntityItem ()
|
||||
{
|
||||
return returnStack;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package tconstruct.tools.entity;
|
||||
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.items.tools.Dagger;
|
||||
import tconstruct.library.tools.AbilityHelper;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
|
||||
public class DaggerEntity extends RotatingBase
|
||||
{
|
||||
|
||||
public DaggerEntity(World world)
|
||||
{
|
||||
super(world);
|
||||
}
|
||||
|
||||
public DaggerEntity(ItemStack itemstack, World world, EntityPlayer entityplayer)
|
||||
{
|
||||
super(world, entityplayer, 0.75F, 0.8F);
|
||||
// TConstruct.logger.info("Stack: "+itemstack);
|
||||
returnStackSlot = entityplayer.inventory.currentItem;
|
||||
returnStack = itemstack;
|
||||
}
|
||||
|
||||
public DaggerEntity(World world, EntityPlayer entityplayer, float f, float g)
|
||||
{
|
||||
super(world, entityplayer, f, g);
|
||||
}
|
||||
|
||||
/*
|
||||
* public void entityInit () { super.entityInit(); }
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void onHit (MovingObjectPosition movingobjectposition)
|
||||
{
|
||||
if (movingobjectposition.entityHit != null)
|
||||
{
|
||||
if (movingobjectposition.entityHit.attackEntityFrom(DamageSource.causeMobDamage(owner), damageDealt))
|
||||
{
|
||||
worldObj.playSoundAtEntity(this, "random.drr", 1.0F, 1.2F / (rand.nextFloat() * 0.2F + 0.9F));
|
||||
motionX *= -0.1D;
|
||||
motionY *= -0.1D;
|
||||
motionZ *= -0.1D;
|
||||
rotationYaw += 180F;
|
||||
prevRotationYaw += 180F;
|
||||
ticksInAir = 0;
|
||||
if (movingobjectposition.entityHit instanceof EntityLiving)
|
||||
{
|
||||
Dagger dagger = (Dagger) returnStack.getItem();
|
||||
this.hitEntity(returnStack, (EntityLiving) movingobjectposition.entityHit, owner, dagger);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
onGround = true;
|
||||
xTile = movingobjectposition.blockX;
|
||||
yTile = movingobjectposition.blockY;
|
||||
zTile = movingobjectposition.blockZ;
|
||||
inTile = worldObj.getBlock(xTile, yTile, zTile);
|
||||
motionX = (float) (movingobjectposition.hitVec.xCoord - posX);
|
||||
motionY = (float) (movingobjectposition.hitVec.yCoord - posY);
|
||||
motionZ = (float) (movingobjectposition.hitVec.zCoord - posZ);
|
||||
float f = MathHelper.sqrt_double(motionX * motionX + motionY * motionY + motionZ * motionZ);
|
||||
posX -= (motionX / (double) f) * 0.05D;
|
||||
posY -= (motionY / (double) f) * 0.05D;
|
||||
posZ -= (motionZ / (double) f) * 0.05D;
|
||||
worldObj.playSoundAtEntity(this, "random.drr", 1.0F, 1.2F / (rand.nextFloat() * 0.2F + 0.9F));
|
||||
arrowShake = 7;
|
||||
if (!worldObj.isRemote)
|
||||
AbilityHelper.damageTool(returnStack, 1, owner, false);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hitEntity (ItemStack stack, EntityLiving mob, EntityPlayer player, ToolCore weapon)
|
||||
{
|
||||
if (!worldObj.isRemote && player.canAttackWithItem())
|
||||
{
|
||||
AbilityHelper.onLeftClickEntity(stack, player, mob, weapon);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dealFireDamage (int i)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package tconstruct.tools.entity;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class FancyEntityItem extends EntityItem
|
||||
{
|
||||
public FancyEntityItem(World par1World, double par2, double par4, double par6)
|
||||
{
|
||||
super(par1World, par2, par4, par6);
|
||||
this.isImmuneToFire = true;
|
||||
this.lifespan = 72000;
|
||||
}
|
||||
|
||||
public FancyEntityItem(World par1World, double par2, double par4, double par6, ItemStack par8ItemStack)
|
||||
{
|
||||
this(par1World, par2, par4, par6);
|
||||
this.setEntityItemStack(par8ItemStack);
|
||||
this.lifespan = (par8ItemStack.getItem() == null ? 6000 : par8ItemStack.getItem().getEntityLifespan(par8ItemStack, par1World));
|
||||
}
|
||||
|
||||
public FancyEntityItem(World par1World)
|
||||
{
|
||||
super(par1World);
|
||||
this.isImmuneToFire = true;
|
||||
this.lifespan = 72000;
|
||||
}
|
||||
|
||||
public FancyEntityItem(World world, Entity original, ItemStack stack)
|
||||
{
|
||||
this(world, original.posX, original.posY, original.posZ);
|
||||
this.delayBeforeCanPickup = 20;
|
||||
this.motionX = original.motionX;
|
||||
this.motionY = original.motionY;
|
||||
this.motionZ = original.motionZ;
|
||||
this.setEntityItemStack(stack);
|
||||
}
|
||||
|
||||
public boolean attackEntityFrom (DamageSource par1DamageSource, float par2)
|
||||
{
|
||||
if (par1DamageSource.getDamageType().equals("outOfWorld"))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,199 @@
|
||||
package tconstruct.tools.entity;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.projectile.EntityThrowable;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class LaunchedPotion extends EntityThrowable
|
||||
{
|
||||
/**
|
||||
* The damage value of the thrown potion that this EntityPotion represents.
|
||||
*/
|
||||
private ItemStack potionDamage;
|
||||
|
||||
public LaunchedPotion(World par1World)
|
||||
{
|
||||
super(par1World);
|
||||
}
|
||||
|
||||
public LaunchedPotion(World par1World, EntityLivingBase par2EntityLiving, int par3)
|
||||
{
|
||||
this(par1World, par2EntityLiving, new ItemStack(Items.potionitem, 1, par3));
|
||||
}
|
||||
|
||||
public LaunchedPotion(World par1World, EntityLivingBase par2EntityLiving, ItemStack par3ItemStack)
|
||||
{
|
||||
super(par1World, par2EntityLiving);
|
||||
this.potionDamage = par3ItemStack;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public LaunchedPotion(World par1World, double par2, double par4, double par6, int par8)
|
||||
{
|
||||
this(par1World, par2, par4, par6, new ItemStack(Items.potionitem, 1, par8));
|
||||
}
|
||||
|
||||
public LaunchedPotion(World par1World, double par2, double par4, double par6, ItemStack par8ItemStack)
|
||||
{
|
||||
super(par1World, par2, par4, par6);
|
||||
this.potionDamage = par8ItemStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the amount of gravity to apply to the thrown entity with each tick.
|
||||
*/
|
||||
@Override
|
||||
protected float getGravityVelocity ()
|
||||
{
|
||||
return 0.05F;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float func_70182_d ()
|
||||
{
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float func_70183_g ()
|
||||
{
|
||||
return -10.0F;
|
||||
}
|
||||
|
||||
public void setPotionDamage (int par1)
|
||||
{
|
||||
if (this.potionDamage == null)
|
||||
{
|
||||
this.potionDamage = new ItemStack(Items.potionitem, 1, 0);
|
||||
}
|
||||
|
||||
this.potionDamage.setItemDamage(par1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the damage value of the thrown potion that this EntityPotion
|
||||
* represents.
|
||||
*/
|
||||
public int getPotionDamage ()
|
||||
{
|
||||
if (this.potionDamage == null)
|
||||
{
|
||||
this.potionDamage = new ItemStack(Items.potionitem, 1, 0);
|
||||
}
|
||||
|
||||
return this.potionDamage.getItemDamage();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when this EntityThrowable hits a block or entity.
|
||||
*/
|
||||
@Override
|
||||
protected void onImpact (MovingObjectPosition par1MovingObjectPosition)
|
||||
{
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
List list = Items.potionitem.getEffects(this.potionDamage);
|
||||
|
||||
if (list != null && !list.isEmpty())
|
||||
{
|
||||
AxisAlignedBB axisalignedbb = this.boundingBox.expand(4.0D, 2.0D, 4.0D);
|
||||
List list1 = this.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb);
|
||||
|
||||
if (list1 != null && !list1.isEmpty())
|
||||
{
|
||||
Iterator iterator = list1.iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
EntityLivingBase entityliving = (EntityLivingBase) iterator.next();
|
||||
double d0 = this.getDistanceSqToEntity(entityliving);
|
||||
|
||||
if (d0 < 16.0D)
|
||||
{
|
||||
double d1 = 1.0D - Math.sqrt(d0) / 4.0D;
|
||||
|
||||
if (entityliving == par1MovingObjectPosition.entityHit)
|
||||
{
|
||||
d1 = 1.0D;
|
||||
}
|
||||
|
||||
Iterator iterator1 = list.iterator();
|
||||
|
||||
while (iterator1.hasNext())
|
||||
{
|
||||
PotionEffect potioneffect = (PotionEffect) iterator1.next();
|
||||
int i = potioneffect.getPotionID();
|
||||
|
||||
if (Potion.potionTypes[i].isInstant())
|
||||
{
|
||||
Potion.potionTypes[i].affectEntity(this.getThrower(), entityliving, potioneffect.getAmplifier(), d1);
|
||||
}
|
||||
else
|
||||
{
|
||||
int j = (int) (d1 * (double) potioneffect.getDuration() + 0.5D);
|
||||
|
||||
if (j > 20)
|
||||
{
|
||||
entityliving.addPotionEffect(new PotionEffect(i, j, potioneffect.getAmplifier()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.worldObj.playAuxSFX(2002, (int) Math.round(this.posX), (int) Math.round(this.posY), (int) Math.round(this.posZ), this.getPotionDamage());
|
||||
this.setDead();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* (abstract) Protected helper method to read subclass entity data from NBT.
|
||||
*/
|
||||
@Override
|
||||
public void readEntityFromNBT (NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
super.readEntityFromNBT(par1NBTTagCompound);
|
||||
|
||||
if (par1NBTTagCompound.hasKey("Potion"))
|
||||
{
|
||||
this.potionDamage = ItemStack.loadItemStackFromNBT(par1NBTTagCompound.getCompoundTag("Potion"));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setPotionDamage(par1NBTTagCompound.getInteger("potionValue"));
|
||||
}
|
||||
|
||||
if (this.potionDamage == null)
|
||||
{
|
||||
this.setDead();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* (abstract) Protected helper method to write subclass entity data to NBT.
|
||||
*/
|
||||
@Override
|
||||
public void writeEntityToNBT (NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
super.writeEntityToNBT(par1NBTTagCompound);
|
||||
|
||||
if (this.potionDamage != null)
|
||||
{
|
||||
par1NBTTagCompound.setTag("Potion", this.potionDamage.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,467 @@
|
||||
package tconstruct.tools.entity;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.library.tools.AbilityHelper;
|
||||
import cpw.mods.fml.common.network.ByteBufUtils;
|
||||
import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData;
|
||||
|
||||
public class RotatingBase extends Entity implements IEntityAdditionalSpawnData
|
||||
{
|
||||
|
||||
public RotatingBase(World world)
|
||||
{
|
||||
super(world);
|
||||
texID = 0;
|
||||
tex2ID = 16 * 3;
|
||||
returnStackSlot = -1;
|
||||
hasHitGround = false;
|
||||
hasHitMob = false;
|
||||
damageDealt = 4;
|
||||
maxGroundTicks = 2400;
|
||||
xTile = -1;
|
||||
yTile = -1;
|
||||
zTile = -1;
|
||||
inTile = Blocks.air;
|
||||
onGround = false;
|
||||
arrowShake = 0;
|
||||
ticksInAir = 0;
|
||||
setSize(0.5F, 0.5F);
|
||||
}
|
||||
|
||||
public RotatingBase(World world, double d, double d1, double d2)
|
||||
{
|
||||
this(world);
|
||||
setPosition(d, d1, d2);
|
||||
yOffset = 0.0F;
|
||||
}
|
||||
|
||||
public RotatingBase(World world, EntityPlayer entityliving, float f, float f1)
|
||||
{
|
||||
this(world);
|
||||
owner = entityliving;
|
||||
setLocationAndAngles(entityliving.posX, entityliving.posY + (double) entityliving.getEyeHeight(), entityliving.posZ, entityliving.rotationYaw, entityliving.rotationPitch);
|
||||
posX -= MathHelper.cos((rotationYaw / 180F) * 3.141593F) * 0.16F;
|
||||
posY -= 0.10000000149011612D;
|
||||
posZ -= MathHelper.sin((rotationYaw / 180F) * 3.141593F) * 0.16F;
|
||||
setPosition(posX, posY, posZ);
|
||||
yOffset = 0.0F;
|
||||
motionX = -MathHelper.sin((rotationYaw / 180F) * 3.141593F) * MathHelper.cos((rotationPitch / 180F) * 3.141593F);
|
||||
motionZ = MathHelper.cos((rotationYaw / 180F) * 3.141593F) * MathHelper.cos((rotationPitch / 180F) * 3.141593F);
|
||||
motionY = -MathHelper.sin((rotationPitch / 180F) * 3.141593F - 0.2f);
|
||||
setArrowHeading(motionX, motionY, motionZ, f, f1);
|
||||
}
|
||||
|
||||
/*
|
||||
* public void setOnGround(boolean flag) { onGround = flag;
|
||||
* this.dataWatcher.updateObject(6, Byte.valueOf((byte) (flag == true ? 1 :
|
||||
* 0))); }
|
||||
*
|
||||
* public boolean getOnGround() { return
|
||||
* this.dataWatcher.getWatchableObjectByte(0) == 1 ? true : false; }
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected void entityInit ()
|
||||
{
|
||||
}
|
||||
|
||||
public void damageItem (int i, boolean flag)
|
||||
{
|
||||
if (!flag)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (returnStack.stackSize < 1)
|
||||
{
|
||||
for (int j = 0; j < 8; j++)
|
||||
{
|
||||
worldObj.spawnParticle("snowballpoof", posX, posY, posZ, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
|
||||
// kill();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* public void returnToPlayer() { damageDagger(0, true);
|
||||
* if(returnStack.stackSize < 1) { return; } if(returnStackSlot > 0) {
|
||||
* mod_Infi2x2.forceAddToInv((EntityPlayer)returnsTo, returnStack,
|
||||
* returnStackSlot, true); } else {
|
||||
* mod_Infi2x2.addToInv((EntityPlayer)returnsTo, returnStack, true); } }
|
||||
*/
|
||||
|
||||
public void determineRotation ()
|
||||
{
|
||||
rotationPitch = -57.29578F * (float) Math.atan2(motionY, motionX);
|
||||
double d = Math.sqrt((double) (rotationYaw * rotationYaw) + motionY * motionY);
|
||||
prevRotationYaw = -57.29578F * (float) Math.atan2(motionZ, d);
|
||||
}
|
||||
|
||||
public void onHit (MovingObjectPosition movingobjectposition)
|
||||
{
|
||||
}
|
||||
|
||||
public void setArrowHeading (double d, double d1, double d2, float f, float f1)
|
||||
{
|
||||
float f2 = MathHelper.sqrt_double(d * d + d1 * d1 + d2 * d2);
|
||||
d /= f2;
|
||||
d1 /= f2;
|
||||
d2 /= f2;
|
||||
d += rand.nextGaussian() * 0.0074999998323619366D * (double) f1;
|
||||
d1 += rand.nextGaussian() * 0.0074999998323619366D * (double) f1;
|
||||
d2 += rand.nextGaussian() * 0.0074999998323619366D * (double) f1;
|
||||
d *= f;
|
||||
d1 *= f;
|
||||
d2 *= f;
|
||||
motionX = d;
|
||||
motionY = d1;
|
||||
motionZ = d2;
|
||||
float f3 = MathHelper.sqrt_double(d * d + d2 * d2);
|
||||
prevRotationYaw = rotationYaw = (float) ((Math.atan2(d, d2) * 180D) / 3.1415927410125732D);
|
||||
prevRotationPitch = rotationPitch = (float) ((Math.atan2(d1, f3) * 180D) / 3.1415927410125732D);
|
||||
ticksInGround = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVelocity (double d, double d1, double d2)
|
||||
{
|
||||
motionX = d;
|
||||
motionY = d1;
|
||||
motionZ = d2;
|
||||
if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F)
|
||||
{
|
||||
float f = MathHelper.sqrt_double(d * d + d2 * d2);
|
||||
prevRotationYaw = rotationYaw = (float) ((Math.atan2(d, d2) * 180D) / 3.1415927410125732D);
|
||||
prevRotationPitch = rotationPitch = (float) ((Math.atan2(d1, f) * 180D) / 3.1415927410125732D);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate ()
|
||||
{
|
||||
super.onUpdate();
|
||||
if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F)
|
||||
{
|
||||
float f = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
|
||||
prevRotationYaw = rotationYaw = (float) ((Math.atan2(motionX, motionZ) * 180D) / Math.PI);
|
||||
prevRotationPitch = rotationPitch = (float) ((Math.atan2(motionY, f) * 180D) / Math.PI);
|
||||
}
|
||||
if (arrowShake > 0)
|
||||
{
|
||||
arrowShake--;
|
||||
}
|
||||
if (onGround)
|
||||
{
|
||||
Block i = worldObj.getBlock(xTile, yTile, zTile);
|
||||
if (i != inTile)
|
||||
{
|
||||
onGround = false;
|
||||
motionX *= rand.nextFloat() * 0.2F;
|
||||
motionY *= rand.nextFloat() * 0.2F;
|
||||
motionZ *= rand.nextFloat() * 0.2F;
|
||||
ticksInGround = 0;
|
||||
ticksInAir = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* this.motionX = 0; this.motionY = 0; this.motionZ = 0;
|
||||
*/
|
||||
/*
|
||||
* ticksInGround++; if (ticksInGround == 1200) { setDead(); } if
|
||||
* (ticksInGround == maxGroundTicks) { setDead(); }
|
||||
*/
|
||||
if (!hasHitGround)
|
||||
{
|
||||
hasHitGround = true;
|
||||
damageItem(1, true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
ticksInAir++;
|
||||
}
|
||||
Vec3 vec3d = Vec3.createVectorHelper(posX, posY, posZ);
|
||||
Vec3 vec3d1 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ);
|
||||
MovingObjectPosition movingobjectposition = worldObj.rayTraceBlocks(vec3d, vec3d1);
|
||||
vec3d = Vec3.createVectorHelper(posX, posY, posZ);
|
||||
vec3d1 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ);
|
||||
if (movingobjectposition != null)
|
||||
{
|
||||
vec3d1 = Vec3.createVectorHelper(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord);
|
||||
}
|
||||
Entity entity = null;
|
||||
List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D));
|
||||
double d = 0.0D;
|
||||
for (int j = 0; j < list.size(); j++)
|
||||
{
|
||||
Entity entity1 = (Entity) list.get(j);
|
||||
if (!entity1.canBeCollidedWith() || entity1 == owner && ticksInAir < 5)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
float f3 = 0.3F;
|
||||
AxisAlignedBB axisalignedbb = entity1.boundingBox.expand(f3, f3, f3);
|
||||
MovingObjectPosition movingobjectposition2 = axisalignedbb.calculateIntercept(vec3d, vec3d1);
|
||||
if (movingobjectposition2 == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
double d1 = vec3d.distanceTo(movingobjectposition2.hitVec);
|
||||
if (d1 < d || d == 0.0D)
|
||||
{
|
||||
entity = entity1;
|
||||
d = d1;
|
||||
}
|
||||
}
|
||||
|
||||
if (entity != null)
|
||||
{
|
||||
MovingObjectPosition movingobjectposition1 = new MovingObjectPosition(entity);
|
||||
onHit(movingobjectposition1);
|
||||
}
|
||||
if (movingobjectposition != null)
|
||||
{
|
||||
onHit(movingobjectposition);
|
||||
}
|
||||
posX += motionX;
|
||||
posY += motionY;
|
||||
posZ += motionZ;
|
||||
float f1 = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
|
||||
rotationYaw = (float) ((Math.atan2(motionX, motionZ) * 180D) / 3.1415927410125732D);
|
||||
for (rotationPitch = (float) ((Math.atan2(motionY, f1) * 180D) / 3.1415927410125732D); rotationPitch - prevRotationPitch < -180F; prevRotationPitch -= 360F)
|
||||
{
|
||||
}
|
||||
for (; rotationPitch - prevRotationPitch >= 180F; prevRotationPitch += 360F)
|
||||
{
|
||||
}
|
||||
for (; rotationYaw - prevRotationYaw < -180F; prevRotationYaw -= 360F)
|
||||
{
|
||||
}
|
||||
for (; rotationYaw - prevRotationYaw >= 180F; prevRotationYaw += 360F)
|
||||
{
|
||||
}
|
||||
rotationPitch = prevRotationPitch + (rotationPitch - prevRotationPitch) * 0.2F;
|
||||
rotationYaw = prevRotationYaw + (rotationYaw - prevRotationYaw) * 0.2F;
|
||||
float f2 = 0.99F;
|
||||
float f4 = 0.03F;
|
||||
if (isInWater())
|
||||
{
|
||||
for (int k = 0; k < 4; k++)
|
||||
{
|
||||
float f5 = 0.25F;
|
||||
worldObj.spawnParticle("bubble", posX - motionX * (double) f5, posY - motionY * (double) f5, posZ - motionZ * (double) f5, motionX, motionY, motionZ);
|
||||
}
|
||||
|
||||
f2 = 0.8F;
|
||||
}
|
||||
motionX *= f2;
|
||||
motionY *= f2;
|
||||
motionZ *= f2;
|
||||
motionY -= f4;
|
||||
setPosition(posX, posY, posZ);
|
||||
if (!onGround)
|
||||
{
|
||||
prevBoomerangRotation = boomerangRotation;
|
||||
for (boomerangRotation += 36F; boomerangRotation > 360F; boomerangRotation -= 360F)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) {
|
||||
* super.readEntityFromNBT(par1NBTTagCompound);
|
||||
*
|
||||
* if (par1NBTTagCompound.hasKey("Potion")) { this.potionDamage =
|
||||
* ItemStack.loadItemStackFromNBT
|
||||
* (par1NBTTagCompound.getCompoundTag("Potion")); } else {
|
||||
* this.setPotionDamage(par1NBTTagCompound.getInteger("potionValue")); }
|
||||
*
|
||||
* if (this.potionDamage == null) { this.setDead(); } }
|
||||
*
|
||||
* public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) {
|
||||
* super.writeEntityToNBT(par1NBTTagCompound);
|
||||
*
|
||||
* if (this.potionDamage != null) {
|
||||
*
|
||||
* } }
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void writeEntityToNBT (NBTTagCompound tags)
|
||||
{
|
||||
tags.setTag("Throwable", this.returnStack.writeToNBT(new NBTTagCompound()));
|
||||
tags.setShort("xTile", (short) xTile);
|
||||
tags.setShort("yTile", (short) yTile);
|
||||
tags.setShort("zTile", (short) zTile);
|
||||
tags.setString("inTile", (String) inTile.getUnlocalizedName());
|
||||
tags.setByte("shake", (byte) arrowShake);
|
||||
tags.setByte("onGround", (byte) (onGround ? 1 : 0));
|
||||
tags.setBoolean("Retrieval", doNotRetrieve);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readEntityFromNBT (NBTTagCompound tags)
|
||||
{
|
||||
// super.readEntityFromNBT(tags);
|
||||
|
||||
this.returnStack = ItemStack.loadItemStackFromNBT(tags.getCompoundTag("Throwable"));
|
||||
xTile = tags.getShort("xTile");
|
||||
yTile = tags.getShort("yTile");
|
||||
zTile = tags.getShort("zTile");
|
||||
// TODO fix this\/
|
||||
// inTile = tags.getString("inTile");
|
||||
arrowShake = tags.getByte("shake") & 0xff;
|
||||
onGround = tags.getByte("onGround") == 1;
|
||||
doNotRetrieve = tags.getBoolean("Retrieval");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCollideWithPlayer (EntityPlayer entityplayer)
|
||||
{
|
||||
onCollideWithPlayer(entityplayer, true);
|
||||
}
|
||||
|
||||
public void onCollideWithPlayer (EntityPlayer entityplayer, boolean flag)
|
||||
{
|
||||
if (returnStack == null || returnStack.stackSize == 0 || worldObj.isRemote)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!flag || onGround && arrowShake <= 0)
|
||||
{
|
||||
if (!flag || returnsTo != null && !returnsTo.isDead && returnsTo != entityplayer)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!doNotRetrieve)
|
||||
AbilityHelper.addToInv(entityplayer, returnStack, true);
|
||||
worldObj.playSoundAtEntity(this, "random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
|
||||
entityplayer.onItemPickup(this, 1);
|
||||
kill();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getShadowSize ()
|
||||
{
|
||||
return 0.0F;
|
||||
}
|
||||
|
||||
public ItemStack getEntityItem ()
|
||||
{
|
||||
return returnStack;
|
||||
}
|
||||
|
||||
public int age = 0;
|
||||
public int hoverStart = 0;
|
||||
public int texID;
|
||||
public int tex2ID;
|
||||
public ItemStack returnStack;
|
||||
public int returnStackSlot;
|
||||
public boolean hasHitGround;
|
||||
public boolean hasHitMob;
|
||||
public float prevBoomerangRotation;
|
||||
public float boomerangRotation;
|
||||
public Entity returnsTo;
|
||||
public int damageDealt;
|
||||
public int maxGroundTicks;
|
||||
protected int xTile;
|
||||
protected int yTile;
|
||||
protected int zTile;
|
||||
protected Block inTile;
|
||||
public int arrowShake;
|
||||
public EntityPlayer owner;
|
||||
protected int ticksInGround;
|
||||
protected int ticksInAir;
|
||||
public boolean doNotRetrieve;
|
||||
|
||||
@Override
|
||||
public void writeSpawnData (ByteBuf data)
|
||||
{
|
||||
NBTTagCompound tags = returnStack.getTagCompound().getCompoundTag("InfiTool");
|
||||
ByteBufUtils.writeItemStack(data, returnStack);
|
||||
data.writeFloat(rotationYaw);
|
||||
data.writeInt(tags.getInteger("RenderHandle"));
|
||||
data.writeInt(tags.getInteger("RenderHead"));
|
||||
data.writeInt(tags.getInteger("RenderAccessory"));
|
||||
|
||||
int effects = 0;
|
||||
if (tags.hasKey("Effect1"))
|
||||
effects++;
|
||||
if (tags.hasKey("Effect2"))
|
||||
effects++;
|
||||
if (tags.hasKey("Effect3"))
|
||||
effects++;
|
||||
if (tags.hasKey("Effect4"))
|
||||
effects++;
|
||||
if (tags.hasKey("Effect5"))
|
||||
effects++;
|
||||
if (tags.hasKey("Effect6"))
|
||||
effects++;
|
||||
data.writeInt(effects);
|
||||
|
||||
switch (effects)
|
||||
{
|
||||
case 6:
|
||||
data.writeInt(tags.getInteger("Effect6"));
|
||||
case 5:
|
||||
data.writeInt(tags.getInteger("Effect5"));
|
||||
case 4:
|
||||
data.writeInt(tags.getInteger("Effect4"));
|
||||
case 3:
|
||||
data.writeInt(tags.getInteger("Effect3"));
|
||||
case 2:
|
||||
data.writeInt(tags.getInteger("Effect2"));
|
||||
case 1:
|
||||
data.writeInt(tags.getInteger("Effect1"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSpawnData (ByteBuf data)
|
||||
{
|
||||
returnStack = ByteBufUtils.readItemStack(data);
|
||||
rotationYaw = data.readFloat();
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
NBTTagCompound toolTag = new NBTTagCompound();
|
||||
toolTag.setInteger("RenderHandle", data.readInt());
|
||||
toolTag.setInteger("RenderHead", data.readInt());
|
||||
toolTag.setInteger("RenderAccessory", data.readInt());
|
||||
switch (data.readInt())
|
||||
{
|
||||
case 6:
|
||||
toolTag.setInteger("Effect6", data.readInt());
|
||||
case 5:
|
||||
toolTag.setInteger("Effect5", data.readInt());
|
||||
case 4:
|
||||
toolTag.setInteger("Effect4", data.readInt());
|
||||
case 3:
|
||||
toolTag.setInteger("Effect3", data.readInt());
|
||||
case 2:
|
||||
toolTag.setInteger("Effect2", data.readInt());
|
||||
case 1:
|
||||
toolTag.setInteger("Effect1", data.readInt());
|
||||
}
|
||||
compound.setTag("InfiTool", toolTag);
|
||||
returnStack.setTagCompound(compound);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,232 @@
|
||||
package tconstruct.tools.inventory;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.inventory.SlotCrafting;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.library.armor.ArmorCore;
|
||||
import tconstruct.library.crafting.ToolBuilder;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import tconstruct.tools.logic.CraftingStationLogic;
|
||||
|
||||
public class CraftingStationContainer extends Container
|
||||
{
|
||||
/** The crafting matrix inventory (3x3). */
|
||||
public InventoryCrafting craftMatrix;// = new InventoryCrafting(this, 3, 3);
|
||||
public IInventory craftResult;// = new InventoryCraftResult();
|
||||
private CraftingStationLogic logic;
|
||||
private World worldObj;
|
||||
private int posX;
|
||||
private int posY;
|
||||
private int posZ;
|
||||
|
||||
public CraftingStationContainer(InventoryPlayer inventorplayer, CraftingStationLogic logic, int x, int y, int z)
|
||||
{
|
||||
this.worldObj = logic.getWorldObj();
|
||||
this.posX = x;
|
||||
this.posY = y;
|
||||
this.posZ = z;
|
||||
this.logic = logic;
|
||||
craftMatrix = new InventoryCraftingStation(this, 3, 3, logic);
|
||||
craftResult = new InventoryCraftingStationResult(logic);
|
||||
|
||||
this.addSlotToContainer(new SlotCrafting(inventorplayer.player, this.craftMatrix, this.craftResult, 0, 124, 35));
|
||||
|
||||
int row;
|
||||
int column;
|
||||
|
||||
for (row = 0; row < 3; ++row)
|
||||
{
|
||||
for (column = 0; column < 3; ++column)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(this.craftMatrix, column + row * 3, 30 + column * 18, 17 + row * 18));
|
||||
}
|
||||
}
|
||||
|
||||
// Player Inventory
|
||||
for (row = 0; row < 3; ++row)
|
||||
{
|
||||
for (column = 0; column < 9; ++column)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(inventorplayer, column + row * 9 + 9, 8 + column * 18, 84 + row * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (column = 0; column < 9; ++column)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(inventorplayer, column, 8 + column * 18, 142));
|
||||
}
|
||||
|
||||
// Side inventory
|
||||
if (logic.chest != null)
|
||||
{
|
||||
IInventory chest = logic.chest.get();
|
||||
IInventory doubleChest = logic.doubleChest == null ? null : logic.doubleChest.get();
|
||||
IInventory firstChest = (logic.doubleFirst ? doubleChest : chest);
|
||||
IInventory secondChest = (logic.doubleFirst ? chest : doubleChest);
|
||||
int count = 0;
|
||||
for (column = 0; column < 9; column++)
|
||||
{
|
||||
for (row = 0; row < 6; row++)
|
||||
{
|
||||
int value = count < 27 ? count : count - 27;
|
||||
this.addSlotToContainer(new Slot(count < 27 ? firstChest : secondChest, value, -108 + row * 18, 19 + column * 18));
|
||||
count++;
|
||||
if (count >= 27 && doubleChest == null)
|
||||
break;
|
||||
}
|
||||
if (count >= 27 && doubleChest == null)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
this.onCraftMatrixChanged(this.craftMatrix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCraftMatrixChanged (IInventory par1IInventory)
|
||||
{
|
||||
ItemStack tool = modifyTool();
|
||||
if (tool != null)
|
||||
this.craftResult.setInventorySlotContents(0, tool);
|
||||
else
|
||||
this.craftResult.setInventorySlotContents(0, CraftingManager.getInstance().findMatchingRecipe(this.craftMatrix, this.worldObj));
|
||||
}
|
||||
|
||||
public ItemStack modifyTool ()
|
||||
{
|
||||
ItemStack input = craftMatrix.getStackInSlot(4);
|
||||
if (input != null)
|
||||
{
|
||||
Item item = input.getItem();
|
||||
if (item instanceof ToolCore)
|
||||
{
|
||||
ItemStack[] slots = new ItemStack[8];
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
slots[i] = craftMatrix.getStackInSlot(i);
|
||||
slots[i + 4] = craftMatrix.getStackInSlot(i + 5);
|
||||
}
|
||||
ItemStack output = ToolBuilder.instance.modifyTool(input, slots, "");
|
||||
if (output != null)
|
||||
return output;
|
||||
}
|
||||
else if (item instanceof ArmorCore)
|
||||
{
|
||||
ItemStack[] slots = new ItemStack[8];
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
slots[i] = craftMatrix.getStackInSlot(i);
|
||||
slots[i + 4] = craftMatrix.getStackInSlot(i + 5);
|
||||
}
|
||||
ItemStack output = ToolBuilder.instance.modifyArmor(input, slots, "");
|
||||
if (output != null)
|
||||
return output;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed (EntityPlayer par1EntityPlayer)
|
||||
{
|
||||
super.onContainerClosed(par1EntityPlayer);
|
||||
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
for (int i = 0; i < 9; ++i)
|
||||
{
|
||||
ItemStack itemstack = this.craftMatrix.getStackInSlotOnClosing(i);
|
||||
|
||||
if (itemstack != null)
|
||||
{
|
||||
par1EntityPlayer.dropPlayerItemWithRandomChoice(itemstack, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith (EntityPlayer player)
|
||||
{
|
||||
|
||||
Block block = worldObj.getBlock(this.posX, this.posY, this.posZ);
|
||||
if (block != TinkerTools.craftingStationWood && block != TinkerTools.craftingSlabWood)
|
||||
return false;
|
||||
return player.getDistanceSq((double) this.posX + 0.5D, (double) this.posY + 0.5D, (double) this.posZ + 0.5D) <= 64.0D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot (EntityPlayer par1EntityPlayer, int par2)
|
||||
{
|
||||
ItemStack itemstack = null;
|
||||
Slot slot = (Slot) this.inventorySlots.get(par2);
|
||||
|
||||
if (slot != null && slot.getHasStack())
|
||||
{
|
||||
ItemStack itemstack1 = slot.getStack();
|
||||
itemstack = itemstack1.copy();
|
||||
|
||||
if (par2 == 0)
|
||||
{
|
||||
if (!this.mergeItemStack(itemstack1, 10, 46, true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
slot.onSlotChange(itemstack1, itemstack);
|
||||
}
|
||||
else if (par2 >= 10 && par2 < 37)
|
||||
{
|
||||
if (!this.mergeItemStack(itemstack1, 37, 46, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (par2 >= 37 && par2 < 46)
|
||||
{
|
||||
if (!this.mergeItemStack(itemstack1, 10, 37, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (!this.mergeItemStack(itemstack1, 10, 46, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (itemstack1.stackSize == 0)
|
||||
{
|
||||
slot.putStack((ItemStack) null);
|
||||
}
|
||||
else
|
||||
{
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
|
||||
if (itemstack1.stackSize == itemstack.stackSize)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
slot.onPickupFromSlot(par1EntityPlayer, itemstack1);
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean func_94530_a (ItemStack par1ItemStack, Slot par2Slot)
|
||||
{
|
||||
return par2Slot.inventory != this.craftResult && super.func_94530_a(par1ItemStack, par2Slot);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
package tconstruct.tools.inventory;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import tconstruct.tools.logic.FrypanLogic;
|
||||
|
||||
public class FrypanContainer extends Container
|
||||
{
|
||||
public FrypanLogic logic;
|
||||
public int progress = 0;
|
||||
public int fuel = 0;
|
||||
public int fuelGague = 0;
|
||||
|
||||
public FrypanContainer(EntityPlayer player, FrypanLogic frypan)
|
||||
{
|
||||
InventoryPlayer inventoryplayer = player.inventory;
|
||||
logic = frypan;
|
||||
this.addSlotToContainer(new Slot(frypan, 1, 26, 45));
|
||||
for (int y = 0; y < 2; y++)
|
||||
for (int x = 0; x < 4; x++)
|
||||
this.addSlotToContainer(new SlotFrypan(frypan, 2 + x + y * 4, 70 + x * 18, 27 + y * 18, player));
|
||||
|
||||
/* Player inventory */
|
||||
for (int column = 0; column < 3; column++)
|
||||
{
|
||||
for (int row = 0; row < 9; row++)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(inventoryplayer, row + column * 9 + 9, 8 + row * 18, 84 + column * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (int column = 0; column < 9; column++)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(inventoryplayer, column, 8 + column * 18, 142));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges ()
|
||||
{
|
||||
super.detectAndSendChanges();
|
||||
for (int i = 0; i < crafters.size(); i++)
|
||||
{
|
||||
ICrafting icrafting = (ICrafting) crafters.get(i);
|
||||
if (progress != logic.progress)
|
||||
{
|
||||
icrafting.sendProgressBarUpdate(this, 0, logic.progress);
|
||||
}
|
||||
if (fuel != logic.fuel)
|
||||
{
|
||||
icrafting.sendProgressBarUpdate(this, 1, logic.fuel);
|
||||
}
|
||||
if (fuelGague != logic.fuelGague)
|
||||
{
|
||||
icrafting.sendProgressBarUpdate(this, 2, logic.fuelGague);
|
||||
}
|
||||
}
|
||||
|
||||
progress = logic.progress;
|
||||
fuel = logic.fuel;
|
||||
fuelGague = logic.fuelGague;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateProgressBar (int i, int j)
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
logic.progress = j;
|
||||
}
|
||||
if (i == 1)
|
||||
{
|
||||
logic.fuel = j;
|
||||
}
|
||||
if (i == 2)
|
||||
{
|
||||
logic.fuelGague = j;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith (EntityPlayer entityplayer)
|
||||
{
|
||||
Block block = logic.getWorldObj().getBlock(logic.xCoord, logic.yCoord, logic.zCoord);
|
||||
if (block != TinkerTools.heldItemBlock)
|
||||
return false;
|
||||
|
||||
return logic.isUseableByPlayer(entityplayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot (EntityPlayer player, int slotID)
|
||||
{
|
||||
ItemStack stack = null;
|
||||
Slot slot = (Slot) this.inventorySlots.get(slotID);
|
||||
|
||||
if (slot != null && slot.getHasStack())
|
||||
{
|
||||
ItemStack slotStack = slot.getStack();
|
||||
stack = slotStack.copy();
|
||||
|
||||
if (slotID < logic.getSizeInventory())
|
||||
{
|
||||
if (!this.mergeItemStack(slotStack, logic.getSizeInventory(), this.inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (!this.mergeItemStack(slotStack, 0, logic.getSizeInventory(), false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (slotStack.stackSize == 0)
|
||||
{
|
||||
slot.putStack((ItemStack) null);
|
||||
}
|
||||
else
|
||||
{
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,189 @@
|
||||
package tconstruct.tools.inventory;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.inventory.SlotFurnace;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
import tconstruct.tools.logic.FurnaceLogic;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class FurnaceContainer extends Container
|
||||
{
|
||||
private FurnaceLogic furnace;
|
||||
private int lastCookTime;
|
||||
private int lastBurnTime;
|
||||
private int lastItemBurnTime;
|
||||
|
||||
public FurnaceContainer(InventoryPlayer par1InventoryPlayer, FurnaceLogic par2TileEntityFurnace)
|
||||
{
|
||||
this.furnace = par2TileEntityFurnace;
|
||||
this.addSlotToContainer(new Slot(par2TileEntityFurnace, 0, 56, 17));
|
||||
this.addSlotToContainer(new Slot(par2TileEntityFurnace, 1, 56, 53));
|
||||
this.addSlotToContainer(new SlotFurnace(par1InventoryPlayer.player, par2TileEntityFurnace, 2, 116, 35));
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 3; ++i)
|
||||
{
|
||||
for (int j = 0; j < 9; ++j)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(par1InventoryPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 9; ++i)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(par1InventoryPlayer, i, 8 + i * 18, 142));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCraftingToCrafters (ICrafting par1ICrafting)
|
||||
{
|
||||
super.addCraftingToCrafters(par1ICrafting);
|
||||
par1ICrafting.sendProgressBarUpdate(this, 0, this.furnace.progress);
|
||||
par1ICrafting.sendProgressBarUpdate(this, 1, this.furnace.fuel);
|
||||
par1ICrafting.sendProgressBarUpdate(this, 2, this.furnace.fuelGague);
|
||||
}
|
||||
|
||||
/**
|
||||
* Looks for changes made in the container, sends them to every listener.
|
||||
*/
|
||||
@Override
|
||||
public void detectAndSendChanges ()
|
||||
{
|
||||
super.detectAndSendChanges();
|
||||
|
||||
for (int i = 0; i < this.crafters.size(); ++i)
|
||||
{
|
||||
ICrafting icrafting = (ICrafting) this.crafters.get(i);
|
||||
|
||||
if (this.lastCookTime != this.furnace.progress)
|
||||
{
|
||||
icrafting.sendProgressBarUpdate(this, 0, this.furnace.progress);
|
||||
}
|
||||
|
||||
if (this.lastBurnTime != this.furnace.fuel)
|
||||
{
|
||||
icrafting.sendProgressBarUpdate(this, 1, this.furnace.fuel);
|
||||
}
|
||||
|
||||
if (this.lastItemBurnTime != this.furnace.fuelGague)
|
||||
{
|
||||
icrafting.sendProgressBarUpdate(this, 2, this.furnace.fuelGague);
|
||||
}
|
||||
}
|
||||
|
||||
this.lastCookTime = this.furnace.progress;
|
||||
this.lastBurnTime = this.furnace.fuel;
|
||||
this.lastItemBurnTime = this.furnace.fuelGague;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void updateProgressBar (int par1, int par2)
|
||||
{
|
||||
if (par1 == 0)
|
||||
{
|
||||
this.furnace.progress = par2;
|
||||
}
|
||||
|
||||
if (par1 == 1)
|
||||
{
|
||||
this.furnace.fuel = par2;
|
||||
}
|
||||
|
||||
if (par1 == 2)
|
||||
{
|
||||
this.furnace.fuelGague = par2;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith (EntityPlayer par1EntityPlayer)
|
||||
{
|
||||
return this.furnace.isUseableByPlayer(par1EntityPlayer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a player shift-clicks on a slot. You must override this or
|
||||
* you will crash when someone does that.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack transferStackInSlot (EntityPlayer par1EntityPlayer, int par2)
|
||||
{
|
||||
ItemStack itemstack = null;
|
||||
Slot slot = (Slot) this.inventorySlots.get(par2);
|
||||
|
||||
if (slot != null && slot.getHasStack())
|
||||
{
|
||||
ItemStack itemstack1 = slot.getStack();
|
||||
itemstack = itemstack1.copy();
|
||||
|
||||
if (par2 == 2)
|
||||
{
|
||||
if (!this.mergeItemStack(itemstack1, 3, 39, true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
slot.onSlotChange(itemstack1, itemstack);
|
||||
}
|
||||
else if (par2 != 1 && par2 != 0)
|
||||
{
|
||||
if (FurnaceRecipes.smelting().getSmeltingResult(itemstack1) != null)
|
||||
{
|
||||
if (!this.mergeItemStack(itemstack1, 0, 1, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (TileEntityFurnace.isItemFuel(itemstack1))
|
||||
{
|
||||
if (!this.mergeItemStack(itemstack1, 1, 2, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (par2 >= 3 && par2 < 30)
|
||||
{
|
||||
if (!this.mergeItemStack(itemstack1, 30, 39, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (par2 >= 30 && par2 < 39 && !this.mergeItemStack(itemstack1, 3, 30, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (!this.mergeItemStack(itemstack1, 3, 39, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (itemstack1.stackSize == 0)
|
||||
{
|
||||
slot.putStack((ItemStack) null);
|
||||
}
|
||||
else
|
||||
{
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
|
||||
if (itemstack1.stackSize == itemstack.stackSize)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
slot.onPickupFromSlot(par1EntityPlayer, itemstack1);
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
package tconstruct.tools.inventory;
|
||||
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class InventoryCraftingStation extends InventoryCrafting
|
||||
{
|
||||
/** the width of the crafting inventory */
|
||||
private int inventoryWidth;
|
||||
|
||||
/**
|
||||
* Class containing the callbacks for the events on_GUIClosed and
|
||||
* on_CraftMaxtrixChanged.
|
||||
*/
|
||||
private Container eventHandler;
|
||||
private InventoryLogic logic;
|
||||
|
||||
public InventoryCraftingStation(Container par1Container, int size, int height, InventoryLogic logic)
|
||||
{
|
||||
super(par1Container, size, height);
|
||||
this.eventHandler = par1Container;
|
||||
this.inventoryWidth = size;
|
||||
this.logic = logic;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of slots in the inventory.
|
||||
*/
|
||||
@Override
|
||||
public int getSizeInventory ()
|
||||
{
|
||||
return 9;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot (int slot)
|
||||
{
|
||||
return slot >= this.getSizeInventory() + 1 ? null : logic.getStackInSlot(slot + 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInRowAndColumn (int row, int column)
|
||||
{
|
||||
if (row >= 0 && row < this.inventoryWidth)
|
||||
{
|
||||
int k = row + column * this.inventoryWidth;
|
||||
return this.getStackInSlot(k);
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public String getInvName ()
|
||||
{
|
||||
return "container.crafting";
|
||||
}
|
||||
|
||||
public boolean isInvNameLocalized ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing (int par1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes from an inventory slot (first arg) up to a specified number
|
||||
* (second arg) of items and returns them in a new stack.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack decrStackSize (int slotID, int par2)
|
||||
{
|
||||
ItemStack stack = logic.getStackInSlot(slotID + 1);
|
||||
if (stack != null)
|
||||
{
|
||||
ItemStack itemstack;
|
||||
|
||||
if (stack.stackSize <= par2)
|
||||
{
|
||||
itemstack = stack.copy();
|
||||
stack = null;
|
||||
logic.setInventorySlotContents(slotID + 1, null);
|
||||
this.eventHandler.onCraftMatrixChanged(this);
|
||||
return itemstack;
|
||||
}
|
||||
else
|
||||
{
|
||||
itemstack = stack.splitStack(par2);
|
||||
|
||||
if (stack.stackSize == 0)
|
||||
{
|
||||
stack = null;
|
||||
}
|
||||
|
||||
this.eventHandler.onCraftMatrixChanged(this);
|
||||
return itemstack;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the given item stack to the specified slot in the inventory (can be
|
||||
* crafting or armor sections).
|
||||
*/
|
||||
@Override
|
||||
public void setInventorySlotContents (int slot, ItemStack itemstack)
|
||||
{
|
||||
logic.setInventorySlotContents(slot + 1, itemstack);
|
||||
this.eventHandler.onCraftMatrixChanged(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum stack size for a inventory slot. Seems to always be
|
||||
* 64, possibly will be extended. *Isn't this more of a set than a get?*
|
||||
*/
|
||||
@Override
|
||||
public int getInventoryStackLimit ()
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when an the contents of an Inventory change, usually
|
||||
*/
|
||||
@Override
|
||||
public void markDirty ()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Do not make give this method the name canInteractWith because it clashes
|
||||
* with Container
|
||||
*/
|
||||
@Override
|
||||
public boolean isUseableByPlayer (EntityPlayer par1EntityPlayer)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void openChest ()
|
||||
{
|
||||
}
|
||||
|
||||
public void closeChest ()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if automation is allowed to insert the given stack (ignoring
|
||||
* stack size) into the given slot.
|
||||
*/
|
||||
public boolean isStackValidForSlot (int par1, ItemStack par2ItemStack)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
package tconstruct.tools.inventory;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.InventoryCraftResult;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import tconstruct.tools.logic.CraftingStationLogic;
|
||||
|
||||
public class InventoryCraftingStationResult extends InventoryCraftResult
|
||||
{
|
||||
CraftingStationLogic logic;
|
||||
|
||||
public InventoryCraftingStationResult(CraftingStationLogic logic)
|
||||
{
|
||||
this.logic = logic;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of slots in the inventory.
|
||||
*/
|
||||
@Override
|
||||
public int getSizeInventory ()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the stack in slot i
|
||||
*/
|
||||
@Override
|
||||
public ItemStack getStackInSlot (int par1)
|
||||
{
|
||||
return logic.getStackInSlot(0);// this.stackResult[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the inventory.
|
||||
*/
|
||||
public String getInvName ()
|
||||
{
|
||||
return "Result";
|
||||
}
|
||||
|
||||
/**
|
||||
* If this returns false, the inventory name will be used as an unlocalized
|
||||
* name, and translated into the player's language. Otherwise it will be
|
||||
* used directly.
|
||||
*/
|
||||
public boolean isInvNameLocalized ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes from an inventory slot (first arg) up to a specified number
|
||||
* (second arg) of items and returns them in a new stack.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack decrStackSize (int par1, int par2)
|
||||
{
|
||||
ItemStack stack = logic.getStackInSlot(0);
|
||||
if (stack != null)
|
||||
{
|
||||
ItemStack itemstack = stack;
|
||||
logic.setInventorySlotContents(0, null);
|
||||
return itemstack;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* When some containers are closed they call this on each slot, then drop
|
||||
* whatever it returns as an EntityItem - like when you close a workbench
|
||||
* GUI.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing (int par1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the given item stack to the specified slot in the inventory (can be
|
||||
* crafting or armor sections).
|
||||
*/
|
||||
@Override
|
||||
public void setInventorySlotContents (int par1, ItemStack par2ItemStack)
|
||||
{
|
||||
logic.setInventorySlotContents(0, par2ItemStack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum stack size for a inventory slot. Seems to always be
|
||||
* 64, possibly will be extended. *Isn't this more of a set than a get?*
|
||||
*/
|
||||
@Override
|
||||
public int getInventoryStackLimit ()
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when an the contents of an Inventory change, usually
|
||||
*/
|
||||
@Override
|
||||
public void markDirty ()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Do not make give this method the name canInteractWith because it clashes
|
||||
* with Container
|
||||
*/
|
||||
@Override
|
||||
public boolean isUseableByPlayer (EntityPlayer par1EntityPlayer)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void openChest ()
|
||||
{
|
||||
}
|
||||
|
||||
public void closeChest ()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if automation is allowed to insert the given stack (ignoring
|
||||
* stack size) into the given slot.
|
||||
*/
|
||||
public boolean isStackValidForSlot (int par1, ItemStack par2ItemStack)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
package tconstruct.tools.inventory;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import tconstruct.armor.inventory.SlotOnlyTake;
|
||||
import tconstruct.library.util.IPattern;
|
||||
import tconstruct.smeltery.inventory.ActiveContainer;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import tconstruct.tools.logic.PartBuilderLogic;
|
||||
import tconstruct.tools.logic.PatternChestLogic;
|
||||
|
||||
public class PartCrafterChestContainer extends ActiveContainer
|
||||
{
|
||||
protected PatternChestLogic patternLogic;
|
||||
protected InventoryPlayer invPlayer;
|
||||
protected PartBuilderLogic logic;
|
||||
protected Slot[] input;
|
||||
protected Slot[] inventory;
|
||||
public boolean largeInventory;
|
||||
|
||||
public PartCrafterChestContainer(InventoryPlayer inventoryplayer, PartBuilderLogic partLogic, PatternChestLogic pLogic)
|
||||
{
|
||||
logic = partLogic;
|
||||
patternLogic = pLogic;
|
||||
largeInventory = true;
|
||||
|
||||
inventory = new Slot[] { new SlotPattern(partLogic, 0, 40, 27), new SlotPattern(partLogic, 1, 40, 45), new Slot(partLogic, 2, 58, 27), new Slot(partLogic, 3, 58, 45),
|
||||
new SlotOnlyTake(partLogic, 4, 102, 27), new SlotOnlyTake(partLogic, 5, 120, 27), new SlotOnlyTake(partLogic, 6, 102, 45), new SlotOnlyTake(partLogic, 7, 120, 45) };
|
||||
for (int iter = 0; iter < inventory.length; iter++)
|
||||
this.addSlotToContainer(inventory[iter]);
|
||||
|
||||
/* Holder inventory */
|
||||
for (int column = 0; column < 5; column++)
|
||||
{
|
||||
for (int row = 0; row < 6; row++)
|
||||
{
|
||||
this.addSlotToContainer(new SlotPattern(pLogic, row + column * 6, -108 + row * 18, 30 + column * 18));
|
||||
}
|
||||
}
|
||||
|
||||
/* Player inventory */
|
||||
for (int column = 0; column < 3; column++)
|
||||
{
|
||||
for (int row = 0; row < 9; row++)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(inventoryplayer, row + column * 9 + 9, 8 + row * 18, 84 + column * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (int column = 0; column < 9; column++)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(inventoryplayer, column, 8 + column * 18, 142));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith (EntityPlayer entityplayer)
|
||||
{
|
||||
Block block = logic.getWorldObj().getBlock(logic.xCoord, logic.yCoord, logic.zCoord);
|
||||
if (block != TinkerTools.toolStationWood && block != TinkerTools.craftingSlabWood)
|
||||
return false;
|
||||
return logic.isUseableByPlayer(entityplayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot (EntityPlayer player, int slotID)
|
||||
{
|
||||
ItemStack stack = null;
|
||||
Slot slot = (Slot) this.inventorySlots.get(slotID);
|
||||
|
||||
if (slot != null && slot.getHasStack())
|
||||
{
|
||||
ItemStack slotStack = slot.getStack();
|
||||
stack = slotStack.copy();
|
||||
|
||||
if (slotID < logic.getSizeInventory())
|
||||
{
|
||||
if (!this.mergeItemStack(slotStack, logic.getSizeInventory() + patternLogic.getSizeInventory(), this.inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (slotStack.getItem() instanceof IPattern)
|
||||
{
|
||||
if (!this.mergeItemStack(slotStack, 0, 2, false) && !this.mergeItemStack(slotStack, 8, 38, false))
|
||||
return null;
|
||||
}
|
||||
else if (!this.mergeItemStack(slotStack, 2, 4, false))
|
||||
return null;
|
||||
}
|
||||
|
||||
if (slotStack.stackSize == 0)
|
||||
{
|
||||
slot.putStack((ItemStack) null);
|
||||
logic.tryBuildPart(slotID);
|
||||
}
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package tconstruct.tools.inventory;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import tconstruct.armor.inventory.SlotOnlyTake;
|
||||
import tconstruct.library.util.IPattern;
|
||||
import tconstruct.smeltery.inventory.ActiveContainer;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import tconstruct.tools.logic.PartBuilderLogic;
|
||||
|
||||
public class PartCrafterContainer extends ActiveContainer
|
||||
{
|
||||
protected InventoryPlayer invPlayer;
|
||||
protected PartBuilderLogic logic;
|
||||
protected Slot[] input;
|
||||
protected Slot[] inventory;
|
||||
public boolean largeInventory;
|
||||
|
||||
public PartCrafterContainer(InventoryPlayer inventoryplayer, PartBuilderLogic partLogic)
|
||||
{
|
||||
invPlayer = inventoryplayer;
|
||||
logic = partLogic;
|
||||
largeInventory = false;
|
||||
|
||||
inventory = new Slot[] { new SlotPattern(partLogic, 0, 40, 27), new SlotPattern(partLogic, 1, 40, 45), new Slot(partLogic, 2, 58, 27), new Slot(partLogic, 3, 58, 45),
|
||||
new SlotOnlyTake(partLogic, 4, 102, 27), new SlotOnlyTake(partLogic, 5, 120, 27), new SlotOnlyTake(partLogic, 6, 102, 45), new SlotOnlyTake(partLogic, 7, 120, 45) };
|
||||
for (int iter = 0; iter < inventory.length; iter++)
|
||||
this.addSlotToContainer(inventory[iter]);
|
||||
|
||||
/* Player inventory */
|
||||
for (int column = 0; column < 3; column++)
|
||||
{
|
||||
for (int row = 0; row < 9; row++)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(inventoryplayer, row + column * 9 + 9, 8 + row * 18, 84 + column * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (int column = 0; column < 9; column++)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(inventoryplayer, column, 8 + column * 18, 142));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith (EntityPlayer entityplayer)
|
||||
{
|
||||
Block block = logic.getWorldObj().getBlock(logic.xCoord, logic.yCoord, logic.zCoord);
|
||||
if (block != TinkerTools.toolStationWood && block != TinkerTools.craftingSlabWood)
|
||||
return false;
|
||||
return logic.isUseableByPlayer(entityplayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot (EntityPlayer player, int slotID)
|
||||
{
|
||||
ItemStack stack = null;
|
||||
Slot slot = (Slot) this.inventorySlots.get(slotID);
|
||||
|
||||
if (slot != null && slot.getHasStack())
|
||||
{
|
||||
ItemStack slotStack = slot.getStack();
|
||||
stack = slotStack.copy();
|
||||
|
||||
if (slotID < logic.getSizeInventory())
|
||||
{
|
||||
if (!this.mergeItemStack(slotStack, logic.getSizeInventory(), this.inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (slotStack.getItem() instanceof IPattern)
|
||||
{
|
||||
if (!this.mergeItemStack(slotStack, 0, 2, false))
|
||||
return null;
|
||||
}
|
||||
else if (!this.mergeItemStack(slotStack, 2, 4, false))
|
||||
return null;
|
||||
}
|
||||
|
||||
if (slotStack.stackSize == 0)
|
||||
{
|
||||
slot.putStack((ItemStack) null);
|
||||
logic.tryBuildPart(slotID);
|
||||
}
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package tconstruct.tools.inventory;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import tconstruct.library.util.IPattern;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import tconstruct.tools.logic.PatternChestLogic;
|
||||
|
||||
public class PatternChestContainer extends Container
|
||||
{
|
||||
public PatternChestLogic logic;
|
||||
public int progress = 0;
|
||||
public int fuel = 0;
|
||||
public int fuelGague = 0;
|
||||
|
||||
public PatternChestContainer(InventoryPlayer inventoryplayer, PatternChestLogic chest)
|
||||
{
|
||||
logic = chest;
|
||||
for (int column = 0; column < 3; column++)
|
||||
{
|
||||
for (int row = 0; row < 10; row++)
|
||||
{
|
||||
this.addSlotToContainer(new SlotPattern(chest, row + column * 10, 8 + row * 18, 18 + column * 18));
|
||||
}
|
||||
}
|
||||
|
||||
/* Player inventory */
|
||||
for (int column = 0; column < 3; column++)
|
||||
{
|
||||
for (int row = 0; row < 9; row++)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(inventoryplayer, row + column * 9 + 9, 17 + row * 18, 86 + column * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (int column = 0; column < 9; column++)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(inventoryplayer, column, 17 + column * 18, 144));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith (EntityPlayer entityplayer)
|
||||
{
|
||||
Block block = logic.getWorldObj().getBlock(logic.xCoord, logic.yCoord, logic.zCoord);
|
||||
if (block != TinkerTools.toolStationWood && block != TinkerTools.craftingSlabWood)
|
||||
return false;
|
||||
return logic.isUseableByPlayer(entityplayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot (EntityPlayer player, int slotID)
|
||||
{
|
||||
ItemStack stack = null;
|
||||
Slot slot = (Slot) this.inventorySlots.get(slotID);
|
||||
|
||||
if (slot != null && slot.getHasStack())
|
||||
{
|
||||
ItemStack slotStack = slot.getStack();
|
||||
stack = slotStack.copy();
|
||||
|
||||
if (slotID < logic.getSizeInventory())
|
||||
{
|
||||
if (!this.mergeItemStack(slotStack, logic.getSizeInventory(), this.inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (!this.mergeItemStack(slotStack, 0, logic.getSizeInventory(), false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (slotStack.stackSize == 0)
|
||||
{
|
||||
slot.putStack((ItemStack) null);
|
||||
}
|
||||
else
|
||||
{
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean mergeItemStack (ItemStack stack, int inventorySize, int slotSize, boolean par4)
|
||||
{
|
||||
if (!(stack.getItem() instanceof IPattern))
|
||||
return false;
|
||||
|
||||
return super.mergeItemStack(stack, inventorySize, slotSize, par4);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
package tconstruct.tools.inventory;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import tconstruct.armor.inventory.SlotOnlyTake;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import tconstruct.tools.logic.StencilTableLogic;
|
||||
|
||||
public class PatternShaperContainer extends Container
|
||||
{
|
||||
public StencilTableLogic logic;
|
||||
|
||||
public PatternShaperContainer(InventoryPlayer inventoryplayer, StencilTableLogic shaper)
|
||||
{
|
||||
logic = shaper;
|
||||
this.addSlotToContainer(new Slot(shaper, 0, 48, 35));
|
||||
this.addSlotToContainer(new SlotOnlyTake(shaper, 1, 106, 35));
|
||||
/*for (int i = 0; i < 3; i++)
|
||||
{
|
||||
for (int l = 0; l < 3; l++)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(craftMatrix, l + i * 3, 30 + l * 18, 17 + i * 18));
|
||||
}
|
||||
}*/
|
||||
|
||||
/* Player inventory */
|
||||
for (int column = 0; column < 3; column++)
|
||||
{
|
||||
for (int row = 0; row < 9; row++)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(inventoryplayer, row + column * 9 + 9, 8 + row * 18, 84 + column * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (int column = 0; column < 9; column++)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(inventoryplayer, column, 8 + column * 18, 142));
|
||||
}
|
||||
}
|
||||
|
||||
/*public void onCraftMatrixChanged(IInventory iinventory)
|
||||
{
|
||||
craftResult.setInventorySloTRepos(0, CraftingManager.getInstance().findMatchingRecipe(craftMatrix, worldObj));
|
||||
}*/
|
||||
|
||||
/*@Override
|
||||
public void onContainerClosed(EntityPlayer entityplayer)
|
||||
{
|
||||
super.onContainerClosed(entityplayer);
|
||||
if (logic.worldObj.isRemote)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ItemStack itemstack = logic.getStackInSlot(0);
|
||||
if (itemstack != null)
|
||||
{
|
||||
entityplayer.dropPlayerItem(itemstack);
|
||||
}
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith (EntityPlayer entityplayer)
|
||||
{
|
||||
Block block = logic.getWorldObj().getBlock(logic.xCoord, logic.yCoord, logic.zCoord);
|
||||
if (block != TinkerTools.toolStationWood && block != TinkerTools.craftingSlabWood)
|
||||
return false;
|
||||
return logic.isUseableByPlayer(entityplayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot (EntityPlayer player, int slotID)
|
||||
{
|
||||
return null;
|
||||
/*ItemStack stack = null;
|
||||
Slot slot = (Slot)this.inventorySlots.get(slotID);
|
||||
|
||||
if (slot != null && slot.getHasStack())
|
||||
{
|
||||
ItemStack slotStack = slot.getStack();
|
||||
stack = slotStack.copy();
|
||||
|
||||
if (slotID < logic.getSizeInventory())
|
||||
{
|
||||
if (!this.mergeItemStack(slotStack, logic.getSizeInventory(), this.inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (!this.mergeItemStack(slotStack, 0, logic.getSizeInventory()-1, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (slotStack.stackSize == 0)
|
||||
{
|
||||
slot.putStack((ItemStack)null);
|
||||
}
|
||||
else
|
||||
{
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
}
|
||||
|
||||
return stack;*/
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package tconstruct.tools.inventory;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemFood;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import tconstruct.achievements.TAchievements;
|
||||
|
||||
public class SlotFrypan extends Slot
|
||||
{
|
||||
|
||||
public EntityPlayer player;
|
||||
|
||||
public SlotFrypan(IInventory par1IInventory, int par2, int par3, int par4, EntityPlayer player)
|
||||
{
|
||||
super(par1IInventory, par2, par3, par4);
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStack (ItemStack par1ItemStack)
|
||||
{
|
||||
super.putStack(par1ItemStack);
|
||||
if (par1ItemStack != null && par1ItemStack.getItem() != null && par1ItemStack.getItem() instanceof ItemFood && par1ItemStack.hasTagCompound())
|
||||
{
|
||||
NBTTagCompound stackTagCompound = par1ItemStack.getTagCompound();
|
||||
if (stackTagCompound == null || !stackTagCompound.getBoolean("frypanKill"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
player.addStat(TAchievements.achievements.get("tconstruct:dualConvenience"), 1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package tconstruct.tools.inventory;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class SlotPartBuilder extends Slot
|
||||
{
|
||||
|
||||
public SlotPartBuilder(IInventory inv, int index, int posX, int posY)
|
||||
{
|
||||
super(inv, index, posX, posY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCrafting (ItemStack par1ItemStack, int par2)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package tconstruct.tools.inventory;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import tconstruct.library.util.IPattern;
|
||||
|
||||
public class SlotPattern extends Slot
|
||||
{
|
||||
public SlotPattern(IInventory builder, int par3, int par4, int par5)
|
||||
{
|
||||
super(builder, par3, par4, par5);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the stack is a valid item for this slot. Always true beside for the armor slots.
|
||||
*/
|
||||
@Override
|
||||
public boolean isItemValid (ItemStack stack)
|
||||
{
|
||||
return stack.getItem() instanceof IPattern;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package tconstruct.tools.inventory;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import tconstruct.library.event.ToolCraftedEvent;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
|
||||
public class SlotTool extends Slot
|
||||
{
|
||||
/** The player that is using the GUI where this slot resides. */
|
||||
public EntityPlayer player;
|
||||
Random random = new Random();
|
||||
|
||||
public SlotTool(EntityPlayer entityplayer, IInventory builder, int par3, int par4, int par5)
|
||||
{
|
||||
super(builder, par3, par4, par5);
|
||||
this.player = entityplayer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the stack is a valid item for this slot. Always true beside for
|
||||
* the armor slots.
|
||||
*/
|
||||
@Override
|
||||
public boolean isItemValid (ItemStack stack)
|
||||
{
|
||||
return false;
|
||||
// return stack.getItem() instanceof ToolCore;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPickupFromSlot (EntityPlayer par1EntityPlayer, ItemStack stack)
|
||||
{
|
||||
this.onCrafting(stack);
|
||||
// stack.setUnlocalizedName("\u00A7f" + toolName);
|
||||
super.onPickupFromSlot(par1EntityPlayer, stack);
|
||||
}
|
||||
|
||||
/**
|
||||
* the itemStack passed in is the output - ie, iron ingots, and pickaxes,
|
||||
* not ore and wood. Typically increases an internal count then calls
|
||||
* onCrafting(item).
|
||||
*/
|
||||
@Override
|
||||
protected void onCrafting (ItemStack stack, int par2)
|
||||
{
|
||||
// this.field_75228_b += par2;
|
||||
this.onCrafting(stack);
|
||||
}
|
||||
|
||||
/**
|
||||
* the itemStack passed in is the output - ie, iron ingots, and pickaxes,
|
||||
* not ore and wood.
|
||||
*/
|
||||
@Override
|
||||
protected void onCrafting (ItemStack stack)
|
||||
{
|
||||
NBTTagCompound tags = stack.getTagCompound();
|
||||
if (!tags.getCompoundTag("InfiTool").hasKey("Built"))
|
||||
{
|
||||
tags.getCompoundTag("InfiTool").setBoolean("Built", true);
|
||||
Boolean full = (inventory.getStackInSlot(2) != null || inventory.getStackInSlot(3) != null);
|
||||
for (int i = 2; i <= 3; i++)
|
||||
inventory.decrStackSize(i, 1);
|
||||
int amount = inventory.getStackInSlot(1).getItem() instanceof ToolCore ? stack.stackSize : 1;
|
||||
inventory.decrStackSize(1, amount);
|
||||
if (!player.worldObj.isRemote && full)
|
||||
player.worldObj.playSoundEffect(player.posX, player.posY, player.posZ, "tinker:little_saw", 1.0F, (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F);
|
||||
// player.worldObj.playAuxSFX(1021, (int)player.posX,
|
||||
// (int)player.posY, (int)player.posZ, 0);
|
||||
MinecraftForge.EVENT_BUS.post(new ToolCraftedEvent(this.inventory, player, stack));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package tconstruct.tools.inventory;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import tconstruct.library.event.ToolCraftedEvent;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
|
||||
public class SlotToolForge extends SlotTool
|
||||
{
|
||||
/** The player that is using the GUI where this slot resides. */
|
||||
Random random = new Random();
|
||||
|
||||
public SlotToolForge(EntityPlayer entityplayer, IInventory builder, int par3, int par4, int par5)
|
||||
{
|
||||
super(entityplayer, builder, par3, par4, par5);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCrafting (ItemStack stack)
|
||||
{
|
||||
NBTTagCompound tags = stack.getTagCompound();
|
||||
if (!tags.getCompoundTag("InfiTool").hasKey("Built"))
|
||||
{
|
||||
tags.getCompoundTag("InfiTool").setBoolean("Built", true);
|
||||
Boolean full = (inventory.getStackInSlot(2) != null || inventory.getStackInSlot(3) != null);
|
||||
for (int i = 2; i <= 4; i++)
|
||||
inventory.decrStackSize(i, 1);
|
||||
int amount = inventory.getStackInSlot(1).getItem() instanceof ToolCore ? stack.stackSize : 1;
|
||||
inventory.decrStackSize(1, amount);
|
||||
if (!player.worldObj.isRemote && full)
|
||||
player.worldObj.playAuxSFX(1021, (int) player.posX, (int) player.posY, (int) player.posZ, 0);
|
||||
MinecraftForge.EVENT_BUS.post(new ToolCraftedEvent(this.inventory, player, stack));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package tconstruct.tools.inventory;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import tconstruct.tools.logic.ToolForgeLogic;
|
||||
import tconstruct.tools.logic.ToolStationLogic;
|
||||
|
||||
public class ToolForgeContainer extends ToolStationContainer
|
||||
{
|
||||
|
||||
public ToolForgeContainer(InventoryPlayer inventoryplayer, ToolForgeLogic logic)
|
||||
{
|
||||
super(inventoryplayer, logic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializeContainer (InventoryPlayer inventoryplayer, ToolStationLogic builderlogic)
|
||||
{
|
||||
invPlayer = inventoryplayer;
|
||||
this.logic = builderlogic;
|
||||
|
||||
toolSlot = new SlotToolForge(inventoryplayer.player, logic, 0, 225, 38);
|
||||
this.addSlotToContainer(toolSlot);
|
||||
slots = new Slot[] { new Slot(logic, 1, 167, 29), new Slot(logic, 2, 169, 29), new Slot(logic, 3, 167, 47), new Slot(logic, 4, 149, 47) };
|
||||
|
||||
for (int iter = 0; iter < 4; iter++)
|
||||
this.addSlotToContainer(slots[iter]);
|
||||
|
||||
/* Player inventory */
|
||||
for (int column = 0; column < 3; column++)
|
||||
{
|
||||
for (int row = 0; row < 9; row++)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(inventoryplayer, row + column * 9 + 9, 118 + row * 18, 84 + column * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (int column = 0; column < 9; column++)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(inventoryplayer, column, 118 + column * 18, 142));
|
||||
}
|
||||
}
|
||||
|
||||
// posX and posY must be the same length
|
||||
@Override
|
||||
public void resetSlots (int[] posX, int[] posY)
|
||||
{
|
||||
inventorySlots.clear();
|
||||
inventoryItemStacks.clear();
|
||||
this.addSlotToContainer(toolSlot);
|
||||
for (int iter = 0; iter < 4; iter++)
|
||||
{
|
||||
slots[iter].xDisplayPosition = posX[iter] + 111;
|
||||
slots[iter].yDisplayPosition = posY[iter] + 1;
|
||||
addSlotToContainer(slots[iter]);
|
||||
}
|
||||
|
||||
for (int column = 0; column < 3; column++)
|
||||
{
|
||||
for (int row = 0; row < 9; row++)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(invPlayer, row + column * 9 + 9, 118 + row * 18, 84 + column * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (int column = 0; column < 9; column++)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(invPlayer, column, 118 + column * 18, 142));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void craftTool (ItemStack stack)
|
||||
{
|
||||
NBTTagCompound tags = stack.getTagCompound();
|
||||
if (!tags.getCompoundTag("InfiTool").hasKey("Built"))
|
||||
{
|
||||
tags.getCompoundTag("InfiTool").setBoolean("Built", true);
|
||||
for (int i = 2; i <= 4; i++)
|
||||
logic.decrStackSize(i, 1);
|
||||
int amount = logic.getStackInSlot(1).getItem() instanceof ToolCore ? stack.stackSize : 1;
|
||||
logic.decrStackSize(1, amount);
|
||||
if (!logic.getWorldObj().isRemote)
|
||||
logic.getWorldObj().playAuxSFX(1021, (int) logic.xCoord, (int) logic.yCoord, (int) logic.zCoord, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith (EntityPlayer entityplayer)
|
||||
{
|
||||
Block block = logic.getWorldObj().getBlock(logic.xCoord, logic.yCoord, logic.zCoord);
|
||||
if (block != TinkerTools.toolForge && block != TinkerTools.craftingSlabWood)
|
||||
return false;
|
||||
return logic.isUseableByPlayer(entityplayer);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,233 @@
|
||||
package tconstruct.tools.inventory;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
import tconstruct.smeltery.inventory.ActiveContainer;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import tconstruct.tools.logic.ToolStationLogic;
|
||||
|
||||
public class ToolStationContainer extends ActiveContainer
|
||||
{
|
||||
public InventoryPlayer invPlayer;
|
||||
public ToolStationLogic logic;
|
||||
public Slot[] slots;
|
||||
public SlotTool toolSlot;
|
||||
public Random random = new Random();
|
||||
|
||||
public ToolStationContainer(InventoryPlayer inventoryplayer, ToolStationLogic builderlogic)
|
||||
{
|
||||
initializeContainer(inventoryplayer, builderlogic);
|
||||
}
|
||||
|
||||
public void initializeContainer (InventoryPlayer inventoryplayer, ToolStationLogic builderlogic)
|
||||
{
|
||||
invPlayer = inventoryplayer;
|
||||
logic = builderlogic;
|
||||
|
||||
toolSlot = new SlotTool(inventoryplayer.player, builderlogic, 0, 225, 38);
|
||||
this.addSlotToContainer(toolSlot);
|
||||
slots = new Slot[] { new Slot(builderlogic, 1, 167, 29), new Slot(builderlogic, 2, 149, 38), new Slot(builderlogic, 3, 167, 47) };
|
||||
|
||||
for (int iter = 0; iter < 3; iter++)
|
||||
this.addSlotToContainer(slots[iter]);
|
||||
|
||||
/* Player inventory */
|
||||
for (int column = 0; column < 3; column++)
|
||||
{
|
||||
for (int row = 0; row < 9; row++)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(inventoryplayer, row + column * 9 + 9, 118 + row * 18, 84 + column * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (int column = 0; column < 9; column++)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(inventoryplayer, column, 118 + column * 18, 142));
|
||||
}
|
||||
}
|
||||
|
||||
// posX and posY must be the same length
|
||||
public void resetSlots (int[] posX, int[] posY)
|
||||
{
|
||||
/* Station inventory */
|
||||
inventorySlots.clear();
|
||||
inventoryItemStacks.clear();
|
||||
this.addSlotToContainer(toolSlot);
|
||||
for (int iter = 0; iter < 3; iter++)
|
||||
{
|
||||
slots[iter].xDisplayPosition = posX[iter] + 111;
|
||||
slots[iter].yDisplayPosition = posY[iter] + 1;
|
||||
addSlotToContainer(slots[iter]);
|
||||
}
|
||||
|
||||
/* Player inventory */
|
||||
for (int column = 0; column < 3; column++)
|
||||
{
|
||||
for (int row = 0; row < 9; row++)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(invPlayer, row + column * 9 + 9, 118 + row * 18, 84 + column * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (int column = 0; column < 9; column++)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(invPlayer, column, 118 + column * 18, 142));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith (EntityPlayer entityplayer)
|
||||
{
|
||||
Block block = logic.getWorldObj().getBlock(logic.xCoord, logic.yCoord, logic.zCoord);
|
||||
if (block != TinkerTools.toolStationWood && block != TinkerTools.craftingSlabWood)
|
||||
return false;
|
||||
return logic.isUseableByPlayer(entityplayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot (EntityPlayer player, int slotID)
|
||||
{
|
||||
ItemStack stack = null;
|
||||
Slot slot = (Slot) this.inventorySlots.get(slotID);
|
||||
|
||||
if (slot != null && slot.getHasStack())
|
||||
{
|
||||
ItemStack slotStack = slot.getStack();
|
||||
stack = slotStack.copy();
|
||||
if (slotID < logic.getSizeInventory())
|
||||
{
|
||||
if (slotID == 0)
|
||||
{
|
||||
if (!this.mergeCraftedStack(slotStack, logic.getSizeInventory(), this.inventorySlots.size(), true, player))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (!this.mergeItemStack(slotStack, logic.getSizeInventory(), this.inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (!this.mergeItemStack(slotStack, 1, logic.getSizeInventory(), false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (slotStack.stackSize == 0)
|
||||
{
|
||||
slot.putStack((ItemStack) null);
|
||||
}
|
||||
else
|
||||
{
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
protected void craftTool (ItemStack stack)
|
||||
{
|
||||
NBTTagCompound tags = stack.getTagCompound();
|
||||
if (!tags.getCompoundTag("InfiTool").hasKey("Built"))
|
||||
{
|
||||
tags.getCompoundTag("InfiTool").setBoolean("Built", true);
|
||||
for (int i = 2; i <= 3; i++)
|
||||
logic.decrStackSize(i, 1);
|
||||
int amount = logic.getStackInSlot(1).getItem() instanceof ToolCore ? stack.stackSize : 1;
|
||||
logic.decrStackSize(1, amount);
|
||||
|
||||
logic.getWorldObj().playSoundEffect(logic.xCoord, logic.yCoord, logic.zCoord, "tinker:little_saw", 1.0F, (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean mergeCraftedStack (ItemStack stack, int slotsStart, int slotsTotal, boolean playerInventory, EntityPlayer player)
|
||||
{
|
||||
boolean failedToMerge = false;
|
||||
int slotIndex = slotsStart;
|
||||
|
||||
if (playerInventory)
|
||||
{
|
||||
slotIndex = slotsTotal - 1;
|
||||
}
|
||||
|
||||
Slot otherInventorySlot;
|
||||
ItemStack copyStack = null;
|
||||
|
||||
/*
|
||||
* if (stack.isStackable()) { while (stack.stackSize > 0 &&
|
||||
* (!playerInventory && slotIndex < slotsTotal || playerInventory &&
|
||||
* slotIndex >= slotsStart)) { otherInventorySlot =
|
||||
* (Slot)this.inventorySlots.get(slotIndex); copyStack =
|
||||
* otherInventorySlot.getStack();
|
||||
*
|
||||
* if (copyStack != null && copyStack.itemID == stack.itemID &&
|
||||
* (!stack.getHasSubtypes() || stack.getItemDamage() ==
|
||||
* copyStack.getItemDamage()) && ItemStack.areItemStackTagsEqual(stack,
|
||||
* copyStack)) { int totalSize = copyStack.stackSize + stack.stackSize;
|
||||
*
|
||||
* if (totalSize <= stack.getMaxStackSize()) { stack.stackSize = 0;
|
||||
* copyStack.stackSize = totalSize; otherInventorySlot.onSlotChanged();
|
||||
* failedToMerge = true; } else if (copyStack.stackSize <
|
||||
* stack.getMaxStackSize()) { stack.stackSize -= stack.getMaxStackSize()
|
||||
* - copyStack.stackSize; copyStack.stackSize = stack.getMaxStackSize();
|
||||
* otherInventorySlot.onSlotChanged(); failedToMerge = true; } }
|
||||
*
|
||||
* if (playerInventory) { --slotIndex; } else { ++slotIndex; } } }
|
||||
*/
|
||||
|
||||
if (stack.stackSize > 0)
|
||||
{
|
||||
if (playerInventory)
|
||||
{
|
||||
slotIndex = slotsTotal - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
slotIndex = slotsStart;
|
||||
}
|
||||
|
||||
while (!playerInventory && slotIndex < slotsTotal || playerInventory && slotIndex >= slotsStart)
|
||||
{
|
||||
otherInventorySlot = (Slot) this.inventorySlots.get(slotIndex);
|
||||
copyStack = otherInventorySlot.getStack();
|
||||
|
||||
if (copyStack == null)
|
||||
{
|
||||
craftTool(stack);
|
||||
otherInventorySlot.putStack(stack.copy());
|
||||
otherInventorySlot.onSlotChanged();
|
||||
stack.stackSize = 0;
|
||||
failedToMerge = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (playerInventory)
|
||||
{
|
||||
--slotIndex;
|
||||
}
|
||||
else
|
||||
{
|
||||
++slotIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* boolean emptySlots = ( ((Slot) inventorySlots.get(2)).getStack() ==
|
||||
* null && ((Slot) inventorySlots.get(3)).getStack() == null );
|
||||
* TConstruct.logger.info("Empty slots"); if (!failedToMerge &&
|
||||
* emptySlots) player.worldObj.playAuxSFX(1021, (int)player.posX,
|
||||
* (int)player.posY, (int)player.posZ, 0);
|
||||
*/
|
||||
|
||||
return failedToMerge;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package tconstruct.tools.itemblocks;
|
||||
|
||||
import mantle.blocks.abstracts.MultiItemBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MathHelper;
|
||||
|
||||
public class CraftingSlabItemBlock extends MultiItemBlock
|
||||
{
|
||||
public static final String blockTypes[] = { "tile.CraftingStation", "Crafter", "Parts", "PatternShaper", "PatternChest", "tile.ToolForge" };
|
||||
|
||||
public CraftingSlabItemBlock(Block b)
|
||||
{
|
||||
super(b, "ToolStation", blockTypes);
|
||||
setMaxDamage(0);
|
||||
setHasSubtypes(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName (ItemStack itemstack)
|
||||
{
|
||||
int pos = MathHelper.clamp_int(itemstack.getItemDamage(), 0, this.blockTypes.length - 1);
|
||||
if (pos == 0 || pos == 5)
|
||||
{
|
||||
return this.blockTypes[pos];
|
||||
}
|
||||
return super.getUnlocalizedName(itemstack);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package tconstruct.tools.itemblocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mantle.blocks.abstracts.MultiItemBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class MultiBrickFancyItem extends MultiItemBlock
|
||||
{
|
||||
static String blockTypes[] = { "obsidian", "sandstone", "netherrack", "stone.refined", "iron", "gold", "lapis", "diamond", "redstone", "bone", "slime", "blueslime", "endstone", "obsidian.ingot",
|
||||
"stone", "stone.road" };
|
||||
|
||||
public MultiBrickFancyItem(Block b)
|
||||
{
|
||||
super(b, "block.fancybrick", blockTypes);
|
||||
setMaxDamage(0);
|
||||
setHasSubtypes(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation (ItemStack stack, EntityPlayer player, List list, boolean par4)
|
||||
{
|
||||
switch (stack.getItemDamage())
|
||||
{
|
||||
case 5:
|
||||
case 6:
|
||||
list.add(StatCollector.translateToLocal("fancybrick1.tooltip"));
|
||||
break;
|
||||
case 7:
|
||||
list.add(StatCollector.translateToLocal("fancybrick2.tooltip"));
|
||||
break;
|
||||
case 8:
|
||||
list.add(StatCollector.translateToLocal("fancybrick3.tooltip"));
|
||||
list.add(StatCollector.translateToLocal("fancybrick4.tooltip"));
|
||||
break;
|
||||
case 10:
|
||||
case 11:
|
||||
list.add(StatCollector.translateToLocal("fancybrick5.tooltip"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package tconstruct.tools.itemblocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mantle.blocks.abstracts.MultiItemBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class MultiBrickItem extends MultiItemBlock
|
||||
{
|
||||
static String blockTypes[] = { "obsidian", "sandstone", "netherrack", "stone.refined", "iron", "gold", "lapis", "diamond", "redstone", "bone", "slime", "blueslime", "endstone", "obsidian.ingot",
|
||||
"stone.road", "stone.refined.road" };
|
||||
|
||||
public MultiBrickItem(Block b)
|
||||
{
|
||||
super(b, "block.brick", blockTypes);
|
||||
setMaxDamage(0);
|
||||
setHasSubtypes(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation (ItemStack stack, EntityPlayer player, List list, boolean par4)
|
||||
{
|
||||
switch (stack.getItemDamage())
|
||||
{
|
||||
case 5:
|
||||
case 6:
|
||||
list.add(StatCollector.translateToLocal("brick1.tooltip"));
|
||||
break;
|
||||
case 7:
|
||||
list.add(StatCollector.translateToLocal("brick2.tooltip"));
|
||||
break;
|
||||
case 8:
|
||||
list.add(StatCollector.translateToLocal("brick3.tooltip"));
|
||||
list.add(StatCollector.translateToLocal("brick4.tooltip"));
|
||||
break;
|
||||
case 10:
|
||||
case 11:
|
||||
list.add(StatCollector.translateToLocal("brick5.tooltip"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package tconstruct.tools.itemblocks;
|
||||
|
||||
import mantle.blocks.abstracts.MultiItemBlock;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
public class ToolStationItemBlock extends MultiItemBlock
|
||||
{
|
||||
public static final String blockTypes[] = { "Crafter", "Parts", "Parts", "Parts", "Parts", "PatternChest", "PatternChest", "PatternChest", "PatternChest", "PatternChest", "PatternShaper",
|
||||
"PatternShaper", "PatternShaper", "PatternShaper", "CastingTable" };
|
||||
|
||||
public ToolStationItemBlock(Block b)
|
||||
{
|
||||
super(b, "ToolStation", blockTypes);
|
||||
setMaxDamage(0);
|
||||
setHasSubtypes(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package tconstruct.tools.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mantle.items.abstracts.CraftingItem;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.util.IToolPart;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
|
||||
public class Bowstring extends CraftingItem implements IToolPart
|
||||
{
|
||||
public Bowstring()
|
||||
{
|
||||
super(toolMaterialNames, buildTextureNames("_bowstring"), "parts/", "tinker", TConstructRegistry.materialTab);
|
||||
this.setHasSubtypes(true);
|
||||
this.setMaxDamage(0);
|
||||
}
|
||||
|
||||
private static String[] buildTextureNames (String textureType)
|
||||
{
|
||||
String[] names = new String[toolMaterialNames.length];
|
||||
for (int i = 0; i < toolMaterialNames.length; i++)
|
||||
{
|
||||
if (toolTextureNames[i].equals(""))
|
||||
names[i] = "";
|
||||
else
|
||||
names[i] = toolTextureNames[i] + textureType;
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
public static final String[] toolMaterialNames = new String[] { "string", "enchantedfabric", "flamestring" };
|
||||
|
||||
public static final String[] toolTextureNames = new String[] { "string", "magicfabric", "flamestring" };
|
||||
|
||||
@Override
|
||||
public int getMaterialID (ItemStack stack)
|
||||
{
|
||||
return stack.getItemDamage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems (Item b, CreativeTabs tab, List list)
|
||||
{
|
||||
list.add(new ItemStack(b, 1, 0));
|
||||
if (TinkerTools.thaumcraftAvailable)
|
||||
list.add(new ItemStack(b, 1, 1));
|
||||
if (Loader.isModLoaded("Natura"))
|
||||
list.add(new ItemStack(b, 1, 2));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package tconstruct.tools.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.crafting.ToolBuilder;
|
||||
import tconstruct.library.crafting.ToolRecipe;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class CreativeModifier extends Item
|
||||
{
|
||||
|
||||
public CreativeModifier()
|
||||
{
|
||||
super();
|
||||
this.setCreativeTab(TConstructRegistry.materialTab);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
/**
|
||||
* returns a list of items with the same ID, but different meta (eg: dye returns 16 items)
|
||||
*/
|
||||
@Override
|
||||
public void getSubItems (Item par1, CreativeTabs par2CreativeTabs, List par3List)
|
||||
{
|
||||
par3List.add(new ItemStack(par1, 1, 0));
|
||||
|
||||
for (ToolRecipe recipe : ToolBuilder.instance.combos)
|
||||
{
|
||||
ToolCore tool = recipe.getType();
|
||||
ItemStack item = new ItemStack(par1, 1, 0);
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setString("TargetLock", tool.getToolName());
|
||||
|
||||
item.setTagCompound(compound);
|
||||
par3List.add(item);
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerIcons (IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("tinker:skull_char_gold");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation (ItemStack stack, EntityPlayer player, List list, boolean par4)
|
||||
{
|
||||
if (stack.hasTagCompound())
|
||||
{
|
||||
String targetLock = "None";
|
||||
targetLock = stack.getTagCompound().getString("TargetLock");
|
||||
list.add(StatCollector.translateToLocal("creativeModLock.tooltip") + targetLock);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package tconstruct.tools.items;
|
||||
|
||||
import mantle.items.abstracts.CraftingItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.util.IToolPart;
|
||||
|
||||
public class Fletching extends CraftingItem implements IToolPart
|
||||
{
|
||||
public Fletching()
|
||||
{
|
||||
super(toolMaterialNames, buildTextureNames("_fletching"), "parts/", "tinker", TConstructRegistry.materialTab);
|
||||
this.setHasSubtypes(true);
|
||||
this.setMaxDamage(0);
|
||||
}
|
||||
|
||||
private static String[] buildTextureNames (String textureType)
|
||||
{
|
||||
String[] names = new String[toolMaterialNames.length];
|
||||
for (int i = 0; i < toolMaterialNames.length; i++)
|
||||
{
|
||||
if (toolTextureNames[i].equals(""))
|
||||
names[i] = "";
|
||||
else
|
||||
names[i] = toolTextureNames[i] + textureType;
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
public static final String[] toolMaterialNames = new String[] { "feather", "leaf", "slime", "blueslime" };
|
||||
|
||||
public static final String[] toolTextureNames = new String[] { "feather", "leaf", "slime", "blueslime" };
|
||||
|
||||
@Override
|
||||
public int getMaterialID (ItemStack stack)
|
||||
{
|
||||
return stack.getItemDamage();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package tconstruct.tools.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mantle.books.BookData;
|
||||
import mantle.client.gui.GuiManual;
|
||||
import mantle.items.abstracts.CraftingItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.achievements.TAchievements;
|
||||
import tconstruct.client.TProxyClient;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class Manual extends CraftingItem
|
||||
{
|
||||
static String[] name = new String[] { "beginner", "toolstation", "smeltery", "diary" };
|
||||
static String[] textureName = new String[] { "tinkerbook_diary", "tinkerbook_toolstation", "tinkerbook_smeltery", "tinkerbook_blue" };
|
||||
|
||||
public Manual()
|
||||
{
|
||||
super(name, textureName, "", "tinker", TConstructRegistry.materialTab);
|
||||
setUnlocalizedName("tconstruct.manual");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public ItemStack onItemRightClick (ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
player.addStat(TAchievements.achievements.get("tconstruct:beginner"), 1);
|
||||
Side side = FMLCommonHandler.instance().getEffectiveSide();
|
||||
player.openGui(TConstruct.instance, mantle.client.MProxyClient.manualGuiID, world, 0, 0, 0);
|
||||
FMLClientHandler.instance().displayGuiScreen(player, new GuiManual(stack, getData(stack)));
|
||||
return stack;
|
||||
}
|
||||
|
||||
private BookData getData (ItemStack stack)
|
||||
{
|
||||
switch (stack.getItemDamage())
|
||||
{
|
||||
case 0:
|
||||
return TProxyClient.manualData.beginner;
|
||||
case 1:
|
||||
return TProxyClient.manualData.toolStation;
|
||||
case 2:
|
||||
return TProxyClient.manualData.smeltery;
|
||||
default:
|
||||
return TProxyClient.manualData.diary;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation (ItemStack stack, EntityPlayer player, List list, boolean par4)
|
||||
{
|
||||
switch (stack.getItemDamage())
|
||||
{
|
||||
case 0:
|
||||
list.add("\u00a7o" + StatCollector.translateToLocal("manual1.tooltip"));
|
||||
break;
|
||||
case 1:
|
||||
list.add("\u00a7o" + StatCollector.translateToLocal("manual2.tooltip"));
|
||||
break;
|
||||
case 2:
|
||||
list.add("\u00a7o" + StatCollector.translateToLocal("manual3.tooltip"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package tconstruct.tools.items;
|
||||
|
||||
import mantle.books.BookData;
|
||||
import mantle.books.BookDataStore;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
import tconstruct.client.TProxyClient;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
public class ManualInfo
|
||||
{
|
||||
// static String[] name = new String[] { "beginner", "toolstation", "smeltery", "diary" };
|
||||
// static String[] textureName = new String[] { "tinkerbook_diary", "tinkerbook_toolstation", "tinkerbook_smeltery", "tinkerbook_blue" };
|
||||
|
||||
BookData beginner = new BookData();
|
||||
BookData toolStation = new BookData();
|
||||
BookData smeltery = new BookData();
|
||||
BookData diary = new BookData();
|
||||
|
||||
/* diary = readManual("/assets/tinker/manuals/diary.xml", dbFactory);
|
||||
volume1 = readManual("/assets/tinker/manuals/firstday.xml", dbFactory);
|
||||
volume2 = readManual("/assets/tinker/manuals/materials.xml", dbFactory);
|
||||
smelter = readManual("/assets/tinker/manuals/smeltery.xml", dbFactory);*/
|
||||
|
||||
public ManualInfo()
|
||||
{
|
||||
Side side = FMLCommonHandler.instance().getEffectiveSide();
|
||||
beginner = initManual(beginner, "tconstruct.manual.beginner", "\u00a7o" + StatCollector.translateToLocal("manual1.tooltip"), side == Side.CLIENT ? TProxyClient.volume1 : null,
|
||||
"tinker:tinkerbook_diary");
|
||||
toolStation = initManual(toolStation, "tconstruct.manual.toolstation", "\u00a7o" + StatCollector.translateToLocal("manual2.tooltip"), side == Side.CLIENT ? TProxyClient.volume2 : null,
|
||||
"tinker:tinkerbook_toolstation");
|
||||
smeltery = initManual(smeltery, "tconstruct.manual.smeltery", "\u00a7o" + StatCollector.translateToLocal("manual3.tooltip"), side == Side.CLIENT ? TProxyClient.smelter : null,
|
||||
"tinker:tinkerbook_smeltery");
|
||||
diary = initManual(diary, "tconstruct.manual.diary", "\u00a7o" + StatCollector.translateToLocal("manual4.tooltip"), side == Side.CLIENT ? TProxyClient.diary : null, "tinker:tinkerbook_blue");
|
||||
|
||||
}
|
||||
|
||||
public BookData initManual (BookData data, String unlocName, String toolTip, Document xmlDoc, String itemImage)
|
||||
{
|
||||
//proxy.readManuals();
|
||||
data.unlocalizedName = unlocName;
|
||||
data.toolTip = unlocName;
|
||||
data.modID = "TConstruct";
|
||||
data.itemImage = new ResourceLocation(data.modID, itemImage);
|
||||
data.doc = xmlDoc;
|
||||
BookDataStore.addBook(data);
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package tconstruct.tools.items;
|
||||
|
||||
import mantle.items.abstracts.CraftingItem;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
|
||||
public class MaterialItem extends CraftingItem
|
||||
{
|
||||
|
||||
public MaterialItem()
|
||||
{
|
||||
super(materialNames, getTextures(), "materials/", "tinker", TConstructRegistry.materialTab);
|
||||
}
|
||||
|
||||
private static String[] getTextures ()
|
||||
{
|
||||
String[] names = new String[craftingTextures.length];
|
||||
for (int i = 0; i < craftingTextures.length; i++)
|
||||
{
|
||||
if (craftingTextures[i].equals(""))
|
||||
names[i] = "";
|
||||
else
|
||||
names[i] = "material_" + craftingTextures[i];
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
static String[] materialNames = new String[] { "PaperStack", "SlimeCrystal", "SearedBrick", "CobaltIngot", "ArditeIngot", "ManyullynIngot", "Mossball", "LavaCrystal", "NecroticBone",
|
||||
"CopperIngot", "TinIngot", "AluminumIngot", "RawAluminum", "BronzeIngot", "AluBrassIngot", "AlumiteIngot", "SteelIngot", "BlueSlimeCrystal", "ObsidianIngot", "IronNugget", "CopperNugget",
|
||||
"TinNugget", "AluminumNugget", "EssenceCrystal", "AluBrassNugget", "SilkyCloth", "SilkyJewel", "ObsidianNugget", "CobaltNugget", "ArditeNugget", "ManyullynNugget", "BronzeNugget",
|
||||
"AlumiteNugget", "SteelNugget", "PigIronIngot", "PigIronNugget", "GlueBall", "SearedBrick", "ArditeDust", "CobaltDust", "AluminumDust", "ManyullynDust", "AluBrassDust" };
|
||||
|
||||
static String[] craftingTextures = new String[] { "paperstack", "slimecrystal", "searedbrick", "cobaltingot", "arditeingot", "manyullyningot", "mossball", "lavacrystal", "necroticbone",
|
||||
"copperingot", "tiningot", "aluminumingot", "aluminumraw", "bronzeingot", "alubrassingot", "alumiteingot", "steelingot", "blueslimecrystal", "obsidianingot", "nugget_iron",
|
||||
"nugget_copper", "nugget_tin", "nugget_aluminum", "", "nugget_alubrass", "silkycloth", "silkyjewel", "nugget_obsidian", "nugget_cobalt", "nugget_ardite", "nugget_manyullyn",
|
||||
"nugget_bronze", "nugget_alumite", "nugget_steel", "pigironingot", "nugget_pigiron", "glueball", "searedbrick_nether", "ardite_dust", "cobalt_dust", "aluminium_dust", "manyullyn_dust",
|
||||
"alubrass_dust" };
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
package tconstruct.tools.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mantle.items.abstracts.CraftingItem;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.crafting.PatternBuilder.MaterialSet;
|
||||
import tconstruct.library.util.IPattern;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class Pattern extends CraftingItem implements IPattern
|
||||
{
|
||||
public Pattern(String patternType, String folder)
|
||||
{
|
||||
this(patternName, getPatternNames(patternType), folder);
|
||||
}
|
||||
|
||||
public Pattern(String[] names, String[] patternTypes, String folder)
|
||||
{
|
||||
super(names, patternTypes, folder, "tinker", TConstructRegistry.materialTab);
|
||||
this.setHasSubtypes(true);
|
||||
this.setMaxDamage(0);
|
||||
this.setContainerItem(this);
|
||||
this.setMaxStackSize(1);
|
||||
}
|
||||
|
||||
protected static String[] getPatternNames (String partType)
|
||||
{
|
||||
String[] names = new String[patternName.length];
|
||||
for (int i = 0; i < patternName.length; i++)
|
||||
names[i] = partType + patternName[i];
|
||||
return names;
|
||||
}
|
||||
|
||||
private static final String[] patternName = new String[] { "ingot", "rod", "pickaxe", "shovel", "axe", "swordblade", "largeguard", "mediumguard", "crossbar", "binding", "frypan", "sign",
|
||||
"knifeblade", "chisel", "largerod", "toughbinding", "largeplate", "broadaxe", "scythe", "excavator", "largeblade", "hammerhead", "fullguard", "bowstring", "fletching", "arrowhead" };
|
||||
|
||||
@Override
|
||||
public void getSubItems (Item b, CreativeTabs tab, List list)
|
||||
{
|
||||
for (int i = 1; i < patternName.length; i++)
|
||||
{
|
||||
// if (i != 23)
|
||||
list.add(new ItemStack(b, 1, i));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getContainerItem (ItemStack stack)
|
||||
{
|
||||
if (stack.stackSize <= 0)
|
||||
return null;
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesContainerItemLeaveCraftingGrid (ItemStack stack)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Tags and information about the pattern */
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation (ItemStack stack, EntityPlayer player, List list, boolean par4)
|
||||
{
|
||||
float cost = getPatternCost(stack) / 2f;
|
||||
if (cost > 0)
|
||||
{
|
||||
if (cost - (int) cost < 0.1)
|
||||
list.add(StatCollector.translateToLocal("pattern1.tooltip") + (int) cost);
|
||||
else
|
||||
list.add(StatCollector.translateToLocal("pattern2.tooltip") + cost);
|
||||
}
|
||||
}
|
||||
|
||||
// 2 for full material, 1 for half.
|
||||
@Override
|
||||
public int getPatternCost (ItemStack pattern)
|
||||
{
|
||||
switch (pattern.getItemDamage())
|
||||
{
|
||||
case 0:
|
||||
return 2;
|
||||
case 1:
|
||||
return 1;
|
||||
case 2:
|
||||
return 2;
|
||||
case 3:
|
||||
return 2;
|
||||
case 4:
|
||||
return 2;
|
||||
case 5:
|
||||
return 2;
|
||||
case 6:
|
||||
return 1;
|
||||
case 7:
|
||||
return 1;
|
||||
case 8:
|
||||
return 1;
|
||||
case 9:
|
||||
return 1;
|
||||
case 10:
|
||||
return 2;
|
||||
case 11:
|
||||
return 2;
|
||||
case 12:
|
||||
return 1;
|
||||
case 13:
|
||||
return 1;
|
||||
case 14:
|
||||
return 6;
|
||||
case 15:
|
||||
return 6;
|
||||
case 16:
|
||||
return 16;
|
||||
case 17:
|
||||
return 16;
|
||||
case 18:
|
||||
return 16;
|
||||
case 19:
|
||||
return 16;
|
||||
case 20:
|
||||
return 16;
|
||||
case 21:
|
||||
return 16;
|
||||
case 22:
|
||||
return 6;
|
||||
case 23:
|
||||
return 6;
|
||||
case 24:
|
||||
return 2;
|
||||
case 25:
|
||||
return 2;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPatternOutput (ItemStack stack, ItemStack input, MaterialSet set)
|
||||
{
|
||||
return TConstructRegistry.getPartMapping((Item) this, stack.getItemDamage(), set.materialID);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,228 @@
|
||||
package tconstruct.tools.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.IEntityLivingData;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Facing;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.client.TProxyClient;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
import tconstruct.world.entity.BlueSlime;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class TitleIcon extends Item
|
||||
{
|
||||
int[] primaryColor = { 0x66BBE8, 0x66BBE8 };
|
||||
int[] secondaryColor = { 0x1567BF, 0xFFEC6E };
|
||||
String[] mobNames = { "TConstruct.EdibleSlime", "TConstruct.KingSlime" };
|
||||
|
||||
String[] achievementIconNames = new String[] { "tinkerer", "preparedFight", "proTinkerer", "enemySlayer", "dualConvenience" };
|
||||
IIcon[] achievementIcons = new IIcon[achievementIconNames.length];
|
||||
|
||||
public TitleIcon()
|
||||
{
|
||||
super();
|
||||
this.setCreativeTab(CreativeTabs.tabMisc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons (IIconRegister iconRegister)
|
||||
{
|
||||
ToolCore.blankSprite = iconRegister.registerIcon("tinker:blanksprite");
|
||||
TProxyClient.metalBall = iconRegister.registerIcon("tinker:metalball");
|
||||
itemIcon = iconRegister.registerIcon("tinker:tparts");
|
||||
for (int i = 0; i < achievementIcons.length; i++)
|
||||
{
|
||||
achievementIcons[i] = iconRegister.registerIcon("tinker:achievementIcons/" + (i < achievementIconNames.length ? achievementIconNames[i] : ""));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean requiresMultipleRenderPasses ()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIconFromDamageForRenderPass (int par1, int par2)
|
||||
{
|
||||
if (par1 == 255)
|
||||
return itemIcon;
|
||||
if (par1 >= 4096)
|
||||
{
|
||||
return getIconFromDamage(par1);
|
||||
}
|
||||
return new ItemStack(Blocks.mob_spawner).getItem().getIconFromDamageForRenderPass(par1, par2);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIconFromDamage (int par1)
|
||||
{
|
||||
if (par1 >= 4096)
|
||||
{
|
||||
int index = par1 - 4096;
|
||||
if (index < achievementIcons.length)
|
||||
{
|
||||
return achievementIcons[index];
|
||||
}
|
||||
}
|
||||
// Not returning null to prevent crashes
|
||||
return itemIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName (ItemStack par1ItemStack)
|
||||
{
|
||||
String s = ("" + StatCollector.translateToLocal(this.getUnlocalizedName() + ".name")).trim();
|
||||
String s1 = mobNames[par1ItemStack.getItemDamage()];
|
||||
|
||||
if (s1 != null)
|
||||
{
|
||||
s = s + " " + StatCollector.translateToLocal("entity." + s1 + ".name");
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems (Item b, CreativeTabs tab, List list)
|
||||
{
|
||||
for (int i = 0; i < mobNames.length; i++)
|
||||
list.add(new ItemStack(b, 1, i));
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getColorFromItemStack (ItemStack stack, int pass)
|
||||
{
|
||||
int damage = stack.getItemDamage();
|
||||
if (damage == 255)
|
||||
return 0xffffff;
|
||||
if (damage >= 4096)
|
||||
return 0xffffff;
|
||||
return pass == 0 ? primaryColor[damage] : secondaryColor[damage];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse (ItemStack stack, EntityPlayer player, World world, int posX, int posY, int posZ, int par7, float par8, float par9, float par10)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
Block b = world.getBlock(posX, posY, posZ);
|
||||
posX += Facing.offsetsXForSide[par7];
|
||||
posY += Facing.offsetsYForSide[par7];
|
||||
posZ += Facing.offsetsZForSide[par7];
|
||||
double d0 = 0.0D;
|
||||
|
||||
if (par7 == 1 && b != null && b.getRenderType() == 11)
|
||||
{
|
||||
d0 = 0.5D;
|
||||
}
|
||||
|
||||
int damage = stack.getItemDamage();
|
||||
switch (damage)
|
||||
{
|
||||
case 0:
|
||||
spawnEntity(posX, posY, posZ, new BlueSlime(world), world, player);
|
||||
break;
|
||||
case 1:
|
||||
spawnBossSlime(posX, posY, posZ, new BlueSlime(world), world, player);
|
||||
break;
|
||||
}
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
{
|
||||
--stack.stackSize;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static EntityLiving activateSpawnEgg (ItemStack stack, World world, double posX, double posY, double posZ, int par7)
|
||||
{
|
||||
Block b = world.getBlock((int) posX, (int) posY, (int) posZ);
|
||||
posX += Facing.offsetsXForSide[par7];
|
||||
posY += Facing.offsetsYForSide[par7];
|
||||
posZ += Facing.offsetsZForSide[par7];
|
||||
double d0 = 0.0D;
|
||||
|
||||
if (par7 == 1 && b != null && b.getRenderType() == 11)
|
||||
{
|
||||
d0 = 0.5D;
|
||||
}
|
||||
|
||||
int damage = stack.getItemDamage();
|
||||
EntityLiving entity = null;
|
||||
switch (damage)
|
||||
{
|
||||
case 0:
|
||||
entity = new BlueSlime(world);
|
||||
spawnEntity(posX, posY, posZ, entity, world);
|
||||
break;
|
||||
case 1:
|
||||
entity = new BlueSlime(world);
|
||||
spawnBossSlime(posX, posY, posZ, new BlueSlime(world), world);
|
||||
break;
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
|
||||
public static void spawnEntity (double x, double y, double z, Entity entity, World world)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
entity.setPosition(x, y, z);
|
||||
((EntityLiving) entity).onSpawnWithEgg((IEntityLivingData) null);
|
||||
world.spawnEntityInWorld(entity);
|
||||
}
|
||||
}
|
||||
|
||||
public static void spawnEntity (double x, double y, double z, Entity entity, World world, EntityPlayer player)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
entity.setPosition(x, y, z);
|
||||
if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT)
|
||||
entity.setAngles(player.cameraYaw, player.cameraYaw);
|
||||
((EntityLiving) entity).onSpawnWithEgg((IEntityLivingData) null);
|
||||
world.spawnEntityInWorld(entity);
|
||||
}
|
||||
}
|
||||
|
||||
public static void spawnBossSlime (double x, double y, double z, BlueSlime entity, World world, EntityPlayer player)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
entity.setPosition(x, y, z);
|
||||
entity.setSlimeSize(8);
|
||||
entity.onSpawnWithEgg((IEntityLivingData) null);
|
||||
world.spawnEntityInWorld(entity);
|
||||
}
|
||||
}
|
||||
|
||||
public static void spawnBossSlime (double x, double y, double z, BlueSlime entity, World world)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
entity.setPosition(x, y, z);
|
||||
entity.setSlimeSize(8);
|
||||
entity.onSpawnWithEgg((IEntityLivingData) null);
|
||||
world.spawnEntityInWorld(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package tconstruct.tools.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mantle.items.abstracts.CraftingItem;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.util.IToolPart;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
|
||||
public class ToolPart extends CraftingItem implements IToolPart
|
||||
{
|
||||
public String partName;
|
||||
|
||||
public ToolPart(String textureType, String name)
|
||||
{
|
||||
super(toolMaterialNames, buildTextureNames(textureType), "parts/", "tinker", TConstructRegistry.materialTab);
|
||||
this.setCreativeTab(TConstructRegistry.partTab);
|
||||
this.setHasSubtypes(true);
|
||||
this.setMaxDamage(0);
|
||||
this.partName = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName (ItemStack par1ItemStack)
|
||||
{
|
||||
String material = StatCollector.translateToLocal("parttype." + toolTextureNames[par1ItemStack.getItemDamage()]);
|
||||
String name = StatCollector.translateToLocal("toolpart." + partName);
|
||||
name = name.replaceAll("%%material", material);
|
||||
|
||||
return name;
|
||||
|
||||
/*
|
||||
* StringBuilder builder = new StringBuilder();
|
||||
* builder.append(StatCollector.translateToLocal("parttype." +
|
||||
* toolTextureNames
|
||||
* [par1ItemStack.getItemDamage()])).append(" ").append(StatCollector
|
||||
* .translateToLocal("toolpart." + partName)); return
|
||||
* builder.toString(); -- String s = ("" +
|
||||
* StatCollector.translateToLocal("toolpart."+partName)).trim(); String
|
||||
* s1 = toolMaterialNames[par1ItemStack.getItemDamage()];
|
||||
*
|
||||
* if (s1 != null) { s = s + " " + StatCollector.translateToLocal(s1); }
|
||||
*
|
||||
* return s;
|
||||
*/
|
||||
}
|
||||
|
||||
private static String[] buildTextureNames (String textureType)
|
||||
{
|
||||
String[] names = new String[toolMaterialNames.length];
|
||||
for (int i = 0; i < toolMaterialNames.length; i++)
|
||||
{
|
||||
if (toolTextureNames[i].equals(""))
|
||||
names[i] = "";
|
||||
else
|
||||
names[i] = toolTextureNames[i] + textureType;
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
public static final String[] toolMaterialNames = new String[] { "Wood", "Stone", "Iron", "Flint", "Cactus", "Bone", "Obsidian", "Netherrack", "Slime", "Paper", "Cobalt", "Ardite", "Manyullyn",
|
||||
"Copper", "Bronze", "Alumite", "Steel", "Blue Slime", "Pig Iron", "", "", "", "", "", "", "", "", "", "", "", "", "Thaumium" };
|
||||
|
||||
public static final String[] toolTextureNames = new String[] { "wood", "stone", "iron", "flint", "cactus", "bone", "obsidian", "netherrack", "slime", "paper", "cobalt", "ardite", "manyullyn",
|
||||
"copper", "bronze", "alumite", "steel", "blueslime", "pigiron", "", "", "", "", "", "", "", "", "", "", "", "", "thaumium" };
|
||||
|
||||
@Override
|
||||
public void getSubItems (Item b, CreativeTabs tab, List list)
|
||||
{
|
||||
for (int i = 0; i < 19; i++)
|
||||
list.add(new ItemStack(b, 1, i));
|
||||
|
||||
if (TinkerTools.thaumcraftAvailable)
|
||||
list.add(new ItemStack(b, 1, 31));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaterialID (ItemStack stack)
|
||||
{
|
||||
return stack.getItemDamage();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package tconstruct.tools.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
public class ToolPartHidden extends ToolPart
|
||||
{
|
||||
|
||||
public ToolPartHidden(String textureType, String name)
|
||||
{
|
||||
super(textureType, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems (Item id, CreativeTabs tab, List list)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package tconstruct.tools.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ToolShard extends ToolPart
|
||||
{
|
||||
|
||||
public ToolShard(String tex)
|
||||
{
|
||||
super(tex, "ToolShard");
|
||||
this.setHasSubtypes(true);
|
||||
this.setMaxDamage(0);
|
||||
}
|
||||
|
||||
private static String[] buildTextureNames (String textureType)
|
||||
{
|
||||
String[] names = new String[toolMaterialNames.length];
|
||||
for (int i = 0; i < toolMaterialNames.length; i++)
|
||||
{
|
||||
if (!toolTextureNames[i].equals(""))
|
||||
names[i] = toolTextureNames[i] + textureType;
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons (IIconRegister iconRegister)
|
||||
{
|
||||
this.icons = new IIcon[textureNames.length];
|
||||
|
||||
for (int i = 0; i < 5; ++i)
|
||||
{
|
||||
this.icons[i] = iconRegister.registerIcon("tinker:" + folder + textureNames[i]);
|
||||
}
|
||||
icons[5] = icons[4];
|
||||
for (int i = 6; i < 9; ++i)
|
||||
{
|
||||
this.icons[i] = iconRegister.registerIcon("tinker:" + folder + textureNames[i]);
|
||||
}
|
||||
icons[9] = icons[8];
|
||||
for (int i = 10; i < icons.length; ++i)
|
||||
{
|
||||
if (!toolTextureNames[i].equals(""))
|
||||
this.icons[i] = iconRegister.registerIcon("tinker:" + folder + textureNames[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems (Item b, CreativeTabs tab, List list)
|
||||
{
|
||||
for (int i = 1; i < 5; i++)
|
||||
list.add(new ItemStack(b, 1, i));
|
||||
for (int i = 6; i < 9; i++)
|
||||
list.add(new ItemStack(b, 1, i));
|
||||
for (int i = 10; i < 19; i++)
|
||||
list.add(new ItemStack(b, 1, i));
|
||||
|
||||
if (TinkerTools.thaumcraftAvailable)
|
||||
list.add(new ItemStack(b, 1, 31));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package tconstruct.tools.logic;
|
||||
|
||||
import tconstruct.tools.inventory.FrypanContainer;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemFood;
|
||||
import net.minecraft.item.ItemHoe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemSword;
|
||||
import net.minecraft.item.ItemTool;
|
||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
/* Slots
|
||||
* 0: Battlesign item
|
||||
*/
|
||||
|
||||
public class BattlesignLogic extends EquipLogic
|
||||
{
|
||||
|
||||
public BattlesignLogic()
|
||||
{
|
||||
super(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultName ()
|
||||
{
|
||||
return "decoration.battlesign";
|
||||
}
|
||||
|
||||
/* NBT */
|
||||
public void readFromNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.readFromNBT(tags);
|
||||
}
|
||||
|
||||
public void writeToNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.writeToNBT(tags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
|
||||
{
|
||||
return null; //Not a normal gui block
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName ()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory ()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory ()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
package tconstruct.tools.logic;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityChest;
|
||||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.tools.inventory.CraftingStationContainer;
|
||||
|
||||
public class CraftingStationLogic extends InventoryLogic implements ISidedInventory
|
||||
{
|
||||
public WeakReference<IInventory> chest; // TODO: These are prototypes
|
||||
public WeakReference<IInventory> doubleChest;
|
||||
public WeakReference<IInventory> patternChest;
|
||||
public WeakReference<IInventory> furnace;
|
||||
public boolean tinkerTable;
|
||||
public boolean stencilTable;
|
||||
public boolean doubleFirst;
|
||||
|
||||
public CraftingStationLogic()
|
||||
{
|
||||
super(17); // 9 for crafting, 1 for output, 6 for extensions, 1 for
|
||||
// plans
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
|
||||
{
|
||||
chest = null;
|
||||
doubleChest = null;
|
||||
patternChest = null;
|
||||
furnace = null;
|
||||
tinkerTable = false;
|
||||
int[] ys = {y, y - 1, y + 1};
|
||||
for (byte iy = 0; iy < 3; iy++)
|
||||
{
|
||||
int yPos = ys[iy];
|
||||
for (int xPos = x - 1; xPos <= x + 1; xPos++)
|
||||
{
|
||||
for (int zPos = z - 1; zPos <= z + 1; zPos++)
|
||||
{
|
||||
TileEntity tile = world.getTileEntity(xPos, yPos, zPos);
|
||||
if (chest == null && tile instanceof TileEntityChest)
|
||||
{
|
||||
chest = new WeakReference(tile);
|
||||
checkForChest(world, xPos, yPos, zPos, 1, 0);
|
||||
checkForChest(world, xPos, yPos, zPos, -1, 0);
|
||||
checkForChest(world, xPos, yPos, zPos, 0, 1);
|
||||
checkForChest(world, xPos, yPos, zPos, 0, -1);
|
||||
}
|
||||
else if (patternChest == null && tile instanceof PatternChestLogic)
|
||||
patternChest = new WeakReference(tile);
|
||||
else if (furnace == null && (tile instanceof TileEntityFurnace || tile instanceof FurnaceLogic))
|
||||
furnace = new WeakReference(tile);
|
||||
else if (tinkerTable == false && tile instanceof ToolStationLogic)
|
||||
tinkerTable = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new CraftingStationContainer(inventoryplayer, this, x, y, z);
|
||||
}
|
||||
|
||||
void checkForChest (World world, int x, int y, int z, int dx, int dz)
|
||||
{
|
||||
TileEntity tile = world.getTileEntity(x + dx, y, z + dz);
|
||||
if (tile instanceof TileEntityChest)
|
||||
{
|
||||
doubleChest = new WeakReference(tile);
|
||||
doubleFirst = dx + dz < 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultName ()
|
||||
{
|
||||
return "crafters.CraftingStation";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDropInventorySlot (int slot)
|
||||
{
|
||||
if (slot == 0)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide (int var1)
|
||||
{
|
||||
return new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem (int i, ItemStack itemstack, int j)
|
||||
{
|
||||
return i != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize (int slot, int quantity)
|
||||
{
|
||||
if (slot == 0)
|
||||
{
|
||||
for (int i = 1; i < getSizeInventory(); i++)
|
||||
decrStackSize(i, 1);
|
||||
}
|
||||
return super.decrStackSize(slot, quantity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem (int i, ItemStack itemstack, int j)
|
||||
{
|
||||
return i == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName ()
|
||||
{
|
||||
return getDefaultName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName ()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory ()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory ()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUpdate ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package tconstruct.tools.logic;
|
||||
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/* Slots
|
||||
* 0: Frying pan item
|
||||
* 1: Fuel
|
||||
* 2-9: Food
|
||||
*/
|
||||
|
||||
public abstract class EquipLogic extends InventoryLogic
|
||||
{
|
||||
|
||||
public EquipLogic(int invSize)
|
||||
{
|
||||
super(invSize);
|
||||
}
|
||||
|
||||
public void setEquipmentItem (ItemStack stack)
|
||||
{
|
||||
inventory[0] = stack.copy();
|
||||
}
|
||||
|
||||
public boolean hasEquipmentItem ()
|
||||
{
|
||||
return inventory[0] != null;
|
||||
}
|
||||
|
||||
public ItemStack getEquipmentItem ()
|
||||
{
|
||||
return inventory[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents (int slot, ItemStack stack)
|
||||
{
|
||||
if (slot == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
super.setInventorySlotContents(slot, stack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot (int slot)
|
||||
{
|
||||
return slot != 0 ? inventory[slot] : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStackInSlot (int slot)
|
||||
{
|
||||
return slot != 0 ? inventory[slot] != null : false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,324 @@
|
||||
package tconstruct.tools.logic;
|
||||
|
||||
import tconstruct.tools.inventory.FrypanContainer;
|
||||
import mantle.blocks.BlockUtils;
|
||||
import mantle.blocks.iface.IActiveLogic;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemFood;
|
||||
import net.minecraft.item.ItemHoe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemSword;
|
||||
import net.minecraft.item.ItemTool;
|
||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
/* Slots
|
||||
* 0: Frying pan item
|
||||
* 1: Fuel
|
||||
* 2-9: Food
|
||||
*/
|
||||
|
||||
public class FrypanLogic extends EquipLogic implements IActiveLogic
|
||||
{
|
||||
boolean active;
|
||||
public int fuel;
|
||||
public int fuelGague;
|
||||
public int progress;
|
||||
|
||||
public FrypanLogic()
|
||||
{
|
||||
super(10);
|
||||
active = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultName ()
|
||||
{
|
||||
return "crafters.frypan";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getActive ()
|
||||
{
|
||||
return active;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActive (boolean flag)
|
||||
{
|
||||
active = flag;
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
/* Fuel gauge */
|
||||
public int gaugeProgressScaled (int scale)
|
||||
{
|
||||
return (progress * scale) / 1000;
|
||||
}
|
||||
|
||||
public int gaugeFuelScaled (int scale)
|
||||
{
|
||||
if (fuelGague == 0)
|
||||
{
|
||||
fuelGague = fuel;
|
||||
if (fuelGague == 0)
|
||||
{
|
||||
fuelGague = 1000;
|
||||
}
|
||||
}
|
||||
return (fuel * scale) / fuelGague;
|
||||
}
|
||||
|
||||
/* Item cooking */
|
||||
@Override
|
||||
public void updateEntity ()
|
||||
{
|
||||
boolean burning = isBurning();
|
||||
boolean updateInventory = false;
|
||||
if (fuel <= 0 && canCook())
|
||||
{
|
||||
fuel = fuelGague = (int) (getItemBurnTime(inventory[1]) * 2.5);
|
||||
if (fuel > 0)
|
||||
{
|
||||
if (inventory[1].getItem().hasContainerItem()) //Fuel slot
|
||||
{
|
||||
inventory[1] = new ItemStack(inventory[1].getItem().getContainerItem());
|
||||
}
|
||||
else
|
||||
{
|
||||
inventory[1].stackSize--;
|
||||
}
|
||||
if (inventory[1].stackSize <= 0)
|
||||
{
|
||||
inventory[1] = null;
|
||||
}
|
||||
updateInventory = true;
|
||||
}
|
||||
}
|
||||
if (isBurning() && canCook())
|
||||
{
|
||||
progress++;
|
||||
if (progress >= 1000)
|
||||
{
|
||||
progress = 0;
|
||||
cookItems();
|
||||
updateInventory = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
progress = 0;
|
||||
}
|
||||
if (fuel > 0)
|
||||
{
|
||||
fuel--;
|
||||
}
|
||||
if (burning != isBurning())
|
||||
{
|
||||
setActive(isBurning());
|
||||
updateInventory = true;
|
||||
}
|
||||
if (updateInventory)
|
||||
{
|
||||
markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public void cookItems ()
|
||||
{
|
||||
if (!canCook())
|
||||
return;
|
||||
|
||||
for (int id = 2; id < 10; id++) //Check every slot
|
||||
{
|
||||
if (canCook())
|
||||
{
|
||||
ItemStack result = getResultFor(inventory[id]);
|
||||
if (result != null)
|
||||
{
|
||||
int ids = 2;
|
||||
boolean placed = false;
|
||||
while (ids < 10 && !placed) //Try to merge stacks first
|
||||
{
|
||||
if (inventory[ids] != null && inventory[ids].isItemEqual(result) && inventory[ids].stackSize < inventory[ids].getMaxStackSize())
|
||||
{
|
||||
if (inventory[ids].stackSize + result.stackSize <= inventory[ids].getMaxStackSize())
|
||||
{
|
||||
inventory[ids].stackSize += result.stackSize;
|
||||
placed = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
int decrement = inventory[ids].getMaxStackSize() - inventory[ids].stackSize;
|
||||
inventory[ids].stackSize = inventory[ids].getMaxStackSize();
|
||||
result.stackSize -= decrement;
|
||||
}
|
||||
}
|
||||
ids++;
|
||||
}
|
||||
|
||||
ids = 2;
|
||||
while (!placed && ids < 10) //Place remaining in slot
|
||||
{
|
||||
if (inventory[ids] == null)
|
||||
{
|
||||
inventory[ids] = result;
|
||||
placed = true;
|
||||
}
|
||||
ids++;
|
||||
}
|
||||
|
||||
if (placed)
|
||||
decrStackSize(id, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canCook ()
|
||||
{
|
||||
for (int id = 2; id < 10; id++)
|
||||
{
|
||||
if (inventory[id] == null) //Nothing here!
|
||||
continue;
|
||||
|
||||
ItemStack result = getResultFor(inventory[id]);
|
||||
if (result == null) //Doesn't cook into anything
|
||||
continue;
|
||||
|
||||
for (int slotid = 2; slotid < 10; slotid++)
|
||||
{
|
||||
if (inventory[slotid] == null)
|
||||
return true;
|
||||
|
||||
else if (inventory[slotid].isItemEqual(result) && inventory[slotid].stackSize + result.stackSize <= inventory[slotid].getMaxStackSize())
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isBurning ()
|
||||
{
|
||||
return fuel > 0;
|
||||
}
|
||||
|
||||
public ItemStack getResultFor (ItemStack stack)
|
||||
{
|
||||
if (stack == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(stack);
|
||||
if (result != null && result.getItem() instanceof ItemFood) //Only valid for food
|
||||
return result.copy();
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static int getItemBurnTime (ItemStack stack)
|
||||
{
|
||||
if (stack == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Item item = stack.getItem();
|
||||
|
||||
if (stack.getItem() instanceof ItemBlock && BlockUtils.getBlockFromItem(item) != null)
|
||||
{
|
||||
Block block = BlockUtils.getBlockFromItem(item);
|
||||
|
||||
if (block == Blocks.wooden_slab)
|
||||
{
|
||||
return 150;
|
||||
}
|
||||
|
||||
if (block == Blocks.log)
|
||||
{
|
||||
return 2400;
|
||||
}
|
||||
|
||||
if (block.getMaterial() == Material.wood)
|
||||
{
|
||||
return 300;
|
||||
}
|
||||
}
|
||||
if (item instanceof ItemTool && ((ItemTool) item).getToolMaterialName().equals("WOOD"))
|
||||
return 200;
|
||||
if (item instanceof ItemSword && ((ItemSword) item).getToolMaterialName().equals("WOOD"))
|
||||
return 200;
|
||||
if (item instanceof ItemHoe && ((ItemHoe) item).getToolMaterialName().equals("WOOD"))
|
||||
return 200;
|
||||
if (item == Items.stick)
|
||||
return 100;
|
||||
if (item == Items.coal)
|
||||
return 800;
|
||||
if (item == Items.lava_bucket)
|
||||
return 20000;
|
||||
if (new ItemStack(item).equals(new ItemStack(Blocks.sapling)))
|
||||
return 100;
|
||||
if (item == Items.blaze_rod)
|
||||
return 2400;
|
||||
return GameRegistry.getFuelValue(stack);
|
||||
}
|
||||
}
|
||||
|
||||
/* NBT */
|
||||
public void readFromNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.readFromNBT(tags);
|
||||
active = tags.getBoolean("Active");
|
||||
fuel = tags.getInteger("Fuel");
|
||||
fuelGague = tags.getInteger("FuelGague");
|
||||
}
|
||||
|
||||
public void writeToNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.writeToNBT(tags);
|
||||
tags.setBoolean("Active", active);
|
||||
tags.setInteger("Fuel", fuel);
|
||||
tags.setInteger("FuelGague", fuelGague);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
|
||||
{
|
||||
return new FrypanContainer(inventoryplayer.player, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName ()
|
||||
{
|
||||
return getDefaultName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName ()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory ()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory ()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,376 @@
|
||||
package tconstruct.tools.logic;
|
||||
|
||||
import mantle.blocks.BlockUtils;
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
import mantle.blocks.iface.IActiveLogic;
|
||||
import mantle.blocks.iface.IFacingLogic;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemHoe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemSword;
|
||||
import net.minecraft.item.ItemTool;
|
||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import tconstruct.tools.inventory.FurnaceContainer;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
/* Slots
|
||||
* 0: Input
|
||||
* 1: Fuel
|
||||
* 2: Output
|
||||
* 3-16: Chest
|
||||
*/
|
||||
|
||||
public class FurnaceLogic extends InventoryLogic implements IActiveLogic, IFacingLogic
|
||||
{
|
||||
boolean active;
|
||||
public int fuel;
|
||||
public int fuelGague;
|
||||
public int progress;
|
||||
public int fuelScale = 200;
|
||||
byte direction;
|
||||
|
||||
public FurnaceLogic()
|
||||
{
|
||||
super(3);
|
||||
active = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultName ()
|
||||
{
|
||||
return "container.furnace";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getActive ()
|
||||
{
|
||||
return active;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActive (boolean flag)
|
||||
{
|
||||
active = flag;
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
/* Fuel gauge */
|
||||
public int gaugeProgressScaled (int scale)
|
||||
{
|
||||
return (progress * scale) / fuelScale;
|
||||
}
|
||||
|
||||
public int gaugeFuelScaled (int scale)
|
||||
{
|
||||
if (fuelGague == 0)
|
||||
{
|
||||
fuelGague = fuel;
|
||||
if (fuelGague == 0)
|
||||
{
|
||||
fuelGague = fuelScale;
|
||||
}
|
||||
}
|
||||
return (fuel * scale) / fuelGague;
|
||||
}
|
||||
|
||||
/* Item cooking */
|
||||
@Override
|
||||
public void updateEntity ()
|
||||
{
|
||||
boolean burning = isBurning();
|
||||
boolean updateInventory = false;
|
||||
if (fuel <= 0 && canSmelt())
|
||||
{
|
||||
fuel = fuelGague = (int) (getItemBurnTime(inventory[1]));
|
||||
if (fuel > 0)
|
||||
{
|
||||
if (inventory[1].getItem().hasContainerItem()) // Fuel slot
|
||||
{
|
||||
inventory[1] = new ItemStack(inventory[1].getItem().getContainerItem());
|
||||
}
|
||||
else
|
||||
{
|
||||
inventory[1].stackSize--;
|
||||
}
|
||||
if (inventory[1].stackSize <= 0)
|
||||
{
|
||||
inventory[1] = null;
|
||||
}
|
||||
updateInventory = true;
|
||||
}
|
||||
}
|
||||
if (isBurning() && canSmelt())
|
||||
{
|
||||
progress++;
|
||||
if (progress >= fuelScale)
|
||||
{
|
||||
progress = 0;
|
||||
cookItems();
|
||||
updateInventory = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
progress = 0;
|
||||
}
|
||||
if (fuel > 0)
|
||||
{
|
||||
fuel--;
|
||||
}
|
||||
if (burning != isBurning())
|
||||
{
|
||||
setActive(isBurning());
|
||||
updateInventory = true;
|
||||
}
|
||||
if (updateInventory)
|
||||
{
|
||||
markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public void cookItems ()
|
||||
{
|
||||
if (this.canSmelt())
|
||||
{
|
||||
ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(this.inventory[0]);
|
||||
|
||||
if (this.inventory[2] == null)
|
||||
{
|
||||
this.inventory[2] = itemstack.copy();
|
||||
}
|
||||
else if (this.inventory[2].isItemEqual(itemstack))
|
||||
{
|
||||
inventory[2].stackSize += itemstack.stackSize;
|
||||
}
|
||||
|
||||
--this.inventory[0].stackSize;
|
||||
|
||||
if (this.inventory[0].stackSize <= 0)
|
||||
{
|
||||
this.inventory[0] = null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean canSmelt ()
|
||||
{
|
||||
if (inventory[0] == null) // Nothing here!
|
||||
return false;
|
||||
else
|
||||
{
|
||||
ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(this.inventory[0]);
|
||||
if (itemstack == null)
|
||||
return false;
|
||||
if (this.inventory[2] == null)
|
||||
return true;
|
||||
if (!this.inventory[2].isItemEqual(itemstack))
|
||||
return false;
|
||||
int result = inventory[2].stackSize + itemstack.stackSize;
|
||||
return (result <= getInventoryStackLimit() && result <= itemstack.getMaxStackSize());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isBurning ()
|
||||
{
|
||||
return fuel > 0;
|
||||
}
|
||||
|
||||
public ItemStack getResultFor (ItemStack stack)
|
||||
{
|
||||
ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(stack);
|
||||
if (result != null) // Only valid for food
|
||||
return result.copy();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int getItemBurnTime (ItemStack stack)
|
||||
{
|
||||
if (stack == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Item item = stack.getItem();
|
||||
|
||||
if (stack.getItem() instanceof ItemBlock && BlockUtils.getBlockFromItem(item) != null)
|
||||
{
|
||||
Block block = BlockUtils.getBlockFromItem(item);
|
||||
|
||||
if (block == Blocks.wooden_slab)
|
||||
{
|
||||
return 150;
|
||||
}
|
||||
|
||||
if (block == Blocks.log)
|
||||
{
|
||||
return 1200;
|
||||
}
|
||||
|
||||
if (block.getMaterial() == Material.wood)
|
||||
{
|
||||
return 300;
|
||||
}
|
||||
|
||||
if (block == Blocks.coal_block)
|
||||
{
|
||||
return 16000;
|
||||
}
|
||||
}
|
||||
|
||||
if (item instanceof ItemTool && ((ItemTool) item).getToolMaterialName().equals("WOOD"))
|
||||
return 200;
|
||||
if (item instanceof ItemSword && ((ItemSword) item).getToolMaterialName().equals("WOOD"))
|
||||
return 200;
|
||||
if (item instanceof ItemHoe && ((ItemHoe) item).getToolMaterialName().equals("WOOD"))
|
||||
return 200;
|
||||
if (item == Items.stick)
|
||||
return 100;
|
||||
if (item == Items.coal)
|
||||
return 1600;
|
||||
if (item == Items.lava_bucket)
|
||||
return 20000;
|
||||
if (item == new ItemStack(Blocks.sapling).getItem())
|
||||
return 100;
|
||||
if (item == Items.blaze_rod)
|
||||
return 2400;
|
||||
return GameRegistry.getFuelValue(stack);
|
||||
}
|
||||
}
|
||||
|
||||
/* NBT */
|
||||
@Override
|
||||
public void readFromNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.readFromNBT(tags);
|
||||
active = tags.getBoolean("Active");
|
||||
fuel = tags.getInteger("Fuel");
|
||||
fuelGague = tags.getInteger("FuelGague");
|
||||
readNetworkNBT(tags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.writeToNBT(tags);
|
||||
tags.setBoolean("Active", active);
|
||||
tags.setInteger("Fuel", fuel);
|
||||
tags.setInteger("FuelGague", fuelGague);
|
||||
writeNetworkNBT(tags);
|
||||
}
|
||||
|
||||
public void readNetworkNBT (NBTTagCompound tags)
|
||||
{
|
||||
direction = tags.getByte("Direction");
|
||||
}
|
||||
|
||||
public void writeNetworkNBT (NBTTagCompound tags)
|
||||
{
|
||||
tags.setByte("Direction", direction);
|
||||
}
|
||||
|
||||
/* Packets */
|
||||
@Override
|
||||
public Packet getDescriptionPacket ()
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
writeNetworkNBT(tag);
|
||||
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket (NetworkManager net, S35PacketUpdateTileEntity packet)
|
||||
{
|
||||
readNetworkNBT(packet.func_148857_g());
|
||||
worldObj.func_147479_m(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
|
||||
{
|
||||
return new FurnaceContainer(inventoryplayer, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getRenderDirection ()
|
||||
{
|
||||
return direction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection getForgeDirection ()
|
||||
{
|
||||
return ForgeDirection.VALID_DIRECTIONS[direction];
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void setDirection (int side)
|
||||
{
|
||||
// Nope!
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void setDirection (float yaw, float pitch, EntityLivingBase player)
|
||||
{
|
||||
int facing = MathHelper.floor_double((double) (yaw / 360) + 0.5D) & 3;
|
||||
switch (facing)
|
||||
{
|
||||
case 0:
|
||||
direction = 2;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
direction = 5;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
direction = 3;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
direction = 4;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName ()
|
||||
{
|
||||
return getDefaultName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory ()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory ()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,215 @@
|
||||
package tconstruct.tools.logic;
|
||||
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.library.crafting.PatternBuilder;
|
||||
import tconstruct.library.util.IPattern;
|
||||
import tconstruct.tools.inventory.PartCrafterChestContainer;
|
||||
import tconstruct.tools.inventory.PartCrafterContainer;
|
||||
|
||||
public class PartBuilderLogic extends InventoryLogic implements ISidedInventory
|
||||
{
|
||||
boolean craftedTop;
|
||||
boolean craftedBottom;
|
||||
|
||||
public PartBuilderLogic()
|
||||
{
|
||||
super(10);
|
||||
craftedTop = false;
|
||||
craftedBottom = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultName ()
|
||||
{
|
||||
return "toolstation.parts";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
|
||||
{
|
||||
for (int xPos = x - 1; xPos <= x + 1; xPos++)
|
||||
{
|
||||
for (int zPos = z - 1; zPos <= z + 1; zPos++)
|
||||
{
|
||||
for (int yPos = y - 1; yPos <= y + 1; yPos++)
|
||||
{
|
||||
TileEntity tile = world.getTileEntity(xPos, yPos, zPos);
|
||||
if (tile != null && tile instanceof PatternChestLogic && (x == xPos || z == zPos))
|
||||
return new PartCrafterChestContainer(inventoryplayer, this, (PatternChestLogic) tile);
|
||||
}
|
||||
}
|
||||
}
|
||||
return new PartCrafterContainer(inventoryplayer, this);
|
||||
}
|
||||
|
||||
//Called when emptying a slot, not when another item is placed in it
|
||||
@Override
|
||||
public ItemStack decrStackSize (int slotID, int quantity)
|
||||
{
|
||||
ItemStack returnStack = super.decrStackSize(slotID, quantity);
|
||||
tryBuildPart(slotID);
|
||||
return returnStack;
|
||||
}
|
||||
|
||||
public void tryBuildPart (int slotID)
|
||||
{
|
||||
if (slotID == 4 || slotID == 5)
|
||||
{
|
||||
if (!craftedTop && inventory[0] != null)
|
||||
{
|
||||
int value = PatternBuilder.instance.getPartValue(inventory[2]);
|
||||
IPattern item = (IPattern) inventory[0].getItem();
|
||||
int cost = item != null ? item.getPatternCost(inventory[0]) : 0;
|
||||
if (value > 0 && cost > 0)
|
||||
{
|
||||
int decrease = cost / value;
|
||||
if (cost % value != 0)
|
||||
decrease++;
|
||||
super.decrStackSize(2, decrease); //Call super to avoid crafting again
|
||||
}
|
||||
}
|
||||
|
||||
if (inventory[4] != null || inventory[5] != null)
|
||||
craftedTop = true;
|
||||
else
|
||||
craftedTop = false;
|
||||
}
|
||||
|
||||
if (!craftedTop)
|
||||
buildTopPart();
|
||||
|
||||
if (slotID == 6 || slotID == 7)
|
||||
{
|
||||
if (!craftedBottom && inventory[1] != null)
|
||||
{
|
||||
int value = PatternBuilder.instance.getPartValue(inventory[3]);
|
||||
IPattern item = (IPattern) inventory[1].getItem();
|
||||
int cost = item != null ? item.getPatternCost(inventory[1]) : 0;
|
||||
if (value > 0 && cost > 0)
|
||||
{
|
||||
int decrease = cost / value;
|
||||
if (cost % value != 0)
|
||||
decrease++;
|
||||
super.decrStackSize(3, decrease); //Call super to avoid crafting again
|
||||
}
|
||||
}
|
||||
|
||||
if (inventory[6] != null || inventory[7] != null)
|
||||
craftedBottom = true;
|
||||
else
|
||||
craftedBottom = false;
|
||||
}
|
||||
|
||||
if (!craftedBottom)
|
||||
buildBottomPart();
|
||||
}
|
||||
|
||||
//Called when a slot has something placed into it.
|
||||
@Override
|
||||
public void setInventorySlotContents (int slot, ItemStack itemstack)
|
||||
{
|
||||
super.setInventorySlotContents(slot, itemstack);
|
||||
if ((slot == 0 || slot == 2) && !craftedTop)
|
||||
buildTopPart();
|
||||
if ((slot == 1 || slot == 3) && !craftedBottom)
|
||||
buildBottomPart();
|
||||
}
|
||||
|
||||
void buildTopPart ()
|
||||
{
|
||||
ItemStack[] parts = PatternBuilder.instance.getToolPart(inventory[2], inventory[0], inventory[1]);
|
||||
if (parts != null)
|
||||
{
|
||||
inventory[4] = parts[0];
|
||||
inventory[5] = parts[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
inventory[4] = inventory[5] = null;
|
||||
}
|
||||
}
|
||||
|
||||
void buildBottomPart ()
|
||||
{
|
||||
ItemStack[] parts = PatternBuilder.instance.getToolPart(inventory[3], inventory[1], inventory[0]);
|
||||
if (parts != null)
|
||||
{
|
||||
inventory[6] = parts[0];
|
||||
inventory[7] = parts[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
inventory[6] = inventory[7] = null;
|
||||
}
|
||||
}
|
||||
|
||||
/* NBT */
|
||||
@Override
|
||||
public void readFromNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.readFromNBT(tags);
|
||||
craftedTop = tags.getBoolean("CraftedTop");
|
||||
craftedBottom = tags.getBoolean("CraftedBottom");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.writeToNBT(tags);
|
||||
tags.setBoolean("CraftedTop", craftedTop);
|
||||
tags.setBoolean("CraftedBottom", craftedBottom);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide (int side)
|
||||
{
|
||||
return new int[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem (int i, ItemStack itemstack, int j)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem (int i, ItemStack itemstack, int j)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName ()
|
||||
{
|
||||
return getDefaultName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory ()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory ()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUpdate ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package tconstruct.tools.logic;
|
||||
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.tools.inventory.PatternChestContainer;
|
||||
|
||||
public class PatternChestLogic extends InventoryLogic
|
||||
{
|
||||
public PatternChestLogic()
|
||||
{
|
||||
super(30);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUpdate ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultName ()
|
||||
{
|
||||
return "toolstation.patternholder";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
|
||||
{
|
||||
return new PatternChestContainer(inventoryplayer, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName ()
|
||||
{
|
||||
return getDefaultName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName ()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory ()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory ()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
package tconstruct.tools.logic;
|
||||
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import tconstruct.tools.inventory.PatternShaperContainer;
|
||||
|
||||
public class StencilTableLogic extends InventoryLogic implements ISidedInventory
|
||||
{
|
||||
public StencilTableLogic()
|
||||
{
|
||||
super(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUpdate ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultName ()
|
||||
{
|
||||
return "toolstation.PatternShaper";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
|
||||
{
|
||||
return new PatternShaperContainer(inventoryplayer, this);
|
||||
}
|
||||
|
||||
/*@Override
|
||||
public void onInventoryChanged()
|
||||
{
|
||||
if (inventory[0] == null)
|
||||
inventory[1] = null;
|
||||
super.onInventoryChanged();
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents (int slot, ItemStack itemstack)
|
||||
{
|
||||
super.setInventorySlotContents(slot, itemstack);
|
||||
if (slot == 0 && itemstack != null && itemstack.getItem() == TinkerTools.blankPattern)//instanceof tconstruct.items.Pattern)
|
||||
{
|
||||
if (itemstack.getItemDamage() == 0)
|
||||
setInventorySlotContents(1, new ItemStack(TinkerTools.woodPattern, 1, 1));
|
||||
/*else if (itemstack.getItemDamage() == 1)
|
||||
setInventorySlotContents(1, new ItemStack(TContent.metalPattern, 1, 0));*/
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize (int slot, int quantity)
|
||||
{
|
||||
if (slot == 1)
|
||||
{
|
||||
super.decrStackSize(0, 1);
|
||||
if (inventory[0] == null)
|
||||
return super.decrStackSize(slot, quantity);
|
||||
else
|
||||
return inventory[1].copy();
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemStack ret = super.decrStackSize(slot, quantity);
|
||||
if (inventory[0] == null)
|
||||
super.decrStackSize(1, 1);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public void altDecrStackSize (int slot, int quantity)
|
||||
{
|
||||
if (inventory[slot] != null)
|
||||
{
|
||||
if (inventory[slot].stackSize <= quantity)
|
||||
{
|
||||
ItemStack stack = inventory[slot];
|
||||
inventory[slot] = null;
|
||||
return;
|
||||
}
|
||||
ItemStack split = inventory[slot].splitStack(quantity);
|
||||
if (inventory[slot].stackSize == 0)
|
||||
{
|
||||
inventory[slot] = null;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDropInventorySlot (int slot)
|
||||
{
|
||||
if (slot == 0)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide (int side)
|
||||
{
|
||||
return new int[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem (int i, ItemStack itemstack, int j)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem (int i, ItemStack itemstack, int j)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName ()
|
||||
{
|
||||
return StatCollector.translateToLocal("toolstation.PatternShaper");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName ()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory ()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory ()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package tconstruct.tools.logic;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.library.crafting.ToolBuilder;
|
||||
import tconstruct.tools.inventory.ToolForgeContainer;
|
||||
|
||||
/* Simple class for storing items in the block
|
||||
*/
|
||||
|
||||
public class ToolForgeLogic extends ToolStationLogic implements ISidedInventory
|
||||
{
|
||||
ItemStack previousTool;
|
||||
String toolName;
|
||||
|
||||
public ToolForgeLogic()
|
||||
{
|
||||
super(6);
|
||||
toolName = "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultName ()
|
||||
{
|
||||
return "crafters.ToolForge";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
|
||||
{
|
||||
return new ToolForgeContainer(inventoryplayer, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildTool (String name)
|
||||
{
|
||||
toolName = name;
|
||||
ItemStack tool = ToolBuilder.instance.buildTool(inventory[1], inventory[2], inventory[3], inventory[4], name);
|
||||
if (inventory[0] == null)
|
||||
inventory[0] = tool;
|
||||
else
|
||||
{
|
||||
NBTTagCompound tags = inventory[0].getTagCompound();
|
||||
if (!tags.getCompoundTag("InfiTool").hasKey("Built"))
|
||||
{
|
||||
inventory[0] = tool;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
package tconstruct.tools.logic;
|
||||
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.library.crafting.ToolBuilder;
|
||||
import tconstruct.tools.inventory.ToolStationContainer;
|
||||
|
||||
/* Simple class for storing items in the block
|
||||
*/
|
||||
|
||||
public class ToolStationLogic extends InventoryLogic implements ISidedInventory
|
||||
{
|
||||
public ItemStack previousTool;
|
||||
public String toolName;
|
||||
|
||||
public ToolStationLogic()
|
||||
{
|
||||
super(4);
|
||||
toolName = "";
|
||||
}
|
||||
|
||||
public ToolStationLogic(int slots)
|
||||
{
|
||||
super(slots);
|
||||
toolName = "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDropInventorySlot (int slot)
|
||||
{
|
||||
if (slot == 0)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing (int var1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultName ()
|
||||
{
|
||||
return "crafters.ToolStation";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
|
||||
{
|
||||
return new ToolStationContainer(inventoryplayer, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty ()
|
||||
{
|
||||
buildTool(toolName);
|
||||
if (this.worldObj != null)
|
||||
{
|
||||
this.blockMetadata = this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord);
|
||||
this.worldObj.markTileEntityChunkModified(this.xCoord, this.yCoord, this.zCoord, this);
|
||||
}
|
||||
}
|
||||
|
||||
public void buildTool (String name)
|
||||
{
|
||||
toolName = name;
|
||||
ItemStack tool = ToolBuilder.instance.buildTool(inventory[1], inventory[2], inventory[3], name);
|
||||
if (inventory[0] == null)
|
||||
inventory[0] = tool;
|
||||
else
|
||||
{
|
||||
NBTTagCompound tags = inventory[0].getTagCompound();
|
||||
if (!tags.getCompoundTag("InfiTool").hasKey("Built"))
|
||||
{
|
||||
inventory[0] = tool;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setToolname (String name)
|
||||
{
|
||||
toolName = name;
|
||||
buildTool(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUpdate ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide (int side)
|
||||
{
|
||||
return new int[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem (int i, ItemStack itemstack, int j)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem (int i, ItemStack itemstack, int j)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName ()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory ()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory ()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,636 @@
|
||||
package tconstruct.tools.model;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.ItemRenderer;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.Render;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class FancyItemRender extends Render
|
||||
{
|
||||
private static final ResourceLocation field_110798_h = new ResourceLocation("textures/misc/enchanted_item_glint.png");
|
||||
private RenderBlocks itemRenderBlocks = new RenderBlocks();
|
||||
|
||||
/** The RNG used in RenderItem (for bobbing itemstacks on the ground) */
|
||||
private Random random = new Random();
|
||||
public boolean renderWithColor = true;
|
||||
|
||||
/** Defines the zLevel of rendering of item on GUI. */
|
||||
public float zLevel;
|
||||
public static boolean renderInFrame;
|
||||
|
||||
public FancyItemRender()
|
||||
{
|
||||
this.shadowSize = 0.15F;
|
||||
this.shadowOpaque = 0.75F;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the item
|
||||
*/
|
||||
public void doRenderItem (EntityItem par1EntityItem, double par2, double par4, double par6, float par8, float par9)
|
||||
{
|
||||
this.bindEntityTexture(par1EntityItem);
|
||||
this.random.setSeed(187L);
|
||||
ItemStack itemstack = par1EntityItem.getEntityItem();
|
||||
|
||||
if (itemstack.getItem() != null)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
float f2 = shouldBob() ? MathHelper.sin(((float) par1EntityItem.age + par9) / 10.0F + par1EntityItem.hoverStart) * 0.1F + 0.1F : 0F;
|
||||
float f3 = (((float) par1EntityItem.age + par9) / 20.0F + par1EntityItem.hoverStart) * (180F / (float) Math.PI);
|
||||
byte b0 = getMiniBlockCount(itemstack);
|
||||
|
||||
GL11.glTranslatef((float) par2, (float) par4 + f2, (float) par6);
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
float f4;
|
||||
float f5;
|
||||
float f6;
|
||||
int i;
|
||||
|
||||
Block block = null;
|
||||
|
||||
block = Block.getBlockFromItem(itemstack.getItem());
|
||||
|
||||
if (ForgeHooksClient.renderEntityItem(par1EntityItem, itemstack, f2, f3, random, renderManager.renderEngine, field_147909_c, 1))
|
||||
{
|
||||
;
|
||||
}
|
||||
else if (itemstack.getItemSpriteNumber() == 0 && block != null && RenderBlocks.renderItemIn3d(Block.getBlockFromItem(itemstack.getItem()).getRenderType()))
|
||||
{
|
||||
GL11.glRotatef(f3, 0.0F, 1.0F, 0.0F);
|
||||
|
||||
if (renderInFrame)
|
||||
{
|
||||
GL11.glScalef(1.25F, 1.25F, 1.25F);
|
||||
GL11.glTranslatef(0.0F, 0.05F, 0.0F);
|
||||
GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
|
||||
}
|
||||
|
||||
float f7 = 0.25F;
|
||||
int j = block.getRenderType();
|
||||
|
||||
if (j == 1 || j == 19 || j == 12 || j == 2)
|
||||
{
|
||||
f7 = 0.5F;
|
||||
}
|
||||
|
||||
GL11.glScalef(f7, f7, f7);
|
||||
|
||||
for (i = 0; i < b0; ++i)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
|
||||
if (i > 0)
|
||||
{
|
||||
f5 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.2F / f7;
|
||||
f4 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.2F / f7;
|
||||
f6 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.2F / f7;
|
||||
GL11.glTranslatef(f5, f4, f6);
|
||||
}
|
||||
|
||||
f5 = 1.0F;
|
||||
this.itemRenderBlocks.renderBlockAsItem(block, itemstack.getItemDamage(), f5);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
float f8;
|
||||
|
||||
if (itemstack.getItemSpriteNumber() == 1 && itemstack.getItem().requiresMultipleRenderPasses())
|
||||
{
|
||||
if (renderInFrame)
|
||||
{
|
||||
GL11.glScalef(0.5128205F, 0.5128205F, 0.5128205F);
|
||||
GL11.glTranslatef(0.0F, -0.05F, 0.0F);
|
||||
}
|
||||
else
|
||||
{
|
||||
GL11.glScalef(0.5F, 0.5F, 0.5F);
|
||||
}
|
||||
|
||||
for (int k = 0; k < itemstack.getItem().getRenderPasses(itemstack.getItemDamage()); ++k)
|
||||
{
|
||||
this.random.setSeed(187L);
|
||||
IIcon icon = itemstack.getItem().getIcon(itemstack, k);
|
||||
f8 = 1.0F;
|
||||
|
||||
if (this.renderWithColor)
|
||||
{
|
||||
i = itemstack.getItem().getColorFromItemStack(itemstack, k);
|
||||
f5 = (float) (i >> 16 & 255) / 255.0F;
|
||||
f4 = (float) (i >> 8 & 255) / 255.0F;
|
||||
f6 = (float) (i & 255) / 255.0F;
|
||||
GL11.glColor4f(f5 * f8, f4 * f8, f6 * f8, 1.0F);
|
||||
this.renderDroppedItem(par1EntityItem, icon, b0, par9, f5 * f8, f4 * f8, f6 * f8, k);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.renderDroppedItem(par1EntityItem, icon, b0, par9, 1.0F, 1.0F, 1.0F, k);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (renderInFrame)
|
||||
{
|
||||
GL11.glScalef(0.5128205F, 0.5128205F, 0.5128205F);
|
||||
GL11.glTranslatef(0.0F, -0.05F, 0.0F);
|
||||
}
|
||||
else
|
||||
{
|
||||
GL11.glScalef(0.5F, 0.5F, 0.5F);
|
||||
}
|
||||
|
||||
IIcon icon1 = itemstack.getIconIndex();
|
||||
|
||||
if (this.renderWithColor)
|
||||
{
|
||||
int l = itemstack.getItem().getColorFromItemStack(itemstack, 0);
|
||||
f8 = (float) (l >> 16 & 255) / 255.0F;
|
||||
float f9 = (float) (l >> 8 & 255) / 255.0F;
|
||||
f5 = (float) (l & 255) / 255.0F;
|
||||
f4 = 1.0F;
|
||||
this.renderDroppedItem(par1EntityItem, icon1, b0, par9, f8 * f4, f9 * f4, f5 * f4);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.renderDroppedItem(par1EntityItem, icon1, b0, par9, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
protected ResourceLocation func_110796_a (EntityItem par1EntityItem)
|
||||
{
|
||||
return this.renderManager.renderEngine.getResourceLocation(par1EntityItem.getEntityItem().getItemSpriteNumber());
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders a dropped item
|
||||
*/
|
||||
private void renderDroppedItem (EntityItem par1EntityItem, IIcon par2Icon, int par3, float par4, float par5, float par6, float par7)
|
||||
{
|
||||
renderDroppedItem(par1EntityItem, par2Icon, par3, par4, par5, par6, par7, 0);
|
||||
}
|
||||
|
||||
private void renderDroppedItem (EntityItem par1EntityItem, IIcon par2Icon, int par3, float par4, float par5, float par6, float par7, int pass)
|
||||
{
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
if (par2Icon == null)
|
||||
{
|
||||
TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
|
||||
ResourceLocation resourcelocation = texturemanager.getResourceLocation(par1EntityItem.getEntityItem().getItemSpriteNumber());
|
||||
par2Icon = ((TextureMap) texturemanager.getTexture(resourcelocation)).getAtlasSprite("missingno");
|
||||
}
|
||||
|
||||
float f4 = ((IIcon) par2Icon).getMinU();
|
||||
float f5 = ((IIcon) par2Icon).getMaxU();
|
||||
float f6 = ((IIcon) par2Icon).getMinV();
|
||||
float f7 = ((IIcon) par2Icon).getMaxV();
|
||||
float f8 = 1.0F;
|
||||
float f9 = 0.5F;
|
||||
float f10 = 0.25F;
|
||||
float f11;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
|
||||
if (renderInFrame)
|
||||
{
|
||||
GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F);
|
||||
}
|
||||
else
|
||||
{
|
||||
GL11.glRotatef((((float) par1EntityItem.age + par4) / 20.0F + par1EntityItem.hoverStart) * (180F / (float) Math.PI), 0.0F, 1.0F, 0.0F);
|
||||
}
|
||||
|
||||
float f12 = 0.0625F;
|
||||
f11 = 0.021875F;
|
||||
ItemStack itemstack = par1EntityItem.getEntityItem();
|
||||
int j = itemstack.stackSize;
|
||||
byte b0 = getMiniItemCount(itemstack);
|
||||
|
||||
GL11.glTranslatef(-f9, -f10, -((f12 + f11) * (float) b0 / 2.0F));
|
||||
|
||||
for (int k = 0; k < b0; ++k)
|
||||
{
|
||||
// Makes items offset when in 3D, like when in 2D, looks much better. Considered a vanilla bug...
|
||||
if (k > 0 && shouldSpreadItems())
|
||||
{
|
||||
float x = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F;
|
||||
float y = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F;
|
||||
float z = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F;
|
||||
GL11.glTranslatef(x, y, f12 + f11);
|
||||
}
|
||||
else
|
||||
{
|
||||
GL11.glTranslatef(0f, 0f, f12 + f11);
|
||||
}
|
||||
|
||||
if (itemstack.getItemSpriteNumber() == 0)
|
||||
{
|
||||
this.bindTexture(TextureMap.locationBlocksTexture);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.bindTexture(TextureMap.locationItemsTexture);
|
||||
}
|
||||
|
||||
GL11.glColor4f(par5, par6, par7, 1.0F);
|
||||
ItemRenderer.renderItemIn2D(tessellator, f5, f6, f4, f7, ((IIcon) par2Icon).getIconWidth(), ((IIcon) par2Icon).getIconHeight(), f12);
|
||||
|
||||
if (itemstack.hasEffect(pass))
|
||||
{
|
||||
GL11.glDepthFunc(GL11.GL_EQUAL);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
this.renderManager.renderEngine.bindTexture(field_110798_h);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
|
||||
float f13 = 0.76F;
|
||||
GL11.glColor4f(0.5F * f13, 0.25F * f13, 0.8F * f13, 1.0F);
|
||||
GL11.glMatrixMode(GL11.GL_TEXTURE);
|
||||
GL11.glPushMatrix();
|
||||
float f14 = 0.125F;
|
||||
GL11.glScalef(f14, f14, f14);
|
||||
float f15 = (float) (Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F;
|
||||
GL11.glTranslatef(f15, 0.0F, 0.0F);
|
||||
GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F);
|
||||
ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 255, 255, f12);
|
||||
GL11.glPopMatrix();
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScalef(f14, f14, f14);
|
||||
f15 = (float) (Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F;
|
||||
GL11.glTranslatef(-f15, 0.0F, 0.0F);
|
||||
GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F);
|
||||
ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 255, 255, f12);
|
||||
GL11.glPopMatrix();
|
||||
GL11.glMatrixMode(GL11.GL_MODELVIEW);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glDepthFunc(GL11.GL_LEQUAL);
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the item's icon or block into the UI at the specified position.
|
||||
*/
|
||||
public void renderItemIntoGUI (FontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5)
|
||||
{
|
||||
renderItemIntoGUI(par1FontRenderer, par2TextureManager, par3ItemStack, par4, par5, false);
|
||||
}
|
||||
|
||||
public void renderItemIntoGUI (FontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5, boolean renderEffect)
|
||||
{
|
||||
Item k = par3ItemStack.getItem();
|
||||
int l = par3ItemStack.getItemDamage();
|
||||
Object object = par3ItemStack.getIconIndex();
|
||||
float f;
|
||||
int i1;
|
||||
float f1;
|
||||
float f2;
|
||||
|
||||
Block block = Block.getBlockFromItem(k);//(k < Block.blocksList.length ? Block.blocksList[k] : null);
|
||||
if (par3ItemStack.getItemSpriteNumber() == 0 && block != null && RenderBlocks.renderItemIn3d(block.getRenderType()))
|
||||
{
|
||||
par2TextureManager.bindTexture(TextureMap.locationBlocksTexture);
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float) (par4 - 2), (float) (par5 + 3), -3.0F + this.zLevel);
|
||||
GL11.glScalef(10.0F, 10.0F, 10.0F);
|
||||
GL11.glTranslatef(1.0F, 0.5F, 1.0F);
|
||||
GL11.glScalef(1.0F, 1.0F, -1.0F);
|
||||
GL11.glRotatef(210.0F, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
|
||||
i1 = k.getColorFromItemStack(par3ItemStack, 0);
|
||||
f = (float) (i1 >> 16 & 255) / 255.0F;
|
||||
f1 = (float) (i1 >> 8 & 255) / 255.0F;
|
||||
f2 = (float) (i1 & 255) / 255.0F;
|
||||
|
||||
if (this.renderWithColor)
|
||||
{
|
||||
GL11.glColor4f(f, f1, f2, 1.0F);
|
||||
}
|
||||
|
||||
GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
|
||||
this.itemRenderBlocks.useInventoryTint = this.renderWithColor;
|
||||
this.itemRenderBlocks.renderBlockAsItem(block, l, 1.0F);
|
||||
this.itemRenderBlocks.useInventoryTint = true;
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
else if (k.requiresMultipleRenderPasses())
|
||||
{
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
|
||||
for (int j1 = 0; j1 < k.getRenderPasses(l); ++j1)
|
||||
{
|
||||
par2TextureManager.bindTexture(par3ItemStack.getItemSpriteNumber() == 0 ? TextureMap.locationBlocksTexture : TextureMap.locationItemsTexture);
|
||||
IIcon icon = k.getIcon(par3ItemStack, j1);
|
||||
int k1 = k.getColorFromItemStack(par3ItemStack, j1);
|
||||
f1 = (float) (k1 >> 16 & 255) / 255.0F;
|
||||
f2 = (float) (k1 >> 8 & 255) / 255.0F;
|
||||
float f3 = (float) (k1 & 255) / 255.0F;
|
||||
|
||||
if (this.renderWithColor)
|
||||
{
|
||||
GL11.glColor4f(f1, f2, f3, 1.0F);
|
||||
}
|
||||
|
||||
this.renderIcon(par4, par5, icon, 16, 16);
|
||||
|
||||
if (par3ItemStack.hasEffect(j1))
|
||||
{
|
||||
renderEffect(par2TextureManager, par4, par5);
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
}
|
||||
else
|
||||
{
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
ResourceLocation resourcelocation = par2TextureManager.getResourceLocation(par3ItemStack.getItemSpriteNumber());
|
||||
par2TextureManager.bindTexture(resourcelocation);
|
||||
|
||||
if (object == null)
|
||||
{
|
||||
object = ((TextureMap) Minecraft.getMinecraft().getTextureManager().getTexture(resourcelocation)).getAtlasSprite("missingno");
|
||||
}
|
||||
|
||||
i1 = k.getColorFromItemStack(par3ItemStack, 0);
|
||||
f = (float) (i1 >> 16 & 255) / 255.0F;
|
||||
f1 = (float) (i1 >> 8 & 255) / 255.0F;
|
||||
f2 = (float) (i1 & 255) / 255.0F;
|
||||
|
||||
if (this.renderWithColor)
|
||||
{
|
||||
GL11.glColor4f(f, f1, f2, 1.0F);
|
||||
}
|
||||
|
||||
this.renderIcon(par4, par5, (IIcon) object, 16, 16);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
|
||||
if (par3ItemStack.hasEffect(0))
|
||||
{
|
||||
renderEffect(par2TextureManager, par4, par5);
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
}
|
||||
|
||||
private void renderEffect (TextureManager manager, int x, int y)
|
||||
{
|
||||
GL11.glDepthFunc(GL11.GL_GREATER);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDepthMask(false);
|
||||
manager.bindTexture(field_110798_h);
|
||||
this.zLevel -= 50.0F;
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_DST_COLOR, GL11.GL_DST_COLOR);
|
||||
GL11.glColor4f(0.5F, 0.25F, 0.8F, 1.0F);
|
||||
this.renderGlint(x * 431278612 + y * 32178161, x - 2, y - 2, 20, 20);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glDepthMask(true);
|
||||
this.zLevel += 50.0F;
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glDepthFunc(GL11.GL_LEQUAL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the item's icon or block into the GUI, including the glint effect.
|
||||
*/
|
||||
public void renderItemAndEffectIntoGUI (FontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5)
|
||||
{
|
||||
if (par3ItemStack != null)
|
||||
{
|
||||
if (!ForgeHooksClient.renderInventoryItem(field_147909_c, par2TextureManager, par3ItemStack, renderWithColor, zLevel, (float) par4, (float) par5))
|
||||
{
|
||||
this.renderItemIntoGUI(par1FontRenderer, par2TextureManager, par3ItemStack, par4, par5, true);
|
||||
}
|
||||
|
||||
/* Modders must handle this themselves if they use custom renderers!
|
||||
if (par3ItemStack.hasEffect())
|
||||
{
|
||||
GL11.glDepthFunc(GL11.GL_GREATER);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDepthMask(false);
|
||||
par2TextureManager.bindTexture(field_110798_h);
|
||||
this.zLevel -= 50.0F;
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_DST_COLOR, GL11.GL_DST_COLOR);
|
||||
GL11.glColor4f(0.5F, 0.25F, 0.8F, 1.0F);
|
||||
this.renderGlint(par4 * 431278612 + par5 * 32178161, par4 - 2, par5 - 2, 20, 20);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glDepthMask(true);
|
||||
this.zLevel += 50.0F;
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glDepthFunc(GL11.GL_LEQUAL);
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
private void renderGlint (int par1, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
for (int j1 = 0; j1 < 2; ++j1)
|
||||
{
|
||||
if (j1 == 0)
|
||||
{
|
||||
GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
|
||||
}
|
||||
|
||||
if (j1 == 1)
|
||||
{
|
||||
GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
|
||||
}
|
||||
|
||||
float f = 0.00390625F;
|
||||
float f1 = 0.00390625F;
|
||||
float f2 = (float) (Minecraft.getSystemTime() % (long) (3000 + j1 * 1873)) / (3000.0F + (float) (j1 * 1873)) * 256.0F;
|
||||
float f3 = 0.0F;
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
float f4 = 4.0F;
|
||||
|
||||
if (j1 == 1)
|
||||
{
|
||||
f4 = -1.0F;
|
||||
}
|
||||
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.addVertexWithUV((double) (par2 + 0), (double) (par3 + par5), (double) this.zLevel, (double) ((f2 + (float) par5 * f4) * f), (double) ((f3 + (float) par5) * f1));
|
||||
tessellator.addVertexWithUV((double) (par2 + par4), (double) (par3 + par5), (double) this.zLevel, (double) ((f2 + (float) par4 + (float) par5 * f4) * f),
|
||||
(double) ((f3 + (float) par5) * f1));
|
||||
tessellator.addVertexWithUV((double) (par2 + par4), (double) (par3 + 0), (double) this.zLevel, (double) ((f2 + (float) par4) * f), (double) ((f3 + 0.0F) * f1));
|
||||
tessellator.addVertexWithUV((double) (par2 + 0), (double) (par3 + 0), (double) this.zLevel, (double) ((f2 + 0.0F) * f), (double) ((f3 + 0.0F) * f1));
|
||||
tessellator.draw();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the item's overlay information. Examples being stack count or damage on top of the item's image at the
|
||||
* specified position.
|
||||
*/
|
||||
public void renderItemOverlayIntoGUI (FontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5)
|
||||
{
|
||||
this.renderItemOverlayIntoGUI(par1FontRenderer, par2TextureManager, par3ItemStack, par4, par5, (String) null);
|
||||
}
|
||||
|
||||
public void renderItemOverlayIntoGUI (FontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5, String par6Str)
|
||||
{
|
||||
if (par3ItemStack != null)
|
||||
{
|
||||
if (par3ItemStack.stackSize > 1 || par6Str != null)
|
||||
{
|
||||
String s1 = par6Str == null ? String.valueOf(par3ItemStack.stackSize) : par6Str;
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
par1FontRenderer.drawStringWithShadow(s1, par4 + 19 - 2 - par1FontRenderer.getStringWidth(s1), par5 + 6 + 3, 16777215);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
if (par3ItemStack.isItemDamaged())
|
||||
{
|
||||
int k = (int) Math.round(13.0D - (double) par3ItemStack.getItemDamageForDisplay() * 13.0D / (double) par3ItemStack.getMaxDamage());
|
||||
int l = (int) Math.round(255.0D - (double) par3ItemStack.getItemDamageForDisplay() * 255.0D / (double) par3ItemStack.getMaxDamage());
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
int i1 = 255 - l << 16 | l << 8;
|
||||
int j1 = (255 - l) / 4 << 16 | 16128;
|
||||
this.renderQuad(tessellator, par4 + 2, par5 + 13, 13, 2, 0);
|
||||
this.renderQuad(tessellator, par4 + 2, par5 + 13, 12, 1, j1);
|
||||
this.renderQuad(tessellator, par4 + 2, par5 + 13, k, 1, i1);
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a quad to the tesselator at the specified position with the set width and height and color. Args:
|
||||
* tessellator, x, y, width, height, color
|
||||
*/
|
||||
private void renderQuad (Tessellator par1Tessellator, int par2, int par3, int par4, int par5, int par6)
|
||||
{
|
||||
par1Tessellator.startDrawingQuads();
|
||||
par1Tessellator.setColorOpaque_I(par6);
|
||||
par1Tessellator.addVertex((double) (par2 + 0), (double) (par3 + 0), 0.0D);
|
||||
par1Tessellator.addVertex((double) (par2 + 0), (double) (par3 + par5), 0.0D);
|
||||
par1Tessellator.addVertex((double) (par2 + par4), (double) (par3 + par5), 0.0D);
|
||||
par1Tessellator.addVertex((double) (par2 + par4), (double) (par3 + 0), 0.0D);
|
||||
par1Tessellator.draw();
|
||||
}
|
||||
|
||||
public void renderIcon (int par1, int par2, IIcon par3Icon, int par4, int par5)
|
||||
{
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.addVertexWithUV((double) (par1 + 0), (double) (par2 + par5), (double) this.zLevel, (double) par3Icon.getMinU(), (double) par3Icon.getMaxV());
|
||||
tessellator.addVertexWithUV((double) (par1 + par4), (double) (par2 + par5), (double) this.zLevel, (double) par3Icon.getMaxU(), (double) par3Icon.getMaxV());
|
||||
tessellator.addVertexWithUV((double) (par1 + par4), (double) (par2 + 0), (double) this.zLevel, (double) par3Icon.getMaxU(), (double) par3Icon.getMinV());
|
||||
tessellator.addVertexWithUV((double) (par1 + 0), (double) (par2 + 0), (double) this.zLevel, (double) par3Icon.getMinU(), (double) par3Icon.getMinV());
|
||||
tessellator.draw();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ResourceLocation getEntityTexture (Entity par1Entity)
|
||||
{
|
||||
return this.func_110796_a((EntityItem) par1Entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
|
||||
* handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
|
||||
* (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1,
|
||||
* double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
|
||||
*/
|
||||
@Override
|
||||
public void doRender (Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
|
||||
{
|
||||
this.doRenderItem((EntityItem) par1Entity, par2, par4, par6, par8, par9);
|
||||
}
|
||||
|
||||
/**
|
||||
* Items should spread out when rendered in 3d?
|
||||
* @return
|
||||
*/
|
||||
public boolean shouldSpreadItems ()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Items should have a bob effect
|
||||
* @return
|
||||
*/
|
||||
public boolean shouldBob ()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public byte getMiniBlockCount (ItemStack stack)
|
||||
{
|
||||
byte ret = 1;
|
||||
if (stack.stackSize > 1)
|
||||
ret = 2;
|
||||
if (stack.stackSize > 5)
|
||||
ret = 3;
|
||||
if (stack.stackSize > 20)
|
||||
ret = 4;
|
||||
if (stack.stackSize > 40)
|
||||
ret = 5;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows for a subclass to override how many rendered items appear in a
|
||||
* "mini item 3d stack"
|
||||
* @param stack
|
||||
* @return
|
||||
*/
|
||||
public byte getMiniItemCount (ItemStack stack)
|
||||
{
|
||||
byte ret = 1;
|
||||
if (stack.stackSize > 1)
|
||||
ret = 2;
|
||||
if (stack.stackSize > 15)
|
||||
ret = 3;
|
||||
if (stack.stackSize > 31)
|
||||
ret = 4;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package tconstruct.tools.model;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class FrypanRender implements ISimpleBlockRenderingHandler
|
||||
{
|
||||
public static int frypanModelID = RenderingRegistry.getNextAvailableRenderId();
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock (Block block, int metadata, int modelID, RenderBlocks renderer)
|
||||
{
|
||||
// Inventory should be an item. This is not here!
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelID, RenderBlocks renderer)
|
||||
{
|
||||
renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.0F, 0.125F, 0.0F, 0.125F, 0.25F, 1.0F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.125F, 0.125F, 0.875F, 0.875F, 0.25F, 1.0F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.875F, 0.125F, 0.0F, 1.0F, 0.25F, 1.0F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.125F, 0.125F, 0.0F, 0.875F, 0.25F, 0.125F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
// renderer.setRenderBounds(1F, 0.0F, 0.4375F, 2F, 0.125F, 0.5625F);
|
||||
// renderer.renderStandardBlock(block, x, y, z);
|
||||
renderHandle(world, x, y, z, block, renderer);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void renderHandle (IBlockAccess world, int x, int y, int z, Block block, RenderBlocks renderer)
|
||||
{
|
||||
switch (world.getBlockMetadata(x, y, z))
|
||||
{
|
||||
case 0:
|
||||
renderer.setRenderBounds(1F, 0.0F, 0.4375F, 2F, 0.125F, 0.5625F);
|
||||
break;
|
||||
case 1:
|
||||
renderer.setRenderBounds(-1F, 0.0F, 0.4375F, 0F, 0.125F, 0.5625F);
|
||||
break;
|
||||
case 2:
|
||||
renderer.setRenderBounds(0.4375F, 0.0F, -1F, 0.5625F, 0.125F, 0F);
|
||||
break;
|
||||
case 3:
|
||||
renderer.setRenderBounds(0.4375F, 0.0F, 1F, 0.5625F, 0.125F, 2F);
|
||||
break;
|
||||
}
|
||||
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory (int modelid)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId ()
|
||||
{
|
||||
return frypanModelID;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package tconstruct.tools.model;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class TableForgeRender implements ISimpleBlockRenderingHandler
|
||||
{
|
||||
public static int model = RenderingRegistry.getNextAvailableRenderId();
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock (Block block, int metadata, int modelID, RenderBlocks renderer)
|
||||
{
|
||||
if (modelID == model)
|
||||
{
|
||||
renderer.setRenderBounds(0.0F, 0.75F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 0.25F, 0.75F, 0.25F);
|
||||
renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.75F, 0.0F, 0.0F, 1.0F, 0.75F, 0.25F);
|
||||
renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.0F, 0.0F, 0.75F, 0.25F, 0.75F, 1.0F);
|
||||
renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.75F, 0.0F, 0.75F, 1.0F, 0.75F, 1.0F);
|
||||
renderStandardInvBlock(renderer, block, metadata);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelID, RenderBlocks renderer)
|
||||
{
|
||||
if (modelID == model)
|
||||
{
|
||||
renderer.setRenderBounds(0.0F, 0.75F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 0.25F, 0.75F, 0.25F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.75F, 0.0F, 0.0F, 1.0F, 0.75F, 0.25F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.0F, 0.0F, 0.75F, 0.25F, 0.75F, 1.0F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.75F, 0.0F, 0.75F, 1.0F, 0.75F, 1.0F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory (int modelID)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId ()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
public static void renderStandardInvBlock (RenderBlocks renderblocks, Block block, int meta)
|
||||
{
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, -1F, 0.0F);
|
||||
renderblocks.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 1.0F, 0.0F);
|
||||
renderblocks.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(1, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, -1F);
|
||||
renderblocks.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(2, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, 1.0F);
|
||||
renderblocks.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(3, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(-1F, 0.0F, 0.0F);
|
||||
renderblocks.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(4, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(1.0F, 0.0F, 0.0F);
|
||||
renderblocks.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(5, meta));
|
||||
tessellator.draw();
|
||||
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package tconstruct.tools.model;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class TableRender implements ISimpleBlockRenderingHandler
|
||||
{
|
||||
public static int tabelModelID = RenderingRegistry.getNextAvailableRenderId();
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock (Block block, int metadata, int modelID, RenderBlocks renderer)
|
||||
{
|
||||
if (modelID == tabelModelID)
|
||||
{
|
||||
if (metadata == 5)
|
||||
{
|
||||
renderer.setRenderBounds(0.0F, 0.0, 0.0F, 1.0F, 0.875F, 1.0F);
|
||||
renderStandardInvBlock(renderer, block, metadata);
|
||||
}
|
||||
else
|
||||
{
|
||||
renderer.setRenderBounds(0.0F, 0.75F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 0.25F, 0.75F, 0.25F);
|
||||
renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.75F, 0.0F, 0.0F, 1.0F, 0.75F, 0.25F);
|
||||
renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.0F, 0.0F, 0.75F, 0.25F, 0.75F, 1.0F);
|
||||
renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.75F, 0.0F, 0.75F, 1.0F, 0.75F, 1.0F);
|
||||
renderStandardInvBlock(renderer, block, metadata);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelID, RenderBlocks renderer)
|
||||
{
|
||||
if (modelID == tabelModelID)
|
||||
{
|
||||
int metadata = world.getBlockMetadata(x, y, z);
|
||||
if (metadata == 5)
|
||||
{
|
||||
renderer.setRenderBounds(0.0F, 0.0, 0.0F, 1.0F, 0.875F, 1.0F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
else
|
||||
{
|
||||
renderer.setRenderBounds(0.0F, 0.75F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 0.25F, 0.75F, 0.25F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.75F, 0.0F, 0.0F, 1.0F, 0.75F, 0.25F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.0F, 0.0F, 0.75F, 0.25F, 0.75F, 1.0F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.75F, 0.0F, 0.75F, 1.0F, 0.75F, 1.0F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory (int modelID)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId ()
|
||||
{
|
||||
return tabelModelID;
|
||||
}
|
||||
|
||||
public static void renderStandardInvBlock (RenderBlocks renderblocks, Block block, int meta)
|
||||
{
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, -1F, 0.0F);
|
||||
renderblocks.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 1.0F, 0.0F);
|
||||
renderblocks.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(1, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, -1F);
|
||||
renderblocks.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(2, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, 1.0F);
|
||||
renderblocks.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(3, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(-1F, 0.0F, 0.0F);
|
||||
renderblocks.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(4, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(1.0F, 0.0F, 0.0F);
|
||||
renderblocks.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(5, meta));
|
||||
tessellator.draw();
|
||||
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package tconstruct.tools.modifiers;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
public class ModAntiSpider extends ToolModTypeFilter
|
||||
{
|
||||
String tooltipName;
|
||||
int max = 4;
|
||||
String guiType;
|
||||
|
||||
public ModAntiSpider(String type, int effect, ItemStack[] items, int[] values)
|
||||
{
|
||||
super(effect, "ModAntiSpider", items, values);
|
||||
tooltipName = "\u00a72" + StatCollector.translateToLocal("modifier.tool.spider");
|
||||
guiType = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canModify (ItemStack tool, ItemStack[] input)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (!tags.hasKey(key))
|
||||
return tags.getInteger("Modifiers") > 0;
|
||||
|
||||
int keyPair[] = tags.getIntArray(key);
|
||||
if (keyPair[0] + matchingAmount(input) <= keyPair[1])
|
||||
return true;
|
||||
|
||||
else if (keyPair[0] == keyPair[1])
|
||||
return tags.getInteger("Modifiers") > 0;
|
||||
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modify (ItemStack[] input, ItemStack tool)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
int increase = matchingAmount(input);
|
||||
if (tags.hasKey(key))
|
||||
{
|
||||
int[] keyPair = tags.getIntArray(key);
|
||||
|
||||
if (keyPair[0] % max == 0)
|
||||
{
|
||||
keyPair[0] += increase;
|
||||
keyPair[1] += max;
|
||||
tags.setIntArray(key, keyPair);
|
||||
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
modifiers -= 1;
|
||||
tags.setInteger("Modifiers", modifiers);
|
||||
}
|
||||
else
|
||||
{
|
||||
keyPair[0] += increase;
|
||||
tags.setIntArray(key, keyPair);
|
||||
}
|
||||
updateModTag(tool, keyPair);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
modifiers -= 1;
|
||||
tags.setInteger("Modifiers", modifiers);
|
||||
String modName = "\u00a72" + guiType + " (" + increase + "/" + max + ")";
|
||||
int tooltipIndex = addToolTip(tool, tooltipName, modName);
|
||||
int[] keyPair = new int[] { increase, max, tooltipIndex };
|
||||
tags.setIntArray(key, keyPair);
|
||||
}
|
||||
}
|
||||
|
||||
void updateModTag (ItemStack tool, int[] keys)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
String tip = "ModifierTip" + keys[2];
|
||||
String modName = "\u00a72" + guiType + " (" + keys[0] + "/" + keys[1] + ")";
|
||||
tags.setString(tip, modName);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
package tconstruct.tools.modifiers;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
public class ModAttack extends ToolModTypeFilter
|
||||
{
|
||||
String tooltipName;
|
||||
int max = 72;
|
||||
String guiType;
|
||||
|
||||
public ModAttack(String type, int effect, ItemStack[] items, int[] value)
|
||||
{
|
||||
super(effect, "ModAttack", items, value);
|
||||
tooltipName = "\u00a7f" + StatCollector.translateToLocal("modifier.tool.quartz");
|
||||
guiType = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canModify (ItemStack tool, ItemStack[] input)
|
||||
{
|
||||
ToolCore toolItem = (ToolCore) tool.getItem();
|
||||
if (!validType(toolItem))
|
||||
return false;
|
||||
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (!tags.hasKey(key))
|
||||
return tags.getInteger("Modifiers") > 0;
|
||||
|
||||
int keyPair[] = tags.getIntArray(key);
|
||||
if (keyPair[0] + matchingAmount(input) <= keyPair[1])
|
||||
return true;
|
||||
|
||||
else if (keyPair[0] == keyPair[1])
|
||||
return tags.getInteger("Modifiers") > 0;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modify (ItemStack[] input, ItemStack tool)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (tags.hasKey(key))
|
||||
{
|
||||
int amount = 24;
|
||||
ToolCore toolItem = (ToolCore) tool.getItem();
|
||||
if (toolItem.pierceArmor() || !nerfType(toolItem))
|
||||
amount = 36;
|
||||
|
||||
int[] keyPair = tags.getIntArray(key);
|
||||
int increase = matchingAmount(input);
|
||||
|
||||
int leftToBoost = amount - (keyPair[0] % amount);
|
||||
if (increase >= leftToBoost)
|
||||
{
|
||||
int attack = tags.getInteger("Attack");
|
||||
attack += 1;
|
||||
tags.setInteger("Attack", attack);
|
||||
}
|
||||
|
||||
if (keyPair[0] % max == 0)
|
||||
{
|
||||
keyPair[0] += increase;
|
||||
keyPair[1] += max;
|
||||
tags.setIntArray(key, keyPair);
|
||||
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
modifiers -= 1;
|
||||
tags.setInteger("Modifiers", modifiers);
|
||||
}
|
||||
else
|
||||
{
|
||||
keyPair[0] += increase;
|
||||
tags.setIntArray(key, keyPair);
|
||||
}
|
||||
updateModTag(tool, keyPair);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
modifiers -= 1;
|
||||
tags.setInteger("Modifiers", modifiers);
|
||||
int increase = matchingAmount(input);
|
||||
String modName = "\u00a7f" + guiType + " (" + increase + "/" + max + ")";
|
||||
int tooltipIndex = addToolTip(tool, tooltipName, modName);
|
||||
int[] keyPair = new int[] { increase, max, tooltipIndex };
|
||||
tags.setIntArray(key, keyPair);
|
||||
|
||||
int attack = tags.getInteger("Attack");
|
||||
attack += 1;
|
||||
tags.setInteger("Attack", attack);
|
||||
}
|
||||
}
|
||||
|
||||
void updateModTag (ItemStack tool, int[] keys)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
String tip = "ModifierTip" + keys[2];
|
||||
String modName = "\u00a7f" + guiType + " (" + keys[0] + "/" + keys[1] + ")";
|
||||
tags.setString(tip, modName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validType (ToolCore tool)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean nerfType (ToolCore tool)
|
||||
{
|
||||
List list = Arrays.asList(tool.toolCategories());
|
||||
return list.contains("throwing") || list.contains("ammo");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package tconstruct.tools.modifiers;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class ModAutoSmelt extends ModBoolean
|
||||
{
|
||||
|
||||
public ModAutoSmelt(ItemStack[] items, int effect, String tag, String c, String tip)
|
||||
{
|
||||
super(items, effect, tag, c, tip);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canModify (ItemStack tool, ItemStack[] input)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (tags.getBoolean("Silk Touch"))
|
||||
return false;
|
||||
return tags.getInteger("Modifiers") > 0 && !tags.getBoolean(key); //Will fail if the modifier is false or the tag doesn't exist
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
package tconstruct.tools.modifiers;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
public class ModBlaze extends ToolModTypeFilter
|
||||
{
|
||||
String tooltipName;
|
||||
int max;
|
||||
|
||||
public ModBlaze(int effect, ItemStack[] items, int[] values)
|
||||
{
|
||||
super(effect, "Blaze", items, values);
|
||||
tooltipName = "\u00a76" + StatCollector.translateToLocal("modifier.tool.blaze");
|
||||
max = 25;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canModify (ItemStack tool, ItemStack[] input)
|
||||
{
|
||||
ToolCore toolItem = (ToolCore) tool.getItem();
|
||||
if (!validType(toolItem))
|
||||
return false;
|
||||
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (!tags.hasKey(key))
|
||||
return tags.getInteger("Modifiers") > 0;
|
||||
|
||||
int keyPair[] = tags.getIntArray(key);
|
||||
if (keyPair[0] + matchingAmount(input) <= keyPair[1])
|
||||
return true;
|
||||
|
||||
else if (keyPair[0] == keyPair[1])
|
||||
return tags.getInteger("Modifiers") > 0;
|
||||
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modify (ItemStack[] input, ItemStack tool)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
int increase = matchingAmount(input);
|
||||
if (tags.hasKey(key))
|
||||
{
|
||||
int[] keyPair = tags.getIntArray(key);
|
||||
if (keyPair[0] == max)
|
||||
{
|
||||
keyPair[0] += increase;
|
||||
keyPair[1] += max;
|
||||
tags.setIntArray(key, keyPair);
|
||||
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
modifiers -= 1;
|
||||
tags.setInteger("Modifiers", modifiers);
|
||||
}
|
||||
else
|
||||
{
|
||||
keyPair[0] += increase;
|
||||
tags.setIntArray(key, keyPair);
|
||||
}
|
||||
updateModTag(tool, keyPair);
|
||||
}
|
||||
else
|
||||
{
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
modifiers -= 1;
|
||||
tags.setInteger("Modifiers", modifiers);
|
||||
String modName = "\u00a76Blaze (" + increase + "/" + max + ")";
|
||||
int tooltipIndex = addToolTip(tool, tooltipName, modName);
|
||||
int[] keyPair = new int[] { increase, max, tooltipIndex };
|
||||
tags.setIntArray(key, keyPair);
|
||||
}
|
||||
|
||||
int fiery = tags.getInteger("Fiery");
|
||||
fiery += (increase);
|
||||
tags.setInteger("Fiery", fiery);
|
||||
|
||||
}
|
||||
|
||||
void updateModTag (ItemStack tool, int[] keys)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
String tip = "ModifierTip" + keys[2];
|
||||
String modName = "\u00a76" + StatCollector.translateToLocal("gui.modifier.blaze") + "(" + keys[0] + "/" + keys[1] + ")";
|
||||
tags.setString(tip, modName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validType (ToolCore tool)
|
||||
{
|
||||
List list = Arrays.asList(tool.toolCategories());
|
||||
return list.contains("melee") || list.contains("ammo");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package tconstruct.tools.modifiers;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import tconstruct.library.tools.ToolMod;
|
||||
|
||||
/* Adds a boolean NBTTag */
|
||||
|
||||
public class ModBoolean extends ToolMod
|
||||
{
|
||||
String color;
|
||||
String tooltipName;
|
||||
|
||||
public ModBoolean(ItemStack[] items, int effect, String tag, String c, String tip)
|
||||
{
|
||||
super(items, effect, tag);
|
||||
color = c;
|
||||
tooltipName = tip;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canModify (ItemStack tool, ItemStack[] input)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
return tags.getInteger("Modifiers") > 0 && !tags.getBoolean(key); // Will
|
||||
// fail
|
||||
// if
|
||||
// the
|
||||
// modifier
|
||||
// is
|
||||
// false
|
||||
// or
|
||||
// the
|
||||
// tag
|
||||
// doesn't
|
||||
// exist
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modify (ItemStack[] input, ItemStack tool)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
|
||||
tags.setBoolean(key, true);
|
||||
// TConstruct.logger.info("Key: "+key+" "+tags.getBoolean(key));
|
||||
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
modifiers -= 1;
|
||||
tags.setInteger("Modifiers", modifiers);
|
||||
|
||||
addToolTip(tool, color + tooltipName, color + key);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
package tconstruct.tools.modifiers;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
public class ModButtertouch extends ModBoolean
|
||||
{
|
||||
|
||||
public ModButtertouch(ItemStack[] items, int effect)
|
||||
{
|
||||
super(items, effect, StatCollector.translateToLocal("gui.modifier.silk"), "\u00a7e", StatCollector.translateToLocal("modifier.tool.silk"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canModify (ItemStack tool, ItemStack[] input)
|
||||
{
|
||||
ToolCore toolItem = (ToolCore) tool.getItem();
|
||||
if (!validType(toolItem))
|
||||
return false;
|
||||
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (!tags.getBoolean("Lava") && !tags.hasKey("Lapis"))
|
||||
{
|
||||
return tags.getInteger("Modifiers") > 0 && !tags.getBoolean(key);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modify (ItemStack[] input, ItemStack tool)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
tags.setBoolean(key, true);
|
||||
addEnchantment(tool, Enchantment.silkTouch, 1);
|
||||
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
modifiers -= 1;
|
||||
tags.setInteger("Modifiers", modifiers);
|
||||
|
||||
int attack = tags.getInteger("Attack");
|
||||
attack -= 3;
|
||||
if (attack < 0)
|
||||
attack = 0;
|
||||
tags.setInteger("Attack", attack);
|
||||
|
||||
int miningSpeed = tags.getInteger("MiningSpeed");
|
||||
miningSpeed -= 300;
|
||||
if (miningSpeed < 0)
|
||||
miningSpeed = 0;
|
||||
tags.setInteger("MiningSpeed", miningSpeed);
|
||||
|
||||
if (tags.hasKey("MiningSpeed2"))
|
||||
{
|
||||
int miningSpeed2 = tags.getInteger("MiningSpeed2");
|
||||
miningSpeed2 -= 300;
|
||||
if (miningSpeed2 < 0)
|
||||
miningSpeed2 = 0;
|
||||
tags.setInteger("MiningSpeed2", miningSpeed2);
|
||||
}
|
||||
|
||||
addToolTip(tool, color + tooltipName, color + key);
|
||||
}
|
||||
|
||||
public void addEnchantment (ItemStack tool, Enchantment enchant, int level)
|
||||
{
|
||||
NBTTagList tags = new NBTTagList();
|
||||
Map enchantMap = EnchantmentHelper.getEnchantments(tool);
|
||||
Iterator iterator = enchantMap.keySet().iterator();
|
||||
int index;
|
||||
int lvl;
|
||||
boolean hasEnchant = false;
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
NBTTagCompound enchantTag = new NBTTagCompound();
|
||||
index = ((Integer) iterator.next()).intValue();
|
||||
lvl = (Integer) enchantMap.get(index);
|
||||
if (index == enchant.effectId)
|
||||
{
|
||||
hasEnchant = true;
|
||||
enchantTag.setShort("id", (short) index);
|
||||
enchantTag.setShort("lvl", (short) ((byte) level));
|
||||
tags.appendTag(enchantTag);
|
||||
}
|
||||
else
|
||||
{
|
||||
enchantTag.setShort("id", (short) index);
|
||||
enchantTag.setShort("lvl", (short) ((byte) lvl));
|
||||
tags.appendTag(enchantTag);
|
||||
}
|
||||
}
|
||||
if (!hasEnchant)
|
||||
{
|
||||
NBTTagCompound enchantTag = new NBTTagCompound();
|
||||
enchantTag.setShort("id", (short) enchant.effectId);
|
||||
enchantTag.setShort("lvl", (short) ((byte) level));
|
||||
tags.appendTag(enchantTag);
|
||||
}
|
||||
tool.stackTagCompound.setTag("ench", tags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validType (ToolCore tool)
|
||||
{
|
||||
List list = Arrays.asList(tool.toolCategories());
|
||||
return list.contains("weapon") || list.contains("harvest");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package tconstruct.tools.modifiers;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
import tconstruct.library.tools.ToolMod;
|
||||
|
||||
public class ModCreativeToolModifier extends ToolMod
|
||||
{
|
||||
public ModCreativeToolModifier(ItemStack[] items)
|
||||
{
|
||||
super(items, 0, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canModify (ItemStack tool, ItemStack[] input)
|
||||
{
|
||||
ToolCore toolItem = (ToolCore) tool.getItem();
|
||||
for (ItemStack stack : input)
|
||||
{
|
||||
if (stack != null && stack.hasTagCompound())
|
||||
{
|
||||
String targetLock = stack.getTagCompound().getString("TargetLock");
|
||||
if (!targetLock.equals("") && !targetLock.equals(toolItem.getToolName()))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modify (ItemStack[] input, ItemStack tool)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
modifiers += 1;
|
||||
tags.setInteger("Modifiers", modifiers);
|
||||
}
|
||||
|
||||
public void addMatchingEffect (ItemStack tool)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package tconstruct.tools.modifiers;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import tconstruct.library.tools.ToolMod;
|
||||
import tconstruct.util.config.PHConstruct;
|
||||
|
||||
/* Adds an integer NBTTag */
|
||||
|
||||
public class ModDurability extends ToolMod
|
||||
{
|
||||
String tooltipName;
|
||||
String color;
|
||||
int durability;
|
||||
float modifier;
|
||||
int miningLevel;
|
||||
|
||||
public ModDurability(ItemStack[] items, int effect, int dur, float mod, int level, String k, String tip, String c)
|
||||
{
|
||||
super(items, effect, k);
|
||||
durability = dur;
|
||||
modifier = mod;
|
||||
miningLevel = level;
|
||||
tooltipName = tip;
|
||||
color = c;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canModify (ItemStack tool, ItemStack[] input)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (tags.hasKey(key))
|
||||
return false;
|
||||
return super.canModify(tool, input);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modify (ItemStack[] input, ItemStack tool)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
|
||||
int base = tags.getInteger("BaseDurability");
|
||||
int bonus = tags.getInteger("BonusDurability");
|
||||
float modDur = tags.getFloat("ModDurability");
|
||||
|
||||
bonus += durability;
|
||||
modDur += modifier;
|
||||
|
||||
int total = (int) ((base + bonus) * (modDur + 1f));
|
||||
if (total <= 0)
|
||||
total = 1;
|
||||
|
||||
tags.setInteger("TotalDurability", total);
|
||||
tags.setInteger("BonusDurability", bonus);
|
||||
tags.setFloat("ModDurability", modDur);
|
||||
|
||||
if (PHConstruct.miningLevelIncrease)
|
||||
{
|
||||
int mLevel = tags.getInteger("HarvestLevel");
|
||||
if (mLevel < miningLevel)
|
||||
tags.setInteger("HarvestLevel", miningLevel);
|
||||
}
|
||||
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
modifiers -= 1;
|
||||
tags.setInteger("Modifiers", modifiers);
|
||||
|
||||
tags.setBoolean(key, true);
|
||||
String modTip = color + key;
|
||||
addToolTip(tool, tooltipName, modTip);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package tconstruct.tools.modifiers;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import tconstruct.library.tools.ToolMod;
|
||||
|
||||
public class ModExtraModifier extends ToolMod
|
||||
{
|
||||
|
||||
public ModExtraModifier(ItemStack[] items, String dataKey)
|
||||
{
|
||||
super(items, 0, dataKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canModify (ItemStack tool, ItemStack[] input)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (tags.getBoolean(key))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modify (ItemStack[] input, ItemStack tool)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
tags.setBoolean(key, true);
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
modifiers += 1;
|
||||
tags.setInteger("Modifiers", modifiers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMatchingEffect (ItemStack tool)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package tconstruct.tools.modifiers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
import cofh.api.energy.IEnergyContainerItem;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
/* TE3 support */
|
||||
|
||||
public class ModFlux extends ModBoolean
|
||||
{
|
||||
|
||||
public ArrayList<ItemStack> batteries = new ArrayList<ItemStack>();
|
||||
|
||||
public ModFlux()
|
||||
{
|
||||
super(new ItemStack[0], 9, StatCollector.translateToLocal("mofifier.tool.flux"), "\u00a7e", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches (ItemStack[] input, ItemStack tool)
|
||||
{
|
||||
boolean battery = false;
|
||||
|
||||
if (input[0] != null)
|
||||
{
|
||||
for (ItemStack stack : batteries)
|
||||
{
|
||||
if (stack.getItem() == input[0].getItem() && input[0].getItem() instanceof IEnergyContainerItem)
|
||||
{
|
||||
battery = true;
|
||||
}
|
||||
}
|
||||
return battery && canModify(tool, input);
|
||||
}
|
||||
|
||||
if (input[1] != null)
|
||||
{
|
||||
|
||||
for (ItemStack stack : batteries)
|
||||
{
|
||||
if (stack.getItem() == input[1].getItem() && input[1].getItem() instanceof IEnergyContainerItem)
|
||||
{
|
||||
battery = true;
|
||||
}
|
||||
return battery && canModify(tool, input);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modify (ItemStack[] input, ItemStack tool)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound();
|
||||
|
||||
if (!tags.hasKey(key))
|
||||
{
|
||||
tags.setBoolean(key, true);
|
||||
|
||||
int modifiers = tags.getCompoundTag("InfiTool").getInteger("Modifiers");
|
||||
modifiers -= 1;
|
||||
tags.getCompoundTag("InfiTool").setInteger("Modifiers", modifiers);
|
||||
int charge = 0;
|
||||
if (input[0] != null && input[0].getItem() != null && input[0].getItem() instanceof IEnergyContainerItem && input[0].hasTagCompound())
|
||||
charge = input[0].getTagCompound().getInteger("Energy");
|
||||
if (input[1] != null && input[1].getItem() != null && input[1].getItem() instanceof IEnergyContainerItem && input[1].hasTagCompound())
|
||||
charge = input[1].getTagCompound().getInteger("Energy");
|
||||
tags.setInteger("Energy", charge);
|
||||
tags.setInteger(key, 1);
|
||||
addModifierTip(tool, "\u00a7eFlux");
|
||||
ToolCore toolcore = (ToolCore) tool.getItem();
|
||||
tool.setItemDamage(1 + (toolcore.getMaxEnergyStored(tool) - charge) * (tool.getMaxDamage() - 1) / toolcore.getMaxEnergyStored(tool));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package tconstruct.tools.modifiers;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import tconstruct.library.tools.ToolMod;
|
||||
|
||||
/* Adds an integer NBTTag */
|
||||
|
||||
public class ModInteger extends ToolMod
|
||||
{
|
||||
String color;
|
||||
String tooltipName;
|
||||
int initialIncrease;
|
||||
int secondaryIncrease;
|
||||
|
||||
public ModInteger(ItemStack[] items, int effect, String dataKey, int increase, String c, String tip)
|
||||
{
|
||||
super(items, effect, dataKey);
|
||||
initialIncrease = secondaryIncrease = increase;
|
||||
color = c;
|
||||
tooltipName = tip;
|
||||
}
|
||||
|
||||
public ModInteger(ItemStack[] items, int effect, String dataKey, int increase1, int increase2, String c, String tip)
|
||||
{
|
||||
super(items, effect, dataKey);
|
||||
initialIncrease = increase1;
|
||||
secondaryIncrease = increase2;
|
||||
color = c;
|
||||
tooltipName = tip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modify (ItemStack[] input, ItemStack tool)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (tags.hasKey(key))
|
||||
{
|
||||
int increase = tags.getInteger(key);
|
||||
increase += secondaryIncrease;
|
||||
tags.setInteger(key, increase);
|
||||
}
|
||||
else
|
||||
{
|
||||
tags.setInteger(key, initialIncrease);
|
||||
}
|
||||
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
modifiers -= 1;
|
||||
tags.setInteger("Modifiers", modifiers);
|
||||
|
||||
addToolTip(tool, color + tooltipName, color + key);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,216 @@
|
||||
package tconstruct.tools.modifiers;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
import tconstruct.library.tools.Weapon;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
public class ModLapis extends ToolModTypeFilter
|
||||
{
|
||||
String tooltipName;
|
||||
int max = 450;
|
||||
|
||||
public ModLapis(int effect, ItemStack[] items, int[] values)
|
||||
{
|
||||
super(effect, "Lapis", items, values);
|
||||
tooltipName = "\u00a79" + StatCollector.translateToLocal("modifier.tool.lapis");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canModify (ItemStack tool, ItemStack[] input)
|
||||
{
|
||||
ToolCore toolItem = (ToolCore) tool.getItem();
|
||||
if (!validType(toolItem))
|
||||
return false;
|
||||
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
|
||||
if (tags.getBoolean("Silk Touch"))
|
||||
return false;
|
||||
|
||||
if (!tags.hasKey(key))
|
||||
return tags.getInteger("Modifiers") > 0;
|
||||
|
||||
int keyPair[] = tags.getIntArray(key);
|
||||
if (keyPair[0] + matchingAmount(input) <= max)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modify (ItemStack[] input, ItemStack tool)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (!tags.hasKey(key))
|
||||
{
|
||||
tags.setBoolean(key, true);
|
||||
|
||||
String modName = "\u00a79Lapis (0/450)";
|
||||
int tooltipIndex = addToolTip(tool, "\u00a79" + StatCollector.translateToLocal("modifier.tool.lapis"), modName);
|
||||
int[] keyPair = new int[] { 0, tooltipIndex };
|
||||
tags.setIntArray(key, keyPair);
|
||||
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
modifiers -= 1;
|
||||
tags.setInteger("Modifiers", modifiers);
|
||||
}
|
||||
|
||||
int increase = matchingAmount(input);
|
||||
int keyPair[] = tags.getIntArray(key);
|
||||
keyPair[0] += increase;
|
||||
tags.setIntArray(key, keyPair);
|
||||
if (tool.getItem() instanceof Weapon)
|
||||
{
|
||||
if (keyPair[0] >= 450)
|
||||
addEnchantment(tool, Enchantment.looting, 3);
|
||||
else if (keyPair[0] >= 300)
|
||||
addEnchantment(tool, Enchantment.looting, 2);
|
||||
else if (keyPair[0] >= 100)
|
||||
addEnchantment(tool, Enchantment.looting, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (keyPair[0] >= 450)
|
||||
addEnchantment(tool, Enchantment.fortune, 3);
|
||||
else if (keyPair[0] >= 300)
|
||||
addEnchantment(tool, Enchantment.fortune, 2);
|
||||
else if (keyPair[0] >= 100)
|
||||
addEnchantment(tool, Enchantment.fortune, 1);
|
||||
}
|
||||
|
||||
updateModTag(tool, keyPair);
|
||||
}
|
||||
|
||||
public void midStreamModify (ItemStack tool, ToolCore toolItem)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (!tags.hasKey(key))
|
||||
return;
|
||||
|
||||
int keyPair[] = tags.getIntArray(key);
|
||||
if (keyPair[0] == max)
|
||||
return;
|
||||
|
||||
if (random.nextInt(50) == 0)
|
||||
{
|
||||
keyPair[0] += 1;
|
||||
tags.setIntArray(key, keyPair);
|
||||
updateModTag(tool, keyPair);
|
||||
}
|
||||
|
||||
List list = Arrays.asList(toolItem.toolCategories());
|
||||
if (list.contains("weapon"))
|
||||
{
|
||||
if (keyPair[0] >= 450)
|
||||
{
|
||||
addEnchantment(tool, Enchantment.looting, 3);
|
||||
}
|
||||
else if (keyPair[0] >= 350)
|
||||
{
|
||||
int chance = keyPair[0] - 300;
|
||||
if (random.nextInt(1000 - chance) == 0)
|
||||
addEnchantment(tool, Enchantment.looting, 3);
|
||||
}
|
||||
else if (keyPair[0] >= 125)
|
||||
{
|
||||
int chance = keyPair[0] - 175;
|
||||
if (random.nextInt(600 - chance) == 0)
|
||||
addEnchantment(tool, Enchantment.looting, 2);
|
||||
}
|
||||
else if (keyPair[0] >= 10)
|
||||
{
|
||||
int chance = keyPair[0] - 25;
|
||||
if (random.nextInt(250 - chance) == 0)
|
||||
addEnchantment(tool, Enchantment.looting, 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (list.contains("harvest"))
|
||||
{
|
||||
if (keyPair[0] >= 450)
|
||||
{
|
||||
addEnchantment(tool, Enchantment.fortune, 3);
|
||||
}
|
||||
else if (keyPair[0] >= 350)
|
||||
{
|
||||
int chance = keyPair[0] - 300;
|
||||
if (random.nextInt(1000 - chance) == 0)
|
||||
addEnchantment(tool, Enchantment.fortune, 3);
|
||||
}
|
||||
else if (keyPair[0] >= 125)
|
||||
{
|
||||
int chance = keyPair[0] - 175;
|
||||
if (random.nextInt(600 - chance) == 0)
|
||||
addEnchantment(tool, Enchantment.fortune, 2);
|
||||
}
|
||||
else if (keyPair[0] >= 10)
|
||||
{
|
||||
int chance = keyPair[0] - 25;
|
||||
if (random.nextInt(250 - chance) == 0)
|
||||
addEnchantment(tool, Enchantment.fortune, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addEnchantment (ItemStack tool, Enchantment enchant, int level)
|
||||
{
|
||||
NBTTagList tags = new NBTTagList();
|
||||
Map enchantMap = EnchantmentHelper.getEnchantments(tool);
|
||||
Iterator iterator = enchantMap.keySet().iterator();
|
||||
int index;
|
||||
int lvl;
|
||||
boolean hasEnchant = false;
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
NBTTagCompound enchantTag = new NBTTagCompound();
|
||||
index = ((Integer) iterator.next()).intValue();
|
||||
lvl = (Integer) enchantMap.get(index);
|
||||
if (index == enchant.effectId)
|
||||
{
|
||||
hasEnchant = true;
|
||||
enchantTag.setShort("id", (short) index);
|
||||
enchantTag.setShort("lvl", (short) ((byte) level));
|
||||
tags.appendTag(enchantTag);
|
||||
}
|
||||
else
|
||||
{
|
||||
enchantTag.setShort("id", (short) index);
|
||||
enchantTag.setShort("lvl", (short) ((byte) lvl));
|
||||
tags.appendTag(enchantTag);
|
||||
}
|
||||
}
|
||||
if (!hasEnchant)
|
||||
{
|
||||
NBTTagCompound enchantTag = new NBTTagCompound();
|
||||
enchantTag.setShort("id", (short) enchant.effectId);
|
||||
enchantTag.setShort("lvl", (short) ((byte) level));
|
||||
tags.appendTag(enchantTag);
|
||||
}
|
||||
tool.stackTagCompound.setTag("ench", tags);
|
||||
}
|
||||
|
||||
void updateModTag (ItemStack tool, int[] keys)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
String tip = "ModifierTip" + keys[1];
|
||||
String modName = "\u00a79" + StatCollector.translateToLocal("gui.modifier.lapis") + "(" + keys[0] + "/" + max + ")";
|
||||
tags.setString(tip, modName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validType (ToolCore tool)
|
||||
{
|
||||
List list = Arrays.asList(tool.toolCategories());
|
||||
return list.contains("weapon") || list.contains("harvest");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package tconstruct.tools.modifiers;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
public class ModPiston extends ToolModTypeFilter
|
||||
{
|
||||
String tooltipName;
|
||||
int max = 10;
|
||||
|
||||
public ModPiston(int effect, ItemStack[] items, int[] values)
|
||||
{
|
||||
super(effect, "Piston", items, values);
|
||||
tooltipName = "\u00a77" + StatCollector.translateToLocal("modifier.tool.piston");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canModify (ItemStack tool, ItemStack[] input)
|
||||
{
|
||||
ToolCore toolItem = (ToolCore) tool.getItem();
|
||||
if (!validType(toolItem))
|
||||
return false;
|
||||
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (!tags.hasKey(key))
|
||||
return tags.getInteger("Modifiers") > 0;
|
||||
|
||||
int keyPair[] = tags.getIntArray(key);
|
||||
if (keyPair[0] + matchingAmount(input) <= keyPair[1])
|
||||
return true;
|
||||
|
||||
else if (keyPair[0] == keyPair[1])
|
||||
return tags.getInteger("Modifiers") > 0;
|
||||
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modify (ItemStack[] input, ItemStack tool)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
int increase = matchingAmount(input);
|
||||
if (tags.hasKey(key))
|
||||
{
|
||||
int[] keyPair = tags.getIntArray(key);
|
||||
if (keyPair[0] % max == 0)
|
||||
{
|
||||
keyPair[0] += increase;
|
||||
keyPair[1] += max;
|
||||
tags.setIntArray(key, keyPair);
|
||||
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
modifiers -= 1;
|
||||
tags.setInteger("Modifiers", modifiers);
|
||||
}
|
||||
else
|
||||
{
|
||||
keyPair[0] += increase;
|
||||
tags.setIntArray(key, keyPair);
|
||||
}
|
||||
updateModTag(tool, keyPair);
|
||||
}
|
||||
else
|
||||
{
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
modifiers -= 1;
|
||||
tags.setInteger("Modifiers", modifiers);
|
||||
String modName = "\u00a74" + StatCollector.translateToLocal("modifier.tool.piston") + "(" + increase + "/" + max + ")";
|
||||
int tooltipIndex = addToolTip(tool, tooltipName, modName);
|
||||
int[] keyPair = new int[] { increase, max, tooltipIndex };
|
||||
tags.setIntArray(key, keyPair);
|
||||
}
|
||||
|
||||
float knockback = tags.getFloat("Knockback");
|
||||
|
||||
knockback += 0.1 * increase;
|
||||
tags.setFloat("Knockback", knockback);
|
||||
}
|
||||
|
||||
void updateModTag (ItemStack tool, int[] keys)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
String tip = "ModifierTip" + keys[2];
|
||||
String modName = "\u00a77" + StatCollector.translateToLocal("modifier.tool.piston") + "(" + keys[0] + "/" + keys[1] + ")";
|
||||
tags.setString(tip, modName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validType (ToolCore tool)
|
||||
{
|
||||
List list = Arrays.asList(tool.toolCategories());
|
||||
return list.contains("weapon");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package tconstruct.tools.modifiers;
|
||||
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import tconstruct.library.tools.ToolMod;
|
||||
|
||||
public class ModPotion extends ToolMod
|
||||
{
|
||||
|
||||
public ModPotion(ItemStack[] items, int effect, String dataKey)
|
||||
{
|
||||
super(new ItemStack[] { new ItemStack(Items.potionitem, 1, Short.MAX_VALUE) }, 0, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canModify (ItemStack tool, ItemStack[] input)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
NBTTagCompound potion = tool.getTagCompound().getCompoundTag("Potion");
|
||||
if (potion == null)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modify (ItemStack[] input, ItemStack tool)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
package tconstruct.tools.modifiers;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
public class ModRedstone extends ToolModTypeFilter
|
||||
{
|
||||
String tooltipName;
|
||||
int max = 50;
|
||||
|
||||
public ModRedstone(int effect, ItemStack[] items, int[] values)
|
||||
{
|
||||
super(effect, "Redstone", items, values);
|
||||
tooltipName = "\u00a74" + StatCollector.translateToLocal("modifier.tool.redstone");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canModify (ItemStack tool, ItemStack[] input)
|
||||
{
|
||||
ToolCore toolItem = (ToolCore) tool.getItem();
|
||||
if (!validType(toolItem))
|
||||
return false;
|
||||
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (!tags.hasKey(key))
|
||||
return tags.getInteger("Modifiers") > 0;
|
||||
|
||||
int keyPair[] = tags.getIntArray(key);
|
||||
if (keyPair[0] + matchingAmount(input) <= keyPair[1])
|
||||
return true;
|
||||
|
||||
else if (keyPair[0] == keyPair[1])
|
||||
return tags.getInteger("Modifiers") > 0;
|
||||
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modify (ItemStack[] input, ItemStack tool)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
int[] keyPair;
|
||||
int increase = matchingAmount(input);
|
||||
if (tags.hasKey(key))
|
||||
{
|
||||
keyPair = tags.getIntArray(key);
|
||||
if (keyPair[0] % max == 0)
|
||||
{
|
||||
keyPair[0] += increase;
|
||||
keyPair[1] += max;
|
||||
tags.setIntArray(key, keyPair);
|
||||
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
modifiers -= 1;
|
||||
tags.setInteger("Modifiers", modifiers);
|
||||
}
|
||||
else
|
||||
{
|
||||
keyPair[0] += increase;
|
||||
tags.setIntArray(key, keyPair);
|
||||
}
|
||||
updateModTag(tool, keyPair);
|
||||
}
|
||||
else
|
||||
{
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
modifiers -= 1;
|
||||
tags.setInteger("Modifiers", modifiers);
|
||||
String modName = "\u00a74" + StatCollector.translateToLocal("gui.modifier.redstone") + "(" + increase + "/" + max + ")";
|
||||
int tooltipIndex = addToolTip(tool, tooltipName, modName);
|
||||
keyPair = new int[] { increase, max, tooltipIndex };
|
||||
tags.setIntArray(key, keyPair);
|
||||
}
|
||||
|
||||
int miningSpeed = tags.getInteger("MiningSpeed");
|
||||
miningSpeed += (increase * 8);
|
||||
tags.setInteger("MiningSpeed", miningSpeed);
|
||||
|
||||
String[] type = { "MiningSpeed2", "MiningSpeedHandle", "MiningSpeedExtra" };
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
if (tags.hasKey(type[i]))
|
||||
{
|
||||
int speed = tags.getInteger(type[i]);
|
||||
speed += (increase * 8);
|
||||
tags.setInteger(type[i], speed);
|
||||
}
|
||||
}
|
||||
|
||||
if (tags.hasKey("DrawSpeed"))
|
||||
{
|
||||
// int drawSpeed = tags.getInteger("DrawSpeed");
|
||||
int baseDrawSpeed = tags.getInteger("BaseDrawSpeed");
|
||||
int drawSpeed = (int) (baseDrawSpeed - (0.1f * baseDrawSpeed * (keyPair[0] / 50f)));
|
||||
tags.setInteger("DrawSpeed", drawSpeed);
|
||||
}
|
||||
}
|
||||
|
||||
void updateModTag (ItemStack tool, int[] keys)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
String tip = "ModifierTip" + keys[2];
|
||||
String modName = "\u00a74" + StatCollector.translateToLocal("gui.modifier.redstone") + "(" + keys[0] + "/" + keys[1] + ")";
|
||||
tags.setString(tip, modName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validType (ToolCore tool)
|
||||
{
|
||||
List list = Arrays.asList(tool.toolCategories());
|
||||
return list.contains("harvest") || list.contains("utility") || list.contains("bow");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package tconstruct.tools.modifiers;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
public class ModReinforced extends ModInteger
|
||||
{
|
||||
|
||||
public ModReinforced(ItemStack[] items, int effect, int increase)
|
||||
{
|
||||
super(items, effect, StatCollector.translateToLocal("modifier.tool.reinforced"), 1, "\u00a75", StatCollector.translateToLocal("modifier.tool.reinforced"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modify (ItemStack[] input, ItemStack tool)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (tags.hasKey(key))
|
||||
{
|
||||
int increase = tags.getInteger(key);
|
||||
increase += secondaryIncrease;
|
||||
tags.setInteger(key, increase);
|
||||
}
|
||||
else
|
||||
{
|
||||
tags.setInteger(key, initialIncrease);
|
||||
}
|
||||
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
modifiers -= 1;
|
||||
tags.setInteger("Modifiers", modifiers);
|
||||
|
||||
int reinforced = tags.getInteger("Unbreaking");
|
||||
reinforced += 1;
|
||||
tags.setInteger("Unbreaking", reinforced);
|
||||
|
||||
addToolTip(tool, color + tooltipName, color + key);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int addToolTip (ItemStack tool, String tooltip, String modifierTip)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
int tipNum = 0;
|
||||
while (true)
|
||||
{
|
||||
tipNum++;
|
||||
String tip = "Tooltip" + tipNum;
|
||||
if (!tags.hasKey(tip))
|
||||
{
|
||||
// tags.setString(tip, tooltip);
|
||||
String modTip = "ModifierTip" + tipNum;
|
||||
String tag = tags.getString(modTip);
|
||||
tags.setString(modTip, getProperName(modifierTip, tag));
|
||||
return tipNum;
|
||||
}
|
||||
else
|
||||
{
|
||||
String modTip = "ModifierTip" + tipNum;
|
||||
String tag = tags.getString(modTip);
|
||||
if (tag.contains(modifierTip))
|
||||
{
|
||||
// tags.setString(tip, getProperName(tooltip, tag));
|
||||
tag = tags.getString(modTip);
|
||||
tags.setString(modTip, getProperName(modifierTip, tag));
|
||||
return tipNum;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
package tconstruct.tools.modifiers;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import tconstruct.library.crafting.PatternBuilder;
|
||||
import tconstruct.library.tools.AbilityHelper;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
import tconstruct.library.tools.ToolMod;
|
||||
|
||||
/* Little mod for actually adding the lapis modifier */
|
||||
|
||||
public class ModRepair extends ToolMod
|
||||
{
|
||||
|
||||
public ModRepair()
|
||||
{
|
||||
super(new ItemStack[0], 0, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches (ItemStack[] input, ItemStack tool)
|
||||
{
|
||||
return canModify(tool, input);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canModify (ItemStack tool, ItemStack[] input)
|
||||
{
|
||||
if ((input[0] == null && input[1] == null))
|
||||
return false;
|
||||
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (tags.getInteger("Damage") > 0)
|
||||
{
|
||||
int headID = tags.getInteger("Head");
|
||||
if (input[0] != null && input[1] != null)
|
||||
return headID == PatternBuilder.instance.getPartID(input[0]) && headID == PatternBuilder.instance.getPartID(input[1]) && calculateIfNecessary(tool, input);
|
||||
else if (input[0] != null && input[1] == null)
|
||||
return headID == PatternBuilder.instance.getPartID(input[0]);
|
||||
else if (input[0] == null && input[1] != null)
|
||||
return headID == PatternBuilder.instance.getPartID(input[1]);
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean calculateIfNecessary (ItemStack tool, ItemStack[] input)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
int damage = tags.getInteger("Damage");
|
||||
int valueSlot1 = 0;
|
||||
int valueSlot2 = 0;
|
||||
if (input[0] != null)
|
||||
valueSlot1 = calculateIncrease(tool, PatternBuilder.instance.getPartValue(input[0]));
|
||||
if (input[1] != null)
|
||||
valueSlot2 = calculateIncrease(tool, PatternBuilder.instance.getPartValue(input[1]));
|
||||
|
||||
return ((damage - valueSlot1) > 0) && ((damage - valueSlot2) > 0);
|
||||
}
|
||||
|
||||
private int calculateIncrease (ItemStack tool, int materialValue)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
int damage = tags.getInteger("Damage");
|
||||
int dur = tags.getInteger("BaseDurability");
|
||||
int increase = (int) (50 + (dur * 0.4f * materialValue));
|
||||
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
float mods = 1.0f;
|
||||
if (modifiers == 2)
|
||||
mods = 0.8f;
|
||||
else if (modifiers == 1)
|
||||
mods = 0.6f;
|
||||
else if (modifiers == 0)
|
||||
mods = 0.4f;
|
||||
|
||||
increase *= mods;
|
||||
|
||||
int repair = tags.getInteger("RepairCount");
|
||||
float repairCount = (100 - repair) / 100f;
|
||||
if (repairCount < 0.5f)
|
||||
repairCount = 0.5f;
|
||||
increase *= repairCount;
|
||||
increase /= ((ToolCore) tool.getItem()).getRepairCost();
|
||||
return increase;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modify (ItemStack[] input, ItemStack tool)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
tags.setBoolean("Broken", false);
|
||||
int damage = tags.getInteger("Damage");
|
||||
int dur = tags.getInteger("BaseDurability");
|
||||
int itemsUsed = 0;
|
||||
|
||||
int materialValue = 0;
|
||||
if (input[0] != null)
|
||||
{
|
||||
materialValue += PatternBuilder.instance.getPartValue(input[0]);
|
||||
itemsUsed++;
|
||||
}
|
||||
if (input[1] != null)
|
||||
{
|
||||
materialValue += PatternBuilder.instance.getPartValue(input[1]);
|
||||
itemsUsed++;
|
||||
}
|
||||
|
||||
int increase = calculateIncrease(tool, materialValue);
|
||||
int repair = tags.getInteger("RepairCount");
|
||||
repair += itemsUsed;
|
||||
tags.setInteger("RepairCount", repair);
|
||||
|
||||
damage -= increase;
|
||||
if (damage < 0)
|
||||
damage = 0;
|
||||
tags.setInteger("Damage", damage);
|
||||
|
||||
AbilityHelper.damageTool(tool, 0, null, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMatchingEffect (ItemStack tool)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package tconstruct.tools.modifiers;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
public class ModSmite extends ToolModTypeFilter
|
||||
{
|
||||
String tooltipName;
|
||||
int max = 36;
|
||||
String tagName;
|
||||
|
||||
public ModSmite(String type, int effect, ItemStack[] items, int[] values)
|
||||
{
|
||||
super(effect, "ModSmite", items, values);
|
||||
tooltipName = "\u00a7e" + StatCollector.translateToLocal("modifier.tool.smite");
|
||||
tagName = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canModify (ItemStack tool, ItemStack[] input)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (!tags.hasKey(key))
|
||||
return tags.getInteger("Modifiers") > 0;
|
||||
|
||||
int keyPair[] = tags.getIntArray(key);
|
||||
if (keyPair[0] + matchingAmount(input) <= keyPair[1])
|
||||
return true;
|
||||
|
||||
else if (keyPair[0] == keyPair[1])
|
||||
return tags.getInteger("Modifiers") > 0;
|
||||
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modify (ItemStack[] input, ItemStack tool)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
int increase = matchingAmount(input);
|
||||
if (tags.hasKey(key))
|
||||
{
|
||||
int[] keyPair = tags.getIntArray(key);
|
||||
|
||||
if (keyPair[0] % max == 0)
|
||||
{
|
||||
keyPair[0] += increase;
|
||||
keyPair[1] += max;
|
||||
tags.setIntArray(key, keyPair);
|
||||
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
modifiers -= 1;
|
||||
tags.setInteger("Modifiers", modifiers);
|
||||
}
|
||||
else
|
||||
{
|
||||
keyPair[0] += increase;
|
||||
tags.setIntArray(key, keyPair);
|
||||
}
|
||||
updateModTag(tool, keyPair);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
modifiers -= 1;
|
||||
tags.setInteger("Modifiers", modifiers);
|
||||
String modName = "\u00a7e" + tagName + " (" + increase + "/" + max + ")";
|
||||
int tooltipIndex = addToolTip(tool, tooltipName, modName);
|
||||
int[] keyPair = new int[] { increase, max, tooltipIndex };
|
||||
tags.setIntArray(key, keyPair);
|
||||
}
|
||||
}
|
||||
|
||||
void updateModTag (ItemStack tool, int[] keys)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
String tip = "ModifierTip" + keys[2];
|
||||
String modName = "\u00a7e" + tagName + " (" + keys[0] + "/" + keys[1] + ")";
|
||||
tags.setString(tip, modName);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,230 @@
|
||||
package tconstruct.tools.modifiers;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import mantle.world.WorldHelper;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.EnumCreatureAttribute;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.item.EntityXPOrb;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.library.ActiveToolMod;
|
||||
import tconstruct.library.tools.AbilityHelper;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import tconstruct.util.config.PHConstruct;
|
||||
import tconstruct.world.TinkerWorld;
|
||||
|
||||
public class TActiveOmniMod extends ActiveToolMod
|
||||
{
|
||||
Random random = new Random();
|
||||
|
||||
/* Updating */
|
||||
@Override
|
||||
public void updateTool (ToolCore tool, ItemStack stack, World world, Entity entity)
|
||||
{
|
||||
if (!world.isRemote && entity instanceof EntityLivingBase && !((EntityLivingBase) entity).isSwingInProgress && stack.getTagCompound() != null)
|
||||
{
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (tags.hasKey("Moss"))
|
||||
{
|
||||
int chance = tags.getInteger("Moss");
|
||||
int check = world.canBlockSeeTheSky((int) entity.posX, (int) entity.posY, (int) entity.posZ) ? 350 : 1150;
|
||||
if (random.nextInt(check) < chance)
|
||||
{
|
||||
AbilityHelper.healTool(stack, 1, (EntityLivingBase) entity, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Harvesting */
|
||||
@Override
|
||||
public boolean beforeBlockBreak (ToolCore tool, ItemStack stack, int x, int y, int z, EntityLivingBase entity)
|
||||
{
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
baconator(tool, stack, entity, tags);
|
||||
|
||||
if (entity instanceof EntityPlayer && ((EntityPlayer) entity).capabilities.isCreativeMode)
|
||||
return false;
|
||||
TinkerTools.modLapis.midStreamModify(stack, tool);
|
||||
|
||||
World world = entity.worldObj;
|
||||
Block block = entity.worldObj.getBlock(x, y, z);
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
// TODO do we need the next to lines????????
|
||||
if (block == null)
|
||||
return false;
|
||||
|
||||
if (tags.getBoolean("Lava") && block.quantityDropped(meta, 0, random) != 0)
|
||||
{
|
||||
ItemStack smeltStack = new ItemStack(block.getItemDropped(meta, random, 0), block.quantityDropped(meta, 0, random), block.damageDropped(meta));
|
||||
if (smeltStack.getItem() == null)
|
||||
return false;
|
||||
ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(smeltStack);
|
||||
if (result != null)
|
||||
{
|
||||
WorldHelper.setBlockToAir(world, x, y, z);
|
||||
if (entity instanceof EntityPlayer && !((EntityPlayer) entity).capabilities.isCreativeMode)
|
||||
tool.onBlockDestroyed(stack, world, block, x, y, z, entity);
|
||||
if (!world.isRemote)
|
||||
{
|
||||
ItemStack spawnme = result.copy();
|
||||
if (!(result.getItem() instanceof ItemBlock) && PHConstruct.lavaFortuneInteraction)
|
||||
{
|
||||
int loot = EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, stack);
|
||||
if (loot > 0)
|
||||
{
|
||||
spawnme.stackSize *= (random.nextInt(loot + 1) + 1);
|
||||
}
|
||||
}
|
||||
EntityItem entityitem = new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, spawnme);
|
||||
|
||||
entityitem.delayBeforeCanPickup = 10;
|
||||
world.spawnEntityInWorld(entityitem);
|
||||
world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12));
|
||||
|
||||
int i = spawnme.stackSize;
|
||||
float f = FurnaceRecipes.smelting().func_151398_b(spawnme);
|
||||
int j;
|
||||
|
||||
if (f == 0.0F)
|
||||
{
|
||||
i = 0;
|
||||
}
|
||||
else if (f < 1.0F)
|
||||
{
|
||||
j = MathHelper.floor_float((float) i * f);
|
||||
|
||||
if (j < MathHelper.ceiling_float_int((float) i * f) && (float) Math.random() < (float) i * f - (float) j)
|
||||
{
|
||||
++j;
|
||||
}
|
||||
|
||||
i = j;
|
||||
}
|
||||
|
||||
while (i > 0)
|
||||
{
|
||||
j = EntityXPOrb.getXPSplit(i);
|
||||
i -= j;
|
||||
entity.worldObj.spawnEntityInWorld(new EntityXPOrb(world, x, y + 0.5, z, j));
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
float f = (float) x + random.nextFloat();
|
||||
float f1 = (float) y + random.nextFloat();
|
||||
float f2 = (float) z + random.nextFloat();
|
||||
float f3 = 0.52F;
|
||||
float f4 = random.nextFloat() * 0.6F - 0.3F;
|
||||
world.spawnParticle("smoke", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("flame", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
|
||||
|
||||
world.spawnParticle("smoke", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("flame", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
|
||||
|
||||
world.spawnParticle("smoke", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("flame", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D);
|
||||
|
||||
world.spawnParticle("smoke", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("flame", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Attacking */
|
||||
|
||||
@Override
|
||||
public int baseAttackDamage (int earlyModDamage, int damage, ToolCore tool, NBTTagCompound tags, NBTTagCompound toolTags, ItemStack stack, EntityLivingBase player, Entity entity)
|
||||
{
|
||||
TinkerTools.modLapis.midStreamModify(stack, tool);
|
||||
baconator(tool, stack, player, tags);
|
||||
return 0;
|
||||
}
|
||||
|
||||
private void baconator (ToolCore tool, ItemStack stack, EntityLivingBase entity, NBTTagCompound tags)
|
||||
{
|
||||
int bacon = 0;
|
||||
bacon += tags.getInteger("Head") == 18 ? 1 : 0;
|
||||
bacon += tags.getInteger("Handle") == 18 ? 1 : 0;
|
||||
bacon += tags.getInteger("Accessory") == 18 ? 1 : 0;
|
||||
bacon += tags.getInteger("Extra") == 18 ? 1 : 0;
|
||||
int chance = tool.getPartAmount() * 100;
|
||||
if (random.nextInt(chance) < bacon)
|
||||
{
|
||||
if (entity instanceof EntityPlayer)
|
||||
AbilityHelper.spawnItemAtPlayer((EntityPlayer) entity, new ItemStack(TinkerWorld.strangeFood, 1, 2));
|
||||
else
|
||||
AbilityHelper.spawnItemAtEntity(entity, new ItemStack(TinkerWorld.strangeFood, 1, 2), 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int attackDamage (int modDamage, int currentDamage, ToolCore tool, NBTTagCompound tags, NBTTagCompound toolTags, ItemStack stack, EntityLivingBase player, Entity entity)
|
||||
{
|
||||
int bonus = 0;
|
||||
if (entity instanceof EntityLivingBase)
|
||||
{
|
||||
EnumCreatureAttribute attribute = ((EntityLivingBase) entity).getCreatureAttribute();
|
||||
if (attribute == EnumCreatureAttribute.UNDEAD)
|
||||
{
|
||||
if (tool == TinkerTools.hammer)
|
||||
{
|
||||
int level = 2;
|
||||
bonus += random.nextInt(level * 2 + 1) + level * 2;
|
||||
}
|
||||
if (toolTags.hasKey("ModSmite"))
|
||||
{
|
||||
int[] array = toolTags.getIntArray("ModSmite");
|
||||
int base = array[0] / 18;
|
||||
bonus += 1 + base + random.nextInt(base + 1);
|
||||
}
|
||||
}
|
||||
if (attribute == EnumCreatureAttribute.ARTHROPOD)
|
||||
{
|
||||
if (toolTags.hasKey("ModAntiSpider"))
|
||||
{
|
||||
int[] array = toolTags.getIntArray("ModAntiSpider");
|
||||
int base = array[0] / 2;
|
||||
bonus += 1 + base + random.nextInt(base + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return bonus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float knockback (float modKnockback, float currentKnockback, ToolCore tool, NBTTagCompound tags, NBTTagCompound toolTags, ItemStack stack, EntityLivingBase player, Entity entity)
|
||||
{
|
||||
float bonus = 0f;
|
||||
if (toolTags.hasKey("Knockback"))
|
||||
{
|
||||
float level = toolTags.getFloat("Knockback");
|
||||
bonus += level;
|
||||
}
|
||||
return bonus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesCriticalHit (ToolCore tool, NBTTagCompound tags, NBTTagCompound toolTags, ItemStack stack, EntityLivingBase player, Entity entity)
|
||||
{
|
||||
if (tool == TinkerTools.cutlass && random.nextInt(10) == 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package tconstruct.tools.modifiers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import tconstruct.library.tools.ToolMod;
|
||||
|
||||
public abstract class ToolModTypeFilter extends ToolMod
|
||||
{
|
||||
public final List<Integer> increase;
|
||||
|
||||
public ToolModTypeFilter(int effect, String dataKey, ItemStack[] items, int[] values)
|
||||
{
|
||||
super(items, effect, dataKey);
|
||||
assert items.length == values.length : "Itemstacks and their values for tool modifiers must be the same length";
|
||||
this.increase = new ArrayList<Integer>();
|
||||
for (int i = 0; i < values.length; i++)
|
||||
{
|
||||
increase.add(values[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if the inputs match the stored items Note: Filters types,
|
||||
* doesn't care about amount
|
||||
*
|
||||
* @param input
|
||||
* The ItemStacks to compare against
|
||||
* @param tool
|
||||
* Item to modify, used for restrictions
|
||||
* @return Whether the recipe matches the input
|
||||
*/
|
||||
@Override
|
||||
public boolean matches (ItemStack[] input, ItemStack tool)
|
||||
{
|
||||
if (!canModify(tool, input))
|
||||
return false;
|
||||
|
||||
boolean minimumMatch = false;
|
||||
for (ItemStack inputStack : input)
|
||||
{
|
||||
if (inputStack == null)
|
||||
continue;
|
||||
|
||||
boolean match = false;
|
||||
for (Object check : stacks)
|
||||
{
|
||||
ItemStack stack = (ItemStack) check;
|
||||
if (stack.getItemDamage() == Short.MAX_VALUE)
|
||||
{
|
||||
if (this.areItemsEquivalent(inputStack, stack))
|
||||
match = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.areItemStacksEquivalent(inputStack, stack))
|
||||
match = true;
|
||||
}
|
||||
}
|
||||
if (!match)
|
||||
return false;
|
||||
|
||||
minimumMatch = true;
|
||||
}
|
||||
return minimumMatch;
|
||||
}
|
||||
|
||||
public int matchingAmount (ItemStack[] input)
|
||||
{
|
||||
int amount = 0;
|
||||
for (ItemStack inputStack : input)
|
||||
{
|
||||
if (inputStack == null)
|
||||
continue;
|
||||
else
|
||||
{
|
||||
for (int iter = 0; iter < stacks.size(); iter++)
|
||||
{
|
||||
ItemStack stack = (ItemStack) stacks.get(iter);
|
||||
if (stack.getItemDamage() == Short.MAX_VALUE)
|
||||
{
|
||||
if (this.areItemsEquivalent(inputStack, stack))
|
||||
amount += increase.get(iter);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.areItemStacksEquivalent(inputStack, stack))
|
||||
amount += increase.get(iter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new itemstack to the list for increases
|
||||
*
|
||||
* @param stack
|
||||
* ItemStack to compare against
|
||||
* @param amount
|
||||
* Amount to increase
|
||||
*/
|
||||
public void addStackToMatchList (ItemStack stack, int amount)
|
||||
{
|
||||
if (stack == null)
|
||||
throw new NullPointerException("ItemStack added to " + this.getClass().getSimpleName() + " cannot be null.");
|
||||
stacks.add(stack);
|
||||
increase.add(amount);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user