Smash PipeLogic hard
PipeLogic is now only used by Iron and Wooden pipes. All other pipes use the empty PipeLogic() class. Pipe connections are now handled by the new PipeConnectionBans class.
This commit is contained in:
parent
80a249e810
commit
61a0e89c4d
43 changed files with 252 additions and 608 deletions
|
@ -586,8 +586,8 @@ public class BlockGenericPipe extends BlockContainer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int par6, float xOffset, float yOffset, float zOffset) {
|
||||
super.onBlockActivated(world, x, y, z, entityplayer, par6, xOffset, yOffset, zOffset);
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int side, float xOffset, float yOffset, float zOffset) {
|
||||
super.onBlockActivated(world, x, y, z, entityplayer, side, xOffset, yOffset, zOffset);
|
||||
|
||||
world.notifyBlocksOfNeighborChange(x, y, z, BuildCraftTransport.genericPipeBlock.blockID);
|
||||
|
||||
|
@ -613,7 +613,7 @@ public class BlockGenericPipe extends BlockContainer {
|
|||
else if (entityplayer.getCurrentEquippedItem().getItem() instanceof IToolWrench)
|
||||
// Only check the instance at this point. Call the IToolWrench
|
||||
// interface callbacks for the individual pipe/logic calls
|
||||
return pipe.blockActivated(world, x, y, z, entityplayer);
|
||||
return pipe.blockActivated(entityplayer);
|
||||
else if (entityplayer.getCurrentEquippedItem().getItem() == BuildCraftTransport.redPipeWire) {
|
||||
if (!pipe.wireSet[IPipe.WireColor.Red.ordinal()]) {
|
||||
pipe.wireSet[IPipe.WireColor.Red.ordinal()] = true;
|
||||
|
@ -681,7 +681,7 @@ public class BlockGenericPipe extends BlockContainer {
|
|||
|
||||
return true;
|
||||
} else
|
||||
return pipe.blockActivated(world, x, y, z, entityplayer);
|
||||
return pipe.blockActivated(entityplayer);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -10,8 +10,8 @@ import buildcraft.transport.gui.GuiDiamondPipe;
|
|||
import buildcraft.transport.gui.GuiEmeraldPipe;
|
||||
import buildcraft.transport.gui.GuiFilteredBuffer;
|
||||
import buildcraft.transport.gui.GuiGateInterface;
|
||||
import buildcraft.transport.pipes.PipeItemsDiamond;
|
||||
import buildcraft.transport.pipes.PipeItemsEmerald;
|
||||
import buildcraft.transport.pipes.PipeLogicDiamond;
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
import java.util.logging.Level;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -43,7 +43,7 @@ public class GuiHandler implements IGuiHandler {
|
|||
|
||||
switch (ID) {
|
||||
case GuiIds.PIPE_DIAMOND:
|
||||
return new ContainerDiamondPipe(player.inventory, (PipeLogicDiamond) pipe.pipe.logic);
|
||||
return new ContainerDiamondPipe(player.inventory, (PipeItemsDiamond) pipe.pipe);
|
||||
|
||||
case GuiIds.PIPE_EMERALD_ITEM:
|
||||
return new ContainerEmeraldPipe(player.inventory, (PipeItemsEmerald) pipe.pipe);
|
||||
|
@ -83,7 +83,7 @@ public class GuiHandler implements IGuiHandler {
|
|||
|
||||
switch (ID) {
|
||||
case GuiIds.PIPE_DIAMOND:
|
||||
return new GuiDiamondPipe(player.inventory, (PipeLogicDiamond) pipe.pipe.logic);
|
||||
return new GuiDiamondPipe(player.inventory, (PipeItemsDiamond) pipe.pipe);
|
||||
|
||||
case GuiIds.PIPE_EMERALD_ITEM:
|
||||
return new GuiEmeraldPipe(player.inventory, (PipeItemsEmerald) pipe.pipe);
|
||||
|
|
|
@ -23,9 +23,11 @@ import buildcraft.core.network.TilePacketWrapper;
|
|||
import buildcraft.core.triggers.ActionRedstoneOutput;
|
||||
import buildcraft.core.utils.Utils;
|
||||
import buildcraft.transport.Gate.GateConditional;
|
||||
import buildcraft.transport.pipes.PipeLogic;
|
||||
import buildcraft.transport.pipes.*;
|
||||
import buildcraft.transport.triggers.ActionSignalOutput;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.HashMultiset;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.Multiset;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
@ -81,7 +83,7 @@ public abstract class Pipe implements IPipe, IDropControlInventory {
|
|||
logic.setTile((TileGenericPipe) tile);
|
||||
}
|
||||
|
||||
public boolean blockActivated(World world, int i, int j, int k, EntityPlayer entityplayer) {
|
||||
public boolean blockActivated(EntityPlayer entityplayer) {
|
||||
return logic.blockActivated(entityplayer);
|
||||
}
|
||||
|
||||
|
@ -101,6 +103,12 @@ public abstract class Pipe implements IPipe, IDropControlInventory {
|
|||
}
|
||||
|
||||
public boolean canPipeConnect(TileEntity tile, ForgeDirection side) {
|
||||
Pipe otherPipe;
|
||||
if (tile instanceof TileGenericPipe) {
|
||||
otherPipe = ((TileGenericPipe) tile).pipe;
|
||||
if (!PipeConnectionBans.canPipesConnect(getClass(), otherPipe.getClass()))
|
||||
return false;
|
||||
}
|
||||
return logic.canPipeConnect(tile, side) && transport.canPipeConnect(tile, side);
|
||||
}
|
||||
|
||||
|
@ -417,8 +425,8 @@ public abstract class Pipe implements IPipe, IDropControlInventory {
|
|||
notifyBlocksOfNeighborChange(side);
|
||||
}
|
||||
}
|
||||
|
||||
public void dropItem(ItemStack stack){
|
||||
|
||||
public void dropItem(ItemStack stack) {
|
||||
Utils.dropItems(container.worldObj, stack, container.xCoord, container.yCoord, container.zCoord);
|
||||
}
|
||||
|
||||
|
@ -661,7 +669,7 @@ public abstract class Pipe implements IPipe, IDropControlInventory {
|
|||
|
||||
@Override
|
||||
public boolean doDrop() {
|
||||
return logic.doDrop();
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isGateActive() {
|
||||
|
|
76
common/buildcraft/transport/PipeConnectionBans.java
Normal file
76
common/buildcraft/transport/PipeConnectionBans.java
Normal file
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* Copyright (c) SpaceToad, 2011-2012
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
package buildcraft.transport;
|
||||
|
||||
import buildcraft.transport.pipes.PipeFluidsCobblestone;
|
||||
import buildcraft.transport.pipes.PipeFluidsStone;
|
||||
import buildcraft.transport.pipes.PipeFluidsWood;
|
||||
import buildcraft.transport.pipes.PipeItemsCobblestone;
|
||||
import buildcraft.transport.pipes.PipeItemsObsidian;
|
||||
import buildcraft.transport.pipes.PipeItemsQuartz;
|
||||
import buildcraft.transport.pipes.PipeItemsStone;
|
||||
import buildcraft.transport.pipes.PipeItemsWood;
|
||||
import buildcraft.transport.pipes.PipePowerWood;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.SetMultimap;
|
||||
|
||||
/**
|
||||
* Controls whether one type of pipe can connect to another.
|
||||
*
|
||||
* @author CovertJaguar <http://www.railcraft.info/>
|
||||
*/
|
||||
public class PipeConnectionBans {
|
||||
|
||||
private static final SetMultimap<Class<? extends Pipe>, Class<? extends Pipe>> connectionBans = HashMultimap.create();
|
||||
|
||||
static {
|
||||
// Fluid pipes
|
||||
banConnection(PipeFluidsStone.class, PipeFluidsCobblestone.class);
|
||||
|
||||
banConnection(PipeFluidsWood.class);
|
||||
|
||||
// Item Pipes
|
||||
banConnection(PipeItemsStone.class, PipeItemsCobblestone.class, PipeItemsQuartz.class);
|
||||
|
||||
banConnection(PipeItemsWood.class);
|
||||
|
||||
banConnection(PipeItemsObsidian.class);
|
||||
|
||||
// Power Pipes
|
||||
banConnection(PipePowerWood.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Will ban connection between any set of pipe types provided.
|
||||
*
|
||||
* If only one parameter is passed in, it will ban connection to pipes of the
|
||||
* same type.
|
||||
*
|
||||
* @param types
|
||||
*/
|
||||
public static void banConnection(Class<? extends Pipe>... types) {
|
||||
if (types.length == 0)
|
||||
return;
|
||||
if (types.length == 1) {
|
||||
connectionBans.put(types[0], types[0]);
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < types.length; i++) {
|
||||
for (int j = 0; j < types.length; j++) {
|
||||
if (i == j)
|
||||
continue;
|
||||
connectionBans.put(types[i], types[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean canPipesConnect(Class<? extends Pipe> type1, Class<? extends Pipe> type2) {
|
||||
return !connectionBans.containsEntry(type1, type2);
|
||||
}
|
||||
}
|
|
@ -9,22 +9,22 @@ package buildcraft.transport.gui;
|
|||
|
||||
import buildcraft.core.gui.BuildCraftContainer;
|
||||
import buildcraft.core.gui.slots.SlotPhantom;
|
||||
import buildcraft.transport.pipes.PipeLogicDiamond;
|
||||
import buildcraft.transport.pipes.PipeItemsDiamond;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
|
||||
public class ContainerDiamondPipe extends BuildCraftContainer {
|
||||
|
||||
private final PipeLogicDiamond logic;
|
||||
private final PipeItemsDiamond pipe;
|
||||
private final IInventory playerInv;
|
||||
private final IInventory filterInv;
|
||||
|
||||
public ContainerDiamondPipe(IInventory playerInventory, PipeLogicDiamond logic) {
|
||||
super(logic.getFilters().getSizeInventory());
|
||||
this.logic = logic;
|
||||
public ContainerDiamondPipe(IInventory playerInventory, PipeItemsDiamond pipe) {
|
||||
super(pipe.getFilters().getSizeInventory());
|
||||
this.pipe = pipe;
|
||||
this.playerInv = playerInventory;
|
||||
this.filterInv = logic.getFilters();
|
||||
this.filterInv = pipe.getFilters();
|
||||
|
||||
for (int y = 0; y < 6; y++) {
|
||||
for (int x = 0; x < 9; x++) {
|
||||
|
@ -45,6 +45,6 @@ public class ContainerDiamondPipe extends BuildCraftContainer {
|
|||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer entityplayer) {
|
||||
return logic.container.isUseableByPlayer(entityplayer);
|
||||
return pipe.container.isUseableByPlayer(entityplayer);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ package buildcraft.transport.gui;
|
|||
import buildcraft.core.DefaultProps;
|
||||
import buildcraft.core.gui.GuiBuildCraft;
|
||||
import buildcraft.core.utils.StringUtils;
|
||||
import buildcraft.transport.pipes.PipeLogicDiamond;
|
||||
import buildcraft.transport.pipes.PipeItemsDiamond;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
@ -21,10 +21,10 @@ public class GuiDiamondPipe extends GuiBuildCraft {
|
|||
IInventory playerInventory;
|
||||
IInventory filterInventory;
|
||||
|
||||
public GuiDiamondPipe(IInventory playerInventory, PipeLogicDiamond logic) {
|
||||
super(new ContainerDiamondPipe(playerInventory, logic), logic.getFilters());
|
||||
public GuiDiamondPipe(IInventory playerInventory, PipeItemsDiamond pipe) {
|
||||
super(new ContainerDiamondPipe(playerInventory, pipe), pipe.getFilters());
|
||||
this.playerInventory = playerInventory;
|
||||
this.filterInventory = logic.getFilters();
|
||||
this.filterInventory = pipe.getFilters();
|
||||
xSize = 175;
|
||||
ySize = 225;
|
||||
}
|
||||
|
|
|
@ -8,8 +8,8 @@ import buildcraft.transport.PipeTransportItems;
|
|||
import buildcraft.transport.PipeTransportPower;
|
||||
import buildcraft.transport.TileGenericPipe;
|
||||
import buildcraft.transport.gui.ContainerGateInterface;
|
||||
import buildcraft.transport.pipes.PipeItemsDiamond;
|
||||
import buildcraft.transport.pipes.PipeItemsEmerald;
|
||||
import buildcraft.transport.pipes.PipeLogicDiamond;
|
||||
import cpw.mods.fml.common.network.IPacketHandler;
|
||||
import cpw.mods.fml.common.network.Player;
|
||||
import java.io.ByteArrayInputStream;
|
||||
|
@ -318,10 +318,10 @@ public class PacketHandlerTransport implements IPacketHandler {
|
|||
if (pipe == null)
|
||||
return;
|
||||
|
||||
if (!(pipe.pipe.logic instanceof PipeLogicDiamond))
|
||||
if (!(pipe.pipe instanceof PipeItemsDiamond))
|
||||
return;
|
||||
|
||||
((PipeLogicDiamond) pipe.pipe.logic).getFilters().setInventorySlotContents(packet.slot, packet.stack);
|
||||
((PipeItemsDiamond) pipe.pipe).getFilters().setInventorySlotContents(packet.slot, packet.stack);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
/**
|
||||
* BuildCraft is open-source. It is distributed under the terms of the
|
||||
* BuildCraft Open Source License. It grants rights to read, modify, compile
|
||||
* or run the code. It does *NOT* grant the right to redistribute this software
|
||||
* or its modifications in any form, binary or source, except if expressively
|
||||
* BuildCraft Open Source License. It grants rights to read, modify, compile or
|
||||
* run the code. It does *NOT* grant the right to redistribute this software or
|
||||
* its modifications in any form, binary or source, except if expressively
|
||||
* granted by the copyright holder.
|
||||
*/
|
||||
|
||||
package buildcraft.transport.pipes;
|
||||
|
||||
import buildcraft.BuildCraftTransport;
|
||||
|
@ -20,7 +19,7 @@ import net.minecraftforge.common.ForgeDirection;
|
|||
public class PipeFluidsCobblestone extends Pipe {
|
||||
|
||||
public PipeFluidsCobblestone(int itemID) {
|
||||
super(new PipeTransportFluids(), new PipeLogicCobblestone(), itemID);
|
||||
super(new PipeTransportFluids(), new PipeLogic(), itemID);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -18,7 +18,7 @@ import buildcraft.transport.PipeTransportFluids;
|
|||
public class PipeFluidsEmerald extends PipeFluidsWood {
|
||||
|
||||
public PipeFluidsEmerald(int itemID) {
|
||||
super(new PipeLogicEmerald(), itemID);
|
||||
super(new PipeLogicWood(), itemID);
|
||||
|
||||
standardIconIndex = PipeIconProvider.TYPE.PipeFluidsEmerald_Standard.ordinal();
|
||||
solidIconIndex = PipeIconProvider.TYPE.PipeAllEmerald_Solid.ordinal();
|
||||
|
|
|
@ -20,7 +20,7 @@ import net.minecraftforge.common.ForgeDirection;
|
|||
public class PipeFluidsGold extends Pipe {
|
||||
|
||||
public PipeFluidsGold(int itemID) {
|
||||
super(new PipeTransportFluids(), new PipeLogicGold(), itemID);
|
||||
super(new PipeTransportFluids(), new PipeLogic(), itemID);
|
||||
|
||||
((PipeTransportFluids) transport).flowRate = 40;
|
||||
((PipeTransportFluids) transport).travelDelay = 4;
|
||||
|
|
|
@ -1,28 +1,34 @@
|
|||
/**
|
||||
* BuildCraft is open-source. It is distributed under the terms of the
|
||||
* BuildCraft Open Source License. It grants rights to read, modify, compile
|
||||
* or run the code. It does *NOT* grant the right to redistribute this software
|
||||
* or its modifications in any form, binary or source, except if expressively
|
||||
* BuildCraft Open Source License. It grants rights to read, modify, compile or
|
||||
* run the code. It does *NOT* grant the right to redistribute this software or
|
||||
* its modifications in any form, binary or source, except if expressively
|
||||
* granted by the copyright holder.
|
||||
*/
|
||||
|
||||
package buildcraft.transport.pipes;
|
||||
|
||||
import buildcraft.BuildCraftTransport;
|
||||
import buildcraft.api.core.IIconProvider;
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import buildcraft.api.transport.IPipeEntry;
|
||||
import buildcraft.transport.Pipe;
|
||||
import buildcraft.transport.PipeIconProvider;
|
||||
import buildcraft.transport.PipeTransportFluids;
|
||||
import buildcraft.transport.TileGenericPipe;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
public class PipeFluidsIron extends Pipe {
|
||||
|
||||
|
||||
protected int standardIconIndex = PipeIconProvider.TYPE.PipeFluidsIron_Standard.ordinal();
|
||||
protected int solidIconIndex = PipeIconProvider.TYPE.PipeAllIron_Solid.ordinal();
|
||||
|
||||
|
||||
public PipeFluidsIron(int itemID) {
|
||||
super(new PipeTransportFluids(), new PipeLogicIron(), itemID);
|
||||
}
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* http://www.mod-buildcraft.com
|
||||
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public License
|
||||
* 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
|
||||
package buildcraft.transport.pipes;
|
||||
|
||||
import buildcraft.BuildCraftTransport;
|
||||
|
@ -19,12 +17,14 @@ import buildcraft.transport.PipeTransportFluids;
|
|||
import buildcraft.transport.TileGenericPipe;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class PipeFluidsSandstone extends Pipe implements IPipeTransportFluidsHook {
|
||||
|
||||
public PipeFluidsSandstone(int itemID) {
|
||||
super(new PipeTransportFluids(), new PipeLogicSandstone(), itemID);
|
||||
super(new PipeTransportFluids(), new PipeLogic(), itemID);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -45,4 +45,9 @@ public class PipeFluidsSandstone extends Pipe implements IPipeTransportFluidsHoo
|
|||
|
||||
return ((PipeTransportFluids) this.transport).fill(from, resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPipeConnect(TileEntity tile, ForgeDirection side) {
|
||||
return (tile instanceof TileGenericPipe) && super.canPipeConnect(tile, side);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
/**
|
||||
* BuildCraft is open-source. It is distributed under the terms of the
|
||||
* BuildCraft Open Source License. It grants rights to read, modify, compile
|
||||
* or run the code. It does *NOT* grant the right to redistribute this software
|
||||
* or its modifications in any form, binary or source, except if expressively
|
||||
* BuildCraft Open Source License. It grants rights to read, modify, compile or
|
||||
* run the code. It does *NOT* grant the right to redistribute this software or
|
||||
* its modifications in any form, binary or source, except if expressively
|
||||
* granted by the copyright holder.
|
||||
*/
|
||||
|
||||
package buildcraft.transport.pipes;
|
||||
|
||||
import buildcraft.BuildCraftTransport;
|
||||
|
@ -20,11 +19,10 @@ import net.minecraftforge.common.ForgeDirection;
|
|||
public class PipeFluidsStone extends Pipe {
|
||||
|
||||
public PipeFluidsStone(int itemID) {
|
||||
super(new PipeTransportFluids(), new PipeLogicStone(), itemID);
|
||||
|
||||
super(new PipeTransportFluids(), new PipeLogic(), itemID);
|
||||
// ((PipeTransportFluids) transport).flowRate = 40;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIconProvider getIconProvider() {
|
||||
|
@ -35,5 +33,4 @@ public class PipeFluidsStone extends Pipe {
|
|||
public int getIconIndex(ForgeDirection direction) {
|
||||
return PipeIconProvider.TYPE.PipeFluidsStone.ordinal();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ import net.minecraftforge.fluids.FluidStack;
|
|||
public class PipeFluidsVoid extends Pipe implements IPipeTransportFluidsHook {
|
||||
|
||||
public PipeFluidsVoid(int itemID) {
|
||||
super(new PipeTransportFluids(), new PipeLogicVoid(), itemID);
|
||||
super(new PipeTransportFluids(), new PipeLogic(), itemID);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -20,8 +20,7 @@ import net.minecraftforge.common.ForgeDirection;
|
|||
public class PipeItemsCobblestone extends Pipe {
|
||||
|
||||
public PipeItemsCobblestone(int itemID) {
|
||||
super(new PipeTransportItems(), new PipeLogicCobblestone(), itemID);
|
||||
|
||||
super(new PipeTransportItems(), new PipeLogic(), itemID);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,18 +1,21 @@
|
|||
/**
|
||||
* BuildCraft is open-source. It is distributed under the terms of the
|
||||
* BuildCraft Open Source License. It grants rights to read, modify, compile
|
||||
* or run the code. It does *NOT* grant the right to redistribute this software
|
||||
* or its modifications in any form, binary or source, except if expressively
|
||||
* BuildCraft Open Source License. It grants rights to read, modify, compile or
|
||||
* run the code. It does *NOT* grant the right to redistribute this software or
|
||||
* its modifications in any form, binary or source, except if expressively
|
||||
* granted by the copyright holder.
|
||||
*/
|
||||
|
||||
package buildcraft.transport.pipes;
|
||||
|
||||
import buildcraft.BuildCraftTransport;
|
||||
import buildcraft.api.core.IIconProvider;
|
||||
import buildcraft.api.core.Position;
|
||||
import buildcraft.api.transport.IPipedItem;
|
||||
import buildcraft.core.GuiIds;
|
||||
import buildcraft.core.inventory.SimpleInventory;
|
||||
import buildcraft.core.network.IClientState;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
import buildcraft.transport.BlockGenericPipe;
|
||||
import buildcraft.transport.IPipeTransportItemsHook;
|
||||
import buildcraft.transport.Pipe;
|
||||
import buildcraft.transport.PipeIconProvider;
|
||||
|
@ -23,6 +26,9 @@ import java.io.DataInputStream;
|
|||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.LinkedList;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
|
@ -31,8 +37,14 @@ import net.minecraftforge.common.ForgeDirection;
|
|||
|
||||
public class PipeItemsDiamond extends Pipe implements IPipeTransportItemsHook, IClientState {
|
||||
|
||||
private SimpleInventory filters = new SimpleInventory(54, "Filters", 1);
|
||||
|
||||
public PipeItemsDiamond(int itemID) {
|
||||
super(new PipeTransportItems(), new PipeLogicDiamond(), itemID);
|
||||
super(new PipeTransportItems(), new PipeLogic(), itemID);
|
||||
}
|
||||
|
||||
public IInventory getFilters() {
|
||||
return filters;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -43,18 +55,39 @@ public class PipeItemsDiamond extends Pipe implements IPipeTransportItemsHook, I
|
|||
|
||||
@Override
|
||||
public int getIconIndex(ForgeDirection direction) {
|
||||
switch(direction){
|
||||
case UNKNOWN: return PipeIconProvider.TYPE.PipeItemsDiamond_Center.ordinal();
|
||||
case DOWN: return PipeIconProvider.TYPE.PipeItemsDiamond_Down.ordinal();
|
||||
case UP: return PipeIconProvider.TYPE.PipeItemsDiamond_Up.ordinal();
|
||||
case NORTH: return PipeIconProvider.TYPE.PipeItemsDiamond_North.ordinal();
|
||||
case SOUTH: return PipeIconProvider.TYPE.PipeItemsDiamond_South.ordinal();
|
||||
case WEST: return PipeIconProvider.TYPE.PipeItemsDiamond_West.ordinal();
|
||||
case EAST: return PipeIconProvider.TYPE.PipeItemsDiamond_East.ordinal();
|
||||
default: throw new IllegalArgumentException("direction out of bounds");
|
||||
switch (direction) {
|
||||
case UNKNOWN:
|
||||
return PipeIconProvider.TYPE.PipeItemsDiamond_Center.ordinal();
|
||||
case DOWN:
|
||||
return PipeIconProvider.TYPE.PipeItemsDiamond_Down.ordinal();
|
||||
case UP:
|
||||
return PipeIconProvider.TYPE.PipeItemsDiamond_Up.ordinal();
|
||||
case NORTH:
|
||||
return PipeIconProvider.TYPE.PipeItemsDiamond_North.ordinal();
|
||||
case SOUTH:
|
||||
return PipeIconProvider.TYPE.PipeItemsDiamond_South.ordinal();
|
||||
case WEST:
|
||||
return PipeIconProvider.TYPE.PipeItemsDiamond_West.ordinal();
|
||||
case EAST:
|
||||
return PipeIconProvider.TYPE.PipeItemsDiamond_East.ordinal();
|
||||
default:
|
||||
throw new IllegalArgumentException("direction out of bounds");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean blockActivated(EntityPlayer entityplayer) {
|
||||
if (entityplayer.getCurrentEquippedItem() != null && entityplayer.getCurrentEquippedItem().itemID < Block.blocksList.length)
|
||||
if (Block.blocksList[entityplayer.getCurrentEquippedItem().itemID] instanceof BlockGenericPipe)
|
||||
return false;
|
||||
|
||||
if (!CoreProxy.proxy.isRenderWorld(container.worldObj)) {
|
||||
entityplayer.openGui(BuildCraftTransport.instance, GuiIds.PIPE_DIAMOND, container.worldObj, container.xCoord, container.yCoord, container.zCoord);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LinkedList<ForgeDirection> filterPossibleMovements(LinkedList<ForgeDirection> possibleOrientations, Position pos, IPipedItem item) {
|
||||
LinkedList<ForgeDirection> filteredOrientations = new LinkedList<ForgeDirection>();
|
||||
|
@ -67,9 +100,8 @@ public class PipeItemsDiamond extends Pipe implements IPipeTransportItemsHook, I
|
|||
// NB: if there's several of the same match, the probability
|
||||
// to use that filter is higher, this is why there are
|
||||
// no breaks here.
|
||||
PipeLogicDiamond diamondLogic = (PipeLogicDiamond) logic;
|
||||
for (int slot = 0; slot < 9; ++slot) {
|
||||
ItemStack stack = diamondLogic.getFilters().getStackInSlot(dir.ordinal() * 9 + slot);
|
||||
ItemStack stack = getFilters().getStackInSlot(dir.ordinal() * 9 + slot);
|
||||
|
||||
if (stack != null) {
|
||||
foundFilter = true;
|
||||
|
@ -94,19 +126,31 @@ public class PipeItemsDiamond extends Pipe implements IPipeTransportItemsHook, I
|
|||
|
||||
@Override
|
||||
public void entityEntered(IPipedItem item, ForgeDirection orientation) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readjustSpeed(IPipedItem item) {
|
||||
((PipeTransportItems) transport).defaultReajustSpeed(item);
|
||||
}
|
||||
/* SAVING & LOADING */
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
filters.readFromNBT(nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
filters.writeToNBT(nbt);
|
||||
}
|
||||
|
||||
// ICLIENTSTATE
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
((PipeLogicDiamond) logic).writeToNBT(nbt);
|
||||
writeToNBT(nbt);
|
||||
NBTBase.writeNamedTag(nbt, data);
|
||||
}
|
||||
|
||||
|
@ -114,8 +158,7 @@ public class PipeItemsDiamond extends Pipe implements IPipeTransportItemsHook, I
|
|||
public void readData(DataInputStream data) throws IOException {
|
||||
NBTBase nbt = NBTBase.readNamedTag(data);
|
||||
if (nbt instanceof NBTTagCompound) {
|
||||
logic.readFromNBT((NBTTagCompound) nbt);
|
||||
readFromNBT((NBTTagCompound) nbt);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ import net.minecraft.inventory.IInventory;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public class PipeItemsEmerald extends PipeItemsWood implements IClientState {
|
||||
|
@ -36,7 +35,7 @@ public class PipeItemsEmerald extends PipeItemsWood implements IClientState {
|
|||
private int currentFilter = 0;
|
||||
|
||||
protected PipeItemsEmerald(int itemID, PipeTransportItems transport) {
|
||||
super(transport, new PipeLogicEmerald(), itemID);
|
||||
super(transport, new PipeLogicWood(), itemID);
|
||||
|
||||
standardIconIndex = PipeIconProvider.TYPE.PipeItemsEmerald_Standard.ordinal();
|
||||
solidIconIndex = PipeIconProvider.TYPE.PipeAllEmerald_Solid.ordinal();
|
||||
|
@ -47,19 +46,19 @@ public class PipeItemsEmerald extends PipeItemsWood implements IClientState {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean blockActivated(World world, int x, int y, int z, EntityPlayer entityplayer) {
|
||||
public boolean blockActivated(EntityPlayer entityplayer) {
|
||||
if (entityplayer.getCurrentEquippedItem() != null && entityplayer.getCurrentEquippedItem().itemID < Block.blocksList.length) {
|
||||
if (Block.blocksList[entityplayer.getCurrentEquippedItem().itemID] instanceof BlockGenericPipe) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (super.blockActivated(world, x, y, z, entityplayer)) {
|
||||
if (super.blockActivated(entityplayer)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!CoreProxy.proxy.isRenderWorld(container.worldObj)) {
|
||||
entityplayer.openGui(BuildCraftTransport.instance, GuiIds.PIPE_EMERALD_ITEM, world, x, y, z);
|
||||
entityplayer.openGui(BuildCraftTransport.instance, GuiIds.PIPE_EMERALD_ITEM, container.worldObj, container.xCoord, container.yCoord, container.zCoord);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -25,7 +25,7 @@ import net.minecraftforge.common.ForgeDirection;
|
|||
public class PipeItemsGold extends Pipe implements IPipeTransportItemsHook {
|
||||
|
||||
public PipeItemsGold(int itemID) {
|
||||
super(new PipeTransportItems(), new PipeLogicGold(), itemID);
|
||||
super(new PipeTransportItems(), new PipeLogic(), itemID);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -43,7 +43,7 @@ public class PipeItemsObsidian extends Pipe implements IPowerReceptor {
|
|||
private int entitiesDroppedIndex = 0;
|
||||
|
||||
public PipeItemsObsidian(int itemID) {
|
||||
super(new PipeTransportItems(), new PipeLogicObsidian(), itemID);
|
||||
super(new PipeTransportItems(), new PipeLogic(), itemID);
|
||||
|
||||
entitiesDropped = new int[32];
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import net.minecraftforge.common.ForgeDirection;
|
|||
public class PipeItemsQuartz extends Pipe implements IPipeTransportItemsHook {
|
||||
|
||||
public PipeItemsQuartz(int itemID) {
|
||||
super(new PipeTransportItems(), new PipeLogicQuartz(), itemID);
|
||||
super(new PipeTransportItems(), new PipeLogic(), itemID);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* http://www.mod-buildcraft.com
|
||||
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public License
|
||||
* 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
|
||||
package buildcraft.transport.pipes;
|
||||
|
||||
import buildcraft.BuildCraftTransport;
|
||||
|
@ -14,13 +12,16 @@ import buildcraft.api.core.IIconProvider;
|
|||
import buildcraft.transport.Pipe;
|
||||
import buildcraft.transport.PipeIconProvider;
|
||||
import buildcraft.transport.PipeTransportItems;
|
||||
import buildcraft.transport.TileGenericPipe;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public class PipeItemsSandstone extends Pipe {
|
||||
|
||||
public PipeItemsSandstone(int itemID) {
|
||||
super(new PipeTransportItems(), new PipeLogicSandstone(), itemID);
|
||||
super(new PipeTransportItems(), new PipeLogic(), itemID);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -33,4 +34,9 @@ public class PipeItemsSandstone extends Pipe {
|
|||
public int getIconIndex(ForgeDirection direction) {
|
||||
return PipeIconProvider.TYPE.PipeItemsSandstone.ordinal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPipeConnect(TileEntity tile, ForgeDirection side) {
|
||||
return (tile instanceof TileGenericPipe) && super.canPipeConnect(tile, side);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
/**
|
||||
* BuildCraft is open-source. It is distributed under the terms of the
|
||||
* BuildCraft Open Source License. It grants rights to read, modify, compile
|
||||
* or run the code. It does *NOT* grant the right to redistribute this software
|
||||
* or its modifications in any form, binary or source, except if expressively
|
||||
* BuildCraft Open Source License. It grants rights to read, modify, compile or
|
||||
* run the code. It does *NOT* grant the right to redistribute this software or
|
||||
* its modifications in any form, binary or source, except if expressively
|
||||
* granted by the copyright holder.
|
||||
*/
|
||||
|
||||
package buildcraft.transport.pipes;
|
||||
|
||||
import buildcraft.BuildCraftTransport;
|
||||
|
@ -25,8 +24,7 @@ import net.minecraftforge.common.ForgeDirection;
|
|||
public class PipeItemsStone extends Pipe implements IPipeTransportItemsHook {
|
||||
|
||||
public PipeItemsStone(int itemID) {
|
||||
super(new PipeTransportItems(), new PipeLogicStone(), itemID);
|
||||
|
||||
super(new PipeTransportItems(), new PipeLogic(), itemID);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -58,7 +56,5 @@ public class PipeItemsStone extends Pipe implements IPipeTransportItemsHook {
|
|||
|
||||
@Override
|
||||
public void entityEntered(IPipedItem item, ForgeDirection orientation) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,157 +0,0 @@
|
|||
/**
|
||||
* BuildCraft is open-source. It is distributed under the terms of the
|
||||
* BuildCraft Open Source License. It grants rights to read, modify, compile
|
||||
* or run the code. It does *NOT* grant the right to redistribute this software
|
||||
* or its modifications in any form, binary or source, except if expressively
|
||||
* granted by the copyright holder.
|
||||
*/
|
||||
|
||||
package buildcraft.transport.pipes;
|
||||
|
||||
/*
|
||||
import java.util.ArrayList;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import buildcraft.BuildCraftBlockUtil;
|
||||
import buildcraft.BuildCraftTransport;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import buildcraft.api.core.Position;
|
||||
import buildcraft.api.power.IPowerProvider;
|
||||
import buildcraft.api.power.IPowerReceptor;
|
||||
import buildcraft.api.power.PowerFramework;
|
||||
import buildcraft.api.power.PowerProvider;
|
||||
import buildcraft.api.transport.IPipedItem;
|
||||
import buildcraft.core.DefaultProps;
|
||||
import buildcraft.core.EntityPassiveItem;
|
||||
import buildcraft.core.Utils;
|
||||
import buildcraft.transport.BlockGenericPipe;
|
||||
import buildcraft.transport.EntityData;
|
||||
import buildcraft.transport.IItemTravelingHook;
|
||||
import buildcraft.transport.ItemPipe;
|
||||
import buildcraft.transport.Pipe;
|
||||
import buildcraft.transport.PipeLogicStripes;
|
||||
import buildcraft.transport.PipeTransportItems;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class PipeItemsStripes extends Pipe implements IItemTravelingHook, IPowerReceptor {
|
||||
|
||||
private IPowerProvider powerProvider;
|
||||
|
||||
public PipeItemsStripes(int itemID) {
|
||||
super(new PipeTransportItems(), new PipeLogicStripes(), itemID);
|
||||
|
||||
((PipeTransportItems) transport).travelHook = this;
|
||||
|
||||
powerProvider = PowerFramework.currentFramework.createPowerProvider();
|
||||
powerProvider.configure(25, 1, 1, 1, 1);
|
||||
powerProvider.configurePowerPerdition(1, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTextureFile() {
|
||||
return DefaultProps.TEXTURE_BLOCKS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTextureIndex(ForgeDirection direction) {
|
||||
return 16 * 7 + 14;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void doWork() {
|
||||
if (powerProvider.useEnergy(1, 1, true) == 1) {
|
||||
ForgeDirection o = getOpenOrientation();
|
||||
|
||||
if (o != ForgeDirection.Unknown) {
|
||||
Position p = new Position(xCoord, yCoord, zCoord, o);
|
||||
p.moveForwards(1.0);
|
||||
|
||||
ArrayList<ItemStack> stacks = BuildCraftBlockUtil
|
||||
.getItemStackFromBlock(worldObj, (int) p.x, (int) p.y, (int) p.z);
|
||||
|
||||
if (stacks != null)
|
||||
for (ItemStack s : stacks)
|
||||
if (s != null) {
|
||||
IPipedItem newItem = new EntityPassiveItem(worldObj, xCoord + 0.5, yCoord
|
||||
+ Utils.getPipeFloorOf(s), zCoord + 0.5, s);
|
||||
|
||||
this.container.entityEntering(newItem, o.reverse());
|
||||
}
|
||||
|
||||
worldObj.setBlock((int) p.x, (int) p.y, (int) p.z, 0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drop(PipeTransportItems pipe, EntityData data) {
|
||||
Position p = new Position(xCoord, yCoord, zCoord, data.orientation);
|
||||
p.moveForwards(1.0);
|
||||
|
||||
if (convertPipe(pipe, data))
|
||||
BuildCraftTransport.pipeItemsStipes.onItemUse(new ItemStack(BuildCraftTransport.pipeItemsStipes),
|
||||
CoreProxy.getBuildCraftPlayer(worldObj), worldObj, (int) p.x, (int) p.y - 1, (int) p.z, 1);
|
||||
else if (worldObj.getBlockId((int) p.x, (int) p.y, (int) p.z) == 0)
|
||||
data.item.getItemStack().getItem().tryPlaceIntoWorld(data.item.getItemStack(), CoreProxy.getBuildCraftPlayer(worldObj), worldObj, (int) p.x,
|
||||
(int) p.y - 1, (int) p.z, 1, 0.0f, 0.0f, 0.0f);
|
||||
else
|
||||
data.item.getItemStack().getItem().tryPlaceIntoWorld(data.item.getItemStack(), CoreProxy.getBuildCraftPlayer(worldObj), worldObj, (int) p.x,
|
||||
(int) p.y, (int) p.z, 1, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void centerReached(PipeTransportItems pipe, EntityData data) {
|
||||
convertPipe(pipe, data);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean convertPipe(PipeTransportItems pipe, EntityData data) {
|
||||
|
||||
if (data.item.getItemStack().getItem() instanceof ItemPipe)
|
||||
|
||||
if (!(data.item.getItemStack().itemID == BuildCraftTransport.pipeItemsStipes.shiftedIndex)) {
|
||||
|
||||
Pipe newPipe = BlockGenericPipe.createPipe(data.item.getItemStack().itemID);
|
||||
newPipe.setTile(this.container);
|
||||
this.container.pipe = newPipe;
|
||||
((PipeTransportItems) newPipe.transport).travelingEntities = (TreeMap<Integer, EntityData>) pipe.travelingEntities
|
||||
.clone();
|
||||
|
||||
data.item.getItemStack().stackSize--;
|
||||
|
||||
if (data.item.getItemStack().stackSize <= 0)
|
||||
((PipeTransportItems) newPipe.transport).travelingEntities.remove(data.item.getEntityId());
|
||||
|
||||
pipe.scheduleRemoval(data.item);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPowerProvider(IPowerProvider provider) {
|
||||
powerProvider = provider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPowerProvider getPowerProvider() {
|
||||
return powerProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int powerRequest() {
|
||||
return getPowerProvider().getMaxEnergyReceived();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endReached(PipeTransportItems pipe, EntityData data, TileEntity tile) {
|
||||
|
||||
}
|
||||
}
|
||||
*/
|
|
@ -24,7 +24,7 @@ import net.minecraftforge.common.ForgeDirection;
|
|||
public class PipeItemsVoid extends Pipe implements IItemTravelingHook {
|
||||
|
||||
public PipeItemsVoid(int itemID) {
|
||||
super(new PipeTransportItems(), new PipeLogicVoid(), itemID);
|
||||
super(new PipeTransportItems(), new PipeLogic(), itemID);
|
||||
((PipeTransportItems) transport).travelHook = this;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,40 +1,26 @@
|
|||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* http://www.mod-buildcraft.com
|
||||
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public License
|
||||
* 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
|
||||
package buildcraft.transport.pipes;
|
||||
|
||||
import buildcraft.core.IDropControlInventory;
|
||||
import buildcraft.transport.TileGenericPipe;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public class PipeLogic implements IDropControlInventory {
|
||||
/**
|
||||
* Note: The entire PipeLogic framework will probably eventually disappear. Use
|
||||
* sparingly.
|
||||
*/
|
||||
public class PipeLogic {
|
||||
|
||||
public int xCoord;
|
||||
public int yCoord;
|
||||
public int zCoord;
|
||||
public World worldObj;
|
||||
public TileGenericPipe container;
|
||||
|
||||
public void setPosition(int xCoord, int yCoord, int zCoord) {
|
||||
this.xCoord = xCoord;
|
||||
this.yCoord = yCoord;
|
||||
this.zCoord = zCoord;
|
||||
}
|
||||
|
||||
public void setWorld(World worldObj) {
|
||||
this.worldObj = worldObj;
|
||||
}
|
||||
|
||||
public void setTile(TileGenericPipe tile) {
|
||||
this.container = tile;
|
||||
}
|
||||
|
@ -74,10 +60,4 @@ public class PipeLogic implements IDropControlInventory {
|
|||
public boolean outputOpen(ForgeDirection to) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* IDROPCONTROLINVENTORY */
|
||||
@Override
|
||||
public boolean doDrop() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public License
|
||||
* 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
package buildcraft.transport.pipes;
|
||||
|
||||
import buildcraft.transport.Pipe;
|
||||
import buildcraft.transport.TileGenericPipe;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public class PipeLogicCobblestone extends PipeLogic {
|
||||
|
||||
@Override
|
||||
public boolean canPipeConnect(TileEntity tile, ForgeDirection side) {
|
||||
Pipe pipe2 = null;
|
||||
|
||||
if (tile instanceof TileGenericPipe) {
|
||||
pipe2 = ((TileGenericPipe) tile).pipe;
|
||||
}
|
||||
|
||||
if (pipe2 != null) {
|
||||
if (pipe2.logic instanceof PipeLogicStone) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (pipe2.logic instanceof PipeLogicQuartz) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return super.canPipeConnect(tile, side);
|
||||
}
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public License
|
||||
* 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
package buildcraft.transport.pipes;
|
||||
|
||||
import buildcraft.BuildCraftTransport;
|
||||
import buildcraft.core.GuiIds;
|
||||
import buildcraft.core.inventory.SimpleInventory;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
import buildcraft.transport.BlockGenericPipe;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class PipeLogicDiamond extends PipeLogic {
|
||||
|
||||
private SimpleInventory filters = new SimpleInventory(54, "Filters", 1);
|
||||
|
||||
/* PIPE LOGIC */
|
||||
@Override
|
||||
public boolean doDrop() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean blockActivated(EntityPlayer entityplayer) {
|
||||
if (entityplayer.getCurrentEquippedItem() != null && entityplayer.getCurrentEquippedItem().itemID < Block.blocksList.length)
|
||||
if (Block.blocksList[entityplayer.getCurrentEquippedItem().itemID] instanceof BlockGenericPipe)
|
||||
return false;
|
||||
|
||||
if (!CoreProxy.proxy.isRenderWorld(container.worldObj)) {
|
||||
entityplayer.openGui(BuildCraftTransport.instance, GuiIds.PIPE_DIAMOND, container.worldObj, container.xCoord, container.yCoord, container.zCoord);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* SAVING & LOADING */
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
super.readFromNBT(nbttagcompound);
|
||||
filters.readFromNBT(nbttagcompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
super.writeToNBT(nbttagcompound);
|
||||
filters.writeToNBT(nbttagcompound);
|
||||
}
|
||||
|
||||
public IInventory getFilters() {
|
||||
return filters;
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
package buildcraft.transport.pipes;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author CovertJaguar <railcraft.wikispaces.com>
|
||||
*/
|
||||
public class PipeLogicEmerald extends PipeLogicWood {
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
|
||||
package buildcraft.transport.pipes;
|
||||
|
||||
public class PipeLogicGold extends PipeLogic {
|
||||
|
||||
}
|
|
@ -24,7 +24,7 @@ public class PipeLogicIron extends PipeLogic {
|
|||
|
||||
boolean lastPower = false;
|
||||
|
||||
public void switchPower() {
|
||||
private void switchPower() {
|
||||
boolean currentPower = container.worldObj.isBlockIndirectlyGettingPowered(container.xCoord, container.yCoord, container.zCoord);
|
||||
|
||||
if (currentPower != lastPower) {
|
||||
|
@ -34,7 +34,7 @@ public class PipeLogicIron extends PipeLogic {
|
|||
}
|
||||
}
|
||||
|
||||
public void switchPosition() {
|
||||
private void switchPosition() {
|
||||
int metadata = container.worldObj.getBlockMetadata(container.xCoord, container.yCoord, container.zCoord);
|
||||
|
||||
int nextMetadata = metadata;
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
|
||||
package buildcraft.transport.pipes;
|
||||
|
||||
import buildcraft.transport.Pipe;
|
||||
import buildcraft.transport.TileGenericPipe;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public class PipeLogicObsidian extends PipeLogic {
|
||||
|
||||
@Override
|
||||
public boolean canPipeConnect(TileEntity tile, ForgeDirection side) {
|
||||
Pipe pipe2 = null;
|
||||
|
||||
if (tile instanceof TileGenericPipe) {
|
||||
pipe2 = ((TileGenericPipe) tile).pipe;
|
||||
}
|
||||
|
||||
return (pipe2 == null || (!(pipe2.logic instanceof PipeLogicObsidian) && !(pipe2.logic instanceof PipeLogicStripes))) && super.canPipeConnect(tile, side);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
|
||||
package buildcraft.transport.pipes;
|
||||
|
||||
import buildcraft.transport.Pipe;
|
||||
import buildcraft.transport.TileGenericPipe;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public class PipeLogicQuartz extends PipeLogic {
|
||||
|
||||
@Override
|
||||
public boolean canPipeConnect(TileEntity tile, ForgeDirection side) {
|
||||
Pipe pipe2 = null;
|
||||
|
||||
if (tile instanceof TileGenericPipe) {
|
||||
pipe2 = ((TileGenericPipe) tile).pipe;
|
||||
}
|
||||
|
||||
if (pipe2 != null) {
|
||||
if (pipe2.logic instanceof PipeLogicStone) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (pipe2.logic instanceof PipeLogicCobblestone) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return super.canPipeConnect(tile, side);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
|
||||
package buildcraft.transport.pipes;
|
||||
|
||||
import buildcraft.transport.TileGenericPipe;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public class PipeLogicSandstone extends PipeLogic {
|
||||
@Override
|
||||
public boolean canPipeConnect(TileEntity tile, ForgeDirection side) {
|
||||
return (tile instanceof TileGenericPipe) && super.canPipeConnect(tile, side);
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
|
||||
package buildcraft.transport.pipes;
|
||||
|
||||
import buildcraft.transport.Pipe;
|
||||
import buildcraft.transport.TileGenericPipe;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public class PipeLogicStone extends PipeLogic {
|
||||
|
||||
@Override
|
||||
public boolean canPipeConnect(TileEntity tile, ForgeDirection side) {
|
||||
Pipe pipe2 = null;
|
||||
|
||||
if (tile instanceof TileGenericPipe) {
|
||||
pipe2 = ((TileGenericPipe) tile).pipe;
|
||||
}
|
||||
|
||||
if (pipe2 != null) {
|
||||
if (pipe2.logic instanceof PipeLogicCobblestone) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (pipe2.logic instanceof PipeLogicQuartz) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return super.canPipeConnect(tile, side);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
|
||||
package buildcraft.transport.pipes;
|
||||
|
||||
import buildcraft.transport.Pipe;
|
||||
import buildcraft.transport.TileGenericPipe;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public class PipeLogicStripes extends PipeLogic {
|
||||
|
||||
@Override
|
||||
public boolean canPipeConnect(TileEntity tile, ForgeDirection side) {
|
||||
Pipe pipe2 = null;
|
||||
|
||||
if (tile instanceof TileGenericPipe) {
|
||||
pipe2 = ((TileGenericPipe) tile).pipe;
|
||||
}
|
||||
|
||||
return (pipe2 == null || !(pipe2.logic instanceof PipeLogicStripes) && !(pipe2.logic instanceof PipeLogicObsidian)) && super.canPipeConnect(tile, side);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
|
||||
package buildcraft.transport.pipes;
|
||||
|
||||
public class PipeLogicVoid extends PipeLogic {
|
||||
|
||||
}
|
|
@ -11,7 +11,6 @@ import buildcraft.api.tools.IToolWrench;
|
|||
import buildcraft.api.transport.PipeManager;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
import buildcraft.core.utils.Utils;
|
||||
import buildcraft.transport.Pipe;
|
||||
import buildcraft.transport.TileGenericPipe;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
@ -63,17 +62,6 @@ public class PipeLogicWood extends PipeLogic {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPipeConnect(TileEntity tile, ForgeDirection side) {
|
||||
Pipe pipe2 = null;
|
||||
|
||||
if (tile instanceof TileGenericPipe) {
|
||||
pipe2 = ((TileGenericPipe) tile).pipe;
|
||||
}
|
||||
|
||||
return (pipe2 == null || !(pipe2.logic instanceof PipeLogicWood)) && super.canPipeConnect(tile, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
super.initialize();
|
||||
|
|
|
@ -19,7 +19,7 @@ import net.minecraftforge.common.ForgeDirection;
|
|||
public class PipePowerCobblestone extends Pipe {
|
||||
|
||||
public PipePowerCobblestone(int itemID) {
|
||||
super(new PipeTransportPower(), new PipeLogicStone(), itemID);
|
||||
super(new PipeTransportPower(), new PipeLogic(), itemID);
|
||||
((PipeTransportPower) transport).initFromPipe(getClass());
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ import net.minecraftforge.common.ForgeDirection;
|
|||
public class PipePowerDiamond extends Pipe {
|
||||
|
||||
public PipePowerDiamond(int itemID) {
|
||||
super(new PipeTransportPower(), new PipeLogicGold(), itemID);
|
||||
super(new PipeTransportPower(), new PipeLogic(), itemID);
|
||||
((PipeTransportPower) transport).initFromPipe(getClass());
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ import net.minecraftforge.common.ForgeDirection;
|
|||
public class PipePowerGold extends Pipe {
|
||||
|
||||
public PipePowerGold(int itemID) {
|
||||
super(new PipeTransportPower(), new PipeLogicGold(), itemID);
|
||||
super(new PipeTransportPower(), new PipeLogic(), itemID);
|
||||
((PipeTransportPower) transport).initFromPipe(getClass());
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ import net.minecraftforge.common.ForgeDirection;
|
|||
public class PipePowerQuartz extends Pipe {
|
||||
|
||||
public PipePowerQuartz(int itemID) {
|
||||
super(new PipeTransportPower(), new PipeLogicStone(), itemID);
|
||||
super(new PipeTransportPower(), new PipeLogic(), itemID);
|
||||
((PipeTransportPower) transport).initFromPipe(getClass());
|
||||
}
|
||||
|
||||
|
|
|
@ -19,8 +19,8 @@ import net.minecraftforge.common.ForgeDirection;
|
|||
public class PipePowerStone extends Pipe {
|
||||
|
||||
public PipePowerStone(int itemID) {
|
||||
super(new PipeTransportPower(), new PipeLogicStone(), itemID);
|
||||
((PipeTransportPower) transport).initFromPipe(getClass());
|
||||
super(new PipeTransportPower(), new PipeLogic(), itemID);
|
||||
((PipeTransportPower) transport).initFromPipe(getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -12,15 +12,15 @@ import net.minecraftforge.common.ForgeDirection;
|
|||
public class PipeStructureCobblestone extends Pipe {
|
||||
|
||||
public PipeStructureCobblestone(int itemID) {
|
||||
super(new PipeTransportStructure(), new PipeLogicCobblestone(), itemID);
|
||||
super(new PipeTransportStructure(), new PipeLogic(), itemID);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIconProvider getIconProvider() {
|
||||
return BuildCraftTransport.instance.pipeIconProvider;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getIconIndex(ForgeDirection direction) {
|
||||
return PipeIconProvider.TYPE.PipeStructureCobblestone.ordinal();
|
||||
|
|
Loading…
Reference in a new issue