Adjusted Lifespan of Item drops

Added a config option for the lifespan of items dropped by pipes and
machines.

Its possible I missed some drop code, it seems to be scattered all over
the place.
This commit is contained in:
CovertJaguar 2012-11-17 02:44:23 -08:00
parent df4531e839
commit 379fa45a46
6 changed files with 37 additions and 7 deletions

View file

@ -88,6 +88,8 @@ public class BuildCraftCore {
public static boolean dropBrokenBlocks = true; // Set to false to prevent the filler from dropping broken blocks. public static boolean dropBrokenBlocks = true; // Set to false to prevent the filler from dropping broken blocks.
public static int itemLifespan = 1200;
public static int updateFactor = 10; public static int updateFactor = 10;
public static BuildCraftConfiguration mainConfiguration; public static BuildCraftConfiguration mainConfiguration;
@ -164,17 +166,23 @@ public class BuildCraftCore {
stripesLaserTexture = 0 * 16 + 3; stripesLaserTexture = 0 * 16 + 3;
transparentTexture = 0 * 16 + 0; transparentTexture = 0 * 16 + 0;
Property continuousCurrent = BuildCraftCore.mainConfiguration.get( Configuration.CATEGORY_GENERAL,"current.continuous", DefaultProps.CURRENT_CONTINUOUS); Property continuousCurrent = BuildCraftCore.mainConfiguration.get( Configuration.CATEGORY_GENERAL, "current.continuous", DefaultProps.CURRENT_CONTINUOUS);
continuousCurrent.comment = "set to true for allowing machines to be driven by continuous current"; continuousCurrent.comment = "set to true for allowing machines to be driven by continuous current";
continuousCurrentModel = continuousCurrent.getBoolean(DefaultProps.CURRENT_CONTINUOUS); continuousCurrentModel = continuousCurrent.getBoolean(DefaultProps.CURRENT_CONTINUOUS);
Property trackNetwork = BuildCraftCore.mainConfiguration.get( Configuration.CATEGORY_GENERAL,"trackNetworkUsage", false); Property trackNetwork = BuildCraftCore.mainConfiguration.get( Configuration.CATEGORY_GENERAL, "trackNetworkUsage", false);
trackNetworkUsage = trackNetwork.getBoolean(false); trackNetworkUsage = trackNetwork.getBoolean(false);
Property dropBlock = BuildCraftCore.mainConfiguration.get( Configuration.CATEGORY_GENERAL,"dropBrokenBlocks", true); Property dropBlock = BuildCraftCore.mainConfiguration.get( Configuration.CATEGORY_GENERAL,"dropBrokenBlocks", true);
dropBlock.comment = "set to false to prevent fillers from dropping blocks."; dropBlock.comment = "set to false to prevent fillers from dropping blocks.";
dropBrokenBlocks = dropBlock.getBoolean(true); dropBrokenBlocks = dropBlock.getBoolean(true);
Property lifespan = BuildCraftCore.mainConfiguration.get( Configuration.CATEGORY_GENERAL, "itemLifespan", itemLifespan);
lifespan.comment = "the lifespan in ticks of items dropped on the ground by pipes and machines, vanilla = 6000, default = 1200";
itemLifespan = lifespan.getInt(itemLifespan);
if(itemLifespan < 100)
itemLifespan = 100;
Property powerFrameworkClass = BuildCraftCore.mainConfiguration.get( Configuration.CATEGORY_GENERAL,"power.framework", "buildcraft.energy.PneumaticPowerFramework"); Property powerFrameworkClass = BuildCraftCore.mainConfiguration.get( Configuration.CATEGORY_GENERAL,"power.framework", "buildcraft.energy.PneumaticPowerFramework");
Property factor = BuildCraftCore.mainConfiguration.get( Configuration.CATEGORY_GENERAL,"network.updateFactor", 10); Property factor = BuildCraftCore.mainConfiguration.get( Configuration.CATEGORY_GENERAL,"network.updateFactor", 10);

View file

@ -304,6 +304,9 @@ public class EntityPassiveItem implements IPipedItem {
EntityItem entityitem = new EntityItem(worldObj, position.x, position.y, position.z, getItemStack()); 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; float f3 = 0.00F + worldObj.rand.nextFloat() * 0.04F - 0.02F;
entityitem.motionX = (float) worldObj.rand.nextGaussian() * f3 + motion.x; entityitem.motionX = (float) worldObj.rand.nextGaussian() * f3 + motion.x;
entityitem.motionY = (float) worldObj.rand.nextGaussian() * f3 + motion.y; entityitem.motionY = (float) worldObj.rand.nextGaussian() * f3 + motion.y;
@ -311,7 +314,6 @@ public class EntityPassiveItem implements IPipedItem {
worldObj.spawnEntityInWorld(entityitem); worldObj.spawnEntityInWorld(entityitem);
remove(); remove();
entityitem.delayBeforeCanPickup = 20;
return entityitem; return entityitem;
} else { } else {
return null; return null;

View file

@ -34,8 +34,22 @@ public class BlockUtil {
public static void breakBlock(World world, int x, int y, int z) { public static void breakBlock(World world, int x, int y, int z) {
int blockId = world.getBlockId(x, y, z); int blockId = world.getBlockId(x, y, z);
if (blockId != 0 && BuildCraftCore.dropBrokenBlocks) if (blockId != 0 && BuildCraftCore.dropBrokenBlocks && !world.isRemote && world.getGameRules().getGameRuleBooleanValue("doTileDrops")) {
Block.blocksList[blockId].dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0); List<ItemStack> items = getBlockDropped(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
for (ItemStack item : items) {
float var = 0.7F;
double dx = world.rand.nextFloat() * var + (1.0F - var) * 0.5D;
double dy = world.rand.nextFloat() * var + (1.0F - var) * 0.5D;
double dz = world.rand.nextFloat() * var + (1.0F - var) * 0.5D;
EntityItem entityitem = new EntityItem(world, x + dx, y + dy, z + dz, item);
entityitem.lifespan = BuildCraftCore.itemLifespan;
entityitem.delayBeforeCanPickup = 10;
world.spawnEntityInWorld(entityitem);
}
}
world.setBlockWithNotify(x, y, z, 0); world.setBlockWithNotify(x, y, z, 0);
} }

View file

@ -93,6 +93,9 @@ public class TileMiningWell extends TileMachine implements IMachine, IPowerRecep
EntityItem entityitem = new EntityItem(world, xCoord + f, yCoord + f1 + 0.5F, zCoord + f2, stack); EntityItem entityitem = new EntityItem(world, xCoord + f, yCoord + f1 + 0.5F, zCoord + f2, stack);
entityitem.lifespan = BuildCraftCore.itemLifespan;
entityitem.delayBeforeCanPickup = 10;
float f3 = 0.05F; float f3 = 0.05F;
entityitem.motionX = (float) world.rand.nextGaussian() * f3; entityitem.motionX = (float) world.rand.nextGaussian() * f3;
entityitem.motionY = (float) world.rand.nextGaussian() * f3 + 1.0F; entityitem.motionY = (float) world.rand.nextGaussian() * f3 + 1.0F;

View file

@ -390,7 +390,7 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor,
// Collect any lost items laying around // Collect any lost items laying around
double[] head = getHead(); double[] head = getHead();
AxisAlignedBB axis = AxisAlignedBB.getBoundingBox(head[0] - 1.5, head[1], head[2] - 1.5, head[0] + 2.5, head[1] + 2.5, head[2] + 2.5); AxisAlignedBB axis = AxisAlignedBB.getBoundingBox(head[0] - 2, head[1] - 2, head[2] - 2, head[0] + 3, head[1] + 3, head[2] + 3);
List result = worldObj.getEntitiesWithinAABB(EntityItem.class, axis); List result = worldObj.getEntitiesWithinAABB(EntityItem.class, axis);
for (int ii = 0; ii < result.size(); ii++) { for (int ii = 0; ii < result.size(); ii++) {
if (result.get(ii) instanceof EntityItem) { if (result.get(ii) instanceof EntityItem) {
@ -422,6 +422,9 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor,
EntityItem entityitem = new EntityItem(worldObj, xCoord + f, yCoord + f1 + 0.5F, zCoord + f2, stack); EntityItem entityitem = new EntityItem(worldObj, xCoord + f, yCoord + f1 + 0.5F, zCoord + f2, stack);
entityitem.lifespan = BuildCraftCore.itemLifespan;
entityitem.delayBeforeCanPickup = 10;
float f3 = 0.05F; float f3 = 0.05F;
entityitem.motionX = (float) worldObj.rand.nextGaussian() * f3; entityitem.motionX = (float) worldObj.rand.nextGaussian() * f3;
entityitem.motionY = (float) worldObj.rand.nextGaussian() * f3 + 1.0F; entityitem.motionY = (float) worldObj.rand.nextGaussian() * f3 + 1.0F;

View file

@ -360,7 +360,7 @@ public class PipeTransportItems extends PipeTransport {
entity.setContainer(container); entity.setContainer(container);
EntityData data = new EntityData(entity, ForgeDirection.values()[dataTag.getInteger("input")]); EntityData data = new EntityData(entity, ForgeDirection.values()[dataTag.getInteger("input")]);
data.output = ForgeDirection.values()[dataTag.getInteger("output")]; data.output = ForgeDirection.getOrientation(dataTag.getInteger("output"));
data.toCenter = dataTag.getBoolean("toCenter"); data.toCenter = dataTag.getBoolean("toCenter");
entitiesToLoad.add(data); entitiesToLoad.add(data);