Skip to content

Commit

Permalink
Merge remote-tracking branch 'asdflj/bookmark' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Dream-Master committed Jan 28, 2023
2 parents fc9893a + 44ff338 commit d60b850
Show file tree
Hide file tree
Showing 14 changed files with 522 additions and 10 deletions.
2 changes: 1 addition & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.glodblock.github.client.gui;

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;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;

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);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package com.glodblock.github.client.gui.container;

import appeng.container.AEBaseContainer;
import appeng.container.slot.SlotFake;
import com.glodblock.github.common.tile.TileFluidAutoFiller;
import com.glodblock.github.util.Util;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import org.apache.commons.lang3.tuple.MutablePair;

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();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package com.glodblock.github.common.block;

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.Util;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ChatComponentText;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;

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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
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;

public class ItemPartFluidTerminal extends FCBaseItem implements IPartItem {
Expand Down Expand Up @@ -50,8 +49,12 @@ public boolean onItemUse(
@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
Expand Down
Loading

0 comments on commit d60b850

Please sign in to comment.