fix #2565, clean up, filler/builder improvements

This commit is contained in:
Adrian 2015-09-11 20:20:49 +02:00
parent 2cc6727398
commit 91b8b8df83
12 changed files with 89 additions and 101 deletions

View file

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

View file

@ -1,3 +1,13 @@
Improvements:
* Architect Tables are less server-intensive now (asie)
* More Ore Dictionary support for recipes (Adaptivity)
Bugs fixed: Bugs fixed:
* [#3008] Rare crash on strange Minecraft world in MapChunk (asie)
* [#3007] "Energy Stored" trigger has incorrect behaviour (asie)
* [#3001] NPE in RobotStationPluggableRenderer (asie) * [#3001] NPE in RobotStationPluggableRenderer (asie)
* [#2922, #2975] Composite blueprints not working (asie)
* [#2565] Fillers not liking certain blocks (asie)
* Fillers and Builders not dropping item on inability to place (asie)

View file

@ -45,7 +45,6 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.client.event.RenderWorldLastEvent; import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.client.event.TextureStitchEvent; import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.common.IPlantable;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.fluids.BlockFluidBase; import net.minecraftforge.fluids.BlockFluidBase;
@ -131,6 +130,7 @@ import buildcraft.core.properties.WorldPropertyIsFluidSource;
import buildcraft.core.properties.WorldPropertyIsHarvestable; import buildcraft.core.properties.WorldPropertyIsHarvestable;
import buildcraft.core.properties.WorldPropertyIsLeaf; import buildcraft.core.properties.WorldPropertyIsLeaf;
import buildcraft.core.properties.WorldPropertyIsOre; import buildcraft.core.properties.WorldPropertyIsOre;
import buildcraft.core.properties.WorldPropertyIsReplaceable;
import buildcraft.core.properties.WorldPropertyIsShoveled; import buildcraft.core.properties.WorldPropertyIsShoveled;
import buildcraft.core.properties.WorldPropertyIsSoft; import buildcraft.core.properties.WorldPropertyIsSoft;
import buildcraft.core.properties.WorldPropertyIsWood; import buildcraft.core.properties.WorldPropertyIsWood;
@ -463,7 +463,7 @@ public class BuildCraftCore extends BuildCraftMod {
for (Object o : Block.blockRegistry) { for (Object o : Block.blockRegistry) {
Block block = (Block) o; Block block = (Block) o;
if (block instanceof BlockFluidBase || block instanceof BlockLiquid || block instanceof IPlantable) { if (block instanceof BlockFluidBase || block instanceof BlockLiquid) {
BuildCraftAPI.softBlocks.add(block); BuildCraftAPI.softBlocks.add(block);
} }
} }
@ -477,6 +477,7 @@ public class BuildCraftCore extends BuildCraftMod {
CropManager.setDefaultHandler(new CropHandlerPlantable()); CropManager.setDefaultHandler(new CropHandlerPlantable());
CropManager.registerHandler(new CropHandlerReeds()); CropManager.registerHandler(new CropHandlerReeds());
BuildCraftAPI.registerWorldProperty("replaceable", new WorldPropertyIsReplaceable());
BuildCraftAPI.registerWorldProperty("soft", new WorldPropertyIsSoft()); BuildCraftAPI.registerWorldProperty("soft", new WorldPropertyIsSoft());
BuildCraftAPI.registerWorldProperty("wood", new WorldPropertyIsWood()); BuildCraftAPI.registerWorldProperty("wood", new WorldPropertyIsWood());
BuildCraftAPI.registerWorldProperty("leaves", new WorldPropertyIsLeaf()); BuildCraftAPI.registerWorldProperty("leaves", new WorldPropertyIsLeaf());

View file

@ -420,16 +420,6 @@ public class TileFiller extends TileAbstractBuilder implements IHasWork, IContro
})); }));
} }
public int getIconGlowLevel(int renderPass) {
if (renderPass == 1) { // Red LED
return done ? 15 : 0;
} else if (renderPass == 2) { // Green LED
return 0;
} else {
return -1;
}
}
@Override @Override
public int getLEDLevel(int led) { public int getLEDLevel(int led) {
return (led == 0 ? done : buildersInAction.size() > 0) ? 15 : 0; return (led == 0 ? done : buildersInAction.size() > 0) ? 15 : 0;

View file

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

View file

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

View file

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

View file

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

View file

@ -0,0 +1,21 @@
/**
* Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.core.properties;
import net.minecraft.block.Block;
import net.minecraft.world.IBlockAccess;
public class WorldPropertyIsReplaceable extends WorldProperty {
@Override
public boolean get(IBlockAccess blockAccess, Block block, int meta, int x, int y, int z) {
return block == null
|| block.isAir(blockAccess, x, y, z)
|| block.isReplaceable(blockAccess, x, y, z);
}
}

View file

@ -39,7 +39,7 @@ import buildcraft.core.lib.network.command.ICommandReceiver;
import buildcraft.core.lib.utils.NetworkUtils; import buildcraft.core.lib.utils.NetworkUtils;
import buildcraft.core.recipes.RefineryRecipeManager; import buildcraft.core.recipes.RefineryRecipeManager;
public class TileRefinery extends TileBuildCraft implements IFluidHandler, IInventory, IHasWork, IFlexibleCrafter, ICommandReceiver { public class TileRefinery extends TileBuildCraft implements IFluidHandler, IHasWork, IFlexibleCrafter, ICommandReceiver {
public static int LIQUID_PER_SLOT = FluidContainerRegistry.BUCKET_VOLUME * 4; public static int LIQUID_PER_SLOT = FluidContainerRegistry.BUCKET_VOLUME * 4;
@ -65,50 +65,6 @@ public class TileRefinery extends TileBuildCraft implements IFluidHandler, IInve
this.setBattery(new RFBattery(10000, 1500, 0)); this.setBattery(new RFBattery(10000, 1500, 0));
} }
@Override
public int getSizeInventory() {
return 0;
}
@Override
public ItemStack getStackInSlot(int i) {
return null;
}
@Override
public ItemStack decrStackSize(int i, int j) {
return null;
}
@Override
public void setInventorySlotContents(int i, ItemStack itemstack) {
}
@Override
public String getInventoryName() {
return null;
}
@Override
public int getInventoryStackLimit() {
return 0;
}
@Override
public boolean isItemValidForSlot(int i, ItemStack itemstack) {
return false;
}
@Override
public boolean isUseableByPlayer(EntityPlayer entityplayer) {
return worldObj.getTileEntity(xCoord, yCoord, zCoord) == this;
}
@Override
public ItemStack getStackInSlotOnClosing(int var1) {
return null;
}
@Override @Override
public void updateEntity() { public void updateEntity() {
super.updateEntity(); super.updateEntity();
@ -228,14 +184,6 @@ public class TileRefinery extends TileBuildCraft implements IFluidHandler, IInve
} }
} }
@Override
public void openInventory() {
}
@Override
public void closeInventory() {
}
public void resetFilters() { public void resetFilters() {
for (SingleUseTank tank : tankManager) { for (SingleUseTank tank : tankManager) {
tank.setAcceptedFluid(null); tank.setAcceptedFluid(null);
@ -357,11 +305,6 @@ public class TileRefinery extends TileBuildCraft implements IFluidHandler, IInve
return true; return true;
} }
@Override
public boolean hasCustomInventoryName() {
return false;
}
@Override @Override
public int getCraftingItemStackSize() { public int getCraftingItemStackSize() {
return 0; return 0;

View file

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

View file

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