add excavation option to the filler, BuildCraft 7.0.11

This commit is contained in:
Adrian 2015-06-16 17:06:11 +02:00
parent 0687b54223
commit 6abc40ed48
10 changed files with 110 additions and 26 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.11"
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]

Binary file not shown.

Before

Width:  |  Height:  |  Size: 448 B

After

Width:  |  Height:  |  Size: 2.4 KiB

View file

@ -0,0 +1,7 @@
Additions:
* Excavation toggle in the Filler! Finally! (asie)
Bugs fixed:
* Crash in rotateLeft (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.10
1.7.10:BuildCraft:7.0.11

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

@ -8,10 +8,13 @@
*/
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 buildcraft.BuildCraftCore;
import buildcraft.api.filler.FillerManager;
import buildcraft.api.statements.IStatement;
import buildcraft.api.statements.IStatementParameter;
@ -23,8 +26,12 @@ 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.network.command.CommandWriter;
import buildcraft.core.lib.network.command.PacketCommand;
import buildcraft.core.lib.utils.StringUtils;
public class GuiFiller extends GuiAdvancedInterface {
@ -49,6 +56,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 +78,10 @@ public class GuiFiller extends GuiAdvancedInterface {
ySize = 240;
}
private IButtonTextureSet getExcavateTexture() {
return filler.isExcavate() ? EXCAVATE_ON : EXCAVATE_OFF;
}
@Override
public void initGui() {
super.initGui();
@ -78,6 +91,8 @@ 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(new GuiBetterButton(2, guiLeft + 150, guiTop + 30, 16,
getExcavateTexture(), ""));
slots.clear();
for (int i = 0; i < 4; i++) {
@ -93,6 +108,17 @@ 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, new GuiBetterButton(2, guiLeft + 150, guiTop + 30, 16,
getExcavateTexture(), ""));
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

@ -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

@ -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

@ -8,12 +8,14 @@
*/
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) {
@ -42,4 +44,9 @@ public enum StandardButtonTextureSets implements IButtonTextureSet {
public int getWidth() {
return width;
}
@Override
public ResourceLocation getTexture() {
return BUTTON_TEXTURES;
}
}