Compare commits

..

No commits in common. "55aac31bb9b9e9f256ab8ec70454209fb6e63cf4" and "bc74b3a29d24a9ddbbb8483842a86cbf9de4bc3a" have entirely different histories.

299 changed files with 5388 additions and 2991 deletions

View file

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

View file

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

View file

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

View file

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

View file

@ -13,7 +13,7 @@ import common.collect.Maps;
import common.init.BlockRegistry; import common.init.BlockRegistry;
import common.init.Blocks; import common.init.Blocks;
import common.init.FluidRegistry; import common.init.FluidRegistry;
import common.properties.Property; import common.properties.IProperty;
import common.util.IRegistry; import common.util.IRegistry;
import common.world.State; import common.world.State;
@ -36,7 +36,7 @@ public class ModelManager
// Log.info("Builtin: " + BlockRegistry.getNameFromBlock(block)); // Log.info("Builtin: " + BlockRegistry.getNameFromBlock(block));
} }
else { else {
Property<?>[] ignored = block.getIgnoredProperties(); IProperty<?>[] ignored = block.getIgnoredProperties();
if(ignored != null) if(ignored != null)
this.mappers.put(block, new MultiStateMap.Builder().ignore(ignored).build()); 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.Lists;
import common.collect.Maps; import common.collect.Maps;
import common.init.BlockRegistry; import common.init.BlockRegistry;
import common.properties.Property; import common.properties.IProperty;
import common.world.State; import common.world.State;
public class MultiStateMap extends StateMap public class MultiStateMap extends StateMap
{ {
private final Property<?> name; private final IProperty<?> name;
private final String suffix; private final String suffix;
private final List < Property<? >> ignored; private final List < IProperty<? >> ignored;
private MultiStateMap(Property<?> name, String suffix, List < Property<? >> ignored) private MultiStateMap(IProperty<?> name, String suffix, List < IProperty<? >> ignored)
{ {
this.name = name; this.name = name;
this.suffix = suffix; this.suffix = suffix;
@ -25,7 +25,7 @@ public class MultiStateMap extends StateMap
protected String getResourceLocation(State state) protected String getResourceLocation(State state)
{ {
Map<Property, Comparable> map = Maps.<Property, Comparable>newLinkedHashMap(state.getProperties()); Map<IProperty, Comparable> map = Maps.<IProperty, Comparable>newLinkedHashMap(state.getProperties());
String s; String s;
if (this.name == null) if (this.name == null)
@ -34,7 +34,7 @@ public class MultiStateMap extends StateMap
} }
else else
{ {
s = ((Property)this.name).getName((Comparable)map.remove(this.name)); s = ((IProperty)this.name).getName((Comparable)map.remove(this.name));
} }
if (this.suffix != null) if (this.suffix != null)
@ -42,7 +42,7 @@ public class MultiStateMap extends StateMap
s = s + this.suffix; s = s + this.suffix;
} }
for (Property<?> iproperty : this.ignored) for (IProperty<?> iproperty : this.ignored)
{ {
map.remove(iproperty); map.remove(iproperty);
} }
@ -52,11 +52,11 @@ public class MultiStateMap extends StateMap
public static class Builder public static class Builder
{ {
private Property<?> name; private IProperty<?> name;
private String suffix; private String suffix;
private final List < Property<? >> ignored = Lists. < Property<? >> newArrayList(); private final List < IProperty<? >> ignored = Lists. < IProperty<? >> newArrayList();
public MultiStateMap.Builder withName(Property<?> builderPropertyIn) public MultiStateMap.Builder withName(IProperty<?> builderPropertyIn)
{ {
this.name = builderPropertyIn; this.name = builderPropertyIn;
return this; return this;
@ -68,7 +68,7 @@ public class MultiStateMap extends StateMap
return this; return this;
} }
public MultiStateMap.Builder ignore(Property<?>... p_178442_1_) public MultiStateMap.Builder ignore(IProperty<?>... p_178442_1_)
{ {
Collections.addAll(this.ignored, p_178442_1_); Collections.addAll(this.ignored, p_178442_1_);
return this; return this;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -20,7 +20,6 @@ import common.init.ItemRegistry;
import common.init.Items; import common.init.Items;
import common.init.SoundEvent; import common.init.SoundEvent;
import common.item.ItemDye; import common.item.ItemDye;
import common.item.ItemPotion;
import common.log.Log; import common.log.Log;
import common.model.ParticleType; import common.model.ParticleType;
import common.rng.Random; import common.rng.Random;
@ -654,7 +653,7 @@ public class WorldClient extends AWorldClient
for (int i1 = 0; i1 < 8; ++i1) 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)}); 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});
} }
ParticleType enumparticletypes = ParticleType.WATER_SPLASH; ParticleType enumparticletypes = ParticleType.WATER_SPLASH;
@ -662,14 +661,13 @@ public class WorldClient extends AWorldClient
float f1 = 1.0F; float f1 = 1.0F;
float f2 = 1.0F; float f2 = 1.0F;
if((data & 16383) != 0) { if((data & 16383) != 0) {
ItemPotion potion = ItemPotion.getPotionItem(data); int j1 = Items.potion.getColorFromDamage(data);
int j1 = potion.getColorFromDamage();
f = (float)(j1 >> 16 & 255) / 255.0F; f = (float)(j1 >> 16 & 255) / 255.0F;
f1 = (float)(j1 >> 8 & 255) / 255.0F; f1 = (float)(j1 >> 8 & 255) / 255.0F;
f2 = (float)(j1 >> 0 & 255) / 255.0F; f2 = (float)(j1 >> 0 & 255) / 255.0F;
enumparticletypes = ParticleType.SPELL; enumparticletypes = ParticleType.SPELL;
if (potion.isEffectInstant()) if (Items.potion.isEffectInstant(data))
{ {
enumparticletypes = ParticleType.SPELL_INSTANT; 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: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 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: 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 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.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: 556 B

After

Width:  |  Height:  |  Size: 556 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: 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: 402 B

After

Width:  |  Height:  |  Size: 402 B

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: 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.

Before

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

View file

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

View file

@ -3,11 +3,10 @@ package common.ai;
import java.util.Map; import java.util.Map;
import common.block.Block; import common.block.Block;
import common.block.foliage.BlockFlower;
import common.collect.Maps; import common.collect.Maps;
import common.entity.npc.EntityNPC; import common.entity.npc.EntityNPC;
import common.init.Blocks; import common.init.Blocks;
import common.item.Item; import common.init.ItemRegistry;
import common.item.ItemStack; import common.item.ItemStack;
import common.rng.Random; import common.rng.Random;
import common.util.BlockPos; import common.util.BlockPos;
@ -18,12 +17,45 @@ import common.world.World;
public class EntityAITakePlace extends EntityAIBase 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<State, ItemStack> STEALABLE = Maps.newHashMap();
private static final Map<Item, State> PLACEABLE = Maps.newHashMap(); private static final Map<StackKey, State> PLACEABLE = Maps.newHashMap();
private static void addPlaceable(State state, ItemStack stack) { private static void addPlaceable(State state, ItemStack stack) {
STEALABLE.put(state, stack); STEALABLE.put(state, stack);
PLACEABLE.put(stack.getItem(), state); PLACEABLE.put(new StackKey(stack), state);
} }
private static void addPlaceable(Block block) { private static void addPlaceable(Block block) {
@ -31,9 +63,7 @@ public class EntityAITakePlace extends EntityAIBase
} }
static { static {
for(BlockFlower block : BlockFlower.FLOWERS) { addPlaceable(Blocks.flower);
addPlaceable(block);
}
addPlaceable(Blocks.brown_mushroom); addPlaceable(Blocks.brown_mushroom);
addPlaceable(Blocks.red_mushroom); addPlaceable(Blocks.red_mushroom);
addPlaceable(Blocks.blue_mushroom); addPlaceable(Blocks.blue_mushroom);
@ -55,7 +85,7 @@ public class EntityAITakePlace extends EntityAIBase
this.place = false; this.place = false;
return this.entity.getRNG().chance(20); return this.entity.getRNG().chance(20);
} }
else if(this.entity.getRNG().chance(200) && PLACEABLE.containsKey(this.entity.getHeldItem().getItem())) { else if(this.entity.getRNG().chance(200) && PLACEABLE.containsKey(new StackKey(this.entity.getHeldItem()))) {
this.place = this.entity.getRNG().rarity(10); this.place = this.entity.getRNG().rarity(10);
return true; return true;
} }
@ -72,11 +102,11 @@ public class EntityAITakePlace extends EntityAIBase
BlockPos blockpos = new BlockPos(i, j, k); BlockPos blockpos = new BlockPos(i, j, k);
if(this.place) { if(this.place) {
ItemStack stack = this.entity.getHeldItem(); ItemStack stack = this.entity.getHeldItem();
if(stack == null || !PLACEABLE.containsKey(this.entity.getHeldItem().getItem())) if(stack == null || !PLACEABLE.containsKey(new StackKey(this.entity.getHeldItem())))
return; return;
Block replace = world.getState(blockpos).getBlock(); Block replace = world.getState(blockpos).getBlock();
Block below = world.getState(blockpos.down()).getBlock(); Block below = world.getState(blockpos.down()).getBlock();
State state = PLACEABLE.get(this.entity.getHeldItem().getItem()); State state = PLACEABLE.get(new StackKey(this.entity.getHeldItem()));
if (state.getBlock().canPlaceBlockAt(world, blockpos) && replace == Blocks.air && if (state.getBlock().canPlaceBlockAt(world, blockpos) && replace == Blocks.air &&
below != Blocks.air && below.isFullCube()) below != Blocks.air && below.isFullCube())
{ {

View file

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

View file

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

View file

@ -0,0 +1,49 @@
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

@ -0,0 +1,12 @@
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

@ -1,8 +0,0 @@
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

@ -1,8 +0,0 @@
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

@ -1,8 +0,0 @@
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

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

View file

@ -1,12 +1,18 @@
package common.block.artificial; package common.block.artificial;
import java.util.List;
import common.block.Block; import common.block.Block;
import common.block.Material; import common.block.Material;
import common.color.DyeColor; import common.color.DyeColor;
import common.item.CheatTab; import common.item.CheatTab;
import common.item.Item;
import common.item.ItemStack;
import common.model.Model; import common.model.Model;
import common.model.ModelProvider; import common.model.ModelProvider;
import common.model.Transforms; import common.model.Transforms;
import common.properties.IProperty;
import common.properties.PropertyEnum;
import common.util.BlockPos; import common.util.BlockPos;
import common.util.Facing; import common.util.Facing;
import common.world.IWorldAccess; import common.world.IWorldAccess;
@ -15,27 +21,25 @@ import common.world.World;
public class BlockCarpet extends Block public class BlockCarpet extends Block
{ {
public static final BlockCarpet[] CARPETS = new BlockCarpet[DyeColor.values().length]; public static final PropertyEnum<DyeColor> COLOR = PropertyEnum.<DyeColor>create("color", DyeColor.class);
private final DyeColor color;
public static BlockCarpet getByColor(DyeColor color) {
return CARPETS[color.getMetadata()];
}
public BlockCarpet(DyeColor color) public BlockCarpet()
{ {
super(Material.FLEECE); super(Material.FLEECE);
this.color = color; this.setDefaultState(this.getBaseState().withProperty(COLOR, DyeColor.WHITE));
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.0625F, 1.0F); this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.0625F, 1.0F);
// this.setTickRandomly(true);
this.setTab(CheatTab.DECORATION); this.setTab(CheatTab.DECORATION);
this.setBlockBoundsFromMeta(); this.setBlockBoundsFromMeta(0);
CARPETS[color.ordinal()] = this;
} }
public DyeColor getColor() { // /**
return this.color; // * Get the MapColor for this Block and the given BlockState
} // */
// public MapColor getMapColor(IBlockState state)
// {
// return ((EnumDyeColor)state.getValue(COLOR)).getMapColor();
// }
/** /**
* Used to determine ambient occlusion and culling when rebuilding chunks for render * Used to determine ambient occlusion and culling when rebuilding chunks for render
@ -55,15 +59,15 @@ public class BlockCarpet extends Block
*/ */
public void setBlockBoundsForItemRender() public void setBlockBoundsForItemRender()
{ {
this.setBlockBoundsFromMeta(); this.setBlockBoundsFromMeta(0);
} }
public void setBlockBoundsBasedOnState(IWorldAccess worldIn, BlockPos pos) public void setBlockBoundsBasedOnState(IWorldAccess worldIn, BlockPos pos)
{ {
this.setBlockBoundsFromMeta(); this.setBlockBoundsFromMeta(0);
} }
private void setBlockBoundsFromMeta() protected void setBlockBoundsFromMeta(int meta)
{ {
int i = 0; int i = 0;
float f = (float)(1 * (1 + i)) / 16.0F; float f = (float)(1 * (1 + i)) / 16.0F;
@ -107,11 +111,52 @@ public class BlockCarpet extends Block
return side == Facing.UP ? true : super.shouldSideBeRendered(worldIn, pos, side); 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() { public Transforms getTransform() {
return Transforms.LAYER; return Transforms.LAYER;
} }
public Model getModel(ModelProvider provider, String name, State state) { public Model getModel(ModelProvider provider, String name, State state) {
return provider.getModel(this.color.getName() + "_wool").add(0, 0, 0, 16, 1, 16).nswe().uv(0, 15, 16, 16).d().u().noCull(); return provider.getModel(state.getValue(COLOR).getName() + "_wool").add(0, 0, 0, 16, 1, 16).nswe().uv(0, 15, 16, 16).d().u().noCull();
} }
} }

View file

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

View file

@ -13,7 +13,7 @@ import common.model.Model;
import common.model.ModelProvider; import common.model.ModelProvider;
import common.model.ModelRotation; import common.model.ModelRotation;
import common.model.Transforms; import common.model.Transforms;
import common.properties.Property; import common.properties.IProperty;
import common.properties.PropertyBool; import common.properties.PropertyBool;
import common.util.BlockPos; import common.util.BlockPos;
import common.util.BoundingBox; 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()))); 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 Property[] getProperties() protected IProperty[] getProperties()
{ {
return new Property[] {NORTH, EAST, WEST, SOUTH}; return new IProperty[] {NORTH, EAST, WEST, SOUTH};
} }
public Transforms getTransform() { public Transforms getTransform() {

View file

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

View file

@ -1,13 +1,9 @@
package common.block.artificial; package common.block.artificial;
import java.util.List;
import common.block.Block; import common.block.Block;
import common.block.Material; import common.block.Material;
import common.block.foliage.BlockFlower; import common.block.foliage.BlockFlower;
import common.collect.Lists;
import common.entity.npc.EntityNPC; import common.entity.npc.EntityNPC;
import common.init.BlockRegistry;
import common.init.Blocks; import common.init.Blocks;
import common.init.ItemRegistry; import common.init.ItemRegistry;
import common.init.Items; import common.init.Items;
@ -17,6 +13,8 @@ import common.item.ItemStack;
import common.model.BlockLayer; import common.model.BlockLayer;
import common.model.Model; import common.model.Model;
import common.model.ModelProvider; import common.model.ModelProvider;
import common.properties.IProperty;
import common.properties.PropertyInteger;
import common.rng.Random; import common.rng.Random;
import common.util.BlockPos; import common.util.BlockPos;
import common.util.Facing; import common.util.Facing;
@ -24,7 +22,7 @@ import common.world.State;
import common.world.World; import common.world.World;
import common.world.AWorldServer; import common.world.AWorldServer;
public class BlockFlowerPot extends Block public class BlockFlowerPot extends Block // Container
{ {
private static final Model flower_pot_cactus = ModelProvider.getModelProvider().getModel("flower_pot") private static final Model flower_pot_cactus = ModelProvider.getModelProvider().getModel("flower_pot")
.add(5, 0, 5, 6, 6, 11) .add(5, 0, 5, 6, 6, 11)
@ -101,18 +99,23 @@ public class BlockFlowerPot extends Block
.u("dirt").uv(6, 6, 10, 10).noCull() .u("dirt").uv(6, 6, 10, 10).noCull()
; ;
public static final List<BlockFlowerPot> POTS = Lists.newArrayList(); public static final PropertyInteger CONTENTS = PropertyInteger.create("contents", 0, 1 + BlockFlower.EnumFlowerType.values().length);
private final Block content;
public BlockFlowerPot(Block content) public BlockFlowerPot()
{ {
super(Material.SMALL); super(Material.SMALL);
this.content = content; this.setDefaultState(this.getBaseState().withProperty(CONTENTS, 0)); // .withProperty(LEGACY_DATA, Integer.valueOf(0)));
this.setBlockBoundsForItemRender(); 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 * Sets the block's bounds for rendering it as an item
*/ */
@ -131,18 +134,43 @@ public class BlockFlowerPot extends Block
return false; 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() public boolean isFullCube()
{ {
return false; 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) public boolean onBlockActivated(World worldIn, BlockPos pos, State state, EntityNPC playerIn, Facing side, float hitX, float hitY, float hitZ)
{ {
ItemStack itemstack = playerIn.inventory.getCurrentItem(); ItemStack itemstack = playerIn.inventory.getCurrentItem();
if (itemstack != null && itemstack.getItem() instanceof ItemBlock) if (itemstack != null && itemstack.getItem() instanceof ItemBlock)
{ {
if (this.content != null) if (state.getValue(CONTENTS) > 0)
{ {
return false; return false;
} }
@ -150,13 +178,14 @@ public class BlockFlowerPot extends Block
{ {
Block block = itemstack.getItem().getBlock(); Block block = itemstack.getItem().getBlock();
if (!(block instanceof BlockFlower) && block != Blocks.cactus) if (block != Blocks.flower && block != Blocks.cactus)
{ {
return false; return false;
} }
else else
{ {
worldIn.setState(pos, BlockRegistry.getRegisteredBlock("flowerpot_" + BlockRegistry.getNameFromBlock(this.content)).getState(), 2); worldIn.setState(pos, state.withProperty(CONTENTS, block == Blocks.cactus ? 1 : (2 + (itemstack.getMetadata() >=
BlockFlower.EnumFlowerType.values().length ? 0 : itemstack.getMetadata()))), 2);
// tileentityflowerpot.setFlowerPotData(itemstack.getItem(), itemstack.getMetadata()); // tileentityflowerpot.setFlowerPotData(itemstack.getItem(), itemstack.getMetadata());
// tileentityflowerpot.markDirty(); // tileentityflowerpot.markDirty();
// worldIn.markBlockForUpdate(pos); // worldIn.markBlockForUpdate(pos);
@ -179,7 +208,18 @@ public class BlockFlowerPot extends Block
public Item getItem(World worldIn, BlockPos pos) public Item getItem(World worldIn, BlockPos pos)
{ {
return worldIn.getState(pos).getBlock() == this && this.content != null ? ItemRegistry.getItemFromBlock(this.content) : Items.flowerpot; 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;
} }
public boolean isPickStrict() public boolean isPickStrict()
@ -206,31 +246,117 @@ public class BlockFlowerPot extends Block
public void onBlockRemoved(AWorldServer worldIn, BlockPos pos, State state) public void onBlockRemoved(AWorldServer worldIn, BlockPos pos, State state)
{ {
if(this.content != null) int type = state.getValue(CONTENTS);
spawnAsEntity(worldIn, pos, new ItemStack(this.content)); if(type > 0)
spawnAsEntity(worldIn, pos, new ItemStack(type == 1 ? Blocks.cactus : Blocks.flower, 1, type == 1 ? 0 : (type - 2)));
super.onBlockRemoved(worldIn, pos, state); 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. * Get the Item that this Block should drop when harvested.
*/ */
public Item getItemDropped(State state, Random rand, int fortune) public Item getItemDropped(State state, Random rand, int fortune)
{ {
return Items.flowerpot; return Items.flower_pot;
} }
/**
* Convert the given metadata into a BlockState for this Block
*/
public State getStateFromMeta(int meta)
{
return this.getState().withProperty(CONTENTS, Math.min(meta, BlockFlower.EnumFlowerType.values().length + 1));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
return state.getValue(CONTENTS);
}
// private TileEntityFlowerPot getTileEntity(World worldIn, BlockPos pos)
// {
// TileEntity tileentity = worldIn.getTileEntity(pos);
// return tileentity instanceof TileEntityFlowerPot ? (TileEntityFlowerPot)tileentity : null;
// }
//
// /**
// * Returns a new instance of a block's tile entity class. Called on placing the block.
// */
// public TileEntity createNewTileEntity(World worldIn, int meta)
// {
// return new TileEntityFlowerPot(null, 0);
// }
protected IProperty[] getProperties()
{
return new IProperty[] {CONTENTS};
}
// /**
// * Get the actual Block state of this Block at the given position. This applies properties not visible in the
// * metadata, such as fence connections.
// */
// public IBlockState getActualState(IBlockState state, IWorldAccess worldIn, BlockPos pos)
// {
// int type = 0;
// TileEntity tileentity = worldIn.getTileEntity(pos);
//
// if (tileentity instanceof TileEntityFlowerPot)
// {
// TileEntityFlowerPot tileentityflowerpot = (TileEntityFlowerPot)tileentity;
// Item item = tileentityflowerpot.getFlowerPotItem();
//
// if (item instanceof ItemBlock)
// {
// int i = tileentityflowerpot.getFlowerPotData();
// Block block = BlockRegistry.getBlockFromItem(item);
// if (block == Blocks.flower)
// {
//
// }
// else if (block == Blocks.cactus)
// {
// type = 1;
// }
// }
// }
//
// return state.withProperty(CONTENTS, type);
// }
public BlockLayer getBlockLayer() public BlockLayer getBlockLayer()
{ {
return BlockLayer.CUTOUT; return BlockLayer.CUTOUT;
} }
public Model getModel(ModelProvider provider, String name, State state) { public Model getModel(ModelProvider provider, String name, State state) {
if(this.content == null) switch(state.getValue(CONTENTS)) {
case 0:
return flower_pot; return flower_pot;
else if(this.content == Blocks.cactus) case 1:
return flower_pot_cactus; return flower_pot_cactus;
else { // case FERN:
String plant = BlockRegistry.getNameFromBlock(this.content); // return flower_pot_fern;
default:
String plant = BlockFlower.EnumFlowerType.getType(BlockFlower.EnumFlowerColor.BASE, state.getValue(CONTENTS) - 2).getName().toLowerCase();
return provider.getModel("flower_pot") return provider.getModel("flower_pot")
.add(5, 0, 5, 6, 6, 11) .add(5, 0, 5, 6, 6, 11)
.d().uv(5, 5, 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.init.ItemRegistry;
import common.item.CheatTab; import common.item.CheatTab;
import common.item.ItemStack; import common.item.ItemStack;
import common.properties.Property; import common.properties.IProperty;
import common.util.BlockPos; import common.util.BlockPos;
import common.util.Facing; import common.util.Facing;
import common.world.State; import common.world.State;
@ -61,14 +61,14 @@ public class BlockHay extends BlockRotatedPillar
return i; return i;
} }
protected Property[] getProperties() protected IProperty[] getProperties()
{ {
return new Property[] {AXIS}; return new IProperty[] {AXIS};
} }
public ItemStack createStackedBlock(State state) public ItemStack createStackedBlock(State state)
{ {
return new ItemStack(ItemRegistry.getItemFromBlock(this)); return new ItemStack(ItemRegistry.getItemFromBlock(this), 1, 0);
} }
/** /**

View file

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

View file

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

View file

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

View file

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

View file

@ -1,36 +1,195 @@
package common.block.artificial; package common.block.artificial;
import java.util.List;
import common.block.Block; import common.block.Block;
import common.block.Material; import common.block.Material;
import common.entity.types.EntityLiving;
import common.init.ItemRegistry;
import common.item.CheatTab; import common.item.CheatTab;
import common.item.Item;
import common.item.ItemStack;
import common.model.Model; import common.model.Model;
import common.model.ModelProvider; 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.State;
import common.world.World;
public class BlockQuartz extends Block { public class BlockQuartz extends Block
private final boolean dark; {
private final boolean ornaments; public static final PropertyEnum<BlockQuartz.EnumType> VARIANT = PropertyEnum.<BlockQuartz.EnumType>create("variant", BlockQuartz.EnumType.class);
public BlockQuartz(boolean dark, boolean ornaments) { private final String prefix;
super(Material.SOLID);
this.dark = dark; public BlockQuartz(String prefix)
this.ornaments = ornaments; {
this.setTab(CheatTab.BLOCKS); super(Material.SOLID);
} this.setDefaultState(this.getBaseState().withProperty(VARIANT, BlockQuartz.EnumType.DEFAULT));
this.setTab(CheatTab.BLOCKS);
this.prefix = prefix;
}
public boolean isDark() { /**
return this.dark; * 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 hasOrnaments() { case X:
return this.ornaments; return this.getState().withProperty(VARIANT, BlockQuartz.EnumType.LINES_X);
}
public Model getModel(ModelProvider provider, String name, State state) { case Y:
String prefix = this.dark ? "black_" : ""; default:
if(this.ornaments) return this.getState().withProperty(VARIANT, BlockQuartz.EnumType.LINES_Y);
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"); 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;
}
}
}
} }

View file

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

View file

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

View file

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

View file

@ -1,50 +1,103 @@
package common.block.artificial; package common.block.artificial;
import java.util.List;
import common.block.Material; import common.block.Material;
import common.color.DyeColor; import common.color.DyeColor;
import common.item.CheatTab; import common.item.CheatTab;
import common.item.Item;
import common.item.ItemStack;
import common.model.BlockLayer; import common.model.BlockLayer;
import common.properties.Property; import common.properties.IProperty;
import common.properties.PropertyEnum;
import common.world.State; import common.world.State;
public class BlockStainedGlassPane extends BlockPane public class BlockStainedGlassPane extends BlockPane
{ {
public static final BlockStainedGlassPane[] PANES = new BlockStainedGlassPane[DyeColor.values().length]; public static final PropertyEnum<DyeColor> COLOR = PropertyEnum.<DyeColor>create("color", DyeColor.class);
private final DyeColor color;
public static BlockStainedGlassPane getByColor(DyeColor color) {
return PANES[color.getMetadata()];
}
public BlockStainedGlassPane(DyeColor color) public BlockStainedGlassPane()
{ {
super(Material.TRANSLUCENT, false); super(Material.TRANSLUCENT, false);
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)).withProperty(COLOR, DyeColor.WHITE));
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); this.setTab(CheatTab.BLOCKS);
PANES[color.ordinal()] = this;
} }
public DyeColor getColor() { /**
return this.color; * 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 < 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() public BlockLayer getBlockLayer()
{ {
return BlockLayer.TRANSLUCENT; return BlockLayer.TRANSLUCENT;
} }
protected Property[] getProperties() /**
* Convert the given metadata into a BlockState for this Block
*/
public State getStateFromMeta(int meta)
{ {
return new Property[] {NORTH, EAST, WEST, SOUTH}; return this.getState().withProperty(COLOR, DyeColor.byMetadata(meta));
} }
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(State state)
{
return ((DyeColor)state.getValue(COLOR)).getMetadata();
}
protected IProperty[] getProperties()
{
return new IProperty[] {NORTH, EAST, WEST, SOUTH, COLOR};
}
// 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) { protected String getPaneBase(State state) {
return this.color.getName() + "_glass"; return state.getValue(COLOR).getName() + "_glass";
} }
protected String getPaneEdge(State state) { protected String getPaneEdge(State state) {
return this.color.getName() + "_glass_pane"; return state.getValue(COLOR).getName() + "_glass_pane";
} }
} }

View file

@ -4,7 +4,6 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import common.block.Block; import common.block.Block;
import common.block.Rotatable;
import common.block.Material; import common.block.Material;
import common.entity.Entity; import common.entity.Entity;
import common.entity.npc.EntityNPC; import common.entity.npc.EntityNPC;
@ -16,7 +15,8 @@ import common.model.BlockLayer;
import common.model.Model; import common.model.Model;
import common.model.ModelProvider; import common.model.ModelProvider;
import common.model.Transforms; import common.model.Transforms;
import common.properties.Property; import common.properties.IProperty;
import common.properties.PropertyDirection;
import common.properties.PropertyEnum; import common.properties.PropertyEnum;
import common.rng.Random; import common.rng.Random;
import common.util.BlockPos; import common.util.BlockPos;
@ -33,8 +33,9 @@ import common.world.State;
import common.world.World; import common.world.World;
import common.world.AWorldServer; import common.world.AWorldServer;
public class BlockStairs extends Block implements Rotatable public class BlockStairs extends Block
{ {
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.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); 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}}; 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}};
@ -804,9 +805,9 @@ public class BlockStairs extends Block implements Rotatable
return state; return state;
} }
protected Property[] getProperties() protected IProperty[] getProperties()
{ {
return new Property[] {FACING, HALF, SHAPE}; return new IProperty[] {FACING, HALF, SHAPE};
} }
public Transforms getTransform() { public Transforms getTransform() {

View file

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

View file

@ -4,17 +4,20 @@ import java.util.List;
import common.block.Block; import common.block.Block;
import common.block.Material; import common.block.Material;
import common.collect.Lists;
import common.init.Blocks; import common.init.Blocks;
import common.item.CheatTab; import common.item.CheatTab;
import common.item.Item;
import common.item.ItemStack;
import common.model.Model; import common.model.Model;
import common.model.ModelProvider; import common.model.ModelProvider;
import common.model.ModelRotation; import common.model.ModelRotation;
import common.properties.Property; import common.properties.IProperty;
import common.properties.PropertyBool; import common.properties.PropertyBool;
import common.properties.PropertyEnum;
import common.util.BlockPos; import common.util.BlockPos;
import common.util.BoundingBox; import common.util.BoundingBox;
import common.util.Facing; import common.util.Facing;
import common.util.Identifyable;
import common.world.IBlockAccess; import common.world.IBlockAccess;
import common.world.IWorldAccess; import common.world.IWorldAccess;
import common.world.State; import common.world.State;
@ -27,26 +30,26 @@ public class BlockWall extends Block
public static final PropertyBool EAST = PropertyBool.create("east"); public static final PropertyBool EAST = PropertyBool.create("east");
public static final PropertyBool SOUTH = PropertyBool.create("south"); public static final PropertyBool SOUTH = PropertyBool.create("south");
public static final PropertyBool WEST = PropertyBool.create("west"); public static final PropertyBool WEST = PropertyBool.create("west");
public static final List<BlockWall> WALLS = Lists.newArrayList(); public static final PropertyEnum<BlockWall.EnumType> VARIANT = PropertyEnum.<BlockWall.EnumType>create("variant", BlockWall.EnumType.class);
private final String texture;
public BlockWall(Block modelBlock, String texture) public BlockWall(Block modelBlock)
{ {
super(modelBlock.getMaterial()); super(modelBlock.getMaterial());
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)).withProperty(VARIANT, BlockWall.EnumType.NORMAL));
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.setHardness(modelBlock.getRawHardness());
this.setResistance(modelBlock.getRawResistance() / 3.0F); this.setResistance(modelBlock.getRawResistance() / 3.0F);
this.setStepSound(modelBlock.sound); this.setStepSound(modelBlock.sound);
this.setTab(CheatTab.BLOCKS); 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() public boolean isFullCube()
{ {
return false; return false;
@ -126,11 +129,47 @@ public class BlockWall extends Block
return (block != this && !(block instanceof BlockFenceGate) ? (block.getMaterial().isOpaque() && block.isFullCube() ? block.getMaterial() != Material.SOFT : false) : true); 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) public boolean shouldSideBeRendered(IWorldAccess worldIn, BlockPos pos, Facing side)
{ {
return side == Facing.DOWN ? super.shouldSideBeRendered(worldIn, pos, side) : true; 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 * Get the actual Block state of this Block at the given position. This applies properties not visible in the
* metadata, such as fence connections. * metadata, such as fence connections.
@ -140,17 +179,13 @@ 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()))); 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())));
} }
public int getMetaFromState(State state) { protected IProperty[] getProperties()
return 0;
}
protected Property[] getProperties()
{ {
return new Property[] {UP, NORTH, EAST, WEST, SOUTH}; return new IProperty[] {UP, NORTH, EAST, WEST, SOUTH, VARIANT};
} }
public Model getModel(ModelProvider provider, String name, State state) { public Model getModel(ModelProvider provider, String name, State state) {
String wall = this.texture; String wall = state.getValue(VARIANT).getName();
boolean n = state.getValue(NORTH); boolean n = state.getValue(NORTH);
boolean s = state.getValue(SOUTH); boolean s = state.getValue(SOUTH);
boolean w = state.getValue(WEST); boolean w = state.getValue(WEST);
@ -293,4 +328,59 @@ public class BlockWall extends Block
.e().uv(5, 3, 11, 16) .e().uv(5, 3, 11, 16)
.rotate(!w ? ModelRotation.X0_Y0 : (!e ? ModelRotation.X0_Y180 : (!s ? ModelRotation.X0_Y270 : ModelRotation.X0_Y90))); .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

@ -1,34 +0,0 @@
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

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

View file

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

View file

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

View file

@ -3,10 +3,9 @@ package common.block.foliage;
import java.util.List; import java.util.List;
import common.block.Block; import common.block.Block;
import common.block.Rotatable; import common.block.BlockDirectional;
import common.block.Material; import common.block.Material;
import common.block.SoundType; import common.block.SoundType;
import common.collect.Lists;
import common.color.Colorizer; import common.color.Colorizer;
import common.entity.npc.EntityNPC; import common.entity.npc.EntityNPC;
import common.entity.types.EntityLiving; import common.entity.types.EntityLiving;
@ -19,7 +18,7 @@ import common.item.ItemShears;
import common.item.ItemStack; import common.item.ItemStack;
import common.model.Model; import common.model.Model;
import common.model.ModelProvider; import common.model.ModelProvider;
import common.properties.Property; import common.properties.IProperty;
import common.properties.PropertyEnum; import common.properties.PropertyEnum;
import common.rng.Random; import common.rng.Random;
import common.tileentity.TileEntity; import common.tileentity.TileEntity;
@ -33,29 +32,20 @@ import common.world.State;
import common.world.World; import common.world.World;
import common.world.AWorldServer; import common.world.AWorldServer;
public class BlockDoublePlant extends BlockBush implements Rotatable, IGrowable public class BlockDoublePlant extends BlockBush implements IGrowable
{ {
public static final PropertyEnum<BlockDoublePlant.EnumPlantType> VARIANT = PropertyEnum.<BlockDoublePlant.EnumPlantType>create("variant", BlockDoublePlant.EnumPlantType.class);
public static final PropertyEnum<BlockDoublePlant.EnumBlockHalf> HALF = PropertyEnum.<BlockDoublePlant.EnumBlockHalf>create("half", BlockDoublePlant.EnumBlockHalf.class); public static final PropertyEnum<BlockDoublePlant.EnumBlockHalf> HALF = PropertyEnum.<BlockDoublePlant.EnumBlockHalf>create("half", BlockDoublePlant.EnumBlockHalf.class);
public static final BlockDoublePlant[] PLANTS = new BlockDoublePlant[EnumPlantType.values().length]; public static final PropertyEnum<Facing> FACING = BlockDirectional.FACING;
private final EnumPlantType type; public BlockDoublePlant()
public static BlockDoublePlant getByType(EnumPlantType type) {
return PLANTS[type.ordinal()];
}
public BlockDoublePlant(EnumPlantType type)
{ {
super(Material.BUSH); super(Material.BUSH);
this.type = type; this.setDefaultState(this.getBaseState().withProperty(VARIANT, BlockDoublePlant.EnumPlantType.SUNFLOWER).withProperty(HALF, BlockDoublePlant.EnumBlockHalf.LOWER).withProperty(FACING, Facing.NORTH));
this.setDefaultState(this.getBaseState().withProperty(HALF, BlockDoublePlant.EnumBlockHalf.LOWER).withProperty(FACING, Facing.NORTH));
this.setHardness(0.0F); this.setHardness(0.0F);
this.setStepSound(SoundType.GRASS); this.setStepSound(SoundType.GRASS);
PLANTS[type.ordinal()] = this; // this.setDisplay("doublePlant");
} // this.setTickRandomly();
public EnumPlantType getType() {
return this.type;
} }
public void updateTick(AWorldServer worldIn, BlockPos pos, State state, Random rand) public void updateTick(AWorldServer worldIn, BlockPos pos, State state, Random rand)
@ -69,8 +59,8 @@ public class BlockDoublePlant extends BlockBush implements Rotatable, IGrowable
worldIn.setState(pos, Blocks.air.getState()); worldIn.setState(pos, Blocks.air.getState());
pos = pos.down(); pos = pos.down();
if(!upper || worldIn.getState(pos).getBlock() == this) if(!upper || worldIn.getState(pos).getBlock() == this)
worldIn.setState(pos, this.type == EnumPlantType.GRASS || worldIn.rand.chance(20) ? Blocks.air.getState() : worldIn.setState(pos, state.getValue(VARIANT) == EnumPlantType.GRASS || worldIn.rand.chance(20) ? Blocks.air.getState() :
Blocks.dead_bush.getState()); Blocks.tallgrass.getState().withProperty(BlockTallGrass.TYPE, BlockTallGrass.EnumType.DEAD_BUSH));
return; return;
} }
super.updateTick(worldIn, pos, state, rand); super.updateTick(worldIn, pos, state, rand);
@ -81,6 +71,21 @@ public class BlockDoublePlant extends BlockBush implements Rotatable, IGrowable
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); 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) public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
{ {
return super.canPlaceBlockAt(worldIn, pos) && worldIn.isAirBlock(pos.up()); return super.canPlaceBlockAt(worldIn, pos) && worldIn.isAirBlock(pos.up());
@ -99,7 +104,8 @@ public class BlockDoublePlant extends BlockBush implements Rotatable, IGrowable
} }
else else
{ {
return this.type == BlockDoublePlant.EnumPlantType.FERN || this.type == BlockDoublePlant.EnumPlantType.GRASS; BlockDoublePlant.EnumPlantType blockdoubleplant$enumplanttype = (BlockDoublePlant.EnumPlantType)this.getActualState(iblockstate, worldIn, pos).getValue(VARIANT);
return blockdoubleplant$enumplanttype == BlockDoublePlant.EnumPlantType.FERN || blockdoubleplant$enumplanttype == BlockDoublePlant.EnumPlantType.GRASS;
} }
} }
@ -154,18 +160,29 @@ public class BlockDoublePlant extends BlockBush implements Rotatable, IGrowable
} }
else else
{ {
return this.type == BlockDoublePlant.EnumPlantType.FERN ? null : (this.type == BlockDoublePlant.EnumPlantType.GRASS ? (rand.chance(8) ? Items.wheat : null) : ItemRegistry.getItemFromBlock(this)); 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));
} }
} }
/**
* 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) public int colorMultiplier(IWorldAccess worldIn, BlockPos pos, int renderPass)
{ {
return this.type != BlockDoublePlant.EnumPlantType.GRASS && this.type != BlockDoublePlant.EnumPlantType.FERN ? 16777215 : Colorizer.getGrassColor(worldIn, pos); BlockDoublePlant.EnumPlantType blockdoubleplant$enumplanttype = this.getVariant(worldIn, pos);
return blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.GRASS && blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.FERN ? 16777215 : Colorizer.getGrassColor(worldIn, pos);
} }
public void placeAt(World worldIn, BlockPos lowerPos, int flags) public void placeAt(World worldIn, BlockPos lowerPos, BlockDoublePlant.EnumPlantType variant, int flags)
{ {
worldIn.setState(lowerPos, this.getState().withProperty(HALF, BlockDoublePlant.EnumBlockHalf.LOWER), flags); worldIn.setState(lowerPos, this.getState().withProperty(HALF, BlockDoublePlant.EnumBlockHalf.LOWER).withProperty(VARIANT, variant), flags);
worldIn.setState(lowerPos.up(), this.getState().withProperty(HALF, BlockDoublePlant.EnumBlockHalf.UPPER), flags); worldIn.setState(lowerPos.up(), this.getState().withProperty(HALF, BlockDoublePlant.EnumBlockHalf.UPPER), flags);
} }
@ -194,8 +211,9 @@ public class BlockDoublePlant extends BlockBush implements Rotatable, IGrowable
// if (!player.creative) // if (!player.creative)
// { // {
State iblockstate = worldIn.getState(pos.down()); State iblockstate = worldIn.getState(pos.down());
BlockDoublePlant.EnumPlantType blockdoubleplant$enumplanttype = (BlockDoublePlant.EnumPlantType)iblockstate.getValue(VARIANT);
if (this.type != BlockDoublePlant.EnumPlantType.FERN && this.type != BlockDoublePlant.EnumPlantType.GRASS) if (blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.FERN && blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.GRASS)
{ {
worldIn.destroyBlock(pos.down(), true); worldIn.destroyBlock(pos.down(), true);
} }
@ -232,23 +250,47 @@ public class BlockDoublePlant extends BlockBush implements Rotatable, IGrowable
private boolean onHarvest(World worldIn, BlockPos pos, State state, EntityNPC player) private boolean onHarvest(World worldIn, BlockPos pos, State state, EntityNPC player)
{ {
if (this.type != BlockDoublePlant.EnumPlantType.FERN && this.type != BlockDoublePlant.EnumPlantType.GRASS) BlockDoublePlant.EnumPlantType blockdoubleplant$enumplanttype = (BlockDoublePlant.EnumPlantType)state.getValue(VARIANT);
if (blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.FERN && blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.GRASS)
{ {
return false; return false;
} }
else else
{ {
spawnAsEntity(worldIn, pos, new ItemStack(this.type == BlockDoublePlant.EnumPlantType.GRASS ? Blocks.tallgrass : Blocks.fern, 2)); // 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));
return true; 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 * Whether this IGrowable can grow
*/ */
public boolean canGrow(World worldIn, BlockPos pos, State state, boolean isClient) public boolean canGrow(World worldIn, BlockPos pos, State state, boolean isClient)
{ {
return this.type != BlockDoublePlant.EnumPlantType.GRASS && this.type != BlockDoublePlant.EnumPlantType.FERN; BlockDoublePlant.EnumPlantType blockdoubleplant$enumplanttype = this.getVariant(worldIn, pos);
return blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.GRASS && blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.FERN;
} }
public boolean canUseBonemeal(World worldIn, Random rand, BlockPos pos, State state) public boolean canUseBonemeal(World worldIn, Random rand, BlockPos pos, State state)
@ -258,7 +300,7 @@ public class BlockDoublePlant extends BlockBush implements Rotatable, IGrowable
public void grow(AWorldServer worldIn, Random rand, BlockPos pos, State state) public void grow(AWorldServer worldIn, Random rand, BlockPos pos, State state)
{ {
spawnAsEntity(worldIn, pos, new ItemStack(this)); spawnAsEntity(worldIn, pos, new ItemStack(this, 1, this.getVariant(worldIn, pos).getMeta()));
} }
/** /**
@ -266,7 +308,26 @@ public class BlockDoublePlant extends BlockBush implements Rotatable, IGrowable
*/ */
public State getStateFromMeta(int meta) public State getStateFromMeta(int meta)
{ {
return (meta & 8) > 0 ? this.getState().withProperty(HALF, BlockDoublePlant.EnumBlockHalf.UPPER) : this.getState().withProperty(HALF, BlockDoublePlant.EnumBlockHalf.LOWER); 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;
} }
/** /**
@ -274,16 +335,21 @@ public class BlockDoublePlant extends BlockBush implements Rotatable, IGrowable
*/ */
public int getMetaFromState(State state) public int getMetaFromState(State state)
{ {
return state.getValue(HALF) == BlockDoublePlant.EnumBlockHalf.UPPER ? 8 | ((Facing)state.getValue(FACING)).getHorizontalIndex() : 0; return state.getValue(HALF) == BlockDoublePlant.EnumBlockHalf.UPPER ? 8 | ((Facing)state.getValue(FACING)).getHorizontalIndex() : ((BlockDoublePlant.EnumPlantType)state.getValue(VARIANT)).getMeta();
} }
protected Property[] getProperties() protected IProperty[] getProperties()
{ {
return new Property[] {HALF, FACING}; return new IProperty[] {HALF, VARIANT, FACING};
} }
// public EnumOffsetType getOffsetType()
// {
// return EnumOffsetType.XZ;
// }
public Model getModel(ModelProvider provider, String name, State state) { public Model getModel(ModelProvider provider, String name, State state) {
if(this.type == EnumPlantType.SUNFLOWER && state.getValue(HALF) == EnumBlockHalf.UPPER) if(state.getValue(VARIANT) == EnumPlantType.SUNFLOWER && state.getValue(HALF) == EnumBlockHalf.UPPER)
return provider.getModel("sunflower_front") 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") .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() .uv(0, 8, 16, 16).noCull()
@ -291,16 +357,16 @@ public class BlockDoublePlant extends BlockBush implements Rotatable, IGrowable
.uv(0, 8, 16, 16).noCull() .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") .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(); .uv(0, 0, 16, 16).noCull().e().uv(0, 0, 16, 16).noCull();
else if(this.type == EnumPlantType.FERN || this.type == EnumPlantType.GRASS) else if(state.getValue(VARIANT) == EnumPlantType.FERN || state.getValue(VARIANT) == EnumPlantType.GRASS)
return provider.getModel(this.type.getName() + "_" + (state.getValue(HALF) == EnumBlockHalf.UPPER return provider.getModel(state.getValue(VARIANT).getName() + "_" + (state.getValue(HALF) == EnumBlockHalf.UPPER
? "top" : "bottom")).crossTint(); ? "top" : "bottom")).crossTint();
else else
return provider.getModel(this.type.getName() + "_" + (state.getValue(HALF) == EnumBlockHalf.UPPER return provider.getModel(state.getValue(VARIANT).getName() + "_" + (state.getValue(HALF) == EnumBlockHalf.UPPER
? "top" : "bottom")).cross(); ? "top" : "bottom")).cross();
} }
public Property<?>[] getIgnoredProperties() { public IProperty<?>[] getIgnoredProperties() {
return new Property[] {FACING}; return new IProperty[] {FACING};
} }
public static enum EnumBlockHalf implements Identifyable public static enum EnumBlockHalf implements Identifyable
@ -323,9 +389,9 @@ public class BlockDoublePlant extends BlockBush implements Rotatable, IGrowable
{ {
SUNFLOWER(0, "sunflower", "Sonnenblume"), SUNFLOWER(0, "sunflower", "Sonnenblume"),
SYRINGA(1, "syringa", "Flieder"), SYRINGA(1, "syringa", "Flieder"),
GRASS(2, "large_tallgrass", "Hohes Gras"), GRASS(2, "double_grass", "Hohes Gras"),
FERN(3, "large_fern", "Großer Farn"), FERN(3, "double_fern", "Großer Farn"),
ROSE(4, "rose_bush", "Rosenstrauch"), ROSE(4, "double_rose", "Rosenstrauch"),
PAEONIA(5, "paeonia", "Pfingstrose"); PAEONIA(5, "paeonia", "Pfingstrose");
private static final BlockDoublePlant.EnumPlantType[] META_LOOKUP = new BlockDoublePlant.EnumPlantType[values().length]; 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.Block;
import common.block.Material; import common.block.Material;
import common.block.natural.BlockDirt;
import common.entity.Entity; import common.entity.Entity;
import common.entity.types.EntityLiving; import common.entity.types.EntityLiving;
import common.init.Blocks; import common.init.Blocks;
import common.init.ItemRegistry; import common.init.ItemRegistry;
import common.init.Items;
import common.item.Item; import common.item.Item;
import common.model.Model; import common.model.Model;
import common.model.ModelProvider; import common.model.ModelProvider;
import common.properties.Property; import common.properties.IProperty;
import common.properties.PropertyInteger; import common.properties.PropertyInteger;
import common.rng.Random; import common.rng.Random;
import common.util.BlockPos; import common.util.BlockPos;
@ -149,12 +149,12 @@ public class BlockFarmland extends Block
*/ */
public Item getItemDropped(State state, Random rand, int fortune) public Item getItemDropped(State state, Random rand, int fortune)
{ {
return Blocks.dirt.getItemDropped(Blocks.dirt.getState(), rand, fortune); return Blocks.dirt.getItemDropped(Blocks.dirt.getState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.DIRT), rand, fortune);
} }
public Item getItem(World worldIn, BlockPos pos) public Item getItem(World worldIn, BlockPos pos)
{ {
return Items.dirt; return ItemRegistry.getItemFromBlock(Blocks.dirt);
} }
/** /**
@ -173,9 +173,9 @@ public class BlockFarmland extends Block
return ((Integer)state.getValue(MOISTURE)).intValue(); return ((Integer)state.getValue(MOISTURE)).intValue();
} }
protected Property[] getProperties() protected IProperty[] getProperties()
{ {
return new Property[] {MOISTURE}; return new IProperty[] {MOISTURE};
} }
public Model getModel(ModelProvider provider, String name, State state) { 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.item.ItemStack;
import common.model.Model; import common.model.Model;
import common.model.ModelProvider; import common.model.ModelProvider;
import common.properties.Property; import common.properties.IProperty;
import common.properties.PropertyEnum; import common.properties.PropertyEnum;
import common.rng.Random; import common.rng.Random;
import common.util.BlockPos; import common.util.BlockPos;
@ -21,24 +21,14 @@ import common.vars.Vars;
import common.world.State; import common.world.State;
import common.world.AWorldServer; import common.world.AWorldServer;
public class BlockFlower extends BlockBush public abstract class BlockFlower extends BlockBush
{ {
public static final BlockFlower[] FLOWERS = new BlockFlower[EnumFlowerType.values().length]; protected PropertyEnum<BlockFlower.EnumFlowerType> type;
private final EnumFlowerType type;
public static BlockFlower getByType(EnumFlowerType type) {
return FLOWERS[type.ordinal()];
}
public BlockFlower(EnumFlowerType type) public BlockFlower()
{ {
this.type = type; this.setDefaultState(this.getBaseState().withProperty(this.getTypeProperty(), /* this.getBlockType() == BlockFlower.EnumFlowerColor.RED ? BlockFlower.EnumFlowerType.ROSE : */ BlockFlower.EnumFlowerType.DANDELION));
FLOWERS[type.ordinal()] = this; // this.setTickRandomly();
}
public EnumFlowerType getType() {
return this.type;
} }
public void updateTick(AWorldServer worldIn, BlockPos pos, State state, Random rand) public void updateTick(AWorldServer worldIn, BlockPos pos, State state, Random rand)
@ -46,40 +36,154 @@ public class BlockFlower extends BlockBush
if(Vars.flowerDry && worldIn.getTemperatureC(pos) >= 50.0f) if(Vars.flowerDry && worldIn.getTemperatureC(pos) >= 50.0f)
{ {
worldIn.setState(pos, worldIn.rand.chance(3) ? Blocks.air.getState() : worldIn.setState(pos, worldIn.rand.chance(3) ? Blocks.air.getState() :
Blocks.dead_bush.getState()); Blocks.tallgrass.getState().withProperty(BlockTallGrass.TYPE, BlockTallGrass.EnumType.DEAD_BUSH));
return; return;
} }
super.updateTick(worldIn, pos, state, rand); 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) { public Model getModel(ModelProvider provider, String name, State state) {
return provider.getModel(this.type.getName()).cross(); return provider.getModel(state.getValue(this.type).getName()).cross();
} }
public static enum EnumFlowerType implements Identifyable public static enum EnumFlowerType implements Identifyable
{ {
DANDELION("dandelion", "Löwenzahn"), DANDELION(BlockFlower.EnumFlowerColor.BASE, 0, "dandelion", "Löwenzahn"),
ROSE("rose", "Rose"), ROSE(BlockFlower.EnumFlowerColor.BASE, 1, "rose", "Rose"),
POPPY("poppy", "Mohn"), POPPY(BlockFlower.EnumFlowerColor.BASE, 2, "poppy", "Mohn"),
BLUE_ORCHID("blue_orchid", "Blaue Orchidee"), BLUE_ORCHID(BlockFlower.EnumFlowerColor.BASE, 3, "blue_orchid", "Blaue Orchidee"),
ALLIUM("allium", "Sternlauch"), ALLIUM(BlockFlower.EnumFlowerColor.BASE, 4, "allium", "Sternlauch"),
HOUSTONIA("houstonia", "Porzellansternchen"), HOUSTONIA(BlockFlower.EnumFlowerColor.BASE, 5, "houstonia", "Porzellansternchen"),
RED_TULIP("red_tulip", "Rote Tulpe"), RED_TULIP(BlockFlower.EnumFlowerColor.BASE, 6, "red_tulip", "Rote Tulpe"),
ORANGE_TULIP("orange_tulip", "Orange Tulpe"), ORANGE_TULIP(BlockFlower.EnumFlowerColor.BASE, 7, "orange_tulip", "Orange Tulpe"),
WHITE_TULIP("white_tulip", "Weiße Tulpe"), WHITE_TULIP(BlockFlower.EnumFlowerColor.BASE, 8, "white_tulip", "Weiße Tulpe"),
PINK_TULIP("pink_tulip", "Rosa Tulpe"), PINK_TULIP(BlockFlower.EnumFlowerColor.BASE, 9, "pink_tulip", "Rosa Tulpe"),
OXEYE_DAISY("daisy", "Margerite"), OXEYE_DAISY(BlockFlower.EnumFlowerColor.BASE, 10, "oxeye_daisy", "Margerite"),
BLACK_LOTUS("black_lotus", "Schwarzer Lotus"); BLACK_LOTUS(BlockFlower.EnumFlowerColor.BASE, 11, "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 name;
private final String display; private final String display;
private EnumFlowerType(String name, 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)
{ {
this.blockType = blockType;
this.meta = meta;
this.name = name; this.name = name;
this.display = display; 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() public String toString()
{ {
return this.name; return this.name;
@ -94,5 +198,19 @@ public class BlockFlower extends BlockBush
{ {
return this.display; 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,6 +3,7 @@ package common.block.foliage;
import common.biome.IBiome; import common.biome.IBiome;
import common.block.Block; import common.block.Block;
import common.block.Material; import common.block.Material;
import common.block.natural.BlockDirt;
import common.color.Colorizer; import common.color.Colorizer;
import common.init.Blocks; import common.init.Blocks;
import common.item.CheatTab; import common.item.CheatTab;
@ -10,7 +11,7 @@ import common.item.Item;
import common.model.BlockLayer; import common.model.BlockLayer;
import common.model.Model; import common.model.Model;
import common.model.ModelProvider; import common.model.ModelProvider;
import common.properties.Property; import common.properties.IProperty;
import common.properties.PropertyBool; import common.properties.PropertyBool;
import common.rng.Random; import common.rng.Random;
import common.util.BlockPos; import common.util.BlockPos;
@ -77,7 +78,7 @@ public class BlockGrass extends Block implements IGrowable
Block block = worldIn.getState(blockpos.up()).getBlock(); Block block = worldIn.getState(blockpos.up()).getBlock();
State iblockstate = worldIn.getState(blockpos); State iblockstate = worldIn.getState(blockpos);
if (iblockstate.getBlock() == Blocks.dirt && worldIn.getLightFromNeighbors(blockpos.up()) >= 4 && block.getLightOpacity() <= 2) if (iblockstate.getBlock() == Blocks.dirt && iblockstate.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.DIRT && worldIn.getLightFromNeighbors(blockpos.up()) >= 4 && block.getLightOpacity() <= 2)
{ {
worldIn.setState(blockpos, Blocks.grass.getState()); worldIn.setState(blockpos, Blocks.grass.getState());
} }
@ -86,7 +87,7 @@ public class BlockGrass extends Block implements IGrowable
} }
else { else {
if(Vars.grassDry) if(Vars.grassDry)
worldIn.setState(pos, worldIn.rand.chance(20) ? Blocks.coarse_dirt.getState() : worldIn.setState(pos, worldIn.rand.chance(20) ? Blocks.dirt.getState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.COARSE_DIRT) :
Blocks.dirt.getState()); Blocks.dirt.getState());
} }
// } // }
@ -97,7 +98,7 @@ public class BlockGrass extends Block implements IGrowable
*/ */
public Item getItemDropped(State state, Random rand, int fortune) public Item getItemDropped(State state, Random rand, int fortune)
{ {
return Blocks.dirt.getItemDropped(Blocks.dirt.getState(), rand, fortune); return Blocks.dirt.getItemDropped(Blocks.dirt.getState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.DIRT), rand, fortune);
} }
/** /**
@ -131,9 +132,9 @@ public class BlockGrass extends Block implements IGrowable
return 0; return 0;
} }
protected Property[] getProperties() protected IProperty[] getProperties()
{ {
return new Property[] {SNOWY}; return new IProperty[] {SNOWY};
} }
public Model getModel(ModelProvider provider, String name, State state) { 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.item.Item;
import common.model.Model; import common.model.Model;
import common.model.ModelProvider; import common.model.ModelProvider;
import common.properties.Property; import common.properties.IProperty;
import common.properties.PropertyEnum; import common.properties.PropertyEnum;
import common.rng.Random; import common.rng.Random;
import common.util.BlockPos; import common.util.BlockPos;
@ -19,7 +19,6 @@ import common.world.World;
public class BlockHugeMushroom extends Block public class BlockHugeMushroom extends Block
{ {
public static final PropertyEnum<BlockHugeMushroom.EnumType> VARIANT = PropertyEnum.<BlockHugeMushroom.EnumType>create("variant", BlockHugeMushroom.EnumType.class); public static final PropertyEnum<BlockHugeMushroom.EnumType> VARIANT = PropertyEnum.<BlockHugeMushroom.EnumType>create("variant", BlockHugeMushroom.EnumType.class);
private final Block smallBlock; private final Block smallBlock;
public BlockHugeMushroom(Material p_i46392_1_, Block p_i46392_3_) public BlockHugeMushroom(Material p_i46392_1_, Block p_i46392_3_)
@ -96,9 +95,9 @@ public class BlockHugeMushroom extends Block
return ((BlockHugeMushroom.EnumType)state.getValue(VARIANT)).getMetadata(); return ((BlockHugeMushroom.EnumType)state.getValue(VARIANT)).getMetadata();
} }
protected Property[] getProperties() protected IProperty[] getProperties()
{ {
return new Property[] {VARIANT}; return new IProperty[] {VARIANT};
} }
public Model getModel(ModelProvider provider, String name, State state) { public Model getModel(ModelProvider provider, String name, State state) {

View file

@ -8,7 +8,6 @@ import common.block.SoundType;
import common.collect.Lists; import common.collect.Lists;
import common.color.Colorizer; import common.color.Colorizer;
import common.entity.npc.EntityNPC; import common.entity.npc.EntityNPC;
import common.init.BlockRegistry;
import common.init.Blocks; import common.init.Blocks;
import common.init.ItemRegistry; import common.init.ItemRegistry;
import common.init.WoodType; import common.init.WoodType;
@ -19,8 +18,9 @@ import common.item.ItemStack;
import common.model.Model; import common.model.Model;
import common.model.ModelProvider; import common.model.ModelProvider;
import common.model.ParticleType; import common.model.ParticleType;
import common.properties.Property; import common.properties.IProperty;
import common.properties.PropertyBool; import common.properties.PropertyBool;
import common.properties.PropertyEnum;
import common.rng.Random; import common.rng.Random;
import common.tileentity.TileEntity; import common.tileentity.TileEntity;
import common.util.BlockPos; import common.util.BlockPos;
@ -33,37 +33,41 @@ import common.world.AWorldServer;
public class BlockLeaves extends BlockLeavesBase 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 PropertyBool DECAY = PropertyBool.create("decay");
public static final List<BlockLeaves> LEAVES = Lists.newArrayList(); 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 WoodType type;
private final LeavesType subType;
int[] surroundings; int[] surroundings;
public static BlockLeaves getLeavesBlock(WoodType type, LeavesType subType) {
return MAPPING[type.ordinal() * LeavesType.values().length + subType.ordinal()];
}
public BlockLeaves(WoodType type, LeavesType subType) public BlockLeaves(WoodType type)
{ {
super(Material.LEAVES); super(Material.LEAVES);
this.type = type; this.type = type;
this.subType = subType; this.setDefaultState(this.getBaseState().withProperty(TYPE, LeavesType.SPRING).withProperty(DECAY, Boolean.valueOf(true)));
this.setDefaultState(this.getBaseState().withProperty(DECAY, Boolean.valueOf(true)));
this.setTickRandomly(); this.setTickRandomly();
this.setTab(CheatTab.PLANTS); this.setTab(CheatTab.PLANTS);
this.setHardness(0.2F); this.setHardness(0.2F);
this.setLightOpacity(1); this.setLightOpacity(1);
this.setStepSound(SoundType.GRASS); this.setStepSound(SoundType.GRASS);
LEAVES.add(this); LEAVES.add(this);
MAPPING[type.ordinal() * LeavesType.values().length + subType.ordinal()] = this;
} }
public LeavesType getType() { // public int getBlockColor()
return this.subType; // {
} // 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 void onBlockRemoved(AWorldServer worldIn, BlockPos pos, State state) public void onBlockRemoved(AWorldServer worldIn, BlockPos pos, State state)
{ {
@ -96,8 +100,8 @@ public class BlockLeaves extends BlockLeavesBase
public void updateTick(AWorldServer worldIn, BlockPos pos, State state, Random rand) public void updateTick(AWorldServer worldIn, BlockPos pos, State state, Random rand)
{ {
if(Vars.seasonLeaves && this.subType != worldIn.getLeavesGen(pos)) { if(Vars.seasonLeaves && state.getValue(TYPE) != worldIn.getLeavesGen(pos)) {
worldIn.setState(pos, getLeavesBlock(this.type, worldIn.getLeavesGen(pos)).getState().withProperty(DECAY, state.getValue(DECAY)), 2); worldIn.setState(pos, state.withProperty(TYPE, worldIn.getLeavesGen(pos)), 2);
} }
if(Vars.leafDry && worldIn.getTemperatureC(pos) >= 50.0f) { if(Vars.leafDry && worldIn.getTemperatureC(pos) >= 50.0f) {
worldIn.setState(pos, worldIn.rand.chance(40) ? Blocks.air.getState() : Blocks.dry_leaves.getState()); worldIn.setState(pos, worldIn.rand.chance(40) ? Blocks.air.getState() : Blocks.dry_leaves.getState());
@ -266,7 +270,7 @@ public class BlockLeaves extends BlockLeavesBase
if (worldIn.rand.chance(i)) if (worldIn.rand.chance(i))
{ {
Item item = this.getItemDropped(state, worldIn.rand, fortune); Item item = this.getItemDropped(state, worldIn.rand, fortune);
spawnAsEntity(worldIn, pos, new ItemStack(item)); spawnAsEntity(worldIn, pos, new ItemStack(item, 1, this.damageDropped(state)));
} }
i = 200; i = 200;
@ -282,29 +286,40 @@ public class BlockLeaves extends BlockLeavesBase
} }
if(this.type.getItem() != null && worldIn.rand.chance(i)) // np if(this.type.getItem() != null && worldIn.rand.chance(i)) // np
spawnAsEntity(worldIn, pos, new ItemStack(ItemRegistry.getRegisteredItem(this.type.getItem()))); spawnAsEntity(worldIn, pos, new ItemStack(ItemRegistry.getRegisteredItem(this.type.getItem()), 1, 0));
} }
} }
public int getRenderColor(State state) public int getRenderColor(State state)
{ {
return state.getBlock() != this || !this.subType.isTinted() ? 16777215 : return state.getBlock() != this || !state.getValue(TYPE).isTinted() ? 16777215 :
((this.type.getTintType() == null ? Colorizer.BASIC : this.type.getTintType()).getColor()); ((this.type.getTintType() == null ? Colorizer.BASIC : this.type.getTintType()).getColor());
} }
public int colorMultiplier(IWorldAccess worldIn, BlockPos pos, int renderPass) public int colorMultiplier(IWorldAccess worldIn, BlockPos pos, int renderPass)
{ {
State state = worldIn.getState(pos); State state = worldIn.getState(pos);
return state.getBlock() != this || !this.subType.isTinted() ? 16777215 : (this.type.getTintType() return state.getBlock() != this || !state.getValue(TYPE).isTinted() ? 16777215 : (this.type.getTintType()
== null ? Colorizer.getFoliageColor(worldIn, pos) : this.type.getTintType().getColor()); == 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) { public State getStateFromMeta(int meta) {
return this.getState().withProperty(DECAY, Boolean.valueOf((meta & 8) == 0)); return this.getState().withProperty(TYPE, LeavesType.getById(meta & 7)).withProperty(DECAY, Boolean.valueOf((meta & 8) == 0));
} }
public int getMetaFromState(State state) { public int getMetaFromState(State state) {
int i = 0; int i = 0;
i = i | ((LeavesType)state.getValue(TYPE)).getIndex();
if(!((Boolean)state.getValue(DECAY)).booleanValue()) { if(!((Boolean)state.getValue(DECAY)).booleanValue()) {
i |= 8; i |= 8;
@ -313,13 +328,22 @@ public class BlockLeaves extends BlockLeavesBase
return i; return i;
} }
protected Property[] getProperties() { // public BlockPlanks.EnumType getWoodType() {
return new Property[] {DECAY}; // return this.type;
// }
protected IProperty[] getProperties() {
return new IProperty[] {TYPE, 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) { public void harvestBlock(World worldIn, EntityNPC player, BlockPos pos, State state, TileEntity te) {
if(!worldIn.client && player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemShears) { if(!worldIn.client && player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemShears) {
spawnAsEntity(worldIn, pos, new ItemStack(this)); // player.triggerAchievement(StatRegistry.mineBlockStatArray[BlockRegistry.getIdFromBlock(this)]);
spawnAsEntity(worldIn, pos, new ItemStack(ItemRegistry.getItemFromBlock(this), 1, ((LeavesType)state.getValue(TYPE)).getIndex()));
} }
else { else {
super.harvestBlock(worldIn, player, pos, state, te); super.harvestBlock(worldIn, player, pos, state, te);
@ -327,11 +351,16 @@ public class BlockLeaves extends BlockLeavesBase
} }
public Model getModel(ModelProvider provider, String name, State state) { public Model getModel(ModelProvider provider, String name, State state) {
return this.subType.isTinted() ? provider.getModel(name).add().all().tint() : return state.getValue(TYPE).isTinted() ? provider.getModel(name + "_" + state.getValue(TYPE).getName()).add().all().tint() :
provider.getModel(name).add().all(); provider.getModel(name + "_" + state.getValue(TYPE).getName()).add().all();
} }
public Property<?>[] getIgnoredProperties() { public IProperty<?>[] getIgnoredProperties() {
return new Property[] {DECAY}; 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);
} }
} }

View file

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

View file

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

View file

@ -2,6 +2,7 @@ package common.block.foliage;
import common.biome.IBiome; import common.biome.IBiome;
import common.block.Block; import common.block.Block;
import common.block.natural.BlockDirt;
import common.init.Blocks; import common.init.Blocks;
import common.model.Model; import common.model.Model;
import common.model.ModelProvider; import common.model.ModelProvider;
@ -78,7 +79,7 @@ public class BlockMushroom extends BlockBush implements IGrowable
if (pos.getY() >= -World.MAX_SIZE_Y && pos.getY() < World.MAX_SIZE_Y) if (pos.getY() >= -World.MAX_SIZE_Y && pos.getY() < World.MAX_SIZE_Y)
{ {
State iblockstate = worldIn.getState(pos.down()); State iblockstate = worldIn.getState(pos.down());
return iblockstate.getBlock() == Blocks.mycelium ? true : (iblockstate.getBlock() == Blocks.podzol ? true : worldIn.getLight(pos) < 13 && this.canPlaceBlockOn(iblockstate.getBlock())); 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()));
} }
else else
{ {

View file

@ -2,13 +2,14 @@ package common.block.foliage;
import common.block.Block; import common.block.Block;
import common.block.Material; import common.block.Material;
import common.block.natural.BlockDirt;
import common.init.Blocks; import common.init.Blocks;
import common.item.CheatTab; import common.item.CheatTab;
import common.item.Item; import common.item.Item;
import common.model.Model; import common.model.Model;
import common.model.ModelProvider; import common.model.ModelProvider;
import common.model.ParticleType; import common.model.ParticleType;
import common.properties.Property; import common.properties.IProperty;
import common.properties.PropertyBool; import common.properties.PropertyBool;
import common.rng.Random; import common.rng.Random;
import common.util.BlockPos; import common.util.BlockPos;
@ -47,7 +48,7 @@ public class BlockMycelium extends Block
if (worldIn.getLightFromNeighbors(pos.up()) < 4 && worldIn.getState(pos.up()).getBlock().getLightOpacity() > 2) if (worldIn.getLightFromNeighbors(pos.up()) < 4 && worldIn.getState(pos.up()).getBlock().getLightOpacity() > 2)
{ {
if(Vars.mycelDecay) if(Vars.mycelDecay)
worldIn.setState(pos, Blocks.dirt.getState()); worldIn.setState(pos, Blocks.dirt.getState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.DIRT));
} }
else if(Vars.mycelSpread) else if(Vars.mycelSpread)
{ {
@ -59,7 +60,7 @@ public class BlockMycelium extends Block
State iblockstate = worldIn.getState(blockpos); State iblockstate = worldIn.getState(blockpos);
Block block = worldIn.getState(blockpos.up()).getBlock(); Block block = worldIn.getState(blockpos.up()).getBlock();
if (iblockstate.getBlock() == Blocks.dirt && worldIn.getLightFromNeighbors(blockpos.up()) >= 4 && block.getLightOpacity() <= 2) if (iblockstate.getBlock() == Blocks.dirt && iblockstate.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.DIRT && worldIn.getLightFromNeighbors(blockpos.up()) >= 4 && block.getLightOpacity() <= 2)
{ {
worldIn.setState(blockpos, this.getState()); worldIn.setState(blockpos, this.getState());
} }
@ -84,7 +85,7 @@ public class BlockMycelium extends Block
*/ */
public Item getItemDropped(State state, Random rand, int fortune) public Item getItemDropped(State state, Random rand, int fortune)
{ {
return Blocks.dirt.getItemDropped(Blocks.dirt.getState(), rand, fortune); return Blocks.dirt.getItemDropped(Blocks.dirt.getState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.DIRT), rand, fortune);
} }
/** /**
@ -95,9 +96,9 @@ public class BlockMycelium extends Block
return 0; return 0;
} }
protected Property[] getProperties() protected IProperty[] getProperties()
{ {
return new Property[] {SNOWY}; return new IProperty[] {SNOWY};
} }
public Model getModel(ModelProvider provider, String name, State state) { public Model getModel(ModelProvider provider, String name, State state) {

View file

@ -1,20 +1,19 @@
package common.block.foliage; package common.block.foliage;
import common.block.Block; import common.block.BlockDirectional;
import common.block.Rotatable;
import common.block.Material; import common.block.Material;
import common.entity.types.EntityLiving; import common.entity.types.EntityLiving;
import common.item.CheatTab; import common.item.CheatTab;
import common.model.Model; import common.model.Model;
import common.model.ModelProvider; import common.model.ModelProvider;
import common.model.ModelRotation; import common.model.ModelRotation;
import common.properties.Property; import common.properties.IProperty;
import common.util.BlockPos; import common.util.BlockPos;
import common.util.Facing; import common.util.Facing;
import common.world.State; import common.world.State;
import common.world.World; import common.world.World;
public class BlockPumpkin extends Block implements Rotatable { public class BlockPumpkin extends BlockDirectional {
public BlockPumpkin() { public BlockPumpkin() {
super(Material.SOFT); super(Material.SOFT);
this.setDefaultState(this.getBaseState().withProperty(FACING, Facing.NORTH)); this.setDefaultState(this.getBaseState().withProperty(FACING, Facing.NORTH));
@ -37,8 +36,8 @@ public class BlockPumpkin extends Block implements Rotatable {
return state.getValue(FACING).getHorizontalIndex(); return state.getValue(FACING).getHorizontalIndex();
} }
protected Property[] getProperties() { protected IProperty[] getProperties() {
return new Property[] {FACING}; return new IProperty[] {FACING};
} }
public Model getModel(ModelProvider provider, String name, State state) { 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.BlockLayer;
import common.model.Model; import common.model.Model;
import common.model.ModelProvider; import common.model.ModelProvider;
import common.properties.Property; import common.properties.IProperty;
import common.properties.PropertyInteger; import common.properties.PropertyInteger;
import common.rng.Random; import common.rng.Random;
import common.util.BlockPos; import common.util.BlockPos;
@ -179,16 +179,16 @@ public class BlockReed extends Block
return ((Integer)state.getValue(AGE)).intValue(); return ((Integer)state.getValue(AGE)).intValue();
} }
protected Property[] getProperties() protected IProperty[] getProperties()
{ {
return new Property[] {AGE}; return new IProperty[] {AGE};
} }
public Model getModel(ModelProvider provider, String name, State state) { public Model getModel(ModelProvider provider, String name, State state) {
return provider.getModel("reeds").crossTint(); return provider.getModel("reeds").crossTint();
} }
public Property<?>[] getIgnoredProperties() { public IProperty<?>[] getIgnoredProperties() {
return new Property[] {AGE}; return new IProperty[] {AGE};
} }
} }

View file

@ -9,7 +9,7 @@ import common.init.WoodType;
import common.item.CheatTab; import common.item.CheatTab;
import common.model.Model; import common.model.Model;
import common.model.ModelProvider; import common.model.ModelProvider;
import common.properties.Property; import common.properties.IProperty;
import common.properties.PropertyInteger; import common.properties.PropertyInteger;
import common.rng.Random; import common.rng.Random;
import common.util.BlockPos; import common.util.BlockPos;
@ -49,7 +49,7 @@ public class BlockSapling extends BlockBush implements IGrowable
if(Vars.saplingDry && worldIn.getTemperatureC(pos) >= 50.0f) if(Vars.saplingDry && worldIn.getTemperatureC(pos) >= 50.0f)
{ {
worldIn.setState(pos, worldIn.rand.chance(25) ? Blocks.air.getState() : worldIn.setState(pos, worldIn.rand.chance(25) ? Blocks.air.getState() :
Blocks.dead_bush.getState()); Blocks.tallgrass.getState().withProperty(BlockTallGrass.TYPE, BlockTallGrass.EnumType.DEAD_BUSH));
return; return;
} }
// if (!worldIn.client) // if (!worldIn.client)
@ -132,9 +132,9 @@ public class BlockSapling extends BlockBush implements IGrowable
return state.getValue(STAGE); return state.getValue(STAGE);
} }
protected Property[] getProperties() protected IProperty[] getProperties()
{ {
return new Property[] {STAGE}; return new IProperty[] {STAGE};
} }
public Model getModel(ModelProvider provider, String name, State state) { public Model getModel(ModelProvider provider, String name, State state) {

View file

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