Added IFlowerPlaceable for items that can be placed by the Rannuncarpus.

This commit is contained in:
Vasco Lavos committed 2015-11-17 20:14:44 +00:00
1 parent 709a8b4338
commit 411c14199e
2 files changed
+36 -2

No files matched your search

@@ -0,0 +1,27 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
* File Created @ [17/11/2015, 20:10:53 (GMT)]
*/
package vazkii.botania.api.item;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import vazkii.botania.api.subtile.SubTileEntity;
/**
* An Item that implements this can be placed by a Rannuncarpus.
*/
public interface IFlowerPlaceable {
/**
* Gets the block to be placed, return null to not place anything.
*/
public Block getBlockToPlaceByFlower(ItemStack stack, SubTileEntity flower, int x, int y, int z);
public void onBlockPlacedByFlower(ItemStack stack, SubTileEntity flower, int x, int y, int z);
}
@@ -32,6 +32,7 @@ import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
import vazkii.botania.api.item.IFlowerPlaceable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.subtile.ISubTileContainer;
import vazkii.botania.api.subtile.RadiusDescriptor;
@@ -83,7 +84,7 @@ public class SubTileRannuncarpus extends SubTileFunctional {
ItemStack stack = item.getEntityItem();
Item stackItem = stack.getItem();
if(stackItem instanceof ItemBlock || stackItem instanceof ItemReed || stackItem instanceof ItemRedstone) {
if(stackItem instanceof ItemBlock || stackItem instanceof ItemReed || stackItem instanceof ItemRedstone || stackItem instanceof IFlowerPlaceable) {
if(!scanned) {
for(int i = -rangePlace; i < rangePlace + 1; i++)
for(int j = -rangePlaceY; j < rangePlaceY + 1; j++)
@@ -102,7 +103,11 @@ public class SubTileRannuncarpus extends SubTileFunctional {
if(!validPositions.isEmpty() && !supertile.getWorldObj().isRemote) {
ChunkCoordinates coords = validPositions.get(supertile.getWorldObj().rand.nextInt(validPositions.size()));
Block blockToPlace = null;
if(stackItem instanceof IFlowerPlaceable)
blockToPlace = ((IFlowerPlaceable) stackItem).getBlockToPlaceByFlower(stack, this, coords.posX, coords.posY, coords.posZ);
if(stackItem instanceof ItemBlock)
blockToPlace = ((ItemBlock) stackItem).field_150939_a;
else if(stackItem instanceof ItemReed)
@@ -111,7 +116,6 @@ public class SubTileRannuncarpus extends SubTileFunctional {
blockToPlace = Blocks.redstone_wire;
if(blockToPlace != null) {
ChunkCoordinates coords = validPositions.get(supertile.getWorldObj().rand.nextInt(validPositions.size()));
if(blockToPlace.canPlaceBlockAt(supertile.getWorldObj(), coords.posX, coords.posY, coords.posZ)) {
supertile.getWorldObj().setBlock(coords.posX, coords.posY, coords.posZ, blockToPlace, stack.getItemDamage(), 1 | 2);
if(ConfigHandler.blockBreakParticles)
@@ -126,6 +130,9 @@ public class SubTileRannuncarpus extends SubTileFunctional {
SubTileEntity subtile = container.getSubTile();
subtile.onBlockPlacedBy(supertile.getWorldObj(), coords.posX, coords.posY, coords.posZ, null, stack);
}
if(stackItem instanceof IFlowerPlaceable)
((IFlowerPlaceable) stackItem).onBlockPlacedByFlower(stack, this, coords.posX, coords.posY, coords.posZ);
if(!supertile.getWorldObj().isRemote) {
stack.stackSize--;