Merge branch '6.5.x' of github.com:BuildCraft/BuildCraft

This commit is contained in:
asiekierka 2015-06-30 12:38:22 +02:00
commit a31bbc9c20
140 changed files with 1241 additions and 789 deletions

View file

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

View file

@ -472,6 +472,9 @@ tip.PipePowerWood=Power Input Pipe
tip.PipeStructureCobblestone=Support pipe
tip.deprecated=Deprecated
tip.filler.excavate.on=Excavate
tip.filler.excavate.off=Do Not Excavate
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.
@ -481,6 +484,9 @@ tip.shift.PipeItemsLapis=Sneak-click to change color
tip.shift.PipeItemsObsidian=Power with an engine\nMore power - greater distance
tip.shift.PipePowerIron=Change the limit with a wrench or gates
tip.PipeItemsEmerald.whitelist=Whitelist
tip.PipeItemsEmerald.blacklist=Blacklist
tip.PipeItemsEmerald.roundrobin=Round Robin (In Order)
tip.tool.add=Add
tip.tool.fullscreen=Fullscreen

Binary file not shown.

Before

Width:  |  Height:  |  Size: 448 B

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 535 B

After

Width:  |  Height:  |  Size: 517 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View file

@ -5,6 +5,7 @@ Additions:
Improvements:
* Builders now show the amount of required items up to 99K instead of 999 (asie)
* Optimizations to Builder/Filler code (asie)
* Tweaks to water spring generation (asie)

View file

@ -0,0 +1,12 @@
Additions:
* Excavation toggle in the Filler! Finally! (asie)
Improvements:
* Color correction in colorblind diamond pipe GUI for easier color distinction (asie - with input from BevoLJ)
* Tooltips in Emerald Transport Pipe (asie)
Bugs fixed:
* Crash in rotateLeft (asie)

View file

@ -0,0 +1,22 @@
Additions:
* [#2819] Leather/dyed helmet support on robots (asie)
* Make mining robots work with GregTech ores (zmaster587, asie)
* Robots can now be filtered in Force/Forbid by wearable, not just by type (asie)
Improvements:
* Rendering helmet overlays on robots is now supported (hea3ven)
* The Accept Items action now supports Lists (asie)
* The builder robot will not pick up materials in creative worlds (hea3ven)
Bugs fixed:
* [#2833] Stained Glass Panes in schematics always white (asie)
* [#2828] Filler crash without Transport (asie)
* [#2822] Stamper eats items that should not used up (asie)
* [#2820] CME in map generation (asie)
* Fix planter robots not freeing reserved blocks (hea3ven)
* NPE in Builder robot (hea3ven)
* Zone planner maps not generating (asie)

View file

@ -0,0 +1,14 @@
Improvements:
* [#2846] Make Blueprints removable from Construction Markers (asie)
* Code optimizations (asie)
Bugs fixed:
* [#2852] Diamond fluid pipes not sorting into unfiltered slots (asie)
* [#2850] Random ArrayIndexOutOfBoundException (asie - not a true fix, it will however give you a console warning if this is caught again; it's very rare)
* [#2849] Graphical Glitch on Assembly Table when using Texture Packs (asie)
* [#2842] Various fixes to robot state saving (hea3ven)
* [#2835] Robot helmet overlay rendering incorrectly (hea3ven)
* [#2753] Remove unused slot from Packager (asie)
* Crashes in item pipe packet sending (asie)

View file

@ -1,3 +1,3 @@
1.6.4:BuildCraft:4.2.2
1.7.2:BuildCraft:6.0.16
1.7.10:BuildCraft:7.0.9
1.7.10:BuildCraft:7.0.13

View file

@ -130,7 +130,6 @@ import buildcraft.core.DefaultProps;
import buildcraft.core.InterModComms;
import buildcraft.core.Version;
import buildcraft.core.blueprints.SchematicRegistry;
import buildcraft.core.builders.patterns.FillerPattern;
import buildcraft.core.builders.schematics.SchematicBlockCreative;
import buildcraft.core.builders.schematics.SchematicFree;
import buildcraft.core.builders.schematics.SchematicIgnore;

View file

@ -280,92 +280,88 @@ public class BuildCraftCore extends BuildCraftMod {
mainConfiguration = new BuildCraftConfiguration(new File(evt.getModConfigurationDirectory(), "buildcraft/main.cfg"));
mainConfigManager = new ConfigManager(mainConfiguration);
try {
mainConfiguration.load();
mainConfiguration.load();
mainConfigManager.getCat("debug").setShowInGui(false);
mainConfigManager.getCat("vars").setShowInGui(false);
mainConfigManager.getCat("debug").setShowInGui(false);
mainConfigManager.getCat("vars").setShowInGui(false);
mainConfigManager.register("general.updateCheck", true, "Should I check the BuildCraft version on startup?", ConfigManager.RestartRequirement.NONE);
mainConfigManager.register("display.hidePowerValues", false, "Should all power values (RF, RF/t) be hidden?", ConfigManager.RestartRequirement.NONE);
mainConfigManager.register("display.hideFluidValues", false, "Should all fluid values (mB, mB/t) be hidden?", ConfigManager.RestartRequirement.NONE);
mainConfigManager.register("general.itemLifespan", 60, "How long, in seconds, should items stay on the ground? (Vanilla = 300, default = 60)", ConfigManager.RestartRequirement.NONE)
.setMinValue(5);
mainConfigManager.register("network.updateFactor", 10, "How often, in ticks, should network update packets be sent? Increasing this might help network performance.", ConfigManager.RestartRequirement.GAME)
.setMinValue(1);
mainConfigManager.register("network.longUpdateFactor", 40, "How often, in ticks, should full network sync packets be sent? Increasing this might help network performance.", ConfigManager.RestartRequirement.GAME)
.setMinValue(1);
mainConfigManager.register("general.canEnginesExplode", false, "Should engines explode upon overheat?", ConfigManager.RestartRequirement.NONE);
mainConfigManager.register("worldgen.enable", true, "Should BuildCraft generate anything in the world?", ConfigManager.RestartRequirement.GAME);
mainConfigManager.register("general.pumpsConsumeWater", false, "Should pumps consume water? Enabling this might cause performance issues!", ConfigManager.RestartRequirement.NONE);
mainConfigManager.register("power.miningUsageMultiplier", 1.0D, "What should the multiplier of all mining-related power usage be?", ConfigManager.RestartRequirement.NONE);
mainConfigManager.register("display.colorBlindMode", false, "Should I enable colorblind mode?", ConfigManager.RestartRequirement.GAME);
mainConfigManager.register("worldgen.generateWaterSprings", true, "Should BuildCraft generate water springs?", ConfigManager.RestartRequirement.GAME);
mainConfigManager.register("general.updateCheck", true, "Should I check the BuildCraft version on startup?", ConfigManager.RestartRequirement.NONE);
mainConfigManager.register("display.hidePowerValues", false, "Should all power values (RF, RF/t) be hidden?", ConfigManager.RestartRequirement.NONE);
mainConfigManager.register("display.hideFluidValues", false, "Should all fluid values (mB, mB/t) be hidden?", ConfigManager.RestartRequirement.NONE);
mainConfigManager.register("general.itemLifespan", 60, "How long, in seconds, should items stay on the ground? (Vanilla = 300, default = 60)", ConfigManager.RestartRequirement.NONE)
.setMinValue(5);
mainConfigManager.register("network.updateFactor", 10, "How often, in ticks, should network update packets be sent? Increasing this might help network performance.", ConfigManager.RestartRequirement.GAME)
.setMinValue(1);
mainConfigManager.register("network.longUpdateFactor", 40, "How often, in ticks, should full network sync packets be sent? Increasing this might help network performance.", ConfigManager.RestartRequirement.GAME)
.setMinValue(1);
mainConfigManager.register("general.canEnginesExplode", false, "Should engines explode upon overheat?", ConfigManager.RestartRequirement.NONE);
mainConfigManager.register("worldgen.enable", true, "Should BuildCraft generate anything in the world?", ConfigManager.RestartRequirement.GAME);
mainConfigManager.register("general.pumpsConsumeWater", false, "Should pumps consume water? Enabling this might cause performance issues!", ConfigManager.RestartRequirement.NONE);
mainConfigManager.register("power.miningUsageMultiplier", 1.0D, "What should the multiplier of all mining-related power usage be?", ConfigManager.RestartRequirement.NONE);
mainConfigManager.register("display.colorBlindMode", false, "Should I enable colorblind mode?", ConfigManager.RestartRequirement.GAME);
mainConfigManager.register("worldgen.generateWaterSprings", true, "Should BuildCraft generate water springs?", ConfigManager.RestartRequirement.GAME);
reloadConfig(ConfigManager.RestartRequirement.GAME);
reloadConfig(ConfigManager.RestartRequirement.GAME);
wrenchItem = (new ItemWrench()).setUnlocalizedName("wrenchItem");
CoreProxy.proxy.registerItem(wrenchItem);
wrenchItem = (new ItemWrench()).setUnlocalizedName("wrenchItem");
CoreProxy.proxy.registerItem(wrenchItem);
mapLocationItem = (new ItemMapLocation()).setUnlocalizedName("mapLocation");
CoreProxy.proxy.registerItem(mapLocationItem);
mapLocationItem = (new ItemMapLocation()).setUnlocalizedName("mapLocation");
CoreProxy.proxy.registerItem(mapLocationItem);
listItem = (ItemList) ((new ItemList()).setUnlocalizedName("list"));
CoreProxy.proxy.registerItem(listItem);
listItem = (ItemList) (new ItemList()).setUnlocalizedName("list");
CoreProxy.proxy.registerItem(listItem);
debuggerItem = (ItemDebugger) ((new ItemDebugger())).setUnlocalizedName("debugger");
CoreProxy.proxy.registerItem(debuggerItem);
debuggerItem = (new ItemDebugger()).setUnlocalizedName("debugger");
CoreProxy.proxy.registerItem(debuggerItem);
if (BuildCraftCore.modifyWorld) {
BlockSpring.EnumSpring.WATER.canGen = BuildCraftCore.mainConfigManager.get("worldgen.generateWaterSprings").getBoolean();
springBlock = new BlockSpring().setBlockName("eternalSpring");
CoreProxy.proxy.registerBlock(springBlock, ItemSpring.class);
}
woodenGearItem = (new ItemGear()).setUnlocalizedName("woodenGearItem");
CoreProxy.proxy.registerItem(woodenGearItem);
OreDictionary.registerOre("gearWood", new ItemStack(woodenGearItem));
stoneGearItem = (new ItemGear()).setUnlocalizedName("stoneGearItem");
CoreProxy.proxy.registerItem(stoneGearItem);
OreDictionary.registerOre("gearStone", new ItemStack(stoneGearItem));
ironGearItem = (new ItemGear()).setUnlocalizedName("ironGearItem");
CoreProxy.proxy.registerItem(ironGearItem);
OreDictionary.registerOre("gearIron", new ItemStack(ironGearItem));
goldGearItem = (new ItemGear()).setUnlocalizedName("goldGearItem");
CoreProxy.proxy.registerItem(goldGearItem);
OreDictionary.registerOre("gearGold", new ItemStack(goldGearItem));
diamondGearItem = (new ItemGear()).setUnlocalizedName("diamondGearItem");
CoreProxy.proxy.registerItem(diamondGearItem);
OreDictionary.registerOre("gearDiamond", new ItemStack(diamondGearItem));
paintbrushItem = (new ItemPaintbrush()).setUnlocalizedName("paintbrush");
CoreProxy.proxy.registerItem(paintbrushItem);
if (TABLET_TESTING) {
tabletItem = new ItemTablet();
tabletItem.setUnlocalizedName("tablet");
CoreProxy.proxy.registerItem(tabletItem);
}
buildToolBlock = new BlockBuildTool();
buildToolBlock.setBlockName("buildToolBlock");
CoreProxy.proxy.registerBlock(buildToolBlock);
engineBlock = (BlockEngine) CompatHooks.INSTANCE.getBlock(BlockEngine.class);
CoreProxy.proxy.registerBlock(engineBlock, ItemEngine.class);
engineBlock.registerTile((Class<? extends TileEngineBase>) CompatHooks.INSTANCE.getTile(TileEngineWood.class), "tile.engineWood");
CoreProxy.proxy.registerTileEntity(TileEngineWood.class, "net.minecraft.src.buildcraft.energy.TileEngineWood");
FMLCommonHandler.instance().bus().register(this);
MinecraftForge.EVENT_BUS.register(this);
MinecraftForge.EVENT_BUS.register(new BlockHighlightHandler());
} finally {
if (BuildCraftCore.modifyWorld) {
BlockSpring.EnumSpring.WATER.canGen = BuildCraftCore.mainConfigManager.get("worldgen.generateWaterSprings").getBoolean();
springBlock = new BlockSpring().setBlockName("eternalSpring");
CoreProxy.proxy.registerBlock(springBlock, ItemSpring.class);
}
woodenGearItem = (new ItemGear()).setUnlocalizedName("woodenGearItem");
CoreProxy.proxy.registerItem(woodenGearItem);
OreDictionary.registerOre("gearWood", new ItemStack(woodenGearItem));
stoneGearItem = (new ItemGear()).setUnlocalizedName("stoneGearItem");
CoreProxy.proxy.registerItem(stoneGearItem);
OreDictionary.registerOre("gearStone", new ItemStack(stoneGearItem));
ironGearItem = (new ItemGear()).setUnlocalizedName("ironGearItem");
CoreProxy.proxy.registerItem(ironGearItem);
OreDictionary.registerOre("gearIron", new ItemStack(ironGearItem));
goldGearItem = (new ItemGear()).setUnlocalizedName("goldGearItem");
CoreProxy.proxy.registerItem(goldGearItem);
OreDictionary.registerOre("gearGold", new ItemStack(goldGearItem));
diamondGearItem = (new ItemGear()).setUnlocalizedName("diamondGearItem");
CoreProxy.proxy.registerItem(diamondGearItem);
OreDictionary.registerOre("gearDiamond", new ItemStack(diamondGearItem));
paintbrushItem = (new ItemPaintbrush()).setUnlocalizedName("paintbrush");
CoreProxy.proxy.registerItem(paintbrushItem);
if (TABLET_TESTING) {
tabletItem = new ItemTablet();
tabletItem.setUnlocalizedName("tablet");
CoreProxy.proxy.registerItem(tabletItem);
}
buildToolBlock = new BlockBuildTool();
buildToolBlock.setBlockName("buildToolBlock");
CoreProxy.proxy.registerBlock(buildToolBlock);
engineBlock = (BlockEngine) CompatHooks.INSTANCE.getBlock(BlockEngine.class);
CoreProxy.proxy.registerBlock(engineBlock, ItemEngine.class);
engineBlock.registerTile((Class<? extends TileEngineBase>) CompatHooks.INSTANCE.getTile(TileEngineWood.class), "tile.engineWood");
CoreProxy.proxy.registerTileEntity(TileEngineWood.class, "net.minecraft.src.buildcraft.energy.TileEngineWood");
FMLCommonHandler.instance().bus().register(this);
MinecraftForge.EVENT_BUS.register(this);
MinecraftForge.EVENT_BUS.register(new BlockHighlightHandler());
}
@Mod.EventHandler
@ -542,6 +538,8 @@ public class BuildCraftCore extends BuildCraftMod {
if (event.map.getTextureType() == 1) {
iconProvider = new CoreIconProvider();
iconProvider.registerIcons(event.map);
StatementManager.registerIcons(event.map);
} else if (event.map.getTextureType() == 0) {
BuildCraftCore.redLaserTexture = event.map.registerIcon("buildcraftcore:laserBox/blockRedLaser");
BuildCraftCore.blueLaserTexture = event.map.registerIcon("buildcraftcore:laserBox/blockBlueLaser");

View file

@ -422,7 +422,7 @@ public class BuildCraftEnergy extends BuildCraftMod {
}
private int findUnusedBiomeID(String biomeName) {
int freeBiomeID = 0;
int freeBiomeID;
// code to find a free biome
for (int i = 1; i < 256; i++) {
if (BiomeGenBase.getBiomeGenArray()[i] == null) {

View file

@ -27,6 +27,7 @@ import cpw.mods.fml.common.network.FMLOutboundHandler;
import cpw.mods.fml.common.network.FMLOutboundHandler.OutboundTarget;
import cpw.mods.fml.relauncher.Side;
import buildcraft.api.core.BCLog;
import buildcraft.core.DefaultProps;
import buildcraft.core.lib.network.Packet;
import buildcraft.core.lib.utils.ThreadSafeUtils;
@ -128,23 +129,28 @@ public class BuildCraftMod {
}
while (!packets.isEmpty()) {
SendRequest r = packets.remove();
net.minecraft.network.Packet p = ThreadSafeUtils.generatePacketFrom(r.packet, r.source.channels.get(Side.SERVER));
List<EntityPlayerMP> playerList = MinecraftServer.getServer().getConfigurationManager().playerEntityList;
for (EntityPlayerMP player : playerList.toArray(new EntityPlayerMP[playerList.size()])) {
if (r.isValid(player)) {
NetHandlerPlayServer handler = player.playerNetServerHandler;
if (handler == null) {
continue;
}
try {
SendRequest r = packets.remove();
net.minecraft.network.Packet p = ThreadSafeUtils.generatePacketFrom(r.packet, r.source.channels.get(Side.SERVER));
List<EntityPlayerMP> playerList = MinecraftServer.getServer().getConfigurationManager().playerEntityList;
for (EntityPlayerMP player : playerList.toArray(new EntityPlayerMP[playerList.size()])) {
if (r.isValid(player)) {
NetHandlerPlayServer handler = player.playerNetServerHandler;
if (handler == null) {
continue;
}
NetworkManager manager = handler.netManager;
if (manager == null || !manager.isChannelOpen()) {
continue;
}
NetworkManager manager = handler.netManager;
if (manager == null || !manager.isChannelOpen()) {
continue;
}
manager.scheduleOutboundPacket(p);
manager.scheduleOutboundPacket(p);
}
}
} catch (Exception e) {
BCLog.logger.error("The BuildCraft packet sender thread raised an exception! Please report to GitHub.");
e.printStackTrace();
}
}
}

View file

@ -24,6 +24,7 @@ import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLInterModComms;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartedEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.event.FMLServerStoppingEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
@ -183,14 +184,11 @@ public class BuildCraftRobotics extends BuildCraftMod {
public static MapManager manager;
private static Thread managerThread;
private boolean noThreadedZoneMapGen;
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent evt) {
new BCCreativeTab("boards");
BuildCraftCore.mainConfigManager.register("general", "boards.blacklist", new String[]{}, "Blacklisted robots boards", ConfigManager.RestartRequirement.GAME);
BuildCraftCore.mainConfigManager.register("experimental", "disableThreadedZoneMapGen", false, "If you're getting frequent EntityTracker crashes, report and turn this on! The option will be removed when we're sure we resolved the bug.\nDO NOT turn this option on if you're not experiencing any issues as it WILL cause slower game performance.", ConfigManager.RestartRequirement.GAME);
reloadConfig(ConfigManager.RestartRequirement.GAME);
@ -387,24 +385,26 @@ public class BuildCraftRobotics extends BuildCraftMod {
}
}
@Mod.EventHandler
public void serverUnload(FMLServerStoppingEvent event) {
private void stopMapManager() {
if (manager != null) {
manager.stop();
manager.saveAllWorlds();
}
if (managerThread != null) {
managerThread.interrupt();
MinecraftForge.EVENT_BUS.unregister(manager);
FMLCommonHandler.instance().bus().unregister(manager);
}
if (managerThread != null) {
managerThread.interrupt();
}
managerThread = null;
manager = null;
}
@Mod.EventHandler
public void serverUnload(FMLServerStoppingEvent event) {
stopMapManager();
}
@Mod.EventHandler
public void serverLoad(FMLServerStartingEvent event) {
File f = new File(DimensionManager.getCurrentSaveRootDirectory(), "buildcraft/zonemap");
@ -415,16 +415,21 @@ public class BuildCraftRobotics extends BuildCraftMod {
e.printStackTrace();
}
manager = new MapManager(f, !noThreadedZoneMapGen);
if (noThreadedZoneMapGen) {
managerThread = new Thread(manager);
managerThread.start();
}
stopMapManager();
manager = new MapManager(f);
managerThread = new Thread(manager);
managerThread.start();
MinecraftForge.EVENT_BUS.register(manager);
FMLCommonHandler.instance().bus().register(manager);
}
@Mod.EventHandler
public void serverLoadFinish(FMLServerStartedEvent event) {
manager.initialize();
}
@Mod.EventHandler
public void processRequests(FMLInterModComms.IMCEvent event) {
InterModComms.processIMC(event);
@ -432,7 +437,6 @@ public class BuildCraftRobotics extends BuildCraftMod {
public void reloadConfig(ConfigManager.RestartRequirement restartType) {
if (restartType == ConfigManager.RestartRequirement.GAME) {
noThreadedZoneMapGen = BuildCraftCore.mainConfigManager.get("experimental.disableThreadedZoneMapGen").getBoolean();
blacklistedRobots = new ArrayList<String>();
blacklistedRobots.addAll(Arrays.asList(BuildCraftCore.mainConfigManager.get("general",

View file

@ -10,13 +10,15 @@ package buildcraft.builders;
import net.minecraft.block.Block;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import buildcraft.api.tools.IToolWrench;
import buildcraft.core.lib.utils.BlockUtils;
import buildcraft.core.lib.utils.Utils;
public class BlockConstructionMarker extends BlockMarker {
@ -31,17 +33,23 @@ public class BlockConstructionMarker extends BlockMarker {
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int par6) {
Utils.preDestroyBlock(world, x, y, z);
dropMarkerIfPresent(world, x, y, z, true);
super.breakBlock(world, x, y, z, block, par6);
}
private boolean dropMarkerIfPresent(World world, int x, int y, int z, boolean onBreak) {
TileConstructionMarker marker = (TileConstructionMarker) world.getTileEntity(x, y, z);
if (marker != null && marker.itemBlueprint != null && !world.isRemote) {
float f1 = 0.7F;
double d = (world.rand.nextFloat() * f1) + (1.0F - f1) * 0.5D;
double d1 = (world.rand.nextFloat() * f1) + (1.0F - f1) * 0.5D;
double d2 = (world.rand.nextFloat() * f1) + (1.0F - f1) * 0.5D;
EntityItem itemToDrop = new EntityItem(world, x + d, y + d1, z + d2, marker.itemBlueprint);
itemToDrop.delayBeforeCanPickup = 10;
world.spawnEntityInWorld(itemToDrop);
BlockUtils.dropItem((WorldServer) world, x, y, z, 6000, marker.itemBlueprint);
marker.itemBlueprint = null;
if (!onBreak) {
marker.bluePrintBuilder = null;
marker.bptContext = null;
marker.sendNetworkUpdate();
}
return true;
}
super.breakBlock(world, x, y, z, block, par6);
return false;
}
@Override
@ -83,6 +91,8 @@ public class BlockConstructionMarker extends BlockMarker {
ItemConstructionMarker.link(entityplayer.getCurrentEquippedItem(), world, x, y, z);
return true;
}
} else if ((equipped == null || equipped instanceof IToolWrench) && entityplayer.isSneaking()) {
return dropMarkerIfPresent(world, x, y, z, false);
}
return false;

View file

@ -49,14 +49,14 @@ public abstract class ItemBlueprint extends ItemBuildCraft implements IBlueprint
String name = NBTUtils.getItemData(stack).getString("name");
if ("".equals(name)) {
list.add(String.format(StringUtils.localize("item.blueprint.unnamed")));
list.add(StringUtils.localize("item.blueprint.unnamed"));
} else {
list.add(String.format (name));
list.add(name);
}
list.add(String.format(StringUtils.localize("item.blueprint.author")
list.add(StringUtils.localize("item.blueprint.author")
+ " "
+ NBTUtils.getItemData(stack).getString("author")));
+ NBTUtils.getItemData(stack).getString("author"));
} else {
list.add(StringUtils.localize("item.blueprint.blank"));
}
@ -65,9 +65,9 @@ public abstract class ItemBlueprint extends ItemBuildCraft implements IBlueprint
BuildingPermission p = BuildingPermission.values()[NBTUtils.getItemData(stack).getByte("permission")];
if (p == BuildingPermission.CREATIVE_ONLY) {
list.add(String.format(StringUtils.localize("item.blueprint.creative_only")));
list.add(StringUtils.localize("item.blueprint.creative_only"));
} else if (p == BuildingPermission.NONE) {
list.add(String.format(StringUtils.localize("item.blueprint.no_build")));
list.add(StringUtils.localize("item.blueprint.no_build"));
}
}
@ -75,7 +75,7 @@ public abstract class ItemBlueprint extends ItemBuildCraft implements IBlueprint
boolean isComplete = NBTUtils.getItemData(stack).getBoolean("isComplete");
if (!isComplete) {
list.add(String.format(StringUtils.localize("item.blueprint.incomplete")));
list.add(StringUtils.localize("item.blueprint.incomplete"));
}
}
}

View file

@ -32,7 +32,8 @@ public class LibraryBlueprintTypeHandler extends LibraryTypeHandlerNBT {
@Override
public String getName(ItemStack stack) {
return ItemBlueprint.getId(stack).name;
LibraryId id = ItemBlueprint.getId(stack);
return id != null ? id.name : "<<CORRUPT>>";
}
@Override

View file

@ -25,7 +25,6 @@ import buildcraft.core.render.RenderBuildingItems;
import buildcraft.core.render.RenderLaser;
public class RenderConstructionMarker extends RenderBoxProvider {
private final RenderBuildingItems renderItems = new RenderBuildingItems();
private final EntityItem dummyEntityItem = new EntityItem(null);

View file

@ -16,6 +16,7 @@ import java.util.List;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
@ -33,6 +34,7 @@ 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.Position;
@ -52,6 +54,7 @@ import buildcraft.core.blueprints.BlueprintBase;
import buildcraft.core.blueprints.BptBuilderBase;
import buildcraft.core.blueprints.BptBuilderBlueprint;
import buildcraft.core.blueprints.BptBuilderTemplate;
import buildcraft.core.blueprints.RequirementItemStack;
import buildcraft.core.builders.TileAbstractBuilder;
import buildcraft.core.lib.fluids.Tank;
import buildcraft.core.lib.fluids.TankManager;
@ -84,7 +87,7 @@ public class TileBuilder extends TileAbstractBuilder implements IHasWork, IFluid
private BptBuilderBase currentBuilder;
private RecursiveBlueprintBuilder recursiveBuilder;
private LinkedList<BlockIndex> path;
private ArrayList<ItemStack> requiredToBuild;
private ArrayList<RequirementItemStack> requiredToBuild;
private NBTTagCompound initNBT = null;
private boolean done = true;
private boolean isBuilding = false;
@ -158,12 +161,8 @@ public class TileBuilder extends TileAbstractBuilder implements IHasWork, IFluid
AxisAlignedBB boundingBox = bpt.getBoundingBox();
if (oldBoundingBox == null || !collision(oldBoundingBox, boundingBox)) {
oldBoundingBox = boundingBox;
if (bpt != null) {
return bpt;
}
return bpt;
}
ix += cx;
@ -298,7 +297,7 @@ public class TileBuilder extends TileAbstractBuilder implements IHasWork, IFluid
}
public BlueprintBase instanciateBlueprint() {
BlueprintBase bpt = null;
BlueprintBase bpt;
try {
bpt = ItemBlueprint.loadBlueprint(getStackInSlot(0));
@ -623,7 +622,7 @@ public class TileBuilder extends TileAbstractBuilder implements IHasWork, IFluid
return getStackInSlot(0) != null && getStackInSlot(0).getItem() instanceof ItemBlueprint;
}
public List<ItemStack> getNeededItems() {
public List<RequirementItemStack> getNeededItems() {
return requiredToBuild;
}
@ -634,12 +633,24 @@ public class TileBuilder extends TileAbstractBuilder implements IHasWork, IFluid
if ("clearItemRequirements".equals(command)) {
requiredToBuild = null;
} else if ("setItemRequirements".equals(command)) {
int size = stream.readUnsignedShort();
requiredToBuild = new ArrayList<ItemStack>();
int size = stream.readUnsignedMedium();
requiredToBuild = new ArrayList<RequirementItemStack>();
for (int i = 0; i < size; i++) {
ItemStack stack = NetworkUtils.readStack(stream);
stack.stackSize = Math.min(999, stream.readUnsignedShort());
requiredToBuild.add(stack);
int itemId = stream.readUnsignedShort();
int itemDamage = stream.readShort();
int stackSize = stream.readUnsignedMedium();
boolean hasCompound = stackSize >= 0x800000;
ItemStack stack = new ItemStack(Item.getItemById(itemId), 1, itemDamage);
if (hasCompound) {
stack.setTagCompound(NetworkUtils.readNBT(stream));
}
if (stack.getItem() != null) {
requiredToBuild.add(new RequirementItemStack(stack, stackSize & 0x7FFFFF));
} else {
BCLog.logger.error("Corrupt ItemStack in TileBuilder.receiveCommand! This should not happen! (ID " + itemId + ", damage " + itemDamage + ")");
}
}
}
} else if (side.isServer()) {
@ -657,14 +668,18 @@ public class TileBuilder extends TileAbstractBuilder implements IHasWork, IFluid
}
}
private Packet getItemRequirementsPacket(final ArrayList<ItemStack> items) {
private Packet getItemRequirementsPacket(final List<RequirementItemStack> items) {
if (items != null) {
return new PacketCommand(this, "setItemRequirements", new CommandWriter() {
public void write(ByteBuf data) {
data.writeShort(items.size());
for (ItemStack rb : items) {
NetworkUtils.writeStack(data, rb);
data.writeShort(rb.stackSize);
data.writeMedium(items.size());
for (RequirementItemStack rb : items) {
data.writeShort(Item.getIdFromItem(rb.stack.getItem()));
data.writeShort(rb.stack.getItemDamage());
data.writeMedium((rb.stack.hasTagCompound() ? 0x800000 : 0x000000) | Math.min(0x7FFFFF, rb.size));
if (rb.stack.hasTagCompound()) {
NetworkUtils.writeNBT(data, rb.stack.getTagCompound());
}
}
}
});
@ -718,7 +733,7 @@ public class TileBuilder extends TileAbstractBuilder implements IHasWork, IFluid
}
public void updateRequirements() {
ArrayList<ItemStack> reqCopy = null;
List<RequirementItemStack> reqCopy = null;
if (currentBuilder instanceof BptBuilderBlueprint) {
currentBuilder.initialize();
reqCopy = ((BptBuilderBlueprint) currentBuilder).neededItems;
@ -730,7 +745,7 @@ public class TileBuilder extends TileAbstractBuilder implements IHasWork, IFluid
}
public void updateRequirements(EntityPlayer caller) {
ArrayList<ItemStack> reqCopy = null;
List<RequirementItemStack> reqCopy = null;
if (currentBuilder instanceof BptBuilderBlueprint) {
currentBuilder.initialize();
reqCopy = ((BptBuilderBlueprint) currentBuilder).neededItems;
@ -843,9 +858,9 @@ public class TileBuilder extends TileAbstractBuilder implements IHasWork, IFluid
return null;
}
ItemStack requirement = bpt.neededItems.get(i);
RequirementItemStack requirement = bpt.neededItems.get(i);
int qty = quantityMissing(requirement);
int qty = quantityMissing(requirement.stack, requirement.size);
if (qty <= 0) {
return null;
@ -855,7 +870,7 @@ public class TileBuilder extends TileAbstractBuilder implements IHasWork, IFluid
request.index = i;
request.requester = this;
request.stack = requirement;
request.stack = requirement.stack;
return request;
}
@ -885,9 +900,9 @@ public class TileBuilder extends TileAbstractBuilder implements IHasWork, IFluid
return stack;
}
ItemStack requirement = bpt.neededItems.get(i);
RequirementItemStack requirement = bpt.neededItems.get(i);
int qty = quantityMissing(requirement);
int qty = quantityMissing(requirement.stack, requirement.size);
if (qty <= 0) {
return stack;
@ -911,8 +926,8 @@ public class TileBuilder extends TileAbstractBuilder implements IHasWork, IFluid
}
}
private int quantityMissing(ItemStack requirement) {
int left = requirement.stackSize;
private int quantityMissing(ItemStack requirement, int amount) {
int left = amount <= 0 ? requirement.stackSize : amount;
for (IInvSlot slot : InventoryIterator.getIterable(this)) {
if (slot.getStackInSlot() != null) {

View file

@ -51,6 +51,7 @@ public class TileFiller extends TileAbstractBuilder implements IHasWork, IContro
private final Box box = new Box();
private boolean done = false;
private boolean excavate = true;
private SimpleInventory inv = new SimpleInventory(27, "Filler", 64);
private NBTTagCompound initNBT = null;
@ -60,6 +61,10 @@ public class TileFiller extends TileAbstractBuilder implements IHasWork, IContro
box.kind = Kind.STRIPES;
}
public boolean isExcavate() {
return excavate;
}
@Override
public void initialize() {
super.initialize();
@ -81,10 +86,8 @@ public class TileFiller extends TileAbstractBuilder implements IHasWork, IContro
sendNetworkUpdate();
}
if (currentPattern != null && currentTemplate == null && box.isInitialized()) {
currentTemplate = currentPattern
.getTemplateBuilder(box, getWorldObj(), patternParameters);
context = currentTemplate.getContext();
if (currentTemplate == null) {
initTemplate();
}
if (initNBT != null && currentTemplate != null) {
@ -95,6 +98,14 @@ public class TileFiller extends TileAbstractBuilder implements IHasWork, IContro
initNBT = null;
}
private void initTemplate() {
if (currentPattern != null && box.isInitialized()) {
currentTemplate = currentPattern.getTemplateBuilder(box, getWorldObj(), patternParameters);
context = currentTemplate.getContext();
currentTemplate.blueprint.excavate = excavate;
}
}
@Override
public void updateEntity() {
super.updateEntity();
@ -125,9 +136,8 @@ public class TileFiller extends TileAbstractBuilder implements IHasWork, IContro
}
}
if (currentPattern != null && currentTemplate == null) {
currentTemplate = currentPattern.getTemplateBuilder(box, getWorldObj(), patternParameters);
context = currentTemplate.getContext();
if (currentTemplate == null) {
initTemplate();
}
if (currentTemplate != null) {
@ -199,6 +209,7 @@ public class TileFiller extends TileAbstractBuilder implements IHasWork, IContro
}
done = nbt.getBoolean("done");
excavate = nbt.hasKey("excavate") ? nbt.getBoolean("excavate") : true;
// The rest of load has to be done upon initialize.
initNBT = (NBTTagCompound) nbt.getCompoundTag("bpt").copy();
@ -219,6 +230,7 @@ public class TileFiller extends TileAbstractBuilder implements IHasWork, IContro
nbt.setTag("box", boxStore);
nbt.setBoolean("done", done);
nbt.setBoolean("excavate", excavate);
NBTTagCompound bptNBT = new NBTTagCompound();
@ -236,7 +248,7 @@ public class TileFiller extends TileAbstractBuilder implements IHasWork, IContro
}
@Override
public int getInventoryStackLimit() {
public int getInventoryStackLimit() {
return inv.getInventoryStackLimit();
}
@ -301,7 +313,7 @@ public class TileFiller extends TileAbstractBuilder implements IHasWork, IContro
@Override
public void writeData(ByteBuf data) {
box.writeData(data);
data.writeBoolean(done);
data.writeByte((done ? 1 : 0) | (excavate ? 2 : 0));
NetworkUtils.writeUTF(data, currentPattern.getUniqueTag());
NBTTagCompound parameterData = new NBTTagCompound();
@ -312,7 +324,9 @@ public class TileFiller extends TileAbstractBuilder implements IHasWork, IContro
@Override
public void readData(ByteBuf data) {
box.readData(data);
done = data.readBoolean();
int flags = data.readUnsignedByte();
done = (flags & 1) > 0;
excavate = (flags & 2) > 0;
FillerPattern pattern = (FillerPattern) FillerManager.registry.getPattern(NetworkUtils.readUTF(data));
NBTTagCompound parameterData = NetworkUtils.readNBT(data);
readParametersFromNBT(parameterData);
@ -339,7 +353,7 @@ public class TileFiller extends TileAbstractBuilder implements IHasWork, IContro
return true;
}
public void rpcSetPatternFromString (final String name) {
public void rpcSetPatternFromString(final String name) {
BuildCraftCore.instance.sendToServer(new PacketCommand(this, "setPattern", new CommandWriter() {
public void write(ByteBuf data) {
NetworkUtils.writeUTF(data, name);
@ -350,12 +364,24 @@ public class TileFiller extends TileAbstractBuilder implements IHasWork, IContro
@Override
public void receiveCommand(String command, Side side, Object sender, ByteBuf stream) {
super.receiveCommand(command, side, sender, stream);
if (side.isServer() && "setPattern".equals(command)) {
String name = NetworkUtils.readUTF(stream);
setPattern((FillerPattern) FillerManager.registry.getPattern(name));
} else if (side.isServer() && "setParameters".equals(command)) {
NBTTagCompound patternData = NetworkUtils.readNBT(stream);
readParametersFromNBT(patternData);
if (side.isServer()) {
if ("setPattern".equals(command)) {
String name = NetworkUtils.readUTF(stream);
setPattern((FillerPattern) FillerManager.registry.getPattern(name));
done = false;
} else if ("setParameters".equals(command)) {
NBTTagCompound patternData = NetworkUtils.readNBT(stream);
readParametersFromNBT(patternData);
done = false;
} else if ("setFlags".equals(command)) {
excavate = stream.readBoolean();
currentTemplate = null;
sendNetworkUpdate();
done = false;
}
}
}
@ -415,4 +441,8 @@ public class TileFiller extends TileAbstractBuilder implements IHasWork, IContro
public int getLEDLevel(int led) {
return (led == 0 ? done : buildersInAction.size() > 0) ? 15 : 0;
}
public void setExcavate(boolean excavate) {
this.excavate = excavate;
}
}

View file

@ -249,9 +249,9 @@ public class TileQuarry extends TileAbstractBuilder implements IHasWork, ISidedI
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 (int ii = 0; ii < result.size(); ii++) {
if (result.get(ii) instanceof EntityItem) {
EntityItem entity = (EntityItem) result.get(ii);
for (Object aResult : result) {
if (aResult instanceof EntityItem) {
EntityItem entity = (EntityItem) aResult;
if (entity.isDead) {
continue;
}

View file

@ -0,0 +1,40 @@
package buildcraft.builders.gui;
import org.lwjgl.opengl.GL11;
import net.minecraft.item.ItemStack;
import buildcraft.core.blueprints.RequirementItemStack;
import buildcraft.core.lib.gui.AdvancedSlot;
import buildcraft.core.lib.gui.GuiAdvancedInterface;
public class BuilderRequirementSlot extends AdvancedSlot {
public RequirementItemStack stack;
public BuilderRequirementSlot(GuiAdvancedInterface gui, int x, int y) {
super(gui, x, y);
}
@Override
public ItemStack getItemStack() {
return stack != null ? stack.stack : null;
}
@Override
public void drawStack(ItemStack item) {
int cornerX = (gui.width - gui.getXSize()) / 2;
int cornerY = (gui.height - gui.getYSize()) / 2;
gui.drawStack(item, cornerX + x, cornerY + y);
if (stack != null) {
// Render real stack size
String s = String.valueOf(stack.size > 999 ? Math.min(99, stack.size / 1000) + "K" : stack.size);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glDisable(GL11.GL_BLEND);
gui.getFontRenderer().drawStringWithShadow(s,
cornerX + x + 17 - gui.getFontRenderer().getStringWidth(s), cornerY + y + 9, 16777215);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_DEPTH_TEST);
}
}
}

View file

@ -56,8 +56,8 @@ public class ContainerArchitect extends BuildCraftContainer {
public void detectAndSendChanges() {
super.detectAndSendChanges();
for (int i = 0; i < crafters.size(); i++) {
ICrafting icrafting = (ICrafting) crafters.get(i);
for (Object crafter : crafters) {
ICrafting icrafting = (ICrafting) crafter;
if (computingTime != architect.getComputingProgressScaled(24)) {
icrafting.sendProgressBarUpdate(this, 0, architect.getComputingProgressScaled(24));
}

View file

@ -50,8 +50,8 @@ public class ContainerBlueprintLibrary extends BuildCraftContainer {
@Override
public void detectAndSendChanges() {
super.detectAndSendChanges();
for (int i = 0; i < crafters.size(); i++) {
ICrafting icrafting = (ICrafting) crafters.get(i);
for (Object crafter : crafters) {
ICrafting icrafting = (ICrafting) crafter;
if (progressIn != library.progressIn) {
icrafting.sendProgressBarUpdate(this, 0, library.progressIn);
}

View file

@ -16,14 +16,14 @@ import io.netty.buffer.ByteBuf;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import buildcraft.BuildCraftCore;
import buildcraft.builders.TileBuilder;
import buildcraft.core.blueprints.RequirementItemStack;
import buildcraft.core.lib.fluids.Tank;
import buildcraft.core.lib.gui.AdvancedSlot;
import buildcraft.core.lib.gui.GuiAdvancedInterface;
import buildcraft.core.lib.gui.ItemSlot;
import buildcraft.core.lib.network.command.CommandWriter;
import buildcraft.core.lib.network.command.PacketCommand;
import buildcraft.core.lib.utils.StringUtils;
@ -48,7 +48,7 @@ public class GuiBuilder extends GuiAdvancedInterface {
for (int i = 0; i < 6; ++i) {
for (int j = 0; j < 4; ++j) {
slots.set(i * 4 + j, new ItemSlot(this, 179 + j * 18, 18 + i * 18));
slots.set(i * 4 + j, new BuilderRequirementSlot(this, 179 + j * 18, 18 + i * 18));
}
}
}
@ -80,7 +80,7 @@ public class GuiBuilder extends GuiAdvancedInterface {
drawTexturedModalRect(guiLeft + 169, guiTop, 169, 0, 256 - 169, ySize);
}
List<ItemStack> needs = builder.getNeededItems();
List<RequirementItemStack> needs = builder.getNeededItems();
if (needs != null) {
if (needs.size() > slots.size()) {
@ -102,9 +102,9 @@ public class GuiBuilder extends GuiAdvancedInterface {
for (int s = 0; s < slots.size(); s++) {
int ts = offset + s;
if (ts >= needs.size()) {
((ItemSlot) slots.get(s)).stack = null;
((BuilderRequirementSlot) slots.get(s)).stack = null;
} else {
((ItemSlot) slots.get(s)).stack = needs.get(ts).copy();
((BuilderRequirementSlot) slots.get(s)).stack = needs.get(ts);
}
}
@ -114,8 +114,8 @@ public class GuiBuilder extends GuiAdvancedInterface {
} else {
sbPosition = 0;
sbLength = 0;
for (int s = 0; s < slots.size(); s++) {
((ItemSlot) slots.get(s)).stack = null;
for (AdvancedSlot slot : slots) {
((BuilderRequirementSlot) slot).stack = null;
}
for (GuiButton b : (List<GuiButton>) buttonList) {
b.visible = false;

View file

@ -8,10 +8,14 @@
*/
package buildcraft.builders.gui;
import io.netty.buffer.ByteBuf;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.inventory.IInventory;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import buildcraft.BuildCraftCore;
import buildcraft.api.filler.FillerManager;
import buildcraft.api.statements.IStatement;
import buildcraft.api.statements.IStatementParameter;
@ -23,8 +27,14 @@ import buildcraft.core.lib.gui.GuiAdvancedInterface;
import buildcraft.core.lib.gui.GuiTools;
import buildcraft.core.lib.gui.StatementParameterSlot;
import buildcraft.core.lib.gui.StatementSlot;
import buildcraft.core.lib.gui.buttons.ButtonTextureSet;
import buildcraft.core.lib.gui.buttons.GuiBetterButton;
import buildcraft.core.lib.gui.buttons.IButtonTextureSet;
import buildcraft.core.lib.gui.buttons.StandardButtonTextureSets;
import buildcraft.core.lib.gui.tooltips.ToolTip;
import buildcraft.core.lib.gui.tooltips.ToolTipLine;
import buildcraft.core.lib.network.command.CommandWriter;
import buildcraft.core.lib.network.command.PacketCommand;
import buildcraft.core.lib.utils.StringUtils;
public class GuiFiller extends GuiAdvancedInterface {
@ -49,6 +59,8 @@ public class GuiFiller extends GuiAdvancedInterface {
}
private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraftbuilders:textures/gui/filler.png");
private static final IButtonTextureSet EXCAVATE_OFF = new ButtonTextureSet(240, -16, 16, 16, TEXTURE);
private static final IButtonTextureSet EXCAVATE_ON = new ButtonTextureSet(224, -16, 16, 16, TEXTURE);
private final IInventory playerInventory;
private final TileFiller filler;
private final GuiFiller instance;
@ -69,6 +81,17 @@ public class GuiFiller extends GuiAdvancedInterface {
ySize = 240;
}
private IButtonTextureSet getExcavateTexture() {
return filler.isExcavate() ? EXCAVATE_ON : EXCAVATE_OFF;
}
private GuiBetterButton getExcavateButton() {
return new GuiBetterButton(2, guiLeft + 150, guiTop + 30, 16, getExcavateTexture(), "")
.setToolTip(new ToolTip(500, new ToolTipLine(
StatCollector.translateToLocal("tip.filler.excavate." + (filler.isExcavate() ? "on" : "off"))
)));
}
@Override
public void initGui() {
super.initGui();
@ -78,6 +101,7 @@ public class GuiFiller extends GuiAdvancedInterface {
StandardButtonTextureSets.LEFT_BUTTON, ""));
buttonList.add(new GuiBetterButton(1, guiLeft + 38 + 16 + 8, guiTop + 30, 10,
StandardButtonTextureSets.RIGHT_BUTTON, ""));
buttonList.add(getExcavateButton());
slots.clear();
for (int i = 0; i < 4; i++) {
@ -93,6 +117,16 @@ public class GuiFiller extends GuiAdvancedInterface {
filler.currentPattern = (FillerPattern) FillerManager.registry.getPreviousPattern(filler.currentPattern);
} else if (button.id == 1) {
filler.currentPattern = (FillerPattern) FillerManager.registry.getNextPattern(filler.currentPattern);
} else if (button.id == 2) {
filler.setExcavate(!filler.isExcavate());
buttonList.set(2, getExcavateButton());
BuildCraftCore.instance.sendToServer(new PacketCommand(filler, "setFlags", new CommandWriter() {
public void write(ByteBuf data) {
data.writeBoolean(filler.isExcavate());
}
}));
}
filler.rpcSetPatternFromString(filler.currentPattern.getUniqueTag());

View file

@ -19,7 +19,7 @@ public class SchematicGlassPane extends SchematicBlock {
@Override
public void getRequirementsForPlacement(IBuilderContext context, LinkedList<ItemStack> requirements) {
requirements.add(new ItemStack(block, 1, 0));
requirements.add(new ItemStack(block, 1, meta));
}
@Override

View file

@ -7,7 +7,7 @@ import cpw.mods.fml.common.gameevent.PlayerEvent;
import net.minecraftforge.common.AchievementPage;
public class AchievementManager {
public AchievementPage page;
public final AchievementPage page;
public AchievementManager(String name) {
page = new AchievementPage(name);

View file

@ -36,7 +36,7 @@ public class BlockSpring extends Block {
public Block liquidBlock;
public boolean canGen = true;
private EnumSpring(int tickRate, int chance, Block liquidBlock) {
EnumSpring(int tickRate, int chance, Block liquidBlock) {
this.tickRate = tickRate;
this.chance = chance;
this.liquidBlock = liquidBlock;

View file

@ -13,9 +13,6 @@ public final class DefaultProps {
public static final String MOD = "BuildCraft";
public static final String DEPENDENCY_CORE = "required-after:BuildCraft|Core@" + Version.VERSION;
public static final String DEPENDENCY_TRANSPORT = "required-after:BuildCraft|Transport@" + Version.VERSION;
public static final String DEPENDENCY_SILICON = "required-after:BuildCraft|Silicon@" + Version.VERSION;
public static final String DEPENDENCY_SILICON_TRANSPORT = DEPENDENCY_TRANSPORT + ";" + DEPENDENCY_SILICON;
public static final String NET_CHANNEL_NAME = "BC";
public static final int MAX_NAME_SIZE = 32;

View file

@ -53,14 +53,14 @@ public abstract class EntityLaser extends Entity {
noClip = true;
isImmuneToFire = true;
dataWatcher.addObject(8, Integer.valueOf(0));
dataWatcher.addObject(9, Integer.valueOf(0));
dataWatcher.addObject(10, Integer.valueOf(0));
dataWatcher.addObject(11, Integer.valueOf(0));
dataWatcher.addObject(12, Integer.valueOf(0));
dataWatcher.addObject(13, Integer.valueOf(0));
dataWatcher.addObject(8, 0);
dataWatcher.addObject(9, 0);
dataWatcher.addObject(10, 0);
dataWatcher.addObject(11, 0);
dataWatcher.addObject(12, 0);
dataWatcher.addObject(13, 0);
dataWatcher.addObject(14, Byte.valueOf((byte) 0));
dataWatcher.addObject(14, (byte) 0);
}
@Override
@ -110,14 +110,14 @@ public abstract class EntityLaser extends Entity {
}
protected void updateDataServer() {
dataWatcher.updateObject(8, Integer.valueOf(encodeDouble(data.head.x)));
dataWatcher.updateObject(9, Integer.valueOf(encodeDouble(data.head.y)));
dataWatcher.updateObject(10, Integer.valueOf(encodeDouble(data.head.z)));
dataWatcher.updateObject(11, Integer.valueOf(encodeDouble(data.tail.x)));
dataWatcher.updateObject(12, Integer.valueOf(encodeDouble(data.tail.y)));
dataWatcher.updateObject(13, Integer.valueOf(encodeDouble(data.tail.z)));
dataWatcher.updateObject(8, encodeDouble(data.head.x));
dataWatcher.updateObject(9, encodeDouble(data.head.y));
dataWatcher.updateObject(10, encodeDouble(data.head.z));
dataWatcher.updateObject(11, encodeDouble(data.tail.x));
dataWatcher.updateObject(12, encodeDouble(data.tail.y));
dataWatcher.updateObject(13, encodeDouble(data.tail.z));
dataWatcher.updateObject(14, Byte.valueOf((byte) (data.isVisible ? 1 : 0)));
dataWatcher.updateObject(14, (byte) (data.isVisible ? 1 : 0));
}
public void setPositions(Position head, Position tail) {

View file

@ -6,7 +6,7 @@ public enum PowerMode {
public static final PowerMode[] VALUES = values();
public final int maxPower;
private PowerMode(int max) {
PowerMode(int max) {
this.maxPower = max;
}

View file

@ -13,7 +13,6 @@ import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import cpw.mods.fml.common.eventhandler.Event.Result;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.event.terraingen.PopulateChunkEvent;
@ -40,14 +39,14 @@ public class SpringPopulate {
}
private void doPopulate(World world, Random random, int x, int z) {
// A spring will be generated every 40th chunk.
if (random.nextFloat() > 0.025f) {
int dimId = world.provider.dimensionId;
// No water springs will generate in the Nether or End.
if (dimId == -1 || dimId == 1) {
return;
}
// Do not generate water in the End or the Nether
BiomeGenBase biomegenbase = world.getWorldChunkManager().getBiomeGenAt(x, z);
if (biomegenbase.biomeID == BiomeGenBase.sky.biomeID || biomegenbase.biomeID == BiomeGenBase.hell.biomeID) {
// A spring will be generated every 40th chunk.
if (random.nextFloat() > 0.025f) {
return;
}

View file

@ -109,12 +109,21 @@ public class TileEngineWood extends TileEngineBase implements IRedstoneEngine {
return 10;
}
// TODO: HACK
@Override
public boolean canConnectEnergy(ForgeDirection from) {
return false;
}
@Override
public int getEnergyStored(ForgeDirection side) {
return 0;
}
@Override
public int getMaxEnergyStored(ForgeDirection side) {
return 0;
}
@Override
protected void sendPower() {
if (progressPart == 2 && !hasSent) {

View file

@ -23,7 +23,7 @@ import buildcraft.api.core.ISerializable;
import buildcraft.api.core.IZone;
public class ZonePlan implements IZone, ISerializable {
private HashMap<ChunkIndex, ZoneChunk> chunkMapping = new HashMap<ChunkIndex, ZoneChunk>();
private final HashMap<ChunkIndex, ZoneChunk> chunkMapping = new HashMap<ChunkIndex, ZoneChunk>();
public boolean get(int x, int z) {
int xChunk = x >> 4;

View file

@ -79,17 +79,17 @@ public abstract class BlueprintBase {
}
public void translateToBlueprint(Translation transform) {
for (int i = 0; i < contents.length; i++) {
if (contents[i] != null) {
contents[i].translateToBlueprint(transform);
for (SchematicBlockBase content : contents) {
if (content != null) {
content.translateToBlueprint(transform);
}
}
}
public void translateToWorld(Translation transform) {
for (int i = 0; i < contents.length; i++) {
if (contents[i] != null) {
contents[i].translateToWorld(transform);
for (SchematicBlockBase content : contents) {
if (content != null) {
content.translateToWorld(transform);
}
}
}
@ -100,7 +100,7 @@ public abstract class BlueprintBase {
for (int x = 0; x < sizeZ; ++x) {
for (int y = 0; y < sizeY; ++y) {
for (int z = 0; z < sizeX; ++z) {
int pos = toArrayPos(x, y, z);
int pos = (y * sizeX + z) * sizeZ + x;
newContents[pos] = contents[toArrayPos(z, y, (sizeZ - 1) - x)];
if (newContents[pos] != null) {

View file

@ -19,9 +19,6 @@ import java.util.List;
import java.util.ListIterator;
import java.util.Map.Entry;
import com.google.common.collect.HashMultiset;
import com.google.common.collect.Multiset;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
@ -59,12 +56,12 @@ import buildcraft.core.lib.utils.BlockUtils;
public class BptBuilderBlueprint extends BptBuilderBase {
public ArrayList<ItemStack> neededItems = new ArrayList<ItemStack>();
public ArrayList<RequirementItemStack> neededItems = new ArrayList<RequirementItemStack>();
protected HashSet<Integer> builtEntities = new HashSet<Integer>();
private HashMap<BuilderItemMetaPair, List<BuildingSlotBlock>> buildList = new HashMap<BuilderItemMetaPair, List<BuildingSlotBlock>>();
private Multiset<Integer> buildStageOccurences = HashMultiset.create();
private int[] buildStageOccurences;
private LinkedList<BuildingSlotEntity> entityList = new LinkedList<BuildingSlotEntity>();
private LinkedList<BuildingSlot> postProcessing = new LinkedList<BuildingSlot>();
private BuildingSlotMapIterator iterator;
@ -268,8 +265,8 @@ public class BptBuilderBlueprint extends BptBuilderBase {
private int getBuildListCount() {
int out = 0;
for (int i = 0; i < 4; i++) {
out += buildStageOccurences.count(i);
for (int i = 0; i < buildStageOccurences.length; i++) {
out += buildStageOccurences[i];
}
return out;
}
@ -297,7 +294,14 @@ public class BptBuilderBlueprint extends BptBuilderBase {
buildList.put(imp, new ArrayList<BuildingSlotBlock>());
}
buildList.get(imp).add(b);
buildStageOccurences.add(b.buildStage);
if (buildStageOccurences == null) {
buildStageOccurences = new int[Math.max(4, b.buildStage + 1)];
} else if (buildStageOccurences.length <= b.buildStage) {
int[] newBSO = new int[b.buildStage + 1];
System.arraycopy(buildStageOccurences, 0, newBSO, 0, buildStageOccurences.length);
buildStageOccurences = newBSO;
}
buildStageOccurences[b.buildStage]++;
}
}
@ -340,7 +344,7 @@ public class BptBuilderBlueprint extends BptBuilderBase {
boolean skipped = false;
for (int i = 0; i < slot.buildStage; i++) {
if (buildStageOccurences.count(i) > 0) {
if (buildStageOccurences[i] > 0) {
iterator.skipList();
skipped = true;
break;
@ -702,33 +706,31 @@ public class BptBuilderBlueprint extends BptBuilderBase {
}
for (Entry<StackKey, Integer> e : computeStacks.entrySet()) {
ItemStack newStack = e.getKey().stack.copy();
newStack.stackSize = e.getValue();
neededItems.add(newStack);
neededItems.add(new RequirementItemStack(e.getKey().stack.copy(), e.getValue()));
}
Collections.sort (neededItems, new Comparator<ItemStack>() {
Collections.sort(neededItems, new Comparator<RequirementItemStack>() {
@Override
public int compare(ItemStack o1, ItemStack o2) {
if (o1.stackSize > o2.stackSize) {
return -1;
} else if (o1.stackSize < o2.stackSize) {
return 1;
} else if (Item.getIdFromItem(o1.getItem()) > Item.getIdFromItem(o2.getItem())) {
return -1;
} else if (Item.getIdFromItem(o1.getItem()) < Item.getIdFromItem(o2.getItem())) {
return 1;
} else if (o1.getItemDamage() > o2.getItemDamage()) {
return -1;
} else if (o1.getItemDamage() < o2.getItemDamage()) {
return 1;
public int compare(RequirementItemStack o1, RequirementItemStack o2) {
if (o1.size != o2.size) {
return o1.size < o2.size ? 1 : -1;
} else {
return 0;
ItemStack os1 = o1.stack;
ItemStack os2 = o2.stack;
if (Item.getIdFromItem(os1.getItem()) > Item.getIdFromItem(os2.getItem())) {
return -1;
} else if (Item.getIdFromItem(os1.getItem()) < Item.getIdFromItem(os2.getItem())) {
return 1;
} else if (os1.getItemDamage() > os2.getItemDamage()) {
return -1;
} else if (os1.getItemDamage() < os2.getItemDamage()) {
return 1;
} else {
return 0;
}
}
}
});
}
@Override

View file

@ -0,0 +1,19 @@
package buildcraft.core.blueprints;
import net.minecraft.item.ItemStack;
public class RequirementItemStack {
public final ItemStack stack;
public final int size;
public RequirementItemStack(ItemStack stack, int size) {
this.stack = stack;
this.size = size;
stack.stackSize = 1;
}
@Override
public int hashCode() {
return this.stack.hashCode() * 13 + this.size;
}
}

View file

@ -14,15 +14,13 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import com.google.common.collect.Multiset;
import net.minecraft.world.WorldSettings;
public class BuildingSlotMapIterator {
private static final int MAX_PER_ITEM = 80;
private final Map<BuilderItemMetaPair, List<BuildingSlotBlock>> slots;
private final Set<BuilderItemMetaPair> availablePairs = new HashSet<BuilderItemMetaPair>();
private final Multiset<Integer> buildStageOccurences;
private final int[] buildStageOccurences;
private final boolean isCreative;
private Iterator<BuilderItemMetaPair> impIterator;
private BuilderItemMetaPair pair;
@ -30,16 +28,19 @@ public class BuildingSlotMapIterator {
private int position, returnsThisCurrent;
public BuildingSlotMapIterator(Map<BuilderItemMetaPair, List<BuildingSlotBlock>> slots, TileAbstractBuilder builder,
Multiset<Integer> buildStageOccurences) {
int[] buildStageOccurences) {
this.slots = slots;
this.impIterator = slots.keySet().iterator();
this.buildStageOccurences = buildStageOccurences;
this.isCreative = builder.getWorldObj().getWorldInfo().getGameType() == WorldSettings.GameType.CREATIVE;
this.isCreative = builder == null
|| builder.getWorldObj().getWorldInfo().getGameType() == WorldSettings.GameType.CREATIVE;
// Generate available pairs
availablePairs.add(new BuilderItemMetaPair(null));
for (int i = 0; i < builder.getSizeInventory(); i++) {
availablePairs.add(new BuilderItemMetaPair(builder.getStackInSlot(i)));
if (builder != null) {
availablePairs.add(new BuilderItemMetaPair(null));
for (int i = 0; i < builder.getSizeInventory(); i++) {
availablePairs.add(new BuilderItemMetaPair(builder.getStackInSlot(i)));
}
}
findNewCurrent();
@ -79,7 +80,7 @@ public class BuildingSlotMapIterator {
}
public void remove() {
buildStageOccurences.remove(current.get(position).buildStage);
buildStageOccurences[current.get(position).buildStage]--;
current.set(position, null);
}

View file

@ -29,7 +29,7 @@ public class ConfigManager implements IModGuiFactory {
}
public enum RestartRequirement {
NONE, WORLD, GAME;
NONE, WORLD, GAME
}
public ConfigManager() {
@ -55,7 +55,7 @@ public class ConfigManager implements IModGuiFactory {
}
private Property create(String s, Object o) {
Property p = null;
Property p;
if (o instanceof Integer) {
p = new Property(s, o.toString(), Property.Type.INTEGER);
} else if (o instanceof String) {

View file

@ -1,36 +0,0 @@
package buildcraft.core.lib;
import net.minecraft.item.Item;
import net.minecraft.stats.Achievement;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent;
import net.minecraftforge.common.AchievementPage;
public class AchievementManager {
public AchievementPage page;
public AchievementManager(String name) {
page = new AchievementPage(name);
AchievementPage.registerAchievementPage(page);
FMLCommonHandler.instance().bus().register(this);
}
public Achievement registerAchievement(Achievement a) {
page.getAchievements().add(a.registerStat());
return a;
}
@SubscribeEvent
public void onCrafting(PlayerEvent.ItemCraftedEvent event) {
Item item = event.crafting.getItem();
int damage = event.crafting.getItemDamage();
for (Achievement a : page.getAchievements()) {
if (item.equals(a.theItemStack.getItem()) && damage == a.theItemStack.getItemDamage()) {
event.player.addStat(a, 1);
}
}
}
}

View file

@ -90,15 +90,15 @@ public abstract class AdvancedSlot {
mc.renderEngine.bindTexture(getTexture());
//System.out.printf("Drawing advanced sprite %s (%d,%d) at %d %d\n", getIcon().getIconName(), getIcon().getOriginX(),getIcon().getOriginY(),cornerX + x, cornerY + y);
GL11.glPushAttrib(GL11.GL_LIGHTING_BIT | GL11.GL_COLOR_BUFFER_BIT);
GL11.glDisable(GL11.GL_LIGHTING); // Make sure that render states are reset, an ItemStack can derp them up.
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_BLEND);
gui.drawTexturedModelRectFromIcon(cornerX + x, cornerY + y, getIcon(), 16, 16);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glDisable(GL11.GL_BLEND);
GL11.glPopAttrib();
}
}
@ -108,6 +108,7 @@ public abstract class AdvancedSlot {
int cornerY = (gui.height - gui.getYSize()) / 2;
gui.drawStack(item, cornerX + x, cornerY + y);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
}
public void selected () {

View file

@ -2,10 +2,15 @@ package buildcraft.core.lib.gui;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
public class ContainerDummy extends Container {
@Override
public boolean canInteractWith(EntityPlayer player) {
return false;
}
@Override
public void onCraftMatrixChanged(IInventory inventory) {
}
}

View file

@ -370,8 +370,7 @@ public abstract class GuiBuildCraft extends GuiContainer {
int xShift = ((gui.width - gui.xSize) / 2) + gui.xSize;
int yShift = ((gui.height - gui.ySize) / 2) + 8;
for (int i = 0; i < ledgers.size(); i++) {
Ledger ledger = ledgers.get(i);
for (Ledger ledger : ledgers) {
if (!ledger.isVisible()) {
continue;
}
@ -389,8 +388,7 @@ public abstract class GuiBuildCraft extends GuiContainer {
}
protected void drawLedgers(int mouseX, int mouseY) {
int xPos = 8;
int yPos = 8;
for (Ledger ledger : ledgers) {
ledger.update();
@ -398,8 +396,8 @@ public abstract class GuiBuildCraft extends GuiContainer {
continue;
}
ledger.draw(xSize, xPos);
xPos += ledger.getHeight();
ledger.draw(xSize, yPos);
yPos += ledger.getHeight();
}
Ledger ledger = getAtPosition(mouseX, mouseY);

View file

@ -11,7 +11,6 @@ package buildcraft.core.lib.gui;
import net.minecraft.item.ItemStack;
public class ItemSlot extends AdvancedSlot {
public ItemStack stack;
public ItemSlot(GuiAdvancedInterface gui, int x, int y) {

View file

@ -8,15 +8,22 @@
*/
package buildcraft.core.lib.gui.buttons;
public class ButtonTextureSet implements IButtonTextureSet {
import net.minecraft.util.ResourceLocation;
public class ButtonTextureSet implements IButtonTextureSet {
private final ResourceLocation texture;
private final int x, y, height, width;
public ButtonTextureSet(int x, int y, int height, int width) {
this(x, y, height, width, StandardButtonTextureSets.BUTTON_TEXTURES);
}
public ButtonTextureSet(int x, int y, int height, int width, ResourceLocation texture) {
this.x = x;
this.y = y;
this.height = height;
this.width = width;
this.texture = texture;
}
@Override
@ -38,4 +45,9 @@ public class ButtonTextureSet implements IButtonTextureSet {
public int getWidth() {
return width;
}
@Override
public ResourceLocation getTexture() {
return texture;
}
}

View file

@ -13,7 +13,6 @@ import org.lwjgl.opengl.GL11;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.util.ResourceLocation;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -22,8 +21,6 @@ import buildcraft.core.lib.gui.tooltips.ToolTip;
@SideOnly(Side.CLIENT)
public class GuiBetterButton extends GuiButton implements IToolTipProvider {
public static final ResourceLocation BUTTON_TEXTURES = new ResourceLocation("buildcraftcore:textures/gui/buttons.png");
protected final IButtonTextureSet texture;
private ToolTip toolTip;
@ -63,7 +60,7 @@ public class GuiBetterButton extends GuiButton implements IToolTipProvider {
}
protected void bindButtonTextures(Minecraft minecraft) {
minecraft.renderEngine.bindTexture(BUTTON_TEXTURES);
minecraft.renderEngine.bindTexture(texture.getTexture());
}
@Override
@ -92,8 +89,9 @@ public class GuiBetterButton extends GuiButton implements IToolTipProvider {
return toolTip;
}
public void setToolTip(ToolTip tips) {
public GuiBetterButton setToolTip(ToolTip tips) {
this.toolTip = tips;
return this;
}
@Override

View file

@ -19,10 +19,12 @@ import net.minecraft.util.ResourceLocation;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import buildcraft.core.lib.gui.tooltips.IToolTipProvider;
import buildcraft.core.lib.gui.tooltips.ToolTip;
@SideOnly(Side.CLIENT)
public class GuiImageButton extends GuiButton implements IButtonClickEventTrigger {
public class GuiImageButton extends GuiButton implements IButtonClickEventTrigger, IToolTipProvider {
public enum ButtonImage {
BLANK(1, 19),
WHITE_LIST(19, 19),
@ -52,6 +54,7 @@ public class GuiImageButton extends GuiButton implements IButtonClickEventTrigge
private ArrayList<IButtonClickEventListener> listeners = new ArrayList<IButtonClickEventListener>();
private ButtonImage image = ButtonImage.BLANK;
private boolean active = false;
private ToolTip toolTip;
public GuiImageButton(int id, int x, int y, ButtonImage image) {
super(id, x, y, SIZE, SIZE, "");
@ -143,4 +146,24 @@ public class GuiImageButton extends GuiButton implements IButtonClickEventTrigge
private boolean isMouseOverButton(int mouseX, int mouseY) {
return mouseX >= xPosition && mouseY >= yPosition && mouseX < xPosition + SIZE && mouseY < yPosition + SIZE;
}
@Override
public ToolTip getToolTip() {
return toolTip;
}
public GuiImageButton setToolTip(ToolTip tips) {
this.toolTip = tips;
return this;
}
@Override
public boolean isToolTipVisible() {
return visible;
}
@Override
public boolean isMouseOver(int mouseX, int mouseY) {
return isMouseOverButton(mouseX, mouseY);
}
}

View file

@ -8,6 +8,8 @@
*/
package buildcraft.core.lib.gui.buttons;
import net.minecraft.util.ResourceLocation;
public interface IButtonTextureSet {
int getX();
@ -17,4 +19,6 @@ public interface IButtonTextureSet {
int getHeight();
int getWidth();
ResourceLocation getTexture();
}

View file

@ -16,7 +16,7 @@ public enum LockButtonState implements IMultiButtonState {
public static final LockButtonState[] VALUES = values();
private final IButtonTextureSet texture;
private LockButtonState(IButtonTextureSet texture) {
LockButtonState(IButtonTextureSet texture) {
this.texture = texture;
}

View file

@ -8,15 +8,17 @@
*/
package buildcraft.core.lib.gui.buttons;
public enum StandardButtonTextureSets implements IButtonTextureSet {
import net.minecraft.util.ResourceLocation;
public enum StandardButtonTextureSets implements IButtonTextureSet {
LARGE_BUTTON(0, 0, 20, 200),
SMALL_BUTTON(0, 80, 15, 200),
LEFT_BUTTON(204, 0, 16, 10),
RIGHT_BUTTON(214, 0, 16, 10);
public static final ResourceLocation BUTTON_TEXTURES = new ResourceLocation("buildcraftcore:textures/gui/buttons.png");
private final int x, y, height, width;
private StandardButtonTextureSets(int x, int y, int height, int width) {
StandardButtonTextureSets(int x, int y, int height, int width) {
this.x = x;
this.y = y;
this.height = height;
@ -42,4 +44,9 @@ public enum StandardButtonTextureSets implements IButtonTextureSet {
public int getWidth() {
return width;
}
@Override
public ResourceLocation getTexture() {
return BUTTON_TEXTURES;
}
}

View file

@ -13,7 +13,7 @@ import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
public abstract interface IGuiReturnHandler {
public interface IGuiReturnHandler {
World getWorld();
void writeGuiData(ByteBuf data);

View file

@ -1,6 +1,5 @@
package buildcraft.core.lib.render;
import net.minecraft.client.Minecraft;
import net.minecraft.util.IIcon;
public class SubIcon implements IIcon {
@ -10,17 +9,13 @@ public class SubIcon implements IIcon {
private float uScale, vScale;
private int iw, ih;
public SubIcon(IIcon icon, int u, int v) {
this(icon, u, v, 16, 16);
public SubIcon(IIcon icon, int u, int v, int size) {
this(icon, u, v, 16, 16, size);
}
public SubIcon(IIcon icon, int u, int v, int w, int h) {
iw = icon.getIconWidth();
ih = icon.getIconHeight();
if (Minecraft.getMinecraft().gameSettings.anisotropicFiltering > 1) {
iw -= 16;
ih -= 16;
}
public SubIcon(IIcon icon, int u, int v, int w, int h, int size) {
iw = size;
ih = size;
this.icon = icon;
this.uScale = icon.getMaxU() - icon.getMinU();
this.vScale = icon.getMaxV() - icon.getMinV();

View file

@ -75,10 +75,10 @@ public final class CraftingUtils {
// End repair recipe handler
List recipes = CraftingManager.getInstance().getRecipeList();
for (int index = 0; index < recipes.size(); ++index) {
IRecipe currentRecipe = (IRecipe) recipes.get(index);
for (Object recipe : recipes) {
IRecipe currentRecipe = (IRecipe) recipe;
if (currentRecipe.matches(par1InventoryCrafting, par2World)) {
if (currentRecipe.matches(par1InventoryCrafting, par2World)) {
return currentRecipe;
}
}

View file

@ -38,12 +38,11 @@ public class IterableAlgorithmRunner extends Thread {
}
long startTime = new Date().getTime();
long elapsedtime = 0;
pathFinding.iterate();
elapsedtime = new Date().getTime() - startTime;
double timeToWait = elapsedtime * 1.5;
long elapsedTime = new Date().getTime() - startTime;
double timeToWait = elapsedTime * 1.5;
sleep((long) timeToWait);
}
} catch (Throwable t) {

View file

@ -23,9 +23,8 @@ import buildcraft.api.core.IZone;
public class PathFindingSearch implements IIterableAlgorithm {
public static int PATH_ITERATIONS = 1000;
private static HashMap<Integer, HashSet<BlockIndex>> reservations = new HashMap<Integer, HashSet<BlockIndex>>();
public static final int PATH_ITERATIONS = 1000;
private static final HashMap<Integer, HashSet<BlockIndex>> reservations = new HashMap<Integer, HashSet<BlockIndex>>();
private World world;
private BlockIndex start;
@ -119,7 +118,7 @@ public class PathFindingSearch implements IIterableAlgorithm {
if (pathFinding.isDone()) {
LinkedList<BlockIndex> path = pathFinding.getResult();
if (path != null && path.size() > 0) {
if (reserve(path.getLast())) {
if (reserve(pathFinding.end())) {
return;
}
}

View file

@ -10,7 +10,7 @@ import java.util.Random;
public class XorShift128Random {
private static final Random seed = new Random();
private static final double DOUBLE_UNIT = 0x1.0p-53;
private long[] s = new long[2];
private final long[] s = new long[2];
public XorShift128Random() {
s[0] = seed.nextLong();
@ -27,7 +27,7 @@ public class XorShift128Random {
}
public int nextInt() {
return (int) (nextLong() & 0xFFFFFFFF);
return (int) nextLong();
}
public boolean nextBoolean() {

View file

@ -19,10 +19,10 @@ import net.minecraft.world.chunk.Chunk;
public class DimensionProperty implements IWorldAccess {
private LongHashMap chunkMapping = new LongHashMap();
private World world;
private int worldHeight;
private WorldProperty worldProperty;
private final LongHashMap chunkMapping = new LongHashMap();
private final World world;
private final int worldHeight;
private final WorldProperty worldProperty;
public DimensionProperty(World iWorld, WorldProperty iProp) {
world = iWorld;

View file

@ -10,18 +10,19 @@ package buildcraft.core.properties;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.oredict.OreDictionary;
public class WorldPropertyIsOre extends WorldProperty {
public HashSet<Integer> ores = new HashSet<Integer>();
private final HashSet<Integer> ores = new HashSet<Integer>();
public WorldPropertyIsOre(int harvestLevel) {
initBlockHarvestTools();
@ -56,12 +57,19 @@ public class WorldPropertyIsOre extends WorldProperty {
if (block == null) {
return false;
} else {
ItemStack stack = new ItemStack(block, 1, meta);
List<ItemStack> toCheck = new ArrayList<ItemStack>();
toCheck.add(new ItemStack(block, 1, meta));
if (stack.getItem() != null) {
for (int id : OreDictionary.getOreIDs(stack)) {
if (ores.contains(id)) {
return true;
if (block.hasTileEntity(meta) && blockAccess instanceof World) {
toCheck.addAll(block.getDrops((World) blockAccess, x, y, z, blockAccess.getBlockMetadata(x, y, z), 0));
}
for (ItemStack stack : toCheck) {
if (stack.getItem() != null) {
for (int id : OreDictionary.getOreIDs(stack)) {
if (ores.contains(id)) {
return true;
}
}
}
}

View file

@ -103,14 +103,10 @@ public class CoreProxy implements ICoreProxy {
@SuppressWarnings("unchecked")
public void addCraftingRecipe(ItemStack result, Object... recipe) {
String name = Item.itemRegistry.getNameForObject(result.getItem());
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(result, recipe));
}
public void addShapelessRecipe(ItemStack result, Object... recipe) {
String name = Item.itemRegistry.getNameForObject(result.getItem());
CraftingManager.getInstance().getRecipeList().add(new ShapelessOreRecipe(result, recipe));
}

View file

@ -12,7 +12,6 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import buildcraft.api.recipes.IAssemblyRecipeManager;
@ -25,8 +24,6 @@ public class AssemblyRecipeManager implements IAssemblyRecipeManager {
@Override
public void addRecipe(String id, int energyCost, ItemStack output, Object... input) {
String name = Item.itemRegistry.getNameForObject(output.getItem());
addRecipe(id, new FlexibleRecipe<ItemStack>(id, output, energyCost, 0, input));
}

View file

@ -186,7 +186,7 @@ public class FlexibleRecipe<T> implements IFlexibleRecipe<T>, IFlexibleRecipeVie
FluidStack fluid = crafter.getCraftingFluidStack(tankid);
if (fluid != null && fluid.isFluidEqual(requirement)) {
int amountUsed = 0;
int amountUsed;
if (fluid.amount > amount) {
amountUsed = amount;
@ -239,7 +239,7 @@ public class FlexibleRecipe<T> implements IFlexibleRecipe<T>, IFlexibleRecipeVie
ItemStack stack = crafter.getCraftingItemStack(slotid);
if (stack != null && filter.matches(stack)) {
ItemStack removed = null;
ItemStack removed;
if (stack.stackSize >= expected) {
removed = crafter.decrCraftingItemStack(slotid, expected);

View file

@ -32,7 +32,7 @@ public class TriggerFluidContainerLevel extends BCStatement implements ITriggerE
public final float level;
private TriggerType(float level) {
TriggerType(float level) {
this.level = level;
}
}

View file

@ -32,7 +32,7 @@ public class TriggerInventoryLevel extends BCStatement implements ITriggerExtern
BELOW25(0.25F), BELOW50(0.5F), BELOW75(0.75F);
public final float level;
private TriggerType(float level) {
TriggerType(float level) {
this.level = level;
}
}

View file

@ -11,7 +11,7 @@ import buildcraft.api.tablet.TabletProgram;
import buildcraft.api.tablet.TabletProgramFactory;
public abstract class TabletBase implements ITablet {
protected LinkedList<TabletProgram> programs = new LinkedList<TabletProgram>();
protected final LinkedList<TabletProgram> programs = new LinkedList<TabletProgram>();
protected TabletBase() {

View file

@ -5,7 +5,7 @@ import buildcraft.api.tablet.TabletTicker;
class TabletRenderer {
private TabletBitmap currDisplay, newDisplay;
private TabletTicker refreshRate = new TabletTicker(0.035F);
private final TabletTicker refreshRate = new TabletTicker(0.035F);
private boolean changed = false;
private boolean isTicking = false;
private int tickLocation = 7;

View file

@ -48,8 +48,8 @@ public class ContainerEngine extends BuildCraftContainer {
public void detectAndSendChanges() {
super.detectAndSendChanges();
for (int i = 0; i < crafters.size(); i++) {
engine.sendGUINetworkData(this, (ICrafting) crafters.get(i));
for (Object crafter : crafters) {
engine.sendGUINetworkData(this, (ICrafting) crafter);
}
}

View file

@ -23,9 +23,8 @@ import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import buildcraft.core.CoreConstants;
import buildcraft.core.internal.IFramePipeConnection;
public class BlockPlainPipe extends Block implements IFramePipeConnection {
public class BlockPlainPipe extends Block {
public BlockPlainPipe() {
super(Material.glass);
@ -54,11 +53,6 @@ public class BlockPlainPipe extends Block implements IFramePipeConnection {
return false;
}
@Override
public boolean isPipeConnected(IBlockAccess blockAccess, int x1, int y1, int z1, int x2, int y2, int z2) {
return false;
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void getSubBlocks(Item item, CreativeTabs tab, List list) {

View file

@ -169,7 +169,7 @@ public class BlockTank extends BlockBuildCraft {
int qtyToFill = container.fill(current, liquid, true);
tank.drain(ForgeDirection.UNKNOWN, qtyToFill, true);
} else if (mustFill || entityplayer.isSneaking()) {
if (liquid != null && liquid.amount > 0) {
if (liquid.amount > 0) {
int qty = tank.fill(ForgeDirection.UNKNOWN, liquid, false);
tank.fill(ForgeDirection.UNKNOWN, container.drain(current, qty, true), true);
}

View file

@ -68,8 +68,8 @@ public class ContainerAutoWorkbench extends BuildCraftContainer {
@Override
public void detectAndSendChanges() {
super.detectAndSendChanges();
for (int i = 0; i < crafters.size(); i++) {
ICrafting icrafting = (ICrafting) crafters.get(i);
for (Object crafter : crafters) {
ICrafting icrafting = (ICrafting) crafter;
if (lastProgress != tile.progress) {
icrafting.sendProgressBarUpdate(this, 0, tile.progress);

View file

@ -76,8 +76,8 @@ public class ContainerRefinery extends BuildCraftContainer {
@Override
public void detectAndSendChanges() {
super.detectAndSendChanges();
for (int i = 0; i < crafters.size(); i++) {
refinery.sendGUINetworkData(this, (ICrafting) crafters.get(i));
for (Object crafter : crafters) {
refinery.sendGUINetworkData(this, (ICrafting) crafter);
}
}
}

View file

@ -9,16 +9,13 @@
package buildcraft.robotics;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLivingBase;
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.robotics.map.MapWorld;
public class BlockZonePlan extends BlockBuildCraft {
public BlockZonePlan() {
@ -45,23 +42,4 @@ public class BlockZonePlan extends BlockBuildCraft {
return true;
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) {
super.onBlockPlacedBy(world, x, y, z, entity, stack);
if (!world.isRemote) {
int r = TileZonePlan.RESOLUTION >> 4;
int cox = x >> 4;
int coz = z >> 4;
MapWorld w = BuildCraftRobotics.manager.getWorld(world);
for (int cx = -r; cx < r; cx++) {
for (int cz = -r; cz < r; cz++) {
int dist = cx * cx + cz * cz;
w.queueChunkForUpdateIfEmpty(cox + cx, coz + cz, dist);
}
}
}
}
}

View file

@ -11,7 +11,6 @@ package buildcraft.robotics;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import java.util.WeakHashMap;
import com.google.common.collect.Iterables;
@ -180,16 +179,16 @@ public class EntityRobot extends EntityRobotBase implements
isImmuneToFire = true;
this.func_110163_bv(); // persistenceRequired = true
dataWatcher.addObject(12, Float.valueOf(0));
dataWatcher.addObject(13, Float.valueOf(0));
dataWatcher.addObject(14, Float.valueOf(0));
dataWatcher.addObject(15, Byte.valueOf((byte) 0));
dataWatcher.addObject(12, (float) 0);
dataWatcher.addObject(13, (float) 0);
dataWatcher.addObject(14, (float) 0);
dataWatcher.addObject(15, (byte) 0);
dataWatcher.addObject(16, "");
dataWatcher.addObject(17, Float.valueOf(0));
dataWatcher.addObject(18, Float.valueOf(0));
dataWatcher.addObject(19, Integer.valueOf(0));
dataWatcher.addObject(20, Byte.valueOf((byte) 0));
dataWatcher.addObject(21, Integer.valueOf(0));
dataWatcher.addObject(17, (float) 0);
dataWatcher.addObject(18, (float) 0);
dataWatcher.addObject(19, 0);
dataWatcher.addObject(20, (byte) 0);
dataWatcher.addObject(21, 0);
}
protected void updateDataClient() {
@ -213,12 +212,12 @@ public class EntityRobot extends EntityRobotBase implements
}
protected void updateDataServer() {
dataWatcher.updateObject(12, Float.valueOf((float) laser.tail.x));
dataWatcher.updateObject(13, Float.valueOf((float) laser.tail.y));
dataWatcher.updateObject(14, Float.valueOf((float) laser.tail.z));
dataWatcher.updateObject(15, Byte.valueOf((byte) (laser.isVisible ? 1 : 0)));
dataWatcher.updateObject(17, Float.valueOf(itemAngle1));
dataWatcher.updateObject(18, Float.valueOf(itemAngle2));
dataWatcher.updateObject(12, (float) laser.tail.x);
dataWatcher.updateObject(13, (float) laser.tail.y);
dataWatcher.updateObject(14, (float) laser.tail.z);
dataWatcher.updateObject(15, (byte) (laser.isVisible ? 1 : 0));
dataWatcher.updateObject(17, itemAngle1);
dataWatcher.updateObject(18, itemAngle2);
}
public boolean isActive() {
@ -289,7 +288,7 @@ public class EntityRobot extends EntityRobotBase implements
if (!worldObj.isRemote) {
// The client-side sleep indicator should also display if the robot is charging.
// To not break gates and other things checking for sleep, this is done here.
dataWatcher.updateObject(20, Byte.valueOf((byte) ((isActive() && ticksCharging == 0) ? 1 : 0)));
dataWatcher.updateObject(20, (byte) ((isActive() && ticksCharging == 0) ? 1 : 0));
dataWatcher.updateObject(21, getEnergy());
if (needsUpdate) {
@ -516,9 +515,9 @@ public class EntityRobot extends EntityRobotBase implements
if (wearables.size() > 0) {
NBTTagList wearableList = new NBTTagList();
for (int i = 0; i < wearables.size(); i++) {
for (ItemStack wearable : wearables) {
NBTTagCompound item = new NBTTagCompound();
wearables.get(i).writeToNBT(item);
wearable.writeToNBT(item);
wearableList.appendTag(item);
}
@ -1121,7 +1120,7 @@ public class EntityRobot extends EntityRobotBase implements
gameProfile = NBTUtil.func_152459_a(nbttagcompound.getCompoundTag("SkullOwner"));
} else if (nbttagcompound.hasKey("SkullOwner", NBT.TAG_STRING)
&& !StringUtils.isNullOrEmpty(nbttagcompound.getString("SkullOwner"))) {
gameProfile = new GameProfile((UUID) null, nbttagcompound.getString("SkullOwner"));
gameProfile = new GameProfile(null, nbttagcompound.getString("SkullOwner"));
}
if (gameProfile != null && !StringUtils.isNullOrEmpty(gameProfile.getName())) {
if (!gameProfile.isComplete()

View file

@ -17,6 +17,7 @@ import java.util.Map;
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;
@ -34,15 +35,15 @@ import buildcraft.api.robots.RobotManager;
public class RobotRegistry extends WorldSavedData implements IRobotRegistry {
protected World world;
protected HashMap<StationIndex, DockingStation> stations = new HashMap<StationIndex, DockingStation>();
protected final HashMap<StationIndex, DockingStation> stations = new HashMap<StationIndex, DockingStation>();
private long nextRobotID = Long.MIN_VALUE;
private HashMap<Long, EntityRobot> robotsLoaded = new HashMap<Long, EntityRobot>();
private HashMap<ResourceId, Long> resourcesTaken = new HashMap<ResourceId, Long>();
private HashMap<Long, HashSet<ResourceId>> resourcesTakenByRobot = new HashMap<Long, HashSet<ResourceId>>();
private HashMap<Long, HashSet<StationIndex>> stationsTakenByRobot = new HashMap<Long, HashSet<StationIndex>>();
private final LongHashMap robotsLoaded = new LongHashMap();
private final HashSet<EntityRobot> robotsLoadedSet = new HashSet<EntityRobot>();
private final HashMap<ResourceId, Long> resourcesTaken = new HashMap<ResourceId, Long>();
private final LongHashMap resourcesTakenByRobot = new LongHashMap();
private final LongHashMap stationsTakenByRobot = new LongHashMap();
public RobotRegistry(String id) {
super(id);
@ -64,11 +65,30 @@ public class RobotRegistry extends WorldSavedData implements IRobotRegistry {
if (robot.getRobotId() == EntityRobotBase.NULL_ROBOT_ID) {
((EntityRobot) robot).setUniqueRobotId(getNextRobotId());
}
if (robotsLoaded.containsKey(robot.getRobotId())) {
if (robotsLoaded.containsItem(robot.getRobotId())) {
BCLog.logger.warn("Robot with id %d was not unregistered properly", robot.getRobotId());
}
robotsLoaded.put(robot.getRobotId(), (EntityRobot) robot);
addRobotLoaded((EntityRobot) robot);
}
private HashSet<ResourceId> getResourcesTakenByRobot(long robotId) {
return (HashSet<ResourceId>) resourcesTakenByRobot.getValueByKey(robotId);
}
private HashSet<StationIndex> getStationsTakenByRobot(long robotId) {
return (HashSet<StationIndex>) stationsTakenByRobot.getValueByKey(robotId);
}
private void addRobotLoaded(EntityRobot robot) {
robotsLoaded.add(robot.getRobotId(), robot);
robotsLoadedSet.add(robot);
}
private void removeRobotLoaded(EntityRobot robot) {
robotsLoaded.remove(robot.getRobotId());
robotsLoadedSet.remove(robot);
}
@Override
@ -76,7 +96,7 @@ public class RobotRegistry extends WorldSavedData implements IRobotRegistry {
markDirty();
releaseResources(robot, true);
robotsLoaded.remove(robot.getRobotId());
removeRobotLoaded((EntityRobot) robot);
}
@Override
@ -84,13 +104,13 @@ public class RobotRegistry extends WorldSavedData implements IRobotRegistry {
markDirty();
releaseResources(robot, false, true);
robotsLoaded.remove(robot.getRobotId());
removeRobotLoaded((EntityRobot) robot);
}
@Override
public EntityRobot getLoadedRobot(long id) {
if (robotsLoaded.containsKey(id)) {
return robotsLoaded.get(id);
if (robotsLoaded.containsItem(id)) {
return (EntityRobot) robotsLoaded.getValueByKey(id);
} else {
return null;
}
@ -109,7 +129,7 @@ public class RobotRegistry extends WorldSavedData implements IRobotRegistry {
long robotId = resourcesTaken.get(resourceId);
if (robotsLoaded.containsKey(robotId) && !robotsLoaded.get(robotId).isDead) {
if (robotsLoaded.containsItem(robotId) && !((EntityRobot) robotsLoaded.getValueByKey(robotId)).isDead) {
return robotId;
} else {
// If the robot is either not loaded or dead, the resource is not
@ -123,10 +143,10 @@ public class RobotRegistry extends WorldSavedData implements IRobotRegistry {
public synchronized EntityRobot robotTaking(ResourceId resourceId) {
long robotId = robotIdTaking(resourceId);
if (robotId == EntityRobotBase.NULL_ROBOT_ID || !robotsLoaded.containsKey(robotId)) {
if (robotId == EntityRobotBase.NULL_ROBOT_ID || !robotsLoaded.containsItem(robotId)) {
return null;
} else {
return robotsLoaded.get(robotId);
return (EntityRobot) robotsLoaded.getValueByKey(robotId);
}
}
@ -148,11 +168,11 @@ public class RobotRegistry extends WorldSavedData implements IRobotRegistry {
if (!resourcesTaken.containsKey(resourceId)) {
resourcesTaken.put(resourceId, robotId);
if (!resourcesTakenByRobot.containsKey(robotId)) {
resourcesTakenByRobot.put(robotId, new HashSet<ResourceId>());
if (!resourcesTakenByRobot.containsItem(robotId)) {
resourcesTakenByRobot.add(robotId, new HashSet<ResourceId>());
}
resourcesTakenByRobot.get(robotId).add(resourceId);
getResourcesTakenByRobot(robotId).add(resourceId);
resourceId.taken(robotId);
@ -173,7 +193,7 @@ public class RobotRegistry extends WorldSavedData implements IRobotRegistry {
if (resourcesTaken.containsKey(resourceId)) {
long robotId = resourcesTaken.get(resourceId);
resourcesTakenByRobot.get(resourcesTaken.get(resourceId)).remove(resourceId);
getResourcesTakenByRobot(robotId).remove(resourceId);
resourcesTaken.remove(resourceId);
resourceId.released(robotId);
}
@ -191,8 +211,8 @@ public class RobotRegistry extends WorldSavedData implements IRobotRegistry {
private synchronized void releaseResources(EntityRobotBase robot, boolean forceAll, boolean resetEntities) {
markDirty();
if (resourcesTakenByRobot.containsKey(robot.getRobotId())) {
HashSet<ResourceId> resourceSet = (HashSet<ResourceId>) resourcesTakenByRobot.get(robot.getRobotId())
if (resourcesTakenByRobot.containsItem(robot.getRobotId())) {
HashSet<ResourceId> resourceSet = (HashSet<ResourceId>) getResourcesTakenByRobot(robot.getRobotId())
.clone();
for (ResourceId id : resourceSet) {
@ -202,8 +222,8 @@ public class RobotRegistry extends WorldSavedData implements IRobotRegistry {
resourcesTakenByRobot.remove(robot.getRobotId());
}
if (stationsTakenByRobot.containsKey(robot.getRobotId())) {
HashSet<StationIndex> stationSet = (HashSet<StationIndex>) stationsTakenByRobot.get(robot.getRobotId())
if (stationsTakenByRobot.containsItem(robot.getRobotId())) {
HashSet<StationIndex> stationSet = (HashSet<StationIndex>) getStationsTakenByRobot(robot.getRobotId())
.clone();
for (StationIndex s : stationSet) {
@ -271,8 +291,8 @@ public class RobotRegistry extends WorldSavedData implements IRobotRegistry {
station.robotTaking().setMainStation(null);
}
} else if (station.robotIdTaking() != EntityRobotBase.NULL_ROBOT_ID) {
if (stationsTakenByRobot.get(station.robotIdTaking()) != null) {
stationsTakenByRobot.get(station.robotIdTaking()).remove(index);
if (stationsTakenByRobot.containsItem(station.robotIdTaking())) {
getStationsTakenByRobot(station.robotIdTaking()).remove(index);
}
}
@ -282,17 +302,17 @@ public class RobotRegistry extends WorldSavedData implements IRobotRegistry {
@Override
public synchronized void take(DockingStation station, long robotId) {
if (!stationsTakenByRobot.containsKey(robotId)) {
stationsTakenByRobot.put(robotId, new HashSet<StationIndex>());
if (!stationsTakenByRobot.containsItem(robotId)) {
stationsTakenByRobot.add(robotId, new HashSet<StationIndex>());
}
stationsTakenByRobot.get(robotId).add(new StationIndex(station));
getStationsTakenByRobot(robotId).add(new StationIndex(station));
}
@Override
public synchronized void release(DockingStation station, long robotId) {
if (stationsTakenByRobot.containsKey(robotId)) {
stationsTakenByRobot.get(robotId).remove(new StationIndex(station));
if (stationsTakenByRobot.containsItem(robotId)) {
getStationsTakenByRobot(robotId).remove(new StationIndex(station));
}
}
@ -345,7 +365,7 @@ public class RobotRegistry extends WorldSavedData implements IRobotRegistry {
for (int i = 0; i < stationList.tagCount(); ++i) {
NBTTagCompound cpt = stationList.getCompoundTagAt(i);
Class<? extends DockingStation> cls = null;
Class<? extends DockingStation> cls;
if (!cpt.hasKey("stationType")) {
cls = DockingStationPipe.class;
@ -376,7 +396,7 @@ public class RobotRegistry extends WorldSavedData implements IRobotRegistry {
@SubscribeEvent
public void onChunkUnload(ChunkEvent.Unload e) {
if (e.world == this.world) {
for (EntityRobot robot : new ArrayList<EntityRobot>(robotsLoaded.values())) {
for (EntityRobot robot : new ArrayList<EntityRobot>(robotsLoadedSet)) {
if (!e.world.loadedEntityList.contains(robot)) {
robot.onChunkUnload();
}

View file

@ -1,10 +1,18 @@
package buildcraft.robotics;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.boards.RedstoneBoardNBT;
import buildcraft.api.boards.RedstoneBoardRegistry;
import buildcraft.api.boards.RedstoneBoardRobotNBT;
import buildcraft.api.robots.DockingStation;
import buildcraft.api.robots.IDockingStationProvider;
import buildcraft.api.transport.IPipeTile;
@ -33,4 +41,30 @@ public final class RobotUtils {
return stations;
}
public static RedstoneBoardRobotNBT getNextBoard(ItemStack stack, boolean reverse) {
Collection<RedstoneBoardNBT<?>> boards = RedstoneBoardRegistry.instance.getAllBoardNBTs();
if (stack == null || !(stack.getItem() instanceof ItemRobot)) {
if (!reverse) {
return (RedstoneBoardRobotNBT) Iterables.getFirst(boards, null);
} else {
return (RedstoneBoardRobotNBT) Iterables.getLast(boards, null);
}
} else {
if (reverse) {
boards = Lists.reverse((List<RedstoneBoardNBT<?>>) boards);
}
boolean found = false;
for (RedstoneBoardNBT boardNBT : boards) {
if (found) {
return (RedstoneBoardRobotNBT) boardNBT;
} else if (ItemRobot.getRobotNBT(stack) == boardNBT) {
found = true;
}
}
return null;
}
}
}

View file

@ -45,7 +45,7 @@ public class AIRobotAttack extends AIRobot {
@Override
public void update() {
if (target.isDead) {
if (target == null || target.isDead) {
terminate();
return;
}

View file

@ -115,12 +115,11 @@ public class AIRobotBreak extends AIRobot {
if (f > 1.0F) {
int i = EnchantmentHelper.getEfficiencyModifier(robot);
ItemStack itemstack = usingItem;
if (i > 0 && itemstack != null) {
if (i > 0) {
float f1 = i * i + 1;
boolean canHarvest = ForgeHooks.canToolHarvestBlock(block, meta, itemstack);
boolean canHarvest = ForgeHooks.canToolHarvestBlock(block, meta, usingItem);
if (!canHarvest && f <= 1.0F) {
f += f1 * 0.08F;
@ -138,6 +137,11 @@ public class AIRobotBreak extends AIRobot {
return (int) Math.ceil((float) BuilderAPI.BREAK_ENERGY * 2 / 30.0F);
}
@Override
public boolean canLoadFromNBT() {
return true;
}
@Override
public void writeSelfToNBT(NBTTagCompound nbt) {
super.writeSelfToNBT(nbt);

View file

@ -8,6 +8,11 @@
*/
package buildcraft.robotics.ai;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.core.BlockIndex;
import buildcraft.api.robots.AIRobot;
import buildcraft.api.robots.DockingStation;
import buildcraft.api.robots.EntityRobotBase;
@ -61,4 +66,31 @@ public class AIRobotGoAndLinkToDock extends AIRobot {
terminate();
}
}
@Override
public boolean canLoadFromNBT() {
return true;
}
@Override
public void writeSelfToNBT(NBTTagCompound nbt) {
super.writeSelfToNBT(nbt);
NBTTagCompound indexNBT = new NBTTagCompound();
station.index().writeTo(indexNBT);
nbt.setTag("stationIndex", indexNBT);
nbt.setByte("stationSide", (byte) station.side().ordinal());
}
@Override
public void loadSelfFromNBT(NBTTagCompound nbt) {
if (nbt.hasKey("stationIndex")) {
BlockIndex index = new BlockIndex(nbt.getCompoundTag("stationIndex"));
ForgeDirection side = ForgeDirection.values()[nbt.getByte("stationSide")];
station = robot.getRegistry().getStation(index.x, index.y, index.z, side);
} else {
station = robot.getLinkedStation();
}
}
}

View file

@ -31,9 +31,4 @@ public class AIRobotGotoSleep extends AIRobot {
terminate();
}
}
@Override
public boolean canLoadFromNBT() {
return true;
}
}

View file

@ -36,13 +36,13 @@ public class AIRobotGotoStationAndLoad extends AIRobot {
@Override
public void delegateAIEnded(AIRobot ai) {
if (ai instanceof AIRobotGotoStationToLoad) {
if (ai.success()) {
if (filter != null && ai.success()) {
startDelegateAI(new AIRobotLoad(robot, filter, quantity));
} else {
setSuccess(false);
terminate();
}
} else if (ai instanceof AIRobotGotoStationToLoad) {
} else if (ai instanceof AIRobotLoad) {
setSuccess(ai.success());
terminate();
}

View file

@ -34,7 +34,7 @@ public class AIRobotGotoStationAndLoadFluids extends AIRobot {
@Override
public void delegateAIEnded(AIRobot ai) {
if (ai instanceof AIRobotGotoStationToLoadFluids) {
if (ai.success()) {
if (filter != null && ai.success()) {
startDelegateAI(new AIRobotLoadFluids(robot, filter));
} else {
setSuccess(false);

View file

@ -59,6 +59,11 @@ public class AIRobotHarvest extends AIRobot {
}
}
@Override
public boolean canLoadFromNBT() {
return true;
}
@Override
public void writeSelfToNBT(NBTTagCompound nbt) {
super.writeSelfToNBT(nbt);

View file

@ -44,7 +44,6 @@ public class AIRobotLoad extends AIRobot {
@Override
public void update() {
if (filter == null) {
// loading error
terminate();
return;
}

View file

@ -38,6 +38,11 @@ public class AIRobotLoadFluids extends AIRobot {
@Override
public void update() {
if (filter == null) {
terminate();
return;
}
waitedCycles++;
if (waitedCycles > 40) {

View file

@ -93,6 +93,11 @@ public class AIRobotSearchBlock extends AIRobot {
return blockFound != null;
}
@Override
public boolean canLoadFromNBT() {
return true;
}
@Override
public void writeSelfToNBT(NBTTagCompound nbt) {
super.writeSelfToNBT(nbt);

0
common/buildcraft/robotics/ai/AIRobotSearchEntity.java Executable file → Normal file
View file

View file

@ -42,7 +42,6 @@ public class AIRobotSearchRandomGroundBlock extends AIRobot {
@Override
public void update() {
if (filter == null) {
// defensive code
terminate();
}
@ -52,8 +51,7 @@ public class AIRobotSearchRandomGroundBlock extends AIRobot {
terminate();
}
int x = 0;
int z = 0;
int x, z;
if (zone == null) {
double r = robot.worldObj.rand.nextFloat() * range;

View file

@ -8,6 +8,8 @@
*/
package buildcraft.robotics.ai;
import net.minecraft.nbt.NBTTagCompound;
import buildcraft.api.robots.EntityRobotBase;
public class AIRobotStraightMoveTo extends AIRobotGoto {
@ -52,4 +54,29 @@ public class AIRobotStraightMoveTo extends AIRobotGoto {
terminate();
}
}
@Override
public boolean canLoadFromNBT() {
return true;
}
@Override
public void writeSelfToNBT(NBTTagCompound nbt) {
super.writeSelfToNBT(nbt);
nbt.setFloat("x", x);
nbt.setFloat("y", y);
nbt.setFloat("z", z);
}
@Override
public void loadSelfFromNBT(NBTTagCompound nbt) {
super.loadSelfFromNBT(nbt);
if (nbt.hasKey("x")) {
x = nbt.getFloat("x");
y = nbt.getFloat("y");
z = nbt.getFloat("z");
}
}
}

View file

@ -46,6 +46,12 @@ public class AIRobotStripesHandler extends AIRobot implements IStripesActivator
@Override
public void update() {
if (useToBlock == null) {
setSuccess(false);
terminate();
return;
}
useCycles++;
if (useCycles > 60) {

View file

@ -17,7 +17,7 @@ import buildcraft.api.robots.DockingStation;
import buildcraft.api.robots.EntityRobotBase;
import buildcraft.api.transport.IInjectable;
import buildcraft.core.lib.inventory.InventoryIterator;
import buildcraft.core.lib.inventory.filters.ArrayStackFilter;
import buildcraft.core.lib.inventory.filters.ArrayStackOrListFilter;
import buildcraft.robotics.statements.ActionRobotFilter;
import buildcraft.robotics.statements.ActionStationInputItems;
@ -64,7 +64,7 @@ public class AIRobotUnload extends AIRobot {
}
if (!ActionRobotFilter
.canInteractWithItem(station, new ArrayStackFilter(robotSlot.getStackInSlot()),
.canInteractWithItem(station, new ArrayStackOrListFilter(robotSlot.getStackInSlot()),
ActionStationInputItems.class)) {
return false;
}

View file

@ -12,6 +12,7 @@ import java.util.LinkedList;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.WorldSettings;
import buildcraft.api.boards.RedstoneBoardRobot;
import buildcraft.api.boards.RedstoneBoardRobotNBT;
@ -88,8 +89,12 @@ public class BoardRobotBuilder extends RedstoneBoardRobot {
startDelegateAI(new AIRobotDisposeItems(robot));
}
requirementsToLookFor = currentBuildingSlot.getRequirements(markerToBuild
.getContext());
if (robot.worldObj.getWorldInfo().getGameType() != WorldSettings.GameType.CREATIVE) {
requirementsToLookFor = currentBuildingSlot.getRequirements(markerToBuild
.getContext());
} else {
requirementsToLookFor = new LinkedList<ItemStack>();
}
if (requirementsToLookFor == null) {
launchingDelay = 40;

View file

@ -9,7 +9,9 @@
package buildcraft.robotics.boards;
import net.minecraft.block.Block;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
@ -80,8 +82,9 @@ public class BoardRobotPump extends RedstoneBoardRobot {
} else {
startDelegateAI(new AIRobotGotoSleep(robot));
}
} else if (ai instanceof AIRobotGotoStationAndUnloadFluids) {
} else if (ai instanceof AIRobotPumpBlock) {
releaseBlockFound();
} else if (ai instanceof AIRobotGotoStationAndUnloadFluids) {
if (!ai.success()) {
startDelegateAI(new AIRobotGotoSleep(robot));
@ -118,4 +121,27 @@ public class BoardRobotPump extends RedstoneBoardRobot {
return fluidFilter.matches(fluid);
}
@Override
public boolean canLoadFromNBT() {
return true;
}
@Override
public void writeSelfToNBT(NBTTagCompound nbt) {
super.writeSelfToNBT(nbt);
if (blockFound != null) {
NBTTagCompound sub = new NBTTagCompound();
blockFound.writeTo(sub);
nbt.setTag("blockFound", sub);
}
}
@Override
public void loadSelfFromNBT(NBTTagCompound nbt) {
super.loadSelfFromNBT(nbt);
if (nbt.hasKey("blockFound")) {
blockFound = new BlockIndex(nbt.getCompoundTag("blockFound"));
}
}
}

View file

@ -6,30 +6,38 @@ import java.util.Date;
import com.google.common.collect.HashBiMap;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.ChunkProviderServer;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.relauncher.Side;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.event.world.BlockEvent;
import net.minecraftforge.event.world.ChunkEvent;
import net.minecraftforge.event.world.WorldEvent;
import buildcraft.core.lib.utils.Utils;
public class MapManager implements Runnable {
private static final int UPDATE_DELAY = 60000;
private final HashBiMap<World, MapWorld> worldMap = HashBiMap.create();
private final File location;
private final boolean isThreaded;
private boolean stop = false;
private long lastSaveTime;
public MapManager(File location, boolean isThreaded) {
public MapManager(File location) {
this.location = location;
this.isThreaded = isThreaded;
}
public void stop() {
stop = true;
saveAllWorlds();
}
public MapWorld getWorld(World world) {
if (world.isRemote) {
if (world == null || world.isRemote) {
return null;
}
@ -41,33 +49,65 @@ public class MapManager implements Runnable {
return worldMap.get(world);
}
private boolean doUpdate(MapWorld world, Chunk chunk) {
int x = chunk.xPosition;
int z = chunk.zPosition;
long updateTime = (new Date()).getTime() - UPDATE_DELAY;
return world.getUpdateTime(x, z) < updateTime || !world.hasChunk(x, z);
}
private void updateChunk(World rworld, Chunk chunk, boolean force) {
MapWorld world = getWorld(rworld);
if (world != null && (force || doUpdate(world, chunk))) {
world.updateChunk(chunk);
}
}
private void updateChunkDelayed(World rworld, Chunk chunk, boolean force, byte time) {
MapWorld world = getWorld(rworld);
if (world != null && (force || doUpdate(world, chunk))) {
world.updateChunkDelayed(chunk, time);
}
}
@SubscribeEvent
public void serverTick(TickEvent.ServerTickEvent event) {
if (!isThreaded && event.phase == TickEvent.Phase.END) {
public void tickDelayedWorlds(TickEvent.WorldTickEvent event) {
if (event.phase == TickEvent.Phase.END && event.side == Side.SERVER) {
MapWorld w = worldMap.get(event.world);
if (w != null) {
w.tick();
}
}
}
@SubscribeEvent
public void worldUnloaded(WorldEvent.Unload event) {
if (worldMap.containsKey(event.world)) {
worldMap.get(event.world).save();
synchronized (worldMap) {
for (MapWorld world : worldMap.values()) {
world.updateChunkInQueue();
}
worldMap.remove(event.world);
}
}
}
@SubscribeEvent
public void chunkLoaded(ChunkEvent.Load event) {
MapWorld world = getWorld(event.getChunk().worldObj);
if (world != null) {
world.queueChunkForUpdateIfEmpty(event.getChunk().xPosition, event.getChunk().zPosition, 99999);
}
updateChunkDelayed(event.world, event.getChunk(), false, (byte) (40 + Utils.RANDOM.nextInt(20)));
}
@SubscribeEvent
public void chunkUnloaded(ChunkEvent.Unload event) {
updateChunk(event.world, event.getChunk(), false);
}
@SubscribeEvent
public void blockPlaced(BlockEvent.PlaceEvent placeEvent) {
Chunk chunk = placeEvent.world.getChunkFromBlockCoords(placeEvent.x, placeEvent.z);
MapWorld world = getWorld(placeEvent.world);
if (world != null) {
if (world != null && doUpdate(world, chunk)) {
int hv = placeEvent.world.getHeightValue(placeEvent.x, placeEvent.z);
if (placeEvent.y >= (hv - 4)) {
world.queueChunkForUpdate(chunk.xPosition, chunk.zPosition, 512);
if (placeEvent.y >= (hv - 3)) {
world.updateChunk(chunk);
}
}
}
@ -76,15 +116,14 @@ public class MapManager implements Runnable {
public void blockBroken(BlockEvent.BreakEvent placeEvent) {
Chunk chunk = placeEvent.world.getChunkFromBlockCoords(placeEvent.x, placeEvent.z);
MapWorld world = getWorld(placeEvent.world);
if (world != null) {
if (world != null && doUpdate(world, chunk)) {
int hv = placeEvent.world.getHeightValue(placeEvent.x, placeEvent.z);
if (placeEvent.y >= (hv - 4)) {
world.queueChunkForUpdate(chunk.xPosition, chunk.zPosition, 512);
if (placeEvent.y >= (hv - 3)) {
world.updateChunk(chunk);
}
}
}
public void saveAllWorlds() {
synchronized (worldMap) {
for (MapWorld world : worldMap.values()) {
@ -98,12 +137,6 @@ public class MapManager implements Runnable {
lastSaveTime = (new Date()).getTime();
while (!stop) {
synchronized (worldMap) {
for (MapWorld world : worldMap.values()) {
world.updateChunkInQueue();
}
}
long now = (new Date()).getTime();
if (now - lastSaveTime > 120000) {
@ -112,10 +145,27 @@ public class MapManager implements Runnable {
}
try {
Thread.sleep(20 * worldMap.size());
Thread.sleep(4000);
} catch (Exception e) {
}
}
}
public void initialize() {
for (WorldServer ws : DimensionManager.getWorlds()) {
MapWorld mw = getWorld(ws);
IChunkProvider provider = ws.getChunkProvider();
if (provider instanceof ChunkProviderServer) {
for (Object o: ((ChunkProviderServer) provider).func_152380_a()) {
if (o != null && o instanceof Chunk) {
Chunk c = (Chunk) o;
if (!mw.hasChunk(c.xPosition, c.zPosition)) {
mw.updateChunkDelayed(c, (byte) (40 + Utils.RANDOM.nextInt(20)));
}
}
}
}
}
}
}

View file

@ -1,13 +1,12 @@
package buildcraft.robotics.map;
import gnu.trove.map.hash.TIntObjectHashMap;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.IntHashMap;
import buildcraft.api.core.INBTStoreable;
public class MapRegion implements INBTStoreable {
private final TIntObjectHashMap<MapChunk> chunks = new TIntObjectHashMap<MapChunk>();
private final IntHashMap chunks = new IntHashMap();
private final int x, z;
public MapRegion(int x, int z) {
@ -24,28 +23,28 @@ public class MapRegion implements INBTStoreable {
}
public boolean hasChunk(int x, int z) {
return chunks.contains((z << 4) | x);
return chunks.containsItem((z << 4) | x);
}
public MapChunk getChunk(int x, int z) {
int id = (z << 4) | x;
MapChunk chunk = chunks.get(id);
MapChunk chunk = (MapChunk) chunks.lookup(id);
if (chunk == null) {
chunk = new MapChunk(x, z);
chunks.put(id, chunk);
chunks.addKey(id, chunk);
}
return chunk;
}
@Override
public void readFromNBT(NBTTagCompound tag) {
chunks.clear();
chunks.clearMap();
if (tag != null) {
for (int i = 0; i < 256; i++) {
if (tag.hasKey("r" + i)) {
MapChunk chunk = new MapChunk(tag.getCompoundTag("r" + i));
chunks.put(i, chunk);
chunks.addKey(i, chunk);
}
}
}
@ -54,7 +53,7 @@ public class MapRegion implements INBTStoreable {
@Override
public void writeToNBT(NBTTagCompound tag) {
for (int i = 0; i < 256; i++) {
MapChunk chunk = chunks.get(i);
MapChunk chunk = (MapChunk) chunks.lookup(i);
if (chunk != null) {
NBTTagCompound chunkNBT = new NBTTagCompound();
synchronized (chunk) {

View file

@ -0,0 +1,25 @@
package buildcraft.robotics.map;
public final class MapUtils {
private MapUtils() {
}
public static long getIDFromCoords(int x, int z) {
return ((x & 0xFFFFFF) << 24) | (z & 0xFFFFFF);
}
public static int getXFromID(long id) {
return (int) (id >> 24);
}
public static int getZFromID(long id) {
int z = (int) (id & 0xFFFFFF);
if (z >= 0x800000) {
return -(z ^ 0xFFFFFF);
} else {
return z;
}
}
}

View file

@ -5,60 +5,34 @@ import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Set;
import gnu.trove.map.hash.TLongObjectHashMap;
import gnu.trove.map.hash.TLongLongHashMap;
import gnu.trove.set.hash.TLongHashSet;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.LongHashMap;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import buildcraft.core.lib.utils.NBTUtils;
import buildcraft.core.lib.utils.ThreadSafeUtils;
public class MapWorld {
private final World world;
private final TLongObjectHashMap<MapRegion> regionMap;
private final Set<QueuedXZ> regionUpdateSet = new HashSet<QueuedXZ>();
private final Queue<QueuedXZ> queuedChunks;
private final LongHashMap regionMap;
private final HashMap<Chunk, Integer> timeToUpdate = new HashMap<Chunk, Integer>();
private final TLongLongHashMap regionUpdateTime;
private final TLongHashSet updatedChunks;
private final File location;
private class QueuedXZ {
int x, z, p;
QueuedXZ(int x, int z, int p) {
this.x = x;
this.z = z;
this.p = p;
}
@Override
public boolean equals(Object other) {
if (other == null || !(other instanceof QueuedXZ)) {
return false;
}
return ((QueuedXZ) other).x == x && ((QueuedXZ) other).z == z;
}
@Override
public int hashCode() {
return x * 31 + z;
}
}
public MapWorld(World world, File location) {
this.world = world;
regionMap = new TLongObjectHashMap<MapRegion>();
queuedChunks = new PriorityQueue<QueuedXZ>(11, new Comparator<QueuedXZ>() {
@Override
public int compare(QueuedXZ c1, QueuedXZ c2) {
return (c1 != null ? c1.p : 0) - (c2 != null ? c2.p : 0);
}
});
regionMap = new LongHashMap();
regionUpdateTime = new TLongLongHashMap();
updatedChunks = new TLongHashSet();
String saveFolder = world.provider.getSaveFolder();
if (saveFolder == null) {
@ -72,13 +46,9 @@ public class MapWorld {
}
}
private long getXzId(int x, int z) {
return (x << 24) | z;
}
private MapRegion getRegion(int x, int z) {
long id = getXzId(x, z);
MapRegion region = regionMap.get(id);
long id = MapUtils.getIDFromCoords(x, z);
MapRegion region = (MapRegion) regionMap.getValueByKey(id);
if (region == null) {
region = new MapRegion(x, z);
@ -99,7 +69,7 @@ public class MapWorld {
}
}
regionMap.put(id, region);
regionMap.add(id, region);
}
return region;
}
@ -114,46 +84,15 @@ public class MapWorld {
return region.hasChunk(x & 15, z & 15);
}
public void queueChunkForUpdate(int x, int z, int priority) {
synchronized (queuedChunks) {
queuedChunks.add(new QueuedXZ(x, z, priority));
}
}
public void queueChunkForUpdateIfEmpty(int x, int z, int priority) {
if (!hasChunk(x, z)) {
queueChunkForUpdate(x, z, priority);
}
}
public void updateChunkInQueue() {
synchronized (queuedChunks) {
if (queuedChunks.size() == 0) {
return;
}
QueuedXZ q = queuedChunks.remove();
if (q == null) {
return;
}
if (world.getChunkProvider().chunkExists(q.x, q.z)) {
updateChunk(q.x, q.z);
}
}
}
public void save() {
Iterator<QueuedXZ> i = regionUpdateSet.iterator();
long[] chunkList;
synchronized (updatedChunks) {
chunkList = updatedChunks.toArray();
updatedChunks.clear();
}
while (i.hasNext()) {
QueuedXZ id = i.next();
i.remove();
if (id == null) {
continue;
}
MapRegion region = regionMap.get(getXzId(id.x, id.z));
for (long id : chunkList) {
MapRegion region = (MapRegion) regionMap.getValueByKey(id);
if (region == null) {
continue;
}
@ -161,7 +100,7 @@ public class MapWorld {
NBTTagCompound output = new NBTTagCompound();
region.writeToNBT(output);
byte[] data = NBTUtils.save(output);
File file = new File(location, "r" + id.x + "," + id.z + ".nbt");
File file = new File(location, "r" + MapUtils.getXFromID(id) + "," + MapUtils.getZFromID(id) + ".nbt");
try {
FileOutputStream f = new FileOutputStream(file);
@ -178,14 +117,42 @@ public class MapWorld {
return chunk.getColor(x & 15, z & 15);
}
private void updateChunk(int x, int z) {
MapChunk chunk = getChunk(x, z);
chunk.update(ThreadSafeUtils.getChunk(world, x, z));
regionUpdateSet.add(new QueuedXZ(x >> 4, z >> 4, 0));
public void tick() {
if (timeToUpdate.size() > 0) {
synchronized (timeToUpdate) {
Set<Chunk> chunks = new HashSet<Chunk>();
chunks.addAll(timeToUpdate.keySet());
for (Chunk c : chunks) {
int v = timeToUpdate.get(c);
if (v > 1) {
timeToUpdate.put(c, v - 1);
} else {
timeToUpdate.remove(c);
updateChunk(c);
}
}
}
}
}
// priority does not matter - see equals
synchronized (queuedChunks) {
queuedChunks.remove(new QueuedXZ(x, z, 0));
public void updateChunk(Chunk rchunk) {
long id = MapUtils.getIDFromCoords(rchunk.xPosition, rchunk.zPosition);
MapChunk chunk = getChunk(rchunk.xPosition, rchunk.zPosition);
chunk.update(rchunk);
updatedChunks.add(id);
synchronized (timeToUpdate) {
timeToUpdate.remove(rchunk);
}
regionUpdateTime.put(id, (new Date()).getTime());
}
public long getUpdateTime(int x, int z) {
return regionUpdateTime.get(MapUtils.getIDFromCoords(x, z));
}
public void updateChunkDelayed(Chunk chunk, byte time) {
synchronized (timeToUpdate) {
timeToUpdate.put(chunk, (int) time);
}
}
}

View file

@ -249,14 +249,32 @@ public class RenderRobot extends Render implements IItemRenderer {
GL11.glScalef(1.0125F, 1.0125F, 1.0125F);
GL11.glTranslatef(0.0f, -0.25f, 0.0f);
GL11.glRotatef(180F, 0, 0, 1);
int color = wearable.getItem().getColorFromItemStack(wearable, 0);
if (color != 16777215) {
GL11.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT);
GL11.glColor3ub((byte) (color >> 16), (byte) ((color >> 8) & 255), (byte) (color & 255));
}
textureManager.bindTexture(RenderBiped.getArmorResource(entity, wearable, 0, null));
ModelBiped armorModel = ForgeHooksClient.getArmorModel(entity, wearable, 0, null);
if (armorModel != null) {
armorModel.render(entity, 0, 0, 0, -90f, 0, 1 / 16F);
if (color != 16777215) {
GL11.glPopAttrib();
}
} else {
GL11.glRotatef(-90.0f, 0.0f, 1.0f, 0.0f);
helmetBox.render(1 / 16F);
if (color != 16777215) {
this.bindTexture(RenderBiped.getArmorResource(entity, wearable, 0, "overlay"));
helmetBox.render(1 / 16F);
GL11.glPopAttrib();
}
}
GL11.glPopMatrix();
} else if (wearable.getItem() instanceof ItemSkull) {
doRenderSkull(wearable);

View file

@ -68,7 +68,9 @@ public class ActionRobotGotoStation extends BCStatement implements IActionIntern
newStation = getStation((StatementParameterItemStack) parameters[0], registry);
}
robot.overrideAI(new AIRobotGoAndLinkToDock(robot, newStation));
if (newStation != null) {
robot.overrideAI(new AIRobotGoAndLinkToDock(robot, newStation));
}
}
}
}

View file

@ -27,9 +27,9 @@ public class ActionRobotWorkInArea extends BCStatement implements IActionInterna
WORK("work_in_area"),
LOAD_UNLOAD("load_unload_area");
private String name;
private final String name;
private AreaType(String iName) {
AreaType(String iName) {
name = iName;
}
@ -46,7 +46,7 @@ public class ActionRobotWorkInArea extends BCStatement implements IActionInterna
}
}
private AreaType areaType;
private final AreaType areaType;
public ActionRobotWorkInArea(AreaType iAreaType) {
super(iAreaType.getTag());

Some files were not shown because too many files have changed in this diff Show more