block cleanup #9
This commit is contained in:
parent
9cc439d774
commit
18d4ea7167
4 changed files with 120 additions and 159 deletions
|
@ -2,152 +2,35 @@ package common.block.artificial;
|
|||
|
||||
import common.block.Block;
|
||||
import common.block.Material;
|
||||
import common.entity.types.EntityLiving;
|
||||
import common.item.CheatTab;
|
||||
import common.model.Model;
|
||||
import common.model.ModelProvider;
|
||||
import common.model.ModelRotation;
|
||||
import common.properties.Property;
|
||||
import common.properties.PropertyEnum;
|
||||
import common.util.BlockPos;
|
||||
import common.util.Facing;
|
||||
import common.util.Identifyable;
|
||||
import common.world.State;
|
||||
import common.world.World;
|
||||
|
||||
public class BlockQuartz extends Block
|
||||
{
|
||||
public static final PropertyEnum<Facing.Axis> AXIS = PropertyEnum.create("axis", Facing.Axis.class);
|
||||
public static final BlockQuartz[] QUARTZ = new BlockQuartz[EnumType.values().length * 2];
|
||||
|
||||
private final EnumType type;
|
||||
public class BlockQuartz extends Block {
|
||||
private final boolean dark;
|
||||
private final boolean ornaments;
|
||||
|
||||
private final boolean dark;
|
||||
|
||||
public static BlockQuartz getByType(boolean dark, EnumType type) {
|
||||
return QUARTZ[(dark ? EnumType.values().length : 0) + type.ordinal()];
|
||||
}
|
||||
|
||||
public BlockQuartz(boolean dark, EnumType type)
|
||||
{
|
||||
super(Material.SOLID);
|
||||
this.type = type;
|
||||
if(type == EnumType.PILLAR)
|
||||
this.setDefaultState(this.getBaseState().withProperty(AXIS, Facing.Axis.Y));
|
||||
this.setTab(CheatTab.BLOCKS);
|
||||
this.dark = dark;
|
||||
QUARTZ[(dark ? EnumType.values().length : 0) + type.ordinal()] = this;
|
||||
}
|
||||
|
||||
public boolean isDark() {
|
||||
return this.dark;
|
||||
}
|
||||
|
||||
public EnumType getType() {
|
||||
return this.type;
|
||||
}
|
||||
public BlockQuartz(boolean dark, boolean ornaments) {
|
||||
super(Material.SOLID);
|
||||
this.dark = dark;
|
||||
this.ornaments = ornaments;
|
||||
this.setTab(CheatTab.BLOCKS);
|
||||
}
|
||||
|
||||
public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, int meta, EntityLiving placer)
|
||||
{
|
||||
return this.type != EnumType.PILLAR ? super.onBlockPlaced(worldIn, pos, facing, hitX, hitY, hitZ, meta, placer) : this.getState().withProperty(AXIS, facing.getAxis());
|
||||
}
|
||||
|
||||
public State getStateFromMeta(int meta)
|
||||
{
|
||||
if(this.type != EnumType.PILLAR)
|
||||
return super.getStateFromMeta(meta);
|
||||
State state = this.getState();
|
||||
switch (meta & 3)
|
||||
{
|
||||
default:
|
||||
state = state.withProperty(AXIS, Facing.Axis.Y);
|
||||
break;
|
||||
case 1:
|
||||
state = state.withProperty(AXIS, Facing.Axis.X);
|
||||
break;
|
||||
case 2:
|
||||
state = state.withProperty(AXIS, Facing.Axis.Z);
|
||||
break;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
public boolean isDark() {
|
||||
return this.dark;
|
||||
}
|
||||
|
||||
public int getMetaFromState(State state)
|
||||
{
|
||||
if(this.type != EnumType.PILLAR)
|
||||
return super.getMetaFromState(state);
|
||||
int meta = 0;
|
||||
switch (state.getValue(AXIS))
|
||||
{
|
||||
case X:
|
||||
meta = 1;
|
||||
break;
|
||||
case Z:
|
||||
meta = 2;
|
||||
break;
|
||||
}
|
||||
return meta;
|
||||
}
|
||||
public boolean hasOrnaments() {
|
||||
return this.ornaments;
|
||||
}
|
||||
|
||||
protected Property[] getProperties()
|
||||
{
|
||||
return this.type != EnumType.PILLAR ? super.getProperties() : new Property[] {AXIS};
|
||||
}
|
||||
|
||||
public Model getModel(ModelProvider provider, String name, State state) {
|
||||
String prefix = this.dark ? "black_" : "";
|
||||
switch(this.type) {
|
||||
case DEFAULT:
|
||||
default:
|
||||
return provider.getModel(prefix + "quartz_block_side").add().nswe().d(prefix + "quartz_block_bottom").u(prefix + "quartz_top");
|
||||
case CHISELED:
|
||||
return provider.getModel(prefix + "quartz_block_chiseled").add().nswe().du(prefix + "quartz_block_chiseled_top");
|
||||
case PILLAR:
|
||||
switch(state.getValue(AXIS)) {
|
||||
case X:
|
||||
return provider.getModel(prefix + "quartz_block_lines").add().nswe().du(prefix + "quartz_block_lines_top").rotate(ModelRotation.X90_Y90);
|
||||
case Y:
|
||||
default:
|
||||
return provider.getModel(prefix + "quartz_block_lines").add().nswe().du(prefix + "quartz_block_lines_top");
|
||||
case Z:
|
||||
return provider.getModel(prefix + "quartz_block_lines").add().nswe().du(prefix + "quartz_block_lines_top").rotate(ModelRotation.X90_Y0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static enum EnumType implements Identifyable
|
||||
{
|
||||
DEFAULT("quartz_block", "Quarzblock", "Schwarzer Quarzblock"),
|
||||
CHISELED("quartz_ornaments", "Gemeißelter Quarzblock", "Schwarzer gemeißelter Quarzblock"),
|
||||
PILLAR("quartz_pillar", "Quarzsäule", "Schwarze Quarzsäule");
|
||||
|
||||
private final String name;
|
||||
private final String displayLight;
|
||||
private final String displayDark;
|
||||
|
||||
private EnumType(String name, String light, String dark)
|
||||
{
|
||||
this.name = name;
|
||||
this.displayLight = light;
|
||||
this.displayDark = dark;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public String getDisplayLight() {
|
||||
return this.displayLight;
|
||||
}
|
||||
|
||||
public String getDisplayDark() {
|
||||
return this.displayDark;
|
||||
}
|
||||
}
|
||||
public Model getModel(ModelProvider provider, String name, State state) {
|
||||
String prefix = this.dark ? "black_" : "";
|
||||
if(this.ornaments)
|
||||
return provider.getModel(prefix + "quartz_block_chiseled").add().nswe().du(prefix + "quartz_block_chiseled_top");
|
||||
else
|
||||
return provider.getModel(prefix + "quartz_block_side").add().nswe().d(prefix + "quartz_block_bottom").u(prefix + "quartz_top");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,87 @@
|
|||
package common.block.artificial;
|
||||
|
||||
import common.block.BlockRotatedPillar;
|
||||
import common.block.Material;
|
||||
import common.entity.types.EntityLiving;
|
||||
import common.item.CheatTab;
|
||||
import common.model.Model;
|
||||
import common.model.ModelProvider;
|
||||
import common.model.ModelRotation;
|
||||
import common.properties.Property;
|
||||
import common.util.BlockPos;
|
||||
import common.util.Facing;
|
||||
import common.world.State;
|
||||
import common.world.World;
|
||||
|
||||
public class BlockQuartzPillar extends BlockRotatedPillar
|
||||
{
|
||||
private final boolean dark;
|
||||
|
||||
public BlockQuartzPillar(boolean dark)
|
||||
{
|
||||
super(Material.SOLID);
|
||||
this.setDefaultState(this.getBaseState().withProperty(AXIS, Facing.Axis.Y));
|
||||
this.setTab(CheatTab.BLOCKS);
|
||||
this.dark = dark;
|
||||
}
|
||||
|
||||
public boolean isDark() {
|
||||
return this.dark;
|
||||
}
|
||||
|
||||
public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, int meta, EntityLiving placer)
|
||||
{
|
||||
return this.getState().withProperty(AXIS, facing.getAxis());
|
||||
}
|
||||
|
||||
public State getStateFromMeta(int meta)
|
||||
{
|
||||
State state = this.getState();
|
||||
switch (meta & 3)
|
||||
{
|
||||
default:
|
||||
state = state.withProperty(AXIS, Facing.Axis.Y);
|
||||
break;
|
||||
case 1:
|
||||
state = state.withProperty(AXIS, Facing.Axis.X);
|
||||
break;
|
||||
case 2:
|
||||
state = state.withProperty(AXIS, Facing.Axis.Z);
|
||||
break;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
public int getMetaFromState(State state)
|
||||
{
|
||||
int meta = 0;
|
||||
switch (state.getValue(AXIS))
|
||||
{
|
||||
case X:
|
||||
meta = 1;
|
||||
break;
|
||||
case Z:
|
||||
meta = 2;
|
||||
break;
|
||||
}
|
||||
return meta;
|
||||
}
|
||||
|
||||
protected Property[] getProperties()
|
||||
{
|
||||
return new Property[] {AXIS};
|
||||
}
|
||||
|
||||
public Model getModel(ModelProvider provider, String name, State state) {
|
||||
String prefix = this.dark ? "black_" : "";
|
||||
switch(state.getValue(AXIS)) {
|
||||
case X:
|
||||
return provider.getModel(prefix + "quartz_block_lines").add().nswe().du(prefix + "quartz_block_lines_top").rotate(ModelRotation.X90_Y90);
|
||||
case Y:
|
||||
default:
|
||||
return provider.getModel(prefix + "quartz_block_lines").add().nswe().du(prefix + "quartz_block_lines_top");
|
||||
case Z:
|
||||
return provider.getModel(prefix + "quartz_block_lines").add().nswe().du(prefix + "quartz_block_lines_top").rotate(ModelRotation.X90_Y0);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -19,6 +19,7 @@ import common.block.artificial.BlockPane;
|
|||
import common.block.artificial.BlockPortal;
|
||||
import common.block.artificial.BlockPortalFrame;
|
||||
import common.block.artificial.BlockQuartz;
|
||||
import common.block.artificial.BlockQuartzPillar;
|
||||
import common.block.artificial.BlockSkull;
|
||||
import common.block.artificial.BlockSlab;
|
||||
import common.block.artificial.BlockStainedGlass;
|
||||
|
@ -415,11 +416,11 @@ public abstract class BlockRegistry {
|
|||
|
||||
|
||||
for(DyeColor color : DyeColor.values()) {
|
||||
registerBlock("wool", (new BlockWool(color)).setHardness(0.8F).setStepSound(SoundType.CLOTH).setDisplay(color.getSubject(-1) + " Wolle")
|
||||
registerBlock(color.getName() + "_wool", (new BlockWool(color)).setHardness(0.8F).setStepSound(SoundType.CLOTH).setDisplay(color.getSubject(-1) + " Wolle")
|
||||
.setShearsEfficiency(1));
|
||||
}
|
||||
for(DyeColor color : DyeColor.values()) {
|
||||
registerBlock("carpet", (new BlockCarpet(color)).setHardness(0.1F).setStepSound(SoundType.CLOTH).setDisplay(color.getSubject(1) + " Teppich").setLightOpacity(0));
|
||||
registerBlock(color.getName() + "_carpet", (new BlockCarpet(color)).setHardness(0.1F).setStepSound(SoundType.CLOTH).setDisplay(color.getSubject(1) + " Teppich").setLightOpacity(0));
|
||||
}
|
||||
for(DyeColor color : BlockBed.COLORS) {
|
||||
registerBlock(color.getName() + "_bed", (new BlockBed(color)).setStepSound(SoundType.WOOD).setHardness(0.2F).setDisplay(color.getSubject(0) + " Bett"));
|
||||
|
@ -498,13 +499,10 @@ public abstract class BlockRegistry {
|
|||
"sandstone_bottom", "sandstone_all")) // fix type
|
||||
.setDisplay("Sandsteintreppe"));
|
||||
|
||||
Block quartz = null;
|
||||
for(BlockQuartz.EnumType type : BlockQuartz.EnumType.values()) {
|
||||
Block block = (new BlockQuartz(false, type)).setStepSound(SoundType.STONE).setHardness(0.8F).setDisplay(type.getDisplayLight());
|
||||
if(type == BlockQuartz.EnumType.DEFAULT)
|
||||
quartz = block;
|
||||
registerBlock(type.getName(), block);
|
||||
}
|
||||
Block quartz = (new BlockQuartz(false, false)).setStepSound(SoundType.STONE).setHardness(0.8F).setDisplay("Quarzblock");
|
||||
registerBlock("quartz_block", quartz);
|
||||
registerBlock("quartz_ornaments", (new BlockQuartz(false, true)).setStepSound(SoundType.STONE).setHardness(0.8F).setDisplay("Gemeißelter Quarzblock"));
|
||||
registerBlock("quartz_pillar", (new BlockQuartzPillar(false)).setStepSound(SoundType.STONE).setHardness(0.8F).setDisplay("Quarzsäule"));
|
||||
registerBlock("quartz_slab", (new BlockSlab(Material.SOLID, "quartz_block_side", "quartz_block_bottom", "quartz_top"))
|
||||
.setHardness(2.0F).setResistance(10.0F).setStepSound(SoundType.STONE).setDisplay("Quarzstufe"));
|
||||
registerBlock("quartz_stairs", (new BlockStairs(quartz.getState(),
|
||||
|
@ -557,13 +555,10 @@ public abstract class BlockRegistry {
|
|||
registerBlock("black_brick_fence", (new BlockFence(Material.SOLID, "black_brick")).setHardness(2.0F).setResistance(10.0F)
|
||||
.setStepSound(SoundType.STONE).setDisplay("Schwarzer Ziegelzaun"));
|
||||
|
||||
Block bquartz = null;
|
||||
for(BlockQuartz.EnumType type : BlockQuartz.EnumType.values()) {
|
||||
Block block = (new BlockQuartz(true, type)).setStepSound(SoundType.STONE).setHardness(0.8F).setDisplay(type.getDisplayDark());
|
||||
if(type == BlockQuartz.EnumType.DEFAULT)
|
||||
bquartz = block;
|
||||
registerBlock("black_" + type.getName(), block);
|
||||
}
|
||||
Block bquartz = (new BlockQuartz(true, false)).setStepSound(SoundType.STONE).setHardness(0.8F).setDisplay("Schwarzer Quarzblock");
|
||||
registerBlock("black_quartz_block", bquartz);
|
||||
registerBlock("black_quartz_ornaments", (new BlockQuartz(true, true)).setStepSound(SoundType.STONE).setHardness(0.8F).setDisplay("Schwarzer gemeißelter Quarzblock"));
|
||||
registerBlock("black_quartz_pillar", (new BlockQuartzPillar(true)).setStepSound(SoundType.STONE).setHardness(0.8F).setDisplay("Schwarze Quarzsäule"));
|
||||
registerBlock("black_quartz_slab", (new BlockSlab(Material.SOLID, "black_quartz_block_side", "black_quartz_block_bottom", "black_quartz_top"))
|
||||
.setHardness(2.0F).setResistance(10.0F).setStepSound(SoundType.STONE).setDisplay("Schwarze Quarzstufe"));
|
||||
registerBlock("black_quartz_stairs", (new BlockStairs(bquartz.getState(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue