Compare commits

...

16 commits

Author SHA1 Message Date
Sen
55aac31bb9
change charged golden apple 2025-06-21 20:29:40 +02:00
Sen
e24794aa84
fix potion overlay 2025-06-21 20:25:12 +02:00
Sen
8c44c024ab
fix server block id loading 2025-06-21 20:17:36 +02:00
Sen
1b041cbf56
block cleanup #11 + textures 2025-06-21 20:09:28 +02:00
Sen
518300e68f
block cleanup #10 2025-06-21 19:59:52 +02:00
Sen
18d4ea7167
block cleanup #9 2025-06-21 19:26:04 +02:00
Sen
9cc439d774
block cleanup #8 2025-06-21 19:06:58 +02:00
Sen
9de6017751
block cleanup #7 2025-06-21 18:58:35 +02:00
Sen
7b25e6181e
block cleanup #6 2025-06-21 14:04:15 +02:00
Sen
9a6abe495c
block cleanup #5 2025-06-21 12:08:26 +02:00
Sen
84611eef7f
block cleanup #4 2025-06-21 11:23:42 +02:00
Sen
a836d7a2a5
property cleanup 2025-06-21 10:31:07 +02:00
Sen
734279ad95
block cleanup #3 2025-06-20 23:54:12 +02:00
Sen
473ef16043
block cleanup #2 2025-06-20 23:10:16 +02:00
Sen
54511912dd
block cleanup #1 2025-06-20 15:40:56 +02:00
Sen
1713ca7f96
temp remove ids, broken 2025-06-20 00:13:42 +02:00
299 changed files with 2993 additions and 5390 deletions

View file

@ -161,7 +161,7 @@ import common.packet.HPacketHandshake;
import common.packet.CPacketAction.Action;
import common.potion.Potion;
import common.potion.PotionEffect;
import common.properties.IProperty;
import common.properties.Property;
import common.sound.EventType;
import common.sound.PositionedSound;
import common.util.BlockPos;
@ -1497,8 +1497,6 @@ public class Client implements IThreadListener {
return;
}
int meta = 0;
boolean flag1 = false;
Item item = null;
if (this.pointed.type == HitPosition.ObjectType.BLOCK)
@ -1519,8 +1517,7 @@ public class Client implements IThreadListener {
}
Block block1 = item instanceof ItemBlock && !block.isPickStrict() ? item.getBlock() : block;
meta = block1.getDamageValue(this.world, blockpos);
flag1 = item.getHasSubtypes();
// meta = block1.getDamageValue(this.world, blockpos); TODO: data
}
else
{
@ -1535,9 +1532,9 @@ public class Client implements IThreadListener {
InventoryPlayer inventoryplayer = this.player.inventory;
inventoryplayer.setCurrentItem(item, meta, flag1);
inventoryplayer.setCurrentItem(item);
if(this.itemCheat) {
this.player.client.addToSendQueue(new CPacketCheat(new ItemStack(item, 1, meta), inventoryplayer.currentItem, this.ctrl()));
this.player.client.addToSendQueue(new CPacketCheat(new ItemStack(item), inventoryplayer.currentItem, this.ctrl()));
}
}
}
@ -1932,7 +1929,7 @@ public class Client implements IThreadListener {
"Schaue auf: " + BlockRegistry.getNameFromBlock(block.getBlock()) + "\n" +
String.format("Position: %d %d %d", pos.getX(), pos.getY(), pos.getZ())
);
for(Entry<IProperty, Comparable> entry : block.getProperties().entrySet()) {
for(Entry<Property, Comparable> entry : block.getProperties().entrySet()) {
str.append("\n" + entry.getKey().getName() + ": " + entry.getValue().toString());
}
@ -1957,7 +1954,7 @@ public class Client implements IThreadListener {
(((EntityLiving)entity).deathTime != 0 ? "Tod: " + ((EntityLiving)entity).deathTime + "t, " : "") + "Rüstung: " + ((EntityLiving)entity).getTotalArmorValue() + ", Pfeile: " + ((EntityLiving)entity).getArrowCountInEntity()
: "Rüstung: n/a, Pfeile: n/a") + "\n" +
(held != null ?
"Gegens.: " + ItemRegistry.getNameFromItem(held.getItem()) + " x" + held.size + " (" + held.getMetadata() + ")" : "Gegens.: n/a") + "\n" +
"Gegens.: " + ItemRegistry.getNameFromItem(held.getItem()) + " x" + held.size : "Gegens.: n/a") + "\n" +
"Eigens.: " + (entity.dead ? "D" : "") + (entity.noClip ? "N" : "") + (entity.onGround ? "G" : "")
+ (entity.canBeCollidedWith() ? "C" : "") + (entity.canBePushed() ? "P" : "")
+ (entity.isBurning() ? "B" : "") + (entity.isPlayer() ? "S" : "")

View file

@ -150,7 +150,7 @@ public abstract class RenderRegistry {
map.put(EntityBoat.class, new RenderBoat(mgr));
map.put(EntityHook.class, new RenderFish(mgr));
map.put(EntityHorse.class, new RenderHorse(mgr, new ModelHorse()));
map.put(EntityDynamite.class, new RenderDynamite(mgr, Items.dynamite, ritem));
map.put(EntityDynamite.class, new RenderDynamite(mgr, ritem));
map.put(EntityNuke.class, new RenderBlockEntity(mgr, Blocks.nuke.getState()));
map.put(EntityMouse.class, new RenderMouse(mgr, new ModelMouse()));
map.put(EntityDie.class, new RenderDie(mgr));

View file

@ -517,7 +517,7 @@ public class ClientPlayer implements IClientPlayer
}
else
{
player.inventory.mainInventory[player.inventory.currentItem] = new ItemStack(ItemRegistry.getItemById(i), 1, 0);
player.inventory.mainInventory[player.inventory.currentItem] = new ItemStack(ItemRegistry.getItemById(i));
}
player.setPositionAndRotation(x, y, z, yaw, pitch);

View file

@ -32,19 +32,13 @@ public class ItemModelMesher
public TextureAtlasSprite getParticleIcon(Item item)
{
return this.getParticleIcon(item, 0);
}
public TextureAtlasSprite getParticleIcon(Item item, int meta)
{
return this.getItemModel(new ItemStack(item, 1, meta)).getBaseTexture();
return this.getItemModel(new ItemStack(item)).getBaseTexture();
}
public IBakedModel getItemModel(ItemStack stack)
{
Item item = stack.getItem();
IBakedModel ibakedmodel = this.simpleShapesCache.get(Integer.valueOf(this.getIndex(item,
stack.isItemStackDamageable() ? 0 : stack.getMetadata())));
IBakedModel ibakedmodel = this.simpleShapesCache.get(this.getIndex(item));
if (ibakedmodel == null)
{
@ -64,9 +58,9 @@ public class ItemModelMesher
return ibakedmodel;
}
private int getIndex(Item item, int meta)
private int getIndex(Item item)
{
return ItemRegistry.getIdFromItem(item) << 16 | meta;
return ItemRegistry.getIdFromItem(item);
}
// public void register(Item item, int meta, ResourceLocation location)
@ -122,9 +116,9 @@ public class ItemModelMesher
continue;
item.getRenderItems(item, stacks);
for(ItemStack stack : stacks) {
this.simpleShapesCache.put(this.getIndex(item, stack.getMetadata()),
this.simpleShapesCache.put(this.getIndex(item),
this.modelManager.getModel("item/" +
ItemRegistry.getNameFromItem(item).toString() + "#" + stack.getMetadata() + '#' + "inventory"));
ItemRegistry.getNameFromItem(item).toString() + '#' + "inventory"));
}
stacks.clear();
}

View file

@ -144,8 +144,8 @@ public abstract class ModelBakery
// {
item.getRenderItems(item, stacks);
for(ItemStack stack : stacks) {
String resourcelocation = "item/" + ItemRegistry.getNameFromItem(item).toString() + "#" + stack.getMetadata() + '#' + "inventory";
models.put(resourcelocation, (ModelBlock)item.getModel(ModelBlock.PROVIDER, ItemRegistry.getNameFromItem(item).toString(), stack.getMetadata()));
String resourcelocation = "item/" + ItemRegistry.getNameFromItem(item).toString() + '#' + "inventory";
models.put(resourcelocation, (ModelBlock)item.getModel(ModelBlock.PROVIDER, ItemRegistry.getNameFromItem(item).toString()));
itemLocations.add(resourcelocation);
}
stacks.clear();

View file

@ -13,7 +13,7 @@ import common.collect.Maps;
import common.init.BlockRegistry;
import common.init.Blocks;
import common.init.FluidRegistry;
import common.properties.IProperty;
import common.properties.Property;
import common.util.IRegistry;
import common.world.State;
@ -36,7 +36,7 @@ public class ModelManager
// Log.info("Builtin: " + BlockRegistry.getNameFromBlock(block));
}
else {
IProperty<?>[] ignored = block.getIgnoredProperties();
Property<?>[] ignored = block.getIgnoredProperties();
if(ignored != null)
this.mappers.put(block, new MultiStateMap.Builder().ignore(ignored).build());
}

View file

@ -7,16 +7,16 @@ import java.util.Map;
import common.collect.Lists;
import common.collect.Maps;
import common.init.BlockRegistry;
import common.properties.IProperty;
import common.properties.Property;
import common.world.State;
public class MultiStateMap extends StateMap
{
private final IProperty<?> name;
private final Property<?> name;
private final String suffix;
private final List < IProperty<? >> ignored;
private final List < Property<? >> ignored;
private MultiStateMap(IProperty<?> name, String suffix, List < IProperty<? >> ignored)
private MultiStateMap(Property<?> name, String suffix, List < Property<? >> ignored)
{
this.name = name;
this.suffix = suffix;
@ -25,7 +25,7 @@ public class MultiStateMap extends StateMap
protected String getResourceLocation(State state)
{
Map<IProperty, Comparable> map = Maps.<IProperty, Comparable>newLinkedHashMap(state.getProperties());
Map<Property, Comparable> map = Maps.<Property, Comparable>newLinkedHashMap(state.getProperties());
String s;
if (this.name == null)
@ -34,7 +34,7 @@ public class MultiStateMap extends StateMap
}
else
{
s = ((IProperty)this.name).getName((Comparable)map.remove(this.name));
s = ((Property)this.name).getName((Comparable)map.remove(this.name));
}
if (this.suffix != null)
@ -42,7 +42,7 @@ public class MultiStateMap extends StateMap
s = s + this.suffix;
}
for (IProperty<?> iproperty : this.ignored)
for (Property<?> iproperty : this.ignored)
{
map.remove(iproperty);
}
@ -52,11 +52,11 @@ public class MultiStateMap extends StateMap
public static class Builder
{
private IProperty<?> name;
private Property<?> name;
private String suffix;
private final List < IProperty<? >> ignored = Lists. < IProperty<? >> newArrayList();
private final List < Property<? >> ignored = Lists. < Property<? >> newArrayList();
public MultiStateMap.Builder withName(IProperty<?> builderPropertyIn)
public MultiStateMap.Builder withName(Property<?> builderPropertyIn)
{
this.name = builderPropertyIn;
return this;
@ -68,7 +68,7 @@ public class MultiStateMap extends StateMap
return this;
}
public MultiStateMap.Builder ignore(IProperty<?>... p_178442_1_)
public MultiStateMap.Builder ignore(Property<?>... p_178442_1_)
{
Collections.addAll(this.ignored, p_178442_1_);
return this;

View file

@ -5,25 +5,25 @@ import java.util.Map.Entry;
import common.block.Block;
import common.collect.Maps;
import common.properties.IProperty;
import common.properties.Property;
import common.world.State;
public abstract class StateMap
{
protected Map<State, String> mapStateModelLocations = Maps.<State, String>newLinkedHashMap();
public String getPropertyString(Map<IProperty, Comparable> p_178131_1_)
public String getPropertyString(Map<Property, Comparable> p_178131_1_)
{
StringBuilder stringbuilder = new StringBuilder();
for (Entry<IProperty, Comparable> entry : p_178131_1_.entrySet())
for (Entry<Property, Comparable> entry : p_178131_1_.entrySet())
{
if (stringbuilder.length() != 0)
{
stringbuilder.append(",");
}
IProperty iproperty = (IProperty)entry.getKey();
Property iproperty = (Property)entry.getKey();
Comparable comparable = (Comparable)entry.getValue();
stringbuilder.append(iproperty.getName());
stringbuilder.append("=");

View file

@ -1,16 +1,16 @@
package client.renderer.entity;
import common.entity.projectile.EntityDynamite;
import common.item.Item;
import common.init.ItemRegistry;
import common.item.ItemStack;
public class RenderDynamite extends RenderItemEntity<EntityDynamite> {
public RenderDynamite(RenderManager renderManagerIn, Item itemIn, RenderItem renderItemIn) {
super(renderManagerIn, itemIn, renderItemIn);
public RenderDynamite(RenderManager renderManagerIn, RenderItem renderItemIn) {
super(renderManagerIn, null, renderItemIn);
}
public ItemStack getStack(EntityDynamite entityIn)
{
return new ItemStack(this.item, 1, entityIn.explosionSize);
return new ItemStack(ItemRegistry.getRegisteredItem("dynamite" + (entityIn.explosionSize <= 0 || entityIn.explosionSize >= 8 ? "" : "_" + entityIn.explosionSize)));
}
}

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

@ -39,7 +39,7 @@ public class RenderItemEntity<T extends Entity> extends Render<T>
public ItemStack getStack(T entityIn)
{
return new ItemStack(this.item, 1, 0);
return new ItemStack(this.item);
}
protected String getEntityTexture(Entity entity)

View file

@ -2,6 +2,7 @@ package client.renderer.entity;
import common.entity.projectile.EntityPotion;
import common.init.Items;
import common.item.ItemPotion;
import common.item.ItemStack;
public class RenderPotion extends RenderItemEntity<EntityPotion>
@ -13,6 +14,6 @@ public class RenderPotion extends RenderItemEntity<EntityPotion>
public ItemStack getStack(EntityPotion entityIn)
{
return new ItemStack(this.item, 1, entityIn.getPotionDamage());
return new ItemStack(ItemPotion.getPotionItem(entityIn.getPotionDamage()));
}
}

View file

@ -6,9 +6,9 @@ import client.Client;
import client.renderer.BlockRenderer;
import client.renderer.GlState;
import client.renderer.texture.TextureMap;
import common.block.tech.BlockTNT;
import common.block.Block;
import common.entity.item.EntityTnt;
import common.init.Blocks;
import common.init.BlockRegistry;
import common.util.ExtMath;
@ -17,12 +17,8 @@ public class RenderTntPrimed extends Render<EntityTnt>
public RenderTntPrimed(RenderManager renderManagerIn)
{
super(renderManagerIn);
// this.shadowSize = 0.5F;
}
/**
* Renders the desired {@code T} type Entity.
*/
public void doRender(EntityTnt entity, double x, double y, double z, float partialTicks)
{
BlockRenderer blockrendererdispatcher = Client.CLIENT.getBlockRendererDispatcher();
@ -42,7 +38,8 @@ public class RenderTntPrimed extends Render<EntityTnt>
float f2 = (1.0F - ((float)entity.fuse - partialTicks + 1.0F) / 100.0F) * 0.8F;
this.bindEntityTexture(entity);
GL11.glTranslatef(-0.5F, -0.5F, 0.5F);
blockrendererdispatcher.renderBlockBrightness(Blocks.tnt.getState().withProperty(BlockTNT.POWER, Integer.valueOf(entity.explosionSize)), entity.getBrightness(partialTicks));
Block tnt = BlockRegistry.getRegisteredBlock("tnt" + (entity.explosionSize <= 0 || entity.explosionSize >= 8 ? "" : "_" + entity.explosionSize));
blockrendererdispatcher.renderBlockBrightness(tnt.getState(), entity.getBrightness(partialTicks));
GL11.glTranslatef(0.0F, 0.0F, 1.0F);
if (entity.fuse / 5 % 2 == 0)
@ -54,7 +51,7 @@ public class RenderTntPrimed extends Render<EntityTnt>
GlState.color(1.0F, 1.0F, 1.0F, f2);
GlState.doPolygonOffset(-3.0F, -3.0F);
GlState.enablePolygonOffset();
blockrendererdispatcher.renderBlockBrightness(Blocks.tnt.getState().withProperty(BlockTNT.POWER, Integer.valueOf(entity.explosionSize)), 1.0F);
blockrendererdispatcher.renderBlockBrightness(tnt.getState(), 1.0F);
GlState.doPolygonOffset(0.0F, 0.0F);
GlState.disablePolygonOffset();
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
@ -67,9 +64,6 @@ public class RenderTntPrimed extends Render<EntityTnt>
super.doRender(entity, x, y, z, partialTicks);
}
/**
* Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
*/
protected String getEntityTexture(EntityTnt entity)
{
return TextureMap.locationBlocksTexture;

View file

@ -10,14 +10,9 @@ import common.world.World;
public class EntityBreakingFX extends EntityFX
{
protected EntityBreakingFX(World worldIn, double posXIn, double posYIn, double posZIn, Item p_i1195_8_)
protected EntityBreakingFX(World worldIn, double posXIn, double posYIn, double posZIn, double xSpeedIn, double ySpeedIn, double zSpeedIn, Item p_i1197_14_)
{
this(worldIn, posXIn, posYIn, posZIn, p_i1195_8_, 0);
}
protected EntityBreakingFX(World worldIn, double posXIn, double posYIn, double posZIn, double xSpeedIn, double ySpeedIn, double zSpeedIn, Item p_i1197_14_, int p_i1197_15_)
{
this(worldIn, posXIn, posYIn, posZIn, p_i1197_14_, p_i1197_15_);
this(worldIn, posXIn, posYIn, posZIn, p_i1197_14_);
this.motionX *= 0.10000000149011612D;
this.motionY *= 0.10000000149011612D;
this.motionZ *= 0.10000000149011612D;
@ -26,10 +21,10 @@ public class EntityBreakingFX extends EntityFX
this.motionZ += zSpeedIn;
}
protected EntityBreakingFX(World worldIn, double posXIn, double posYIn, double posZIn, Item p_i1196_8_, int p_i1196_9_)
protected EntityBreakingFX(World worldIn, double posXIn, double posYIn, double posZIn, Item p_i1196_8_)
{
super(worldIn, posXIn, posYIn, posZIn, 0.0D, 0.0D, 0.0D);
this.setParticleIcon(Client.CLIENT.getRenderItem().getItemModelMesher().getParticleIcon(p_i1196_8_, p_i1196_9_));
this.setParticleIcon(Client.CLIENT.getRenderItem().getItemModelMesher().getParticleIcon(p_i1196_8_));
this.particleRed = this.particleGreen = this.particleBlue = 1.0F;
this.particleGravity = 1.0F; // Blocks.snow.particleGravity;
this.particleScale /= 2.0F;
@ -75,8 +70,7 @@ public class EntityBreakingFX extends EntityFX
{
public EntityFX getEntityFX(int particleID, World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn, int... p_178902_15_)
{
int i = p_178902_15_.length > 1 ? p_178902_15_[1] : 0;
return new EntityBreakingFX(worldIn, xCoordIn, yCoordIn, zCoordIn, xSpeedIn, ySpeedIn, zSpeedIn, ItemRegistry.getItemById(p_178902_15_[0]), i);
return new EntityBreakingFX(worldIn, xCoordIn, yCoordIn, zCoordIn, xSpeedIn, ySpeedIn, zSpeedIn, ItemRegistry.getItemById(p_178902_15_[0]));
}
}

View file

@ -277,7 +277,7 @@ public class EntityFirework
if (aint.length == 0)
{
aint = new int[] {ItemDye.dyeColors[0]};
aint = new int[] {ItemDye.FIREWORK_COLORS[0]};
}
if (l == 1)

View file

@ -189,8 +189,7 @@ public class PlayerController {
if(this.stack != null && stack != null) {
flag = stack.getItem() == this.stack.getItem()
&& ItemStack.areItemStackTagsEqual(stack, this.stack)
&& (stack.isItemStackDamageable() || stack.getMetadata() == this.stack.getMetadata());
&& ItemStack.areItemStackTagsEqual(stack, this.stack);
}
return pos.equals(this.position) && flag;

View file

@ -20,6 +20,7 @@ import common.init.ItemRegistry;
import common.init.Items;
import common.init.SoundEvent;
import common.item.ItemDye;
import common.item.ItemPotion;
import common.log.Log;
import common.model.ParticleType;
import common.rng.Random;
@ -653,7 +654,7 @@ public class WorldClient extends AWorldClient
for (int i1 = 0; i1 < 8; ++i1)
{
this.spawnEntityFX(ParticleType.ITEM_CRACK, ParticleType.ITEM_CRACK.getShouldIgnoreRange(), d13, d14, d16, this.rand.gaussian() * 0.15D, this.rand.doublev() * 0.2D, this.rand.gaussian() * 0.15D, new int[] {ItemRegistry.getIdFromItem(Items.potion), data});
this.spawnEntityFX(ParticleType.ITEM_CRACK, ParticleType.ITEM_CRACK.getShouldIgnoreRange(), d13, d14, d16, this.rand.gaussian() * 0.15D, this.rand.doublev() * 0.2D, this.rand.gaussian() * 0.15D, new int[] {ItemRegistry.getIdFromItem(Items.potion)});
}
ParticleType enumparticletypes = ParticleType.WATER_SPLASH;
@ -661,13 +662,14 @@ public class WorldClient extends AWorldClient
float f1 = 1.0F;
float f2 = 1.0F;
if((data & 16383) != 0) {
int j1 = Items.potion.getColorFromDamage(data);
ItemPotion potion = ItemPotion.getPotionItem(data);
int j1 = potion.getColorFromDamage();
f = (float)(j1 >> 16 & 255) / 255.0F;
f1 = (float)(j1 >> 8 & 255) / 255.0F;
f2 = (float)(j1 >> 0 & 255) / 255.0F;
enumparticletypes = ParticleType.SPELL;
if (Items.potion.isEffectInstant(data))
if (potion.isEffectInstant())
{
enumparticletypes = ParticleType.SPELL_INSTANT;
}

View file

Before

Width:  |  Height:  |  Size: 3 KiB

After

Width:  |  Height:  |  Size: 3 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 3 KiB

After

Width:  |  Height:  |  Size: 3 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 3 KiB

After

Width:  |  Height:  |  Size: 3 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 413 B

After

Width:  |  Height:  |  Size: 413 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 469 B

After

Width:  |  Height:  |  Size: 469 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 556 B

After

Width:  |  Height:  |  Size: 556 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 3 KiB

After

Width:  |  Height:  |  Size: 3 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 3 KiB

After

Width:  |  Height:  |  Size: 3 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 706 B

After

Width:  |  Height:  |  Size: 706 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 670 B

After

Width:  |  Height:  |  Size: 670 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 715 B

After

Width:  |  Height:  |  Size: 715 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 717 B

After

Width:  |  Height:  |  Size: 717 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 545 B

After

Width:  |  Height:  |  Size: 545 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 698 B

After

Width:  |  Height:  |  Size: 698 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 637 B

After

Width:  |  Height:  |  Size: 637 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 402 B

After

Width:  |  Height:  |  Size: 402 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 584 B

After

Width:  |  Height:  |  Size: 584 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

View file

Before

Width:  |  Height:  |  Size: 541 B

After

Width:  |  Height:  |  Size: 541 B

Before After
Before After

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

@ -64,14 +64,14 @@ public class EntityAIShareItems extends EntityAIWatchClosest2
{
int l = itemstack.size / 2;
itemstack.size -= l;
itemstack1 = new ItemStack(item, l, itemstack.getMetadata());
itemstack1 = new ItemStack(item, l);
}
else if (item == Items.wheats && itemstack.size > 5)
{
int j = itemstack.size / 2 / 3 * 3;
int k = j / 3;
itemstack.size -= j;
itemstack1 = new ItemStack(Items.bread, k, 0);
itemstack1 = new ItemStack(Items.bread, k);
}
if (itemstack.size <= 0)

View file

@ -3,10 +3,11 @@ 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;
import common.init.ItemRegistry;
import common.item.Item;
import common.item.ItemStack;
import common.rng.Random;
import common.util.BlockPos;
@ -17,45 +18,12 @@ import common.world.World;
public class EntityAITakePlace extends EntityAIBase
{
private static class StackKey {
public String item;
public int meta;
public StackKey(String str) {
String[] tok = str.split(":", 2);
this.item = tok[0];
this.meta = tok.length > 1 ? Integer.parseInt(tok[1]) : -1;
}
public StackKey(ItemStack stack) {
this.item = ItemRegistry.getNameFromItem(stack.getItem()).toString();
this.meta = stack.getItem().getMaxDamage() <= 0 ? stack.getMetadata() : -1;
}
// public boolean isSame(ItemStack stack) {
// return this.item.equals(ItemRegistry.getNameFromItem(stack.getItem()).toString()) &&
// (stack.getItem().getMaxDamage() > 0 || stack.getMetadata() == this.meta);
// }
public boolean equals(Object other) {
return other instanceof StackKey && ((StackKey)other).item.equals(this.item) && ((StackKey)other).meta == this.meta;
}
public int hashCode() {
return this.item.hashCode() ^ (this.meta << 8);
}
public String toString() {
return this.item + (this.meta == -1 ? "" : (":" + this.meta));
}
}
private static final Map<State, ItemStack> STEALABLE = Maps.newHashMap();
private static final Map<StackKey, State> PLACEABLE = Maps.newHashMap();
private static final Map<Item, State> PLACEABLE = Maps.newHashMap();
private static void addPlaceable(State state, ItemStack stack) {
STEALABLE.put(state, stack);
PLACEABLE.put(new StackKey(stack), state);
PLACEABLE.put(stack.getItem(), state);
}
private static void addPlaceable(Block block) {
@ -63,7 +31,9 @@ public class EntityAITakePlace extends EntityAIBase
}
static {
addPlaceable(Blocks.flower);
for(BlockFlower block : BlockFlower.FLOWERS) {
addPlaceable(block);
}
addPlaceable(Blocks.brown_mushroom);
addPlaceable(Blocks.red_mushroom);
addPlaceable(Blocks.blue_mushroom);
@ -85,7 +55,7 @@ public class EntityAITakePlace extends EntityAIBase
this.place = false;
return this.entity.getRNG().chance(20);
}
else if(this.entity.getRNG().chance(200) && PLACEABLE.containsKey(new StackKey(this.entity.getHeldItem()))) {
else if(this.entity.getRNG().chance(200) && PLACEABLE.containsKey(this.entity.getHeldItem().getItem())) {
this.place = this.entity.getRNG().rarity(10);
return true;
}
@ -102,11 +72,11 @@ public class EntityAITakePlace extends EntityAIBase
BlockPos blockpos = new BlockPos(i, j, k);
if(this.place) {
ItemStack stack = this.entity.getHeldItem();
if(stack == null || !PLACEABLE.containsKey(new StackKey(this.entity.getHeldItem())))
if(stack == null || !PLACEABLE.containsKey(this.entity.getHeldItem().getItem()))
return;
Block replace = world.getState(blockpos).getBlock();
Block below = world.getState(blockpos.down()).getBlock();
State state = PLACEABLE.get(new StackKey(this.entity.getHeldItem()));
State state = PLACEABLE.get(this.entity.getHeldItem().getItem());
if (state.getBlock().canPlaceBlockAt(world, blockpos) && replace == Blocks.air &&
below != Blocks.air && below.isFullCube())
{

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

@ -32,7 +32,7 @@ import common.model.BlockLayer;
import common.model.Model;
import common.model.ModelProvider;
import common.model.Transforms;
import common.properties.IProperty;
import common.properties.Property;
import common.rng.Random;
import common.tileentity.TileEntity;
import common.util.BlockPos;
@ -156,7 +156,7 @@ public class Block {
}
}
private final ImmutableList<IProperty> properties;
private final ImmutableList<Property> properties;
private final ImmutableList<State> states;
protected final Material material;
@ -212,14 +212,14 @@ public class Block {
return (T[])((Object[])((Object[])Array.newInstance(clazz, size)));
}
private static Map<IProperty, Comparable> createMap(Iterable<IProperty> keys, Iterable<Comparable> values) {
return populateMap(keys, values, Maps.<IProperty, Comparable>newLinkedHashMap());
private static Map<Property, Comparable> createMap(Iterable<Property> keys, Iterable<Comparable> values) {
return populateMap(keys, values, Maps.<Property, Comparable>newLinkedHashMap());
}
private static Map<IProperty, Comparable> populateMap(Iterable<IProperty> keys, Iterable<Comparable> values, Map<IProperty, Comparable> map) {
private static Map<Property, Comparable> populateMap(Iterable<Property> keys, Iterable<Comparable> values, Map<Property, Comparable> map) {
Iterator<Comparable> iterator = values.iterator();
for(IProperty prop : keys) {
for(Property prop : keys) {
map.put(prop, iterator.next());
}
@ -231,28 +231,28 @@ public class Block {
}
}
private static List<Iterable<Comparable>> getAllowedValues(List<IProperty> properties) {
private static List<Iterable<Comparable>> getAllowedValues(List<Property> properties) {
List<Iterable<Comparable>> list = Lists.<Iterable<Comparable>>newArrayList();
for(int z = 0; z < properties.size(); z++) {
list.add((properties.get(z)).getAllowedValues());
list.add((properties.get(z)).getStates());
}
return list;
}
private static ImmutableList<IProperty> getPropertyList(IProperty[] properties) {
Arrays.sort(properties, new Comparator<IProperty>() {
public int compare(IProperty p1, IProperty p2) {
private static ImmutableList<Property> getPropertyList(Property[] properties) {
Arrays.sort(properties, new Comparator<Property>() {
public int compare(Property p1, Property p2) {
return p1.getName().compareTo(p2.getName());
}
});
return ImmutableList.copyOf(properties);
}
private static ImmutableList<State> getStateList(List<IProperty> properties, Block block) {
Map<Map<IProperty, Comparable>, State> map = Maps.<Map<IProperty, Comparable>, State>newLinkedHashMap();
private static ImmutableList<State> getStateList(List<Property> properties, Block block) {
Map<Map<Property, Comparable>, State> map = Maps.<Map<Property, Comparable>, State>newLinkedHashMap();
List<State> list = Lists.<State>newArrayList();
for(List<Comparable> allowed : cartesianProduct(getAllowedValues(properties))) {
Map<IProperty, Comparable> props = createMap(properties, allowed);
Map<Property, Comparable> props = createMap(properties, allowed);
State state = new State(block, ImmutableMap.copyOf(props));
map.put(props, state);
list.add(state);
@ -388,7 +388,7 @@ public class Block {
return this.states.get(0);
}
public Collection<IProperty> getPropertyMap() {
public Collection<Property> getPropertyMap() {
return this.properties;
}
@ -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,10 +621,6 @@ public class Block {
}
}
public int damageDropped(State state) {
return 0;
}
public float getExplosionResistance(Entity exploder) {
return this.blockResistance / 5.0F;
}
@ -852,14 +848,9 @@ public class Block {
}
public ItemStack createStackedBlock(State state) {
int i = 0;
Item item = ItemRegistry.getItemFromBlock(this);
if(item != null && item.getHasSubtypes()) {
i = this.getMetaFromState(state);
}
return new ItemStack(item, 1, i);
// TODO: data
return new ItemStack(item);
}
public int quantityDroppedWithBonus(int fortune, Random random) {
@ -901,14 +892,6 @@ public class Block {
return ItemRegistry.getItemFromBlock(this);
}
public int getDamageValue(World worldIn, BlockPos pos) {
return this.damageDropped(worldIn.getState(pos));
}
public void getSubBlocks(Item itemIn, CheatTab tab, List<ItemStack> list) {
list.add(new ItemStack(itemIn, 1, 0));
}
public CheatTab getTab() {
return this.tab;
}
@ -951,8 +934,8 @@ public class Block {
return state;
}
protected IProperty[] getProperties() {
return new IProperty[0];
protected Property[] getProperties() {
return new Property[0];
}
protected final void setDefaultState(State state) {
@ -991,7 +974,7 @@ public class Block {
return provider.getModel(name).add().all();
}
public IProperty<?>[] getIgnoredProperties() {
public Property<?>[] getIgnoredProperties() {
return null;
}

View file

@ -1,49 +0,0 @@
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);
public BlockColored(Material material) {
super(material);
this.setDefaultState(this.getBaseState().withProperty(COLOR, DyeColor.WHITE));
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 Model getModel(ModelProvider provider, String name, State state) {
return provider.getModel(state.getValue(COLOR).getName() + "_" + name).add().all();
}
}

View file

@ -1,12 +0,0 @@
package common.block;
import common.properties.PropertyDirection;
import common.util.Facing;
public abstract class BlockDirectional extends Block {
public static final PropertyDirection FACING = PropertyDirection.create("facing", Facing.Plane.HORIZONTAL);
public BlockDirectional(Material material) {
super(material);
}
}

View file

@ -0,0 +1,8 @@
package common.block;
import common.properties.PropertyEnum;
import common.util.Facing;
public interface Directional {
public static final PropertyEnum<Facing> FACING = PropertyEnum.create("facing", Facing.class, Facing.values());
}

View file

@ -0,0 +1,8 @@
package common.block;
import common.properties.PropertyEnum;
import common.util.Facing;
public interface DirectionalDown {
public static final PropertyEnum<Facing> FACING = PropertyEnum.create("facing", Facing.class, Facing.DOWN, Facing.NORTH, Facing.SOUTH, Facing.WEST, Facing.EAST);
}

View file

@ -0,0 +1,8 @@
package common.block;
import common.properties.PropertyEnum;
import common.util.Facing;
public interface DirectionalUp {
public static final PropertyEnum<Facing> FACING = PropertyEnum.create("facing", Facing.class, Facing.UP, Facing.NORTH, Facing.SOUTH, Facing.WEST, Facing.EAST);
}

View file

@ -0,0 +1,8 @@
package common.block;
import common.properties.PropertyEnum;
import common.util.Facing;
public interface Rotatable {
public static final PropertyEnum<Facing> FACING = PropertyEnum.create("facing", Facing.class, Facing.NORTH, Facing.SOUTH, Facing.WEST, Facing.EAST);
}

View file

@ -1,7 +1,7 @@
package common.block.artificial;
import common.block.Block;
import common.block.BlockDirectional;
import common.block.Rotatable;
import common.block.Material;
import common.color.DyeColor;
import common.color.TextColor;
@ -12,7 +12,7 @@ import common.model.BlockLayer;
import common.model.Model;
import common.model.ModelProvider;
import common.model.ModelRotation;
import common.properties.IProperty;
import common.properties.Property;
import common.properties.PropertyEnum;
import common.rng.Random;
import common.util.BlockPos;
@ -23,7 +23,7 @@ import common.world.IWorldAccess;
import common.world.State;
import common.world.World;
public class BlockBed extends BlockDirectional {
public class BlockBed extends Block implements Rotatable {
public static enum EnumPartType implements Identifyable {
HEAD("head"), FOOT("foot");
@ -188,8 +188,8 @@ public class BlockBed extends BlockDirectional {
return ((Facing)state.getValue(FACING)).getHorizontalIndex() | (state.getValue(PART) == BlockBed.EnumPartType.HEAD ? 8 : 0);
}
protected IProperty[] getProperties() {
return new IProperty[] {FACING, PART};
protected Property[] getProperties() {
return new Property[] {FACING, PART};
}
public Model getModel(ModelProvider provider, String name, State state) {

View file

@ -8,7 +8,7 @@ import common.item.Item;
import common.model.BlockLayer;
import common.model.Model;
import common.model.ModelProvider;
import common.properties.IProperty;
import common.properties.Property;
import common.properties.PropertyInteger;
import common.rng.Random;
import common.util.BlockPos;
@ -228,9 +228,9 @@ public class BlockCake extends Block
return ((Integer)state.getValue(BITES)).intValue();
}
protected IProperty[] getProperties()
protected Property[] getProperties()
{
return new IProperty[] {BITES};
return new Property[] {BITES};
}
public int getComparatorInputOverride(World worldIn, BlockPos pos)

View file

@ -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,27 @@ import common.world.World;
public class BlockCarpet extends Block
{
public static final PropertyEnum<DyeColor> COLOR = PropertyEnum.<DyeColor>create("color", DyeColor.class);
public BlockCarpet()
{
super(Material.FLEECE);
this.setDefaultState(this.getBaseState().withProperty(COLOR, DyeColor.WHITE));
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.0625F, 1.0F);
// this.setTickRandomly(true);
this.setTab(CheatTab.DECORATION);
this.setBlockBoundsFromMeta(0);
public static final BlockCarpet[] CARPETS = new BlockCarpet[DyeColor.values().length];
private final DyeColor color;
public static BlockCarpet getByColor(DyeColor color) {
return CARPETS[color.getMetadata()];
}
// /**
// * Get the MapColor for this Block and the given BlockState
// */
// public MapColor getMapColor(IBlockState state)
// {
// return ((EnumDyeColor)state.getValue(COLOR)).getMapColor();
// }
public BlockCarpet(DyeColor color)
{
super(Material.FLEECE);
this.color = color;
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.0625F, 1.0F);
this.setTab(CheatTab.DECORATION);
this.setBlockBoundsFromMeta();
CARPETS[color.ordinal()] = this;
}
public DyeColor getColor() {
return this.color;
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
@ -59,15 +55,15 @@ public class BlockCarpet extends Block
*/
public void setBlockBoundsForItemRender()
{
this.setBlockBoundsFromMeta(0);
this.setBlockBoundsFromMeta();
}
public void setBlockBoundsBasedOnState(IWorldAccess worldIn, BlockPos pos)
{
this.setBlockBoundsFromMeta(0);
this.setBlockBoundsFromMeta();
}
protected void setBlockBoundsFromMeta(int meta)
private void setBlockBoundsFromMeta()
{
int i = 0;
float f = (float)(1 * (1 + i)) / 16.0F;
@ -111,52 +107,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();
}
}

View file

@ -3,6 +3,7 @@ package common.block.artificial;
import java.util.List;
import common.block.Block;
import common.block.Rotatable;
import common.block.Material;
import common.collect.Lists;
import common.entity.npc.EntityNPC;
@ -13,9 +14,8 @@ import common.model.BlockLayer;
import common.model.Model;
import common.model.ModelProvider;
import common.model.ModelRotation;
import common.properties.IProperty;
import common.properties.Property;
import common.properties.PropertyBool;
import common.properties.PropertyDirection;
import common.properties.PropertyEnum;
import common.rng.Random;
import common.util.BlockPos;
@ -29,9 +29,8 @@ import common.world.IWorldAccess;
import common.world.State;
import common.world.World;
public class BlockDoor extends Block
public class BlockDoor extends Block implements Rotatable
{
public static final PropertyDirection FACING = PropertyDirection.create("facing", Facing.Plane.HORIZONTAL);
public static final PropertyBool OPEN = PropertyBool.create("open");
public static final PropertyEnum<BlockDoor.EnumHingePosition> HINGE = PropertyEnum.<BlockDoor.EnumHingePosition>create("hinge", BlockDoor.EnumHingePosition.class);
public static final PropertyBool POWERED = PropertyBool.create("powered");
@ -446,9 +445,9 @@ public class BlockDoor extends Block
return (combinedMeta & 16) != 0;
}
protected IProperty[] getProperties()
protected Property[] getProperties()
{
return new IProperty[] {HALF, FACING, OPEN, HINGE, POWERED};
return new Property[] {HALF, FACING, OPEN, HINGE, POWERED};
}
private static ModelRotation getRotation(Facing rot, int offset) {
@ -500,8 +499,8 @@ public class BlockDoor extends Block
}
}
public IProperty<?>[] getIgnoredProperties() {
return new IProperty[] {POWERED};
public Property<?>[] getIgnoredProperties() {
return new Property[] {POWERED};
}
public static enum EnumDoorHalf implements Identifyable

View file

@ -13,7 +13,7 @@ import common.model.Model;
import common.model.ModelProvider;
import common.model.ModelRotation;
import common.model.Transforms;
import common.properties.IProperty;
import common.properties.Property;
import common.properties.PropertyBool;
import common.util.BlockPos;
import common.util.BoundingBox;
@ -196,9 +196,9 @@ public class BlockFence extends Block
return state.withProperty(NORTH, Boolean.valueOf(this.canConnectTo(worldIn, pos.north()))).withProperty(EAST, Boolean.valueOf(this.canConnectTo(worldIn, pos.east()))).withProperty(SOUTH, Boolean.valueOf(this.canConnectTo(worldIn, pos.south()))).withProperty(WEST, Boolean.valueOf(this.canConnectTo(worldIn, pos.west())));
}
protected IProperty[] getProperties()
protected Property[] getProperties()
{
return new IProperty[] {NORTH, EAST, WEST, SOUTH};
return new Property[] {NORTH, EAST, WEST, SOUTH};
}
public Transforms getTransform() {

View file

@ -1,7 +1,7 @@
package common.block.artificial;
import common.block.Block;
import common.block.BlockDirectional;
import common.block.Rotatable;
import common.block.Material;
import common.entity.npc.EntityNPC;
import common.entity.types.EntityLiving;
@ -12,7 +12,7 @@ import common.model.Model;
import common.model.ModelProvider;
import common.model.ModelRotation;
import common.model.Transforms;
import common.properties.IProperty;
import common.properties.Property;
import common.properties.PropertyBool;
import common.util.BlockPos;
import common.util.BoundingBox;
@ -22,7 +22,7 @@ import common.world.IWorldAccess;
import common.world.State;
import common.world.World;
public class BlockFenceGate extends BlockDirectional
public class BlockFenceGate extends Block implements Rotatable
{
public static final PropertyBool OPEN = PropertyBool.create("open");
public static final PropertyBool POWERED = PropertyBool.create("powered");
@ -200,9 +200,9 @@ public class BlockFenceGate extends BlockDirectional
return i;
}
protected IProperty[] getProperties()
protected Property[] getProperties()
{
return new IProperty[] {FACING, OPEN, POWERED, IN_WALL};
return new Property[] {FACING, OPEN, POWERED, IN_WALL};
}
public Transforms getTransform() {
@ -406,7 +406,7 @@ public class BlockFenceGate extends BlockDirectional
.rotate(ModelRotation.getNorthRot(state.getValue(FACING).getOpposite()));
}
public IProperty<?>[] getIgnoredProperties() {
return new IProperty[] {POWERED};
public Property<?>[] getIgnoredProperties() {
return new Property[] {POWERED};
}
}

View file

@ -1,9 +1,13 @@
package common.block.artificial;
import java.util.List;
import common.block.Block;
import common.block.Material;
import common.block.foliage.BlockFlower;
import common.collect.Lists;
import common.entity.npc.EntityNPC;
import common.init.BlockRegistry;
import common.init.Blocks;
import common.init.ItemRegistry;
import common.init.Items;
@ -13,8 +17,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 +24,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 +101,18 @@ 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);
public static final List<BlockFlowerPot> POTS = Lists.newArrayList();
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();
POTS.add(this);
}
// /**
// * 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 +131,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 +150,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 +179,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.flowerpot;
}
public boolean isPickStrict()
@ -246,117 +206,31 @@ 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.
*/
public Item getItemDropped(State state, Random rand, int fortune)
{
return Items.flower_pot;
return Items.flowerpot;
}
/**
* 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)

View file

@ -6,7 +6,7 @@ import common.entity.types.EntityLiving;
import common.init.ItemRegistry;
import common.item.CheatTab;
import common.item.ItemStack;
import common.properties.IProperty;
import common.properties.Property;
import common.util.BlockPos;
import common.util.Facing;
import common.world.State;
@ -61,14 +61,14 @@ public class BlockHay extends BlockRotatedPillar
return i;
}
protected IProperty[] getProperties()
protected Property[] getProperties()
{
return new IProperty[] {AXIS};
return new Property[] {AXIS};
}
public ItemStack createStackedBlock(State state)
{
return new ItemStack(ItemRegistry.getItemFromBlock(this), 1, 0);
return new ItemStack(ItemRegistry.getItemFromBlock(this));
}
/**

View file

@ -1,7 +1,7 @@
package common.block.artificial;
import common.block.Block;
import common.block.BlockDirectional;
import common.block.Rotatable;
import common.block.Material;
import common.entity.types.EntityLiving;
import common.item.CheatTab;
@ -9,8 +9,7 @@ import common.model.BlockLayer;
import common.model.Model;
import common.model.ModelProvider;
import common.model.ModelRotation;
import common.properties.IProperty;
import common.properties.PropertyDirection;
import common.properties.Property;
import common.util.BlockPos;
import common.util.BoundingBox;
import common.util.Facing;
@ -18,10 +17,8 @@ import common.world.IWorldAccess;
import common.world.State;
import common.world.World;
public class BlockLadder extends Block
public class BlockLadder extends Block implements Rotatable
{
public static final PropertyDirection FACING = PropertyDirection.create("facing", Facing.Plane.HORIZONTAL);
public BlockLadder()
{
super(Material.SMALL);
@ -161,9 +158,9 @@ public class BlockLadder extends Block
return ((Facing)state.getValue(FACING)).getIndex();
}
protected IProperty[] getProperties()
protected Property[] getProperties()
{
return new IProperty[] {FACING};
return new Property[] {FACING};
}
public Model getModel(ModelProvider provider, String name, State state) {
@ -171,6 +168,6 @@ public class BlockLadder extends Block
.add(0, 0, 15.2f, 16, 16, 15.2f).noShade()
.n().uv(0, 0, 16, 16).noCull()
.s().uv(0, 0, 16, 16).noCull()
.rotate(ModelRotation.getNorthRot(state.getValue(BlockDirectional.FACING)));
.rotate(ModelRotation.getNorthRot(state.getValue(FACING)));
}
}

View file

@ -12,7 +12,7 @@ import common.model.BlockLayer;
import common.model.Model;
import common.model.ModelProvider;
import common.model.ModelRotation;
import common.properties.IProperty;
import common.properties.Property;
import common.properties.PropertyBool;
import common.rng.Random;
import common.util.BlockPos;
@ -180,7 +180,7 @@ public class BlockPane extends Block
public final boolean canPaneConnectToBlock(Block blockIn)
{
return blockIn.isFullBlock() || blockIn == this || blockIn == Blocks.glass || blockIn == Blocks.stained_glass || blockIn == Blocks.stained_glass_pane || blockIn instanceof BlockPane;
return blockIn.isFullBlock() || blockIn == this || blockIn == Blocks.glass || blockIn instanceof BlockStainedGlass || blockIn instanceof BlockStainedGlassPane || blockIn instanceof BlockPane;
}
public boolean canSilkHarvest()
@ -201,9 +201,9 @@ public class BlockPane extends Block
return 0;
}
protected IProperty[] getProperties()
protected Property[] getProperties()
{
return new IProperty[] {NORTH, EAST, WEST, SOUTH};
return new Property[] {NORTH, EAST, WEST, SOUTH};
}
public boolean isMagnetic() {

View file

@ -12,7 +12,7 @@ import common.model.BlockLayer;
import common.model.Model;
import common.model.ModelProvider;
import common.model.ParticleType;
import common.properties.IProperty;
import common.properties.Property;
import common.properties.PropertyEnum;
import common.properties.PropertyInteger;
import common.rng.Random;
@ -277,9 +277,9 @@ public class BlockPortal extends Block
return (state.getValue(AXIS) == Axis.Z ? 8 : 0) | state.getValue(DIM);
}
protected IProperty[] getProperties()
protected Property[] getProperties()
{
return new IProperty[] {AXIS, DIM};
return new Property[] {AXIS, DIM};
}
public Model getModel(ModelProvider provider, String name, State state) {

View file

@ -3,6 +3,7 @@ package common.block.artificial;
import java.util.List;
import common.block.Block;
import common.block.Rotatable;
import common.block.Material;
import common.entity.Entity;
import common.entity.npc.EntityNPC;
@ -15,9 +16,8 @@ import common.item.ItemStack;
import common.model.Model;
import common.model.ModelProvider;
import common.model.ModelRotation;
import common.properties.IProperty;
import common.properties.Property;
import common.properties.PropertyBool;
import common.properties.PropertyDirection;
import common.rng.Random;
import common.tileentity.TileEntity;
import common.util.BlockPos;
@ -26,9 +26,8 @@ import common.util.Facing;
import common.world.State;
import common.world.World;
public class BlockPortalFrame extends Block
public class BlockPortalFrame extends Block implements Rotatable
{
public static final PropertyDirection FACING = PropertyDirection.create("facing", Facing.Plane.HORIZONTAL);
public static final PropertyBool ORB = PropertyBool.create("orb");
public BlockPortalFrame()
@ -133,9 +132,9 @@ public class BlockPortalFrame extends Block
return i;
}
protected IProperty[] getProperties()
protected Property[] getProperties()
{
return new IProperty[] {FACING, ORB};
return new Property[] {FACING, ORB};
}
public void onBlockDestroyedByPlayer(World worldIn, BlockPos pos, State state)

View file

@ -1,195 +1,36 @@
package common.block.artificial;
import java.util.List;
import common.block.Block;
import common.block.Material;
import common.entity.types.EntityLiving;
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.ModelRotation;
import common.properties.IProperty;
import common.properties.PropertyEnum;
import common.util.BlockPos;
import common.util.Facing;
import common.util.Identifyable;
import common.world.State;
import common.world.World;
public class BlockQuartz extends Block
{
public static final PropertyEnum<BlockQuartz.EnumType> VARIANT = PropertyEnum.<BlockQuartz.EnumType>create("variant", BlockQuartz.EnumType.class);
public class BlockQuartz extends Block {
private final boolean dark;
private final boolean ornaments;
private final String prefix;
public BlockQuartz(String prefix)
{
super(Material.SOLID);
this.setDefaultState(this.getBaseState().withProperty(VARIANT, BlockQuartz.EnumType.DEFAULT));
this.setTab(CheatTab.BLOCKS);
this.prefix = prefix;
}
public BlockQuartz(boolean dark, boolean ornaments) {
super(Material.SOLID);
this.dark = dark;
this.ornaments = ornaments;
this.setTab(CheatTab.BLOCKS);
}
/**
* 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())
{
switch (facing.getAxis())
{
case Z:
return this.getState().withProperty(VARIANT, BlockQuartz.EnumType.LINES_Z);
public boolean isDark() {
return this.dark;
}
case X:
return this.getState().withProperty(VARIANT, BlockQuartz.EnumType.LINES_X);
public boolean hasOrnaments() {
return this.ornaments;
}
case Y:
default:
return this.getState().withProperty(VARIANT, BlockQuartz.EnumType.LINES_Y);
}
}
else
{
return meta == BlockQuartz.EnumType.CHISELED.getMetadata() ? this.getState().withProperty(VARIANT, BlockQuartz.EnumType.CHISELED) : this.getState().withProperty(VARIANT, BlockQuartz.EnumType.DEFAULT);
}
}
/**
* 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 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};
}
public Model getModel(ModelProvider provider, String name, State state) {
switch(state.getValue(VARIANT)) {
case DEFAULT:
default:
return provider.getModel(this.prefix + "quartz_block_side").add().nswe().d(this.prefix + "quartz_block_bottom").u(this.prefix + "quartz_top");
case CHISELED:
return provider.getModel(this.prefix + "quartz_block_chiseled").add().nswe().du(this.prefix + "quartz_block_chiseled_top");
case LINES_X:
return provider.getModel(this.prefix + "quartz_block_lines").add().nswe().du(this.prefix + "quartz_block_lines_top").rotate(ModelRotation.X90_Y90);
case LINES_Y:
return provider.getModel(this.prefix + "quartz_block_lines").add().nswe().du(this.prefix + "quartz_block_lines_top");
case LINES_Z:
return provider.getModel(this.prefix + "quartz_block_lines").add().nswe().du(this.prefix + "quartz_block_lines_top").rotate(ModelRotation.X90_Y0);
}
}
public static enum EnumType implements Identifyable
{
DEFAULT(0, "default", "default", null),
CHISELED(1, "chiseled", "chiseled", null),
LINES_Y(2, "lines_y", "lines", Facing.Axis.Y),
LINES_X(3, "lines_x", "lines", Facing.Axis.X),
LINES_Z(4, "lines_z", "lines", Facing.Axis.Z);
private static final BlockQuartz.EnumType[] META_LOOKUP = new BlockQuartz.EnumType[values().length];
private final int meta;
private final String name;
private final String unlocalizedName;
private final Facing.Axis axis;
private EnumType(int meta, String name, String unlocalizedName, Facing.Axis axis)
{
this.meta = meta;
this.name = name;
this.unlocalizedName = unlocalizedName;
this.axis = axis;
}
public int getMetadata()
{
return this.meta;
}
public String toString()
{
return this.name;
// return this.unlocalizedName;
}
public static BlockQuartz.EnumType byMetadata(int meta)
{
if (meta < 0 || meta >= META_LOOKUP.length)
{
meta = 0;
}
return META_LOOKUP[meta];
}
public String getName()
{
return this.name;
}
public Facing.Axis getAxis()
{
return this.axis;
}
static {
for (BlockQuartz.EnumType blockquartz$enumtype : values())
{
META_LOOKUP[blockquartz$enumtype.getMetadata()] = blockquartz$enumtype;
}
}
}
public Model getModel(ModelProvider provider, String name, State state) {
String prefix = this.dark ? "black_" : "";
if(this.ornaments)
return provider.getModel(prefix + "quartz_block_chiseled").add().nswe().du(prefix + "quartz_block_chiseled_top");
else
return provider.getModel(prefix + "quartz_block_side").add().nswe().d(prefix + "quartz_block_bottom").u(prefix + "quartz_top");
}
}

View file

@ -0,0 +1,87 @@
package common.block.artificial;
import common.block.BlockRotatedPillar;
import common.block.Material;
import common.entity.types.EntityLiving;
import common.item.CheatTab;
import common.model.Model;
import common.model.ModelProvider;
import common.model.ModelRotation;
import common.properties.Property;
import common.util.BlockPos;
import common.util.Facing;
import common.world.State;
import common.world.World;
public class BlockQuartzPillar extends BlockRotatedPillar
{
private final boolean dark;
public BlockQuartzPillar(boolean dark)
{
super(Material.SOLID);
this.setDefaultState(this.getBaseState().withProperty(AXIS, Facing.Axis.Y));
this.setTab(CheatTab.BLOCKS);
this.dark = dark;
}
public boolean isDark() {
return this.dark;
}
public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, int meta, EntityLiving placer)
{
return this.getState().withProperty(AXIS, facing.getAxis());
}
public State getStateFromMeta(int meta)
{
State state = this.getState();
switch (meta & 3)
{
default:
state = state.withProperty(AXIS, Facing.Axis.Y);
break;
case 1:
state = state.withProperty(AXIS, Facing.Axis.X);
break;
case 2:
state = state.withProperty(AXIS, Facing.Axis.Z);
break;
}
return state;
}
public int getMetaFromState(State state)
{
int meta = 0;
switch (state.getValue(AXIS))
{
case X:
meta = 1;
break;
case Z:
meta = 2;
break;
}
return meta;
}
protected Property[] getProperties()
{
return new Property[] {AXIS};
}
public Model getModel(ModelProvider provider, String name, State state) {
String prefix = this.dark ? "black_" : "";
switch(state.getValue(AXIS)) {
case X:
return provider.getModel(prefix + "quartz_block_lines").add().nswe().du(prefix + "quartz_block_lines_top").rotate(ModelRotation.X90_Y90);
case Y:
default:
return provider.getModel(prefix + "quartz_block_lines").add().nswe().du(prefix + "quartz_block_lines_top");
case Z:
return provider.getModel(prefix + "quartz_block_lines").add().nswe().du(prefix + "quartz_block_lines_top").rotate(ModelRotation.X90_Y0);
}
}
}

View file

@ -1,6 +1,7 @@
package common.block.artificial;
import common.block.BlockDirectional;
import common.block.Block;
import common.block.Rotatable;
import common.block.Material;
import common.entity.Entity;
import common.entity.types.EntityLiving;
@ -9,14 +10,14 @@ import common.item.Item;
import common.model.Model;
import common.model.ModelProvider;
import common.model.ModelRotation;
import common.properties.IProperty;
import common.properties.Property;
import common.rng.Random;
import common.util.BlockPos;
import common.util.Facing;
import common.world.State;
import common.world.World;
public class BlockSkull extends BlockDirectional {
public class BlockSkull extends Block implements Rotatable {
public BlockSkull() {
super(Material.SMALL);
this.setDefaultState(this.getBaseState().withProperty(FACING, Facing.NORTH));
@ -39,8 +40,8 @@ public class BlockSkull extends BlockDirectional {
return state.getValue(FACING).getHorizontalIndex();
}
protected IProperty[] getProperties() {
return new IProperty[] {FACING};
protected Property[] getProperties() {
return new Property[] {FACING};
}
public Model getModel(ModelProvider provider, String name, State state) {

View file

@ -3,6 +3,7 @@ package common.block.artificial;
import java.util.List;
import common.block.Block;
import common.block.Directional;
import common.block.Material;
import common.collect.Lists;
import common.entity.Entity;
@ -12,9 +13,8 @@ import common.item.Item;
import common.item.ItemStack;
import common.model.Model;
import common.model.ModelProvider;
import common.properties.IProperty;
import common.properties.Property;
import common.properties.PropertyBool;
import common.properties.PropertyDirection;
import common.util.BlockPos;
import common.util.BoundingBox;
import common.util.Facing;
@ -23,9 +23,8 @@ import common.world.IWorldAccess;
import common.world.State;
import common.world.World;
public class BlockSlab extends Block
public class BlockSlab extends Block implements Directional
{
public static final PropertyDirection FACING = PropertyDirection.create("facing");
public static final PropertyBool DOUBLE = PropertyBool.create("double");
public static final PropertyBool SEAMLESS = PropertyBool.create("seamless");
public static final List<BlockSlab> SLABS = Lists.newArrayList();
@ -72,9 +71,9 @@ public class BlockSlab extends Block
return dir == Facing.DOWN ? 0 : (dir == Facing.UP ? 1 : (dir.getHorizontalIndex() + 2));
}
protected IProperty[] getProperties()
protected Property[] getProperties()
{
return new IProperty[] {FACING, DOUBLE, SEAMLESS};
return new Property[] {FACING, DOUBLE, SEAMLESS};
}
public boolean canSilkHarvest()
@ -96,7 +95,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));
}
}
}

View file

@ -1,52 +1,34 @@
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);
public static final BlockStainedGlass[] GLASS = new BlockStainedGlass[DyeColor.values().length];
private final DyeColor color;
public static BlockStainedGlass getByColor(DyeColor color) {
return GLASS[color.getMetadata()];
}
public BlockStainedGlass() {
this.setDefaultState(this.getBaseState().withProperty(COLOR, DyeColor.WHITE));
public BlockStainedGlass(DyeColor color) {
this.color = color;
GLASS[color.ordinal()] = this;
}
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,103 +1,50 @@
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.properties.Property;
import common.world.State;
public class BlockStainedGlassPane extends BlockPane
{
public static final PropertyEnum<DyeColor> COLOR = PropertyEnum.<DyeColor>create("color", DyeColor.class);
public static final BlockStainedGlassPane[] PANES = new BlockStainedGlassPane[DyeColor.values().length];
private final DyeColor color;
public static BlockStainedGlassPane getByColor(DyeColor color) {
return PANES[color.getMetadata()];
}
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);
PANES[color.ordinal()] = 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 ((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)
protected Property[] getProperties()
{
return this.getState().withProperty(COLOR, DyeColor.byMetadata(meta));
return new Property[] {NORTH, EAST, WEST, SOUTH};
}
/**
* 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};
}
// 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";
}
}

View file

@ -4,6 +4,7 @@ import java.util.Arrays;
import java.util.List;
import common.block.Block;
import common.block.Rotatable;
import common.block.Material;
import common.entity.Entity;
import common.entity.npc.EntityNPC;
@ -15,8 +16,7 @@ import common.model.BlockLayer;
import common.model.Model;
import common.model.ModelProvider;
import common.model.Transforms;
import common.properties.IProperty;
import common.properties.PropertyDirection;
import common.properties.Property;
import common.properties.PropertyEnum;
import common.rng.Random;
import common.util.BlockPos;
@ -33,9 +33,8 @@ import common.world.State;
import common.world.World;
import common.world.AWorldServer;
public class BlockStairs extends Block
public class BlockStairs extends Block implements Rotatable
{
public static final PropertyDirection FACING = PropertyDirection.create("facing", Facing.Plane.HORIZONTAL);
public static final PropertyEnum<BlockStairs.EnumHalf> HALF = PropertyEnum.<BlockStairs.EnumHalf>create("half", BlockStairs.EnumHalf.class);
public static final PropertyEnum<BlockStairs.EnumShape> SHAPE = PropertyEnum.<BlockStairs.EnumShape>create("shape", BlockStairs.EnumShape.class);
private static final int[][] field_150150_a = new int[][] {{4, 5}, {5, 7}, {6, 7}, {4, 6}, {0, 1}, {1, 3}, {2, 3}, {0, 2}};
@ -805,9 +804,9 @@ public class BlockStairs extends Block
return state;
}
protected IProperty[] getProperties()
protected Property[] getProperties()
{
return new IProperty[] {FACING, HALF, SHAPE};
return new Property[] {FACING, HALF, SHAPE};
}
public Transforms getTransform() {

View file

@ -1,140 +0,0 @@
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();
public BlockStoneBrick()
{
super(Material.SOLID);
this.setDefaultState(this.getBaseState().withProperty(VARIANT, BlockStoneBrick.EnumType.DEFAULT));
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 Model getModel(ModelProvider provider, String name, State state) {
return provider.getModel("stonebrick_" + state.getValue(VARIANT).getTexture()).add().all();
}
public static enum EnumType implements Identifyable
{
DEFAULT("default", 0, "stonebrick", "Steinziegel"),
MOSSY("mossy", 1, "mossy_stonebrick", "Bemooste Steinziegel"),
CRACKED("cracked", 2, "cracked_stonebrick", "Rissige Steinziegel"),
CHISELED("chiseled", 3, "chiseled_stonebrick", "Gemeißelte Steinziegel");
private static final BlockStoneBrick.EnumType[] META_LOOKUP = new BlockStoneBrick.EnumType[values().length];
private final int meta;
private final String texture;
private final String name;
private final String display;
private EnumType(String texture, int meta, String name, String display)
{
this.texture = texture;
this.meta = meta;
this.name = name;
this.display = display;
}
public int getMetadata()
{
return this.meta;
}
public String toString()
{
return this.name;
}
public static BlockStoneBrick.EnumType byMetadata(int meta)
{
if (meta < 0 || meta >= META_LOOKUP.length)
{
meta = 0;
}
return META_LOOKUP[meta];
}
public String getName()
{
return this.name;
}
public String getTexture()
{
return this.texture;
}
public String getDisplay()
{
return this.display;
}
static {
for (BlockStoneBrick.EnumType blockstonebrick$enumtype : values())
{
META_LOOKUP[blockstonebrick$enumtype.getMetadata()] = blockstonebrick$enumtype;
}
}
}
}

View file

@ -1,6 +1,7 @@
package common.block.artificial;
import common.block.Block;
import common.block.Rotatable;
import common.block.Material;
import common.entity.npc.EntityNPC;
import common.entity.types.EntityLiving;
@ -11,9 +12,8 @@ import common.model.Model;
import common.model.ModelProvider;
import common.model.ModelRotation;
import common.model.Transforms;
import common.properties.IProperty;
import common.properties.Property;
import common.properties.PropertyBool;
import common.properties.PropertyDirection;
import common.properties.PropertyEnum;
import common.util.BlockPos;
import common.util.BoundingBox;
@ -26,9 +26,8 @@ import common.world.IWorldAccess;
import common.world.State;
import common.world.World;
public class BlockTrapDoor extends Block
public class BlockTrapDoor extends Block implements Rotatable
{
public static final PropertyDirection FACING = PropertyDirection.create("facing", Facing.Plane.HORIZONTAL);
public static final PropertyBool OPEN = PropertyBool.create("open");
public static final PropertyEnum<BlockTrapDoor.DoorHalf> HALF = PropertyEnum.<BlockTrapDoor.DoorHalf>create("half", BlockTrapDoor.DoorHalf.class);
@ -250,7 +249,7 @@ public class BlockTrapDoor extends Block
private static boolean isValidSupportBlock(Block blockIn)
{
return blockIn.getMaterial().isOpaque() && blockIn.isFullCube() || blockIn == Blocks.glass || blockIn == Blocks.stained_glass || blockIn == Blocks.glowstone || blockIn instanceof BlockSlab || blockIn instanceof BlockStairs;
return blockIn.getMaterial().isOpaque() && blockIn.isFullCube() || blockIn == Blocks.glass || blockIn instanceof BlockStainedGlass || blockIn == Blocks.glowstone || blockIn instanceof BlockSlab || blockIn instanceof BlockStairs;
}
public BlockLayer getBlockLayer()
@ -287,9 +286,9 @@ public class BlockTrapDoor extends Block
return i;
}
protected IProperty[] getProperties()
protected Property[] getProperties()
{
return new IProperty[] {FACING, OPEN, HALF};
return new Property[] {FACING, OPEN, HALF};
}
public boolean isMagnetic() {

View file

@ -4,20 +4,17 @@ import java.util.List;
import common.block.Block;
import common.block.Material;
import common.collect.Lists;
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.Property;
import common.properties.PropertyBool;
import common.properties.PropertyEnum;
import common.util.BlockPos;
import common.util.BoundingBox;
import common.util.Facing;
import common.util.Identifyable;
import common.world.IBlockAccess;
import common.world.IWorldAccess;
import common.world.State;
@ -30,25 +27,25 @@ 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);
public static final List<BlockWall> WALLS = Lists.newArrayList();
private final String texture;
public BlockWall(Block modelBlock)
public BlockWall(Block modelBlock, String texture)
{
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.texture = texture;
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);
WALLS.add(this);
}
public String getTexture() {
return this.texture;
}
// /**
// * Gets the localized name of this block. Used for the statistics page.
// */
// public String getLocalizedName()
// {
// return "Bruchsteinmauer";
// }
public boolean isFullCube()
{
@ -129,47 +126,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.
@ -179,13 +140,17 @@ public class BlockWall extends Block
return state.withProperty(UP, Boolean.valueOf(worldIn.getState(pos.up()).getBlock() != Blocks.air)).withProperty(NORTH, Boolean.valueOf(this.canConnectTo(worldIn, pos.north()))).withProperty(EAST, Boolean.valueOf(this.canConnectTo(worldIn, pos.east()))).withProperty(SOUTH, Boolean.valueOf(this.canConnectTo(worldIn, pos.south()))).withProperty(WEST, Boolean.valueOf(this.canConnectTo(worldIn, pos.west())));
}
protected IProperty[] getProperties()
public int getMetaFromState(State state) {
return 0;
}
protected Property[] getProperties()
{
return new IProperty[] {UP, NORTH, EAST, WEST, SOUTH, VARIANT};
return new Property[] {UP, NORTH, EAST, WEST, SOUTH};
}
public Model getModel(ModelProvider provider, String name, State state) {
String wall = state.getValue(VARIANT).getName();
String wall = this.texture;
boolean n = state.getValue(NORTH);
boolean s = state.getValue(SOUTH);
boolean w = state.getValue(WEST);
@ -328,59 +293,4 @@ public class BlockWall extends Block
.e().uv(5, 3, 11, 16)
.rotate(!w ? ModelRotation.X0_Y0 : (!e ? ModelRotation.X0_Y180 : (!s ? ModelRotation.X0_Y270 : ModelRotation.X0_Y90)));
}
public static enum EnumType implements Identifyable
{
NORMAL(0, "cobblestone", "Bruchsteinmauer"),
MOSSY(1, "mossy_cobblestone", "Bemooste Bruchsteinmauer");
private static final BlockWall.EnumType[] META_LOOKUP = new BlockWall.EnumType[values().length];
private final int meta;
private final String name;
private String display;
private EnumType(int meta, String name, String display)
{
this.meta = meta;
this.name = name;
this.display = display;
}
public int getMetadata()
{
return this.meta;
}
public String toString()
{
return this.name;
}
public static BlockWall.EnumType byMetadata(int meta)
{
if (meta < 0 || meta >= META_LOOKUP.length)
{
meta = 0;
}
return META_LOOKUP[meta];
}
public String getName()
{
return this.name;
}
public String getDisplay()
{
return this.display;
}
static {
for (BlockWall.EnumType blockwall$enumtype : values())
{
META_LOOKUP[blockwall$enumtype.getMetadata()] = blockwall$enumtype;
}
}
}
}

View file

@ -0,0 +1,34 @@
package common.block.artificial;
import common.block.Block;
import common.block.Material;
import common.color.DyeColor;
import common.item.CheatTab;
import common.model.Model;
import common.model.ModelProvider;
import common.world.State;
public class BlockWool extends Block {
public static final BlockWool[] WOOLS = new BlockWool[DyeColor.values().length];
private final DyeColor color;
public static BlockWool getByColor(DyeColor color) {
return WOOLS[color.getMetadata()];
}
public BlockWool(DyeColor color) {
super(Material.BURNABLE);
this.color = color;
this.setTab(CheatTab.BLOCKS);
WOOLS[color.ordinal()] = this;
}
public DyeColor getColor() {
return this.color;
}
public Model getModel(ModelProvider provider, String name, State state) {
return provider.getModel(this.color.getName() + "_wool").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

@ -9,7 +9,7 @@ import common.item.CheatTab;
import common.model.BlockLayer;
import common.model.Model;
import common.model.ModelProvider;
import common.properties.IProperty;
import common.properties.Property;
import common.properties.PropertyInteger;
import common.rng.Random;
import common.util.BlockPos;
@ -161,16 +161,16 @@ public class BlockCactus extends Block
return ((Integer)state.getValue(AGE)).intValue();
}
protected IProperty[] getProperties()
protected Property[] getProperties()
{
return new IProperty[] {AGE};
return new Property[] {AGE};
}
public Model getModel(ModelProvider provider, String name, State state) {
return cactus;
}
public IProperty<?>[] getIgnoredProperties() {
return new IProperty[] {AGE};
public Property<?>[] getIgnoredProperties() {
return new Property[] {AGE};
}
}

View file

@ -1,7 +1,7 @@
package common.block.foliage;
import common.block.Block;
import common.block.BlockDirectional;
import common.block.Rotatable;
import common.block.Material;
import common.color.DyeColor;
import common.entity.types.EntityLiving;
@ -13,7 +13,7 @@ import common.model.BlockLayer;
import common.model.Model;
import common.model.ModelProvider;
import common.model.ModelRotation;
import common.properties.IProperty;
import common.properties.Property;
import common.properties.PropertyInteger;
import common.rng.Random;
import common.util.BlockPos;
@ -25,7 +25,7 @@ import common.world.State;
import common.world.World;
import common.world.AWorldServer;
public class BlockCocoa extends BlockDirectional implements IGrowable
public class BlockCocoa extends Block implements Rotatable, IGrowable
{
public static final PropertyInteger AGE = PropertyInteger.create("age", 0, 2);
@ -169,21 +169,13 @@ public class BlockCocoa extends BlockDirectional implements IGrowable
for (int k = 0; k < j; ++k)
{
spawnAsEntity(worldIn, pos, new ItemStack(Items.dye, 1, DyeColor.BROWN.getDyeDamage()));
spawnAsEntity(worldIn, pos, new ItemStack(Items.cocoa));
}
}
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;
}
/**
@ -228,9 +220,9 @@ public class BlockCocoa extends BlockDirectional implements IGrowable
return i;
}
protected IProperty[] getProperties()
protected Property[] getProperties()
{
return new IProperty[] {FACING, AGE};
return new Property[] {FACING, AGE};
}
public Model getModel(ModelProvider provider, String name, State state) {

View file

@ -9,7 +9,7 @@ import common.item.Item;
import common.item.ItemStack;
import common.model.Model;
import common.model.ModelProvider;
import common.properties.IProperty;
import common.properties.Property;
import common.properties.PropertyInteger;
import common.rng.Random;
import common.util.BlockPos;
@ -163,7 +163,7 @@ public class BlockCrops extends BlockBush implements IGrowable
{
if (worldIn.rand.zrange(15) <= i)
{
spawnAsEntity(worldIn, pos, new ItemStack(this.getSeed(), 1, 0));
spawnAsEntity(worldIn, pos, new ItemStack(this.getSeed()));
}
}
}
@ -217,9 +217,9 @@ public class BlockCrops extends BlockBush implements IGrowable
return ((Integer)state.getValue(AGE)).intValue();
}
protected IProperty[] getProperties()
protected Property[] getProperties()
{
return new IProperty[] {AGE};
return new Property[] {AGE};
}
public Model getModel(ModelProvider provider, String name, State state) {

View file

@ -2,6 +2,7 @@ package common.block.foliage;
import common.block.Block;
import common.block.Material;
import common.block.natural.BlockColoredClay;
import common.entity.npc.EntityNPC;
import common.init.Blocks;
import common.init.Items;
@ -38,7 +39,7 @@ public class BlockDeadBush extends BlockBush
*/
protected boolean canPlaceBlockOn(Block ground)
{
return ground == Blocks.sand || ground == Blocks.hardened_clay || ground == Blocks.stained_hardened_clay || ground == Blocks.dirt;
return ground == Blocks.sand || ground == Blocks.hardened_clay || ground instanceof BlockColoredClay || ground == Blocks.dirt;
}
/**
@ -62,7 +63,7 @@ public class BlockDeadBush extends BlockBush
if (!worldIn.client && player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemShears)
{
// player.triggerAchievement(StatRegistry.mineBlockStatArray[BlockRegistry.getIdFromBlock(this)]);
spawnAsEntity(worldIn, pos, new ItemStack(Blocks.deadbush, 1, 0));
spawnAsEntity(worldIn, pos, new ItemStack(Blocks.deadbush));
}
else
{

View file

@ -3,9 +3,10 @@ package common.block.foliage;
import java.util.List;
import common.block.Block;
import common.block.BlockDirectional;
import common.block.Rotatable;
import common.block.Material;
import common.block.SoundType;
import common.collect.Lists;
import common.color.Colorizer;
import common.entity.npc.EntityNPC;
import common.entity.types.EntityLiving;
@ -18,7 +19,7 @@ import common.item.ItemShears;
import common.item.ItemStack;
import common.model.Model;
import common.model.ModelProvider;
import common.properties.IProperty;
import common.properties.Property;
import common.properties.PropertyEnum;
import common.rng.Random;
import common.tileentity.TileEntity;
@ -32,20 +33,29 @@ import common.world.State;
import common.world.World;
import common.world.AWorldServer;
public class BlockDoublePlant extends BlockBush implements IGrowable
public class BlockDoublePlant extends BlockBush implements Rotatable, 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 static final BlockDoublePlant[] PLANTS = new BlockDoublePlant[EnumPlantType.values().length];
public BlockDoublePlant()
private final EnumPlantType type;
public static BlockDoublePlant getByType(EnumPlantType type) {
return PLANTS[type.ordinal()];
}
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();
PLANTS[type.ordinal()] = this;
}
public EnumPlantType getType() {
return this.type;
}
public void updateTick(AWorldServer worldIn, BlockPos pos, State state, Random rand)
@ -59,8 +69,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 +81,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 +99,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 +154,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 +194,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 +232,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 +258,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 +266,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 +274,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()
protected Property[] getProperties()
{
return new IProperty[] {HALF, VARIANT, FACING};
return new Property[] {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,16 +291,16 @@ 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();
}
public IProperty<?>[] getIgnoredProperties() {
return new IProperty[] {FACING};
public Property<?>[] getIgnoredProperties() {
return new Property[] {FACING};
}
public static enum EnumBlockHalf implements Identifyable
@ -389,9 +323,9 @@ public class BlockDoublePlant extends BlockBush implements IGrowable
{
SUNFLOWER(0, "sunflower", "Sonnenblume"),
SYRINGA(1, "syringa", "Flieder"),
GRASS(2, "double_grass", "Hohes Gras"),
FERN(3, "double_fern", "Großer Farn"),
ROSE(4, "double_rose", "Rosenstrauch"),
GRASS(2, "large_tallgrass", "Hohes Gras"),
FERN(3, "large_fern", "Großer Farn"),
ROSE(4, "rose_bush", "Rosenstrauch"),
PAEONIA(5, "paeonia", "Pfingstrose");
private static final BlockDoublePlant.EnumPlantType[] META_LOOKUP = new BlockDoublePlant.EnumPlantType[values().length];

View file

@ -2,15 +2,15 @@ package common.block.foliage;
import common.block.Block;
import common.block.Material;
import common.block.natural.BlockDirt;
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;
import common.properties.IProperty;
import common.properties.Property;
import common.properties.PropertyInteger;
import common.rng.Random;
import common.util.BlockPos;
@ -149,12 +149,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;
}
/**
@ -173,9 +173,9 @@ public class BlockFarmland extends Block
return ((Integer)state.getValue(MOISTURE)).intValue();
}
protected IProperty[] getProperties()
protected Property[] getProperties()
{
return new IProperty[] {MOISTURE};
return new Property[] {MOISTURE};
}
public Model getModel(ModelProvider provider, String name, State state) {

View file

@ -12,7 +12,7 @@ import common.item.Item;
import common.item.ItemStack;
import common.model.Model;
import common.model.ModelProvider;
import common.properties.IProperty;
import common.properties.Property;
import common.properties.PropertyEnum;
import common.rng.Random;
import common.util.BlockPos;
@ -21,14 +21,24 @@ import common.vars.Vars;
import common.world.State;
import common.world.AWorldServer;
public abstract class BlockFlower extends BlockBush
public class BlockFlower extends BlockBush
{
protected PropertyEnum<BlockFlower.EnumFlowerType> type;
public 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("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

@ -3,7 +3,6 @@ package common.block.foliage;
import common.biome.IBiome;
import common.block.Block;
import common.block.Material;
import common.block.natural.BlockDirt;
import common.color.Colorizer;
import common.init.Blocks;
import common.item.CheatTab;
@ -11,7 +10,7 @@ import common.item.Item;
import common.model.BlockLayer;
import common.model.Model;
import common.model.ModelProvider;
import common.properties.IProperty;
import common.properties.Property;
import common.properties.PropertyBool;
import common.rng.Random;
import common.util.BlockPos;
@ -78,7 +77,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 +86,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 +97,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);
}
/**
@ -132,9 +131,9 @@ public class BlockGrass extends Block implements IGrowable
return 0;
}
protected IProperty[] getProperties()
protected Property[] getProperties()
{
return new IProperty[] {SNOWY};
return new Property[] {SNOWY};
}
public Model getModel(ModelProvider provider, String name, State state) {

View file

@ -7,7 +7,7 @@ import common.init.ItemRegistry;
import common.item.Item;
import common.model.Model;
import common.model.ModelProvider;
import common.properties.IProperty;
import common.properties.Property;
import common.properties.PropertyEnum;
import common.rng.Random;
import common.util.BlockPos;
@ -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_)
@ -95,9 +96,9 @@ public class BlockHugeMushroom extends Block
return ((BlockHugeMushroom.EnumType)state.getValue(VARIANT)).getMetadata();
}
protected IProperty[] getProperties()
protected Property[] getProperties()
{
return new IProperty[] {VARIANT};
return new Property[] {VARIANT};
}
public Model getModel(ModelProvider provider, String name, State state) {

View file

@ -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;
@ -18,9 +19,8 @@ import common.item.ItemStack;
import common.model.Model;
import common.model.ModelProvider;
import common.model.ParticleType;
import common.properties.IProperty;
import common.properties.Property;
import common.properties.PropertyBool;
import common.properties.PropertyEnum;
import common.rng.Random;
import common.tileentity.TileEntity;
import common.util.BlockPos;
@ -33,41 +33,37 @@ 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 static final BlockLeaves[] MAPPING = new BlockLeaves[WoodType.values().length * LeavesType.values().length];
private final WoodType type;
private final LeavesType subType;
int[] surroundings;
public static BlockLeaves getLeavesBlock(WoodType type, LeavesType subType) {
return MAPPING[type.ordinal() * LeavesType.values().length + subType.ordinal()];
}
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);
this.setLightOpacity(1);
this.setStepSound(SoundType.GRASS);
LEAVES.add(this);
MAPPING[type.ordinal() * LeavesType.values().length + subType.ordinal()] = 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 +96,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, getLeavesBlock(this.type, 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 +266,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 +282,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 +313,13 @@ public class BlockLeaves extends BlockLeavesBase
return i;
}
// public BlockPlanks.EnumType getWoodType() {
// return this.type;
// }
protected IProperty[] getProperties() {
return new IProperty[] {TYPE, DECAY};
protected Property[] getProperties() {
return new Property[] {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 +327,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).add().all().tint() :
provider.getModel(name).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);
public Property<?>[] getIgnoredProperties() {
return new Property[] {DECAY};
}
}

View file

@ -3,7 +3,7 @@ package common.block.foliage;
import java.util.List;
import common.block.Block;
import common.block.BlockDirectional;
import common.block.Rotatable;
import common.block.liquid.BlockLiquid;
import common.block.liquid.BlockStaticLiquid;
import common.entity.Entity;
@ -14,7 +14,7 @@ import common.item.CheatTab;
import common.model.Model;
import common.model.ModelProvider;
import common.model.ModelRotation;
import common.properties.IProperty;
import common.properties.Property;
import common.util.BlockPos;
import common.util.BoundingBox;
import common.util.Facing;
@ -22,14 +22,14 @@ import common.world.IWorldAccess;
import common.world.State;
import common.world.World;
public class BlockLilyPad extends BlockBush
public class BlockLilyPad extends BlockBush implements Rotatable
{
public BlockLilyPad()
{
float f = 0.5F;
float f1 = 0.015625F;
this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f1, 0.5F + f);
this.setDefaultState(this.getBaseState().withProperty(BlockDirectional.FACING, Facing.NORTH));
this.setDefaultState(this.getBaseState().withProperty(FACING, Facing.NORTH));
this.setTab(CheatTab.PLANTS);
}
@ -87,22 +87,22 @@ public class BlockLilyPad extends BlockBush
public State getStateFromMeta(int meta)
{
return this.getState().withProperty(BlockDirectional.FACING, Facing.getHorizontal(meta));
return this.getState().withProperty(FACING, Facing.getHorizontal(meta));
}
public int getMetaFromState(State state)
{
return ((Facing)state.getValue(BlockDirectional.FACING)).getHorizontalIndex();
return ((Facing)state.getValue(FACING)).getHorizontalIndex();
}
protected IProperty[] getProperties()
protected Property[] getProperties()
{
return new IProperty[] {BlockDirectional.FACING};
return new Property[] {FACING};
}
public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, int meta, EntityLiving placer)
{
return this.getState().withProperty(BlockDirectional.FACING, placer.getHorizontalFacing().getOpposite());
return this.getState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());
}
public Model getModel(ModelProvider provider, String name, State state) {
@ -110,6 +110,6 @@ public class BlockLilyPad extends BlockBush
.add(0, 0.25f, 0, 16, 0.25f, 16)
.d().uv(16, 16, 0, 0).tint().noCull()
.u().uv(16, 0, 0, 16).tint().noCull()
.rotate(ModelRotation.getNorthRot(state.getValue(BlockDirectional.FACING)));
.rotate(ModelRotation.getNorthRot(state.getValue(FACING)));
}
}

View file

@ -8,7 +8,7 @@ import common.item.CheatTab;
import common.model.Model;
import common.model.ModelProvider;
import common.model.ModelRotation;
import common.properties.IProperty;
import common.properties.Property;
import common.properties.PropertyEnum;
import common.util.BlockPos;
import common.util.Facing;
@ -82,19 +82,19 @@ public class BlockLog extends BlockRotatedPillar
switch (meta & 3)
{
case 0:
default:
iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Y);
break;
case 4:
case 1:
iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.X);
break;
case 8:
case 2:
iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Z);
break;
default:
case 3:
iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.NONE);
}
@ -109,7 +109,6 @@ public class BlockLog extends BlockRotatedPillar
public int getMetaFromState(State state)
{
int i = 0;
// i = i | ((BlockPlanks.EnumType)state.getValue(VARIANT)).getMetadata();
switch ((BlockLog.EnumAxis)state.getValue(LOG_AXIS))
{
@ -128,9 +127,9 @@ public class BlockLog extends BlockRotatedPillar
return i;
}
protected IProperty[] getProperties()
protected Property[] getProperties()
{
return new IProperty[] {LOG_AXIS};
return new Property[] {LOG_AXIS};
}
public static enum EnumAxis implements Identifyable

View file

@ -2,7 +2,6 @@ package common.block.foliage;
import common.biome.IBiome;
import common.block.Block;
import common.block.natural.BlockDirt;
import common.init.Blocks;
import common.model.Model;
import common.model.ModelProvider;
@ -79,7 +78,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

@ -2,14 +2,13 @@ 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;
import common.model.Model;
import common.model.ModelProvider;
import common.model.ParticleType;
import common.properties.IProperty;
import common.properties.Property;
import common.properties.PropertyBool;
import common.rng.Random;
import common.util.BlockPos;
@ -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);
}
/**
@ -96,9 +95,9 @@ public class BlockMycelium extends Block
return 0;
}
protected IProperty[] getProperties()
protected Property[] getProperties()
{
return new IProperty[] {SNOWY};
return new Property[] {SNOWY};
}
public Model getModel(ModelProvider provider, String name, State state) {

View file

@ -1,19 +1,20 @@
package common.block.foliage;
import common.block.BlockDirectional;
import common.block.Block;
import common.block.Rotatable;
import common.block.Material;
import common.entity.types.EntityLiving;
import common.item.CheatTab;
import common.model.Model;
import common.model.ModelProvider;
import common.model.ModelRotation;
import common.properties.IProperty;
import common.properties.Property;
import common.util.BlockPos;
import common.util.Facing;
import common.world.State;
import common.world.World;
public class BlockPumpkin extends BlockDirectional {
public class BlockPumpkin extends Block implements Rotatable {
public BlockPumpkin() {
super(Material.SOFT);
this.setDefaultState(this.getBaseState().withProperty(FACING, Facing.NORTH));
@ -36,8 +37,8 @@ public class BlockPumpkin extends BlockDirectional {
return state.getValue(FACING).getHorizontalIndex();
}
protected IProperty[] getProperties() {
return new IProperty[] {FACING};
protected Property[] getProperties() {
return new Property[] {FACING};
}
public Model getModel(ModelProvider provider, String name, State state) {

View file

@ -8,7 +8,7 @@ import common.item.Item;
import common.model.BlockLayer;
import common.model.Model;
import common.model.ModelProvider;
import common.properties.IProperty;
import common.properties.Property;
import common.properties.PropertyInteger;
import common.rng.Random;
import common.util.BlockPos;
@ -179,16 +179,16 @@ public class BlockReed extends Block
return ((Integer)state.getValue(AGE)).intValue();
}
protected IProperty[] getProperties()
protected Property[] getProperties()
{
return new IProperty[] {AGE};
return new Property[] {AGE};
}
public Model getModel(ModelProvider provider, String name, State state) {
return provider.getModel("reeds").crossTint();
}
public IProperty<?>[] getIgnoredProperties() {
return new IProperty[] {AGE};
public Property<?>[] getIgnoredProperties() {
return new Property[] {AGE};
}
}

View file

@ -9,7 +9,7 @@ import common.init.WoodType;
import common.item.CheatTab;
import common.model.Model;
import common.model.ModelProvider;
import common.properties.IProperty;
import common.properties.Property;
import common.properties.PropertyInteger;
import common.rng.Random;
import common.util.BlockPos;
@ -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)
@ -132,9 +132,9 @@ public class BlockSapling extends BlockBush implements IGrowable
return state.getValue(STAGE);
}
protected IProperty[] getProperties()
protected Property[] getProperties()
{
return new IProperty[] {STAGE};
return new Property[] {STAGE};
}
public Model getModel(ModelProvider provider, String name, State state) {

View file

@ -1,8 +1,7 @@
package common.block.foliage;
import java.util.function.Predicate;
import common.block.Block;
import common.block.DirectionalUp;
import common.init.Blocks;
import common.init.Items;
import common.item.CheatTab;
@ -11,8 +10,7 @@ import common.item.ItemStack;
import common.model.Model;
import common.model.ModelProvider;
import common.model.ModelRotation;
import common.properties.IProperty;
import common.properties.PropertyDirection;
import common.properties.Property;
import common.properties.PropertyInteger;
import common.rng.Random;
import common.util.BlockPos;
@ -23,16 +21,10 @@ import common.world.State;
import common.world.World;
import common.world.AWorldServer;
public class BlockStem extends BlockBush implements IGrowable
public class BlockStem extends BlockBush implements DirectionalUp, IGrowable
{
public static final PropertyInteger AGE = PropertyInteger.create("age", 0, 7);
public static final PropertyDirection FACING = PropertyDirection.create("facing", new Predicate<Facing>()
{
public boolean test(Facing p_apply_1_)
{
return p_apply_1_ != Facing.DOWN;
}
});
private final Block crop;
public BlockStem(Block crop)
@ -234,9 +226,9 @@ public class BlockStem extends BlockBush implements IGrowable
return ((Integer)state.getValue(AGE)).intValue();
}
protected IProperty[] getProperties()
protected Property[] getProperties()
{
return new IProperty[] {AGE, FACING};
return new Property[] {AGE, FACING};
}
public Model getModel(ModelProvider provider, String name, State state) {

Some files were not shown because too many files have changed in this diff Show more