Do not create already existing block property

This commit is contained in:
drcrazy 2019-03-07 11:49:23 +03:00
parent 4650f3e375
commit 682b8ccede
5 changed files with 8 additions and 67 deletions

View file

@ -111,7 +111,6 @@ public class BlockNuke extends BaseBlock {
@Override @Override
protected void fillStateContainer(StateContainer.Builder<Block, IBlockState> builder) { protected void fillStateContainer(StateContainer.Builder<Block, IBlockState> builder) {
OVERLAY = BooleanProperty.create("overlay");
builder.add(OVERLAY); builder.add(OVERLAY);
} }
} }

View file

@ -34,6 +34,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.state.BooleanProperty; import net.minecraft.state.BooleanProperty;
import net.minecraft.state.DirectionProperty; import net.minecraft.state.DirectionProperty;
import net.minecraft.state.StateContainer; import net.minecraft.state.StateContainer;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
@ -53,7 +54,7 @@ import techreborn.tiles.lighting.TileLamp;
public class BlockLamp extends BaseTileBlock { public class BlockLamp extends BaseTileBlock {
public static DirectionProperty FACING; public static DirectionProperty FACING = BlockStateProperties.FACING;
public static BooleanProperty ACTIVE; public static BooleanProperty ACTIVE;
protected final VoxelShape[] shape; protected final VoxelShape[] shape;
@ -113,7 +114,6 @@ public class BlockLamp extends BaseTileBlock {
// Block // Block
@Override @Override
protected void fillStateContainer(StateContainer.Builder<Block, IBlockState> builder) { protected void fillStateContainer(StateContainer.Builder<Block, IBlockState> builder) {
FACING = DirectionProperty.create("facing", EnumFacing.Plane.HORIZONTAL);
ACTIVE = BooleanProperty.create("active"); ACTIVE = BooleanProperty.create("active");
builder.add(FACING, ACTIVE); builder.add(FACING, ACTIVE);
} }

View file

@ -24,8 +24,6 @@
package techreborn.blocks.storage; package techreborn.blocks.storage;
import com.google.common.base.Predicate;
import com.google.common.collect.Iterators;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
@ -34,6 +32,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.state.DirectionProperty; import net.minecraft.state.DirectionProperty;
import net.minecraft.state.StateContainer; import net.minecraft.state.StateContainer;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand; import net.minecraft.util.EnumHand;
@ -48,14 +47,11 @@ import reborncore.common.blocks.BlockWrenchEventHandler;
import reborncore.common.util.WrenchUtils; import reborncore.common.util.WrenchUtils;
import techreborn.TechReborn; import techreborn.TechReborn;
import java.util.Iterator;
import java.util.Random;
/** /**
* Created by Rushmead * Created by Rushmead
*/ */
public abstract class BlockEnergyStorage extends BaseTileBlock { public abstract class BlockEnergyStorage extends BaseTileBlock {
public static DirectionProperty FACING = DirectionProperty.create("facing", Facings.ALL); public static DirectionProperty FACING = BlockStateProperties.FACING;;
public String name; public String name;
public IMachineGuiHandler gui; public IMachineGuiHandler gui;
@ -101,7 +97,6 @@ public abstract class BlockEnergyStorage extends BaseTileBlock {
// Block // Block
@Override @Override
protected void fillStateContainer(StateContainer.Builder<Block, IBlockState> builder) { protected void fillStateContainer(StateContainer.Builder<Block, IBlockState> builder) {
FACING = DirectionProperty.create("facing", Facings.ALL);
builder.add(FACING); builder.add(FACING);
} }
@ -142,29 +137,4 @@ public abstract class BlockEnergyStorage extends BaseTileBlock {
} }
setFacing(facing, worldIn, pos); setFacing(facing, worldIn, pos);
} }
public enum Facings implements Predicate<EnumFacing>, Iterable<EnumFacing> {
ALL;
public EnumFacing[] facings() {
return new EnumFacing[] { EnumFacing.NORTH, EnumFacing.EAST, EnumFacing.SOUTH, EnumFacing.WEST,
EnumFacing.UP, EnumFacing.DOWN };
}
public EnumFacing random(Random rand) {
EnumFacing[] aenumfacing = this.facings();
return aenumfacing[rand.nextInt(aenumfacing.length)];
}
@Override
public boolean apply(EnumFacing p_apply_1_) {
return p_apply_1_ != null;
}
@Override
public Iterator<EnumFacing> iterator() {
return Iterators.forArray(this.facings());
}
}
} }

View file

@ -24,8 +24,6 @@
package techreborn.blocks.transformers; package techreborn.blocks.transformers;
import com.google.common.base.Predicate;
import com.google.common.collect.Iterators;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
@ -34,6 +32,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.state.DirectionProperty; import net.minecraft.state.DirectionProperty;
import net.minecraft.state.StateContainer; import net.minecraft.state.StateContainer;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand; import net.minecraft.util.EnumHand;
@ -47,14 +46,12 @@ import reborncore.common.blocks.BlockWrenchEventHandler;
import reborncore.common.util.WrenchUtils; import reborncore.common.util.WrenchUtils;
import techreborn.TechReborn; import techreborn.TechReborn;
import java.util.Iterator;
import java.util.Random;
/** /**
* Created by Rushmead * Created by Rushmead
*/ */
public abstract class BlockTransformer extends BaseTileBlock { public abstract class BlockTransformer extends BaseTileBlock {
public static DirectionProperty FACING = DirectionProperty.create("facing", Facings.ALL);
public static DirectionProperty FACING = BlockStateProperties.FACING;
public String name; public String name;
public BlockTransformer(String name) { public BlockTransformer(String name) {
@ -90,7 +87,6 @@ public abstract class BlockTransformer extends BaseTileBlock {
// Block // Block
@Override @Override
protected void fillStateContainer(StateContainer.Builder<Block, IBlockState> builder) { protected void fillStateContainer(StateContainer.Builder<Block, IBlockState> builder) {
FACING = DirectionProperty.create("facing", EnumFacing.Plane.HORIZONTAL);
builder.add(FACING); builder.add(FACING);
} }
@ -113,28 +109,4 @@ public abstract class BlockTransformer extends BaseTileBlock {
return super.onBlockActivated(state, worldIn, pos, playerIn, hand, side, hitX, hitY, hitZ); return super.onBlockActivated(state, worldIn, pos, playerIn, hand, side, hitX, hitY, hitZ);
} }
public enum Facings implements Predicate<EnumFacing>, Iterable<EnumFacing> {
ALL;
public EnumFacing[] facings() {
return new EnumFacing[] { EnumFacing.NORTH, EnumFacing.EAST, EnumFacing.SOUTH, EnumFacing.WEST,
EnumFacing.UP, EnumFacing.DOWN };
}
public EnumFacing random(Random rand) {
EnumFacing[] aenumfacing = this.facings();
return aenumfacing[rand.nextInt(aenumfacing.length)];
}
@Override
public boolean apply(EnumFacing p_apply_1_) {
return p_apply_1_ != null;
}
@Override
public Iterator<EnumFacing> iterator() {
return Iterators.forArray(this.facings());
}
}
} }

View file

@ -53,7 +53,7 @@ public class TileTransformer extends TilePowerAcceptor
implements IToolDrop, IListInfoProvider { implements IToolDrop, IListInfoProvider {
@ConfigRegistry(config = "misc", category = "general", key = "IC2TransformersStyle", comment = "Input from dots side, output from other sides, like in IC2.") @ConfigRegistry(config = "misc", category = "general", key = "IC2TransformersStyle", comment = "Input from dots side, output from other sides, like in IC2.")
public static boolean IC2TransformersStyle = false; public static boolean IC2TransformersStyle = true;
public String name; public String name;
public Block wrenchDrop; public Block wrenchDrop;