diff --git a/src/minecraft/biomesoplenty/blocks/BlockBOPPlant.java b/src/minecraft/biomesoplenty/blocks/BlockBOPPlant.java index 76d374194..d51d17a09 100644 --- a/src/minecraft/biomesoplenty/blocks/BlockBOPPlant.java +++ b/src/minecraft/biomesoplenty/blocks/BlockBOPPlant.java @@ -91,25 +91,74 @@ public class BlockBOPPlant extends BlockFlower implements IShearable list.add(new ItemStack(blockID, 1, i)); } - @Override - public boolean canPlaceBlockAt(World world, int x, int y, int z) - { - return super.canPlaceBlockAt(world, x, y, z) && this.canThisPlantGrowOnThisBlockID(world.getBlockId(x, y - 1, z), world.getBlockMetadata(x, y, z)); - } +// @Override +// public boolean canPlaceBlockAt(World world, int x, int y, int z) +// { +// return true;//super.canPlaceBlockAt(world, x, y, z) && this.canThisPlantGrowOnThisBlockID(world.getBlockId(x, y - 1, z), world.getBlockMetadata(x, y, z)); +// } protected boolean canThisPlantGrowOnThisBlockID(int id, int meta) { // TODO - if (meta == 0) - return id == Blocks.driedDirt.get().blockID || id == Block.sand.blockID; - else if (meta == 1) - return id == Blocks.redRock.get().blockID; - else if (meta == 2 || meta == 3) - return id == Block.sand.blockID; - else if (meta == 4) - return id == Blocks.holyGrass.get().blockID; + switch (meta) + { + case 0: // Dead Grass + return id == Blocks.driedDirt.get().blockID || id == Block.sand.blockID; + + case 1: // Desert Grass + return id == Blocks.redRock.get().blockID; + + case 2: // Desert Sprouts + case 3: // Dune Grass + return id == Block.sand.blockID; + + case 4: // Holy Tall Grass + return id == Blocks.holyGrass.get().blockID; + + case 5: + return true; + + case 7: + return id == Block.grass.blockID; + + default: + return id == Block.grass.blockID || id == Block.dirt.blockID || id == Block.tilledField.blockID; + } + } + + @Override + public boolean canPlaceBlockOnSide(World world, int x, int y, int z, int side, ItemStack itemStack) + { + int id = world.getBlockId(x, y - 1, z); + int meta = itemStack.getItemDamage(); + + if (itemStack.itemID == this.blockID) + switch (meta) + { + case 0: // Dead Grass + return id == Blocks.driedDirt.get().blockID || id == Block.sand.blockID; + + case 1: // Desert Grass + return id == Blocks.redRock.get().blockID; + + case 2: // Desert Sprouts + case 3: // Dune Grass + return id == Block.sand.blockID; + + case 4: // Holy Tall Grass + return id == Blocks.holyGrass.get().blockID; + + case 5: // Thorns + return true; + + case 7: // Cattail + return id != Block.grass.blockID ? false : (world.getBlockMaterial(x - 1, y - 1, z) == Material.water ? true : (world.getBlockMaterial(x + 1, y - 1, z) == Material.water ? true : (world.getBlockMaterial(x, y - 1, z - 1) == Material.water ? true : world.getBlockMaterial(x, y - 1, z + 1) == Material.water))); + + default: + return id == Block.grass.blockID || id == Block.dirt.blockID || id == Block.tilledField.blockID; + } else - return id == Block.grass.blockID || id == Block.dirt.blockID || id == Block.tilledField.blockID; + return this.canPlaceBlockOnSide(world, x, y, z, side); } @Override diff --git a/src/minecraft/biomesoplenty/items/ItemBOPFoliage.java b/src/minecraft/biomesoplenty/items/ItemBOPFoliage.java index 8a99f563a..05333c4c0 100644 --- a/src/minecraft/biomesoplenty/items/ItemBOPFoliage.java +++ b/src/minecraft/biomesoplenty/items/ItemBOPFoliage.java @@ -29,7 +29,7 @@ public class ItemBOPFoliage extends ItemBlock textures = new Icon[foliageTypes.length - 1]; for (int i = 0; i < foliageTypes.length - 1; ++i) - textures[i] = iconRegister.registerIcon("BiomesOPlenty:item" + foliageTypes[i]); + textures[i] = iconRegister.registerIcon("BiomesOPlenty:item_" + foliageTypes[i]); } @Override diff --git a/src/minecraft/biomesoplenty/items/ItemBOPPlant.java b/src/minecraft/biomesoplenty/items/ItemBOPPlant.java index 48a0c08b2..839b449ef 100644 --- a/src/minecraft/biomesoplenty/items/ItemBOPPlant.java +++ b/src/minecraft/biomesoplenty/items/ItemBOPPlant.java @@ -1,13 +1,21 @@ package biomesoplenty.items; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.util.Icon; +import net.minecraft.world.World; public class ItemBOPPlant extends ItemBlock { private static final String[] plants = new String[] {"deadgrass", "desertgrass", "desertsprouts", "dunegrass", "holytallgrass", "thorn", "barley", "cattail"}; + @SideOnly(Side.CLIENT) + private Icon[] textures; public ItemBOPPlant(int par1) { @@ -22,6 +30,15 @@ public class ItemBOPPlant extends ItemBlock return meta & 15; } + @SideOnly(Side.CLIENT) + public void registerIcons(IconRegister iconRegister) + { + textures = new Icon[2]; + + textures[0] = iconRegister.registerIcon("BiomesOPlenty:item_barley"); + textures[1] = iconRegister.registerIcon("BiomesOPlenty:item_cattail"); + } + @Override public String getUnlocalizedName(ItemStack itemStack) { @@ -31,6 +48,70 @@ public class ItemBOPPlant extends ItemBlock @Override public Icon getIconFromDamage(int meta) { - return Block.blocksList[this.itemID].getIcon(0, meta); + if (meta == 6) + return textures[0]; + else if (meta == 7) + return textures[1]; + else + return Block.blocksList[this.itemID].getIcon(0, meta); + } + + public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) + { + int id = world.getBlockId(x, y, z); + + if (id == Block.snow.blockID && (world.getBlockMetadata(x, y, z) & 7) < 1) + side = 1; + else if (!Block.blocksList[id].isBlockReplaceable(world, x, y, z)) + { + if (side == 0) + --y; + + if (side == 1) + ++y; + + if (side == 2) + --z; + + if (side == 3) + ++z; + + if (side == 4) + --x; + + if (side == 5) + ++x; + } + + if (!player.canPlayerEdit(x, y, z, side, itemStack)) + { + return false; + } + else if (itemStack.stackSize == 0) + { + return false; + } + else + { + if (world.canPlaceEntityOnSide(this.getBlockID(), x, y, z, false, side, (Entity)null, itemStack)) + { + Block block = Block.blocksList[this.getBlockID()]; + int j1 = block.onBlockPlaced(world, x, y, z, side, hitX, hitY, hitZ, 0); + + if (world.setBlock(x, y, z, this.getBlockID(), itemStack.getItemDamage(), 3)) + { + if (world.getBlockId(x, y, z) == this.getBlockID()) + { + Block.blocksList[this.getBlockID()].onBlockPlacedBy(world, x, y, z, player, itemStack); + Block.blocksList[this.getBlockID()].onPostBlockPlaced(world, x, y, z, j1); + } + + world.playSoundEffect((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), block.stepSound.getPlaceSound(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F); + --itemStack.stackSize; + } + } + + return true; + } } } diff --git a/src/minecraft/mods/BiomesOPlenty/textures/blocks/brownsappling.png b/src/minecraft/mods/BiomesOPlenty/textures/blocks/brownsappling.png deleted file mode 100644 index 4dfcba918..000000000 Binary files a/src/minecraft/mods/BiomesOPlenty/textures/blocks/brownsappling.png and /dev/null differ diff --git a/src/minecraft/mods/BiomesOPlenty/textures/blocks/darksappling.png b/src/minecraft/mods/BiomesOPlenty/textures/blocks/darksappling.png deleted file mode 100644 index 943985a1f..000000000 Binary files a/src/minecraft/mods/BiomesOPlenty/textures/blocks/darksappling.png and /dev/null differ diff --git a/src/minecraft/mods/BiomesOPlenty/textures/blocks/firsappling.png b/src/minecraft/mods/BiomesOPlenty/textures/blocks/firsappling.png deleted file mode 100644 index 3a900b161..000000000 Binary files a/src/minecraft/mods/BiomesOPlenty/textures/blocks/firsappling.png and /dev/null differ diff --git a/src/minecraft/mods/BiomesOPlenty/textures/blocks/holysappling.png b/src/minecraft/mods/BiomesOPlenty/textures/blocks/holysappling.png deleted file mode 100644 index 57918c583..000000000 Binary files a/src/minecraft/mods/BiomesOPlenty/textures/blocks/holysappling.png and /dev/null differ diff --git a/src/minecraft/mods/BiomesOPlenty/textures/blocks/itemalgae.png b/src/minecraft/mods/BiomesOPlenty/textures/blocks/item_algae.png similarity index 100% rename from src/minecraft/mods/BiomesOPlenty/textures/blocks/itemalgae.png rename to src/minecraft/mods/BiomesOPlenty/textures/blocks/item_algae.png diff --git a/src/minecraft/mods/BiomesOPlenty/textures/blocks/item_barley.png b/src/minecraft/mods/BiomesOPlenty/textures/blocks/item_barley.png new file mode 100644 index 000000000..66d2d8542 Binary files /dev/null and b/src/minecraft/mods/BiomesOPlenty/textures/blocks/item_barley.png differ diff --git a/src/minecraft/mods/BiomesOPlenty/textures/blocks/itembush.png b/src/minecraft/mods/BiomesOPlenty/textures/blocks/item_bush.png similarity index 100% rename from src/minecraft/mods/BiomesOPlenty/textures/blocks/itembush.png rename to src/minecraft/mods/BiomesOPlenty/textures/blocks/item_bush.png diff --git a/src/minecraft/mods/BiomesOPlenty/textures/blocks/item_cattail.png b/src/minecraft/mods/BiomesOPlenty/textures/blocks/item_cattail.png new file mode 100644 index 000000000..9969871e7 Binary files /dev/null and b/src/minecraft/mods/BiomesOPlenty/textures/blocks/item_cattail.png differ diff --git a/src/minecraft/mods/BiomesOPlenty/textures/blocks/itemhighgrass.png b/src/minecraft/mods/BiomesOPlenty/textures/blocks/item_highgrass.png similarity index 100% rename from src/minecraft/mods/BiomesOPlenty/textures/blocks/itemhighgrass.png rename to src/minecraft/mods/BiomesOPlenty/textures/blocks/item_highgrass.png diff --git a/src/minecraft/mods/BiomesOPlenty/textures/blocks/itemmediumgrass.png b/src/minecraft/mods/BiomesOPlenty/textures/blocks/item_mediumgrass.png similarity index 100% rename from src/minecraft/mods/BiomesOPlenty/textures/blocks/itemmediumgrass.png rename to src/minecraft/mods/BiomesOPlenty/textures/blocks/item_mediumgrass.png diff --git a/src/minecraft/mods/BiomesOPlenty/textures/blocks/itemshortgrass.png b/src/minecraft/mods/BiomesOPlenty/textures/blocks/item_shortgrass.png similarity index 100% rename from src/minecraft/mods/BiomesOPlenty/textures/blocks/itemshortgrass.png rename to src/minecraft/mods/BiomesOPlenty/textures/blocks/item_shortgrass.png diff --git a/src/minecraft/mods/BiomesOPlenty/textures/blocks/itemsprout.png b/src/minecraft/mods/BiomesOPlenty/textures/blocks/item_sprout.png similarity index 100% rename from src/minecraft/mods/BiomesOPlenty/textures/blocks/itemsprout.png rename to src/minecraft/mods/BiomesOPlenty/textures/blocks/item_sprout.png diff --git a/src/minecraft/mods/BiomesOPlenty/textures/blocks/magicsappling.png b/src/minecraft/mods/BiomesOPlenty/textures/blocks/magicsappling.png deleted file mode 100644 index 699e58c9b..000000000 Binary files a/src/minecraft/mods/BiomesOPlenty/textures/blocks/magicsappling.png and /dev/null differ diff --git a/src/minecraft/mods/BiomesOPlenty/textures/blocks/mangrovesappling.png b/src/minecraft/mods/BiomesOPlenty/textures/blocks/mangrovesappling.png deleted file mode 100644 index 52b89f735..000000000 Binary files a/src/minecraft/mods/BiomesOPlenty/textures/blocks/mangrovesappling.png and /dev/null differ diff --git a/src/minecraft/mods/BiomesOPlenty/textures/blocks/orangesappling.png b/src/minecraft/mods/BiomesOPlenty/textures/blocks/orangesappling.png deleted file mode 100644 index 97508348a..000000000 Binary files a/src/minecraft/mods/BiomesOPlenty/textures/blocks/orangesappling.png and /dev/null differ diff --git a/src/minecraft/mods/BiomesOPlenty/textures/blocks/originsappling.png b/src/minecraft/mods/BiomesOPlenty/textures/blocks/originsappling.png deleted file mode 100644 index 28df09475..000000000 Binary files a/src/minecraft/mods/BiomesOPlenty/textures/blocks/originsappling.png and /dev/null differ diff --git a/src/minecraft/mods/BiomesOPlenty/textures/blocks/palmsappling.png b/src/minecraft/mods/BiomesOPlenty/textures/blocks/palmsappling.png deleted file mode 100644 index a3727a41c..000000000 Binary files a/src/minecraft/mods/BiomesOPlenty/textures/blocks/palmsappling.png and /dev/null differ diff --git a/src/minecraft/mods/BiomesOPlenty/textures/blocks/pinksappling.png b/src/minecraft/mods/BiomesOPlenty/textures/blocks/pinksappling.png deleted file mode 100644 index 90b2d5d95..000000000 Binary files a/src/minecraft/mods/BiomesOPlenty/textures/blocks/pinksappling.png and /dev/null differ diff --git a/src/minecraft/mods/BiomesOPlenty/textures/blocks/redsappling.png b/src/minecraft/mods/BiomesOPlenty/textures/blocks/redsappling.png deleted file mode 100644 index b290027bf..000000000 Binary files a/src/minecraft/mods/BiomesOPlenty/textures/blocks/redsappling.png and /dev/null differ diff --git a/src/minecraft/mods/BiomesOPlenty/textures/blocks/redwoodsappling.png b/src/minecraft/mods/BiomesOPlenty/textures/blocks/redwoodsappling.png deleted file mode 100644 index 339774141..000000000 Binary files a/src/minecraft/mods/BiomesOPlenty/textures/blocks/redwoodsappling.png and /dev/null differ diff --git a/src/minecraft/mods/BiomesOPlenty/textures/blocks/whitesappling.png b/src/minecraft/mods/BiomesOPlenty/textures/blocks/whitesappling.png deleted file mode 100644 index 6b6a84546..000000000 Binary files a/src/minecraft/mods/BiomesOPlenty/textures/blocks/whitesappling.png and /dev/null differ diff --git a/src/minecraft/mods/BiomesOPlenty/textures/blocks/willowsappling.png b/src/minecraft/mods/BiomesOPlenty/textures/blocks/willowsappling.png deleted file mode 100644 index 8e5ffadf0..000000000 Binary files a/src/minecraft/mods/BiomesOPlenty/textures/blocks/willowsappling.png and /dev/null differ diff --git a/src/minecraft/mods/BiomesOPlenty/textures/blocks/yellowsappling.png b/src/minecraft/mods/BiomesOPlenty/textures/blocks/yellowsappling.png deleted file mode 100644 index c53598c48..000000000 Binary files a/src/minecraft/mods/BiomesOPlenty/textures/blocks/yellowsappling.png and /dev/null differ