Fixed aesu powers in creative tab, more work moving away from ic2 core and only needing ic2 api

This commit is contained in:
modmuss50 2015-07-23 13:42:20 +01:00
parent 277e5e5e45
commit 496151fcae
10 changed files with 100 additions and 42 deletions

View file

@ -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();
}
}

View file

@ -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());
}

View file

@ -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);

View file

@ -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;

View file

@ -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);

View file

@ -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);

View file

@ -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";

View file

@ -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]);
}
}

View file

@ -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());
}

View file

@ -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;
}
}