Placed machines now face the block they are placed on, like hoppers, fixes #231

This commit is contained in:
Raoul Van den Berge
2016-07-30 13:59:09 +02:00
parent e1293733b5
commit 955ee43b25
3 changed files with 15 additions and 7 deletions

View File

@@ -13,6 +13,7 @@
- Added support for processing patterns with big stacksizes
- The slot where the Wireless Grid is in in the Wireless Grid GUI is now disabled, so the item can't be thrown out of the inventory by accident
- Changed Relay recipe to use redstone torch instead of Basic Processor
- Placed machines now face the block they are placed on, like hoppers
**NOTE:** Config change: the config options for the energy capacity of the Controller and wether the Controller uses energy are now in a different config category called "controller", if you changed these config options, don't forget the change it under the new category.

View File

@@ -98,12 +98,23 @@ public abstract class BlockBase extends Block {
return false;
}
@Override
public IBlockState onBlockPlaced(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase entity) {
IBlockState state = super.onBlockPlaced(world, pos, facing, hitX, hitY, hitZ, meta, entity);
if (getPlacementType() != null) {
return state.withProperty(DIRECTION, getPlacementType().getFrom(facing, entity));
}
return state;
}
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack) {
super.onBlockPlacedBy(world, pos, state, player, stack);
if (getPlacementType() != null) {
((TileBase) world.getTileEntity(pos)).setDirection(getPlacementType().getFrom(pos, player));
((TileBase) world.getTileEntity(pos)).setDirection(state.getValue(DIRECTION));
}
}

View File

@@ -1,9 +1,7 @@
package refinedstorage.block;
import net.minecraft.block.BlockPistonBase;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
public enum EnumPlacementType {
ANY(
@@ -22,12 +20,10 @@ public enum EnumPlacementType {
this.allowed = allowed;
}
EnumFacing getFrom(BlockPos pos, EntityLivingBase entity) {
EnumFacing getFrom(EnumFacing facing, EntityLivingBase entity) {
switch (this) {
case ANY:
EnumFacing facing = BlockPistonBase.getFacingFromEntity(pos, entity);
return entity.isSneaking() ? facing.getOpposite() : facing;
return facing.getOpposite();
case HORIZONTAL:
return entity.getHorizontalFacing().getOpposite();
default: