mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
watz tank sharing, missinng mutable texture crash fix
This commit is contained in:
parent
4d1e902981
commit
0a2edf189d
@ -1,5 +1,6 @@
|
||||
package com.hbm.inventory.container;
|
||||
|
||||
import com.hbm.inventory.SlotNonRetarded;
|
||||
import com.hbm.tileentity.machine.TileEntityWatz;
|
||||
import com.hbm.util.InventoryUtil;
|
||||
|
||||
@ -21,7 +22,7 @@ public class ContainerWatz extends Container {
|
||||
for(int i = 0; i < 6; i++) {
|
||||
|
||||
if(i + j > 1 && i + j < 9 && 5 - i + j > 1 && i + 5 - j > 1) {
|
||||
this.addSlotToContainer(new Slot(watz, index, 17 + i * 18, 8 + j * 18));
|
||||
this.addSlotToContainer(new SlotNonRetarded(watz, index, 17 + i * 18, 8 + j * 18));
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -24,22 +24,43 @@ public class GUIWatz extends GuiInfoContainer {
|
||||
this.ySize = 229;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int x, int y, float interp) {
|
||||
super.drawScreen(x, y, interp);
|
||||
|
||||
this.drawCustomInfoStat(x, y, guiLeft + 13, guiTop + 100, 18, 18, x, y, new String[] { String.format("%,d", watz.heat) + " TU" });
|
||||
this.drawCustomInfoStat(x, y, guiLeft + 143, guiTop + 71, 16, 16, x, y, new String[] { watz.isLocked ? "Unlock pellet IO configuration" : "Lock pellet IO configuration" });
|
||||
|
||||
watz.tanks[0].renderTankInfo(this, x, y, guiLeft + 142, guiTop + 23, 6, 45);
|
||||
watz.tanks[1].renderTankInfo(this, x, y, guiLeft + 148, guiTop + 23, 6, 45);
|
||||
watz.tanks[2].renderTankInfo(this, x, y, guiLeft + 154, guiTop + 23, 6, 45);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int i, int j) {
|
||||
this.fontRendererObj.drawString(I18n.format("container.inventory"), 8, this.ySize - 93, 4210752);
|
||||
|
||||
String flux = "" + ((int)(watz.fluxDisplay * 10)) / 10.0D;
|
||||
this.fontRendererObj.drawString(flux, 159 - this.fontRendererObj.getStringWidth(flux), 105, 0x00ff00);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float interp, int x, int y) {
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
|
||||
float col = (float) (Math.sin(System.currentTimeMillis() / 500D) * 0.5 + 0.5);
|
||||
GL11.glColor4f(1.0F, col, col, 1.0F);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
//float col = (float) (Math.sin(System.currentTimeMillis() / 500D) * 0.5 + 0.5);
|
||||
//GL11.glColor4f(1.0F, col, col, 1.0F);
|
||||
drawTexturedModalRect(guiLeft, guiTop, 0, 0, 131, 122);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
drawTexturedModalRect(guiLeft + 131, guiTop, 131, 0, 36, 122);
|
||||
drawTexturedModalRect(guiLeft, guiTop + 130, 0, 130, xSize, 99);
|
||||
drawTexturedModalRect(guiLeft + 126, guiTop + 31, 176, 31, 9, 60);
|
||||
drawTexturedModalRect(guiLeft + 105, guiTop + 96, 185, 26, 30, 26);
|
||||
drawTexturedModalRect(guiLeft + 9, guiTop + 96, 184, 0, 26, 26);
|
||||
|
||||
watz.tanks[0].renderTank(guiLeft + 143, guiTop + 69, this.zLevel, 4, 43);
|
||||
watz.tanks[1].renderTank(guiLeft + 149, guiTop + 69, this.zLevel, 4, 43);
|
||||
watz.tanks[2].renderTank(guiLeft + 155, guiTop + 69, this.zLevel, 4, 43);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1161,6 +1161,7 @@ public class ModItems {
|
||||
public static ItemRBMKPellet rbmk_pellet_drx;
|
||||
|
||||
public static Item watz_pellet;
|
||||
public static Item watz_pellet_depleted;
|
||||
|
||||
public static Item scrap_plastic;
|
||||
public static Item scrap;
|
||||
@ -3814,7 +3815,8 @@ public class ModItems {
|
||||
.setMeltingPoint(100000)
|
||||
.setUnlocalizedName("rbmk_fuel_test").setTextureName(RefStrings.MODID + ":rbmk_fuel_test");
|
||||
|
||||
watz_pellet = new ItemWatzPellet().setUnlocalizedName("watz_pellet").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":watz_pellet");
|
||||
watz_pellet = new ItemWatzPellet().setUnlocalizedName("watz_pellet").setTextureName(RefStrings.MODID + ":watz_pellet");
|
||||
watz_pellet_depleted = new ItemWatzPellet().setUnlocalizedName("watz_pellet_depleted").setTextureName(RefStrings.MODID + ":watz_pellet");
|
||||
|
||||
trinitite = new ItemNuclearWaste().setUnlocalizedName("trinitite").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":trinitite_new");
|
||||
nuclear_waste_long = new ItemWasteLong().setUnlocalizedName("nuclear_waste_long").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":nuclear_waste_long");
|
||||
@ -6656,6 +6658,7 @@ public class ModItems {
|
||||
GameRegistry.registerItem(rbmk_pellet_drx, rbmk_pellet_drx.getUnlocalizedName());
|
||||
|
||||
GameRegistry.registerItem(watz_pellet, watz_pellet.getUnlocalizedName());
|
||||
GameRegistry.registerItem(watz_pellet_depleted, watz_pellet_depleted.getUnlocalizedName());
|
||||
|
||||
GameRegistry.registerItem(debris_graphite, debris_graphite.getUnlocalizedName());
|
||||
GameRegistry.registerItem(debris_metal, debris_metal.getUnlocalizedName());
|
||||
|
||||
@ -3,6 +3,8 @@ package com.hbm.items.machine;
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.items.ItemEnumMulti;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.main.MainRegistry;
|
||||
import com.hbm.render.icon.RGBMutatorInterpolatedComponentRemap;
|
||||
import com.hbm.render.icon.TextureAtlasSpriteMutatable;
|
||||
import com.hbm.util.EnumUtil;
|
||||
@ -25,6 +27,8 @@ public class ItemWatzPellet extends ItemEnumMulti {
|
||||
|
||||
public ItemWatzPellet() {
|
||||
super(EnumWatzType.class, true, true);
|
||||
this.setMaxStackSize(16);
|
||||
this.setCreativeTab(MainRegistry.controlTab);
|
||||
}
|
||||
|
||||
public static enum EnumWatzType {
|
||||
@ -69,9 +73,11 @@ public class ItemWatzPellet extends ItemEnumMulti {
|
||||
TextureMap map = (TextureMap) reg;
|
||||
|
||||
for(int i = 0; i < EnumWatzType.values().length; i++) {
|
||||
EnumWatzType mat = EnumWatzType.values()[i];
|
||||
String placeholderName = this.getIconString() + "-" + mat.name();
|
||||
TextureAtlasSpriteMutatable mutableIcon = new TextureAtlasSpriteMutatable(placeholderName, new RGBMutatorInterpolatedComponentRemap(0xD2D2D2, 0x333333, mat.colorLight, mat.colorDark));
|
||||
EnumWatzType type = EnumWatzType.values()[i];
|
||||
String placeholderName = this.getIconString() + "-" + (type.name() + this.getUnlocalizedName());
|
||||
int light = this == ModItems.watz_pellet_depleted ? desaturate(type.colorLight) : type.colorLight;
|
||||
int dark = this == ModItems.watz_pellet_depleted ? desaturate(type.colorDark) : type.colorDark;
|
||||
TextureAtlasSpriteMutatable mutableIcon = new TextureAtlasSpriteMutatable(placeholderName, new RGBMutatorInterpolatedComponentRemap(0xD2D2D2, 0x333333, light, dark));
|
||||
map.setTextureEntry(placeholderName, mutableIcon);
|
||||
icons[i] = mutableIcon;
|
||||
}
|
||||
@ -79,6 +85,26 @@ public class ItemWatzPellet extends ItemEnumMulti {
|
||||
|
||||
this.itemIcon = reg.registerIcon(this.getIconString());
|
||||
}
|
||||
|
||||
public static int desaturate(int color) {
|
||||
int r = (color & 0xff0000) >> 16;
|
||||
int g = (color & 0x00ff00) >> 8;
|
||||
int b = (color & 0x0000ff);
|
||||
|
||||
int avg = (r + g + b) / 3;
|
||||
double approach = 0.9;
|
||||
double mult = 0.75;
|
||||
|
||||
r -= (r - avg) * approach;
|
||||
g -= (g - avg) * approach;
|
||||
b -= (b - avg) * approach;
|
||||
|
||||
r *= mult;
|
||||
g *= mult;
|
||||
b *= mult;
|
||||
|
||||
return (r << 16) | (g << 8) | b;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
@ -10,7 +10,6 @@ import com.hbm.inventory.material.NTMMaterial;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.render.icon.RGBMutatorInterpolatedComponentRemap;
|
||||
import com.hbm.render.icon.TextureAtlasSpriteMutatable;
|
||||
import com.hbm.util.I18nUtil;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@ -50,7 +49,6 @@ public class ItemAutogen extends Item {
|
||||
for(NTMMaterial mat : Mats.orderedList) {
|
||||
if(!textureOverrides.containsKey(mat) && mat.solidColorLight != mat.solidColorDark && (shape == null || mat.shapes.contains(shape))) { //only generate icons if there is no override, color variation is available and if the icon will actually be used
|
||||
String placeholderName = this.getIconString() + "-" + mat.names[0]; //the part after the dash is discarded - the name only has to be unique so that the hashmap which holds all the icon definitions can hold multiple references
|
||||
//TextureAtlasSpriteMutatable mutableIcon = new TextureAtlasSpriteMutatable(placeholderName, new RGBMutatorInterpolatedComponentRemap(0xFFFFFF, 0x565656, mat.solidColorLight, mat.solidColorDark));
|
||||
TextureAtlasSpriteMutatable mutableIcon = new TextureAtlasSpriteMutatable(placeholderName, new RGBMutatorInterpolatedComponentRemap(0xFFFFFF, 0x505050, mat.solidColorLight, mat.solidColorDark));
|
||||
map.setTextureEntry(placeholderName, mutableIcon);
|
||||
iconMap.put(mat, mutableIcon);
|
||||
@ -72,13 +70,6 @@ public class ItemAutogen extends Item {
|
||||
list.add(new ItemStack(item, 1, mat.id));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*for(NTMMaterial mat : Mats.orderedList) {
|
||||
if(mat.smeltable == SmeltingBehavior.SMELTABLE || mat.smeltable == SmeltingBehavior.ADDITIVE) {
|
||||
list.add(new ItemStack(item, 1, mat.id));
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -123,7 +114,7 @@ public class ItemAutogen extends Item {
|
||||
return "UNDEFINED";
|
||||
}
|
||||
|
||||
String matName = I18nUtil.resolveKey(mat.getUnlocalizedName());
|
||||
String matName = StatCollector.translateToLocal(mat.getUnlocalizedName());
|
||||
return StatCollector.translateToLocalFormatted(this.getUnlocalizedNameInefficiently(stack) + ".name", matName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -115,8 +115,10 @@ public class TextureAtlasSpriteMutatable extends TextureAtlasSprite {
|
||||
loadSprite(abufferedimage, animationmetadatasection, (float) anisotropic > 1.0F);
|
||||
} catch(RuntimeException runtimeexception) {
|
||||
cpw.mods.fml.client.FMLClientHandler.instance().trackBrokenTexture(resourcelocation1, runtimeexception.getMessage());
|
||||
return true; //return TRUE to prevent stitching non-existent texture, vanilla loading will deal with that!
|
||||
} catch(IOException ioexception1) {
|
||||
cpw.mods.fml.client.FMLClientHandler.instance().trackMissingTexture(resourcelocation1);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false; //FALSE! prevents vanilla loading (we just did that ourselves)
|
||||
|
||||
@ -6,6 +6,8 @@ import java.util.List;
|
||||
import com.hbm.inventory.container.ContainerWatz;
|
||||
import com.hbm.inventory.fluid.Fluids;
|
||||
import com.hbm.inventory.fluid.tank.FluidTank;
|
||||
import com.hbm.inventory.fluid.trait.FT_Heatable;
|
||||
import com.hbm.inventory.fluid.trait.FT_Heatable.HeatingStep;
|
||||
import com.hbm.inventory.gui.GUIWatz;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.items.machine.ItemWatzPellet.EnumWatzType;
|
||||
@ -30,6 +32,7 @@ public class TileEntityWatz extends TileEntityMachineBase implements IGUIProvide
|
||||
|
||||
public FluidTank[] tanks;
|
||||
public int heat;
|
||||
public double fluxLastBase;
|
||||
public double fluxLastReaction; //stores the flux created by the reaction, excludes passive emission
|
||||
public double fluxDisplay;
|
||||
|
||||
@ -55,17 +58,86 @@ public class TileEntityWatz extends TileEntityMachineBase implements IGUIProvide
|
||||
|
||||
if(!worldObj.isRemote && !updateLock()) {
|
||||
|
||||
//TODO: figure out how to make fluid transport instant instead of sloshy,
|
||||
//perhaps an initial count that combines all tanks into one large virtual one?
|
||||
List<TileEntityWatz> segments = new ArrayList();
|
||||
segments.add(this);
|
||||
|
||||
/* accumulate all segments */
|
||||
for(int y = yCoord - 3; y >= 0; y -= 3) {
|
||||
TileEntity tile = Compat.getTileStandard(worldObj, xCoord, y, zCoord);
|
||||
if(tile instanceof TileEntityWatz) {
|
||||
segments.add((TileEntityWatz) tile);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* set up shared tanks */
|
||||
FluidTank[] sharedTanks = new FluidTank[3];
|
||||
for(int i = 0; i < 3; i++) sharedTanks[i] = new FluidTank(tanks[i].getTankType(), 0);
|
||||
|
||||
for(TileEntityWatz segment : segments) {
|
||||
for(int i = 0; i < 3; i++) {
|
||||
sharedTanks[i].changeTankSize(sharedTanks[i].getMaxFill() + segment.tanks[i].getMaxFill());
|
||||
sharedTanks[i].setFill(sharedTanks[i].getFill() + segment.tanks[i].getFill());
|
||||
}
|
||||
}
|
||||
|
||||
//update coolant, bottom to top
|
||||
for(int i = segments.size() - 1; i >= 0; i--) {
|
||||
TileEntityWatz segment = segments.get(i);
|
||||
segment.updateCoolant(sharedTanks);
|
||||
}
|
||||
|
||||
/* update reaction, top to bottom */
|
||||
this.updateReaction(null);
|
||||
for(int i = 1; i < segments.size(); i++) {
|
||||
TileEntityWatz segment = segments.get(i);
|
||||
TileEntityWatz above = segments.get(i - 1);
|
||||
segment.updateReaction(above);
|
||||
}
|
||||
|
||||
//TODO: call fluidSend on the bottom-most segment
|
||||
|
||||
/* re-distribute fluid from shared tanks back into actual tanks, bottom to top */
|
||||
for(int i = segments.size() - 1; i >= 0; i--) {
|
||||
TileEntityWatz segment = segments.get(i);
|
||||
for(int j = 0; j < 3; j++) {
|
||||
int min = Math.min(segment.tanks[j].getMaxFill(), sharedTanks[j].getFill());
|
||||
segment.tanks[j].setFill(min);
|
||||
sharedTanks[j].setFill(sharedTanks[j].getFill() - min);
|
||||
}
|
||||
}
|
||||
|
||||
/* send sync packets (order doesn't matter) */
|
||||
for(TileEntityWatz segment : segments) {
|
||||
segment.sendPacket(sharedTanks);
|
||||
segment.heat *= 0.99; //cool 1% per tick
|
||||
}
|
||||
|
||||
updateManual(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateCoolant(FluidTank[] tanks) {
|
||||
|
||||
double coolingFactor = 0.05D; //20% per tick, TEMP
|
||||
double heatToUse = this.heat * coolingFactor;
|
||||
|
||||
//TODO: add sanity checking so fucking with the tank type doesn't instantly crash the game
|
||||
FT_Heatable trait = tanks[0].getTankType().getTrait(FT_Heatable.class);
|
||||
HeatingStep step = trait.getFirstStep();
|
||||
|
||||
int heatCycles = (int) (heatToUse / step.heatReq);
|
||||
int coolCycles = tanks[0].getFill() / step.amountReq;
|
||||
int hotCycles = (tanks[1].getMaxFill() - tanks[1].getFill()) / step.amountProduced;
|
||||
|
||||
int cycles = Math.min(heatCycles, Math.min(hotCycles, coolCycles));
|
||||
this.heat -= cycles * step.heatReq;
|
||||
tanks[0].setFill(tanks[0].getFill() - coolCycles * step.amountReq);
|
||||
tanks[1].setFill(tanks[1].getFill() + hotCycles * step.amountProduced);
|
||||
}
|
||||
|
||||
/** enforces strict top to bottom update order (instead of semi-random based on placement) */
|
||||
public void updateManual(boolean topMost) {
|
||||
|
||||
//TODO: do heat to coolant first
|
||||
public void updateReaction(TileEntityWatz above) {
|
||||
|
||||
List<ItemStack> pellets = new ArrayList();
|
||||
|
||||
@ -111,29 +183,27 @@ public class TileEntityWatz extends TileEntityMachineBase implements IGUIProvide
|
||||
}
|
||||
|
||||
this.heat += addedHeat;
|
||||
this.fluxLastBase = baseFlux;
|
||||
this.fluxLastReaction = addedFlux;
|
||||
}
|
||||
|
||||
public void sendPacket(FluidTank[] tanks) {
|
||||
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setInteger("heat", this.heat);
|
||||
data.setDouble("flux", this.fluxLastReaction + baseFlux);
|
||||
data.setDouble("flux", this.fluxLastReaction + this.fluxLastBase);
|
||||
for(int i = 0; i < tanks.length; i++) {
|
||||
tanks[i].writeToNBT(data, "t" + i);
|
||||
}
|
||||
this.networkPack(data, 25);
|
||||
|
||||
TileEntity below = Compat.getTileStandard(worldObj, xCoord, yCoord - 3, zCoord);
|
||||
if(below instanceof TileEntityWatz) {
|
||||
TileEntityWatz watz = (TileEntityWatz) below;
|
||||
//TODO: move down fluids and exchange pellets
|
||||
watz.updateManual(false);
|
||||
}
|
||||
}
|
||||
|
||||
/** Prevent manual updates when another segment is above this one */
|
||||
public boolean updateLock() {
|
||||
return Compat.getTileStandard(worldObj, xCoord, yCoord + 3, zCoord) instanceof TileEntityWatz;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void networkUnpack(NBTTagCompound nbt) {
|
||||
this.heat = nbt.getInteger("heat");
|
||||
this.fluxDisplay = nbt.getDouble("flux");
|
||||
@ -142,6 +212,16 @@ public class TileEntityWatz extends TileEntityMachineBase implements IGUIProvide
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack stack) {
|
||||
return stack.getItem() == ModItems.watz_pellet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
AxisAlignedBB bb = null;
|
||||
|
||||
@Override
|
||||
|
||||
@ -512,7 +512,7 @@ public class InventoryUtil {
|
||||
slot.putStack(current);
|
||||
success = true;
|
||||
} else if(current.stackSize < max) {
|
||||
stack.stackSize -= stack.getMaxStackSize() - current.stackSize;
|
||||
stack.stackSize -= max - current.stackSize;
|
||||
current.stackSize = max;
|
||||
slot.putStack(current);
|
||||
success = true;
|
||||
|
||||
@ -36,7 +36,7 @@ public class StatHelper {
|
||||
*/
|
||||
public static void resetStatShitFuck() {
|
||||
|
||||
publicReferenceToOneshotStatListPleaseAllPointAndLaugh = ReflectionHelper.getPrivateValue(StatList.class, null, "oneShotStats"); //TODO: not fuck up the mapping here
|
||||
publicReferenceToOneshotStatListPleaseAllPointAndLaugh = ReflectionHelper.getPrivateValue(StatList.class, null, "field_75942_a", "oneShotStats"); //TODO: not fuck up the mapping here
|
||||
|
||||
for(int i = 0; i < StatList.objectCraftStats.length; i++) StatList.objectCraftStats[i] = null;
|
||||
for(int i = 0; i < StatList.mineBlockStatArray.length; i++) StatList.mineBlockStatArray[i] = null;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user