Merged EntityData and EntityPassiveItem
They have been replaced by TravelingItem. Which means yes, I broke the various pipe hooks again. Additionally IPipedItem and IEntityPassiveItemContribution have been deleted. Contributions were replaced by a simple NBTCompoundTag field in TravelingItem (which is essentially all that contributions were anyway).
This commit is contained in:
parent
d9636a7455
commit
d62148bb07
21 changed files with 495 additions and 815 deletions
|
@ -1,20 +0,0 @@
|
||||||
/**
|
|
||||||
* Copyright (c) SpaceToad, 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.api.transport;
|
|
||||||
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
|
|
||||||
public interface IPassiveItemContribution {
|
|
||||||
|
|
||||||
public void readFromNBT(NBTTagCompound nbttagcompound);
|
|
||||||
|
|
||||||
public void writeToNBT(NBTTagCompound nbttagcompound);
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,51 +0,0 @@
|
||||||
package buildcraft.transport;
|
|
||||||
|
|
||||||
import buildcraft.core.utils.EnumColor;
|
|
||||||
import java.util.EnumSet;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
|
||||||
|
|
||||||
public class EntityData {
|
|
||||||
|
|
||||||
// TODO: Move passive data here too, like position, speed and all?
|
|
||||||
// TODO: Create an object pool?
|
|
||||||
public boolean toCenter = true;
|
|
||||||
public final IPipedItem item;
|
|
||||||
public EnumColor color;
|
|
||||||
public ForgeDirection input = ForgeDirection.UNKNOWN;
|
|
||||||
public ForgeDirection output = ForgeDirection.UNKNOWN;
|
|
||||||
public EnumSet<ForgeDirection> blacklist = EnumSet.noneOf(ForgeDirection.class);
|
|
||||||
|
|
||||||
public EntityData(IPipedItem item, ForgeDirection orientation) {
|
|
||||||
this.item = item;
|
|
||||||
this.input = orientation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EntityData(IPipedItem item) {
|
|
||||||
this.item = item;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void reset() {
|
|
||||||
toCenter = true;
|
|
||||||
blacklist.clear();
|
|
||||||
output = ForgeDirection.UNKNOWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void writeToNBT(NBTTagCompound data) {
|
|
||||||
data.setBoolean("toCenter", toCenter);
|
|
||||||
data.setInteger("input", input.ordinal());
|
|
||||||
data.setInteger("output", output.ordinal());
|
|
||||||
|
|
||||||
data.setByte("color", color != null ? (byte) color.ordinal() : -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void readFromNBT(NBTTagCompound data) {
|
|
||||||
toCenter = data.getBoolean("toCenter");
|
|
||||||
input = ForgeDirection.getOrientation(data.getInteger("input"));
|
|
||||||
output = ForgeDirection.getOrientation(data.getInteger("output"));
|
|
||||||
|
|
||||||
byte c = data.getByte("color");
|
|
||||||
if (c != -1)
|
|
||||||
color = EnumColor.fromId(c);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,366 +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;
|
|
||||||
|
|
||||||
import buildcraft.BuildCraftCore;
|
|
||||||
import buildcraft.api.core.Position;
|
|
||||||
import buildcraft.api.transport.IPassiveItemContribution;
|
|
||||||
import buildcraft.core.proxy.CoreProxy;
|
|
||||||
import java.util.TreeMap;
|
|
||||||
import net.minecraft.entity.item.EntityItem;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraft.nbt.NBTTagList;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.util.MathHelper;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
|
||||||
|
|
||||||
public class EntityPassiveItem implements IPipedItem {
|
|
||||||
|
|
||||||
private TreeMap<String, IPassiveItemContribution> contributions = new TreeMap<String, IPassiveItemContribution>();
|
|
||||||
protected static int maxId = 0;
|
|
||||||
protected World worldObj;
|
|
||||||
|
|
||||||
protected float speed = 0.01F;
|
|
||||||
protected ItemStack item;
|
|
||||||
|
|
||||||
protected TileEntity container;
|
|
||||||
|
|
||||||
protected Position position;
|
|
||||||
protected int entityId;
|
|
||||||
|
|
||||||
/* CONSTRUCTORS */
|
|
||||||
public EntityPassiveItem(World world) {
|
|
||||||
this(world, maxId < Short.MAX_VALUE ? ++maxId : (maxId = Short.MIN_VALUE));
|
|
||||||
}
|
|
||||||
|
|
||||||
public EntityPassiveItem(World world, int id) {
|
|
||||||
setEntityId(id);
|
|
||||||
// PipeManager.getAllEntities().put(getEntityId(), this);
|
|
||||||
worldObj = world;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EntityPassiveItem(World world, double d, double d1, double d2) {
|
|
||||||
this(world);
|
|
||||||
position = new Position(d, d1, d2);
|
|
||||||
worldObj = world;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EntityPassiveItem(World world, double d, double d1, double d2, ItemStack itemstack) {
|
|
||||||
this(world, d, d1, d2);
|
|
||||||
this.setItemStack(itemstack.copy());
|
|
||||||
}
|
|
||||||
|
|
||||||
/* CREATING & CACHING */
|
|
||||||
public static IPipedItem getOrCreate(World world, int id) {
|
|
||||||
// if (PipeManager.getAllEntities().containsKey(id)) {
|
|
||||||
// return PipeManager.getAllEntities().get(id);
|
|
||||||
// } else {
|
|
||||||
return new EntityPassiveItem(world, id);
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see net.minecraft.src.buildcraft.api.IPipedItem#remove()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void remove() {
|
|
||||||
// if (PipeManager.getAllEntities().containsKey(getEntityId())) {
|
|
||||||
// PipeManager.getAllEntities().remove(getEntityId());
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
/* GETTING & SETTING */
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see net.minecraft.src.buildcraft.api.IPipedItem#setWorld(net.minecraft.src.World)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void setWorld(World world) {
|
|
||||||
worldObj = world;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see net.minecraft.src.buildcraft.api.IPipedItem#getPosition()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Position getPosition() {
|
|
||||||
return position;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see net.minecraft.src.buildcraft.api.IPipedItem#setPosition(double, double, double)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void setPosition(double x, double y, double z) {
|
|
||||||
position = new Position(x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see net.minecraft.src.buildcraft.api.IPipedItem#getSpeed()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public float getSpeed() {
|
|
||||||
return speed;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see net.minecraft.src.buildcraft.api.IPipedItem#setSpeed(float)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void setSpeed(float speed) {
|
|
||||||
this.speed = speed;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see net.minecraft.src.buildcraft.api.IPipedItem#getItemStack()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ItemStack getItemStack() {
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see net.minecraft.src.buildcraft.api.IPipedItem#setItemStack(net.minecraft.src.ItemStack)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void setItemStack(ItemStack item) {
|
|
||||||
this.item = item;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see net.minecraft.src.buildcraft.api.IPipedItem#getContainer()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public TileEntity getContainer() {
|
|
||||||
return container;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see net.minecraft.src.buildcraft.api.IPipedItem#setContainer(net.minecraft.src.TileEntity)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void setContainer(TileEntity container) {
|
|
||||||
this.container = container;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see net.minecraft.src.buildcraft.api.IPipedItem#getEntityId()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int getEntityId() {
|
|
||||||
return entityId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see net.minecraft.src.buildcraft.api.IPipedItem#setEntityId(int)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void setEntityId(int entityId) {
|
|
||||||
this.entityId = entityId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* SAVING & LOADING */
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see net.minecraft.src.buildcraft.api.IPipedItem#readFromNBT(net.minecraft.src.NBTTagCompound)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
|
||||||
setPosition(nbttagcompound.getDouble("x"), nbttagcompound.getDouble("y"), nbttagcompound.getDouble("z"));
|
|
||||||
|
|
||||||
setSpeed(nbttagcompound.getFloat("speed"));
|
|
||||||
setItemStack(ItemStack.loadItemStackFromNBT(nbttagcompound.getCompoundTag("Item")));
|
|
||||||
|
|
||||||
NBTTagList contribList = nbttagcompound.getTagList("contribList");
|
|
||||||
|
|
||||||
for (int i = 0; i < contribList.tagCount(); ++i) {
|
|
||||||
NBTTagCompound cpt = (NBTTagCompound) contribList.tagAt(i);
|
|
||||||
String key = cpt.getString("key");
|
|
||||||
|
|
||||||
String className = cpt.getString("class");
|
|
||||||
|
|
||||||
if (getClass().getName().startsWith("net.minecraft.src")) {
|
|
||||||
className = "net.minecraft.src." + className;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
IPassiveItemContribution contrib = ((IPassiveItemContribution) Class.forName(className).newInstance());
|
|
||||||
|
|
||||||
contrib.readFromNBT(cpt);
|
|
||||||
|
|
||||||
contributions.put(key, contrib);
|
|
||||||
} catch (InstantiationException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (ClassNotFoundException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see net.minecraft.src.buildcraft.api.IPipedItem#writeToNBT(net.minecraft.src.NBTTagCompound)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
|
||||||
nbttagcompound.setDouble("x", position.x);
|
|
||||||
nbttagcompound.setDouble("y", position.y);
|
|
||||||
nbttagcompound.setDouble("z", position.z);
|
|
||||||
nbttagcompound.setFloat("speed", getSpeed());
|
|
||||||
NBTTagCompound nbttagcompound2 = new NBTTagCompound();
|
|
||||||
getItemStack().writeToNBT(nbttagcompound2);
|
|
||||||
nbttagcompound.setCompoundTag("Item", nbttagcompound2);
|
|
||||||
|
|
||||||
NBTTagList contribList = new NBTTagList();
|
|
||||||
|
|
||||||
for (String key : contributions.keySet()) {
|
|
||||||
IPassiveItemContribution contrib = contributions.get(key);
|
|
||||||
NBTTagCompound cpt = new NBTTagCompound();
|
|
||||||
|
|
||||||
contrib.writeToNBT(cpt);
|
|
||||||
cpt.setString("key", key);
|
|
||||||
|
|
||||||
String className = contrib.getClass().getName();
|
|
||||||
|
|
||||||
if (className.startsWith("net.minecraft.src.")) {
|
|
||||||
className = className.replace("net.minecraft.src.", "");
|
|
||||||
}
|
|
||||||
|
|
||||||
cpt.setString("class", className);
|
|
||||||
contribList.appendTag(cpt);
|
|
||||||
}
|
|
||||||
|
|
||||||
nbttagcompound.setTag("contribList", contribList);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see net.minecraft.src.buildcraft.api.IPipedItem#toEntityItem(net.minecraft.src.buildcraft.api.Orientations)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public EntityItem toEntityItem(ForgeDirection dir) {
|
|
||||||
if (!CoreProxy.proxy.isRenderWorld(worldObj)) {
|
|
||||||
if (getItemStack().stackSize <= 0)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
Position motion = new Position(0, 0, 0, dir);
|
|
||||||
motion.moveForwards(0.1 + getSpeed() * 2F);
|
|
||||||
|
|
||||||
EntityItem entityitem = new EntityItem(worldObj, position.x, position.y, position.z, getItemStack());
|
|
||||||
|
|
||||||
entityitem.lifespan = BuildCraftCore.itemLifespan;
|
|
||||||
entityitem.delayBeforeCanPickup = 10;
|
|
||||||
|
|
||||||
float f3 = 0.00F + worldObj.rand.nextFloat() * 0.04F - 0.02F;
|
|
||||||
entityitem.motionX = (float) worldObj.rand.nextGaussian() * f3 + motion.x;
|
|
||||||
entityitem.motionY = (float) worldObj.rand.nextGaussian() * f3 + motion.y;
|
|
||||||
entityitem.motionZ = (float) worldObj.rand.nextGaussian() * f3 + +motion.z;
|
|
||||||
worldObj.spawnEntityInWorld(entityitem);
|
|
||||||
remove();
|
|
||||||
|
|
||||||
return entityitem;
|
|
||||||
} else
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see net.minecraft.src.buildcraft.api.IPipedItem#getEntityBrightness(float)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public float getEntityBrightness(float f) {
|
|
||||||
int i = MathHelper.floor_double(position.x);
|
|
||||||
int j = MathHelper.floor_double(position.z);
|
|
||||||
worldObj.getClass();
|
|
||||||
if (worldObj.blockExists(i, 128 / 2, j)) {
|
|
||||||
double d = 0.66000000000000003D;
|
|
||||||
int k = MathHelper.floor_double(position.y + d);
|
|
||||||
return worldObj.getLightBrightness(i, k, j);
|
|
||||||
} else
|
|
||||||
return 0.0F;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see net.minecraft.src.buildcraft.api.IPipedItem#isCorrupted()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean isCorrupted() {
|
|
||||||
return getItemStack() == null || getItemStack().stackSize <= 0 || Item.itemsList[getItemStack().itemID] == null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see net.minecraft.src.buildcraft.api.IPipedItem#addContribution(java.lang.String, net.minecraft.src.buildcraft.api.IPassiveItemContribution)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void addContribution(String key, IPassiveItemContribution contribution) {
|
|
||||||
contributions.put(key, contribution);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see net.minecraft.src.buildcraft.api.IPipedItem#getContribution(java.lang.String)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public IPassiveItemContribution getContribution(String key) {
|
|
||||||
return contributions.get(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see net.minecraft.src.buildcraft.api.IPipedItem#hasContributions()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean hasContributions() {
|
|
||||||
return contributions.size() > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canSinkTo(TileEntity entity) {
|
|
||||||
return true; // a passive item can sink anywhere
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -4,10 +4,10 @@ import net.minecraft.tileentity.TileEntity;
|
||||||
|
|
||||||
public interface IItemTravelingHook {
|
public interface IItemTravelingHook {
|
||||||
|
|
||||||
public void drop(PipeTransportItems transport, EntityData data);
|
public void drop(PipeTransportItems transport, TravelingItem item);
|
||||||
|
|
||||||
public void centerReached(PipeTransportItems transport, EntityData data);
|
public void centerReached(PipeTransportItems transport, TravelingItem item);
|
||||||
|
|
||||||
public void endReached(PipeTransportItems transport, EntityData data, TileEntity tile);
|
public void endReached(PipeTransportItems transport, TravelingItem item, TileEntity tile);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,9 +15,9 @@ import net.minecraftforge.common.ForgeDirection;
|
||||||
|
|
||||||
public interface IPipeTransportItemsHook {
|
public interface IPipeTransportItemsHook {
|
||||||
|
|
||||||
public LinkedList<ForgeDirection> filterPossibleMovements(LinkedList<ForgeDirection> possibleOrientations, Position pos, EntityData data);
|
public LinkedList<ForgeDirection> filterPossibleMovements(LinkedList<ForgeDirection> possibleOrientations, Position pos, TravelingItem item);
|
||||||
|
|
||||||
public void entityEntered(IPipedItem item, ForgeDirection orientation);
|
public void entityEntered(TravelingItem item, ForgeDirection orientation);
|
||||||
|
|
||||||
public void readjustSpeed(IPipedItem item);
|
public void readjustSpeed(TravelingItem item);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,91 +0,0 @@
|
||||||
package buildcraft.transport;
|
|
||||||
|
|
||||||
import buildcraft.api.core.Position;
|
|
||||||
import buildcraft.api.transport.IPassiveItemContribution;
|
|
||||||
import net.minecraft.entity.item.EntityItem;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
|
||||||
|
|
||||||
public interface IPipedItem {
|
|
||||||
|
|
||||||
public abstract void remove();
|
|
||||||
|
|
||||||
/* GETTING & SETTING */
|
|
||||||
public abstract void setWorld(World world);
|
|
||||||
|
|
||||||
public abstract Position getPosition();
|
|
||||||
|
|
||||||
public abstract void setPosition(double x, double y, double z);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the speed
|
|
||||||
*/
|
|
||||||
public abstract float getSpeed();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param speed
|
|
||||||
* the speed to set
|
|
||||||
*/
|
|
||||||
public abstract void setSpeed(float speed);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the item
|
|
||||||
*/
|
|
||||||
public abstract ItemStack getItemStack();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param item
|
|
||||||
* the item to set
|
|
||||||
*/
|
|
||||||
public abstract void setItemStack(ItemStack item);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the container
|
|
||||||
*/
|
|
||||||
public abstract TileEntity getContainer();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param container
|
|
||||||
* the container to set
|
|
||||||
*/
|
|
||||||
public abstract void setContainer(TileEntity container);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the entityId
|
|
||||||
*/
|
|
||||||
public abstract int getEntityId();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param entityId
|
|
||||||
* the entityId to set
|
|
||||||
*/
|
|
||||||
public abstract void setEntityId(int entityId);
|
|
||||||
|
|
||||||
/* SAVING & LOADING */
|
|
||||||
public abstract void readFromNBT(NBTTagCompound nbttagcompound);
|
|
||||||
|
|
||||||
public abstract void writeToNBT(NBTTagCompound nbttagcompound);
|
|
||||||
|
|
||||||
public abstract EntityItem toEntityItem(ForgeDirection dir);
|
|
||||||
|
|
||||||
public abstract float getEntityBrightness(float f);
|
|
||||||
|
|
||||||
public abstract boolean isCorrupted();
|
|
||||||
|
|
||||||
public abstract void addContribution(String key, IPassiveItemContribution contribution);
|
|
||||||
|
|
||||||
public abstract IPassiveItemContribution getContribution(String key);
|
|
||||||
|
|
||||||
public abstract boolean hasContributions();
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the can this item be moved into this specific entity type.
|
|
||||||
* (basic BuildCraft PipedItems always return true)
|
|
||||||
*/
|
|
||||||
public abstract boolean canSinkTo(TileEntity entity);
|
|
||||||
|
|
||||||
}
|
|
|
@ -23,16 +23,18 @@ import buildcraft.core.utils.Utils;
|
||||||
import buildcraft.transport.network.PacketPipeTransportContent;
|
import buildcraft.transport.network.PacketPipeTransportContent;
|
||||||
import buildcraft.transport.network.PacketPipeTransportNBT;
|
import buildcraft.transport.network.PacketPipeTransportNBT;
|
||||||
import buildcraft.transport.network.PacketSimpleId;
|
import buildcraft.transport.network.PacketSimpleId;
|
||||||
|
import com.google.common.collect.BiMap;
|
||||||
|
import com.google.common.collect.ForwardingSet;
|
||||||
|
import com.google.common.collect.HashBiMap;
|
||||||
import cpw.mods.fml.common.network.PacketDispatcher;
|
import cpw.mods.fml.common.network.PacketDispatcher;
|
||||||
import cpw.mods.fml.common.network.Player;
|
import cpw.mods.fml.common.network.Player;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.entity.item.EntityItem;
|
||||||
|
@ -50,18 +52,78 @@ public class PipeTransportItems extends PipeTransport {
|
||||||
public static final int MAX_PIPE_STACKS = 64;
|
public static final int MAX_PIPE_STACKS = 64;
|
||||||
public static final int MAX_PIPE_ITEMS = 1024;
|
public static final int MAX_PIPE_ITEMS = 1024;
|
||||||
public boolean allowBouncing = false;
|
public boolean allowBouncing = false;
|
||||||
public Map<Integer, EntityData> travelingEntities = new HashMap<Integer, EntityData>();
|
|
||||||
private final List<EntityData> entitiesToLoad = new LinkedList<EntityData>();
|
|
||||||
private int delay = 0;
|
|
||||||
// TODO: generalize the use of this hook in particular for obsidian pipe
|
// TODO: generalize the use of this hook in particular for obsidian pipe
|
||||||
public IItemTravelingHook travelHook;
|
public IItemTravelingHook travelHook;
|
||||||
|
public final TravelerSet items = new TravelerSet();
|
||||||
|
|
||||||
|
public class TravelerSet extends ForwardingSet<TravelingItem> {
|
||||||
|
|
||||||
|
private final BiMap<Integer, TravelingItem> delegate = HashBiMap.create();
|
||||||
|
private final Set<TravelingItem> toLoad = new HashSet<TravelingItem>();
|
||||||
|
private final Set<TravelingItem> toRemove = new HashSet<TravelingItem>();
|
||||||
|
private int delay = 0;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Set<TravelingItem> delegate() {
|
||||||
|
return delegate.values();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean add(TravelingItem item) {
|
||||||
|
if (delegate.containsValue(item))
|
||||||
|
return false;
|
||||||
|
item.setContainer(container);
|
||||||
|
delegate.put(item.id, item);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean addAll(Collection<? extends TravelingItem> collection) {
|
||||||
|
boolean changed = false;
|
||||||
|
for (TravelingItem item : collection) {
|
||||||
|
changed |= add(item);
|
||||||
|
}
|
||||||
|
return changed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TravelingItem get(int id) {
|
||||||
|
return delegate.get(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void scheduleLoad(TravelingItem item) {
|
||||||
|
delay = 2;
|
||||||
|
toLoad.add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void performLoad() {
|
||||||
|
if (delay > 0) {
|
||||||
|
delay--;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
addAll(toLoad);
|
||||||
|
toLoad.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean scheduleRemoval(TravelingItem item) {
|
||||||
|
return toRemove.add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean unscheduleRemoval(TravelingItem item) {
|
||||||
|
return toRemove.remove(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void performRemoval() {
|
||||||
|
removeAll(toRemove);
|
||||||
|
toRemove.clear();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PipeType getPipeType() {
|
public PipeType getPipeType() {
|
||||||
return PipeType.ITEM;
|
return PipeType.ITEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readjustSpeed(IPipedItem item) {
|
public void readjustSpeed(TravelingItem item) {
|
||||||
if (container.pipe instanceof IPipeTransportItemsHook) {
|
if (container.pipe instanceof IPipeTransportItemsHook) {
|
||||||
((IPipeTransportItemsHook) container.pipe).readjustSpeed(item);
|
((IPipeTransportItemsHook) container.pipe).readjustSpeed(item);
|
||||||
} else {
|
} else {
|
||||||
|
@ -69,7 +131,7 @@ public class PipeTransportItems extends PipeTransport {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void defaultReajustSpeed(IPipedItem item) {
|
public void defaultReajustSpeed(TravelingItem item) {
|
||||||
float speed = item.getSpeed();
|
float speed = item.getSpeed();
|
||||||
|
|
||||||
if (speed > Utils.pipeNormalSpeed) {
|
if (speed > Utils.pipeNormalSpeed) {
|
||||||
|
@ -83,66 +145,49 @@ public class PipeTransportItems extends PipeTransport {
|
||||||
item.setSpeed(speed);
|
item.setSpeed(speed);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void entityEntering(IPipedItem item, ForgeDirection inputOrientation) {
|
public void injectItem(TravelingItem item, ForgeDirection inputOrientation) {
|
||||||
EntityData data = travelingEntities.get(item.getEntityId());
|
if (item.isCorrupted())
|
||||||
|
|
||||||
if (data == null) {
|
|
||||||
data = new EntityData(item, inputOrientation);
|
|
||||||
}
|
|
||||||
entityEntering(data, inputOrientation);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void entityEntering(EntityData data, ForgeDirection inputOrientation) {
|
|
||||||
if (data.item.isCorrupted())
|
|
||||||
// Safe guard - if for any reason the item is corrupted at this
|
// Safe guard - if for any reason the item is corrupted at this
|
||||||
// stage, avoid adding it to the pipe to avoid further exceptions.
|
// stage, avoid adding it to the pipe to avoid further exceptions.
|
||||||
return;
|
return;
|
||||||
|
|
||||||
data.reset();
|
item.reset();
|
||||||
data.input = inputOrientation;
|
item.input = inputOrientation;
|
||||||
|
|
||||||
EntityData existingData = travelingEntities.get(data.item.getEntityId());
|
items.add(item);
|
||||||
|
|
||||||
if (existingData == null) {
|
readjustSpeed(item);
|
||||||
travelingEntities.put(data.item.getEntityId(), data);
|
|
||||||
} else {
|
|
||||||
data = existingData;
|
|
||||||
}
|
|
||||||
|
|
||||||
data.item.setContainer(container);
|
|
||||||
|
|
||||||
readjustSpeed(data.item);
|
|
||||||
|
|
||||||
// Reajusting Ypos to make sure the object looks like sitting on the
|
// Reajusting Ypos to make sure the object looks like sitting on the
|
||||||
// pipe.
|
// pipe.
|
||||||
if (inputOrientation != ForgeDirection.UP && inputOrientation != ForgeDirection.DOWN) {
|
if (inputOrientation != ForgeDirection.UP && inputOrientation != ForgeDirection.DOWN) {
|
||||||
data.item.setPosition(data.item.getPosition().x, container.yCoord + Utils.getPipeFloorOf(data.item.getItemStack()), data.item.getPosition().z);
|
item.setPosition(item.getPosition().x, container.yCoord + Utils.getPipeFloorOf(item.getItemStack()), item.getPosition().z);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!container.worldObj.isRemote) {
|
if (!container.worldObj.isRemote) {
|
||||||
data.output = resolveDestination(data);
|
item.output = resolveDestination(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (container.pipe instanceof IPipeTransportItemsHook) {
|
if (container.pipe instanceof IPipeTransportItemsHook) {
|
||||||
((IPipeTransportItemsHook) container.pipe).entityEntered(data.item, inputOrientation);
|
((IPipeTransportItemsHook) container.pipe).entityEntered(item, inputOrientation);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!container.worldObj.isRemote) {
|
if (!container.worldObj.isRemote) {
|
||||||
sendItemPacket(data);
|
sendItemPacket(item);
|
||||||
|
|
||||||
if (travelingEntities.size() > BuildCraftTransport.groupItemsTrigger) {
|
if (items.size() > BuildCraftTransport.groupItemsTrigger) {
|
||||||
groupEntities();
|
groupEntities();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (travelingEntities.size() > MAX_PIPE_STACKS) {
|
if (items.size() > MAX_PIPE_STACKS) {
|
||||||
BuildCraftCore.bcLog.log(Level.WARNING, String.format("Pipe exploded at %d,%d,%d because it had too many stacks: %d", container.xCoord, container.yCoord, container.zCoord, travelingEntities.size()));
|
BuildCraftCore.bcLog.log(Level.WARNING, String.format("Pipe exploded at %d,%d,%d because it had too many stacks: %d", container.xCoord, container.yCoord, container.zCoord, items.size()));
|
||||||
destroyPipe();
|
destroyPipe();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int numItems = 0;
|
int numItems = 0;
|
||||||
for (EntityData ed : travelingEntities.values()) {
|
for (TravelingItem travellingItem : items) {
|
||||||
ItemStack stack = ed.item.getItemStack();
|
ItemStack stack = travellingItem.getItemStack();
|
||||||
if (stack != null && stack.stackSize > 0)
|
if (stack != null && stack.stackSize > 0)
|
||||||
numItems += stack.stackSize;
|
numItems += stack.stackSize;
|
||||||
}
|
}
|
||||||
|
@ -150,7 +195,6 @@ public class PipeTransportItems extends PipeTransport {
|
||||||
if (numItems > MAX_PIPE_ITEMS) {
|
if (numItems > MAX_PIPE_ITEMS) {
|
||||||
BuildCraftCore.bcLog.log(Level.WARNING, String.format("Pipe exploded at %d,%d,%d because it had too many items: %d", container.xCoord, container.yCoord, container.zCoord, numItems));
|
BuildCraftCore.bcLog.log(Level.WARNING, String.format("Pipe exploded at %d,%d,%d because it had too many items: %d", container.xCoord, container.yCoord, container.zCoord, numItems));
|
||||||
destroyPipe();
|
destroyPipe();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -161,44 +205,43 @@ public class PipeTransportItems extends PipeTransport {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bounces the item back into the pipe without changing the
|
* Bounces the item back into the pipe without changing the items map.
|
||||||
* travelingEntities map.
|
|
||||||
*
|
*
|
||||||
* @param data
|
* @param item
|
||||||
*/
|
*/
|
||||||
protected void reverseItem(EntityData data) {
|
protected void reverseItem(TravelingItem item) {
|
||||||
if (data.item.isCorrupted())
|
if (item.isCorrupted())
|
||||||
// Safe guard - if for any reason the item is corrupted at this
|
// Safe guard - if for any reason the item is corrupted at this
|
||||||
// stage, avoid adding it to the pipe to avoid further exceptions.
|
// stage, avoid adding it to the pipe to avoid further exceptions.
|
||||||
return;
|
return;
|
||||||
|
|
||||||
unscheduleRemoval(data.item);
|
items.unscheduleRemoval(item);
|
||||||
|
|
||||||
data.toCenter = true;
|
item.toCenter = true;
|
||||||
data.input = data.output.getOpposite();
|
item.input = item.output.getOpposite();
|
||||||
|
|
||||||
readjustSpeed(data.item);
|
readjustSpeed(item);
|
||||||
|
|
||||||
// Reajusting Ypos to make sure the object looks like sitting on the
|
// Reajusting Ypos to make sure the object looks like sitting on the
|
||||||
// pipe.
|
// pipe.
|
||||||
if (data.input != ForgeDirection.UP && data.input != ForgeDirection.DOWN) {
|
if (item.input != ForgeDirection.UP && item.input != ForgeDirection.DOWN) {
|
||||||
data.item.setPosition(data.item.getPosition().x, container.yCoord + Utils.getPipeFloorOf(data.item.getItemStack()), data.item.getPosition().z);
|
item.setPosition(item.getPosition().x, container.yCoord + Utils.getPipeFloorOf(item.getItemStack()), item.getPosition().z);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!container.worldObj.isRemote) {
|
if (!container.worldObj.isRemote) {
|
||||||
data.output = resolveDestination(data);
|
item.output = resolveDestination(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (container.pipe instanceof IPipeTransportItemsHook) {
|
if (container.pipe instanceof IPipeTransportItemsHook) {
|
||||||
((IPipeTransportItemsHook) container.pipe).entityEntered(data.item, data.input);
|
((IPipeTransportItemsHook) container.pipe).entityEntered(item, item.input);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!container.worldObj.isRemote) {
|
if (!container.worldObj.isRemote) {
|
||||||
sendItemPacket(data);
|
sendItemPacket(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ForgeDirection resolveDestination(EntityData data) {
|
public ForgeDirection resolveDestination(TravelingItem data) {
|
||||||
LinkedList<ForgeDirection> listOfPossibleMovements = getPossibleMovements(data);
|
LinkedList<ForgeDirection> listOfPossibleMovements = getPossibleMovements(data);
|
||||||
|
|
||||||
if (listOfPossibleMovements.size() == 0)
|
if (listOfPossibleMovements.size() == 0)
|
||||||
|
@ -213,33 +256,33 @@ public class PipeTransportItems extends PipeTransport {
|
||||||
* Returns a list of all possible movements, that is to say adjacent
|
* Returns a list of all possible movements, that is to say adjacent
|
||||||
* implementers of IPipeEntry or TileEntityChest.
|
* implementers of IPipeEntry or TileEntityChest.
|
||||||
*/
|
*/
|
||||||
public LinkedList<ForgeDirection> getPossibleMovements(EntityData data) {
|
public LinkedList<ForgeDirection> getPossibleMovements(TravelingItem item) {
|
||||||
LinkedList<ForgeDirection> result = new LinkedList<ForgeDirection>();
|
LinkedList<ForgeDirection> result = new LinkedList<ForgeDirection>();
|
||||||
|
|
||||||
data.blacklist.add(data.input.getOpposite());
|
item.blacklist.add(item.input.getOpposite());
|
||||||
|
|
||||||
for (ForgeDirection o : ForgeDirection.VALID_DIRECTIONS) {
|
for (ForgeDirection o : ForgeDirection.VALID_DIRECTIONS) {
|
||||||
if (!data.blacklist.contains(o) && container.pipe.outputOpen(o))
|
if (!item.blacklist.contains(o) && container.pipe.outputOpen(o))
|
||||||
if (canReceivePipeObjects(o, data.item)) {
|
if (canReceivePipeObjects(o, item)) {
|
||||||
result.add(o);
|
result.add(o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.size() == 0 && allowBouncing) {
|
if (result.size() == 0 && allowBouncing) {
|
||||||
if (canReceivePipeObjects(data.input.getOpposite(), data.item)) {
|
if (canReceivePipeObjects(item.input.getOpposite(), item)) {
|
||||||
result.add(data.input.getOpposite());
|
result.add(item.input.getOpposite());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.container.pipe instanceof IPipeTransportItemsHook) {
|
if (this.container.pipe instanceof IPipeTransportItemsHook) {
|
||||||
Position pos = new Position(container.xCoord, container.yCoord, container.zCoord, data.input);
|
Position pos = new Position(container.xCoord, container.yCoord, container.zCoord, item.input);
|
||||||
result = ((IPipeTransportItemsHook) this.container.pipe).filterPossibleMovements(result, pos, data);
|
result = ((IPipeTransportItemsHook) this.container.pipe).filterPossibleMovements(result, pos, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canReceivePipeObjects(ForgeDirection o, IPipedItem item) {
|
public boolean canReceivePipeObjects(ForgeDirection o, TravelingItem item) {
|
||||||
TileEntity entity = container.getTile(o);
|
TileEntity entity = container.getTile(o);
|
||||||
|
|
||||||
if (!Utils.checkPipesConnections(entity, container))
|
if (!Utils.checkPipesConnections(entity, container))
|
||||||
|
@ -260,130 +303,103 @@ public class PipeTransportItems extends PipeTransport {
|
||||||
public void updateEntity() {
|
public void updateEntity() {
|
||||||
moveSolids();
|
moveSolids();
|
||||||
}
|
}
|
||||||
Set<Integer> toRemove = new HashSet<Integer>();
|
|
||||||
|
|
||||||
public void scheduleRemoval(IPipedItem item) {
|
|
||||||
toRemove.add(item.getEntityId());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void unscheduleRemoval(IPipedItem item) {
|
|
||||||
toRemove.remove(item.getEntityId());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void performRemoval() {
|
|
||||||
travelingEntities.keySet().removeAll(toRemove);
|
|
||||||
toRemove.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void moveSolids() {
|
private void moveSolids() {
|
||||||
if (delay > 0) {
|
items.performLoad();
|
||||||
delay--;
|
items.performRemoval();
|
||||||
} else if (!entitiesToLoad.isEmpty()) {
|
|
||||||
for (EntityData data : entitiesToLoad) {
|
|
||||||
data.item.setWorld(container.worldObj);
|
|
||||||
data.item.setContainer(container);
|
|
||||||
travelingEntities.put(data.item.getEntityId(), data);
|
|
||||||
}
|
|
||||||
entitiesToLoad.clear();
|
|
||||||
}
|
|
||||||
performRemoval();
|
|
||||||
|
|
||||||
for (EntityData data : travelingEntities.values()) {
|
for (TravelingItem item : items) {
|
||||||
if (data.item.isCorrupted()) {
|
if (item.isCorrupted()) {
|
||||||
scheduleRemoval(data.item);
|
items.scheduleRemoval(item);
|
||||||
data.item.remove();
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.item.getContainer() != this.container) {
|
if (item.getContainer() != this.container) {
|
||||||
scheduleRemoval(data.item);
|
items.scheduleRemoval(item);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Position motion = new Position(0, 0, 0, data.toCenter ? data.input : data.output);
|
Position motion = new Position(0, 0, 0, item.toCenter ? item.input : item.output);
|
||||||
motion.moveForwards(data.item.getSpeed());
|
motion.moveForwards(item.getSpeed());
|
||||||
|
|
||||||
Position pos = data.item.getPosition();
|
Position pos = item.getPosition();
|
||||||
data.item.setPosition(pos.x + motion.x, pos.y + motion.y, pos.z + motion.z);
|
item.setPosition(pos.x + motion.x, pos.y + motion.y, pos.z + motion.z);
|
||||||
pos = data.item.getPosition();
|
pos = item.getPosition();
|
||||||
|
|
||||||
if ((data.toCenter && middleReached(data, pos)) || outOfBounds(pos)) {
|
if ((item.toCenter && middleReached(item, pos)) || outOfBounds(pos)) {
|
||||||
data.toCenter = false;
|
item.toCenter = false;
|
||||||
|
|
||||||
// Reajusting to the middle
|
// Reajusting to the middle
|
||||||
data.item.setPosition(container.xCoord + 0.5, container.yCoord + Utils.getPipeFloorOf(data.item.getItemStack()), container.zCoord + 0.5);
|
item.setPosition(container.xCoord + 0.5, container.yCoord + Utils.getPipeFloorOf(item.getItemStack()), container.zCoord + 0.5);
|
||||||
|
|
||||||
if (data.output == ForgeDirection.UNKNOWN) {
|
if (item.output == ForgeDirection.UNKNOWN) {
|
||||||
if (travelHook != null) {
|
if (travelHook != null) {
|
||||||
travelHook.drop(this, data);
|
travelHook.drop(this, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityItem dropped = null;
|
EntityItem dropped = null;
|
||||||
|
|
||||||
if (!toRemove.contains(data.item.getEntityId())) {
|
if (items.scheduleRemoval(item)) {
|
||||||
dropped = data.item.toEntityItem(data.input);
|
dropped = item.toEntityItem(item.input);
|
||||||
}
|
}
|
||||||
|
|
||||||
scheduleRemoval(data.item);
|
|
||||||
|
|
||||||
if (dropped != null) {
|
if (dropped != null) {
|
||||||
onDropped(dropped);
|
onDropped(dropped);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (travelHook != null) {
|
if (travelHook != null) {
|
||||||
travelHook.centerReached(this, data);
|
travelHook.centerReached(this, item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (!data.toCenter && endReached(pos)) {
|
} else if (!item.toCenter && endReached(pos)) {
|
||||||
TileEntity tile = container.getTile(data.output);
|
TileEntity tile = container.getTile(item.output);
|
||||||
|
|
||||||
if (travelHook != null) {
|
if (travelHook != null) {
|
||||||
travelHook.endReached(this, data, tile);
|
travelHook.endReached(this, item, tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the item has not been scheduled to removal by the hook
|
// If the item has not been scheduled to removal by the hook
|
||||||
if (!toRemove.contains(data.item.getEntityId())) {
|
if (items.scheduleRemoval(item)) {
|
||||||
scheduleRemoval(data.item);
|
handleTileReached(item, tile);
|
||||||
handleTileReached(data, tile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
performRemoval();
|
items.performRemoval();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean passToNextPipe(EntityData data, TileEntity tile) {
|
private boolean passToNextPipe(TravelingItem item, TileEntity tile) {
|
||||||
if (tile instanceof TileGenericPipe) {
|
if (tile instanceof TileGenericPipe) {
|
||||||
TileGenericPipe pipe = (TileGenericPipe) tile;
|
TileGenericPipe pipe = (TileGenericPipe) tile;
|
||||||
if (BlockGenericPipe.isValid(pipe.pipe) && pipe.pipe.transport instanceof PipeTransportItems) {
|
if (BlockGenericPipe.isValid(pipe.pipe) && pipe.pipe.transport instanceof PipeTransportItems) {
|
||||||
((PipeTransportItems) pipe.pipe.transport).entityEntering(data, data.output);
|
((PipeTransportItems) pipe.pipe.transport).injectItem(item, item.output);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleTileReached(EntityData data, TileEntity tile) {
|
private void handleTileReached(TravelingItem item, TileEntity tile) {
|
||||||
if (passToNextPipe(data, tile)) {
|
if (passToNextPipe(item, tile)) {
|
||||||
// NOOP
|
// NOOP
|
||||||
} else if (tile instanceof IInventory) {
|
} else if (tile instanceof IInventory) {
|
||||||
if (!CoreProxy.proxy.isRenderWorld(container.worldObj)) {
|
if (!CoreProxy.proxy.isRenderWorld(container.worldObj)) {
|
||||||
ItemStack added = Transactor.getTransactorFor(tile).add(data.item.getItemStack(), data.output.getOpposite(), true);
|
ItemStack added = Transactor.getTransactorFor(tile).add(item.getItemStack(), item.output.getOpposite(), true);
|
||||||
|
|
||||||
data.item.getItemStack().stackSize -= added.stackSize;
|
item.getItemStack().stackSize -= added.stackSize;
|
||||||
|
|
||||||
if (data.item.getItemStack().stackSize > 0) {
|
if (item.getItemStack().stackSize > 0) {
|
||||||
reverseItem(data);
|
reverseItem(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (travelHook != null) {
|
if (travelHook != null) {
|
||||||
travelHook.drop(this, data);
|
travelHook.drop(this, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityItem dropped = data.item.toEntityItem(data.output);
|
EntityItem dropped = item.toEntityItem(item.output);
|
||||||
|
|
||||||
if (dropped != null) {
|
if (dropped != null) {
|
||||||
// On SMP, the client side doesn't actually drops
|
// On SMP, the client side doesn't actually drops
|
||||||
|
@ -393,9 +409,9 @@ public class PipeTransportItems extends PipeTransport {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean middleReached(EntityData entity, Position pos) {
|
protected boolean middleReached(TravelingItem item, Position pos) {
|
||||||
float middleLimit = entity.item.getSpeed() * 1.01F;
|
float middleLimit = item.getSpeed() * 1.01F;
|
||||||
return (Math.abs(container.xCoord + 0.5 - pos.x) < middleLimit && Math.abs(container.yCoord + Utils.getPipeFloorOf(entity.item.getItemStack()) - pos.y) < middleLimit && Math
|
return (Math.abs(container.xCoord + 0.5 - pos.x) < middleLimit && Math.abs(container.yCoord + Utils.getPipeFloorOf(item.getItemStack()) - pos.y) < middleLimit && Math
|
||||||
.abs(container.zCoord + 0.5 - pos.z) < middleLimit);
|
.abs(container.zCoord + 0.5 - pos.z) < middleLimit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -421,27 +437,19 @@ public class PipeTransportItems extends PipeTransport {
|
||||||
try {
|
try {
|
||||||
NBTTagCompound dataTag = (NBTTagCompound) nbttaglist.tagAt(j);
|
NBTTagCompound dataTag = (NBTTagCompound) nbttaglist.tagAt(j);
|
||||||
|
|
||||||
IPipedItem entity = new EntityPassiveItem(null);
|
TravelingItem item = new TravelingItem();
|
||||||
entity.readFromNBT(dataTag);
|
item.readFromNBT(dataTag);
|
||||||
|
|
||||||
if (entity.isCorrupted()) {
|
if (item.isCorrupted()) {
|
||||||
entity.remove();
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
entity.setContainer(container);
|
items.scheduleLoad(item);
|
||||||
|
|
||||||
EntityData data = new EntityData(entity);
|
|
||||||
data.readFromNBT(dataTag);
|
|
||||||
|
|
||||||
entitiesToLoad.add(data);
|
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
t.printStackTrace();
|
|
||||||
// It may be the case that entities cannot be reloaded between
|
// It may be the case that entities cannot be reloaded between
|
||||||
// two versions - ignore these errors.
|
// two versions - ignore these errors.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delay = 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -450,11 +458,10 @@ public class PipeTransportItems extends PipeTransport {
|
||||||
|
|
||||||
NBTTagList nbttaglist = new NBTTagList();
|
NBTTagList nbttaglist = new NBTTagList();
|
||||||
|
|
||||||
for (EntityData data : travelingEntities.values()) {
|
for (TravelingItem item : items) {
|
||||||
NBTTagCompound dataTag = new NBTTagCompound();
|
NBTTagCompound dataTag = new NBTTagCompound();
|
||||||
nbttaglist.appendTag(dataTag);
|
nbttaglist.appendTag(dataTag);
|
||||||
data.item.writeToNBT(dataTag);
|
item.writeToNBT(dataTag);
|
||||||
data.writeToNBT(dataTag);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nbt.setTag("travelingEntities", nbttaglist);
|
nbt.setTag("travelingEntities", nbttaglist);
|
||||||
|
@ -473,26 +480,22 @@ public class PipeTransportItems extends PipeTransport {
|
||||||
if (packet.getID() != PacketIds.PIPE_CONTENTS)
|
if (packet.getID() != PacketIds.PIPE_CONTENTS)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
IPipedItem item;
|
TravelingItem item = items.get(packet.getTravellingItemId());
|
||||||
EntityData data = travelingEntities.get(packet.getEntityId());
|
if (item == null) {
|
||||||
if (data == null) {
|
item = new TravelingItem(packet.getTravellingItemId());
|
||||||
item = EntityPassiveItem.getOrCreate(container.worldObj, packet.getEntityId());
|
items.add(item);
|
||||||
data = new EntityData(item);
|
|
||||||
travelingEntities.put(item.getEntityId(), data);
|
|
||||||
} else {
|
|
||||||
item = data.item;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.getItemStack() == null) {
|
if (item.getItemStack() == null) {
|
||||||
item.setItemStack(new ItemStack(packet.getItemId(), packet.getStackSize(), packet.getItemDamage()));
|
item.setItemStack(new ItemStack(packet.getItemId(), packet.getStackSize(), packet.getItemDamage()));
|
||||||
if (packet.hasNBT()) {
|
if (packet.hasNBT()) {
|
||||||
PacketDispatcher.sendPacketToServer(new PacketSimpleId(PacketIds.REQUEST_ITEM_NBT, container.xCoord, container.yCoord, container.zCoord, packet.getEntityId()).getPacket());
|
PacketDispatcher.sendPacketToServer(new PacketSimpleId(PacketIds.REQUEST_ITEM_NBT, container.xCoord, container.yCoord, container.zCoord, packet.getTravellingItemId()).getPacket());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (item.getItemStack().itemID != packet.getItemId() || item.getItemStack().stackSize != packet.getStackSize() || item.getItemStack().getItemDamage() != packet.getItemDamage() || item.getItemStack().hasTagCompound() != packet.hasNBT()) {
|
if (item.getItemStack().itemID != packet.getItemId() || item.getItemStack().stackSize != packet.getStackSize() || item.getItemStack().getItemDamage() != packet.getItemDamage() || item.getItemStack().hasTagCompound() != packet.hasNBT()) {
|
||||||
item.setItemStack(new ItemStack(packet.getItemId(), packet.getStackSize(), packet.getItemDamage()));
|
item.setItemStack(new ItemStack(packet.getItemId(), packet.getStackSize(), packet.getItemDamage()));
|
||||||
if (packet.hasNBT()) {
|
if (packet.hasNBT()) {
|
||||||
PacketDispatcher.sendPacketToServer(new PacketSimpleId(PacketIds.REQUEST_ITEM_NBT, container.xCoord, container.yCoord, container.zCoord, packet.getEntityId()).getPacket());
|
PacketDispatcher.sendPacketToServer(new PacketSimpleId(PacketIds.REQUEST_ITEM_NBT, container.xCoord, container.yCoord, container.zCoord, packet.getTravellingItemId()).getPacket());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -503,31 +506,29 @@ public class PipeTransportItems extends PipeTransport {
|
||||||
|
|
||||||
item.setSpeed(packet.getSpeed());
|
item.setSpeed(packet.getSpeed());
|
||||||
|
|
||||||
item.setContainer(container);
|
item.input = packet.getInputOrientation();
|
||||||
|
item.output = packet.getOutputOrientation();
|
||||||
data.input = packet.getInputOrientation();
|
item.color = packet.getColor();
|
||||||
data.output = packet.getOutputOrientation();
|
|
||||||
data.color = packet.getColor();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the NBT tag Request from player of the entityId
|
* Handles the NBT tag Request from player of the id
|
||||||
*/
|
*/
|
||||||
public void handleNBTRequestPacket(EntityPlayer player, int entityId) {
|
public void handleNBTRequestPacket(EntityPlayer player, int entityId) {
|
||||||
EntityData data = travelingEntities.get(entityId);
|
TravelingItem item = items.get(entityId);
|
||||||
if (data == null || data.item == null || data.item.getItemStack() == null)
|
if (item == null || item.item == null || item.getItemStack() == null)
|
||||||
return;
|
return;
|
||||||
PacketDispatcher.sendPacketToPlayer(new PacketPipeTransportNBT(PacketIds.PIPE_ITEM_NBT, container.xCoord, container.yCoord, container.zCoord, entityId, data.item.getItemStack().getTagCompound()).getPacket(), (Player) player);
|
PacketDispatcher.sendPacketToPlayer(new PacketPipeTransportNBT(PacketIds.PIPE_ITEM_NBT, container.xCoord, container.yCoord, container.zCoord, entityId, item.getItemStack().getTagCompound()).getPacket(), (Player) player);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the Item NBT tag information of the packet
|
* Handles the Item NBT tag information of the packet
|
||||||
*/
|
*/
|
||||||
public void handleNBTPacket(PacketPipeTransportNBT packet) {
|
public void handleNBTPacket(PacketPipeTransportNBT packet) {
|
||||||
EntityData data = travelingEntities.get(packet.getEntityId());
|
TravelingItem item = items.get(packet.getEntityId());
|
||||||
if (data == null || data.item == null || data.item.getItemStack() == null)
|
if (item == null || item.item == null || item.getItemStack() == null)
|
||||||
return;
|
return;
|
||||||
data.item.getItemStack().setTagCompound(packet.getTagCompound());
|
item.getItemStack().setTagCompound(packet.getTagCompound());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -536,18 +537,18 @@ public class PipeTransportItems extends PipeTransport {
|
||||||
* @param data
|
* @param data
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Packet createItemPacket(EntityData data) {
|
public Packet createItemPacket(TravelingItem data) {
|
||||||
PacketPipeTransportContent packet = new PacketPipeTransportContent(data);
|
PacketPipeTransportContent packet = new PacketPipeTransportContent(data);
|
||||||
return packet.getPacket();
|
return packet.getPacket();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendItemPacket(EntityData data) {
|
private void sendItemPacket(TravelingItem data) {
|
||||||
int dimension = container.worldObj.provider.dimensionId;
|
int dimension = container.worldObj.provider.dimensionId;
|
||||||
PacketDispatcher.sendPacketToAllAround(container.xCoord, container.yCoord, container.zCoord, DefaultProps.PIPE_CONTENTS_RENDER_DIST, dimension, createItemPacket(data));
|
PacketDispatcher.sendPacketToAllAround(container.xCoord, container.yCoord, container.zCoord, DefaultProps.PIPE_CONTENTS_RENDER_DIST, dimension, createItemPacket(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getNumberOfItems() {
|
public int getNumberOfItems() {
|
||||||
return travelingEntities.size();
|
return items.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDropped(EntityItem item) {
|
public void onDropped(EntityItem item) {
|
||||||
|
@ -579,12 +580,11 @@ public class PipeTransportItems extends PipeTransport {
|
||||||
*/
|
*/
|
||||||
public void groupEntities() {
|
public void groupEntities() {
|
||||||
// determine groupable entities
|
// determine groupable entities
|
||||||
List<EntityData> entities = new ArrayList<EntityData>();
|
List<TravelingItem> entities = new ArrayList<TravelingItem>();
|
||||||
|
|
||||||
for (EntityData entityData : travelingEntities.values()) {
|
for (TravelingItem item : items) {
|
||||||
if (!entityData.item.hasContributions()
|
if (!item.hasExtraData() && item.getItemStack().stackSize < item.getItemStack().getMaxStackSize()) {
|
||||||
&& entityData.item.getItemStack().stackSize < entityData.item.getItemStack().getMaxStackSize()) {
|
entities.add(item);
|
||||||
entities.add(entityData);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -592,12 +592,12 @@ public class PipeTransportItems extends PipeTransport {
|
||||||
return; // nothing groupable
|
return; // nothing groupable
|
||||||
|
|
||||||
// sort the groupable entities to have all entities with the same id:dmg next to each other (contiguous range)
|
// sort the groupable entities to have all entities with the same id:dmg next to each other (contiguous range)
|
||||||
Collections.sort(entities, new Comparator<EntityData>() {
|
Collections.sort(entities, new Comparator<TravelingItem>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(EntityData a, EntityData b) {
|
public int compare(TravelingItem a, TravelingItem b) {
|
||||||
// the item id is always less than 2^15 so the int won't overflow
|
// the item id is always less than 2^15 so the int won't overflow
|
||||||
int itemA = (a.item.getItemStack().itemID << 16) | a.item.getItemStack().getItemDamage();
|
int itemA = (a.getItemStack().itemID << 16) | a.getItemStack().getItemDamage();
|
||||||
int itemB = (b.item.getItemStack().itemID << 16) | b.item.getItemStack().getItemDamage();
|
int itemB = (b.getItemStack().itemID << 16) | b.getItemStack().getItemDamage();
|
||||||
|
|
||||||
return itemA - itemB;
|
return itemA - itemB;
|
||||||
}
|
}
|
||||||
|
@ -605,10 +605,10 @@ public class PipeTransportItems extends PipeTransport {
|
||||||
|
|
||||||
// group the entities
|
// group the entities
|
||||||
int matchStart = 0;
|
int matchStart = 0;
|
||||||
int lastId = (entities.get(0).item.getItemStack().itemID << 16) | entities.get(0).item.getItemStack().getItemDamage();
|
int lastId = (entities.get(0).getItemStack().itemID << 16) | entities.get(0).getItemStack().getItemDamage();
|
||||||
|
|
||||||
for (int i = 1; i < entities.size(); i++) {
|
for (int i = 1; i < entities.size(); i++) {
|
||||||
int id = (entities.get(i).item.getItemStack().itemID << 16) | entities.get(i).item.getItemStack().getItemDamage();
|
int id = (entities.get(i).getItemStack().itemID << 16) | entities.get(i).getItemStack().getItemDamage();
|
||||||
|
|
||||||
if (id != lastId) {
|
if (id != lastId) {
|
||||||
// merge within the last matching ID range
|
// merge within the last matching ID range
|
||||||
|
@ -631,34 +631,33 @@ public class PipeTransportItems extends PipeTransport {
|
||||||
* @param start start index (inclusive)
|
* @param start start index (inclusive)
|
||||||
* @param end end index (exclusive)
|
* @param end end index (exclusive)
|
||||||
*/
|
*/
|
||||||
private void groupEntityRange(List<EntityData> entities, int start, int end) {
|
private void groupEntityRange(List<TravelingItem> entities, int start, int end) {
|
||||||
for (int j = start; j < end; j++) {
|
for (int j = start; j < end; j++) {
|
||||||
EntityData target = entities.get(j);
|
TravelingItem target = entities.get(j);
|
||||||
if (target == null)
|
if (target == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (int k = j + 1; k < end; k++) {
|
for (int k = j + 1; k < end; k++) {
|
||||||
EntityData source = entities.get(k);
|
TravelingItem source = entities.get(k);
|
||||||
if (source == null)
|
if (source == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// only merge if the ItemStack tags match
|
// only merge if the ItemStack tags match
|
||||||
if (ItemStack.areItemStackTagsEqual(source.item.getItemStack(), target.item.getItemStack())) {
|
if (ItemStack.areItemStackTagsEqual(source.getItemStack(), target.getItemStack())) {
|
||||||
// merge source to target
|
// merge source to target
|
||||||
int amount = source.item.getItemStack().stackSize;
|
int amount = source.getItemStack().stackSize;
|
||||||
int space = target.item.getItemStack().getMaxStackSize() - target.item.getItemStack().stackSize;
|
int space = target.getItemStack().getMaxStackSize() - target.getItemStack().stackSize;
|
||||||
|
|
||||||
if (amount <= space) {
|
if (amount <= space) {
|
||||||
// source fits completely into target
|
// source fits completely into target
|
||||||
target.item.getItemStack().stackSize += amount;
|
target.getItemStack().stackSize += amount;
|
||||||
|
|
||||||
source.item.remove();
|
items.remove(source);
|
||||||
travelingEntities.remove(source.item.getEntityId());
|
|
||||||
entities.set(k, null);
|
entities.set(k, null);
|
||||||
} else {
|
} else {
|
||||||
target.item.getItemStack().stackSize += space;
|
target.getItemStack().stackSize += space;
|
||||||
|
|
||||||
source.item.getItemStack().stackSize -= space;
|
source.getItemStack().stackSize -= space;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (amount >= space) {
|
if (amount >= space) {
|
||||||
|
@ -674,11 +673,11 @@ public class PipeTransportItems extends PipeTransport {
|
||||||
public void dropContents() {
|
public void dropContents() {
|
||||||
groupEntities();
|
groupEntities();
|
||||||
|
|
||||||
for (EntityData data : travelingEntities.values()) {
|
for (TravelingItem item : items) {
|
||||||
container.pipe.dropItem(data.item.getItemStack());
|
container.pipe.dropItem(item.getItemStack());
|
||||||
}
|
}
|
||||||
|
|
||||||
travelingEntities.clear();
|
items.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -342,8 +342,8 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
|
||||||
itemPos.z += 0.5;
|
itemPos.z += 0.5;
|
||||||
itemPos.moveForwards(0.5);
|
itemPos.moveForwards(0.5);
|
||||||
|
|
||||||
EntityPassiveItem pipedItem = new EntityPassiveItem(worldObj, itemPos.x, itemPos.y, itemPos.z, payload);
|
TravelingItem pipedItem = new TravelingItem(itemPos.x, itemPos.y, itemPos.z, payload);
|
||||||
((PipeTransportItems) pipe.transport).entityEntering(pipedItem, from.getOpposite());
|
((PipeTransportItems) pipe.transport).injectItem(pipedItem, from.getOpposite());
|
||||||
}
|
}
|
||||||
return payload.stackSize;
|
return payload.stackSize;
|
||||||
}
|
}
|
||||||
|
|
219
common/buildcraft/transport/TravelingItem.java
Normal file
219
common/buildcraft/transport/TravelingItem.java
Normal file
|
@ -0,0 +1,219 @@
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
import buildcraft.BuildCraftCore;
|
||||||
|
import buildcraft.api.core.Position;
|
||||||
|
import buildcraft.core.proxy.CoreProxy;
|
||||||
|
import buildcraft.core.utils.EnumColor;
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import net.minecraft.entity.item.EntityItem;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.nbt.NBTTagList;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.MathHelper;
|
||||||
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
|
|
||||||
|
public class TravelingItem {
|
||||||
|
|
||||||
|
private static int maxId = 0;
|
||||||
|
protected float speed = 0.01F;
|
||||||
|
protected ItemStack item;
|
||||||
|
protected TileEntity container;
|
||||||
|
protected Position position;
|
||||||
|
public final int id;
|
||||||
|
public boolean toCenter = true;
|
||||||
|
public EnumColor color;
|
||||||
|
public ForgeDirection input = ForgeDirection.UNKNOWN;
|
||||||
|
public ForgeDirection output = ForgeDirection.UNKNOWN;
|
||||||
|
public final EnumSet<ForgeDirection> blacklist = EnumSet.noneOf(ForgeDirection.class);
|
||||||
|
private NBTTagCompound extraData;
|
||||||
|
|
||||||
|
/* CONSTRUCTORS */
|
||||||
|
public TravelingItem() {
|
||||||
|
this(maxId < Short.MAX_VALUE ? ++maxId : (maxId = Short.MIN_VALUE));
|
||||||
|
}
|
||||||
|
|
||||||
|
public TravelingItem(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TravelingItem(double x, double y, double z, ItemStack stack) {
|
||||||
|
this();
|
||||||
|
this.position = new Position(x, y, z);
|
||||||
|
this.item = stack.copy();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* GETTING & SETTING */
|
||||||
|
public Position getPosition() {
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPosition(double x, double y, double z) {
|
||||||
|
position = new Position(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getSpeed() {
|
||||||
|
return speed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSpeed(float speed) {
|
||||||
|
this.speed = speed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack getItemStack() {
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItemStack(ItemStack item) {
|
||||||
|
this.item = item;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TileEntity getContainer() {
|
||||||
|
return container;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContainer(TileEntity container) {
|
||||||
|
this.container = container;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NBTTagCompound getExtraData() {
|
||||||
|
if (extraData == null)
|
||||||
|
extraData = new NBTTagCompound();
|
||||||
|
return extraData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasExtraData() {
|
||||||
|
return extraData != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reset() {
|
||||||
|
toCenter = true;
|
||||||
|
blacklist.clear();
|
||||||
|
input = ForgeDirection.UNKNOWN;
|
||||||
|
output = ForgeDirection.UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* SAVING & LOADING */
|
||||||
|
public void readFromNBT(NBTTagCompound data) {
|
||||||
|
setPosition(data.getDouble("x"), data.getDouble("y"), data.getDouble("z"));
|
||||||
|
|
||||||
|
setSpeed(data.getFloat("speed"));
|
||||||
|
setItemStack(ItemStack.loadItemStackFromNBT(data.getCompoundTag("Item")));
|
||||||
|
|
||||||
|
toCenter = data.getBoolean("toCenter");
|
||||||
|
input = ForgeDirection.getOrientation(data.getInteger("input"));
|
||||||
|
output = ForgeDirection.getOrientation(data.getInteger("output"));
|
||||||
|
|
||||||
|
byte c = data.getByte("color");
|
||||||
|
if (c != -1)
|
||||||
|
color = EnumColor.fromId(c);
|
||||||
|
|
||||||
|
NBTTagList contribList = data.getTagList("contribList");
|
||||||
|
|
||||||
|
for (int i = 0; i < contribList.tagCount(); ++i) {
|
||||||
|
NBTTagCompound cpt = (NBTTagCompound) contribList.tagAt(i);
|
||||||
|
String key = cpt.getString("key");
|
||||||
|
|
||||||
|
String className = cpt.getString("class");
|
||||||
|
|
||||||
|
if (getClass().getName().startsWith("net.minecraft.src")) {
|
||||||
|
className = "net.minecraft.src." + className;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.hasKey("extraData"))
|
||||||
|
extraData = data.getCompoundTag("extraData");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writeToNBT(NBTTagCompound data) {
|
||||||
|
data.setDouble("x", position.x);
|
||||||
|
data.setDouble("y", position.y);
|
||||||
|
data.setDouble("z", position.z);
|
||||||
|
data.setFloat("speed", getSpeed());
|
||||||
|
NBTTagCompound nbttagcompound2 = new NBTTagCompound();
|
||||||
|
getItemStack().writeToNBT(nbttagcompound2);
|
||||||
|
data.setCompoundTag("Item", nbttagcompound2);
|
||||||
|
|
||||||
|
data.setBoolean("toCenter", toCenter);
|
||||||
|
data.setInteger("input", input.ordinal());
|
||||||
|
data.setInteger("output", output.ordinal());
|
||||||
|
|
||||||
|
data.setByte("color", color != null ? (byte) color.ordinal() : -1);
|
||||||
|
|
||||||
|
if (extraData != null)
|
||||||
|
data.setTag("extraData", extraData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityItem toEntityItem(ForgeDirection dir) {
|
||||||
|
if (container != null && !CoreProxy.proxy.isRenderWorld(container.worldObj)) {
|
||||||
|
if (getItemStack().stackSize <= 0)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
Position motion = new Position(0, 0, 0, dir);
|
||||||
|
motion.moveForwards(0.1 + getSpeed() * 2F);
|
||||||
|
|
||||||
|
EntityItem entityitem = new EntityItem(container.worldObj, position.x, position.y, position.z, getItemStack());
|
||||||
|
|
||||||
|
entityitem.lifespan = BuildCraftCore.itemLifespan;
|
||||||
|
entityitem.delayBeforeCanPickup = 10;
|
||||||
|
|
||||||
|
float f3 = 0.00F + container.worldObj.rand.nextFloat() * 0.04F - 0.02F;
|
||||||
|
entityitem.motionX = (float) container.worldObj.rand.nextGaussian() * f3 + motion.x;
|
||||||
|
entityitem.motionY = (float) container.worldObj.rand.nextGaussian() * f3 + motion.y;
|
||||||
|
entityitem.motionZ = (float) container.worldObj.rand.nextGaussian() * f3 + +motion.z;
|
||||||
|
container.worldObj.spawnEntityInWorld(entityitem);
|
||||||
|
return entityitem;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getEntityBrightness(float f) {
|
||||||
|
int i = MathHelper.floor_double(position.x);
|
||||||
|
int j = MathHelper.floor_double(position.z);
|
||||||
|
if (container.worldObj.blockExists(i, 128 / 2, j)) {
|
||||||
|
double d = 0.66000000000000003D;
|
||||||
|
int k = MathHelper.floor_double(position.y + d);
|
||||||
|
return container.worldObj.getLightBrightness(i, k, j);
|
||||||
|
} else
|
||||||
|
return 0.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCorrupted() {
|
||||||
|
return getItemStack() == null || getItemStack().stackSize <= 0 || Item.itemsList[getItemStack().itemID] == null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the can this item be moved into this specific inventory type.
|
||||||
|
* (basic BuildCraft PipedItems always return true)
|
||||||
|
*/
|
||||||
|
public boolean canSinkTo(TileEntity entity) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int hash = 7;
|
||||||
|
hash = 67 * hash + this.id;
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
final TravelingItem other = (TravelingItem) obj;
|
||||||
|
if (this.id != other.id)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,7 +3,7 @@ package buildcraft.transport.network;
|
||||||
import buildcraft.core.network.BuildCraftPacket;
|
import buildcraft.core.network.BuildCraftPacket;
|
||||||
import buildcraft.core.network.PacketIds;
|
import buildcraft.core.network.PacketIds;
|
||||||
import buildcraft.core.utils.EnumColor;
|
import buildcraft.core.utils.EnumColor;
|
||||||
import buildcraft.transport.EntityData;
|
import buildcraft.transport.TravelingItem;
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -12,7 +12,7 @@ import net.minecraftforge.common.ForgeDirection;
|
||||||
|
|
||||||
public class PacketPipeTransportContent extends BuildCraftPacket {
|
public class PacketPipeTransportContent extends BuildCraftPacket {
|
||||||
|
|
||||||
private EntityData entityData;
|
private TravelingItem item;
|
||||||
private int entityId;
|
private int entityId;
|
||||||
private ForgeDirection input;
|
private ForgeDirection input;
|
||||||
private ForgeDirection output;
|
private ForgeDirection output;
|
||||||
|
@ -32,29 +32,29 @@ public class PacketPipeTransportContent extends BuildCraftPacket {
|
||||||
public PacketPipeTransportContent() {
|
public PacketPipeTransportContent() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public PacketPipeTransportContent(EntityData data) {
|
public PacketPipeTransportContent(TravelingItem item) {
|
||||||
this.entityData = data;
|
this.item = item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeData(DataOutputStream data) throws IOException {
|
public void writeData(DataOutputStream data) throws IOException {
|
||||||
data.writeFloat((float) entityData.item.getPosition().x);
|
data.writeFloat((float) item.getPosition().x);
|
||||||
data.writeFloat((float) entityData.item.getPosition().y);
|
data.writeFloat((float) item.getPosition().y);
|
||||||
data.writeFloat((float) entityData.item.getPosition().z);
|
data.writeFloat((float) item.getPosition().z);
|
||||||
|
|
||||||
data.writeShort(entityData.item.getEntityId());
|
data.writeShort(item.id);
|
||||||
|
|
||||||
data.writeByte((byte) entityData.input.ordinal());
|
data.writeByte((byte) item.input.ordinal());
|
||||||
data.writeByte((byte) entityData.output.ordinal());
|
data.writeByte((byte) item.output.ordinal());
|
||||||
|
|
||||||
data.writeShort(entityData.item.getItemStack().itemID);
|
data.writeShort(item.getItemStack().itemID);
|
||||||
data.writeByte((byte) entityData.item.getItemStack().stackSize);
|
data.writeByte((byte) item.getItemStack().stackSize);
|
||||||
data.writeShort(entityData.item.getItemStack().getItemDamage());
|
data.writeShort(item.getItemStack().getItemDamage());
|
||||||
|
|
||||||
data.writeByte(entityData.color != null ? entityData.color.ordinal() : -1);
|
data.writeByte(item.color != null ? item.color.ordinal() : -1);
|
||||||
|
|
||||||
data.writeFloat(entityData.item.getSpeed());
|
data.writeFloat(item.getSpeed());
|
||||||
data.writeBoolean(entityData.item.getItemStack().hasTagCompound());
|
data.writeBoolean(item.getItemStack().hasTagCompound());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -84,7 +84,7 @@ public class PacketPipeTransportContent extends BuildCraftPacket {
|
||||||
this.hasNBT = data.readBoolean();
|
this.hasNBT = data.readBoolean();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getEntityId() {
|
public int getTravellingItemId() {
|
||||||
return entityId;
|
return entityId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,16 +13,14 @@ import buildcraft.api.core.Position;
|
||||||
import buildcraft.api.gates.IAction;
|
import buildcraft.api.gates.IAction;
|
||||||
import buildcraft.api.tools.IToolWrench;
|
import buildcraft.api.tools.IToolWrench;
|
||||||
import buildcraft.core.network.TileNetworkData;
|
import buildcraft.core.network.TileNetworkData;
|
||||||
import buildcraft.core.triggers.BCTrigger;
|
|
||||||
import buildcraft.core.utils.EnumColor;
|
import buildcraft.core.utils.EnumColor;
|
||||||
import buildcraft.core.utils.Utils;
|
import buildcraft.core.utils.Utils;
|
||||||
import buildcraft.transport.EntityData;
|
|
||||||
import buildcraft.transport.IPipeTransportItemsHook;
|
import buildcraft.transport.IPipeTransportItemsHook;
|
||||||
import buildcraft.transport.IPipedItem;
|
|
||||||
import buildcraft.transport.Pipe;
|
import buildcraft.transport.Pipe;
|
||||||
import buildcraft.transport.PipeIconProvider;
|
import buildcraft.transport.PipeIconProvider;
|
||||||
import buildcraft.transport.PipeTransportItems;
|
import buildcraft.transport.PipeTransportItems;
|
||||||
import buildcraft.transport.TileGenericPipe;
|
import buildcraft.transport.TileGenericPipe;
|
||||||
|
import buildcraft.transport.TravelingItem;
|
||||||
import buildcraft.transport.triggers.ActionPipeColor;
|
import buildcraft.transport.triggers.ActionPipeColor;
|
||||||
import buildcraft.transport.triggers.ActionPipeDirection;
|
import buildcraft.transport.triggers.ActionPipeDirection;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
@ -122,11 +120,11 @@ public class PipeItemsDaizuli extends Pipe<PipeTransportItems> implements IPipeT
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LinkedList<ForgeDirection> filterPossibleMovements(LinkedList<ForgeDirection> possibleOrientations, Position pos, EntityData data) {
|
public LinkedList<ForgeDirection> filterPossibleMovements(LinkedList<ForgeDirection> possibleOrientations, Position pos, TravelingItem item) {
|
||||||
LinkedList<ForgeDirection> newMovements = new LinkedList<ForgeDirection>();
|
LinkedList<ForgeDirection> newMovements = new LinkedList<ForgeDirection>();
|
||||||
EnumColor c = getColor();
|
EnumColor c = getColor();
|
||||||
for (ForgeDirection dir : possibleOrientations) {
|
for (ForgeDirection dir : possibleOrientations) {
|
||||||
if (data.color == c) {
|
if (item.color == c) {
|
||||||
if (dir.ordinal() == container.getBlockMetadata())
|
if (dir.ordinal() == container.getBlockMetadata())
|
||||||
newMovements.add(dir);
|
newMovements.add(dir);
|
||||||
} else if (dir.ordinal() != container.getBlockMetadata()) {
|
} else if (dir.ordinal() != container.getBlockMetadata()) {
|
||||||
|
@ -137,11 +135,11 @@ public class PipeItemsDaizuli extends Pipe<PipeTransportItems> implements IPipeT
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void entityEntered(IPipedItem item, ForgeDirection orientation) {
|
public void entityEntered(TravelingItem item, ForgeDirection orientation) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readjustSpeed(IPipedItem item) {
|
public void readjustSpeed(TravelingItem item) {
|
||||||
if (item.getSpeed() > Utils.pipeNormalSpeed) {
|
if (item.getSpeed() > Utils.pipeNormalSpeed) {
|
||||||
item.setSpeed(item.getSpeed() - Utils.pipeNormalSpeed / 4.0F);
|
item.setSpeed(item.getSpeed() - Utils.pipeNormalSpeed / 4.0F);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,17 +10,16 @@ package buildcraft.transport.pipes;
|
||||||
import buildcraft.BuildCraftTransport;
|
import buildcraft.BuildCraftTransport;
|
||||||
import buildcraft.api.core.IIconProvider;
|
import buildcraft.api.core.IIconProvider;
|
||||||
import buildcraft.api.core.Position;
|
import buildcraft.api.core.Position;
|
||||||
import buildcraft.transport.IPipedItem;
|
|
||||||
import buildcraft.core.GuiIds;
|
import buildcraft.core.GuiIds;
|
||||||
import buildcraft.core.inventory.SimpleInventory;
|
import buildcraft.core.inventory.SimpleInventory;
|
||||||
import buildcraft.core.network.IClientState;
|
import buildcraft.core.network.IClientState;
|
||||||
import buildcraft.core.proxy.CoreProxy;
|
import buildcraft.core.proxy.CoreProxy;
|
||||||
import buildcraft.transport.BlockGenericPipe;
|
import buildcraft.transport.BlockGenericPipe;
|
||||||
import buildcraft.transport.EntityData;
|
|
||||||
import buildcraft.transport.IPipeTransportItemsHook;
|
import buildcraft.transport.IPipeTransportItemsHook;
|
||||||
import buildcraft.transport.Pipe;
|
import buildcraft.transport.Pipe;
|
||||||
import buildcraft.transport.PipeIconProvider;
|
import buildcraft.transport.PipeIconProvider;
|
||||||
import buildcraft.transport.PipeTransportItems;
|
import buildcraft.transport.PipeTransportItems;
|
||||||
|
import buildcraft.transport.TravelingItem;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
|
@ -90,7 +89,7 @@ public class PipeItemsDiamond extends Pipe<PipeTransportItems> implements IPipeT
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LinkedList<ForgeDirection> filterPossibleMovements(LinkedList<ForgeDirection> possibleOrientations, Position pos, EntityData data) {
|
public LinkedList<ForgeDirection> filterPossibleMovements(LinkedList<ForgeDirection> possibleOrientations, Position pos, TravelingItem item) {
|
||||||
LinkedList<ForgeDirection> filteredOrientations = new LinkedList<ForgeDirection>();
|
LinkedList<ForgeDirection> filteredOrientations = new LinkedList<ForgeDirection>();
|
||||||
LinkedList<ForgeDirection> defaultOrientations = new LinkedList<ForgeDirection>();
|
LinkedList<ForgeDirection> defaultOrientations = new LinkedList<ForgeDirection>();
|
||||||
|
|
||||||
|
@ -108,10 +107,10 @@ public class PipeItemsDiamond extends Pipe<PipeTransportItems> implements IPipeT
|
||||||
foundFilter = true;
|
foundFilter = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stack != null && stack.itemID == data.item.getItemStack().itemID)
|
if (stack != null && stack.itemID == item.getItemStack().itemID)
|
||||||
if ((Item.itemsList[data.item.getItemStack().itemID].isDamageable())) {
|
if ((Item.itemsList[item.getItemStack().itemID].isDamageable())) {
|
||||||
filteredOrientations.add(dir);
|
filteredOrientations.add(dir);
|
||||||
} else if (stack.getItemDamage() == data.item.getItemStack().getItemDamage()) {
|
} else if (stack.getItemDamage() == item.getItemStack().getItemDamage()) {
|
||||||
filteredOrientations.add(dir);
|
filteredOrientations.add(dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,11 +125,11 @@ public class PipeItemsDiamond extends Pipe<PipeTransportItems> implements IPipeT
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void entityEntered(IPipedItem item, ForgeDirection orientation) {
|
public void entityEntered(TravelingItem item, ForgeDirection orientation) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readjustSpeed(IPipedItem item) {
|
public void readjustSpeed(TravelingItem item) {
|
||||||
transport.defaultReajustSpeed(item);
|
transport.defaultReajustSpeed(item);
|
||||||
}
|
}
|
||||||
/* SAVING & LOADING */
|
/* SAVING & LOADING */
|
||||||
|
|
|
@ -10,13 +10,12 @@ package buildcraft.transport.pipes;
|
||||||
import buildcraft.BuildCraftTransport;
|
import buildcraft.BuildCraftTransport;
|
||||||
import buildcraft.api.core.IIconProvider;
|
import buildcraft.api.core.IIconProvider;
|
||||||
import buildcraft.api.core.Position;
|
import buildcraft.api.core.Position;
|
||||||
import buildcraft.transport.IPipedItem;
|
|
||||||
import buildcraft.core.utils.Utils;
|
import buildcraft.core.utils.Utils;
|
||||||
import buildcraft.transport.EntityData;
|
|
||||||
import buildcraft.transport.IPipeTransportItemsHook;
|
import buildcraft.transport.IPipeTransportItemsHook;
|
||||||
import buildcraft.transport.Pipe;
|
import buildcraft.transport.Pipe;
|
||||||
import buildcraft.transport.PipeIconProvider;
|
import buildcraft.transport.PipeIconProvider;
|
||||||
import buildcraft.transport.PipeTransportItems;
|
import buildcraft.transport.PipeTransportItems;
|
||||||
|
import buildcraft.transport.TravelingItem;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
@ -40,17 +39,17 @@ public class PipeItemsGold extends Pipe implements IPipeTransportItemsHook {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LinkedList<ForgeDirection> filterPossibleMovements(LinkedList<ForgeDirection> possibleOrientations, Position pos, EntityData data) {
|
public LinkedList<ForgeDirection> filterPossibleMovements(LinkedList<ForgeDirection> possibleOrientations, Position pos, TravelingItem item) {
|
||||||
return possibleOrientations;
|
return possibleOrientations;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void entityEntered(IPipedItem item, ForgeDirection orientation) {
|
public void entityEntered(TravelingItem item, ForgeDirection orientation) {
|
||||||
item.setSpeed(Math.min(Math.max(Utils.pipeNormalSpeed, item.getSpeed()) * 2f, Utils.pipeNormalSpeed * 30F));
|
item.setSpeed(Math.min(Math.max(Utils.pipeNormalSpeed, item.getSpeed()) * 2f, Utils.pipeNormalSpeed * 30F));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readjustSpeed(IPipedItem item) {
|
public void readjustSpeed(TravelingItem item) {
|
||||||
item.setSpeed(Math.min(Math.max(Utils.pipeNormalSpeed, item.getSpeed()) * 2f, Utils.pipeNormalSpeed * 30F));
|
item.setSpeed(Math.min(Math.max(Utils.pipeNormalSpeed, item.getSpeed()) * 2f, Utils.pipeNormalSpeed * 30F));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,15 +12,14 @@ import buildcraft.api.core.IIconProvider;
|
||||||
import buildcraft.api.core.Position;
|
import buildcraft.api.core.Position;
|
||||||
import buildcraft.api.gates.IAction;
|
import buildcraft.api.gates.IAction;
|
||||||
import buildcraft.api.tools.IToolWrench;
|
import buildcraft.api.tools.IToolWrench;
|
||||||
import buildcraft.transport.IPipedItem;
|
|
||||||
import buildcraft.core.utils.EnumColor;
|
import buildcraft.core.utils.EnumColor;
|
||||||
import buildcraft.core.utils.Utils;
|
import buildcraft.core.utils.Utils;
|
||||||
import buildcraft.transport.EntityData;
|
|
||||||
import buildcraft.transport.IItemTravelingHook;
|
import buildcraft.transport.IItemTravelingHook;
|
||||||
import buildcraft.transport.IPipeTransportItemsHook;
|
import buildcraft.transport.IPipeTransportItemsHook;
|
||||||
import buildcraft.transport.Pipe;
|
import buildcraft.transport.Pipe;
|
||||||
import buildcraft.transport.PipeIconProvider;
|
import buildcraft.transport.PipeIconProvider;
|
||||||
import buildcraft.transport.PipeTransportItems;
|
import buildcraft.transport.PipeTransportItems;
|
||||||
|
import buildcraft.transport.TravelingItem;
|
||||||
import buildcraft.transport.triggers.ActionPipeColor;
|
import buildcraft.transport.triggers.ActionPipeColor;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
@ -83,20 +82,20 @@ public class PipeItemsLapis extends Pipe<PipeTransportItems> implements IItemTra
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drop(PipeTransportItems transport, EntityData data) {
|
public void drop(PipeTransportItems transport, TravelingItem data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void centerReached(PipeTransportItems transport, EntityData data) {
|
public void centerReached(PipeTransportItems transport, TravelingItem item) {
|
||||||
data.color = getColor();
|
item.color = getColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void endReached(PipeTransportItems pipe, EntityData data, TileEntity tile) {
|
public void endReached(PipeTransportItems pipe, TravelingItem item, TileEntity tile) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readjustSpeed(IPipedItem item) {
|
public void readjustSpeed(TravelingItem item) {
|
||||||
if (item.getSpeed() > Utils.pipeNormalSpeed) {
|
if (item.getSpeed() > Utils.pipeNormalSpeed) {
|
||||||
item.setSpeed(item.getSpeed() - Utils.pipeNormalSpeed / 4.0F);
|
item.setSpeed(item.getSpeed() - Utils.pipeNormalSpeed / 4.0F);
|
||||||
}
|
}
|
||||||
|
@ -107,12 +106,12 @@ public class PipeItemsLapis extends Pipe<PipeTransportItems> implements IItemTra
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LinkedList<ForgeDirection> filterPossibleMovements(LinkedList<ForgeDirection> possibleOrientations, Position pos, EntityData data) {
|
public LinkedList<ForgeDirection> filterPossibleMovements(LinkedList<ForgeDirection> possibleOrientations, Position pos, TravelingItem travellingItem) {
|
||||||
return possibleOrientations;
|
return possibleOrientations;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void entityEntered(IPipedItem item, ForgeDirection orientation) {
|
public void entityEntered(TravelingItem travellingItem, ForgeDirection orientation) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -14,8 +14,7 @@ import buildcraft.api.power.IPowerReceptor;
|
||||||
import buildcraft.api.power.PowerHandler;
|
import buildcraft.api.power.PowerHandler;
|
||||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||||
import buildcraft.api.power.PowerHandler.Type;
|
import buildcraft.api.power.PowerHandler.Type;
|
||||||
import buildcraft.transport.IPipedItem;
|
import buildcraft.transport.TravelingItem;
|
||||||
import buildcraft.transport.EntityPassiveItem;
|
|
||||||
import buildcraft.core.proxy.CoreProxy;
|
import buildcraft.core.proxy.CoreProxy;
|
||||||
import buildcraft.core.utils.Utils;
|
import buildcraft.core.utils.Utils;
|
||||||
import buildcraft.transport.Pipe;
|
import buildcraft.transport.Pipe;
|
||||||
|
@ -246,11 +245,11 @@ public class PipeItemsObsidian extends Pipe<PipeTransportItems> implements IPowe
|
||||||
CoreProxy.proxy.removeEntity(entity);
|
CoreProxy.proxy.removeEntity(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
IPipedItem passive = new EntityPassiveItem(container.worldObj, container.xCoord + 0.5, container.yCoord + Utils.getPipeFloorOf(stack), container.zCoord + 0.5, stack);
|
TravelingItem passive = new TravelingItem(container.xCoord + 0.5, container.yCoord + Utils.getPipeFloorOf(stack), container.zCoord + 0.5, stack);
|
||||||
|
|
||||||
passive.setSpeed((float) speed);
|
passive.setSpeed((float) speed);
|
||||||
|
|
||||||
transport.entityEntering(passive, orientation);
|
transport.injectItem(passive, orientation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,13 +10,12 @@ package buildcraft.transport.pipes;
|
||||||
import buildcraft.BuildCraftTransport;
|
import buildcraft.BuildCraftTransport;
|
||||||
import buildcraft.api.core.IIconProvider;
|
import buildcraft.api.core.IIconProvider;
|
||||||
import buildcraft.api.core.Position;
|
import buildcraft.api.core.Position;
|
||||||
import buildcraft.transport.IPipedItem;
|
|
||||||
import buildcraft.core.utils.Utils;
|
import buildcraft.core.utils.Utils;
|
||||||
import buildcraft.transport.EntityData;
|
|
||||||
import buildcraft.transport.IPipeTransportItemsHook;
|
import buildcraft.transport.IPipeTransportItemsHook;
|
||||||
import buildcraft.transport.Pipe;
|
import buildcraft.transport.Pipe;
|
||||||
import buildcraft.transport.PipeIconProvider;
|
import buildcraft.transport.PipeIconProvider;
|
||||||
import buildcraft.transport.PipeTransportItems;
|
import buildcraft.transport.PipeTransportItems;
|
||||||
|
import buildcraft.transport.TravelingItem;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
@ -41,7 +40,7 @@ public class PipeItemsQuartz extends Pipe implements IPipeTransportItemsHook {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readjustSpeed(IPipedItem item) {
|
public void readjustSpeed(TravelingItem item) {
|
||||||
if (item.getSpeed() > Utils.pipeNormalSpeed) {
|
if (item.getSpeed() > Utils.pipeNormalSpeed) {
|
||||||
item.setSpeed(item.getSpeed() - Utils.pipeNormalSpeed / 4.0F);
|
item.setSpeed(item.getSpeed() - Utils.pipeNormalSpeed / 4.0F);
|
||||||
}
|
}
|
||||||
|
@ -52,11 +51,11 @@ public class PipeItemsQuartz extends Pipe implements IPipeTransportItemsHook {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LinkedList<ForgeDirection> filterPossibleMovements(LinkedList<ForgeDirection> possibleOrientations, Position pos, EntityData data) {
|
public LinkedList<ForgeDirection> filterPossibleMovements(LinkedList<ForgeDirection> possibleOrientations, Position pos, TravelingItem item) {
|
||||||
return possibleOrientations;
|
return possibleOrientations;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void entityEntered(IPipedItem item, ForgeDirection orientation) {
|
public void entityEntered(TravelingItem item, ForgeDirection orientation) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,13 +10,12 @@ package buildcraft.transport.pipes;
|
||||||
import buildcraft.BuildCraftTransport;
|
import buildcraft.BuildCraftTransport;
|
||||||
import buildcraft.api.core.IIconProvider;
|
import buildcraft.api.core.IIconProvider;
|
||||||
import buildcraft.api.core.Position;
|
import buildcraft.api.core.Position;
|
||||||
import buildcraft.transport.IPipedItem;
|
|
||||||
import buildcraft.core.utils.Utils;
|
import buildcraft.core.utils.Utils;
|
||||||
import buildcraft.transport.EntityData;
|
|
||||||
import buildcraft.transport.IPipeTransportItemsHook;
|
import buildcraft.transport.IPipeTransportItemsHook;
|
||||||
import buildcraft.transport.Pipe;
|
import buildcraft.transport.Pipe;
|
||||||
import buildcraft.transport.PipeIconProvider;
|
import buildcraft.transport.PipeIconProvider;
|
||||||
import buildcraft.transport.PipeTransportItems;
|
import buildcraft.transport.PipeTransportItems;
|
||||||
|
import buildcraft.transport.TravelingItem;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
@ -40,7 +39,7 @@ public class PipeItemsStone extends Pipe implements IPipeTransportItemsHook {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readjustSpeed(IPipedItem item) {
|
public void readjustSpeed(TravelingItem item) {
|
||||||
if (item.getSpeed() > Utils.pipeNormalSpeed) {
|
if (item.getSpeed() > Utils.pipeNormalSpeed) {
|
||||||
item.setSpeed(item.getSpeed() - Utils.pipeNormalSpeed / 2.0F);
|
item.setSpeed(item.getSpeed() - Utils.pipeNormalSpeed / 2.0F);
|
||||||
}
|
}
|
||||||
|
@ -51,11 +50,11 @@ public class PipeItemsStone extends Pipe implements IPipeTransportItemsHook {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LinkedList<ForgeDirection> filterPossibleMovements(LinkedList<ForgeDirection> possibleOrientations, Position pos, EntityData data) {
|
public LinkedList<ForgeDirection> filterPossibleMovements(LinkedList<ForgeDirection> possibleOrientations, Position pos, TravelingItem item) {
|
||||||
return possibleOrientations;
|
return possibleOrientations;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void entityEntered(IPipedItem item, ForgeDirection orientation) {
|
public void entityEntered(TravelingItem item, ForgeDirection orientation) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,11 +9,11 @@ package buildcraft.transport.pipes;
|
||||||
|
|
||||||
import buildcraft.BuildCraftTransport;
|
import buildcraft.BuildCraftTransport;
|
||||||
import buildcraft.api.core.IIconProvider;
|
import buildcraft.api.core.IIconProvider;
|
||||||
import buildcraft.transport.EntityData;
|
|
||||||
import buildcraft.transport.IItemTravelingHook;
|
import buildcraft.transport.IItemTravelingHook;
|
||||||
import buildcraft.transport.Pipe;
|
import buildcraft.transport.Pipe;
|
||||||
import buildcraft.transport.PipeIconProvider;
|
import buildcraft.transport.PipeIconProvider;
|
||||||
import buildcraft.transport.PipeTransportItems;
|
import buildcraft.transport.PipeTransportItems;
|
||||||
|
import buildcraft.transport.TravelingItem;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
@ -39,17 +39,17 @@ public class PipeItemsVoid extends Pipe<PipeTransportItems> implements IItemTrav
|
||||||
|
|
||||||
// This is called if the void pipe is only connected to one pipe
|
// This is called if the void pipe is only connected to one pipe
|
||||||
@Override
|
@Override
|
||||||
public void drop(PipeTransportItems pipe, EntityData data) {
|
public void drop(PipeTransportItems pipe, TravelingItem item) {
|
||||||
data.item.getItemStack().stackSize = 0;
|
item.getItemStack().stackSize = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is called when the void pipe is connected to multiple pipes
|
// This is called when the void pipe is connected to multiple pipes
|
||||||
@Override
|
@Override
|
||||||
public void centerReached(PipeTransportItems pipe, EntityData data) {
|
public void centerReached(PipeTransportItems pipe, TravelingItem item) {
|
||||||
transport.scheduleRemoval(data.item);
|
transport.items.scheduleRemoval(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void endReached(PipeTransportItems pipe, EntityData data, TileEntity tile) {
|
public void endReached(PipeTransportItems pipe, TravelingItem item, TileEntity tile) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,9 +15,8 @@ import buildcraft.api.power.IPowerReceptor;
|
||||||
import buildcraft.api.power.PowerHandler;
|
import buildcraft.api.power.PowerHandler;
|
||||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||||
import buildcraft.api.power.PowerHandler.Type;
|
import buildcraft.api.power.PowerHandler.Type;
|
||||||
import buildcraft.transport.IPipedItem;
|
|
||||||
import buildcraft.api.transport.PipeManager;
|
import buildcraft.api.transport.PipeManager;
|
||||||
import buildcraft.transport.EntityPassiveItem;
|
import buildcraft.transport.TravelingItem;
|
||||||
import buildcraft.core.inventory.InventoryWrapper;
|
import buildcraft.core.inventory.InventoryWrapper;
|
||||||
import buildcraft.core.utils.Utils;
|
import buildcraft.core.utils.Utils;
|
||||||
import buildcraft.transport.Pipe;
|
import buildcraft.transport.Pipe;
|
||||||
|
@ -137,9 +136,9 @@ public class PipeItemsWood extends Pipe<PipeTransportItems> implements IPowerRec
|
||||||
|
|
||||||
entityPos.moveForwards(0.6);
|
entityPos.moveForwards(0.6);
|
||||||
|
|
||||||
IPipedItem entity = new EntityPassiveItem(container.worldObj, entityPos.x, entityPos.y, entityPos.z, stack);
|
TravelingItem entity = new TravelingItem( entityPos.x, entityPos.y, entityPos.z, stack);
|
||||||
|
|
||||||
transport.entityEntering(entity, entityPos.orientation);
|
transport.injectItem(entity, entityPos.orientation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,18 +10,17 @@ package buildcraft.transport.render;
|
||||||
import buildcraft.BuildCraftCore;
|
import buildcraft.BuildCraftCore;
|
||||||
import buildcraft.BuildCraftCore.RenderMode;
|
import buildcraft.BuildCraftCore.RenderMode;
|
||||||
import buildcraft.BuildCraftTransport;
|
import buildcraft.BuildCraftTransport;
|
||||||
import buildcraft.transport.IPipedItem;
|
|
||||||
import buildcraft.core.render.RenderEntityBlock;
|
import buildcraft.core.render.RenderEntityBlock;
|
||||||
import buildcraft.core.render.RenderEntityBlock.BlockInterface;
|
import buildcraft.core.render.RenderEntityBlock.BlockInterface;
|
||||||
import buildcraft.core.utils.EnumColor;
|
import buildcraft.core.utils.EnumColor;
|
||||||
import buildcraft.core.utils.Utils;
|
import buildcraft.core.utils.Utils;
|
||||||
import buildcraft.transport.EntityData;
|
|
||||||
import buildcraft.transport.Pipe;
|
import buildcraft.transport.Pipe;
|
||||||
import buildcraft.transport.PipeIconProvider;
|
import buildcraft.transport.PipeIconProvider;
|
||||||
import buildcraft.transport.PipeTransportFluids;
|
import buildcraft.transport.PipeTransportFluids;
|
||||||
import buildcraft.transport.PipeTransportItems;
|
import buildcraft.transport.PipeTransportItems;
|
||||||
import buildcraft.transport.PipeTransportPower;
|
import buildcraft.transport.PipeTransportPower;
|
||||||
import buildcraft.transport.TileGenericPipe;
|
import buildcraft.transport.TileGenericPipe;
|
||||||
|
import buildcraft.transport.TravelingItem;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
@ -410,13 +409,13 @@ public class RenderPipe extends TileEntitySpecialRenderer {
|
||||||
float light = pipe.container.worldObj.getLightBrightness(pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord);
|
float light = pipe.container.worldObj.getLightBrightness(pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord);
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (EntityData itemData : pipe.transport.travelingEntities.values()) {
|
for (TravelingItem travellingItem : pipe.transport.items) {
|
||||||
if (count >= MAX_ITEMS_TO_RENDER) {
|
if (count >= MAX_ITEMS_TO_RENDER) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
doRenderItem(itemData.item, x + itemData.item.getPosition().x - pipe.container.xCoord, y + itemData.item.getPosition().y - pipe.container.yCoord, z + itemData.item.getPosition().z
|
doRenderItem(travellingItem, x + travellingItem.getPosition().x - pipe.container.xCoord, y + travellingItem.getPosition().y - pipe.container.yCoord, z + travellingItem.getPosition().z
|
||||||
- pipe.container.zCoord, light, itemData.color);
|
- pipe.container.zCoord, light, travellingItem.color);
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -424,13 +423,13 @@ public class RenderPipe extends TileEntitySpecialRenderer {
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doRenderItem(IPipedItem entityitem, double x, double y, double z, float light, EnumColor color) {
|
public void doRenderItem(TravelingItem travellingItem, double x, double y, double z, float light, EnumColor color) {
|
||||||
|
|
||||||
if (entityitem == null || entityitem.getItemStack() == null)
|
if (travellingItem == null || travellingItem.getItemStack() == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
float renderScale = 0.7f;
|
float renderScale = 0.7f;
|
||||||
ItemStack itemstack = entityitem.getItemStack();
|
ItemStack itemstack = travellingItem.getItemStack();
|
||||||
GL11.glPushMatrix();
|
GL11.glPushMatrix();
|
||||||
GL11.glTranslatef((float) x, (float) y, (float) z);
|
GL11.glTranslatef((float) x, (float) y, (float) z);
|
||||||
GL11.glTranslatef(0, 0.25F, 0);
|
GL11.glTranslatef(0, 0.25F, 0);
|
||||||
|
|
|
@ -10,12 +10,12 @@ package buildcraft.transport.triggers;
|
||||||
import buildcraft.api.gates.ITriggerParameter;
|
import buildcraft.api.gates.ITriggerParameter;
|
||||||
import buildcraft.core.triggers.BCTrigger;
|
import buildcraft.core.triggers.BCTrigger;
|
||||||
import buildcraft.core.utils.StringUtils;
|
import buildcraft.core.utils.StringUtils;
|
||||||
import buildcraft.transport.EntityData;
|
|
||||||
import buildcraft.transport.ITriggerPipe;
|
import buildcraft.transport.ITriggerPipe;
|
||||||
import buildcraft.transport.Pipe;
|
import buildcraft.transport.Pipe;
|
||||||
import buildcraft.transport.PipeTransportFluids;
|
import buildcraft.transport.PipeTransportFluids;
|
||||||
import buildcraft.transport.PipeTransportItems;
|
import buildcraft.transport.PipeTransportItems;
|
||||||
import buildcraft.transport.PipeTransportPower;
|
import buildcraft.transport.PipeTransportPower;
|
||||||
|
import buildcraft.transport.TravelingItem;
|
||||||
import buildcraft.transport.pipes.PipePowerWood;
|
import buildcraft.transport.pipes.PipePowerWood;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
@ -88,16 +88,16 @@ public class TriggerPipeContents extends BCTrigger implements ITriggerPipe {
|
||||||
PipeTransportItems transportItems = (PipeTransportItems) pipe.transport;
|
PipeTransportItems transportItems = (PipeTransportItems) pipe.transport;
|
||||||
|
|
||||||
if (kind == Kind.Empty)
|
if (kind == Kind.Empty)
|
||||||
return transportItems.travelingEntities.isEmpty();
|
return transportItems.items.isEmpty();
|
||||||
else if (kind == Kind.ContainsItems)
|
else if (kind == Kind.ContainsItems)
|
||||||
if (parameter != null && parameter.getItem() != null) {
|
if (parameter != null && parameter.getItem() != null) {
|
||||||
for (EntityData data : transportItems.travelingEntities.values()) {
|
for (TravelingItem item : transportItems.items) {
|
||||||
if (data.item.getItemStack().itemID == parameter.getItem().itemID
|
if (item.getItemStack().itemID == parameter.getItem().itemID
|
||||||
&& data.item.getItemStack().getItemDamage() == parameter.getItem().getItemDamage())
|
&& item.getItemStack().getItemDamage() == parameter.getItem().getItemDamage())
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
return !transportItems.travelingEntities.isEmpty();
|
return !transportItems.items.isEmpty();
|
||||||
} else if (pipe.transport instanceof PipeTransportFluids) {
|
} else if (pipe.transport instanceof PipeTransportFluids) {
|
||||||
PipeTransportFluids transportFluids = (PipeTransportFluids) pipe.transport;
|
PipeTransportFluids transportFluids = (PipeTransportFluids) pipe.transport;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue