Merge branch 'BuildCraft-5.1.x' into NextGen
Conflicts: buildcraft_resources/assets/buildcraft/lang/en_US.lang common/buildcraft/energy/BlockEngine.java common/buildcraft/factory/BlockTank.java common/buildcraft/transport/pipes/PipeItemsEmerald.java
This commit is contained in:
commit
5812d4f0bf
21 changed files with 501 additions and 194 deletions
|
@ -14,7 +14,7 @@ buildscript {
|
|||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath 'net.minecraftforge.gradle:ForgeGradle:1.1-SNAPSHOT'
|
||||
classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT'
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ 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]
|
||||
|
||||
minecraft {
|
||||
version = "1.7.2-10.12.0.1047" // McVersion-ForgeVersion this variable is later changed to contain only the MC version, while the apiVersion variable is used for the forge version. Yeah its stupid, and will be changed eentually.
|
||||
version = "1.7.2-10.12.1.1060" // McVersion-ForgeVersion this variable is later changed to contain only the MC version, while the apiVersion variable is used for the forge version. Yeah its stupid, and will be changed eentually.
|
||||
|
||||
assetDir = "run/assets" // the place for ForgeGradle to download the assets. The assets that the launcher gets and stuff
|
||||
|
||||
|
|
|
@ -98,6 +98,7 @@ gui.heat=Heat
|
|||
gui.assemblyRate=Energy Rate
|
||||
gui.assemblyCurrentRequired=Energy Required
|
||||
gui.clickcraft=-Click to Craft-
|
||||
gui.pipes.emerald.title=Filters
|
||||
gui.pipes.emerald.blocking=Blocking
|
||||
gui.pipes.emerald.blocking.tip=Extraction is blocked if one element in filter is missing
|
||||
gui.pipes.emerald.nonblocking=Non Blocking
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 3.3 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2 KiB After Width: | Height: | Size: 1.8 KiB |
|
@ -152,8 +152,8 @@ public class BuildCraftSilicon extends BuildCraftMod {
|
|||
BuildcraftRecipes.assemblyTable.addRecipe(10000, ItemGate.makeGateItem(GateMaterial.REDSTONE, GateLogic.AND), Chipset.RED.getStack(), PipeWire.RED.getStack());
|
||||
|
||||
addGateRecipe(20000, GateMaterial.IRON, Chipset.IRON, PipeWire.RED, PipeWire.BLUE);
|
||||
addGateRecipe(40000, GateMaterial.GOLD, Chipset.GOLD, PipeWire.RED, PipeWire.BLUE, PipeWire.YELLOW);
|
||||
addGateRecipe(80000, GateMaterial.DIAMOND, Chipset.DIAMOND, PipeWire.RED, PipeWire.BLUE, PipeWire.YELLOW, PipeWire.GREEN);
|
||||
addGateRecipe(40000, GateMaterial.GOLD, Chipset.GOLD, PipeWire.RED, PipeWire.BLUE, PipeWire.GREEN);
|
||||
addGateRecipe(80000, GateMaterial.DIAMOND, Chipset.DIAMOND, PipeWire.RED, PipeWire.BLUE, PipeWire.GREEN, PipeWire.YELLOW);
|
||||
|
||||
// REVERSAL RECIPES
|
||||
EnumSet<GateMaterial> materials = EnumSet.allOf(GateMaterial.class);
|
||||
|
|
|
@ -42,12 +42,15 @@ public class BlockBlueprintLibrary extends BlockContainer {
|
|||
if (entityplayer.isSneaking())
|
||||
return false;
|
||||
|
||||
TileBlueprintLibrary tile = (TileBlueprintLibrary) world.getTileEntity(i, j, k);
|
||||
TileEntity tile = world.getTileEntity(i, j, k);
|
||||
if (tile instanceof TileBlueprintLibrary) {
|
||||
TileBlueprintLibrary tileBlueprint = (TileBlueprintLibrary)tile;
|
||||
if (!tileBlueprint.locked || entityplayer.getDisplayName().equals(tileBlueprint.owner))
|
||||
if (!world.isRemote) {
|
||||
entityplayer.openGui(BuildCraftBuilders.instance, GuiIds.BLUEPRINT_LIBRARY, world, i, j, k);
|
||||
}
|
||||
}
|
||||
|
||||
if (!tile.locked || entityplayer.getDisplayName().equals(tile.owner))
|
||||
if (!world.isRemote) {
|
||||
entityplayer.openGui(BuildCraftBuilders.instance, GuiIds.BLUEPRINT_LIBRARY, world, i, j, k);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -71,8 +74,9 @@ public class BlockBlueprintLibrary extends BlockContainer {
|
|||
@Override
|
||||
public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entityliving, ItemStack stack) {
|
||||
if (!world.isRemote && entityliving instanceof EntityPlayer) {
|
||||
TileBlueprintLibrary tile = (TileBlueprintLibrary) world.getTileEntity(i, j, k);
|
||||
tile.owner = ((EntityPlayer) entityliving).getDisplayName();
|
||||
TileEntity tile = world.getTileEntity(i, j, k);
|
||||
if (tile instanceof TileBlueprintLibrary)
|
||||
((TileBlueprintLibrary)tile).owner = ((EntityPlayer) entityliving).getDisplayName();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -85,7 +85,9 @@ public class BlockMarker extends BlockContainer {
|
|||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityplayer, int par6, float par7, float par8, float par9) {
|
||||
((TileMarker) world.getTileEntity(i, j, k)).tryConnection();
|
||||
TileEntity tile = world.getTileEntity(i, j, k);
|
||||
if (tile instanceof TileMarker)
|
||||
((TileMarker) tile).tryConnection();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -112,7 +114,9 @@ public class BlockMarker extends BlockContainer {
|
|||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
|
||||
((TileMarker) world.getTileEntity(x, y, z)).updateSignals();
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if (tile instanceof TileMarker)
|
||||
((TileMarker) tile).updateSignals();
|
||||
dropTorchIfCantStay(world, x, y, z);
|
||||
}
|
||||
|
||||
|
|
154
common/buildcraft/core/gui/buttons/GuiImageButton.java
Normal file
154
common/buildcraft/core/gui/buttons/GuiImageButton.java
Normal file
|
@ -0,0 +1,154 @@
|
|||
/**
|
||||
* Copyright (c) 2011-2014, 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.gui.buttons;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import buildcraft.core.DefaultProps;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiImageButton extends GuiButton implements IButtonClickEventTrigger {
|
||||
|
||||
public enum ButtonImage {
|
||||
BLANK(1, 19),
|
||||
WHITE_LIST(19, 19),
|
||||
BLACK_LIST(37, 19),
|
||||
ROUND_ROBIN(55, 19);
|
||||
|
||||
private final int u, v;
|
||||
|
||||
ButtonImage(int u, int v) {
|
||||
this.u = u;
|
||||
this.v = v;
|
||||
}
|
||||
|
||||
public int getU(){
|
||||
return u;
|
||||
}
|
||||
|
||||
public int getV(){
|
||||
return v;
|
||||
}
|
||||
}
|
||||
|
||||
public static final ResourceLocation ICON_BUTTON_TEXTURES = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/icon_button.png");
|
||||
|
||||
public static final int SIZE = 18;
|
||||
|
||||
private ArrayList<IButtonClickEventListener> listeners = new ArrayList<IButtonClickEventListener>();
|
||||
private ButtonImage image = ButtonImage.BLANK;
|
||||
private boolean active = false;
|
||||
|
||||
public GuiImageButton(int id, int x, int y, ButtonImage image) {
|
||||
super(id, x, y, SIZE, SIZE, "");
|
||||
|
||||
this.image = image;
|
||||
}
|
||||
|
||||
public boolean IsActive()
|
||||
{
|
||||
return active;
|
||||
}
|
||||
|
||||
public void Activate()
|
||||
{
|
||||
active = true;
|
||||
}
|
||||
|
||||
public void DeActivate()
|
||||
{
|
||||
active = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft minecraft, int x, int y) {
|
||||
|
||||
if (!visible) {
|
||||
return;
|
||||
}
|
||||
|
||||
minecraft.renderEngine.bindTexture(ICON_BUTTON_TEXTURES);
|
||||
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
int buttonState = getButtonState(x, y);
|
||||
|
||||
drawTexturedModalRect(xPosition, yPosition, buttonState * SIZE, 0, SIZE, SIZE);
|
||||
|
||||
drawTexturedModalRect(xPosition + 1, yPosition + 1, image.getU(), image.getV(), SIZE - 2, SIZE - 2);
|
||||
|
||||
mouseDragged(minecraft, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mousePressed(Minecraft par1Minecraft, int par2, int par3) {
|
||||
boolean pressed = super.mousePressed(par1Minecraft, par2, par3);
|
||||
|
||||
if (pressed) {
|
||||
active = !active;
|
||||
notifyAllListeners();
|
||||
}
|
||||
|
||||
return pressed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerListener(IButtonClickEventListener listener) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListener(IButtonClickEventListener listener) {
|
||||
listeners.remove(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyAllListeners() {
|
||||
for (IButtonClickEventListener listener : listeners) {
|
||||
listener.handleButtonClick(this, this.id);
|
||||
}
|
||||
}
|
||||
|
||||
private int getButtonState(int mouseX, int mouseY) {
|
||||
if (!this.enabled) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (isMouseOverButton(mouseX, mouseY)) {
|
||||
if (!this.active) {
|
||||
return 2;
|
||||
}
|
||||
else {
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.active) {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isMouseOverButton(int mouseX, int mouseY) {
|
||||
return mouseX >= xPosition && mouseY >= yPosition && mouseX < xPosition + SIZE && mouseY < yPosition + SIZE;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
/**
|
||||
* Copyright (c) 2011-2014, 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.gui.buttons;
|
||||
|
||||
public interface IButtonClickEventListener {
|
||||
public void handleButtonClick(IButtonClickEventTrigger button, int buttonId);
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
/**
|
||||
* Copyright (c) 2011-2014, 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.gui.buttons;
|
||||
|
||||
public interface IButtonClickEventTrigger {
|
||||
public void registerListener(IButtonClickEventListener listener);
|
||||
public void removeListener(IButtonClickEventListener listener);
|
||||
public void notifyAllListeners();
|
||||
}
|
|
@ -8,13 +8,11 @@
|
|||
*/
|
||||
package buildcraft.energy;
|
||||
|
||||
import buildcraft.BuildCraftCore;
|
||||
import buildcraft.core.BlockBuildCraft;
|
||||
import buildcraft.core.CreativeTabBuildCraft;
|
||||
import buildcraft.core.ICustomHighlight;
|
||||
import buildcraft.core.IItemPipe;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import static net.minecraft.util.AxisAlignedBB.getBoundingBox;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
|
@ -31,11 +29,13 @@ import net.minecraft.util.Vec3;
|
|||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import static net.minecraft.util.AxisAlignedBB.getBoundingBox;
|
||||
import buildcraft.BuildCraftCore;
|
||||
import buildcraft.core.BlockBuildCraft;
|
||||
import buildcraft.core.CreativeTabBuildCraft;
|
||||
import buildcraft.core.ICustomHighlight;
|
||||
import buildcraft.core.IItemPipe;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockEngine extends BlockBuildCraft implements ICustomHighlight {
|
||||
|
||||
|
@ -121,7 +121,7 @@ public class BlockEngine extends BlockBuildCraft implements ICustomHighlight {
|
|||
@Override
|
||||
public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer player, int side, float par7, float par8, float par9) {
|
||||
|
||||
TileEngine tile = (TileEngine) world.getTileEntity(i, j, k);
|
||||
TileEntity tile = world.getTileEntity(i, j, k);
|
||||
|
||||
// REMOVED DUE TO CREATIVE ENGINE REQUIREMENTS - dmillerw
|
||||
// Drop through if the player is sneaking
|
||||
|
@ -137,7 +137,7 @@ public class BlockEngine extends BlockBuildCraft implements ICustomHighlight {
|
|||
}
|
||||
|
||||
if (tile instanceof TileEngine) {
|
||||
return tile.onBlockActivated(player, ForgeDirection.getOrientation(side));
|
||||
return ((TileEngine) tile).onBlockActivated(player, ForgeDirection.getOrientation(side));
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -204,11 +204,13 @@ public class BlockEngine extends BlockBuildCraft implements ICustomHighlight {
|
|||
|
||||
@Override
|
||||
public void onPostBlockPlaced(World world, int x, int y, int z, int par5) {
|
||||
TileEngine tile = (TileEngine) world.getTileEntity(x, y, z);
|
||||
tile.orientation = ForgeDirection.UP;
|
||||
|
||||
if (!tile.isOrientationValid()) {
|
||||
tile.switchOrientation(true);
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if (tile instanceof TileEngine) {
|
||||
TileEngine engine = (TileEngine)tile;
|
||||
engine.orientation = ForgeDirection.UP;
|
||||
if (!engine.isOrientationValid()) {
|
||||
engine.switchOrientation(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -220,9 +222,9 @@ public class BlockEngine extends BlockBuildCraft implements ICustomHighlight {
|
|||
@SuppressWarnings({"all"})
|
||||
@Override
|
||||
public void randomDisplayTick(World world, int i, int j, int k, Random random) {
|
||||
TileEngine tile = (TileEngine) world.getTileEntity(i, j, k);
|
||||
TileEntity tile = world.getTileEntity(i, j, k);
|
||||
|
||||
if (!tile.isBurning()) {
|
||||
if (tile instanceof TileEngine && !((TileEngine) tile).isBurning()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -252,10 +254,10 @@ public class BlockEngine extends BlockBuildCraft implements ICustomHighlight {
|
|||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
|
||||
TileEngine tile = (TileEngine) world.getTileEntity(x, y, z);
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
|
||||
if (tile != null) {
|
||||
tile.checkRedstonePower();
|
||||
if (tile instanceof TileEngine) {
|
||||
((TileEngine) tile).checkRedstonePower();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ import java.util.Set;
|
|||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockFlower;
|
||||
import net.minecraft.block.BlockStaticLiquid;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -260,7 +261,7 @@ public class OilPopulate {
|
|||
|
||||
private boolean isReplaceableFluid(World world, int x, int y, int z) {
|
||||
Block block = world.getBlock(x, y, z);
|
||||
return (block instanceof BlockFluidBase || block instanceof IFluidBlock) && block.getMaterial() != Material.lava;
|
||||
return (block instanceof BlockStaticLiquid || block instanceof BlockFluidBase || block instanceof IFluidBlock) && block.getMaterial() != Material.lava;
|
||||
}
|
||||
|
||||
private boolean isOil(World world, int x, int y, int z) {
|
||||
|
@ -357,6 +358,10 @@ public class OilPopulate {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (block instanceof BlockStaticLiquid) {
|
||||
return y;
|
||||
}
|
||||
|
||||
if (block instanceof BlockFluidBase) {
|
||||
return y;
|
||||
}
|
||||
|
|
|
@ -54,8 +54,9 @@ public class BlockQuarry extends BlockBuildCraft {
|
|||
|
||||
world.setBlockMetadataWithNotify(i, j, k, orientation.getOpposite().ordinal(), 1);
|
||||
if (entityliving instanceof EntityPlayer) {
|
||||
TileQuarry tq = (TileQuarry) world.getTileEntity(i, j, k);
|
||||
tq.placedBy = (EntityPlayer) entityliving;
|
||||
TileEntity tile = world.getTileEntity(i, j, k);
|
||||
if (tile instanceof TileQuarry)
|
||||
((TileQuarry) tile).placedBy = (EntityPlayer) entityliving;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -89,44 +89,47 @@ public class BlockTank extends BlockContainer {
|
|||
if (current != null) {
|
||||
FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(current);
|
||||
|
||||
TileTank tank = (TileTank) world.getTileEntity(i, j, k);
|
||||
TileEntity tile = world.getTileEntity(i, j, k);
|
||||
if(tile instanceof TileTank)
|
||||
{
|
||||
TileTank tank = (TileTank)tile;
|
||||
// Handle filled containers
|
||||
if (liquid != null) {
|
||||
int qty = tank.fill(ForgeDirection.UNKNOWN, liquid, true);
|
||||
|
||||
// Handle filled containers
|
||||
if (liquid != null) {
|
||||
int qty = tank.fill(ForgeDirection.UNKNOWN, liquid, true);
|
||||
if (qty != 0 && !BuildCraftCore.debugMode && !entityplayer.capabilities.isCreativeMode) {
|
||||
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, InvUtils.consumeItem(current));
|
||||
}
|
||||
|
||||
if (qty != 0 && !BuildCraftCore.debugMode && !entityplayer.capabilities.isCreativeMode) {
|
||||
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, InvUtils.consumeItem(current));
|
||||
}
|
||||
return true;
|
||||
|
||||
return true;
|
||||
// Handle empty containers
|
||||
} else {
|
||||
FluidStack available = tank.getTankInfo(ForgeDirection.UNKNOWN)[0].fluid;
|
||||
|
||||
// Handle empty containers
|
||||
} else {
|
||||
FluidStack available = tank.getTankInfo(ForgeDirection.UNKNOWN)[0].fluid;
|
||||
if (available != null) {
|
||||
ItemStack filled = FluidContainerRegistry.fillFluidContainer(available, current);
|
||||
|
||||
if (available != null) {
|
||||
ItemStack filled = FluidContainerRegistry.fillFluidContainer(available, current);
|
||||
liquid = FluidContainerRegistry.getFluidForFilledItem(filled);
|
||||
|
||||
liquid = FluidContainerRegistry.getFluidForFilledItem(filled);
|
||||
|
||||
if (liquid != null) {
|
||||
if (!BuildCraftCore.debugMode && !entityplayer.capabilities.isCreativeMode) {
|
||||
if (current.stackSize > 1) {
|
||||
if (!entityplayer.inventory.addItemStackToInventory(filled))
|
||||
return false;
|
||||
else {
|
||||
if (liquid != null) {
|
||||
if (!BuildCraftCore.debugMode && !entityplayer.capabilities.isCreativeMode) {
|
||||
if (current.stackSize > 1) {
|
||||
if (!entityplayer.inventory.addItemStackToInventory(filled)) {
|
||||
return false;
|
||||
} else {
|
||||
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, InvUtils.consumeItem(current));
|
||||
}
|
||||
} else {
|
||||
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, InvUtils.consumeItem(current));
|
||||
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, filled);
|
||||
}
|
||||
} else {
|
||||
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, InvUtils.consumeItem(current));
|
||||
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, filled);
|
||||
}
|
||||
|
||||
tank.drain(ForgeDirection.UNKNOWN, liquid.amount, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
tank.drain(ForgeDirection.UNKNOWN, liquid.amount, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1123,9 +1123,12 @@ public class BlockGenericPipe extends BlockBuildCraft {
|
|||
boolean placed = world.setBlock(i, j, k, block, meta, 3);
|
||||
|
||||
if (placed) {
|
||||
TileGenericPipe tile = (TileGenericPipe) world.getTileEntity(i, j, k);
|
||||
tile.initialize(pipe);
|
||||
tile.sendUpdateToClient();
|
||||
TileEntity tile = world.getTileEntity(i, j, k);
|
||||
if (tile instanceof TileGenericPipe) {
|
||||
TileGenericPipe tilePipe = (TileGenericPipe) tile;
|
||||
tilePipe.initialize(pipe);
|
||||
tilePipe.sendUpdateToClient();
|
||||
}
|
||||
}
|
||||
|
||||
return placed;
|
||||
|
|
|
@ -9,9 +9,11 @@
|
|||
package buildcraft.transport;
|
||||
|
||||
import buildcraft.transport.pipes.PipeFluidsCobblestone;
|
||||
import buildcraft.transport.pipes.PipeFluidsEmerald;
|
||||
import buildcraft.transport.pipes.PipeFluidsStone;
|
||||
import buildcraft.transport.pipes.PipeFluidsWood;
|
||||
import buildcraft.transport.pipes.PipeItemsCobblestone;
|
||||
import buildcraft.transport.pipes.PipeItemsEmerald;
|
||||
import buildcraft.transport.pipes.PipeItemsEmzuli;
|
||||
import buildcraft.transport.pipes.PipeItemsObsidian;
|
||||
import buildcraft.transport.pipes.PipeItemsQuartz;
|
||||
|
@ -33,11 +35,15 @@ public class PipeConnectionBans {
|
|||
banConnection(PipeFluidsStone.class, PipeFluidsCobblestone.class);
|
||||
|
||||
banConnection(PipeFluidsWood.class);
|
||||
|
||||
banConnection(PipeFluidsEmerald.class);
|
||||
|
||||
// Item Pipes
|
||||
banConnection(PipeItemsStone.class, PipeItemsCobblestone.class, PipeItemsQuartz.class);
|
||||
|
||||
banConnection(PipeItemsWood.class);
|
||||
|
||||
banConnection(PipeItemsEmerald.class);
|
||||
|
||||
banConnection(PipeItemsObsidian.class);
|
||||
|
||||
|
|
|
@ -337,7 +337,7 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler
|
|||
private void moveFluids() {
|
||||
short newTimeSlot = (short) (container.getWorldObj().getTotalWorldTime() % travelDelay);
|
||||
|
||||
short outputCount = computeCurrentConnectionStatesAndTickFlows(newTimeSlot);
|
||||
short outputCount = computeCurrentConnectionStatesAndTickFlows(newTimeSlot > 0 && newTimeSlot < travelDelay ? newTimeSlot : 0);
|
||||
moveFromPipe(outputCount);
|
||||
moveFromCenter(outputCount);
|
||||
moveToCenter();
|
||||
|
|
|
@ -33,12 +33,12 @@ public class ContainerEmeraldPipe extends BuildCraftContainer {
|
|||
|
||||
for (int l = 0; l < 3; l++) {
|
||||
for (int k1 = 0; k1 < 9; k1++) {
|
||||
addSlotToContainer(new Slot(playerInventory, k1 + l * 9 + 9, 8 + k1 * 18, 50 + l * 18));
|
||||
addSlotToContainer(new Slot(playerInventory, k1 + l * 9 + 9, 8 + k1 * 18, 79 + l * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (int i1 = 0; i1 < 9; i1++) {
|
||||
addSlotToContainer(new Slot(playerInventory, i1, 8 + i1 * 18, 108));
|
||||
addSlotToContainer(new Slot(playerInventory, i1, 8 + i1 * 18, 137));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,30 +15,42 @@ import org.lwjgl.opengl.GL11;
|
|||
|
||||
import buildcraft.core.DefaultProps;
|
||||
import buildcraft.core.gui.GuiBuildCraft;
|
||||
import buildcraft.core.gui.buttons.GuiMultiButton;
|
||||
import buildcraft.core.gui.buttons.GuiImageButton;
|
||||
import buildcraft.core.gui.buttons.IButtonClickEventTrigger;
|
||||
import buildcraft.core.gui.buttons.IButtonClickEventListener;
|
||||
import buildcraft.core.network.PacketGuiReturn;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
import buildcraft.core.utils.StringUtils;
|
||||
import buildcraft.transport.pipes.PipeItemsEmerald;
|
||||
import buildcraft.transport.pipes.PipeItemsEmerald.EmeraldPipeSettings;
|
||||
import buildcraft.transport.pipes.PipeItemsEmerald.FilterMode;
|
||||
|
||||
public class GuiEmeraldPipe extends GuiBuildCraft {
|
||||
public class GuiEmeraldPipe extends GuiBuildCraft implements IButtonClickEventListener {
|
||||
|
||||
private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/filter_2.png");
|
||||
private GuiMultiButton button;
|
||||
private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/pipe_emerald.png");
|
||||
|
||||
private static final int WHITE_LIST_BUTTON_ID = 1;
|
||||
private static final int BLACK_LIST_BUTTON_ID = 2;
|
||||
private static final int ROUND_ROBIN_BUTTON_ID = 3;
|
||||
|
||||
private GuiImageButton whiteListButton;
|
||||
private GuiImageButton blackListButton;
|
||||
private GuiImageButton roundRobinButton;
|
||||
|
||||
IInventory playerInventory;
|
||||
IInventory filterInventory;
|
||||
|
||||
PipeItemsEmerald pipe;
|
||||
|
||||
public GuiEmeraldPipe(IInventory playerInventory, PipeItemsEmerald pipe) {
|
||||
super(new ContainerEmeraldPipe(playerInventory, pipe), pipe.getFilters(), TEXTURE);
|
||||
|
||||
this.pipe = pipe;
|
||||
|
||||
this.playerInventory = playerInventory;
|
||||
this.filterInventory = pipe.getFilters();
|
||||
|
||||
xSize = 175;
|
||||
ySize = 132;
|
||||
ySize = 161;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -46,24 +58,74 @@ public class GuiEmeraldPipe extends GuiBuildCraft {
|
|||
super.initGui();
|
||||
|
||||
this.buttonList.clear();
|
||||
this.button = new GuiMultiButton(0, this.guiLeft + this.xSize - (80 + 6), this.guiTop + 34, 80, this.pipe.getStateController().copy());
|
||||
this.buttonList.add(this.button);
|
||||
|
||||
this.whiteListButton = new GuiImageButton(WHITE_LIST_BUTTON_ID, this.guiLeft + 7, this.guiTop + 41, GuiImageButton.ButtonImage.WHITE_LIST);
|
||||
this.whiteListButton.registerListener(this);
|
||||
this.buttonList.add(this.whiteListButton);
|
||||
|
||||
this.blackListButton = new GuiImageButton(BLACK_LIST_BUTTON_ID, this.guiLeft + 7 + 18, this.guiTop + 41, GuiImageButton.ButtonImage.BLACK_LIST);
|
||||
this.blackListButton.registerListener(this);
|
||||
this.buttonList.add(this.blackListButton);
|
||||
|
||||
this.roundRobinButton = new GuiImageButton(ROUND_ROBIN_BUTTON_ID, this.guiLeft + 7 + 36, this.guiTop + 41, GuiImageButton.ButtonImage.ROUND_ROBIN);
|
||||
this.roundRobinButton.registerListener(this);
|
||||
this.buttonList.add(this.roundRobinButton);
|
||||
|
||||
switch (pipe.getSettings().getFilterMode()) {
|
||||
case WHITE_LIST:
|
||||
this.whiteListButton.Activate();
|
||||
break;
|
||||
case BLACK_LIST:
|
||||
this.blackListButton.Activate();
|
||||
break;
|
||||
case ROUND_ROBIN:
|
||||
this.roundRobinButton.Activate();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
if (pipe.getWorld().isRemote) {
|
||||
pipe.getStateController().setCurrentState(button.getController().getCurrentState());
|
||||
PacketGuiReturn pkt = new PacketGuiReturn(pipe.getContainer());
|
||||
pkt.sendPacket();
|
||||
}
|
||||
|
||||
super.onGuiClosed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleButtonClick(IButtonClickEventTrigger sender, int buttonId) {
|
||||
switch (buttonId) {
|
||||
case WHITE_LIST_BUTTON_ID:
|
||||
whiteListButton.Activate();
|
||||
blackListButton.DeActivate();
|
||||
roundRobinButton.DeActivate();
|
||||
|
||||
pipe.getSettings().setFilterMode(FilterMode.WHITE_LIST);
|
||||
break;
|
||||
case BLACK_LIST_BUTTON_ID:
|
||||
whiteListButton.DeActivate();
|
||||
blackListButton.Activate();
|
||||
roundRobinButton.DeActivate();
|
||||
|
||||
pipe.getSettings().setFilterMode(FilterMode.BLACK_LIST);
|
||||
break;
|
||||
case ROUND_ROBIN_BUTTON_ID:
|
||||
whiteListButton.DeActivate();
|
||||
blackListButton.DeActivate();
|
||||
roundRobinButton.Activate();
|
||||
|
||||
pipe.getSettings().setFilterMode(FilterMode.ROUND_ROBIN);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
|
||||
fontRendererObj.drawString(filterInventory.getInventoryName(), getCenteredOffset(filterInventory.getInventoryName()), 6, 0x404040);
|
||||
String title = StringUtils.localize("gui.pipes.emerald.title");
|
||||
|
||||
fontRendererObj.drawString(title, (xSize - fontRendererObj.getStringWidth(title)) / 2, 6, 0x404040);
|
||||
fontRendererObj.drawString(StringUtils.localize("gui.inventory"), 8, ySize - 93, 0x404040);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,62 +12,58 @@ import io.netty.buffer.ByteBuf;
|
|||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import buildcraft.BuildCraftTransport;
|
||||
import buildcraft.core.GuiIds;
|
||||
import buildcraft.core.gui.buttons.IButtonTextureSet;
|
||||
import buildcraft.core.gui.buttons.IMultiButtonState;
|
||||
import buildcraft.core.gui.buttons.MultiButtonController;
|
||||
import buildcraft.core.gui.buttons.StandardButtonTextureSets;
|
||||
import buildcraft.core.gui.tooltips.ToolTip;
|
||||
import buildcraft.core.gui.tooltips.ToolTipLine;
|
||||
import buildcraft.core.inventory.InvUtils;
|
||||
import buildcraft.core.inventory.InventoryWrapper;
|
||||
import buildcraft.core.inventory.SimpleInventory;
|
||||
import buildcraft.core.inventory.StackHelper;
|
||||
import buildcraft.core.network.IClientState;
|
||||
import buildcraft.core.network.IGuiReturnHandler;
|
||||
import buildcraft.core.utils.StringUtils;
|
||||
import buildcraft.core.utils.Utils;
|
||||
import buildcraft.transport.BlockGenericPipe;
|
||||
import buildcraft.transport.PipeIconProvider;
|
||||
|
||||
public class PipeItemsEmerald extends PipeItemsWood implements IClientState, IGuiReturnHandler {
|
||||
|
||||
public static enum ButtonState implements IMultiButtonState {
|
||||
|
||||
BLOCKING("gui.pipes.emerald.blocking"), NONBLOCKING("gui.pipes.emerald.nonblocking");
|
||||
private final String label;
|
||||
|
||||
private ButtonState(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabel() {
|
||||
return StringUtils.localize(this.label);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IButtonTextureSet getTextureSet() {
|
||||
return StandardButtonTextureSets.SMALL_BUTTON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ToolTip getToolTip() {
|
||||
return this.tip;
|
||||
}
|
||||
private final ToolTip tip = new ToolTip(500) {
|
||||
@Override
|
||||
public void refresh() {
|
||||
clear();
|
||||
tip.add(new ToolTipLine(StringUtils.localize(label + ".tip")));
|
||||
}
|
||||
};
|
||||
public enum FilterMode {
|
||||
WHITE_LIST, BLACK_LIST, ROUND_ROBIN;
|
||||
}
|
||||
private final MultiButtonController stateController = MultiButtonController.getController(ButtonState.BLOCKING.ordinal(), ButtonState.values());
|
||||
|
||||
public class EmeraldPipeSettings {
|
||||
|
||||
private FilterMode filterMode;
|
||||
|
||||
public EmeraldPipeSettings() {
|
||||
filterMode = FilterMode.WHITE_LIST;
|
||||
}
|
||||
|
||||
public FilterMode getFilterMode() {
|
||||
return filterMode;
|
||||
}
|
||||
|
||||
public void setFilterMode(FilterMode mode) {
|
||||
filterMode = mode;
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
filterMode = FilterMode.values()[nbt.getByte("filterMode")];
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
nbt.setByte("filterMode", (byte) filterMode.ordinal());
|
||||
}
|
||||
}
|
||||
|
||||
private EmeraldPipeSettings settings = new EmeraldPipeSettings();
|
||||
|
||||
private final SimpleInventory filters = new SimpleInventory(9, "Filters", 1);
|
||||
|
||||
private int currentFilter = 0;
|
||||
|
||||
public PipeItemsEmerald(Item item) {
|
||||
|
@ -96,34 +92,100 @@ public class PipeItemsEmerald extends PipeItemsWood implements IClientState, IGu
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the itemstack that can be if something can be extracted from this
|
||||
* inventory, null if none. On certain cases, the extractable slot depends
|
||||
* on the position of the pipe.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack[] checkExtract(IInventory inventory, boolean doRemove, ForgeDirection from) {
|
||||
IInventory inv = InvUtils.getInventory(inventory);
|
||||
ItemStack result = checkExtractGeneric(inv, doRemove, from);
|
||||
|
||||
// check through every filter once if non-blocking
|
||||
if (doRemove
|
||||
&& stateController.getButtonState() == ButtonState.NONBLOCKING
|
||||
&& result == null) {
|
||||
int count = 1;
|
||||
while (result == null && count < filters.getSizeInventory()) {
|
||||
incrementFilter();
|
||||
result = checkExtractGeneric(inv, doRemove, from);
|
||||
count++;
|
||||
}
|
||||
if (inventory == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (result != null) {
|
||||
return new ItemStack[] { result };
|
||||
// Handle possible double chests and wrap it in the ISidedInventory interface.
|
||||
ISidedInventory sidedInventory = InventoryWrapper.getWrappedInventory(InvUtils.getInventory(inventory));
|
||||
|
||||
if (settings.getFilterMode() == FilterMode.ROUND_ROBIN) {
|
||||
return checkExtractRoundRobin(sidedInventory, doRemove, from);
|
||||
}
|
||||
|
||||
return checkExtractFiltered(sidedInventory, doRemove, from);
|
||||
}
|
||||
|
||||
private ItemStack[] checkExtractFiltered(ISidedInventory inventory, boolean doRemove, ForgeDirection from) {
|
||||
for (int k : inventory.getAccessibleSlotsFromSide(from.ordinal())) {
|
||||
ItemStack stack = inventory.getStackInSlot(k);
|
||||
|
||||
if (stack == null || stack.stackSize <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!inventory.canExtractItem(k, stack, from.ordinal())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean matches = isFiltered(stack);
|
||||
boolean isBlackList = settings.getFilterMode() == FilterMode.BLACK_LIST;
|
||||
|
||||
if ((isBlackList && matches) || (!isBlackList && !matches)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (doRemove) {
|
||||
double energyUsed = mjStored > stack.stackSize ? stack.stackSize : mjStored;
|
||||
mjStored -= energyUsed;
|
||||
|
||||
stack = inventory.decrStackSize(k, (int) Math.floor(energyUsed));
|
||||
}
|
||||
|
||||
return new ItemStack[]{ stack };
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private ItemStack[] checkExtractRoundRobin(ISidedInventory inventory, boolean doRemove, ForgeDirection from) {
|
||||
for (int i : inventory.getAccessibleSlotsFromSide(from.ordinal())) {
|
||||
ItemStack stack = inventory.getStackInSlot(i);
|
||||
|
||||
if (stack != null && stack.stackSize > 0) {
|
||||
ItemStack filter = getCurrentFilter();
|
||||
|
||||
if (filter == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!StackHelper.instance().isMatchingItem(filter, stack, true, false)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!inventory.canExtractItem(i, stack, from.ordinal())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (doRemove) {
|
||||
// In Round Robin mode, extract only 1 item regardless of power level.
|
||||
stack = inventory.decrStackSize(i, 1);
|
||||
incrementFilter();
|
||||
}
|
||||
|
||||
return new ItemStack[]{ stack };
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean isFiltered(ItemStack stack) {
|
||||
for (int i = 0; i < filters.getSizeInventory(); i++) {
|
||||
ItemStack filter = filters.getStackInSlot(i);
|
||||
|
||||
if (filter == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (StackHelper.instance().isMatchingItem(filter, stack, true, false)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void incrementFilter() {
|
||||
|
@ -143,56 +205,14 @@ public class PipeItemsEmerald extends PipeItemsWood implements IClientState, IGu
|
|||
return filters.getStackInSlot(currentFilter % filters.getSizeInventory());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack checkExtractGeneric(net.minecraft.inventory.ISidedInventory inventory, boolean doRemove, ForgeDirection from) {
|
||||
for (int i : inventory.getAccessibleSlotsFromSide(from.ordinal())) {
|
||||
ItemStack stack = inventory.getStackInSlot(i);
|
||||
if (stack != null && stack.stackSize > 0) {
|
||||
ItemStack filter = getCurrentFilter();
|
||||
if (filter == null) {
|
||||
return null;
|
||||
}
|
||||
if (!filter.isItemEqual(stack)) {
|
||||
continue;
|
||||
}
|
||||
if (!inventory.canExtractItem(i, stack, from.ordinal())) {
|
||||
continue;
|
||||
}
|
||||
if (doRemove) {
|
||||
incrementFilter();
|
||||
double energyUsed = mjStored > stack.stackSize ? stack.stackSize : mjStored;
|
||||
mjStored -= energyUsed;
|
||||
|
||||
return inventory.decrStackSize(i, (int) energyUsed);
|
||||
} else {
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
public IInventory getFilters() {
|
||||
return filters;
|
||||
}
|
||||
|
||||
/* SAVING & LOADING */
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
filters.readFromNBT(nbt);
|
||||
currentFilter = nbt.getInteger("currentFilter");
|
||||
|
||||
stateController.readFromNBT(nbt, "state");
|
||||
public EmeraldPipeSettings getSettings() {
|
||||
return settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
filters.writeToNBT(nbt);
|
||||
nbt.setInteger("currentFilter", currentFilter);
|
||||
|
||||
stateController.writeToNBT(nbt, "state");
|
||||
}
|
||||
|
||||
// ICLIENTSTATE
|
||||
@Override
|
||||
public void writeData(ByteBuf data) {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
|
@ -206,21 +226,33 @@ public class PipeItemsEmerald extends PipeItemsWood implements IClientState, IGu
|
|||
readFromNBT(nbt);
|
||||
}
|
||||
|
||||
public IInventory getFilters() {
|
||||
return filters;
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
|
||||
filters.readFromNBT(nbt);
|
||||
settings.readFromNBT(nbt);
|
||||
|
||||
currentFilter = nbt.getInteger("currentFilter");
|
||||
}
|
||||
|
||||
public MultiButtonController getStateController() {
|
||||
return stateController;
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
|
||||
filters.writeToNBT(nbt);
|
||||
settings.writeToNBT(nbt);
|
||||
|
||||
nbt.setInteger("currentFilter", currentFilter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeGuiData(ByteBuf data) {
|
||||
data.writeByte(stateController.getCurrentState());
|
||||
data.writeByte((byte)settings.getFilterMode().ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readGuiData(ByteBuf data, EntityPlayer sender) {
|
||||
stateController.setCurrentState(data.readByte());
|
||||
settings.setFilterMode(FilterMode.values()[data.readByte()]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue