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.Block;
|
||||||
import common.block.Material;
|
import common.block.Material;
|
||||||
import common.entity.types.EntityLiving;
|
|
||||||
import common.item.CheatTab;
|
import common.item.CheatTab;
|
||||||
import common.model.Model;
|
import common.model.Model;
|
||||||
import common.model.ModelProvider;
|
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.State;
|
||||||
import common.world.World;
|
|
||||||
|
|
||||||
public class BlockQuartz extends Block
|
public class BlockQuartz extends Block {
|
||||||
{
|
private final boolean dark;
|
||||||
public static final PropertyEnum<Facing.Axis> AXIS = PropertyEnum.create("axis", Facing.Axis.class);
|
private final boolean ornaments;
|
||||||
public static final BlockQuartz[] QUARTZ = new BlockQuartz[EnumType.values().length * 2];
|
|
||||||
|
|
||||||
private final EnumType type;
|
|
||||||
|
|
||||||
private final boolean dark;
|
public BlockQuartz(boolean dark, boolean ornaments) {
|
||||||
|
super(Material.SOLID);
|
||||||
public static BlockQuartz getByType(boolean dark, EnumType type) {
|
this.dark = dark;
|
||||||
return QUARTZ[(dark ? EnumType.values().length : 0) + type.ordinal()];
|
this.ornaments = ornaments;
|
||||||
}
|
this.setTab(CheatTab.BLOCKS);
|
||||||
|
}
|
||||||
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 State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, int meta, EntityLiving placer)
|
public boolean isDark() {
|
||||||
{
|
return this.dark;
|
||||||
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 int getMetaFromState(State state)
|
public boolean hasOrnaments() {
|
||||||
{
|
return this.ornaments;
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Property[] getProperties()
|
public Model getModel(ModelProvider provider, String name, State state) {
|
||||||
{
|
String prefix = this.dark ? "black_" : "";
|
||||||
return this.type != EnumType.PILLAR ? super.getProperties() : new Property[] {AXIS};
|
if(this.ornaments)
|
||||||
}
|
return provider.getModel(prefix + "quartz_block_chiseled").add().nswe().du(prefix + "quartz_block_chiseled_top");
|
||||||
|
else
|
||||||
public Model getModel(ModelProvider provider, String name, State state) {
|
return provider.getModel(prefix + "quartz_block_side").add().nswe().d(prefix + "quartz_block_bottom").u(prefix + "quartz_top");
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.BlockPortal;
|
||||||
import common.block.artificial.BlockPortalFrame;
|
import common.block.artificial.BlockPortalFrame;
|
||||||
import common.block.artificial.BlockQuartz;
|
import common.block.artificial.BlockQuartz;
|
||||||
|
import common.block.artificial.BlockQuartzPillar;
|
||||||
import common.block.artificial.BlockSkull;
|
import common.block.artificial.BlockSkull;
|
||||||
import common.block.artificial.BlockSlab;
|
import common.block.artificial.BlockSlab;
|
||||||
import common.block.artificial.BlockStainedGlass;
|
import common.block.artificial.BlockStainedGlass;
|
||||||
|
@ -415,11 +416,11 @@ public abstract class BlockRegistry {
|
||||||
|
|
||||||
|
|
||||||
for(DyeColor color : DyeColor.values()) {
|
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));
|
.setShearsEfficiency(1));
|
||||||
}
|
}
|
||||||
for(DyeColor color : DyeColor.values()) {
|
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) {
|
for(DyeColor color : BlockBed.COLORS) {
|
||||||
registerBlock(color.getName() + "_bed", (new BlockBed(color)).setStepSound(SoundType.WOOD).setHardness(0.2F).setDisplay(color.getSubject(0) + " Bett"));
|
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
|
"sandstone_bottom", "sandstone_all")) // fix type
|
||||||
.setDisplay("Sandsteintreppe"));
|
.setDisplay("Sandsteintreppe"));
|
||||||
|
|
||||||
Block quartz = null;
|
Block quartz = (new BlockQuartz(false, false)).setStepSound(SoundType.STONE).setHardness(0.8F).setDisplay("Quarzblock");
|
||||||
for(BlockQuartz.EnumType type : BlockQuartz.EnumType.values()) {
|
registerBlock("quartz_block", quartz);
|
||||||
Block block = (new BlockQuartz(false, type)).setStepSound(SoundType.STONE).setHardness(0.8F).setDisplay(type.getDisplayLight());
|
registerBlock("quartz_ornaments", (new BlockQuartz(false, true)).setStepSound(SoundType.STONE).setHardness(0.8F).setDisplay("Gemeißelter Quarzblock"));
|
||||||
if(type == BlockQuartz.EnumType.DEFAULT)
|
registerBlock("quartz_pillar", (new BlockQuartzPillar(false)).setStepSound(SoundType.STONE).setHardness(0.8F).setDisplay("Quarzsäule"));
|
||||||
quartz = block;
|
|
||||||
registerBlock(type.getName(), block);
|
|
||||||
}
|
|
||||||
registerBlock("quartz_slab", (new BlockSlab(Material.SOLID, "quartz_block_side", "quartz_block_bottom", "quartz_top"))
|
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"));
|
.setHardness(2.0F).setResistance(10.0F).setStepSound(SoundType.STONE).setDisplay("Quarzstufe"));
|
||||||
registerBlock("quartz_stairs", (new BlockStairs(quartz.getState(),
|
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)
|
registerBlock("black_brick_fence", (new BlockFence(Material.SOLID, "black_brick")).setHardness(2.0F).setResistance(10.0F)
|
||||||
.setStepSound(SoundType.STONE).setDisplay("Schwarzer Ziegelzaun"));
|
.setStepSound(SoundType.STONE).setDisplay("Schwarzer Ziegelzaun"));
|
||||||
|
|
||||||
Block bquartz = null;
|
Block bquartz = (new BlockQuartz(true, false)).setStepSound(SoundType.STONE).setHardness(0.8F).setDisplay("Schwarzer Quarzblock");
|
||||||
for(BlockQuartz.EnumType type : BlockQuartz.EnumType.values()) {
|
registerBlock("black_quartz_block", bquartz);
|
||||||
Block block = (new BlockQuartz(true, type)).setStepSound(SoundType.STONE).setHardness(0.8F).setDisplay(type.getDisplayDark());
|
registerBlock("black_quartz_ornaments", (new BlockQuartz(true, true)).setStepSound(SoundType.STONE).setHardness(0.8F).setDisplay("Schwarzer gemeißelter Quarzblock"));
|
||||||
if(type == BlockQuartz.EnumType.DEFAULT)
|
registerBlock("black_quartz_pillar", (new BlockQuartzPillar(true)).setStepSound(SoundType.STONE).setHardness(0.8F).setDisplay("Schwarze Quarzsäule"));
|
||||||
bquartz = block;
|
|
||||||
registerBlock("black_" + type.getName(), block);
|
|
||||||
}
|
|
||||||
registerBlock("black_quartz_slab", (new BlockSlab(Material.SOLID, "black_quartz_block_side", "black_quartz_block_bottom", "black_quartz_top"))
|
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"));
|
.setHardness(2.0F).setResistance(10.0F).setStepSound(SoundType.STONE).setDisplay("Schwarze Quarzstufe"));
|
||||||
registerBlock("black_quartz_stairs", (new BlockStairs(bquartz.getState(),
|
registerBlock("black_quartz_stairs", (new BlockStairs(bquartz.getState(),
|
||||||
|
|
|
@ -9,7 +9,6 @@ import common.block.Block;
|
||||||
import common.block.BlockRotatedPillar;
|
import common.block.BlockRotatedPillar;
|
||||||
import common.block.artificial.BlockDoor;
|
import common.block.artificial.BlockDoor;
|
||||||
import common.block.artificial.BlockPortal;
|
import common.block.artificial.BlockPortal;
|
||||||
import common.block.artificial.BlockQuartz;
|
|
||||||
import common.block.foliage.BlockLog;
|
import common.block.foliage.BlockLog;
|
||||||
import common.block.tech.BlockLever;
|
import common.block.tech.BlockLever;
|
||||||
import common.block.tech.BlockRail;
|
import common.block.tech.BlockRail;
|
||||||
|
@ -75,9 +74,6 @@ public abstract class RotationRegistry {
|
||||||
else if(prop == BlockLog.LOG_AXIS) {
|
else if(prop == BlockLog.LOG_AXIS) {
|
||||||
axis = ((BlockLog.EnumAxis)v).getAxis();
|
axis = ((BlockLog.EnumAxis)v).getAxis();
|
||||||
}
|
}
|
||||||
else if(prop == BlockQuartz.AXIS) {
|
|
||||||
axis = ((Facing.Axis)v);
|
|
||||||
}
|
|
||||||
else if(prop == BlockLever.FACING) {
|
else if(prop == BlockLever.FACING) {
|
||||||
dv = ((BlockLever.EnumOrientation)v).getFacing().getDirectionVec();
|
dv = ((BlockLever.EnumOrientation)v).getFacing().getDirectionVec();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue