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:
* 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)
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)
* 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)
* 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();
BiomeGenBase[] biomeGenArray = BiomeGenBase.getBiomeGenArray();
if (oilDesertBiomeId > 0) {
if (BiomeGenBase.getBiomeGenArray()[oilDesertBiomeId] != null) {
if (biomeGenArray.length >= oilDesertBiomeId || biomeGenArray[oilDesertBiomeId] != null) {
oilDesertBiomeId = findUnusedBiomeID("oilDesert");
// save changes to config file
BuildCraftCore.mainConfiguration.get("worldgen.biomes", "biomeOilDesert", oilDesertBiomeId).set(oilDesertBiomeId);
@ -170,7 +172,7 @@ public class BuildCraftEnergy extends BuildCraftMod {
}
if (oilOceanBiomeId > 0) {
if (BiomeGenBase.getBiomeGenArray()[oilOceanBiomeId] != null) {
if (biomeGenArray.length >= oilOceanBiomeId || biomeGenArray[oilOceanBiomeId] != null) {
oilOceanBiomeId = findUnusedBiomeID("oilOcean");
// save changes to config file
BuildCraftCore.mainConfiguration.get("worldgen.biomes", "biomeOilOcean", oilOceanBiomeId).set(oilOceanBiomeId);
@ -433,7 +435,7 @@ public class BuildCraftEnergy extends BuildCraftMod {
private static final long serialVersionUID = 1L;
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;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.ConcurrentSkipListSet;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
@ -27,12 +30,13 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.BuildCraftCore;
import buildcraft.api.core.BlockIndex;
import buildcraft.core.CoreConstants;
import buildcraft.core.internal.IFramePipeConnection;
import buildcraft.core.lib.utils.Utils;
public class BlockFrame extends Block implements IFramePipeConnection {
private static final ThreadLocal<Boolean> isRemovingFrames = new ThreadLocal<Boolean>();
public BlockFrame() {
super(Material.glass);
@ -45,16 +49,33 @@ public class BlockFrame extends Block implements IFramePipeConnection {
return;
}
removeNeighboringFrames(world, x, y, z);
if (isRemovingFrames.get() == null) {
removeNeighboringFrames(world, x, y, z);
}
}
public void removeNeighboringFrames(World world, int x, int y, int z) {
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
Block nBlock = world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ);
if (nBlock == this) {
world.setBlockToAir(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ);
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) {
Block nBlock = world.getBlock(i.x + dir.offsetX, i.y + dir.offsetY, i.z + dir.offsetZ);
if (nBlock == this) {
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

View file

@ -149,7 +149,7 @@ public class BlockMarker extends BlockBuildCraft {
private void dropTorchIfCantStay(World world, int x, int y, int 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);
world.setBlockToAir(x, y, z);
}

View file

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

View file

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

View file

@ -33,17 +33,19 @@ public class RenderLEDTile extends TileEntitySpecialRenderer {
public static void registerBlockIcons(IIconRegister register) {
for (Block b : iconMap.keySet().toArray(new Block[iconMap.keySet().size()])) {
String base = ResourceUtils.getObjectPrefix(Block.blockRegistry.getNameForObject(b));
List<IIcon> icons = new ArrayList<IIcon>();
if (b instanceof ICustomLEDBlock) {
for (String s : ((ICustomLEDBlock) b).getLEDSuffixes()) {
icons.add(register.registerIcon(base + "/" + s));
if (base != null) {
List<IIcon> icons = new ArrayList<IIcon>();
if (b instanceof ICustomLEDBlock) {
for (String s : ((ICustomLEDBlock) b).getLEDSuffixes()) {
icons.add(register.registerIcon(base + "/" + s));
}
} else {
icons.add(register.registerIcon(base + "/led_red"));
icons.add(register.registerIcon(base + "/led_green"));
}
} else {
icons.add(register.registerIcon(base + "/led_red"));
icons.add(register.registerIcon(base + "/led_green"));
}
iconMap.put(b, icons.toArray(new IIcon[icons.size()]));
iconMap.put(b, icons.toArray(new IIcon[icons.size()]));
}
}
}

View file

@ -51,7 +51,10 @@ public class StackRequest {
public IRequestProvider getRequester(World world) {
if (requester == null) {
requester = getStation(world).getRequestProvider();
DockingStation dockingStation = getStation(world);
if (dockingStation != null) {
requester = dockingStation.getRequestProvider();
}
}
return requester;
}
@ -85,24 +88,30 @@ public class StackRequest {
stack.writeToNBT(stackNBT);
nbt.setTag("stack", stackNBT);
NBTTagCompound stationIndexNBT = new NBTTagCompound();
station.index().writeTo(stationIndexNBT);
nbt.setTag("stationIndex", stationIndexNBT);
nbt.setByte("stationSide", (byte) station.side().ordinal());
if (station != null) {
NBTTagCompound stationIndexNBT = new NBTTagCompound();
station.index().writeTo(stationIndexNBT);
nbt.setTag("stationIndex", stationIndexNBT);
nbt.setByte("stationSide", (byte) station.side().ordinal());
}
}
public static StackRequest loadFromNBT(NBTTagCompound nbt) {
int slot = nbt.getInteger("slot");
if (nbt.hasKey("stationIndex")) {
int slot = nbt.getInteger("slot");
ItemStack stack = ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("stack"));
ItemStack stack = ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("stack"));
BlockIndex stationIndex = new BlockIndex(nbt.getCompoundTag("stationIndex"));
ForgeDirection stationSide = ForgeDirection.values()[nbt.getByte("stationSide")];
BlockIndex stationIndex = new BlockIndex(nbt.getCompoundTag("stationIndex"));
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) {
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
public void start() {
startDelegateAI(new AIRobotGotoStation(robot, requested.getStation(robot.worldObj)));
if (requested != null) {
startDelegateAI(new AIRobotGotoStation(robot, requested.getStation(robot.worldObj)));
} else {
setSuccess(false);
terminate();
}
}
@Override

View file

@ -142,18 +142,22 @@ public class TileAssemblyTable extends TileLaserTableBase implements IInventory,
private void generatePlannedOutputIcons() {
for (String s : plannedOutput) {
IFlexibleRecipe<ItemStack> recipe = AssemblyRecipeManager.INSTANCE.getRecipe(s);
CraftingResult<ItemStack> result = recipe.craft(this, true);
if (result != null && result.usedItems != null && result.usedItems.size() > 0) {
plannedOutputIcons.put(s, result);
} else if (recipe instanceof IFlexibleRecipeViewable) {
// !! HACK !! TODO !! HACK !!
Object out = ((IFlexibleRecipeViewable) recipe).getOutput();
if (out instanceof ItemStack) {
result = new CraftingResult<ItemStack>();
result.crafted = (ItemStack) out;
result.recipe = recipe;
if (recipe != null) {
CraftingResult<ItemStack> result = recipe.craft(this, true);
if (result != null && result.usedItems != null && result.usedItems.size() > 0) {
plannedOutputIcons.put(s, result);
} else if (recipe instanceof IFlexibleRecipeViewable) {
// !! HACK !! TODO !! HACK !!
Object out = ((IFlexibleRecipeViewable) recipe).getOutput();
if (out instanceof ItemStack) {
result = new CraftingResult<ItemStack>();
result.crafted = (ItemStack) out;
result.recipe = recipe;
plannedOutputIcons.put(s, result);
}
}
} else {
plannedOutput.remove(s);
}
}

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