block cleanup #1
This commit is contained in:
parent
1713ca7f96
commit
54511912dd
23 changed files with 163 additions and 811 deletions
|
@ -592,7 +592,7 @@ public class Block {
|
|||
Item item = this.getItemDropped(state, worldIn.rand, fortune);
|
||||
|
||||
if(item != null) {
|
||||
spawnAsEntity(worldIn, pos, new ItemStack(item, 1, this.damageDropped(state)));
|
||||
spawnAsEntity(worldIn, pos, new ItemStack(item));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -621,7 +621,7 @@ public class Block {
|
|||
}
|
||||
}
|
||||
|
||||
public int damageDropped(State state) {
|
||||
public final int damageDropped(State state) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -896,12 +896,12 @@ public class Block {
|
|||
return ItemRegistry.getItemFromBlock(this);
|
||||
}
|
||||
|
||||
public int getDamageValue(World worldIn, BlockPos pos) {
|
||||
return this.damageDropped(worldIn.getState(pos));
|
||||
public final int getDamageValue(World worldIn, BlockPos pos) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void getSubBlocks(Item itemIn, CheatTab tab, List<ItemStack> list) {
|
||||
list.add(new ItemStack(itemIn, 1, 0));
|
||||
public final void getSubBlocks(Item itemIn, CheatTab tab, List<ItemStack> list) {
|
||||
list.add(new ItemStack(itemIn));
|
||||
}
|
||||
|
||||
public CheatTab getTab() {
|
||||
|
|
|
@ -1,49 +1,25 @@
|
|||
package common.block;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import common.color.DyeColor;
|
||||
import common.item.CheatTab;
|
||||
import common.item.Item;
|
||||
import common.item.ItemStack;
|
||||
import common.model.Model;
|
||||
import common.model.ModelProvider;
|
||||
import common.properties.IProperty;
|
||||
import common.properties.PropertyEnum;
|
||||
import common.world.State;
|
||||
|
||||
public class BlockColored extends Block {
|
||||
public static final PropertyEnum<DyeColor> COLOR = PropertyEnum.<DyeColor>create("color", DyeColor.class);
|
||||
private final DyeColor color;
|
||||
|
||||
public BlockColored(Material material) {
|
||||
public BlockColored(Material material, DyeColor color) {
|
||||
super(material);
|
||||
this.setDefaultState(this.getBaseState().withProperty(COLOR, DyeColor.WHITE));
|
||||
this.color = color;
|
||||
this.setTab(CheatTab.BLOCKS);
|
||||
}
|
||||
|
||||
public int damageDropped(State state) {
|
||||
return state.getValue(COLOR).getMetadata();
|
||||
}
|
||||
|
||||
public void getSubBlocks(Item item, CheatTab tab, List<ItemStack> list) {
|
||||
for(DyeColor color : DyeColor.values()) {
|
||||
list.add(new ItemStack(item, 1, color.getMetadata()));
|
||||
}
|
||||
}
|
||||
|
||||
public State getStateFromMeta(int meta) {
|
||||
return this.getState().withProperty(COLOR, DyeColor.byMetadata(meta));
|
||||
}
|
||||
|
||||
public int getMetaFromState(State state) {
|
||||
return state.getValue(COLOR).getMetadata();
|
||||
}
|
||||
|
||||
protected IProperty[] getProperties() {
|
||||
return new IProperty[] {COLOR};
|
||||
|
||||
public DyeColor getColor() {
|
||||
return this.color;
|
||||
}
|
||||
|
||||
public Model getModel(ModelProvider provider, String name, State state) {
|
||||
return provider.getModel(state.getValue(COLOR).getName() + "_" + name).add().all();
|
||||
return provider.getModel(this.color.getName() + "_" + name).add().all();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,12 @@
|
|||
package common.block.artificial;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import common.block.Block;
|
||||
import common.block.Material;
|
||||
import common.color.DyeColor;
|
||||
import common.item.CheatTab;
|
||||
import common.item.Item;
|
||||
import common.item.ItemStack;
|
||||
import common.model.Model;
|
||||
import common.model.ModelProvider;
|
||||
import common.model.Transforms;
|
||||
import common.properties.IProperty;
|
||||
import common.properties.PropertyEnum;
|
||||
import common.util.BlockPos;
|
||||
import common.util.Facing;
|
||||
import common.world.IWorldAccess;
|
||||
|
@ -21,25 +15,20 @@ import common.world.World;
|
|||
|
||||
public class BlockCarpet extends Block
|
||||
{
|
||||
public static final PropertyEnum<DyeColor> COLOR = PropertyEnum.<DyeColor>create("color", DyeColor.class);
|
||||
private final DyeColor color;
|
||||
|
||||
public BlockCarpet()
|
||||
public BlockCarpet(DyeColor color)
|
||||
{
|
||||
super(Material.FLEECE);
|
||||
this.setDefaultState(this.getBaseState().withProperty(COLOR, DyeColor.WHITE));
|
||||
this.color = color;
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.0625F, 1.0F);
|
||||
// this.setTickRandomly(true);
|
||||
this.setTab(CheatTab.DECORATION);
|
||||
this.setBlockBoundsFromMeta(0);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Get the MapColor for this Block and the given BlockState
|
||||
// */
|
||||
// public MapColor getMapColor(IBlockState state)
|
||||
// {
|
||||
// return ((EnumDyeColor)state.getValue(COLOR)).getMapColor();
|
||||
// }
|
||||
|
||||
public DyeColor getColor() {
|
||||
return this.color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to determine ambient occlusion and culling when rebuilding chunks for render
|
||||
|
@ -111,52 +100,11 @@ public class BlockCarpet extends Block
|
|||
return side == Facing.UP ? true : super.shouldSideBeRendered(worldIn, pos, side);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the metadata of the item this Block can drop. This method is called when the block gets destroyed. It
|
||||
* returns the metadata of the dropped item based on the old metadata of the block.
|
||||
*/
|
||||
public int damageDropped(State state)
|
||||
{
|
||||
return ((DyeColor)state.getValue(COLOR)).getMetadata();
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
|
||||
*/
|
||||
public void getSubBlocks(Item itemIn, CheatTab tab, List<ItemStack> list)
|
||||
{
|
||||
for (int i = 0; i < 16; ++i)
|
||||
{
|
||||
list.add(new ItemStack(itemIn, 1, i));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given metadata into a BlockState for this Block
|
||||
*/
|
||||
public State getStateFromMeta(int meta)
|
||||
{
|
||||
return this.getState().withProperty(COLOR, DyeColor.byMetadata(meta));
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the BlockState into the correct metadata value
|
||||
*/
|
||||
public int getMetaFromState(State state)
|
||||
{
|
||||
return ((DyeColor)state.getValue(COLOR)).getMetadata();
|
||||
}
|
||||
|
||||
protected IProperty[] getProperties()
|
||||
{
|
||||
return new IProperty[] {COLOR};
|
||||
}
|
||||
|
||||
public Transforms getTransform() {
|
||||
return Transforms.LAYER;
|
||||
}
|
||||
|
||||
public Model getModel(ModelProvider provider, String name, State state) {
|
||||
return provider.getModel(state.getValue(COLOR).getName() + "_wool").add(0, 0, 0, 16, 1, 16).nswe().uv(0, 15, 16, 16).d().u().noCull();
|
||||
return provider.getModel(this.color.getName() + "_wool").add(0, 0, 0, 16, 1, 16).nswe().uv(0, 15, 16, 16).d().u().noCull();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import common.block.Block;
|
|||
import common.block.Material;
|
||||
import common.block.foliage.BlockFlower;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.init.BlockRegistry;
|
||||
import common.init.Blocks;
|
||||
import common.init.ItemRegistry;
|
||||
import common.init.Items;
|
||||
|
@ -13,8 +14,6 @@ import common.item.ItemStack;
|
|||
import common.model.BlockLayer;
|
||||
import common.model.Model;
|
||||
import common.model.ModelProvider;
|
||||
import common.properties.IProperty;
|
||||
import common.properties.PropertyInteger;
|
||||
import common.rng.Random;
|
||||
import common.util.BlockPos;
|
||||
import common.util.Facing;
|
||||
|
@ -22,7 +21,7 @@ import common.world.State;
|
|||
import common.world.World;
|
||||
import common.world.AWorldServer;
|
||||
|
||||
public class BlockFlowerPot extends Block // Container
|
||||
public class BlockFlowerPot extends Block
|
||||
{
|
||||
private static final Model flower_pot_cactus = ModelProvider.getModelProvider().getModel("flower_pot")
|
||||
.add(5, 0, 5, 6, 6, 11)
|
||||
|
@ -99,23 +98,15 @@ public class BlockFlowerPot extends Block // Container
|
|||
.u("dirt").uv(6, 6, 10, 10).noCull()
|
||||
;
|
||||
|
||||
public static final PropertyInteger CONTENTS = PropertyInteger.create("contents", 0, 1 + BlockFlower.EnumFlowerType.values().length);
|
||||
private final Block content;
|
||||
|
||||
public BlockFlowerPot()
|
||||
public BlockFlowerPot(Block content)
|
||||
{
|
||||
super(Material.SMALL);
|
||||
this.setDefaultState(this.getBaseState().withProperty(CONTENTS, 0)); // .withProperty(LEGACY_DATA, Integer.valueOf(0)));
|
||||
this.content = content;
|
||||
this.setBlockBoundsForItemRender();
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Gets the localized name of this block. Used for the statistics page.
|
||||
// */
|
||||
// public String getLocalizedName()
|
||||
// {
|
||||
// return "Blumentopf";
|
||||
// }
|
||||
|
||||
/**
|
||||
* Sets the block's bounds for rendering it as an item
|
||||
*/
|
||||
|
@ -134,43 +125,18 @@ public class BlockFlowerPot extends Block // Container
|
|||
return false;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render
|
||||
// */
|
||||
// public int getRenderType()
|
||||
// {
|
||||
// return 3;
|
||||
// }
|
||||
|
||||
public boolean isFullCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// public int colorMultiplier(IWorldAccess worldIn, BlockPos pos, int renderPass)
|
||||
// {
|
||||
// TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||
//
|
||||
// if (tileentity instanceof TileEntityFlowerPot)
|
||||
// {
|
||||
// Item item = ((TileEntityFlowerPot)tileentity).getFlowerPotItem();
|
||||
//
|
||||
// if (item instanceof ItemBlock)
|
||||
// {
|
||||
// return BlockRegistry.getBlockFromItem(item).colorMultiplier(worldIn, pos, renderPass);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return 16777215;
|
||||
// }
|
||||
|
||||
public boolean onBlockActivated(World worldIn, BlockPos pos, State state, EntityNPC playerIn, Facing side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
ItemStack itemstack = playerIn.inventory.getCurrentItem();
|
||||
|
||||
if (itemstack != null && itemstack.getItem() instanceof ItemBlock)
|
||||
{
|
||||
if (state.getValue(CONTENTS) > 0)
|
||||
if (this.content != null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -178,14 +144,13 @@ public class BlockFlowerPot extends Block // Container
|
|||
{
|
||||
Block block = itemstack.getItem().getBlock();
|
||||
|
||||
if (block != Blocks.flower && block != Blocks.cactus)
|
||||
if (!(block instanceof BlockFlower) && block != Blocks.cactus)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
worldIn.setState(pos, state.withProperty(CONTENTS, block == Blocks.cactus ? 1 : (2 + (itemstack.getMetadata() >=
|
||||
BlockFlower.EnumFlowerType.values().length ? 0 : itemstack.getMetadata()))), 2);
|
||||
worldIn.setState(pos, BlockRegistry.getRegisteredBlock("flowerpot_" + BlockRegistry.getNameFromBlock(this.content)).getState(), 2);
|
||||
// tileentityflowerpot.setFlowerPotData(itemstack.getItem(), itemstack.getMetadata());
|
||||
// tileentityflowerpot.markDirty();
|
||||
// worldIn.markBlockForUpdate(pos);
|
||||
|
@ -208,18 +173,7 @@ public class BlockFlowerPot extends Block // Container
|
|||
|
||||
public Item getItem(World worldIn, BlockPos pos)
|
||||
{
|
||||
State state = worldIn.getState(pos);
|
||||
return state.getBlock() == this ? (state.getValue(CONTENTS) == 1 ? ItemRegistry.getItemFromBlock(Blocks.cactus) :
|
||||
(state.getValue(CONTENTS) >= 2 ? ItemRegistry.getItemFromBlock(Blocks.flower) : Items.flower_pot)) : Items.flower_pot;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the meta to use for the Pick Block ItemStack result
|
||||
*/
|
||||
public int getDamageValue(World worldIn, BlockPos pos)
|
||||
{
|
||||
State state = worldIn.getState(pos);
|
||||
return state.getBlock() == this && state.getValue(CONTENTS) >= 2 ? state.getValue(CONTENTS) - 2 : 0;
|
||||
return worldIn.getState(pos).getBlock() == this && this.content != null ? ItemRegistry.getItemFromBlock(this.content) : Items.flower_pot;
|
||||
}
|
||||
|
||||
public boolean isPickStrict()
|
||||
|
@ -246,27 +200,11 @@ public class BlockFlowerPot extends Block // Container
|
|||
|
||||
public void onBlockRemoved(AWorldServer worldIn, BlockPos pos, State state)
|
||||
{
|
||||
int type = state.getValue(CONTENTS);
|
||||
if(type > 0)
|
||||
spawnAsEntity(worldIn, pos, new ItemStack(type == 1 ? Blocks.cactus : Blocks.flower, 1, type == 1 ? 0 : (type - 2)));
|
||||
if(this.content != null)
|
||||
spawnAsEntity(worldIn, pos, new ItemStack(this.content));
|
||||
super.onBlockRemoved(worldIn, pos, state);
|
||||
}
|
||||
|
||||
// public void onBlockHarvested(World worldIn, BlockPos pos, IBlockState state, EntityNPC player)
|
||||
// {
|
||||
// super.onBlockHarvested(worldIn, pos, state, player);
|
||||
//
|
||||
// if (player.capabilities.isCreativeMode)
|
||||
// {
|
||||
// TileEntityFlowerPot tileentityflowerpot = this.getTileEntity(worldIn, pos);
|
||||
//
|
||||
// if (tileentityflowerpot != null)
|
||||
// {
|
||||
// tileentityflowerpot.setFlowerPotData((Item)null, 0);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* Get the Item that this Block should drop when harvested.
|
||||
*/
|
||||
|
@ -275,88 +213,18 @@ public class BlockFlowerPot extends Block // Container
|
|||
return Items.flower_pot;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given metadata into a BlockState for this Block
|
||||
*/
|
||||
public State getStateFromMeta(int meta)
|
||||
{
|
||||
return this.getState().withProperty(CONTENTS, Math.min(meta, BlockFlower.EnumFlowerType.values().length + 1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the BlockState into the correct metadata value
|
||||
*/
|
||||
public int getMetaFromState(State state)
|
||||
{
|
||||
return state.getValue(CONTENTS);
|
||||
}
|
||||
|
||||
// private TileEntityFlowerPot getTileEntity(World worldIn, BlockPos pos)
|
||||
// {
|
||||
// TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||
// return tileentity instanceof TileEntityFlowerPot ? (TileEntityFlowerPot)tileentity : null;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Returns a new instance of a block's tile entity class. Called on placing the block.
|
||||
// */
|
||||
// public TileEntity createNewTileEntity(World worldIn, int meta)
|
||||
// {
|
||||
// return new TileEntityFlowerPot(null, 0);
|
||||
// }
|
||||
|
||||
protected IProperty[] getProperties()
|
||||
{
|
||||
return new IProperty[] {CONTENTS};
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Get the actual Block state of this Block at the given position. This applies properties not visible in the
|
||||
// * metadata, such as fence connections.
|
||||
// */
|
||||
// public IBlockState getActualState(IBlockState state, IWorldAccess worldIn, BlockPos pos)
|
||||
// {
|
||||
// int type = 0;
|
||||
// TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||
//
|
||||
// if (tileentity instanceof TileEntityFlowerPot)
|
||||
// {
|
||||
// TileEntityFlowerPot tileentityflowerpot = (TileEntityFlowerPot)tileentity;
|
||||
// Item item = tileentityflowerpot.getFlowerPotItem();
|
||||
//
|
||||
// if (item instanceof ItemBlock)
|
||||
// {
|
||||
// int i = tileentityflowerpot.getFlowerPotData();
|
||||
// Block block = BlockRegistry.getBlockFromItem(item);
|
||||
// if (block == Blocks.flower)
|
||||
// {
|
||||
//
|
||||
// }
|
||||
// else if (block == Blocks.cactus)
|
||||
// {
|
||||
// type = 1;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return state.withProperty(CONTENTS, type);
|
||||
// }
|
||||
|
||||
public BlockLayer getBlockLayer()
|
||||
{
|
||||
return BlockLayer.CUTOUT;
|
||||
}
|
||||
|
||||
public Model getModel(ModelProvider provider, String name, State state) {
|
||||
switch(state.getValue(CONTENTS)) {
|
||||
case 0:
|
||||
if(this.content == null)
|
||||
return flower_pot;
|
||||
case 1:
|
||||
else if(this.content == Blocks.cactus)
|
||||
return flower_pot_cactus;
|
||||
// case FERN:
|
||||
// return flower_pot_fern;
|
||||
default:
|
||||
String plant = BlockFlower.EnumFlowerType.getType(BlockFlower.EnumFlowerColor.BASE, state.getValue(CONTENTS) - 2).getName().toLowerCase();
|
||||
else {
|
||||
String plant = BlockRegistry.getNameFromBlock(this.content);
|
||||
return provider.getModel("flower_pot")
|
||||
.add(5, 0, 5, 6, 6, 11)
|
||||
.d().uv(5, 5, 6, 11)
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
|||
import common.block.Block;
|
||||
import common.block.Material;
|
||||
import common.entity.types.EntityLiving;
|
||||
import common.init.Blocks;
|
||||
import common.init.ItemRegistry;
|
||||
import common.item.CheatTab;
|
||||
import common.item.Item;
|
||||
|
@ -14,6 +15,7 @@ import common.model.ModelProvider;
|
|||
import common.model.ModelRotation;
|
||||
import common.properties.IProperty;
|
||||
import common.properties.PropertyEnum;
|
||||
import common.rng.Random;
|
||||
import common.util.BlockPos;
|
||||
import common.util.Facing;
|
||||
import common.util.Identifyable;
|
||||
|
@ -22,102 +24,56 @@ import common.world.World;
|
|||
|
||||
public class BlockQuartz extends Block
|
||||
{
|
||||
public static final PropertyEnum<BlockQuartz.EnumType> VARIANT = PropertyEnum.<BlockQuartz.EnumType>create("variant", BlockQuartz.EnumType.class);
|
||||
private final EnumType type;
|
||||
|
||||
private final String prefix;
|
||||
|
||||
public BlockQuartz(String prefix)
|
||||
public BlockQuartz(String prefix, EnumType type)
|
||||
{
|
||||
super(Material.SOLID);
|
||||
this.setDefaultState(this.getBaseState().withProperty(VARIANT, BlockQuartz.EnumType.DEFAULT));
|
||||
this.type = type;
|
||||
this.setTab(CheatTab.BLOCKS);
|
||||
this.prefix = prefix;
|
||||
}
|
||||
|
||||
public EnumType getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
|
||||
* IBlockstate
|
||||
*/
|
||||
public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, int meta, EntityLiving placer)
|
||||
{
|
||||
if (meta == BlockQuartz.EnumType.LINES_Y.getMetadata())
|
||||
if (this.type == EnumType.LINES_Y)
|
||||
{
|
||||
switch (facing.getAxis())
|
||||
{
|
||||
case Z:
|
||||
return this.getState().withProperty(VARIANT, BlockQuartz.EnumType.LINES_Z);
|
||||
return Blocks.quartz_block_z.getState();
|
||||
|
||||
case X:
|
||||
return this.getState().withProperty(VARIANT, BlockQuartz.EnumType.LINES_X);
|
||||
return Blocks.quartz_block_x.getState();
|
||||
|
||||
case Y:
|
||||
default:
|
||||
return this.getState().withProperty(VARIANT, BlockQuartz.EnumType.LINES_Y);
|
||||
return this.getState();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return meta == BlockQuartz.EnumType.CHISELED.getMetadata() ? this.getState().withProperty(VARIANT, BlockQuartz.EnumType.CHISELED) : this.getState().withProperty(VARIANT, BlockQuartz.EnumType.DEFAULT);
|
||||
return this.getState();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the metadata of the item this Block can drop. This method is called when the block gets destroyed. It
|
||||
* returns the metadata of the dropped item based on the old metadata of the block.
|
||||
*/
|
||||
public int damageDropped(State state)
|
||||
{
|
||||
BlockQuartz.EnumType blockquartz$enumtype = (BlockQuartz.EnumType)state.getValue(VARIANT);
|
||||
return blockquartz$enumtype != BlockQuartz.EnumType.LINES_X && blockquartz$enumtype != BlockQuartz.EnumType.LINES_Z ? blockquartz$enumtype.getMetadata() : BlockQuartz.EnumType.LINES_Y.getMetadata();
|
||||
}
|
||||
|
||||
public Item getItemDropped(State state, Random rand, int fortune) {
|
||||
return this.type != BlockQuartz.EnumType.LINES_X && this.type != BlockQuartz.EnumType.LINES_Z ? super.getItemDropped(state, rand, fortune) : ItemRegistry.getItemFromBlock(Blocks.quartz_block_y);
|
||||
}
|
||||
|
||||
public ItemStack createStackedBlock(State state)
|
||||
{
|
||||
BlockQuartz.EnumType blockquartz$enumtype = (BlockQuartz.EnumType)state.getValue(VARIANT);
|
||||
return blockquartz$enumtype != BlockQuartz.EnumType.LINES_X && blockquartz$enumtype != BlockQuartz.EnumType.LINES_Z ? super.createStackedBlock(state) : new ItemStack(ItemRegistry.getItemFromBlock(this), 1, BlockQuartz.EnumType.LINES_Y.getMetadata());
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
|
||||
*/
|
||||
public void getSubBlocks(Item itemIn, CheatTab tab, List<ItemStack> list)
|
||||
{
|
||||
list.add(new ItemStack(itemIn, 1, BlockQuartz.EnumType.DEFAULT.getMetadata()));
|
||||
list.add(new ItemStack(itemIn, 1, BlockQuartz.EnumType.CHISELED.getMetadata()));
|
||||
list.add(new ItemStack(itemIn, 1, BlockQuartz.EnumType.LINES_Y.getMetadata()));
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Get the MapColor for this Block and the given BlockState
|
||||
// */
|
||||
// public MapColor getMapColor(IBlockState state)
|
||||
// {
|
||||
// return MapColor.quartzColor;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Convert the given metadata into a BlockState for this Block
|
||||
*/
|
||||
public State getStateFromMeta(int meta)
|
||||
{
|
||||
return this.getState().withProperty(VARIANT, BlockQuartz.EnumType.byMetadata(meta));
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the BlockState into the correct metadata value
|
||||
*/
|
||||
public int getMetaFromState(State state)
|
||||
{
|
||||
return ((BlockQuartz.EnumType)state.getValue(VARIANT)).getMetadata();
|
||||
}
|
||||
|
||||
protected IProperty[] getProperties()
|
||||
{
|
||||
return new IProperty[] {VARIANT};
|
||||
return this.type != BlockQuartz.EnumType.LINES_X && this.type != BlockQuartz.EnumType.LINES_Z ? super.createStackedBlock(state) : new ItemStack(Blocks.quartz_block_y);
|
||||
}
|
||||
|
||||
public Model getModel(ModelProvider provider, String name, State state) {
|
||||
switch(state.getValue(VARIANT)) {
|
||||
switch(this.type) {
|
||||
case DEFAULT:
|
||||
default:
|
||||
return provider.getModel(this.prefix + "quartz_block_side").add().nswe().d(this.prefix + "quartz_block_bottom").u(this.prefix + "quartz_top");
|
||||
|
@ -162,7 +118,6 @@ public class BlockQuartz extends Block
|
|||
public String toString()
|
||||
{
|
||||
return this.name;
|
||||
// return this.unlocalizedName;
|
||||
}
|
||||
|
||||
public static BlockQuartz.EnumType byMetadata(int meta)
|
||||
|
|
|
@ -96,7 +96,7 @@ public class BlockSlab extends Block
|
|||
|
||||
if (item != null)
|
||||
{
|
||||
spawnAsEntity(worldIn, pos, new ItemStack(item, 1, this.damageDropped(state)));
|
||||
spawnAsEntity(worldIn, pos, new ItemStack(item));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,103 +1,43 @@
|
|||
package common.block.artificial;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import common.block.Material;
|
||||
import common.color.DyeColor;
|
||||
import common.item.CheatTab;
|
||||
import common.item.Item;
|
||||
import common.item.ItemStack;
|
||||
import common.model.BlockLayer;
|
||||
import common.properties.IProperty;
|
||||
import common.properties.PropertyEnum;
|
||||
import common.world.State;
|
||||
|
||||
public class BlockStainedGlassPane extends BlockPane
|
||||
{
|
||||
public static final PropertyEnum<DyeColor> COLOR = PropertyEnum.<DyeColor>create("color", DyeColor.class);
|
||||
private final DyeColor color;
|
||||
|
||||
public BlockStainedGlassPane()
|
||||
public BlockStainedGlassPane(DyeColor color)
|
||||
{
|
||||
super(Material.TRANSLUCENT, false);
|
||||
this.setDefaultState(this.getBaseState().withProperty(NORTH, Boolean.valueOf(false)).withProperty(EAST, Boolean.valueOf(false)).withProperty(SOUTH, Boolean.valueOf(false)).withProperty(WEST, Boolean.valueOf(false)).withProperty(COLOR, DyeColor.WHITE));
|
||||
this.color = color;
|
||||
this.setDefaultState(this.getBaseState().withProperty(NORTH, Boolean.valueOf(false)).withProperty(EAST, Boolean.valueOf(false)).withProperty(SOUTH, Boolean.valueOf(false)).withProperty(WEST, Boolean.valueOf(false)));
|
||||
this.setTab(CheatTab.BLOCKS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the metadata of the item this Block can drop. This method is called when the block gets destroyed. It
|
||||
* returns the metadata of the dropped item based on the old metadata of the block.
|
||||
*/
|
||||
public int damageDropped(State state)
|
||||
{
|
||||
return ((DyeColor)state.getValue(COLOR)).getMetadata();
|
||||
|
||||
public DyeColor getColor() {
|
||||
return this.color;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
|
||||
*/
|
||||
public void getSubBlocks(Item itemIn, CheatTab tab, List<ItemStack> list)
|
||||
{
|
||||
for (int i = 0; i < DyeColor.values().length; ++i)
|
||||
{
|
||||
list.add(new ItemStack(itemIn, 1, i));
|
||||
}
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Get the MapColor for this Block and the given BlockState
|
||||
// */
|
||||
// public MapColor getMapColor(IBlockState state)
|
||||
// {
|
||||
// return ((EnumDyeColor)state.getValue(COLOR)).getMapColor();
|
||||
// }
|
||||
|
||||
public BlockLayer getBlockLayer()
|
||||
{
|
||||
return BlockLayer.TRANSLUCENT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given metadata into a BlockState for this Block
|
||||
*/
|
||||
public State getStateFromMeta(int meta)
|
||||
{
|
||||
return this.getState().withProperty(COLOR, DyeColor.byMetadata(meta));
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the BlockState into the correct metadata value
|
||||
*/
|
||||
public int getMetaFromState(State state)
|
||||
{
|
||||
return ((DyeColor)state.getValue(COLOR)).getMetadata();
|
||||
}
|
||||
|
||||
protected IProperty[] getProperties()
|
||||
{
|
||||
return new IProperty[] {NORTH, EAST, WEST, SOUTH, COLOR};
|
||||
return new IProperty[] {NORTH, EAST, WEST, SOUTH};
|
||||
}
|
||||
|
||||
// public void onBlockAdded(IWorldServer worldIn, BlockPos pos, State state)
|
||||
// {
|
||||
// if (!worldIn.client)
|
||||
// {
|
||||
// BlockBeacon.updateColorAsync(worldIn, pos);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public void onBlockRemoved(IWorldServer worldIn, BlockPos pos, State state)
|
||||
// {
|
||||
// if (!worldIn.client)
|
||||
// {
|
||||
// BlockBeacon.updateColorAsync(worldIn, pos);
|
||||
// }
|
||||
// }
|
||||
|
||||
protected String getPaneBase(State state) {
|
||||
return state.getValue(COLOR).getName() + "_glass";
|
||||
return this.color.getName() + "_glass";
|
||||
}
|
||||
|
||||
protected String getPaneEdge(State state) {
|
||||
return state.getValue(COLOR).getName() + "_glass_pane";
|
||||
return this.color.getName() + "_glass_pane";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,77 +1,30 @@
|
|||
package common.block.artificial;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import common.block.Block;
|
||||
import common.block.Material;
|
||||
import common.item.CheatTab;
|
||||
import common.item.Item;
|
||||
import common.item.ItemStack;
|
||||
import common.model.Model;
|
||||
import common.model.ModelProvider;
|
||||
import common.properties.IProperty;
|
||||
import common.properties.PropertyEnum;
|
||||
import common.util.Identifyable;
|
||||
import common.world.State;
|
||||
|
||||
public class BlockStoneBrick extends Block
|
||||
{
|
||||
public static final PropertyEnum<BlockStoneBrick.EnumType> VARIANT = PropertyEnum.<BlockStoneBrick.EnumType>create("variant", BlockStoneBrick.EnumType.class);
|
||||
public static final int DEFAULT_META = BlockStoneBrick.EnumType.DEFAULT.getMetadata();
|
||||
public static final int MOSSY_META = BlockStoneBrick.EnumType.MOSSY.getMetadata();
|
||||
public static final int CRACKED_META = BlockStoneBrick.EnumType.CRACKED.getMetadata();
|
||||
public static final int CHISELED_META = BlockStoneBrick.EnumType.CHISELED.getMetadata();
|
||||
private final EnumType type;
|
||||
|
||||
public BlockStoneBrick()
|
||||
public BlockStoneBrick(EnumType type)
|
||||
{
|
||||
super(Material.SOLID);
|
||||
this.setDefaultState(this.getBaseState().withProperty(VARIANT, BlockStoneBrick.EnumType.DEFAULT));
|
||||
this.type = type;
|
||||
this.setTab(CheatTab.BLOCKS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the metadata of the item this Block can drop. This method is called when the block gets destroyed. It
|
||||
* returns the metadata of the dropped item based on the old metadata of the block.
|
||||
*/
|
||||
public int damageDropped(State state)
|
||||
{
|
||||
return ((BlockStoneBrick.EnumType)state.getValue(VARIANT)).getMetadata();
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
|
||||
*/
|
||||
public void getSubBlocks(Item itemIn, CheatTab tab, List<ItemStack> list)
|
||||
{
|
||||
for (BlockStoneBrick.EnumType blockstonebrick$enumtype : BlockStoneBrick.EnumType.values())
|
||||
{
|
||||
list.add(new ItemStack(itemIn, 1, blockstonebrick$enumtype.getMetadata()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given metadata into a BlockState for this Block
|
||||
*/
|
||||
public State getStateFromMeta(int meta)
|
||||
{
|
||||
return this.getState().withProperty(VARIANT, BlockStoneBrick.EnumType.byMetadata(meta));
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the BlockState into the correct metadata value
|
||||
*/
|
||||
public int getMetaFromState(State state)
|
||||
{
|
||||
return ((BlockStoneBrick.EnumType)state.getValue(VARIANT)).getMetadata();
|
||||
}
|
||||
|
||||
protected IProperty[] getProperties()
|
||||
{
|
||||
return new IProperty[] {VARIANT};
|
||||
|
||||
public EnumType getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public Model getModel(ModelProvider provider, String name, State state) {
|
||||
return provider.getModel("stonebrick_" + state.getValue(VARIANT).getTexture()).add().all();
|
||||
return provider.getModel("stonebrick_" + this.type.getTexture()).add().all();
|
||||
}
|
||||
|
||||
public static enum EnumType implements Identifyable
|
||||
|
|
|
@ -1,19 +1,14 @@
|
|||
package common.block.artificial;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import common.block.Block;
|
||||
import common.block.Material;
|
||||
import common.init.Blocks;
|
||||
import common.item.CheatTab;
|
||||
import common.item.Item;
|
||||
import common.item.ItemStack;
|
||||
import common.model.Model;
|
||||
import common.model.ModelProvider;
|
||||
import common.model.ModelRotation;
|
||||
import common.properties.IProperty;
|
||||
import common.properties.PropertyBool;
|
||||
import common.properties.PropertyEnum;
|
||||
import common.util.BlockPos;
|
||||
import common.util.BoundingBox;
|
||||
import common.util.Facing;
|
||||
|
@ -30,25 +25,23 @@ public class BlockWall extends Block
|
|||
public static final PropertyBool EAST = PropertyBool.create("east");
|
||||
public static final PropertyBool SOUTH = PropertyBool.create("south");
|
||||
public static final PropertyBool WEST = PropertyBool.create("west");
|
||||
public static final PropertyEnum<BlockWall.EnumType> VARIANT = PropertyEnum.<BlockWall.EnumType>create("variant", BlockWall.EnumType.class);
|
||||
|
||||
private final EnumType type;
|
||||
|
||||
public BlockWall(Block modelBlock)
|
||||
public BlockWall(Block modelBlock, EnumType type)
|
||||
{
|
||||
super(modelBlock.getMaterial());
|
||||
this.setDefaultState(this.getBaseState().withProperty(UP, Boolean.valueOf(false)).withProperty(NORTH, Boolean.valueOf(false)).withProperty(EAST, Boolean.valueOf(false)).withProperty(SOUTH, Boolean.valueOf(false)).withProperty(WEST, Boolean.valueOf(false)).withProperty(VARIANT, BlockWall.EnumType.NORMAL));
|
||||
this.type = type;
|
||||
this.setDefaultState(this.getBaseState().withProperty(UP, Boolean.valueOf(false)).withProperty(NORTH, Boolean.valueOf(false)).withProperty(EAST, Boolean.valueOf(false)).withProperty(SOUTH, Boolean.valueOf(false)).withProperty(WEST, Boolean.valueOf(false)));
|
||||
this.setHardness(modelBlock.getRawHardness());
|
||||
this.setResistance(modelBlock.getRawResistance() / 3.0F);
|
||||
this.setStepSound(modelBlock.sound);
|
||||
this.setTab(CheatTab.BLOCKS);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Gets the localized name of this block. Used for the statistics page.
|
||||
// */
|
||||
// public String getLocalizedName()
|
||||
// {
|
||||
// return "Bruchsteinmauer";
|
||||
// }
|
||||
|
||||
public EnumType getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public boolean isFullCube()
|
||||
{
|
||||
|
@ -129,47 +122,11 @@ public class BlockWall extends Block
|
|||
return (block != this && !(block instanceof BlockFenceGate) ? (block.getMaterial().isOpaque() && block.isFullCube() ? block.getMaterial() != Material.SOFT : false) : true);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
|
||||
*/
|
||||
public void getSubBlocks(Item itemIn, CheatTab tab, List<ItemStack> list)
|
||||
{
|
||||
for (BlockWall.EnumType blockwall$enumtype : BlockWall.EnumType.values())
|
||||
{
|
||||
list.add(new ItemStack(itemIn, 1, blockwall$enumtype.getMetadata()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the metadata of the item this Block can drop. This method is called when the block gets destroyed. It
|
||||
* returns the metadata of the dropped item based on the old metadata of the block.
|
||||
*/
|
||||
public int damageDropped(State state)
|
||||
{
|
||||
return ((BlockWall.EnumType)state.getValue(VARIANT)).getMetadata();
|
||||
}
|
||||
|
||||
public boolean shouldSideBeRendered(IWorldAccess worldIn, BlockPos pos, Facing side)
|
||||
{
|
||||
return side == Facing.DOWN ? super.shouldSideBeRendered(worldIn, pos, side) : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given metadata into a BlockState for this Block
|
||||
*/
|
||||
public State getStateFromMeta(int meta)
|
||||
{
|
||||
return this.getState().withProperty(VARIANT, BlockWall.EnumType.byMetadata(meta));
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the BlockState into the correct metadata value
|
||||
*/
|
||||
public int getMetaFromState(State state)
|
||||
{
|
||||
return ((BlockWall.EnumType)state.getValue(VARIANT)).getMetadata();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the actual Block state of this Block at the given position. This applies properties not visible in the
|
||||
* metadata, such as fence connections.
|
||||
|
@ -181,11 +138,11 @@ public class BlockWall extends Block
|
|||
|
||||
protected IProperty[] getProperties()
|
||||
{
|
||||
return new IProperty[] {UP, NORTH, EAST, WEST, SOUTH, VARIANT};
|
||||
return new IProperty[] {UP, NORTH, EAST, WEST, SOUTH};
|
||||
}
|
||||
|
||||
public Model getModel(ModelProvider provider, String name, State state) {
|
||||
String wall = state.getValue(VARIANT).getName();
|
||||
String wall = this.type.getName();
|
||||
boolean n = state.getValue(NORTH);
|
||||
boolean s = state.getValue(SOUTH);
|
||||
boolean w = state.getValue(WEST);
|
||||
|
|
|
@ -7,6 +7,7 @@ import common.entity.Entity;
|
|||
import common.entity.types.EntityLiving;
|
||||
import common.init.Blocks;
|
||||
import common.init.ItemRegistry;
|
||||
import common.init.Items;
|
||||
import common.item.Item;
|
||||
import common.model.Model;
|
||||
import common.model.ModelProvider;
|
||||
|
@ -149,12 +150,12 @@ public class BlockFarmland extends Block
|
|||
*/
|
||||
public Item getItemDropped(State state, Random rand, int fortune)
|
||||
{
|
||||
return Blocks.dirt.getItemDropped(Blocks.dirt.getState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.DIRT), rand, fortune);
|
||||
return Blocks.dirt.getItemDropped(Blocks.dirt.getState(), rand, fortune);
|
||||
}
|
||||
|
||||
public Item getItem(World worldIn, BlockPos pos)
|
||||
{
|
||||
return ItemRegistry.getItemFromBlock(Blocks.dirt);
|
||||
return Items.dirt;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -78,7 +78,7 @@ public class BlockGrass extends Block implements IGrowable
|
|||
Block block = worldIn.getState(blockpos.up()).getBlock();
|
||||
State iblockstate = worldIn.getState(blockpos);
|
||||
|
||||
if (iblockstate.getBlock() == Blocks.dirt && iblockstate.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.DIRT && worldIn.getLightFromNeighbors(blockpos.up()) >= 4 && block.getLightOpacity() <= 2)
|
||||
if (iblockstate.getBlock() == Blocks.dirt && worldIn.getLightFromNeighbors(blockpos.up()) >= 4 && block.getLightOpacity() <= 2)
|
||||
{
|
||||
worldIn.setState(blockpos, Blocks.grass.getState());
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ public class BlockGrass extends Block implements IGrowable
|
|||
}
|
||||
else {
|
||||
if(Vars.grassDry)
|
||||
worldIn.setState(pos, worldIn.rand.chance(20) ? Blocks.dirt.getState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.COARSE_DIRT) :
|
||||
worldIn.setState(pos, worldIn.rand.chance(20) ? Blocks.coarse_dirt.getState() :
|
||||
Blocks.dirt.getState());
|
||||
}
|
||||
// }
|
||||
|
@ -98,7 +98,7 @@ public class BlockGrass extends Block implements IGrowable
|
|||
*/
|
||||
public Item getItemDropped(State state, Random rand, int fortune)
|
||||
{
|
||||
return Blocks.dirt.getItemDropped(Blocks.dirt.getState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.DIRT), rand, fortune);
|
||||
return Blocks.dirt.getItemDropped(Blocks.dirt.getState(), rand, fortune);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -19,6 +19,7 @@ import common.world.World;
|
|||
public class BlockHugeMushroom extends Block
|
||||
{
|
||||
public static final PropertyEnum<BlockHugeMushroom.EnumType> VARIANT = PropertyEnum.<BlockHugeMushroom.EnumType>create("variant", BlockHugeMushroom.EnumType.class);
|
||||
|
||||
private final Block smallBlock;
|
||||
|
||||
public BlockHugeMushroom(Material p_i46392_1_, Block p_i46392_3_)
|
||||
|
|
|
@ -8,6 +8,7 @@ import common.block.SoundType;
|
|||
import common.collect.Lists;
|
||||
import common.color.Colorizer;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.init.BlockRegistry;
|
||||
import common.init.Blocks;
|
||||
import common.init.ItemRegistry;
|
||||
import common.init.WoodType;
|
||||
|
@ -20,7 +21,6 @@ import common.model.ModelProvider;
|
|||
import common.model.ParticleType;
|
||||
import common.properties.IProperty;
|
||||
import common.properties.PropertyBool;
|
||||
import common.properties.PropertyEnum;
|
||||
import common.rng.Random;
|
||||
import common.tileentity.TileEntity;
|
||||
import common.util.BlockPos;
|
||||
|
@ -33,19 +33,20 @@ import common.world.AWorldServer;
|
|||
|
||||
public class BlockLeaves extends BlockLeavesBase
|
||||
{
|
||||
public static final PropertyEnum<LeavesType> TYPE = PropertyEnum.<LeavesType>create("type", LeavesType.class);
|
||||
public static final PropertyBool DECAY = PropertyBool.create("decay");
|
||||
public static final List<BlockLeaves> LEAVES = Lists.newArrayList();
|
||||
|
||||
private final WoodType type;
|
||||
private final LeavesType subType;
|
||||
|
||||
int[] surroundings;
|
||||
|
||||
public BlockLeaves(WoodType type)
|
||||
public BlockLeaves(WoodType type, LeavesType subType)
|
||||
{
|
||||
super(Material.LEAVES);
|
||||
this.type = type;
|
||||
this.setDefaultState(this.getBaseState().withProperty(TYPE, LeavesType.SPRING).withProperty(DECAY, Boolean.valueOf(true)));
|
||||
this.subType = subType;
|
||||
this.setDefaultState(this.getBaseState().withProperty(DECAY, Boolean.valueOf(true)));
|
||||
this.setTickRandomly();
|
||||
this.setTab(CheatTab.PLANTS);
|
||||
this.setHardness(0.2F);
|
||||
|
@ -54,20 +55,9 @@ public class BlockLeaves extends BlockLeavesBase
|
|||
LEAVES.add(this);
|
||||
}
|
||||
|
||||
// public int getBlockColor()
|
||||
// {
|
||||
// return ColorizerFoliage.getFoliageColor(0.5D, 1.0D);
|
||||
// }
|
||||
|
||||
// public int getRenderColor(IBlockState state)
|
||||
// {
|
||||
// return ColorizerFoliage.getFoliageColorBasic();
|
||||
// }
|
||||
//
|
||||
// public int colorMultiplier(IWorldAccess worldIn, BlockPos pos, int renderPass)
|
||||
// {
|
||||
// return BiomeColorHelper.getFoliageColorAtPos(worldIn, pos);
|
||||
// }
|
||||
public LeavesType getType() {
|
||||
return this.subType;
|
||||
}
|
||||
|
||||
public void onBlockRemoved(AWorldServer worldIn, BlockPos pos, State state)
|
||||
{
|
||||
|
@ -100,8 +90,8 @@ public class BlockLeaves extends BlockLeavesBase
|
|||
|
||||
public void updateTick(AWorldServer worldIn, BlockPos pos, State state, Random rand)
|
||||
{
|
||||
if(Vars.seasonLeaves && state.getValue(TYPE) != worldIn.getLeavesGen(pos)) {
|
||||
worldIn.setState(pos, state.withProperty(TYPE, worldIn.getLeavesGen(pos)), 2);
|
||||
if(Vars.seasonLeaves && this.subType != worldIn.getLeavesGen(pos)) {
|
||||
worldIn.setState(pos, BlockRegistry.getRegisteredBlock(this.type + "_leaves_" + worldIn.getLeavesGen(pos)).getState().withProperty(DECAY, state.getValue(DECAY)), 2);
|
||||
}
|
||||
if(Vars.leafDry && worldIn.getTemperatureC(pos) >= 50.0f) {
|
||||
worldIn.setState(pos, worldIn.rand.chance(40) ? Blocks.air.getState() : Blocks.dry_leaves.getState());
|
||||
|
@ -270,7 +260,7 @@ public class BlockLeaves extends BlockLeavesBase
|
|||
if (worldIn.rand.chance(i))
|
||||
{
|
||||
Item item = this.getItemDropped(state, worldIn.rand, fortune);
|
||||
spawnAsEntity(worldIn, pos, new ItemStack(item, 1, this.damageDropped(state)));
|
||||
spawnAsEntity(worldIn, pos, new ItemStack(item));
|
||||
}
|
||||
|
||||
i = 200;
|
||||
|
@ -286,40 +276,29 @@ public class BlockLeaves extends BlockLeavesBase
|
|||
}
|
||||
|
||||
if(this.type.getItem() != null && worldIn.rand.chance(i)) // np
|
||||
spawnAsEntity(worldIn, pos, new ItemStack(ItemRegistry.getRegisteredItem(this.type.getItem()), 1, 0));
|
||||
spawnAsEntity(worldIn, pos, new ItemStack(ItemRegistry.getRegisteredItem(this.type.getItem())));
|
||||
}
|
||||
}
|
||||
|
||||
public int getRenderColor(State state)
|
||||
{
|
||||
return state.getBlock() != this || !state.getValue(TYPE).isTinted() ? 16777215 :
|
||||
return state.getBlock() != this || !this.subType.isTinted() ? 16777215 :
|
||||
((this.type.getTintType() == null ? Colorizer.BASIC : this.type.getTintType()).getColor());
|
||||
}
|
||||
|
||||
public int colorMultiplier(IWorldAccess worldIn, BlockPos pos, int renderPass)
|
||||
{
|
||||
State state = worldIn.getState(pos);
|
||||
return state.getBlock() != this || !state.getValue(TYPE).isTinted() ? 16777215 : (this.type.getTintType()
|
||||
return state.getBlock() != this || !this.subType.isTinted() ? 16777215 : (this.type.getTintType()
|
||||
== null ? Colorizer.getFoliageColor(worldIn, pos) : this.type.getTintType().getColor());
|
||||
}
|
||||
|
||||
public void getSubBlocks(Item itemIn, CheatTab tab, List<ItemStack> list) {
|
||||
for(int z = 0; z < LeavesType.values().length; z++) {
|
||||
list.add(new ItemStack(itemIn, 1, z));
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack createStackedBlock(State state) {
|
||||
return new ItemStack(ItemRegistry.getItemFromBlock(this), 1, ((LeavesType)state.getValue(TYPE)).getIndex());
|
||||
}
|
||||
|
||||
public State getStateFromMeta(int meta) {
|
||||
return this.getState().withProperty(TYPE, LeavesType.getById(meta & 7)).withProperty(DECAY, Boolean.valueOf((meta & 8) == 0));
|
||||
return this.getState().withProperty(DECAY, Boolean.valueOf((meta & 8) == 0));
|
||||
}
|
||||
|
||||
public int getMetaFromState(State state) {
|
||||
int i = 0;
|
||||
i = i | ((LeavesType)state.getValue(TYPE)).getIndex();
|
||||
|
||||
if(!((Boolean)state.getValue(DECAY)).booleanValue()) {
|
||||
i |= 8;
|
||||
|
@ -328,22 +307,13 @@ public class BlockLeaves extends BlockLeavesBase
|
|||
return i;
|
||||
}
|
||||
|
||||
// public BlockPlanks.EnumType getWoodType() {
|
||||
// return this.type;
|
||||
// }
|
||||
|
||||
protected IProperty[] getProperties() {
|
||||
return new IProperty[] {TYPE, DECAY};
|
||||
return new IProperty[] {DECAY};
|
||||
}
|
||||
|
||||
// public int damageDropped(IBlockState state) {
|
||||
// return ((LeavesType)state.getValue(TYPE)).getIndex();
|
||||
// }
|
||||
|
||||
public void harvestBlock(World worldIn, EntityNPC player, BlockPos pos, State state, TileEntity te) {
|
||||
if(!worldIn.client && player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemShears) {
|
||||
// player.triggerAchievement(StatRegistry.mineBlockStatArray[BlockRegistry.getIdFromBlock(this)]);
|
||||
spawnAsEntity(worldIn, pos, new ItemStack(ItemRegistry.getItemFromBlock(this), 1, ((LeavesType)state.getValue(TYPE)).getIndex()));
|
||||
spawnAsEntity(worldIn, pos, new ItemStack(this));
|
||||
}
|
||||
else {
|
||||
super.harvestBlock(worldIn, player, pos, state, te);
|
||||
|
@ -351,16 +321,11 @@ public class BlockLeaves extends BlockLeavesBase
|
|||
}
|
||||
|
||||
public Model getModel(ModelProvider provider, String name, State state) {
|
||||
return state.getValue(TYPE).isTinted() ? provider.getModel(name + "_" + state.getValue(TYPE).getName()).add().all().tint() :
|
||||
provider.getModel(name + "_" + state.getValue(TYPE).getName()).add().all();
|
||||
return this.subType.isTinted() ? provider.getModel(name + "_" + this.subType.getName()).add().all().tint() :
|
||||
provider.getModel(name + "_" + this.subType.getName()).add().all();
|
||||
}
|
||||
|
||||
public IProperty<?>[] getIgnoredProperties() {
|
||||
return new IProperty[] {DECAY};
|
||||
}
|
||||
|
||||
public int getDamageValue(World worldIn, BlockPos pos) {
|
||||
State state = worldIn.getState(pos);
|
||||
return state.getBlock() == this ? state.getValue(TYPE).getIndex() : super.getDamageValue(worldIn, pos);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package common.block.foliage;
|
|||
|
||||
import common.block.Block;
|
||||
import common.block.Material;
|
||||
import common.block.natural.BlockDirt;
|
||||
import common.init.Blocks;
|
||||
import common.item.CheatTab;
|
||||
import common.item.Item;
|
||||
|
@ -48,7 +47,7 @@ public class BlockMycelium extends Block
|
|||
if (worldIn.getLightFromNeighbors(pos.up()) < 4 && worldIn.getState(pos.up()).getBlock().getLightOpacity() > 2)
|
||||
{
|
||||
if(Vars.mycelDecay)
|
||||
worldIn.setState(pos, Blocks.dirt.getState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.DIRT));
|
||||
worldIn.setState(pos, Blocks.dirt.getState());
|
||||
}
|
||||
else if(Vars.mycelSpread)
|
||||
{
|
||||
|
@ -60,7 +59,7 @@ public class BlockMycelium extends Block
|
|||
State iblockstate = worldIn.getState(blockpos);
|
||||
Block block = worldIn.getState(blockpos.up()).getBlock();
|
||||
|
||||
if (iblockstate.getBlock() == Blocks.dirt && iblockstate.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.DIRT && worldIn.getLightFromNeighbors(blockpos.up()) >= 4 && block.getLightOpacity() <= 2)
|
||||
if (iblockstate.getBlock() == Blocks.dirt && worldIn.getLightFromNeighbors(blockpos.up()) >= 4 && block.getLightOpacity() <= 2)
|
||||
{
|
||||
worldIn.setState(blockpos, this.getState());
|
||||
}
|
||||
|
@ -85,7 +84,7 @@ public class BlockMycelium extends Block
|
|||
*/
|
||||
public Item getItemDropped(State state, Random rand, int fortune)
|
||||
{
|
||||
return Blocks.dirt.getItemDropped(Blocks.dirt.getState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.DIRT), rand, fortune);
|
||||
return Blocks.dirt.getItemDropped(Blocks.dirt.getState(), rand, fortune);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,51 +1,42 @@
|
|||
package common.block.natural;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import common.block.Block;
|
||||
import common.block.Material;
|
||||
import common.init.Blocks;
|
||||
import common.init.Items;
|
||||
import common.item.CheatTab;
|
||||
import common.item.Item;
|
||||
import common.item.ItemStack;
|
||||
import common.model.Model;
|
||||
import common.model.ModelProvider;
|
||||
import common.properties.IProperty;
|
||||
import common.properties.PropertyBool;
|
||||
import common.properties.PropertyEnum;
|
||||
import common.rng.Random;
|
||||
import common.util.BlockPos;
|
||||
import common.util.Identifyable;
|
||||
import common.world.IWorldAccess;
|
||||
import common.world.State;
|
||||
import common.world.World;
|
||||
|
||||
public class BlockDirt extends Block
|
||||
{
|
||||
public static final PropertyEnum<BlockDirt.DirtType> VARIANT = PropertyEnum.<BlockDirt.DirtType>create("variant", BlockDirt.DirtType.class);
|
||||
public static final PropertyBool SNOWY = PropertyBool.create("snowy");
|
||||
|
||||
public BlockDirt()
|
||||
private final DirtType type;
|
||||
|
||||
public BlockDirt(DirtType type)
|
||||
{
|
||||
super(Material.LOOSE);
|
||||
this.setDefaultState(this.getBaseState().withProperty(VARIANT, BlockDirt.DirtType.DIRT).withProperty(SNOWY, Boolean.valueOf(false)));
|
||||
this.type = type;
|
||||
this.setDefaultState(this.getBaseState().withProperty(SNOWY, Boolean.valueOf(false)));
|
||||
this.setTab(CheatTab.NATURE);
|
||||
}
|
||||
|
||||
public DirtType getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Get the MapColor for this Block and the given BlockState
|
||||
// */
|
||||
// public MapColor getMapColor(IBlockState state)
|
||||
// {
|
||||
// return ((BlockDirt.DirtType)state.getValue(VARIANT)).getMapColor();
|
||||
// }
|
||||
|
||||
/**
|
||||
* Get the actual Block state of this Block at the given position. This applies properties not visible in the
|
||||
* metadata, such as fence connections.
|
||||
*/
|
||||
public State getActualState(State state, IWorldAccess worldIn, BlockPos pos)
|
||||
{
|
||||
if (state.getValue(VARIANT) == BlockDirt.DirtType.PODZOL)
|
||||
if (this.type == DirtType.PODZOL)
|
||||
{
|
||||
Block block = worldIn.getState(pos.up()).getBlock();
|
||||
state = state.withProperty(SNOWY, Boolean.valueOf(block == Blocks.snow || block == Blocks.snow_layer));
|
||||
|
@ -54,64 +45,17 @@ public class BlockDirt extends Block
|
|||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
|
||||
*/
|
||||
public void getSubBlocks(Item itemIn, CheatTab tab, List<ItemStack> list)
|
||||
{
|
||||
list.add(new ItemStack(this, 1, BlockDirt.DirtType.DIRT.getMetadata()));
|
||||
list.add(new ItemStack(this, 1, BlockDirt.DirtType.COARSE_DIRT.getMetadata()));
|
||||
list.add(new ItemStack(this, 1, BlockDirt.DirtType.PODZOL.getMetadata()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the meta to use for the Pick Block ItemStack result
|
||||
*/
|
||||
public int getDamageValue(World worldIn, BlockPos pos)
|
||||
{
|
||||
State iblockstate = worldIn.getState(pos);
|
||||
return iblockstate.getBlock() != this ? 0 : ((BlockDirt.DirtType)iblockstate.getValue(VARIANT)).getMetadata();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given metadata into a BlockState for this Block
|
||||
*/
|
||||
public State getStateFromMeta(int meta)
|
||||
{
|
||||
return this.getState().withProperty(VARIANT, BlockDirt.DirtType.byMetadata(meta));
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the BlockState into the correct metadata value
|
||||
*/
|
||||
public int getMetaFromState(State state)
|
||||
{
|
||||
return ((BlockDirt.DirtType)state.getValue(VARIANT)).getMetadata();
|
||||
}
|
||||
|
||||
protected IProperty[] getProperties()
|
||||
{
|
||||
return new IProperty[] {VARIANT, SNOWY};
|
||||
return new IProperty[] {SNOWY};
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the metadata of the item this Block can drop. This method is called when the block gets destroyed. It
|
||||
* returns the metadata of the dropped item based on the old metadata of the block.
|
||||
*/
|
||||
public int damageDropped(State state)
|
||||
{
|
||||
BlockDirt.DirtType blockdirt$dirttype = (BlockDirt.DirtType)state.getValue(VARIANT);
|
||||
|
||||
if (blockdirt$dirttype == BlockDirt.DirtType.PODZOL)
|
||||
{
|
||||
blockdirt$dirttype = BlockDirt.DirtType.DIRT;
|
||||
}
|
||||
|
||||
return blockdirt$dirttype.getMetadata();
|
||||
}
|
||||
public Item getItemDropped(State state, Random rand, int fortune) {
|
||||
return this.type == DirtType.PODZOL ? Items.dirt : super.getItemDropped(state, rand, fortune);
|
||||
}
|
||||
|
||||
public Model getModel(ModelProvider provider, String name, State state) {
|
||||
switch(state.getValue(VARIANT)) {
|
||||
switch(this.type) {
|
||||
case DIRT:
|
||||
default:
|
||||
return provider.getModel("dirt").add().all();
|
||||
|
@ -125,32 +69,19 @@ public class BlockDirt extends Block
|
|||
|
||||
public static enum DirtType implements Identifyable
|
||||
{
|
||||
DIRT(0, "dirt", "Erde"),
|
||||
COARSE_DIRT(1, "coarse_dirt", "Grobe Erde"),
|
||||
PODZOL(2, "podzol", "Podsol");
|
||||
DIRT("dirt", "Erde"),
|
||||
COARSE_DIRT("coarse_dirt", "Grobe Erde"),
|
||||
PODZOL("podzol", "Podsol");
|
||||
|
||||
private static final BlockDirt.DirtType[] METADATA_LOOKUP = new BlockDirt.DirtType[values().length];
|
||||
private final int metadata;
|
||||
private final String name;
|
||||
private final String display;
|
||||
|
||||
// private DirtType(int meta, String name)
|
||||
// {
|
||||
// this(meta, name, name);
|
||||
// }
|
||||
|
||||
private DirtType(int meta, String name, String display)
|
||||
private DirtType(String name, String display)
|
||||
{
|
||||
this.metadata = meta;
|
||||
this.name = name;
|
||||
this.display = display;
|
||||
}
|
||||
|
||||
public int getMetadata()
|
||||
{
|
||||
return this.metadata;
|
||||
}
|
||||
|
||||
public String getDisplay()
|
||||
{
|
||||
return this.display;
|
||||
|
@ -161,26 +92,9 @@ public class BlockDirt extends Block
|
|||
return this.name;
|
||||
}
|
||||
|
||||
public static BlockDirt.DirtType byMetadata(int metadata)
|
||||
{
|
||||
if (metadata < 0 || metadata >= METADATA_LOOKUP.length)
|
||||
{
|
||||
metadata = 0;
|
||||
}
|
||||
|
||||
return METADATA_LOOKUP[metadata];
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
static {
|
||||
for (BlockDirt.DirtType blockdirt$dirttype : values())
|
||||
{
|
||||
METADATA_LOOKUP[blockdirt$dirttype.getMetadata()] = blockdirt$dirttype;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,12 +11,4 @@ public class BlockHardenedClay extends Block
|
|||
super(Material.SOLID);
|
||||
this.setTab(CheatTab.NATURE);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Get the MapColor for this Block and the given BlockState
|
||||
// */
|
||||
// public MapColor getMapColor(IBlockState state)
|
||||
// {
|
||||
// return null;
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -12,14 +12,6 @@ public class BlockHellRock extends Block
|
|||
this.setTab(CheatTab.NATURE);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Get the MapColor for this Block and the given BlockState
|
||||
// */
|
||||
// public MapColor getMapColor(IBlockState state)
|
||||
// {
|
||||
// return MapColor.hellColor;
|
||||
// }
|
||||
|
||||
public boolean canKeepFire() {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -125,11 +125,6 @@ public class BlockOre extends Block
|
|||
}
|
||||
}
|
||||
|
||||
public int getDamageValue(World worldIn, BlockPos pos)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public boolean isXrayVisible()
|
||||
{
|
||||
return true;
|
||||
|
|
|
@ -1,49 +1,22 @@
|
|||
package common.block.natural;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import common.block.Block;
|
||||
import common.block.Material;
|
||||
import common.item.CheatTab;
|
||||
import common.item.Item;
|
||||
import common.item.ItemStack;
|
||||
import common.model.Model;
|
||||
import common.model.ModelProvider;
|
||||
import common.properties.IProperty;
|
||||
import common.properties.PropertyBool;
|
||||
import common.world.State;
|
||||
|
||||
public class BlockRock extends Block {
|
||||
public static final PropertyBool SMOOTH = PropertyBool.create("smooth");
|
||||
|
||||
public BlockRock() {
|
||||
private final boolean smooth;
|
||||
|
||||
public BlockRock(boolean smooth) {
|
||||
super(Material.SOLID);
|
||||
this.setDefaultState(this.getBaseState().withProperty(SMOOTH, false));
|
||||
this.smooth = smooth;
|
||||
this.setTab(CheatTab.NATURE);
|
||||
}
|
||||
|
||||
public int damageDropped(State state) {
|
||||
return state.getValue(SMOOTH) ? 1 : 0;
|
||||
}
|
||||
|
||||
public void getSubBlocks(Item itemIn, CheatTab tab, List<ItemStack> list) {
|
||||
list.add(new ItemStack(itemIn, 1, 0));
|
||||
list.add(new ItemStack(itemIn, 1, 1));
|
||||
}
|
||||
|
||||
public State getStateFromMeta(int meta) {
|
||||
return this.getState().withProperty(SMOOTH, (meta & 1) != 0);
|
||||
}
|
||||
|
||||
public int getMetaFromState(State state) {
|
||||
return state.getValue(SMOOTH) ? 1 : 0;
|
||||
}
|
||||
|
||||
protected IProperty[] getProperties() {
|
||||
return new IProperty[] {SMOOTH};
|
||||
}
|
||||
|
||||
public Model getModel(ModelProvider provider, String name, State state) {
|
||||
return provider.getModel(state.getValue(SMOOTH) ? "smooth_rock" : "rock").add().all();
|
||||
return provider.getModel(this.smooth ? "smooth_rock" : "rock").add().all();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,81 +1,30 @@
|
|||
package common.block.natural;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import common.block.Block;
|
||||
import common.block.Material;
|
||||
import common.item.CheatTab;
|
||||
import common.item.Item;
|
||||
import common.item.ItemStack;
|
||||
import common.model.Model;
|
||||
import common.model.ModelProvider;
|
||||
import common.properties.IProperty;
|
||||
import common.properties.PropertyEnum;
|
||||
import common.util.Identifyable;
|
||||
import common.world.State;
|
||||
|
||||
public class BlockSandStone extends Block
|
||||
{
|
||||
public static final PropertyEnum<BlockSandStone.EnumType> TYPE = PropertyEnum.<BlockSandStone.EnumType>create("type", BlockSandStone.EnumType.class);
|
||||
private final EnumType type;
|
||||
|
||||
public BlockSandStone()
|
||||
public BlockSandStone(EnumType type)
|
||||
{
|
||||
super(Material.SOLID);
|
||||
this.setDefaultState(this.getBaseState().withProperty(TYPE, BlockSandStone.EnumType.DEFAULT));
|
||||
this.type = type;
|
||||
this.setTab(CheatTab.NATURE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the metadata of the item this Block can drop. This method is called when the block gets destroyed. It
|
||||
* returns the metadata of the dropped item based on the old metadata of the block.
|
||||
*/
|
||||
public int damageDropped(State state)
|
||||
{
|
||||
return ((BlockSandStone.EnumType)state.getValue(TYPE)).getMetadata();
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
|
||||
*/
|
||||
public void getSubBlocks(Item itemIn, CheatTab tab, List<ItemStack> list)
|
||||
{
|
||||
for (BlockSandStone.EnumType blocksandstone$enumtype : BlockSandStone.EnumType.values())
|
||||
{
|
||||
list.add(new ItemStack(itemIn, 1, blocksandstone$enumtype.getMetadata()));
|
||||
}
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Get the MapColor for this Block and the given BlockState
|
||||
// */
|
||||
// public MapColor getMapColor(IBlockState state)
|
||||
// {
|
||||
// return MapColor.sandColor;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Convert the given metadata into a BlockState for this Block
|
||||
*/
|
||||
public State getStateFromMeta(int meta)
|
||||
{
|
||||
return this.getState().withProperty(TYPE, BlockSandStone.EnumType.byMetadata(meta));
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the BlockState into the correct metadata value
|
||||
*/
|
||||
public int getMetaFromState(State state)
|
||||
{
|
||||
return ((BlockSandStone.EnumType)state.getValue(TYPE)).getMetadata();
|
||||
}
|
||||
|
||||
protected IProperty[] getProperties()
|
||||
{
|
||||
return new IProperty[] {TYPE};
|
||||
|
||||
public EnumType getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public Model getModel(ModelProvider provider, String name, State state) {
|
||||
switch(state.getValue(TYPE)) {
|
||||
switch(this.type) {
|
||||
case DEFAULT:
|
||||
default:
|
||||
return provider.getModel("sandstone_normal").add().nswe().d("sandstone_bottom").u("sandstone_all");
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package common.block.tech;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import common.block.Block;
|
||||
import common.block.Material;
|
||||
import common.entity.Entity;
|
||||
|
@ -13,12 +11,10 @@ import common.init.Items;
|
|||
import common.init.SoundEvent;
|
||||
import common.item.CheatTab;
|
||||
import common.item.Item;
|
||||
import common.item.ItemStack;
|
||||
import common.model.Model;
|
||||
import common.model.ModelProvider;
|
||||
import common.properties.IProperty;
|
||||
import common.properties.PropertyBool;
|
||||
import common.properties.PropertyInteger;
|
||||
import common.util.BlockPos;
|
||||
import common.util.Facing;
|
||||
import common.world.Explosion;
|
||||
|
@ -29,14 +25,20 @@ import common.world.AWorldServer;
|
|||
public class BlockTNT extends Block
|
||||
{
|
||||
public static final PropertyBool EXPLODE = PropertyBool.create("explode");
|
||||
public static final PropertyInteger POWER = PropertyInteger.create("power", 0, 7);
|
||||
|
||||
private final int power;
|
||||
|
||||
public BlockTNT()
|
||||
public BlockTNT(int power)
|
||||
{
|
||||
super(Material.EXPLOSIVE);
|
||||
this.power = power;
|
||||
this.setDefaultState(this.getBaseState().withProperty(EXPLODE, Boolean.valueOf(false)));
|
||||
this.setTab(CheatTab.TECHNOLOGY);
|
||||
}
|
||||
|
||||
public int getExplosionPower() {
|
||||
return this.power;
|
||||
}
|
||||
|
||||
public void onBlockAdded(AWorldServer worldIn, BlockPos pos, State state)
|
||||
{
|
||||
|
@ -68,7 +70,7 @@ public class BlockTNT extends Block
|
|||
{
|
||||
if (!worldIn.client)
|
||||
{
|
||||
EntityTnt entitytntprimed = new EntityTnt(worldIn, (double)((float)pos.getX() + 0.5F), (double)pos.getY(), (double)((float)pos.getZ() + 0.5F), explosionIn.getExplosivePlacedBy(), prevState.getValue(POWER).intValue());
|
||||
EntityTnt entitytntprimed = new EntityTnt(worldIn, (double)((float)pos.getX() + 0.5F), (double)pos.getY(), (double)((float)pos.getZ() + 0.5F), explosionIn.getExplosivePlacedBy(), this.power);
|
||||
entitytntprimed.fuse = worldIn.rand.zrange(entitytntprimed.fuse / 4) + entitytntprimed.fuse / 8;
|
||||
worldIn.spawnEntityInWorld(entitytntprimed);
|
||||
}
|
||||
|
@ -88,7 +90,7 @@ public class BlockTNT extends Block
|
|||
{
|
||||
if (((Boolean)state.getValue(EXPLODE)).booleanValue())
|
||||
{
|
||||
EntityTnt entitytntprimed = new EntityTnt(worldIn, (double)((float)pos.getX() + 0.5F), (double)pos.getY(), (double)((float)pos.getZ() + 0.5F), igniter, state.getValue(POWER).intValue());
|
||||
EntityTnt entitytntprimed = new EntityTnt(worldIn, (double)((float)pos.getX() + 0.5F), (double)pos.getY(), (double)((float)pos.getZ() + 0.5F), igniter, this.power);
|
||||
worldIn.spawnEntityInWorld(entitytntprimed);
|
||||
worldIn.playSoundAtEntity(entitytntprimed, SoundEvent.FUSE, 1.0F);
|
||||
}
|
||||
|
@ -138,13 +140,6 @@ public class BlockTNT extends Block
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void getSubBlocks(Item itemIn, CheatTab tab, List<ItemStack> list)
|
||||
{
|
||||
for(int z = 0; z < 8; z++) {
|
||||
list.add(new ItemStack(itemIn, 1, z));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether this block can drop from an explosion.
|
||||
|
@ -159,7 +154,7 @@ public class BlockTNT extends Block
|
|||
*/
|
||||
public State getStateFromMeta(int meta)
|
||||
{
|
||||
return this.getState().withProperty(EXPLODE, Boolean.valueOf((meta & 1) > 0)).withProperty(POWER, Integer.valueOf(((meta >> 1) & 7)));
|
||||
return this.getState().withProperty(EXPLODE, Boolean.valueOf((meta & 1) > 0));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -167,17 +162,12 @@ public class BlockTNT extends Block
|
|||
*/
|
||||
public int getMetaFromState(State state)
|
||||
{
|
||||
return (((Boolean)state.getValue(EXPLODE)).booleanValue() ? 1 : 0) | (state.getValue(POWER).intValue() << 1);
|
||||
}
|
||||
|
||||
public int damageDropped(State state)
|
||||
{
|
||||
return ((Integer)state.getValue(POWER)).intValue();
|
||||
return ((Boolean)state.getValue(EXPLODE)).booleanValue() ? 1 : 0;
|
||||
}
|
||||
|
||||
protected IProperty[] getProperties()
|
||||
{
|
||||
return new IProperty[] {EXPLODE, POWER};
|
||||
return new IProperty[] {EXPLODE};
|
||||
}
|
||||
|
||||
public boolean isXrayVisible()
|
||||
|
@ -186,7 +176,7 @@ public class BlockTNT extends Block
|
|||
}
|
||||
|
||||
public Model getModel(ModelProvider provider, String name, State state) {
|
||||
String power = state.getValue(POWER) == 0 ? "" : ("_" + state.getValue(POWER));
|
||||
String power = this.power == 0 ? "" : ("_" + this.power);
|
||||
return provider.getModel("tnt_side" + power).add().nswe().d("tnt_bottom" + power).u("tnt_top" + power);
|
||||
}
|
||||
|
||||
|
|
|
@ -32,14 +32,6 @@ public class BlockBanner extends BlockContainer
|
|||
float f1 = 1.0F;
|
||||
this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f1, 0.5F + f);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Gets the localized name of this block. Used for the statistics page.
|
||||
// */
|
||||
// public String getLocalizedName()
|
||||
// {
|
||||
// return "Banner";
|
||||
// }
|
||||
|
||||
public boolean isPickStrict()
|
||||
{
|
||||
|
@ -103,14 +95,6 @@ public class BlockBanner extends BlockContainer
|
|||
{
|
||||
return Items.banner;
|
||||
}
|
||||
|
||||
public int getDamageValue(World worldIn, BlockPos pos)
|
||||
{
|
||||
TileEntity te = worldIn.getTileEntity(pos);
|
||||
if(te instanceof TileEntityBanner)
|
||||
return ((TileEntityBanner)te).getBaseColor();
|
||||
return super.getDamageValue(worldIn, pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Spawns this Block's drops into the World as EntityItems.
|
||||
|
|
|
@ -140,7 +140,7 @@ public class EntityFalling extends Entity implements IObjectData
|
|||
}
|
||||
else if (this.shouldDropItem && Vars.objectDrop)
|
||||
{
|
||||
this.entityDropItem(new ItemStack(block, 1, block.damageDropped(this.fallTile)), 0.0F);
|
||||
this.entityDropItem(new ItemStack(block), 0.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ public class EntityFalling extends Entity implements IObjectData
|
|||
{
|
||||
if (this.shouldDropItem && Vars.objectDrop)
|
||||
{
|
||||
this.entityDropItem(new ItemStack(block, 1, block.damageDropped(this.fallTile)), 0.0F);
|
||||
this.entityDropItem(new ItemStack(block), 0.0F);
|
||||
}
|
||||
|
||||
this.setDead();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue