Merge pull request #71 from asdflj/bookmark
add fluid auto filler & wireless fluid pattern terminal
No files matched your search
@@ -6,3 +6,4 @@ out/
|
||||
*.ipr
|
||||
*.iws
|
||||
run/
|
||||
build/
|
||||
@@ -1,4 +1,4 @@
|
||||
//version: 1675110695
|
||||
//version: 1675173326
|
||||
/*
|
||||
DO NOT CHANGE THIS FILE!
|
||||
Also, you may replace this file at any time if there is an update available.
|
||||
@@ -66,7 +66,7 @@ plugins {
|
||||
id 'com.diffplug.spotless' version '6.7.2' apply false
|
||||
id 'com.modrinth.minotaur' version '2.+' apply false
|
||||
id 'com.matthewprenger.cursegradle' version '1.4.0' apply false
|
||||
id 'com.gtnewhorizons.retrofuturagradle' version '1.1.2'
|
||||
id 'com.gtnewhorizons.retrofuturagradle' version '1.1.3'
|
||||
}
|
||||
boolean settingsupdated = verifySettingsGradle()
|
||||
settingsupdated = verifyGitAttributes() || settingsupdated
|
||||
@@ -743,6 +743,7 @@ idea {
|
||||
module {
|
||||
downloadJavadoc = true
|
||||
downloadSources = true
|
||||
inheritOutputDirs = true
|
||||
}
|
||||
project {
|
||||
settings {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
dependencies {
|
||||
compile('com.github.GTNewHorizons:NotEnoughItems:2.3.21-GTNH:dev')
|
||||
compile('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-148-GTNH-pre:dev')
|
||||
compile('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-149-GTNH:dev')
|
||||
compile('curse.maven:cofh-core-69162:2388751')
|
||||
compile('com.github.GTNewHorizons:waila:1.5.22:dev')
|
||||
compileOnly('com.github.GTNewHorizons:ExtraCells2:2.5.25:dev') { transitive = false }
|
||||
|
||||
@@ -28,7 +28,7 @@ import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
modid = FluidCraft.MODID,
|
||||
version = FluidCraft.VERSION,
|
||||
name = FluidCraft.MODNAME,
|
||||
dependencies = "required-after:appliedenergistics2;after:waila")
|
||||
dependencies = "required-after:appliedenergistics2;required-after:CoFHCore;after:waila")
|
||||
public class FluidCraft {
|
||||
|
||||
public static final String MODID = "GRADLETOKEN_MODID";
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.glodblock.github.client.gui;
|
||||
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import appeng.client.gui.AEBaseMEGui;
|
||||
import appeng.core.localization.GuiText;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidAutoFiller;
|
||||
import com.glodblock.github.common.tile.TileFluidAutoFiller;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
|
||||
public class GuiFluidAutoFiller extends AEBaseMEGui {
|
||||
|
||||
protected EntityPlayer player;
|
||||
private static final ResourceLocation TEX_BG = FluidCraft.resource("textures/gui/fluid_auto_filler.png");
|
||||
|
||||
public GuiFluidAutoFiller(InventoryPlayer ipl, TileFluidAutoFiller tile) {
|
||||
super(new ContainerFluidAutoFiller(ipl, tile));
|
||||
this.player = ipl.player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
|
||||
mc.getTextureManager().bindTexture(TEX_BG);
|
||||
drawTexturedModalRect(offsetX, offsetY, 0, 0, 176, ySize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
|
||||
fontRendererObj.drawString(getGuiDisplayName(I18n.format(NameConst.GUI_FLUID_AUTO_FILLER)), 8, 6, 0x404040);
|
||||
fontRendererObj.drawString(GuiText.inventory.getLocal(), 8, ySize - 94, 0x404040);
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,8 @@ import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
|
||||
import com.glodblock.github.common.parts.PartFluidTerminal;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.item.WirelessFluidTerminal;
|
||||
import com.glodblock.github.inventory.item.WirelessPatternTerminal;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import com.glodblock.github.util.Ae2ReflectClient;
|
||||
|
||||
@@ -34,7 +36,12 @@ public class GuiFluidPatternTerminalCraftingStatus extends GuiCraftingStatus {
|
||||
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL_EX, 1));
|
||||
else if (host instanceof PartFluidTerminal) {
|
||||
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.FLUID_TERM, 1));
|
||||
} else if (host instanceof WirelessFluidTerminal) {
|
||||
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.WIRELESS_FLUID_TERM, 1));
|
||||
} else if (host instanceof WirelessPatternTerminal) {
|
||||
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.WIRELESS_PATTERN_TERM, 1));
|
||||
}
|
||||
|
||||
super.initGui();
|
||||
originalGuiBtn = Ae2ReflectClient.getOriginalGuiButton(this);
|
||||
}
|
||||
@@ -46,6 +53,9 @@ public class GuiFluidPatternTerminalCraftingStatus extends GuiCraftingStatus {
|
||||
else if (host instanceof PartFluidPatternTerminalEx)
|
||||
InventoryHandler.switchGui(GuiType.FLUID_PATTERN_TERMINAL_EX);
|
||||
else if (host instanceof PartFluidTerminal) InventoryHandler.switchGui(GuiType.FLUID_TERMINAL);
|
||||
else if (host instanceof WirelessFluidTerminal) InventoryHandler.switchGui(GuiType.WIRELESS_FLUID_TERMINAL);
|
||||
else if (host instanceof WirelessPatternTerminal)
|
||||
InventoryHandler.switchGui(GuiType.WIRELESS_FLUID_PATTERN_TERMINAL);
|
||||
} else {
|
||||
super.actionPerformed(btn);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import appeng.container.slot.AppEngSlot;
|
||||
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidPortableCell;
|
||||
import com.glodblock.github.inventory.item.IFluidPortableCell;
|
||||
import com.glodblock.github.inventory.item.IWirelessTerminal;
|
||||
|
||||
public class GuiFluidPortableCell extends GuiFluidTerminal {
|
||||
|
||||
@@ -20,6 +21,10 @@ public class GuiFluidPortableCell extends GuiFluidTerminal {
|
||||
|
||||
@Override
|
||||
protected int getMaxRows() {
|
||||
return 3;
|
||||
if (this.container.getHost() instanceof IWirelessTerminal) {
|
||||
return super.getMaxRows();
|
||||
} else {
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.glodblock.github.client.gui;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import com.glodblock.github.inventory.item.IWirelessTerminal;
|
||||
|
||||
public class GuiPatternPortableCell extends GuiFluidPatternTerminal {
|
||||
|
||||
public GuiPatternPortableCell(InventoryPlayer inventoryPlayer, IWirelessTerminal te) {
|
||||
super(inventoryPlayer, te);
|
||||
}
|
||||
}
|
||||
@@ -88,7 +88,7 @@ public abstract class FCGuiEncodeTerminal extends GuiItemMonitor {
|
||||
FluidCraft.proxy.netHandler.sendToServer(
|
||||
new CPacketFluidPatternTermBtns(
|
||||
"PatternTerminal.Prioritize",
|
||||
container.prioritize ? PRIORITY_DISABLE : PRIORITY_ENABLE));
|
||||
isShiftKeyDown() ? "2" : (container.prioritize ? PRIORITY_DISABLE : PRIORITY_ENABLE)));
|
||||
} else if (this.invertBtn == btn) {
|
||||
FluidCraft.proxy.netHandler.sendToServer(
|
||||
new CPacketFluidPatternTermBtns("PatternTerminal.Invert", container.inverted ? "0" : "1"));
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.glodblock.github.client.gui.container;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.apache.commons.lang3.tuple.MutablePair;
|
||||
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.slot.SlotFake;
|
||||
|
||||
import com.glodblock.github.common.tile.TileFluidAutoFiller;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
public class ContainerFluidAutoFiller extends AEBaseContainer {
|
||||
|
||||
public static class FakeSlot extends SlotFake {
|
||||
|
||||
public FakeSlot(IInventory inv, int idx, int x, int y) {
|
||||
super(inv, idx, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStack(ItemStack is) {
|
||||
MutablePair<Boolean, ItemStack> result = ContainerFluidAutoFiller.isItemValid(is);
|
||||
if (result.left) {
|
||||
if (super.getHasStack()) super.clearStack();
|
||||
super.putStack(result.right);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final TileFluidAutoFiller tile;
|
||||
|
||||
public ContainerFluidAutoFiller(InventoryPlayer ipl, TileFluidAutoFiller tile) {
|
||||
super(ipl, tile);
|
||||
this.tile = tile;
|
||||
addSlotToContainer(new FakeSlot(tile.getInventory(), 0, 80, 35));
|
||||
bindPlayerInventory(ipl, 0, 84);
|
||||
}
|
||||
|
||||
public static MutablePair<Boolean, ItemStack> isItemValid(ItemStack itemStack) {
|
||||
boolean result = Util.FluidUtil.isFluidContainer(itemStack);
|
||||
if (!result) return new MutablePair<>(false, null);
|
||||
ItemStack tank = itemStack.copy();
|
||||
tank.stackSize = 1;
|
||||
if (Util.FluidUtil.isFilled(tank)) {
|
||||
return new MutablePair<>(true, Util.FluidUtil.clearFluid(tank));
|
||||
} else {
|
||||
return new MutablePair<>(true, tank);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
tile.updatePattern();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.glodblock.github.client.gui.container;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerMultiplier;
|
||||
import appeng.util.Platform;
|
||||
|
||||
import com.glodblock.github.inventory.item.IWirelessTerminal;
|
||||
|
||||
public class ContainerPatternPortableCell extends ContainerFluidPatternTerminal {
|
||||
|
||||
private double powerMultiplier = 0.5;
|
||||
private final IWirelessTerminal civ;
|
||||
private int ticks = 0;
|
||||
private final int slot;
|
||||
|
||||
public ContainerPatternPortableCell(InventoryPlayer ip, IWirelessTerminal monitorable) {
|
||||
super(ip, monitorable);
|
||||
if (monitorable != null) {
|
||||
final int slotIndex = monitorable.getInventorySlot();
|
||||
this.lockPlayerInventorySlot(slotIndex);
|
||||
this.slot = slotIndex;
|
||||
} else {
|
||||
this.slot = -1;
|
||||
this.lockPlayerInventorySlot(ip.currentItem);
|
||||
}
|
||||
this.civ = monitorable;
|
||||
}
|
||||
|
||||
public void detectAndSendChanges() {
|
||||
final ItemStack currentItem = this.slot < 0 ? this.getPlayerInv().getCurrentItem()
|
||||
: this.getPlayerInv().getStackInSlot(this.slot);
|
||||
if (this.civ != null) {
|
||||
if (currentItem != this.civ.getItemStack()) {
|
||||
if (currentItem != null) {
|
||||
if (Platform.isSameItem(this.civ.getItemStack(), currentItem)) {
|
||||
this.getPlayerInv()
|
||||
.setInventorySlotContents(this.getPlayerInv().currentItem, this.civ.getItemStack());
|
||||
} else {
|
||||
this.setValidContainer(false);
|
||||
}
|
||||
} else {
|
||||
this.setValidContainer(false);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.setValidContainer(false);
|
||||
}
|
||||
this.ticks++;
|
||||
if (this.ticks > 10 && this.civ != null) {
|
||||
this.civ.extractAEPower(
|
||||
this.getPowerMultiplier() * this.ticks,
|
||||
Actionable.MODULATE,
|
||||
PowerMultiplier.CONFIG);
|
||||
this.ticks = 0;
|
||||
}
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
|
||||
private double getPowerMultiplier() {
|
||||
return this.powerMultiplier;
|
||||
}
|
||||
|
||||
void setPowerMultiplier(final double powerMultiplier) {
|
||||
this.powerMultiplier = powerMultiplier;
|
||||
}
|
||||
}
|
||||
@@ -36,8 +36,8 @@ import com.glodblock.github.client.gui.container.ContainerItemMonitor;
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import com.glodblock.github.common.item.ItemFluidEncodedPattern;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.common.parts.base.FCFluidEncodeTerminal;
|
||||
import com.glodblock.github.inventory.IPatternConsumer;
|
||||
import com.glodblock.github.inventory.item.PatternTerminal;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import com.glodblock.github.util.FluidPatternDetails;
|
||||
import com.glodblock.github.util.Util;
|
||||
@@ -45,7 +45,7 @@ import com.glodblock.github.util.Util;
|
||||
public abstract class FCContainerEncodeTerminal extends ContainerItemMonitor
|
||||
implements IAEAppEngInventory, IOptionalSlotHost, IContainerCraftingPacket, IPatternConsumer {
|
||||
|
||||
protected final FCFluidEncodeTerminal patternTerminal;
|
||||
protected final PatternTerminal patternTerminal;
|
||||
protected final AppEngInternalInventory cOut = new AppEngInternalInventory(null, 1);
|
||||
protected final IInventory crafting;
|
||||
protected final SlotRestrictedInput patternSlotIN;
|
||||
@@ -77,7 +77,7 @@ public abstract class FCContainerEncodeTerminal extends ContainerItemMonitor
|
||||
|
||||
public FCContainerEncodeTerminal(final InventoryPlayer ip, final ITerminalHost monitorable) {
|
||||
super(ip, monitorable);
|
||||
this.patternTerminal = (FCFluidEncodeTerminal) monitorable;
|
||||
this.patternTerminal = (PatternTerminal) monitorable;
|
||||
this.inverted = patternTerminal.isInverted();
|
||||
final IInventory patternInv = this.patternTerminal.getInventoryByName("pattern");
|
||||
this.crafting = this.patternTerminal.getInventoryByName("crafting");
|
||||
@@ -170,7 +170,7 @@ public abstract class FCContainerEncodeTerminal extends ContainerItemMonitor
|
||||
}
|
||||
}
|
||||
|
||||
public FCFluidEncodeTerminal getPatternTerminal() {
|
||||
public PatternTerminal getPatternTerminal() {
|
||||
return this.patternTerminal;
|
||||
}
|
||||
|
||||
@@ -368,13 +368,11 @@ public abstract class FCContainerEncodeTerminal extends ContainerItemMonitor
|
||||
for (final ItemStack encodedPatternStack : AEApi.instance().definitions().items().encodedPattern()
|
||||
.maybeStack(1).asSet()) {
|
||||
output = encodedPatternStack;
|
||||
this.patternSlotOUT.putStack(output);
|
||||
}
|
||||
} else if (output.getItem() instanceof ItemFluidEncodedPattern) {
|
||||
for (final ItemStack encodedPatternStack : AEApi.instance().definitions().items().encodedPattern()
|
||||
.maybeStack(1).asSet()) {
|
||||
output = encodedPatternStack;
|
||||
this.patternSlotOUT.putStack(output);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -399,6 +397,7 @@ public abstract class FCContainerEncodeTerminal extends ContainerItemMonitor
|
||||
encodedValue.setBoolean("beSubstitute", this.beSubstitute);
|
||||
encodedValue.setBoolean("prioritize", this.prioritize);
|
||||
output.setTagCompound(encodedValue);
|
||||
this.patternSlotOUT.putStack(output);
|
||||
}
|
||||
|
||||
protected ItemStack[] getInputs() {
|
||||
|
||||
@@ -32,6 +32,8 @@ import appeng.util.ConfigManager;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
import appeng.util.Platform;
|
||||
|
||||
import com.glodblock.github.inventory.item.IWirelessTerminal;
|
||||
|
||||
public abstract class FCContainerMonitor<T extends IAEStack<T>> extends AEBaseContainer
|
||||
implements IConfigManagerHost, IConfigurableObject, IMEMonitorHandlerReceiver<T> {
|
||||
|
||||
@@ -98,6 +100,7 @@ public abstract class FCContainerMonitor<T extends IAEStack<T>> extends AEBaseCo
|
||||
this.updatePowerStatus();
|
||||
final boolean oldAccessible = this.canAccessViewCells;
|
||||
this.canAccessViewCells = this.host instanceof WirelessTerminalGuiObject
|
||||
|| this.host instanceof IWirelessTerminal
|
||||
|| this.hasAccess(SecurityPermissions.BUILD, false);
|
||||
if (this.canAccessViewCells != oldAccessible) {
|
||||
for (int y = 0; y < 5; y++) {
|
||||
@@ -214,4 +217,8 @@ public abstract class FCContainerMonitor<T extends IAEStack<T>> extends AEBaseCo
|
||||
this.getGui().updateSetting(manager, settingName, newValue);
|
||||
}
|
||||
}
|
||||
|
||||
public ITerminalHost getHost() {
|
||||
return this.host;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package com.glodblock.github.client.render;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.render.tank.ModelCertusTank;
|
||||
import com.glodblock.github.common.tile.TileCertusQuartzTank;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
|
||||
public class ItemCertusQuartzTankRender implements IItemRenderer {
|
||||
|
||||
private final ModelCertusTank model = new ModelCertusTank();
|
||||
|
||||
public ItemCertusQuartzTankRender() {
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileCertusQuartzTank.class, new RenderBlockCertusQuartzTank());
|
||||
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ItemAndBlockHolder.CERTUS_QUARTZ_TANK), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
|
||||
return type != ItemRenderType.EQUIPPED_FIRST_PERSON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
|
||||
Minecraft.getMinecraft().renderEngine
|
||||
.bindTexture(FluidCraft.resource("textures/blocks/certus_quartz_tank/map.png"));
|
||||
GL11.glPushMatrix();
|
||||
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
|
||||
GL11.glScalef(1, -1, -1);
|
||||
this.model.render(0.0625f);
|
||||
GL11.glScalef(1, -1, 1);
|
||||
this.model.render(0.0625f);
|
||||
|
||||
if (item != null && item.hasTagCompound()) {
|
||||
FluidStack storedFluid = FluidStack
|
||||
.loadFluidStackFromNBT(item.getTagCompound().getCompoundTag("tileEntity"));
|
||||
int tankCapacity = 32000;
|
||||
|
||||
if (storedFluid != null && storedFluid.getFluid() != null) {
|
||||
IIcon fluidIcon = storedFluid.getFluid().getIcon();
|
||||
if (fluidIcon == null) fluidIcon = FluidRegistry.LAVA.getIcon();
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
RenderBlocks renderer = new RenderBlocks();
|
||||
GL11.glScalef(1, 1, -1);
|
||||
renderer.setRenderBounds(
|
||||
0.08F,
|
||||
0.001F,
|
||||
0.08F,
|
||||
0.92F,
|
||||
(float) storedFluid.amount / (float) tankCapacity * 0.999F,
|
||||
0.92F);
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
|
||||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
Block waterBlock = FluidRegistry.WATER.getBlock();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setColorRGBA_F(
|
||||
(storedFluid.getFluid().getColor() >> 16 & 0xFF) / 255.0F,
|
||||
(storedFluid.getFluid().getColor() >> 8 & 0xFF) / 255.0F,
|
||||
(storedFluid.getFluid().getColor() & 0xFF) / 255.0F,
|
||||
1.0F);
|
||||
tessellator.setNormal(0.0F, -1F, 0.0F);
|
||||
renderer.renderFaceYNeg(waterBlock, 0.0D, 0.0D, 0.0D, fluidIcon);
|
||||
tessellator.setNormal(0.0F, 1.0F, 0.0F);
|
||||
renderer.renderFaceYPos(waterBlock, 0.0D, 0.0D, 0.0D, fluidIcon);
|
||||
tessellator.setNormal(0.0F, 0.0F, -1F);
|
||||
renderer.renderFaceZNeg(waterBlock, 0.0D, 0.0D, 0.0D, fluidIcon);
|
||||
tessellator.setNormal(0.0F, 0.0F, 1.0F);
|
||||
renderer.renderFaceZPos(waterBlock, 0.0D, 0.0D, 0.0D, fluidIcon);
|
||||
tessellator.setNormal(-1F, 0.0F, 0.0F);
|
||||
renderer.renderFaceXNeg(waterBlock, 0.0D, 0.0D, 0.0D, fluidIcon);
|
||||
tessellator.setNormal(1.0F, 0.0F, 0.0F);
|
||||
renderer.renderFaceXPos(waterBlock, 0.0D, 0.0D, 0.0D, fluidIcon);
|
||||
tessellator.draw();
|
||||
}
|
||||
}
|
||||
GL11.glPopAttrib();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
@@ -27,25 +27,19 @@ public class ItemWalrusRender implements IItemRenderer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, IItemRenderer.ItemRenderType type) {
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem(IItemRenderer.ItemRenderType type, ItemStack item, Object... data) {
|
||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(this.textureWalrus);
|
||||
GL11.glPushMatrix();
|
||||
switch (type) {
|
||||
case ENTITY:
|
||||
break;
|
||||
case EQUIPPED:
|
||||
break;
|
||||
case EQUIPPED_FIRST_PERSON:
|
||||
GL11.glRotated(180, 0, 1, 0);
|
||||
GL11.glTranslatef(-1F, 0.5F, -0.5F);
|
||||
break;
|
||||
case FIRST_PERSON_MAP:
|
||||
break;
|
||||
case INVENTORY:
|
||||
GL11.glTranslatef(-0.5F, -0.5F, -0.1F);
|
||||
break;
|
||||
@@ -57,8 +51,7 @@ public class ItemWalrusRender implements IItemRenderer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper(IItemRenderer.ItemRenderType type, ItemStack item,
|
||||
IItemRenderer.ItemRendererHelper helper) {
|
||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, IItemRenderer.ItemRendererHelper helper) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.glodblock.github.client.render;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.glodblock.github.client.render.tank.FluidTankRenderer;
|
||||
import com.glodblock.github.common.tile.TileCertusQuartzTank;
|
||||
import com.glodblock.github.util.RenderUtil;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
public class RenderBlockCertusQuartzTank extends TileEntitySpecialRenderer {
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) {
|
||||
TileCertusQuartzTank tank = (TileCertusQuartzTank) tileentity;
|
||||
|
||||
FluidStack liquid = tank.tank.getFluid();
|
||||
if (liquid == null || liquid.getFluid() == null || liquid.amount <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
int color = liquid.getFluid().getColor(liquid);
|
||||
|
||||
int[] displayList = FluidTankRenderer.getFluidDisplayLists(liquid, tileentity.getWorldObj(), false);
|
||||
if (displayList == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
bindTexture(TextureMap.locationBlocksTexture);
|
||||
RenderUtil.setGLColorFromInt(color);
|
||||
|
||||
GL11.glTranslatef((float) x + 0.0625F, (float) y + 0.5F, (float) z + 0.0625F);
|
||||
GL11.glScalef(0.875F, 0.99F, 0.875F);
|
||||
GL11.glTranslatef(0, -0.5F, 0);
|
||||
|
||||
int dl = (int) ((float) liquid.amount / (float) (tank.tank.getCapacity())
|
||||
* (FluidTankRenderer.DISPLAY_STAGES - 1));
|
||||
GL11.glCallList(displayList[Util.clamp(dl, 0, FluidTankRenderer.DISPLAY_STAGES - 1)]);
|
||||
|
||||
GL11.glPopAttrib();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
package com.glodblock.github.client.render.tank;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GLAllocation;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.glodblock.github.util.RenderUtil;
|
||||
|
||||
public class FluidTankRenderer {
|
||||
|
||||
public static final int DISPLAY_STAGES = 100;
|
||||
private static final Map<Fluid, int[]> flowingRenderCache = new HashMap<>();
|
||||
private static final Map<Fluid, int[]> stillRenderCache = new HashMap<>();
|
||||
private static final RenderEntityBlock.RenderInfo liquidBlock = new RenderEntityBlock.RenderInfo();
|
||||
|
||||
public static void onTextureReload() {
|
||||
for (int[] ia : flowingRenderCache.values()) {
|
||||
for (int i : ia) {
|
||||
GL11.glDeleteLists(i, 1);
|
||||
}
|
||||
}
|
||||
flowingRenderCache.clear();
|
||||
|
||||
for (int[] ia : stillRenderCache.values()) {
|
||||
for (int i : ia) {
|
||||
GL11.glDeleteLists(i, 1);
|
||||
}
|
||||
}
|
||||
stillRenderCache.clear();
|
||||
}
|
||||
|
||||
public static IIcon getFluidTexture(FluidStack fluidStack, boolean flowing) {
|
||||
if (fluidStack == null) {
|
||||
return null;
|
||||
}
|
||||
return getFluidTexture(fluidStack.getFluid(), flowing);
|
||||
}
|
||||
|
||||
public static IIcon getFluidTexture(Fluid fluid, boolean flowing) {
|
||||
if (fluid == null) {
|
||||
return null;
|
||||
}
|
||||
IIcon icon = flowing ? fluid.getFlowingIcon() : fluid.getStillIcon();
|
||||
if (icon == null) {
|
||||
icon = ((TextureMap) Minecraft.getMinecraft().getTextureManager()
|
||||
.getTexture(TextureMap.locationBlocksTexture)).getAtlasSprite("missingno");
|
||||
}
|
||||
return icon;
|
||||
}
|
||||
|
||||
public static void setColorForFluidStack(FluidStack fluidstack) {
|
||||
if (fluidstack == null) {
|
||||
return;
|
||||
}
|
||||
int color = fluidstack.getFluid().getColor(fluidstack);
|
||||
RenderUtil.setGLColorFromInt(color);
|
||||
}
|
||||
|
||||
public static int[] getFluidDisplayLists(FluidStack fluidStack, World world, boolean flowing) {
|
||||
if (fluidStack == null) {
|
||||
return null;
|
||||
}
|
||||
Fluid fluid = fluidStack.getFluid();
|
||||
if (fluid == null) {
|
||||
return null;
|
||||
}
|
||||
Map<Fluid, int[]> cache = flowing ? flowingRenderCache : stillRenderCache;
|
||||
int[] diplayLists = cache.get(fluid);
|
||||
if (diplayLists != null) {
|
||||
return diplayLists;
|
||||
}
|
||||
|
||||
diplayLists = new int[DISPLAY_STAGES];
|
||||
|
||||
if (fluid.getBlock() != null) {
|
||||
liquidBlock.baseBlock = fluid.getBlock();
|
||||
} else {
|
||||
liquidBlock.baseBlock = Blocks.water;
|
||||
}
|
||||
liquidBlock.texture = getFluidTexture(fluidStack, flowing);
|
||||
|
||||
cache.put(fluid, diplayLists);
|
||||
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glDisable(GL11.GL_CULL_FACE);
|
||||
|
||||
for (int s = 0; s < DISPLAY_STAGES; ++s) {
|
||||
diplayLists[s] = GLAllocation.generateDisplayLists(1);
|
||||
GL11.glNewList(diplayLists[s], 4864 /* GL_COMPILE */);
|
||||
|
||||
liquidBlock.minX = 0.01f;
|
||||
liquidBlock.minY = 0;
|
||||
liquidBlock.minZ = 0.01f;
|
||||
|
||||
liquidBlock.maxX = 0.99f;
|
||||
liquidBlock.maxY = Math.max(s, 1) / (float) DISPLAY_STAGES;
|
||||
liquidBlock.maxZ = 0.99f;
|
||||
|
||||
RenderEntityBlock.INSTANCE.renderBlock(liquidBlock);
|
||||
GL11.glEndList();
|
||||
}
|
||||
|
||||
GL11.glColor4f(1, 1, 1, 1);
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
|
||||
return diplayLists;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
package com.glodblock.github.client.render.tank;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.glodblock.github.common.tile.TileCertusQuartzTank;
|
||||
|
||||
public class ModelCertusTank extends ModelBase {
|
||||
|
||||
ModelRenderer Shape1;
|
||||
|
||||
public ModelCertusTank() {
|
||||
this.textureWidth = 64;
|
||||
this.textureHeight = 64;
|
||||
|
||||
this.Shape1 = new ModelRenderer(this, 0, 0);
|
||||
this.Shape1.addBox(0F, 0F, 0F, 14, 16, 14);
|
||||
this.Shape1.setRotationPoint(-7F, -8F, -7F);
|
||||
this.Shape1.setTextureSize(this.textureWidth, this.textureHeight);
|
||||
this.Shape1.mirror = true;
|
||||
setRotation(this.Shape1, 0F, 0F, 0F);
|
||||
|
||||
}
|
||||
|
||||
public void render(float f) {
|
||||
this.Shape1.render(f);
|
||||
}
|
||||
|
||||
public void renderFluid(TileEntity tileEntity, double x, double y, double z, RenderBlocks renderer) {
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
if (tileEntity != null
|
||||
&& ((TileCertusQuartzTank) tileEntity).getTankInfo(ForgeDirection.UNKNOWN)[0].fluid != null) {
|
||||
Fluid storedFluid = ((TileCertusQuartzTank) tileEntity).getRenderFluid();
|
||||
float scale = ((TileCertusQuartzTank) tileEntity).getRenderScale();
|
||||
if (storedFluid != null && scale > 0) {
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
Block id = Block.getBlockById(FluidRegistry.WATER.getID());
|
||||
IIcon fluidIcon = storedFluid.getIcon();
|
||||
if (fluidIcon == null) fluidIcon = FluidRegistry.LAVA.getIcon();
|
||||
renderer.setRenderBounds(0.08F, 0.001F, 0.08F, 0.92, scale * 0.999F, 0.92F);
|
||||
tessellator.setColorRGBA_F(
|
||||
(storedFluid.getColor() >> 16 & 0xFF) / 255.0F,
|
||||
(storedFluid.getColor() >> 8 & 0xFF) / 255.0F,
|
||||
(storedFluid.getColor() & 0xFF) / 255.0F,
|
||||
1.0F);
|
||||
tessellator.setNormal(0.0F, -1F, 0.0F);
|
||||
renderer.renderFaceYNeg(id, x, y, z, fluidIcon);
|
||||
tessellator.setNormal(0.0F, 1.0F, 0.0F);
|
||||
renderer.renderFaceYPos(id, x, y, z, fluidIcon);
|
||||
tessellator.setNormal(0.0F, 0.0F, -1F);
|
||||
renderer.renderFaceZNeg(id, x, y, z, fluidIcon);
|
||||
tessellator.setNormal(0.0F, 0.0F, 1.0F);
|
||||
renderer.renderFaceZPos(id, x, y, z, fluidIcon);
|
||||
tessellator.setNormal(-1F, 0.0F, 0.0F);
|
||||
renderer.renderFaceXNeg(id, x, y, z, fluidIcon);
|
||||
tessellator.setNormal(1.0F, 0.0F, 0.0F);
|
||||
renderer.renderFaceXPos(id, x, y, z, fluidIcon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void renderInnerBlock(Block block, int x, int y, int z, RenderBlocks renderer, IBlockAccess world) {
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
tessellator.setBrightness(15728640);
|
||||
boolean tankUp = world.getTileEntity(x, y + 1, z) instanceof TileCertusQuartzTank;
|
||||
boolean tankDown = world.getTileEntity(x, y - 1, z) instanceof TileCertusQuartzTank;
|
||||
int meta = 0;
|
||||
if (tankUp && tankDown) meta = 3;
|
||||
else if (tankUp) meta = 2;
|
||||
else if (tankDown) meta = 1;
|
||||
if (!tankUp) {
|
||||
tessellator.setNormal(0, -1, 0);
|
||||
renderer.renderFaceYNeg(block, x, y + 0.99F, z, block.getIcon(1, 0));
|
||||
}
|
||||
if (!tankDown) {
|
||||
tessellator.setNormal(0, 1, 0);
|
||||
renderer.renderFaceYPos(block, x, y - 0.99F, z, block.getIcon(0, 0));
|
||||
}
|
||||
IIcon sideIcon = block.getIcon(3, meta);
|
||||
tessellator.setNormal(0, 0, -1);
|
||||
renderer.renderFaceZNeg(block, x, y, z + 0.875F, sideIcon);
|
||||
tessellator.setNormal(0, 0, 1);
|
||||
renderer.renderFaceZPos(block, x, y, z - 0.875F, sideIcon);
|
||||
tessellator.setNormal(-1, 0, 0);
|
||||
renderer.renderFaceXNeg(block, x + 0.875F, y, z, sideIcon);
|
||||
tessellator.setNormal(1, 0, 0);
|
||||
renderer.renderFaceXPos(block, x - 0.875F, y, z, sideIcon);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public void renderOuterBlock(Block block, int x, int y, int z, RenderBlocks renderer, IBlockAccess world) {
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
boolean tankUp = world.getTileEntity(x, y + 1, z) instanceof TileCertusQuartzTank;
|
||||
boolean tankDown = world.getTileEntity(x, y - 1, z) instanceof TileCertusQuartzTank;
|
||||
int meta = 0;
|
||||
if (tankUp && tankDown) meta = 3;
|
||||
else if (tankUp) meta = 2;
|
||||
else if (tankDown) meta = 1;
|
||||
if (!tankDown) {
|
||||
tessellator.setNormal(0.0F, -1F, 0.0F);
|
||||
renderer.renderFaceYNeg(block, x, y, z, block.getIcon(0, 0));
|
||||
}
|
||||
if (!tankUp) {
|
||||
tessellator.setNormal(0.0F, 1.0F, 0.0F);
|
||||
renderer.renderFaceYPos(block, x, y, z, block.getIcon(1, 0));
|
||||
}
|
||||
|
||||
IIcon sideIcon = block.getIcon(3, meta);
|
||||
tessellator.setNormal(0.0F, 0.0F, -1F);
|
||||
renderer.renderFaceZNeg(block, x, y, z, sideIcon);
|
||||
tessellator.setNormal(0.0F, 0.0F, 1.0F);
|
||||
renderer.renderFaceZPos(block, x, y, z, sideIcon);
|
||||
tessellator.setNormal(-1F, 0.0F, 0.0F);
|
||||
renderer.renderFaceXNeg(block, x, y, z, sideIcon);
|
||||
tessellator.setNormal(1.0F, 0.0F, 0.0F);
|
||||
renderer.renderFaceXPos(block, x, y, z, sideIcon);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
private void setRotation(ModelRenderer model, float x, float y, float z) {
|
||||
model.rotateAngleX = x;
|
||||
model.rotateAngleY = y;
|
||||
model.rotateAngleZ = z;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
package com.glodblock.github.client.render.tank;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.Render;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.EnumSkyBlock;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class RenderEntityBlock extends Render {
|
||||
|
||||
public static RenderEntityBlock INSTANCE = new RenderEntityBlock();
|
||||
protected RenderBlocks renderBlocks;
|
||||
|
||||
private RenderEntityBlock() {
|
||||
renderBlocks = field_147909_c;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ResourceLocation getEntityTexture(Entity entity) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public static class RenderInfo {
|
||||
|
||||
public double minX = 0.0F;
|
||||
public double minY = 0.0F;
|
||||
public double minZ = 0.0F;
|
||||
public double maxX = 1.0F;
|
||||
public double maxY = 1.0F;
|
||||
public double maxZ = 1.0F;
|
||||
public Block baseBlock = Blocks.sand;
|
||||
public IIcon texture = null;
|
||||
public IIcon[] textureArray = null;
|
||||
public boolean[] renderSide = new boolean[] { true, true, true, true, true, true };
|
||||
public int light = -1;
|
||||
public int brightness = -1;
|
||||
|
||||
public RenderInfo() {}
|
||||
|
||||
public RenderInfo(Block template, IIcon[] texture) {
|
||||
this();
|
||||
this.baseBlock = template;
|
||||
this.textureArray = texture;
|
||||
}
|
||||
|
||||
public RenderInfo(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) {
|
||||
this();
|
||||
setBounds(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
}
|
||||
|
||||
public void setSkyBlockLight(World world, int x, int y, int z, int light) {
|
||||
this.brightness = world.getSkyBlockTypeBrightness(EnumSkyBlock.Sky, x, y, z) << 16 | light;
|
||||
}
|
||||
|
||||
public float getBlockBrightness(IBlockAccess iblockaccess, int i, int j, int k) {
|
||||
return baseBlock.getMixedBrightnessForBlock(iblockaccess, i, j, k);
|
||||
}
|
||||
|
||||
public final void setBounds(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) {
|
||||
this.minX = minX;
|
||||
this.minY = minY;
|
||||
this.minZ = minZ;
|
||||
this.maxX = maxX;
|
||||
this.maxY = maxY;
|
||||
this.maxZ = maxZ;
|
||||
}
|
||||
|
||||
public final void setRenderSingleSide(int side) {
|
||||
Arrays.fill(renderSide, false);
|
||||
renderSide[side] = true;
|
||||
}
|
||||
|
||||
public final void setRenderAllSides() {
|
||||
Arrays.fill(renderSide, true);
|
||||
}
|
||||
|
||||
public void rotate() {
|
||||
double temp = minX;
|
||||
minX = minZ;
|
||||
minZ = temp;
|
||||
|
||||
temp = maxX;
|
||||
maxX = maxZ;
|
||||
maxZ = temp;
|
||||
}
|
||||
|
||||
public void reverseX() {
|
||||
double temp = minX;
|
||||
minX = 1 - maxX;
|
||||
maxX = 1 - temp;
|
||||
}
|
||||
|
||||
public void reverseZ() {
|
||||
double temp = minZ;
|
||||
minZ = 1 - maxZ;
|
||||
maxZ = 1 - temp;
|
||||
}
|
||||
|
||||
public IIcon getBlockTextureFromSide(int i) {
|
||||
if (texture != null) {
|
||||
return texture;
|
||||
}
|
||||
|
||||
int index = i;
|
||||
|
||||
if (textureArray == null || textureArray.length == 0) {
|
||||
return baseBlock.getBlockTextureFromSide(index);
|
||||
} else {
|
||||
if (index >= textureArray.length) {
|
||||
index = 0;
|
||||
}
|
||||
|
||||
return textureArray[index];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doRender(Entity entity, double x, double y, double z, float f, float f1) {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
public void renderBlock(RenderInfo info) {
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
|
||||
renderBlocks.setRenderBounds(info.minX, info.minY, info.minZ, info.maxX, info.maxY, info.maxZ);
|
||||
|
||||
if (info.light != -1) {
|
||||
tessellator.setBrightness(info.light << 20 | info.light << 4);
|
||||
} else if (info.brightness != -1) {
|
||||
tessellator.setBrightness(info.brightness << 4);
|
||||
}
|
||||
|
||||
if (info.renderSide[0]) {
|
||||
tessellator.setNormal(0, -1, 0);
|
||||
renderBlocks.renderFaceYNeg(info.baseBlock, 0, 0, 0, info.getBlockTextureFromSide(0));
|
||||
}
|
||||
if (info.renderSide[1]) {
|
||||
tessellator.setNormal(0, 1, 0);
|
||||
renderBlocks.renderFaceYPos(info.baseBlock, 0, 0, 0, info.getBlockTextureFromSide(1));
|
||||
}
|
||||
if (info.renderSide[2]) {
|
||||
tessellator.setNormal(0, 0, -1);
|
||||
renderBlocks.renderFaceZNeg(info.baseBlock, 0, 0, 0, info.getBlockTextureFromSide(2));
|
||||
}
|
||||
if (info.renderSide[3]) {
|
||||
tessellator.setNormal(0, 0, 1);
|
||||
renderBlocks.renderFaceZPos(info.baseBlock, 0, 0, 0, info.getBlockTextureFromSide(3));
|
||||
}
|
||||
if (info.renderSide[4]) {
|
||||
tessellator.setNormal(-1, 0, 0);
|
||||
renderBlocks.renderFaceXNeg(info.baseBlock, 0, 0, 0, info.getBlockTextureFromSide(4));
|
||||
}
|
||||
if (info.renderSide[5]) {
|
||||
tessellator.setNormal(1, 0, 0);
|
||||
renderBlocks.renderFaceXPos(info.baseBlock, 0, 0, 0, info.getBlockTextureFromSide(5));
|
||||
}
|
||||
tessellator.draw();
|
||||
}
|
||||
}
|
||||
@@ -9,10 +9,14 @@ import net.minecraft.item.ItemStack;
|
||||
|
||||
public abstract class BaseBlockContainer extends BlockContainer {
|
||||
|
||||
public BaseBlockContainer(Material p_i45386_1_) {
|
||||
super(p_i45386_1_);
|
||||
public BaseBlockContainer(Material material) {
|
||||
super(material);
|
||||
}
|
||||
|
||||
public void addInformation(ItemStack itemStack, EntityPlayer player, List<String> toolTip,
|
||||
boolean advancedToolTips) {}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,211 @@
|
||||
package com.glodblock.github.common.block;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import appeng.api.implementations.items.IAEWrench;
|
||||
|
||||
import com.glodblock.github.common.item.ItemCertusQuartzTank;
|
||||
import com.glodblock.github.common.tabs.FluidCraftingTabs;
|
||||
import com.glodblock.github.common.tile.TileCertusQuartzTank;
|
||||
import com.glodblock.github.loader.ChannelLoader;
|
||||
import com.glodblock.github.loader.IRegister;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockCertusQuartzTank extends BaseBlockContainer implements IRegister<BlockCertusQuartzTank> {
|
||||
|
||||
IIcon breakIcon;
|
||||
IIcon topIcon;
|
||||
IIcon bottomIcon;
|
||||
IIcon sideIcon;
|
||||
IIcon sideMiddleIcon;
|
||||
IIcon sideTopIcon;
|
||||
IIcon sideBottomIcon;
|
||||
|
||||
public BlockCertusQuartzTank() {
|
||||
super(Material.glass);
|
||||
setBlockName(NameConst.BLOCK_CERTUS_QUARTZ_TANK);
|
||||
setResistance(10.0F);
|
||||
setHardness(2.0F);
|
||||
setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 1.0F, 0.9375F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRenderInPass(int pass) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World var1, int var2) {
|
||||
return new TileCertusQuartzTank();
|
||||
}
|
||||
|
||||
public ItemStack getDropWithNBT(World world, int x, int y, int z) {
|
||||
NBTTagCompound tileEntity = new NBTTagCompound();
|
||||
TileEntity worldTE = world.getTileEntity(x, y, z);
|
||||
if (worldTE instanceof TileCertusQuartzTank) {
|
||||
ItemStack dropStack = new ItemStack(ItemAndBlockHolder.CERTUS_QUARTZ_TANK, 1);
|
||||
|
||||
((TileCertusQuartzTank) worldTE).writeToNBTWithoutCoords(tileEntity);
|
||||
|
||||
if (!tileEntity.hasKey("Empty")) {
|
||||
dropStack.setTagCompound(new NBTTagCompound());
|
||||
dropStack.stackTagCompound.setTag("tileEntity", tileEntity);
|
||||
}
|
||||
return dropStack;
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
switch (meta) {
|
||||
case 1:
|
||||
return this.sideTopIcon;
|
||||
case 2:
|
||||
return this.sideBottomIcon;
|
||||
case 3:
|
||||
return this.sideMiddleIcon;
|
||||
default:
|
||||
return side == 0 ? this.bottomIcon : side == 1 ? this.topIcon : this.sideIcon;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) {
|
||||
return getDropWithNBT(world, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue(IBlockAccess world, int x, int y, int z) {
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if (tile instanceof TileCertusQuartzTank) {
|
||||
TileCertusQuartzTank tank = (TileCertusQuartzTank) tile;
|
||||
return tank.getFluidLightLevel();
|
||||
}
|
||||
return super.getLightValue(world, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World worldObj, int x, int y, int z, EntityPlayer entityplayer, int blockID,
|
||||
float offsetX, float offsetY, float offsetZ) {
|
||||
ItemStack current = entityplayer.inventory.getCurrentItem();
|
||||
|
||||
if (entityplayer.isSneaking() && current != null) {
|
||||
if (current.getItem() instanceof IAEWrench
|
||||
&& ((IAEWrench) current.getItem()).canWrench(current, entityplayer, x, y, z)) {
|
||||
dropBlockAsItem(worldObj, x, y, z, getDropWithNBT(worldObj, x, y, z));
|
||||
worldObj.setBlockToAir(x, y, z);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (current != null) {
|
||||
FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(current);
|
||||
TileCertusQuartzTank tank = (TileCertusQuartzTank) worldObj.getTileEntity(x, y, z);
|
||||
|
||||
if (liquid != null) {
|
||||
int amountFilled = tank.fill(ForgeDirection.UNKNOWN, liquid, true);
|
||||
if (amountFilled != 0 && !entityplayer.capabilities.isCreativeMode && current.getItem() != null) {
|
||||
if (current.stackSize > 1) {
|
||||
entityplayer.inventory.mainInventory[entityplayer.inventory.currentItem].stackSize -= 1;
|
||||
entityplayer.inventory.addItemStackToInventory(current.getItem().getContainerItem(current));
|
||||
} else {
|
||||
entityplayer.inventory.mainInventory[entityplayer.inventory.currentItem] = current.getItem()
|
||||
.getContainerItem(current);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
FluidStack available = tank.getTankInfo(ForgeDirection.UNKNOWN)[0].fluid;
|
||||
if (available != null) {
|
||||
ItemStack filled = FluidContainerRegistry.fillFluidContainer(available, current);
|
||||
|
||||
liquid = FluidContainerRegistry.getFluidForFilledItem(filled);
|
||||
|
||||
if (liquid != null) {
|
||||
tank.drain(ForgeDirection.UNKNOWN, liquid.amount, true);
|
||||
if (!entityplayer.capabilities.isCreativeMode) {
|
||||
if (current.stackSize == 1) {
|
||||
entityplayer.inventory.mainInventory[entityplayer.inventory.currentItem] = filled;
|
||||
} else {
|
||||
entityplayer.inventory.mainInventory[entityplayer.inventory.currentItem].stackSize--;
|
||||
if (!entityplayer.inventory.addItemStackToInventory(filled))
|
||||
entityplayer.entityDropItem(filled, 0);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, Block neighborBlock) {
|
||||
if (!world.isRemote) {
|
||||
ChannelLoader.sendPacketToAllPlayers(world.getTileEntity(x, y, z).getDescriptionPacket(), world);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {
|
||||
if (stack != null && stack.hasTagCompound()) {
|
||||
if (FluidStack.loadFluidStackFromNBT(stack.getTagCompound().getCompoundTag("tileEntity")) != null) list.add(
|
||||
FluidStack.loadFluidStackFromNBT(stack.getTagCompound().getCompoundTag("tileEntity")).amount
|
||||
+ "mB");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister iconregister) {
|
||||
String folder = NameConst.RES_KEY + "certus_quartz_tank/";
|
||||
this.breakIcon = iconregister.registerIcon(folder + "cube");
|
||||
this.topIcon = iconregister.registerIcon(folder + "top");
|
||||
this.bottomIcon = iconregister.registerIcon(folder + "bottom");
|
||||
this.sideIcon = iconregister.registerIcon(folder + "side");
|
||||
this.sideMiddleIcon = iconregister.registerIcon(folder + "side_mid");
|
||||
this.sideTopIcon = iconregister.registerIcon(folder + "side_top");
|
||||
this.sideBottomIcon = iconregister.registerIcon(folder + "side_bottom");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockCertusQuartzTank register() {
|
||||
GameRegistry.registerBlock(this, ItemCertusQuartzTank.class, NameConst.BLOCK_CERTUS_QUARTZ_TANK);
|
||||
GameRegistry.registerTileEntity(TileCertusQuartzTank.class, NameConst.BLOCK_CERTUS_QUARTZ_TANK);
|
||||
setCreativeTab(FluidCraftingTabs.INSTANCE);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package com.glodblock.github.common.block;
|
||||
|
||||
import static net.minecraft.client.gui.GuiScreen.isShiftKeyDown;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.util.Platform;
|
||||
|
||||
import com.glodblock.github.common.item.FCBaseItemBlock;
|
||||
import com.glodblock.github.common.tabs.FluidCraftingTabs;
|
||||
import com.glodblock.github.common.tile.TileFluidAutoFiller;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import com.glodblock.github.util.RenderUtil;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockFluidAutoFiller extends FCBaseBlock {
|
||||
|
||||
public BlockFluidAutoFiller() {
|
||||
super(Material.iron, NameConst.BLOCK_FLUID_AUTO_FILLER);
|
||||
setTileEntity(TileFluidAutoFiller.class);
|
||||
setFullBlock(false);
|
||||
setOpaque(false);
|
||||
this.lightOpacity = 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockFluidAutoFiller register() {
|
||||
GameRegistry.registerBlock(this, FCBaseItemBlock.class, NameConst.BLOCK_FLUID_AUTO_FILLER);
|
||||
GameRegistry.registerTileEntity(TileFluidAutoFiller.class, NameConst.BLOCK_FLUID_AUTO_FILLER);
|
||||
setCreativeTab(FluidCraftingTabs.INSTANCE);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivated(World world, int x, int y, int z, EntityPlayer player, int facing, float hitX,
|
||||
float hitY, float hitZ) {
|
||||
if (player.isSneaking()) {
|
||||
return false;
|
||||
}
|
||||
TileFluidAutoFiller tile = getTileEntity(world, x, y, z);
|
||||
if (tile != null) {
|
||||
if (Platform.isServer()) {
|
||||
if (Util.hasPermission(player, SecurityPermissions.INJECT, tile)) {
|
||||
InventoryHandler.openGui(
|
||||
player,
|
||||
world,
|
||||
new BlockPos(x, y, z),
|
||||
ForgeDirection.getOrientation(facing),
|
||||
GuiType.FLUID_AUTO_FILLER);
|
||||
} else {
|
||||
player.addChatComponentMessage(new ChatComponentText("You don't have permission to view."));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(final ItemStack itemStack, final EntityPlayer player, final List<String> toolTip,
|
||||
final boolean advancedToolTips) {
|
||||
if (isShiftKeyDown()) {
|
||||
toolTip.addAll(
|
||||
RenderUtil.listFormattedStringToWidth(
|
||||
StatCollector.translateToLocal(NameConst.TT_FLUID_AUTO_FILLER)));
|
||||
} else {
|
||||
toolTip.add(NameConst.i18n(NameConst.TT_SHIFT_FOR_MORE));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
package com.glodblock.github.common.item;
|
||||
|
||||
import static com.glodblock.github.loader.recipe.WirelessTerminalRecipe.getInfinityBoosterCard;
|
||||
import static com.glodblock.github.util.Util.hasInfinityBoosterCard;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.features.ILocatable;
|
||||
import appeng.api.features.IWirelessTermHandler;
|
||||
import appeng.api.features.IWirelessTermRegistry;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import appeng.items.tools.powered.ToolWirelessTerminal;
|
||||
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.item.IItemInventory;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemBaseWirelessTerminal extends ToolWirelessTerminal implements IItemInventory {
|
||||
|
||||
protected GuiType type;
|
||||
public static String infinityBoosterCard = "infinityBoosterCard";
|
||||
|
||||
public ItemBaseWirelessTerminal(GuiType t) {
|
||||
super();
|
||||
this.type = Optional.of(t).get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(final ItemStack item, final World w, final EntityPlayer player) {
|
||||
if (player.isSneaking()) return removeInfinityBoosterCard(player, item);
|
||||
IWirelessTermRegistry term = AEApi.instance().registries().wireless();
|
||||
if (!term.isWirelessTerminal(item)) {
|
||||
player.addChatMessage(PlayerMessages.DeviceNotWirelessTerminal.get());
|
||||
return item;
|
||||
}
|
||||
final IWirelessTermHandler handler = term.getWirelessTerminalHandler(item);
|
||||
final String unparsedKey = handler.getEncryptionKey(item);
|
||||
if (unparsedKey.isEmpty()) {
|
||||
player.addChatMessage(PlayerMessages.DeviceNotLinked.get());
|
||||
return item;
|
||||
}
|
||||
final long parsedKey = Long.parseLong(unparsedKey);
|
||||
final ILocatable securityStation = AEApi.instance().registries().locatable().getLocatableBy(parsedKey);
|
||||
if (securityStation == null) {
|
||||
player.addChatMessage(PlayerMessages.StationCanNotBeLocated.get());
|
||||
return item;
|
||||
}
|
||||
if (handler.hasPower(player, 0.5, item)) {
|
||||
InventoryHandler.openGui(
|
||||
player,
|
||||
w,
|
||||
new BlockPos(player.inventory.currentItem, 0, 0),
|
||||
ForgeDirection.UNKNOWN,
|
||||
this.type);
|
||||
} else {
|
||||
player.addChatMessage(PlayerMessages.DeviceNotPowered.get());
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
private ItemStack removeInfinityBoosterCard(final EntityPlayer player, ItemStack is) {
|
||||
if (hasInfinityBoosterCard(is)) {
|
||||
if (!player.inventory.addItemStackToInventory(getInfinityBoosterCard())) {
|
||||
player.entityDropItem(getInfinityBoosterCard(), 0);
|
||||
}
|
||||
is.getTagCompound().setBoolean(infinityBoosterCard, false);
|
||||
}
|
||||
return is;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void addCheckedInformation(ItemStack stack, EntityPlayer player, List<String> lines,
|
||||
boolean displayMoreInfo) {
|
||||
super.addCheckedInformation(stack, player, lines, displayMoreInfo);
|
||||
if (GuiScreen.isCtrlKeyDown()) {
|
||||
lines.add(NameConst.i18n(NameConst.TT_WIRELESS_INSTALLED));
|
||||
if (hasInfinityBoosterCard(stack)) {
|
||||
lines.add(" " + EnumChatFormatting.GOLD + getInfinityBoosterCard().getDisplayName());
|
||||
}
|
||||
} else {
|
||||
lines.add(NameConst.i18n(NameConst.TT_CTRL_FOR_MORE));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHandle(final ItemStack is) {
|
||||
return is.getItem() == this;
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getInventory(ItemStack stack, World world, int x, int y, int z, EntityPlayer player) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setGuiType(GuiType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public GuiType guiGuiType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
package com.glodblock.github.common.item;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidContainerItem;
|
||||
|
||||
import com.glodblock.github.common.tile.TileCertusQuartzTank;
|
||||
|
||||
public class ItemCertusQuartzTank extends BaseItemBlockContainer implements IFluidContainerItem {
|
||||
|
||||
private final int capacity = 32000;
|
||||
|
||||
public ItemCertusQuartzTank(Block block) {
|
||||
super(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ItemStack container, int maxDrain, boolean doDrain) {
|
||||
if (container.stackSize != 1 || container.stackTagCompound == null
|
||||
|| !container.stackTagCompound.hasKey("tileEntity")
|
||||
|| container.stackTagCompound.getCompoundTag("tileEntity").hasKey("Empty")) {
|
||||
return null;
|
||||
}
|
||||
|
||||
FluidStack stack = FluidStack.loadFluidStackFromNBT(container.stackTagCompound.getCompoundTag("tileEntity"));
|
||||
if (stack == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int currentAmount = stack.amount;
|
||||
stack.amount = Math.min(stack.amount, maxDrain);
|
||||
if (doDrain) {
|
||||
if (currentAmount == stack.amount) {
|
||||
container.stackTagCompound.removeTag("tileEntity");
|
||||
|
||||
if (container.stackTagCompound.hasNoTags()) {
|
||||
container.stackTagCompound = null;
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
NBTTagCompound fluidTag = container.stackTagCompound.getCompoundTag("tileEntity");
|
||||
fluidTag.setInteger("Amount", currentAmount - stack.amount);
|
||||
container.stackTagCompound.setTag("tileEntity", fluidTag);
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(ItemStack container, FluidStack resource, boolean doFill) {
|
||||
if (resource == null || container.stackSize != 1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!doFill) {
|
||||
if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("tileEntity")) {
|
||||
return Math.min(this.capacity, resource.amount);
|
||||
}
|
||||
|
||||
FluidStack stack = FluidStack
|
||||
.loadFluidStackFromNBT(container.stackTagCompound.getCompoundTag("tileEntity"));
|
||||
|
||||
if (stack == null) {
|
||||
return Math.min(this.capacity, resource.amount);
|
||||
}
|
||||
|
||||
if (!stack.isFluidEqual(resource)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return Math.min(this.capacity - stack.amount, resource.amount);
|
||||
}
|
||||
|
||||
if (container.stackTagCompound == null) {
|
||||
container.stackTagCompound = new NBTTagCompound();
|
||||
}
|
||||
|
||||
if (!container.stackTagCompound.hasKey("tileEntity")
|
||||
|| container.stackTagCompound.getCompoundTag("tileEntity").hasKey("Empty")) {
|
||||
NBTTagCompound fluidTag = resource.writeToNBT(new NBTTagCompound());
|
||||
|
||||
if (this.capacity < resource.amount) {
|
||||
fluidTag.setInteger("Amount", this.capacity);
|
||||
container.stackTagCompound.setTag("tileEntity", fluidTag);
|
||||
return this.capacity;
|
||||
}
|
||||
|
||||
container.stackTagCompound.setTag("tileEntity", fluidTag);
|
||||
return resource.amount;
|
||||
}
|
||||
|
||||
NBTTagCompound fluidTag = container.stackTagCompound.getCompoundTag("tileEntity");
|
||||
FluidStack stack = FluidStack.loadFluidStackFromNBT(fluidTag);
|
||||
|
||||
if (!stack.isFluidEqual(resource)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int filled = this.capacity - stack.amount;
|
||||
if (resource.amount < filled) {
|
||||
stack.amount += resource.amount;
|
||||
filled = resource.amount;
|
||||
} else {
|
||||
stack.amount = this.capacity;
|
||||
}
|
||||
|
||||
container.stackTagCompound.setTag("tileEntity", stack.writeToNBT(fluidTag));
|
||||
return filled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCapacity(ItemStack container) {
|
||||
return this.capacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack getFluid(ItemStack container) {
|
||||
if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("tileEntity")) {
|
||||
return null;
|
||||
}
|
||||
return FluidStack.loadFluidStackFromNBT(container.stackTagCompound.getCompoundTag("tileEntity"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side,
|
||||
float hitX, float hitY, float hitZ, int metadata) {
|
||||
if (!world.setBlock(x, y, z, this.field_150939_a, metadata, 3)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (world.getBlock(x, y, z) == this.field_150939_a) {
|
||||
this.field_150939_a.onBlockPlacedBy(world, x, y, z, player, stack);
|
||||
this.field_150939_a.onPostBlockPlaced(world, x, y, z, metadata);
|
||||
}
|
||||
|
||||
if (stack != null && stack.hasTagCompound()) {
|
||||
((TileCertusQuartzTank) world.getTileEntity(x, y, z))
|
||||
.readFromNBTWithoutCoords(stack.getTagCompound().getCompoundTag("tileEntity"));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,6 @@ import javax.annotation.Nullable;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
@@ -47,8 +46,12 @@ public class ItemPartFluidTerminal extends FCBaseItem implements IPartItem {
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean flag) {
|
||||
if (isShiftKeyDown()) tooltip.add(StatCollector.translateToLocalFormatted(NameConst.TT_FLUID_TERMINAL));
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List toolTip, boolean flag) {
|
||||
if (isShiftKeyDown()) {
|
||||
toolTip.add(NameConst.i18n(NameConst.TT_FLUID_TERMINAL));
|
||||
} else {
|
||||
toolTip.add(NameConst.i18n(NameConst.TT_SHIFT_FOR_MORE));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -192,7 +192,7 @@ public class ItemPortableFluidCell extends AEBasePoweredItem
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getInventory(ItemStack stack, World world, int x, int y, int z) {
|
||||
public Object getInventory(ItemStack stack, World world, int x, int y, int z, EntityPlayer player) {
|
||||
return new PortableFluidCellInventory(stack, x);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.glodblock.github.common.item;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import appeng.util.Platform;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.common.tabs.FluidCraftingTabs;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.item.WirelessFluidTerminal;
|
||||
import com.glodblock.github.loader.IRegister;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import com.glodblock.github.util.Util;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class ItemWirelessFluidTerminal extends ItemBaseWirelessTerminal
|
||||
implements IRegister<ItemWirelessFluidTerminal> {
|
||||
|
||||
public ItemWirelessFluidTerminal() {
|
||||
super(GuiType.WIRELESS_FLUID_TERMINAL);
|
||||
AEApi.instance().registries().wireless().registerWirelessHandler(this);
|
||||
this.setFeature(EnumSet.of(AEFeature.WirelessAccessTerminal, AEFeature.PoweredTools));
|
||||
setUnlocalizedName(NameConst.ITEM_WIRELESS_FLUID_TERMINAL);
|
||||
setTextureName(FluidCraft.resource(NameConst.ITEM_WIRELESS_FLUID_TERMINAL).toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemWirelessFluidTerminal register() {
|
||||
GameRegistry.registerItem(this, NameConst.ITEM_WIRELESS_FLUID_TERMINAL, FluidCraft.MODID);
|
||||
setCreativeTab(FluidCraftingTabs.INSTANCE);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getInventory(ItemStack stack, World world, int x, int y, int z, EntityPlayer player) {
|
||||
try {
|
||||
IGridNode gridNode = Util.getWirelessGrid(stack);
|
||||
if (gridNode != null) {
|
||||
return new WirelessFluidTerminal(stack, x, gridNode, player);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if (Platform.isClient()) player.addChatMessage(PlayerMessages.OutOfRange.get());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.glodblock.github.common.item;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import appeng.util.Platform;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.common.tabs.FluidCraftingTabs;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.item.WirelessPatternTerminal;
|
||||
import com.glodblock.github.loader.IRegister;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import com.glodblock.github.util.Util;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class ItemWirelessPatternTerminal extends ItemBaseWirelessTerminal
|
||||
implements IRegister<ItemWirelessPatternTerminal> {
|
||||
|
||||
public ItemWirelessPatternTerminal() {
|
||||
super(GuiType.WIRELESS_FLUID_PATTERN_TERMINAL);
|
||||
AEApi.instance().registries().wireless().registerWirelessHandler(this);
|
||||
this.setFeature(EnumSet.of(AEFeature.WirelessAccessTerminal, AEFeature.PoweredTools));
|
||||
setUnlocalizedName(NameConst.ITEM_WIRELESS_FLUID_PATTERN_TERMINAL);
|
||||
setTextureName(FluidCraft.resource(NameConst.ITEM_WIRELESS_FLUID_PATTERN_TERMINAL).toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemWirelessPatternTerminal register() {
|
||||
GameRegistry.registerItem(this, NameConst.ITEM_WIRELESS_FLUID_PATTERN_TERMINAL, FluidCraft.MODID);
|
||||
setCreativeTab(FluidCraftingTabs.INSTANCE);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getInventory(ItemStack stack, World world, int x, int y, int z, EntityPlayer player) {
|
||||
try {
|
||||
IGridNode gridNode = Util.getWirelessGrid(stack);
|
||||
if (gridNode != null) {
|
||||
return new WirelessPatternTerminal(stack, x, gridNode, player);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if (Platform.isClient()) player.addChatMessage(PlayerMessages.OutOfRange.get());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.glodblock.github.common.parts.base;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@@ -9,7 +10,10 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
|
||||
public abstract class FCFluidEncodeTerminal extends FCPart {
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.inventory.item.PatternTerminal;
|
||||
|
||||
public abstract class FCFluidEncodeTerminal extends FCPart implements PatternTerminal {
|
||||
|
||||
protected AppEngInternalInventory crafting;
|
||||
protected AppEngInternalInventory output;
|
||||
@@ -154,4 +158,34 @@ public abstract class FCFluidEncodeTerminal extends FCPart {
|
||||
|
||||
return super.getInventoryByName(name);
|
||||
}
|
||||
|
||||
public void sortCraftingItems() {
|
||||
List<ItemStack> items = new ArrayList<ItemStack>();
|
||||
List<ItemStack> fluids = new ArrayList<ItemStack>();
|
||||
for (ItemStack is : this.crafting) {
|
||||
if (is == null) continue;
|
||||
if (is.getItem() instanceof ItemFluidPacket) {
|
||||
fluids.add(is);
|
||||
} else {
|
||||
items.add(is);
|
||||
}
|
||||
}
|
||||
if (this.prioritize) {
|
||||
fluids.addAll(items);
|
||||
items.clear();
|
||||
} else {
|
||||
items.addAll(fluids);
|
||||
fluids.clear();
|
||||
}
|
||||
|
||||
for (int i = 0; i < this.crafting.getSizeInventory(); i++) {
|
||||
if (this.crafting.getStackInSlot(i) == null) break;
|
||||
if (items.isEmpty()) {
|
||||
this.crafting.setInventorySlotContents(i, fluids.get(i));
|
||||
} else {
|
||||
this.crafting.setInventorySlotContents(i, items.get(i));
|
||||
}
|
||||
}
|
||||
saveChanges();
|
||||
}
|
||||
}
|
||||
@@ -111,14 +111,16 @@ public abstract class FCPartMonitor extends AbstractPartDisplay implements IPart
|
||||
boolean needRedraw = super.readFromStream(data);
|
||||
|
||||
final boolean isLocked = data.readBoolean();
|
||||
needRedraw = this.isLocked != isLocked;
|
||||
needRedraw |= this.isLocked != isLocked;
|
||||
|
||||
this.isLocked = isLocked;
|
||||
|
||||
final boolean val = data.readBoolean();
|
||||
if (val) {
|
||||
needRedraw |= this.configuredFluid == null;
|
||||
this.configuredFluid = AEFluidStack.loadFluidStackFromPacket(data);
|
||||
} else {
|
||||
needRedraw |= this.configuredFluid != null;
|
||||
this.configuredFluid = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,277 @@
|
||||
package com.glodblock.github.common.tile;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.*;
|
||||
|
||||
import com.glodblock.github.loader.ChannelLoader;
|
||||
|
||||
public class TileCertusQuartzTank extends TileEntity implements IFluidHandler {
|
||||
|
||||
private FluidStack lastBeforeUpdate = null;
|
||||
public FluidTank tank = new FluidTank(32000) {
|
||||
|
||||
@Override
|
||||
public FluidTank readFromNBT(NBTTagCompound nbt) {
|
||||
if (!nbt.hasKey("Empty")) {
|
||||
FluidStack fluid = FluidStack.loadFluidStackFromNBT(nbt);
|
||||
setFluid(fluid);
|
||||
} else {
|
||||
setFluid(null);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid) {
|
||||
return this.tank.getFluid() == null || this.tank.getFluid().getFluid() == fluid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid) {
|
||||
return this.tank.getFluid() == null || this.tank.getFluid().getFluid() == fluid;
|
||||
}
|
||||
|
||||
public int getFluidLightLevel() {
|
||||
FluidStack tankFluid = tank.getFluid();
|
||||
return tankFluid == null || tankFluid.amount == 0 ? 0 : tankFluid.getFluid().getLuminosity(tankFluid);
|
||||
}
|
||||
|
||||
public void compareAndUpdate() {
|
||||
if (!this.worldObj.isRemote) {
|
||||
FluidStack current = this.tank.getFluid();
|
||||
if (current != null) {
|
||||
if (this.lastBeforeUpdate != null) {
|
||||
if (Math.abs(current.amount - this.lastBeforeUpdate.amount) >= 500) {
|
||||
ChannelLoader.sendPacketToAllPlayers(getDescriptionPacket(), this.worldObj);
|
||||
this.lastBeforeUpdate = current.copy();
|
||||
} else if (this.lastBeforeUpdate.amount < this.tank.getCapacity()
|
||||
&& current.amount == this.tank.getCapacity()
|
||||
|| this.lastBeforeUpdate.amount == this.tank.getCapacity()
|
||||
&& current.amount < this.tank.getCapacity()) {
|
||||
ChannelLoader.sendPacketToAllPlayers(getDescriptionPacket(), this.worldObj);
|
||||
this.lastBeforeUpdate = current.copy();
|
||||
}
|
||||
} else {
|
||||
ChannelLoader.sendPacketToAllPlayers(getDescriptionPacket(), this.worldObj);
|
||||
this.lastBeforeUpdate = current.copy();
|
||||
}
|
||||
} else if (this.lastBeforeUpdate != null) {
|
||||
ChannelLoader.sendPacketToAllPlayers(getDescriptionPacket(), this.worldObj);
|
||||
this.lastBeforeUpdate = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public FluidStack drain(FluidStack fluid, boolean doDrain, boolean findMainTank) {
|
||||
if (findMainTank) {
|
||||
int yOff = 0;
|
||||
TileEntity offTE = this.worldObj.getTileEntity(this.xCoord, this.yCoord + yOff, this.zCoord);
|
||||
TileCertusQuartzTank mainTank = this;
|
||||
while (true) {
|
||||
if (offTE instanceof TileCertusQuartzTank) {
|
||||
Fluid offFluid = ((TileCertusQuartzTank) offTE).getFluid();
|
||||
if (offFluid != null && offFluid == fluid.getFluid()) {
|
||||
mainTank = (TileCertusQuartzTank) this.worldObj
|
||||
.getTileEntity(this.xCoord, this.yCoord + yOff, this.zCoord);
|
||||
yOff++;
|
||||
offTE = this.worldObj.getTileEntity(this.xCoord, this.yCoord + yOff, this.zCoord);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return mainTank != null ? mainTank.drain(fluid, doDrain, false) : null;
|
||||
}
|
||||
|
||||
FluidStack drained = this.tank.drain(fluid.amount, doDrain);
|
||||
compareAndUpdate();
|
||||
|
||||
if (drained == null || drained.amount < fluid.amount) {
|
||||
TileEntity offTE = this.worldObj.getTileEntity(this.xCoord, this.yCoord - 1, this.zCoord);
|
||||
if (offTE instanceof TileCertusQuartzTank) {
|
||||
TileCertusQuartzTank tank = (TileCertusQuartzTank) offTE;
|
||||
FluidStack externallyDrained = tank.drain(
|
||||
new FluidStack(fluid.getFluid(), fluid.amount - (drained != null ? drained.amount : 0)),
|
||||
doDrain,
|
||||
false);
|
||||
|
||||
if (externallyDrained != null) return new FluidStack(
|
||||
fluid.getFluid(),
|
||||
(drained != null ? drained.amount : 0) + externallyDrained.amount);
|
||||
else return drained;
|
||||
}
|
||||
}
|
||||
|
||||
return drained;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
|
||||
if (this.tank.getFluid() == null || resource == null || resource.getFluid() != this.tank.getFluid().getFluid())
|
||||
return null;
|
||||
|
||||
return drain(resource, doDrain, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
|
||||
if (this.tank.getFluid() == null) return null;
|
||||
|
||||
return drain(from, new FluidStack(this.tank.getFluid(), maxDrain), doDrain);
|
||||
}
|
||||
|
||||
public int fill(FluidStack fluid, boolean doFill, boolean findMainTank) {
|
||||
if (findMainTank) {
|
||||
int yOff = 0;
|
||||
TileEntity offTE = this.worldObj.getTileEntity(this.xCoord, this.yCoord - yOff, this.zCoord);
|
||||
TileCertusQuartzTank mainTank = this;
|
||||
while (true) {
|
||||
if (offTE instanceof TileCertusQuartzTank) {
|
||||
Fluid offFluid = ((TileCertusQuartzTank) offTE).getFluid();
|
||||
if (offFluid == null || offFluid == fluid.getFluid()) {
|
||||
mainTank = (TileCertusQuartzTank) this.worldObj
|
||||
.getTileEntity(this.xCoord, this.yCoord - yOff, this.zCoord);
|
||||
yOff++;
|
||||
offTE = this.worldObj.getTileEntity(this.xCoord, this.yCoord - yOff, this.zCoord);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return mainTank != null ? mainTank.fill(fluid, doFill, false) : 0;
|
||||
}
|
||||
|
||||
int filled = this.tank.fill(fluid, doFill);
|
||||
compareAndUpdate();
|
||||
|
||||
if (filled < fluid.amount) {
|
||||
TileEntity offTE = this.worldObj.getTileEntity(this.xCoord, this.yCoord + 1, this.zCoord);
|
||||
if (offTE instanceof TileCertusQuartzTank) {
|
||||
TileCertusQuartzTank tank = (TileCertusQuartzTank) offTE;
|
||||
return filled + tank.fill(new FluidStack(fluid.getFluid(), fluid.amount - filled), doFill, false);
|
||||
}
|
||||
}
|
||||
|
||||
return filled;
|
||||
}
|
||||
|
||||
/* IFluidHandler */
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
|
||||
if (resource == null || this.tank.getFluid() != null && resource.getFluid() != this.tank.getFluid().getFluid())
|
||||
return 0;
|
||||
return fill(resource, doFill, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket() {
|
||||
NBTTagCompound nbtTag = new NBTTagCompound();
|
||||
writeToNBT(nbtTag);
|
||||
return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, nbtTag);
|
||||
}
|
||||
|
||||
public Fluid getFluid() {
|
||||
FluidStack tankFluid = this.tank.getFluid();
|
||||
return tankFluid != null && tankFluid.amount > 0 ? tankFluid.getFluid() : null;
|
||||
}
|
||||
|
||||
public Fluid getRenderFluid() {
|
||||
return this.tank.getFluid() != null ? this.tank.getFluid().getFluid() : null;
|
||||
}
|
||||
|
||||
public float getRenderScale() {
|
||||
return (float) this.tank.getFluidAmount() / this.tank.getCapacity();
|
||||
}
|
||||
|
||||
public FluidTankInfo[] getTankInfo(boolean goToMainTank) {
|
||||
if (!goToMainTank) return new FluidTankInfo[] { this.tank.getInfo() };
|
||||
|
||||
int amount = 0, capacity = 0;
|
||||
Fluid fluid = null;
|
||||
|
||||
int yOff = 0;
|
||||
TileEntity offTE = this.worldObj.getTileEntity(this.xCoord, this.yCoord - yOff, this.zCoord);
|
||||
TileCertusQuartzTank mainTank;
|
||||
while (true) {
|
||||
if (offTE instanceof TileCertusQuartzTank) {
|
||||
if (((TileCertusQuartzTank) offTE).getFluid() == null
|
||||
|| ((TileCertusQuartzTank) offTE).getFluid() == getFluid()) {
|
||||
yOff++;
|
||||
offTE = this.worldObj.getTileEntity(this.xCoord, this.yCoord - yOff, this.zCoord);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
yOff = 0;
|
||||
offTE = this.worldObj.getTileEntity(this.xCoord, this.yCoord + yOff, this.zCoord);
|
||||
while (true) {
|
||||
if (offTE instanceof TileCertusQuartzTank) {
|
||||
mainTank = (TileCertusQuartzTank) offTE;
|
||||
if (mainTank.getFluid() == null || mainTank.getFluid() == getFluid()) {
|
||||
FluidTankInfo info = mainTank.getTankInfo(false)[0];
|
||||
if (info != null) {
|
||||
capacity += info.capacity;
|
||||
if (info.fluid != null) {
|
||||
amount += info.fluid.amount;
|
||||
if (info.fluid.getFluid() != null) fluid = info.fluid.getFluid();
|
||||
}
|
||||
}
|
||||
yOff++;
|
||||
offTE = this.worldObj.getTileEntity(this.xCoord, this.yCoord + yOff, this.zCoord);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return new FluidTankInfo[] {
|
||||
new FluidTankInfo(fluid != null ? new FluidStack(fluid, amount) : null, capacity) };
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
|
||||
return getTankInfo(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) {
|
||||
this.worldObj.markBlockRangeForRenderUpdate(
|
||||
this.xCoord,
|
||||
this.yCoord,
|
||||
this.zCoord,
|
||||
this.xCoord,
|
||||
this.yCoord,
|
||||
this.zCoord);
|
||||
readFromNBT(packet.func_148857_g());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag) {
|
||||
super.readFromNBT(tag);
|
||||
readFromNBTWithoutCoords(tag);
|
||||
}
|
||||
|
||||
public void readFromNBTWithoutCoords(NBTTagCompound tag) {
|
||||
this.tank.readFromNBT(tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tag) {
|
||||
super.writeToNBT(tag);
|
||||
writeToNBTWithoutCoords(tag);
|
||||
}
|
||||
|
||||
public void writeToNBTWithoutCoords(NBTTagCompound tag) {
|
||||
this.tank.writeToNBT(tag);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,301 @@
|
||||
package com.glodblock.github.common.tile;
|
||||
|
||||
import static com.glodblock.github.loader.RecipeLoader.BUCKET;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import org.apache.commons.lang3.tuple.MutablePair;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerMultiplier;
|
||||
import appeng.api.implementations.ICraftingPatternItem;
|
||||
import appeng.api.networking.GridFlags;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
import appeng.api.networking.crafting.ICraftingProvider;
|
||||
import appeng.api.networking.crafting.ICraftingProviderHelper;
|
||||
import appeng.api.networking.events.MENetworkBootingStatusChange;
|
||||
import appeng.api.networking.events.MENetworkCraftingPatternChange;
|
||||
import appeng.api.networking.events.MENetworkEventSubscribe;
|
||||
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.security.MachineSource;
|
||||
import appeng.api.networking.storage.IBaseMonitor;
|
||||
import appeng.api.networking.storage.IStorageGrid;
|
||||
import appeng.api.networking.ticking.IGridTickable;
|
||||
import appeng.api.networking.ticking.TickRateModulation;
|
||||
import appeng.api.networking.ticking.TickingRequest;
|
||||
import appeng.api.storage.IMEMonitorHandlerReceiver;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.helpers.Reflected;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkInvTile;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
public class TileFluidAutoFiller extends AENetworkInvTile
|
||||
implements ICraftingProvider, IMEMonitorHandlerReceiver<IAEFluidStack>, IGridTickable {
|
||||
|
||||
private final AppEngInternalInventory inventory = new AppEngInternalInventory(this, 1);
|
||||
private final BaseActionSource source = new MachineSource(this);
|
||||
private IItemList<IAEFluidStack> fluids = AEApi.instance().storage().createFluidList();
|
||||
private final Item encodedPattern = AEApi.instance().definitions().items().encodedPattern().maybeItem().orNull();
|
||||
private IAEItemStack returnStack;
|
||||
private boolean isPowered;
|
||||
|
||||
public IInventory getInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
@Reflected
|
||||
public TileFluidAutoFiller() {
|
||||
getProxy().setIdlePowerUsage(1D);
|
||||
getProxy().setFlags(GridFlags.REQUIRE_CHANNEL);
|
||||
inventory.setInventorySlotContents(0, BUCKET);
|
||||
}
|
||||
|
||||
public ItemStack getContainerItem() {
|
||||
return getInventory().getStackInSlot(0);
|
||||
}
|
||||
|
||||
public void setContainerItem(ItemStack is) {
|
||||
getInventory().setInventorySlotContents(0, is);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added) {}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsBySide(ForgeDirection whichSide) {
|
||||
return new int[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeRotated() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void updatePattern() {
|
||||
ItemStack is = inventory.getStackInSlot(0);
|
||||
if (is == null) return;
|
||||
this.setContainerItem(is);
|
||||
postEvent();
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBTEvent(NBTTagCompound data) {
|
||||
inventory.readFromNBT(data, "Inv");
|
||||
if (inventory.getStackInSlot(0) == null) {
|
||||
inventory.setInventorySlotContents(0, BUCKET);
|
||||
}
|
||||
updatePattern();
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public NBTTagCompound writeToNBTEvent(NBTTagCompound data) {
|
||||
inventory.writeToNBT(data, "Inv");
|
||||
return data;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IInventory getInternalInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DimensionalCoord getLocation() {
|
||||
return new DimensionalCoord(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType(ForgeDirection dir) {
|
||||
return AECableType.DENSE;
|
||||
}
|
||||
|
||||
private IStorageGrid getStorageGrid() {
|
||||
try {
|
||||
return this.getProxy().getGrid().getCache(IStorageGrid.class);
|
||||
} catch (GridAccessException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void provideCrafting(ICraftingProviderHelper craftingTracker) {
|
||||
IStorageGrid storage = getStorageGrid();
|
||||
if (storage == null) return;
|
||||
IItemList<IAEFluidStack> fluidStorage = this.fluids.isEmpty() ? storage.getFluidInventory().getStorageList()
|
||||
: this.fluids;
|
||||
for (IAEFluidStack fluidStack : fluidStorage) {
|
||||
Fluid fluid = fluidStack.getFluid();
|
||||
if (fluid == null) continue;
|
||||
int maxCapacity = Util.FluidUtil.getCapacity(this.getContainerItem(), fluid);
|
||||
if (maxCapacity == 0) continue;
|
||||
MutablePair<Integer, ItemStack> filled = Util.FluidUtil
|
||||
.fillStack(this.getContainerItem().copy(), new FluidStack(fluid, maxCapacity));
|
||||
if (filled.right == null) continue;
|
||||
ItemStack pattern = getPattern(this.getContainerItem(), filled.right);
|
||||
ICraftingPatternItem patter = (ICraftingPatternItem) pattern.getItem();
|
||||
craftingTracker.addCraftingOption(this, patter.getPatternForItem(pattern, getWorldObj()));
|
||||
}
|
||||
}
|
||||
|
||||
private ItemStack getPattern(ItemStack emptyContainer, ItemStack filledContainer) {
|
||||
NBTTagList in = new NBTTagList();
|
||||
NBTTagList out = new NBTTagList();
|
||||
in.appendTag(emptyContainer.writeToNBT(new NBTTagCompound()));
|
||||
ItemStack fluidDrop = ItemFluidDrop.newStack(Util.FluidUtil.getFluidFromContainer(filledContainer));
|
||||
in.appendTag(createItemTag(fluidDrop));
|
||||
out.appendTag(filledContainer.writeToNBT(new NBTTagCompound()));
|
||||
NBTTagCompound itemTag = new NBTTagCompound();
|
||||
itemTag.setTag("in", in);
|
||||
itemTag.setTag("out", out);
|
||||
itemTag.setBoolean("crafting", false);
|
||||
ItemStack pattern = new ItemStack(this.encodedPattern);
|
||||
pattern.setTagCompound(itemTag);
|
||||
return pattern;
|
||||
}
|
||||
|
||||
protected NBTBase createItemTag(final ItemStack i) {
|
||||
final NBTTagCompound c = new NBTTagCompound();
|
||||
if (i != null) {
|
||||
i.writeToNBT(c);
|
||||
c.setInteger("Count", i.stackSize);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pushPattern(ICraftingPatternDetails patternDetails, InventoryCrafting table) {
|
||||
this.returnStack = AEApi.instance().storage()
|
||||
.createItemStack(patternDetails.getCondensedOutputs()[0].getItemStack());
|
||||
try {
|
||||
this.getProxy().getTick().alertDevice(this.getProxy().getNode());
|
||||
} catch (GridAccessException ignored) {
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBusy() {
|
||||
return this.returnStack != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(Object verificationToken) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postChange(IBaseMonitor<IAEFluidStack> monitor, Iterable<IAEFluidStack> change,
|
||||
BaseActionSource source) {
|
||||
if (this.getProxy().isActive() && this.getStorageGrid() != null) {
|
||||
boolean hasChanged = false;
|
||||
IItemList<IAEFluidStack> stored = this.getStorageGrid().getFluidInventory().getStorageList();
|
||||
for (IAEFluidStack tmp : change) {
|
||||
if (stored.findPrecise(tmp) == null || this.fluids.findPrecise(tmp) == null) {
|
||||
hasChanged = true;
|
||||
this.fluids = stored;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (hasChanged) postEvent();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean postEvent() {
|
||||
try {
|
||||
this.getProxy().getGrid()
|
||||
.postEvent(new MENetworkCraftingPatternChange(this, getGridNode(ForgeDirection.UNKNOWN)));
|
||||
return true;
|
||||
} catch (GridAccessException ignored) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onListUpdate() {}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void stateChange(final MENetworkPowerStatusChange p) {
|
||||
this.updatePowerState();
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public final void bootingRender(final MENetworkBootingStatusChange c) {
|
||||
this.updatePowerState();
|
||||
}
|
||||
|
||||
private void updatePowerState() {
|
||||
boolean newState = false;
|
||||
try {
|
||||
newState = this.getProxy().isActive()
|
||||
&& this.getProxy().getEnergy().extractAEPower(1, Actionable.SIMULATE, PowerMultiplier.CONFIG)
|
||||
> 0.0001;
|
||||
if (newState != this.isPowered && newState) {
|
||||
this.getProxy().getStorage().getFluidInventory().addListener(this, null);
|
||||
}
|
||||
} catch (final GridAccessException ignored) {}
|
||||
if (newState != this.isPowered) {
|
||||
this.isPowered = newState;
|
||||
this.markForUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gridChanged() {
|
||||
try {
|
||||
this.getProxy().getStorage().getFluidInventory().removeListener(this);
|
||||
} catch (final GridAccessException ignored) {}
|
||||
super.gridChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickingRequest getTickingRequest(IGridNode node) {
|
||||
return new TickingRequest(1, 5, this.returnStack == null, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickRateModulation tickingRequest(IGridNode node, int TicksSinceLastCall) {
|
||||
if (this.getStorageGrid() == null) {
|
||||
return TickRateModulation.SLOWER;
|
||||
}
|
||||
IAEItemStack nodAdded = getStorageGrid().getItemInventory()
|
||||
.injectItems(this.returnStack, Actionable.SIMULATE, this.source);
|
||||
if (nodAdded == null) {
|
||||
getStorageGrid().getItemInventory().injectItems(this.returnStack, Actionable.MODULATE, this.source);
|
||||
this.returnStack = null;
|
||||
return TickRateModulation.SLEEP;
|
||||
} else {
|
||||
return TickRateModulation.SLOWER;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dropItems() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.glodblock.github.inventory;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.tile.inventory.BiggerAppEngInventory;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ItemBiggerAppEngInventory extends BiggerAppEngInventory {
|
||||
|
||||
private final ItemStack is;
|
||||
private final String name;
|
||||
|
||||
public ItemBiggerAppEngInventory(ItemStack is, String name, int size) {
|
||||
super(null, size);
|
||||
this.name = name;
|
||||
this.is = is;
|
||||
this.readFromNBT(Platform.openNbtData(is), name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
this.writeToNBT(Platform.openNbtData(is), this.name);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.glodblock.github.inventory;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class WirelessFluidPatternTerminalPatterns extends AppEngInternalInventory {
|
||||
|
||||
private final ItemStack is;
|
||||
|
||||
public WirelessFluidPatternTerminalPatterns(final ItemStack is) {
|
||||
super(null, 2);
|
||||
this.is = is;
|
||||
this.readFromNBT(Platform.openNbtData(is), "pattern");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
this.writeToNBT(Platform.openNbtData(is), "pattern");
|
||||
}
|
||||
}
|
||||
@@ -22,10 +22,24 @@ import com.glodblock.github.common.parts.base.FCSharedFluidBus;
|
||||
import com.glodblock.github.common.tile.*;
|
||||
import com.glodblock.github.inventory.IDualHost;
|
||||
import com.glodblock.github.inventory.item.IFluidPortableCell;
|
||||
import com.glodblock.github.inventory.item.IWirelessTerminal;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public enum GuiType {
|
||||
|
||||
FLUID_AUTO_FILLER(new TileGuiFactory<TileFluidAutoFiller>(TileFluidAutoFiller.class) {
|
||||
|
||||
@Override
|
||||
protected Object createServerGui(EntityPlayer player, TileFluidAutoFiller inv) {
|
||||
return new ContainerFluidAutoFiller(player.inventory, inv);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object createClientGui(EntityPlayer player, TileFluidAutoFiller inv) {
|
||||
return new GuiFluidAutoFiller(player.inventory, inv);
|
||||
}
|
||||
}),
|
||||
|
||||
FLUID_LEVEL_EMITTER(new PartGuiFactory<PartFluidLevelEmitter>(PartFluidLevelEmitter.class) {
|
||||
|
||||
@Override
|
||||
@@ -156,15 +170,15 @@ public enum GuiType {
|
||||
}
|
||||
}),
|
||||
|
||||
CRAFTING_STATUS(new PartGuiFactory<FCPart>(FCPart.class) {
|
||||
CRAFTING_STATUS(new PartOrItemGuiFactory<ITerminalHost>(ITerminalHost.class) {
|
||||
|
||||
@Override
|
||||
protected Object createServerGui(EntityPlayer player, FCPart inv) {
|
||||
protected Object createServerGui(EntityPlayer player, ITerminalHost inv) {
|
||||
return new ContainerCraftingStatus(player.inventory, inv);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object createClientGui(EntityPlayer player, FCPart inv) {
|
||||
protected Object createClientGui(EntityPlayer player, ITerminalHost inv) {
|
||||
return new GuiFluidPatternTerminalCraftingStatus(player.inventory, inv);
|
||||
}
|
||||
}),
|
||||
@@ -194,6 +208,30 @@ public enum GuiType {
|
||||
return new GuiFluidPortableCell(player.inventory, inv);
|
||||
}
|
||||
}),
|
||||
WIRELESS_FLUID_TERMINAL(new ItemGuiFactory<IWirelessTerminal>(IWirelessTerminal.class) {
|
||||
|
||||
@Override
|
||||
protected Object createServerGui(EntityPlayer player, IWirelessTerminal inv) {
|
||||
return new ContainerFluidPortableCell(player.inventory, inv);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object createClientGui(EntityPlayer player, IWirelessTerminal inv) {
|
||||
return new GuiFluidPortableCell(player.inventory, inv);
|
||||
}
|
||||
}),
|
||||
WIRELESS_FLUID_PATTERN_TERMINAL(new ItemGuiFactory<IWirelessTerminal>(IWirelessTerminal.class) {
|
||||
|
||||
@Override
|
||||
protected Object createServerGui(EntityPlayer player, IWirelessTerminal inv) {
|
||||
return new ContainerPatternPortableCell(player.inventory, inv);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object createClientGui(EntityPlayer player, IWirelessTerminal inv) {
|
||||
return new GuiPatternPortableCell(player.inventory, inv);
|
||||
}
|
||||
}),
|
||||
|
||||
FLUID_PATTERN_TERMINAL(new PartGuiFactory<ITerminalHost>(ITerminalHost.class) {
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.glodblock.github.inventory.gui;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
@@ -32,7 +33,7 @@ public abstract class ItemGuiFactory<T> implements IGuiFactory {
|
||||
if (item == null || !(item.getItem() instanceof IItemInventory)) {
|
||||
return null;
|
||||
}
|
||||
T inv = getInventory(((IItemInventory) item.getItem()).getInventory(item, world, x, y, z));
|
||||
T inv = getInventory(((IItemInventory) item.getItem()).getInventory(item, world, x, y, z, player));
|
||||
if (inv == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -59,7 +60,10 @@ public abstract class ItemGuiFactory<T> implements IGuiFactory {
|
||||
if (item == null || !(item.getItem() instanceof IItemInventory)) {
|
||||
return null;
|
||||
}
|
||||
T inv = getInventory(((IItemInventory) item.getItem()).getInventory(item, world, x, y, z));
|
||||
T inv = getInventory(((IItemInventory) item.getItem()).getInventory(item, world, x, y, z, player));
|
||||
if (inv == null && Minecraft.getMinecraft().currentScreen != null) {
|
||||
player.closeScreen();
|
||||
}
|
||||
return inv != null ? createClientGui(player, inv) : null;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.glodblock.github.inventory.gui;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerOpenContext;
|
||||
|
||||
import com.glodblock.github.inventory.item.IItemInventory;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
public abstract class PartOrItemGuiFactory<T> extends PartGuiFactory<T> {
|
||||
|
||||
PartOrItemGuiFactory(Class<T> invClass) {
|
||||
super(invClass);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected T getItemInventory(Object inv) {
|
||||
return invClass.isInstance(inv) ? invClass.cast(inv) : null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Object createServerGui(EntityPlayer player, World world, int x, int y, int z, ForgeDirection face) {
|
||||
ImmutablePair<Util.GuiHelper.GuiType, Integer> result = Util.GuiHelper.decodeType(y);
|
||||
|
||||
if (result.getLeft() == Util.GuiHelper.GuiType.ITEM) {
|
||||
ItemStack item = player.getHeldItem();
|
||||
if (item == null || !(item.getItem() instanceof IItemInventory)) {
|
||||
return null;
|
||||
}
|
||||
T inv = getItemInventory(
|
||||
((IItemInventory) item.getItem()).getInventory(item, world, x, result.getRight(), z, player));
|
||||
if (inv == null) {
|
||||
return null;
|
||||
}
|
||||
Object gui = createServerGui(player, inv);
|
||||
if (gui instanceof AEBaseContainer) {
|
||||
ContainerOpenContext ctx = new ContainerOpenContext(inv);
|
||||
ctx.setWorld(world);
|
||||
ctx.setX(x);
|
||||
ctx.setY(y);
|
||||
ctx.setZ(z);
|
||||
ctx.setSide(face);
|
||||
((AEBaseContainer) gui).setOpenContext(ctx);
|
||||
}
|
||||
return gui;
|
||||
} else {
|
||||
return super.createServerGui(player, world, x, result.getRight(), z, face);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Object createClientGui(EntityPlayer player, World world, int x, int y, int z, ForgeDirection face) {
|
||||
ImmutablePair<Util.GuiHelper.GuiType, Integer> result = Util.GuiHelper.decodeType(y);
|
||||
if (result.left == Util.GuiHelper.GuiType.ITEM) {
|
||||
ItemStack item = player.getHeldItem();
|
||||
if (item == null || !(item.getItem() instanceof IItemInventory)) {
|
||||
return null;
|
||||
}
|
||||
T inv = getItemInventory(
|
||||
((IItemInventory) item.getItem()).getInventory(item, world, x, result.getRight(), z, player));
|
||||
return inv != null ? createClientGui(player, inv) : null;
|
||||
} else {
|
||||
return super.createClientGui(player, world, x, result.getRight(), z, face);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
package com.glodblock.github.inventory.item;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IItemInventory {
|
||||
|
||||
Object getInventory(ItemStack stack, World world, int x, int y, int z);
|
||||
Object getInventory(ItemStack stack, World world, int x, int y, int z, EntityPlayer player);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.glodblock.github.inventory.item;
|
||||
|
||||
public interface IWirelessPatternTerminal extends IWirelessTerminal, PatternTerminal {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.glodblock.github.inventory.item;
|
||||
|
||||
import appeng.api.implementations.tiles.IViewCellStorage;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.tile.inventory.IAEAppEngInventory;
|
||||
|
||||
public interface IWirelessTerminal extends IFluidPortableCell, IViewCellStorage, IAEAppEngInventory, IGridHost {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.glodblock.github.inventory.item;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
|
||||
public interface PatternTerminal {
|
||||
|
||||
boolean isInverted();
|
||||
|
||||
IInventory getInventoryByName(final String name);
|
||||
|
||||
boolean canBeSubstitute();
|
||||
|
||||
boolean isPrioritize();
|
||||
|
||||
boolean isSubstitution();
|
||||
|
||||
boolean shouldCombine();
|
||||
|
||||
void onChangeCrafting(IAEItemStack[] newCrafting, IAEItemStack[] newOutput);
|
||||
|
||||
void setCraftingRecipe(final boolean craftingMode);
|
||||
|
||||
void setSubstitution(boolean canSubstitute);
|
||||
|
||||
void setBeSubstitute(boolean canBeSubstitute);
|
||||
|
||||
void setCombineMode(boolean shouldCombine);
|
||||
|
||||
void setPrioritization(boolean canPrioritize);
|
||||
|
||||
void setInverted(boolean inverted);
|
||||
|
||||
int getActivePage();
|
||||
|
||||
void setActivePage(int activePage);
|
||||
|
||||
boolean isCraftingRecipe();
|
||||
|
||||
void sortCraftingItems();
|
||||
|
||||
default void saveSettings() {}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
package com.glodblock.github.inventory.item;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import appeng.api.config.*;
|
||||
import appeng.api.implementations.items.IAEItemPowerStorage;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.MEMonitorHandler;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.items.contents.WirelessTerminalViewCells;
|
||||
import appeng.items.tools.powered.ToolWirelessTerminal;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.ConfigManager;
|
||||
import appeng.util.Platform;
|
||||
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
public class WirelessFluidTerminal extends MEMonitorHandler<IAEFluidStack> implements IWirelessTerminal {
|
||||
|
||||
private final ItemStack target;
|
||||
private final IAEItemPowerStorage ips;
|
||||
private final int inventorySlot;
|
||||
private final AppEngInternalInventory viewCell;
|
||||
private final StorageChannel channel;
|
||||
private final IGridNode grid;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public WirelessFluidTerminal(final ItemStack is, final int slot, IGridNode gridNode, EntityPlayer player) {
|
||||
super(
|
||||
(IMEInventoryHandler<IAEFluidStack>) Objects
|
||||
.requireNonNull(Util.getWirelessInv(is, player, StorageChannel.FLUIDS)));
|
||||
this.ips = (ToolWirelessTerminal) is.getItem();
|
||||
this.grid = gridNode;
|
||||
this.target = is;
|
||||
this.inventorySlot = slot;
|
||||
this.viewCell = new WirelessTerminalViewCells(is);
|
||||
this.channel = StorageChannel.FLUIDS;
|
||||
}
|
||||
|
||||
public StorageChannel getChannel() {
|
||||
return this.channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
return this.target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double extractAEPower(double amt, Actionable mode, PowerMultiplier usePowerMultiplier) {
|
||||
amt = usePowerMultiplier.multiply(amt);
|
||||
if (mode == Actionable.SIMULATE) {
|
||||
return usePowerMultiplier.divide(Math.min(amt, this.ips.getAECurrentPower(this.target)));
|
||||
}
|
||||
return usePowerMultiplier.divide(this.ips.extractAEPower(this.target, amt));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEMonitor<IAEItemStack> getItemInventory() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEMonitor<IAEFluidStack> getFluidInventory() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigManager getConfigManager() {
|
||||
final ConfigManager out = new ConfigManager((manager, settingName, newValue) -> {
|
||||
final NBTTagCompound data = Platform.openNbtData(this.target);
|
||||
manager.writeToNBT(data);
|
||||
});
|
||||
out.registerSetting(Settings.SORT_BY, SortOrder.NAME);
|
||||
out.registerSetting(Settings.VIEW_MODE, ViewItems.ALL);
|
||||
out.registerSetting(Settings.SORT_DIRECTION, SortDir.ASCENDING);
|
||||
out.readFromNBT((NBTTagCompound) Platform.openNbtData(this.target).copy());
|
||||
return out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventorySlot() {
|
||||
return this.inventorySlot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getViewCellStorage() {
|
||||
return this.viewCell;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getGridNode(ForgeDirection dir) {
|
||||
return this.grid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType(ForgeDirection dir) {
|
||||
return AECableType.NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void securityBreak() {
|
||||
this.getGridNode(ForgeDirection.UNKNOWN).getMachine().securityBreak();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveChanges() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack,
|
||||
ItemStack newStack) {}
|
||||
}
|
||||
@@ -0,0 +1,312 @@
|
||||
package com.glodblock.github.inventory.item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import appeng.api.config.*;
|
||||
import appeng.api.implementations.items.IAEItemPowerStorage;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.MEMonitorHandler;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.items.contents.WirelessTerminalViewCells;
|
||||
import appeng.items.tools.powered.ToolWirelessTerminal;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.ConfigManager;
|
||||
import appeng.util.Platform;
|
||||
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.inventory.ItemBiggerAppEngInventory;
|
||||
import com.glodblock.github.inventory.WirelessFluidPatternTerminalPatterns;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
public class WirelessPatternTerminal extends MEMonitorHandler<IAEItemStack> implements IWirelessPatternTerminal {
|
||||
|
||||
private final ItemStack target;
|
||||
private final IAEItemPowerStorage ips;
|
||||
private final EntityPlayer p;
|
||||
private final int inventorySlot;
|
||||
private final AppEngInternalInventory viewCell;
|
||||
private final StorageChannel channel;
|
||||
private final IGridNode grid;
|
||||
|
||||
protected AppEngInternalInventory crafting;
|
||||
protected AppEngInternalInventory output;
|
||||
protected final WirelessFluidPatternTerminalPatterns pattern;
|
||||
|
||||
protected boolean craftingMode = true;
|
||||
protected boolean substitute = false;
|
||||
protected boolean combine = false;
|
||||
protected boolean prioritize = false;
|
||||
protected boolean inverted = false;
|
||||
protected boolean beSubstitute = false;
|
||||
protected int activePage = 0;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public WirelessPatternTerminal(final ItemStack is, final int slot, IGridNode gridNode, EntityPlayer player) {
|
||||
super(
|
||||
(IMEInventoryHandler<IAEItemStack>) Objects
|
||||
.requireNonNull(Util.getWirelessInv(is, player, StorageChannel.ITEMS)));
|
||||
this.ips = (ToolWirelessTerminal) is.getItem();
|
||||
this.grid = gridNode;
|
||||
this.target = is;
|
||||
this.p = player;
|
||||
this.inventorySlot = slot;
|
||||
this.viewCell = new WirelessTerminalViewCells(is);
|
||||
this.channel = StorageChannel.ITEMS;
|
||||
this.pattern = new WirelessFluidPatternTerminalPatterns(is);
|
||||
this.crafting = new ItemBiggerAppEngInventory(is, "crafting", 9);
|
||||
this.output = new ItemBiggerAppEngInventory(is, "output", 3);
|
||||
}
|
||||
|
||||
public StorageChannel getChannel() {
|
||||
return this.channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
return this.target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double extractAEPower(double amt, Actionable mode, PowerMultiplier usePowerMultiplier) {
|
||||
amt = usePowerMultiplier.multiply(amt);
|
||||
if (mode == Actionable.SIMULATE) {
|
||||
return usePowerMultiplier.divide(Math.min(amt, this.ips.getAECurrentPower(this.target)));
|
||||
}
|
||||
return usePowerMultiplier.divide(this.ips.extractAEPower(this.target, amt));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEMonitor<IAEItemStack> getItemInventory() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEMonitor<IAEFluidStack> getFluidInventory() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void readFromNBT() {
|
||||
NBTTagCompound data = Platform.openNbtData(this.target);
|
||||
this.setCraftingRecipe(data.getBoolean("craftingMode"));
|
||||
this.setSubstitution(data.getBoolean("substitute"));
|
||||
this.setCombineMode(data.getBoolean("combine"));
|
||||
this.setBeSubstitute(data.getBoolean("beSubstitute"));
|
||||
this.setPrioritization(data.getBoolean("priorization"));
|
||||
this.setInverted(data.getBoolean("inverted"));
|
||||
this.setActivePage(data.getInteger("activePage"));
|
||||
}
|
||||
|
||||
public void writeToNBT() {
|
||||
NBTTagCompound data = Platform.openNbtData(this.target);
|
||||
data.setBoolean("craftingMode", this.craftingMode);
|
||||
data.setBoolean("substitute", this.substitute);
|
||||
data.setBoolean("combine", this.combine);
|
||||
data.setBoolean("beSubstitute", this.beSubstitute);
|
||||
data.setBoolean("priorization", this.prioritize);
|
||||
data.setBoolean("inverted", this.inverted);
|
||||
data.setInteger("activePage", this.activePage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigManager getConfigManager() {
|
||||
final ConfigManager out = new ConfigManager((manager, settingName, newValue) -> {
|
||||
final NBTTagCompound data = Platform.openNbtData(this.target);
|
||||
manager.writeToNBT(data);
|
||||
});
|
||||
out.registerSetting(Settings.SORT_BY, SortOrder.NAME);
|
||||
out.registerSetting(Settings.VIEW_MODE, ViewItems.ALL);
|
||||
out.registerSetting(Settings.SORT_DIRECTION, SortDir.ASCENDING);
|
||||
out.readFromNBT((NBTTagCompound) Platform.openNbtData(this.target).copy());
|
||||
this.readFromNBT();
|
||||
return out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventorySlot() {
|
||||
return this.inventorySlot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getViewCellStorage() {
|
||||
return this.viewCell;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getGridNode(ForgeDirection dir) {
|
||||
return this.grid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType(ForgeDirection dir) {
|
||||
return AECableType.NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void securityBreak() {
|
||||
this.getGridNode(ForgeDirection.UNKNOWN).getMachine().securityBreak();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveChanges() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack,
|
||||
ItemStack newStack) {}
|
||||
|
||||
@Override
|
||||
public boolean isInverted() {
|
||||
return this.inverted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName(String name) {
|
||||
if (name.equals("crafting")) {
|
||||
return this.crafting;
|
||||
}
|
||||
|
||||
if (name.equals("output")) {
|
||||
return this.output;
|
||||
}
|
||||
|
||||
if (name.equals("pattern")) {
|
||||
return this.pattern;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeSubstitute() {
|
||||
return this.beSubstitute;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPrioritize() {
|
||||
return this.prioritize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSubstitution() {
|
||||
return this.substitute;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldCombine() {
|
||||
return this.combine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeCrafting(IAEItemStack[] newCrafting, IAEItemStack[] newOutput) {
|
||||
IInventory crafting = this.getInventoryByName("crafting");
|
||||
IInventory output = this.getInventoryByName("output");
|
||||
if (crafting instanceof AppEngInternalInventory && output instanceof AppEngInternalInventory) {
|
||||
for (int x = 0; x < crafting.getSizeInventory() && x < newCrafting.length; x++) {
|
||||
final IAEItemStack item = newCrafting[x];
|
||||
crafting.setInventorySlotContents(x, item == null ? null : item.getItemStack());
|
||||
}
|
||||
for (int x = 0; x < output.getSizeInventory() && x < newOutput.length; x++) {
|
||||
final IAEItemStack item = newOutput[x];
|
||||
output.setInventorySlotContents(x, item == null ? null : item.getItemStack());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCraftingRecipe(boolean craftingMode) {
|
||||
this.craftingMode = craftingMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSubstitution(boolean canSubstitute) {
|
||||
this.substitute = canSubstitute;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeSubstitute(boolean canBeSubstitute) {
|
||||
this.beSubstitute = canBeSubstitute;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCombineMode(boolean shouldCombine) {
|
||||
this.combine = shouldCombine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPrioritization(boolean canPrioritize) {
|
||||
this.prioritize = canPrioritize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInverted(boolean inverted) {
|
||||
this.inverted = inverted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getActivePage() {
|
||||
return this.activePage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActivePage(int activePage) {
|
||||
this.activePage = activePage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCraftingRecipe() {
|
||||
return this.craftingMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sortCraftingItems() {
|
||||
List<ItemStack> items = new ArrayList<ItemStack>();
|
||||
List<ItemStack> fluids = new ArrayList<ItemStack>();
|
||||
for (ItemStack is : this.crafting) {
|
||||
if (is == null) continue;
|
||||
if (is.getItem() instanceof ItemFluidPacket) {
|
||||
fluids.add(is);
|
||||
} else {
|
||||
items.add(is);
|
||||
}
|
||||
}
|
||||
if (this.prioritize) {
|
||||
fluids.addAll(items);
|
||||
items.clear();
|
||||
} else {
|
||||
items.addAll(fluids);
|
||||
fluids.clear();
|
||||
}
|
||||
|
||||
for (int i = 0; i < this.crafting.getSizeInventory(); i++) {
|
||||
if (this.crafting.getStackInSlot(i) == null) break;
|
||||
if (items.isEmpty()) {
|
||||
this.crafting.setInventorySlotContents(i, fluids.get(i));
|
||||
} else {
|
||||
this.crafting.setInventorySlotContents(i, items.get(i));
|
||||
}
|
||||
}
|
||||
saveChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveSettings() {
|
||||
this.writeToNBT();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,25 +1,73 @@
|
||||
package com.glodblock.github.inventory.slot;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.apache.commons.lang3.tuple.MutablePair;
|
||||
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
|
||||
public class FCSlotRestrictedInput extends SlotRestrictedInput {
|
||||
|
||||
private ItemStack valid;
|
||||
@FunctionalInterface
|
||||
public interface Filter {
|
||||
|
||||
MutablePair<Boolean, ItemStack> isItemValid(final ItemStack inputItem);
|
||||
}
|
||||
|
||||
private final Filter filter;
|
||||
private final InventoryPlayer p;
|
||||
private ItemStack validItem = null;
|
||||
|
||||
public FCSlotRestrictedInput(ItemStack valid, IInventory i, int slotIndex, int x, int y, InventoryPlayer p) {
|
||||
this(
|
||||
(inputItem) -> new MutablePair<>(
|
||||
valid.getItem().getClass().isAssignableFrom(inputItem.getItem().getClass()),
|
||||
valid),
|
||||
i,
|
||||
slotIndex,
|
||||
x,
|
||||
y,
|
||||
p);
|
||||
this.validItem = valid;
|
||||
}
|
||||
|
||||
public FCSlotRestrictedInput(Filter filter, IInventory i, int slotIndex, int x, int y, InventoryPlayer p) {
|
||||
super(PlacableItemType.INSCRIBER_PLATE, i, slotIndex, x, y, p);
|
||||
this.valid = valid;
|
||||
this.filter = filter;
|
||||
this.p = p;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(final ItemStack i) {
|
||||
if (i.getItem().getClass().isAssignableFrom(valid.getItem().getClass())) {
|
||||
return true;
|
||||
public boolean isItemValid(final ItemStack inputItem) {
|
||||
MutablePair<Boolean, ItemStack> result = this.filter.isItemValid(inputItem);
|
||||
return result.left;
|
||||
}
|
||||
|
||||
public boolean getAllowEdit() {
|
||||
return super.canTakeStack(this.p.player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack(final EntityPlayer par1EntityPlayer) {
|
||||
return getAllowEdit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPickupFromSlot(final EntityPlayer p, final ItemStack i) {
|
||||
if (getAllowEdit()) {
|
||||
super.onPickupFromSlot(p, i);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIcon() {
|
||||
if (validItem != null) {
|
||||
return super.getIcon();
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,9 @@
|
||||
package com.glodblock.github.loader;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.network.*;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
@@ -47,4 +51,12 @@ public class ChannelLoader implements Runnable {
|
||||
FluidCraft.proxy.netHandler
|
||||
.registerMessage(new SPacketSetItemAmount.Handler(), SPacketSetItemAmount.class, id++, Side.CLIENT);
|
||||
}
|
||||
|
||||
public static void sendPacketToAllPlayers(Packet packet, World world) {
|
||||
for (Object player : world.playerEntities) {
|
||||
if (player instanceof EntityPlayerMP) {
|
||||
((EntityPlayerMP) player).playerNetServerHandler.sendPacket(packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,8 @@ import com.glodblock.github.common.storage.CellType;
|
||||
|
||||
public class ItemAndBlockHolder {
|
||||
|
||||
public static BlockCertusQuartzTank CERTUS_QUARTZ_TANK = new BlockCertusQuartzTank().register();
|
||||
public static BlockFluidAutoFiller FLUID_AUTO_FILLER = new BlockFluidAutoFiller().register();
|
||||
public static BlockFluidDiscretizer DISCRETIZER = new BlockFluidDiscretizer().register();
|
||||
public static BlockLevelMaintainer LEVEL_MAINTAINER = new BlockLevelMaintainer().register();
|
||||
public static BlockFluidPatternEncoder ENCODER = new BlockFluidPatternEncoder().register();
|
||||
@@ -30,6 +32,8 @@ public class ItemAndBlockHolder {
|
||||
public static ItemFluidStorageMonitor FLUID_STORAGE_MONITOR = new ItemFluidStorageMonitor().register();
|
||||
public static ItemFluidConversionMonitor FLUID_CONVERSION_MONITOR = new ItemFluidConversionMonitor().register();
|
||||
public static ItemPortableFluidCell PORTABLE_FLUID_CELL = new ItemPortableFluidCell().register();
|
||||
public static ItemWirelessFluidTerminal WIRELESS_FLUID_TERM = new ItemWirelessFluidTerminal().register();
|
||||
public static ItemWirelessPatternTerminal WIRELESS_PATTERN_TERM = new ItemWirelessPatternTerminal().register();
|
||||
public static ItemFluidPacket PACKET = new ItemFluidPacket().register();
|
||||
public static ItemBasicFluidStorageCell CELL1K = new ItemBasicFluidStorageCell(CellType.Cell1kPart, 1).register();
|
||||
public static ItemBasicFluidStorageCell CELL4K = new ItemBasicFluidStorageCell(CellType.Cell4kPart, 4).register();
|
||||
|
||||
@@ -14,6 +14,7 @@ import net.minecraftforge.oredict.ShapelessOreRecipe;
|
||||
import com.glodblock.github.common.Config;
|
||||
import com.glodblock.github.common.item.ItemBasicFluidStorageCell;
|
||||
import com.glodblock.github.common.storage.CellType;
|
||||
import com.glodblock.github.loader.recipe.WirelessTerminalRecipe;
|
||||
import com.glodblock.github.util.ModAndClassUtil;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
@@ -93,6 +94,8 @@ public class RecipeLoader implements Runnable {
|
||||
GameRegistry.findItem("appliedenergistics2", "item.ItemMultiMaterial"),
|
||||
1,
|
||||
54);
|
||||
public static final ItemStack AE2_WIRELESS_TERMINAL = GameRegistry
|
||||
.findItemStack("appliedenergistics2", "item.ToolWirelessTerminal", 1);
|
||||
public static final ItemStack AE2_ME_CHEST = GameRegistry
|
||||
.findItemStack("appliedenergistics2", "tile.BlockChest", 1);
|
||||
public static final ItemStack AE2_ENERGY_CELL = GameRegistry
|
||||
@@ -128,6 +131,15 @@ public class RecipeLoader implements Runnable {
|
||||
AE2_INTERFACE));
|
||||
GameRegistry.addShapelessRecipe(FLUID_INTERFACE.stack(), INTERFACE.stack());
|
||||
GameRegistry.addShapelessRecipe(INTERFACE.stack(), FLUID_INTERFACE.stack());
|
||||
GameRegistry.addShapelessRecipe(WIRELESS_FLUID_TERM.stack(), AE2_WIRELESS_TERMINAL, BUCKET);
|
||||
GameRegistry.addShapelessRecipe(WIRELESS_PATTERN_TERM.stack(), WIRELESS_FLUID_TERM, FLUID_TERMINAL);
|
||||
if (ModAndClassUtil.WCT) {
|
||||
GameRegistry.addRecipe(new WirelessTerminalRecipe(WIRELESS_PATTERN_TERM.stack()));
|
||||
GameRegistry.addRecipe(new WirelessTerminalRecipe(WIRELESS_FLUID_TERM.stack()));
|
||||
}
|
||||
GameRegistry
|
||||
.addRecipe(new ShapedOreRecipe(CERTUS_QUARTZ_TANK.stack(), "GGG", "G G", "GGG", 'G', AE2_QUARTZ_GLASS));
|
||||
GameRegistry.addShapelessRecipe(FLUID_AUTO_FILLER.stack(), FLUID_TERMINAL, ENCODER);
|
||||
GameRegistry.addRecipe(
|
||||
new ShapedOreRecipe(
|
||||
DISCRETIZER.stack(),
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.glodblock.github.loader;
|
||||
|
||||
import com.glodblock.github.client.render.ItemCertusQuartzTankRender;
|
||||
import com.glodblock.github.client.render.ItemDropRender;
|
||||
import com.glodblock.github.client.render.ItemPacketRender;
|
||||
import com.glodblock.github.client.render.ItemWalrusRender;
|
||||
@@ -11,5 +12,6 @@ public class RenderLoader implements Runnable {
|
||||
new ItemDropRender();
|
||||
new ItemPacketRender();
|
||||
new ItemWalrusRender();
|
||||
new ItemCertusQuartzTankRender();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.glodblock.github.loader.recipe;
|
||||
|
||||
import static com.glodblock.github.util.Util.hasInfinityBoosterCard;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.ShapelessRecipes;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.p455w0rd.wirelesscraftingterminal.items.ItemEnum;
|
||||
import net.p455w0rd.wirelesscraftingterminal.items.ItemInfinityBooster;
|
||||
|
||||
import appeng.util.Platform;
|
||||
|
||||
import com.glodblock.github.common.item.ItemBaseWirelessTerminal;
|
||||
|
||||
public class WirelessTerminalRecipe extends ShapelessRecipes {
|
||||
|
||||
private static final ItemStack infinityBoosterCard = ItemEnum.BOOSTER_CARD.getStack();
|
||||
private final ItemStack installedTerm;
|
||||
|
||||
public WirelessTerminalRecipe(ItemStack term) {
|
||||
super(term, Arrays.asList(term, infinityBoosterCard));
|
||||
this.installedTerm = installInfinityBoosterCard(term);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(InventoryCrafting inv, World w) {
|
||||
ItemStack term = inv.getStackInSlot(0);
|
||||
ItemStack infinityBoosterCard = inv.getStackInSlot(1);
|
||||
return term != null && term.getItem() instanceof ItemBaseWirelessTerminal
|
||||
&& !hasInfinityBoosterCard(term)
|
||||
&& infinityBoosterCard != null
|
||||
&& infinityBoosterCard.getItem() instanceof ItemInfinityBooster;
|
||||
}
|
||||
|
||||
public static ItemStack getInfinityBoosterCard() {
|
||||
return infinityBoosterCard.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCraftingResult(InventoryCrafting inv) {
|
||||
return installInfinityBoosterCard(inv.getStackInSlot(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRecipeSize() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
private ItemStack installInfinityBoosterCard(ItemStack is) {
|
||||
is = is.copy();
|
||||
NBTTagCompound data = Platform.openNbtData(is);
|
||||
data.setBoolean(ItemBaseWirelessTerminal.infinityBoosterCard, true);
|
||||
is.setTagCompound(data);
|
||||
return is;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getRecipeOutput() {
|
||||
return installedTerm;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import codechicken.nei.api.IConfigureNEI;
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.GuiFluidPatternTerminal;
|
||||
import com.glodblock.github.client.gui.GuiFluidPatternTerminalEx;
|
||||
import com.glodblock.github.client.gui.GuiPatternPortableCell;
|
||||
import com.glodblock.github.nei.recipes.FluidRecipe;
|
||||
|
||||
public class NEI_FC_Config implements IConfigureNEI {
|
||||
@@ -15,6 +16,10 @@ public class NEI_FC_Config implements IConfigureNEI {
|
||||
API.registerNEIGuiHandler(new NEIGuiHandler());
|
||||
|
||||
for (String identifier : FluidRecipe.getSupportRecipes()) {
|
||||
API.registerGuiOverlayHandler(
|
||||
GuiPatternPortableCell.class,
|
||||
FluidPatternTerminalRecipeTransferHandler.INSTANCE,
|
||||
identifier);
|
||||
API.registerGuiOverlayHandler(
|
||||
GuiFluidPatternTerminal.class,
|
||||
FluidPatternTerminalRecipeTransferHandler.INSTANCE,
|
||||
|
||||
@@ -106,9 +106,18 @@ public class CPacketFluidPatternTermBtns implements IMessage {
|
||||
cpt.getPatternTerminal().setActivePage(Integer.parseInt(Value));
|
||||
break;
|
||||
case "PatternTerminal.Prioritize":
|
||||
cpt.getPatternTerminal().setPrioritization(Value.equals("1"));
|
||||
switch (Value) {
|
||||
case "0":
|
||||
case "1":
|
||||
cpt.getPatternTerminal().setPrioritization(Value.equals("1"));
|
||||
break;
|
||||
case "2":
|
||||
cpt.getPatternTerminal().sortCraftingItems();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
cpt.getPatternTerminal().saveSettings();
|
||||
} else if (Name.equals("Terminal.Cpu") && c instanceof ContainerFluidCraftConfirm) {
|
||||
final ContainerFluidCraftConfirm qk = (ContainerFluidCraftConfirm) c;
|
||||
qk.cycleCpu(Value.equals("Next"));
|
||||
|
||||
@@ -14,6 +14,7 @@ import appeng.container.ContainerOpenContext;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
@@ -60,15 +61,25 @@ public class CPacketSwitchGuis implements IMessage {
|
||||
return null;
|
||||
}
|
||||
TileEntity te = context.getTile();
|
||||
if (te == null) {
|
||||
return null;
|
||||
if (te != null) {
|
||||
InventoryHandler.openGui(
|
||||
player,
|
||||
player.worldObj,
|
||||
new BlockPos(te),
|
||||
Objects.requireNonNull(context.getSide()),
|
||||
message.guiType);
|
||||
} else {
|
||||
InventoryHandler.openGui(
|
||||
player,
|
||||
player.worldObj,
|
||||
new BlockPos(
|
||||
player.inventory.currentItem,
|
||||
Util.GuiHelper.encodeType(0, Util.GuiHelper.GuiType.ITEM),
|
||||
0),
|
||||
Objects.requireNonNull(context.getSide()),
|
||||
message.guiType);
|
||||
}
|
||||
InventoryHandler.openGui(
|
||||
player,
|
||||
player.worldObj,
|
||||
new BlockPos(te),
|
||||
Objects.requireNonNull(context.getSide()),
|
||||
message.guiType);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,15 +38,11 @@ public class FluidSorters {
|
||||
}
|
||||
};
|
||||
|
||||
public static final Comparator<IAEItemStack> CONFIG_BASED_SORT_BY_NAME = new Comparator<IAEItemStack>() {
|
||||
|
||||
@Override
|
||||
public int compare(final IAEItemStack o1, final IAEItemStack o2) {
|
||||
if (getDirection() == SortDir.ASCENDING) {
|
||||
return Platform.getItemDisplayName(o1).compareToIgnoreCase(Platform.getItemDisplayName(o2));
|
||||
}
|
||||
return Platform.getItemDisplayName(o2).compareToIgnoreCase(Platform.getItemDisplayName(o1));
|
||||
public static final Comparator<IAEItemStack> CONFIG_BASED_SORT_BY_NAME = (o1, o2) -> {
|
||||
if (getDirection() == SortDir.ASCENDING) {
|
||||
return Platform.getItemDisplayName(o1).compareToIgnoreCase(Platform.getItemDisplayName(o2));
|
||||
}
|
||||
return Platform.getItemDisplayName(o2).compareToIgnoreCase(Platform.getItemDisplayName(o1));
|
||||
};
|
||||
public static final Comparator<IAEItemStack> CONFIG_BASED_SORT_BY_SIZE = new Comparator<IAEItemStack>() {
|
||||
|
||||
@@ -89,33 +85,15 @@ public class FluidSorters {
|
||||
}
|
||||
|
||||
public static int compareInt(final int a, final int b) {
|
||||
if (a == b) {
|
||||
return 0;
|
||||
}
|
||||
if (a < b) {
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
return Integer.compare(a, b);
|
||||
}
|
||||
|
||||
public static int compareLong(final long a, final long b) {
|
||||
if (a == b) {
|
||||
return 0;
|
||||
}
|
||||
if (a < b) {
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
return Long.compare(a, b);
|
||||
}
|
||||
|
||||
public static int compareDouble(final double a, final double b) {
|
||||
if (a == b) {
|
||||
return 0;
|
||||
}
|
||||
if (a < b) {
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
return Double.compare(a, b);
|
||||
}
|
||||
|
||||
private static SortDir getDirection() {
|
||||
|
||||
@@ -9,12 +9,14 @@ import com.glodblock.github.FluidCraft;
|
||||
|
||||
public class NameConst {
|
||||
|
||||
public static final String BLOCK_CERTUS_QUARTZ_TANK = "certus_quartz_tank";
|
||||
public static final String BLOCK_FLUID_DISCRETIZER = "fluid_discretizer";
|
||||
public static final String BLOCK_FLUID_PATTERN_ENCODER = "fluid_pattern_encoder";
|
||||
public static final String BLOCK_FLUID_PACKET_DECODER = "fluid_packet_decoder";
|
||||
public static final String BLOCK_FLUID_INTERFACE = "fluid_interface";
|
||||
public static final String BLOCK_INGREDIENT_BUFFER = "ingredient_buffer";
|
||||
public static final String BLOCK_FLUID_BUFFER = "fluid_buffer";
|
||||
public static final String BLOCK_FLUID_AUTO_FILLER = "fluid_auto_filler";
|
||||
public static final String BLOCK_LARGE_INGREDIENT_BUFFER = "large_ingredient_buffer";
|
||||
public static final String BLOCK_OC_PATTERN_EDITOR = "oc_pattern_editor";
|
||||
public static final String BLOCK_LEVEL_MAINTAINER = "level_maintainer";
|
||||
@@ -34,6 +36,8 @@ public class NameConst {
|
||||
public static final String ITEM_FLUID_PACKET = "fluid_packet";
|
||||
public static final String ITEM_FLUID_STORAGE = "fluid_storage";
|
||||
public static final String ITEM_FLUID_PORTABLE_CELL = "portable_fluid_cell";
|
||||
public static final String ITEM_WIRELESS_FLUID_TERMINAL = "wireless_fluid_terminal";
|
||||
public static final String ITEM_WIRELESS_FLUID_PATTERN_TERMINAL = "wireless_fluid_pattern_terminal";
|
||||
public static final String ITEM_FLUID_PART = "fluid_part";
|
||||
|
||||
public static final String TT_KEY = FluidCraft.MODID + ".tooltip.";
|
||||
@@ -70,6 +74,9 @@ public class NameConst {
|
||||
public static final String TT_CELL_CONTENTS = TT_KEY + "cell_contents";
|
||||
public static final String TT_CELL_EMPTY = TT_KEY + "cell_empty";
|
||||
public static final String TT_CELL_PORTABLE = TT_KEY + "cell_portable";
|
||||
public static final String TT_WIRELESS = TT_KEY + "wireless.";
|
||||
public static final String TT_WIRELESS_INSTALLED = TT_WIRELESS + "installed";
|
||||
public static final String TT_FLUID_AUTO_FILLER = TT_KEY + "fluid_auto_filler";
|
||||
|
||||
public static final String WAILA_KEY = FluidCraft.MODID + ".waila.";
|
||||
public static final String WAILA_ENABLE = WAILA_KEY + "enable";
|
||||
@@ -85,6 +92,7 @@ public class NameConst {
|
||||
public static final String GUI_LEVEL_MAINTAINER = GUI_KEY + BLOCK_LEVEL_MAINTAINER;
|
||||
public static final String GUI_FLUID_PATTERN_ENCODER = GUI_KEY + BLOCK_FLUID_PATTERN_ENCODER;
|
||||
public static final String GUI_FLUID_PACKET_DECODER = GUI_KEY + BLOCK_FLUID_PACKET_DECODER;
|
||||
public static final String GUI_FLUID_AUTO_FILLER = GUI_KEY + BLOCK_FLUID_AUTO_FILLER;
|
||||
public static final String GUI_INGREDIENT_BUFFER = GUI_KEY + BLOCK_INGREDIENT_BUFFER;
|
||||
public static final String GUI_LARGE_INGREDIENT_BUFFER = GUI_KEY + BLOCK_LARGE_INGREDIENT_BUFFER;
|
||||
public static final String GUI_FLUID_INTERFACE = GUI_KEY + BLOCK_FLUID_INTERFACE;
|
||||
|
||||
@@ -72,4 +72,11 @@ public final class RenderUtil {
|
||||
public static List<String> listFormattedStringToWidth(String str) {
|
||||
return Minecraft.getMinecraft().fontRenderer.listFormattedStringToWidth(str, 150);
|
||||
}
|
||||
|
||||
public static void setGLColorFromInt(int color) {
|
||||
float red = (color >> 16 & 255) / 255.0F;
|
||||
float green = (color >> 8 & 255) / 255.0F;
|
||||
float blue = (color & 255) / 255.0F;
|
||||
GL11.glColor4f(red, green, blue, 1.0F);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.glodblock.github.util;
|
||||
|
||||
import static com.glodblock.github.common.item.ItemBaseWirelessTerminal.infinityBoosterCard;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -11,19 +13,30 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.*;
|
||||
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.MutablePair;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.implementations.tiles.IWirelessAccessPoint;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.security.ISecurityGrid;
|
||||
import appeng.api.networking.storage.IBaseMonitor;
|
||||
import appeng.api.networking.storage.IStorageGrid;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.util.WorldCoord;
|
||||
import appeng.items.tools.powered.ToolWirelessTerminal;
|
||||
import appeng.tile.networking.TileCableBus;
|
||||
import appeng.tile.networking.TileWireless;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
|
||||
import com.glodblock.github.common.item.ItemBaseWirelessTerminal;
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.inventory.IAEFluidTank;
|
||||
@@ -34,6 +47,62 @@ import io.netty.buffer.ByteBuf;
|
||||
|
||||
public final class Util {
|
||||
|
||||
public static boolean hasInfinityBoosterCard(ItemStack is) {
|
||||
if (ModAndClassUtil.WCT && is.getItem() instanceof ItemBaseWirelessTerminal) {
|
||||
NBTTagCompound data = Platform.openNbtData(is);
|
||||
return data.hasKey(infinityBoosterCard) && data.getBoolean(infinityBoosterCard);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static IGridNode getWirelessGrid(ItemStack is) {
|
||||
if (is.getItem() instanceof ToolWirelessTerminal) {
|
||||
String key = ((ToolWirelessTerminal) is.getItem()).getEncryptionKey(is);
|
||||
IGridHost securityTerminal = (IGridHost) AEApi.instance().registries().locatable()
|
||||
.getLocatableBy(Long.parseLong(key));
|
||||
if (securityTerminal == null) return null;
|
||||
return securityTerminal.getGridNode(ForgeDirection.UNKNOWN);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static IBaseMonitor<? extends IAEStack<? extends IAEStack<?>>> getWirelessInv(ItemStack is,
|
||||
EntityPlayer player, StorageChannel channel) {
|
||||
IGridNode gridNode = getWirelessGrid(is);
|
||||
if (gridNode == null) return null;
|
||||
IGrid grid = gridNode.getGrid();
|
||||
if (grid == null) return null;
|
||||
boolean canConnect = false;
|
||||
if (hasInfinityBoosterCard(is)) {
|
||||
canConnect = true;
|
||||
} else {
|
||||
for (IGridNode node : grid.getMachines(TileWireless.class)) {
|
||||
IWirelessAccessPoint accessPoint = (IWirelessAccessPoint) node.getMachine();
|
||||
if (accessPoint.isActive() && accessPoint.getLocation().getDimension() == player.dimension) {
|
||||
WorldCoord distance = accessPoint.getLocation()
|
||||
.subtract((int) player.posX, (int) player.posY, (int) player.posZ);
|
||||
int squaredDistance = distance.x * distance.x + distance.y * distance.y + distance.z * distance.z;
|
||||
if (squaredDistance <= accessPoint.getRange() * accessPoint.getRange()) {
|
||||
canConnect = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (canConnect) {
|
||||
IStorageGrid gridCache = grid.getCache(IStorageGrid.class);
|
||||
if (gridCache != null) {
|
||||
if (channel == StorageChannel.FLUIDS) {
|
||||
return gridCache.getFluidInventory();
|
||||
} else {
|
||||
return gridCache.getItemInventory();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int findItemInPlayerInvSlot(EntityPlayer player, ItemStack itemStack) {
|
||||
for (int i = 0; i < player.inventory.mainInventory.length; i++) {
|
||||
if (player.inventory.mainInventory[i] != null && player.inventory.mainInventory[i] == itemStack) return i;
|
||||
@@ -218,6 +287,35 @@ public final class Util {
|
||||
}
|
||||
}
|
||||
|
||||
public static class GuiHelper {
|
||||
|
||||
public enum GuiType {
|
||||
TILE,
|
||||
ITEM
|
||||
}
|
||||
|
||||
private static final int value = 1 << 30;
|
||||
|
||||
public static int encodeType(int y, GuiType type) {
|
||||
if (Math.abs(y) > (1 << 28)) {
|
||||
throw new IllegalArgumentException("out of range");
|
||||
}
|
||||
return value | (type.ordinal() << 29) | y;
|
||||
}
|
||||
|
||||
public static ImmutablePair<GuiType, Integer> decodeType(int y) {
|
||||
if (Math.abs(y) > (1 << 28)) {
|
||||
return new ImmutablePair<>(GuiType.values()[y >> 29 & 1], y - (3 << 29 & y));
|
||||
} else {
|
||||
return new ImmutablePair<>(GuiType.TILE, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static int clamp(int value, int min, int max) {
|
||||
return value < min ? min : (Math.min(value, max));
|
||||
}
|
||||
|
||||
public static class FluidUtil {
|
||||
|
||||
public static IAEFluidStack createAEFluidStack(Fluid fluid) {
|
||||
|
||||
@@ -11,6 +11,8 @@ item.part_fluid_level_emitter.name=ME Fluid Level Emitter
|
||||
item.part_fluid_storage_monitor.name=ME Fluid Storage Monitor
|
||||
item.part_fluid_conversion_monitor.name=ME Fluid Conversion Monitor
|
||||
item.portable_fluid_cell.name=Portable Fluid Cell
|
||||
item.wireless_fluid_terminal.name=Wireless Fluid Terminal
|
||||
item.wireless_fluid_pattern_terminal.name=Wireless Fluid Pattern Terminal
|
||||
item.fluid_packet.name=Fluid Packet
|
||||
item.fluid_storage.1.name=%s1k%s ME Fluid Storage Cell
|
||||
item.fluid_storage.4.name=%s4k%s ME Fluid Storage Cell
|
||||
@@ -39,6 +41,8 @@ tile.oc_pattern_editor.name=OC Pattern Editor
|
||||
tile.level_maintainer.name=ME Level Maintainer
|
||||
tile.fluid_buffer.name=ME Fluid Buffer
|
||||
tile.walrus.name=Walrus
|
||||
tile.fluid_auto_filler.name=ME Fluid Auto Filler
|
||||
tile.certus_quartz_tank.name=Certus Quartz Tank
|
||||
|
||||
ae2fc.waila.speed=Speed
|
||||
ae2fc.waila.enable=Enable
|
||||
@@ -50,6 +54,7 @@ ae2fc.tooltip.fluid_packet_decoder.desc=The Fluid Decoder can decode Fluid packe
|
||||
ae2fc.tooltip.discretizer.desc=When the ME Fluid Discretizer is attached to your ME System, it will represent the Fluids that are stored in your ME Fluid Storage Cells (Or Storage bus) as drops. They will be the item equivalent of fluids. Its just another way to show fluids, it won't actually convert your fluids to items.
|
||||
ae2fc.tooltip.fluid_buffer.desc=This is a high speed fluid IO
|
||||
ae2fc.tooltip.walrus.desc=GTNH is like a job
|
||||
ae2fc.tooltip.fluid_auto_filler=Creates fluid canning pattern with given container automatically.
|
||||
ae2fc.tooltip.level_maintainer.Who_Am_I=Who Am I?
|
||||
ae2fc.tooltip.level_maintainer.title=§6Request Status§r
|
||||
ae2fc.tooltip.level_maintainer.desc=Automatically keeps items and fluids in stock by requesting new crafts when needed. Has to be connected to an ME network.
|
||||
@@ -80,6 +85,7 @@ ae2fc.tooltip.not_combine=Merge the same items
|
||||
ae2fc.tooltip.not_combine.hint=Disabled
|
||||
ae2fc.tooltip.combine=Merge the same items
|
||||
ae2fc.tooltip.combine.hint=Enabled
|
||||
ae2fc.tooltip.wireless.installed=Installed Card:
|
||||
|
||||
ae2fc.tooltip.not_prio=Allow fluids to be placed first
|
||||
ae2fc.tooltip.not_prio.hint=Enabled
|
||||
@@ -110,6 +116,7 @@ ae2fc.gui.part_fluid_import=ME Fluid Import Bus
|
||||
ae2fc.gui.part_fluid_export=ME Fluid Export Bus
|
||||
ae2fc.gui.part_fluid_terminal=ME Fluid Terminal
|
||||
ae2fc.gui.part_fluid_storage_bus=ME Fluid Storage Bus
|
||||
ae2fc.gui.fluid_auto_filler=ME Fluid Auto Filler
|
||||
|
||||
error.unknown=Unknown
|
||||
|
||||
|
||||
@@ -10,6 +10,9 @@ item.part_fluid_storage_bus.name=ME流体存储总线
|
||||
item.part_fluid_level_emitter.name=ME流体发信器
|
||||
item.part_fluid_storage_monitor.name=ME流体存储监控器
|
||||
item.part_fluid_conversion_monitor.name=ME流体交换监控器
|
||||
item.portable_fluid_cell.name=便携流体单元
|
||||
item.wireless_fluid_terminal.name=无线流体终端
|
||||
item.wireless_fluid_pattern_terminal.name=无线样板终端
|
||||
item.fluid_packet.name=流体封包
|
||||
item.fluid_storage.1.name=%s1k%s-ME流体存储元件
|
||||
item.fluid_storage.4.name=%s4k%s-ME流体存储元件
|
||||
@@ -18,6 +21,7 @@ item.fluid_storage.64.name=%s64k%s-ME流体存储元件
|
||||
item.fluid_storage.256.name=%s256k%s-ME流体存储元件
|
||||
item.fluid_storage.1024.name=%s1024k%s-ME流体存储元件
|
||||
item.fluid_storage.4096.name=%s4096k%s-ME流体存储元件
|
||||
item.fluid_storage.16384.name=%s16384k%s-ME流体存储元件
|
||||
item.fluid_part.0.name=%s1k%s-ME流体存储组件
|
||||
item.fluid_part.1.name=%s4k%s-ME流体存储组件
|
||||
item.fluid_part.2.name=%s16k%s-ME流体存储组件
|
||||
@@ -25,6 +29,7 @@ item.fluid_part.3.name=%s64k%s-ME流体存储组件
|
||||
item.fluid_part.4.name=%s256k%s-ME流体存储组件
|
||||
item.fluid_part.5.name=%s1024k%s-ME流体存储组件
|
||||
item.fluid_part.6.name=%s4096k%s-ME流体存储组件
|
||||
item.fluid_part.7.name=%s16384k%s-ME流体存储组件
|
||||
|
||||
tile.fluid_discretizer.name=ME流体离散器
|
||||
tile.fluid_pattern_encoder.name=流体适配型样板编码台
|
||||
@@ -36,6 +41,8 @@ tile.oc_pattern_editor.name=OC样板编辑器
|
||||
tile.level_maintainer.name=ME库存维持器
|
||||
tile.fluid_buffer.name=ME流体缓存器
|
||||
tile.walrus.name=海象
|
||||
tile.fluid_auto_filler.name=ME流体自动装填器
|
||||
tile.certus_quartz_tank.name=赛特斯石英水槽
|
||||
|
||||
ae2fc.waila.speed=速度
|
||||
ae2fc.waila.enable=启用
|
||||
@@ -47,6 +54,7 @@ ae2fc.tooltip.fluid_packet_decoder.desc=流体解码器可以解码液体数据
|
||||
ae2fc.tooltip.discretizer.desc=当ME流体离散器连接到您的ME系统时,它将把存储在的ME流体存储单元(或存储总线)中的流体表现为物品液滴。它们将是流体的等价物。它只是显示流体的另一种方式,它不会真正把你的流体转换成物品。
|
||||
ae2fc.tooltip.fluid_buffer.desc=这就是一个高速的流体IO接口
|
||||
ae2fc.tooltip.walrus.desc=GTNH is like a job
|
||||
ae2fc.tooltip.fluid_auto_filler=自动生成指定容器流体灌装样板。
|
||||
ae2fc.tooltip.level_maintainer.Who_Am_I=Who Am I?
|
||||
ae2fc.tooltip.level_maintainer.title=§6请求状态§r
|
||||
ae2fc.tooltip.level_maintainer.desc=通过在需要时请求合成,自动保持物品和流体的库存。必须连接到ME网络。
|
||||
@@ -64,7 +72,8 @@ ae2fc.tooltip.level_maintainer.request_size=§6缓存量§r
|
||||
ae2fc.tooltip.level_maintainer.request_size.hint=数量定义了在请求器开始请求新合成之前应该保留多少物品。
|
||||
|
||||
ae2fc.tooltip.cell_contents=内含流体:
|
||||
ae2fc.tooltip.cell_empty=Cell is empty
|
||||
ae2fc.tooltip.cell_empty=空存储
|
||||
ae2fc.tooltip.cell_portable=右键打开GUI,它就像一个背包,但你需要在使用前给它充能。
|
||||
ae2fc.tooltip.fluid_terminal=我们不再需要EC2了吗?
|
||||
ae2fc.tooltip.invalid_fluid=流体无效!
|
||||
ae2fc.tooltip.encode_pattern=编写样板
|
||||
@@ -76,6 +85,7 @@ ae2fc.tooltip.not_combine=合并输出相同物品
|
||||
ae2fc.tooltip.not_combine.hint=禁用
|
||||
ae2fc.tooltip.combine=合并输出相同物品
|
||||
ae2fc.tooltip.combine.hint=启用
|
||||
ae2fc.tooltip.wireless.installed=已安装的卡:
|
||||
|
||||
ae2fc.tooltip.not_prio=优先放置流体
|
||||
ae2fc.tooltip.not_prio.hint=启用
|
||||
@@ -106,6 +116,7 @@ ae2fc.gui.part_fluid_import=ME流体输入总线
|
||||
ae2fc.gui.part_fluid_export=ME流体输出总线
|
||||
ae2fc.gui.part_fluid_terminal=流体终端
|
||||
ae2fc.gui.part_fluid_storage_bus=ME流体存储总线
|
||||
ae2fc.gui.fluid_auto_filler=ME流体自动装填器
|
||||
|
||||
error.unknown=未知流体
|
||||
|
||||
|
||||
|
After Width: | Height: | Size: 297 B |
|
After Width: | Height: | Size: 230 B |
|
After Width: | Height: | Size: 710 B |
|
After Width: | Height: | Size: 177 B |
|
After Width: | Height: | Size: 204 B |
|
After Width: | Height: | Size: 182 B |
|
After Width: | Height: | Size: 189 B |
|
After Width: | Height: | Size: 329 B |
|
After Width: | Height: | Size: 995 B |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 355 B |