Move to Forge block rotation implementation.
Hopefully the configurator should rotate more stuff now and more wrenches should be able to rotate our blocks
This commit is contained in:
parent
14b40d901a
commit
799f49d9b6
6 changed files with 188 additions and 20 deletions
|
@ -802,4 +802,37 @@ public class BlockBasic extends Block
|
|||
return super.shouldSideBeRendered(world, x, y, z, side);
|
||||
}
|
||||
}
|
||||
|
||||
public ForgeDirection[] getValidRotations(World world, int x, int y, int z)
|
||||
{
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
ForgeDirection[] valid = new ForgeDirection[6];
|
||||
if(tile instanceof TileEntityBasicBlock)
|
||||
{
|
||||
TileEntityBasicBlock basicTile = (TileEntityBasicBlock)tile;
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
if(basicTile.canSetFacing(dir.ordinal()))
|
||||
{
|
||||
valid[dir.ordinal()] = dir;
|
||||
}
|
||||
}
|
||||
}
|
||||
return valid;
|
||||
}
|
||||
|
||||
public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis)
|
||||
{
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if(tile instanceof TileEntityBasicBlock)
|
||||
{
|
||||
TileEntityBasicBlock basicTile = (TileEntityBasicBlock)tile;
|
||||
if(basicTile.canSetFacing(axis.ordinal()))
|
||||
{
|
||||
basicTile.setFacing((short)axis.ordinal());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -321,4 +321,37 @@ public class BlockEnergyCube extends BlockContainer
|
|||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public ForgeDirection[] getValidRotations(World world, int x, int y, int z)
|
||||
{
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
ForgeDirection[] valid = new ForgeDirection[6];
|
||||
if(tile instanceof TileEntityBasicBlock)
|
||||
{
|
||||
TileEntityBasicBlock basicTile = (TileEntityBasicBlock)tile;
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
if(basicTile.canSetFacing(dir.ordinal()))
|
||||
{
|
||||
valid[dir.ordinal()] = dir;
|
||||
}
|
||||
}
|
||||
}
|
||||
return valid;
|
||||
}
|
||||
|
||||
public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis)
|
||||
{
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if(tile instanceof TileEntityBasicBlock)
|
||||
{
|
||||
TileEntityBasicBlock basicTile = (TileEntityBasicBlock)tile;
|
||||
if(basicTile.canSetFacing(axis.ordinal()))
|
||||
{
|
||||
basicTile.setFacing((short)axis.ordinal());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,8 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
|
||||
import cpw.mods.fml.common.ModAPIManager;
|
||||
|
@ -235,4 +237,37 @@ public class BlockGasTank extends BlockContainer
|
|||
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
public ForgeDirection[] getValidRotations(World world, int x, int y, int z)
|
||||
{
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
ForgeDirection[] valid = new ForgeDirection[6];
|
||||
if(tile instanceof TileEntityBasicBlock)
|
||||
{
|
||||
TileEntityBasicBlock basicTile = (TileEntityBasicBlock)tile;
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
if(basicTile.canSetFacing(dir.ordinal()))
|
||||
{
|
||||
valid[dir.ordinal()] = dir;
|
||||
}
|
||||
}
|
||||
}
|
||||
return valid;
|
||||
}
|
||||
|
||||
public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis)
|
||||
{
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if(tile instanceof TileEntityBasicBlock)
|
||||
{
|
||||
TileEntityBasicBlock basicTile = (TileEntityBasicBlock)tile;
|
||||
if(basicTile.canSetFacing(axis.ordinal()))
|
||||
{
|
||||
basicTile.setFacing((short)axis.ordinal());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1279,4 +1279,37 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
public ForgeDirection[] getValidRotations(World world, int x, int y, int z)
|
||||
{
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
ForgeDirection[] valid = new ForgeDirection[6];
|
||||
if(tile instanceof TileEntityBasicBlock)
|
||||
{
|
||||
TileEntityBasicBlock basicTile = (TileEntityBasicBlock)tile;
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
if(basicTile.canSetFacing(dir.ordinal()))
|
||||
{
|
||||
valid[dir.ordinal()] = dir;
|
||||
}
|
||||
}
|
||||
}
|
||||
return valid;
|
||||
}
|
||||
|
||||
public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis)
|
||||
{
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if(tile instanceof TileEntityBasicBlock)
|
||||
{
|
||||
TileEntityBasicBlock basicTile = (TileEntityBasicBlock)tile;
|
||||
if(basicTile.canSetFacing(axis.ordinal()))
|
||||
{
|
||||
basicTile.setFacing((short)axis.ordinal());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package mekanism.common.item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
|
@ -13,6 +14,8 @@ import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
|||
import mekanism.common.tile.TileEntityBasicBlock;
|
||||
import mekanism.common.tile.TileEntityElectricChest;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
@ -65,6 +68,7 @@ public class ItemConfigurator extends ItemEnergized implements IToolWrench
|
|||
{
|
||||
if(!world.isRemote)
|
||||
{
|
||||
Block block = world.getBlock(x, y, z);
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
|
||||
if(tile instanceof IConfigurable)
|
||||
|
@ -172,27 +176,18 @@ public class ItemConfigurator extends ItemEnergized implements IToolWrench
|
|||
}
|
||||
else if(getState(stack) == 2)
|
||||
{
|
||||
if(tile instanceof TileEntityBasicBlock)
|
||||
ForgeDirection axis = ForgeDirection.getOrientation(side);
|
||||
List<ForgeDirection> l = Arrays.asList(block.getValidRotations(world, x, y, z));
|
||||
|
||||
if(!player.isSneaking() && l.contains(axis))
|
||||
{
|
||||
TileEntityBasicBlock basicBlock = (TileEntityBasicBlock)tile;
|
||||
int newSide = basicBlock.facing;
|
||||
|
||||
if(!player.isSneaking())
|
||||
{
|
||||
newSide = side;
|
||||
}
|
||||
else {
|
||||
newSide = ForgeDirection.OPPOSITES[side];
|
||||
}
|
||||
|
||||
if(basicBlock.canSetFacing(newSide))
|
||||
{
|
||||
basicBlock.setFacing((short)newSide);
|
||||
world.playSoundEffect(x, y, z, "random.click", 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
return true;
|
||||
block.rotateBlock(world, x, y, z, axis);
|
||||
}
|
||||
else if(player.isSneaking() && l.contains(axis.getOpposite())) {
|
||||
block.rotateBlock(world, x, y, z, axis.getOpposite());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else if(getState(stack) == 3)
|
||||
{
|
||||
|
|
|
@ -40,7 +40,12 @@ import net.minecraft.world.IBlockAccess;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.api.peripheral.IPeripheralProvider;
|
||||
|
||||
import cpw.mods.fml.common.ModAPIManager;
|
||||
import cpw.mods.fml.common.Optional.Interface;
|
||||
import cpw.mods.fml.common.Optional.Method;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
|
@ -55,7 +60,8 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
* @author AidanBrady
|
||||
*
|
||||
*/
|
||||
public class BlockGenerator extends BlockContainer implements ISpecialBounds
|
||||
@Interface(iface = "dan200.computercraft.api.peripheral.IPeripheralProvider", modid = "ComputerCraft")
|
||||
public class BlockGenerator extends BlockContainer implements ISpecialBounds, IPeripheralProvider
|
||||
{
|
||||
public Random machineRand = new Random();
|
||||
|
||||
|
@ -608,4 +614,37 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds
|
|||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public ForgeDirection[] getValidRotations(World world, int x, int y, int z)
|
||||
{
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
ForgeDirection[] valid = new ForgeDirection[6];
|
||||
if(tile instanceof TileEntityBasicBlock)
|
||||
{
|
||||
TileEntityBasicBlock basicTile = (TileEntityBasicBlock)tile;
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
if(basicTile.canSetFacing(dir.ordinal()))
|
||||
{
|
||||
valid[dir.ordinal()] = dir;
|
||||
}
|
||||
}
|
||||
}
|
||||
return valid;
|
||||
}
|
||||
|
||||
public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis)
|
||||
{
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if(tile instanceof TileEntityBasicBlock)
|
||||
{
|
||||
TileEntityBasicBlock basicTile = (TileEntityBasicBlock)tile;
|
||||
if(basicTile.canSetFacing(axis.ordinal()))
|
||||
{
|
||||
basicTile.setFacing((short)axis.ordinal());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue