Merge pull request #1164 from MartinTheDragon/curving-conveyor-cranes
Make conveyor crane I/O sides configurable
@ -1,11 +1,12 @@
|
||||
package com.hbm.blocks.network;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import api.hbm.block.IToolable;
|
||||
import com.hbm.blocks.IBlockSideRotation;
|
||||
import com.hbm.items.tool.ItemTooling;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.main.MainRegistry;
|
||||
|
||||
import com.hbm.tileentity.network.TileEntityCraneBase;
|
||||
import com.hbm.util.ChatBuilder;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
@ -21,11 +22,16 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public abstract class BlockCraneBase extends BlockContainer implements IBlockSideRotation {
|
||||
import java.util.Random;
|
||||
|
||||
public abstract class BlockCraneBase extends BlockContainer implements IBlockSideRotation, IToolable {
|
||||
|
||||
@SideOnly(Side.CLIENT) protected IIcon iconSide;
|
||||
@SideOnly(Side.CLIENT) protected IIcon iconIn;
|
||||
@ -37,10 +43,24 @@ public abstract class BlockCraneBase extends BlockContainer implements IBlockSid
|
||||
@SideOnly(Side.CLIENT) protected IIcon iconDirectionalUp;
|
||||
@SideOnly(Side.CLIENT) protected IIcon iconDirectionalDown;
|
||||
|
||||
@SideOnly(Side.CLIENT) protected IIcon iconDirectionalTurnLeft;
|
||||
@SideOnly(Side.CLIENT) protected IIcon iconDirectionalTurnRight;
|
||||
@SideOnly(Side.CLIENT) protected IIcon iconDirectionalSideLeftTurnUp;
|
||||
@SideOnly(Side.CLIENT) protected IIcon iconDirectionalSideRightTurnUp;
|
||||
@SideOnly(Side.CLIENT) protected IIcon iconDirectionalSideLeftTurnDown;
|
||||
@SideOnly(Side.CLIENT) protected IIcon iconDirectionalSideRightTurnDown;
|
||||
@SideOnly(Side.CLIENT) protected IIcon iconDirectionalSideUpTurnLeft;
|
||||
@SideOnly(Side.CLIENT) protected IIcon iconDirectionalSideUpTurnRight;
|
||||
@SideOnly(Side.CLIENT) protected IIcon iconDirectionalSideDownTurnLeft;
|
||||
@SideOnly(Side.CLIENT) protected IIcon iconDirectionalSideDownTurnRight;
|
||||
|
||||
public BlockCraneBase(Material mat) {
|
||||
super(mat);
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract TileEntityCraneBase createNewTileEntity(World p_149915_1_, int p_149915_2_);
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister iconRegister) {
|
||||
@ -54,7 +74,9 @@ public abstract class BlockCraneBase extends BlockContainer implements IBlockSid
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
|
||||
if(world.isRemote) {
|
||||
if(player.getHeldItem() != null && player.getHeldItem().getItem() instanceof ItemTooling) {
|
||||
return false;
|
||||
} else if(world.isRemote) {
|
||||
return true;
|
||||
} else if(!player.isSneaking()) {
|
||||
FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z);
|
||||
@ -70,6 +92,146 @@ public abstract class BlockCraneBase extends BlockContainer implements IBlockSid
|
||||
world.setBlockMetadataWithNotify(x, y, z, l, 2);
|
||||
}
|
||||
|
||||
protected boolean hasReversedIO() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onScrew(World world, EntityPlayer player, int x, int y, int z, int side, float fX, float fY, float fZ, ToolType tool) {
|
||||
if (tool != ToolType.SCREWDRIVER) return false;
|
||||
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if (!(te instanceof TileEntityCraneBase)) return false;
|
||||
|
||||
TileEntityCraneBase craneTileEntity = (TileEntityCraneBase) te;
|
||||
|
||||
// some cranes like the ejector have reversed input and output sides
|
||||
// so this bit of logic is to hide that away from the player
|
||||
boolean actuallyCycleInput = player.isSneaking() != hasReversedIO();
|
||||
ForgeDirection newDirection;
|
||||
|
||||
if (actuallyCycleInput) { // cycle input
|
||||
// it's in reverse because players are more likely to want to turn the output from DOWN to UP
|
||||
int newValue = Math.floorMod(world.getBlockMetadata(x, y, z) - 1, 6);
|
||||
newDirection = ForgeDirection.getOrientation(newValue);
|
||||
|
||||
world.setBlockMetadataWithNotify(x, y, z, newValue, 3);
|
||||
craneTileEntity.ensureOutputOverrideValid();
|
||||
} else { // cycle output
|
||||
newDirection = craneTileEntity.cycleOutputOverride();
|
||||
}
|
||||
|
||||
if (!world.isRemote) {
|
||||
ChatBuilder message = player.isSneaking()
|
||||
? ChatBuilder.start("Input: ").color(EnumChatFormatting.GREEN)
|
||||
: ChatBuilder.start("Output: ").color(EnumChatFormatting.RED);
|
||||
message.next(newDirection.name()).color(EnumChatFormatting.WHITE);
|
||||
player.addChatComponentMessage(message.flush());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public ForgeDirection getInputSide(IBlockAccess world, int x, int y, int z) {
|
||||
return ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the player-overridden output direction, or {@link ForgeDirection#UNKNOWN} if unset.
|
||||
* A return value of {@link ForgeDirection#UNKNOWN} suggests use of default meta behavior.
|
||||
* <i>Should</i> never return the current input direction.
|
||||
*/
|
||||
protected final ForgeDirection getOutputSideOverride(IBlockAccess world, int x, int y, int z) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if (!(te instanceof TileEntityCraneBase)) return ForgeDirection.UNKNOWN;
|
||||
TileEntityCraneBase craneTileEntity = (TileEntityCraneBase) te;
|
||||
|
||||
return craneTileEntity.getOutputOverride();
|
||||
}
|
||||
|
||||
public ForgeDirection getOutputSide(IBlockAccess world, int x, int y, int z) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if (!(te instanceof TileEntityCraneBase)) return ForgeDirection.UNKNOWN;
|
||||
TileEntityCraneBase craneTileEntity = (TileEntityCraneBase) te;
|
||||
|
||||
return craneTileEntity.getOutputSide();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
||||
ForgeDirection inputSide = getInputSide(world, x, y, z);
|
||||
ForgeDirection outputOverride = getOutputSideOverride(world, x, y, z);
|
||||
boolean outputSideOverridden = outputOverride != ForgeDirection.UNKNOWN && outputOverride.getOpposite() != inputSide;
|
||||
ForgeDirection outputSide = outputSideOverridden ? outputOverride : inputSide.getOpposite();
|
||||
|
||||
// take your left hand, make your thumb the input side and the index finger the output side
|
||||
// angle your middle finger to make your hand look like coordinate axes
|
||||
// the direction your middle finger is pointing towards will be the direction returned from this function
|
||||
ForgeDirection leftHandRotation = outputSide.getRotation(inputSide);
|
||||
|
||||
if(side == 0 || side == 1) {
|
||||
if(side == outputSide.ordinal()) {
|
||||
return this.iconOut;
|
||||
}
|
||||
if(side == inputSide.ordinal()) {
|
||||
return this.iconIn;
|
||||
}
|
||||
|
||||
if (side == 1) {
|
||||
if (outputSideOverridden) {
|
||||
if (leftHandRotation == ForgeDirection.UP) {
|
||||
return this.iconDirectionalTurnLeft;
|
||||
}
|
||||
if (leftHandRotation == ForgeDirection.DOWN) {
|
||||
return this.iconDirectionalTurnRight;
|
||||
}
|
||||
} else return iconDirectional;
|
||||
}
|
||||
|
||||
return this.blockIcon;
|
||||
}
|
||||
|
||||
if(side == outputSide.ordinal()) {
|
||||
return this.iconSideOut;
|
||||
}
|
||||
if(side == inputSide.ordinal()) {
|
||||
return this.iconSideIn;
|
||||
}
|
||||
|
||||
if (outputSideOverridden) {
|
||||
if (leftHandRotation.ordinal() == side) {
|
||||
if (outputSide == ForgeDirection.UP)
|
||||
return this.iconDirectionalSideLeftTurnUp;
|
||||
if (outputSide == ForgeDirection.DOWN)
|
||||
return this.iconDirectionalSideRightTurnDown;
|
||||
if (inputSide == ForgeDirection.UP)
|
||||
return this.iconDirectionalSideUpTurnRight;
|
||||
if (inputSide == ForgeDirection.DOWN)
|
||||
return this.iconDirectionalSideDownTurnLeft;
|
||||
}
|
||||
if (leftHandRotation.getOpposite().ordinal() == side) {
|
||||
if (outputSide == ForgeDirection.UP)
|
||||
return this.iconDirectionalSideRightTurnUp;
|
||||
if (outputSide == ForgeDirection.DOWN)
|
||||
return this.iconDirectionalSideLeftTurnDown;
|
||||
if (inputSide == ForgeDirection.UP)
|
||||
return this.iconDirectionalSideUpTurnLeft;
|
||||
if (inputSide == ForgeDirection.DOWN)
|
||||
return this.iconDirectionalSideDownTurnRight;
|
||||
}
|
||||
} else {
|
||||
if(outputSide == ForgeDirection.UP) {
|
||||
return this.iconDirectionalUp;
|
||||
}
|
||||
if(outputSide == ForgeDirection.DOWN) {
|
||||
return this.iconDirectionalDown;
|
||||
}
|
||||
}
|
||||
|
||||
return this.iconSide;
|
||||
}
|
||||
|
||||
// kept for inventory rendering
|
||||
@Override
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
|
||||
@ -101,6 +263,20 @@ public abstract class BlockCraneBase extends BlockContainer implements IBlockSid
|
||||
return this.iconSide;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRotationFromSide(IBlockAccess world, int x, int y, int z, int side) {
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
|
||||
if(meta > 1 && side == 1) {
|
||||
if(meta == 2) return 3;
|
||||
if(meta == 3) return 0;
|
||||
if(meta == 4) return 1;
|
||||
if(meta == 5) return 2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int renderIDClassic = RenderingRegistry.getNextAvailableRenderId();
|
||||
|
||||
@Override
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
package com.hbm.blocks.network;
|
||||
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.tileentity.network.TileEntityCraneBoxer;
|
||||
|
||||
import api.hbm.conveyor.IConveyorItem;
|
||||
import api.hbm.conveyor.IConveyorPackage;
|
||||
import api.hbm.conveyor.IEnterableBlock;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.tileentity.network.TileEntityCraneBase;
|
||||
import com.hbm.tileentity.network.TileEntityCraneBoxer;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
@ -14,8 +14,6 @@ import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
@ -26,7 +24,7 @@ public class CraneBoxer extends BlockCraneBase implements IEnterableBlock {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
public TileEntityCraneBase createNewTileEntity(World world, int meta) {
|
||||
return new TileEntityCraneBoxer();
|
||||
}
|
||||
|
||||
@ -34,31 +32,26 @@ public class CraneBoxer extends BlockCraneBase implements IEnterableBlock {
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister iconRegister) {
|
||||
super.registerBlockIcons(iconRegister);
|
||||
this.iconIn = iconRegister.registerIcon(RefStrings.MODID + ":crane_box");
|
||||
this.iconSideIn = iconRegister.registerIcon(RefStrings.MODID + ":crane_side_box");
|
||||
this.iconOut = iconRegister.registerIcon(RefStrings.MODID + ":crane_box");
|
||||
this.iconSideOut = iconRegister.registerIcon(RefStrings.MODID + ":crane_side_box");
|
||||
this.iconDirectional = iconRegister.registerIcon(RefStrings.MODID + ":crane_boxer_top");
|
||||
this.iconDirectionalUp = iconRegister.registerIcon(RefStrings.MODID + ":crane_boxer_side_up");
|
||||
this.iconDirectionalDown = iconRegister.registerIcon(RefStrings.MODID + ":crane_boxer_side_down");
|
||||
this.iconDirectionalTurnLeft = iconRegister.registerIcon(RefStrings.MODID + ":crane_boxer_top_left");
|
||||
this.iconDirectionalTurnRight = iconRegister.registerIcon(RefStrings.MODID + ":crane_boxer_top_right");
|
||||
this.iconDirectionalSideLeftTurnUp = iconRegister.registerIcon(RefStrings.MODID + ":crane_boxer_side_left_turn_up");
|
||||
this.iconDirectionalSideRightTurnUp = iconRegister.registerIcon(RefStrings.MODID + ":crane_boxer_side_right_turn_up");
|
||||
this.iconDirectionalSideLeftTurnDown = iconRegister.registerIcon(RefStrings.MODID + ":crane_boxer_side_left_turn_down");
|
||||
this.iconDirectionalSideRightTurnDown = iconRegister.registerIcon(RefStrings.MODID + ":crane_boxer_side_right_turn_down");
|
||||
this.iconDirectionalSideUpTurnLeft = iconRegister.registerIcon(RefStrings.MODID + ":crane_boxer_side_up_turn_left");
|
||||
this.iconDirectionalSideUpTurnRight = iconRegister.registerIcon(RefStrings.MODID + ":crane_boxer_side_up_turn_right");
|
||||
this.iconDirectionalSideDownTurnLeft = iconRegister.registerIcon(RefStrings.MODID + ":crane_boxer_side_down_turn_left");
|
||||
this.iconDirectionalSideDownTurnRight = iconRegister.registerIcon(RefStrings.MODID + ":crane_boxer_side_down_turn_right");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRotationFromSide(IBlockAccess world, int x, int y, int z, int side) {
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
|
||||
if(meta > 1 && side == 1) {
|
||||
if(meta == 2) return 3;
|
||||
if(meta == 3) return 0;
|
||||
if(meta == 4) return 1;
|
||||
if(meta == 5) return 2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public boolean canItemEnter(World world, int x, int y, int z, ForgeDirection dir, IConveyorItem entity) {
|
||||
ForgeDirection orientation = ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z));
|
||||
return orientation == dir;
|
||||
return getInputSide(world, x, y, z) == dir;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -1,16 +1,16 @@
|
||||
package com.hbm.blocks.network;
|
||||
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.tileentity.network.TileEntityCraneBase;
|
||||
import com.hbm.tileentity.network.TileEntityCraneExtractor;
|
||||
|
||||
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.IIconRegister;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class CraneExtractor extends BlockCraneBase {
|
||||
|
||||
@ -19,7 +19,7 @@ public class CraneExtractor extends BlockCraneBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
public TileEntityCraneBase createNewTileEntity(World world, int meta) {
|
||||
return new TileEntityCraneExtractor();
|
||||
}
|
||||
|
||||
@ -30,6 +30,21 @@ public class CraneExtractor extends BlockCraneBase {
|
||||
this.iconDirectional = iconRegister.registerIcon(RefStrings.MODID + ":crane_out_top");
|
||||
this.iconDirectionalUp = iconRegister.registerIcon(RefStrings.MODID + ":crane_out_side_down");
|
||||
this.iconDirectionalDown = iconRegister.registerIcon(RefStrings.MODID + ":crane_out_side_up");
|
||||
this.iconDirectionalTurnLeft = iconRegister.registerIcon(RefStrings.MODID + ":crane_out_top_right");
|
||||
this.iconDirectionalTurnRight = iconRegister.registerIcon(RefStrings.MODID + ":crane_out_top_left");
|
||||
this.iconDirectionalSideLeftTurnUp = iconRegister.registerIcon(RefStrings.MODID + ":crane_out_side_up_turn_left");
|
||||
this.iconDirectionalSideRightTurnUp = iconRegister.registerIcon(RefStrings.MODID + ":crane_out_side_up_turn_right");
|
||||
this.iconDirectionalSideLeftTurnDown = iconRegister.registerIcon(RefStrings.MODID + ":crane_out_side_down_turn_left");
|
||||
this.iconDirectionalSideRightTurnDown = iconRegister.registerIcon(RefStrings.MODID + ":crane_out_side_down_turn_right");
|
||||
this.iconDirectionalSideUpTurnLeft = iconRegister.registerIcon(RefStrings.MODID + ":crane_out_side_left_turn_up");
|
||||
this.iconDirectionalSideUpTurnRight = iconRegister.registerIcon(RefStrings.MODID + ":crane_out_side_right_turn_up");
|
||||
this.iconDirectionalSideDownTurnLeft = iconRegister.registerIcon(RefStrings.MODID + ":crane_out_side_left_turn_down");
|
||||
this.iconDirectionalSideDownTurnRight = iconRegister.registerIcon(RefStrings.MODID + ":crane_out_side_right_turn_down");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean hasReversedIO() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -37,6 +52,25 @@ public class CraneExtractor extends BlockCraneBase {
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
|
||||
if(meta > 1 && side == 1) {
|
||||
// ok so i've been sitting around for 4-5 hours trying to come up with a
|
||||
// more elegant way to implement this and i have seriously no clue what
|
||||
// the guys at mojang did, but the uv rotation makes absolutely no sense
|
||||
// it's 2:30 am, please just accept this
|
||||
// - martin
|
||||
ForgeDirection leftHandDirection = getOutputSide(world, x, y, z).getRotation(getInputSide(world, x, y, z));
|
||||
if (leftHandDirection == ForgeDirection.UP) {
|
||||
if (meta == 2) return 2;
|
||||
if (meta == 3) return 1;
|
||||
if (meta == 4) return 3;
|
||||
if (meta == 5) return 0;
|
||||
}
|
||||
if (leftHandDirection == ForgeDirection.DOWN) {
|
||||
if (meta == 2) return 1;
|
||||
if (meta == 3) return 2;
|
||||
if (meta == 4) return 0;
|
||||
if (meta == 5) return 3;
|
||||
}
|
||||
|
||||
if(meta == 2) return 0;
|
||||
if(meta == 3) return 3;
|
||||
if(meta == 4) return 2;
|
||||
|
||||
@ -1,15 +1,13 @@
|
||||
package com.hbm.blocks.network;
|
||||
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.tileentity.network.TileEntityCraneBase;
|
||||
import com.hbm.tileentity.network.TileEntityCraneGrabber;
|
||||
|
||||
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.IIconRegister;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class CraneGrabber extends BlockCraneBase {
|
||||
@ -19,7 +17,7 @@ public class CraneGrabber extends BlockCraneBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
public TileEntityCraneBase createNewTileEntity(World world, int meta) {
|
||||
return new TileEntityCraneGrabber();
|
||||
}
|
||||
|
||||
@ -27,28 +25,24 @@ public class CraneGrabber extends BlockCraneBase {
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister iconRegister) {
|
||||
super.registerBlockIcons(iconRegister);
|
||||
this.iconIn = iconRegister.registerIcon(RefStrings.MODID + ":crane_pull");
|
||||
this.iconSideIn = iconRegister.registerIcon(RefStrings.MODID + ":crane_side_pull");
|
||||
this.iconDirectional = iconRegister.registerIcon(RefStrings.MODID + ":crane_grabber_top");
|
||||
this.iconDirectionalUp = iconRegister.registerIcon(RefStrings.MODID + ":crane_grabber_side_up");
|
||||
this.iconDirectionalDown = iconRegister.registerIcon(RefStrings.MODID + ":crane_grabber_side_down");
|
||||
this.iconOut = iconRegister.registerIcon(RefStrings.MODID + ":crane_pull");
|
||||
this.iconSideOut = iconRegister.registerIcon(RefStrings.MODID + ":crane_side_pull");
|
||||
this.iconDirectionalTurnLeft = iconRegister.registerIcon(RefStrings.MODID + ":crane_grabber_top_left");
|
||||
this.iconDirectionalTurnRight = iconRegister.registerIcon(RefStrings.MODID + ":crane_grabber_top_right");
|
||||
this.iconDirectionalSideLeftTurnUp = iconRegister.registerIcon(RefStrings.MODID + ":crane_grabber_side_left_turn_up");
|
||||
this.iconDirectionalSideRightTurnUp = iconRegister.registerIcon(RefStrings.MODID + ":crane_grabber_side_right_turn_up");
|
||||
this.iconDirectionalSideLeftTurnDown = iconRegister.registerIcon(RefStrings.MODID + ":crane_grabber_side_left_turn_down");
|
||||
this.iconDirectionalSideRightTurnDown = iconRegister.registerIcon(RefStrings.MODID + ":crane_grabber_side_right_turn_down");
|
||||
this.iconDirectionalSideUpTurnLeft = iconRegister.registerIcon(RefStrings.MODID + ":crane_grabber_side_up_turn_left");
|
||||
this.iconDirectionalSideUpTurnRight = iconRegister.registerIcon(RefStrings.MODID + ":crane_grabber_side_up_turn_right");
|
||||
this.iconDirectionalSideDownTurnLeft = iconRegister.registerIcon(RefStrings.MODID + ":crane_grabber_side_down_turn_left");
|
||||
this.iconDirectionalSideDownTurnRight = iconRegister.registerIcon(RefStrings.MODID + ":crane_grabber_side_down_turn_right");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRotationFromSide(IBlockAccess world, int x, int y, int z, int side) {
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
|
||||
if(meta > 1 && side == 1) {
|
||||
if(meta == 2) return 3;
|
||||
if(meta == 3) return 0;
|
||||
if(meta == 4) return 1;
|
||||
if(meta == 5) return 2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
|
||||
this.dropContents(world, x, y, z, block, meta, 9, 11);
|
||||
super.breakBlock(world, x, y, z, block, meta);
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
package com.hbm.blocks.network;
|
||||
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.tileentity.network.TileEntityCraneInserter;
|
||||
|
||||
import api.hbm.conveyor.IConveyorItem;
|
||||
import api.hbm.conveyor.IConveyorPackage;
|
||||
import api.hbm.conveyor.IEnterableBlock;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.tileentity.network.TileEntityCraneBase;
|
||||
import com.hbm.tileentity.network.TileEntityCraneInserter;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
@ -18,7 +18,6 @@ import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
@ -29,7 +28,7 @@ public class CraneInserter extends BlockCraneBase implements IEnterableBlock {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
public TileEntityCraneBase createNewTileEntity(World world, int meta) {
|
||||
return new TileEntityCraneInserter();
|
||||
}
|
||||
|
||||
@ -40,6 +39,16 @@ public class CraneInserter extends BlockCraneBase implements IEnterableBlock {
|
||||
this.iconDirectional = iconRegister.registerIcon(RefStrings.MODID + ":crane_in_top");
|
||||
this.iconDirectionalUp = iconRegister.registerIcon(RefStrings.MODID + ":crane_in_side_up");
|
||||
this.iconDirectionalDown = iconRegister.registerIcon(RefStrings.MODID + ":crane_in_side_down");
|
||||
this.iconDirectionalTurnLeft = iconRegister.registerIcon(RefStrings.MODID + ":crane_in_top_left");
|
||||
this.iconDirectionalTurnRight = iconRegister.registerIcon(RefStrings.MODID + ":crane_in_top_right");
|
||||
this.iconDirectionalSideLeftTurnUp = iconRegister.registerIcon(RefStrings.MODID + ":crane_in_side_left_turn_up");
|
||||
this.iconDirectionalSideRightTurnUp = iconRegister.registerIcon(RefStrings.MODID + ":crane_in_side_right_turn_up");
|
||||
this.iconDirectionalSideLeftTurnDown = iconRegister.registerIcon(RefStrings.MODID + ":crane_in_side_left_turn_down");
|
||||
this.iconDirectionalSideRightTurnDown = iconRegister.registerIcon(RefStrings.MODID + ":crane_in_side_right_turn_down");
|
||||
this.iconDirectionalSideUpTurnLeft = iconRegister.registerIcon(RefStrings.MODID + ":crane_in_side_up_turn_left");
|
||||
this.iconDirectionalSideUpTurnRight = iconRegister.registerIcon(RefStrings.MODID + ":crane_in_side_up_turn_right");
|
||||
this.iconDirectionalSideDownTurnLeft = iconRegister.registerIcon(RefStrings.MODID + ":crane_in_side_down_turn_left");
|
||||
this.iconDirectionalSideDownTurnRight = iconRegister.registerIcon(RefStrings.MODID + ":crane_in_side_down_turn_right");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -50,7 +59,8 @@ public class CraneInserter extends BlockCraneBase implements IEnterableBlock {
|
||||
|
||||
@Override
|
||||
public void onItemEnter(World world, int x, int y, int z, ForgeDirection dir, IConveyorItem entity) {
|
||||
TileEntity te = world.getTileEntity(x - dir.offsetX, y - dir.offsetY, z - dir.offsetZ);
|
||||
ForgeDirection outputDirection = getOutputSide(world, x, y, z);
|
||||
TileEntity te = world.getTileEntity(x + outputDirection.offsetX, y + outputDirection.offsetY, z + outputDirection.offsetZ);
|
||||
|
||||
if(entity == null || entity.getItemStack() == null || entity.getItemStack().stackSize <= 0) {
|
||||
return;
|
||||
@ -62,19 +72,19 @@ public class CraneInserter extends BlockCraneBase implements IEnterableBlock {
|
||||
|
||||
if(te instanceof ISidedInventory) {
|
||||
ISidedInventory sided = (ISidedInventory) te;
|
||||
access = masquerade(sided, dir.ordinal());
|
||||
access = masquerade(sided, outputDirection.getOpposite().ordinal());
|
||||
}
|
||||
|
||||
if(te instanceof IInventory) {
|
||||
IInventory inv = (IInventory) te;
|
||||
|
||||
addToInventory(inv, access, toAdd, dir.ordinal());
|
||||
addToInventory(inv, access, toAdd, outputDirection.getOpposite().ordinal());
|
||||
}
|
||||
|
||||
if(toAdd != null && toAdd.stackSize > 0) {
|
||||
addToInventory((TileEntityCraneInserter) world.getTileEntity(x, y, z), null, toAdd, dir.ordinal());
|
||||
if(toAdd.stackSize > 0) {
|
||||
addToInventory((TileEntityCraneInserter) world.getTileEntity(x, y, z), null, toAdd, outputDirection.getOpposite().ordinal());
|
||||
}
|
||||
if(toAdd != null && toAdd.stackSize > 0) {
|
||||
if(toAdd.stackSize > 0) {
|
||||
EntityItem drop = new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, toAdd.copy());
|
||||
world.spawnEntityInWorld(drop);
|
||||
}
|
||||
@ -147,21 +157,7 @@ public class CraneInserter extends BlockCraneBase implements IEnterableBlock {
|
||||
@Override
|
||||
public void onPackageEnter(World world, int x, int y, int z, ForgeDirection dir, IConveyorPackage entity) { }
|
||||
|
||||
@Override
|
||||
public int getRotationFromSide(IBlockAccess world, int x, int y, int z, int side) {
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
|
||||
if(meta > 1 && side == 1) {
|
||||
if(meta == 2) return 3;
|
||||
if(meta == 3) return 0;
|
||||
if(meta == 4) return 1;
|
||||
if(meta == 5) return 2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public boolean hasComparatorInputOverride() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
package com.hbm.blocks.network;
|
||||
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.tileentity.network.TileEntityCraneUnboxer;
|
||||
|
||||
import api.hbm.conveyor.IConveyorItem;
|
||||
import api.hbm.conveyor.IConveyorPackage;
|
||||
import api.hbm.conveyor.IEnterableBlock;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.tileentity.network.TileEntityCraneBase;
|
||||
import com.hbm.tileentity.network.TileEntityCraneUnboxer;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
@ -14,7 +14,6 @@ import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
@ -26,7 +25,7 @@ public class CraneUnboxer extends BlockCraneBase implements IEnterableBlock {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
public TileEntityCraneBase createNewTileEntity(World world, int meta) {
|
||||
return new TileEntityCraneUnboxer();
|
||||
}
|
||||
|
||||
@ -34,11 +33,26 @@ public class CraneUnboxer extends BlockCraneBase implements IEnterableBlock {
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister iconRegister) {
|
||||
super.registerBlockIcons(iconRegister);
|
||||
this.iconIn = iconRegister.registerIcon(RefStrings.MODID + ":crane_box");
|
||||
this.iconSideIn = iconRegister.registerIcon(RefStrings.MODID + ":crane_side_box");
|
||||
this.iconOut = iconRegister.registerIcon(RefStrings.MODID + ":crane_box");
|
||||
this.iconSideOut = iconRegister.registerIcon(RefStrings.MODID + ":crane_side_box");
|
||||
this.iconDirectional = iconRegister.registerIcon(RefStrings.MODID + ":crane_unboxer_top");
|
||||
this.iconDirectionalUp = iconRegister.registerIcon(RefStrings.MODID + ":crane_unboxer_side_down");
|
||||
this.iconDirectionalDown = iconRegister.registerIcon(RefStrings.MODID + ":crane_unboxer_side_up");
|
||||
this.iconDirectionalTurnLeft = iconRegister.registerIcon(RefStrings.MODID + ":crane_unboxer_top_right");
|
||||
this.iconDirectionalTurnRight = iconRegister.registerIcon(RefStrings.MODID + ":crane_unboxer_top_left");
|
||||
this.iconDirectionalSideLeftTurnUp = iconRegister.registerIcon(RefStrings.MODID + ":crane_unboxer_side_up_turn_left");
|
||||
this.iconDirectionalSideRightTurnUp = iconRegister.registerIcon(RefStrings.MODID + ":crane_unboxer_side_up_turn_right");
|
||||
this.iconDirectionalSideLeftTurnDown = iconRegister.registerIcon(RefStrings.MODID + ":crane_unboxer_side_down_turn_left");
|
||||
this.iconDirectionalSideRightTurnDown = iconRegister.registerIcon(RefStrings.MODID + ":crane_unboxer_side_down_turn_right");
|
||||
this.iconDirectionalSideUpTurnLeft = iconRegister.registerIcon(RefStrings.MODID + ":crane_unboxer_side_left_turn_up");
|
||||
this.iconDirectionalSideUpTurnRight = iconRegister.registerIcon(RefStrings.MODID + ":crane_unboxer_side_right_turn_up");
|
||||
this.iconDirectionalSideDownTurnLeft = iconRegister.registerIcon(RefStrings.MODID + ":crane_unboxer_side_left_turn_down");
|
||||
this.iconDirectionalSideDownTurnRight = iconRegister.registerIcon(RefStrings.MODID + ":crane_unboxer_side_right_turn_down");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean hasReversedIO() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -46,6 +60,25 @@ public class CraneUnboxer extends BlockCraneBase implements IEnterableBlock {
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
|
||||
if(meta > 1 && side == 1) {
|
||||
// ok so i've been sitting around for 4-5 hours trying to come up with a
|
||||
// more elegant way to implement this and i have seriously no clue what
|
||||
// the guys at mojang did, but the uv rotation makes absolutely no sense
|
||||
// it's 2:30 am, please just accept this
|
||||
// - martin
|
||||
ForgeDirection leftHandDirection = getOutputSide(world, x, y, z).getRotation(getInputSide(world, x, y, z));
|
||||
if (leftHandDirection == ForgeDirection.UP) {
|
||||
if (meta == 2) return 2;
|
||||
if (meta == 3) return 1;
|
||||
if (meta == 4) return 3;
|
||||
if (meta == 5) return 0;
|
||||
}
|
||||
if (leftHandDirection == ForgeDirection.DOWN) {
|
||||
if (meta == 2) return 1;
|
||||
if (meta == 3) return 2;
|
||||
if (meta == 4) return 0;
|
||||
if (meta == 5) return 3;
|
||||
}
|
||||
|
||||
if(meta == 2) return 0;
|
||||
if(meta == 3) return 3;
|
||||
if(meta == 4) return 2;
|
||||
@ -71,15 +104,16 @@ public class CraneUnboxer extends BlockCraneBase implements IEnterableBlock {
|
||||
|
||||
@Override
|
||||
public boolean canPackageEnter(World world, int x, int y, int z, ForgeDirection dir, IConveyorPackage entity) {
|
||||
return true;
|
||||
return getOutputSide(world, x, y, z) == dir;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPackageEnter(World world, int x, int y, int z, ForgeDirection dir, IConveyorPackage entity) {
|
||||
TileEntityCraneUnboxer unboxer = (TileEntityCraneUnboxer) world.getTileEntity(x, y, z);
|
||||
ForgeDirection accessedSide = getOutputSide(world, x, y, z).getOpposite();
|
||||
|
||||
for(ItemStack stack : entity.getItemStacks()) {
|
||||
ItemStack remainder = CraneInserter.addToInventory(unboxer, unboxer.getAccessibleSlotsFromSide(dir.ordinal()), stack, dir.ordinal());
|
||||
ItemStack remainder = CraneInserter.addToInventory(unboxer, unboxer.getAccessibleSlotsFromSide(accessedSide.ordinal()), stack, accessedSide.ordinal());
|
||||
|
||||
if(remainder != null && remainder.stackSize > 0) {
|
||||
EntityItem drop = new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, remainder.copy());
|
||||
|
||||
@ -0,0 +1,94 @@
|
||||
package com.hbm.tileentity.network;
|
||||
|
||||
import com.hbm.tileentity.TileEntityMachineBase;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public abstract class TileEntityCraneBase extends TileEntityMachineBase {
|
||||
public TileEntityCraneBase(int scount) {
|
||||
super(scount);
|
||||
}
|
||||
|
||||
// extension to the meta system
|
||||
// for compatibility purposes, normal meta values are still used by default
|
||||
private ForgeDirection outputOverride = ForgeDirection.UNKNOWN;
|
||||
|
||||
// for extra stability in case the screwdriver action doesn't get synced to other clients
|
||||
@SideOnly(Side.CLIENT)
|
||||
private ForgeDirection cachedOutputOverride = ForgeDirection.UNKNOWN;
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
if (hasWorldObj() && worldObj.isRemote) {
|
||||
if (cachedOutputOverride != outputOverride) {
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
cachedOutputOverride = outputOverride;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ForgeDirection getInputSide() {
|
||||
return ForgeDirection.getOrientation(getBlockMetadata());
|
||||
}
|
||||
|
||||
public ForgeDirection getOutputSide() {
|
||||
ForgeDirection override = getOutputOverride();
|
||||
return override != ForgeDirection.UNKNOWN ? override : ForgeDirection.getOrientation(getBlockMetadata()).getOpposite();
|
||||
}
|
||||
|
||||
public ForgeDirection getOutputOverride() {
|
||||
return outputOverride;
|
||||
}
|
||||
|
||||
public ForgeDirection cycleOutputOverride() {
|
||||
do {
|
||||
outputOverride = ForgeDirection.getOrientation(Math.floorMod(outputOverride.ordinal() - 1, 7));
|
||||
} while (outputOverride.ordinal() == getBlockMetadata());
|
||||
|
||||
onBlockChanged();
|
||||
return outputOverride;
|
||||
}
|
||||
|
||||
public void ensureOutputOverrideValid() {
|
||||
if (outputOverride.ordinal() == getBlockMetadata())
|
||||
cycleOutputOverride();
|
||||
}
|
||||
|
||||
protected void onBlockChanged() {
|
||||
if (!hasWorldObj()) return;
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
worldObj.notifyBlockChange(xCoord, yCoord, zCoord, getBlockType());
|
||||
markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket() {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
writeToNBT(nbt);
|
||||
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 0, nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
|
||||
readFromNBT(pkt.func_148857_g());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
if (nbt.hasKey("CraneOutputOverride", Constants.NBT.TAG_BYTE))
|
||||
outputOverride = ForgeDirection.getOrientation(nbt.getByte("CraneOutputOverride"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
nbt.setByte("CraneOutputOverride", (byte) outputOverride.ordinal());
|
||||
}
|
||||
}
|
||||
@ -1,13 +1,11 @@
|
||||
package com.hbm.tileentity.network;
|
||||
|
||||
import api.hbm.conveyor.IConveyorBelt;
|
||||
import com.hbm.entity.item.EntityMovingPackage;
|
||||
import com.hbm.interfaces.IControlReceiver;
|
||||
import com.hbm.inventory.container.ContainerCraneBoxer;
|
||||
import com.hbm.inventory.gui.GUICraneBoxer;
|
||||
import com.hbm.tileentity.IGUIProvider;
|
||||
import com.hbm.tileentity.TileEntityMachineBase;
|
||||
|
||||
import api.hbm.conveyor.IConveyorBelt;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
@ -20,7 +18,7 @@ import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileEntityCraneBoxer extends TileEntityMachineBase implements IGUIProvider, IControlReceiver {
|
||||
public class TileEntityCraneBoxer extends TileEntityCraneBase implements IGUIProvider, IControlReceiver {
|
||||
|
||||
public byte mode = 0;
|
||||
public static final byte MODE_4 = 0;
|
||||
@ -42,15 +40,15 @@ public class TileEntityCraneBoxer extends TileEntityMachineBase implements IGUIP
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
super.updateEntity();
|
||||
if(!worldObj.isRemote) {
|
||||
|
||||
boolean redstone = worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord);
|
||||
|
||||
if(mode == MODE_REDSTONE && redstone && !lastRedstone) {
|
||||
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata()).getOpposite();
|
||||
Block b = worldObj.getBlock(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ);
|
||||
ForgeDirection outputSide = getOutputSide();
|
||||
Block b = worldObj.getBlock(xCoord + outputSide.offsetX, yCoord + outputSide.offsetY, zCoord + outputSide.offsetZ);
|
||||
IConveyorBelt belt = null;
|
||||
|
||||
if(b instanceof IConveyorBelt) {
|
||||
@ -79,8 +77,8 @@ public class TileEntityCraneBoxer extends TileEntityMachineBase implements IGUIP
|
||||
}
|
||||
|
||||
EntityMovingPackage moving = new EntityMovingPackage(worldObj);
|
||||
Vec3 pos = Vec3.createVectorHelper(xCoord + 0.5 + dir.offsetX * 0.55, yCoord + 0.5 + dir.offsetY * 0.55, zCoord + 0.5 + dir.offsetZ * 0.55);
|
||||
Vec3 snap = belt.getClosestSnappingPosition(worldObj, xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, pos);
|
||||
Vec3 pos = Vec3.createVectorHelper(xCoord + 0.5 + outputSide.offsetX * 0.55, yCoord + 0.5 + outputSide.offsetY * 0.55, zCoord + 0.5 + outputSide.offsetZ * 0.55);
|
||||
Vec3 snap = belt.getClosestSnappingPosition(worldObj, xCoord + outputSide.offsetX, yCoord + outputSide.offsetY, zCoord + outputSide.offsetZ, pos);
|
||||
moving.setPosition(snap.xCoord, snap.yCoord, snap.zCoord);
|
||||
moving.setItemStacks(box);
|
||||
worldObj.spawnEntityInWorld(moving);
|
||||
@ -116,8 +114,8 @@ public class TileEntityCraneBoxer extends TileEntityMachineBase implements IGUIP
|
||||
}
|
||||
}
|
||||
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata()).getOpposite();
|
||||
Block b = worldObj.getBlock(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ);
|
||||
ForgeDirection outputSide = getOutputSide();
|
||||
Block b = worldObj.getBlock(xCoord + outputSide.offsetX, yCoord + outputSide.offsetY, zCoord + outputSide.offsetZ);
|
||||
IConveyorBelt belt = null;
|
||||
|
||||
if(b instanceof IConveyorBelt) {
|
||||
@ -138,8 +136,8 @@ public class TileEntityCraneBoxer extends TileEntityMachineBase implements IGUIP
|
||||
}
|
||||
|
||||
EntityMovingPackage moving = new EntityMovingPackage(worldObj);
|
||||
Vec3 pos = Vec3.createVectorHelper(xCoord + 0.5 + dir.offsetX * 0.55, yCoord + 0.5 + dir.offsetY * 0.55, zCoord + 0.5 + dir.offsetZ * 0.55);
|
||||
Vec3 snap = belt.getClosestSnappingPosition(worldObj, xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, pos);
|
||||
Vec3 pos = Vec3.createVectorHelper(xCoord + 0.5 + outputSide.offsetX * 0.55, yCoord + 0.5 + outputSide.offsetY * 0.55, zCoord + 0.5 + outputSide.offsetZ * 0.55);
|
||||
Vec3 snap = belt.getClosestSnappingPosition(worldObj, xCoord + outputSide.offsetX, yCoord + outputSide.offsetY, zCoord + outputSide.offsetZ, pos);
|
||||
moving.setPosition(snap.xCoord, snap.yCoord, snap.zCoord);
|
||||
moving.setItemStacks(box);
|
||||
worldObj.spawnEntityInWorld(moving);
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.hbm.tileentity.network;
|
||||
|
||||
import api.hbm.conveyor.IConveyorBelt;
|
||||
import com.hbm.entity.item.EntityMovingItem;
|
||||
import com.hbm.interfaces.IControlReceiver;
|
||||
import com.hbm.inventory.container.ContainerCraneExtractor;
|
||||
@ -7,9 +8,6 @@ import com.hbm.inventory.gui.GUICraneExtractor;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.module.ModulePatternMatcher;
|
||||
import com.hbm.tileentity.IGUIProvider;
|
||||
import com.hbm.tileentity.TileEntityMachineBase;
|
||||
|
||||
import api.hbm.conveyor.IConveyorBelt;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
@ -26,7 +24,7 @@ import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileEntityCraneExtractor extends TileEntityMachineBase implements IGUIProvider, IControlReceiver {
|
||||
public class TileEntityCraneExtractor extends TileEntityCraneBase implements IGUIProvider, IControlReceiver {
|
||||
|
||||
public boolean isWhitelist = false;
|
||||
public ModulePatternMatcher matcher;
|
||||
@ -55,7 +53,7 @@ public class TileEntityCraneExtractor extends TileEntityMachineBase implements I
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
super.updateEntity();
|
||||
if(!worldObj.isRemote) {
|
||||
|
||||
int delay = 20;
|
||||
@ -79,9 +77,10 @@ public class TileEntityCraneExtractor extends TileEntityMachineBase implements I
|
||||
}
|
||||
}
|
||||
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata());
|
||||
TileEntity te = worldObj.getTileEntity(xCoord - dir.offsetX, yCoord - dir.offsetY, zCoord - dir.offsetZ);
|
||||
Block b = worldObj.getBlock(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ);
|
||||
ForgeDirection inputSide = getOutputSide(); // note the switcheroo!
|
||||
ForgeDirection outputSide = getInputSide();
|
||||
TileEntity te = worldObj.getTileEntity(xCoord + inputSide.offsetX, yCoord + inputSide.offsetY, zCoord + inputSide.offsetZ);
|
||||
Block b = worldObj.getBlock(xCoord + outputSide.offsetX, yCoord + outputSide.offsetY, zCoord + outputSide.offsetZ);
|
||||
|
||||
int[] access = null;
|
||||
ISidedInventory sided = null;
|
||||
@ -89,7 +88,7 @@ public class TileEntityCraneExtractor extends TileEntityMachineBase implements I
|
||||
if(te instanceof ISidedInventory) {
|
||||
sided = (ISidedInventory) te;
|
||||
//access = sided.getAccessibleSlotsFromSide(dir.ordinal());
|
||||
access = masquerade(sided, dir.ordinal());
|
||||
access = masquerade(sided, inputSide.getOpposite().ordinal());
|
||||
}
|
||||
|
||||
boolean hasSent = false;
|
||||
@ -108,7 +107,7 @@ public class TileEntityCraneExtractor extends TileEntityMachineBase implements I
|
||||
int index = access == null ? i : access[i];
|
||||
ItemStack stack = inv.getStackInSlot(index);
|
||||
|
||||
if(stack != null && (sided == null || sided.canExtractItem(index, stack, dir.ordinal()))){
|
||||
if(stack != null && (sided == null || sided.canExtractItem(index, stack, inputSide.getOpposite().ordinal()))){
|
||||
|
||||
boolean match = this.matchesFilter(stack);
|
||||
|
||||
@ -119,8 +118,8 @@ public class TileEntityCraneExtractor extends TileEntityMachineBase implements I
|
||||
stack.stackSize = toSend;
|
||||
|
||||
EntityMovingItem moving = new EntityMovingItem(worldObj);
|
||||
Vec3 pos = Vec3.createVectorHelper(xCoord + 0.5 + dir.offsetX * 0.55, yCoord + 0.5 + dir.offsetY * 0.55, zCoord + 0.5 + dir.offsetZ * 0.55);
|
||||
Vec3 snap = belt.getClosestSnappingPosition(worldObj, xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, pos);
|
||||
Vec3 pos = Vec3.createVectorHelper(xCoord + 0.5 + outputSide.offsetX * 0.55, yCoord + 0.5 + outputSide.offsetY * 0.55, zCoord + 0.5 + outputSide.offsetZ * 0.55);
|
||||
Vec3 snap = belt.getClosestSnappingPosition(worldObj, xCoord + outputSide.offsetX, yCoord + outputSide.offsetY, zCoord + outputSide.offsetZ, pos);
|
||||
moving.setPosition(snap.xCoord, snap.yCoord, snap.zCoord);
|
||||
moving.setItemStack(stack);
|
||||
worldObj.spawnEntityInWorld(moving);
|
||||
@ -144,8 +143,8 @@ public class TileEntityCraneExtractor extends TileEntityMachineBase implements I
|
||||
stack.stackSize = toSend;
|
||||
|
||||
EntityMovingItem moving = new EntityMovingItem(worldObj);
|
||||
Vec3 pos = Vec3.createVectorHelper(xCoord + 0.5 + dir.offsetX * 0.55, yCoord + 0.5 + dir.offsetY * 0.55, zCoord + 0.5 + dir.offsetZ * 0.55);
|
||||
Vec3 snap = belt.getClosestSnappingPosition(worldObj, xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, pos);
|
||||
Vec3 pos = Vec3.createVectorHelper(xCoord + 0.5 + outputSide.offsetX * 0.55, yCoord + 0.5 + outputSide.offsetY * 0.55, zCoord + 0.5 + outputSide.offsetZ * 0.55);
|
||||
Vec3 snap = belt.getClosestSnappingPosition(worldObj, xCoord + outputSide.offsetX, yCoord + outputSide.offsetY, zCoord + outputSide.offsetZ, pos);
|
||||
moving.setPosition(snap.xCoord, snap.yCoord, snap.zCoord);
|
||||
moving.setItemStack(stack);
|
||||
worldObj.spawnEntityInWorld(moving);
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
package com.hbm.tileentity.network;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.blocks.network.CraneInserter;
|
||||
import com.hbm.entity.item.EntityMovingItem;
|
||||
@ -11,8 +9,6 @@ import com.hbm.inventory.gui.GUICraneGrabber;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.module.ModulePatternMatcher;
|
||||
import com.hbm.tileentity.IGUIProvider;
|
||||
import com.hbm.tileentity.TileEntityMachineBase;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
@ -29,7 +25,9 @@ import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileEntityCraneGrabber extends TileEntityMachineBase implements IGUIProvider, IControlReceiver {
|
||||
import java.util.List;
|
||||
|
||||
public class TileEntityCraneGrabber extends TileEntityCraneBase implements IGUIProvider, IControlReceiver {
|
||||
|
||||
public boolean isWhitelist = false;
|
||||
public ModulePatternMatcher matcher;
|
||||
@ -50,7 +48,7 @@ public class TileEntityCraneGrabber extends TileEntityMachineBase implements IGU
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
super.updateEntity();
|
||||
if(!worldObj.isRemote) {
|
||||
|
||||
int delay = 20;
|
||||
@ -74,15 +72,16 @@ public class TileEntityCraneGrabber extends TileEntityMachineBase implements IGU
|
||||
}
|
||||
}
|
||||
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata());
|
||||
TileEntity te = worldObj.getTileEntity(xCoord - dir.offsetX, yCoord - dir.offsetY, zCoord - dir.offsetZ);
|
||||
ForgeDirection inputSide = getInputSide();
|
||||
ForgeDirection outputSide = getOutputSide();
|
||||
TileEntity te = worldObj.getTileEntity(xCoord + outputSide.offsetX, yCoord + outputSide.offsetY, zCoord + outputSide.offsetZ);
|
||||
|
||||
int[] access = null;
|
||||
ISidedInventory sided = null;
|
||||
|
||||
if(te instanceof ISidedInventory) {
|
||||
sided = (ISidedInventory) te;
|
||||
access = CraneInserter.masquerade(sided, dir.ordinal());
|
||||
access = CraneInserter.masquerade(sided, outputSide.getOpposite().ordinal());
|
||||
}
|
||||
|
||||
if(te instanceof IInventory) {
|
||||
@ -95,14 +94,14 @@ public class TileEntityCraneGrabber extends TileEntityMachineBase implements IGU
|
||||
*/
|
||||
double reach = 1D;
|
||||
if(this.getBlockMetadata() > 1) { //ignore if pointing up or down
|
||||
Block b = worldObj.getBlock(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ);
|
||||
Block b = worldObj.getBlock(xCoord + inputSide.offsetX, yCoord + inputSide.offsetY, zCoord + inputSide.offsetZ);
|
||||
if(b == ModBlocks.conveyor_double) reach = 0.5D;
|
||||
if(b == ModBlocks.conveyor_triple) reach = 0.33D;
|
||||
}
|
||||
|
||||
double x = xCoord + dir.offsetX * reach;
|
||||
double y = yCoord + dir.offsetY * reach;
|
||||
double z = zCoord + dir.offsetZ * reach;
|
||||
double x = xCoord + inputSide.offsetX * reach;
|
||||
double y = yCoord + inputSide.offsetY * reach;
|
||||
double z = zCoord + inputSide.offsetZ * reach;
|
||||
List<EntityMovingItem> items = worldObj.getEntitiesWithinAABB(EntityMovingItem.class, AxisAlignedBB.getBoundingBox(x + 0.1875D, y + 0.1875D, z + 0.1875D, x + 0.8125D, y + 0.8125D, z + 0.8125D));
|
||||
|
||||
for(EntityMovingItem item : items) {
|
||||
@ -113,7 +112,7 @@ public class TileEntityCraneGrabber extends TileEntityMachineBase implements IGU
|
||||
ItemStack copy = stack.copy();
|
||||
int toAdd = Math.min(stack.stackSize, amount);
|
||||
copy.stackSize = toAdd;
|
||||
ItemStack ret = CraneInserter.addToInventory((IInventory) te, access, copy, dir.ordinal());
|
||||
ItemStack ret = CraneInserter.addToInventory((IInventory) te, access, copy, outputSide.getOpposite().ordinal());
|
||||
int didAdd = toAdd - (ret != null ? ret.stackSize : 0);
|
||||
stack.stackSize -= didAdd;
|
||||
|
||||
|
||||
@ -4,8 +4,6 @@ import com.hbm.blocks.network.CraneInserter;
|
||||
import com.hbm.inventory.container.ContainerCraneInserter;
|
||||
import com.hbm.inventory.gui.GUICraneInserter;
|
||||
import com.hbm.tileentity.IGUIProvider;
|
||||
import com.hbm.tileentity.TileEntityMachineBase;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
@ -18,7 +16,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileEntityCraneInserter extends TileEntityMachineBase implements IGUIProvider {
|
||||
public class TileEntityCraneInserter extends TileEntityCraneBase implements IGUIProvider {
|
||||
|
||||
public static final int[] access = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 };
|
||||
|
||||
@ -33,18 +31,18 @@ public class TileEntityCraneInserter extends TileEntityMachineBase implements IG
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
super.updateEntity();
|
||||
if(!worldObj.isRemote) {
|
||||
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata());
|
||||
TileEntity te = worldObj.getTileEntity(xCoord - dir.offsetX, yCoord - dir.offsetY, zCoord - dir.offsetZ);
|
||||
ForgeDirection outputSide = getOutputSide();
|
||||
TileEntity te = worldObj.getTileEntity(xCoord + outputSide.offsetX, yCoord + outputSide.offsetY, zCoord + outputSide.offsetZ);
|
||||
|
||||
int[] access = null;
|
||||
|
||||
if(te instanceof ISidedInventory) {
|
||||
ISidedInventory sided = (ISidedInventory) te;
|
||||
//access = sided.getAccessibleSlotsFromSide(dir.ordinal());
|
||||
access = CraneInserter.masquerade(sided, dir.ordinal());
|
||||
access = CraneInserter.masquerade(sided, outputSide.getOpposite().ordinal());
|
||||
}
|
||||
|
||||
if(te instanceof IInventory) {
|
||||
@ -53,7 +51,7 @@ public class TileEntityCraneInserter extends TileEntityMachineBase implements IG
|
||||
ItemStack stack = slots[i];
|
||||
|
||||
if(stack != null) {
|
||||
ItemStack ret = CraneInserter.addToInventory((IInventory) te, access, stack.copy(), dir.ordinal());
|
||||
ItemStack ret = CraneInserter.addToInventory((IInventory) te, access, stack.copy(), outputSide.getOpposite().ordinal());
|
||||
|
||||
if(ret == null || ret.stackSize != stack.stackSize) {
|
||||
slots[i] = ret;
|
||||
@ -72,7 +70,7 @@ public class TileEntityCraneInserter extends TileEntityMachineBase implements IG
|
||||
if(stack != null) {
|
||||
stack = stack.copy();
|
||||
stack.stackSize = 1;
|
||||
ItemStack ret = CraneInserter.addToInventory((IInventory) te, access, stack.copy(), dir.ordinal());
|
||||
ItemStack ret = CraneInserter.addToInventory((IInventory) te, access, stack.copy(), outputSide.getOpposite().ordinal());
|
||||
|
||||
if(ret == null || ret.stackSize != stack.stackSize) {
|
||||
this.decrStackSize(i, 1);
|
||||
|
||||
@ -1,13 +1,11 @@
|
||||
package com.hbm.tileentity.network;
|
||||
|
||||
import api.hbm.conveyor.IConveyorBelt;
|
||||
import com.hbm.entity.item.EntityMovingItem;
|
||||
import com.hbm.inventory.container.ContainerCraneUnboxer;
|
||||
import com.hbm.inventory.gui.GUICraneUnboxer;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.tileentity.IGUIProvider;
|
||||
import com.hbm.tileentity.TileEntityMachineBase;
|
||||
|
||||
import api.hbm.conveyor.IConveyorBelt;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
@ -19,7 +17,7 @@ import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileEntityCraneUnboxer extends TileEntityMachineBase implements IGUIProvider {
|
||||
public class TileEntityCraneUnboxer extends TileEntityCraneBase implements IGUIProvider {
|
||||
|
||||
public TileEntityCraneUnboxer() {
|
||||
super(23);
|
||||
@ -32,7 +30,7 @@ public class TileEntityCraneUnboxer extends TileEntityMachineBase implements IGU
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
super.updateEntity();
|
||||
if(!worldObj.isRemote) {
|
||||
|
||||
int delay = 20;
|
||||
@ -65,8 +63,8 @@ public class TileEntityCraneUnboxer extends TileEntityMachineBase implements IGU
|
||||
}
|
||||
}
|
||||
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata());
|
||||
Block b = worldObj.getBlock(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ);
|
||||
ForgeDirection outputSide = getInputSide(); // note the switcheroo!
|
||||
Block b = worldObj.getBlock(xCoord + outputSide.offsetX, yCoord + outputSide.offsetY, zCoord + outputSide.offsetZ);
|
||||
|
||||
if(b instanceof IConveyorBelt) {
|
||||
|
||||
@ -82,8 +80,8 @@ public class TileEntityCraneUnboxer extends TileEntityMachineBase implements IGU
|
||||
stack.stackSize = toSend;
|
||||
|
||||
EntityMovingItem moving = new EntityMovingItem(worldObj);
|
||||
Vec3 pos = Vec3.createVectorHelper(xCoord + 0.5 + dir.offsetX * 0.55, yCoord + 0.5 + dir.offsetY * 0.55, zCoord + 0.5 + dir.offsetZ * 0.55);
|
||||
Vec3 snap = belt.getClosestSnappingPosition(worldObj, xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, pos);
|
||||
Vec3 pos = Vec3.createVectorHelper(xCoord + 0.5 + outputSide.offsetX * 0.55, yCoord + 0.5 + outputSide.offsetY * 0.55, zCoord + 0.5 + outputSide.offsetZ * 0.55);
|
||||
Vec3 snap = belt.getClosestSnappingPosition(worldObj, xCoord + outputSide.offsetX, yCoord + outputSide.offsetY, zCoord + outputSide.offsetZ, pos);
|
||||
moving.setPosition(snap.xCoord, snap.yCoord, snap.zCoord);
|
||||
moving.setItemStack(stack);
|
||||
worldObj.spawnEntityInWorld(moving);
|
||||
|
||||
|
After Width: | Height: | Size: 518 B |
|
After Width: | Height: | Size: 504 B |
|
After Width: | Height: | Size: 514 B |
|
After Width: | Height: | Size: 511 B |
|
After Width: | Height: | Size: 514 B |
|
After Width: | Height: | Size: 522 B |
|
After Width: | Height: | Size: 519 B |
|
After Width: | Height: | Size: 514 B |
|
After Width: | Height: | Size: 462 B |
|
After Width: | Height: | Size: 472 B |
|
After Width: | Height: | Size: 521 B |
|
After Width: | Height: | Size: 518 B |
|
After Width: | Height: | Size: 504 B |
|
After Width: | Height: | Size: 473 B |
|
After Width: | Height: | Size: 500 B |
|
After Width: | Height: | Size: 510 B |
|
After Width: | Height: | Size: 506 B |
|
After Width: | Height: | Size: 526 B |
|
After Width: | Height: | Size: 768 B |
|
After Width: | Height: | Size: 770 B |
|
Before Width: | Height: | Size: 305 B After Width: | Height: | Size: 252 B |
|
After Width: | Height: | Size: 496 B |
|
After Width: | Height: | Size: 524 B |
|
After Width: | Height: | Size: 524 B |
|
After Width: | Height: | Size: 490 B |
|
After Width: | Height: | Size: 530 B |
|
After Width: | Height: | Size: 508 B |
|
After Width: | Height: | Size: 507 B |
|
After Width: | Height: | Size: 526 B |
|
After Width: | Height: | Size: 776 B |
|
After Width: | Height: | Size: 772 B |
|
Before Width: | Height: | Size: 252 B After Width: | Height: | Size: 305 B |
|
After Width: | Height: | Size: 513 B |
|
After Width: | Height: | Size: 519 B |
|
After Width: | Height: | Size: 519 B |
|
After Width: | Height: | Size: 500 B |
|
After Width: | Height: | Size: 515 B |
|
After Width: | Height: | Size: 502 B |
|
After Width: | Height: | Size: 500 B |
|
After Width: | Height: | Size: 525 B |
|
After Width: | Height: | Size: 763 B |
|
After Width: | Height: | Size: 763 B |
|
Before Width: | Height: | Size: 358 B After Width: | Height: | Size: 325 B |
|
Before Width: | Height: | Size: 325 B After Width: | Height: | Size: 358 B |
|
After Width: | Height: | Size: 488 B |
|
After Width: | Height: | Size: 506 B |
|
After Width: | Height: | Size: 507 B |
|
After Width: | Height: | Size: 508 B |
|
After Width: | Height: | Size: 516 B |
|
After Width: | Height: | Size: 516 B |
|
After Width: | Height: | Size: 491 B |
|
After Width: | Height: | Size: 509 B |
|
After Width: | Height: | Size: 456 B |
|
After Width: | Height: | Size: 458 B |