Improved Metadata Rotation Code

Simplified metadata rotation code by only having a single function that
rotates metadata by 90 degrees clockwise and applying it repeatedly for
180 and 270 degree rotations. Removed flipDoorMetadata() from dimHelper
and replaced all references to it with references to BlockRotator. This
makes all our rotations reference a single function. Replaced hardcoded
rotation in DungeonSchematic.

Added support for wood (tree trunk) and quartz pillar metadata
rotations.
This commit is contained in:
SenseiKiwi 2013-08-02 07:48:44 -04:00
parent 0c7da8a54c
commit b050c6c61b
5 changed files with 263 additions and 747 deletions

View file

@ -7,12 +7,14 @@ import StevenDimDoors.mod_pocketDim.LinkData;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
import StevenDimDoors.mod_pocketDim.helpers.yCoordHelper;
import StevenDimDoors.mod_pocketDim.schematic.BlockRotator;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
@ -67,7 +69,8 @@ public class ExitDoor extends dimDoor
dimHelper.instance.createLink(locDimID, ExitDimID, par2, par3, par4, par2, yCoord, par4,par1World.getBlockMetadata(par2, par3-1, par4));
dimHelper.instance.createLink(ExitDimID, locDimID, par2, yCoord, par4, par2, par3, par4,dimHelper.instance.flipDoorMetadata(par1World.getBlockMetadata(par2, par3-1, par4)));
dimHelper.instance.createLink(ExitDimID, locDimID, par2, yCoord, par4, par2, par3, par4,
BlockRotator.transformMetadata(par1World.getBlockMetadata(par2, par3 - 1, par4), 2, Block.doorWood.blockID));
}

View file

@ -7,6 +7,7 @@ import StevenDimDoors.mod_pocketDim.LinkData;
import StevenDimDoors.mod_pocketDim.TileEntityDimDoor;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
import StevenDimDoors.mod_pocketDim.schematic.BlockRotator;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
@ -150,7 +151,7 @@ public class dimDoor extends BlockContainer
if(par1World.getBlockMetadata(par2, par3-1, par4)==var12)
{
var12=dimHelper.instance.flipDoorMetadata(var12);
var12 = BlockRotator.transformMetadata(var12, 2, Block.doorWood.blockID);
}
par1World.setBlockMetadataWithNotify(par2, par3-1, par4, var12,2);
@ -165,7 +166,7 @@ public class dimDoor extends BlockContainer
int var12 = (int) (MathHelper.floor_double((double)((par5EntityPlayer.rotationYaw+90) * 4.0F / 360.0F) + 0.5D) & 3);
if(par1World.getBlockMetadata(par2, par3, par4)==var12)
{
var12=dimHelper.instance.flipDoorMetadata(var12);
var12 = BlockRotator.transformMetadata(var12, 2, Block.doorWood.blockID);
}
par1World.setBlockMetadataWithNotify(par2, par3, par4, var12,2);

View file

@ -102,7 +102,9 @@ public class DungeonSchematic extends Schematic {
MONOLITH_SPAWN_MARKER_ID, EXIT_DOOR_MARKER_ID);
applyFilter(finder);
orientation = (finder.getEntranceOrientation() + 2) & 3; //Flip the entrance's orientation to get the dungeon's orientation
//Flip the entrance's orientation to get the dungeon's orientation
orientation = BlockRotator.transformMetadata(finder.getEntranceOrientation(), 2, Block.doorWood.blockID);
entranceDoorLocation = finder.getEntranceDoorLocation();
exitDoorLocations = finder.getExitDoorLocations();
dimensionalDoorLocations = finder.getDimensionalDoorLocations();
@ -195,7 +197,7 @@ public class DungeonSchematic extends Schematic {
pocketPoint.setZ(dz);
blockID = blocks[index];
BlockRotator.transformPoint(pocketPoint, entranceDoorLocation, turnAngle, pocketCenter);
blockMeta = BlockRotator.transformMetadata(metadata[index], turnAngle + BlockRotator.NORTH_DOOR_METADATA, blockID);
blockMeta = BlockRotator.transformMetadata(metadata[index], turnAngle, blockID);
//In the future, we might want to make this more efficient by building whole chunks at a time
setBlockDirectly(world, pocketPoint.getX(), pocketPoint.getY(), pocketPoint.getZ(), blockID, blockMeta);
@ -353,7 +355,7 @@ public class DungeonSchematic extends Schematic {
sideLink.locXCoord,
sideLink.locYCoord,
sideLink.locZCoord,
dimHelper.instance.flipDoorMetadata(sideLink.linkOrientation));
BlockRotator.transformMetadata(sideLink.linkOrientation, 2, Block.doorWood.blockID));
if (world.getBlockId(linkDestination.getX(), linkDestination.getY() - 3, linkDestination.getZ()) == properties.FabricBlockID)
{

View file

@ -43,6 +43,7 @@ import StevenDimDoors.mod_pocketDim.SchematicLoader;
import StevenDimDoors.mod_pocketDim.TileEntityRift;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.dungeon.DungeonSchematic;
import StevenDimDoors.mod_pocketDim.schematic.BlockRotator;
import StevenDimDoors.mod_pocketDim.world.LimboProvider;
import StevenDimDoors.mod_pocketDim.world.PocketProvider;
import cpw.mods.fml.common.FMLCommonHandler;
@ -92,44 +93,6 @@ public class dimHelper extends DimensionManager
public static final int DEFAULT_POCKET_SIZE = 39;
public static final int DEFAULT_POCKET_WALL_THICKNESS = 5;
public static final int MAX_WORLD_HEIGHT = 254;
//Stupid function I use because I don't understand bitwise operations yet. Used in door orientation
//TODO get rid of this
public int flipDoorMetadata(int data)
{
if(data==0)
{
return 2;
}
if(data==1)
{
return 3;
}
if(data==2)
{
return 0;
}
if(data==3)
{
return 1;
}
if(data==4)
{
return 6;
}
if(data==5)
{
return 7;
}
if(data==6)
{
return 4;
}
if(data==7)
{
return 5;
}
else return -10;
}
public int getDimDepth(int DimID)
{
@ -849,7 +812,7 @@ public class dimHelper extends DimensionManager
PacketHandler.onDimCreatedPacket(destDimData);
}
link = this.createLink(DimensionManager.getWorld(link.locDimID).provider.dimensionId,dimensionID,link.locXCoord,link.locYCoord,link.locZCoord, link.destXCoord,constrainPocketY(link.destYCoord),link.destZCoord,link.linkOrientation); //creates and registers the two rifts that link the parent and pocket dim.
this.createLink(dimensionID,DimensionManager.getWorld(link.locDimID).provider.dimensionId, link.destXCoord,constrainPocketY(link.destYCoord),link.destZCoord, link.locXCoord,link.locYCoord,link.locZCoord, this.flipDoorMetadata(link.linkOrientation));
this.createLink(dimensionID,DimensionManager.getWorld(link.locDimID).provider.dimensionId, link.destXCoord,constrainPocketY(link.destYCoord),link.destZCoord, link.locXCoord,link.locYCoord,link.locZCoord, BlockRotator.transformMetadata(link.linkOrientation, 2, Block.doorWood.blockID));
return link;
}

View file

@ -1,7 +1,5 @@
package StevenDimDoors.mod_pocketDim.schematic;
import java.util.ArrayList;
import net.minecraft.block.Block;
import net.minecraft.block.BlockComparator;
import net.minecraft.block.BlockDoor;
@ -17,720 +15,269 @@ public class BlockRotator
//until we can rewrite it.
public final static int EAST_DOOR_METADATA = 0;
private final static int SOUTH_DOOR_METADATA = 1;
private final static int WEST_DOOR_METADATA = 2;
public final static int NORTH_DOOR_METADATA = 3;
private final static int BLOCK_ID_COUNT = 4096;
private final static ArrayList<Integer> metadataFlipList = new ArrayList<Integer>();
//Provides a fast lookup table for whether blocks have orientations
private final static boolean[] hasOrientations = new boolean[BLOCK_ID_COUNT];
static
{
metadataFlipList.add(Block.dispenser.blockID);
metadataFlipList.add(Block.stairsStoneBrick.blockID);
metadataFlipList.add(Block.lever.blockID);
metadataFlipList.add(Block.stoneButton.blockID);
metadataFlipList.add(Block.redstoneRepeaterIdle.blockID);
metadataFlipList.add(Block.redstoneRepeaterActive.blockID);
metadataFlipList.add(Block.tripWireSource.blockID);
metadataFlipList.add(Block.torchWood.blockID);
metadataFlipList.add(Block.torchRedstoneIdle.blockID);
metadataFlipList.add(Block.torchRedstoneActive.blockID);
metadataFlipList.add(Block.doorIron.blockID);
metadataFlipList.add(Block.doorWood.blockID);
metadataFlipList.add(Block.pistonBase.blockID);
metadataFlipList.add(Block.pistonStickyBase.blockID);
metadataFlipList.add(Block.pistonExtension.blockID);
metadataFlipList.add(Block.redstoneComparatorIdle.blockID);
metadataFlipList.add(Block.redstoneComparatorActive.blockID);
metadataFlipList.add(Block.signPost.blockID);
metadataFlipList.add(Block.signWall.blockID);
metadataFlipList.add(Block.skull.blockID);
metadataFlipList.add(Block.ladder.blockID);
metadataFlipList.add(Block.vine.blockID);
metadataFlipList.add(Block.anvil.blockID);
metadataFlipList.add(Block.chest.blockID);
metadataFlipList.add(Block.chestTrapped.blockID);
metadataFlipList.add(Block.hopperBlock.blockID);
metadataFlipList.add(Block.stairsNetherBrick.blockID);
metadataFlipList.add(Block.stairsCobblestone.blockID);
metadataFlipList.add(Block.stairsNetherBrick.blockID);
metadataFlipList.add(Block.stairsNetherQuartz.blockID);
metadataFlipList.add(Block.stairsSandStone.blockID);
metadataFlipList.add(mod_pocketDim.dimDoor.blockID);
metadataFlipList.add(mod_pocketDim.ExitDoor.blockID);
hasOrientations[Block.dispenser.blockID] = true;
hasOrientations[Block.stairsStoneBrick.blockID] = true;
hasOrientations[Block.lever.blockID] = true;
hasOrientations[Block.stoneButton.blockID] = true;
hasOrientations[Block.redstoneRepeaterIdle.blockID] = true;
hasOrientations[Block.redstoneRepeaterActive.blockID] = true;
hasOrientations[Block.tripWireSource.blockID] = true;
hasOrientations[Block.torchWood.blockID] = true;
hasOrientations[Block.torchRedstoneIdle.blockID] = true;
hasOrientations[Block.torchRedstoneActive.blockID] = true;
hasOrientations[Block.doorIron.blockID] = true;
hasOrientations[Block.doorWood.blockID] = true;
hasOrientations[Block.pistonBase.blockID] = true;
hasOrientations[Block.pistonStickyBase.blockID] = true;
hasOrientations[Block.pistonExtension.blockID] = true;
hasOrientations[Block.redstoneComparatorIdle.blockID] = true;
hasOrientations[Block.redstoneComparatorActive.blockID] = true;
hasOrientations[Block.signPost.blockID] = true;
hasOrientations[Block.signWall.blockID] = true;
hasOrientations[Block.skull.blockID] = true;
hasOrientations[Block.ladder.blockID] = true;
hasOrientations[Block.vine.blockID] = true;
hasOrientations[Block.anvil.blockID] = true;
hasOrientations[Block.chest.blockID] = true;
hasOrientations[Block.chestTrapped.blockID] = true;
hasOrientations[Block.hopperBlock.blockID] = true;
hasOrientations[Block.stairsNetherBrick.blockID] = true;
hasOrientations[Block.stairsCobblestone.blockID] = true;
hasOrientations[Block.stairsNetherBrick.blockID] = true;
hasOrientations[Block.stairsNetherQuartz.blockID] = true;
hasOrientations[Block.stairsSandStone.blockID] = true;
hasOrientations[Block.wood.blockID] = true;
hasOrientations[Block.blockNetherQuartz.blockID] = true;
hasOrientations[mod_pocketDim.dimDoor.blockID] = true;
hasOrientations[mod_pocketDim.ExitDoor.blockID] = true;
}
public static int transformMetadata(int metadata, int orientation, int blockID)
public static int transformMetadata(int metadata, int turns, int blockID)
{
//I changed rotations to reduce the monstrous code we had. It might be
//slightly less efficient, but it's easier to maintain for now. ~SenseiKiwi
//Correct negative turns and get the minimum number of rotations needed
turns += 1 << 16;
turns %= 4;
if (hasOrientations[blockID])
{
while (turns > 0)
{
metadata = rotateMetadataBy90(metadata, blockID);
turns--;
}
}
return metadata;
}
private static int rotateMetadataBy90(int metadata, int blockID)
{
//TODO: Replace this horrible function with something prettier. We promise we will for the next version,
//after switching to MC 1.6. PADRE, PLEASE FORGIVE ME.
//Hax to fix negative orientations
orientation += 1 << 16;
orientation %= 4;
if (metadataFlipList.contains(blockID))
//after switching to MC 1.6. PADRE, PLEASE FORGIVE OUR SINS.
if (blockID == Block.wood.blockID)
{
switch (orientation)
if (metadata >= 4 && metadata < 12)
{
case EAST_DOOR_METADATA:
return (metadata % 8) + 4;
}
}
else if (blockID == Block.blockNetherQuartz.blockID)
{
if (metadata == 3 || metadata == 4)
{
return (metadata - 2) % 2 + 3;
}
}
else if (Block.blocksList[blockID] instanceof BlockStairs)
{
if (blockID == Block.hopperBlock.blockID)
{
switch (metadata)
{
case 2:
metadata = 5;
break;
case 3:
metadata = 4;
break;
case 4:
metadata = 2;
break;
case 5:
metadata = 3;
break;
}
}
if(Block.blocksList[blockID] instanceof BlockStairs)
{
switch (metadata)
{
case 0:
metadata = 2;
break;
case 1:
metadata = 3;
break;
case 2:
metadata = 1;
break;
case 3:
metadata = 0;
break;
case 7:
metadata = 4;
break;
case 6:
metadata = 5;
break;
case 5:
metadata = 7;
break;
case 4:
metadata = 6;
break;
}
}
else if(blockID== Block.chest.blockID||blockID== Block.chestTrapped.blockID||blockID== Block.ladder.blockID)
{
switch (metadata)
{
case 2:
metadata = 5;
break;
case 3:
metadata = 4;
break;
case 4:
metadata = 2;
break;
case 5:
metadata = 3;
break;
}
}
else if (blockID==Block.vine.blockID)
{
switch (metadata)
{
case 1:
metadata = 2;
break;
case 2:
metadata = 4;
break;
case 4:
metadata = 8;
break;
case 8:
metadata = 1;
break;
}
}
else if(blockID== Block.lever.blockID||blockID== Block.stoneButton.blockID||blockID== Block.woodenButton.blockID||blockID== Block.torchWood.blockID||blockID== Block.torchRedstoneIdle.blockID||blockID== Block.torchRedstoneActive.blockID)
{
switch (metadata)
{
case 12:
metadata = 9;
break;
case 11:
metadata = 10;
break;
case 10:
metadata = 12;
break;
case 9:
metadata = 11;
break;
case 2:
metadata = 4;
break;
case 3:
metadata = 2;
break;
case 1:
metadata = 3;
break;
case 4:
metadata = 1;
break;
}
}
else if(blockID== Block.pistonBase.blockID||blockID==Block.pistonExtension.blockID||blockID==Block.pistonStickyBase.blockID||blockID==Block.dispenser.blockID||blockID==Block.dropper.blockID)
{
switch (metadata)
{
case 4:
metadata = 2;
break;
case 5:
metadata = 3;
break;
case 13:
metadata = 11;
break;
case 12:
metadata = 10;
break;
case 3:
metadata = 4;
break;
case 2:
metadata = 5;
break;
case 11:
metadata = 12;
break;
case 10:
metadata = 13;
break;
}
}
else if(Block.blocksList[blockID] instanceof BlockRedstoneRepeater || Block.blocksList[blockID] instanceof BlockDoor || Block.blocksList[blockID] instanceof dimDoor || blockID== Block.tripWireSource.blockID || Block.blocksList[blockID] instanceof BlockComparator)
{
switch (metadata)
{
case 0:
metadata = 1;
break;
case 1:
metadata = 2;
break;
case 2:
metadata = 3;
break;
case 3:
metadata = 0;
break;
case 4:
metadata = 5;
break;
case 5:
metadata = 6;
break;
case 6:
metadata = 7;
break;
case 7:
metadata = 4;
break;
case 8:
metadata = 9;
break;
case 9:
metadata = 10;
break;
case 10:
metadata = 11;
break;
case 11:
metadata = 8;
break;
case 12:
metadata = 13;
break;
case 13:
metadata = 14;
break;
case 14:
metadata = 15;
break;
case 15:
metadata = 12;
break;
}
}
switch (metadata)
{
case 0:
metadata = 2;
break;
case SOUTH_DOOR_METADATA:
if (blockID == Block.hopperBlock.blockID)
{
switch (metadata)
{
case 2:
metadata = 3;
break;
case 3:
metadata = 2;
break;
case 4:
metadata = 5;
break;
case 5:
metadata = 4;
break;
}
}
if(Block.blocksList[blockID] instanceof BlockStairs)
{
switch (metadata)
{
case 0:
metadata = 1;
break;
case 1:
metadata = 0;
break;
case 2:
metadata = 3;
break;
case 3:
metadata = 2;
break;
case 7:
metadata = 6;
break;
case 6:
metadata = 7;
break;
case 5:
metadata = 4;
break;
case 4:
metadata = 5;
break;
}
}
else if(blockID== Block.chest.blockID||blockID== Block.chestTrapped.blockID||blockID==Block.ladder.blockID)
{
switch (metadata)
{
case 2:
metadata = 3;
break;
case 3:
metadata = 2;
break;
case 4:
metadata = 5;
break;
case 5:
metadata = 4;
break;
}
}
else if(blockID==Block.vine.blockID)
{
switch (metadata)
{
case 1:
metadata = 4;
break;
case 2:
metadata = 8;
break;
case 4:
metadata = 1;
break;
case 8:
metadata = 2;
break;
}
}
else if(blockID== Block.lever.blockID||blockID== Block.torchWood.blockID||blockID== Block.torchRedstoneIdle.blockID||blockID== Block.torchRedstoneActive.blockID)
{
switch (metadata)
{
case 12:
metadata = 11;
break;
case 11:
metadata = 12;
break;
case 10:
metadata = 9;
break;
case 9:
metadata = 10;
break;
case 2:
metadata = 1;
break;
case 3:
metadata = 4;
break;
case 1:
metadata = 2;
break;
case 4:
metadata = 3;
break;
}
}
else if(blockID== Block.pistonBase.blockID||blockID==Block.pistonStickyBase.blockID||blockID==Block.dispenser.blockID||blockID==Block.dropper.blockID)
{
switch (metadata)
{
case 4:
metadata = 5;
break;
case 5:
metadata = 4;
break;
case 13:
metadata = 12;
break;
case 12:
metadata = 13;
break;
case 3:
metadata = 2;
break;
case 2:
metadata = 3;
break;
case 11:
metadata = 10;
break;
case 10:
metadata = 11;
break;
}
}
else if(Block.blocksList[blockID] instanceof BlockRedstoneRepeater ||Block.blocksList[blockID] instanceof BlockDoor || Block.blocksList[blockID] instanceof dimDoor || blockID== Block.tripWireSource.blockID||Block.blocksList[blockID] instanceof BlockComparator)
{
switch (metadata)
{
case 0:
metadata = 2;
break;
case 1:
metadata = 3;
break;
case 2:
metadata = 0;
break;
case 3:
metadata = 1;
break;
case 4:
metadata = 6;
break;
case 5:
metadata = 7;
break;
case 6:
metadata = 4;
break;
case 7:
metadata = 5;
break;
case 8:
metadata = 10;
break;
case 9:
metadata = 11;
break;
case 10:
metadata = 8;
break;
case 11:
metadata = 9;
break;
case 12:
metadata = 14;
break;
case 13:
metadata = 15;
break;
case 14:
metadata = 12;
break;
case 15:
metadata = 13;
break;
}
}
case 1:
metadata = 3;
break;
case WEST_DOOR_METADATA:
if (blockID == Block.hopperBlock.blockID)
{
switch (metadata)
{
case 2:
metadata = 4;
break;
case 3:
metadata = 5;
break;
case 4:
metadata = 3;
break;
case 5:
metadata = 2;
break;
}
}
if(Block.blocksList[blockID] instanceof BlockStairs)
{
switch (metadata)
{
case 2:
metadata = 0;
break;
case 3:
metadata = 1;
break;
case 1:
metadata = 2;
break;
case 0:
metadata = 3;
break;
case 4:
metadata = 7;
break;
case 5:
metadata = 6;
break;
case 7:
metadata = 5;
break;
case 6:
metadata = 4;
break;
}
}
else if(blockID== Block.chest.blockID||blockID== Block.chestTrapped.blockID||blockID==Block.ladder.blockID)
{
switch (metadata)
{
case 2:
metadata = 4;
break;
case 3:
metadata = 5;
break;
case 4:
metadata = 3;
break;
case 5:
metadata = 2;
break;
}
}
else if(blockID==Block.vine.blockID)
{
switch (metadata)
{
case 1:
metadata = 8;
break;
case 2:
metadata = 1;
break;
case 4:
metadata = 2;
break;
case 8:
metadata = 4;
break;
}
}
else if(blockID== Block.lever.blockID||blockID== Block.torchWood.blockID||blockID== Block.torchRedstoneIdle.blockID||blockID== Block.torchRedstoneActive.blockID)
{
switch (metadata)
{
case 9:
metadata = 12;
break;
case 10:
metadata = 11;
break;
case 12:
metadata = 10;
break;
case 11:
metadata = 9;
break;
case 4:
metadata = 2;
break;
case 2:
metadata = 3;
break;
case 3:
metadata = 1;
break;
case 1:
metadata = 4;
break;
}
}
else if(blockID== Block.pistonBase.blockID||blockID==Block.pistonStickyBase.blockID||blockID==Block.dispenser.blockID||blockID==Block.dropper.blockID)
{
switch (metadata)
{
case 2:
metadata = 4;
break;
case 3:
metadata = 5;
break;
case 11:
metadata = 13;
break;
case 10:
metadata = 12;
break;
case 4:
metadata = 3;
break;
case 5:
metadata = 2;
break;
case 12:
metadata = 11;
break;
case 13:
metadata = 10;
break;
}
}
else if(Block.blocksList[blockID] instanceof BlockRedstoneRepeater ||Block.blocksList[blockID] instanceof BlockDoor || Block.blocksList[blockID] instanceof dimDoor || blockID== Block.tripWireSource.blockID||Block.blocksList[blockID] instanceof BlockComparator)
{
switch (metadata)
{
case 1:
metadata = 0;
break;
case 2:
metadata = 1;
break;
case 3:
metadata = 2;
break;
case 0:
metadata = 3;
break;
case 5:
metadata = 4;
break;
case 6:
metadata = 5;
break;
case 7:
metadata = 6;
break;
case 4:
metadata = 7;
break;
case 9:
metadata = 8;
break;
case 10:
metadata = 9;
break;
case 11:
metadata = 10;
break;
case 8:
metadata = 11;
break;
case 13:
metadata = 12;
break;
case 14:
metadata = 13;
break;
case 15:
metadata = 14;
break;
case 12:
metadata = 15;
break;
}
}
case 2:
metadata = 1;
break;
case NORTH_DOOR_METADATA:
/**
* this is the default case- never need to change anything here
*
*/
case 3:
metadata = 0;
break;
case 7:
metadata = 4;
break;
case 6:
metadata = 5;
break;
case 5:
metadata = 7;
break;
case 4:
metadata = 6;
break;
}
}
else if (blockID == Block.chest.blockID || blockID == Block.chestTrapped.blockID || blockID == Block.ladder.blockID || blockID == Block.hopperBlock.blockID)
{
switch (metadata)
{
case 2:
metadata = 5;
break;
case 3:
metadata = 4;
break;
case 4:
metadata = 2;
break;
case 5:
metadata = 3;
break;
}
}
else if (blockID==Block.vine.blockID)
{
switch (metadata)
{
case 1:
metadata = 2;
break;
case 2:
metadata = 4;
break;
case 4:
metadata = 8;
break;
case 8:
metadata = 1;
break;
}
}
else if(blockID== Block.lever.blockID||blockID== Block.stoneButton.blockID||blockID== Block.woodenButton.blockID||blockID== Block.torchWood.blockID||blockID== Block.torchRedstoneIdle.blockID||blockID== Block.torchRedstoneActive.blockID)
{
switch (metadata)
{
case 12:
metadata = 9;
break;
case 11:
metadata = 10;
break;
case 10:
metadata = 12;
break;
case 9:
metadata = 11;
break;
case 2:
metadata = 4;
break;
case 3:
metadata = 2;
break;
case 1:
metadata = 3;
break;
case 4:
metadata = 1;
break;
}
}
else if(blockID== Block.pistonBase.blockID||blockID==Block.pistonExtension.blockID||blockID==Block.pistonStickyBase.blockID||blockID==Block.dispenser.blockID||blockID==Block.dropper.blockID)
{
switch (metadata)
{
case 4:
metadata = 2;
break;
case 5:
metadata = 3;
break;
case 13:
metadata = 11;
break;
case 12:
metadata = 10;
break;
case 3:
metadata = 4;
break;
case 2:
metadata = 5;
break;
case 11:
metadata = 12;
break;
case 10:
metadata = 13;
break;
}
}
else if(Block.blocksList[blockID] instanceof BlockRedstoneRepeater || Block.blocksList[blockID] instanceof BlockDoor || Block.blocksList[blockID] instanceof dimDoor || blockID== Block.tripWireSource.blockID || Block.blocksList[blockID] instanceof BlockComparator)
{
switch (metadata)
{
case 0:
metadata = 1;
break;
case 1:
metadata = 2;
break;
case 2:
metadata = 3;
break;
case 3:
metadata = 0;
break;
case 4:
metadata = 5;
break;
case 5:
metadata = 6;
break;
case 6:
metadata = 7;
break;
case 7:
metadata = 4;
break;
case 8:
metadata = 9;
break;
case 9:
metadata = 10;
break;
case 10:
metadata = 11;
break;
case 11:
metadata = 8;
break;
case 12:
metadata = 13;
break;
case 13:
metadata = 14;
break;
case 14:
metadata = 15;
break;
case 15:
metadata = 12;
break;
}
}