fix a fair amount of bugs

This commit is contained in:
asiekierka 2015-10-01 08:49:48 +02:00
parent 927b0f099d
commit 5ce9ab97f2
11 changed files with 103 additions and 57 deletions

View file

@ -1,14 +1,17 @@
Additions:
* "/buildcraft op" and "/buildcraft deop", used to op/deop the BuildCraft "fake player" (asie)
Improvements: Improvements:
* New quarry frame model! (asie) * "/buildcraft op" and "/buildcraft deop" commands, letting you easily op/deop the BuildCraft "fake player" (asie)
* New Quarry frame model (asie)
* Quarry now rebuilds its own frame if it is removed (asie) * Quarry now rebuilds its own frame if it is removed (asie)
Bugs fixed: Bugs fixed:
* [#3033] Emerald Transport Pipes only changing setting after closing GUI (asie)
* [#2998] Quarries not respecting a certain form of player-specific protection (asie) * [#2998] Quarries not respecting a certain form of player-specific protection (asie)
* Biome config crashing instead of finding a new ID on setting ID past 256 (asie)
* Crash in TileAssemblyTable upon removing a mod whose Assembly Table recipes were being used (asie)
* Creative Engines only outputting 1/5th the advertised RF/t (asie) * Creative Engines only outputting 1/5th the advertised RF/t (asie)
* Frame icon not rendering on Quarry Frame building (asie) * Frame icon not rendering on Quarry frame building (asie)
* NullPointerException on invalid StackRequest saving (asie)
* Rare StackOverflowException on breaking Markers (asie)
* StackOverflowException when breaking large Quarry frames (asie)

View file

@ -159,8 +159,10 @@ public class BuildCraftEnergy extends BuildCraftMod {
BuildCraftCore.mainConfiguration.save(); BuildCraftCore.mainConfiguration.save();
BiomeGenBase[] biomeGenArray = BiomeGenBase.getBiomeGenArray();
if (oilDesertBiomeId > 0) { if (oilDesertBiomeId > 0) {
if (BiomeGenBase.getBiomeGenArray()[oilDesertBiomeId] != null) { if (biomeGenArray.length >= oilDesertBiomeId || biomeGenArray[oilDesertBiomeId] != null) {
oilDesertBiomeId = findUnusedBiomeID("oilDesert"); oilDesertBiomeId = findUnusedBiomeID("oilDesert");
// save changes to config file // save changes to config file
BuildCraftCore.mainConfiguration.get("worldgen.biomes", "biomeOilDesert", oilDesertBiomeId).set(oilDesertBiomeId); BuildCraftCore.mainConfiguration.get("worldgen.biomes", "biomeOilDesert", oilDesertBiomeId).set(oilDesertBiomeId);
@ -170,7 +172,7 @@ public class BuildCraftEnergy extends BuildCraftMod {
} }
if (oilOceanBiomeId > 0) { if (oilOceanBiomeId > 0) {
if (BiomeGenBase.getBiomeGenArray()[oilOceanBiomeId] != null) { if (biomeGenArray.length >= oilOceanBiomeId || biomeGenArray[oilOceanBiomeId] != null) {
oilOceanBiomeId = findUnusedBiomeID("oilOcean"); oilOceanBiomeId = findUnusedBiomeID("oilOcean");
// save changes to config file // save changes to config file
BuildCraftCore.mainConfiguration.get("worldgen.biomes", "biomeOilOcean", oilOceanBiomeId).set(oilOceanBiomeId); BuildCraftCore.mainConfiguration.get("worldgen.biomes", "biomeOilOcean", oilOceanBiomeId).set(oilOceanBiomeId);
@ -433,7 +435,7 @@ public class BuildCraftEnergy extends BuildCraftMod {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public BiomeIdLimitException(String biome) { public BiomeIdLimitException(String biome) {
super(String.format("You have run out of free Biome ID spaces for %s", biome)); super(String.format("You have run out of free Biome ID spaces for %s - free more Biome IDs or disable the biome by setting the ID to 0!", biome));
} }
} }

View file

@ -9,8 +9,11 @@
package buildcraft.builders; package buildcraft.builders;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import java.util.Set;
import java.util.concurrent.ConcurrentSkipListSet;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
@ -27,12 +30,13 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.BuildCraftCore; import buildcraft.api.core.BlockIndex;
import buildcraft.core.CoreConstants; import buildcraft.core.CoreConstants;
import buildcraft.core.internal.IFramePipeConnection; import buildcraft.core.internal.IFramePipeConnection;
import buildcraft.core.lib.utils.Utils; import buildcraft.core.lib.utils.Utils;
public class BlockFrame extends Block implements IFramePipeConnection { public class BlockFrame extends Block implements IFramePipeConnection {
private static final ThreadLocal<Boolean> isRemovingFrames = new ThreadLocal<Boolean>();
public BlockFrame() { public BlockFrame() {
super(Material.glass); super(Material.glass);
@ -45,16 +49,33 @@ public class BlockFrame extends Block implements IFramePipeConnection {
return; return;
} }
if (isRemovingFrames.get() == null) {
removeNeighboringFrames(world, x, y, z); removeNeighboringFrames(world, x, y, z);
} }
}
public void removeNeighboringFrames(World world, int x, int y, int z) { public void removeNeighboringFrames(World world, int x, int y, int z) {
isRemovingFrames.set(true);
Set<BlockIndex> frameCoords = new ConcurrentSkipListSet<BlockIndex>();
frameCoords.add(new BlockIndex(x, y, z));
while (frameCoords.size() > 0) {
Iterator<BlockIndex> frameCoordIterator = frameCoords.iterator();
while (frameCoordIterator.hasNext()) {
BlockIndex i = frameCoordIterator.next();
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
Block nBlock = world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ); Block nBlock = world.getBlock(i.x + dir.offsetX, i.y + dir.offsetY, i.z + dir.offsetZ);
if (nBlock == this) { if (nBlock == this) {
world.setBlockToAir(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ); world.setBlockToAir(i.x + dir.offsetX, i.y + dir.offsetY, i.z + dir.offsetZ);
frameCoords.add(new BlockIndex(i.x + dir.offsetX, i.y + dir.offsetY, i.z + dir.offsetZ));
} }
} }
frameCoordIterator.remove();
}
}
isRemovingFrames.remove();
} }
@Override @Override

View file

@ -149,7 +149,7 @@ public class BlockMarker extends BlockBuildCraft {
private void dropTorchIfCantStay(World world, int x, int y, int z) { private void dropTorchIfCantStay(World world, int x, int y, int z) {
int meta = world.getBlockMetadata(x, y, z); int meta = world.getBlockMetadata(x, y, z);
if (!canPlaceBlockOnSide(world, x, y, z, meta)) { if (!canPlaceBlockOnSide(world, x, y, z, meta) && world.getBlock(x, y, z) == this) {
dropBlockAsItem(world, x, y, z, 0, 0); dropBlockAsItem(world, x, y, z, 0, 0);
world.setBlockToAir(x, y, z); world.setBlockToAir(x, y, z);
} }

View file

@ -20,6 +20,7 @@ import net.minecraftforge.common.DimensionManager;
import buildcraft.BuildCraftCore; import buildcraft.BuildCraftCore;
import buildcraft.core.network.PacketIds; import buildcraft.core.network.PacketIds;
// TODO: Rename to PacketGuiUpdate
public class PacketGuiReturn extends Packet { public class PacketGuiReturn extends Packet {
private EntityPlayer sender; private EntityPlayer sender;
private IGuiReturnHandler obj; private IGuiReturnHandler obj;

View file

@ -48,6 +48,10 @@ public final class ResourceUtils {
* @return * @return
*/ */
public static String getObjectPrefix(String objectName) { public static String getObjectPrefix(String objectName) {
if (objectName == null) {
return null;
}
int splitLocation = objectName.indexOf(":"); int splitLocation = objectName.indexOf(":");
return objectName.substring(0, splitLocation).replaceAll("[^a-zA-Z0-9\\s]", "") + objectName.substring(splitLocation); return objectName.substring(0, splitLocation).replaceAll("[^a-zA-Z0-9\\s]", "") + objectName.substring(splitLocation);
} }

View file

@ -33,6 +33,7 @@ public class RenderLEDTile extends TileEntitySpecialRenderer {
public static void registerBlockIcons(IIconRegister register) { public static void registerBlockIcons(IIconRegister register) {
for (Block b : iconMap.keySet().toArray(new Block[iconMap.keySet().size()])) { for (Block b : iconMap.keySet().toArray(new Block[iconMap.keySet().size()])) {
String base = ResourceUtils.getObjectPrefix(Block.blockRegistry.getNameForObject(b)); String base = ResourceUtils.getObjectPrefix(Block.blockRegistry.getNameForObject(b));
if (base != null) {
List<IIcon> icons = new ArrayList<IIcon>(); List<IIcon> icons = new ArrayList<IIcon>();
if (b instanceof ICustomLEDBlock) { if (b instanceof ICustomLEDBlock) {
for (String s : ((ICustomLEDBlock) b).getLEDSuffixes()) { for (String s : ((ICustomLEDBlock) b).getLEDSuffixes()) {
@ -46,6 +47,7 @@ public class RenderLEDTile extends TileEntitySpecialRenderer {
iconMap.put(b, icons.toArray(new IIcon[icons.size()])); iconMap.put(b, icons.toArray(new IIcon[icons.size()]));
} }
} }
}
@Override @Override
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float f) { public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float f) {

View file

@ -51,7 +51,10 @@ public class StackRequest {
public IRequestProvider getRequester(World world) { public IRequestProvider getRequester(World world) {
if (requester == null) { if (requester == null) {
requester = getStation(world).getRequestProvider(); DockingStation dockingStation = getStation(world);
if (dockingStation != null) {
requester = dockingStation.getRequestProvider();
}
} }
return requester; return requester;
} }
@ -85,13 +88,16 @@ public class StackRequest {
stack.writeToNBT(stackNBT); stack.writeToNBT(stackNBT);
nbt.setTag("stack", stackNBT); nbt.setTag("stack", stackNBT);
if (station != null) {
NBTTagCompound stationIndexNBT = new NBTTagCompound(); NBTTagCompound stationIndexNBT = new NBTTagCompound();
station.index().writeTo(stationIndexNBT); station.index().writeTo(stationIndexNBT);
nbt.setTag("stationIndex", stationIndexNBT); nbt.setTag("stationIndex", stationIndexNBT);
nbt.setByte("stationSide", (byte) station.side().ordinal()); nbt.setByte("stationSide", (byte) station.side().ordinal());
} }
}
public static StackRequest loadFromNBT(NBTTagCompound nbt) { public static StackRequest loadFromNBT(NBTTagCompound nbt) {
if (nbt.hasKey("stationIndex")) {
int slot = nbt.getInteger("slot"); int slot = nbt.getInteger("slot");
ItemStack stack = ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("stack")); ItemStack stack = ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("stack"));
@ -100,9 +106,12 @@ public class StackRequest {
ForgeDirection stationSide = ForgeDirection.values()[nbt.getByte("stationSide")]; ForgeDirection stationSide = ForgeDirection.values()[nbt.getByte("stationSide")];
return new StackRequest(slot, stack, stationIndex, stationSide); return new StackRequest(slot, stack, stationIndex, stationSide);
} else {
return null;
}
} }
public ResourceId getResourceId(World world) { public ResourceId getResourceId(World world) {
return new ResourceIdRequest(getStation(world), slot); return getStation(world) != null ? new ResourceIdRequest(getStation(world), slot) : null;
} }
} }

View file

@ -36,7 +36,12 @@ public class AIRobotDeliverRequested extends AIRobot {
@Override @Override
public void start() { public void start() {
if (requested != null) {
startDelegateAI(new AIRobotGotoStation(robot, requested.getStation(robot.worldObj))); startDelegateAI(new AIRobotGotoStation(robot, requested.getStation(robot.worldObj)));
} else {
setSuccess(false);
terminate();
}
} }
@Override @Override

View file

@ -142,6 +142,7 @@ public class TileAssemblyTable extends TileLaserTableBase implements IInventory,
private void generatePlannedOutputIcons() { private void generatePlannedOutputIcons() {
for (String s : plannedOutput) { for (String s : plannedOutput) {
IFlexibleRecipe<ItemStack> recipe = AssemblyRecipeManager.INSTANCE.getRecipe(s); IFlexibleRecipe<ItemStack> recipe = AssemblyRecipeManager.INSTANCE.getRecipe(s);
if (recipe != null) {
CraftingResult<ItemStack> result = recipe.craft(this, true); CraftingResult<ItemStack> result = recipe.craft(this, true);
if (result != null && result.usedItems != null && result.usedItems.size() > 0) { if (result != null && result.usedItems != null && result.usedItems.size() > 0) {
plannedOutputIcons.put(s, result); plannedOutputIcons.put(s, result);
@ -155,6 +156,9 @@ public class TileAssemblyTable extends TileLaserTableBase implements IInventory,
plannedOutputIcons.put(s, result); plannedOutputIcons.put(s, result);
} }
} }
} else {
plannedOutput.remove(s);
}
} }
for (String s : plannedOutputIcons.keySet().toArray(new String[plannedOutputIcons.size()])) { for (String s : plannedOutputIcons.keySet().toArray(new String[plannedOutputIcons.size()])) {

View file

@ -82,16 +82,6 @@ public class GuiEmeraldPipe extends GuiBuildCraft implements IButtonClickEventLi
} }
} }
@Override
public void onGuiClosed() {
if (pipe.getWorld().isRemote) {
PacketGuiReturn pkt = new PacketGuiReturn(pipe.getContainer());
pkt.sendPacket();
}
super.onGuiClosed();
}
@Override @Override
public void handleButtonClick(IButtonClickEventTrigger sender, int buttonId) { public void handleButtonClick(IButtonClickEventTrigger sender, int buttonId) {
switch (buttonId) { switch (buttonId) {
@ -117,6 +107,11 @@ public class GuiEmeraldPipe extends GuiBuildCraft implements IButtonClickEventLi
pipe.getSettings().setFilterMode(FilterMode.ROUND_ROBIN); pipe.getSettings().setFilterMode(FilterMode.ROUND_ROBIN);
break; break;
} }
if (pipe.getWorld().isRemote) {
PacketGuiReturn pkt = new PacketGuiReturn(pipe.getContainer());
pkt.sendPacket();
}
} }
@Override @Override