Compare commits

..
21 changed files with 390 additions and 232 deletions

No files matched your search

+6 -5
View File
@@ -34,11 +34,11 @@
* For more details, see https://docs.gradle.org/8.0.1/userguide/java_library_plugin.html#sec:java_library_configurations_graph
*/
dependencies {
api('com.github.GTNewHorizons:NotEnoughItems:2.8.33-GTNH:dev')
api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-739-GTNH:dev')
api('com.github.GTNewHorizons:NotEnoughItems:2.8.26-GTNH:dev')
api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-727-GTNH:dev')
api('curse.maven:cofh-core-69162:2388751')
api('com.github.GTNewHorizons:waila:1.9.7:dev')
api("com.github.GTNewHorizons:GTNHLib:0.8.0:dev")
api("com.github.GTNewHorizons:GTNHLib:0.7.3:dev")
implementation("com.github.GTNewHorizons:WirelessCraftingTerminal:1.12.7:dev") {
exclude group: 'com.github.GTNewHorizons', module: 'Applied-Energistics-2-Unofficial'
@@ -46,9 +46,9 @@ dependencies {
compileOnly('com.github.GTNewHorizons:Baubles-Expanded:2.2.2-GTNH:dev')
compileOnly('com.github.GTNewHorizons:ExtraCells2:2.5.35:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:ForestryMC:4.11.2:dev')
compileOnly('com.github.GTNewHorizons:ForestryMC:4.11.0:dev')
compileOnly('com.github.GTNewHorizons:EnderIO:2.10.3:dev')
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.52.99:dev') {
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.52.87:dev') {
exclude group: 'com.github.GTNewHorizons', module: 'AE2FluidCraft-Rework'
exclude group: 'com.github.GTNewHorizons', module: 'Applied-Energistics-2-Unofficial'
}
@@ -57,6 +57,7 @@ dependencies {
compileOnly('com.gregoriust.gregtech:gregtech_1.7.10:6.14.23:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:OpenComputers:1.12.4-GTNH:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:ThaumicEnergistics:1.7.14-GTNH:dev') { transitive = false }
compileOnly("com.github.GTNewHorizons:Hodgepodge:2.7.9:dev") { transitive = false }
runtimeOnlyNonPublishable("com.github.GTNewHorizons:DuraDisplay:1.4.0:dev")
}
@@ -19,7 +19,9 @@ import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.network.CPacketFluidUpdate;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.Util;
import com.mitchej123.hodgepodge.textures.IPatchedTextureAtlasSprite;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEFluidStack;
@@ -95,6 +97,10 @@ public class GuiFluidTerminal extends GuiFluidMonitor {
IIcon icon = fluid.getIcon();
if (icon == null) return;
if (ModAndClassUtil.HODGEPODGE && icon instanceof IPatchedTextureAtlasSprite) {
((IPatchedTextureAtlasSprite) icon).markNeedsAnimationUpdate();
}
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_BLEND);
@@ -103,7 +109,7 @@ public class GuiFluidTerminal extends GuiFluidMonitor {
(fluid.getColor() >> 16 & 0xFF) / 255.0F,
(fluid.getColor() >> 8 & 0xFF) / 255.0F,
(fluid.getColor() & 0xFF) / 255.0F);
drawTexturedModelRectFromIcon(posX, posY, icon, 16, 16);
drawTexturedModelRectFromIcon(posX, posY, fluid.getIcon(), 16, 16);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_BLEND);
GL11.glColor3f(1, 1, 1);
@@ -17,9 +17,10 @@ import org.lwjgl.opengl.GL11;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.render.tank.ModelCertusTank;
import com.glodblock.github.common.item.ItemCertusQuartzTank;
import com.glodblock.github.common.tile.TileCertusQuartzTank;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.util.ModAndClassUtil;
import com.mitchej123.hodgepodge.textures.IPatchedTextureAtlasSprite;
import cpw.mods.fml.client.registry.ClientRegistry;
@@ -34,7 +35,7 @@ public class ItemCertusQuartzTankRender implements IItemRenderer {
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
return true;
return type != ItemRenderType.EQUIPPED_FIRST_PERSON;
}
@Override
@@ -48,32 +49,31 @@ public class ItemCertusQuartzTankRender implements IItemRenderer {
.bindTexture(FluidCraft.resource("textures/blocks/certus_quartz_tank/map.png"));
GL11.glPushMatrix();
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
GL11.glDisable(GL11.GL_CULL_FACE);
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glDisable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
if (type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) {
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
}
GL11.glRotatef(180F, 1F, 0F, 0F);
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);
GL11.glRotatef(180F, 1F, 0F, 0F);
if (item.getItem() instanceof ItemCertusQuartzTank itemCertusQuartzTank) {
FluidStack storedFluid = itemCertusQuartzTank.getFluid(item);
int tankCapacity = itemCertusQuartzTank.getCapacity(item);
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();
if (ModAndClassUtil.HODGEPODGE && fluidIcon instanceof IPatchedTextureAtlasSprite) {
((IPatchedTextureAtlasSprite) fluidIcon).markNeedsAnimationUpdate();
}
Tessellator tessellator = Tessellator.instance;
RenderBlocks renderer = new RenderBlocks();
Block waterBlock = FluidRegistry.WATER.getBlock();
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
GL11.glScalef(1, 1, -1);
renderer.setRenderBounds(
0.08F,
0.001F,
@@ -81,12 +81,9 @@ public class ItemCertusQuartzTankRender implements IItemRenderer {
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);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
Block waterBlock = FluidRegistry.WATER.getBlock();
tessellator.startDrawingQuads();
tessellator.setColorRGBA_F(
(storedFluid.getFluid().getColor() >> 16 & 0xFF) / 255.0F,
@@ -13,7 +13,9 @@ import org.lwjgl.opengl.GL11;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.RenderUtil;
import com.mitchej123.hodgepodge.textures.IPatchedTextureAtlasSprite;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -44,9 +46,16 @@ public class ItemPacketRender implements IItemRenderer {
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
FluidStack fluid = ItemFluidPacket.getFluidStack(item);
int RGB = fluid == null ? 0xFFFFFF : fluid.getFluid().getColor(fluid);
int RGB = 0xFFFFFF;
if (fluid != null) {
RGB = fluid.getFluid().getColor(fluid);
}
IIcon icon = fluid == null ? FluidRegistry.WATER.getStillIcon() : fluid.getFluid().getStillIcon();
if (ModAndClassUtil.HODGEPODGE && icon instanceof IPatchedTextureAtlasSprite) {
((IPatchedTextureAtlasSprite) icon).markNeedsAnimationUpdate();
}
if (RGB != 0xFFFFFF) {
GL11.glColor3f((RGB >> 16 & 0xFF) / 255.0F, (RGB >> 8 & 0xFF) / 255.0F, (RGB & 0xFF) / 255.0F);
}
@@ -25,7 +25,8 @@ public class ModelCertusTank extends ModelBase {
this.textureHeight = 64;
this.Shape1 = new ModelRenderer(this, 0, 0);
this.Shape1.addBox(-7F, -8F, -7F, 14, 16, 14);
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);
@@ -2,10 +2,10 @@ 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.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
@@ -16,11 +16,11 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidContainerItem;
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;
@@ -106,104 +106,71 @@ public class BlockCertusQuartzTank extends BaseBlockContainer implements IRegist
}
@Override
public boolean onBlockActivated(World worldObj, int x, int y, int z, EntityPlayer player, int side, float offsetX,
float offsetY, float offsetZ) {
ItemStack itemInHand = player.inventory.getCurrentItem();
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 (itemInHand == null || itemInHand.getItem() == null) {
return false;
}
// In case if we're holding a IFluidContainerItem which is also a block we'll just allow to place a block
// instead of trying to fill or drain it. In other cases we don't need to handle blocks either way
if (itemInHand.getItem() instanceof ItemBlock) {
return false;
}
if (player.isSneaking()) {
if (itemInHand.getItem() instanceof IAEWrench wrench && wrench.canWrench(itemInHand, player, x, y, z)) {
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);
TileCertusQuartzTank tank = (TileCertusQuartzTank) worldObj.getTileEntity(x, y, z);
boolean isCreativeMode = player.capabilities.isCreativeMode;
if (FluidContainerRegistry.isFilledContainer(itemInHand)) {
// Fill the tank from the container in hand
FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(itemInHand);
if (fluid == null) {
return false;
}
int amountFilled = tank.fill(ForgeDirection.UNKNOWN, fluid, true);
if (amountFilled > 0 && !isCreativeMode) {
ItemStack empty = FluidContainerRegistry.drainFluidContainer(itemInHand);
replaceItemInInventory(worldObj, player, itemInHand, empty);
}
return true;
} else if (FluidContainerRegistry.isEmptyContainer(itemInHand)) {
// Fill the container in hand from the tank
FluidStack available = tank.getTankInfo(true)[0].fluid;
ItemStack filled = FluidContainerRegistry.fillFluidContainer(available, itemInHand);
FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(filled);
if (fluid == null) {
return false;
}
tank.drain(ForgeDirection.UNKNOWN, fluid.amount, true);
if (!isCreativeMode) {
replaceItemInInventory(worldObj, player, itemInHand, filled);
}
return true;
} else if (itemInHand.getItem() instanceof IFluidContainerItem) {
ItemStack singleContainerItem = itemInHand.copy();
singleContainerItem.stackSize = 1;
IFluidContainerItem fluidContainer = (IFluidContainerItem) singleContainerItem.getItem();
assert fluidContainer != null;
FluidStack fluid = fluidContainer.getFluid(itemInHand);
if (fluid != null && fluid.amount > 0) {
// Fill the tank from the container in hand
int filled = tank.fill(ForgeDirection.UNKNOWN, fluid, true);
if (filled > 0 && !isCreativeMode) {
fluidContainer.drain(singleContainerItem, filled, true);
replaceItemInInventory(worldObj, player, itemInHand, singleContainerItem);
if (liquid != null) {
int amountFilled = tank.fill(ForgeDirection.UNKNOWN, liquid, true);
if (amountFilled != 0 && !entityplayer.capabilities.isCreativeMode && current.getItem() != null) {
ItemStack empty;
if (FluidContainerRegistry.isContainer(current)) {
empty = FluidContainerRegistry.drainFluidContainer(current);
} else {
// Try this as a fallback.
entityplayer.inventory.addItemStackToInventory(current.getItem().getContainerItem(current));
empty = current.getItem().getContainerItem(current);
}
if (current.stackSize > 1) {
entityplayer.inventory.mainInventory[entityplayer.inventory.currentItem].stackSize -= 1;
entityplayer.inventory.addItemStackToInventory(empty);
} else {
entityplayer.inventory.mainInventory[entityplayer.inventory.currentItem] = empty;
}
}
return true;
} else {
// Fill the container in hand from the tank
int containerCapacity = fluidContainer.getCapacity(itemInHand);
FluidStack drained = tank.drain(ForgeDirection.UNKNOWN, containerCapacity, true);
if (drained != null && drained.amount > 0 && !isCreativeMode) {
fluidContainer.fill(singleContainerItem, drained, true);
replaceItemInInventory(worldObj, player, itemInHand, singleContainerItem);
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 true;
}
return false;
}
private void replaceItemInInventory(World world, EntityPlayer player, ItemStack item, ItemStack replacement) {
if (item.stackSize > 1) {
item.stackSize--;
// This method meant to be called both from client and server side, and trying to drop an item
// from the client side would create a doubled ghost item, so we don't allow to do that
if (!player.inventory.addItemStackToInventory(replacement) && !world.isRemote) {
player.entityDropItem(replacement, 0);
}
} else {
player.inventory.setInventorySlotContents(player.inventory.currentItem, replacement);
@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);
}
}
@@ -138,14 +138,19 @@ public class ItemCertusQuartzTank extends BaseItemBlockContainer implements IFlu
@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 (!super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata)) {
if (!world.setBlock(x, y, z, this.field_150939_a, metadata, 3)) {
return false;
}
if (stack != null) {
((TileCertusQuartzTank) world.getTileEntity(x, y, z)).readFromItemNBT(stack.getTagCompound());
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;
}
}
@@ -234,7 +234,6 @@ public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInter
Platform.spawnDrops(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord, drops);
}
duality.setStorage(p2p.duality.getStorage());
duality.setSlotInv(p2p.duality.getSlotInv());
duality.sharedInventory = true;
} else {
if (duality.sharedInventory) {
@@ -310,7 +309,6 @@ public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInter
@Override
public PartP2PTunnel<?> applyMemoryCard(EntityPlayer player, IMemoryCard memoryCard, ItemStack is) {
PartP2PTunnel<?> newTunnel = super.applyMemoryCard(player, memoryCard, is);
if (Platform.isClient()) return newTunnel;
NBTTagCompound data = memoryCard.getData(is);
if (newTunnel instanceof PartFluidP2PInterface p2PInterface) {
p2PInterface.duality.getConfigManager().readFromNBT(data);
@@ -401,12 +399,6 @@ public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInter
for (int i = 0; i < storage.getSizeInventory(); ++i) {
newStorage.setInventorySlotContents(i, storage.getStackInSlot(i));
}
IInventory config = fromInterface.duality.getInventoryByName("config");
IInventory newConfig = newDuality.getInventoryByName("config");
for (int i = 0; i < config.getSizeInventory(); ++i) {
newConfig.setInventorySlotContents(i, config.getStackInSlot(i));
}
}
AppEngInternalInventory patterns = fromInterface.duality.getPatterns();
@@ -219,16 +219,12 @@ public class FluidCellInventory implements IFluidCellInventory {
public long getRemainingFluidCountDist(IAEFluidStack l) {
long remaining;
long types = 0;
long maxFluidTypes = this.getTotalFluidTypes();
IInventory configInventory = this.getConfigInventory();
for (int i = 0; i < configInventory.getSizeInventory(); i++) {
// Check all partition slots to determine min distribution behaviour until max fluid types is reached
if (types >= maxFluidTypes) break;
if (configInventory.getStackInSlot(i) != null) {
for (int i = 0; i < this.getTotalFluidTypes(); i++) {
if (this.getConfigInventory().getStackInSlot(i) != null) {
types++;
}
}
if (types == 0) types = maxFluidTypes;
if (types == 0) types = this.getTotalFluidTypes();
if (l != null) {
if (restrictionLong > 0) {
remaining = Math.min((restrictionLong / types) - l.getStackSize(), getRemainingFluidCount());
@@ -56,6 +56,7 @@ public class FluidCellInventoryHandler extends MEInventoryHandler<IAEFluidStack>
final IInventory upgrades = ci.getUpgradesInventory();
boolean hasSticky = false;
boolean hasInverter = false;
for (int x = 0; x < upgrades.getSizeInventory(); x++) {
final ItemStack is = upgrades.getStackInSlot(x);
@@ -63,11 +64,14 @@ public class FluidCellInventoryHandler extends MEInventoryHandler<IAEFluidStack>
final Upgrades u = ((IUpgradeModule) is.getItem()).getType(is);
if (u == Upgrades.STICKY) {
hasSticky = true;
break;
} else if (u == Upgrades.INVERTER) {
hasInverter = true;
}
}
}
this.setWhitelist(hasInverter ? IncludeExclude.BLACKLIST : IncludeExclude.WHITELIST);
if (hasSticky) {
setSticky(true);
}
@@ -1,10 +1,12 @@
package com.glodblock.github.common.tile;
import net.minecraft.block.Block;
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.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
@@ -12,11 +14,14 @@ import net.minecraftforge.fluids.FluidTank;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import com.glodblock.github.loader.ChannelLoader;
import com.glodblock.github.util.BlockPos;
public class TileCertusQuartzTank extends TileEntity implements IFluidHandler {
private FluidStack lastBeforeUpdate = null;
public FluidTank tank = new FluidTank(32000);
private boolean hasUpdate;
@Override
public boolean canDrain(ForgeDirection from, Fluid fluid) {
@@ -33,6 +38,32 @@ public class TileCertusQuartzTank extends TileEntity implements IFluidHandler {
return tankFluid == null || tankFluid.amount == 0 ? 0 : tankFluid.getFluid().getLuminosity(tankFluid);
}
public void compareAndUpdate() {
if (this.worldObj.isRemote) {
return;
}
FluidStack current = this.tank.getFluid();
if (current == null || this.lastBeforeUpdate == null) {
if (current != this.lastBeforeUpdate) {
ChannelLoader.sendPacketToAllPlayers(getDescriptionPacket(), this.worldObj);
this.lastBeforeUpdate = current == null ? null : current.copy();
}
return;
}
boolean amountSufficientlyChanged = Math.abs(current.amount - this.lastBeforeUpdate.amount) >= 500;
boolean isFull = current.amount == this.tank.getCapacity();
boolean wasFull = this.lastBeforeUpdate.amount == this.tank.getCapacity();
boolean fullStateChanged = isFull != wasFull;
if (amountSufficientlyChanged || fullStateChanged) {
ChannelLoader.sendPacketToAllPlayers(getDescriptionPacket(), this.worldObj);
this.lastBeforeUpdate = current.copy();
}
}
public FluidStack drain(FluidStack fluid, boolean doDrain, boolean findMainTank) {
if (fluid == null || this.getFluid() == null || this.getFluid() != fluid.getFluid()) {
return null;
@@ -57,9 +88,7 @@ public class TileCertusQuartzTank extends TileEntity implements IFluidHandler {
FluidStack drainedFluid = this.tank.drain(fluid.amount, doDrain);
int drained = drainedFluid != null ? drainedFluid.amount : 0;
if (drained > 0) {
update();
}
compareAndUpdate();
if (drained < fluid.amount) {
TileCertusQuartzTank tankBelow = this.getTankBelow();
@@ -115,10 +144,7 @@ public class TileCertusQuartzTank extends TileEntity implements IFluidHandler {
}
int filled = this.tank.fill(fluid, doFill);
if (filled > 0) {
update();
}
compareAndUpdate();
if (filled < fluid.amount) {
TileCertusQuartzTank tankAbove = this.getTankAbove();
@@ -139,6 +165,13 @@ public class TileCertusQuartzTank extends TileEntity implements IFluidHandler {
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;
@@ -152,6 +185,33 @@ public class TileCertusQuartzTank extends TileEntity implements IFluidHandler {
return (float) this.tank.getFluidAmount() / this.tank.getCapacity();
}
private void onComparatorUpdate(World world, int x, int y, int z, Block block) {
world.func_147453_f(x, y, z, block);
}
@Override
public void updateEntity() {
if (this.tank.getFluid() != null) {
TileCertusQuartzTank below = getTankBelow();
if (below != null) {
FluidStack fluid = this.tank.getFluid().copy();
int amount = below.tank.fill(fluid, true);
if (amount > 0) {
this.tank.drain(amount, true);
this.hasUpdate = true;
below.hasUpdate = true;
this.compareAndUpdate();
below.compareAndUpdate();
}
}
}
if (this.hasUpdate) {
onComparatorUpdate(this.worldObj, this.xCoord, this.yCoord, this.zCoord, this.getBlockType());
this.hasUpdate = false;
}
}
private TileCertusQuartzTank getTankAbove() {
TileEntity tile = new BlockPos(this).getOffSet(0, 1, 0).getTileEntity();
if (tile instanceof TileCertusQuartzTank tankTile) {
@@ -210,49 +270,6 @@ public class TileCertusQuartzTank extends TileEntity implements IFluidHandler {
return getTankInfo(true);
}
public FluidTankInfo[] getInternalFluid() {
return this.getTankInfo(true);
}
private void flowFluidDown(boolean checkTankAbove) {
if (this.getFluid() != null) {
TileCertusQuartzTank below = getTankBelow();
if (below != null) {
FluidStack fluid = this.tank.getFluid().copy();
int amount = below.tank.fill(fluid, true);
if (amount > 0) {
this.tank.drain(amount, true);
this.update();
below.update();
below.flowFluidDown(false);
}
}
}
if (checkTankAbove) {
TileCertusQuartzTank above = getTankAbove();
if (above != null && above.getFluid() != null) {
if (this.getFluid() == null || this.getFluid() == above.getFluid()) {
above.flowFluidDown(true);
}
}
}
}
public void update() {
if (!this.worldObj.isRemote) {
markDirty();
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
}
}
@Override
public Packet getDescriptionPacket() {
NBTTagCompound nbtTag = new NBTTagCompound();
writeToNBT(nbtTag);
return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, nbtTag);
}
@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) {
this.worldObj.markBlockRangeForRenderUpdate(
@@ -275,15 +292,6 @@ public class TileCertusQuartzTank extends TileEntity implements IFluidHandler {
this.tank.readFromNBT(tag);
}
// Specifically used when player is placing a tank in world,
// so we can apply the item's NBT and flow down its fluid in lower tanks
public void readFromItemNBT(NBTTagCompound tag) {
if (tag != null) {
this.readFromNBTWithoutCoords(tag.getCompoundTag("tileEntity"));
}
this.flowFluidDown(true);
}
@Override
public void writeToNBT(NBTTagCompound tag) {
super.writeToNBT(tag);
@@ -293,4 +301,8 @@ public class TileCertusQuartzTank extends TileEntity implements IFluidHandler {
public void writeToNBTWithoutCoords(NBTTagCompound tag) {
this.tank.writeToNBT(tag);
}
public FluidTankInfo[] getInternalFluid() {
return this.getTankInfo(true);
}
}
@@ -1,30 +0,0 @@
package com.glodblock.github.crossmod.waila;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.fluids.FluidTankInfo;
import com.glodblock.github.common.tile.TileCertusQuartzTank;
import appeng.integration.modules.waila.BaseWailaDataProvider;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
public class CertusQuartzTankWailaDataProvider extends BaseWailaDataProvider {
@Override
public List<String> getWailaBody(final ItemStack itemStack, final List<String> currentToolTip,
final IWailaDataAccessor accessor, final IWailaConfigHandler config) {
TileEntity tileEntity = accessor.getTileEntity();
if (tileEntity instanceof TileCertusQuartzTank quartzTank) {
FluidTankInfo info = quartzTank.getTankInfo(true)[0];
if (info.fluid != null) {
currentToolTip
.add(Tooltip.fluidFormat(info.fluid.getLocalizedName(), info.fluid.amount, info.capacity));
}
}
return currentToolTip;
}
}
@@ -0,0 +1,71 @@
package com.glodblock.github.crossmod.waila;
import java.util.List;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import com.glodblock.github.crossmod.waila.vanilla.FluidInvWailaDataProvider;
import com.google.common.collect.Lists;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
public class VanillaTileWailaDataProvider implements IWailaDataProvider {
private final List<IWailaDataProvider> providers;
public VanillaTileWailaDataProvider() {
final IWailaDataProvider fluidInv = new FluidInvWailaDataProvider();
this.providers = Lists.newArrayList(fluidInv);
}
@Override
public ItemStack getWailaStack(final IWailaDataAccessor accessor, final IWailaConfigHandler config) {
return null;
}
@Override
public List<String> getWailaHead(final ItemStack itemStack, final List<String> currentToolTip,
final IWailaDataAccessor accessor, final IWailaConfigHandler config) {
for (final IWailaDataProvider provider : this.providers) {
provider.getWailaHead(itemStack, currentToolTip, accessor, config);
}
return currentToolTip;
}
@Override
public List<String> getWailaBody(final ItemStack itemStack, final List<String> currentToolTip,
final IWailaDataAccessor accessor, final IWailaConfigHandler config) {
for (final IWailaDataProvider provider : this.providers) {
provider.getWailaBody(itemStack, currentToolTip, accessor, config);
}
return currentToolTip;
}
@Override
public List<String> getWailaTail(final ItemStack itemStack, final List<String> currentToolTip,
final IWailaDataAccessor accessor, final IWailaConfigHandler config) {
for (final IWailaDataProvider provider : this.providers) {
provider.getWailaTail(itemStack, currentToolTip, accessor, config);
}
return currentToolTip;
}
@Override
public NBTTagCompound getNBTData(final EntityPlayerMP player, final TileEntity te, final NBTTagCompound tag,
final World world, final int x, final int y, final int z) {
for (final IWailaDataProvider provider : this.providers) {
provider.getNBTData(player, te, tag, world, x, y, z);
}
return tag;
}
}
@@ -1,7 +1,6 @@
package com.glodblock.github.crossmod.waila;
import com.glodblock.github.common.tile.TileCertusQuartzTank;
import com.glodblock.github.util.ModAndClassUtil;
import net.minecraft.tileentity.TileEntity;
import appeng.api.parts.IPartHost;
import appeng.tile.AEBaseTile;
@@ -27,9 +26,9 @@ public class WailaInit {
registrar.registerBodyProvider(tile, AEBaseTile.class);
registrar.registerNBTProvider(tile, AEBaseTile.class);
if (!ModAndClassUtil.WAILA_PLUGINS) {
final IWailaDataProvider certusQuartzTank = new CertusQuartzTankWailaDataProvider();
registrar.registerBodyProvider(certusQuartzTank, TileCertusQuartzTank.class);
}
final IWailaDataProvider vanillaTile = new VanillaTileWailaDataProvider();
registrar.registerBodyProvider(vanillaTile, TileEntity.class);
registrar.registerNBTProvider(vanillaTile, TileEntity.class);
}
}
@@ -0,0 +1,50 @@
package com.glodblock.github.crossmod.waila.vanilla;
import java.util.List;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidTankInfo;
import com.glodblock.github.common.tile.TileCertusQuartzTank;
import com.glodblock.github.crossmod.waila.Tooltip;
import com.glodblock.github.util.Util;
import appeng.integration.modules.waila.BaseWailaDataProvider;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
public class FluidInvWailaDataProvider extends BaseWailaDataProvider {
@Override
public List<String> getWailaBody(final ItemStack itemStack, final List<String> currentToolTip,
final IWailaDataAccessor accessor, final IWailaConfigHandler config) {
final TileEntity te = accessor.getTileEntity();
if (te instanceof TileCertusQuartzTank) {
if (accessor.getNBTData().hasKey("fluidInv")) {
NBTTagCompound data = (NBTTagCompound) accessor.getNBTData().getTag("fluidInv");
for (FluidTankInfo info : Util.FluidUtil.fluidTankInfoReadFromNBT(data)) {
if (info.fluid == null) continue;
currentToolTip
.add(Tooltip.fluidFormat(info.fluid.getLocalizedName(), info.fluid.amount, info.capacity));
}
}
}
return currentToolTip;
}
@Override
public NBTTagCompound getNBTData(final EntityPlayerMP player, final TileEntity te, final NBTTagCompound tag,
final World world, final int x, final int y, final int z) {
if (te instanceof TileCertusQuartzTank) {
NBTTagCompound data = new NBTTagCompound();
Util.FluidUtil.fluidTankInfoWriteToNBT(((TileCertusQuartzTank) te).getInternalFluid(), data);
tag.setTag("fluidInv", data);
te.writeToNBT(tag);
}
return tag;
}
}
@@ -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.CPacketCraftRequest;
import com.glodblock.github.network.CPacketDumpTank;
@@ -96,4 +100,12 @@ public class ChannelLoader implements Runnable {
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);
}
}
}
}
@@ -23,6 +23,8 @@ import org.lwjgl.opengl.GL11;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.common.storage.FluidCellInventoryHandler;
import com.glodblock.github.util.ModAndClassUtil;
import com.mitchej123.hodgepodge.textures.IPatchedTextureAtlasSprite;
import appeng.api.AEApi;
import appeng.api.config.TerminalFontSize;
@@ -162,6 +164,10 @@ public class NEICellViewHandler implements IUsageHandler {
final int line = i % ROW_ITEM_NUM;
final int row = i / ROW_ITEM_NUM;
if (ModAndClassUtil.HODGEPODGE && icon instanceof IPatchedTextureAtlasSprite sprite) {
sprite.markNeedsAnimationUpdate();
}
tessellator.setColorRGBA(color >> 16 & 0xFF, color >> 8 & 0xFF, color & 0xFF, 0xFF);
tessellator.addVertexWithUV(
OFFSET_X + 18 * (line + 1) - 1,
@@ -136,6 +136,18 @@ public class CommonProxy {
Upgrades.STICKY.registerItem(new ItemStack(ItemAndBlockHolder.QUANTUM_CELL), 1);
Upgrades.STICKY.registerItem(new ItemStack(ItemAndBlockHolder.SINGULARITY_CELL), 1);
Upgrades.INVERTER.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_VOID_CELL), 1);
Upgrades.INVERTER.registerItem(new ItemStack(ItemAndBlockHolder.CELL1K), 1);
Upgrades.INVERTER.registerItem(new ItemStack(ItemAndBlockHolder.CELL4K), 1);
Upgrades.INVERTER.registerItem(new ItemStack(ItemAndBlockHolder.CELL16K), 1);
Upgrades.INVERTER.registerItem(new ItemStack(ItemAndBlockHolder.CELL64K), 1);
Upgrades.INVERTER.registerItem(new ItemStack(ItemAndBlockHolder.CELL256K), 1);
Upgrades.INVERTER.registerItem(new ItemStack(ItemAndBlockHolder.CELL1024K), 1);
Upgrades.INVERTER.registerItem(new ItemStack(ItemAndBlockHolder.CELL4096K), 1);
Upgrades.INVERTER.registerItem(new ItemStack(ItemAndBlockHolder.CELL16384K), 1);
Upgrades.INVERTER.registerItem(new ItemStack(ItemAndBlockHolder.QUANTUM_CELL), 1);
Upgrades.INVERTER.registerItem(new ItemStack(ItemAndBlockHolder.SINGULARITY_CELL), 1);
Upgrades.VOID_OVERFLOW.registerItem(new ItemStack(ItemAndBlockHolder.CELL1K), 1);
Upgrades.VOID_OVERFLOW.registerItem(new ItemStack(ItemAndBlockHolder.CELL4K), 1);
Upgrades.VOID_OVERFLOW.registerItem(new ItemStack(ItemAndBlockHolder.CELL16K), 1);
@@ -156,6 +168,16 @@ public class CommonProxy {
Upgrades.STICKY.registerItem(new ItemStack(ItemAndBlockHolder.CELL16384KM), 1);
Upgrades.STICKY.registerItem(new ItemStack(ItemAndBlockHolder.ARTIFICIAL_UNIVERSE_CELL), 1);
Upgrades.INVERTER.registerItem(new ItemStack(ItemAndBlockHolder.CELL1KM), 1);
Upgrades.INVERTER.registerItem(new ItemStack(ItemAndBlockHolder.CELL4KM), 1);
Upgrades.INVERTER.registerItem(new ItemStack(ItemAndBlockHolder.CELL16KM), 1);
Upgrades.INVERTER.registerItem(new ItemStack(ItemAndBlockHolder.CELL64KM), 1);
Upgrades.INVERTER.registerItem(new ItemStack(ItemAndBlockHolder.CELL256KM), 1);
Upgrades.INVERTER.registerItem(new ItemStack(ItemAndBlockHolder.CELL1024KM), 1);
Upgrades.INVERTER.registerItem(new ItemStack(ItemAndBlockHolder.CELL4096KM), 1);
Upgrades.INVERTER.registerItem(new ItemStack(ItemAndBlockHolder.CELL16384KM), 1);
Upgrades.INVERTER.registerItem(new ItemStack(ItemAndBlockHolder.ARTIFICIAL_UNIVERSE_CELL), 1);
Upgrades.VOID_OVERFLOW.registerItem(new ItemStack(ItemAndBlockHolder.CELL1KM), 1);
Upgrades.VOID_OVERFLOW.registerItem(new ItemStack(ItemAndBlockHolder.CELL4KM), 1);
Upgrades.VOID_OVERFLOW.registerItem(new ItemStack(ItemAndBlockHolder.CELL16KM), 1);
@@ -32,8 +32,8 @@ public final class ModAndClassUtil {
public static boolean COFH = false;
public static boolean GTPP = false;
public static boolean WAILA = false;
public static boolean WAILA_PLUGINS = false;
public static boolean AVARITIA = false;
public static boolean HODGEPODGE = false;
public static boolean NEW_HORIZONS_CORE_MOD = false;
public static boolean isV2;
@@ -147,8 +147,8 @@ public final class ModAndClassUtil {
if (Loader.isModLoaded("CoFHCore")) COFH = true;
if (Loader.isModLoaded("miscutils")) GTPP = true;
if (Loader.isModLoaded("Waila")) WAILA = true;
if (Loader.isModLoaded("wailaplugins")) WAILA_PLUGINS = true;
if (Loader.isModLoaded("Avaritia")) AVARITIA = true;
if (Loader.isModLoaded("hodgepodge")) HODGEPODGE = true;
if (Loader.isModLoaded("dreamcraft")) NEW_HORIZONS_CORE_MOD = true;
}
}
@@ -12,6 +12,8 @@ import net.minecraft.util.IIcon;
import org.lwjgl.opengl.GL11;
import com.mitchej123.hodgepodge.textures.IPatchedTextureAtlasSprite;
import appeng.api.storage.data.IAEFluidStack;
public final class RenderUtil {
@@ -51,6 +53,9 @@ public final class RenderUtil {
if (aeFluidStack.getStackSize() > 0 && hi > 0) {
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
IIcon fluidIcon = aeFluidStack.getFluid().getStillIcon();
if (ModAndClassUtil.HODGEPODGE && fluidIcon instanceof IPatchedTextureAtlasSprite) {
((IPatchedTextureAtlasSprite) fluidIcon).markNeedsAnimationUpdate();
}
GL11.glColor3f(
(float) (aeFluidStack.getFluid().getColor() >> 16 & 255) / 255.0F,
(float) (aeFluidStack.getFluid().getColor() >> 8 & 255) / 255.0F,
@@ -7,6 +7,8 @@ import static com.glodblock.github.util.Util.DimensionalCoordSide.hasEnergyCard;
import static net.minecraft.init.Items.glass_bottle;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import net.minecraft.entity.player.EntityPlayer;
@@ -22,6 +24,7 @@ import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidContainerItem;
import org.apache.commons.lang3.tuple.ImmutablePair;
@@ -507,6 +510,36 @@ public final class Util {
public static final ItemStack water_bucket = new ItemStack(Items.water_bucket, 1);
public static void fluidTankInfoWriteToNBT(FluidTankInfo[] infos, NBTTagCompound data) {
int i = 0;
for (FluidTankInfo info : infos) {
if (info.fluid != null && info.fluid.amount > 0) {
NBTTagCompound fs = new NBTTagCompound();
info.fluid.writeToNBT(fs);
fs.setInteger("capacity", info.capacity);
data.setTag("#" + i, fs);
}
i++;
}
data.setInteger("fluidInvSize", i);
}
public static FluidTankInfo[] fluidTankInfoReadFromNBT(NBTTagCompound data) {
int i = 0;
List<FluidTankInfo> infos = new ArrayList<>();
while (data.hasKey("fluidInvSize") && i < data.getInteger("fluidInvSize")) {
if (data.hasKey("#" + i)) {
NBTTagCompound tag = (NBTTagCompound) data.getTag("#" + i);
FluidStack fs = FluidStack.loadFluidStackFromNBT(tag);
infos.add(new FluidTankInfo(fs, tag.getInteger("capacity")));
} else {
infos.add(new FluidTankInfo(null, 0));
}
i++;
}
return infos.toArray(new FluidTankInfo[0]);
}
public static IAEFluidStack createAEFluidStack(Fluid fluid) {
return createAEFluidStack(new FluidStack(fluid, FluidContainerRegistry.BUCKET_VOLUME));
}