Clean up Greenhouse door properties

This commit is contained in:
mezz committed 2016-04-30 02:33:06 -07:00
1 parent 1d8f2dae66
commit cc34078ab4
1 file changed
+27 -25
@@ -10,15 +10,11 @@
******************************************************************************/
package forestry.greenhouse.blocks;
import javax.annotation.Nonnull;
import java.util.Random;
import forestry.api.core.IModelManager;
import forestry.api.core.IStateMapperRegister;
import forestry.core.proxy.Proxies;
import forestry.greenhouse.tiles.TileGreenhouseDoor;
import net.minecraft.block.Block;
import net.minecraft.block.BlockDoor;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.properties.PropertyEnum;
@@ -37,14 +33,20 @@ import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.core.IModelManager;
import forestry.api.core.IStateMapperRegister;
import forestry.core.proxy.Proxies;
import forestry.core.utils.Translator;
import forestry.greenhouse.tiles.TileGreenhouseDoor;
public class BlockGreenhouseDoor extends BlockGreenhouse implements IStateMapperRegister {
//The door propertys
//The door properties
private static final PropertyDirection FACING = BlockDoor.FACING;
private static final PropertyBool OPEN = BlockDoor.OPEN;
private static final PropertyEnum<BlockDoor.EnumHingePosition> HINGE = BlockDoor.HINGE;
@@ -52,9 +54,8 @@ public class BlockGreenhouseDoor extends BlockGreenhouse implements IStateMappe
private static final PropertyEnum<BlockDoor.EnumDoorHalf> HALF = BlockDoor.HALF;
public BlockGreenhouseDoor() {
super();
setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(OPEN, Boolean.valueOf(false)).withProperty(HINGE, BlockDoor.EnumHingePosition.LEFT).withProperty(POWERED, Boolean.valueOf(false)).withProperty(HALF, BlockDoor.EnumDoorHalf.LOWER));
}
setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(OPEN, false).withProperty(HINGE, BlockDoor.EnumHingePosition.LEFT).withProperty(POWERED, false).withProperty(HALF, BlockDoor.EnumDoorHalf.LOWER));
}
@Override
public String getLocalizedName(){
@@ -158,7 +159,7 @@ public class BlockGreenhouseDoor extends BlockGreenhouse implements IStateMappe
state = iblockstate.cycleProperty(OPEN);
world.setBlockState(blockpos, state, 2);
world.markBlockRangeForRenderUpdate(blockpos, pos);
world.playAuxSFXAtEntity(player, state.getValue(OPEN).booleanValue() ? 1003 : 1006, pos, 0);
world.playAuxSFXAtEntity(player, state.getValue(OPEN) ? 1003 : 1006, pos, 0);
return true;
}
}
@@ -171,8 +172,8 @@ public class BlockGreenhouseDoor extends BlockGreenhouse implements IStateMappe
BlockPos blockpos = iblockstate.getValue(HALF) == BlockDoor.EnumDoorHalf.LOWER ? pos : pos.down();
IBlockState iblockstate1 = pos == blockpos ? iblockstate : worldIn.getBlockState(blockpos);
if (iblockstate1.getBlock() == this && iblockstate1.getValue(OPEN).booleanValue() != open){
worldIn.setBlockState(blockpos, iblockstate1.withProperty(OPEN, Boolean.valueOf(open)), 2);
if (iblockstate1.getBlock() == this && iblockstate1.getValue(OPEN) != open) {
worldIn.setBlockState(blockpos, iblockstate1.withProperty(OPEN, open), 2);
worldIn.markBlockRangeForRenderUpdate(blockpos, pos);
worldIn.playAuxSFXAtEntity((EntityPlayer)null, open ? 1003 : 1006, pos, 0);
}
@@ -216,11 +217,11 @@ public class BlockGreenhouseDoor extends BlockGreenhouse implements IStateMappe
}else{
boolean flag = worldIn.isBlockPowered(pos) || worldIn.isBlockPowered(blockpos1);
if ((flag || neighborBlock.canProvidePower()) && neighborBlock != this && flag != iblockstate1.getValue(POWERED).booleanValue()){
worldIn.setBlockState(blockpos1, iblockstate1.withProperty(POWERED, Boolean.valueOf(flag)), 2);
if ((flag || neighborBlock.canProvidePower()) && neighborBlock != this && flag != iblockstate1.getValue(POWERED)) {
worldIn.setBlockState(blockpos1, iblockstate1.withProperty(POWERED, flag), 2);
if (flag != state.getValue(OPEN).booleanValue()){
worldIn.setBlockState(pos, state.withProperty(OPEN, Boolean.valueOf(flag)), 2);
if (flag != state.getValue(OPEN)) {
worldIn.setBlockState(pos, state.withProperty(OPEN, flag), 2);
worldIn.markBlockRangeForRenderUpdate(pos, pos);
worldIn.playAuxSFXAtEntity((EntityPlayer)null, flag ? 1003 : 1006, pos, 0);
}
@@ -242,7 +243,7 @@ public class BlockGreenhouseDoor extends BlockGreenhouse implements IStateMappe
@Override
public boolean canPlaceBlockAt(World worldIn, BlockPos pos){
return pos.getY() >= worldIn.getHeight() - 1 ? false : World.doesBlockHaveSolidTopSurface(worldIn, pos.down()) && super.canPlaceBlockAt(worldIn, pos) && super.canPlaceBlockAt(worldIn, pos.up());
return pos.getY() < worldIn.getHeight() - 1 && (World.doesBlockHaveSolidTopSurface(worldIn, pos.down()) && super.canPlaceBlockAt(worldIn, pos) && super.canPlaceBlockAt(worldIn, pos.up()));
}
@Override
@@ -317,14 +318,14 @@ public class BlockGreenhouseDoor extends BlockGreenhouse implements IStateMappe
i |= 1;
}
if (state.getValue(POWERED).booleanValue())
if (state.getValue(POWERED))
{
i |= 2;
}
}else{
i = i | state.getValue(FACING).rotateY().getHorizontalIndex();
if (state.getValue(OPEN).booleanValue()){
if (state.getValue(OPEN)) {
i |= 4;
}
}
@@ -341,8 +342,8 @@ public class BlockGreenhouseDoor extends BlockGreenhouse implements IStateMappe
@SideOnly(Side.CLIENT)
@Override
public void registerStateMapper() {
Proxies.render.registerStateMapper(this, new StateMap.Builder().ignore(new IProperty[] {BlockDoor.POWERED}).build());
}
Proxies.render.registerStateMapper(this, new StateMap.Builder().ignore(BlockDoor.POWERED).build());
}
protected static int removeHalfBit(int meta)
{
@@ -389,10 +390,11 @@ public class BlockGreenhouseDoor extends BlockGreenhouse implements IStateMappe
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
return state;
}
@Override
public BlockGreenhouseType getGreenhouseType() {
return BlockGreenhouseType.DOOR;
@Nonnull
@Override
public BlockGreenhouseType getGreenhouseType() {
return BlockGreenhouseType.DOOR;
}
}