Fixed Crafter facing bottom side on placement

This commit is contained in:
Raoul Van den Berge
2016-08-08 02:16:12 +02:00
parent b830b3c31e
commit a341cc4319
5 changed files with 13 additions and 4 deletions

View File

@@ -103,7 +103,7 @@ public abstract class BlockBase extends Block {
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.withProperty(DIRECTION, getPlacementType().getFrom(facing, pos, entity));
}
return state;

View File

@@ -237,7 +237,7 @@ public class BlockCable extends BlockCoverable {
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.withProperty(DIRECTION, getPlacementType().getFrom(facing, pos, entity));
}
return state;

View File

@@ -33,7 +33,7 @@ public class BlockCrafter extends BlockNode {
@Override
public EnumPlacementType getPlacementType() {
return EnumPlacementType.ANY;
return EnumPlacementType.ANY_FACE_PLAYER;
}
public boolean hasConnectivityState() {

View File

@@ -1,12 +1,17 @@
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(
EnumFacing.VALUES
),
ANY_FACE_PLAYER(
EnumFacing.VALUES
),
HORIZONTAL(
EnumFacing.NORTH,
EnumFacing.EAST,
@@ -20,10 +25,12 @@ public enum EnumPlacementType {
this.allowed = allowed;
}
EnumFacing getFrom(EnumFacing facing, EntityLivingBase entity) {
EnumFacing getFrom(EnumFacing facing, BlockPos pos, EntityLivingBase entity) {
switch (this) {
case ANY:
return facing.getOpposite();
case ANY_FACE_PLAYER:
return BlockPistonBase.getFacingFromEntity(pos, entity);
case HORIZONTAL:
return entity.getHorizontalFacing().getOpposite();
default:
@@ -34,6 +41,7 @@ public enum EnumPlacementType {
EnumFacing getNext(EnumFacing previous) {
switch (this) {
case ANY:
case ANY_FACE_PLAYER:
return previous.ordinal() + 1 >= EnumFacing.VALUES.length ? EnumFacing.VALUES[0] : EnumFacing.VALUES[previous.ordinal() + 1];
case HORIZONTAL:
return previous.rotateYCCW();