diff --git a/src/main/java/techreborn/client/GuiUtil.java b/src/main/java/techreborn/client/GuiUtil.java new file mode 100644 index 000000000..b6bfdc063 --- /dev/null +++ b/src/main/java/techreborn/client/GuiUtil.java @@ -0,0 +1,34 @@ +package techreborn.client; + +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.util.IIcon; + +public class GuiUtil { + + public static void drawRepeated(IIcon icon, double x, double y, double width, double height, double z) + { + double iconWidthStep = (icon.getMaxU() - icon.getMinU()) / 16.0D; + double iconHeightStep = (icon.getMaxV() - icon.getMinV()) / 16.0D; + + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + for (double cy = y; cy < y + height; cy += 16.0D) + { + double quadHeight = Math.min(16.0D, height + y - cy); + double maxY = cy + quadHeight; + double maxV = icon.getMinV() + iconHeightStep * quadHeight; + for (double cx = x; cx < x + width; cx += 16.0D) + { + double quadWidth = Math.min(16.0D, width + x - cx); + double maxX = cx + quadWidth; + double maxU = icon.getMinU() + iconWidthStep * quadWidth; + + tessellator.addVertexWithUV(cx, maxY, z, icon.getMinU(), maxV); + tessellator.addVertexWithUV(maxX, maxY, z, maxU, maxV); + tessellator.addVertexWithUV(maxX, cy, z, maxU, icon.getMinV()); + tessellator.addVertexWithUV(cx, cy, z, icon.getMinU(), icon.getMinV()); + } + } + tessellator.draw(); + } +} diff --git a/src/main/java/techreborn/client/container/ContainerAesu.java b/src/main/java/techreborn/client/container/ContainerAesu.java index 21f107cd0..0de465471 100644 --- a/src/main/java/techreborn/client/container/ContainerAesu.java +++ b/src/main/java/techreborn/client/container/ContainerAesu.java @@ -56,11 +56,11 @@ public class ContainerAesu extends TechRebornContainer { super.detectAndSendChanges(); for (int i = 0; i < this.crafters.size(); i++) { ICrafting icrafting = (ICrafting)this.crafters.get(i); - if(this.euOut != tile.output){ - icrafting.sendProgressBarUpdate(this, 0, tile.output); + if(this.euOut != tile.getMaxOutput()){ + icrafting.sendProgressBarUpdate(this, 0, (int) tile.getMaxOutput()); } - if(this.storedEu != tile.energy){ - icrafting.sendProgressBarUpdate(this, 1, (int) tile.energy); + if(this.storedEu != tile.getEnergy()){ + icrafting.sendProgressBarUpdate(this, 1, (int) tile.getEnergy()); } if(this.euChange != tile.getEuChange() && tile.getEuChange() != -1){ icrafting.sendProgressBarUpdate(this, 2, (int) tile.getEuChange()); @@ -71,8 +71,8 @@ public class ContainerAesu extends TechRebornContainer { @Override public void addCraftingToCrafters(ICrafting crafting) { super.addCraftingToCrafters(crafting); - crafting.sendProgressBarUpdate(this, 0, tile.output); - crafting.sendProgressBarUpdate(this, 1, (int) tile.energy); + crafting.sendProgressBarUpdate(this, 0, (int) tile.getMaxOutput()); + crafting.sendProgressBarUpdate(this, 1, (int) tile.getEnergy()); crafting.sendProgressBarUpdate(this, 2 , (int) tile.getEuChange()); } diff --git a/src/main/java/techreborn/client/gui/GuiGrinder.java b/src/main/java/techreborn/client/gui/GuiGrinder.java index ca684c61a..d5a6627b3 100644 --- a/src/main/java/techreborn/client/gui/GuiGrinder.java +++ b/src/main/java/techreborn/client/gui/GuiGrinder.java @@ -1,7 +1,6 @@ package techreborn.client.gui; import codechicken.lib.gui.GuiDraw; -import ic2.core.util.DrawUtil; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.resources.I18n; @@ -9,6 +8,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; +import techreborn.client.GuiUtil; import techreborn.client.container.ContainerGrinder; import techreborn.lib.ModInfo; import techreborn.tiles.TileGrinder; @@ -58,7 +58,7 @@ public class GuiGrinder extends GuiContainer{ this.mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture); int liquidHeight = grinder.tank.getFluidAmount() * 47 / grinder.tank.getCapacity(); - DrawUtil.drawRepeated(fluidIcon, k + 11, l + 19 + 47 - liquidHeight, 12.0D, liquidHeight, this.zLevel); + GuiUtil.drawRepeated(fluidIcon, k + 11, l + 19 + 47 - liquidHeight, 12.0D, liquidHeight, this.zLevel); this.mc.renderEngine.bindTexture(texture); diff --git a/src/main/java/techreborn/client/gui/GuiIndustrialElectrolyzer.java b/src/main/java/techreborn/client/gui/GuiIndustrialElectrolyzer.java index 35d611307..e8e1eba64 100644 --- a/src/main/java/techreborn/client/gui/GuiIndustrialElectrolyzer.java +++ b/src/main/java/techreborn/client/gui/GuiIndustrialElectrolyzer.java @@ -1,6 +1,5 @@ package techreborn.client.gui; -import ic2.core.util.DrawUtil; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.resources.I18n; diff --git a/src/main/java/techreborn/client/gui/GuiIndustrialSawmill.java b/src/main/java/techreborn/client/gui/GuiIndustrialSawmill.java index f2dc0841b..da3cabb36 100644 --- a/src/main/java/techreborn/client/gui/GuiIndustrialSawmill.java +++ b/src/main/java/techreborn/client/gui/GuiIndustrialSawmill.java @@ -1,7 +1,6 @@ package techreborn.client.gui; import codechicken.lib.gui.GuiDraw; -import ic2.core.util.DrawUtil; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.resources.I18n; @@ -9,6 +8,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; +import techreborn.client.GuiUtil; import techreborn.client.container.ContainerIndustrialSawmill; import techreborn.lib.ModInfo; import techreborn.tiles.TileIndustrialSawmill; @@ -69,8 +69,8 @@ public class GuiIndustrialSawmill extends GuiContainer { .bindTexture(TextureMap.locationBlocksTexture); int liquidHeight = sawmill.tank.getFluidAmount() * 47 / sawmill.tank.getCapacity(); - DrawUtil.drawRepeated(fluidIcon, k + 11, l + 19 + 47 - - liquidHeight, 12.0D, liquidHeight, this.zLevel); + GuiUtil.drawRepeated(fluidIcon, k + 11, l + 19 + 47 + - liquidHeight, 12.0D, liquidHeight, this.zLevel); this.mc.renderEngine.bindTexture(texture); drawTexturedModalRect(k + 11, l + 19, 176, 86, 12, 47); diff --git a/src/main/java/techreborn/itemblocks/ItemBlockAesu.java b/src/main/java/techreborn/itemblocks/ItemBlockAesu.java index 9322631a7..1a55e3ad6 100644 --- a/src/main/java/techreborn/itemblocks/ItemBlockAesu.java +++ b/src/main/java/techreborn/itemblocks/ItemBlockAesu.java @@ -82,6 +82,9 @@ public class ItemBlockAesu extends ItemBlock { public void writeToNBTWithoutCoords(NBTTagCompound tagCompound, double energy) { + NBTTagCompound data = new NBTTagCompound(); + data.setDouble("energy", energy); + tagCompound.setTag("TilePowerAcceptor", data); tagCompound.setDouble("energy", energy); tagCompound.setDouble("euChange", 0); tagCompound.setDouble("euLastTick", 0); diff --git a/src/main/java/techreborn/lib/ModInfo.java b/src/main/java/techreborn/lib/ModInfo.java index 86dd31d6e..3e43a1109 100644 --- a/src/main/java/techreborn/lib/ModInfo.java +++ b/src/main/java/techreborn/lib/ModInfo.java @@ -6,7 +6,7 @@ public class ModInfo { public static final String MOD_NAME = "TechReborn"; public static final String MOD_ID = "techreborn"; public static final String MOD_VERSION = "@MODVERSION@"; - public static final String MOD_DEPENDENCUIES = "required-after:IC2@:;" + + public static final String MOD_DEPENDENCUIES = "required-after:Forge@[10.13.3.1374,)"; public static final String SERVER_PROXY_CLASS = "techreborn.proxies.CommonProxy"; public static final String CLIENT_PROXY_CLASS = "techreborn.proxies.ClientProxy"; diff --git a/src/main/java/techreborn/partSystem/parts/CablePart.java b/src/main/java/techreborn/partSystem/parts/CablePart.java index b7f360e47..7832bf226 100644 --- a/src/main/java/techreborn/partSystem/parts/CablePart.java +++ b/src/main/java/techreborn/partSystem/parts/CablePart.java @@ -1,5 +1,6 @@ package techreborn.partSystem.parts; +import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import ic2.api.energy.event.EnergyTileLoadEvent; @@ -8,7 +9,6 @@ import ic2.api.energy.tile.IEnergyConductor; import ic2.api.energy.tile.IEnergyTile; import ic2.api.item.IC2Items; import ic2.api.network.INetworkTileEntityEventListener; -import ic2.core.IC2; import net.minecraft.entity.Entity; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -25,6 +25,7 @@ import techreborn.partSystem.IModPart; import techreborn.partSystem.IPartDesc; import techreborn.partSystem.ModPart; import techreborn.partSystem.ModPartUtils; +import techreborn.util.LogHelper; import java.util.ArrayList; import java.util.HashMap; @@ -154,7 +155,7 @@ public class CablePart extends ModPart implements IEnergyConductor, INetworkTile @Override public void tick() { - if (IC2.platform.isSimulating() && !this.addedToEnergyNet) { + if (!FMLCommonHandler.instance().getEffectiveSide().isClient() && !this.addedToEnergyNet) { MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); this.addedToEnergyNet = true; nearByChange(); @@ -176,7 +177,7 @@ public class CablePart extends ModPart implements IEnergyConductor, INetworkTile @Override public void onAdded() { checkConnections(world, getX(), getY(), getZ()); - if (IC2.platform.isSimulating()) { + if (!FMLCommonHandler.instance().getEffectiveSide().isClient()) { MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); this.addedToEnergyNet = true; nearByChange(); @@ -186,7 +187,7 @@ public class CablePart extends ModPart implements IEnergyConductor, INetworkTile @Override public void onRemoved() { - if (IC2.platform.isSimulating() && this.addedToEnergyNet) { + if (!FMLCommonHandler.instance().getEffectiveSide().isClient() && this.addedToEnergyNet) { MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this)); this.addedToEnergyNet = false; } @@ -527,7 +528,7 @@ public class CablePart extends ModPart implements IEnergyConductor, INetworkTile return; default: - IC2.platform.displayError("An unknown event type was received over multiplayer.\nThis could happen due to corrupted data or a bug.\n\n(Technical information: event ID " + i + ", tile entity below)\n" + "T: " + this + " (" + this.xCoord + ", " + this.yCoord + ", " + this.zCoord + ")", new Object[0]); + } } diff --git a/src/main/java/techreborn/powerSystem/TilePowerAcceptor.java b/src/main/java/techreborn/powerSystem/TilePowerAcceptor.java index 2612d5a6d..c8fbfaa55 100644 --- a/src/main/java/techreborn/powerSystem/TilePowerAcceptor.java +++ b/src/main/java/techreborn/powerSystem/TilePowerAcceptor.java @@ -256,6 +256,17 @@ public abstract class TilePowerAcceptor extends RFProviderTile implements tag.setTag("TilePowerAcceptor", data); } + public void readFromNBTWithoutCoords(NBTTagCompound tag) { + NBTTagCompound data = tag.getCompoundTag("TilePowerAcceptor"); + energy = data.getDouble("energy"); + } + + public void writeToNBTWithoutCoords(NBTTagCompound tag) { + NBTTagCompound data = new NBTTagCompound(); + data.setDouble("energy", energy); + tag.setTag("TilePowerAcceptor", data); + } + public int getEnergyScaled(int scale) { return (int)(getEnergy() * scale / getMaxPower()); } diff --git a/src/main/java/techreborn/tiles/TileAesu.java b/src/main/java/techreborn/tiles/TileAesu.java index 5038490c0..002bcc2fd 100644 --- a/src/main/java/techreborn/tiles/TileAesu.java +++ b/src/main/java/techreborn/tiles/TileAesu.java @@ -1,18 +1,16 @@ package techreborn.tiles; -import ic2.api.energy.EnergyNet; import ic2.api.tile.IWrenchable; -import ic2.core.util.Util; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import techreborn.blocks.storage.EUStorageTile; +import net.minecraftforge.common.util.ForgeDirection; import techreborn.config.ConfigTechReborn; import techreborn.init.ModBlocks; +import techreborn.powerSystem.TilePowerAcceptor; import techreborn.util.Inventory; -import techreborn.util.LogHelper; -public class TileAesu extends EUStorageTile implements IWrenchable { +public class TileAesu extends TilePowerAcceptor implements IWrenchable { public static final int MAX_OUTPUT = ConfigTechReborn.aesuMaxOutput; public static final int MAX_STORAGE = ConfigTechReborn.aesuMaxStorage; @@ -24,7 +22,7 @@ public class TileAesu extends EUStorageTile implements IWrenchable { public TileAesu() { - super(5, TileAesu.MAX_OUTPUT, TileAesu.MAX_STORAGE); + super(5); } @Override @@ -37,13 +35,13 @@ public class TileAesu extends EUStorageTile implements IWrenchable { } else { ticks ++; - euChange += energy - euLastTick; - if(euLastTick == energy){ + euChange += getEnergy() - euLastTick; + if(euLastTick == getEnergy()){ euChange = 0; } } - euLastTick = energy; + euLastTick = getEnergy(); } @Override @@ -58,14 +56,13 @@ public class TileAesu extends EUStorageTile implements IWrenchable { @Override public short getFacing() { - return super.getFacing(); + return (short) worldObj.getBlockMetadata(xCoord, yCoord, zCoord); } @Override public void setFacing(short facing) { worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, facing, 2); - super.setFacing(facing); } @Override @@ -95,12 +92,6 @@ public class TileAesu extends EUStorageTile implements IWrenchable { return false; } - @Override - public String getInventoryName() - { - return "AESU"; - } - public void handleGuiInputFromClient(int id){ if(id == 0){ OUTPUT += 256; @@ -120,8 +111,6 @@ public class TileAesu extends EUStorageTile implements IWrenchable { if(OUTPUT <= -1){ OUTPUT = 0; } - output = OUTPUT; - LogHelper.debug("Set output to " + getOutput()); } public double getEuChange(){ @@ -143,21 +132,42 @@ public class TileAesu extends EUStorageTile implements IWrenchable { public void writeToNBTWithoutCoords(NBTTagCompound tagCompound) { - tagCompound.setDouble("energy", this.energy); + super.writeToNBTWithoutCoords(tagCompound); tagCompound.setDouble("euChange", euChange); tagCompound.setDouble("euLastTick", euLastTick); - tagCompound.setBoolean("active", this.getActive()); - tagCompound.setByte("redstoneMode", this.redstoneMode); inventory.writeToNBT(tagCompound); } public void readFromNBTWithoutCoords(NBTTagCompound nbttagcompound) { - this.energy = Util.limit(nbttagcompound.getDouble("energy"), 0.0D, (double) this.maxStorage + EnergyNet.instance.getPowerFromTier(this.tier)); - this.redstoneMode = nbttagcompound.getByte("redstoneMode"); + super.readFromNBTWithoutCoords(nbttagcompound); this.euChange = nbttagcompound.getDouble("euChange"); this.euLastTick = nbttagcompound.getDouble("euLastTick"); inventory.readFromNBT(nbttagcompound); } + @Override + public double getMaxPower() { + return TileAesu.MAX_STORAGE; + } + + @Override + public boolean canAcceptEnergy(ForgeDirection direction) { + return true; + } + + @Override + public boolean canProvideEnergy(ForgeDirection direction) { + return true; + } + + @Override + public double getMaxOutput() { + return OUTPUT; + } + + @Override + public double getMaxInput() { + return 4096 * 2; + } }