Merge branch '6.5.x' into 7.2.x

This commit is contained in:
asiekierka 2015-09-12 15:30:55 +02:00
commit f958df297c
54 changed files with 376 additions and 251 deletions

View file

@ -10,7 +10,6 @@ package buildcraft.api.blueprints;
import java.util.LinkedList;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@ -99,12 +98,14 @@ public abstract class Schematic {
}
}
if (stack.stackSize == 0 && stack.getItem().getContainerItem() != null) {
Item container = stack.getItem().getContainerItem();
ItemStack newStack = new ItemStack(container);
slot.setStackInSlot(newStack);
} else if (stack.stackSize == 0) {
slot.setStackInSlot(null);
if (stack.stackSize == 0) {
stack.stackSize = 1;
if (stack.getItem().hasContainerItem(stack)) {
ItemStack newStack = stack.getItem().getContainerItem(stack);
slot.setStackInSlot(newStack);
} else {
slot.setStackInSlot(null);
}
}
return result;

View file

@ -10,11 +10,14 @@ package buildcraft.api.blueprints;
import java.util.LinkedList;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.core.BuildCraftAPI;
public class SchematicMask extends SchematicBlockBase {
@ -36,14 +39,19 @@ public class SchematicMask extends SchematicBlockBase {
return;
} else {
ItemStack stack = stacks.getFirst();
EntityPlayer player = BuildCraftAPI.proxy.getBuildCraftPlayer((WorldServer) context.world()).get();
// force the block to be air block, in case it's just a soft
// block which replacement is not straightforward
context.world().setBlock(x, y, z, Blocks.air, 0, 3);
stack.tryPlaceItemIntoWorld(
BuildCraftAPI.proxy.getBuildCraftPlayer((WorldServer) context.world()).get(),
context.world(), x, y, z, 1, 0.0f, 0.0f, 0.0f);
// Find nearest solid surface to place on
ForgeDirection dir = ForgeDirection.DOWN;
while (dir != ForgeDirection.UNKNOWN && BuildCraftAPI.isSoftBlock(context.world(), x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ)) {
dir = ForgeDirection.getOrientation(dir.ordinal() + 1);
}
stack.tryPlaceItemIntoWorld(player, context.world(), x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, dir.getOpposite().ordinal(), 0.0f, 0.0f, 0.0f);
}
} else {
context.world().setBlock(x, y, z, Blocks.air, 0, 3);
@ -53,9 +61,9 @@ public class SchematicMask extends SchematicBlockBase {
@Override
public boolean isAlreadyBuilt(IBuilderContext context, int x, int y, int z) {
if (isConcrete) {
return !BuildCraftAPI.isSoftBlock(context.world(), x, y, z);
return !BuildCraftAPI.getWorldProperty("replaceable").get(context.world(), x, y, z);
} else {
return BuildCraftAPI.isSoftBlock(context.world(), x, y, z);
return BuildCraftAPI.getWorldProperty("replaceable").get(context.world(), x, y, z);
}
}

View file

@ -8,7 +8,7 @@
*/
package buildcraft.api.robots;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.inventory.IInventory;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
@ -189,7 +189,7 @@ public abstract class DockingStation {
return ForgeDirection.UNKNOWN;
}
public ISidedInventory getItemInput() {
public IInventory getItemInput() {
return null;
}

View file

@ -6,7 +6,7 @@
* Please check the contents of the license, which should be located
* as "LICENSE.API" in the BuildCraft source code distribution.
*/
@API(apiVersion = "2.2", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|robotics")
@API(apiVersion = "3.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|robotics")
package buildcraft.api.robots;
import cpw.mods.fml.common.API;

View file

@ -22,7 +22,7 @@ apply plugin: 'forge' // adds the forge dependency
apply plugin: 'maven' // for uploading to a maven repo
apply plugin: 'checkstyle'
version = "7.1.1"
version = "7.2.0"
group= "com.mod-buildcraft"
archivesBaseName = "buildcraft" // the name that all artifacts will use as a base. artifacts names follow this pattern: [baseName]-[appendix]-[version]-[classifier].[extension]

View file

@ -354,6 +354,7 @@ item.PipeFluidsQuartz.name=Quartz Fluid Pipe
item.PipeFluidsGold.name=Golden Fluid Pipe
item.PipeFluidsEmerald.name=Emerald Fluid Pipe
item.PipeFluidsDiamond.name=Diamond Fluid Pipe
item.PipeFluidsClay.name=Clay Fluid Pipe
item.PipePowerWood.name=Wooden Kinesis Pipe
item.PipePowerCobblestone.name=Cobblestone Kinesis Pipe
item.PipePowerStone.name=Stone Kinesis Pipe

View file

@ -0,0 +1,13 @@
Backported from 7.1:
* Blueprint Library GUI improvements (asie)
* Clay fluid pipe (asie)
* Fluid pipe capacity scaling with fluidMultiplier (asie)
* Zone Planner improvements (dynamic texture, zooming in) (asie)
Bugs fixed:
* [#2939] Quarry makes server crash when used and chunkloading is off in some cases (asie)
* Builder inconsistently respecting OreDict (knexer)
* ClassCastException when trying to plant reeds (hea3ven)
* Random minor crashes (asie)

View file

@ -0,0 +1,14 @@
Bugs fixed:
* [#3000] Robots only charge to 20% when "go to home" is true (hea3ven, asie)
* [#2996] DockingStationPipe crash (asie)
* [#2994] Dupe with just about anything that mines (asie)
* [#2991] Carrier robots ignoring Provide Items filters (asie)
* [#2984] List sorting crash with flowers (asie)
* [#2978] Programming Table refusing to work after item removal (asie)
* [#2977, #2526] Assembly Table voiding excess energy (just made it not void it after all) (asie)
* [#2976] Builder dupes (asie)
* [#2974] Single Energy Pulse fix makes things worse - revert to previous code (asie)
* [#2971] Stamping Table overflow on multiple-output items (asie)
* [#2969] Crash when Silicon present without Transport (asie)
* [#2964] Fluid/laser textures breaking on texture pack change (asie)

View file

@ -0,0 +1,20 @@
Improvements:
* Rewritten robots request system (hea3ven)
* Changed the IRequestProvider api to be independent of robots.
* Delivery robots can now carry more than an item at a time.
* Builders, requesters and docking stations can now request more than one item at a time.
* Architect Tables are less server-intensive now (asie)
* More Ore Dictionary support for recipes (Adaptivity)
* Proper Docking Station renderer (asie)
Bugs fixed:
* [#3008] Rare crash on strange Minecraft world in MapChunk (asie)
* [#3007] "Energy Stored" trigger has incorrect behaviour (asie)
* [#3001] NPE in RobotStationPluggableRenderer (asie)
* [#2922, #2975] Composite blueprints not working (asie)
* [#2565] Fillers not liking certain blocks (asie)
* Fillers and Builders not dropping item on inability to place (asie)
* Quarry arm jitter on client side (asie)
* Robots not using the correct sides when accessing inventories/tanks (hea3ven)

View file

@ -1,3 +1,3 @@
1.6.4:BuildCraft:4.2.2
1.7.2:BuildCraft:6.0.16
1.7.10:BuildCraft:7.0.20
1.7.10:BuildCraft:7.0.23

View file

@ -600,7 +600,7 @@ public class BuildCraftBuilders extends BuildCraftMod {
"dyeBlack", 'p', Items.paper);
CoreProxy.proxy.addCraftingRecipe(new ItemStack(blueprintItem, 1), "ppp", "pip", "ppp", 'i',
new ItemStack(Items.dye, 1, 4), 'p', Items.paper);
"gemLapis", 'p', Items.paper);
if (constructionMarkerBlock != null) {
CoreProxy.proxy.addCraftingRecipe(new ItemStack(constructionMarkerBlock, 1), "l ", "r ", 'l',

View file

@ -125,6 +125,7 @@ import buildcraft.core.lib.commands.RootCommand;
import buildcraft.core.lib.engines.ItemEngine;
import buildcraft.core.lib.engines.TileEngineBase;
import buildcraft.core.lib.network.ChannelHandler;
import buildcraft.core.lib.render.FluidRenderer;
import buildcraft.core.lib.utils.ColorUtils;
import buildcraft.core.lib.utils.NBTUtils;
import buildcraft.core.lib.utils.Utils;
@ -143,7 +144,7 @@ import buildcraft.core.properties.WorldPropertyIsFluidSource;
import buildcraft.core.properties.WorldPropertyIsHarvestable;
import buildcraft.core.properties.WorldPropertyIsLeaf;
import buildcraft.core.properties.WorldPropertyIsOre;
import buildcraft.core.properties.WorldPropertyIsRock;
import buildcraft.core.properties.WorldPropertyIsReplaceable;
import buildcraft.core.properties.WorldPropertyIsShoveled;
import buildcraft.core.properties.WorldPropertyIsSoft;
import buildcraft.core.properties.WorldPropertyIsWood;
@ -154,6 +155,7 @@ import buildcraft.core.recipes.ProgrammingRecipeManager;
import buildcraft.core.recipes.RefineryRecipeManager;
import buildcraft.core.render.BlockHighlightHandler;
import buildcraft.core.render.RenderLEDTile;
import buildcraft.core.render.RenderLaser;
import buildcraft.core.statements.ActionMachineControl;
import buildcraft.core.statements.ActionRedstoneOutput;
import buildcraft.core.statements.DefaultActionProvider;
@ -388,6 +390,9 @@ public class BuildCraftCore extends BuildCraftMod {
MinecraftForge.EVENT_BUS.register(this);
MinecraftForge.EVENT_BUS.register(new BlockHighlightHandler());
MinecraftForge.EVENT_BUS.register(new ListTooltipHandler());
OreDictionary.registerOre("chestWood", Blocks.chest);
OreDictionary.registerOre("craftingTableWood", Blocks.crafting_table);
}
@Mod.EventHandler
@ -505,6 +510,7 @@ public class BuildCraftCore extends BuildCraftMod {
CropManager.setDefaultHandler(new CropHandlerPlantable());
CropManager.registerHandler(new CropHandlerReeds());
BuildCraftAPI.registerWorldProperty("replaceable", new WorldPropertyIsReplaceable());
BuildCraftAPI.registerWorldProperty("soft", new WorldPropertyIsSoft());
BuildCraftAPI.registerWorldProperty("wood", new WorldPropertyIsWood());
BuildCraftAPI.registerWorldProperty("leaves", new WorldPropertyIsLeaf());
@ -514,7 +520,6 @@ public class BuildCraftCore extends BuildCraftMod {
BuildCraftAPI.registerWorldProperty("harvestable", new WorldPropertyIsHarvestable());
BuildCraftAPI.registerWorldProperty("farmland", new WorldPropertyIsFarmland());
BuildCraftAPI.registerWorldProperty("shoveled", new WorldPropertyIsShoveled());
BuildCraftAPI.registerWorldProperty("rock", new WorldPropertyIsRock());
BuildCraftAPI.registerWorldProperty("dirt", new WorldPropertyIsDirt());
BuildCraftAPI.registerWorldProperty("fluidSource", new WorldPropertyIsFluidSource());
@ -593,6 +598,13 @@ public class BuildCraftCore extends BuildCraftMod {
}
}
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void textureHook(TextureStitchEvent.Post event) {
FluidRenderer.onTextureReload();
RenderLaser.onTextureReload();
}
public void reloadConfig(ConfigManager.RestartRequirement restartType) {
if (restartType == ConfigManager.RestartRequirement.GAME) {
modifyWorld = mainConfigManager.get("worldgen.enable").getBoolean();

View file

@ -198,14 +198,14 @@ public class BuildCraftFactory extends BuildCraftMod {
if (autoWorkbenchBlock != null) {
CoreProxy.proxy.addCraftingRecipe(new ItemStack(autoWorkbenchBlock),
"gwg",
'w', Blocks.crafting_table,
'w', "craftingTableWood",
'g', "gearStone");
CoreProxy.proxy.addCraftingRecipe(new ItemStack(autoWorkbenchBlock),
"g",
"w",
"g",
'w', Blocks.crafting_table,
'w', "craftingTableWood",
'g', "gearStone");
}
@ -232,7 +232,7 @@ public class BuildCraftFactory extends BuildCraftMod {
"ICI",
" G ",
'I', "ingotIron",
'C', Blocks.chest,
'C', "chestWood",
'G', "gearStone");
CoreProxy.proxy.addShapelessRecipe(new ItemStack(hopperBlock), Blocks.hopper, "gearStone");

View file

@ -373,7 +373,7 @@ public class BuildCraftRobotics extends BuildCraftMod {
"IPI",
"GCG",
"IRI",
'C', Blocks.chest,
'C', "chestWood",
'R', "dustRedstone",
'P', Blocks.piston,
'G', "gearIron",

View file

@ -15,7 +15,9 @@ import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.Achievement;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Optional;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLInterModComms;
import cpw.mods.fml.common.event.FMLMissingMappingsEvent;
@ -130,7 +132,7 @@ public class BuildCraftSilicon extends BuildCraftMod {
CoreProxy.proxy.registerTileEntity(TileIntegrationTable.class,
"net.minecraft.src.buildcraft.factory.TileIntegrationTable");
CoreProxy.proxy.registerTileEntity(TileChargingTable.class,
"net.minecraft.src.buildcraft.factory.TileChargingTable");
"net.minecraft.src.buildcraft.factory.TileChargingTable");
CoreProxy.proxy.registerTileEntity(TileProgrammingTable.class,
"net.minecraft.src.buildcraft.factory.TileProgrammingTable");
CoreProxy.proxy.registerTileEntity(TilePackager.class, "buildcraft.TilePackager");
@ -146,11 +148,18 @@ public class BuildCraftSilicon extends BuildCraftMod {
}
BlockDispenser.dispenseBehaviorRegistry.putObject(packageItem, new ItemPackage.DispenseBehaviour());
StripesHandlerDispenser.items.add(packageItem);
if (Loader.isModLoaded("BuildCraft|Transport")) {
initTransport();
}
SiliconProxy.proxy.registerRenderers();
}
@Optional.Method(modid = "BuildCraft|Transport")
private void initTransport() {
StripesHandlerDispenser.items.add(packageItem);
}
public static void loadRecipes() {
// TABLES
@ -228,7 +237,7 @@ public class BuildCraftSilicon extends BuildCraftMod {
"OGO",
'O', Blocks.obsidian,
'R', new ItemStack(redstoneChipset, 1, 0),
'C', Items.emerald,
'C', "gemEmerald",
'G', "gearDiamond");
CoreProxy.proxy.addCraftingRecipe(new ItemStack(assemblyTableBlock, 1, 5),
@ -236,7 +245,7 @@ public class BuildCraftSilicon extends BuildCraftMod {
"ORO",
"OGO",
'O', Blocks.obsidian,
'W', Blocks.crafting_table,
'W', "craftingTableWood",
'G', "gearGold",
'R', new ItemStack(redstoneChipset, 1, 0));
@ -245,7 +254,7 @@ public class BuildCraftSilicon extends BuildCraftMod {
"ICI",
" P ",
'I', "ingotIron",
'C', Blocks.crafting_table,
'C', "craftingTableWood",
'P', Blocks.piston);
// CHIPSETS

View file

@ -659,7 +659,7 @@ public class BuildCraftTransport extends BuildCraftMod {
CoreProxy.proxy.addCraftingRecipe(new ItemStack(filteredBufferBlock, 1),
"wdw", "wcw", "wpw", 'w', "plankWood", 'd',
BuildCraftTransport.pipeItemsDiamond, 'c', Blocks.chest, 'p',
BuildCraftTransport.pipeItemsDiamond, 'c', "chestWood", 'p',
Blocks.piston);
//Facade turning helper

View file

@ -903,7 +903,7 @@ public class TileBuilder extends TileAbstractBuilder implements IHasWork, IFluid
for (IInvSlot slot : InventoryIterator.getIterable(this)) {
if (slot.getStackInSlot() != null) {
if (StackHelper.isMatchingItem(requirement, slot.getStackInSlot())) {
if (StackHelper.isEqualItem(requirement, slot.getStackInSlot())) {
if (slot.getStackInSlot().stackSize >= left) {
return 0;
} else {

View file

@ -93,7 +93,7 @@ public class TileFiller extends TileAbstractBuilder implements IHasWork, IContro
}
private void initTemplate() {
if (currentPattern != null && box.isInitialized()) {
if (currentPattern != null && box.isInitialized() && box.sizeX() > 0 && box.sizeY() > 0 && box.sizeZ() > 0) {
currentTemplate = currentPattern.getTemplateBuilder(box, getWorldObj(), patternParameters);
currentTemplate.blueprint.excavate = excavate;
}
@ -420,16 +420,6 @@ public class TileFiller extends TileAbstractBuilder implements IHasWork, IContro
}));
}
public int getIconGlowLevel(int renderPass) {
if (renderPass == 1) { // Red LED
return done ? 15 : 0;
} else if (renderPass == 2) { // Green LED
return 0;
} else {
return -1;
}
}
@Override
public int getLEDLevel(int led) {
return (led == 0 ? done : buildersInAction.size() > 0) ? 15 : 0;

View file

@ -50,6 +50,7 @@ import buildcraft.core.Box;
import buildcraft.core.Box.Kind;
import buildcraft.core.CoreConstants;
import buildcraft.core.DefaultAreaProvider;
import buildcraft.core.DefaultProps;
import buildcraft.core.blueprints.Blueprint;
import buildcraft.core.blueprints.BptBuilderBase;
import buildcraft.core.blueprints.BptBuilderBlueprint;
@ -475,6 +476,11 @@ public class TileQuarry extends TileAbstractBuilder implements IHasWork, ISidedI
&& !(block instanceof BlockLiquid) && !(block instanceof IFluidBlock);
}
@Override
protected int getNetworkUpdateRange() {
return DefaultProps.NETWORK_UPDATE_RANGE + (int) Math.ceil(Math.sqrt(yCoord * yCoord + box.sizeX() * box.sizeX() + box.sizeZ() * box.sizeZ()));
}
@Override
public void invalidate() {
if (chunkTicket != null) {
@ -516,6 +522,7 @@ public class TileQuarry extends TileAbstractBuilder implements IHasWork, ISidedI
if (BuildCraftBuilders.quarryLoadsChunks && chunkTicket == null) {
chunkTicket = ForgeChunkManager.requestTicket(BuildCraftBuilders.instance, worldObj, Type.NORMAL);
}
if (chunkTicket != null) {
chunkTicket.getModData().setInteger("quarryX", xCoord);
chunkTicket.getModData().setInteger("quarryY", yCoord);

View file

@ -195,7 +195,7 @@ public class RecursiveBlueprintReader {
}
}
}
} else if (blockScanner != null && writingBlueprint.getData() != null) {
} else if (blockScanner != null) {
createBlueprint();
done = true;

View file

@ -45,7 +45,7 @@ public class GuiFiller extends GuiAdvancedInterface {
@Override
public IStatementParameter getParameter() {
if (slot >= instance.filler.patternParameters.length) {
if (instance.filler.patternParameters == null || slot >= instance.filler.patternParameters.length) {
return null;
} else {
return instance.filler.patternParameters[slot];

View file

@ -8,11 +8,9 @@
*/
package buildcraft.core.blueprints;
import java.io.IOException;
import java.util.ArrayList;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
@ -47,8 +45,7 @@ public abstract class BlueprintBase {
protected MappingRegistry mapping = new MappingRegistry();
protected SchematicBlockBase[] contents;
private ComputeDataThread computeData;
private byte [] data;
private NBTTagCompound nbt;
private ForgeDirection mainDir = ForgeDirection.EAST;
public BlueprintBase() {
@ -256,59 +253,24 @@ public abstract class BlueprintBase {
return new BptContext(world, box, mapping);
}
public void addSubBlueprint(BlueprintBase bpt, int x, int y, int z, ForgeDirection dir) {
NBTTagCompound nbt = new NBTTagCompound();
public void addSubBlueprint(BlueprintBase subBpt, int x, int y, int z, ForgeDirection dir) {
NBTTagCompound subNBT = new NBTTagCompound();
nbt.setInteger("x", x);
nbt.setInteger("y", y);
nbt.setInteger("z", z);
nbt.setByte("dir", (byte) dir.ordinal());
subNBT.setInteger("x", x);
subNBT.setInteger("y", y);
subNBT.setInteger("z", z);
subNBT.setByte("dir", (byte) dir.ordinal());
subNBT.setTag("bpt", subBpt.getNBT());
NBTTagCompound bptNBT = getNBT();
nbt.setTag("bpt", bptNBT);
subBlueprintsNBT.add(nbt);
subBlueprintsNBT.add(subNBT);
}
class ComputeDataThread extends Thread {
public NBTTagCompound nbt;
@Override
public void run () {
try {
BlueprintBase.this.setData(CompressedStreamTools.compress(nbt));
} catch (IOException e) {
e.printStackTrace();
}
public NBTTagCompound getNBT() {
if (nbt == null) {
nbt = new NBTTagCompound();
writeToNBTInternal(nbt);
}
}
/**
* This function will return the binary data associated to this blueprint.
* This data is computed asynchronously. If the data is not yet available,
* null will be returned.
*/
public synchronized byte[] getData() {
if (data != null) {
return data;
} else if (computeData == null) {
computeData = new ComputeDataThread();
computeData.nbt = new NBTTagCompound();
writeToNBTInternal(computeData.nbt);
computeData.start();
}
return null;
}
public synchronized NBTTagCompound getNBT() {
if (computeData == null) {
computeData = new ComputeDataThread();
computeData.nbt = new NBTTagCompound();
writeToNBTInternal(computeData.nbt);
computeData.start();
}
return computeData.nbt;
return nbt;
}
public BlueprintBase adjustToWorld(World world, int x, int y, int z, ForgeDirection o) {
@ -346,10 +308,6 @@ public abstract class BlueprintBase {
return this;
}
public synchronized void setData(byte[] b) {
data = b;
}
public abstract void loadContents(NBTTagCompound nbt) throws BptError;
public abstract void saveContents(NBTTagCompound nbt);

View file

@ -535,7 +535,7 @@ public class BptBuilderBlueprint extends BptBuilderBase {
FluidStack fluidStack = fluid != null ? FluidContainerRegistry.getFluidForFilledItem(invStk) : null;
boolean compatibleContainer = fluidStack != null && fluidStack.getFluid() == fluid && fluidStack.amount >= FluidContainerRegistry.BUCKET_VOLUME;
if (StackHelper.isMatchingItem(reqStk, invStk, true, true) || compatibleContainer) {
if (StackHelper.isEqualItem(reqStk, invStk) || compatibleContainer) {
try {
stacksUsed.add(slot.useItem(context, reqStk, slotInv));
} catch (Throwable t) {
@ -618,7 +618,7 @@ public class BptBuilderBlueprint extends BptBuilderBase {
FluidStack fluidStack = fluid != null ? FluidContainerRegistry.getFluidForFilledItem(invStk) : null;
boolean fluidFound = fluidStack != null && fluidStack.getFluid() == fluid && fluidStack.amount >= FluidContainerRegistry.BUCKET_VOLUME;
if (fluidFound || StackHelper.isCraftingEquivalent(reqStk, invStk, true)) {
if (fluidFound || StackHelper.isEqualItem(reqStk, invStk)) {
try {
usedStack = slot.getSchematic().useItem(context, reqStk, slotInv);
slot.addStackConsumed (usedStack);

View file

@ -27,6 +27,7 @@ import buildcraft.api.blueprints.MappingRegistry;
import buildcraft.api.core.ISerializable;
import buildcraft.api.core.Position;
import buildcraft.core.StackAtPosition;
import buildcraft.core.lib.inventory.InvUtils;
public class BuildingItem implements IBuildingItem, ISerializable {
@ -161,23 +162,27 @@ public class BuildingItem implements IBuildingItem, ISerializable {
private void build() {
if (slotToBuild != null) {
int destX = (int) Math.floor(destination.x);
int destY = (int) Math.floor(destination.y);
int destZ = (int) Math.floor(destination.z);
Block block = context.world().getBlock(destX, destY, destZ);
int meta = context.world().getBlockMetadata(destX, destY, destZ);
context.world().playAuxSFXAtEntity(null, 2001,
destX, destY, destZ,
Block.getIdFromBlock(block) + (meta << 12));
/*if (BlockUtil.isToughBlock(context.world(), destX, destY, destZ)) {
BlockUtil.breakBlock(context.world(), destX, destY, destZ, BuildCraftBuilders.fillerLifespanTough);
} else {
BlockUtil.breakBlock(context.world(), destX, destY, destZ, BuildCraftBuilders.fillerLifespanNormal);
}*/
slotToBuild.writeToWorld(context);
int destX = (int) Math.floor(destination.x);
int destY = (int) Math.floor(destination.y);
int destZ = (int) Math.floor(destination.z);
Block oldBlock = context.world().getBlock(destX, destY, destZ);
int oldMeta = context.world().getBlockMetadata(destX, destY, destZ);
if (slotToBuild.writeToWorld(context)) {
context.world().playAuxSFXAtEntity(null, 2001,
destX, destY, destZ,
Block.getIdFromBlock(oldBlock) + (oldMeta << 12));
} else {
for (ItemStack s : slotToBuild.stackConsumed) {
InvUtils.dropItems(context.world(), s, destX, destY, destZ);
}
}
}
}

View file

@ -27,8 +27,8 @@ public abstract class BuildingSlot {
public boolean built = false;
public void writeToWorld(IBuilderContext context) {
public boolean writeToWorld(IBuilderContext context) {
return false;
}
public void writeCompleted (IBuilderContext context, double complete) {

View file

@ -57,22 +57,28 @@ public class BuildingSlotBlock extends BuildingSlot {
}
@Override
public void writeToWorld(IBuilderContext context) {
public boolean writeToWorld(IBuilderContext context) {
if (mode == Mode.ClearIfInvalid) {
if (!getSchematic().isAlreadyBuilt(context, x, y, z)) {
if (BuildCraftBuilders.dropBrokenBlocks) {
BlockUtils.breakBlock((WorldServer) context.world(), x, y, z);
return BlockUtils.breakBlock((WorldServer) context.world(), x, y, z);
} else {
context.world().setBlockToAir(x, y, z);
return true;
}
}
} else {
try {
getSchematic().placeInWorld(context, x, y, z, stackConsumed);
// This is slightly hackish, but it's a very important way to verify
// the stored requirements.
// This is also slightly hackish, but that's what you get when
// you're unable to break an API too much.
if (!getSchematic().isAlreadyBuilt(context, x, y, z)) {
return false;
}
// This is slightly hackish, but it's a very important way to verify
// the stored requirements for anti-cheating purposes.
if (!context.world().isAirBlock(x, y, z) &&
getSchematic().getBuildingPermission() == BuildingPermission.ALL &&
getSchematic() instanceof SchematicBlock) {
@ -85,7 +91,7 @@ public class BuildingSlotBlock extends BuildingSlot {
for (ItemStack s : sb.storedRequirements) {
boolean contains = false;
for (ItemStack ss : oldRequirements) {
if (StackHelper.isMatchingItem(s, ss)) {
if (StackHelper.isEqualItem(s, ss)) {
contains = true;
break;
}
@ -95,7 +101,7 @@ public class BuildingSlotBlock extends BuildingSlot {
BCLog.logger.warn("Location: " + x + ", " + y + ", " + z + " - ItemStack: " + s.toString());
context.world().removeTileEntity(x, y, z);
context.world().setBlockToAir(x, y, z);
return;
return false;
}
}
// Restore the stored requirements.
@ -114,11 +120,16 @@ public class BuildingSlotBlock extends BuildingSlot {
if (e != null) {
e.updateEntity();
}
return true;
} catch (Throwable t) {
t.printStackTrace();
context.world().setBlockToAir(x, y, z);
return false;
}
}
return false;
}
@Override

View file

@ -34,8 +34,9 @@ public class BuildingSlotEntity extends BuildingSlot {
public int sequenceNumber;
@Override
public void writeToWorld(IBuilderContext context) {
public boolean writeToWorld(IBuilderContext context) {
schematic.writeToWorld(context);
return true;
}
@Override

View file

@ -108,10 +108,14 @@ public abstract class TileBuildCraft extends TileEntity implements IEnergyHandle
public void sendNetworkUpdate() {
if (worldObj != null && !worldObj.isRemote) {
BuildCraftCore.instance.sendToPlayers(getPacketUpdate(), worldObj,
xCoord, yCoord, zCoord, DefaultProps.NETWORK_UPDATE_RANGE);
xCoord, yCoord, zCoord, getNetworkUpdateRange());
}
}
protected int getNetworkUpdateRange() {
return DefaultProps.NETWORK_UPDATE_RANGE;
}
public void writeData(ByteBuf stream) {
}

View file

@ -133,7 +133,7 @@ public class StackHelper {
return false;
}
public static boolean isMatchingItemOrList(ItemStack a, ItemStack b) {
public static boolean isMatchingItemOrList(final ItemStack a, final ItemStack b) {
if (a == null || b == null) {
return false;
}
@ -157,10 +157,21 @@ public class StackHelper {
* @param comparison The stack to compare.
* @return true if id, damage and NBT match.
*/
public static boolean isMatchingItem(ItemStack base, ItemStack comparison) {
public static boolean isMatchingItem(final ItemStack base, final ItemStack comparison) {
return isMatchingItem(base, comparison, true, true);
}
/**
* This variant also checks damage for damaged items.
*/
public static boolean isEqualItem(final ItemStack a, final ItemStack b) {
if (isMatchingItem(a, b, false, true)) {
return isWildcard(a) || isWildcard(b) || a.getItemDamage() == b.getItemDamage();
} else {
return false;
}
}
/**
* Compares item id, and optionally damage and NBT. Accepts wildcard damage.
* Ignores damage entirely if the item doesn't have subtypes.

View file

@ -40,6 +40,22 @@ public final class FluidRenderer {
}
public static void onTextureReload() {
for (int[] ia : flowingRenderCache.values()) {
for (int i : ia) {
GL11.glDeleteLists(i, 1);
}
}
flowingRenderCache.clear();
for (int[] ia : stillRenderCache.values()) {
for (int i : ia) {
GL11.glDeleteLists(i, 1);
}
}
stillRenderCache.clear();
}
public static IIcon getFluidTexture(FluidStack fluidStack, boolean flowing) {
if (fluidStack == null) {
return null;

View file

@ -108,7 +108,6 @@ public class BlockMiner {
Block.getIdFromBlock(block)
+ (meta << 12));
Utils.preDestroyBlock(world, x, y, z);
world.setBlockToAir(x, y, z);
} else {
hasFailed = true;

View file

@ -0,0 +1,21 @@
/**
* Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team
* 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.core.properties;
import net.minecraft.block.Block;
import net.minecraft.world.IBlockAccess;
public class WorldPropertyIsReplaceable extends WorldProperty {
@Override
public boolean get(IBlockAccess blockAccess, Block block, int meta, int x, int y, int z) {
return block == null
|| block.isAir(blockAccess, x, y, z)
|| block.isReplaceable(blockAccess, x, y, z);
}
}

View file

@ -38,6 +38,10 @@ public class RenderLaser extends Render {
public RenderLaser() {
}
public static void onTextureReload() {
scaledBoxes = null;
}
private static ModelRenderer getBox(int index) {
if (box == null) {
box = new ModelRenderer[40];

View file

@ -65,7 +65,7 @@ public class TriggerEnergy extends BCStatement implements ITriggerInternal {
}
if (energyMaxStored > 0) {
float level = energyStored / energyMaxStored;
float level = (float) energyStored / (float) energyMaxStored;
if (high) {
return level > 0.95F;
} else {

View file

@ -10,10 +10,8 @@ package buildcraft.factory;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import cpw.mods.fml.relauncher.Side;
@ -39,7 +37,7 @@ import buildcraft.core.lib.network.command.ICommandReceiver;
import buildcraft.core.lib.utils.NetworkUtils;
import buildcraft.core.recipes.RefineryRecipeManager;
public class TileRefinery extends TileBuildCraft implements IFluidHandler, IInventory, IHasWork, IFlexibleCrafter, ICommandReceiver {
public class TileRefinery extends TileBuildCraft implements IFluidHandler, IHasWork, IFlexibleCrafter, ICommandReceiver {
public static int LIQUID_PER_SLOT = FluidContainerRegistry.BUCKET_VOLUME * 4;
@ -65,50 +63,6 @@ public class TileRefinery extends TileBuildCraft implements IFluidHandler, IInve
this.setBattery(new RFBattery(10000, 1500, 0));
}
@Override
public int getSizeInventory() {
return 0;
}
@Override
public ItemStack getStackInSlot(int i) {
return null;
}
@Override
public ItemStack decrStackSize(int i, int j) {
return null;
}
@Override
public void setInventorySlotContents(int i, ItemStack itemstack) {
}
@Override
public String getInventoryName() {
return null;
}
@Override
public int getInventoryStackLimit() {
return 0;
}
@Override
public boolean isItemValidForSlot(int i, ItemStack itemstack) {
return false;
}
@Override
public boolean isUseableByPlayer(EntityPlayer entityplayer) {
return worldObj.getTileEntity(xCoord, yCoord, zCoord) == this;
}
@Override
public ItemStack getStackInSlotOnClosing(int var1) {
return null;
}
@Override
public void updateEntity() {
super.updateEntity();
@ -228,14 +182,6 @@ public class TileRefinery extends TileBuildCraft implements IFluidHandler, IInve
}
}
@Override
public void openInventory() {
}
@Override
public void closeInventory() {
}
public void resetFilters() {
for (SingleUseTank tank : tankManager) {
tank.setAcceptedFluid(null);
@ -357,11 +303,6 @@ public class TileRefinery extends TileBuildCraft implements IFluidHandler, IInve
return true;
}
@Override
public boolean hasCustomInventoryName() {
return false;
}
@Override
public int getCraftingItemStackSize() {
return 0;

View file

@ -26,7 +26,7 @@ public class ContainerRefinery extends BuildCraftContainer {
public TileRefinery refinery;
public ContainerRefinery(InventoryPlayer inventory, TileRefinery refinery) {
super(refinery.getSizeInventory());
super(0);
for (int l = 0; l < 3; l++) {
for (int k1 = 0; k1 < 9; k1++) {
@ -43,7 +43,7 @@ public class ContainerRefinery extends BuildCraftContainer {
@Override
public boolean canInteractWith(EntityPlayer entityplayer) {
return refinery.isUseableByPlayer(entityplayer);
return entityplayer.worldObj.getTileEntity(refinery.xCoord, refinery.yCoord, refinery.zCoord) == refinery;
}
/* SETTING AND GETTING FILTERS */

View file

@ -28,7 +28,7 @@ public class GuiRefinery extends GuiAdvancedInterface {
private final ContainerRefinery container;
public GuiRefinery(InventoryPlayer inventory, TileRefinery refinery) {
super(new ContainerRefinery(inventory, refinery), refinery, TEXTURE);
super(new ContainerRefinery(inventory, refinery), null, TEXTURE);
xSize = 175;
ySize = 207;
@ -83,12 +83,10 @@ public class GuiRefinery extends GuiAdvancedInterface {
container.refinery.tankManager.get(position).colorRenderCache = 0xFFFFFF;
}
} else {
TileRefinery ref = (TileRefinery) this.tile;
if (position == 0) {
container.setFilter(position, ref.tanks[0].getFluidType());
container.setFilter(position, container.refinery.tanks[0].getFluidType());
} else if (position == 1) {
container.setFilter(position, ref.tanks[1].getFluidType());
container.setFilter(position, container.refinery.tanks[1].getFluidType());
}
}
}

View file

@ -236,7 +236,7 @@ public class DockingStationPipe extends DockingStation implements IRequestProvid
@Override
public void unsafeRelease(EntityRobotBase robot) {
super.unsafeRelease(robot);
if (robotTaking() == null) {
if (robotTaking() == null && getPipe() != null) {
getPipe().scheduleRenderUpdate();
}
}

View file

@ -696,7 +696,9 @@ public class EntityRobot extends EntityRobotBase implements
@Override
public ItemStack getStackInSlotOnClosing(int var1) {
return inv[var1].splitStack(var1);
ItemStack stack = inv[var1];
inv[var1] = null;
return stack;
}
@Override

View file

@ -38,7 +38,7 @@ public class RobotStationPluggable extends PipePluggable implements IPipePluggab
return;
}
RobotStationState state = ((RobotStationPluggable) pipePluggable).renderState;
RobotStationState state = ((RobotStationPluggable) pipePluggable).getRenderState();
switch(state) {
case None:
@ -188,6 +188,9 @@ public class RobotStationPluggable extends PipePluggable implements IPipePluggab
}
public RobotStationState getRenderState() {
if (renderState == null) {
renderState = RobotStationState.None;
}
return renderState;
}
@ -204,12 +207,16 @@ public class RobotStationPluggable extends PipePluggable implements IPipePluggab
@Override
public boolean requiresRenderUpdate(PipePluggable o) {
return renderState != ((RobotStationPluggable) o).renderState;
return getRenderState() != ((RobotStationPluggable) o).getRenderState();
}
@Override
public void readData(ByteBuf data) {
this.renderState = RobotStationState.values()[data.readUnsignedByte()];
try {
this.renderState = RobotStationState.values()[data.readUnsignedByte()];
} catch (ArrayIndexOutOfBoundsException e) {
this.renderState = RobotStationState.None;
}
}
@Override
@ -247,7 +254,7 @@ public class RobotStationPluggable extends PipePluggable implements IPipePluggab
info.add("RobotStationPluggable: No station found!");
} else {
refreshRenderState();
info.add("Docking Station (side " + side.name() + ", " + renderState.name() + ")");
info.add("Docking Station (side " + side.name() + ", " + getRenderState().name() + ")");
if (station.robotTaking() != null && station.robotTaking() instanceof IDebuggable) {
((IDebuggable) station.robotTaking()).getDebugInfo(info, ForgeDirection.UNKNOWN, debugger, player);
}

View file

@ -8,6 +8,7 @@
*/
package buildcraft.robotics.ai;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
@ -65,17 +66,18 @@ public class AIRobotLoad extends AIRobot {
int loaded = 0;
ISidedInventory tileInventory = station.getItemInput();
IInventory tileInventory = station.getItemInput();
if (tileInventory == null) {
return false;
}
for (IInvSlot slot : InventoryIterator.getIterable(tileInventory, station.getItemInputSide())) {
for (IInvSlot slot : InventoryIterator.getIterable(tileInventory, station.getItemInputSide())) {
ItemStack stack = slot.getStackInSlot();
if (stack == null
|| !slot.canTakeStackFromSlot(stack)
|| !filter.matches(stack)
|| !ActionStationProvideItems.canExtractItem(station, stack)
|| !ActionRobotFilter.canInteractWithItem(station, filter,
ActionStationProvideItems.class)) {
continue;

View file

@ -41,8 +41,10 @@ public class AIRobotMain extends AIRobot {
startDelegateAI(new AIRobotRecharge(robot));
}
}
} else if (overridingAI != null && ai != overridingAI) {
startDelegateAI(overridingAI);
} else if (!(ai instanceof AIRobotRecharge)) {
if (overridingAI != null && ai != overridingAI) {
startDelegateAI(overridingAI);
}
}
}

View file

@ -51,13 +51,11 @@ public class AIRobotSearchStackRequest extends AIRobot {
@Override
public void delegateAIEnded(AIRobot ai) {
if (ai instanceof AIRobotSearchStation) {
if (!ai.success()) {
terminate();
} else {
if (ai.success()) {
request = getOrderFromRequestingStation(((AIRobotSearchStation) ai).targetStation, true);
terminate();
}
terminate();
}
}

View file

@ -40,6 +40,10 @@ public class MapChunk {
int y = chunk.getHeightValue(bx, bz);
int color;
if (y < 0) {
y = 255;
}
while ((color = chunk.getBlock(bx, y, bz).getMapColor(0).colorIndex) == MapColor.airColor.colorIndex) {
y--;
if (y < 0) {

View file

@ -125,8 +125,11 @@ public class MapWorld {
if (v > 1) {
timeToUpdate.put(c, v - 1);
} else {
timeToUpdate.remove(c);
updateChunk(c);
try {
updateChunk(c);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}

View file

@ -9,11 +9,15 @@
package buildcraft.robotics.statements;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.ItemStack;
import buildcraft.api.robots.DockingStation;
import buildcraft.api.statements.IActionInternal;
import buildcraft.api.statements.IStatementContainer;
import buildcraft.api.statements.IStatementParameter;
import buildcraft.api.statements.StatementParameterItemStack;
import buildcraft.api.statements.StatementSlot;
import buildcraft.core.lib.inventory.filters.StatementParameterStackFilter;
import buildcraft.core.lib.utils.StringUtils;
import buildcraft.core.statements.BCStatement;
@ -48,4 +52,24 @@ public class ActionStationProvideItems extends BCStatement implements IActionInt
IStatementParameter[] parameters) {
}
public static boolean canExtractItem(DockingStation station, ItemStack stack) {
boolean hasFilter = false;
for (StatementSlot s : station.getActiveActions()) {
if (s.statement instanceof ActionStationProvideItems) {
StatementParameterStackFilter param = new StatementParameterStackFilter(s.parameters);
if (param.hasFilter()) {
hasFilter = true;
if (param.matches(stack)) {
return true;
}
}
}
}
return !hasFilter;
}
}

View file

@ -77,6 +77,9 @@ public class TileAssemblyTable extends TileLaserTableBase implements IInventory,
}
if (currentRecipe == null) {
/* if (getEnergy() >= 50) {
setEnergy(Math.max(0, getEnergy() - 50));
} */
return;
}
@ -89,10 +92,10 @@ public class TileAssemblyTable extends TileLaserTableBase implements IInventory,
}
if (getEnergy() >= currentRecipe.craft(this, true).energyCost) {
setEnergy(0);
if (currentRecipe.canBeCrafted(this)) {
outputStack(currentRecipe.craft(this, false).crafted.copy(), true);
CraftingResult<ItemStack> result = currentRecipe.craft(this, false);
setEnergy(Math.max(0, getEnergy() - result.energyCost));
outputStack(result.crafted.copy(), true);
setNextCurrentRecipe();
}

View file

@ -102,7 +102,7 @@ public class TileProgrammingTable extends TileLaserTableBase implements IInvento
public void readData(ByteBuf stream) {
super.readData(stream);
currentRecipeId = NetworkUtils.readUTF(stream);
optionId = stream.readUnsignedByte();
optionId = stream.readByte();
updateRecipe();
}
@ -158,7 +158,7 @@ public class TileProgrammingTable extends TileLaserTableBase implements IInvento
}
}
if ((oldId != null && currentRecipeId != null && !oldId.equals(currentRecipeId))
if ((oldId != null && currentRecipeId != null && !oldId.equals(currentRecipeId))
|| (oldId == null && currentRecipeId != null)
|| (oldId != null && currentRecipeId == null)) {
optionId = -1;
@ -187,9 +187,11 @@ public class TileProgrammingTable extends TileLaserTableBase implements IInvento
@Override
public void receiveCommand(String command, Side side, Object sender, ByteBuf stream) {
if (side.isServer() && "select".equals(command)) {
optionId = stream.readUnsignedByte();
optionId = stream.readByte();
if (optionId >= options.size()) {
optionId = 0;
optionId = -1;
} else if (optionId < -1) {
optionId = -1;
}
queueNetworkUpdate();

View file

@ -2,6 +2,7 @@ package buildcraft.silicon;
import java.lang.ref.WeakReference;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
@ -142,7 +143,29 @@ public class TileStampingTable extends TileLaserTableBase implements IHasWork, I
handleLeftoverItems(crafting);
handleLeftoverItems(internalPlayer.inventory);
outputStack(result, this, 1, false);
for (int i = 1; i <= 4; i++) {
ItemStack inside = inv.getStackInSlot(i);
if (inside == null || inside.stackSize <= 0) {
inv.setInventorySlotContents(i, result.copy());
result.stackSize = 0;
break;
} else if (StackHelper.canStacksMerge(inside, result)) {
result.stackSize -= StackHelper.mergeStacks(result, inside, true);
if (result.stackSize == 0) {
break;
}
}
}
if (result.stackSize > 0) {
EntityItem entityitem = new EntityItem(worldObj, xCoord + 0.5, yCoord + 0.7, zCoord + 0.5,
result.copy());
worldObj.spawnEntityInWorld(entityitem);
result.stackSize = 0;
}
decrStackSize(0, 1);
} else {
ItemStack outputSlot = getStackInSlot(1);

View file

@ -168,7 +168,11 @@ public class GuiProgrammingTable extends GuiAdvancedInterface {
return;
}
table.rpcSelectOption(slot.id);
if (table.optionId == slot.id) {
table.rpcSelectOption(-1);
} else {
table.rpcSelectOption(slot.id);
}
}
}

View file

@ -46,12 +46,17 @@ public class PipePluggableState implements ISerializable {
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
if (this.pluggableMatrix.isConnected(dir)) {
try {
PipePluggable p = PipeManager.pipePluggables.get(data.readUnsignedShort()).newInstance();
p.readData(data);
pluggables[dir.ordinal()] = p;
Class<? extends PipePluggable> pc = PipeManager.pipePluggables.get(data.readUnsignedShort());
if (pluggables[dir.ordinal()] == null || pc != pluggables[dir.ordinal()].getClass()) {
PipePluggable p = pc.newInstance();
pluggables[dir.ordinal()] = p;
}
} catch (Exception e) {
e.printStackTrace();
}
if (pluggables[dir.ordinal()] != null) {
pluggables[dir.ordinal()].readData(data);
}
} else {
pluggables[dir.ordinal()] = null;
}

View file

@ -289,7 +289,9 @@ public class PipeTransportPower extends PipeTransport implements IDebuggable {
Object tile = providers[dir.ordinal()];
if (tile instanceof IPipeTile && ((Pipe<?>) ((IPipeTile) tile).getPipe()).transport instanceof PipeTransportPower) {
if (tile instanceof IPipeTile
&& ((IPipeTile) tile).getPipe() != null
&& ((Pipe<?>) ((IPipeTile) tile).getPipe()).transport instanceof PipeTransportPower) {
continue;
}
if (tile instanceof IEnergyHandler) {
@ -332,7 +334,7 @@ public class PipeTransportPower extends PipeTransport implements IDebuggable {
TileEntity entity = tiles[i];
if (entity instanceof IPipeTile && ((IPipeTile) entity).getPipeType() == IPipeTile.PipeType.POWER) {
IPipeTile nearbyTile = (IPipeTile) entity;
if (nearbyTile.getPipe() == null) {
if (nearbyTile.getPipe() == null || nearbyTile.getPipeType() != IPipeTile.PipeType.POWER) {
continue;
}
PipeTransportPower nearbyTransport = (PipeTransportPower) ((Pipe) nearbyTile.getPipe()).transport;

View file

@ -21,7 +21,6 @@ import buildcraft.api.gates.IGate;
import buildcraft.api.gates.IGateExpansion;
import buildcraft.api.statements.IActionInternal;
import buildcraft.api.statements.IStatement;
import buildcraft.core.lib.utils.MathUtils;
import buildcraft.transport.statements.ActionEnergyPulsar;
import buildcraft.transport.statements.ActionSingleEnergyPulse;
@ -39,6 +38,7 @@ public final class GateExpansionPulsar extends GateExpansionBuildcraft implement
}
private class GateExpansionControllerPulsar extends GateExpansionController {
private static final int PULSE_PERIOD = 10;
private boolean isActive;
private boolean singlePulse;
@ -58,7 +58,7 @@ public final class GateExpansionPulsar extends GateExpansionBuildcraft implement
@Override
public void startResolution() {
if (isActive) {
if (isActive()) {
disablePulse();
}
}
@ -84,35 +84,46 @@ public final class GateExpansionPulsar extends GateExpansionBuildcraft implement
@Override
public void tick(IGate gate) {
if (!isActive && hasPulsed) {
hasPulsed = false;
}
if (tick++ % PULSE_PERIOD != 0) {
// only do the treatement once every period
return;
}
gate.setPulsing(isActive);
if (!isActive) {
gate.setPulsing(false);
return;
}
if (pipeTile instanceof IEnergyHandler && ((singlePulse && !hasPulsed) || (!singlePulse && isActive))) {
((IEnergyHandler) pipeTile).receiveEnergy(ForgeDirection.UNKNOWN, MathUtils.clamp(1 << (count - 1), 1, 64) * 10,
if (pipeTile instanceof IEnergyHandler && (!singlePulse || !hasPulsed)) {
gate.setPulsing(true);
((IEnergyHandler) pipeTile).receiveEnergy(ForgeDirection.UNKNOWN, Math.min(1 << (count - 1), 64) * 10,
false);
hasPulsed = true;
} else {
gate.setPulsing(true);
}
}
private void enableSinglePulse(int count) {
isActive = true;
singlePulse = true;
hasPulsed = false;
isActive = true;
this.count = count;
}
private void enablePulse(int count) {
isActive = true;
hasPulsed = false;
singlePulse = false;
this.count = count;
}
private void disablePulse() {
if (!isActive) {
hasPulsed = false;
}
isActive = false;
this.count = 0;
}

View file

@ -8,8 +8,8 @@
*/
package buildcraft.transport.pipes;
import java.util.Arrays;
import java.util.List;
import java.util.WeakHashMap;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
@ -42,16 +42,11 @@ import buildcraft.transport.pipes.events.PipeEventItem;
import buildcraft.transport.utils.TransportUtils;
public class PipeItemsObsidian extends Pipe<PipeTransportItems> implements IEnergyHandler {
private RFBattery battery = new RFBattery(2560, 640, 0);
private int[] entitiesDropped;
private int entitiesDroppedIndex = 0;
private final RFBattery battery = new RFBattery(2560, 640, 0);
private final WeakHashMap<Entity, Long> entityDropTime = new WeakHashMap<Entity, Long>();
public PipeItemsObsidian(Item item) {
super(new PipeTransportItems(), item);
entitiesDropped = new int[32];
Arrays.fill(entitiesDropped, -1);
}
@Override
@ -257,12 +252,7 @@ public class PipeItemsObsidian extends Pipe<PipeTransportItems> implements IEner
}
public void eventHandler(PipeEventItem.DropItem event) {
if (entitiesDroppedIndex + 1 >= entitiesDropped.length) {
entitiesDroppedIndex = 0;
} else {
entitiesDroppedIndex++;
}
entitiesDropped[entitiesDroppedIndex] = event.entity.getEntityId();
entityDropTime.put(event.entity, event.entity.worldObj.getTotalWorldTime() + 200);
}
public boolean canSuck(Entity entity, int distance) {
@ -276,10 +266,9 @@ public class PipeItemsObsidian extends Pipe<PipeTransportItems> implements IEner
return false;
}
for (int element : entitiesDropped) {
if (item.getEntityId() == element) {
return false;
}
long wt = entity.worldObj.getTotalWorldTime();
if (entityDropTime.containsKey(entity) && entityDropTime.get(entity) >= wt) {
return false;
}
return battery.getEnergyStored() >= distance * 10;