Update BlockInteger/String
This commit is contained in:
parent
5e9454d390
commit
d05d3b90df
|
@ -6,15 +6,15 @@ import net.minecraft.block.Block;
|
|||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyInteger;
|
||||
import net.minecraft.block.state.BlockState;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.property.ExtendedBlockState;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
|
@ -38,7 +38,7 @@ public class BlockInteger extends Block
|
|||
private final int maxMeta;
|
||||
private final PropertyInteger metaProp;
|
||||
private final IUnlistedProperty unlistedMetaProp;
|
||||
private final BlockState realBlockState;
|
||||
private final BlockStateContainer realBlockState;
|
||||
|
||||
public BlockInteger(Material material, int maxMeta, String propName)
|
||||
{
|
||||
|
@ -60,7 +60,7 @@ public class BlockInteger extends Block
|
|||
@Override
|
||||
public IBlockState getStateFromMeta(int meta)
|
||||
{
|
||||
return getBlockState().getBaseState().withProperty(metaProp, meta);
|
||||
return getDefaultState().withProperty(metaProp, meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -76,19 +76,19 @@ public class BlockInteger extends Block
|
|||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlockState()
|
||||
public BlockStateContainer getBlockState()
|
||||
{
|
||||
return this.realBlockState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState createBlockState()
|
||||
public BlockStateContainer createBlockState()
|
||||
{
|
||||
return Blocks.air.getBlockState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock(MovingObjectPosition target, World world, BlockPos pos, EntityPlayer player)
|
||||
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player)
|
||||
{
|
||||
return new ItemStack(this, 1, this.getMetaFromState(world.getBlockState(pos)));
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ public class BlockInteger extends Block
|
|||
return (IExtendedBlockState) this.getBaseExtendedState().getBaseState();
|
||||
}
|
||||
|
||||
private BlockState createRealBlockState()
|
||||
private BlockStateContainer createRealBlockState()
|
||||
{
|
||||
return new ExtendedBlockState(this, new IProperty[] { metaProp }, new IUnlistedProperty[] { unlistedMetaProp });
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import net.minecraft.block.ITileEntityProvider;
|
|||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public abstract class BlockIntegerContainer extends BlockInteger implements ITileEntityProvider
|
||||
|
|
|
@ -6,15 +6,15 @@ import lombok.Getter;
|
|||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.state.BlockState;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.property.ExtendedBlockState;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
|
@ -42,7 +42,7 @@ public class BlockString extends Block
|
|||
private final List<String> values;
|
||||
private final PropertyString stringProp;
|
||||
private final IUnlistedProperty unlistedStringProp;
|
||||
private final BlockState realBlockState;
|
||||
private final BlockStateContainer realBlockState;
|
||||
|
||||
public BlockString(Material material, String[] values, String propName)
|
||||
{
|
||||
|
@ -81,19 +81,19 @@ public class BlockString extends Block
|
|||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlockState()
|
||||
public BlockStateContainer getBlockState()
|
||||
{
|
||||
return this.realBlockState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState createBlockState()
|
||||
public BlockStateContainer createBlockState()
|
||||
{
|
||||
return Blocks.air.getBlockState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock(MovingObjectPosition target, World world, BlockPos pos, EntityPlayer player)
|
||||
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player)
|
||||
{
|
||||
return new ItemStack(this, 1, this.getMetaFromState(world.getBlockState(pos)));
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ public class BlockString extends Block
|
|||
return (IExtendedBlockState) this.getBaseExtendedState().getBaseState();
|
||||
}
|
||||
|
||||
private BlockState createRealBlockState()
|
||||
private BlockStateContainer createRealBlockState()
|
||||
{
|
||||
return new ExtendedBlockState(this, new IProperty[] { stringProp }, new IUnlistedProperty[] { unlistedStringProp });
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import net.minecraft.block.ITileEntityProvider;
|
|||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public abstract class BlockStringContainer extends BlockString implements ITileEntityProvider
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
package WayofTime.bloodmagic.block.property;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
import net.minecraft.block.properties.PropertyHelper;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
@ -21,6 +24,11 @@ public class PropertyString extends PropertyHelper<String>
|
|||
allowedValues = ImmutableSet.copyOf(hashSet);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Optional<String> parseValue(String value) {
|
||||
return allowedValues.contains(value) ? Optional.of(value) : Optional.<String>absent();
|
||||
}
|
||||
|
||||
public static PropertyString create(String name, String[] values)
|
||||
{
|
||||
return new PropertyString(name, values);
|
||||
|
|
Loading…
Reference in a new issue