Drawbridges and more drawbridges

This commit is contained in:
mDiyo committed 2013-06-30 17:25:35 -07:00
1 parent 801222dbc8
commit 3657ecdbda
11 files changed
+512 -116

No files matched your search

+1 -1
View File
@@ -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
{
@@ -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];
@@ -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);
}
}
@@ -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);
@@ -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++)
@@ -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)
@@ -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)
@@ -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
@@ -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;
@@ -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 ();
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB