Merge branch 'BOP-1.8-3.0.x' of https://github.com/Glitchfiend/BiomesOPlenty into BOP-1.8-3.0.x
This commit is contained in:
commit
1ca26f4f1c
44 changed files with 917 additions and 360 deletions
|
@ -117,6 +117,8 @@ public class BOPBlocks
|
||||||
public static Block pine_sapling;
|
public static Block pine_sapling;
|
||||||
public static Block mahogany_sapling;
|
public static Block mahogany_sapling;
|
||||||
|
|
||||||
|
public static Block double_foliage;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,15 +8,17 @@
|
||||||
|
|
||||||
package biomesoplenty.api.block;
|
package biomesoplenty.api.block;
|
||||||
|
|
||||||
import java.util.Map;
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.item.ItemBlock;
|
import net.minecraft.item.ItemBlock;
|
||||||
|
|
||||||
public interface IBOPBlock {
|
public interface IBOPBlock {
|
||||||
|
|
||||||
public Map<String, IBlockState> getNamedStates();
|
|
||||||
public IBlockState getNamedState(String name);
|
|
||||||
public Class<? extends ItemBlock> getItemClass();
|
public Class<? extends ItemBlock> getItemClass();
|
||||||
|
public int getItemRenderColor(IBlockState state, int tintIndex);
|
||||||
|
public IProperty[] getPresetProperties();
|
||||||
|
public IProperty[] getRenderProperties();
|
||||||
|
public IBlockState getDefaultState();
|
||||||
|
public String getStateName(IBlockState state);
|
||||||
|
|
||||||
}
|
}
|
|
@ -8,9 +8,6 @@
|
||||||
|
|
||||||
package biomesoplenty.common.block;
|
package biomesoplenty.common.block;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
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.properties.IProperty;
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
@ -38,12 +35,15 @@ public class BlockBOPDirt extends Block implements IBOPBlock
|
||||||
@Override
|
@Override
|
||||||
protected BlockState createBlockState() {return new BlockState(this, new IProperty[] { COARSE, VARIANT });}
|
protected BlockState createBlockState() {return new BlockState(this, new IProperty[] { COARSE, VARIANT });}
|
||||||
|
|
||||||
// implement IDHBlock
|
// implement IBOPBlock
|
||||||
private Map<String, IBlockState> namedStates = new HashMap<String, IBlockState>();
|
|
||||||
public Map<String, IBlockState> getNamedStates() {return this.namedStates;}
|
|
||||||
public IBlockState getNamedState(String name) {return this.namedStates.get(name);}
|
|
||||||
public Class<? extends ItemBlock> getItemClass() { return ItemBOPBlock.class; }
|
public Class<? extends ItemBlock> getItemClass() { return ItemBOPBlock.class; }
|
||||||
|
public int getItemRenderColor(IBlockState state, int tintIndex) { return this.getRenderColor(state); }
|
||||||
|
public IProperty[] getPresetProperties() { return new IProperty[] {COARSE, VARIANT}; }
|
||||||
|
public IProperty[] getRenderProperties() { return new IProperty[] {COARSE, VARIANT}; }
|
||||||
|
public String getStateName(IBlockState state)
|
||||||
|
{
|
||||||
|
return (Boolean.TRUE.equals(state.getValue(COARSE)) ? "coarse_" : "") + ((BOPDirtType) state.getValue(VARIANT)).getName() + "_dirt";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public BlockBOPDirt() {
|
public BlockBOPDirt() {
|
||||||
|
@ -54,16 +54,7 @@ public class BlockBOPDirt extends Block implements IBOPBlock
|
||||||
this.setHardness(0.5F);
|
this.setHardness(0.5F);
|
||||||
this.setHarvestLevel("shovel", 0);
|
this.setHarvestLevel("shovel", 0);
|
||||||
this.setStepSound(Block.soundTypeGravel);
|
this.setStepSound(Block.soundTypeGravel);
|
||||||
|
this.setDefaultState( this.blockState.getBaseState().withProperty(COARSE, Boolean.valueOf(false)).withProperty(VARIANT, BOPDirtType.LOAMY) );
|
||||||
// define named states
|
|
||||||
this.namedStates.put("loamy_dirt", this.blockState.getBaseState().withProperty(COARSE, Boolean.valueOf(false)).withProperty(VARIANT, BOPDirtType.LOAMY) );
|
|
||||||
this.namedStates.put("sandy_dirt", this.blockState.getBaseState().withProperty(COARSE, Boolean.valueOf(false)).withProperty(VARIANT, BOPDirtType.SANDY) );
|
|
||||||
this.namedStates.put("silty_dirt", this.blockState.getBaseState().withProperty(COARSE, Boolean.valueOf(false)).withProperty(VARIANT, BOPDirtType.SILTY) );
|
|
||||||
this.namedStates.put("coarse_loamy_dirt", this.blockState.getBaseState().withProperty(COARSE, Boolean.valueOf(true)).withProperty(VARIANT, BOPDirtType.LOAMY) );
|
|
||||||
this.namedStates.put("coarse_sandy_dirt", this.blockState.getBaseState().withProperty(COARSE, Boolean.valueOf(true)).withProperty(VARIANT, BOPDirtType.SANDY) );
|
|
||||||
this.namedStates.put("coarse_silty_dirt", this.blockState.getBaseState().withProperty(COARSE, Boolean.valueOf(true)).withProperty(VARIANT, BOPDirtType.SILTY) );
|
|
||||||
|
|
||||||
this.setDefaultState(this.namedStates.get("loamy_dirt"));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,12 +8,10 @@
|
||||||
|
|
||||||
package biomesoplenty.common.block;
|
package biomesoplenty.common.block;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import biomesoplenty.api.block.IBOPBlock;
|
import biomesoplenty.api.block.IBOPBlock;
|
||||||
import net.minecraft.block.BlockDoor;
|
import net.minecraft.block.BlockDoor;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemBlock;
|
import net.minecraft.item.ItemBlock;
|
||||||
|
@ -24,11 +22,13 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
public class BlockBOPDoor extends BlockDoor implements IBOPBlock
|
public class BlockBOPDoor extends BlockDoor implements IBOPBlock
|
||||||
{
|
{
|
||||||
// implement IDHBlock
|
|
||||||
protected Map<String, IBlockState> namedStates = new HashMap<String, IBlockState>();
|
// implement IBOPBlock
|
||||||
public Map<String, IBlockState> getNamedStates() {return this.namedStates;}
|
|
||||||
public IBlockState getNamedState(String name) {return this.namedStates.get(name);}
|
|
||||||
public Class<? extends ItemBlock> getItemClass() { return null; }
|
public Class<? extends ItemBlock> getItemClass() { return null; }
|
||||||
|
public int getItemRenderColor(IBlockState state, int tintIndex) { return this.getRenderColor(state); }
|
||||||
|
public IProperty[] getPresetProperties() { return new IProperty[] {}; }
|
||||||
|
public IProperty[] getRenderProperties() { return new IProperty[] {FACING, OPEN, HINGE, HALF}; }
|
||||||
|
public String getStateName(IBlockState state) {return "";}
|
||||||
|
|
||||||
private Item doorItem;
|
private Item doorItem;
|
||||||
|
|
||||||
|
|
|
@ -8,23 +8,24 @@
|
||||||
|
|
||||||
package biomesoplenty.common.block;
|
package biomesoplenty.common.block;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import biomesoplenty.api.block.IBOPBlock;
|
import biomesoplenty.api.block.IBOPBlock;
|
||||||
import biomesoplenty.common.item.ItemBOPBlock;
|
import biomesoplenty.common.item.ItemBOPBlock;
|
||||||
import net.minecraft.block.BlockFence;
|
import net.minecraft.block.BlockFence;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.item.ItemBlock;
|
import net.minecraft.item.ItemBlock;
|
||||||
|
|
||||||
public class BlockBOPFence extends BlockFence implements IBOPBlock
|
public class BlockBOPFence extends BlockFence implements IBOPBlock
|
||||||
{
|
{
|
||||||
// implement IDHBlock
|
|
||||||
protected Map<String, IBlockState> namedStates = new HashMap<String, IBlockState>();
|
// implement IBOPBlock
|
||||||
public Map<String, IBlockState> getNamedStates() {return this.namedStates;}
|
|
||||||
public IBlockState getNamedState(String name) {return this.namedStates.get(name);}
|
|
||||||
public Class<? extends ItemBlock> getItemClass() { return ItemBOPBlock.class; }
|
public Class<? extends ItemBlock> getItemClass() { return ItemBOPBlock.class; }
|
||||||
|
public int getItemRenderColor(IBlockState state, int tintIndex) { return this.getRenderColor(state); }
|
||||||
|
public IProperty[] getPresetProperties() { return new IProperty[] {}; }
|
||||||
|
public IProperty[] getRenderProperties() { return new IProperty[] {NORTH, EAST, SOUTH, WEST}; }
|
||||||
|
public String getStateName(IBlockState state) {return "";}
|
||||||
|
|
||||||
|
|
||||||
public BlockBOPFence()
|
public BlockBOPFence()
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,12 +8,10 @@
|
||||||
|
|
||||||
package biomesoplenty.common.block;
|
package biomesoplenty.common.block;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import biomesoplenty.api.block.IBOPBlock;
|
import biomesoplenty.api.block.IBOPBlock;
|
||||||
import biomesoplenty.common.item.ItemBOPBlock;
|
import biomesoplenty.common.item.ItemBOPBlock;
|
||||||
import net.minecraft.block.BlockFenceGate;
|
import net.minecraft.block.BlockFenceGate;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.item.ItemBlock;
|
import net.minecraft.item.ItemBlock;
|
||||||
|
|
||||||
|
@ -23,11 +21,13 @@ import net.minecraft.item.ItemBlock;
|
||||||
public class BlockBOPFenceGate extends BlockFenceGate implements IBOPBlock
|
public class BlockBOPFenceGate extends BlockFenceGate implements IBOPBlock
|
||||||
{
|
{
|
||||||
|
|
||||||
// implement IDHBlock
|
// implement IBOPBlock
|
||||||
protected Map<String, IBlockState> namedStates = new HashMap<String, IBlockState>();
|
|
||||||
public Map<String, IBlockState> getNamedStates() {return this.namedStates;}
|
|
||||||
public IBlockState getNamedState(String name) {return this.namedStates.get(name);}
|
|
||||||
public Class<? extends ItemBlock> getItemClass() { return ItemBOPBlock.class; }
|
public Class<? extends ItemBlock> getItemClass() { return ItemBOPBlock.class; }
|
||||||
|
public int getItemRenderColor(IBlockState state, int tintIndex) { return this.getRenderColor(state); }
|
||||||
|
public IProperty[] getPresetProperties() { return new IProperty[] {}; }
|
||||||
|
public IProperty[] getRenderProperties() { return new IProperty[] {FACING, OPEN, IN_WALL}; }
|
||||||
|
public String getStateName(IBlockState state) {return "";}
|
||||||
|
|
||||||
|
|
||||||
public BlockBOPFenceGate()
|
public BlockBOPFenceGate()
|
||||||
{
|
{
|
||||||
|
|
|
@ -47,18 +47,20 @@ public class BlockBOPFlower1 extends BlockDecoration {
|
||||||
@Override
|
@Override
|
||||||
protected BlockState createBlockState() {return new BlockState(this, new IProperty[] { VARIANT });}
|
protected BlockState createBlockState() {return new BlockState(this, new IProperty[] { VARIANT });}
|
||||||
|
|
||||||
|
|
||||||
|
// implement IBOPBlock
|
||||||
|
public IProperty[] getPresetProperties() { return new IProperty[] {VARIANT}; }
|
||||||
|
public IProperty[] getRenderProperties() { return new IProperty[] {VARIANT}; }
|
||||||
|
public String getStateName(IBlockState state)
|
||||||
|
{
|
||||||
|
return ((FlowerType) state.getValue(VARIANT)).getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public BlockBOPFlower1()
|
public BlockBOPFlower1()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
|
this.setDefaultState( this.blockState.getBaseState().withProperty(VARIANT, FlowerType.CLOVER) );
|
||||||
// define named states
|
|
||||||
for(FlowerType flowerType : FlowerType.values())
|
|
||||||
{
|
|
||||||
this.namedStates.put(flowerType.getName(), this.blockState.getBaseState().withProperty(VARIANT, flowerType));
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setDefaultState(this.getNamedState("clover"));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -35,18 +35,20 @@ public class BlockBOPFlower2 extends BlockDecoration {
|
||||||
@Override
|
@Override
|
||||||
protected BlockState createBlockState() {return new BlockState(this, new IProperty[] { VARIANT });}
|
protected BlockState createBlockState() {return new BlockState(this, new IProperty[] { VARIANT });}
|
||||||
|
|
||||||
|
|
||||||
|
// implement IBOPBlock
|
||||||
|
public IProperty[] getPresetProperties() { return new IProperty[] {VARIANT}; }
|
||||||
|
public IProperty[] getRenderProperties() { return new IProperty[] {VARIANT}; }
|
||||||
|
public String getStateName(IBlockState state)
|
||||||
|
{
|
||||||
|
return ((FlowerType) state.getValue(VARIANT)).getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public BlockBOPFlower2()
|
public BlockBOPFlower2()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
|
this.setDefaultState( this.blockState.getBaseState().withProperty(VARIANT, FlowerType.LAVENDER) );
|
||||||
// define named states
|
|
||||||
for(FlowerType flowerType : FlowerType.values())
|
|
||||||
{
|
|
||||||
this.namedStates.put(flowerType.getName(), this.blockState.getBaseState().withProperty(VARIANT, flowerType));
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setDefaultState(this.getNamedState("lavender"));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,24 +8,24 @@
|
||||||
|
|
||||||
package biomesoplenty.common.block;
|
package biomesoplenty.common.block;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import biomesoplenty.api.block.IBOPBlock;
|
import biomesoplenty.api.block.IBOPBlock;
|
||||||
import biomesoplenty.common.item.ItemBOPBlock;
|
import biomesoplenty.common.item.ItemBOPBlock;
|
||||||
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.properties.IProperty;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.item.ItemBlock;
|
import net.minecraft.item.ItemBlock;
|
||||||
|
|
||||||
public class BlockBOPGeneric extends Block implements IBOPBlock
|
public class BlockBOPGeneric extends Block implements IBOPBlock
|
||||||
{
|
{
|
||||||
|
|
||||||
// implement IDHBlock
|
// implement IBOPBlock
|
||||||
protected Map<String, IBlockState> namedStates = new HashMap<String, IBlockState>();
|
|
||||||
public Map<String, IBlockState> getNamedStates() {return this.namedStates;}
|
|
||||||
public IBlockState getNamedState(String name) {return this.namedStates.get(name);}
|
|
||||||
public Class<? extends ItemBlock> getItemClass() { return ItemBOPBlock.class; }
|
public Class<? extends ItemBlock> getItemClass() { return ItemBOPBlock.class; }
|
||||||
|
public int getItemRenderColor(IBlockState state, int tintIndex) { return this.getRenderColor(state); }
|
||||||
|
public IProperty[] getPresetProperties() { return new IProperty[] {}; }
|
||||||
|
public IProperty[] getRenderProperties() { return new IProperty[] {}; }
|
||||||
|
public String getStateName(IBlockState state) {return "";}
|
||||||
|
|
||||||
|
|
||||||
public BlockBOPGeneric() {
|
public BlockBOPGeneric() {
|
||||||
// use rock as default material
|
// use rock as default material
|
||||||
|
|
|
@ -8,8 +8,6 @@
|
||||||
|
|
||||||
package biomesoplenty.common.block;
|
package biomesoplenty.common.block;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import biomesoplenty.api.block.BOPBlocks;
|
import biomesoplenty.api.block.BOPBlocks;
|
||||||
|
@ -47,13 +45,24 @@ public class BlockBOPGrass extends BlockGrass implements IBOPBlock
|
||||||
public static enum BOPGrassType implements IStringSerializable {SPECTRAL_MOSS, SMOLDERING, LOAMY, SANDY, SILTY, ORIGIN, OVERGROWN_NETHERRACK; public String getName() {return this.name().toLowerCase();}};
|
public static enum BOPGrassType implements IStringSerializable {SPECTRAL_MOSS, SMOLDERING, LOAMY, SANDY, SILTY, ORIGIN, OVERGROWN_NETHERRACK; public String getName() {return this.name().toLowerCase();}};
|
||||||
public static final PropertyEnum VARIANT = PropertyEnum.create("variant", BOPGrassType.class);
|
public static final PropertyEnum VARIANT = PropertyEnum.create("variant", BOPGrassType.class);
|
||||||
@Override
|
@Override
|
||||||
protected BlockState createBlockState() {return new BlockState(this, new IProperty[] { VARIANT, SNOWY });}
|
protected BlockState createBlockState() {return new BlockState(this, new IProperty[] { SNOWY, VARIANT });}
|
||||||
|
|
||||||
// implement IDHBlock
|
|
||||||
private Map<String, IBlockState> namedStates = new HashMap<String, IBlockState>();
|
// implement IBOPBlock
|
||||||
public Map<String, IBlockState> getNamedStates() {return this.namedStates;}
|
|
||||||
public IBlockState getNamedState(String name) {return this.namedStates.get(name);}
|
|
||||||
public Class<? extends ItemBlock> getItemClass() { return ItemBOPBlock.class; }
|
public Class<? extends ItemBlock> getItemClass() { return ItemBOPBlock.class; }
|
||||||
|
public int getItemRenderColor(IBlockState state, int tintIndex) { return this.getRenderColor(state); }
|
||||||
|
public IProperty[] getPresetProperties() { return new IProperty[] {VARIANT}; }
|
||||||
|
public IProperty[] getRenderProperties() { return new IProperty[] {SNOWY, VARIANT}; }
|
||||||
|
public String getStateName(IBlockState state) {
|
||||||
|
BOPGrassType grassType = (BOPGrassType)state.getValue(VARIANT);
|
||||||
|
switch (grassType)
|
||||||
|
{
|
||||||
|
case SPECTRAL_MOSS: case OVERGROWN_NETHERRACK:
|
||||||
|
return grassType.getName();
|
||||||
|
default:
|
||||||
|
return grassType.getName() + "_grass_block";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public BlockBOPGrass()
|
public BlockBOPGrass()
|
||||||
|
@ -64,17 +73,7 @@ public class BlockBOPGrass extends BlockGrass implements IBOPBlock
|
||||||
this.setHardness(0.6F);
|
this.setHardness(0.6F);
|
||||||
this.setHarvestLevel("shovel", 0); // TODO: I think this just determines which tool speeds up digging - need to investigate more
|
this.setHarvestLevel("shovel", 0); // TODO: I think this just determines which tool speeds up digging - need to investigate more
|
||||||
this.setStepSound(Block.soundTypeGrass);
|
this.setStepSound(Block.soundTypeGrass);
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(SNOWY, Boolean.valueOf(false)).withProperty(VARIANT, BOPGrassType.LOAMY));
|
||||||
// define named states
|
|
||||||
this.namedStates.put("spectral_moss", this.blockState.getBaseState().withProperty(SNOWY, Boolean.valueOf(false)).withProperty(VARIANT, BOPGrassType.SPECTRAL_MOSS) );
|
|
||||||
this.namedStates.put("smoldering_grass_block", this.blockState.getBaseState().withProperty(SNOWY, Boolean.valueOf(false)).withProperty(VARIANT, BOPGrassType.SMOLDERING) );
|
|
||||||
this.namedStates.put("loamy_grass_block", this.blockState.getBaseState().withProperty(SNOWY, Boolean.valueOf(false)).withProperty(VARIANT, BOPGrassType.LOAMY) );
|
|
||||||
this.namedStates.put("sandy_grass_block", this.blockState.getBaseState().withProperty(SNOWY, Boolean.valueOf(false)).withProperty(VARIANT, BOPGrassType.SANDY) );
|
|
||||||
this.namedStates.put("silty_grass_block", this.blockState.getBaseState().withProperty(SNOWY, Boolean.valueOf(false)).withProperty(VARIANT, BOPGrassType.SILTY) );
|
|
||||||
this.namedStates.put("origin_grass_block", this.blockState.getBaseState().withProperty(SNOWY, Boolean.valueOf(false)).withProperty(VARIANT, BOPGrassType.ORIGIN) );
|
|
||||||
this.namedStates.put("overgrown_netherrack", this.blockState.getBaseState().withProperty(SNOWY, Boolean.valueOf(false)).withProperty(VARIANT, BOPGrassType.OVERGROWN_NETHERRACK) );
|
|
||||||
|
|
||||||
this.setDefaultState(this.namedStates.get("loamy_grass_block"));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,9 +8,7 @@
|
||||||
|
|
||||||
package biomesoplenty.common.block;
|
package biomesoplenty.common.block;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import biomesoplenty.api.block.IBOPBlock;
|
import biomesoplenty.api.block.IBOPBlock;
|
||||||
|
@ -38,11 +36,13 @@ public class BlockBOPLeaves extends BlockLeaves implements IBOPBlock
|
||||||
@Override
|
@Override
|
||||||
protected BlockState createBlockState() {return new BlockState(this, new IProperty[] {CHECK_DECAY, DECAYABLE});}
|
protected BlockState createBlockState() {return new BlockState(this, new IProperty[] {CHECK_DECAY, DECAYABLE});}
|
||||||
|
|
||||||
// implement IDHBlock
|
// implement IBOPBlock
|
||||||
private Map<String, IBlockState> namedStates = new HashMap<String, IBlockState>();
|
|
||||||
public Map<String, IBlockState> getNamedStates() {return this.namedStates;}
|
|
||||||
public IBlockState getNamedState(String name) {return this.namedStates.get(name);}
|
|
||||||
public Class<? extends ItemBlock> getItemClass() { return ItemBOPBlock.class; }
|
public Class<? extends ItemBlock> getItemClass() { return ItemBOPBlock.class; }
|
||||||
|
public int getItemRenderColor(IBlockState state, int tintIndex) { return this.getRenderColor(state); }
|
||||||
|
public IProperty[] getPresetProperties() { return new IProperty[] {}; }
|
||||||
|
public IProperty[] getRenderProperties() { return new IProperty[] {}; }
|
||||||
|
public String getStateName(IBlockState state) {return "";}
|
||||||
|
|
||||||
|
|
||||||
private ItemStack sapling;
|
private ItemStack sapling;
|
||||||
private ItemStack fruit;
|
private ItemStack fruit;
|
||||||
|
|
|
@ -8,9 +8,6 @@
|
||||||
|
|
||||||
package biomesoplenty.common.block;
|
package biomesoplenty.common.block;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import biomesoplenty.api.block.IBOPBlock;
|
import biomesoplenty.api.block.IBOPBlock;
|
||||||
import biomesoplenty.common.item.ItemBOPLilypad;
|
import biomesoplenty.common.item.ItemBOPLilypad;
|
||||||
import net.minecraft.block.BlockLilyPad;
|
import net.minecraft.block.BlockLilyPad;
|
||||||
|
@ -31,23 +28,28 @@ public class BlockBOPLilypad extends BlockLilyPad implements IBOPBlock
|
||||||
@Override
|
@Override
|
||||||
protected BlockState createBlockState() {return new BlockState(this, new IProperty[] { VARIANT });}
|
protected BlockState createBlockState() {return new BlockState(this, new IProperty[] { VARIANT });}
|
||||||
|
|
||||||
// implement IDHBlock
|
|
||||||
private Map<String, IBlockState> namedStates = new HashMap<String, IBlockState>();
|
// implement IBOPBlock
|
||||||
public Map<String, IBlockState> getNamedStates() {return this.namedStates;}
|
|
||||||
public IBlockState getNamedState(String name) {return this.namedStates.get(name);}
|
|
||||||
// need to use a custom item class because of the unique way lilies are placed
|
// need to use a custom item class because of the unique way lilies are placed
|
||||||
public Class<? extends ItemBlock> getItemClass() { return ItemBOPLilypad.class; }
|
public Class<? extends ItemBlock> getItemClass() { return ItemBOPLilypad.class; }
|
||||||
|
public int getItemRenderColor(IBlockState state, int tintIndex) { return this.getRenderColor(state); }
|
||||||
|
public IProperty[] getPresetProperties() { return new IProperty[] {VARIANT}; }
|
||||||
|
public IProperty[] getRenderProperties() { return new IProperty[] {VARIANT}; }
|
||||||
|
public String getStateName(IBlockState state) {
|
||||||
|
LilypadType type = (LilypadType) state.getValue(VARIANT);
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case DUCKWEED:
|
||||||
|
return type.getName();
|
||||||
|
default:
|
||||||
|
return "lily_"+type.getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public BlockBOPLilypad()
|
public BlockBOPLilypad()
|
||||||
{
|
{
|
||||||
// define named states
|
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT, LilypadType.MEDIUM));
|
||||||
this.namedStates.put("lily_medium", this.blockState.getBaseState().withProperty(VARIANT, LilypadType.MEDIUM) );
|
|
||||||
this.namedStates.put("lily_small", this.blockState.getBaseState().withProperty(VARIANT, LilypadType.SMALL) );
|
|
||||||
this.namedStates.put("lily_tiny", this.blockState.getBaseState().withProperty(VARIANT, LilypadType.TINY) );
|
|
||||||
this.namedStates.put("duckweed", this.blockState.getBaseState().withProperty(VARIANT, LilypadType.DUCKWEED) );
|
|
||||||
|
|
||||||
this.setDefaultState(this.namedStates.get("lily_medium"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -8,9 +8,6 @@
|
||||||
|
|
||||||
package biomesoplenty.common.block;
|
package biomesoplenty.common.block;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import biomesoplenty.api.block.IBOPBlock;
|
import biomesoplenty.api.block.IBOPBlock;
|
||||||
import biomesoplenty.common.item.ItemBOPBlock;
|
import biomesoplenty.common.item.ItemBOPBlock;
|
||||||
import net.minecraft.block.BlockLog;
|
import net.minecraft.block.BlockLog;
|
||||||
|
@ -26,11 +23,14 @@ public class BlockBOPLog extends BlockLog implements IBOPBlock
|
||||||
@Override
|
@Override
|
||||||
protected BlockState createBlockState() {return new BlockState(this, new IProperty[] { LOG_AXIS });}
|
protected BlockState createBlockState() {return new BlockState(this, new IProperty[] { LOG_AXIS });}
|
||||||
|
|
||||||
// implement IDHBlock
|
|
||||||
protected Map<String, IBlockState> namedStates = new HashMap<String, IBlockState>();
|
// implement IBOPBlock
|
||||||
public Map<String, IBlockState> getNamedStates() {return this.namedStates;}
|
|
||||||
public IBlockState getNamedState(String name) {return this.namedStates.get(name);}
|
|
||||||
public Class<? extends ItemBlock> getItemClass() { return ItemBOPBlock.class; }
|
public Class<? extends ItemBlock> getItemClass() { return ItemBOPBlock.class; }
|
||||||
|
public int getItemRenderColor(IBlockState state, int tintIndex) { return this.getRenderColor(state); }
|
||||||
|
public IProperty[] getPresetProperties() { return new IProperty[] {}; }
|
||||||
|
public IProperty[] getRenderProperties() { return new IProperty[] {LOG_AXIS}; }
|
||||||
|
public String getStateName(IBlockState state) {return "";}
|
||||||
|
|
||||||
|
|
||||||
public BlockBOPLog()
|
public BlockBOPLog()
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,12 +9,14 @@
|
||||||
package biomesoplenty.common.block;
|
package biomesoplenty.common.block;
|
||||||
|
|
||||||
import biomesoplenty.api.block.BOPBlocks;
|
import biomesoplenty.api.block.BOPBlocks;
|
||||||
|
import biomesoplenty.common.item.ItemBOPBlock;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.properties.IProperty;
|
import net.minecraft.block.properties.IProperty;
|
||||||
import net.minecraft.block.properties.PropertyEnum;
|
import net.minecraft.block.properties.PropertyEnum;
|
||||||
import net.minecraft.block.state.BlockState;
|
import net.minecraft.block.state.BlockState;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
|
import net.minecraft.item.ItemBlock;
|
||||||
import net.minecraft.util.BlockPos;
|
import net.minecraft.util.BlockPos;
|
||||||
import net.minecraft.util.IStringSerializable;
|
import net.minecraft.util.IStringSerializable;
|
||||||
import net.minecraft.world.IBlockAccess;
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
@ -32,20 +34,22 @@ public class BlockBOPMushroom extends BlockDecoration
|
||||||
protected BlockState createBlockState() {return new BlockState(this, new IProperty[] { VARIANT });}
|
protected BlockState createBlockState() {return new BlockState(this, new IProperty[] { VARIANT });}
|
||||||
|
|
||||||
|
|
||||||
|
// implement IBOPBlock
|
||||||
|
public Class<? extends ItemBlock> getItemClass() { return ItemBOPBlock.class; }
|
||||||
|
public int getItemRenderColor(IBlockState state, int tintIndex) { return this.getRenderColor(state); }
|
||||||
|
public IProperty[] getPresetProperties() { return new IProperty[] {VARIANT}; }
|
||||||
|
public IProperty[] getRenderProperties() { return new IProperty[] {VARIANT}; }
|
||||||
|
public String getStateName(IBlockState state)
|
||||||
|
{
|
||||||
|
return ((MushroomType) state.getValue(VARIANT)).getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public BlockBOPMushroom()
|
public BlockBOPMushroom()
|
||||||
{
|
{
|
||||||
// set some defaults
|
// set some defaults
|
||||||
this.setBlockBoundsByRadiusAndHeight(0.2F, 0.4F);
|
this.setBlockBoundsByRadiusAndHeight(0.2F, 0.4F);
|
||||||
|
this.setDefaultState( this.blockState.getBaseState().withProperty(VARIANT, MushroomType.TOADSTOOL) );
|
||||||
// define named states
|
|
||||||
this.namedStates.put("toadstool", this.blockState.getBaseState().withProperty(VARIANT, MushroomType.TOADSTOOL));
|
|
||||||
this.namedStates.put("portobello", this.blockState.getBaseState().withProperty(VARIANT, MushroomType.PORTOBELLO));
|
|
||||||
this.namedStates.put("blue_milk_cap", this.blockState.getBaseState().withProperty(VARIANT, MushroomType.BLUE_MILK_CAP));
|
|
||||||
this.namedStates.put("glowshroom", this.blockState.getBaseState().withProperty(VARIANT, MushroomType.GLOWSHROOM));
|
|
||||||
this.namedStates.put("flat_mushroom", this.blockState.getBaseState().withProperty(VARIANT, MushroomType.FLAT_MUSHROOM));
|
|
||||||
this.namedStates.put("shadow_shroom", this.blockState.getBaseState().withProperty(VARIANT, MushroomType.SHADOW_SHROOM));
|
|
||||||
|
|
||||||
this.setDefaultState(this.namedStates.get("toadstool"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// map from state to meta and vice verca
|
// map from state to meta and vice verca
|
||||||
|
@ -94,7 +98,6 @@ public class BlockBOPMushroom extends BlockDecoration
|
||||||
boolean onStone = (groundBlock == Blocks.stone || groundBlock == BOPBlocks.stone); // TODO: hard dirt too? the other edge cases?
|
boolean onStone = (groundBlock == Blocks.stone || groundBlock == BOPBlocks.stone); // TODO: hard dirt too? the other edge cases?
|
||||||
boolean onEndstone = (groundBlock == Blocks.end_stone);
|
boolean onEndstone = (groundBlock == Blocks.end_stone);
|
||||||
|
|
||||||
//System.out.println("ground block is " + BlockStateUtils.getStateInfoAsString(groundState));
|
|
||||||
if (groundBlock instanceof BlockBOPGrass)
|
if (groundBlock instanceof BlockBOPGrass)
|
||||||
{
|
{
|
||||||
switch ((BlockBOPGrass.BOPGrassType) groundState.getValue(BlockBOPGrass.VARIANT))
|
switch ((BlockBOPGrass.BOPGrassType) groundState.getValue(BlockBOPGrass.VARIANT))
|
||||||
|
|
|
@ -8,23 +8,23 @@
|
||||||
|
|
||||||
package biomesoplenty.common.block;
|
package biomesoplenty.common.block;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import biomesoplenty.api.block.IBOPBlock;
|
import biomesoplenty.api.block.IBOPBlock;
|
||||||
import biomesoplenty.common.item.ItemBOPBlock;
|
import biomesoplenty.common.item.ItemBOPBlock;
|
||||||
import net.minecraft.block.BlockStairs;
|
import net.minecraft.block.BlockStairs;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.item.ItemBlock;
|
import net.minecraft.item.ItemBlock;
|
||||||
|
|
||||||
public class BlockBOPStairs extends BlockStairs implements IBOPBlock
|
public class BlockBOPStairs extends BlockStairs implements IBOPBlock
|
||||||
{
|
{
|
||||||
|
|
||||||
// implement IDHBlock
|
// implement IBOPBlock
|
||||||
protected Map<String, IBlockState> namedStates = new HashMap<String, IBlockState>();
|
|
||||||
public Map<String, IBlockState> getNamedStates() {return this.namedStates;}
|
|
||||||
public IBlockState getNamedState(String name) {return this.namedStates.get(name);}
|
|
||||||
public Class<? extends ItemBlock> getItemClass() { return ItemBOPBlock.class; }
|
public Class<? extends ItemBlock> getItemClass() { return ItemBOPBlock.class; }
|
||||||
|
public int getItemRenderColor(IBlockState state, int tintIndex) { return this.getRenderColor(state); }
|
||||||
|
public IProperty[] getPresetProperties() { return new IProperty[] {}; }
|
||||||
|
public IProperty[] getRenderProperties() { return new IProperty[] {FACING, HALF, SHAPE}; }
|
||||||
|
public String getStateName(IBlockState state) {return "";}
|
||||||
|
|
||||||
|
|
||||||
public BlockBOPStairs(IBlockState modelState)
|
public BlockBOPStairs(IBlockState modelState)
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,9 +8,6 @@
|
||||||
|
|
||||||
package biomesoplenty.common.block;
|
package biomesoplenty.common.block;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import biomesoplenty.api.block.IBOPBlock;
|
import biomesoplenty.api.block.IBOPBlock;
|
||||||
import biomesoplenty.common.item.ItemBOPBlock;
|
import biomesoplenty.common.item.ItemBOPBlock;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
@ -37,11 +34,17 @@ public class BlockBOPStone extends Block implements IBOPBlock
|
||||||
@Override
|
@Override
|
||||||
protected BlockState createBlockState() {return new BlockState(this, new IProperty[] { VARIANT, POLISHED });}
|
protected BlockState createBlockState() {return new BlockState(this, new IProperty[] { VARIANT, POLISHED });}
|
||||||
|
|
||||||
// implement IDHBlock
|
|
||||||
private Map<String, IBlockState> namedStates = new HashMap<String, IBlockState>();
|
// implement IBOPBlock
|
||||||
public Map<String, IBlockState> getNamedStates() {return this.namedStates;}
|
|
||||||
public IBlockState getNamedState(String name) {return this.namedStates.get(name);}
|
|
||||||
public Class<? extends ItemBlock> getItemClass() { return ItemBOPBlock.class; }
|
public Class<? extends ItemBlock> getItemClass() { return ItemBOPBlock.class; }
|
||||||
|
public int getItemRenderColor(IBlockState state, int tintIndex) { return this.getRenderColor(state); }
|
||||||
|
public IProperty[] getPresetProperties() { return new IProperty[] {VARIANT, POLISHED}; }
|
||||||
|
public IProperty[] getRenderProperties() { return new IProperty[] {VARIANT, POLISHED}; }
|
||||||
|
public String getStateName(IBlockState state)
|
||||||
|
{
|
||||||
|
return (Boolean.TRUE.equals(state.getValue(POLISHED)) ? "polished_" : "") + ((StoneType) state.getValue(VARIANT)).getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public BlockBOPStone()
|
public BlockBOPStone()
|
||||||
{
|
{
|
||||||
|
@ -49,20 +52,10 @@ public class BlockBOPStone extends Block implements IBOPBlock
|
||||||
|
|
||||||
// set some defaults
|
// set some defaults
|
||||||
this.setStepSound(Block.soundTypeStone);
|
this.setStepSound(Block.soundTypeStone);
|
||||||
|
|
||||||
this.setHarvestLevel("pickaxe", 1, this.getDefaultState().withProperty(VARIANT, StoneType.LIMESTONE));
|
this.setHarvestLevel("pickaxe", 1, this.getDefaultState().withProperty(VARIANT, StoneType.LIMESTONE));
|
||||||
this.setHarvestLevel("pickaxe", 2, this.getDefaultState().withProperty(VARIANT, StoneType.SILTSTONE));
|
this.setHarvestLevel("pickaxe", 2, this.getDefaultState().withProperty(VARIANT, StoneType.SILTSTONE));
|
||||||
this.setHarvestLevel("pickaxe", 3, this.getDefaultState().withProperty(VARIANT, StoneType.SHALE));
|
this.setHarvestLevel("pickaxe", 3, this.getDefaultState().withProperty(VARIANT, StoneType.SHALE));
|
||||||
|
this.setDefaultState( this.blockState.getBaseState().withProperty(VARIANT, StoneType.LIMESTONE).withProperty(POLISHED, Boolean.valueOf(false)) );
|
||||||
// define named states
|
|
||||||
this.namedStates.put("limestone", this.blockState.getBaseState().withProperty(VARIANT, StoneType.LIMESTONE).withProperty(POLISHED, Boolean.valueOf(false)) );
|
|
||||||
this.namedStates.put("siltstone", this.blockState.getBaseState().withProperty(VARIANT, StoneType.SILTSTONE).withProperty(POLISHED, Boolean.valueOf(false)) );
|
|
||||||
this.namedStates.put("shale", this.blockState.getBaseState().withProperty(VARIANT, StoneType.SHALE).withProperty(POLISHED, Boolean.valueOf(false)) );
|
|
||||||
this.namedStates.put("polished_limestone", this.blockState.getBaseState().withProperty(VARIANT, StoneType.LIMESTONE).withProperty(POLISHED, Boolean.valueOf(true)) );
|
|
||||||
this.namedStates.put("polished_siltstone", this.blockState.getBaseState().withProperty(VARIANT, StoneType.SILTSTONE).withProperty(POLISHED, Boolean.valueOf(true)) );
|
|
||||||
this.namedStates.put("polished_shale", this.blockState.getBaseState().withProperty(VARIANT, StoneType.SHALE).withProperty(POLISHED, Boolean.valueOf(true)) );
|
|
||||||
|
|
||||||
this.setDefaultState(this.namedStates.get("limestone"));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,12 +8,10 @@
|
||||||
|
|
||||||
package biomesoplenty.common.block;
|
package biomesoplenty.common.block;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import biomesoplenty.api.block.IBOPBlock;
|
import biomesoplenty.api.block.IBOPBlock;
|
||||||
import biomesoplenty.common.item.ItemBOPBlock;
|
import biomesoplenty.common.item.ItemBOPBlock;
|
||||||
import net.minecraft.block.BlockVine;
|
import net.minecraft.block.BlockVine;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.item.ItemBlock;
|
import net.minecraft.item.ItemBlock;
|
||||||
import net.minecraft.util.BlockPos;
|
import net.minecraft.util.BlockPos;
|
||||||
|
@ -23,11 +21,14 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
public class BlockBOPVine extends BlockVine implements IBOPBlock
|
public class BlockBOPVine extends BlockVine implements IBOPBlock
|
||||||
{
|
{
|
||||||
// implement IDHBlock
|
|
||||||
protected Map<String, IBlockState> namedStates = new HashMap<String, IBlockState>();
|
// implement IBOPBlock
|
||||||
public Map<String, IBlockState> getNamedStates() {return this.namedStates;}
|
|
||||||
public IBlockState getNamedState(String name) {return this.namedStates.get(name);}
|
|
||||||
public Class<? extends ItemBlock> getItemClass() { return ItemBOPBlock.class; }
|
public Class<? extends ItemBlock> getItemClass() { return ItemBOPBlock.class; }
|
||||||
|
public int getItemRenderColor(IBlockState state, int tintIndex) { return this.getRenderColor(state); }
|
||||||
|
public IProperty[] getPresetProperties() { return new IProperty[] {}; }
|
||||||
|
public IProperty[] getRenderProperties() { return new IProperty[] {UP, NORTH, EAST, SOUTH, WEST}; }
|
||||||
|
public String getStateName(IBlockState state) {return "";}
|
||||||
|
|
||||||
|
|
||||||
// if set to true, (the default), use BlockVine getBlockColor(), getRenderColor() and colorMultiplier() functions to color the texture based on biome
|
// if set to true, (the default), use BlockVine getBlockColor(), getRenderColor() and colorMultiplier() functions to color the texture based on biome
|
||||||
// if set to false, use 0xFFFFFF for all the color functions so that the texture is used as it is
|
// if set to false, use 0xFFFFFF for all the color functions so that the texture is used as it is
|
||||||
|
|
|
@ -29,6 +29,7 @@ public class BlockBamboo extends BlockDecoration
|
||||||
@Override
|
@Override
|
||||||
protected BlockState createBlockState() {return new BlockState(this, new IProperty[] { AGE });}
|
protected BlockState createBlockState() {return new BlockState(this, new IProperty[] { AGE });}
|
||||||
|
|
||||||
|
|
||||||
public BlockBamboo()
|
public BlockBamboo()
|
||||||
{
|
{
|
||||||
this.setHardness(0.2F);
|
this.setHardness(0.2F);
|
||||||
|
@ -96,7 +97,6 @@ public class BlockBamboo extends BlockDecoration
|
||||||
int age = ((Integer)state.getValue(AGE)).intValue();
|
int age = ((Integer)state.getValue(AGE)).intValue();
|
||||||
int treeHeight = 1;
|
int treeHeight = 1;
|
||||||
while (worldIn.getBlockState(pos.down(treeHeight)).getBlock() == this) {++treeHeight;}
|
while (worldIn.getBlockState(pos.down(treeHeight)).getBlock() == this) {++treeHeight;}
|
||||||
//System.out.println("Banboo age: "+age+" tree height: "+treeHeight);
|
|
||||||
|
|
||||||
if (treeHeight < 4)
|
if (treeHeight < 4)
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,9 +8,6 @@
|
||||||
|
|
||||||
package biomesoplenty.common.block;
|
package biomesoplenty.common.block;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
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.properties.IProperty;
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
@ -40,12 +37,15 @@ public class BlockBones extends Block implements IBOPBlock
|
||||||
@Override
|
@Override
|
||||||
protected BlockState createBlockState() {return new BlockState(this, new IProperty[] { AXIS, VARIANT });}
|
protected BlockState createBlockState() {return new BlockState(this, new IProperty[] { AXIS, VARIANT });}
|
||||||
|
|
||||||
// implement IDHBlock
|
// implement IBOPBlock
|
||||||
private Map<String, IBlockState> namedStates = new HashMap<String, IBlockState>();
|
|
||||||
public Map<String, IBlockState> getNamedStates() {return this.namedStates;}
|
|
||||||
public IBlockState getNamedState(String name) {return this.namedStates.get(name);}
|
|
||||||
public Class<? extends ItemBlock> getItemClass() { return ItemBOPBlock.class; }
|
public Class<? extends ItemBlock> getItemClass() { return ItemBOPBlock.class; }
|
||||||
|
public int getItemRenderColor(IBlockState state, int tintIndex) { return this.getRenderColor(state); }
|
||||||
|
public IProperty[] getPresetProperties() { return new IProperty[] {VARIANT}; }
|
||||||
|
public IProperty[] getRenderProperties() { return new IProperty[] {AXIS, VARIANT}; }
|
||||||
|
public String getStateName(IBlockState state)
|
||||||
|
{
|
||||||
|
return ((BoneType) state.getValue(VARIANT)).getName() + "_bone_segment";
|
||||||
|
}
|
||||||
|
|
||||||
public BlockBones()
|
public BlockBones()
|
||||||
{
|
{
|
||||||
|
@ -56,13 +56,7 @@ public class BlockBones extends Block implements IBOPBlock
|
||||||
this.setResistance(5.0F);
|
this.setResistance(5.0F);
|
||||||
this.setStepSound(Block.soundTypeStone);
|
this.setStepSound(Block.soundTypeStone);
|
||||||
|
|
||||||
// define named states
|
this.setDefaultState(this.blockState.getBaseState().withProperty(AXIS, EnumFacing.Axis.Y).withProperty(VARIANT, BoneType.LARGE));
|
||||||
this.namedStates.put("small_bone_segment", this.blockState.getBaseState().withProperty(AXIS, EnumFacing.Axis.Y).withProperty(VARIANT, BoneType.SMALL));
|
|
||||||
this.namedStates.put("medium_bone_segment", this.blockState.getBaseState().withProperty(AXIS, EnumFacing.Axis.Y).withProperty(VARIANT, BoneType.MEDIUM));
|
|
||||||
this.namedStates.put("large_bone_segment", this.blockState.getBaseState().withProperty(AXIS, EnumFacing.Axis.Y).withProperty(VARIANT, BoneType.LARGE));
|
|
||||||
|
|
||||||
this.setDefaultState(this.namedStates.get("large_bone_segment"));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,22 @@ public class BlockCoral extends BlockDecoration
|
||||||
@Override
|
@Override
|
||||||
protected BlockState createBlockState() {return new BlockState(this, new IProperty[] { LEVEL, VARIANT });}
|
protected BlockState createBlockState() {return new BlockState(this, new IProperty[] { LEVEL, VARIANT });}
|
||||||
|
|
||||||
|
// implement IBOPBlock
|
||||||
|
public IProperty[] getPresetProperties() { return new IProperty[] {VARIANT}; }
|
||||||
|
public IProperty[] getRenderProperties() { return new IProperty[] {VARIANT}; }
|
||||||
|
public String getStateName(IBlockState state)
|
||||||
|
{
|
||||||
|
CoralType type = (CoralType) state.getValue(VARIANT);
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case ALGAE:
|
||||||
|
return type.getName();
|
||||||
|
default:
|
||||||
|
return type.getName()+"_coral";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public BlockCoral()
|
public BlockCoral()
|
||||||
{
|
{
|
||||||
super(Material.water);
|
super(Material.water);
|
||||||
|
@ -42,15 +58,7 @@ public class BlockCoral extends BlockDecoration
|
||||||
this.setHardness(0.6F);
|
this.setHardness(0.6F);
|
||||||
this.setStepSound(Block.soundTypeSand);
|
this.setStepSound(Block.soundTypeSand);
|
||||||
this.setBlockBoundsByRadiusAndHeight(0.4F, 0.8F);
|
this.setBlockBoundsByRadiusAndHeight(0.4F, 0.8F);
|
||||||
|
this.setDefaultState( this.blockState.getBaseState().withProperty(LEVEL, 15).withProperty(VARIANT, CoralType.PINK) );
|
||||||
// define named states
|
|
||||||
this.namedStates.put("pink_coral", this.blockState.getBaseState().withProperty(LEVEL, 15).withProperty(VARIANT, CoralType.PINK) );
|
|
||||||
this.namedStates.put("orange_coral", this.blockState.getBaseState().withProperty(LEVEL, 15).withProperty(VARIANT, CoralType.ORANGE) );
|
|
||||||
this.namedStates.put("blue_coral", this.blockState.getBaseState().withProperty(LEVEL, 15).withProperty(VARIANT, CoralType.BLUE) );
|
|
||||||
this.namedStates.put("glowing_coral", this.blockState.getBaseState().withProperty(LEVEL, 15).withProperty(VARIANT, CoralType.GLOWING) );
|
|
||||||
this.namedStates.put("algae", this.blockState.getBaseState().withProperty(LEVEL, 15).withProperty(VARIANT, CoralType.ALGAE) );
|
|
||||||
|
|
||||||
this.setDefaultState(this.namedStates.get("pink_coral"));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,6 @@
|
||||||
|
|
||||||
package biomesoplenty.common.block;
|
package biomesoplenty.common.block;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import biomesoplenty.api.block.IBOPBlock;
|
import biomesoplenty.api.block.IBOPBlock;
|
||||||
|
@ -17,6 +15,7 @@ import biomesoplenty.api.item.BOPItems;
|
||||||
import biomesoplenty.common.item.ItemBOPBlock;
|
import biomesoplenty.common.item.ItemBOPBlock;
|
||||||
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.properties.IProperty;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemBlock;
|
import net.minecraft.item.ItemBlock;
|
||||||
|
@ -24,11 +23,13 @@ import net.minecraft.item.ItemBlock;
|
||||||
public class BlockCrystal extends Block implements IBOPBlock
|
public class BlockCrystal extends Block implements IBOPBlock
|
||||||
{
|
{
|
||||||
|
|
||||||
// implement IDHBlock
|
// implement IBOPBlock
|
||||||
protected Map<String, IBlockState> namedStates = new HashMap<String, IBlockState>();
|
|
||||||
public Map<String, IBlockState> getNamedStates() {return this.namedStates;}
|
|
||||||
public IBlockState getNamedState(String name) {return this.namedStates.get(name);}
|
|
||||||
public Class<? extends ItemBlock> getItemClass() { return ItemBOPBlock.class; }
|
public Class<? extends ItemBlock> getItemClass() { return ItemBOPBlock.class; }
|
||||||
|
public int getItemRenderColor(IBlockState state, int tintIndex) { return this.getRenderColor(state); }
|
||||||
|
public IProperty[] getPresetProperties() { return new IProperty[] {}; }
|
||||||
|
public IProperty[] getRenderProperties() { return new IProperty[] {}; }
|
||||||
|
public String getStateName(IBlockState state) {return "";}
|
||||||
|
|
||||||
|
|
||||||
public BlockCrystal() {
|
public BlockCrystal() {
|
||||||
super(Material.glass);
|
super(Material.glass);
|
||||||
|
|
|
@ -8,12 +8,11 @@
|
||||||
|
|
||||||
package biomesoplenty.common.block;
|
package biomesoplenty.common.block;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
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.properties.IProperty;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.item.ItemBlock;
|
import net.minecraft.item.ItemBlock;
|
||||||
|
@ -31,11 +30,13 @@ import biomesoplenty.common.item.ItemBOPBlock;
|
||||||
public class BlockDecoration extends Block implements IBOPBlock
|
public class BlockDecoration extends Block implements IBOPBlock
|
||||||
{
|
{
|
||||||
|
|
||||||
// implement IDHBlock
|
// implement IBOPBlock
|
||||||
protected Map<String, IBlockState> namedStates = new HashMap<String, IBlockState>();
|
|
||||||
public Map<String, IBlockState> getNamedStates() {return this.namedStates;}
|
|
||||||
public IBlockState getNamedState(String name) {return this.namedStates.get(name);}
|
|
||||||
public Class<? extends ItemBlock> getItemClass() { return ItemBOPBlock.class; }
|
public Class<? extends ItemBlock> getItemClass() { return ItemBOPBlock.class; }
|
||||||
|
public int getItemRenderColor(IBlockState state, int tintIndex) { return this.getRenderColor(state); }
|
||||||
|
public IProperty[] getPresetProperties() { return new IProperty[] {}; }
|
||||||
|
public IProperty[] getRenderProperties() { return new IProperty[] {}; }
|
||||||
|
public String getStateName(IBlockState state) {return "";}
|
||||||
|
|
||||||
|
|
||||||
// constructor
|
// constructor
|
||||||
public BlockDecoration() {
|
public BlockDecoration() {
|
||||||
|
@ -55,21 +56,20 @@ public class BlockDecoration extends Block implements IBOPBlock
|
||||||
}
|
}
|
||||||
|
|
||||||
// utility function for setting the block bounds - typically decoration blocks are smaller than full block size
|
// utility function for setting the block bounds - typically decoration blocks are smaller than full block size
|
||||||
public BlockDecoration setBlockBoundsByRadiusAndHeight(float radius, float height)
|
public void setBlockBoundsByRadiusAndHeight(float radius, float height)
|
||||||
{
|
{
|
||||||
return this.setBlockBoundsByRadiusAndHeight(radius,height,false);
|
this.setBlockBoundsByRadiusAndHeight(radius,height,false);
|
||||||
}
|
}
|
||||||
public BlockDecoration setBlockBoundsByRadiusAndHeight(float radius, float height, boolean fromTop)
|
public void setBlockBoundsByRadiusAndHeight(float radius, float height, boolean fromTop)
|
||||||
{
|
{
|
||||||
this.setBlockBounds(0.5F - radius, (fromTop ? 1.0F - height : 0.0F), 0.5F - radius, 0.5F + radius, (fromTop ? 1.0F : height), 0.5F + radius);
|
this.setBlockBounds(0.5F - radius, (fromTop ? 1.0F - height : 0.0F), 0.5F - radius, 0.5F + radius, (fromTop ? 1.0F : height), 0.5F + radius);
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// add a canBlockStay() check before placing this block
|
// add a canBlockStay() check before placing this block
|
||||||
@Override
|
@Override
|
||||||
public boolean canReplace(World world, BlockPos pos, EnumFacing side, ItemStack stack)
|
public boolean canReplace(World world, BlockPos pos, EnumFacing side, ItemStack stack)
|
||||||
{
|
{
|
||||||
return super.canReplace(world, pos, side, stack) && this.canBlockStay(world, pos, this.getStateFromMeta(stack.getMetadata()));
|
return world.getBlockState(pos).getBlock().isReplaceable(world, pos) && this.canBlockStay(world, pos, this.getStateFromMeta(stack.getMetadata()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// check this block is still able to remain after neighbor change
|
// check this block is still able to remain after neighbor change
|
||||||
|
|
|
@ -0,0 +1,231 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright 2014, the Biomes O' Plenty Team
|
||||||
|
*
|
||||||
|
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License.
|
||||||
|
*
|
||||||
|
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
package biomesoplenty.common.block;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
import net.minecraft.block.properties.PropertyEnum;
|
||||||
|
import net.minecraft.block.state.BlockState;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.IStringSerializable;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
class BlockDoubleDecoration extends BlockDecoration {
|
||||||
|
|
||||||
|
// add half property
|
||||||
|
public static enum Half implements IStringSerializable {LOWER, UPPER; public String getName() {return this.name().toLowerCase();}};
|
||||||
|
public static final PropertyEnum HALF = PropertyEnum.create("half", Half.class);
|
||||||
|
protected BlockState createBlockState() {return new BlockState(this, new IProperty[] { HALF });}
|
||||||
|
|
||||||
|
public IProperty[] getRenderProperties() { return new IProperty[] {HALF}; }
|
||||||
|
|
||||||
|
public float radius;
|
||||||
|
public float height;
|
||||||
|
public boolean fromTop;
|
||||||
|
|
||||||
|
public BlockDoubleDecoration()
|
||||||
|
{
|
||||||
|
this(Material.plants);
|
||||||
|
}
|
||||||
|
public BlockDoubleDecoration(Material material)
|
||||||
|
{
|
||||||
|
super(material);
|
||||||
|
this.radius = 0.5F;
|
||||||
|
this.height = 1.0F;
|
||||||
|
this.fromTop = false;
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(HALF, Half.LOWER));
|
||||||
|
}
|
||||||
|
|
||||||
|
// map from state to meta and vice verca
|
||||||
|
@Override
|
||||||
|
public IBlockState getStateFromMeta(int meta)
|
||||||
|
{
|
||||||
|
return this.getDefaultState().withProperty(HALF, Half.values()[meta]);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
return ((Half) state.getValue(HALF)).ordinal();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// utility functions
|
||||||
|
public BlockPos getLowerPos(IBlockAccess world, BlockPos pos)
|
||||||
|
{
|
||||||
|
IBlockState state = world.getBlockState(pos);
|
||||||
|
if (state.getBlock() != this) {return pos;}
|
||||||
|
return world.getBlockState(pos).getValue(HALF) == Half.UPPER ? pos.down() : pos;
|
||||||
|
}
|
||||||
|
public BlockPos getUpperPos(IBlockAccess world, BlockPos pos)
|
||||||
|
{
|
||||||
|
IBlockState state = world.getBlockState(pos);
|
||||||
|
if (state.getBlock() != this) {return pos.up();}
|
||||||
|
return world.getBlockState(pos).getValue(HALF) == Half.UPPER ? pos : pos.up();
|
||||||
|
}
|
||||||
|
public IBlockState getLowerState(IBlockAccess world, BlockPos pos)
|
||||||
|
{
|
||||||
|
return world.getBlockState(this.getLowerPos(world, pos));
|
||||||
|
}
|
||||||
|
public IBlockState getUpperState(IBlockAccess world, BlockPos pos)
|
||||||
|
{
|
||||||
|
return world.getBlockState(this.getUpperPos(world, pos));
|
||||||
|
}
|
||||||
|
public boolean isValidDoubleBlock(IBlockAccess world, BlockPos pos)
|
||||||
|
{
|
||||||
|
IBlockState lowerState = this.getLowerState(world, pos);
|
||||||
|
IBlockState upperState = this.getUpperState(world, pos);
|
||||||
|
return lowerState.getBlock() == this && lowerState.getValue(HALF) == Half.LOWER && upperState.getBlock() == this && upperState.getValue(HALF) == Half.UPPER;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// drop block as item if it cannot remain here - return whether on not it could stay
|
||||||
|
@Override
|
||||||
|
protected boolean checkAndDropBlock(World worldIn, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
if (this.isValidDoubleBlock(worldIn, pos) && this.canBlockStay(worldIn, this.getLowerPos(worldIn, pos), state))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.dropBlockAsItem(worldIn, pos, state, 0);
|
||||||
|
worldIn.setBlockState(pos, Blocks.air.getDefaultState(), 3);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// This DoubleDecoration can replace the block at pos if both the block and the one above it are replaceable and the environment is suitable (canBlockStay)
|
||||||
|
@Override
|
||||||
|
public boolean canReplace(World world, BlockPos pos, EnumFacing side, ItemStack stack)
|
||||||
|
{
|
||||||
|
return world.getBlockState(pos).getBlock().isReplaceable(world, pos) && world.getBlockState(pos.up()).getBlock().isReplaceable(world, pos.up()) && this.canBlockStay(world, pos, this.getStateFromMeta(stack.getMetadata()));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called by ItemBlock before the block is placed - the placed block must always be Half.LOWER
|
||||||
|
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
|
||||||
|
{
|
||||||
|
return this.getStateFromMeta(meta).withProperty(HALF, Half.LOWER);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called by ItemBlock after the (lower) block has been placed
|
||||||
|
// Use it to add the top half of the block
|
||||||
|
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
|
||||||
|
worldIn.setBlockState(pos.up(), this.getStateFromMeta(stack.getMetadata()).withProperty(HALF, Half.UPPER), 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
// child classes should put code in here which checks the ground is ok
|
||||||
|
public boolean canBlockStay(World world, BlockPos lowerPos, IBlockState state)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
// utility function for setting the block bounds -
|
||||||
|
public void setBlockBoundsByRadiusAndHeight(float radius, float height, boolean fromTop)
|
||||||
|
{
|
||||||
|
this.radius = radius;
|
||||||
|
this.height = height;
|
||||||
|
this.fromTop = fromTop;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
IBlockState state = worldIn.getBlockState(pos);
|
||||||
|
switch ((Half) state.getValue(HALF))
|
||||||
|
{
|
||||||
|
case LOWER:
|
||||||
|
super.setBlockBoundsByRadiusAndHeight(this.radius, this.fromTop ? this.height : 1.0F, this.fromTop);
|
||||||
|
break;
|
||||||
|
case UPPER:
|
||||||
|
super.setBlockBoundsByRadiusAndHeight(this.radius, this.fromTop ? 1.0F : this.height, this.fromTop);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// handle drops from UPPER and LOWER separately
|
||||||
|
@Override
|
||||||
|
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune)
|
||||||
|
{
|
||||||
|
if (state.getValue(HALF) == Half.UPPER)
|
||||||
|
{
|
||||||
|
return this.getUpperDrops(world, this.getUpperPos(world, pos), this.getUpperState(world, pos), fortune);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return this.getLowerDrops(world, this.getLowerPos(world, pos), this.getLowerState(world, pos), fortune);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// default behavior is that UPPER drops nothing, and LOWER drops the default item
|
||||||
|
public List<ItemStack> getUpperDrops(IBlockAccess world, BlockPos upperPos, IBlockState upperState, int fortune)
|
||||||
|
{
|
||||||
|
return new java.util.ArrayList<ItemStack>();
|
||||||
|
}
|
||||||
|
public List<ItemStack> getLowerDrops(IBlockAccess world, BlockPos lowerPos, IBlockState lowerState, int fortune)
|
||||||
|
{
|
||||||
|
return super.getDrops(world, lowerPos, lowerState, fortune);
|
||||||
|
}
|
||||||
|
|
||||||
|
// if a child class chooses to implement IShearable make shearing the upper or lower block act as shearing both
|
||||||
|
public List<ItemStack> onSheared(ItemStack item, IBlockAccess world, BlockPos pos, int fortune) {
|
||||||
|
|
||||||
|
List<ItemStack> drops = new java.util.ArrayList<ItemStack>();
|
||||||
|
drops.addAll( this.getUpperShearDrops(item, world, this.getUpperPos(world, pos), this.getUpperState(world, pos), fortune) );
|
||||||
|
drops.addAll( this.getLowerShearDrops(item, world, this.getLowerPos(world, pos), this.getLowerState(world, pos), fortune) );
|
||||||
|
|
||||||
|
// whichever half was sheared, turn the other to air (to prevent it dropping an additional item when it pops)
|
||||||
|
if (world instanceof World)
|
||||||
|
{
|
||||||
|
((World)world).setBlockToAir( pos.add(0, world.getBlockState(pos).getValue(HALF) == Half.UPPER ? -1 : 1, 0) );
|
||||||
|
}
|
||||||
|
|
||||||
|
return drops;
|
||||||
|
}
|
||||||
|
|
||||||
|
// default behavior is that UPPER drops nothing, and LOWER drops the default item
|
||||||
|
public List<ItemStack> getUpperShearDrops(ItemStack item, IBlockAccess world, BlockPos upperPos, IBlockState upperState, int fortune) {
|
||||||
|
return new java.util.ArrayList<ItemStack>();
|
||||||
|
}
|
||||||
|
public List<ItemStack> getLowerShearDrops(ItemStack item, IBlockAccess world, BlockPos lowerPos, IBlockState lowerState, int fortune) {
|
||||||
|
return super.getDrops(world, lowerPos, lowerState, fortune);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// discard the HALF info in the items dropped - make them all Half.LOWER so that they can stack - keep other state info such as VARIANT
|
||||||
|
@Override
|
||||||
|
public int damageDropped(IBlockState state)
|
||||||
|
{
|
||||||
|
return this.getMetaFromState( state.withProperty(HALF, Half.LOWER) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
195
src/main/java/biomesoplenty/common/block/BlockDoubleFoliage.java
Normal file
195
src/main/java/biomesoplenty/common/block/BlockDoubleFoliage.java
Normal file
|
@ -0,0 +1,195 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright 2014, the Biomes O' Plenty Team
|
||||||
|
*
|
||||||
|
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License.
|
||||||
|
*
|
||||||
|
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
package biomesoplenty.common.block;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import biomesoplenty.api.block.BOPBlocks;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
import net.minecraft.block.properties.PropertyEnum;
|
||||||
|
import net.minecraft.block.state.BlockState;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.IStringSerializable;
|
||||||
|
import net.minecraft.world.ColorizerGrass;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraft.world.biome.BiomeColorHelper;
|
||||||
|
import net.minecraftforge.common.ForgeHooks;
|
||||||
|
import net.minecraftforge.common.IShearable;
|
||||||
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
|
public class BlockDoubleFoliage extends BlockDoubleDecoration implements IShearable
|
||||||
|
{
|
||||||
|
|
||||||
|
// add properties (note we inherit HALF from BlockDoubleDecoration)
|
||||||
|
public static enum FoliageType implements IStringSerializable {FLAX; public String getName() {return this.name().toLowerCase();}};
|
||||||
|
public static final PropertyEnum VARIANT = PropertyEnum.create("variant", FoliageType.class);
|
||||||
|
@Override
|
||||||
|
protected BlockState createBlockState() {return new BlockState(this, new IProperty[] { HALF, VARIANT });}
|
||||||
|
|
||||||
|
|
||||||
|
// implement IBOPBlock
|
||||||
|
public IProperty[] getPresetProperties() { return new IProperty[] {VARIANT}; }
|
||||||
|
public IProperty[] getRenderProperties() { return new IProperty[] {HALF, VARIANT}; }
|
||||||
|
public String getStateName(IBlockState state)
|
||||||
|
{
|
||||||
|
return ((FoliageType) state.getValue(VARIANT)).getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public BlockDoubleFoliage()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
this.setDefaultState( this.blockState.getBaseState().withProperty(HALF, Half.LOWER) .withProperty(VARIANT, FoliageType.FLAX) );
|
||||||
|
}
|
||||||
|
|
||||||
|
// map from state to meta and vice verca - use highest bit for Half, and lower bits for variant
|
||||||
|
@Override
|
||||||
|
public IBlockState getStateFromMeta(int meta)
|
||||||
|
{
|
||||||
|
return this.getDefaultState().withProperty(HALF, Half.values()[meta >> 3]).withProperty(VARIANT, FoliageType.values()[meta & 7]);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
return ((Half) state.getValue(HALF)).ordinal() * 8 + ((FoliageType) state.getValue(VARIANT)).ordinal();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: comment these
|
||||||
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public int getBlockColor()
|
||||||
|
{
|
||||||
|
return ColorizerGrass.getGrassColor(0.5D, 1.0D);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public int getRenderColor(IBlockState state)
|
||||||
|
{
|
||||||
|
return this.getBlockColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass)
|
||||||
|
{
|
||||||
|
switch ((FoliageType) worldIn.getBlockState(pos).getValue(VARIANT))
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
return BiomeColorHelper.getGrassColorAtPos(worldIn, pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// flax item should not be tinted, even though the model is
|
||||||
|
@Override
|
||||||
|
public int getItemRenderColor(IBlockState state, int tintIndex)
|
||||||
|
{
|
||||||
|
switch ((FoliageType) state.getValue(VARIANT))
|
||||||
|
{
|
||||||
|
case FLAX:
|
||||||
|
return 0xFFFFFF;
|
||||||
|
default:
|
||||||
|
return this.getRenderColor(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// different variants have different sizes
|
||||||
|
@Override
|
||||||
|
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
|
||||||
|
{
|
||||||
|
switch ((FoliageType) worldIn.getBlockState(pos).getValue(VARIANT))
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
this.setBlockBoundsByRadiusAndHeight(0.4F, 0.8F);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canBlockStay(World world, BlockPos lowerPos, IBlockState state)
|
||||||
|
{
|
||||||
|
IBlockState groundState = world.getBlockState(lowerPos.down());
|
||||||
|
Block groundBlock = groundState.getBlock();
|
||||||
|
boolean onFertile = (groundBlock == Blocks.dirt || groundBlock == BOPBlocks.dirt || groundBlock == Blocks.mycelium || groundBlock == Blocks.grass);
|
||||||
|
if (groundBlock instanceof BlockBOPGrass)
|
||||||
|
{
|
||||||
|
switch ((BlockBOPGrass.BOPGrassType) groundState.getValue(BlockBOPGrass.VARIANT))
|
||||||
|
{
|
||||||
|
case SPECTRAL_MOSS: case SMOLDERING:
|
||||||
|
break;
|
||||||
|
case OVERGROWN_NETHERRACK: case LOAMY: case SANDY: case SILTY: case ORIGIN: default:
|
||||||
|
onFertile = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return onFertile;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// get the items dropped when you bash the bush
|
||||||
|
@Override
|
||||||
|
public List<ItemStack> getLowerDrops(IBlockAccess world, BlockPos lowerPos, IBlockState lowerState, int fortune)
|
||||||
|
{
|
||||||
|
Random rand = world instanceof World ? ((World)world).rand : RANDOM;
|
||||||
|
|
||||||
|
// start with an empty stack
|
||||||
|
List<ItemStack> ret = new java.util.ArrayList<ItemStack>();
|
||||||
|
|
||||||
|
// add items based on the VARIANT - default is to return nothing (require shears to collect the block)
|
||||||
|
switch ((FoliageType) lowerState.getValue(VARIANT))
|
||||||
|
{
|
||||||
|
case FLAX:
|
||||||
|
if (rand.nextInt(8) == 0)
|
||||||
|
{
|
||||||
|
// 1 in 8 chance of getting a seed from this grass
|
||||||
|
ret.add(ForgeHooks.getGrassSeed(rand));
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isShearable(ItemStack item, IBlockAccess world, BlockPos pos) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ItemStack> getLowerShearDrops(ItemStack item, IBlockAccess world, BlockPos lowerPos, IBlockState lowerState, int fortune) {
|
||||||
|
// start with an empty stack
|
||||||
|
List<ItemStack> ret = new java.util.ArrayList<ItemStack>();
|
||||||
|
|
||||||
|
// add items based on the VARIANT
|
||||||
|
switch ((FoliageType) lowerState.getValue(VARIANT))
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
// default is to get the (lower) block unaltered
|
||||||
|
ret.add(new ItemStack(this, 1, this.getMetaFromState(lowerState.withProperty(HALF, Half.LOWER) )));
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -8,13 +8,11 @@
|
||||||
|
|
||||||
package biomesoplenty.common.block;
|
package biomesoplenty.common.block;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
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.properties.IProperty;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
@ -34,11 +32,12 @@ import biomesoplenty.common.item.ItemBOPBlock;
|
||||||
public class BlockFlesh extends Block implements IBOPBlock
|
public class BlockFlesh extends Block implements IBOPBlock
|
||||||
{
|
{
|
||||||
|
|
||||||
// implement IDHBlock
|
// implement IBOPBlock
|
||||||
private Map<String, IBlockState> namedStates = new HashMap<String, IBlockState>();
|
|
||||||
public Map<String, IBlockState> getNamedStates() {return this.namedStates;}
|
|
||||||
public IBlockState getNamedState(String name) {return this.namedStates.get(name);}
|
|
||||||
public Class<? extends ItemBlock> getItemClass() { return ItemBOPBlock.class; }
|
public Class<? extends ItemBlock> getItemClass() { return ItemBOPBlock.class; }
|
||||||
|
public int getItemRenderColor(IBlockState state, int tintIndex) { return this.getRenderColor(state); }
|
||||||
|
public IProperty[] getPresetProperties() { return new IProperty[] {}; }
|
||||||
|
public IProperty[] getRenderProperties() { return new IProperty[] {}; }
|
||||||
|
public String getStateName(IBlockState state) {return "";}
|
||||||
|
|
||||||
public BlockFlesh() {
|
public BlockFlesh() {
|
||||||
super(Material.sponge);
|
super(Material.sponge);
|
||||||
|
|
|
@ -52,18 +52,20 @@ public class BlockFoliage extends BlockDecoration implements IShearable
|
||||||
@Override
|
@Override
|
||||||
protected BlockState createBlockState() {return new BlockState(this, new IProperty[] { VARIANT });}
|
protected BlockState createBlockState() {return new BlockState(this, new IProperty[] { VARIANT });}
|
||||||
|
|
||||||
|
|
||||||
|
// implement IBOPBlock
|
||||||
|
public IProperty[] getPresetProperties() { return new IProperty[] {VARIANT}; }
|
||||||
|
public IProperty[] getRenderProperties() { return new IProperty[] {VARIANT}; }
|
||||||
|
public String getStateName(IBlockState state)
|
||||||
|
{
|
||||||
|
return ((FoliageType) state.getValue(VARIANT)).getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public BlockFoliage()
|
public BlockFoliage()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
|
this.setDefaultState( this.blockState.getBaseState().withProperty(VARIANT, FoliageType.SHORTGRASS) );
|
||||||
// define named states
|
|
||||||
for(FoliageType foliageType : FoliageType.values())
|
|
||||||
{
|
|
||||||
this.namedStates.put(foliageType.getName(), this.blockState.getBaseState().withProperty(VARIANT, foliageType));
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setDefaultState(this.getNamedState("shortgrass"));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// map from state to meta and vice verca
|
// map from state to meta and vice verca
|
||||||
|
@ -158,6 +160,20 @@ public class BlockFoliage extends BlockDecoration implements IShearable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// berrybush item should not be tinted, even though the model is
|
||||||
|
@Override
|
||||||
|
public int getItemRenderColor(IBlockState state, int tintIndex)
|
||||||
|
{
|
||||||
|
switch ((FoliageType) state.getValue(VARIANT))
|
||||||
|
{
|
||||||
|
case BERRYBUSH:
|
||||||
|
return 0xFFFFFF;
|
||||||
|
default:
|
||||||
|
return this.getRenderColor(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// different variants have different sizes
|
// different variants have different sizes
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -34,21 +34,23 @@ public class BlockFruit extends BlockDecoration
|
||||||
@Override
|
@Override
|
||||||
protected BlockState createBlockState() {return new BlockState(this, new IProperty[] { VARIANT });}
|
protected BlockState createBlockState() {return new BlockState(this, new IProperty[] { VARIANT });}
|
||||||
|
|
||||||
|
|
||||||
|
// implement IBOPBlock
|
||||||
|
public IProperty[] getPresetProperties() { return new IProperty[] {VARIANT}; }
|
||||||
|
public IProperty[] getRenderProperties() { return new IProperty[] {VARIANT}; }
|
||||||
|
public String getStateName(IBlockState state)
|
||||||
|
{
|
||||||
|
return ((FruitType) state.getValue(VARIANT)).getName() + "_block";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// constructor
|
// constructor
|
||||||
public BlockFruit() {
|
public BlockFruit() {
|
||||||
|
|
||||||
// set some defaults
|
// set some defaults
|
||||||
this.setStepSound(Block.soundTypeGrass);
|
this.setStepSound(Block.soundTypeGrass);
|
||||||
this.setBlockBoundsByRadiusAndHeight(0.25F, 0.25F, true);
|
this.setBlockBoundsByRadiusAndHeight(0.25F, 0.25F, true);
|
||||||
|
this.setDefaultState( this.blockState.getBaseState().withProperty(VARIANT, FruitType.APPLE) );
|
||||||
// define named states
|
|
||||||
this.namedStates.put("apple_block", this.blockState.getBaseState().withProperty(VARIANT, FruitType.APPLE));
|
|
||||||
this.namedStates.put("persimmon_block", this.blockState.getBaseState().withProperty(VARIANT, FruitType.PERSIMMON));
|
|
||||||
this.namedStates.put("peach_block", this.blockState.getBaseState().withProperty(VARIANT, FruitType.PEACH));
|
|
||||||
this.namedStates.put("pear_block", this.blockState.getBaseState().withProperty(VARIANT, FruitType.PEAR));
|
|
||||||
|
|
||||||
this.setDefaultState(this.namedStates.get("apple_block"));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// map from state to meta and vice verca
|
// map from state to meta and vice verca
|
||||||
|
|
|
@ -8,9 +8,6 @@
|
||||||
|
|
||||||
package biomesoplenty.common.block;
|
package biomesoplenty.common.block;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import biomesoplenty.api.block.IBOPBlock;
|
import biomesoplenty.api.block.IBOPBlock;
|
||||||
import biomesoplenty.common.item.ItemBOPBlock;
|
import biomesoplenty.common.item.ItemBOPBlock;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
@ -31,11 +28,16 @@ public class BlockGem extends Block implements IBOPBlock
|
||||||
@Override
|
@Override
|
||||||
protected BlockState createBlockState() {return new BlockState(this, new IProperty[] { VARIANT });}
|
protected BlockState createBlockState() {return new BlockState(this, new IProperty[] { VARIANT });}
|
||||||
|
|
||||||
// implement IDHBlock
|
|
||||||
private Map<String, IBlockState> namedStates = new HashMap<String, IBlockState>();
|
// implement IBOPBlock
|
||||||
public Map<String, IBlockState> getNamedStates() {return this.namedStates;}
|
|
||||||
public IBlockState getNamedState(String name) {return this.namedStates.get(name);}
|
|
||||||
public Class<? extends ItemBlock> getItemClass() { return ItemBOPBlock.class; }
|
public Class<? extends ItemBlock> getItemClass() { return ItemBOPBlock.class; }
|
||||||
|
public int getItemRenderColor(IBlockState state, int tintIndex) { return this.getRenderColor(state); }
|
||||||
|
public IProperty[] getPresetProperties() { return new IProperty[] {VARIANT}; }
|
||||||
|
public IProperty[] getRenderProperties() { return new IProperty[] {VARIANT}; }
|
||||||
|
public String getStateName(IBlockState state)
|
||||||
|
{
|
||||||
|
return ((GemType) state.getValue(VARIANT)).getName() + "_block";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public BlockGem()
|
public BlockGem()
|
||||||
|
@ -47,19 +49,7 @@ public class BlockGem extends Block implements IBOPBlock
|
||||||
this.setResistance(10.0F);
|
this.setResistance(10.0F);
|
||||||
this.setStepSound(Block.soundTypeMetal);
|
this.setStepSound(Block.soundTypeMetal);
|
||||||
this.setHarvestLevel("pickaxe", 2);
|
this.setHarvestLevel("pickaxe", 2);
|
||||||
|
this.setDefaultState( this.blockState.getBaseState().withProperty(VARIANT, GemType.AMETHYST) );
|
||||||
// define named states
|
|
||||||
this.namedStates.put("amethyst_block", this.blockState.getBaseState().withProperty(VARIANT, GemType.AMETHYST) );
|
|
||||||
this.namedStates.put("ruby_block", this.blockState.getBaseState().withProperty(VARIANT, GemType.RUBY) );
|
|
||||||
this.namedStates.put("peridot_block", this.blockState.getBaseState().withProperty(VARIANT, GemType.PERIDOT) );
|
|
||||||
this.namedStates.put("topaz_block", this.blockState.getBaseState().withProperty(VARIANT, GemType.TOPAZ) );
|
|
||||||
this.namedStates.put("tanzanite_block", this.blockState.getBaseState().withProperty(VARIANT, GemType.TANZANITE) );
|
|
||||||
this.namedStates.put("malachite_block", this.blockState.getBaseState().withProperty(VARIANT, GemType.MALACHITE) );
|
|
||||||
this.namedStates.put("sapphire_block", this.blockState.getBaseState().withProperty(VARIANT, GemType.SAPPHIRE) );
|
|
||||||
this.namedStates.put("amber_block", this.blockState.getBaseState().withProperty(VARIANT, GemType.AMBER) );
|
|
||||||
|
|
||||||
this.setDefaultState(this.namedStates.get("amethyst_block"));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// map from state to meta and vice verca
|
// map from state to meta and vice verca
|
||||||
|
|
|
@ -10,14 +10,13 @@ package biomesoplenty.common.block;
|
||||||
|
|
||||||
import static biomesoplenty.common.block.BlockGem.VARIANT;
|
import static biomesoplenty.common.block.BlockGem.VARIANT;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import biomesoplenty.api.block.IBOPBlock;
|
import biomesoplenty.api.block.IBOPBlock;
|
||||||
import biomesoplenty.api.item.BOPItems;
|
import biomesoplenty.api.item.BOPItems;
|
||||||
import biomesoplenty.common.block.BlockGem.GemType;
|
import biomesoplenty.common.block.BlockGem.GemType;
|
||||||
import biomesoplenty.common.item.ItemBOPBlock;
|
import biomesoplenty.common.item.ItemBOPBlock;
|
||||||
|
import biomesoplenty.common.util.block.BlockStateUtils;
|
||||||
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.properties.IProperty;
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
@ -33,11 +32,16 @@ public class BlockGemOre extends Block implements IBOPBlock
|
||||||
@Override
|
@Override
|
||||||
protected BlockState createBlockState() {return new BlockState(this, new IProperty[] { VARIANT });}
|
protected BlockState createBlockState() {return new BlockState(this, new IProperty[] { VARIANT });}
|
||||||
|
|
||||||
// implement IDHBlock
|
|
||||||
private Map<String, IBlockState> namedStates = new HashMap<String, IBlockState>();
|
// implement IBOPBlock
|
||||||
public Map<String, IBlockState> getNamedStates() {return this.namedStates;}
|
|
||||||
public IBlockState getNamedState(String name) {return this.namedStates.get(name);}
|
|
||||||
public Class<? extends ItemBlock> getItemClass() { return ItemBOPBlock.class; }
|
public Class<? extends ItemBlock> getItemClass() { return ItemBOPBlock.class; }
|
||||||
|
public int getItemRenderColor(IBlockState state, int tintIndex) { return this.getRenderColor(state); }
|
||||||
|
public IProperty[] getPresetProperties() { return new IProperty[] {VARIANT}; }
|
||||||
|
public IProperty[] getRenderProperties() { return new IProperty[] {VARIANT}; }
|
||||||
|
public String getStateName(IBlockState state)
|
||||||
|
{
|
||||||
|
return ((GemType) state.getValue(VARIANT)).getName() + "_ore";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public BlockGemOre()
|
public BlockGemOre()
|
||||||
|
@ -48,22 +52,14 @@ public class BlockGemOre extends Block implements IBOPBlock
|
||||||
this.setHardness(3.0F);
|
this.setHardness(3.0F);
|
||||||
this.setResistance(5.0F);
|
this.setResistance(5.0F);
|
||||||
this.setStepSound(Block.soundTypePiston);
|
this.setStepSound(Block.soundTypePiston);
|
||||||
|
this.setDefaultState( this.blockState.getBaseState().withProperty(VARIANT, GemType.AMETHYST) );
|
||||||
// define named states
|
|
||||||
this.namedStates.put("amethyst_ore", this.blockState.getBaseState().withProperty(VARIANT, GemType.AMETHYST) );
|
|
||||||
this.namedStates.put("ruby_ore", this.blockState.getBaseState().withProperty(VARIANT, GemType.RUBY) );
|
|
||||||
this.namedStates.put("peridot_ore", this.blockState.getBaseState().withProperty(VARIANT, GemType.PERIDOT) );
|
|
||||||
this.namedStates.put("topaz_ore", this.blockState.getBaseState().withProperty(VARIANT, GemType.TOPAZ) );
|
|
||||||
this.namedStates.put("tanzanite_ore", this.blockState.getBaseState().withProperty(VARIANT, GemType.TANZANITE) );
|
|
||||||
this.namedStates.put("malachite_ore", this.blockState.getBaseState().withProperty(VARIANT, GemType.MALACHITE) );
|
|
||||||
this.namedStates.put("sapphire_ore", this.blockState.getBaseState().withProperty(VARIANT, GemType.SAPPHIRE) );
|
|
||||||
this.namedStates.put("amber_ore", this.blockState.getBaseState().withProperty(VARIANT, GemType.AMBER) );
|
|
||||||
|
|
||||||
this.setDefaultState(this.namedStates.get("amethyst_ore"));
|
|
||||||
|
|
||||||
// all variants need pickaxe:2 to harvest, except amethyst which needs pickaxe:3
|
// all variants need pickaxe:2 to harvest, except amethyst which needs pickaxe:3
|
||||||
for (IBlockState state : this.namedStates.values()) {this.setHarvestLevel("pickaxe", 2, state);}
|
for (IBlockState state : BlockStateUtils.getBlockPresets(this))
|
||||||
this.setHarvestLevel("pickaxe", 3, this.namedStates.get("amethyst_ore"));
|
{
|
||||||
|
this.setHarvestLevel("pickaxe", 2, state);
|
||||||
|
}
|
||||||
|
this.setHarvestLevel("pickaxe", 3, this.blockState.getBaseState().withProperty(VARIANT, GemType.AMETHYST));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,6 @@
|
||||||
|
|
||||||
package biomesoplenty.common.block;
|
package biomesoplenty.common.block;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
@ -37,11 +35,16 @@ public class BlockHive extends Block implements IBOPBlock
|
||||||
@Override
|
@Override
|
||||||
protected BlockState createBlockState() {return new BlockState(this, new IProperty[] { VARIANT });}
|
protected BlockState createBlockState() {return new BlockState(this, new IProperty[] { VARIANT });}
|
||||||
|
|
||||||
// implement IDHBlock
|
|
||||||
private Map<String, IBlockState> namedStates = new HashMap<String, IBlockState>();
|
// implement IBOPBlock
|
||||||
public Map<String, IBlockState> getNamedStates() {return this.namedStates;}
|
|
||||||
public IBlockState getNamedState(String name) {return this.namedStates.get(name);}
|
|
||||||
public Class<? extends ItemBlock> getItemClass() { return ItemBOPBlock.class; }
|
public Class<? extends ItemBlock> getItemClass() { return ItemBOPBlock.class; }
|
||||||
|
public int getItemRenderColor(IBlockState state, int tintIndex) { return this.getRenderColor(state); }
|
||||||
|
public IProperty[] getPresetProperties() { return new IProperty[] {VARIANT}; }
|
||||||
|
public IProperty[] getRenderProperties() { return new IProperty[] {VARIANT}; }
|
||||||
|
public String getStateName(IBlockState state)
|
||||||
|
{
|
||||||
|
return ((HiveType) state.getValue(VARIANT)).getName() + "_block";
|
||||||
|
}
|
||||||
|
|
||||||
public BlockHive()
|
public BlockHive()
|
||||||
{
|
{
|
||||||
|
@ -50,15 +53,7 @@ public class BlockHive extends Block implements IBOPBlock
|
||||||
// set some defaults
|
// set some defaults
|
||||||
this.setHardness(0.5F);
|
this.setHardness(0.5F);
|
||||||
this.setStepSound(Block.soundTypeGrass);
|
this.setStepSound(Block.soundTypeGrass);
|
||||||
|
this.setDefaultState( this.blockState.getBaseState().withProperty(VARIANT, HiveType.HIVE) );
|
||||||
// define named states
|
|
||||||
this.namedStates.put("hive_block", this.blockState.getBaseState().withProperty(VARIANT, HiveType.HIVE) );
|
|
||||||
this.namedStates.put("honeycomb_block", this.blockState.getBaseState().withProperty(VARIANT, HiveType.HONEYCOMB) );
|
|
||||||
this.namedStates.put("empty_honeycomb_block", this.blockState.getBaseState().withProperty(VARIANT, HiveType.EMPTY_HONEYCOMB) );
|
|
||||||
this.namedStates.put("filled_honeycomb_block", this.blockState.getBaseState().withProperty(VARIANT, HiveType.FILLED_HONEYCOMB) );
|
|
||||||
|
|
||||||
this.setDefaultState(this.namedStates.get("hive_block"));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// map from state to meta and vice verca
|
// map from state to meta and vice verca
|
||||||
|
|
|
@ -8,8 +8,6 @@
|
||||||
|
|
||||||
package biomesoplenty.common.block;
|
package biomesoplenty.common.block;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
@ -40,13 +38,17 @@ public class BlockMud extends Block implements IBOPBlock
|
||||||
@Override
|
@Override
|
||||||
protected BlockState createBlockState() {return new BlockState(this, new IProperty[] { VARIANT });}
|
protected BlockState createBlockState() {return new BlockState(this, new IProperty[] { VARIANT });}
|
||||||
|
|
||||||
// implement IDHBlock
|
|
||||||
private Map<String, IBlockState> namedStates = new HashMap<String, IBlockState>();
|
|
||||||
public Map<String, IBlockState> getNamedStates() {return this.namedStates;}
|
|
||||||
public IBlockState getNamedState(String name) {return this.namedStates.get(name);}
|
|
||||||
public Class<? extends ItemBlock> getItemClass() {return ItemBOPBlock.class;}
|
|
||||||
|
|
||||||
// constructor
|
// implement IBOPBlock
|
||||||
|
public Class<? extends ItemBlock> getItemClass() { return ItemBOPBlock.class; }
|
||||||
|
public int getItemRenderColor(IBlockState state, int tintIndex) { return this.getRenderColor(state); }
|
||||||
|
public IProperty[] getPresetProperties() { return new IProperty[] {VARIANT}; }
|
||||||
|
public IProperty[] getRenderProperties() { return new IProperty[] {VARIANT}; }
|
||||||
|
public String getStateName(IBlockState state)
|
||||||
|
{
|
||||||
|
return ((MudType) state.getValue(VARIANT)).getName();
|
||||||
|
}
|
||||||
|
|
||||||
public BlockMud() {
|
public BlockMud() {
|
||||||
|
|
||||||
super(Material.sand);
|
super(Material.sand);
|
||||||
|
@ -54,12 +56,7 @@ public class BlockMud extends Block implements IBOPBlock
|
||||||
// set some defaults
|
// set some defaults
|
||||||
this.setHardness(0.6F);
|
this.setHardness(0.6F);
|
||||||
this.setStepSound(Block.soundTypeSand);
|
this.setStepSound(Block.soundTypeSand);
|
||||||
|
this.setDefaultState( this.blockState.getBaseState().withProperty(VARIANT, MudType.MUD) );
|
||||||
// define named states
|
|
||||||
this.namedStates.put("mud", this.blockState.getBaseState().withProperty(VARIANT, MudType.MUD) );
|
|
||||||
this.namedStates.put("quicksand", this.blockState.getBaseState().withProperty(VARIANT, MudType.QUICKSAND) );
|
|
||||||
|
|
||||||
this.setDefaultState(this.namedStates.get("mud"));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,19 +28,23 @@ public class BlockStoneFormations extends BlockDecoration
|
||||||
@Override
|
@Override
|
||||||
protected BlockState createBlockState() {return new BlockState(this, new IProperty[] { VARIANT });}
|
protected BlockState createBlockState() {return new BlockState(this, new IProperty[] { VARIANT });}
|
||||||
|
|
||||||
|
|
||||||
|
// implement IBOPBlock
|
||||||
|
public IProperty[] getPresetProperties() { return new IProperty[] {VARIANT}; }
|
||||||
|
public IProperty[] getRenderProperties() { return new IProperty[] {VARIANT}; }
|
||||||
|
public String getStateName(IBlockState state)
|
||||||
|
{
|
||||||
|
return ((StoneFormationType) state.getValue(VARIANT)).getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// constructor
|
// constructor
|
||||||
public BlockStoneFormations() {
|
public BlockStoneFormations() {
|
||||||
|
|
||||||
// set some defaults
|
// set some defaults
|
||||||
this.setHardness(0.5F);
|
this.setHardness(0.5F);
|
||||||
this.setStepSound(Block.soundTypePiston);
|
this.setStepSound(Block.soundTypePiston);
|
||||||
|
this.setDefaultState( this.blockState.getBaseState().withProperty(VARIANT, StoneFormationType.STALAGMITE) );
|
||||||
// define named states
|
|
||||||
this.namedStates.put("stalactite", this.blockState.getBaseState().withProperty(VARIANT, StoneFormationType.STALACTITE) );
|
|
||||||
this.namedStates.put("stalagmite", this.blockState.getBaseState().withProperty(VARIANT, StoneFormationType.STALAGMITE) );
|
|
||||||
|
|
||||||
this.setDefaultState(this.namedStates.get("stalagmite"));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// map from state to meta and vice verca
|
// map from state to meta and vice verca
|
||||||
|
|
|
@ -8,25 +8,27 @@
|
||||||
|
|
||||||
package biomesoplenty.common.block;
|
package biomesoplenty.common.block;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import net.minecraft.block.BlockCrops;
|
import net.minecraft.block.BlockCrops;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemBlock;
|
import net.minecraft.item.ItemBlock;
|
||||||
import biomesoplenty.api.block.IBOPBlock;
|
import biomesoplenty.api.block.IBOPBlock;
|
||||||
import biomesoplenty.api.item.BOPItems;
|
import biomesoplenty.api.item.BOPItems;
|
||||||
|
import biomesoplenty.common.item.ItemBOPBlock;
|
||||||
|
|
||||||
// TODO: stop snow settling on this (floats above it)
|
// TODO: stop snow settling on this (floats above it)
|
||||||
public class BlockTurnip extends BlockCrops implements IBOPBlock
|
public class BlockTurnip extends BlockCrops implements IBOPBlock
|
||||||
{
|
{
|
||||||
|
|
||||||
// implement IDHBlock
|
// implement IBOPBlock
|
||||||
private Map<String, IBlockState> namedStates = new HashMap<String, IBlockState>();
|
public Class<? extends ItemBlock> getItemClass() { return ItemBOPBlock.class; }
|
||||||
public Map<String, IBlockState> getNamedStates() {return this.namedStates;}
|
public int getItemRenderColor(IBlockState state, int tintIndex) { return this.getRenderColor(state); }
|
||||||
public IBlockState getNamedState(String name) {return this.namedStates.get(name);}
|
public IProperty[] getPresetProperties() { return new IProperty[] {}; }
|
||||||
public Class<? extends ItemBlock> getItemClass() {return null;}
|
public IProperty[] getRenderProperties() { return new IProperty[] {AGE}; }
|
||||||
|
public String getStateName(IBlockState state) {return "";}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Item getSeed()
|
protected Item getSeed()
|
||||||
|
|
|
@ -10,7 +10,7 @@ package biomesoplenty.common.init;
|
||||||
|
|
||||||
import static biomesoplenty.api.block.BOPBlocks.*;
|
import static biomesoplenty.api.block.BOPBlocks.*;
|
||||||
|
|
||||||
import java.util.Map;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
|
@ -46,6 +46,7 @@ import biomesoplenty.common.block.BlockBamboo;
|
||||||
import biomesoplenty.common.block.BlockBones;
|
import biomesoplenty.common.block.BlockBones;
|
||||||
import biomesoplenty.common.block.BlockCoral;
|
import biomesoplenty.common.block.BlockCoral;
|
||||||
import biomesoplenty.common.block.BlockCrystal;
|
import biomesoplenty.common.block.BlockCrystal;
|
||||||
|
import biomesoplenty.common.block.BlockDoubleFoliage;
|
||||||
import biomesoplenty.common.block.BlockFoliage;
|
import biomesoplenty.common.block.BlockFoliage;
|
||||||
import biomesoplenty.common.block.BlockFruit;
|
import biomesoplenty.common.block.BlockFruit;
|
||||||
import biomesoplenty.common.block.BlockGem;
|
import biomesoplenty.common.block.BlockGem;
|
||||||
|
@ -56,6 +57,7 @@ import biomesoplenty.common.block.BlockStoneFormations;
|
||||||
import biomesoplenty.common.block.BlockTurnip;
|
import biomesoplenty.common.block.BlockTurnip;
|
||||||
import biomesoplenty.common.block.BlockFlesh;
|
import biomesoplenty.common.block.BlockFlesh;
|
||||||
import biomesoplenty.common.handler.GuiEventHandler;
|
import biomesoplenty.common.handler.GuiEventHandler;
|
||||||
|
import biomesoplenty.common.util.block.BlockStateUtils;
|
||||||
import biomesoplenty.common.util.inventory.CreativeTabBOP;
|
import biomesoplenty.common.util.inventory.CreativeTabBOP;
|
||||||
import biomesoplenty.core.BiomesOPlenty;
|
import biomesoplenty.core.BiomesOPlenty;
|
||||||
|
|
||||||
|
@ -231,7 +233,7 @@ public class ModBlocks
|
||||||
dark_leaves = registerBlock( new BlockBOPLeaves( new ItemStack(dark_sapling, 1, 0), new ItemStack(Items.apple, 1, 0), 20, true ), "dark_leaves" );
|
dark_leaves = registerBlock( new BlockBOPLeaves( new ItemStack(dark_sapling, 1, 0), new ItemStack(Items.apple, 1, 0), 20, true ), "dark_leaves" );
|
||||||
bamboo_leaves = registerBlock( new BlockBOPLeaves( new ItemStack(bamboo_sapling, 1, 0), new ItemStack(Items.apple, 1, 0), 20, true ), "bamboo_leaves" );
|
bamboo_leaves = registerBlock( new BlockBOPLeaves( new ItemStack(bamboo_sapling, 1, 0), new ItemStack(Items.apple, 1, 0), 20, true ), "bamboo_leaves" );
|
||||||
|
|
||||||
|
double_foliage = registerBlock( new BlockDoubleFoliage(), "double_foliage" );
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -281,21 +283,22 @@ public class ModBlocks
|
||||||
|
|
||||||
if (block instanceof IBOPBlock)
|
if (block instanceof IBOPBlock)
|
||||||
{
|
{
|
||||||
// if this block supports the IBOPBlock interface then we can use getNamedStates() and getItemClass()
|
// if this block supports the IBOPBlock interface then we can determine the item block class, and sub-blocks automatically
|
||||||
IBOPBlock bopBlock = (IBOPBlock)block;
|
IBOPBlock bopBlock = (IBOPBlock)block;
|
||||||
GameRegistry.registerBlock(block, bopBlock.getItemClass(), blockName);
|
GameRegistry.registerBlock(block, bopBlock.getItemClass(), blockName);
|
||||||
if (bopBlock.getNamedStates().isEmpty())
|
ImmutableSet<IBlockState> presets = BlockStateUtils.getBlockPresets(bopBlock);
|
||||||
|
|
||||||
|
if (presets.isEmpty())
|
||||||
{
|
{
|
||||||
// block has no named variants to register
|
// block has no sub-blocks to register
|
||||||
registerBlockVariant(block, blockName, block.getMetaFromState(block.getDefaultState()));
|
registerBlockVariant(block, blockName, block.getMetaFromState(block.getDefaultState()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// register all the named variants
|
// register all the sub-blocks
|
||||||
for (Map.Entry<String,IBlockState> entry : bopBlock.getNamedStates().entrySet())
|
for (IBlockState state : presets)
|
||||||
{
|
{
|
||||||
String stateName = entry.getKey();
|
String stateName = bopBlock.getStateName(state);
|
||||||
IBlockState state = entry.getValue();
|
|
||||||
int stateMeta = block.getMetaFromState(state);
|
int stateMeta = block.getMetaFromState(state);
|
||||||
registerBlockVariant(block, stateName, stateMeta);
|
registerBlockVariant(block, stateName, stateMeta);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,12 @@ package biomesoplenty.common.item;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
|
import biomesoplenty.api.block.BOPBlocks;
|
||||||
import biomesoplenty.api.block.IBOPBlock;
|
import biomesoplenty.api.block.IBOPBlock;
|
||||||
import biomesoplenty.common.block.BlockBOPGrass;
|
import biomesoplenty.common.block.BlockBOPGrass;
|
||||||
|
import biomesoplenty.common.util.block.BlockStateUtils;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
|
@ -46,23 +50,25 @@ public class ItemBOPBlock extends ItemBlock
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public void getSubItems(Item itemIn, CreativeTabs tab, List subItems)
|
public void getSubItems(Item itemIn, CreativeTabs tab, List subItems)
|
||||||
{
|
{
|
||||||
if (bopBlock.getNamedStates().isEmpty())
|
ImmutableSet<IBlockState> presets = BlockStateUtils.getBlockPresets(bopBlock);
|
||||||
|
if (presets.isEmpty())
|
||||||
{
|
{
|
||||||
subItems.add(new ItemStack(this.block, 1, this.block.getMetaFromState( this.block.getDefaultState() )));
|
subItems.add(new ItemStack(this.block, 1, this.block.getMetaFromState( this.block.getDefaultState() )));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (IBlockState state : this.bopBlock.getNamedStates().values())
|
for (IBlockState state : presets)
|
||||||
{
|
{
|
||||||
subItems.add(new ItemStack(this.block, 1, this.block.getMetaFromState(state)));
|
subItems.add(new ItemStack(this.block, 1, this.block.getMetaFromState(state)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: renderPass is actually tintIndex - use for berries etc?
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public int getColorFromItemStack(ItemStack stack, int renderPass)
|
public int getColorFromItemStack(ItemStack stack, int tintIndex)
|
||||||
{
|
{
|
||||||
return this.block.getRenderColor(this.block.getStateFromMeta(stack.getMetadata()));
|
return this.bopBlock.getItemRenderColor(this.block.getStateFromMeta(stack.getMetadata()), tintIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -74,17 +80,18 @@ public class ItemBOPBlock extends ItemBlock
|
||||||
@Override
|
@Override
|
||||||
public String getUnlocalizedName(ItemStack stack)
|
public String getUnlocalizedName(ItemStack stack)
|
||||||
{
|
{
|
||||||
if (bopBlock.getNamedStates().isEmpty())
|
ImmutableSet<IBlockState> presets = BlockStateUtils.getBlockPresets(bopBlock);
|
||||||
|
if (presets.isEmpty())
|
||||||
{
|
{
|
||||||
return super.getUnlocalizedName();
|
return super.getUnlocalizedName();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int meta = stack.getMetadata();
|
int meta = stack.getMetadata();
|
||||||
for (Map.Entry<String,IBlockState> entry : bopBlock.getNamedStates().entrySet()) {
|
for (IBlockState state : presets) {
|
||||||
if (block.getMetaFromState(entry.getValue()) == meta)
|
if (block.getMetaFromState(state) == meta)
|
||||||
{
|
{
|
||||||
return super.getUnlocalizedName() + "." + entry.getKey();
|
return super.getUnlocalizedName() + "." + bopBlock.getStateName(state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return super.getUnlocalizedName() + "." + meta;
|
return super.getUnlocalizedName() + "." + meta;
|
||||||
|
|
|
@ -11,11 +11,15 @@ package biomesoplenty.common.util.block;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.Stack;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import net.minecraft.block.properties.IProperty;
|
import net.minecraft.block.properties.IProperty;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import biomesoplenty.api.block.BOPBlocks;
|
||||||
|
import biomesoplenty.api.block.IBOPBlock;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
@ -42,6 +46,81 @@ public class BlockStateUtils
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static ImmutableSet<IBlockState> getBlockPresets(IBOPBlock block)
|
||||||
|
{
|
||||||
|
return getStatesSet(block.getDefaultState(), block.getPresetProperties());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ImmutableSet<IBlockState> getBlockRenderStates(IBOPBlock block)
|
||||||
|
{
|
||||||
|
return getStatesSet(block.getDefaultState(), block.getRenderProperties());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ImmutableSet<IBlockState> getStatesSet(IBlockState baseState, IProperty... properties)
|
||||||
|
{
|
||||||
|
Stack<IProperty> propStack = new Stack<IProperty>();
|
||||||
|
List<IBlockState> states = new ArrayList<IBlockState>();
|
||||||
|
for (IProperty prop : properties) {propStack.push(prop);}
|
||||||
|
if (!propStack.isEmpty())
|
||||||
|
{
|
||||||
|
addStatesToList(baseState, states, propStack);
|
||||||
|
}
|
||||||
|
ImmutableSet<IBlockState> ret = ImmutableSet.copyOf(states);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void addStatesToList(IBlockState state, List<IBlockState> list, Stack<IProperty> stack)
|
||||||
|
{
|
||||||
|
if (stack.empty())
|
||||||
|
{
|
||||||
|
list.add(state);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
IProperty prop = stack.pop();
|
||||||
|
for (Object value : prop.getAllowedValues())
|
||||||
|
{
|
||||||
|
addStatesToList(state.withProperty(prop, (Comparable)value), list, stack);
|
||||||
|
}
|
||||||
|
stack.push(prop);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
public static Map<String,IBlockState> getStatesSetNamed(IBlockState baseState, IProperty... properties)
|
||||||
|
{
|
||||||
|
Stack<IProperty> propStack = new Stack<IProperty>();
|
||||||
|
Map<String,IBlockState> states = new HashMap<String, IBlockState>();
|
||||||
|
for (IProperty prop : properties) {propStack.push(prop);}
|
||||||
|
AddStatesToMap(baseState, states, propStack);
|
||||||
|
return states;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void AddStatesToMap(IBlockState state, Map<String, IBlockState> map, Stack<IProperty> stack)
|
||||||
|
{
|
||||||
|
if (stack.empty())
|
||||||
|
{
|
||||||
|
map.put(state.getBlock().getStateName(state), state);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
IProperty prop = stack.pop();
|
||||||
|
for (Object value : prop.getAllowedValues())
|
||||||
|
{
|
||||||
|
AddStatesToMap(state.withProperty(prop, (Comparable)value), map, stack);
|
||||||
|
}
|
||||||
|
stack.push(prop);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static IProperty getPropertyByName(IBlockState blockState, String propertyName)
|
public static IProperty getPropertyByName(IBlockState blockState, String propertyName)
|
||||||
{
|
{
|
||||||
for (IProperty property : (ImmutableSet<IProperty>) blockState.getProperties().keySet())
|
for (IProperty property : (ImmutableSet<IProperty>) blockState.getProperties().keySet())
|
||||||
|
@ -53,6 +132,7 @@ public class BlockStateUtils
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static boolean isValidPropertyName(IBlockState blockState, String propertyName)
|
public static boolean isValidPropertyName(IBlockState blockState, String propertyName)
|
||||||
{
|
{
|
||||||
return getPropertyByName(blockState, propertyName) != null;
|
return getPropertyByName(blockState, propertyName) != null;
|
||||||
|
@ -199,4 +279,5 @@ public class BlockStateUtils
|
||||||
return validValues.get(counter);
|
return validValues.get(counter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"variants": {
|
||||||
|
"half=upper,variant=flax": { "model": "biomesoplenty:flax_upper" },
|
||||||
|
"half=lower,variant=flax": { "model": "biomesoplenty:flax_lower" }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent": "block/tallgrass",
|
||||||
|
"textures": {
|
||||||
|
"cross": "biomesoplenty:blocks/flax_lower"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"parent": "biomesoplenty:block/cross_with_overlay",
|
||||||
|
"textures": {
|
||||||
|
"colored": "biomesoplenty:blocks/flax_flowers",
|
||||||
|
"greyscale": "biomesoplenty:blocks/flax_upper",
|
||||||
|
"particle": "biomesoplenty:blocks/flax_upper"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"parent": "builtin/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "biomesoplenty:items/flax"
|
||||||
|
},
|
||||||
|
"display": {
|
||||||
|
"thirdperson": {
|
||||||
|
"rotation": [ -90, 0, 0 ],
|
||||||
|
"translation": [ 0, 1, -3 ],
|
||||||
|
"scale": [ 0.55, 0.55, 0.55 ]
|
||||||
|
},
|
||||||
|
"firstperson": {
|
||||||
|
"rotation": [ 0, -135, 25 ],
|
||||||
|
"translation": [ 0, 4, 2 ],
|
||||||
|
"scale": [ 1.7, 1.7, 1.7 ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 567 B |
Binary file not shown.
After Width: | Height: | Size: 596 B |
Binary file not shown.
After Width: | Height: | Size: 524 B |
BIN
src/main/resources/assets/biomesoplenty/textures/items/flax.png
Normal file
BIN
src/main/resources/assets/biomesoplenty/textures/items/flax.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
Loading…
Reference in a new issue