From 3657ecdbdaeec4e72a628491d1209396d17a5524 Mon Sep 17 00:00:00 2001 From: mDiyo Date: Sun, 30 Jun 2013 17:25:35 -0700 Subject: [PATCH] Drawbridges and more drawbridges --- mods/tinker/tconstruct/TConstruct.java | 2 +- .../tconstruct/blocks/RedstoneMachine.java | 9 + .../blocks/logic/DrawbridgeLogic.java | 222 +++++++++++++++++- .../tconstruct/client/TProxyClient.java | 4 +- .../inventory/DrawbridgeContainer.java | 1 + .../tconstruct/items/tools/Excavator.java | 2 +- .../tinker/tconstruct/items/tools/Hammer.java | 2 +- .../library/TConstructRegistry.java | 185 +++++++++++++++ .../client/TConstructClientRegistry.java | 1 - .../tconstruct/library/tools/HarvestTool.java | 200 ++++++++-------- mods/tinker/textures/gui/drawbridge.png | Bin 1451 -> 4054 bytes 11 files changed, 512 insertions(+), 116 deletions(-) diff --git a/mods/tinker/tconstruct/TConstruct.java b/mods/tinker/tconstruct/TConstruct.java index 0d860894..4ca7cdbd 100644 --- a/mods/tinker/tconstruct/TConstruct.java +++ b/mods/tinker/tconstruct/TConstruct.java @@ -37,7 +37,7 @@ import cpw.mods.fml.common.registry.VillagerRegistry; * @dependencies: IC2 API, MFR API */ -@Mod(modid = "TConstruct", name = "TConstruct", version = "1.5.1_1.4.dev.5", dependencies = "required-after:Forge@[7.7.1.675,)") +@Mod(modid = "TConstruct", name = "TConstruct", version = "1.5.1_1.4.dev.7", dependencies = "required-after:Forge@[7.7.1.675,)") @NetworkMod(serverSideRequired = false, clientSideRequired = true, channels = { "TConstruct" }, packetHandler = mods.tinker.tconstruct.util.network.TPacketHandler.class) public class TConstruct { diff --git a/mods/tinker/tconstruct/blocks/RedstoneMachine.java b/mods/tinker/tconstruct/blocks/RedstoneMachine.java index 5147e7b5..d9729c80 100644 --- a/mods/tinker/tconstruct/blocks/RedstoneMachine.java +++ b/mods/tinker/tconstruct/blocks/RedstoneMachine.java @@ -12,6 +12,7 @@ import mods.tinker.tconstruct.library.TConstructRegistry; import mods.tinker.tconstruct.library.blocks.InventoryBlock; import mods.tinker.tconstruct.library.util.IActiveLogic; import mods.tinker.tconstruct.library.util.IFacingLogic; +import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; @@ -111,6 +112,14 @@ public class RedstoneMachine extends InventoryBlock int meta = world.getBlockMetadata(x, y, z); if (meta == 0) { + DrawbridgeLogic drawbridge = (DrawbridgeLogic) logic; + ItemStack stack = drawbridge.getStackInSlot(1); + if (stack != null && stack.itemID < 4096) + { + Block block = Block.blocksList[stack.itemID]; + if (block != null && block.renderAsNormalBlock()) + return block.getIcon(side, stack.getItemDamage()); + } if (side == direction) { return icons[getTextureIndex(side) + 3]; diff --git a/mods/tinker/tconstruct/blocks/logic/DrawbridgeLogic.java b/mods/tinker/tconstruct/blocks/logic/DrawbridgeLogic.java index f8966b9f..3ca21d77 100644 --- a/mods/tinker/tconstruct/blocks/logic/DrawbridgeLogic.java +++ b/mods/tinker/tconstruct/blocks/logic/DrawbridgeLogic.java @@ -1,18 +1,24 @@ package mods.tinker.tconstruct.blocks.logic; +import mods.tinker.tconstruct.common.TContent; import mods.tinker.tconstruct.inventory.DrawbridgeContainer; +import mods.tinker.tconstruct.library.TConstructRegistry; import mods.tinker.tconstruct.library.blocks.InventoryLogic; import mods.tinker.tconstruct.library.util.CoordTuple; import mods.tinker.tconstruct.library.util.IActiveLogic; import mods.tinker.tconstruct.library.util.IFacingLogic; import net.minecraft.block.Block; +import net.minecraft.block.BlockPistonMoving; +import net.minecraft.block.BlockSnow; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; +import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.INetworkManager; import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.Packet132TileEntityData; +import net.minecraft.util.Facing; import net.minecraft.util.MathHelper; import net.minecraft.world.World; import net.minecraftforge.common.ForgeDirection; @@ -27,7 +33,7 @@ public class DrawbridgeLogic extends InventoryLogic implements IFacingLogic, IAc public DrawbridgeLogic() { - super(1); + super(2); } @Override @@ -105,6 +111,24 @@ public class DrawbridgeLogic extends InventoryLogic implements IFacingLogic, IAc protected String getDefaultName () { return "tinker.drawbridge"; + } + + @Override + public void setInventorySlotContents(int slot, ItemStack itemstack) + { + super.setInventorySlotContents(slot, itemstack); + if (slot == 1) + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } + + + @Override + public ItemStack decrStackSize(int slot, int quantity) + { + ItemStack stack = super.decrStackSize(slot, quantity); + if (slot == 1) + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + return stack; } public void updateEntity () @@ -115,7 +139,7 @@ public class DrawbridgeLogic extends InventoryLogic implements IFacingLogic, IAc if (ticks == 5) { ticks = 0; - if (active) + if (active) //Placement { if (inventory[0] != null && inventory[0].stackSize > 1 && extension < 16) { @@ -147,11 +171,12 @@ public class DrawbridgeLogic extends InventoryLogic implements IFacingLogic, IAc } Block block = Block.blocksList[worldObj.getBlockId(xPos, yPos, zPos)]; - if (block == null || block.isAirBlock(worldObj, xPos, yPos, zPos)) + if (block == null || block.isAirBlock(worldObj, xPos, yPos, zPos) || block.isBlockReplaceable(worldObj, xPos, yPos, zPos)) { + //tryExtend(worldObj, xPos, yPos, zPos, direction); worldObj.setBlock(xPos, yPos, zPos, inventory[0].itemID, inventory[0].getItemDamage(), 3); + worldObj.playSoundEffect((double)xPos + 0.5D, (double)yPos + 0.5D, (double)zPos + 0.5D, "tile.piston.out", 0.25F, worldObj.rand.nextFloat() * 0.25F + 0.6F); inventory[0].stackSize--; - //inventory[0].getItem().onItemUse(inventory[0], null, worldObj, xPos, yPos, zPos, direction, 0.5F, 0.5F, 0.5F); } else { @@ -165,7 +190,7 @@ public class DrawbridgeLogic extends InventoryLogic implements IFacingLogic, IAc working = false; } } - else + else //Retraction { if ((inventory[0] == null || inventory[0].stackSize < inventory[0].getMaxStackSize()) && extension > 0) { @@ -195,14 +220,13 @@ public class DrawbridgeLogic extends InventoryLogic implements IFacingLogic, IAc break; } - //System.out.println("Extension: "+extension+" Coord: "+new CoordTuple(xPos, yPos, zPos)); - Block block = Block.blocksList[worldObj.getBlockId(xPos, yPos, zPos)]; if (block != null) { int meta = worldObj.getBlockMetadata(xPos, yPos, zPos); - if (block.blockID == inventory[0].itemID && meta == inventory[0].getItemDamage()) + if (inventory[0] != null && validBlock(block) && validMetadata(block.blockID, meta)) { + worldObj.playSoundEffect((double)xPos + 0.5D, (double)yPos + 0.5D, (double)zPos + 0.5D, "tile.piston.in", 0.25F, worldObj.rand.nextFloat() * 0.15F + 0.6F); worldObj.setBlock(xPos, yPos, zPos, 0); inventory[0].stackSize++; } @@ -221,6 +245,184 @@ public class DrawbridgeLogic extends InventoryLogic implements IFacingLogic, IAc } } } + + boolean validBlock(Block block) + { + int type = TConstructRegistry.interchangableBlockMapping[block.blockID]; + if (type != 0) + { + return block.blockID == inventory[0].itemID || type == inventory[0].itemID; + } + return block.blockID == inventory[0].itemID; + } + + boolean validMetadata (int blockID, int metadata) + { + int type = TConstructRegistry.drawbridgeState[blockID]; + if (type == 0) + { + return metadata == inventory[0].getItemDamage(); + } + if (type == 1) + { + return true; + } + if (type == 2) + { + return false; + } + if (type == 3) + { + return true; //TODO: rotational metadata + } + if (type == 4) + { + return true; + } + if (type == 5) + { + return metadata == inventory[0].getItemDamage(); + } + return false; + } + + private boolean tryExtend(World par1World, int x, int y, int z, int side) + { + int posX = x + Facing.offsetsXForSide[side]; + int posY = y + Facing.offsetsYForSide[side]; + int posZ = z + Facing.offsetsZForSide[side]; + int newX = 0; + + while (true) + { + int blockID; + + if (newX < 13) + { + if (posY <= 0 || posY >= par1World.getHeight() - 1) + { + return false; + } + + blockID = par1World.getBlockId(posX, posY, posZ); + + if (blockID != 0) + { + if (!canPushBlock(blockID, par1World, posX, posY, posZ, true)) + { + return false; + } + + if (Block.blocksList[blockID].getMobilityFlag() != 1) + { + if (newX == 12) + { + return false; + } + + posX += Facing.offsetsXForSide[side]; + posY += Facing.offsetsYForSide[side]; + posZ += Facing.offsetsZForSide[side]; + ++newX; + continue; + } + + //With our change to how snowballs are dropped this needs to dissallow to mimic vanilla behavior. + float chance = (Block.blocksList[blockID] instanceof BlockSnow ? -1.0f : 1.0f); + Block.blocksList[blockID].dropBlockAsItemWithChance(par1World, posX, posY, posZ, par1World.getBlockMetadata(posX, posY, posZ), chance, 0); + par1World.setBlockToAir(posX, posY, posZ); + } + } + + newX = posX; + blockID = posY; + int newZ = posZ; + int k2 = 0; + int[] aint; + int l2; + int i3; + int j3; + + for (aint = new int[13]; posX != x || posY != y || posZ != z; posZ = j3) + { + l2 = posX - Facing.offsetsXForSide[side]; + i3 = posY - Facing.offsetsYForSide[side]; + j3 = posZ - Facing.offsetsZForSide[side]; + int k3 = par1World.getBlockId(l2, i3, j3); + int l3 = par1World.getBlockMetadata(l2, i3, j3); + + if (k3 == TContent.redstoneMachine.blockID && l2 == x && i3 == y && j3 == z) + { + par1World.setBlock(posX, posY, posZ, Block.pistonMoving.blockID, side | 0, 4); + par1World.setBlockTileEntity(posX, posY, posZ, BlockPistonMoving.getTileEntity(Block.pistonExtension.blockID, side | 0, side, true, false)); + } + else + { + par1World.setBlock(posX, posY, posZ, Block.pistonMoving.blockID, l3, 4); + par1World.setBlockTileEntity(posX, posY, posZ, BlockPistonMoving.getTileEntity(k3, l3, side, true, false)); + } + + aint[k2++] = k3; + posX = l2; + posY = i3; + } + + posX = newX; + posY = blockID; + posZ = newZ; + + for (k2 = 0; posX != x || posY != y || posZ != z; posZ = j3) + { + l2 = posX - Facing.offsetsXForSide[side]; + i3 = posY - Facing.offsetsYForSide[side]; + j3 = posZ - Facing.offsetsZForSide[side]; + par1World.notifyBlocksOfNeighborChange(l2, i3, j3, aint[k2++]); + posX = l2; + posY = i3; + } + + return true; + } + } + + private static boolean canPushBlock(int par0, World par1World, int par2, int par3, int par4, boolean par5) + { + if (par0 == Block.obsidian.blockID) + { + return false; + } + else + { + if (par0 != Block.pistonBase.blockID && par0 != Block.pistonStickyBase.blockID) + { + if (Block.blocksList[par0].getBlockHardness(par1World, par2, par3, par4) == -1.0F) + { + return false; + } + + if (Block.blocksList[par0].getMobilityFlag() == 2) + { + return false; + } + + if (Block.blocksList[par0].getMobilityFlag() == 1) + { + if (!par5) + { + return false; + } + + return true; + } + } + /*else if (isExtended(par1World.getBlockMetadata(par2, par3, par4))) + { + return false; + }*/ + + return !par1World.blockHasTileEntity(par2, par3, par4); + } + } @Override public void readFromNBT (NBTTagCompound tags) @@ -257,14 +459,14 @@ public class DrawbridgeLogic extends InventoryLogic implements IFacingLogic, IAc public Packet getDescriptionPacket () { NBTTagCompound tag = new NBTTagCompound(); - writeCustomNBT(tag); + writeToNBT(tag); return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag); } @Override public void onDataPacket (INetworkManager net, Packet132TileEntityData packet) { - readCustomNBT(packet.customParam1); + readFromNBT(packet.customParam1); worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); } } diff --git a/mods/tinker/tconstruct/client/TProxyClient.java b/mods/tinker/tconstruct/client/TProxyClient.java index a08006bb..576639a9 100644 --- a/mods/tinker/tconstruct/client/TProxyClient.java +++ b/mods/tinker/tconstruct/client/TProxyClient.java @@ -538,8 +538,8 @@ public class TProxyClient extends TProxyCommon //TConstruct recipes TConstructClientRegistry.registerManualSmallRecipe("patternbook1", new ItemStack(TContent.manualBook, 1, 0), new ItemStack(Item.paper), pattern, null, null); - TConstructClientRegistry.registerManualSmallRecipe("patternbook1", new ItemStack(TContent.manualBook, 1, 1), new ItemStack(TContent.manualBook, 1, 0), null, null, null); - TConstructClientRegistry.registerManualSmallRecipe("patternbook1", new ItemStack(TContent.manualBook, 1, 2), new ItemStack(TContent.manualBook, 1, 1), null, null, null); + TConstructClientRegistry.registerManualSmallRecipe("patternbook2", new ItemStack(TContent.manualBook, 1, 1), new ItemStack(TContent.manualBook, 1, 0), null, null, null); + TConstructClientRegistry.registerManualSmallRecipe("patternbook3", new ItemStack(TContent.manualBook, 1, 2), new ItemStack(TContent.manualBook, 1, 1), null, null, null); TConstructClientRegistry.registerManualSmallRecipe("blankpattern", pattern, plank, stick, stick, plank); TConstructClientRegistry.registerManualSmallRecipe("toolstation", new ItemStack(TContent.toolStationWood, 1, 0), null, pattern, null, workbench); TConstructClientRegistry.registerManualSmallRecipe("partcrafter", new ItemStack(TContent.toolStationWood, 1, 1), null, pattern, null, log); diff --git a/mods/tinker/tconstruct/inventory/DrawbridgeContainer.java b/mods/tinker/tconstruct/inventory/DrawbridgeContainer.java index b4430597..864bc2a1 100644 --- a/mods/tinker/tconstruct/inventory/DrawbridgeContainer.java +++ b/mods/tinker/tconstruct/inventory/DrawbridgeContainer.java @@ -19,6 +19,7 @@ public class DrawbridgeContainer extends Container this.logic = logic; this.addSlotToContainer(new Slot(logic, 0, 80, 36)); + this.addSlotToContainer(new Slot(logic, 1, 35, 36)); /* Player inventory */ for (int column = 0; column < 3; column++) diff --git a/mods/tinker/tconstruct/items/tools/Excavator.java b/mods/tinker/tconstruct/items/tools/Excavator.java index 3d37aae1..219e0de9 100644 --- a/mods/tinker/tconstruct/items/tools/Excavator.java +++ b/mods/tinker/tconstruct/items/tools/Excavator.java @@ -198,7 +198,7 @@ public class Excavator extends HarvestTool int hlvl = MinecraftForge.getBlockHarvestLevel(block, meta, getHarvestType()); float localHardness = block == null ? Float.MAX_VALUE : block.getBlockHardness(world, xPos, yPos, zPos); - if (hlvl <= tags.getInteger("HarvestLevel") && localHardness <= blockHardness) + if (hlvl <= tags.getInteger("HarvestLevel") && localHardness - 1.5 <= blockHardness) { boolean cancelHarvest = false; for (ActiveToolMod mod : TConstructRegistry.activeModifiers) diff --git a/mods/tinker/tconstruct/items/tools/Hammer.java b/mods/tinker/tconstruct/items/tools/Hammer.java index 318c2e53..ba3ef06f 100644 --- a/mods/tinker/tconstruct/items/tools/Hammer.java +++ b/mods/tinker/tconstruct/items/tools/Hammer.java @@ -270,7 +270,7 @@ public class Hammer extends HarvestTool int hlvl = MinecraftForge.getBlockHarvestLevel(block, meta, getHarvestType()); float localHardness = block == null ? Float.MAX_VALUE : block.getBlockHardness(world, xPos, yPos, zPos); - if (hlvl <= tags.getInteger("HarvestLevel") && localHardness <= blockHardness) + if (hlvl <= tags.getInteger("HarvestLevel") && localHardness - 1.5 <= blockHardness) { boolean cancelHarvest = false; for (ActiveToolMod mod : TConstructRegistry.activeModifiers) diff --git a/mods/tinker/tconstruct/library/TConstructRegistry.java b/mods/tinker/tconstruct/library/TConstructRegistry.java index 9501aa64..dbc12963 100644 --- a/mods/tinker/tconstruct/library/TConstructRegistry.java +++ b/mods/tinker/tconstruct/library/TConstructRegistry.java @@ -9,8 +9,12 @@ import java.util.List; import mods.tinker.tconstruct.library.crafting.*; import mods.tinker.tconstruct.library.tools.*; import mods.tinker.tconstruct.library.util.*; +import net.minecraft.block.*; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntitySign; import net.minecraftforge.common.ForgeHooks; /** A registry to store any relevant API work @@ -333,6 +337,187 @@ public class TConstructRegistry activeModifiers.add(mod); } + /* Used to determine how blocks are laid out in the drawbridge + * 0: Metadata has to match + * 1: Metadata has no meaning + * 2: Should not be placed + * 3: Has rotational metadata + * 4: Rails + * 5: Has rotational TileEntity data + */ + public static int[] drawbridgeState = new int[Block.blocksList.length]; + /** Blocks that are interchangable with each other. Ex: Still and flowing water */ + public static int[] interchangableBlockMapping = new int[Block.blocksList.length]; + /** Blocks that place items, and vice versa */ + public static int[] blockToItemMapping = new int[Item.itemsList.length]; + + static void initializeDrawbridgeState () + { + drawbridgeState[Block.stone.blockID] = 1; + drawbridgeState[Block.grass.blockID] = 1; + drawbridgeState[Block.dirt.blockID] = 1; + drawbridgeState[Block.cobblestone.blockID] = 1; + drawbridgeState[Block.bedrock.blockID] = 2; + drawbridgeState[Block.waterMoving.blockID] = 1; + drawbridgeState[Block.waterStill.blockID] = 1; + interchangableBlockMapping[Block.waterStill.blockID] = Block.waterMoving.blockID; + interchangableBlockMapping[Block.waterMoving.blockID] = Block.waterStill.blockID; + drawbridgeState[Block.lavaMoving.blockID] = 1; + drawbridgeState[Block.lavaStill.blockID] = 1; + interchangableBlockMapping[Block.lavaStill.blockID] = Block.lavaMoving.blockID; + interchangableBlockMapping[Block.lavaMoving.blockID] = Block.lavaStill.blockID; + drawbridgeState[Block.sand.blockID] = 1; + drawbridgeState[Block.gravel.blockID] = 1; + drawbridgeState[Block.oreGold.blockID] = 1; + drawbridgeState[Block.oreIron.blockID] = 1; + drawbridgeState[Block.oreCoal.blockID] = 1; + drawbridgeState[Block.sponge.blockID] = 1; + drawbridgeState[Block.oreLapis.blockID] = 1; + drawbridgeState[Block.blockLapis.blockID] = 1; + drawbridgeState[Block.dispenser.blockID] = 3; + drawbridgeState[Block.music.blockID] = 1; + drawbridgeState[Block.bed.blockID] = 2; + drawbridgeState[Block.railPowered.blockID] = 4; + drawbridgeState[Block.railDetector.blockID] = 4; + drawbridgeState[Block.pistonStickyBase.blockID] = 3; + drawbridgeState[Block.web.blockID] = 1; + drawbridgeState[Block.pistonBase.blockID] = 3; + drawbridgeState[Block.pistonExtension.blockID] = 2; + drawbridgeState[Block.plantYellow.blockID] = 1; + drawbridgeState[Block.plantRed.blockID] = 1; + drawbridgeState[Block.mushroomBrown.blockID] = 1; + drawbridgeState[Block.mushroomRed.blockID] = 1; + drawbridgeState[Block.blockGold.blockID] = 1; + drawbridgeState[Block.blockIron.blockID] = 1; + drawbridgeState[Block.brick.blockID] = 1; + drawbridgeState[Block.tnt.blockID] = 1; + drawbridgeState[Block.bookShelf.blockID] = 1; + drawbridgeState[Block.cobblestoneMossy.blockID] = 1; + drawbridgeState[Block.obsidian.blockID] = 1; + drawbridgeState[Block.torchWood.blockID] = 1; + drawbridgeState[Block.fire.blockID] = 1; + drawbridgeState[Block.mobSpawner.blockID] = 2; + drawbridgeState[Block.stairsWoodOak.blockID] = 3; + drawbridgeState[Block.chest.blockID] = 5; + drawbridgeState[Block.redstoneWire.blockID] = 1; + blockToItemMapping[Block.redstoneWire.blockID] = Item.redstone.itemID; + blockToItemMapping[Item.redstone.itemID] = Block.redstoneWire.blockID; + drawbridgeState[Block.oreDiamond.blockID] = 1; + drawbridgeState[Block.blockDiamond.blockID] = 1; + drawbridgeState[Block.workbench.blockID] = 1; + drawbridgeState[Block.crops.blockID] = 2; + drawbridgeState[Block.tilledField.blockID] = 1; + drawbridgeState[Block.furnaceIdle.blockID] = 3; + drawbridgeState[Block.furnaceBurning.blockID] = 3; + interchangableBlockMapping[Block.furnaceIdle.blockID] = Block.furnaceBurning.blockID; + interchangableBlockMapping[Block.furnaceBurning.blockID] = Block.furnaceIdle.blockID; + drawbridgeState[Block.tilledField.blockID] = 1; + drawbridgeState[Block.signPost.blockID] = 3; + drawbridgeState[Block.doorWood.blockID] = 2; + drawbridgeState[Block.ladder.blockID] = 1; + drawbridgeState[Block.rail.blockID] = 4; + drawbridgeState[Block.stairsCobblestone.blockID] = 3; + drawbridgeState[Block.signWall.blockID] = 3; + drawbridgeState[Block.lever.blockID] = 3; + drawbridgeState[Block.pressurePlateStone.blockID] = 1; + drawbridgeState[Block.doorIron.blockID] = 2; + drawbridgeState[Block.pressurePlatePlanks.blockID] = 1; + drawbridgeState[Block.oreRedstone.blockID] = 1; + drawbridgeState[Block.oreRedstoneGlowing.blockID] = 1; + drawbridgeState[Block.torchRedstoneIdle.blockID] = 1; + drawbridgeState[Block.torchRedstoneActive.blockID] = 1; + drawbridgeState[Block.stoneButton.blockID] = 3; + drawbridgeState[Block.snow.blockID] = 1; + drawbridgeState[Block.ice.blockID] = 1; + drawbridgeState[Block.blockSnow.blockID] = 1; + drawbridgeState[Block.cactus.blockID] = 2; + drawbridgeState[Block.blockClay.blockID] = 1; + drawbridgeState[Block.reed.blockID] = 1; + drawbridgeState[Block.jukebox.blockID] = 1; + drawbridgeState[Block.fence.blockID] = 1; + drawbridgeState[Block.pumpkin.blockID] = 1; + drawbridgeState[Block.netherrack.blockID] = 1; + drawbridgeState[Block.slowSand.blockID] = 1; + drawbridgeState[Block.glowStone.blockID] = 1; + drawbridgeState[Block.portal.blockID] = 2; + drawbridgeState[Block.pumpkinLantern.blockID] = 1; + drawbridgeState[Block.cake.blockID] = 2; + drawbridgeState[Block.redstoneRepeaterIdle.blockID] = 3; + drawbridgeState[Block.redstoneRepeaterActive.blockID] = 3; + interchangableBlockMapping[Block.redstoneRepeaterIdle.blockID] = Block.redstoneRepeaterActive.blockID; + interchangableBlockMapping[Block.redstoneRepeaterActive.blockID] = Block.redstoneRepeaterIdle.blockID; + blockToItemMapping[Block.redstoneRepeaterIdle.blockID] = Item.redstoneRepeater.itemID; + blockToItemMapping[Block.redstoneRepeaterActive.blockID] = Item.redstoneRepeater.itemID; + blockToItemMapping[Item.redstoneRepeater.itemID] = Block.redstoneRepeaterIdle.blockID; + drawbridgeState[Block.lockedChest.blockID] = 5; + drawbridgeState[Block.trapdoor.blockID] = 3; + drawbridgeState[Block.mushroomCapBrown.blockID] = 1; + drawbridgeState[Block.mushroomCapRed.blockID] = 1; + drawbridgeState[Block.fenceIron.blockID] = 1; + drawbridgeState[Block.thinGlass.blockID] = 1; + drawbridgeState[Block.melon.blockID] = 1; + drawbridgeState[Block.pumpkinStem.blockID] = 2; + drawbridgeState[Block.melonStem.blockID] = 2; + drawbridgeState[Block.vine.blockID] = 3; + drawbridgeState[Block.fenceGate.blockID] = 3; + drawbridgeState[Block.stairsBrick.blockID] = 3; + drawbridgeState[Block.stairsStoneBrick.blockID] = 3; + drawbridgeState[Block.mycelium.blockID] = 1; + drawbridgeState[Block.waterlily.blockID] = 1; + drawbridgeState[Block.netherBrick.blockID] = 1; + drawbridgeState[Block.netherFence.blockID] = 1; + drawbridgeState[Block.netherFence.blockID] = 3; + drawbridgeState[Block.netherStalk.blockID] = 2; + drawbridgeState[Block.enchantmentTable.blockID] = 1; + drawbridgeState[Block.brewingStand.blockID] = 1; + drawbridgeState[Block.cauldron.blockID] = 1; + drawbridgeState[Block.endPortal.blockID] = 2; + drawbridgeState[Block.dragonEgg.blockID] = 1; + drawbridgeState[Block.redstoneLampIdle.blockID] = 1; + drawbridgeState[Block.redstoneLampActive.blockID] = 1; + drawbridgeState[Block.cocoaPlant.blockID] = 2; + drawbridgeState[Block.stairsSandStone.blockID] = 3; + drawbridgeState[Block.oreEmerald.blockID] = 1; + drawbridgeState[Block.enderChest.blockID] = 5; + drawbridgeState[Block.tripWireSource.blockID] = 1; + drawbridgeState[Block.tripWire.blockID] = 1; + drawbridgeState[Block.blockEmerald.blockID] = 1; + drawbridgeState[Block.stairsWoodSpruce.blockID] = 3; + drawbridgeState[Block.stairsWoodBirch.blockID] = 3; + drawbridgeState[Block.stairsWoodJungle.blockID] = 3; + drawbridgeState[Block.commandBlock.blockID] = 1; + drawbridgeState[Block.beacon.blockID] = 1; + drawbridgeState[Block.cobblestoneWall.blockID] = 1; + drawbridgeState[Block.flowerPot.blockID] = 1; + drawbridgeState[Block.carrot.blockID] = 2; + drawbridgeState[Block.potato.blockID] = 1; + drawbridgeState[Block.woodenButton.blockID] = 3; + drawbridgeState[Block.skull.blockID] = 2; + drawbridgeState[Block.chestTrapped.blockID] = 5; + drawbridgeState[Block.pressurePlateGold.blockID] = 1; + drawbridgeState[Block.pressurePlateIron.blockID] = 1; + drawbridgeState[Block.redstoneComparatorIdle.blockID] = 1; + drawbridgeState[Block.redstoneComparatorActive.blockID] = 1; + interchangableBlockMapping[Block.redstoneComparatorIdle.blockID] = Block.redstoneComparatorActive.blockID; + interchangableBlockMapping[Block.redstoneComparatorActive.blockID] = Block.redstoneComparatorIdle.blockID; + blockToItemMapping[Block.redstoneComparatorIdle.blockID] = Item.comparator.itemID; + blockToItemMapping[Block.redstoneComparatorActive.blockID] = Item.comparator.itemID; + blockToItemMapping[Item.comparator.itemID] = Block.redstoneComparatorIdle.blockID; + drawbridgeState[Block.daylightSensor.blockID] = 1; + drawbridgeState[Block.blockRedstone.blockID] = 1; + drawbridgeState[Block.oreNetherQuartz.blockID] = 1; + drawbridgeState[Block.hopperBlock.blockID] = 3; + drawbridgeState[Block.blockNetherQuartz.blockID] = 1; + drawbridgeState[Block.stairsNetherQuartz.blockID] = 3; + drawbridgeState[Block.railActivator.blockID] = 4; + drawbridgeState[Block.dropper.blockID] = 3; + } + + static + { + initializeDrawbridgeState(); + } + /** Default Material Index * 0: Wood * 1: Stone diff --git a/mods/tinker/tconstruct/library/client/TConstructClientRegistry.java b/mods/tinker/tconstruct/library/client/TConstructClientRegistry.java index 7dcbe018..4c68328f 100644 --- a/mods/tinker/tconstruct/library/client/TConstructClientRegistry.java +++ b/mods/tinker/tconstruct/library/client/TConstructClientRegistry.java @@ -4,7 +4,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Map; -import mods.tinker.tconstruct.client.pages.BookPage; import mods.tinker.tconstruct.library.TConstructRegistry; import mods.tinker.tconstruct.library.crafting.ToolBuilder; import mods.tinker.tconstruct.library.tools.ToolCore; diff --git a/mods/tinker/tconstruct/library/tools/HarvestTool.java b/mods/tinker/tconstruct/library/tools/HarvestTool.java index 9379d6e8..7c7c97cf 100644 --- a/mods/tinker/tconstruct/library/tools/HarvestTool.java +++ b/mods/tinker/tconstruct/library/tools/HarvestTool.java @@ -14,115 +14,115 @@ import net.minecraftforge.common.MinecraftForge; public abstract class HarvestTool extends ToolCore { - public HarvestTool(int itemID, int baseDamage) - { - super(itemID, baseDamage); - } + public HarvestTool(int itemID, int baseDamage) + { + super(itemID, baseDamage); + } - @Override - public boolean onBlockStartBreak (ItemStack stack, int x, int y, int z, EntityPlayer player) - { - NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool"); - World world = player.worldObj; - int bID = player.worldObj.getBlockId(x, y, z); - int meta = world.getBlockMetadata(x, y, z); - Block block = Block.blocksList[bID]; - if (block == null || bID < 1) - return false; - int hlvl = MinecraftForge.getBlockHarvestLevel(block, meta, getHarvestType()); + @Override + public boolean onBlockStartBreak (ItemStack stack, int x, int y, int z, EntityPlayer player) + { + NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool"); + World world = player.worldObj; + int bID = player.worldObj.getBlockId(x, y, z); + int meta = world.getBlockMetadata(x, y, z); + Block block = Block.blocksList[bID]; + if (block == null || bID < 1) + return false; + int hlvl = MinecraftForge.getBlockHarvestLevel(block, meta, getHarvestType()); - if (hlvl <= tags.getInteger("HarvestLevel")) - { - boolean cancelHarvest = false; - for (ActiveToolMod mod : TConstructRegistry.activeModifiers) - { - if (mod.beforeBlockBreak(this, stack, x, y, z, player)) - cancelHarvest = true; - } - return cancelHarvest; - } - else - { - world.setBlockToAir(x, y, z); - if (!player.capabilities.isCreativeMode) - onBlockDestroyed(stack, world, bID, x, y, z, player); - if (!world.isRemote) - world.playAuxSFX(2001, x, y, z, bID + (meta << 12)); - return true; - } - } + if (hlvl <= tags.getInteger("HarvestLevel")) + { + boolean cancelHarvest = false; + for (ActiveToolMod mod : TConstructRegistry.activeModifiers) + { + if (mod.beforeBlockBreak(this, stack, x, y, z, player)) + cancelHarvest = true; + } + return cancelHarvest; + } + else + { + world.setBlockToAir(x, y, z); + if (!player.capabilities.isCreativeMode) + onBlockDestroyed(stack, world, bID, x, y, z, player); + if (!world.isRemote) + world.playAuxSFX(2001, x, y, z, bID + (meta << 12)); + return true; + } + } - @Override - public float getStrVsBlock (ItemStack stack, Block block, int meta) - { + @Override + public float getStrVsBlock (ItemStack stack, Block block, int meta) + { if (!stack.hasTagCompound()) - return 1.0f; - - NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool"); - if (tags.getBoolean("Broken")) - return 0.1f; + return 1.0f; - Material[] materials = getEffectiveMaterials(); - for (int i = 0; i < materials.length; i++) - { - if (materials[i] == block.blockMaterial) - { - float mineSpeed = tags.getInteger("MiningSpeed"); - int heads = 1; - if (tags.hasKey("MiningSpeed2")) - { - mineSpeed += tags.getInteger("MiningSpeed2"); - heads++; - } - - if (tags.hasKey("MiningSpeedHandle")) - { - mineSpeed += tags.getInteger("MiningSpeedHandle"); - heads++; - } - - if (tags.hasKey("MiningSpeedExtra")) - { - mineSpeed += tags.getInteger("MiningSpeedExtra"); - heads++; - } - float trueSpeed = mineSpeed / (heads * 100f); - int hlvl = MinecraftForge.getBlockHarvestLevel(block, meta, getHarvestType()); - int durability = tags.getInteger("Damage"); + NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool"); + if (tags.getBoolean("Broken")) + return 0.1f; - float stonebound = tags.getFloat("Shoddy"); - float bonusLog = (float) Math.log(durability / 72f + 1) * 2 * stonebound; - trueSpeed += bonusLog; + Material[] materials = getEffectiveMaterials(); + for (int i = 0; i < materials.length; i++) + { + if (materials[i] == block.blockMaterial) + { + float mineSpeed = tags.getInteger("MiningSpeed"); + int heads = 1; + if (tags.hasKey("MiningSpeed2")) + { + mineSpeed += tags.getInteger("MiningSpeed2"); + heads++; + } - if (hlvl <= tags.getInteger("HarvestLevel")) - return trueSpeed; - return 0.1f; - } - } - return super.getStrVsBlock(stack, block, meta); - } + if (tags.hasKey("MiningSpeedHandle")) + { + mineSpeed += tags.getInteger("MiningSpeedHandle"); + heads++; + } - public boolean canHarvestBlock (Block block) - { - if (block.blockMaterial.isToolNotRequired()) - { - return true; - } - for (Material m : getEffectiveMaterials()) - { - if (m == block.blockMaterial) - return true; - } - return false; - } + if (tags.hasKey("MiningSpeedExtra")) + { + mineSpeed += tags.getInteger("MiningSpeedExtra"); + heads++; + } + float trueSpeed = mineSpeed / (heads * 100f); + int hlvl = MinecraftForge.getBlockHarvestLevel(block, meta, getHarvestType()); + int durability = tags.getInteger("Damage"); - @Override - public String[] toolCategories () - { - return new String[] { "harvest" }; - } + float stonebound = tags.getFloat("Shoddy"); + float bonusLog = (float) Math.log(durability / 72f + 1) * 2 * stonebound; + trueSpeed += bonusLog; - protected abstract Material[] getEffectiveMaterials (); + if (hlvl <= tags.getInteger("HarvestLevel")) + return trueSpeed; + return 0.1f; + } + } + return super.getStrVsBlock(stack, block, meta); + } - protected abstract String getHarvestType (); + public boolean canHarvestBlock (Block block) + { + if (block.blockMaterial.isToolNotRequired()) + { + return true; + } + for (Material m : getEffectiveMaterials()) + { + if (m == block.blockMaterial) + return true; + } + return false; + } + + @Override + public String[] toolCategories () + { + return new String[] { "harvest" }; + } + + protected abstract Material[] getEffectiveMaterials (); + + protected abstract String getHarvestType (); } diff --git a/mods/tinker/textures/gui/drawbridge.png b/mods/tinker/textures/gui/drawbridge.png index f9a23bc824178834fa56ebf07538b26f0b145de0..38bac0a6e146a49e73f604e21eda703d939ba6af 100644 GIT binary patch literal 4054 zcmd5;i$Bxt|GqcNhGKG9Pi0Ky6hvuU8bzs0lyZ0^mBU!rR+PgddeW1g8k19@ zNu(UN>RBhDMHFF{!!pd-)XaDK{l5Rh_w#w(uls)8r`P9my|4H6zEVAjd)6qgR|WvA zaoy{D5CDjL2muI1c}Kc%KS*SO0 zDA)Zi@Lol<7Q(anvOW)@ z#d0rN{naERfcA$f^pZl-j@8xqSM#W`rAtH&XxX>LAGSyfUNkF3D&tq5T8RU1hY zW394*iPnh)1z75qKdKMUN@Idzg6;rn`bsH6J-k{?83wYl4y@yyMYoT z{k$AO*D;ml$xO9n=ZM2EBl?>Q#OxlEd12nw{-#@B&iwvq50n6R@aCw@EXHqwX*brc zW+z~Io++|8-kq73>5?5k=-iXfJyvDR|CkHgWn+`o+`P|Bf0Vb-pW2XMS~YX~&)45R zrO)d&7mVcR@17i~eCe5=?gY|w`_lTxeb~(oMf1wjLUHPZ_(^cnm_}j(zj5ic{xl{= zmH#bg`SKgtH^)e@gy)eLj$I?R7MfuQfD7SsvxKhp%MqZJAH)W%FghB8QBLDy-DiL{^g|U#sY~r`Aj;mDkVb z*T+jL`J;1rHxEn05fCUi{_`13^0ITJxSf4=PV zGANj}smU0+Yy<_LD_tVYt7c|0x$G&+9?_Tw=y@IeNKZY-M=UEcEUrg5N?oO@z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