block cleanup #2

This commit is contained in:
Sen 2025-06-20 23:10:16 +02:00
parent 54511912dd
commit 473ef16043
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
41 changed files with 278 additions and 757 deletions

View file

@ -230,7 +230,7 @@ public class RenderItem
if (item == Items.fishing_rod && entityplayer.fishEntity != null)
{
modelresourcelocation = "item/fishing_rod#1" + '#' + "inventory";
modelresourcelocation = "item/fishing_rod_cast" + '#' + "inventory";
}
else if (item == Items.bow && entityplayer.getItemInUse() != null)
{
@ -238,15 +238,15 @@ public class RenderItem
if (i >= 18)
{
modelresourcelocation = "item/bow#3" + '#' + "inventory";
modelresourcelocation = "item/bow_pulling_3" + '#' + "inventory";
}
else if (i > 13)
{
modelresourcelocation = "item/bow#2" + '#' + "inventory";
modelresourcelocation = "item/bow_pulling_2" + '#' + "inventory";
}
else if (i > 0)
{
modelresourcelocation = "item/bow#1" + '#' + "inventory";
modelresourcelocation = "item/bow_pulling_1" + '#' + "inventory";
}
}

View file

@ -1,6 +1,5 @@
package common.ai;
import common.block.foliage.BlockTallGrass;
import common.entity.animal.EntitySheep;
import common.init.BlockRegistry;
import common.init.Blocks;
@ -35,7 +34,7 @@ public class EntityAIEatGrass extends EntityAIBase
{
BlockPos blockpos = new BlockPos(this.grassEaterEntity.posX, this.grassEaterEntity.posY, this.grassEaterEntity.posZ);
State state = this.entityWorld.getState(blockpos);
return (state.getBlock() == Blocks.tallgrass && state.getValue(BlockTallGrass.TYPE) == BlockTallGrass.EnumType.GRASS) ||
return state.getBlock() == Blocks.tallgrass ||
this.entityWorld.getState(blockpos.down()).getBlock() == Blocks.grass;
}
}
@ -86,7 +85,7 @@ public class EntityAIEatGrass extends EntityAIBase
BlockPos blockpos = new BlockPos(this.grassEaterEntity.posX, this.grassEaterEntity.posY, this.grassEaterEntity.posZ);
State state = this.entityWorld.getState(blockpos);
if (state.getBlock() == Blocks.tallgrass && state.getValue(BlockTallGrass.TYPE) == BlockTallGrass.EnumType.GRASS)
if (state.getBlock() == Blocks.tallgrass)
{
if (Vars.mobGrief)
{

View file

@ -3,6 +3,7 @@ package common.ai;
import java.util.Map;
import common.block.Block;
import common.block.foliage.BlockFlower;
import common.collect.Maps;
import common.entity.npc.EntityNPC;
import common.init.Blocks;
@ -30,7 +31,9 @@ public class EntityAITakePlace extends EntityAIBase
}
static {
addPlaceable(Blocks.flower);
for(BlockFlower.EnumFlowerType type : BlockFlower.EnumFlowerType.values()) {
addPlaceable(BlockFlower.getByType(type));
}
addPlaceable(Blocks.brown_mushroom);
addPlaceable(Blocks.red_mushroom);
addPlaceable(Blocks.blue_mushroom);

View file

@ -1,5 +1,7 @@
package common.ai;
import java.util.function.Predicate;
import common.entity.npc.EntityNPC;
import common.entity.types.EntityLiving;
import common.item.Item;
@ -38,7 +40,7 @@ public class EntityAITempt extends EntityAIBase
/** True if this EntityAITempt task is running */
private boolean isRunning;
private Item temptItem;
private Predicate<ItemStack> temptItem;
private double range;
private double distance;
@ -48,11 +50,19 @@ public class EntityAITempt extends EntityAIBase
private boolean scaredByPlayerMovement;
private boolean avoidWater;
public EntityAITempt(EntityLiving temptedEntityIn, double speedIn, Item temptItemIn, boolean scaredByPlayerMovementIn) {
public EntityAITempt(EntityLiving temptedEntityIn, double speedIn, final Item temptItemIn, boolean scaredByPlayerMovementIn) {
this(temptedEntityIn, speedIn, new Predicate<ItemStack>() {
public boolean test(ItemStack stack) {
return stack.getItem() == temptItemIn;
}
}, 2.5, 10.0, scaredByPlayerMovementIn);
}
public EntityAITempt(EntityLiving temptedEntityIn, double speedIn, Predicate<ItemStack> temptItemIn, boolean scaredByPlayerMovementIn) {
this(temptedEntityIn, speedIn, temptItemIn, 2.5, 10.0, scaredByPlayerMovementIn);
}
public EntityAITempt(EntityLiving temptedEntityIn, double speedIn, Item temptItemIn, double distance, double range, boolean scaredByPlayerMovementIn)
public EntityAITempt(EntityLiving temptedEntityIn, double speedIn, Predicate<ItemStack> temptItemIn, double distance, double range, boolean scaredByPlayerMovementIn)
{
this.temptedEntity = temptedEntityIn;
this.speed = speedIn;
@ -91,7 +101,7 @@ public class EntityAITempt extends EntityAIBase
if(this.temptItem == null)
return this.temptedEntity.getDistanceSqToEntity(this.temptingPlayer) >= this.distance;
ItemStack itemstack = this.temptingPlayer.getCurrentEquippedItem();
return itemstack == null ? false : itemstack.getItem() == this.temptItem;
return itemstack == null ? false : this.temptItem.test(itemstack);
}
}
}

View file

@ -621,10 +621,6 @@ public class Block {
}
}
public final int damageDropped(State state) {
return 0;
}
public float getExplosionResistance(Entity exploder) {
return this.blockResistance / 5.0F;
}
@ -896,14 +892,6 @@ public class Block {
return ItemRegistry.getItemFromBlock(this);
}
public final int getDamageValue(World worldIn, BlockPos pos) {
return 0;
}
public final void getSubBlocks(Item itemIn, CheatTab tab, List<ItemStack> list) {
list.add(new ItemStack(itemIn));
}
public CheatTab getTab() {
return this.tab;
}

View file

@ -1,52 +1,27 @@
package common.block.artificial;
import java.util.List;
import common.color.DyeColor;
import common.item.CheatTab;
import common.item.Item;
import common.item.ItemStack;
import common.model.BlockLayer;
import common.model.Model;
import common.model.ModelProvider;
import common.properties.IProperty;
import common.properties.PropertyEnum;
import common.world.State;
public class BlockStainedGlass extends BlockGlass {
public static final PropertyEnum<DyeColor> COLOR = PropertyEnum.<DyeColor>create("color", DyeColor.class);
private final DyeColor color;
public BlockStainedGlass() {
this.setDefaultState(this.getBaseState().withProperty(COLOR, DyeColor.WHITE));
public BlockStainedGlass(DyeColor color) {
this.color = color;
}
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 DyeColor getColor() {
return this.color;
}
public BlockLayer getBlockLayer() {
return BlockLayer.TRANSLUCENT;
}
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 Model getModel(ModelProvider provider, String name, State state) {
return provider.getModel(state.getValue(COLOR).getName() + "_glass").add().all();
return provider.getModel(this.color.getName() + "_glass").add().all();
}
}

View file

@ -1,9 +0,0 @@
package common.block.foliage;
public class BlockBaseFlower extends BlockFlower
{
public BlockFlower.EnumFlowerColor getBlockType()
{
return BlockFlower.EnumFlowerColor.BASE;
}
}

View file

@ -175,15 +175,7 @@ public class BlockCocoa extends BlockDirectional implements IGrowable
public Item getItem(World worldIn, BlockPos pos)
{
return Items.dye;
}
/**
* Gets the meta to use for the Pick Block ItemStack result
*/
public int getDamageValue(World worldIn, BlockPos pos)
{
return DyeColor.BROWN.getDyeDamage();
return Items.cocoa;
}
/**

View file

@ -34,18 +34,22 @@ import common.world.AWorldServer;
public class BlockDoublePlant extends BlockBush implements IGrowable
{
public static final PropertyEnum<BlockDoublePlant.EnumPlantType> VARIANT = PropertyEnum.<BlockDoublePlant.EnumPlantType>create("variant", BlockDoublePlant.EnumPlantType.class);
public static final PropertyEnum<BlockDoublePlant.EnumBlockHalf> HALF = PropertyEnum.<BlockDoublePlant.EnumBlockHalf>create("half", BlockDoublePlant.EnumBlockHalf.class);
public static final PropertyEnum<Facing> FACING = BlockDirectional.FACING;
public BlockDoublePlant()
private final EnumPlantType type;
public BlockDoublePlant(EnumPlantType type)
{
super(Material.BUSH);
this.setDefaultState(this.getBaseState().withProperty(VARIANT, BlockDoublePlant.EnumPlantType.SUNFLOWER).withProperty(HALF, BlockDoublePlant.EnumBlockHalf.LOWER).withProperty(FACING, Facing.NORTH));
this.type = type;
this.setDefaultState(this.getBaseState().withProperty(HALF, BlockDoublePlant.EnumBlockHalf.LOWER).withProperty(FACING, Facing.NORTH));
this.setHardness(0.0F);
this.setStepSound(SoundType.GRASS);
// this.setDisplay("doublePlant");
// this.setTickRandomly();
}
public EnumPlantType getType() {
return this.type;
}
public void updateTick(AWorldServer worldIn, BlockPos pos, State state, Random rand)
@ -59,8 +63,8 @@ public class BlockDoublePlant extends BlockBush implements IGrowable
worldIn.setState(pos, Blocks.air.getState());
pos = pos.down();
if(!upper || worldIn.getState(pos).getBlock() == this)
worldIn.setState(pos, state.getValue(VARIANT) == EnumPlantType.GRASS || worldIn.rand.chance(20) ? Blocks.air.getState() :
Blocks.tallgrass.getState().withProperty(BlockTallGrass.TYPE, BlockTallGrass.EnumType.DEAD_BUSH));
worldIn.setState(pos, this.type == EnumPlantType.GRASS || worldIn.rand.chance(20) ? Blocks.air.getState() :
Blocks.dead_bush.getState());
return;
}
super.updateTick(worldIn, pos, state, rand);
@ -71,21 +75,6 @@ public class BlockDoublePlant extends BlockBush implements IGrowable
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
public BlockDoublePlant.EnumPlantType getVariant(IWorldAccess worldIn, BlockPos pos)
{
State iblockstate = worldIn.getState(pos);
if (iblockstate.getBlock() == this)
{
iblockstate = this.getActualState(iblockstate, worldIn, pos);
return (BlockDoublePlant.EnumPlantType)iblockstate.getValue(VARIANT);
}
else
{
return BlockDoublePlant.EnumPlantType.FERN;
}
}
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
{
return super.canPlaceBlockAt(worldIn, pos) && worldIn.isAirBlock(pos.up());
@ -104,8 +93,7 @@ public class BlockDoublePlant extends BlockBush implements IGrowable
}
else
{
BlockDoublePlant.EnumPlantType blockdoubleplant$enumplanttype = (BlockDoublePlant.EnumPlantType)this.getActualState(iblockstate, worldIn, pos).getValue(VARIANT);
return blockdoubleplant$enumplanttype == BlockDoublePlant.EnumPlantType.FERN || blockdoubleplant$enumplanttype == BlockDoublePlant.EnumPlantType.GRASS;
return this.type == BlockDoublePlant.EnumPlantType.FERN || this.type == BlockDoublePlant.EnumPlantType.GRASS;
}
}
@ -160,29 +148,18 @@ public class BlockDoublePlant extends BlockBush implements IGrowable
}
else
{
BlockDoublePlant.EnumPlantType blockdoubleplant$enumplanttype = (BlockDoublePlant.EnumPlantType)state.getValue(VARIANT);
return blockdoubleplant$enumplanttype == BlockDoublePlant.EnumPlantType.FERN ? null : (blockdoubleplant$enumplanttype == BlockDoublePlant.EnumPlantType.GRASS ? (rand.chance(8) ? Items.wheat : null) : ItemRegistry.getItemFromBlock(this));
return this.type == BlockDoublePlant.EnumPlantType.FERN ? null : (this.type == BlockDoublePlant.EnumPlantType.GRASS ? (rand.chance(8) ? Items.wheat : null) : ItemRegistry.getItemFromBlock(this));
}
}
/**
* 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 state.getValue(HALF) != BlockDoublePlant.EnumBlockHalf.UPPER && state.getValue(VARIANT) != BlockDoublePlant.EnumPlantType.GRASS ? ((BlockDoublePlant.EnumPlantType)state.getValue(VARIANT)).getMeta() : 0;
}
public int colorMultiplier(IWorldAccess worldIn, BlockPos pos, int renderPass)
{
BlockDoublePlant.EnumPlantType blockdoubleplant$enumplanttype = this.getVariant(worldIn, pos);
return blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.GRASS && blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.FERN ? 16777215 : Colorizer.getGrassColor(worldIn, pos);
return this.type != BlockDoublePlant.EnumPlantType.GRASS && this.type != BlockDoublePlant.EnumPlantType.FERN ? 16777215 : Colorizer.getGrassColor(worldIn, pos);
}
public void placeAt(World worldIn, BlockPos lowerPos, BlockDoublePlant.EnumPlantType variant, int flags)
public void placeAt(World worldIn, BlockPos lowerPos, int flags)
{
worldIn.setState(lowerPos, this.getState().withProperty(HALF, BlockDoublePlant.EnumBlockHalf.LOWER).withProperty(VARIANT, variant), flags);
worldIn.setState(lowerPos, this.getState().withProperty(HALF, BlockDoublePlant.EnumBlockHalf.LOWER), flags);
worldIn.setState(lowerPos.up(), this.getState().withProperty(HALF, BlockDoublePlant.EnumBlockHalf.UPPER), flags);
}
@ -211,9 +188,8 @@ public class BlockDoublePlant extends BlockBush implements IGrowable
// if (!player.creative)
// {
State iblockstate = worldIn.getState(pos.down());
BlockDoublePlant.EnumPlantType blockdoubleplant$enumplanttype = (BlockDoublePlant.EnumPlantType)iblockstate.getValue(VARIANT);
if (blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.FERN && blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.GRASS)
if (this.type != BlockDoublePlant.EnumPlantType.FERN && this.type != BlockDoublePlant.EnumPlantType.GRASS)
{
worldIn.destroyBlock(pos.down(), true);
}
@ -250,47 +226,23 @@ public class BlockDoublePlant extends BlockBush implements IGrowable
private boolean onHarvest(World worldIn, BlockPos pos, State state, EntityNPC player)
{
BlockDoublePlant.EnumPlantType blockdoubleplant$enumplanttype = (BlockDoublePlant.EnumPlantType)state.getValue(VARIANT);
if (blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.FERN && blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.GRASS)
if (this.type != BlockDoublePlant.EnumPlantType.FERN && this.type != BlockDoublePlant.EnumPlantType.GRASS)
{
return false;
}
else
{
// player.triggerAchievement(StatRegistry.mineBlockStatArray[BlockRegistry.getIdFromBlock(this)]);
int i = (blockdoubleplant$enumplanttype == BlockDoublePlant.EnumPlantType.GRASS ? BlockTallGrass.EnumType.GRASS : BlockTallGrass.EnumType.FERN).getMeta();
spawnAsEntity(worldIn, pos, new ItemStack(Blocks.tallgrass, 2, i));
spawnAsEntity(worldIn, pos, new ItemStack(this.type == BlockDoublePlant.EnumPlantType.GRASS ? Blocks.tallgrass : Blocks.fern, 2));
return 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 (BlockDoublePlant.EnumPlantType blockdoubleplant$enumplanttype : BlockDoublePlant.EnumPlantType.values())
{
list.add(new ItemStack(itemIn, 1, blockdoubleplant$enumplanttype.getMeta()));
}
}
/**
* Gets the meta to use for the Pick Block ItemStack result
*/
public int getDamageValue(World worldIn, BlockPos pos)
{
return this.getVariant(worldIn, pos).getMeta();
}
/**
* Whether this IGrowable can grow
*/
public boolean canGrow(World worldIn, BlockPos pos, State state, boolean isClient)
{
BlockDoublePlant.EnumPlantType blockdoubleplant$enumplanttype = this.getVariant(worldIn, pos);
return blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.GRASS && blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.FERN;
return this.type != BlockDoublePlant.EnumPlantType.GRASS && this.type != BlockDoublePlant.EnumPlantType.FERN;
}
public boolean canUseBonemeal(World worldIn, Random rand, BlockPos pos, State state)
@ -300,7 +252,7 @@ public class BlockDoublePlant extends BlockBush implements IGrowable
public void grow(AWorldServer worldIn, Random rand, BlockPos pos, State state)
{
spawnAsEntity(worldIn, pos, new ItemStack(this, 1, this.getVariant(worldIn, pos).getMeta()));
spawnAsEntity(worldIn, pos, new ItemStack(this));
}
/**
@ -308,26 +260,7 @@ public class BlockDoublePlant extends BlockBush implements IGrowable
*/
public State getStateFromMeta(int meta)
{
return (meta & 8) > 0 ? this.getState().withProperty(HALF, BlockDoublePlant.EnumBlockHalf.UPPER) : this.getState().withProperty(HALF, BlockDoublePlant.EnumBlockHalf.LOWER).withProperty(VARIANT, BlockDoublePlant.EnumPlantType.byMetadata(meta & 7));
}
/**
* 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(HALF) == BlockDoublePlant.EnumBlockHalf.UPPER)
{
State iblockstate = worldIn.getState(pos.down());
if (iblockstate.getBlock() == this)
{
state = state.withProperty(VARIANT, iblockstate.getValue(VARIANT));
}
}
return state;
return (meta & 8) > 0 ? this.getState().withProperty(HALF, BlockDoublePlant.EnumBlockHalf.UPPER) : this.getState().withProperty(HALF, BlockDoublePlant.EnumBlockHalf.LOWER);
}
/**
@ -335,21 +268,16 @@ public class BlockDoublePlant extends BlockBush implements IGrowable
*/
public int getMetaFromState(State state)
{
return state.getValue(HALF) == BlockDoublePlant.EnumBlockHalf.UPPER ? 8 | ((Facing)state.getValue(FACING)).getHorizontalIndex() : ((BlockDoublePlant.EnumPlantType)state.getValue(VARIANT)).getMeta();
return state.getValue(HALF) == BlockDoublePlant.EnumBlockHalf.UPPER ? 8 | ((Facing)state.getValue(FACING)).getHorizontalIndex() : 0;
}
protected IProperty[] getProperties()
{
return new IProperty[] {HALF, VARIANT, FACING};
return new IProperty[] {HALF, FACING};
}
// public EnumOffsetType getOffsetType()
// {
// return EnumOffsetType.XZ;
// }
public Model getModel(ModelProvider provider, String name, State state) {
if(state.getValue(VARIANT) == EnumPlantType.SUNFLOWER && state.getValue(HALF) == EnumBlockHalf.UPPER)
if(this.type == EnumPlantType.SUNFLOWER && state.getValue(HALF) == EnumBlockHalf.UPPER)
return provider.getModel("sunflower_front")
.add(0.8f, 0f, 8f, 15.2f, 8f, 8f).noShade().rotate(8, 8, 8, Axis.Y, 45, true).ns("sunflower_top")
.uv(0, 8, 16, 16).noCull()
@ -357,11 +285,11 @@ public class BlockDoublePlant extends BlockBush implements IGrowable
.uv(0, 8, 16, 16).noCull()
.add(9.6f, -1f, 1f, 9.6f, 15f, 15f).noShade().rotate(8, 8, 8, Axis.Z, 22.5f, true).w("sunflower_back")
.uv(0, 0, 16, 16).noCull().e().uv(0, 0, 16, 16).noCull();
else if(state.getValue(VARIANT) == EnumPlantType.FERN || state.getValue(VARIANT) == EnumPlantType.GRASS)
return provider.getModel(state.getValue(VARIANT).getName() + "_" + (state.getValue(HALF) == EnumBlockHalf.UPPER
else if(this.type == EnumPlantType.FERN || this.type == EnumPlantType.GRASS)
return provider.getModel(this.type.getName() + "_" + (state.getValue(HALF) == EnumBlockHalf.UPPER
? "top" : "bottom")).crossTint();
else
return provider.getModel(state.getValue(VARIANT).getName() + "_" + (state.getValue(HALF) == EnumBlockHalf.UPPER
return provider.getModel(this.type.getName() + "_" + (state.getValue(HALF) == EnumBlockHalf.UPPER
? "top" : "bottom")).cross();
}

View file

@ -23,12 +23,22 @@ import common.world.AWorldServer;
public abstract class BlockFlower extends BlockBush
{
protected PropertyEnum<BlockFlower.EnumFlowerType> type;
private static final BlockFlower[] FLOWERS = new BlockFlower[EnumFlowerType.values().length];
private final EnumFlowerType type;
public static BlockFlower getByType(EnumFlowerType type) {
return FLOWERS[type.ordinal()];
}
public BlockFlower()
public BlockFlower(EnumFlowerType type)
{
this.setDefaultState(this.getBaseState().withProperty(this.getTypeProperty(), /* this.getBlockType() == BlockFlower.EnumFlowerColor.RED ? BlockFlower.EnumFlowerType.ROSE : */ BlockFlower.EnumFlowerType.DANDELION));
// this.setTickRandomly();
this.type = type;
FLOWERS[type.ordinal()] = this;
}
public EnumFlowerType getType() {
return this.type;
}
public void updateTick(AWorldServer worldIn, BlockPos pos, State state, Random rand)
@ -36,154 +46,40 @@ public abstract class BlockFlower extends BlockBush
if(Vars.flowerDry && worldIn.getTemperatureC(pos) >= 50.0f)
{
worldIn.setState(pos, worldIn.rand.chance(3) ? Blocks.air.getState() :
Blocks.tallgrass.getState().withProperty(BlockTallGrass.TYPE, BlockTallGrass.EnumType.DEAD_BUSH));
Blocks.dead_bush.getState());
return;
}
super.updateTick(worldIn, pos, state, rand);
}
/**
* 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 ((BlockFlower.EnumFlowerType)state.getValue(this.getTypeProperty())).getMeta();
}
/**
* 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 (BlockFlower.EnumFlowerType blockflower$enumflowertype : BlockFlower.EnumFlowerType.getTypes(this.getBlockType()))
{
list.add(new ItemStack(itemIn, 1, blockflower$enumflowertype.getMeta()));
}
}
/**
* Convert the given metadata into a BlockState for this Block
*/
public State getStateFromMeta(int meta)
{
return this.getState().withProperty(this.getTypeProperty(), BlockFlower.EnumFlowerType.getType(this.getBlockType(), meta));
}
/**
* Get the Type of this flower (Yellow/Red)
*/
public abstract BlockFlower.EnumFlowerColor getBlockType();
public IProperty<BlockFlower.EnumFlowerType> getTypeProperty()
{
if (this.type == null)
{
this.type = PropertyEnum.<BlockFlower.EnumFlowerType>create("type", BlockFlower.EnumFlowerType.class, new Predicate<BlockFlower.EnumFlowerType>()
{
public boolean test(BlockFlower.EnumFlowerType p_apply_1_)
{
return p_apply_1_.getBlockType() == BlockFlower.this.getBlockType();
}
});
}
return this.type;
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
return ((BlockFlower.EnumFlowerType)state.getValue(this.getTypeProperty())).getMeta();
}
protected IProperty[] getProperties()
{
return new IProperty[] {this.getTypeProperty()};
}
// public EnumOffsetType getOffsetType()
// {
// return EnumOffsetType.XZ;
// }
public static enum EnumFlowerColor
{
BASE;
public BlockFlower getBlock()
{
return Blocks.flower; // this == BASE ? Blocks.flower : null;
}
}
public Model getModel(ModelProvider provider, String name, State state) {
return provider.getModel(state.getValue(this.type).getName()).cross();
return provider.getModel(this.type.getName()).cross();
}
public static enum EnumFlowerType implements Identifyable
{
DANDELION(BlockFlower.EnumFlowerColor.BASE, 0, "dandelion", "Löwenzahn"),
ROSE(BlockFlower.EnumFlowerColor.BASE, 1, "rose", "Rose"),
POPPY(BlockFlower.EnumFlowerColor.BASE, 2, "poppy", "Mohn"),
BLUE_ORCHID(BlockFlower.EnumFlowerColor.BASE, 3, "blue_orchid", "Blaue Orchidee"),
ALLIUM(BlockFlower.EnumFlowerColor.BASE, 4, "allium", "Sternlauch"),
HOUSTONIA(BlockFlower.EnumFlowerColor.BASE, 5, "houstonia", "Porzellansternchen"),
RED_TULIP(BlockFlower.EnumFlowerColor.BASE, 6, "red_tulip", "Rote Tulpe"),
ORANGE_TULIP(BlockFlower.EnumFlowerColor.BASE, 7, "orange_tulip", "Orange Tulpe"),
WHITE_TULIP(BlockFlower.EnumFlowerColor.BASE, 8, "white_tulip", "Weiße Tulpe"),
PINK_TULIP(BlockFlower.EnumFlowerColor.BASE, 9, "pink_tulip", "Rosa Tulpe"),
OXEYE_DAISY(BlockFlower.EnumFlowerColor.BASE, 10, "oxeye_daisy", "Margerite"),
BLACK_LOTUS(BlockFlower.EnumFlowerColor.BASE, 11, "black_lotus", "Schwarzer Lotus");
DANDELION("dandelion", "Löwenzahn"),
ROSE("rose", "Rose"),
POPPY("poppy", "Mohn"),
BLUE_ORCHID("blue_orchid", "Blaue Orchidee"),
ALLIUM("allium", "Sternlauch"),
HOUSTONIA("houstonia", "Porzellansternchen"),
RED_TULIP("red_tulip", "Rote Tulpe"),
ORANGE_TULIP("orange_tulip", "Orange Tulpe"),
WHITE_TULIP("white_tulip", "Weiße Tulpe"),
PINK_TULIP("pink_tulip", "Rosa Tulpe"),
OXEYE_DAISY("oxeye_daisy", "Margerite"),
BLACK_LOTUS("black_lotus", "Schwarzer Lotus");
private static final BlockFlower.EnumFlowerType[][] TYPES_FOR_BLOCK = new BlockFlower.EnumFlowerType[BlockFlower.EnumFlowerColor.values().length][];
private final BlockFlower.EnumFlowerColor blockType;
private final int meta;
private final String name;
private final String display;
// private EnumFlowerType(BlockFlower.EnumFlowerColor blockType, int meta, String name)
// {
// this(blockType, meta, name, name);
// }
private EnumFlowerType(BlockFlower.EnumFlowerColor blockType, int meta, String name, String display)
private EnumFlowerType(String name, String display)
{
this.blockType = blockType;
this.meta = meta;
this.name = name;
this.display = display;
}
public BlockFlower.EnumFlowerColor getBlockType()
{
return this.blockType;
}
public int getMeta()
{
return this.meta;
}
public static BlockFlower.EnumFlowerType getType(BlockFlower.EnumFlowerColor blockType, int meta)
{
BlockFlower.EnumFlowerType[] ablockflower$enumflowertype = TYPES_FOR_BLOCK[blockType.ordinal()];
if (meta < 0 || meta >= ablockflower$enumflowertype.length)
{
meta = 0;
}
return ablockflower$enumflowertype[meta];
}
public static BlockFlower.EnumFlowerType[] getTypes(BlockFlower.EnumFlowerColor flowerColor)
{
return TYPES_FOR_BLOCK[flowerColor.ordinal()];
}
public String toString()
{
return this.name;
@ -198,19 +94,5 @@ public abstract class BlockFlower extends BlockBush
{
return this.display;
}
static {
for (final BlockFlower.EnumFlowerColor blockflower$enumflowercolor : BlockFlower.EnumFlowerColor.values())
{
Collection<BlockFlower.EnumFlowerType> collection = Filter.<BlockFlower.EnumFlowerType>filter(Lists.newArrayList(values()), new Predicate<BlockFlower.EnumFlowerType>()
{
public boolean test(BlockFlower.EnumFlowerType p_apply_1_)
{
return p_apply_1_.getBlockType() == blockflower$enumflowercolor;
}
});
TYPES_FOR_BLOCK[blockflower$enumflowercolor.ordinal()] = (BlockFlower.EnumFlowerType[])collection.toArray(new BlockFlower.EnumFlowerType[collection.size()]);
}
}
}
}

View file

@ -79,7 +79,7 @@ public class BlockMushroom extends BlockBush implements IGrowable
if (pos.getY() >= -World.MAX_SIZE_Y && pos.getY() < World.MAX_SIZE_Y)
{
State iblockstate = worldIn.getState(pos.down());
return iblockstate.getBlock() == Blocks.mycelium ? true : (iblockstate.getBlock() == Blocks.dirt && iblockstate.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.PODZOL ? true : worldIn.getLight(pos) < 13 && this.canPlaceBlockOn(iblockstate.getBlock()));
return iblockstate.getBlock() == Blocks.mycelium ? true : (iblockstate.getBlock() == Blocks.podzol ? true : worldIn.getLight(pos) < 13 && this.canPlaceBlockOn(iblockstate.getBlock()));
}
else
{

View file

@ -49,7 +49,7 @@ public class BlockSapling extends BlockBush implements IGrowable
if(Vars.saplingDry && worldIn.getTemperatureC(pos) >= 50.0f)
{
worldIn.setState(pos, worldIn.rand.chance(25) ? Blocks.air.getState() :
Blocks.tallgrass.getState().withProperty(BlockTallGrass.TYPE, BlockTallGrass.EnumType.DEAD_BUSH));
Blocks.dead_bush.getState());
return;
}
// if (!worldIn.client)

View file

@ -27,33 +27,31 @@ import common.world.AWorldServer;
public class BlockTallGrass extends BlockBush implements IGrowable
{
public static final PropertyEnum<BlockTallGrass.EnumType> TYPE = PropertyEnum.<BlockTallGrass.EnumType>create("type", BlockTallGrass.EnumType.class);
private final EnumType type;
public BlockTallGrass()
public BlockTallGrass(EnumType type)
{
super(Material.BUSH);
this.setDefaultState(this.getBaseState().withProperty(TYPE, BlockTallGrass.EnumType.DEAD_BUSH));
this.type = type;
float f = 0.4F;
this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.8F, 0.5F + f);
// this.setTickRandomly();
}
public EnumType getType() {
return this.type;
}
public void updateTick(AWorldServer worldIn, BlockPos pos, State state, Random rand)
{
if(Vars.tallgrassDry && worldIn.getTemperatureC(pos) >= 50.0f && state.getValue(TYPE) != EnumType.DEAD_BUSH)
if(Vars.tallgrassDry && worldIn.getTemperatureC(pos) >= 50.0f && this.type != EnumType.DEAD_BUSH)
{
worldIn.setState(pos, state.getValue(TYPE) == EnumType.GRASS || worldIn.rand.chance(20) ? Blocks.air.getState() :
this.getState().withProperty(TYPE, EnumType.DEAD_BUSH));
worldIn.setState(pos, this.type == EnumType.GRASS || worldIn.rand.chance(20) ? Blocks.air.getState() :
Blocks.dead_bush.getState());
return;
}
super.updateTick(worldIn, pos, state, rand);
}
// public int getBlockColor()
// {
// return ColorizerFoliage.getGrassColor(0.5D, 1.0D);
// }
public boolean canBlockStay(World worldIn, BlockPos pos, State state)
{
return this.canPlaceBlockOn(worldIn.getState(pos.down()).getBlock());
@ -75,8 +73,7 @@ public class BlockTallGrass extends BlockBush implements IGrowable
}
else
{
BlockTallGrass.EnumType blocktallgrass$enumtype = (BlockTallGrass.EnumType)state.getValue(TYPE);
return blocktallgrass$enumtype == BlockTallGrass.EnumType.DEAD_BUSH ? 16777215 : Colorizer.getGrassColor(0.5D, 1.0D);
return this.type == EnumType.DEAD_BUSH ? 16777215 : Colorizer.getGrassColor(0.5D, 1.0D);
}
}
@ -105,8 +102,7 @@ public class BlockTallGrass extends BlockBush implements IGrowable
{
if (!worldIn.client && player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemShears)
{
// player.triggerAchievement(StatRegistry.mineBlockStatArray[BlockRegistry.getIdFromBlock(this)]);
spawnAsEntity(worldIn, pos, new ItemStack(Blocks.tallgrass, 1, ((BlockTallGrass.EnumType)state.getValue(TYPE)).getMeta()));
spawnAsEntity(worldIn, pos, new ItemStack(this));
}
else
{
@ -114,32 +110,12 @@ public class BlockTallGrass extends BlockBush implements IGrowable
}
}
/**
* 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().getMetaFromState(iblockstate);
}
/**
* 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 < 3; ++i) // FIX (dead)bush!
{
list.add(new ItemStack(itemIn, 1, i));
}
}
/**
* Whether this IGrowable can grow
*/
public boolean canGrow(World worldIn, BlockPos pos, State state, boolean isClient)
{
return state.getValue(TYPE) != BlockTallGrass.EnumType.DEAD_BUSH;
return this.type != EnumType.DEAD_BUSH;
}
public boolean canUseBonemeal(World worldIn, Random rand, BlockPos pos, State state)
@ -149,48 +125,22 @@ public class BlockTallGrass extends BlockBush implements IGrowable
public void grow(AWorldServer worldIn, Random rand, BlockPos pos, State state)
{
BlockDoublePlant.EnumPlantType blockdoubleplant$enumplanttype = BlockDoublePlant.EnumPlantType.GRASS;
BlockDoublePlant block = Blocks.tallgrass_double;
if (state.getValue(TYPE) == BlockTallGrass.EnumType.FERN)
if (this.type == BlockTallGrass.EnumType.FERN)
{
blockdoubleplant$enumplanttype = BlockDoublePlant.EnumPlantType.FERN;
block = Blocks.fern_double;
}
if (Blocks.double_plant.canPlaceBlockAt(worldIn, pos))
if (block.canPlaceBlockAt(worldIn, pos))
{
Blocks.double_plant.placeAt(worldIn, pos, blockdoubleplant$enumplanttype, 2);
block.placeAt(worldIn, pos, 2);
}
}
/**
* Convert the given metadata into a BlockState for this Block
*/
public State getStateFromMeta(int meta)
{
return this.getState().withProperty(TYPE, BlockTallGrass.EnumType.byMetadata(meta));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
return ((BlockTallGrass.EnumType)state.getValue(TYPE)).getMeta();
}
protected IProperty[] getProperties()
{
return new IProperty[] {TYPE};
}
// public EnumOffsetType getOffsetType()
// {
// return EnumOffsetType.XYZ;
// }
public Model getModel(ModelProvider provider, String name, State state) {
if(state.getValue(TYPE) != EnumType.DEAD_BUSH)
return provider.getModel(state.getValue(TYPE).getName()).crossTint();
if(this.type != EnumType.DEAD_BUSH)
return provider.getModel(this.type.getName()).crossTint();
else
return provider.getModel("deadbush").cross();
}

View file

@ -1,81 +1,30 @@
package common.block.natural;
import java.util.List;
import common.block.BlockFalling;
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 BlockSand extends BlockFalling
{
public static final PropertyEnum<BlockSand.EnumType> VARIANT = PropertyEnum.<BlockSand.EnumType>create("variant", BlockSand.EnumType.class);
private final EnumType type;
public BlockSand()
public BlockSand(EnumType type)
{
super(Material.LOOSE);
this.setDefaultState(this.getBaseState().withProperty(VARIANT, BlockSand.EnumType.SAND));
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 ((BlockSand.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 (BlockSand.EnumType blocksand$enumtype : BlockSand.EnumType.values())
{
list.add(new ItemStack(itemIn, 1, blocksand$enumtype.getMetadata()));
}
}
// /**
// * Get the MapColor for this Block and the given BlockState
// */
// public MapColor getMapColor(IBlockState state)
// {
// return ((BlockSand.EnumType)state.getValue(VARIANT)).getMapColor();
// }
/**
* Convert the given metadata into a BlockState for this Block
*/
public State getStateFromMeta(int meta)
{
return this.getState().withProperty(VARIANT, BlockSand.EnumType.byMetadata(meta));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
return ((BlockSand.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(state.getValue(VARIANT).getName()).add().all();
return provider.getModel(this.type.getName()).add().all();
}
public static enum EnumType implements Identifyable

View file

@ -1,7 +1,5 @@
package common.block.tech;
import java.util.List;
import common.block.BlockFalling;
import common.block.Material;
import common.entity.item.EntityFalling;
@ -11,15 +9,12 @@ import common.inventory.Container;
import common.inventory.ContainerRepair;
import common.inventory.InventoryPlayer;
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.model.Transforms;
import common.properties.IProperty;
import common.properties.PropertyDirection;
import common.properties.PropertyInteger;
import common.tileentity.IInteractionObject;
import common.util.BlockPos;
import common.util.Facing;
@ -30,15 +25,21 @@ import common.world.World;
public class BlockAnvil extends BlockFalling
{
public static final PropertyDirection FACING = PropertyDirection.create("facing", Facing.Plane.HORIZONTAL);
public static final PropertyInteger DAMAGE = PropertyInteger.create("damage", 0, 2);
private final int damage;
public BlockAnvil()
public BlockAnvil(int damage)
{
super(Material.HEAVY);
this.setDefaultState(this.getBaseState().withProperty(FACING, Facing.NORTH).withProperty(DAMAGE, Integer.valueOf(0)));
this.damage = damage;
this.setDefaultState(this.getBaseState().withProperty(FACING, Facing.NORTH));
this.setLightOpacity(0);
this.setTab(CheatTab.TECHNOLOGY);
}
public int getAnvilDamage() {
return this.damage;
}
public boolean isFullCube()
{
@ -60,7 +61,7 @@ public class BlockAnvil extends BlockFalling
public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, int meta, EntityLiving placer)
{
Facing enumfacing = placer.getHorizontalFacing().rotateY();
return super.onBlockPlaced(worldIn, pos, facing, hitX, hitY, hitZ, meta, placer).withProperty(FACING, enumfacing).withProperty(DAMAGE, Integer.valueOf(meta >> 2));
return super.onBlockPlaced(worldIn, pos, facing, hitX, hitY, hitZ, meta, placer).withProperty(FACING, enumfacing);
}
public boolean onBlockActivated(World worldIn, BlockPos pos, State state, EntityNPC playerIn, Facing side, float hitX, float hitY, float hitZ)
@ -73,15 +74,6 @@ public class BlockAnvil extends BlockFalling
return true;
}
/**
* 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 ((Integer)state.getValue(DAMAGE)).intValue();
}
public void setBlockBoundsBasedOnState(IWorldAccess worldIn, BlockPos pos)
{
Facing enumfacing = (Facing)worldIn.getState(pos).getValue(FACING);
@ -96,16 +88,6 @@ public class BlockAnvil extends BlockFalling
}
}
/**
* 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, 0));
list.add(new ItemStack(itemIn, 1, 1));
list.add(new ItemStack(itemIn, 1, 2));
}
protected void onStartFalling(EntityFalling fallingEntity)
{
fallingEntity.setHurtEntities(true);
@ -134,7 +116,7 @@ public class BlockAnvil extends BlockFalling
*/
public State getStateFromMeta(int meta)
{
return this.getState().withProperty(FACING, Facing.getHorizontal(meta & 3)).withProperty(DAMAGE, Integer.valueOf((meta & 12) == 12 ? 0 : ((meta & 12) >> 2)));
return this.getState().withProperty(FACING, Facing.getHorizontal(meta & 3));
}
/**
@ -144,13 +126,12 @@ public class BlockAnvil extends BlockFalling
{
int i = 0;
i = i | ((Facing)state.getValue(FACING)).getHorizontalIndex();
i = i | ((Integer)state.getValue(DAMAGE)).intValue() << 2;
return i;
}
protected IProperty[] getProperties()
{
return new IProperty[] {FACING, DAMAGE};
return new IProperty[] {FACING};
}
public Transforms getTransform() {
@ -165,7 +146,7 @@ public class BlockAnvil extends BlockFalling
.ns().uv(4, 11, 12, 12).noCull().w().uv(4, 3, 5, 13).rot(90).noCull().e().uv(5, 3, 4, 13).rot(270).noCull()
.add(6, 5, 4, 10, 10, 12).du().uv(10, 12, 6, 4).rot(180).noCull()
.ns().uv(6, 6, 10, 11).noCull().w().uv(5, 4, 10, 12).rot(90).noCull().e().uv(10, 4, 5, 12).rot(270).noCull()
.add(3, 10, 0, 13, 16, 16).d().uv(3, 0, 13, 16).rot(180).noCull().u("anvil_top_" + state.getValue(DAMAGE))
.add(3, 10, 0, 13, 16, 16).d().uv(3, 0, 13, 16).rot(180).noCull().u("anvil_top_" + this.damage)
.uv(3, 0, 13, 16).rot(180).noCull()
.ns().uv(3, 0, 13, 6).noCull().w().uv(10, 0, 16, 16).rot(90).noCull().e().uv(16, 0, 10, 16).rot(270).noCull()
.rotate(ModelRotation.getNorthRot(state.getValue(FACING)));

View file

@ -1,7 +1,5 @@
package common.block.tech;
import java.util.List;
import common.block.BlockContainer;
import common.block.Material;
import common.block.SoundType;
@ -10,7 +8,6 @@ import common.init.Blocks;
import common.init.ItemRegistry;
import common.item.CheatTab;
import common.item.Item;
import common.item.ItemStack;
import common.model.Model;
import common.model.ModelProvider;
import common.model.Transforms;
@ -180,17 +177,6 @@ public class BlockDaylightDetector extends BlockContainer
return new IProperty[] {POWER};
}
/**
* 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)
{
if (!this.inverted)
{
super.getSubBlocks(itemIn, tab, list);
}
}
public Transforms getTransform() {
return Transforms.FLAT;
}

View file

@ -16,7 +16,7 @@ import common.ai.EntityAIWatchClosest;
import common.ai.EntityJumpHelper;
import common.ai.EntityMoveHelper;
import common.block.Block;
import common.block.foliage.BlockTallGrass;
import common.block.foliage.BlockFlower;
import common.entity.DamageSource;
import common.entity.Entity;
import common.entity.npc.Alignment;
@ -25,7 +25,6 @@ import common.entity.types.EntityAnimal;
import common.entity.types.EntityLiving;
import common.init.BlockRegistry;
import common.init.Blocks;
import common.init.ItemRegistry;
import common.init.Items;
import common.init.SoundEvent;
import common.item.Item;
@ -64,9 +63,12 @@ public class EntityRabbit extends EntityAnimal {
this.navigator.setHeightRequirement(2.5F);
this.tasks.addTask(1, new EntityAISwimming(this));
this.tasks.addTask(1, new EntityRabbit.AIPanic(this, 1.33D));
this.tasks.addTask(2, new EntityAITempt(this, 1.0D, Items.carrot, false));
this.tasks.addTask(2, new EntityAITempt(this, 1.0D, Items.golden_carrot, false));
this.tasks.addTask(2, new EntityAITempt(this, 1.0D, ItemRegistry.getItemFromBlock(Blocks.flower), false));
this.tasks.addTask(2, new EntityAITempt(this, 1.0D, new Predicate<ItemStack>() {
public boolean test(ItemStack stack) {
Item item = stack.getItem();
return item == Items.carrot || item == Items.golden_carrot || item.getBlock() instanceof BlockFlower;
}
}, false));
this.tasks.addTask(3, new EntityAIMate(this, 0.8D) {
protected int getMatingCooldown() {
return EntityRabbit.this.rand.excl(50, 200);
@ -268,7 +270,7 @@ public class EntityRabbit extends EntityAnimal {
}
private boolean isRabbitBreedingItem(Item itemIn) {
return itemIn == Items.carrot || itemIn == Items.golden_carrot || itemIn == ItemRegistry.getItemFromBlock(Blocks.flower);
return itemIn == Items.carrot || itemIn == Items.golden_carrot || itemIn.getBlock() instanceof BlockFlower;
}
public EntityRabbit createChild(EntityLiving ageable) {
@ -489,8 +491,8 @@ public class EntityRabbit extends EntityAnimal {
if(Vars.rabidRabbits)
return block != Blocks.bedrock;
return block == Blocks.carrot || block == Blocks.potato || block == Blocks.wheat || block == Blocks.brown_mushroom ||
block == Blocks.flower || block == Blocks.blue_mushroom ||
(block == Blocks.tallgrass && state.getValue(BlockTallGrass.TYPE) == BlockTallGrass.EnumType.GRASS);
block instanceof BlockFlower || block == Blocks.blue_mushroom ||
block == Blocks.tallgrass;
}
}

View file

@ -122,7 +122,7 @@ public class EntitySheep extends EntityAnimal
{
if (!this.getSheared())
{
this.entityDropItem(new ItemStack(ItemRegistry.getItemFromBlock(Blocks.wool), 1, this.getFleeceColor().getMetadata()), 0.0F);
this.entityDropItem(new ItemStack(ItemRegistry.getRegisteredItem(this.getFleeceColor().getName() + "_wool")), 0.0F);
}
// int i = this.rand.roll(2) + this.rand.zrange(1 + lootingModifier);
@ -191,7 +191,7 @@ public class EntitySheep extends EntityAnimal
for (int j = 0; j < i; ++j)
{
EntityItem entityitem = this.entityDropItem(new ItemStack(ItemRegistry.getItemFromBlock(Blocks.wool), 1, this.getFleeceColor().getMetadata()), 1.0F);
EntityItem entityitem = this.entityDropItem(new ItemStack(ItemRegistry.getRegisteredItem(this.getFleeceColor().getName() + "_wool")), 1.0F);
entityitem.motionY += (double)(this.rand.floatv() * 0.05F);
entityitem.motionX += (double)((this.rand.floatv() - this.rand.floatv()) * 0.1F);
entityitem.motionZ += (double)((this.rand.floatv() - this.rand.floatv()) * 0.1F);

View file

@ -169,7 +169,7 @@ public class EntityFalling extends Entity implements IObjectData
if (i > 0)
{
List<Entity> list = Lists.newArrayList(this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox()));
boolean flag = block == Blocks.anvil;
boolean flag = block instanceof BlockAnvil;
DamageSource damagesource = flag ? DamageSource.anvil : DamageSource.fallingBlock;
if(this.worldObj.client || (flag ? Vars.damageAcme : Vars.damageSquish)) {
@ -181,7 +181,8 @@ public class EntityFalling extends Entity implements IObjectData
if (flag && (this.worldObj.client || Vars.anvilFallDecay) && (double)this.rand.floatv() < 0.05000000074505806D + (double)i * 0.05D)
{
int j = ((Integer)this.fallTile.getValue(BlockAnvil.DAMAGE)).intValue();
BlockAnvil anvil = (BlockAnvil)block;
int j = anvil.getAnvilDamage();
++j;
if (j > 2)
@ -190,7 +191,7 @@ public class EntityFalling extends Entity implements IObjectData
}
else
{
this.fallTile = this.fallTile.withProperty(BlockAnvil.DAMAGE, Integer.valueOf(j));
this.fallTile = BlockRegistry.getRegisteredBlock("anvil_damaged_" + j).getState().withProperty(BlockAnvil.FACING, this.fallTile.getValue(BlockAnvil.FACING));
}
}
}

View file

@ -5,6 +5,7 @@ import java.util.List;
import common.entity.effect.EntityLightning;
import common.entity.types.EntityLiving;
import common.init.Items;
import common.item.ItemPotion;
import common.item.ItemStack;
import common.potion.Potion;
import common.potion.PotionEffect;
@ -37,9 +38,9 @@ public class EntityMage extends EntityNPC
ItemStack itemstack = this.getHeldItem();
this.setItem(0, null);
if (itemstack != null && itemstack.getItem() == Items.potion)
if (itemstack != null && itemstack.getItem() instanceof ItemPotion potion)
{
List<PotionEffect> list = Items.potion.getEffects(itemstack);
List<PotionEffect> list = potion.getEffects();
if (list != null)
{
@ -84,14 +85,14 @@ public class EntityMage extends EntityNPC
if (i > -1)
{
this.setItem(0, new ItemStack(Items.potion, 1, i));
this.setItem(0, new ItemStack(ItemPotion.getPotionItem(i)));
this.attackTimer = this.getHeldItem().getMaxItemUseDuration();
this.drinking = true;
this.setSpeedMod(0.165f);
}
else if(this.rand.chance(80)) {
boolean far = this.getAttackTarget() != null && this.getAttackTarget().getDistanceSqToEntity(this) >= 256.0;
this.setItem(0, far || this.rand.chance() ? new ItemStack(Items.potion, 1, 16384) : null);
this.setItem(0, far || this.rand.chance() ? new ItemStack(Items.splash_potion) : null);
}
}
}

View file

@ -6,6 +6,7 @@ import common.entity.types.EntityLiving;
import common.entity.types.EntityThrowable;
import common.entity.types.IObjectData;
import common.init.Items;
import common.item.ItemPotion;
import common.item.ItemStack;
import common.potion.Potion;
import common.potion.PotionEffect;
@ -17,9 +18,6 @@ import common.world.World;
public class EntityPotion extends EntityThrowable implements IObjectData
{
/**
* The damage value of the thrown potion that this EntityPotion represents.
*/
private ItemStack potionDamage;
public EntityPotion(World worldIn)
@ -29,7 +27,7 @@ public class EntityPotion extends EntityThrowable implements IObjectData
public EntityPotion(World worldIn, EntityLiving throwerIn, int meta)
{
this(worldIn, throwerIn, new ItemStack(Items.potion, 1, meta));
this(worldIn, throwerIn, new ItemStack(ItemPotion.getPotionItem(meta)));
}
public EntityPotion(World worldIn, EntityLiving throwerIn, ItemStack potionDamageIn)
@ -40,7 +38,7 @@ public class EntityPotion extends EntityThrowable implements IObjectData
public EntityPotion(World worldIn, double x, double y, double z, int data)
{
this(worldIn, x, y, z, new ItemStack(Items.potion, 1, data));
this(worldIn, x, y, z, new ItemStack(ItemPotion.getPotionItem(data)));
}
public EntityPotion(World worldIn, double x, double y, double z, ItemStack potionDamageIn)
@ -72,12 +70,7 @@ public class EntityPotion extends EntityThrowable implements IObjectData
*/
public void setPotionDamage(int potionId)
{
if (this.potionDamage == null)
{
this.potionDamage = new ItemStack(Items.potion);
}
this.potionDamage.setMetadata(potionId);
this.potionDamage = new ItemStack(ItemPotion.getPotionItem(potionId));
}
/**
@ -90,7 +83,7 @@ public class EntityPotion extends EntityThrowable implements IObjectData
this.potionDamage = new ItemStack(Items.potion);
}
return this.potionDamage.getMetadata();
return this.potionDamage.getItem() instanceof ItemPotion potion ? potion.getPotionData() : 0;
}
/**
@ -100,7 +93,7 @@ public class EntityPotion extends EntityThrowable implements IObjectData
{
if (!this.worldObj.client)
{
List<PotionEffect> list = Items.potion.getEffects(this.potionDamage);
List<PotionEffect> list = this.potionDamage != null && this.potionDamage.getItem() instanceof ItemPotion potion ? potion.getEffects() : null;
BoundingBox axisalignedbb = this.getEntityBoundingBox().expand(4.0D, 2.0D, 4.0D);
List<EntityLiving> list1 = this.worldObj.<EntityLiving>getEntitiesWithinAABB(EntityLiving.class, axisalignedbb);
@ -171,7 +164,7 @@ public class EntityPotion extends EntityThrowable implements IObjectData
this.setPotionDamage(tagCompund.getInt("potionValue"));
}
if (this.potionDamage == null)
if (this.potionDamage == null || !(this.potionDamage.getItem() instanceof ItemPotion))
{
this.setDead();
}

View file

@ -7,6 +7,7 @@ import common.block.tech.BlockAnvil;
import common.enchantment.Enchantment;
import common.enchantment.EnchantmentHelper;
import common.entity.npc.EntityNPC;
import common.init.BlockRegistry;
import common.init.Blocks;
import common.init.Items;
import common.item.ItemStack;
@ -100,9 +101,9 @@ public class ContainerRepair extends Container
ContainerRepair.this.maximumCost = 0;
State iblockstate = worldIn.getState(blockPosIn);
if (/* !playerIn.creative && */ !worldIn.client && Vars.anvilRepairDecay && iblockstate.getBlock() == Blocks.anvil && playerIn.getRNG().floatv() < 0.12F)
if (/* !playerIn.creative && */ !worldIn.client && Vars.anvilRepairDecay && iblockstate.getBlock() instanceof BlockAnvil anvil && playerIn.getRNG().floatv() < 0.12F)
{
int l = ((Integer)iblockstate.getValue(BlockAnvil.DAMAGE)).intValue();
int l = anvil.getAnvilDamage();
++l;
if (l > 2)
@ -112,7 +113,7 @@ public class ContainerRepair extends Container
}
else
{
worldIn.setState(blockPosIn, iblockstate.withProperty(BlockAnvil.DAMAGE, Integer.valueOf(l)), 2);
worldIn.setState(blockPosIn, BlockRegistry.getRegisteredBlock("anvil_damaged_" + l).getState().withProperty(BlockAnvil.FACING, iblockstate.getValue(BlockAnvil.FACING)), 2);
worldIn.playAuxSFX(1021, blockPosIn, 0);
}
}

View file

@ -15,8 +15,6 @@ import common.model.ItemMeshDefinition;
import common.model.Model;
import common.model.ModelProvider;
import common.model.Transforms;
import common.rng.Random;
import common.tags.TagObject;
import common.util.BlockPos;
import common.util.ExtMath;
import common.util.Facing;
@ -243,7 +241,7 @@ public class Item
public void getSubItems(Item itemIn, CheatTab tab, List<ItemStack> subItems)
{
subItems.add(new ItemStack(itemIn, 1, 0));
subItems.add(new ItemStack(itemIn));
}
public CheatTab getTab()
@ -305,6 +303,6 @@ public class Item
}
public void getRenderItems(Item itemIn, List<ItemStack> subItems) {
this.getSubItems(itemIn, null, subItems);
subItems.add(new ItemStack(itemIn));
}
}

View file

@ -2,16 +2,11 @@ package common.item;
import common.block.Block;
public class ItemAnvilBlock extends ItemMultiTexture
public class ItemAnvilBlock extends ItemBlock
{
public ItemAnvilBlock(Block block, int data)
public ItemAnvilBlock(Block block)
{
super(block, data);
}
public int getMetadata()
{
return this.data << 2;
super(block);
}
public boolean isMagnetic() {

View file

@ -202,14 +202,10 @@ public class ItemBanner extends ItemBlock
{
public String getModelLocation(ItemStack stack)
{
return "item/banner#0" + '#' + "inventory";
return "item/banner" + '#' + "inventory";
}
};
}
public void getRenderItems(Item itemIn, List<ItemStack> subItems) {
subItems.add(new ItemStack(itemIn, 1, 0));
}
public Model getModel(ModelProvider provider, String name) {
return provider.getModel(provider.getEntityModel(), this.getTransform());

View file

@ -178,14 +178,6 @@ public class ItemBlock extends Item
return this.block.getTab();
}
/**
* returns a list of items with the same ID, but different meta (eg: dye returns 16 items)
*/
public void getSubItems(Item itemIn, CheatTab tab, List<ItemStack> subItems)
{
this.block.getSubBlocks(itemIn, tab, subItems);
}
public Block getBlock()
{
return this.block;

View file

@ -138,19 +138,20 @@ public class ItemBow extends Item
}
public void getRenderItems(Item itemIn, List<ItemStack> subItems) {
subItems.add(new ItemStack(itemIn, 1, 0));
super.getRenderItems(itemIn, subItems);
for(int z = 0; z < 3; z++) {
subItems.add(new ItemStack(itemIn, 1, 1 + z));
final int data = z + 1;
subItems.add(new ItemStack(new ItemBow() {
public Model getModel(ModelProvider provider, String name) {
return provider.getModel(this.getTransform(), "bow_pulling_" + data);
}
}));
}
}
public Transforms getTransform() {
return Transforms.RANGED;
}
public Model getModel(ModelProvider provider, String name) {
return provider.getModel(this.getTransform(), data == 0 ? "bow" : ("bow_pulling_" + (data - 1)));
}
public boolean canBeWielded() {
return true;

View file

@ -22,11 +22,6 @@ public class ItemCloth extends ItemBlock
this(block, display, null, color);
}
public int getMetadata()
{
return this.color.getMetadata();
}
public String getDisplay(ItemStack stack)
{
return this.color.getSubject(this.display) + " " + super.getDisplay(stack);

View file

@ -5,27 +5,20 @@ import common.block.Block;
public class ItemColored extends ItemBlock
{
private final Block coloredBlock;
private final int data;
public ItemColored(Block block, String flatTexture, int data)
public ItemColored(Block block, String flatTexture)
{
super(block, flatTexture);
this.coloredBlock = block;
this.data = data;
}
public ItemColored(Block block, int data)
public ItemColored(Block block)
{
this(block, null, data);
this(block, null);
}
public int getColorFromItemStack(ItemStack stack, int renderPass)
{
return this.coloredBlock.getRenderColor(this.coloredBlock.getStateFromMeta(this.data));
}
public int getMetadata()
{
return this.data;
return this.coloredBlock.getRenderColor(this.coloredBlock.getState());
}
}

View file

@ -7,22 +7,24 @@ import common.color.Colorizer;
import common.model.Model;
import common.model.ModelProvider;
public class ItemDoublePlant extends ItemMultiTexture
public class ItemDoublePlant extends ItemBlock
{
public ItemDoublePlant(Block block, int data)
private final BlockDoublePlant.EnumPlantType type;
public ItemDoublePlant(Block block, BlockDoublePlant.EnumPlantType type)
{
super(block, true, data);
super(block, "");
this.type = type;
}
public int getColorFromItemStack(ItemStack stack, int renderPass)
{
BlockDoublePlant.EnumPlantType blockdoubleplant$enumplanttype = BlockDoublePlant.EnumPlantType.byMetadata(this.data);
return blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.GRASS && blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.FERN ? super.getColorFromItemStack(stack, renderPass) : Colorizer.getGrassColor(0.5D, 1.0D);
return this.type != BlockDoublePlant.EnumPlantType.GRASS && this.type != BlockDoublePlant.EnumPlantType.FERN ? super.getColorFromItemStack(stack, renderPass) : Colorizer.getGrassColor(0.5D, 1.0D);
}
public Model getModel(ModelProvider provider, String name) {
return provider.getModel(this.getTransform(), "blocks/" + (
BlockDoublePlant.EnumPlantType.byMetadata(this.data) == EnumPlantType.SUNFLOWER ? "sunflower_front" :
BlockDoublePlant.EnumPlantType.byMetadata(this.data).getName() + "_top"));
this.type == EnumPlantType.SUNFLOWER ? "sunflower_front" :
this.type.getName() + "_top"));
}
}

View file

@ -196,12 +196,8 @@ public class ItemEnchantedBook extends Item
{
public String getModelLocation(ItemStack stack)
{
return "item/enchanted_book#0" + '#' + "inventory";
return "item/enchanted_book" + '#' + "inventory";
}
};
}
public void getRenderItems(Item itemIn, List<ItemStack> subItems) {
subItems.add(new ItemStack(itemIn, 1, 0));
}
}

View file

@ -79,15 +79,15 @@ public class ItemFishingRod extends Item
}
public void getRenderItems(Item itemIn, List<ItemStack> subItems) {
subItems.add(new ItemStack(itemIn, 1, 0));
subItems.add(new ItemStack(itemIn, 1, 1));
super.getRenderItems(itemIn, subItems);
subItems.add(new ItemStack(new ItemFishingRod() {
public Model getModel(ModelProvider provider, String name) {
return provider.getModel(this.getTransform(), "fishing_rod_cast");
}
}));
}
public Transforms getTransform() {
return Transforms.TOOL_FLIP;
}
public Model getModel(ModelProvider provider, String name) {
return provider.getModel(this.getTransform(), data == 1 ? "fishing_rod_cast" : "fishing_rod");
}
}

View file

@ -47,14 +47,12 @@ public class ItemHoe extends Item
if (block == Blocks.dirt)
{
switch ((BlockDirt.DirtType)iblockstate.getValue(BlockDirt.VARIANT))
{
case DIRT:
return this.useHoe(stack, playerIn, worldIn, pos, Blocks.farmland.getState());
return this.useHoe(stack, playerIn, worldIn, pos, Blocks.farmland.getState());
}
case COARSE_DIRT:
return this.useHoe(stack, playerIn, worldIn, pos, Blocks.dirt.getState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.DIRT));
}
if (block == Blocks.coarse_dirt)
{
return this.useHoe(stack, playerIn, worldIn, pos, Blocks.dirt.getState());
}
}

View file

@ -1,32 +1,29 @@
package common.item;
import common.block.foliage.BlockLeaves;
import common.block.foliage.LeavesType;
public class ItemLeaves extends ItemBlock
{
protected final BlockLeaves leaves;
private final LeavesType type;
public ItemLeaves(BlockLeaves block, LeavesType type)
public ItemLeaves(BlockLeaves block)
{
super(block);
this.leaves = block;
this.type = type;
}
public int getMetadata()
{
return this.type.getIndex() | 8;
return 8;
}
public int getColorFromItemStack(ItemStack stack, int renderPass)
{
return this.leaves.getRenderColor(this.leaves.getState().withProperty(BlockLeaves.TYPE, this.type));
return this.leaves.getRenderColor(this.leaves.getState());
}
public String getDisplay(ItemStack stack)
{
return this.block.getDisplay() + " (" + this.type.getDisplayName() + ")";
return this.block.getDisplay() + " (" + this.leaves.getType().getDisplayName() + ")";
}
}

View file

@ -14,7 +14,7 @@ public class ItemLilyPad extends ItemColored
{
public ItemLilyPad(Block block)
{
super(block, false, "");
super(block, "");
}
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityNPC playerIn)
@ -60,9 +60,4 @@ public class ItemLilyPad extends ItemColored
return itemStackIn;
}
}
public int getColorFromItemStack(ItemStack stack, int renderPass)
{
return Blocks.waterlily.getRenderColor(Blocks.waterlily.getState());
}
}

View file

@ -1,24 +0,0 @@
package common.item;
import common.block.Block;
public class ItemMultiTexture extends ItemBlock
{
protected final int data;
public ItemMultiTexture(Block block, boolean flatTexture, int data)
{
super(block, flatTexture ? "" : null);
this.data = data;
}
public ItemMultiTexture(Block block, int data)
{
this(block, false, data);
}
public int getMetadata()
{
return this.data;
}
}

View file

@ -20,58 +20,37 @@ import common.world.World;
public class ItemPotion extends Item
{
private Map<Integer, List<PotionEffect>> effectCache = Maps.<Integer, List<PotionEffect>>newHashMap();
private static final Map<Integer, ItemPotion> POTIONS = Maps.newHashMap();
private static final Map<List<PotionEffect>, Integer> SUB_ITEMS_CACHE = Maps.<List<PotionEffect>, Integer>newLinkedHashMap();
private final int data;
private List<PotionEffect> effectCache;
public static ItemPotion getPotionItem(int data) {
return POTIONS.getOrDefault(data, isSplash(data) ? Items.splash_potion : Items.potion);
}
public ItemPotion()
public ItemPotion(int data)
{
this.data = data;
this.setMaxAmount(1);
this.setTab(CheatTab.MAGIC);
this.setColor(TextColor.ORK);
POTIONS.put(data, this);
}
public int getPotionData() {
return this.data;
}
public List<PotionEffect> getEffects(ItemStack stack)
public List<PotionEffect> getEffects()
{
// if (stack.hasTagCompound() && stack.getTagCompound().hasList("CustomPotionEffects"))
// {
// List<PotionEffect> list1 = Lists.<PotionEffect>newArrayList();
// NBTTagList nbttaglist = stack.getTagCompound().getTagList("CustomPotionEffects", 10);
//
// for (int i = 0; i < nbttaglist.tagCount(); ++i)
// {
// NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i);
// PotionEffect potioneffect = PotionEffect.readCustomPotionEffectFromNBT(nbttagcompound);
//
// if (potioneffect != null)
// {
// list1.add(potioneffect);
// }
// }
//
// return list1;
// }
// else
// {
List<PotionEffect> list = (List)this.effectCache.get(Integer.valueOf(stack.getMetadata()));
List<PotionEffect> list = this.effectCache;
if (list == null)
{
list = PotionHelper.getPotionEffects(stack.getMetadata());
this.effectCache.put(Integer.valueOf(stack.getMetadata()), list);
}
return list;
// }
}
public List<PotionEffect> getEffects(int meta)
{
List<PotionEffect> list = (List)this.effectCache.get(Integer.valueOf(meta));
if (list == null)
{
list = PotionHelper.getPotionEffects(meta);
this.effectCache.put(Integer.valueOf(meta), list);
list = this.effectCache = PotionHelper.getPotionEffects(this.data);
}
return list;
@ -90,7 +69,7 @@ public class ItemPotion extends Item
if (!worldIn.client)
{
List<PotionEffect> list = this.getEffects(stack);
List<PotionEffect> list = this.getEffects();
if (list != null)
{
@ -140,7 +119,7 @@ public class ItemPotion extends Item
*/
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityNPC playerIn)
{
if (isSplash(itemStackIn.getMetadata()))
if (isSplash(this.data))
{
// if (!playerIn.creative)
// {
@ -172,19 +151,19 @@ public class ItemPotion extends Item
return (meta & 16384) != 0;
}
public int getColorFromDamage(int meta)
public int getColorFromDamage()
{
return PotionHelper.getLiquidColor(meta);
return PotionHelper.getLiquidColor(this.data);
}
public int getColorFromItemStack(ItemStack stack, int renderPass)
{
return renderPass > 0 ? 16777215 : this.getColorFromDamage(stack.getMetadata());
return renderPass > 0 ? 16777215 : this.getColorFromDamage();
}
public boolean isEffectInstant(int meta)
public boolean isEffectInstant()
{
List<PotionEffect> list = this.getEffects(meta);
List<PotionEffect> list = this.getEffects();
if (list != null && !list.isEmpty())
{
@ -206,20 +185,20 @@ public class ItemPotion extends Item
public String getDisplay(ItemStack stack)
{
if ((stack.getMetadata() & 16383) == 0)
if ((this.data & 16383) == 0)
{
return (isSplash(stack.getMetadata()) ? "Werfbare " : "") + "Wasserflasche";
return (isSplash(this.data) ? "Werfbare " : "") + "Wasserflasche";
}
else
{
String s = "";
if (isSplash(stack.getMetadata()))
if (isSplash(this.data))
{
s = "Werfbarer ";
}
List<PotionEffect> list = Items.potion.getEffects(stack);
List<PotionEffect> list = this.getEffects();
if (list != null && !list.isEmpty())
{
@ -229,7 +208,7 @@ public class ItemPotion extends Item
}
else
{
String s1 = PotionHelper.getPotionPrefix(stack.getMetadata());
String s1 = PotionHelper.getPotionPrefix(this.data);
return s1.trim() + " " + super.getDisplay(stack);
}
}
@ -240,9 +219,9 @@ public class ItemPotion extends Item
*/
public void addInformation(ItemStack stack, EntityNPC playerIn, List<String> tooltip)
{
if ((stack.getMetadata() & 16383) != 0)
if ((this.data & 16383) != 0)
{
List<PotionEffect> list = Items.potion.getEffects(stack);
List<PotionEffect> list = this.getEffects();
List<String> implications = Lists.newArrayList();
if (list != null && !list.isEmpty())
@ -287,17 +266,15 @@ public class ItemPotion extends Item
public boolean hasEffect(ItemStack stack)
{
List<PotionEffect> list = this.getEffects(stack);
List<PotionEffect> list = this.getEffects();
return list != null && !list.isEmpty();
}
/**
* returns a list of items with the same ID, but different meta (eg: dye returns 16 items)
*/
public void getSubItems(Item itemIn, CheatTab tab, List<ItemStack> subItems)
public static List<Integer> getValidDataValues()
{
super.getSubItems(itemIn, tab, subItems);
subItems.add(new ItemStack(itemIn, 1, 16384));
List<Integer> data = Lists.newArrayList();
data.add(0);
data.add(16384);
if (SUB_ITEMS_CACHE.isEmpty())
{
@ -348,43 +325,25 @@ public class ItemPotion extends Item
while (iterator.hasNext())
{
int j1 = ((Integer)iterator.next()).intValue();
subItems.add(new ItemStack(itemIn, 1, j1));
data.add(j1);
}
return data;
}
// public Set<String> getValidTags() {
// return Sets.newHashSet("CustomPotionEffects");
// }
// public boolean validateNbt(NBTTagCompound tag, boolean adv) {
// if(tag.hasKey("CustomPotionEffects")) {
// if(!adv) {
// return false;
// }
// if(!tag.hasList("CustomPotionEffects")) {
// return false;
// }
// NBTTagList effects = tag.getTagList("CustomPotionEffects", 10);
// if(effects.hasNoTags()) {
// return false;
// }
// }
// return true;
// }
public ItemMeshDefinition getMesher() {
return new ItemMeshDefinition()
{
public String getModelLocation(ItemStack stack)
{
return ItemPotion.isSplash(stack.getMetadata()) ? ("item/potion#16384" + '#' + "inventory") : ("item/potion#0" + '#' + "inventory");
return ItemPotion.isSplash(ItemPotion.this.data) ? ("item/splash_potion" + '#' + "inventory") : ("item/potion" + '#' + "inventory");
}
};
}
public void getRenderItems(Item itemIn, List<ItemStack> subItems) {
subItems.add(new ItemStack(itemIn, 1, 0));
subItems.add(new ItemStack(itemIn, 1, 16384));
if(this.data == 0 || this.data == 16384)
super.getRenderItems(itemIn, subItems);
}
public Model getModel(ModelProvider provider, String name) {

View file

@ -1,6 +1,6 @@
package common.item;
import common.block.Block;
import common.block.tech.BlockTNT;
import common.color.TextColor;
public class ItemTNT extends ItemBlock
@ -9,18 +9,13 @@ public class ItemTNT extends ItemBlock
private final int power;
public ItemTNT(Block block, int power)
public ItemTNT(BlockTNT block)
{
super(block);
this.power = power;
this.power = block.getExplosionPower();
this.setColor(TextColor.RED);
}
public int getMetadata()
{
return (this.power & 7) << 1;
}
public String getDisplay(ItemStack stack)
{
return super.getDisplay(stack) + (this.power == 0 ? "" : " " + TIERS[this.power-1]);

View file

@ -5,14 +5,17 @@ import common.block.artificial.BlockWall;
import common.model.Model;
import common.model.ModelProvider;
public class ItemWall extends ItemMultiTexture {
public ItemWall(Block block, int data) {
super(block, data);
public class ItemWall extends ItemBlock {
private final BlockWall.EnumType type;
public ItemWall(Block block, BlockWall.EnumType type) {
super(block);
this.type = type;
}
public Model getModel(ModelProvider provider, String name) {
return provider.getModel(
provider.getModel(this.block.getStateFromMeta(this.data).getValue(BlockWall.VARIANT).getName())
provider.getModel(this.type.getName())
.add(4, 0, 4, 12, 16, 12)
.d().uv(4, 4, 12, 12)
.u().uv(4, 4, 12, 12).noCull()

View file

@ -19,7 +19,7 @@ public class RngLoot extends RngItem
super(weight);
this.item = new ItemStack(item);
this.minStackSize = min;
this.setMaxAmount(max);
this.maxStackSize = max;
}
public RngLoot(ItemStack stack, int min, int max, int weight)
@ -27,7 +27,7 @@ public class RngLoot extends RngItem
super(weight);
this.item = stack;
this.minStackSize = min;
this.setMaxAmount(max);
this.maxStackSize = max;
}
public ItemStack getItem(Random rand) {

View file

@ -143,21 +143,20 @@ public class TileEntityBrewingStand extends TileEntityLockable implements ITicka
for (int i = 0; i < 3; ++i)
{
if (this.brewingItemStacks[i] != null && this.brewingItemStacks[i].getItem() == Items.potion)
if (this.brewingItemStacks[i] != null && this.brewingItemStacks[i].getItem() instanceof ItemPotion potion)
{
int j = this.brewingItemStacks[i].getMetadata();
int k = this.getPotionResult(j, itemstack);
int k = this.getPotionResult(potion.getPotionData(), itemstack);
if (!ItemPotion.isSplash(j) && ItemPotion.isSplash(k))
if (!ItemPotion.isSplash(potion.getPotionData()) && ItemPotion.isSplash(k))
{
flag = true;
break;
}
List<PotionEffect> list = Items.potion.getEffects(j);
List<PotionEffect> list1 = Items.potion.getEffects(k);
List<PotionEffect> list = potion.getEffects();
List<PotionEffect> list1 = ItemPotion.getPotionItem(k).getEffects();
if ((j <= 0 || list != list1) && (list == null || !list.equals(list1) && list1 != null) && j != k)
if ((potion.getPotionData() <= 0 || list != list1) && (list == null || !list.equals(list1) && list1 != null) && potion.getPotionData() != k)
{
flag = true;
break;
@ -182,23 +181,22 @@ public class TileEntityBrewingStand extends TileEntityLockable implements ITicka
for (int i = 0; i < 3; ++i)
{
if (this.brewingItemStacks[i] != null && this.brewingItemStacks[i].getItem() == Items.potion)
if (this.brewingItemStacks[i] != null && this.brewingItemStacks[i].getItem() instanceof ItemPotion potion)
{
int j = this.brewingItemStacks[i].getMetadata();
int k = this.getPotionResult(j, itemstack);
List<PotionEffect> list = Items.potion.getEffects(j);
List<PotionEffect> list1 = Items.potion.getEffects(k);
int k = this.getPotionResult(potion.getPotionData(), itemstack);
List<PotionEffect> list = potion.getEffects();
List<PotionEffect> list1 = ItemPotion.getPotionItem(k).getEffects();
if (j > 0 && list == list1 || list != null && (list.equals(list1) || list1 == null))
if (potion.getPotionData() > 0 && list == list1 || list != null && (list.equals(list1) || list1 == null))
{
if (!ItemPotion.isSplash(j) && ItemPotion.isSplash(k))
if (!ItemPotion.isSplash(potion.getPotionData()) && ItemPotion.isSplash(k))
{
this.brewingItemStacks[i].setMetadata(k);
this.brewingItemStacks[i] = new ItemStack(ItemPotion.getPotionItem(k));
}
}
else if (j != k)
else if (potion.getPotionData() != k)
{
this.brewingItemStacks[i].setMetadata(k);
this.brewingItemStacks[i] = new ItemStack(ItemPotion.getPotionItem(k));
}
}
}