Merge branch '7.1.x' of github.com:BuildCraft/BuildCraft into 7.1.x

This commit is contained in:
asiekierka 2015-08-03 19:22:11 +02:00
commit 9a68480932
99 changed files with 1537 additions and 853 deletions

View file

@ -8,32 +8,24 @@
*/
package buildcraft.api.core;
import java.lang.reflect.Method;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public final class BCLog {
public static final Logger logger = LogManager.getLogger("BuildCraft");
/**
* Deactivate constructor
*/
private BCLog() {
}
public static void initLog() {
logger.info("Starting BuildCraft " + getVersion());
logger.info("Copyright (c) SpaceToad, 2011-2015");
logger.info("http://www.mod-buildcraft.com");
@Deprecated
public static void logErrorAPI(String mod, Throwable error, Class<?> classFile) {
logErrorAPI(error, classFile);
}
public static void logErrorAPI(String mod, Throwable error, Class<?> classFile) {
StringBuilder msg = new StringBuilder(mod);
msg.append(" API error, please update your mods. Error: ").append(error);
public static void logErrorAPI(Throwable error, Class<?> classFile) {
StringBuilder msg = new StringBuilder("API error! Please update your mods. Error: ");
msg.append(error);
StackTraceElement[] stackTrace = error.getStackTrace();
if (stackTrace.length > 0) {
msg.append(", ").append(stackTrace[0]);
@ -42,19 +34,13 @@ public final class BCLog {
logger.log(Level.ERROR, msg.toString());
if (classFile != null) {
msg = new StringBuilder(mod);
msg.append(" API error: ").append(classFile.getSimpleName()).append(" is loaded from ").append(classFile.getProtectionDomain().getCodeSource().getLocation());
msg.append("API error: ").append(classFile.getSimpleName()).append(" is loaded from ").append(classFile.getProtectionDomain().getCodeSource().getLocation());
logger.log(Level.ERROR, msg.toString());
}
}
public static String getVersion() {
try {
Class<?> clazz = Class.forName("buildcraft.core.Version");
Method method = clazz.getDeclaredMethod("getVersion");
return String.valueOf(method.invoke(null));
} catch (Exception e) {
return "UNKNOWN VERSION";
}
}
@Deprecated
public static String getVersion() {
return BuildCraftAPI.getVersion();
}
}

View file

@ -18,7 +18,6 @@ import net.minecraft.world.World;
* This class is a comparable container for integer block positions.
*/
public class BlockIndex implements Comparable<BlockIndex> {
public int x;
public int y;
public int z;
@ -31,7 +30,6 @@ public class BlockIndex implements Comparable<BlockIndex> {
* Creates an index for a block located on x, y. z
*/
public BlockIndex(int x, int y, int z) {
this.x = x;
this.y = y;
this.z = z;

View file

@ -8,6 +8,7 @@
*/
package buildcraft.api.core;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
@ -28,6 +29,16 @@ public final class BuildCraftAPI {
private BuildCraftAPI() {
}
public static String getVersion() {
try {
Class<?> clazz = Class.forName("buildcraft.core.Version");
Method method = clazz.getDeclaredMethod("getVersion");
return String.valueOf(method.invoke(null));
} catch (Exception e) {
return "UNKNOWN VERSION";
}
}
public static IWorldProperty getWorldProperty(String name) {
return worldProperties.get(name);
}

View file

@ -15,7 +15,6 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
public class Position implements ISerializable {
public double x, y, z;
public ForgeDirection orientation;

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 = "1.5", owner = "BuildCraft|Core", provides = "BuildCraftAPI|core")
@API(apiVersion = "1.6", owner = "BuildCraft|Core", provides = "BuildCraftAPI|core")
package buildcraft.api.core;
import cpw.mods.fml.common.API;

View file

@ -8,9 +8,10 @@
*/
package buildcraft.api.robots;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.IFluidHandler;
@ -184,18 +185,34 @@ public abstract class DockingStation {
return null;
}
public IInventory getItemInput() {
public ForgeDirection getItemOutputSide() {
return ForgeDirection.UNKNOWN;
}
public ISidedInventory getItemInput() {
return null;
}
public ForgeDirection getItemInputSide() {
return ForgeDirection.UNKNOWN;
}
public IFluidHandler getFluidOutput() {
return null;
}
public ForgeDirection getFluidOutputSide() {
return ForgeDirection.UNKNOWN;
}
public IFluidHandler getFluidInput() {
return null;
}
public ForgeDirection getFluidInputSide() {
return ForgeDirection.UNKNOWN;
}
public boolean providesPower() {
return false;
}

View file

@ -10,28 +10,37 @@ package buildcraft.api.robots;
import net.minecraft.item.ItemStack;
/**
* Provide requests of items that need to be fulfilled.
*
* Requests are organized as an linear array, where null entries mark slots
* without a requests. A request in a slot, or the amount of slots, is allowed
* to change before a call to {@link #offerItem(int, ItemStack)}, but it is not
* recommended that this is frequent, since the request delivery won't fail
* until it is offered the previous request.
*/
public interface IRequestProvider {
/**
* Return the total number of request slots available from this provider.
*
* @return
*/
int getNumberOfRequests();
int getRequestsCount();
/**
* Return the stack requested in slot i, provided that this request is not
* in process of being provided by a robot.
* Return a stack with the request in the slot.
*
* @param slot
* @return the request in the slot, or null if there's no request.
*/
StackRequest getAvailableRequest(int i);
ItemStack getRequest(int slot);
/**
* Allocate the request at slot i to the robot given in parameter, and
* return true if the allocation is successful.
* Fulfill the request in slot with the stack given and return any excess.
*
* @param slot
* @param stack
* @return any excess that was not used to fulfill the request.
*/
boolean takeRequest(int i, EntityRobotBase robot);
/**
* Provide a stack to fulfill request at index i. Return the stack minus
* items that have been taken.
*/
ItemStack provideItemsForRequest(int i, ItemStack stack);
ItemStack offerItem(int slot, ItemStack stack);
}

View file

@ -9,50 +9,17 @@
package buildcraft.api.robots;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.core.BlockIndex;
public abstract class ResourceId {
public BlockIndex index = new BlockIndex();
public ForgeDirection side = ForgeDirection.UNKNOWN;
public int localId = 0;
protected ResourceId() {
}
@Override
public boolean equals(Object obj) {
if (obj == null || obj.getClass() != getClass()) {
return false;
}
ResourceId compareId = (ResourceId) obj;
return index.equals(compareId.index)
&& side == compareId.side
&& localId == compareId.localId;
}
@Override
public int hashCode() {
return (((index != null ? index.hashCode() : 0) * 37) + (side != null ? side.ordinal() : 0) * 37) + localId;
}
public void writeToNBT(NBTTagCompound nbt) {
NBTTagCompound indexNBT = new NBTTagCompound();
index.writeTo(indexNBT);
nbt.setTag("index", indexNBT);
nbt.setByte("side", (byte) side.ordinal());
nbt.setInteger("localId", localId);
nbt.setString("resourceName", RobotManager.getResourceIdName(getClass()));
}
protected void readFromNBT(NBTTagCompound nbt) {
index = new BlockIndex(nbt.getCompoundTag("index"));
side = ForgeDirection.values()[nbt.getByte("side")];
localId = nbt.getInteger("localId");
}
public static ResourceId load(NBTTagCompound nbt) {
@ -75,12 +42,4 @@ public abstract class ResourceId {
return null;
}
public void taken(long robotId) {
}
public void released(long robotId) {
}
}

View file

@ -8,12 +8,20 @@
*/
package buildcraft.api.robots;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.core.BlockIndex;
public class ResourceIdBlock extends ResourceId {
public BlockIndex index = new BlockIndex();
public ForgeDirection side = ForgeDirection.UNKNOWN;
public ResourceIdBlock() {
}
@ -30,4 +38,35 @@ public class ResourceIdBlock extends ResourceId {
index = new BlockIndex(tile);
}
@Override
public boolean equals(Object obj) {
if (obj == null || obj.getClass() != getClass()) {
return false;
}
ResourceIdBlock compareId = (ResourceIdBlock) obj;
return index.equals(compareId.index) && side == compareId.side;
}
@Override
public int hashCode() {
return new HashCodeBuilder().append(index.hashCode()).append(side != null ? side.ordinal() : 0).build();
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
NBTTagCompound indexNBT = new NBTTagCompound();
index.writeTo(indexNBT);
nbt.setTag("index", indexNBT);
nbt.setByte("side", (byte) side.ordinal());
}
@Override
protected void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
index = new BlockIndex(nbt.getCompoundTag("index"));
side = ForgeDirection.values()[nbt.getByte("side")];
}
}

View file

@ -8,19 +8,61 @@
*/
package buildcraft.api.robots;
import net.minecraft.tileentity.TileEntity;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.core.BlockIndex;
public class ResourceIdRequest extends ResourceId {
private BlockIndex index;
private ForgeDirection side;
private int slot;
public ResourceIdRequest() {
}
public ResourceIdRequest(TileEntity tile, int i) {
index = new BlockIndex(tile);
localId = i;
public ResourceIdRequest(DockingStation station, int slot) {
index = station.index();
side = station.side();
this.slot = slot;
}
@Override
public boolean equals(Object obj) {
if (obj == null || obj.getClass() != getClass()) {
return false;
}
ResourceIdRequest compareId = (ResourceIdRequest) obj;
return index.equals(compareId.index) && side.equals(compareId.side) && slot == compareId.slot;
}
@Override
public int hashCode() {
return new HashCodeBuilder().append(index.hashCode()).append(side.hashCode()).append(slot).build();
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
NBTTagCompound indexNBT = new NBTTagCompound();
index.writeTo(indexNBT);
nbt.setTag("index", indexNBT);
nbt.setByte("side", (byte) side.ordinal());
nbt.setInteger("localId", slot);
}
@Override
protected void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
index = new BlockIndex(nbt.getCompoundTag("index"));
side = ForgeDirection.getOrientation(nbt.getByte("side"));
slot = nbt.getInteger("localId");
}
}

View file

@ -51,6 +51,14 @@ public abstract class RobotManager {
if (aiRobotsByNames.containsKey(name)) {
BCLog.logger.info("Overriding " + aiRobotsByNames.get(name).getName() + " with " + aiRobot.getName());
}
// Check if NBT-load constructor is present
try {
aiRobot.getConstructor(EntityRobotBase.class);
} catch (NoSuchMethodException e) {
throw new RuntimeException("AI class " + aiRobot.getName() + " lacks NBT load construtor! This is a bug!");
}
aiRobots.add(aiRobot);
aiRobotsByNames.put(name, aiRobot);
aiRobotsNames.put(aiRobot, name);

View file

@ -1,19 +0,0 @@
/**
* Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* The BuildCraft API is distributed under the terms of the MIT License.
* Please check the contents of the license, which should be located
* as "LICENSE.API" in the BuildCraft source code distribution.
*/
package buildcraft.api.robots;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
public class StackRequest {
public ItemStack stack;
public int index;
public TileEntity requester;
public DockingStation station;
}

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.1", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|robotics")
@API(apiVersion = "2.2", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|robotics")
package buildcraft.api.robots;
import cpw.mods.fml.common.API;

View file

@ -20,6 +20,8 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.core.BCLog;
public final class StatementManager {
public static Map<String, IStatement> statements = new HashMap<String, IStatement>();
@ -159,6 +161,9 @@ public final class StatementManager {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (Error error) {
BCLog.logErrorAPI(error, IStatementParameter.class);
throw error;
}
return null;

View file

@ -18,6 +18,7 @@ buildcraft.boardRobotCrafter=Crafter
buildcraft.boardRobotDelivery=Delivery
buildcraft.boardRobotPump=Pump
buildcraft.boardRobotStripes=Stripes
buildcraft.boardRobotBreaker=Breaker
buildcraft.boardRobotPicker.desc=Picks up items
buildcraft.boardRobotLumberjack.desc=Breaks logs
@ -37,6 +38,7 @@ buildcraft.boardRobotCrafter.desc=Crafts items
buildcraft.boardRobotDelivery.desc=Delivers items upon request
buildcraft.boardRobotPump.desc=Pumps out liquids
buildcraft.boardRobotStripes.desc=Uhh... Stripes!
buildcraft.boardRobotStripes.desc=Mines stone
chat.gateCopier.clear=Gate information cleared.
chat.gateCopier.gateCopied=Copied gate information to copier.
@ -377,6 +379,7 @@ item.FacadePhased.state_transparent=Transparent
item.PipePlug.name=Pipe Plug
item.Lens.name=Lens
item.Filter.name=Filter
item.PipePowerAdapter.name=Power Adapter
item.debugger.name=Debugger
item.debugger.warning=Use only for testing! Leaks secrets.
item.package.name=Package
@ -476,6 +479,8 @@ tip.deprecated=Deprecated
tip.filler.excavate.on=Excavate
tip.filler.excavate.off=Do Not Excavate
tip.list.matches=Matches
tip.shift.PipeFluidsDiamond=GUI accepts any fluid containers
tip.shift.PipeFluidsEmerald=GUI accepts any fluid container
tip.shift.PipeItemsClay=Prioritizes machines and chests\nover neighbouring pipes.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 139 B

After

Width:  |  Height:  |  Size: 139 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 990 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 299 B

After

Width:  |  Height:  |  Size: 283 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 289 B

After

Width:  |  Height:  |  Size: 275 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 272 B

After

Width:  |  Height:  |  Size: 272 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 293 B

View file

@ -1,18 +1,48 @@
BREAKING CHANGES!
* Cobblestone Structure Pipes have a new recipe. (asie)
* Quartz Fluid Pipes no longer connect to Cobblestone or Stone Fluid Pipes. This might break existing builds! (asie)
Additions:
* Clay fluid pipe! The power of insertion applied to liquids. (asie)
* New blueprint library GUI, now featuring a scrollbar! (asie)
* New Lists - sort by type, material, or both, and other improvements! (asie)
* Core:
* New Lists! (asie)
* Sort by type, material, or both! Precise sorting!
* See with a tooltip if an item matches the List!
* Transport:
* Clay fluid pipe! The power of insertion applied to liquids. (asie)
* Power Adapters! Connect Kinesis Pipes to non-Kinesis pipes. (asie)
Improvements:
* Use integrated server data in singleplayer for certain tiles - back to the smoothness of 1.2.5! (asie)
* Rewritten pipe wires - should now propagate more or less instantly. (asie)
* Fluid pipe capacity and extraction rate now scales with the base flow multiplier. (asie)
* Debugger support for fluid pipes (asie)
* Add events for robot interaction and removal (asie)
* Core/Any:
* Use integrated server data in singleplayer for certain tiles - back to the smoothness of 1.2.5! (asie)
* Minor optimizations (asie, gamerForEA)
* Builders:
* New blueprint library GUI, now featuring a scrollbar! (asie)
* Factory:
* Chutes now support the Comparator (asie)
* Less lag on Tank updating - new comparator update system (asie)
* Robotics:
* 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.
* Zone Planners now have a dynamic texture (asie)
* Requesters now support the Comparator (asie)
* Add events for robot interaction and removal (asie)
* Add the Breaker robot that mines stone materials (hea3ven)
* Fix robots not using the correct sides when accessing inventories/tanks (hea3ven)
* Fix loading break ai from nbt (hea3ven)
* Transport:
* Filtered Buffers now support the Comparator (asie)
* Lenses do not require Iron Ingots anymore (asie)
* New power beam display algorithm (asie)
* Rewritten pipe wires - should now propagate more or less instantly. (asie)
* Debugger support for fluid pipes (asie)
* Fluid pipe capacity and extraction rate now scales with the base flow multiplier. (asie)
Bugs fixed:
* "Lens-Filter" diodes not working (asie)
* Make Docking Station items look like the real thing (asie)

View file

@ -34,6 +34,7 @@ import net.minecraft.stats.Achievement;
import net.minecraft.world.World;
import cpw.mods.fml.client.event.ConfigChangedEvent;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLInterModComms;
@ -84,8 +85,6 @@ import buildcraft.builders.TileBlueprintLibrary;
import buildcraft.builders.TileBuilder;
import buildcraft.builders.TileConstructionMarker;
import buildcraft.builders.TileFiller;
import buildcraft.core.TileMarker;
import buildcraft.core.TilePathMarker;
import buildcraft.builders.TileQuarry;
import buildcraft.builders.blueprints.RealBlueprintDeployer;
import buildcraft.builders.schematics.SchematicAir;
@ -125,6 +124,8 @@ import buildcraft.builders.urbanism.UrbanistToolsIconProvider;
import buildcraft.core.CompatHooks;
import buildcraft.core.DefaultProps;
import buildcraft.core.InterModComms;
import buildcraft.core.TileMarker;
import buildcraft.core.TilePathMarker;
import buildcraft.core.Version;
import buildcraft.core.blueprints.SchematicRegistry;
import buildcraft.core.builders.schematics.SchematicBlockCreative;
@ -494,7 +495,9 @@ public class BuildCraftBuilders extends BuildCraftMod {
schemes.registerSchematicBlock(architectBlock, SchematicRotateMeta.class, new int[]{2, 5, 3, 4}, true);
schemes.registerSchematicBlock(builderBlock, SchematicRotateMeta.class, new int[]{2, 5, 3, 4}, true);
schemes.registerSchematicBlock(constructionMarkerBlock, SchematicIgnore.class);
if (constructionMarkerBlock != null) {
schemes.registerSchematicBlock(constructionMarkerBlock, SchematicIgnore.class);
}
schemes.registerSchematicBlock(frameBlock, SchematicFree.class);
// Factories required to save entities in world
@ -536,10 +539,6 @@ public class BuildCraftBuilders extends BuildCraftMod {
quarryBlock = (BlockQuarry) CompatHooks.INSTANCE.getBlock(BlockQuarry.class);
CoreProxy.proxy.registerBlock(quarryBlock.setBlockName("machineBlock"));
constructionMarkerBlock = (BlockConstructionMarker) CompatHooks.INSTANCE.getBlock(BlockConstructionMarker.class);
CoreProxy.proxy.registerBlock(constructionMarkerBlock.setBlockName("constructionMarkerBlock"),
ItemConstructionMarker.class);
fillerBlock = (BlockFiller) CompatHooks.INSTANCE.getBlock(BlockFiller.class);
CoreProxy.proxy.registerBlock(fillerBlock.setBlockName("fillerBlock"));
@ -567,9 +566,16 @@ public class BuildCraftBuilders extends BuildCraftMod {
CoreProxy.proxy.registerTileEntity(TileBuilder.class, "net.minecraft.src.builders.TileBuilder");
CoreProxy.proxy.registerTileEntity(TileArchitect.class, "net.minecraft.src.builders.TileTemplate");
CoreProxy.proxy.registerTileEntity(TilePathMarker.class, "net.minecraft.src.builders.TilePathMarker");
CoreProxy.proxy.registerTileEntity(TileConstructionMarker.class, "net.minecraft.src.builders.TileConstructionMarker");
CoreProxy.proxy.registerTileEntity(TileBlueprintLibrary.class, "net.minecraft.src.builders.TileBlueprintLibrary");
if (Loader.isModLoaded("BuildCraft|Robotics")) {
constructionMarkerBlock = (BlockConstructionMarker) CompatHooks.INSTANCE.getBlock(BlockConstructionMarker.class);
CoreProxy.proxy.registerBlock(constructionMarkerBlock.setBlockName("constructionMarkerBlock"),
ItemConstructionMarker.class);
CoreProxy.proxy.registerTileEntity(TileConstructionMarker.class, "net.minecraft.src.builders.TileConstructionMarker");
}
SchematicRegistry.INSTANCE.readConfiguration(BuildCraftCore.mainConfiguration);
if (BuildCraftCore.mainConfiguration.hasChanged()) {
@ -600,8 +606,10 @@ public class BuildCraftBuilders extends BuildCraftMod {
CoreProxy.proxy.addCraftingRecipe(new ItemStack(blueprintItem, 1), "ppp", "pip", "ppp", 'i',
new ItemStack(Items.dye, 1, 4), 'p', Items.paper);
CoreProxy.proxy.addCraftingRecipe(new ItemStack(constructionMarkerBlock, 1), "l ", "r ", 'l',
"gearGold", 'r', Blocks.redstone_torch);
if (constructionMarkerBlock != null) {
CoreProxy.proxy.addCraftingRecipe(new ItemStack(constructionMarkerBlock, 1), "l ", "r ", 'l',
"gearGold", 'r', Blocks.redstone_torch);
}
CoreProxy.proxy.addCraftingRecipe(new ItemStack(fillerBlock, 1), "btb", "ycy", "gCg", 'b',
"dyeBlack", 't', BuildCraftCore.markerBlock, 'y', "dyeYellow",

View file

@ -133,6 +133,7 @@ import buildcraft.core.list.ListMatchHandlerClass;
import buildcraft.core.list.ListMatchHandlerFluid;
import buildcraft.core.list.ListMatchHandlerOreDictionary;
import buildcraft.core.list.ListRegistry;
import buildcraft.core.list.ListTooltipHandler;
import buildcraft.core.network.PacketHandlerCore;
import buildcraft.core.properties.WorldPropertyIsDirt;
import buildcraft.core.properties.WorldPropertyIsFarmland;
@ -140,6 +141,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.WorldPropertyIsShoveled;
import buildcraft.core.properties.WorldPropertyIsSoft;
import buildcraft.core.properties.WorldPropertyIsWood;
@ -155,6 +157,7 @@ import buildcraft.core.statements.ActionRedstoneOutput;
import buildcraft.core.statements.DefaultActionProvider;
import buildcraft.core.statements.DefaultTriggerProvider;
import buildcraft.core.statements.StatementParameterDirection;
import buildcraft.core.statements.StatementParameterItemStackExact;
import buildcraft.core.statements.StatementParameterRedstoneGateSideOnly;
import buildcraft.core.statements.TriggerEnergy;
import buildcraft.core.statements.TriggerFluidContainer;
@ -275,7 +278,9 @@ public class BuildCraftCore extends BuildCraftMod {
@Mod.EventHandler
public void loadConfiguration(FMLPreInitializationEvent evt) {
BCLog.initLog();
BCLog.logger.info("Starting BuildCraft " + Version.getVersion());
BCLog.logger.info("Copyright (c) the BuildCraft team, 2011-2015");
BCLog.logger.info("http://www.mod-buildcraft.com");
new BCCreativeTab("main");
@ -380,6 +385,7 @@ public class BuildCraftCore extends BuildCraftMod {
FMLCommonHandler.instance().bus().register(this);
MinecraftForge.EVENT_BUS.register(this);
MinecraftForge.EVENT_BUS.register(new BlockHighlightHandler());
MinecraftForge.EVENT_BUS.register(new ListTooltipHandler());
}
@Mod.EventHandler
@ -408,6 +414,7 @@ public class BuildCraftCore extends BuildCraftMod {
StatementManager.registerParameterClass("buildcraft:stackAction", StatementParameterItemStack.class);
StatementManager.registerParameterClass(StatementParameterItemStack.class);
StatementManager.registerParameterClass(StatementParameterItemStackExact.class);
StatementManager.registerParameterClass(StatementParameterDirection.class);
StatementManager.registerParameterClass(StatementParameterRedstoneGateSideOnly.class);
StatementManager.registerTriggerProvider(new DefaultTriggerProvider());
@ -504,6 +511,7 @@ 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());
@ -657,10 +665,13 @@ public class BuildCraftCore extends BuildCraftMod {
CoreProxy.proxy.addShapelessRecipe(outputStack, anyPaintbrush, EnumColor.fromId(i).getDye());
}
// Convert old lists to new lists
CoreProxy.proxy.addShapelessRecipe(new ItemStack(listItem, 1, 1), new ItemStack(listItem, 1, 0));
if (Loader.isModLoaded("BuildCraft|Silicon")) {
CoreSiliconRecipes.loadSiliconRecipes();
} else {
CoreProxy.proxy.addCraftingRecipe(new ItemStack(listItem), "ppp", "pYp", "ppp", 'p', Items.paper, 'Y',
CoreProxy.proxy.addCraftingRecipe(new ItemStack(listItem, 1, 1), "ppp", "pYp", "ppp", 'p', Items.paper, 'Y',
"dyeGreen");
}
}

View file

@ -111,6 +111,7 @@ import buildcraft.robotics.ai.AIRobotUnloadFluids;
import buildcraft.robotics.ai.AIRobotUseToolOnBlock;
import buildcraft.robotics.boards.BCBoardNBT;
import buildcraft.robotics.boards.BoardRobotBomber;
import buildcraft.robotics.boards.BoardRobotBreaker;
import buildcraft.robotics.boards.BoardRobotBuilder;
import buildcraft.robotics.boards.BoardRobotButcher;
import buildcraft.robotics.boards.BoardRobotCarrier;
@ -237,6 +238,7 @@ public class BuildCraftRobotics extends BuildCraftMod {
RedstoneBoardRegistry.instance.registerBoardType(new BCBoardNBT("buildcraft:boardRobotButcher", "butcher", BoardRobotButcher.class, "blue"), 32000);
RedstoneBoardRegistry.instance.registerBoardType(new BCBoardNBT("buildcraft:shovelman", "shovelman", BoardRobotShovelman.class, "blue"), 32000);
RedstoneBoardRegistry.instance.registerBoardType(new BCBoardNBT("buildcraft:boardRobotPump", "pump", BoardRobotPump.class, "blue"), 32000);
RedstoneBoardRegistry.instance.registerBoardType(new BCBoardNBT("buildcraft:boardRobotBreaker", "breaker", BoardRobotBreaker.class, "blue"), 32000);
// Even more expensive
// These handle complex multi-step operations.
@ -279,6 +281,7 @@ public class BuildCraftRobotics extends BuildCraftMod {
RobotManager.registerAIRobot(AIRobotMain.class, "aiRobotMain", "buildcraft.core.robots.AIRobotMain");
RobotManager.registerAIRobot(BoardRobotEmpty.class, "boardRobotEmpty");
RobotManager.registerAIRobot(BoardRobotBomber.class, "boardRobotBomber", "buildcraft.core.robots.boards.BoardRobotBomber");
RobotManager.registerAIRobot(BoardRobotBreaker.class, "boardRobotBreaker");
if (Loader.isModLoaded("BuildCraft|Builders")) {
RobotManager.registerAIRobot(BoardRobotBuilder.class, "boardRobotBuilder", "buildcraft.core.robots.boards.BoardRobotBuilder");
}

View file

@ -142,8 +142,10 @@ import buildcraft.transport.pipes.PipePowerWood;
import buildcraft.transport.pipes.PipeStructureCobblestone;
import buildcraft.transport.pluggable.ItemLens;
import buildcraft.transport.pluggable.ItemPlug;
import buildcraft.transport.pluggable.ItemPowerAdapter;
import buildcraft.transport.pluggable.LensPluggable;
import buildcraft.transport.pluggable.PlugPluggable;
import buildcraft.transport.pluggable.PowerAdapterPluggable;
import buildcraft.transport.render.PipeRendererTESR;
import buildcraft.transport.schematics.BptPipeFiltered;
import buildcraft.transport.schematics.BptPipeRotatable;
@ -323,54 +325,52 @@ public class BuildCraftTransport extends BuildCraftMod {
CoreProxy.proxy.registerBlock(filteredBufferBlock.setBlockName("filteredBufferBlock"));
pipeWaterproof = new ItemBuildCraft();
pipeWaterproof.setUnlocalizedName("pipeWaterproof");
CoreProxy.proxy.registerItem(pipeWaterproof);
genericPipeBlock = (BlockGenericPipe) CompatHooks.INSTANCE.getBlock(BlockGenericPipe.class);
CoreProxy.proxy.registerBlock(genericPipeBlock.setBlockName("pipeBlock"), ItemBlock.class);
pipeItemsWood = buildPipe(PipeItemsWood.class, "Wooden Transport Pipe", BCCreativeTab.get("pipes"), "plankWood", "blockGlassColorless", "plankWood");
pipeItemsEmerald = buildPipe(PipeItemsEmerald.class, "Emerald Transport Pipe", BCCreativeTab.get("pipes"), "gemEmerald", "blockGlassColorless", "gemEmerald");
pipeItemsCobblestone = buildPipe(PipeItemsCobblestone.class, "Cobblestone Transport Pipe", BCCreativeTab.get("pipes"), "cobblestone", "blockGlassColorless", "cobblestone");
pipeItemsStone = buildPipe(PipeItemsStone.class, "Stone Transport Pipe", BCCreativeTab.get("pipes"), "stone", "blockGlassColorless", "stone");
pipeItemsQuartz = buildPipe(PipeItemsQuartz.class, "Quartz Transport Pipe", BCCreativeTab.get("pipes"), "blockQuartz", "blockGlassColorless", "blockQuartz");
pipeItemsIron = buildPipe(PipeItemsIron.class, "Iron Transport Pipe", BCCreativeTab.get("pipes"), "ingotIron", "blockGlassColorless", "ingotIron");
pipeItemsGold = buildPipe(PipeItemsGold.class, "Golden Transport Pipe", BCCreativeTab.get("pipes"), "ingotGold", "blockGlassColorless", "ingotGold");
pipeItemsDiamond = buildPipe(PipeItemsDiamond.class, "Diamond Transport Pipe", BCCreativeTab.get("pipes"), "gemDiamond", "blockGlassColorless", "gemDiamond");
pipeItemsObsidian = buildPipe(PipeItemsObsidian.class, "Obsidian Transport Pipe", BCCreativeTab.get("pipes"), Blocks.obsidian, "blockGlassColorless", Blocks.obsidian);
pipeItemsLapis = buildPipe(PipeItemsLapis.class, "Lapis Transport Pipe", BCCreativeTab.get("pipes"), "blockLapis", "blockGlassColorless", "blockLapis");
pipeItemsDaizuli = buildPipe(PipeItemsDaizuli.class, "Daizuli Transport Pipe", BCCreativeTab.get("pipes"), "blockLapis", "blockGlassColorless", "gemDiamond");
pipeItemsSandstone = buildPipe(PipeItemsSandstone.class, "Sandstone Transport Pipe", BCCreativeTab.get("pipes"), Blocks.sandstone, "blockGlassColorless", Blocks.sandstone);
pipeItemsVoid = buildPipe(PipeItemsVoid.class, "Void Transport Pipe", BCCreativeTab.get("pipes"), "dyeBlack", "blockGlassColorless", "dustRedstone");
pipeItemsEmzuli = buildPipe(PipeItemsEmzuli.class, "Emzuli Transport Pipe", BCCreativeTab.get("pipes"), "blockLapis", "blockGlassColorless", "gemEmerald");
pipeItemsStripes = buildPipe(PipeItemsStripes.class, "Stripes Transport Pipe", BCCreativeTab.get("pipes"), "gearGold", "blockGlassColorless", "gearGold");
pipeItemsClay = buildPipe(PipeItemsClay.class, "Clay Transport Pipe", BCCreativeTab.get("pipes"), Blocks.clay, "blockGlassColorless", Blocks.clay);
pipeItemsWood = buildPipe(PipeItemsWood.class, "plankWood", "blockGlassColorless", "plankWood");
pipeItemsEmerald = buildPipe(PipeItemsEmerald.class, "gemEmerald", "blockGlassColorless", "gemEmerald");
pipeItemsCobblestone = buildPipe(PipeItemsCobblestone.class, "cobblestone", "blockGlassColorless", "cobblestone");
pipeItemsStone = buildPipe(PipeItemsStone.class, "stone", "blockGlassColorless", "stone");
pipeItemsQuartz = buildPipe(PipeItemsQuartz.class, "blockQuartz", "blockGlassColorless", "blockQuartz");
pipeItemsIron = buildPipe(PipeItemsIron.class, "ingotIron", "blockGlassColorless", "ingotIron");
pipeItemsGold = buildPipe(PipeItemsGold.class, "ingotGold", "blockGlassColorless", "ingotGold");
pipeItemsDiamond = buildPipe(PipeItemsDiamond.class, "gemDiamond", "blockGlassColorless", "gemDiamond");
pipeItemsObsidian = buildPipe(PipeItemsObsidian.class, Blocks.obsidian, "blockGlassColorless", Blocks.obsidian);
pipeItemsLapis = buildPipe(PipeItemsLapis.class, "blockLapis", "blockGlassColorless", "blockLapis");
pipeItemsDaizuli = buildPipe(PipeItemsDaizuli.class, "blockLapis", "blockGlassColorless", "gemDiamond");
pipeItemsSandstone = buildPipe(PipeItemsSandstone.class, Blocks.sandstone, "blockGlassColorless", Blocks.sandstone);
pipeItemsVoid = buildPipe(PipeItemsVoid.class, "dyeBlack", "blockGlassColorless", "dustRedstone");
pipeItemsEmzuli = buildPipe(PipeItemsEmzuli.class, "blockLapis", "blockGlassColorless", "gemEmerald");
pipeItemsStripes = buildPipe(PipeItemsStripes.class, "gearGold", "blockGlassColorless", "gearGold");
pipeItemsClay = buildPipe(PipeItemsClay.class, Blocks.clay, "blockGlassColorless", Blocks.clay);
pipeFluidsWood = buildPipe(PipeFluidsWood.class, "Wooden Waterproof Pipe", BCCreativeTab.get("pipes"), pipeWaterproof, pipeItemsWood);
pipeFluidsCobblestone = buildPipe(PipeFluidsCobblestone.class, "Cobblestone Waterproof Pipe", BCCreativeTab.get("pipes"), pipeWaterproof, pipeItemsCobblestone);
pipeFluidsStone = buildPipe(PipeFluidsStone.class, "Stone Waterproof Pipe", BCCreativeTab.get("pipes"), pipeWaterproof, pipeItemsStone);
pipeFluidsQuartz = buildPipe(PipeFluidsQuartz.class, "Quartz Waterproof Pipe", BCCreativeTab.get("pipes"), pipeWaterproof, pipeItemsQuartz);
pipeFluidsIron = buildPipe(PipeFluidsIron.class, "Iron Waterproof Pipe", BCCreativeTab.get("pipes"), pipeWaterproof, pipeItemsIron);
pipeFluidsGold = buildPipe(PipeFluidsGold.class, "Golden Waterproof Pipe", BCCreativeTab.get("pipes"), pipeWaterproof, pipeItemsGold);
pipeFluidsEmerald = buildPipe(PipeFluidsEmerald.class, "Emerald Waterproof Pipe", BCCreativeTab.get("pipes"), pipeWaterproof, pipeItemsEmerald);
pipeFluidsDiamond = buildPipe(PipeFluidsDiamond.class, "Diamond Waterproof Pipe", BCCreativeTab.get("pipes"), pipeWaterproof, pipeItemsDiamond);
pipeFluidsSandstone = buildPipe(PipeFluidsSandstone.class, "Sandstone Waterproof Pipe", BCCreativeTab.get("pipes"), pipeWaterproof, pipeItemsSandstone);
pipeFluidsVoid = buildPipe(PipeFluidsVoid.class, "Void Waterproof Pipe", BCCreativeTab.get("pipes"), pipeWaterproof, pipeItemsVoid);
pipeFluidsClay = buildPipe(PipeFluidsClay.class, "Clay Waterproof Pipe", BCCreativeTab.get("pipes"), pipeWaterproof, pipeItemsClay);
pipeFluidsWood = buildPipe(PipeFluidsWood.class, pipeWaterproof, pipeItemsWood);
pipeFluidsCobblestone = buildPipe(PipeFluidsCobblestone.class, pipeWaterproof, pipeItemsCobblestone);
pipeFluidsStone = buildPipe(PipeFluidsStone.class, pipeWaterproof, pipeItemsStone);
pipeFluidsQuartz = buildPipe(PipeFluidsQuartz.class, pipeWaterproof, pipeItemsQuartz);
pipeFluidsIron = buildPipe(PipeFluidsIron.class, pipeWaterproof, pipeItemsIron);
pipeFluidsGold = buildPipe(PipeFluidsGold.class, pipeWaterproof, pipeItemsGold);
pipeFluidsEmerald = buildPipe(PipeFluidsEmerald.class, pipeWaterproof, pipeItemsEmerald);
pipeFluidsDiamond = buildPipe(PipeFluidsDiamond.class, pipeWaterproof, pipeItemsDiamond);
pipeFluidsSandstone = buildPipe(PipeFluidsSandstone.class, pipeWaterproof, pipeItemsSandstone);
pipeFluidsVoid = buildPipe(PipeFluidsVoid.class, pipeWaterproof, pipeItemsVoid);
pipeFluidsClay = buildPipe(PipeFluidsClay.class, pipeWaterproof, pipeItemsClay);
pipePowerWood = buildPipe(PipePowerWood.class, "Wooden Kinesis Pipe", BCCreativeTab.get("pipes"), "dustRedstone", pipeItemsWood);
pipePowerCobblestone = buildPipe(PipePowerCobblestone.class, "Cobblestone Kinesis Pipe", BCCreativeTab.get("pipes"), "dustRedstone", pipeItemsCobblestone);
pipePowerStone = buildPipe(PipePowerStone.class, "Stone Kinesis Pipe", BCCreativeTab.get("pipes"), "dustRedstone", pipeItemsStone);
pipePowerQuartz = buildPipe(PipePowerQuartz.class, "Quartz Kinesis Pipe", BCCreativeTab.get("pipes"), "dustRedstone", pipeItemsQuartz);
pipePowerIron = buildPipe(PipePowerIron.class, "Iron Kinesis Pipe", BCCreativeTab.get("pipes"), "dustRedstone", pipeItemsIron);
pipePowerGold = buildPipe(PipePowerGold.class, "Golden Kinesis Pipe", BCCreativeTab.get("pipes"), "dustRedstone", pipeItemsGold);
pipePowerDiamond = buildPipe(PipePowerDiamond.class, "Diamond Kinesis Pipe", BCCreativeTab.get("pipes"), "dustRedstone", pipeItemsDiamond);
pipePowerEmerald = buildPipe(PipePowerEmerald.class, "Emerald Kinesis Pipe", BCCreativeTab.get("pipes"), "dustRedstone", pipeItemsEmerald);
pipePowerSandstone = buildPipe(PipePowerSandstone.class, "Sandstone Kinesis Pipe", BCCreativeTab.get("pipes"), "dustRedstone", pipeItemsSandstone);
pipePowerWood = buildPipe(PipePowerWood.class, "dustRedstone", pipeItemsWood);
pipePowerCobblestone = buildPipe(PipePowerCobblestone.class, "dustRedstone", pipeItemsCobblestone);
pipePowerStone = buildPipe(PipePowerStone.class, "dustRedstone", pipeItemsStone);
pipePowerQuartz = buildPipe(PipePowerQuartz.class, "dustRedstone", pipeItemsQuartz);
pipePowerIron = buildPipe(PipePowerIron.class, "dustRedstone", pipeItemsIron);
pipePowerGold = buildPipe(PipePowerGold.class, "dustRedstone", pipeItemsGold);
pipePowerDiamond = buildPipe(PipePowerDiamond.class, "dustRedstone", pipeItemsDiamond);
pipePowerEmerald = buildPipe(PipePowerEmerald.class, "dustRedstone", pipeItemsEmerald);
pipePowerSandstone = buildPipe(PipePowerSandstone.class, "dustRedstone", pipeItemsSandstone);
pipeStructureCobblestone = buildPipe(PipeStructureCobblestone.class, "Cobblestone Structure Pipe", BCCreativeTab.get("pipes"), Blocks.gravel, pipeItemsCobblestone);
pipeStructureCobblestone = buildPipe(PipeStructureCobblestone.class, Blocks.cobblestone, Blocks.gravel, Blocks.cobblestone);
pipeWire = new ItemPipeWire();
CoreProxy.proxy.registerItem(pipeWire);
@ -393,9 +393,9 @@ public class BuildCraftTransport extends BuildCraftMod {
lensItem.setUnlocalizedName("pipeLens");
CoreProxy.proxy.registerItem(lensItem);
//powerAdapterItem = new ItemPowerAdapter();
//powerAdapterItem.setUnlocalizedName("pipePowerAdapter");
//CoreProxy.proxy.registerItem(powerAdapterItem);
powerAdapterItem = new ItemPowerAdapter();
powerAdapterItem.setUnlocalizedName("pipePowerAdapter");
CoreProxy.proxy.registerItem(powerAdapterItem);
gateCopier = new ItemGateCopier();
CoreProxy.proxy.registerItem(gateCopier);
@ -518,6 +518,7 @@ public class BuildCraftTransport extends BuildCraftMod {
PipeManager.registerPipePluggable(GatePluggable.class, "gate");
PipeManager.registerPipePluggable(LensPluggable.class, "lens");
PipeManager.registerPipePluggable(PlugPluggable.class, "plug");
PipeManager.registerPipePluggable(PowerAdapterPluggable.class, "powerAdapter");
GateExpansions.registerExpansion(GateExpansionPulsar.INSTANCE);
GateExpansions.registerExpansion(GateExpansionTimer.INSTANCE);
@ -663,17 +664,15 @@ public class BuildCraftTransport extends BuildCraftMod {
// Pipe Plug
GameRegistry.addShapelessRecipe(new ItemStack(plugItem, 4), new ItemStack(pipeStructureCobblestone));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(powerAdapterItem, 4), "scs", "sbs", "sas", 's', pipeStructureCobblestone, 'a', Items.redstone, 'b', "gearStone", 'c', "ingotGold"));
if (Loader.isModLoaded("BuildCraft|Silicon")) {
TransportSiliconRecipes.loadSiliconRecipes();
} else {
BCLog.logger.warn("**********************************************");
BCLog.logger.warn("* You are using the BuildCraft Transport *");
BCLog.logger.warn("* module WITHOUT the Silicon module. Certain *");
BCLog.logger.warn("* crafting recipes will be unavailable, and *");
BCLog.logger.warn("* you are HIGHLY encouraged to either add *");
BCLog.logger.warn("* the module or add custom recipes for those *");
BCLog.logger.warn("* parts of the mod. *");
BCLog.logger.warn("* module WITHOUT the Silicon module. Gates *");
BCLog.logger.warn("* will not be available. *");
BCLog.logger.warn("**********************************************");
// Alternate recipes
@ -697,8 +696,18 @@ public class BuildCraftTransport extends BuildCraftMod {
InterModComms.processIMC(event);
}
public static Item buildPipe(Class<? extends Pipe> clas, Object... ingredients) {
return buildPipe(clas, BCCreativeTab.get("pipes"), ingredients);
}
@Deprecated
public static Item buildPipe(Class<? extends Pipe> clas,
String descr, BCCreativeTab creativeTab,
String descr, BCCreativeTab creativeTab,
Object... ingredients) {
return buildPipe(clas, creativeTab, ingredients);
}
public static Item buildPipe(Class<? extends Pipe> clas, BCCreativeTab creativeTab,
Object... ingredients) {
ItemPipe res = BlockGenericPipe.registerPipe(clas, creativeTab);
res.setUnlocalizedName(clas.getSimpleName());

View file

@ -18,10 +18,10 @@ import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.BuildCraftBuilders;
import buildcraft.core.GuiIds;
import buildcraft.core.internal.ICustomLEDBlock;
import buildcraft.core.lib.block.BlockBuildCraft;
public class BlockArchitect extends BlockBuildCraft {
public class BlockArchitect extends BlockBuildCraft implements ICustomLEDBlock {
public BlockArchitect() {
super(Material.iron);
setRotatable(true);
@ -66,4 +66,9 @@ public class BlockArchitect extends BlockBuildCraft {
public int getLightValue(IBlockAccess world, int x, int y, int z) {
return 1;
}
@Override
public String[] getLEDSuffixes() {
return new String[] { "led_red", "led_mode_copy", "led_mode_edit" };
}
}

View file

@ -50,51 +50,6 @@ public class BlockQuarry extends BlockHatched {
return new TileQuarry();
}
public void searchFrames(World world, int i, int j, int k) {
int width2 = 1;
if (!world.checkChunksExist(i - width2, j - width2, k - width2, i + width2, j + width2, k + width2)) {
return;
}
Block block = world.getBlock(i, j, k);
if (block != BuildCraftBuilders.frameBlock) {
return;
}
int meta = world.getBlockMetadata(i, j, k);
if ((meta & 8) == 0) {
world.setBlockMetadataWithNotify(i, j, k, meta | 8, 0);
ForgeDirection[] dirs = ForgeDirection.VALID_DIRECTIONS;
for (ForgeDirection dir : dirs) {
switch (dir) {
case UP:
searchFrames(world, i, j + 1, k);
break;
case DOWN:
searchFrames(world, i, j - 1, k);
break;
case SOUTH:
searchFrames(world, i, j, k + 1);
break;
case NORTH:
searchFrames(world, i, j, k - 1);
break;
case EAST:
searchFrames(world, i + 1, j, k);
break;
case WEST:
default:
searchFrames(world, i - 1, j, k);
break;
}
}
}
}
@Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
if (BuildCraftBuilders.quarryOneTimeUse) {

View file

@ -15,7 +15,9 @@ import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry;
import buildcraft.BuildCraftBuilders;
import buildcraft.builders.render.RenderArchitect;
import buildcraft.builders.render.RenderBuilderTile;
import buildcraft.builders.render.RenderConstructionMarker;
import buildcraft.builders.render.RenderFiller;
import buildcraft.builders.urbanism.TileUrbanist;
import buildcraft.core.lib.EntityBlock;

View file

@ -97,7 +97,7 @@ public class EntityMechanicalArm extends Entity {
private void findAndJoinQuarry() {
TileEntity te = worldObj.getTileEntity((int) posX, (int) posY, (int) posZ);
if (te != null && te instanceof TileQuarry) {
if (te instanceof TileQuarry) {
parent = (TileQuarry) te;
parent.setArm(this);
} else {

View file

@ -1,6 +1,5 @@
package buildcraft.builders;
import java.util.BitSet;
import java.util.Iterator;
import net.minecraft.block.Block;
@ -15,30 +14,11 @@ import buildcraft.core.builders.schematics.SchematicBlockCreative;
import buildcraft.core.builders.schematics.SchematicTileCreative;
public final class HeuristicBlockDetection {
private static BitSet craftableBlockList = new BitSet(65536);
private HeuristicBlockDetection() {
}
public static void start() {
// Initialize craftableBlockList
/* for (Object or : CraftingManager.getInstance().getRecipeList()) {
if (or instanceof IRecipe) {
IRecipe recipe = ((IRecipe) or);
if (recipe.getRecipeOutput() != null && recipe.getRecipeOutput().getItem() != null &&
recipe.getRecipeOutput().getItem() instanceof ItemBlock) {
int pos = recipe.getRecipeOutput().getItemDamage() & 15;
pos |= Block.getIdFromBlock(Block.getBlockFromItem(recipe.getRecipeOutput().getItem())) << 4;
if (pos >= 0 && pos < 65536) {
craftableBlockList.set(pos);
}
}
}
} */
// Register blocks
Iterator i = Block.blockRegistry.iterator();
while (i.hasNext()) {
Block block = (Block) i.next();
@ -81,9 +61,4 @@ public final class HeuristicBlockDetection {
}
}
}
private static boolean canCraft(Block block, int meta) {
int pos = Block.getIdFromBlock(block) << 4 | meta;
return craftableBlockList.get(pos);
}
}

View file

@ -9,7 +9,6 @@
package buildcraft.builders;
import java.util.ArrayList;
import java.util.LinkedList;
import io.netty.buffer.ByteBuf;
@ -45,20 +44,23 @@ import buildcraft.core.lib.utils.NetworkUtils;
import buildcraft.core.lib.utils.Utils;
public class TileArchitect extends TileBuildCraft implements IInventory, IBoxProvider, ICommandReceiver, ILEDProvider {
public enum Mode {
EDIT, COPY
}
public String currentAuthorName = "";
public Mode mode = Mode.EDIT;
public Box box = new Box();
public String name = "";
public BlueprintReadConfiguration readConfiguration = new BlueprintReadConfiguration();
public LinkedList<LaserData> subLasers = new LinkedList<LaserData>();
public ArrayList<LaserData> subLasers = new ArrayList<LaserData>();
public ArrayList<BlockIndex> subBlueprints = new ArrayList<BlockIndex>();
private SimpleInventory inv = new SimpleInventory(2, "Architect", 1);
private RecursiveBlueprintReader reader;
private boolean isProcessing;
private boolean clientIsWorking, initialized;
public TileArchitect() {
box.kind = Kind.BLUE_STRIPES;
@ -69,12 +71,11 @@ public class TileArchitect extends TileBuildCraft implements IInventory, IBoxPro
super.updateEntity();
if (!worldObj.isRemote) {
if (reader != null) {
if (mode == Mode.COPY && reader != null) {
reader.iterate();
if (reader.isDone()) {
reader = null;
isProcessing = false;
sendNetworkUpdate();
}
}
@ -85,17 +86,25 @@ public class TileArchitect extends TileBuildCraft implements IInventory, IBoxPro
public void initialize() {
super.initialize();
if (!worldObj.isRemote) {
if (!worldObj.isRemote && !initialized) {
if (!box.isInitialized()) {
IAreaProvider a = Utils.getNearbyAreaProvider(worldObj, xCoord,
yCoord, zCoord);
if (a != null) {
mode = Mode.COPY;
box.initialize(a);
a.removeFromWorld();
sendNetworkUpdate();
return;
} else {
mode = Mode.EDIT;
}
} else {
mode = Mode.COPY;
}
initialized = true;
sendNetworkUpdate();
}
}
@ -114,7 +123,7 @@ public class TileArchitect extends TileBuildCraft implements IInventory, IBoxPro
ItemStack result = inv.decrStackSize(i, j);
if (i == 0) {
initializeComputing();
initializeBlueprint();
}
return result;
@ -125,7 +134,7 @@ public class TileArchitect extends TileBuildCraft implements IInventory, IBoxPro
inv.setInventorySlotContents(i, itemstack);
if (i == 0) {
initializeComputing();
initializeBlueprint();
}
}
@ -159,6 +168,7 @@ public class TileArchitect extends TileBuildCraft implements IInventory, IBoxPro
inv.readFromNBT(nbt);
mode = Mode.values()[nbt.getByte("mode")];
name = nbt.getString("name");
currentAuthorName = nbt.getString("lastAuthor");
@ -187,6 +197,7 @@ public class TileArchitect extends TileBuildCraft implements IInventory, IBoxPro
inv.writeToNBT(nbt);
nbt.setByte("mode", (byte) mode.ordinal());
nbt.setString("name", name);
nbt.setString("lastAuthor", currentAuthorName);
@ -205,15 +216,22 @@ public class TileArchitect extends TileBuildCraft implements IInventory, IBoxPro
nbt.setTag("subBlueprints", subBptList);
}
private boolean getIsWorking() {
return mode == Mode.COPY ? reader != null : false;
}
@Override
public void writeData(ByteBuf stream) {
box.writeData(stream);
NetworkUtils.writeUTF(stream, name);
readConfiguration.writeData(stream);
stream.writeBoolean(reader != null);
stream.writeShort(subLasers.size());
for (LaserData ld: subLasers) {
ld.writeData(stream);
stream.writeBoolean(getIsWorking());
stream.writeByte(mode.ordinal());
if (mode == Mode.COPY) {
readConfiguration.writeData(stream);
stream.writeShort(subLasers.size());
for (LaserData ld: subLasers) {
ld.writeData(stream);
}
}
}
@ -221,19 +239,18 @@ public class TileArchitect extends TileBuildCraft implements IInventory, IBoxPro
public void readData(ByteBuf stream) {
box.readData(stream);
name = NetworkUtils.readUTF(stream);
readConfiguration.readData(stream);
boolean newIsProcessing = stream.readBoolean();
if (newIsProcessing != isProcessing) {
isProcessing = newIsProcessing;
worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord);
}
clientIsWorking = stream.readBoolean();
mode = Mode.values()[stream.readByte()];
int size = stream.readUnsignedShort();
subLasers.clear();
for (int i = 0; i < size; i++) {
LaserData ld = new LaserData();
ld.readData(stream);
subLasers.add(ld);
if (mode == Mode.COPY) {
readConfiguration.readData(stream);
int size = stream.readUnsignedShort();
subLasers.clear();
for (int i = 0; i < size; i++) {
LaserData ld = new LaserData();
ld.readData(stream);
subLasers.add(ld);
}
}
}
@Override
@ -242,12 +259,14 @@ public class TileArchitect extends TileBuildCraft implements IInventory, IBoxPro
destroy();
}
private void initializeComputing() {
private void initializeBlueprint() {
if (getWorldObj().isRemote) {
return;
}
reader = new RecursiveBlueprintReader(this);
if (mode == Mode.COPY) {
reader = new RecursiveBlueprintReader(this);
}
sendNetworkUpdate();
}
@ -300,6 +319,7 @@ public class TileArchitect extends TileBuildCraft implements IInventory, IBoxPro
}
});
}
@Override
public void receiveCommand(String command, Side side, Object sender, ByteBuf stream) {
if ("setName".equals(command)) {
@ -326,9 +346,10 @@ public class TileArchitect extends TileBuildCraft implements IInventory, IBoxPro
}
public void addSubBlueprint(TileEntity sub) {
addSubBlueprint(new BlockIndex(sub));
sendNetworkUpdate();
if (mode == Mode.COPY) {
addSubBlueprint(new BlockIndex(sub));
sendNetworkUpdate();
}
}
private void addSubBlueprint(BlockIndex index) {
@ -349,7 +370,19 @@ public class TileArchitect extends TileBuildCraft implements IInventory, IBoxPro
@Override
public int getLEDLevel(int led) {
return (led == 0 ? isProcessing : box != null && box.isInitialized()) ? 15 : 0;
boolean condition = false;
switch (led) {
case 0:
condition = clientIsWorking;
break;
case 1:
condition = mode == Mode.COPY && box != null && box.isInitialized();
break;
case 2:
condition = mode == Mode.EDIT;
break;
}
return condition ? 15 : 0;
}
@Override

View file

@ -23,7 +23,9 @@ import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.WorldSettings.GameType;
import cpw.mods.fml.relauncher.Side;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
@ -32,18 +34,13 @@ import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import buildcraft.BuildCraftBuilders;
import buildcraft.BuildCraftCore;
import buildcraft.api.core.BCLog;
import buildcraft.api.core.BlockIndex;
import buildcraft.api.core.IInvSlot;
import buildcraft.api.core.IPathProvider;
import buildcraft.api.core.Position;
import buildcraft.api.robots.EntityRobotBase;
import buildcraft.api.robots.IRequestProvider;
import buildcraft.api.robots.ResourceIdRequest;
import buildcraft.api.robots.RobotManager;
import buildcraft.api.robots.StackRequest;
import buildcraft.api.tiles.IControllable;
import buildcraft.api.tiles.IHasWork;
import buildcraft.builders.blueprints.RecursiveBlueprintBuilder;
@ -839,7 +836,7 @@ public class TileBuilder extends TileAbstractBuilder implements IHasWork, IFluid
}
@Override
public int getNumberOfRequests() {
public int getRequestsCount() {
if (currentBuilder == null) {
return 0;
} else if (!(currentBuilder instanceof BptBuilderBlueprint)) {
@ -852,7 +849,7 @@ public class TileBuilder extends TileAbstractBuilder implements IHasWork, IFluid
}
@Override
public StackRequest getAvailableRequest(int i) {
public ItemStack getRequest(int slot) {
if (currentBuilder == null) {
return null;
} else if (!(currentBuilder instanceof BptBuilderBlueprint)) {
@ -860,41 +857,25 @@ public class TileBuilder extends TileAbstractBuilder implements IHasWork, IFluid
} else {
BptBuilderBlueprint bpt = (BptBuilderBlueprint) currentBuilder;
if (bpt.neededItems.size() <= i) {
if (bpt.neededItems.size() <= slot) {
return null;
}
RequirementItemStack requirement = bpt.neededItems.get(i);
RequirementItemStack requirement = bpt.neededItems.get(slot);
int qty = quantityMissing(requirement.stack, requirement.size);
if (qty <= 0) {
return null;
}
StackRequest request = new StackRequest();
request.index = i;
request.requester = this;
request.stack = requirement.stack;
return request;
ItemStack requestStack = requirement.stack.copy();
requestStack.stackSize = qty;
return requestStack;
}
}
@Override
public boolean takeRequest(int i, EntityRobotBase robot) {
if (currentBuilder == null) {
return false;
} else if (!(currentBuilder instanceof BptBuilderBlueprint)) {
return false;
} else {
return RobotManager.registryProvider.getRegistry(worldObj).take(new ResourceIdRequest(this, i), robot);
}
}
@Override
public ItemStack provideItemsForRequest(int i, ItemStack stack) {
public ItemStack offerItem(int slot, ItemStack stack) {
if (currentBuilder == null) {
return stack;
} else if (!(currentBuilder instanceof BptBuilderBlueprint)) {
@ -902,11 +883,11 @@ public class TileBuilder extends TileAbstractBuilder implements IHasWork, IFluid
} else {
BptBuilderBlueprint bpt = (BptBuilderBlueprint) currentBuilder;
if (bpt.neededItems.size() <= i) {
if (bpt.neededItems.size() <= slot) {
return stack;
}
RequirementItemStack requirement = bpt.neededItems.get(i);
RequirementItemStack requirement = bpt.neededItems.get(slot);
int qty = quantityMissing(requirement.stack, requirement.size);

View file

@ -252,21 +252,18 @@ public class TileQuarry extends TileAbstractBuilder implements IHasWork, ISidedI
// Collect any lost items laying around
double[] head = getHead();
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);
for (Object aResult : result) {
if (aResult instanceof EntityItem) {
EntityItem entity = (EntityItem) aResult;
if (entity.isDead) {
continue;
}
ItemStack mineable = entity.getEntityItem();
if (mineable.stackSize <= 0) {
continue;
}
CoreProxy.proxy.removeEntity(entity);
miner.mineStack(mineable);
List<EntityItem> result = worldObj.getEntitiesWithinAABB(EntityItem.class, axis);
for (EntityItem entity : result) {
if (entity.isDead) {
continue;
}
ItemStack mineable = entity.getEntityItem();
if (mineable.stackSize <= 0) {
continue;
}
CoreProxy.proxy.removeEntity(entity);
miner.mineStack(mineable);
}
stage = Stage.IDLE;

View file

@ -6,13 +6,14 @@
* 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.builders;
package buildcraft.builders.render;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.tileentity.TileEntity;
import buildcraft.builders.TileArchitect;
import buildcraft.core.EntityLaser;
import buildcraft.core.LaserData;
import buildcraft.core.render.RenderBoxProvider;

View file

@ -6,7 +6,7 @@
* 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.builders;
package buildcraft.builders.render;
import org.lwjgl.opengl.GL11;
@ -19,6 +19,7 @@ import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import buildcraft.builders.TileConstructionMarker;
import buildcraft.core.EntityLaser;
import buildcraft.core.render.RenderBoxProvider;
import buildcraft.core.render.RenderBuildingItems;

View file

@ -24,7 +24,7 @@ import buildcraft.api.core.IAreaProvider;
import buildcraft.api.core.IBox;
import buildcraft.api.core.ISerializable;
import buildcraft.api.core.Position;
import buildcraft.core.lib.utils.Utils;
import buildcraft.core.lib.utils.LaserUtils;
public class Box implements IBox, ISerializable {
public enum Kind {
@ -244,7 +244,7 @@ public class Box implements IBox, ISerializable {
@Override
public void createLaserData() {
lasersData = Utils.createLaserDataBox(xMin, yMin, zMin, xMax, yMax, zMax);
lasersData = LaserUtils.createLaserDataBox(xMin, yMin, zMin, xMax, yMax, zMax);
}
public void writeToNBT(NBTTagCompound nbttagcompound) {

View file

@ -15,7 +15,7 @@ public final class CoreSiliconRecipes {
@Optional.Method(modid = "BuildCraft|Silicon")
public static void loadSiliconRecipes() {
// Lists
BuildcraftRecipeRegistry.assemblyTable.addRecipe("buildcraft:list", 20000, new ItemStack(BuildCraftCore.listItem),
BuildcraftRecipeRegistry.assemblyTable.addRecipe("buildcraft:list", 20000, new ItemStack(BuildCraftCore.listItem, 1, 1),
"dyeGreen", "dustRedstone", new ItemStack(Items.paper, 8));
}
}

View file

@ -18,7 +18,6 @@ import cpw.mods.fml.relauncher.SideOnly;
import buildcraft.core.proxy.CoreProxy;
public class TickHandlerCore {
private boolean nagged;
@SideOnly(Side.CLIENT)
@ -30,23 +29,15 @@ public class TickHandlerCore {
EntityPlayer player = evt.player;
// if(!Config.disableVersionCheck) {
if (Version.needsUpdateNoticeAndMarkAsSeen()) {
player.addChatMessage(new ChatComponentTranslation("bc_update.new_version",
Version.getRecommendedVersion(),
CoreProxy.proxy.getMinecraftVersion()));
player.addChatMessage(new ChatComponentTranslation("bc_update.download"));
// TODO: This takes too much realstate. See how to improve
// Version.displayChangelog(player);
player.addChatMessage(new ChatComponentTranslation("bc_update.once"));
player.addChatMessage(new ChatComponentTranslation("bc_update.again"));
}
// }
nagged = true;
}
}

View file

@ -21,7 +21,7 @@ import buildcraft.api.core.Position;
import buildcraft.api.tiles.ITileAreaProvider;
import buildcraft.core.lib.EntityBlock;
import buildcraft.core.lib.block.TileBuildCraft;
import buildcraft.core.lib.utils.Utils;
import buildcraft.core.lib.utils.LaserUtils;
import buildcraft.core.proxy.CoreProxy;
public class TileMarker extends TileBuildCraft implements ITileAreaProvider {
@ -152,23 +152,23 @@ public class TileMarker extends TileBuildCraft implements ITileAreaProvider {
if (showSignals) {
signals = new EntityBlock[6];
if (!origin.isSet() || !origin.vect[0].isSet()) {
signals[0] = Utils.createLaser(worldObj, new Position(xCoord, yCoord, zCoord), new Position(xCoord + DefaultProps.MARKER_RANGE - 1, yCoord, zCoord),
signals[0] = LaserUtils.createLaser(worldObj, new Position(xCoord, yCoord, zCoord), new Position(xCoord + DefaultProps.MARKER_RANGE - 1, yCoord, zCoord),
LaserKind.Blue);
signals[1] = Utils.createLaser(worldObj, new Position(xCoord - DefaultProps.MARKER_RANGE + 1, yCoord, zCoord), new Position(xCoord, yCoord, zCoord),
signals[1] = LaserUtils.createLaser(worldObj, new Position(xCoord - DefaultProps.MARKER_RANGE + 1, yCoord, zCoord), new Position(xCoord, yCoord, zCoord),
LaserKind.Blue);
}
if (!origin.isSet() || !origin.vect[1].isSet()) {
signals[2] = Utils.createLaser(worldObj, new Position(xCoord, yCoord, zCoord), new Position(xCoord, yCoord + DefaultProps.MARKER_RANGE - 1, zCoord),
signals[2] = LaserUtils.createLaser(worldObj, new Position(xCoord, yCoord, zCoord), new Position(xCoord, yCoord + DefaultProps.MARKER_RANGE - 1, zCoord),
LaserKind.Blue);
signals[3] = Utils.createLaser(worldObj, new Position(xCoord, yCoord - DefaultProps.MARKER_RANGE + 1, zCoord), new Position(xCoord, yCoord, zCoord),
signals[3] = LaserUtils.createLaser(worldObj, new Position(xCoord, yCoord - DefaultProps.MARKER_RANGE + 1, zCoord), new Position(xCoord, yCoord, zCoord),
LaserKind.Blue);
}
if (!origin.isSet() || !origin.vect[2].isSet()) {
signals[4] = Utils.createLaser(worldObj, new Position(xCoord, yCoord, zCoord), new Position(xCoord, yCoord, zCoord + DefaultProps.MARKER_RANGE - 1),
signals[4] = LaserUtils.createLaser(worldObj, new Position(xCoord, yCoord, zCoord), new Position(xCoord, yCoord, zCoord + DefaultProps.MARKER_RANGE - 1),
LaserKind.Blue);
signals[5] = Utils.createLaser(worldObj, new Position(xCoord, yCoord, zCoord - DefaultProps.MARKER_RANGE + 1), new Position(xCoord, yCoord, zCoord),
signals[5] = LaserUtils.createLaser(worldObj, new Position(xCoord, yCoord, zCoord - DefaultProps.MARKER_RANGE + 1), new Position(xCoord, yCoord, zCoord),
LaserKind.Blue);
}
}
@ -320,7 +320,7 @@ public class TileMarker extends TileBuildCraft implements ITileAreaProvider {
o.zMax = origin.vect[2].z;
}
lasers = Utils.createLaserBox(worldObj, o.xMin, o.yMin, o.zMin, o.xMax, o.yMax, o.zMax, LaserKind.Red);
lasers = LaserUtils.createLaserBox(worldObj, o.xMin, o.yMin, o.zMin, o.xMax, o.yMax, o.zMax, LaserKind.Red);
}
@Override

View file

@ -71,17 +71,19 @@ public class BptBuilderBlueprint extends BptBuilderBase {
}
@Override
protected void internalInit () {
protected void internalInit() {
for (int j = blueprint.sizeY - 1; j >= 0; --j) {
for (int i = 0; i < blueprint.sizeX; ++i) {
for (int k = 0; k < blueprint.sizeZ; ++k) {
int xCoord = i + x - blueprint.anchorX;
int yCoord = j + y - blueprint.anchorY;
int zCoord = k + z - blueprint.anchorZ;
int yCoord = j + y - blueprint.anchorY;
if (yCoord < 0 || yCoord >= context.world.getHeight()) {
continue;
}
if (yCoord < 0 || yCoord >= context.world.getHeight()) {
continue;
}
for (int i = 0; i < blueprint.sizeX; ++i) {
int xCoord = i + x - blueprint.anchorX;
for (int k = 0; k < blueprint.sizeZ; ++k) {
int zCoord = k + z - blueprint.anchorZ;
if (!isLocationUsed(xCoord, yCoord, zCoord)) {
SchematicBlock slot = (SchematicBlock) blueprint.get(i, j, k);
@ -119,15 +121,21 @@ public class BptBuilderBlueprint extends BptBuilderBase {
LinkedList<BuildingSlotBlock> tmpExpanding = new LinkedList<BuildingSlotBlock>();
for (int j = 0; j < blueprint.sizeY; ++j) {
int yCoord = j + y - blueprint.anchorY;
if (yCoord < 0 || yCoord >= context.world.getHeight()) {
continue;
}
for (int i = 0; i < blueprint.sizeX; ++i) {
int xCoord = i + x - blueprint.anchorX;
for (int k = 0; k < blueprint.sizeZ; ++k) {
int xCoord = i + x - blueprint.anchorX;
int yCoord = j + y - blueprint.anchorY;
int zCoord = k + z - blueprint.anchorZ;
SchematicBlock slot = (SchematicBlock) blueprint.get(i, j, k);
if (slot == null || yCoord < 0 || yCoord >= context.world.getHeight()) {
if (slot == null) {
continue;
}

View file

@ -40,15 +40,17 @@ public class BptBuilderTemplate extends BptBuilderBase {
protected void internalInit () {
if (blueprint.excavate) {
for (int j = blueprint.sizeY - 1; j >= 0; --j) {
for (int i = 0; i < blueprint.sizeX; ++i) {
for (int k = 0; k < blueprint.sizeZ; ++k) {
int xCoord = i + x - blueprint.anchorX;
int yCoord = j + y - blueprint.anchorY;
int zCoord = k + z - blueprint.anchorZ;
int yCoord = j + y - blueprint.anchorY;
if (yCoord < 0 || yCoord >= context.world.getHeight()) {
continue;
}
if (yCoord < 0 || yCoord >= context.world.getHeight()) {
continue;
}
for (int i = 0; i < blueprint.sizeX; ++i) {
int xCoord = i + x - blueprint.anchorX;
for (int k = 0; k < blueprint.sizeZ; ++k) {
int zCoord = k + z - blueprint.anchorZ;
SchematicBlockBase slot = blueprint.get(i, j, k);
@ -70,15 +72,17 @@ public class BptBuilderTemplate extends BptBuilderBase {
}
for (int j = 0; j < blueprint.sizeY; ++j) {
for (int i = 0; i < blueprint.sizeX; ++i) {
for (int k = 0; k < blueprint.sizeZ; ++k) {
int xCoord = i + x - blueprint.anchorX;
int yCoord = j + y - blueprint.anchorY;
int zCoord = k + z - blueprint.anchorZ;
int yCoord = j + y - blueprint.anchorY;
if (yCoord < 0 || yCoord >= context.world.getHeight()) {
continue;
}
if (yCoord < 0 || yCoord >= context.world.getHeight()) {
continue;
}
for (int i = 0; i < blueprint.sizeX; ++i) {
int xCoord = i + x - blueprint.anchorX;
for (int k = 0; k < blueprint.sizeZ; ++k) {
int zCoord = k + z - blueprint.anchorZ;
SchematicBlockBase slot = blueprint.get(i, j, k);

View file

@ -0,0 +1,5 @@
package buildcraft.core.internal;
public interface ICustomLEDBlock {
String[] getLEDSuffixes();
}

View file

@ -15,9 +15,11 @@ import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import cpw.mods.fml.common.FMLCommonHandler;
@ -26,9 +28,11 @@ import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.BuildCraftCore;
import buildcraft.api.core.IInvSlot;
import buildcraft.api.events.BlockInteractionEvent;
import buildcraft.api.tiles.IHasWork;
import buildcraft.core.BCCreativeTab;
import buildcraft.core.lib.inventory.InventoryIterator;
import buildcraft.core.lib.utils.ResourceUtils;
import buildcraft.core.lib.utils.Utils;
import buildcraft.core.lib.utils.XorShift128Random;
@ -271,4 +275,32 @@ public abstract class BlockBuildCraft extends BlockContainer {
}
return meta >= 2 && meta <= 5 ? meta : 3;
}
@Override
public boolean hasComparatorInputOverride() {
return this instanceof IComparatorInventory;
}
public int getComparatorInputOverride(World world, int x, int y, int z, int side) {
TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof IInventory) {
int count = 0;
int countNonEmpty = 0;
float power = 0.0F;
for (IInvSlot slot : InventoryIterator.getIterable((IInventory) tile, ForgeDirection.getOrientation(side))) {
if (((IComparatorInventory) this).doesSlotCountComparator(tile, slot.getIndex(), slot.getStackInSlot())) {
count++;
if (slot.getStackInSlot() != null) {
countNonEmpty++;
power += (float) slot.getStackInSlot().stackSize / (float) Math.min(((IInventory) tile).getInventoryStackLimit(), slot.getStackInSlot().getMaxStackSize());
}
}
}
power /= count;
return MathHelper.floor_float(power * 14.0F) + (countNonEmpty > 0 ? 1 : 0);
}
return 0;
}
}

View file

@ -0,0 +1,11 @@
package buildcraft.core.lib.block;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
/**
* Implemented by Blocks which have an inventory Comparator override.
*/
public interface IComparatorInventory {
boolean doesSlotCountComparator(TileEntity tile, int slot, ItemStack stack);
}

View file

@ -0,0 +1,62 @@
package buildcraft.core.lib.render;
import net.minecraft.util.IIcon;
public class FakeIcon implements IIcon {
private final int w, h;
private final float minU, maxU, minV, maxV;
public FakeIcon(float minU, float maxU, float minV, float maxV, int w, int h) {
this.minU = minU;
this.minV = minV;
this.maxU = maxU;
this.maxV = maxV;
this.w = w;
this.h = h;
}
@Override
public int getIconWidth() {
return w;
}
@Override
public int getIconHeight() {
return h;
}
@Override
public float getMinU() {
return minU;
}
@Override
public float getMaxU() {
return maxU;
}
@Override
public float getInterpolatedU(double uu) {
return (float) (minU + (uu * (maxU - minU) / 16.0));
}
@Override
public float getMinV() {
return minV;
}
@Override
public float getMaxV() {
return maxV;
}
@Override
public float getInterpolatedV(double uu) {
return (float) (minV + (uu * (maxV - minV) / 16.0));
}
@Override
public String getIconName() {
return "FakeIcon";
}
}

View file

@ -52,12 +52,11 @@ public final class RenderEntityBlock extends Render {
public Block baseBlock = Blocks.sand;
public IIcon texture = null;
public IIcon[] textureArray = null;
public boolean[] renderSide = new boolean[6];
public boolean[] renderSide = new boolean[]{true, true, true, true, true, true};
public int light = -1;
public int brightness = -1;
public RenderInfo() {
setRenderAllSides();
}
public RenderInfo(Block template, IIcon[] texture) {

View file

@ -15,6 +15,10 @@ public class AverageInt {
public AverageInt(int precise) {
this.precise = precise;
clear();
}
public void clear() {
this.data = new int[precise];
this.pos = 0;
}

View file

@ -3,7 +3,6 @@ package buildcraft.core.lib.utils;
import java.util.BitSet;
public final class BitSetUtils {
private BitSetUtils() {
}

View file

@ -302,6 +302,10 @@ public final class BlockUtils {
return done;
}
public static void onComparatorUpdate(World world, int x, int y, int z, Block block) {
world.func_147453_f(x, y, z, block);
}
public static TileEntityChest getOtherDoubleChest(TileEntity inv) {
if (inv instanceof TileEntityChest) {
TileEntityChest chest = (TileEntityChest) inv;

View file

@ -1,115 +0,0 @@
/**
* 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.lib.utils;
import org.apache.logging.log4j.Level;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.config.Property;
import buildcraft.api.core.BCLog;
public class ConfigUtils {
private static final String COMMENT_PREFIX = "";
private static final String COMMENT_SUFFIX = "";
private final Configuration config;
private final String cat;
public ConfigUtils(Configuration config, String cat) {
this.config = config;
this.cat = cat;
}
public boolean get(String tag, boolean defaultValue, String comment) {
return get(tag, defaultValue, false, comment);
}
public boolean get(String tag, boolean defaultValue, boolean reset, String comment) {
Property prop = config.get(cat, tag, defaultValue);
prop.comment = COMMENT_PREFIX + comment.replace("{t}", tag) + COMMENT_SUFFIX;
boolean ret = parseBoolean(prop, defaultValue);
if (reset) {
prop.set(defaultValue);
}
return ret;
}
public int get(String tag, int defaultValue, String comment) {
Property prop = config.get(cat, tag, defaultValue);
prop.comment = COMMENT_PREFIX + comment.replace("{t}", tag) + COMMENT_SUFFIX;
return parseInteger(prop, defaultValue);
}
public int get(String tag, int min, int defaultValue, int max, String comment) {
Property prop = config.get(cat, tag, defaultValue);
prop.comment = COMMENT_PREFIX + comment.replace("{t}", tag) + COMMENT_SUFFIX;
int parsed = parseInteger(prop, defaultValue);
int clamped = Math.max(parsed, min);
clamped = Math.min(clamped, max);
if (clamped != parsed) {
prop.set(clamped);
}
return clamped;
}
public float get(String tag, float min, float defaultValue, float max, String comment) {
Property prop = config.get(cat, tag, defaultValue);
prop.comment = COMMENT_PREFIX + comment.replace("{t}", tag) + COMMENT_SUFFIX;
double parsed = parseDouble(prop, defaultValue);
double clamped = Math.max(parsed, min);
clamped = Math.min(clamped, max);
if (clamped != parsed) {
prop.set(clamped);
}
return (float) clamped;
}
private boolean parseBoolean(Property prop, boolean defaultValue) {
String value = prop.getString();
boolean parsed;
try {
parsed = Boolean.parseBoolean(value);
} catch (NumberFormatException ex) {
BCLog.logger.log(Level.WARN, "Failed to parse config tag, reseting to default: " + prop.getName(), ex);
prop.set(defaultValue);
return defaultValue;
}
return parsed;
}
private int parseInteger(Property prop, int defaultValue) {
String value = prop.getString();
int parsed;
try {
parsed = Integer.parseInt(value);
} catch (NumberFormatException ex) {
BCLog.logger.log(Level.WARN, "Failed to parse config tag, reseting to default: " + prop.getName(), ex);
prop.set(defaultValue);
return defaultValue;
}
return parsed;
}
private double parseDouble(Property prop, double defaultValue) {
String value = prop.getString();
double parsed;
try {
parsed = Double.parseDouble(value);
} catch (NumberFormatException ex) {
BCLog.logger.log(Level.WARN, "Failed to parse config tag, reseting to default: " + prop.getName(), ex);
prop.set(defaultValue);
return defaultValue;
}
return parsed;
}
}

View file

@ -0,0 +1,117 @@
package buildcraft.core.lib.utils;
import net.minecraft.world.World;
import buildcraft.api.core.Position;
import buildcraft.core.LaserData;
import buildcraft.core.LaserKind;
import buildcraft.core.lib.EntityBlock;
import buildcraft.core.proxy.CoreProxy;
public final class LaserUtils {
private LaserUtils() {
}
public static EntityBlock createLaser(World world, Position p1, Position p2, LaserKind kind) {
if (p1.equals(p2)) {
return null;
}
double iSize = p2.x - p1.x;
double jSize = p2.y - p1.y;
double kSize = p2.z - p1.z;
double i = p1.x;
double j = p1.y;
double k = p1.z;
if (iSize != 0) {
i += 0.5;
j += 0.45;
k += 0.45;
jSize = 0.10;
kSize = 0.10;
} else if (jSize != 0) {
i += 0.45;
j += 0.5;
k += 0.45;
iSize = 0.10;
kSize = 0.10;
} else if (kSize != 0) {
i += 0.45;
j += 0.45;
k += 0.5;
iSize = 0.10;
jSize = 0.10;
}
EntityBlock block = CoreProxy.proxy.newEntityBlock(world, i, j, k, iSize, jSize, kSize, kind);
block.setBrightness(210);
world.spawnEntityInWorld(block);
return block;
}
public static EntityBlock[] createLaserBox(World world, double xMin, double yMin, double zMin, double xMax, double yMax, double zMax, LaserKind kind) {
EntityBlock[] lasers = new EntityBlock[12];
Position[] p = new Position[8];
p[0] = new Position(xMin, yMin, zMin);
p[1] = new Position(xMax, yMin, zMin);
p[2] = new Position(xMin, yMax, zMin);
p[3] = new Position(xMax, yMax, zMin);
p[4] = new Position(xMin, yMin, zMax);
p[5] = new Position(xMax, yMin, zMax);
p[6] = new Position(xMin, yMax, zMax);
p[7] = new Position(xMax, yMax, zMax);
lasers[0] = createLaser(world, p[0], p[1], kind);
lasers[1] = createLaser(world, p[0], p[2], kind);
lasers[2] = createLaser(world, p[2], p[3], kind);
lasers[3] = createLaser(world, p[1], p[3], kind);
lasers[4] = createLaser(world, p[4], p[5], kind);
lasers[5] = createLaser(world, p[4], p[6], kind);
lasers[6] = createLaser(world, p[5], p[7], kind);
lasers[7] = createLaser(world, p[6], p[7], kind);
lasers[8] = createLaser(world, p[0], p[4], kind);
lasers[9] = createLaser(world, p[1], p[5], kind);
lasers[10] = createLaser(world, p[2], p[6], kind);
lasers[11] = createLaser(world, p[3], p[7], kind);
return lasers;
}
public static LaserData[] createLaserDataBox(double xMin, double yMin, double zMin, double xMax, double yMax, double zMax) {
LaserData[] lasers = new LaserData[12];
Position[] p = new Position[8];
p[0] = new Position(xMin, yMin, zMin);
p[1] = new Position(xMax, yMin, zMin);
p[2] = new Position(xMin, yMax, zMin);
p[3] = new Position(xMax, yMax, zMin);
p[4] = new Position(xMin, yMin, zMax);
p[5] = new Position(xMax, yMin, zMax);
p[6] = new Position(xMin, yMax, zMax);
p[7] = new Position(xMax, yMax, zMax);
lasers[0] = new LaserData (p[0], p[1]);
lasers[1] = new LaserData (p[0], p[2]);
lasers[2] = new LaserData (p[2], p[3]);
lasers[3] = new LaserData (p[1], p[3]);
lasers[4] = new LaserData (p[4], p[5]);
lasers[5] = new LaserData (p[4], p[6]);
lasers[6] = new LaserData (p[5], p[7]);
lasers[7] = new LaserData (p[6], p[7]);
lasers[8] = new LaserData (p[0], p[4]);
lasers[9] = new LaserData (p[1], p[5]);
lasers[10] = new LaserData (p[2], p[6]);
lasers[11] = new LaserData (p[3], p[7]);
return lasers;
}
}

View file

@ -35,7 +35,7 @@ public final class ThreadSafeUtils {
}
IChunkProvider provider = world.getChunkProvider();
// These probably won't guarantee full thread safety, but it's our best bets.
// These probably won't guarantee full thread safety, but it's our best bet.
if (!Utils.CAULDRON_DETECTED && provider instanceof ChunkProviderServer) {
// Slight optimization
chunk = (Chunk) ((ChunkProviderServer) provider).loadedChunkHashMap.getValueByKey(ChunkCoordIntPair.chunkXZ2Int(x, z));

View file

@ -39,17 +39,13 @@ import buildcraft.api.transport.IInjectable;
import buildcraft.api.transport.IPipeTile;
import buildcraft.core.CompatHooks;
import buildcraft.core.DefaultProps;
import buildcraft.core.LaserData;
import buildcraft.core.LaserKind;
import buildcraft.core.internal.IDropControlInventory;
import buildcraft.core.internal.IFramePipeConnection;
import buildcraft.core.lib.EntityBlock;
import buildcraft.core.lib.block.TileBuildCraft;
import buildcraft.core.lib.inventory.ITransactor;
import buildcraft.core.lib.inventory.InvUtils;
import buildcraft.core.lib.inventory.Transactor;
import buildcraft.core.lib.network.Packet;
import buildcraft.core.proxy.CoreProxy;
public final class Utils {
public static final boolean CAULDRON_DETECTED;
@ -178,108 +174,6 @@ public final class Utils {
return null;
}
public static EntityBlock createLaser(World world, Position p1, Position p2, LaserKind kind) {
if (p1.equals(p2)) {
return null;
}
double iSize = p2.x - p1.x;
double jSize = p2.y - p1.y;
double kSize = p2.z - p1.z;
double i = p1.x;
double j = p1.y;
double k = p1.z;
if (iSize != 0) {
i += 0.5;
j += 0.45;
k += 0.45;
jSize = 0.10;
kSize = 0.10;
} else if (jSize != 0) {
i += 0.45;
j += 0.5;
k += 0.45;
iSize = 0.10;
kSize = 0.10;
} else if (kSize != 0) {
i += 0.45;
j += 0.45;
k += 0.5;
iSize = 0.10;
jSize = 0.10;
}
EntityBlock block = CoreProxy.proxy.newEntityBlock(world, i, j, k, iSize, jSize, kSize, kind);
block.setBrightness(210);
world.spawnEntityInWorld(block);
return block;
}
public static EntityBlock[] createLaserBox(World world, double xMin, double yMin, double zMin, double xMax, double yMax, double zMax, LaserKind kind) {
EntityBlock[] lasers = new EntityBlock[12];
Position[] p = new Position[8];
p[0] = new Position(xMin, yMin, zMin);
p[1] = new Position(xMax, yMin, zMin);
p[2] = new Position(xMin, yMax, zMin);
p[3] = new Position(xMax, yMax, zMin);
p[4] = new Position(xMin, yMin, zMax);
p[5] = new Position(xMax, yMin, zMax);
p[6] = new Position(xMin, yMax, zMax);
p[7] = new Position(xMax, yMax, zMax);
lasers[0] = Utils.createLaser(world, p[0], p[1], kind);
lasers[1] = Utils.createLaser(world, p[0], p[2], kind);
lasers[2] = Utils.createLaser(world, p[2], p[3], kind);
lasers[3] = Utils.createLaser(world, p[1], p[3], kind);
lasers[4] = Utils.createLaser(world, p[4], p[5], kind);
lasers[5] = Utils.createLaser(world, p[4], p[6], kind);
lasers[6] = Utils.createLaser(world, p[5], p[7], kind);
lasers[7] = Utils.createLaser(world, p[6], p[7], kind);
lasers[8] = Utils.createLaser(world, p[0], p[4], kind);
lasers[9] = Utils.createLaser(world, p[1], p[5], kind);
lasers[10] = Utils.createLaser(world, p[2], p[6], kind);
lasers[11] = Utils.createLaser(world, p[3], p[7], kind);
return lasers;
}
public static LaserData[] createLaserDataBox(double xMin, double yMin, double zMin, double xMax, double yMax, double zMax) {
LaserData[] lasers = new LaserData[12];
Position[] p = new Position[8];
p[0] = new Position(xMin, yMin, zMin);
p[1] = new Position(xMax, yMin, zMin);
p[2] = new Position(xMin, yMax, zMin);
p[3] = new Position(xMax, yMax, zMin);
p[4] = new Position(xMin, yMin, zMax);
p[5] = new Position(xMax, yMin, zMax);
p[6] = new Position(xMin, yMax, zMax);
p[7] = new Position(xMax, yMax, zMax);
lasers[0] = new LaserData (p[0], p[1]);
lasers[1] = new LaserData (p[0], p[2]);
lasers[2] = new LaserData (p[2], p[3]);
lasers[3] = new LaserData (p[1], p[3]);
lasers[4] = new LaserData (p[4], p[5]);
lasers[5] = new LaserData (p[4], p[6]);
lasers[6] = new LaserData (p[5], p[7]);
lasers[7] = new LaserData (p[6], p[7]);
lasers[8] = new LaserData (p[0], p[4]);
lasers[9] = new LaserData (p[1], p[5]);
lasers[10] = new LaserData (p[2], p[6]);
lasers[11] = new LaserData (p[3], p[7]);
return lasers;
}
public static void preDestroyBlock(World world, int i, int j, int k) {
TileEntity tile = BlockUtils.getTileEntity(world, i, j, k);

View file

@ -2,18 +2,18 @@ package buildcraft.core.list;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import buildcraft.core.lib.inventory.StackHelper;
import buildcraft.core.lib.utils.FluidUtils;
public class ListMatchHandlerFluid extends ListMatchHandler {
@Override
public boolean matches(Type type, ItemStack stack, ItemStack target, boolean precise) {
if (type == Type.MATERIAL) {
if (type == Type.TYPE) {
if (FluidContainerRegistry.isContainer(stack) && FluidContainerRegistry.isContainer(target)) {
ItemStack emptyContainerStack = FluidContainerRegistry.drainFluidContainer(stack);
ItemStack emptyContainerTarget = FluidContainerRegistry.drainFluidContainer(target);
@ -21,7 +21,7 @@ public class ListMatchHandlerFluid extends ListMatchHandler {
return true;
}
}
} else if (type == Type.TYPE) {
} else if (type == Type.MATERIAL) {
FluidStack fStack = FluidUtils.getFluidStackFromItemStack(stack);
FluidStack fTarget = FluidUtils.getFluidStackFromItemStack(target);
if (fStack != null && fTarget != null) {
@ -33,7 +33,7 @@ public class ListMatchHandlerFluid extends ListMatchHandler {
@Override
public List<ItemStack> getClientExamples(Type type, ItemStack stack) {
if (type == Type.TYPE) {
if (type == Type.MATERIAL) {
FluidStack fStack = FluidUtils.getFluidStackFromItemStack(stack);
if (fStack != null) {
List<ItemStack> examples = new ArrayList<ItemStack>();
@ -44,7 +44,7 @@ public class ListMatchHandlerFluid extends ListMatchHandler {
}
return examples;
}
} else if (type == Type.MATERIAL) {
} else if (type == Type.TYPE) {
if (FluidContainerRegistry.isContainer(stack)) {
List<ItemStack> examples = new ArrayList<ItemStack>();
ItemStack emptyContainerStack = FluidContainerRegistry.drainFluidContainer(stack);

View file

@ -0,0 +1,24 @@
package buildcraft.core.list;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
import buildcraft.api.items.IList;
import buildcraft.core.lib.utils.StringUtils;
public class ListTooltipHandler {
@SubscribeEvent
public void itemTooltipEvent(ItemTooltipEvent event) {
if (event.itemStack != null && event.entityPlayer != null && event.entityPlayer.openContainer != null
&& event.entityPlayer.openContainer instanceof ContainerListNew) {
ItemStack list = event.entityPlayer.getCurrentEquippedItem();
if (list != null && list.getItem() instanceof IList) {
if (((IList) list.getItem()).matches(list, event.itemStack)) {
event.toolTip.add(EnumChatFormatting.GREEN + StringUtils.localize("tip.list.matches"));
}
}
}
}
}

View file

@ -0,0 +1,49 @@
/**
* 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 java.util.HashSet;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.oredict.OreDictionary;
public class WorldPropertyIsRock extends WorldProperty {
private final HashSet<Integer> rockIds = new HashSet<Integer>();
public WorldPropertyIsRock() {
rockIds.add(OreDictionary.getOreID("stone"));
rockIds.add(OreDictionary.getOreID("cobblestone"));
rockIds.add(OreDictionary.getOreID("sandstone"));
}
@Override
public boolean get(IBlockAccess blockAccess, Block block, int meta, int x, int y, int z) {
if (block == null) {
return false;
} else if (block == Blocks.stone) {
return true;
} else {
ItemStack stack = new ItemStack(block);
if (stack.getItem() != null) {
for (int id : OreDictionary.getOreIDs(stack)) {
if (rockIds.contains(id)) {
return true;
}
}
}
}
return false;
}
}

View file

@ -1,6 +1,8 @@
package buildcraft.core.render;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.lwjgl.opengl.GL11;
@ -12,6 +14,7 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import buildcraft.core.internal.ICustomLEDBlock;
import buildcraft.core.internal.ILEDProvider;
import buildcraft.core.lib.block.BlockBuildCraft;
import buildcraft.core.lib.render.RenderEntityBlock;
@ -29,12 +32,18 @@ public class RenderLEDTile extends TileEntitySpecialRenderer {
public static void registerBlockIcons(IIconRegister register) {
for (Block b : iconMap.keySet().toArray(new Block[iconMap.keySet().size()])) {
// TODO (7.1): The count of icons is hardcoded here. Consider adding a better way.
String base = ResourceUtils.getObjectPrefix(Block.blockRegistry.getNameForObject(b));
iconMap.put(b, new IIcon[] {
register.registerIcon(base + "/led_red"),
register.registerIcon(base + "/led_green")
});
List<IIcon> icons = new ArrayList<IIcon>();
if (b instanceof ICustomLEDBlock) {
for (String s : ((ICustomLEDBlock) b).getLEDSuffixes()) {
icons.add(register.registerIcon(base + "/" + s));
}
} else {
icons.add(register.registerIcon(base + "/led_red"));
icons.add(register.registerIcon(base + "/led_green"));
}
iconMap.put(b, icons.toArray(new IIcon[icons.size()]));
}
}
@ -58,8 +67,10 @@ public class RenderLEDTile extends TileEntitySpecialRenderer {
GL11.glScalef(Z_OFFSET, Z_OFFSET, Z_OFFSET);
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
for (int i = 0; i < 2; i++) {
renderBox.texture = iconMap.get(block)[i];
IIcon[] icons = iconMap.get(block);
for (int i = 0; i < icons.length; i++) {
renderBox.texture = icons[i];
if (((BlockBuildCraft) block).isRotatable()) {
renderBox.setRenderSingleSide(((BlockBuildCraft) block).getFrontSide(tile.getBlockMetadata()));
} else {
@ -71,7 +82,9 @@ public class RenderLEDTile extends TileEntitySpecialRenderer {
renderBox.renderSide[5] = true;
}
renderBox.light = provider.getLEDLevel(i);
RenderEntityBlock.INSTANCE.renderBlock(renderBox);
if (renderBox.light > 0) {
RenderEntityBlock.INSTANCE.renderBlock(renderBox);
}
}
GL11.glPopAttrib();

View file

@ -0,0 +1,118 @@
package buildcraft.core.statements;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.IIcon;
import buildcraft.api.statements.IStatement;
import buildcraft.api.statements.IStatementContainer;
import buildcraft.api.statements.IStatementParameter;
import buildcraft.api.statements.StatementMouseClick;
public class StatementParameterItemStackExact implements IStatementParameter {
protected ItemStack stack;
@Override
public IIcon getIcon() {
return null;
}
@Override
public ItemStack getItemStack() {
return stack;
}
@Override
public void onClick(IStatementContainer source, IStatement stmt, ItemStack stack, StatementMouseClick mouse) {
if (stack != null) {
if (areItemsEqual(this.stack, stack)) {
if (mouse.getButton() == 0) {
this.stack.stackSize += (mouse.isShift()) ? 16 : 1;
if (this.stack.stackSize > 64) {
this.stack.stackSize = 64;
}
} else {
this.stack.stackSize -= (mouse.isShift()) ? 16 : 1;
if (this.stack.stackSize < 0) {
this.stack.stackSize = 0;
}
}
} else {
this.stack = stack.copy();
}
} else {
if (this.stack != null) {
if (mouse.getButton() == 0) {
this.stack.stackSize += (mouse.isShift()) ? 16 : 1;
if (this.stack.stackSize > 64) {
this.stack.stackSize = 64;
}
} else {
this.stack.stackSize -= (mouse.isShift()) ? 16 : 1;
if (this.stack.stackSize < 0) {
this.stack = null;
}
}
}
}
}
@Override
public void writeToNBT(NBTTagCompound compound) {
if (stack != null) {
NBTTagCompound tagCompound = new NBTTagCompound();
stack.writeToNBT(tagCompound);
compound.setTag("stack", tagCompound);
}
}
@Override
public void readFromNBT(NBTTagCompound compound) {
stack = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("stack"));
}
@Override
public boolean equals(Object object) {
if (object instanceof StatementParameterItemStackExact) {
StatementParameterItemStackExact param = (StatementParameterItemStackExact) object;
return areItemsEqual(stack, param.stack);
} else {
return false;
}
}
private boolean areItemsEqual(ItemStack stack1, ItemStack stack2) {
if (stack1 != null) {
return stack1.isItemEqual(stack2) && ItemStack.areItemStackTagsEqual(stack1, stack2);
} else {
return stack2 == null;
}
}
@Override
public String getDescription() {
if (stack != null) {
return stack.getDisplayName();
} else {
return "";
}
}
@Override
public String getUniqueTag() {
return "buildcraft:stackExact";
}
@Override
public void registerIcons(IIconRegister iconRegister) {
}
@Override
public IStatementParameter rotateLeft() {
return this;
}
}

View file

@ -11,6 +11,7 @@ package buildcraft.factory;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
@ -22,9 +23,9 @@ import buildcraft.BuildCraftFactory;
import buildcraft.api.transport.IItemPipe;
import buildcraft.core.GuiIds;
import buildcraft.core.lib.block.BlockBuildCraft;
import buildcraft.core.lib.block.IComparatorInventory;
public class BlockHopper extends BlockBuildCraft {
public class BlockHopper extends BlockBuildCraft implements IComparatorInventory {
private static IIcon icon;
public BlockHopper() {
@ -85,4 +86,9 @@ public class BlockHopper extends BlockBuildCraft {
public IIcon getIconAbsolute(int par1, int par2) {
return icon;
}
@Override
public boolean doesSlotCountComparator(TileEntity tile, int slot, ItemStack stack) {
return true;
}
}

View file

@ -114,6 +114,7 @@ public class TileHopper extends TileBuildCraft implements IInventory, IEnergyHan
@Override
public void markDirty() {
super.markDirty();
isEmpty = true;
for (int internalSlot = 0; internalSlot < inventory.getSizeInventory(); internalSlot++) {

View file

@ -27,6 +27,7 @@ import buildcraft.api.core.SafeTimeTracker;
import buildcraft.core.lib.block.TileBuildCraft;
import buildcraft.core.lib.fluids.Tank;
import buildcraft.core.lib.fluids.TankManager;
import buildcraft.core.lib.utils.BlockUtils;
public class TileTank extends TileBuildCraft implements IFluidHandler {
public final Tank tank = new Tank("tank", FluidContainerRegistry.BUCKET_VOLUME * 16, this);
@ -82,7 +83,7 @@ public class TileTank extends TileBuildCraft implements IFluidHandler {
}
if (hasUpdate) {
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockType());
BlockUtils.onComparatorUpdate(worldObj, xCoord, yCoord, zCoord, getBlockType());
hasUpdate = false;
}

View file

@ -10,14 +10,16 @@ package buildcraft.robotics;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import buildcraft.BuildCraftRobotics;
import buildcraft.core.GuiIds;
import buildcraft.core.lib.block.BlockBuildCraft;
import buildcraft.core.lib.block.IComparatorInventory;
public class BlockRequester extends BlockBuildCraft {
public class BlockRequester extends BlockBuildCraft implements IComparatorInventory {
public BlockRequester() {
super(Material.iron);
setRotatable(true);
@ -42,4 +44,9 @@ public class BlockRequester extends BlockBuildCraft {
return true;
}
@Override
public boolean doesSlotCountComparator(TileEntity tile, int slot, ItemStack stack) {
return ((TileRequester) tile).getRequestTemplate(slot) != null;
}
}

View file

@ -1,20 +1,28 @@
package buildcraft.robotics;
import java.util.List;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.IFluidHandler;
import buildcraft.BuildCraftRobotics;
import buildcraft.api.core.BlockIndex;
import buildcraft.api.core.EnumColor;
import buildcraft.api.gates.IGate;
import buildcraft.api.robots.DockingStation;
import buildcraft.api.robots.EntityRobotBase;
import buildcraft.api.robots.IRequestProvider;
import buildcraft.api.robots.RobotManager;
import buildcraft.api.statements.IStatement;
import buildcraft.api.statements.StatementSlot;
import buildcraft.api.transport.IInjectable;
import buildcraft.api.transport.IPipeTile;
import buildcraft.core.lib.inventory.InventoryWrapper;
import buildcraft.transport.Pipe;
import buildcraft.transport.PipeTransportItems;
import buildcraft.transport.TravelingItem;
@ -22,7 +30,7 @@ import buildcraft.transport.gates.ActionIterator;
import buildcraft.transport.pipes.PipeFluidsWood;
import buildcraft.transport.pipes.PipeItemsWood;
public class DockingStationPipe extends DockingStation {
public class DockingStationPipe extends DockingStation implements IRequestProvider {
private IInjectable injectablePipe = new IInjectable() {
@Override
@ -92,7 +100,12 @@ public class DockingStationPipe extends DockingStation {
}
@Override
public IInventory getItemInput() {
public ForgeDirection getItemOutputSide() {
return side().getOpposite();
}
@Override
public ISidedInventory getItemInput() {
if (getPipe().getPipeType() != IPipeTile.PipeType.ITEM) {
return null;
}
@ -107,12 +120,26 @@ public class DockingStationPipe extends DockingStation {
TileEntity connectedTile = getPipe().getWorld().getTileEntity(x() + dir.offsetX,
y() + dir.offsetY, z() + dir.offsetZ);
if (connectedTile instanceof IInventory) {
return (IInventory) connectedTile;
return InventoryWrapper.getWrappedInventory(connectedTile);
}
return null;
}
@Override
public ForgeDirection getItemInputSide() {
if (getPipe().getPipeType() != IPipeTile.PipeType.ITEM) {
return ForgeDirection.UNKNOWN;
}
if (!(getPipe().getPipe() instanceof PipeItemsWood)) {
return ForgeDirection.UNKNOWN;
}
int meta = ((TileEntity) getPipe()).getBlockMetadata();
return ForgeDirection.getOrientation(meta).getOpposite();
}
@Override
public IFluidHandler getFluidInput() {
if (getPipe().getPipeType() != IPipeTile.PipeType.FLUID) {
@ -135,6 +162,20 @@ public class DockingStationPipe extends DockingStation {
return null;
}
@Override
public ForgeDirection getFluidInputSide() {
if (getPipe().getPipeType() != IPipeTile.PipeType.FLUID) {
return ForgeDirection.UNKNOWN;
}
if (!(getPipe().getPipe() instanceof PipeFluidsWood)) {
return ForgeDirection.UNKNOWN;
}
int meta = ((TileEntity) getPipe()).getBlockMetadata();
return ForgeDirection.getOrientation(meta).getOpposite();
}
@Override
public IFluidHandler getFluidOutput() {
if (getPipe().getPipeType() != IPipeTile.PipeType.FLUID) {
@ -144,6 +185,11 @@ public class DockingStationPipe extends DockingStation {
return (IFluidHandler) ((Pipe) getPipe().getPipe()).transport;
}
@Override
public ForgeDirection getFluidOutputSide() {
return ForgeDirection.UNKNOWN;
}
@Override
public boolean providesPower() {
return getPipe().getPipeType() == IPipeTile.PipeType.POWER;
@ -158,7 +204,7 @@ public class DockingStationPipe extends DockingStation {
return (IRequestProvider) nearbyTile;
}
}
return null;
return this;
}
@Override
@ -199,4 +245,62 @@ public class DockingStationPipe extends DockingStation {
public void onChunkUnload() {
pipe = null;
}
@Override
public int getRequestsCount() {
return 127;
}
@Override
public ItemStack getRequest(int slot) {
ForgeDirection side = ForgeDirection.getOrientation((slot & 0x70) >> 4);
int action = (slot & 0xc) >> 2;
int param = slot & 0x3;
IGate gate = getPipe().getPipe().getGate(side);
if (gate == null) {
return null;
}
List<IStatement> actions = gate.getActions();
if (actions.size() <= action) {
return null;
}
if (actions.get(action) != BuildCraftRobotics.actionStationRequestItems) {
return null;
}
List<StatementSlot> activeActions = gate.getActiveActions();
StatementSlot slotStmt = null;
for (StatementSlot stmt : activeActions) {
if (stmt.statement == actions.get(action)) {
slotStmt = stmt;
break;
}
}
if (slotStmt == null) {
return null;
}
if (slotStmt.parameters.length <= param) {
return null;
}
if (slotStmt.parameters[param] == null) {
return null;
}
return slotStmt.parameters[param].getItemStack();
}
@Override
public ItemStack offerItem(int slot, ItemStack stack) {
int consumed = injectablePipe.injectItem(stack, true, side.getOpposite(), null);
if (stack.stackSize > consumed) {
ItemStack newStack = stack.copy();
newStack.stackSize -= consumed;
return newStack;
}
return null;
}
}

View file

@ -16,7 +16,6 @@ import java.util.WeakHashMap;
import com.google.common.collect.Iterables;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import io.netty.buffer.ByteBuf;
import net.minecraft.client.Minecraft;
@ -35,7 +34,6 @@ import net.minecraft.server.MinecraftServer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EntityDamageSource;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
@ -48,7 +46,6 @@ import net.minecraft.world.WorldServer;
import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.common.util.Constants.NBT;
@ -1058,13 +1055,15 @@ public class EntityRobot extends EntityRobotBase implements
}
private IZone getZone(AreaType areaType) {
for (StatementSlot s : linkedDockingStation.getActiveActions()) {
if (s.statement instanceof ActionRobotWorkInArea
&& ((ActionRobotWorkInArea) s.statement).getAreaType() == areaType) {
IZone zone = ActionRobotWorkInArea.getArea(s);
if (linkedDockingStation != null) {
for (StatementSlot s : linkedDockingStation.getActiveActions()) {
if (s.statement instanceof ActionRobotWorkInArea
&& ((ActionRobotWorkInArea) s.statement).getAreaType() == areaType) {
IZone zone = ActionRobotWorkInArea.getArea(s);
if (zone != null) {
return zone;
if (zone != null) {
return zone;
}
}
}
}

View file

@ -14,14 +14,15 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.LongHashMap;
import net.minecraft.world.World;
import net.minecraft.world.WorldSavedData;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.event.world.ChunkEvent;
@ -175,8 +176,6 @@ public class RobotRegistry extends WorldSavedData implements IRobotRegistry {
getResourcesTakenByRobot(robotId).add(resourceId);
resourceId.taken(robotId);
return true;
} else {
return false;
@ -196,7 +195,6 @@ public class RobotRegistry extends WorldSavedData implements IRobotRegistry {
getResourcesTakenByRobot(robotId).remove(resourceId);
resourcesTaken.remove(resourceId);
resourceId.released(robotId);
}
}

View file

@ -8,11 +8,13 @@
*/
package buildcraft.robotics;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.Loader;
import net.minecraftforge.client.MinecraftForgeClient;
import buildcraft.BuildCraftRobotics;
import buildcraft.robotics.render.RenderZonePlan;
import buildcraft.robotics.render.RenderRobot;
import buildcraft.robotics.render.RobotStationItemRenderer;
@ -20,6 +22,8 @@ public class RoboticsProxyClient extends RoboticsProxy {
public void registerRenderers() {
RenderingRegistry.registerEntityRenderingHandler(EntityRobot.class, new RenderRobot());
MinecraftForgeClient.registerItemRenderer(BuildCraftRobotics.robotItem, new RenderRobot());
ClientRegistry.bindTileEntitySpecialRenderer(TileZonePlan.class, new RenderZonePlan());
// TODO: Move robot station textures locally
if (Loader.isModLoaded("BuildCraft|Transport")) {
loadBCTransport();

View file

@ -0,0 +1,108 @@
/**
* Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* The BuildCraft API is distributed under the terms of the MIT License.
* Please check the contents of the license, which should be located
* as "LICENSE.API" in the BuildCraft source code distribution.
*/
package buildcraft.robotics;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.core.BlockIndex;
import buildcraft.api.robots.DockingStation;
import buildcraft.api.robots.IRequestProvider;
import buildcraft.api.robots.IRobotRegistry;
import buildcraft.api.robots.ResourceId;
import buildcraft.api.robots.ResourceIdRequest;
import buildcraft.api.robots.RobotManager;
public class StackRequest {
private IRequestProvider requester;
private int slot;
private ItemStack stack;
private DockingStation station;
private BlockIndex stationIndex;
private ForgeDirection stationSide;
public StackRequest(IRequestProvider requester, int slot, ItemStack stack) {
this.requester = requester;
this.slot = slot;
this.stack = stack;
this.station = null;
}
private StackRequest(int slot, ItemStack stack, BlockIndex stationIndex, ForgeDirection stationSide) {
requester = null;
this.slot = slot;
this.stack = stack;
station = null;
this.stationIndex = stationIndex;
this.stationSide = stationSide;
}
public IRequestProvider getRequester(World world) {
if (requester == null) {
requester = getStation(world).getRequestProvider();
}
return requester;
}
public int getSlot() {
return slot;
}
public ItemStack getStack() {
return stack;
}
public DockingStation getStation(World world) {
if (station == null) {
IRobotRegistry robotRegistry = RobotManager.registryProvider.getRegistry(world);
station = robotRegistry.getStation(stationIndex.x, stationIndex.y, stationIndex.z, stationSide);
}
return station;
}
public void setStation(DockingStation station) {
this.station = station;
this.stationIndex = station.index();
this.stationSide = station.side();
}
public void writeToNBT(NBTTagCompound nbt) {
nbt.setInteger("slot", slot);
NBTTagCompound stackNBT = new NBTTagCompound();
stack.writeToNBT(stackNBT);
nbt.setTag("stack", stackNBT);
NBTTagCompound stationIndexNBT = new NBTTagCompound();
station.index().writeTo(stationIndexNBT);
nbt.setTag("stationIndex", stationIndexNBT);
nbt.setByte("stationSide", (byte) station.side().ordinal());
}
public static StackRequest loadFromNBT(NBTTagCompound nbt) {
int slot = nbt.getInteger("slot");
ItemStack stack = ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("stack"));
BlockIndex stationIndex = new BlockIndex(nbt.getCompoundTag("stationIndex"));
ForgeDirection stationSide = ForgeDirection.values()[nbt.getByte("stationSide")];
return new StackRequest(slot, stack, stationIndex, stationSide);
}
public ResourceId getResourceId(World world) {
return new ResourceIdRequest(getStation(world), slot);
}
}

View file

@ -14,14 +14,11 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import cpw.mods.fml.relauncher.Side;
import buildcraft.BuildCraftCore;
import buildcraft.api.robots.EntityRobotBase;
import buildcraft.api.robots.IRequestProvider;
import buildcraft.api.robots.ResourceIdRequest;
import buildcraft.api.robots.RobotManager;
import buildcraft.api.robots.StackRequest;
import buildcraft.core.lib.block.TileBuildCraft;
import buildcraft.core.lib.inventory.SimpleInventory;
import buildcraft.core.lib.inventory.StackHelper;
@ -60,7 +57,7 @@ public class TileRequester extends TileBuildCraft implements IInventory, IReques
}
}
public ItemStack getRequest(int index) {
public ItemStack getRequestTemplate(int index) {
return requests.getStackInSlot(index);
}
@ -163,47 +160,48 @@ public class TileRequester extends TileBuildCraft implements IInventory, IReques
}
@Override
public int getNumberOfRequests() {
public int getRequestsCount() {
return NB_ITEMS;
}
@Override
public StackRequest getAvailableRequest(int i) {
public ItemStack getRequest(int i) {
if (requests.getStackInSlot(i) == null) {
return null;
} else if (isFulfilled(i)) {
return null;
} else if (RobotManager.registryProvider.getRegistry(worldObj).isTaken(new ResourceIdRequest(this, i))) {
return null;
} else {
StackRequest r = new StackRequest();
ItemStack request = requests.getStackInSlot(i).copy();
r.index = i;
r.stack = requests.getStackInSlot(i);
r.requester = this;
ItemStack existingStack = inv.getStackInSlot(i);
if (existingStack == null) {
return request;
}
return r;
if (!StackHelper.isMatchingItemOrList(request, existingStack)) {
return null;
}
request.stackSize -= existingStack.stackSize;
if (request.stackSize <= 0) {
return null;
}
return request;
}
}
@Override
public boolean takeRequest(int i, EntityRobotBase robot) {
if (requests.getStackInSlot(i) == null) {
return false;
} else if (isFulfilled(i)) {
return false;
} else {
return RobotManager.registryProvider.getRegistry(worldObj).take(new ResourceIdRequest(this, i), robot);
}
}
@Override
public ItemStack provideItemsForRequest(int i, ItemStack stack) {
public ItemStack offerItem(int i, ItemStack stack) {
ItemStack existingStack = inv.getStackInSlot(i);
if (requests.getStackInSlot(i) == null) {
return stack;
} else if (existingStack == null) {
if (!StackHelper.isMatchingItemOrList(stack, requests.getStackInSlot(i))) {
return stack;
}
int maxQty = requests.getStackInSlot(i).stackSize;
if (stack.stackSize <= maxQty) {
@ -221,7 +219,7 @@ public class TileRequester extends TileBuildCraft implements IInventory, IReques
}
} else if (!StackHelper.isMatchingItemOrList(stack, existingStack)) {
return stack;
} else if (existingStack == null || StackHelper.isMatchingItemOrList(stack, requests.getStackInSlot(i))) {
} else if (StackHelper.isMatchingItemOrList(stack, requests.getStackInSlot(i))) {
int maxQty = requests.getStackInSlot(i).stackSize;
if (existingStack.stackSize + stack.stackSize <= maxQty) {

View file

@ -8,6 +8,7 @@
*/
package buildcraft.robotics;
import java.util.Arrays;
import java.util.List;
import io.netty.buffer.ByteBuf;
@ -19,7 +20,9 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.server.MinecraftServer;
import buildcraft.BuildCraftCore;
import buildcraft.BuildCraftRobotics;
import buildcraft.api.core.IZone;
import buildcraft.api.core.SafeTimeTracker;
import buildcraft.api.items.IMapLocation;
import buildcraft.api.items.INamedItem;
import buildcraft.core.ItemMapLocation;
@ -30,6 +33,7 @@ import buildcraft.core.lib.network.command.CommandWriter;
import buildcraft.core.lib.network.command.PacketCommand;
import buildcraft.core.lib.utils.NetworkUtils;
import buildcraft.robotics.gui.ContainerZonePlan;
import buildcraft.robotics.map.MapWorld;
public class TileZonePlan extends TileBuildCraft implements IInventory {
@ -37,17 +41,17 @@ public class TileZonePlan extends TileBuildCraft implements IInventory {
public static final int CRAFT_TIME = 120;
private static int RESOLUTION_CHUNKS = RESOLUTION >> 4;
public final byte[] previewColors = new byte[80];
public int chunkStartX, chunkStartZ;
public short progress = 0;
public String mapName = "";
private final SimpleInventory inv = new SimpleInventory(3, "inv", 64);
private final SafeTimeTracker previewRecalcTimer = new SafeTimeTracker(100);
private ZonePlan[] selectedAreas = new ZonePlan[16];
private int currentSelectedArea = 0;
private SimpleInventory inv = new SimpleInventory(3, "inv", 64);
@Override
public void initialize() {
super.initialize();
@ -67,6 +71,10 @@ public class TileZonePlan extends TileBuildCraft implements IInventory {
return;
}
if (previewRecalcTimer.markTimeIfDelay(worldObj)) {
recalculatePreview();
}
if (inv.getStackInSlot(0) != null
&& inv.getStackInSlot(1) == null
&& inv.getStackInSlot(0).getItem() instanceof ItemMapLocation) {
@ -93,6 +101,24 @@ public class TileZonePlan extends TileBuildCraft implements IInventory {
}
}
private void recalculatePreview() {
byte[] newPreviewColors = new byte[80];
MapWorld mw = BuildCraftRobotics.manager.getWorld(worldObj);
for (int y = 0; y < 8; y++) {
for (int x = 0; x < 10; x++) {
int tx = (x * 10) - 45;
int ty = (y * 10) - 35;
newPreviewColors[y * 10 + x] = (byte) mw.getColor(xCoord + tx, zCoord + ty);
}
}
if (!Arrays.equals(previewColors, newPreviewColors)) {
System.arraycopy(newPreviewColors, 0, previewColors, 0, 80);
sendNetworkUpdate();
}
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
@ -135,12 +161,14 @@ public class TileZonePlan extends TileBuildCraft implements IInventory {
public void writeData(ByteBuf stream) {
stream.writeShort(progress);
NetworkUtils.writeUTF(stream, mapName);
stream.writeBytes(previewColors, 0, 80);
}
@Override
public void readData(ByteBuf stream) {
progress = stream.readShort();
mapName = NetworkUtils.readUTF(stream);
stream.readBytes(previewColors, 0, 80);
}
private void importMap(ItemStack stack) {

View file

@ -9,14 +9,15 @@
package buildcraft.robotics.ai;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import buildcraft.api.core.IInvSlot;
import buildcraft.api.robots.AIRobot;
import buildcraft.api.robots.EntityRobotBase;
import buildcraft.api.robots.IRequestProvider;
import buildcraft.api.robots.StackRequest;
import buildcraft.core.lib.inventory.InvUtils;
import buildcraft.core.lib.inventory.filters.ArrayStackOrListFilter;
import buildcraft.robotics.StackRequest;
public class AIRobotDeliverRequested extends AIRobot {
@ -35,48 +36,67 @@ public class AIRobotDeliverRequested extends AIRobot {
@Override
public void start() {
startDelegateAI(new AIRobotGotoStation(robot, requested.station));
startDelegateAI(new AIRobotGotoStation(robot, requested.getStation(robot.worldObj)));
}
@Override
public void delegateAIEnded(AIRobot ai) {
if (ai instanceof AIRobotGotoStation) {
if (!ai.success()) {
setSuccess(false);
terminate();
return;
}
IInvSlot slot = InvUtils.getItem(robot, new ArrayStackOrListFilter(requested.stack));
IInvSlot slot = InvUtils.getItem(robot, new ArrayStackOrListFilter(requested.getStack()));
if (slot == null) {
setSuccess(false);
terminate();
return;
}
if (requested.requester != null) {
ItemStack newStack = ((IRequestProvider)
requested.requester).provideItemsForRequest(requested.index,
slot.getStackInSlot().copy());
if (newStack == null || newStack.stackSize != slot.getStackInSlot().stackSize) {
delivered = true;
slot.setStackInSlot(newStack);
}
IRequestProvider requester = requested.getRequester(robot.worldObj);
if (requester == null) {
setSuccess(false);
terminate();
} else {
startDelegateAI(new AIRobotUnload(robot));
return;
}
} else if (ai instanceof AIRobotUnload) {
delivered = ai.success();
ItemStack newStack = requester.offerItem(requested.getSlot(), slot.getStackInSlot().copy());
if (newStack == null || newStack.stackSize != slot.getStackInSlot().stackSize) {
slot.setStackInSlot(newStack);
}
terminate();
}
}
@Override
public boolean success() {
return delivered;
}
@Override
public boolean canLoadFromNBT() {
return true;
}
@Override
public void writeSelfToNBT(NBTTagCompound nbt) {
super.writeSelfToNBT(nbt);
if (requested != null) {
NBTTagCompound requestNBT = new NBTTagCompound();
requested.writeToNBT(requestNBT);
nbt.setTag("currentRequest", requestNBT);
}
}
@Override
public void loadSelfFromNBT(NBTTagCompound nbt) {
super.loadSelfFromNBT(nbt);
if (nbt.hasKey("currentRequest")) {
requested = StackRequest.loadFromNBT(nbt.getCompoundTag("currentRequest"));
}
}
}

View file

@ -11,8 +11,6 @@ package buildcraft.robotics.ai;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.robots.AIRobot;
import buildcraft.api.robots.EntityRobotBase;
import buildcraft.core.lib.inventory.ITransactor;
@ -83,7 +81,7 @@ public class AIRobotFetchAndEquipItemStack extends AIRobot {
ITransactor trans = Transactor.getTransactorFor(tileInventory);
ItemStack itemFound = trans.remove(filter, ForgeDirection.UNKNOWN, true);
ItemStack itemFound = trans.remove(filter, robot.getDockingStation().getItemInputSide(), true);
if (itemFound != null) {
robot.setItemInUse(itemFound);

View file

@ -8,8 +8,9 @@
*/
package buildcraft.robotics.ai;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.core.IInvSlot;
@ -64,15 +65,16 @@ public class AIRobotLoad extends AIRobot {
int loaded = 0;
IInventory tileInventory = station.getItemInput();
ISidedInventory tileInventory = station.getItemInput();
if (tileInventory == null) {
return false;
}
for (IInvSlot slot : InventoryIterator.getIterable(tileInventory)) {
for (IInvSlot slot : InventoryIterator.getIterable(tileInventory, station.getItemInputSide())) {
ItemStack stack = slot.getStackInSlot();
if (stack == null
|| !slot.canTakeStackFromSlot(stack)
|| !filter.matches(stack)
|| !ActionRobotFilter.canInteractWithItem(station, filter,
ActionStationProvideItems.class)) {

View file

@ -71,7 +71,9 @@ public class AIRobotLoadFluids extends AIRobot {
return 0;
}
FluidStack drainable = handler.drain(station.side, FluidContainerRegistry.BUCKET_VOLUME,
ForgeDirection side = station.getFluidInputSide();
FluidStack drainable = handler.drain(side, FluidContainerRegistry.BUCKET_VOLUME,
false);
if (drainable == null || !filter.matches(drainable.getFluid())) {
return 0;
@ -82,7 +84,7 @@ public class AIRobotLoadFluids extends AIRobot {
if (filled > 0 && doLoad) {
drainable.amount = filled;
handler.drain(station.side, drainable, true);
handler.drain(side, drainable, true);
}
return filled;
}

View file

@ -28,6 +28,10 @@ public class AIRobotSearchBlock extends AIRobot {
private double maxDistanceToEnd;
private IZone zone;
public AIRobotSearchBlock(EntityRobotBase iRobot) {
super(iRobot);
}
public AIRobotSearchBlock(EntityRobotBase iRobot, boolean random, IBlockFilter iPathFound,
double iMaxDistanceToEnd) {
super(iRobot);

View file

@ -8,7 +8,9 @@
*/
package buildcraft.robotics.ai;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import net.minecraft.item.ItemStack;
@ -16,20 +18,15 @@ import buildcraft.api.robots.AIRobot;
import buildcraft.api.robots.DockingStation;
import buildcraft.api.robots.EntityRobotBase;
import buildcraft.api.robots.IRequestProvider;
import buildcraft.api.robots.StackRequest;
import buildcraft.api.statements.IStatementParameter;
import buildcraft.api.statements.StatementParameterItemStack;
import buildcraft.api.statements.StatementSlot;
import buildcraft.core.lib.inventory.StackHelper;
import buildcraft.core.lib.inventory.filters.IStackFilter;
import buildcraft.robotics.IStationFilter;
import buildcraft.robotics.statements.ActionRobotFilter;
import buildcraft.robotics.statements.ActionStationRequestItems;
import buildcraft.robotics.statements.ActionStationRequestItemsMachine;
import buildcraft.robotics.StackRequest;
public class AIRobotSearchStackRequest extends AIRobot {
public StackRequest request = null;
public DockingStation station = null;
private Collection<ItemStack> blackList;
@ -57,11 +54,7 @@ public class AIRobotSearchStackRequest extends AIRobot {
if (!ai.success()) {
terminate();
} else {
request = getOrderFromRequestingAction(((AIRobotSearchStation) ai).targetStation);
if (request == null) {
request = getOrderFromRequestingStation(((AIRobotSearchStation) ai).targetStation, true);
}
request = getOrderFromRequestingStation(((AIRobotSearchStation) ai).targetStation, true);
terminate();
}
@ -84,29 +77,16 @@ public class AIRobotSearchStackRequest extends AIRobot {
}
private StackRequest getOrderFromRequestingStation(DockingStation station, boolean take) {
if (!ActionRobotFilter.canInteractWithItem(station, filter, ActionStationRequestItemsMachine.class)) {
return null;
}
IRequestProvider provider = station.getRequestProvider();
if (provider == null) {
return null;
}
for (int i = 0; i < provider.getNumberOfRequests(); ++i) {
StackRequest requestFound = provider.getAvailableRequest(i);
if (requestFound != null
&& !isBlacklisted(requestFound.stack)
&& filter.matches(requestFound.stack)) {
requestFound.station = station;
for (StackRequest req : getAvailableRequests(station)) {
if (!isBlacklisted(req.getStack()) && filter.matches(req.getStack())) {
req.setStation(station);
if (take) {
if (provider.takeRequest(i, robot)) {
return requestFound;
if (robot.getRegistry().take(req.getResourceId(robot.worldObj), robot)) {
return req;
}
} else {
return requestFound;
return req;
}
}
}
@ -114,32 +94,32 @@ public class AIRobotSearchStackRequest extends AIRobot {
return null;
}
private StackRequest getOrderFromRequestingAction(DockingStation station) {
for (StatementSlot s : station.getActiveActions()) {
if (s.statement instanceof ActionStationRequestItems) {
for (IStatementParameter p : s.parameters) {
StatementParameterItemStack param = (StatementParameterItemStack) p;
private Collection<StackRequest> getAvailableRequests(DockingStation station) {
List<StackRequest> result = new ArrayList<StackRequest>();
if (param != null && !isBlacklisted(param.getItemStack())) {
StackRequest req = new StackRequest();
req.station = station;
req.stack = param.getItemStack();
return req;
}
}
}
IRequestProvider provider = station.getRequestProvider();
if (provider == null) {
return result;
}
return null;
for (int i = 0; i < provider.getRequestsCount(); i++) {
if (provider.getRequest(i) == null) {
continue;
}
StackRequest req = new StackRequest(provider, i, provider.getRequest(i));
req.setStation(station);
if (!robot.getRegistry().isTaken(req.getResourceId(robot.worldObj))) {
result.add(req);
}
}
return result;
}
private class StationProviderFilter implements IStationFilter {
@Override
public boolean matches(DockingStation station) {
return getOrderFromRequestingAction(station) != null
|| getOrderFromRequestingStation(station, false) != null;
return getOrderFromRequestingStation(station, false) != null;
}
}

View file

@ -45,6 +45,9 @@ public class AIRobotSearchStation extends AIRobot {
DockingStation potentialStation = null;
for (DockingStation station : robot.getRegistry().getStations()) {
if (!station.isInitialized()) {
continue;
}
if (station.isTaken() && station.robotIdTaking() != robot.getRobotId()) {
continue;

View file

@ -9,6 +9,7 @@
package buildcraft.robotics.ai;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.core.IInvSlot;
@ -19,7 +20,7 @@ import buildcraft.api.transport.IInjectable;
import buildcraft.core.lib.inventory.InventoryIterator;
import buildcraft.core.lib.inventory.filters.ArrayStackOrListFilter;
import buildcraft.robotics.statements.ActionRobotFilter;
import buildcraft.robotics.statements.ActionStationInputItems;
import buildcraft.robotics.statements.ActionStationAcceptItems;
public class AIRobotUnload extends AIRobot {
@ -53,7 +54,7 @@ public class AIRobotUnload extends AIRobot {
return false;
}
ForgeDirection injectSide = station.side().getOpposite();
ForgeDirection injectSide = station.getItemOutputSide();
if (!output.canInjectItems(injectSide)) {
return false;
}
@ -65,7 +66,7 @@ public class AIRobotUnload extends AIRobot {
if (!ActionRobotFilter
.canInteractWithItem(station, new ArrayStackOrListFilter(robotSlot.getStackInSlot()),
ActionStationInputItems.class)) {
ActionStationAcceptItems.class)) {
return false;
}

View file

@ -64,7 +64,7 @@ public class AIRobotUnloadFluids extends AIRobot {
}
drainable = drainable.copy();
int filled = fluidHandler.fill(station.side, drainable, doUnload);
int filled = fluidHandler.fill(station.getFluidOutputSide(), drainable, doUnload);
if (filled > 0 && doUnload) {
drainable.amount = filled;

View file

@ -0,0 +1,39 @@
/**
* 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.robotics.boards;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import buildcraft.api.boards.RedstoneBoardRobotNBT;
import buildcraft.api.core.BuildCraftAPI;
import buildcraft.api.robots.EntityRobotBase;
public class BoardRobotBreaker extends BoardRobotGenericBreakBlock {
public BoardRobotBreaker(EntityRobotBase iRobot) {
super(iRobot);
}
@Override
public RedstoneBoardRobotNBT getNBTHandler() {
return BCBoardNBT.REGISTRY.get("breaker");
}
@Override
public boolean isExpectedTool(ItemStack stack) {
return stack != null && stack.getItem().getToolClasses(stack).contains("pickaxe");
}
@Override
public boolean isExpectedBlock(World world, int x, int y, int z) {
return BuildCraftAPI.getWorldProperty("rock").get(world, x, y, z);
}
}

View file

@ -11,14 +11,15 @@ package buildcraft.robotics.boards;
import java.util.ArrayList;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import buildcraft.api.boards.RedstoneBoardRobot;
import buildcraft.api.boards.RedstoneBoardRobotNBT;
import buildcraft.api.robots.AIRobot;
import buildcraft.api.robots.EntityRobotBase;
import buildcraft.api.robots.StackRequest;
import buildcraft.core.lib.inventory.StackHelper;
import buildcraft.core.lib.inventory.filters.IStackFilter;
import buildcraft.robotics.StackRequest;
import buildcraft.robotics.ai.AIRobotDeliverRequested;
import buildcraft.robotics.ai.AIRobotDisposeItems;
import buildcraft.robotics.ai.AIRobotGotoSleep;
@ -44,9 +45,6 @@ public class BoardRobotDelivery extends RedstoneBoardRobot {
@Override
public void update() {
if (robot.containsItems()) {
// Always makes sure that when starting a craft, the inventory is
// clean.
startDelegateAI(new AIRobotDisposeItems(robot));
return;
}
@ -55,7 +53,12 @@ public class BoardRobotDelivery extends RedstoneBoardRobot {
startDelegateAI(new AIRobotSearchStackRequest(robot, ActionRobotFilter.getGateFilter(robot
.getLinkedStation()), deliveryBlacklist));
} else {
startDelegateAI(new AIRobotGotoStationAndLoad(robot, new ReqFilter(), 1));
startDelegateAI(new AIRobotGotoStationAndLoad(robot, new IStackFilter() {
@Override
public boolean matches(ItemStack stack) {
return currentRequest != null && StackHelper.isMatchingItemOrList(stack, currentRequest.getStack());
}
}, currentRequest.getStack().stackSize));
}
}
@ -68,33 +71,51 @@ public class BoardRobotDelivery extends RedstoneBoardRobot {
} else {
currentRequest = ((AIRobotSearchStackRequest) ai).request;
if (!currentRequest.station.take(robot)) {
currentRequest = null;
if (!currentRequest.getStation(robot.worldObj).take(robot)) {
releaseCurrentRequest();
}
}
} else if (ai instanceof AIRobotGotoStationAndLoad) {
if (!ai.success()) {
deliveryBlacklist.add(currentRequest.stack);
robot.releaseResources();
currentRequest = null;
deliveryBlacklist.add(currentRequest.getStack());
releaseCurrentRequest();
} else {
startDelegateAI(new AIRobotDeliverRequested(robot, currentRequest));
}
} else if (ai instanceof AIRobotDeliverRequested) {
robot.releaseResources();
releaseCurrentRequest();
}
}
private void releaseCurrentRequest() {
if (currentRequest != null) {
robot.getRegistry().release(currentRequest.getResourceId(robot.worldObj));
currentRequest.getStation(robot.worldObj).release(robot);
currentRequest = null;
}
}
private class ReqFilter implements IStackFilter {
@Override
public boolean canLoadFromNBT() {
return true;
}
@Override
public boolean matches(ItemStack stack) {
if (currentRequest == null) {
return false;
} else {
return StackHelper.isMatchingItemOrList(stack, currentRequest.stack);
}
@Override
public void writeSelfToNBT(NBTTagCompound nbt) {
super.writeSelfToNBT(nbt);
if (currentRequest != null) {
NBTTagCompound requestNBT = new NBTTagCompound();
currentRequest.writeToNBT(requestNBT);
nbt.setTag("currentRequest", requestNBT);
}
}
@Override
public void loadSelfFromNBT(NBTTagCompound nbt) {
super.loadSelfFromNBT(nbt);
if (nbt.hasKey("currentRequest")) {
currentRequest = StackRequest.loadFromNBT(nbt.getCompoundTag("currentRequest"));
}
}
}

View file

@ -70,7 +70,7 @@ public class ContainerRequester extends BuildCraftContainer implements ICommandR
final ItemStack[] stacks = new ItemStack[TileRequester.NB_ITEMS];
for (int i = 0; i < TileRequester.NB_ITEMS; ++i) {
stacks[i] = requester.getRequest(i);
stacks[i] = requester.getRequestTemplate(i);
}
BuildCraftCore.instance.sendToPlayer((EntityPlayer) sender, new PacketCommand(this, "receiveRequestList",

View file

@ -0,0 +1,58 @@
package buildcraft.robotics.render;
import java.util.HashMap;
import org.lwjgl.opengl.GL11;
import net.minecraft.block.material.MapColor;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import buildcraft.core.lib.block.BlockBuildCraft;
import buildcraft.core.lib.render.DynamicTextureBC;
import buildcraft.core.lib.render.FakeIcon;
import buildcraft.core.lib.render.RenderEntityBlock;
import buildcraft.robotics.TileZonePlan;
public class RenderZonePlan extends TileEntitySpecialRenderer {
private static final float Z_OFFSET = 2049 / 2048.0F;
private static final HashMap<TileZonePlan, DynamicTextureBC> TEXTURES = new HashMap<TileZonePlan, DynamicTextureBC>();
@Override
public void renderTileEntityAt(TileEntity tile, double tx, double ty, double tz, float partialTicks) {
TileZonePlan zonePlan = (TileZonePlan) tile;
if (!TEXTURES.containsKey(zonePlan)) {
DynamicTextureBC textureBC = new DynamicTextureBC(16, 16);
TEXTURES.put(zonePlan, textureBC);
}
DynamicTextureBC textureBC = TEXTURES.get(zonePlan);
FakeIcon fakeIcon = new FakeIcon(0, 1, 0, 1, 16, 16);
for (int y = 0; y < 8; y++) {
for (int x = 0; x < 10; x++) {
textureBC.setColor(x + 3, y + 3, 0xFF000000 | MapColor.mapColorArray[zonePlan.previewColors[y * 10 + x]].colorValue);
}
}
GL11.glPushMatrix();
GL11.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT);
GL11.glTranslatef((float) tx + 0.5F, (float) ty + 0.5F, (float) tz + 0.5F);
GL11.glScalef(Z_OFFSET, Z_OFFSET, Z_OFFSET);
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
textureBC.updateTexture();
RenderEntityBlock.RenderInfo renderBox = new RenderEntityBlock.RenderInfo();
renderBox.setRenderSingleSide(((BlockBuildCraft) zonePlan.getBlockType()).getFrontSide(zonePlan.getBlockMetadata()));
renderBox.texture = fakeIcon;
renderBox.light = 15;
RenderEntityBlock.INSTANCE.renderBlock(renderBox);
GL11.glPopAttrib();
GL11.glPopMatrix();
}
}

View file

@ -13,6 +13,7 @@ import net.minecraft.client.renderer.texture.IIconRegister;
import buildcraft.api.statements.IStatementParameter;
import buildcraft.api.statements.StatementParameterItemStack;
import buildcraft.core.lib.utils.StringUtils;
import buildcraft.core.statements.StatementParameterItemStackExact;
public class ActionStationRequestItems extends ActionStationInputItems {
@ -42,6 +43,6 @@ public class ActionStationRequestItems extends ActionStationInputItems {
@Override
public IStatementParameter createParameter(int index) {
return new StatementParameterItemStack();
return new StatementParameterItemStackExact();
}
}

View file

@ -10,6 +10,7 @@ package buildcraft.transport;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
@ -17,8 +18,9 @@ import buildcraft.BuildCraftTransport;
import buildcraft.api.transport.IItemPipe;
import buildcraft.core.GuiIds;
import buildcraft.core.lib.block.BlockBuildCraft;
import buildcraft.core.lib.block.IComparatorInventory;
public class BlockFilteredBuffer extends BlockBuildCraft {
public class BlockFilteredBuffer extends BlockBuildCraft implements IComparatorInventory {
public BlockFilteredBuffer() {
super(Material.iron);
setHardness(5F);
@ -52,4 +54,9 @@ public class BlockFilteredBuffer extends BlockBuildCraft {
return true;
}
@Override
public boolean doesSlotCountComparator(TileEntity tile, int slot, ItemStack stack) {
return ((TileFilteredBuffer) tile).getFilters().getStackInSlot(slot) != null;
}
}

View file

@ -143,9 +143,9 @@ public class PipeIconProvider implements IIconProvider {
TransparentFacade("transparent_facade"),
Transparent("core:misc/transparent"),
//
/* PipePowerAdapterTop("pipePowerAdapterTop"),
PipePowerAdapterSide("pipePowerAdapterSide"),
PipePowerAdapterBottom("pipePowerAdapterBottom"), */
PipePowerAdapterBottom("pipePowerAdapterBottom"),
PipePowerAdapterTop("pipePowerAdapterTop"),
//
ItemBox("itemBox");
public static final TYPE[] VALUES = values();

View file

@ -32,6 +32,7 @@ import buildcraft.api.transport.IPipeTile;
import buildcraft.core.CompatHooks;
import buildcraft.core.DefaultProps;
import buildcraft.core.lib.block.TileBuildCraft;
import buildcraft.core.lib.utils.AverageInt;
import buildcraft.transport.network.PacketPowerUpdate;
import buildcraft.transport.pipes.PipePowerCobblestone;
import buildcraft.transport.pipes.PipePowerDiamond;
@ -46,8 +47,7 @@ import buildcraft.transport.pipes.PipePowerWood;
public class PipeTransportPower extends PipeTransport implements IDebuggable {
public static final Map<Class<? extends Pipe<?>>, Integer> powerCapacities = new HashMap<Class<? extends Pipe<?>>, Integer>();
public static final Map<Class<? extends Pipe<?>>, Float> powerResistances = new HashMap<Class<? extends Pipe<?>>, Float>();
private static final int DISPLAY_SMOOTHING = 10;
private static final int OVERLOAD_TICKS = 60;
public short[] displayPower = new short[6];
@ -61,13 +61,12 @@ public class PipeTransportPower extends PipeTransport implements IDebuggable {
public int[] dbgEnergyOutput = new int[6];
public int[] dbgEnergyOffered = new int[6];
private final AverageInt[] powerAverage = new AverageInt[6];
private final TileEntity[] tiles = new TileEntity[6];
private final Object[] providers = new Object[6];
private boolean needsInit = true;
private short[] prevDisplayPower = new short[6];
private int[] powerQuery = new int[6];
private long currentDate;
@ -78,6 +77,7 @@ public class PipeTransportPower extends PipeTransport implements IDebuggable {
public PipeTransportPower() {
for (int i = 0; i < 6; ++i) {
powerQuery[i] = 0;
powerAverage[i] = new AverageInt(10);
}
}
@ -159,7 +159,7 @@ public class PipeTransportPower extends PipeTransport implements IDebuggable {
tiles[o] = null;
internalPower[o] = 0;
internalNextPower[o] = 0;
displayPower[o] = 0;
powerAverage[o].clear();
}
providers[o] = getEnergyProvider(o);
}
@ -200,10 +200,6 @@ public class PipeTransportPower extends PipeTransport implements IDebuggable {
}
}
// Send the power to nearby pipes who requested it
System.arraycopy(displayPower, 0, prevDisplayPower, 0, 6);
Arrays.fill(displayPower, (short) 0);
for (int i = 0; i < 6; ++i) {
if (internalPower[i] > 0) {
int totalPowerQuery = 0;
@ -222,7 +218,7 @@ public class PipeTransportPower extends PipeTransport implements IDebuggable {
Object ep = providers[j];
double watts = Math.min(internalPower[i] * powerQuery[j] / totalPowerQuery, internalPower[i]);
if (ep instanceof IPipeTile) {
if (ep instanceof IPipeTile && ((IPipeTile) ep).getPipeType() == IPipeTile.PipeType.POWER) {
Pipe<?> nearbyPipe = (Pipe<?>) ((IPipeTile) ep).getPipe();
PipeTransportPower nearbyTransport = (PipeTransportPower) nearbyPipe.transport;
watts = nearbyTransport.receiveEnergy(
@ -251,20 +247,22 @@ public class PipeTransportPower extends PipeTransport implements IDebuggable {
}
}
displayPower[j] += watts;
displayPower[i] += watts;
powerAverage[j].push((int) Math.ceil(watts));
powerAverage[i].push((int) Math.ceil(watts));
}
}
}
}
}
float highestPower = 0.0F;
short highestPower = 0;
for (int i = 0; i < 6; i++) {
displayPower[i] = (short) Math.floor((float) (prevDisplayPower[i] * (DISPLAY_SMOOTHING - 1) + displayPower[i]) / DISPLAY_SMOOTHING);
powerAverage[i].tick();
displayPower[i] = (short) Math.round(powerAverage[i].getAverage());
if (displayPower[i] > highestPower) {
highestPower = displayPower[i];
}
}
overload += highestPower > ((float) maxPower) * 0.95F ? 1 : -1;
if (overload < 0) {
overload = 0;
@ -322,7 +320,7 @@ public class PipeTransportPower extends PipeTransport implements IDebuggable {
for (int i = 0; i < 6; ++i) {
if (transferQuery[i] != 0 && tiles[i] != null) {
TileEntity entity = tiles[i];
if (entity instanceof IPipeTile) {
if (entity instanceof IPipeTile && ((IPipeTile) entity).getPipeType() == IPipeTile.PipeType.POWER) {
IPipeTile nearbyTile = (IPipeTile) entity;
if (nearbyTile.getPipe() == null) {
continue;

View file

@ -66,7 +66,7 @@ import buildcraft.transport.pluggable.PlugPluggable;
public class TileGenericPipe extends TileEntity implements IFluidHandler,
IPipeTile, ITileBufferHolder, IEnergyHandler, IDropControlInventory,
ISyncedTile, ISolidSideTile, IGuiReturnHandler, IRedstoneEngineReceiver,
IDebuggable {
IDebuggable, IPipeConnection {
public boolean initialized = false;
public final PipeRenderState renderState = new PipeRenderState();
@ -1280,4 +1280,12 @@ public class TileGenericPipe extends TileEntity implements IFluidHandler,
((IDebuggable) getPipePluggable(side)).getDebugInfo(info, side, debugger, player);
}
}
@Override
public ConnectOverride overridePipeConnection(PipeType type, ForgeDirection with) {
if (type == PipeType.POWER && hasPipePluggable(with) && getPipePluggable(with) instanceof IEnergyHandler) {
return ConnectOverride.CONNECT;
}
return ConnectOverride.DEFAULT;
}
}

View file

@ -45,7 +45,7 @@ public final class TransportSiliconRecipes {
// Lenses, Filters
for (int i = 0; i < 16; i++) {
BuildcraftRecipeRegistry.assemblyTable.addRecipe("buildcraft:lens:" + i, 10000, new ItemStack(BuildCraftTransport.lensItem, 2, i),
ColorUtils.getOreDictionaryName(15 - i), "blockGlass", "ingotIron");
ColorUtils.getOreDictionaryName(15 - i), "blockGlass");
BuildcraftRecipeRegistry.assemblyTable.addRecipe("buildcraft:filter:" + i, 10000, new ItemStack(BuildCraftTransport.lensItem, 2, i + 16),
ColorUtils.getOreDictionaryName(15 - i), "blockGlass", Blocks.iron_bars);
}

View file

@ -12,7 +12,6 @@ import io.netty.buffer.ByteBuf;
import buildcraft.core.lib.network.PacketCoordinates;
import buildcraft.core.network.PacketIds;
import buildcraft.transport.render.PipeRendererTESR;
public class PacketPowerUpdate extends PacketCoordinates {
@ -32,7 +31,7 @@ public class PacketPowerUpdate extends PacketCoordinates {
displayPower = new short[] { 0, 0, 0, 0, 0, 0 };
overload = data.readBoolean();
for (int i = 0; i < displayPower.length; i++) {
displayPower[i] = data.readUnsignedByte();
displayPower[i] = data.readShort();
}
}
@ -41,8 +40,7 @@ public class PacketPowerUpdate extends PacketCoordinates {
super.writeData(data);
data.writeBoolean(overload);
for (short element : displayPower) {
data.writeByte(Math.min(PipeRendererTESR.POWER_STAGES,
(int) Math.ceil(element * PipeRendererTESR.DISPLAY_MULTIPLIER)));
data.writeShort(element);
}
}
}

View file

@ -8,23 +8,17 @@
*/
package buildcraft.transport.pluggable;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.common.util.ForgeDirection;
import cofh.api.energy.IEnergyHandler;
import buildcraft.api.transport.IPipe;
import buildcraft.api.transport.IPipeTile;
import buildcraft.api.transport.pluggable.IPipePluggableItem;
import buildcraft.api.transport.pluggable.PipePluggable;
import buildcraft.core.lib.items.ItemBuildCraft;
public class ItemPowerAdapter extends ItemBuildCraft implements IPipePluggableItem {
public ItemPowerAdapter() {
super();
}
@ -39,24 +33,9 @@ public class ItemPowerAdapter extends ItemBuildCraft implements IPipePluggableIt
return true;
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister par1IconRegister) {
this.itemIcon = par1IconRegister.registerIcon("buildcraft:pipePowerAdapter");
}
@Override
@SideOnly(Side.CLIENT)
public int getSpriteNumber() {
return 0;
}
@Override
public PipePluggable createPipePluggable(IPipe pipe, ForgeDirection side, ItemStack stack) {
if (pipe.getTile().getPipeType() != IPipeTile.PipeType.POWER && pipe instanceof IEnergyHandler) {
return new PowerAdapterPluggable();
} else {
return null;
}
return new PowerAdapterPluggable();
}
}

View file

@ -18,7 +18,7 @@ import buildcraft.core.lib.utils.MatrixTranformations;
import buildcraft.transport.PipeIconProvider;
public class PlugPluggable extends PipePluggable {
private static final class PlugPluggableRenderer implements IPipePluggableRenderer {
protected static final class PlugPluggableRenderer implements IPipePluggableRenderer {
public static final IPipePluggableRenderer INSTANCE = new PlugPluggableRenderer();
private float zFightOffset = 1 / 4096.0F;

View file

@ -6,6 +6,7 @@ import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraftforge.common.util.ForgeDirection;
import cofh.api.energy.IEnergyHandler;
@ -15,13 +16,15 @@ import buildcraft.api.transport.IPipe;
import buildcraft.api.transport.IPipeTile;
import buildcraft.api.transport.pluggable.IPipePluggableRenderer;
import buildcraft.api.transport.pluggable.PipePluggable;
import buildcraft.core.lib.render.FakeBlock;
import buildcraft.core.lib.utils.MatrixTranformations;
import buildcraft.transport.PipeIconProvider;
public class PowerAdapterPluggable extends PipePluggable implements IEnergyHandler {
private static final int MAX_POWER = 40;
private IPipeTile container;
public class PowerAdapterPluggableRenderer implements IPipePluggableRenderer {
protected static final class PowerAdapterPluggableRenderer implements IPipePluggableRenderer {
private float zFightOffset = 1 / 4096.0F;
@Override
@ -32,17 +35,24 @@ public class PowerAdapterPluggable extends PipePluggable implements IEnergyHandl
float[][] zeroState = new float[3][2];
IIcon[] icons = FakeBlock.INSTANCE.getTextureState().popArray();
int bottom = side.ordinal();
for (int i = 0; i < 6; i++) {
icons[i] = BuildCraftTransport.instance.pipeIconProvider.getIcon(
(i & 6) == (bottom & 6) ? PipeIconProvider.TYPE.PipePowerAdapterBottom.ordinal() : PipeIconProvider.TYPE.PipePowerAdapterSide.ordinal()
);
}
// X START - END
zeroState[0][0] = 0.25F;
zeroState[0][1] = 0.75F;
zeroState[0][0] = 0.1875F;
zeroState[0][1] = 0.8125F;
// Y START - END
zeroState[1][0] = 0.000F;
zeroState[1][1] = 0.125F;
zeroState[1][1] = 0.1251F;
// Z START - END
zeroState[2][0] = 0.25F;
zeroState[2][1] = 0.75F;
blockStateMachine.getTextureState().set(BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.PipeStructureCobblestone.ordinal())); // Structure Pipe
zeroState[2][0] = 0.1875F;
zeroState[2][1] = 0.8125F;
float[][] rotated = MatrixTranformations.deepClone(zeroState);
MatrixTranformations.transform(rotated, side);
@ -50,22 +60,25 @@ public class PowerAdapterPluggable extends PipePluggable implements IEnergyHandl
renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]);
renderblocks.renderStandardBlock(blockStateMachine.getBlock(), x, y, z);
// X START - END
zeroState[0][0] = 0.25F + 0.125F / 2 + zFightOffset;
zeroState[0][1] = 0.75F - 0.125F / 2 + zFightOffset;
// Y START - END
zeroState[1][0] = 0.25F;
zeroState[1][1] = 0.25F + 0.125F;
// Z START - END
zeroState[2][0] = 0.25F + 0.125F / 2;
zeroState[2][1] = 0.75F - 0.125F / 2;
icons[bottom] = icons[bottom ^ 1] = BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.PipePowerAdapterTop.ordinal());
// X START - END
zeroState[0][0] = 0.25F + zFightOffset;
zeroState[0][1] = 0.75F - zFightOffset;
// Y START - END
zeroState[1][0] = 0.125F;
zeroState[1][1] = 0.25F + zFightOffset;
// Z START - END
zeroState[2][0] = 0.25F + zFightOffset;
zeroState[2][1] = 0.75F - zFightOffset;
blockStateMachine.getTextureState().set(BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.PipeStructureCobblestone.ordinal())); // Structure Pipe
rotated = MatrixTranformations.deepClone(zeroState);
MatrixTranformations.transform(rotated, side);
renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]);
renderblocks.renderStandardBlock(blockStateMachine.getBlock(), x, y, z);
FakeBlock.INSTANCE.getTextureState().pushArray();
}
}
@ -95,7 +108,7 @@ public class PowerAdapterPluggable extends PipePluggable implements IEnergyHandl
@Override
public ItemStack[] getDropItems(IPipeTile pipe) {
return new ItemStack[] { new ItemStack(BuildCraftTransport.plugItem) };
return new ItemStack[] { new ItemStack(BuildCraftTransport.powerAdapterItem) };
}
@Override
@ -137,11 +150,11 @@ public class PowerAdapterPluggable extends PipePluggable implements IEnergyHandl
@Override
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) {
int maxR = Math.min(40, maxReceive);
if (container instanceof IEnergyHandler) {
int energyCanReceive = ((IEnergyHandler) container).receiveEnergy(from, maxR, true);
int maxR = Math.min(MAX_POWER, maxReceive);
if (container.getPipe() instanceof IEnergyHandler) {
int energyCanReceive = ((IEnergyHandler) container.getPipe()).receiveEnergy(from, maxR, true);
if (!simulate) {
return ((IEnergyHandler) container).receiveEnergy(from, energyCanReceive, false);
return ((IEnergyHandler) container.getPipe()).receiveEnergy(from, energyCanReceive, false);
} else {
return energyCanReceive;
}
@ -156,8 +169,8 @@ public class PowerAdapterPluggable extends PipePluggable implements IEnergyHandl
@Override
public int getEnergyStored(ForgeDirection from) {
if (container instanceof IEnergyHandler) {
return ((IEnergyHandler) container).getEnergyStored(from);
if (container.getPipe() instanceof IEnergyHandler) {
return ((IEnergyHandler) container.getPipe()).getEnergyStored(from);
} else {
return 0;
}
@ -165,8 +178,8 @@ public class PowerAdapterPluggable extends PipePluggable implements IEnergyHandl
@Override
public int getMaxEnergyStored(ForgeDirection from) {
if (container instanceof IEnergyHandler) {
return ((IEnergyHandler) container).getMaxEnergyStored(from);
if (container.getPipe() instanceof IEnergyHandler) {
return ((IEnergyHandler) container.getPipe()).getMaxEnergyStored(from);
} else {
return 0;
}
@ -176,4 +189,9 @@ public class PowerAdapterPluggable extends PipePluggable implements IEnergyHandl
public boolean canConnectEnergy(ForgeDirection from) {
return true;
}
@Override
public boolean requiresRenderUpdate(PipePluggable o) {
return false;
}
}

View file

@ -61,8 +61,8 @@ import buildcraft.transport.utils.FluidRenderData;
public class PipeRendererTESR extends TileEntitySpecialRenderer {
public static final PipeRendererTESR INSTANCE = new PipeRendererTESR();
public static final float DISPLAY_MULTIPLIER = 0.1f;
public static final int POWER_STAGES = 100;
public static final int POWER_STAGES = 256;
private static final float POWER_MAGIC = 0.7F; // Math.pow(displayPower, POWER_MAGIC)
private static final int LIQUID_STAGES = 40;
private static final int MAX_ITEMS_TO_RENDER = 10;
@ -662,7 +662,6 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer {
GL11.glPushMatrix();
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
GL11.glDisable(GL11.GL_LIGHTING);
// GL11.glEnable(GL11.GL_BLEND);
GL11.glTranslatef((float) x, (float) y, (float) z);
@ -671,7 +670,7 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer {
int[] displayList = pow.overload > 0 ? displayPowerListOverload : displayPowerList;
for (int side = 0; side < 6; ++side) {
short stage = pow.displayPower[side];
int stage = (int) Math.ceil(Math.pow(pow.displayPower[side], POWER_MAGIC));
if (stage >= 1) {
if (!pipe.container.isPipeConnected(ForgeDirection.getOrientation(side))) {
continue;

View file

@ -111,16 +111,16 @@ public class TriggerPipeContents extends BCStatement implements ITriggerInternal
switch (kind) {
case empty:
for (double s : transportPower.displayPower) {
if (s > 1e-4) {
for (short s : transportPower.displayPower) {
if (s > 0) {
return false;
}
}
return true;
case containsEnergy:
for (double s : transportPower.displayPower) {
if (s > 1e-4) {
for (short s : transportPower.displayPower) {
if (s > 0) {
return true;
}
}

View file

@ -8,7 +8,7 @@
Checkstyle-Configuration: BuildCraft
Description: none
-->
<module name="Checker">
<module name="Checker">
<property name="severity" value="error"/>
<module name="SuppressionCommentFilter">
<property name="offCommentFormat" value="CHECKSTYLE.OFF\: ([\w\|]+)"/>
@ -83,5 +83,10 @@
<module name="UpperEll"/>
<module name="OuterTypeFilename"/>
<module name="FileContentsHolder"/>
<module name="RegexpSinglelineJava">
<property name="format" value="System\.(out|err)\.print(ln|f){0,1}\(.*\)"/>
<property name="ignoreComments" value="true"/>
<property name="message" value="Standard output/error stream should not be used."/>
</module>
</module>
</module>

View file

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View file

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB