restore planting functionality, fix #2691
This commit is contained in:
parent
db002ea714
commit
8582f8c8b7
2 changed files with 36 additions and 13 deletions
|
@ -11,6 +11,8 @@ package buildcraft;
|
|||
import java.io.PrintWriter;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
|
||||
import buildcraft.transport.stripes.*;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
|
@ -165,19 +167,6 @@ import buildcraft.transport.statements.TriggerPipeContents;
|
|||
import buildcraft.transport.statements.TriggerPipeContents.PipeContents;
|
||||
import buildcraft.transport.statements.TriggerPipeSignal;
|
||||
import buildcraft.transport.statements.TriggerRedstoneFaderInput;
|
||||
import buildcraft.transport.stripes.PipeExtensionListener;
|
||||
import buildcraft.transport.stripes.StripesHandlerArrow;
|
||||
import buildcraft.transport.stripes.StripesHandlerBucket;
|
||||
import buildcraft.transport.stripes.StripesHandlerDispenser;
|
||||
import buildcraft.transport.stripes.StripesHandlerEntityInteract;
|
||||
import buildcraft.transport.stripes.StripesHandlerHoe;
|
||||
import buildcraft.transport.stripes.StripesHandlerMinecartDestroy;
|
||||
import buildcraft.transport.stripes.StripesHandlerPipeWires;
|
||||
import buildcraft.transport.stripes.StripesHandlerPipes;
|
||||
import buildcraft.transport.stripes.StripesHandlerPlaceBlock;
|
||||
import buildcraft.transport.stripes.StripesHandlerRightClick;
|
||||
import buildcraft.transport.stripes.StripesHandlerShears;
|
||||
import buildcraft.transport.stripes.StripesHandlerUse;
|
||||
|
||||
@Mod(version = Version.VERSION, modid = "BuildCraft|Transport", name = "Buildcraft Transport", dependencies = DefaultProps.DEPENDENCY_CORE)
|
||||
public class BuildCraftTransport extends BuildCraftMod {
|
||||
|
@ -481,6 +470,7 @@ public class BuildCraftTransport extends BuildCraftMod {
|
|||
// Item use stripes handlers
|
||||
PipeManager.registerStripesHandler(new StripesHandlerRightClick(), -32768);
|
||||
PipeManager.registerStripesHandler(new StripesHandlerDispenser(), -49152);
|
||||
PipeManager.registerStripesHandler(new StripesHandlerPlant(), 0);
|
||||
PipeManager.registerStripesHandler(new StripesHandlerBucket(), 0);
|
||||
PipeManager.registerStripesHandler(new StripesHandlerArrow(), 0);
|
||||
PipeManager.registerStripesHandler(new StripesHandlerShears(), 0);
|
||||
|
|
33
common/buildcraft/transport/stripes/StripesHandlerPlant.java
Normal file
33
common/buildcraft/transport/stripes/StripesHandlerPlant.java
Normal file
|
@ -0,0 +1,33 @@
|
|||
package buildcraft.transport.stripes;
|
||||
|
||||
import buildcraft.api.transport.IStripesActivator;
|
||||
import buildcraft.api.transport.IStripesHandler;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.IPlantable;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class StripesHandlerPlant implements IStripesHandler {
|
||||
@Override
|
||||
public StripesHandlerType getType() {
|
||||
return StripesHandlerType.ITEM_USE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldHandle(ItemStack stack) {
|
||||
return stack.getItem() instanceof IPlantable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(World world, int x, int y, int z, ForgeDirection direction, ItemStack stack, EntityPlayer player, IStripesActivator activator) {
|
||||
Block b = world.getBlock(x, y - 1, z);
|
||||
IPlantable plant = (IPlantable) stack.getItem();
|
||||
if (b.canSustainPlant(world, x, y - 1, z, ForgeDirection.UP, (IPlantable) stack.getItem())) {
|
||||
world.setBlock(x, y, z, plant.getPlant(world, x, y, z), plant.getPlantMetadata(world, x, y, z), 3);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue