add default stripes handler and fix style
This commit is contained in:
parent
6ee68a5296
commit
f6fe4ffcb2
4 changed files with 59 additions and 6 deletions
|
@ -12,9 +12,7 @@ import java.util.ArrayList;
|
|||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.WorldServer;
|
||||
|
@ -38,9 +36,13 @@ import buildcraft.transport.PipeTransportItems;
|
|||
import buildcraft.transport.TileGenericPipe;
|
||||
import buildcraft.transport.TravelingItem;
|
||||
import buildcraft.transport.pipes.events.PipeEventItem;
|
||||
import buildcraft.transport.stripes.StripesHandlerDefault;
|
||||
import buildcraft.transport.utils.TransportUtils;
|
||||
|
||||
public class PipeItemsStripes extends Pipe<PipeTransportItems> implements IEnergyHandler, IStripesPipe {
|
||||
|
||||
private IStripesHandler defaultItemsHandler = new StripesHandlerDefault();
|
||||
|
||||
public PipeItemsStripes(Item item) {
|
||||
super(new PipeTransportItems(), item);
|
||||
}
|
||||
|
@ -109,6 +111,11 @@ public class PipeItemsStripes extends Pipe<PipeTransportItems> implements IEnerg
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(defaultItemsHandler.handle(getWorld(), (int) p.x, (int) p.y, (int) p.z,
|
||||
event.direction, stack, player, this)) {
|
||||
event.entity = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
/**
|
||||
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License.
|
||||
* Please check the contents of the license, which should be located
|
||||
* as "LICENSE.API" in the BuildCraft source code distribution.
|
||||
*/
|
||||
package buildcraft.transport.stripes;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import buildcraft.api.transport.IStripesHandler;
|
||||
import buildcraft.api.transport.IStripesPipe;
|
||||
|
||||
public class StripesHandlerDefault implements IStripesHandler {
|
||||
|
||||
@Override
|
||||
public StripesHandlerType getType() {
|
||||
return StripesHandlerType.ITEM_USE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldHandle(ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(World world, int x, int y, int z,
|
||||
ForgeDirection direction, ItemStack stack, EntityPlayer player,
|
||||
IStripesPipe pipe) {
|
||||
if (!world.isAirBlock(x, y, z)) {
|
||||
return false;
|
||||
}
|
||||
if (!stack.tryPlaceItemIntoWorld(player, world, x, y - 1, z, 1, 0.0f, 0.0f, 0.0f)) {
|
||||
return false;
|
||||
}
|
||||
pipe.sendItem(stack, direction.getOpposite());
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue