Merge pull request #621 from Vaern/GC-Rework-Pt2

Gas Centrifuge Rework Part Two: Righting my Wrongs Boogaloo
This commit is contained in:
HbmMods 2022-06-17 13:41:31 +02:00 committed by GitHub
commit 0b511f604f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 338 additions and 271 deletions

View File

@ -1,18 +1,27 @@
package com.hbm.handler.nei; package com.hbm.handler.nei;
import static codechicken.lib.gui.GuiDraw.drawTexturedModalRect;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import com.hbm.handler.nei.AnvilRecipeHandler.RecipeSet;
import com.hbm.inventory.gui.GUIMachineGasCent; import com.hbm.inventory.gui.GUIMachineGasCent;
import com.hbm.inventory.recipes.GasCentrifugeRecipes; import com.hbm.inventory.recipes.GasCentrifugeRecipes;
import com.hbm.inventory.recipes.MachineRecipes; import com.hbm.inventory.recipes.MachineRecipes;
import com.hbm.lib.RefStrings;
import codechicken.nei.NEIServerUtils; import codechicken.nei.NEIServerUtils;
import codechicken.nei.PositionedStack; import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.TemplateRecipeHandler; import codechicken.nei.recipe.TemplateRecipeHandler;
import codechicken.nei.recipe.TemplateRecipeHandler.RecipeTransferRect;
import codechicken.nei.recipe.TemplateRecipeHandler.RecipeTransferRectHandler;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -22,16 +31,19 @@ public class GasCentrifugeRecipeHandler extends TemplateRecipeHandler {
public class SmeltingSet extends TemplateRecipeHandler.CachedRecipe { public class SmeltingSet extends TemplateRecipeHandler.CachedRecipe {
PositionedStack input; PositionedStack input;
PositionedStack result1; List<PositionedStack> output = new ArrayList();
PositionedStack result2; boolean isHighSpeed;
PositionedStack result3; int centNumber;
public SmeltingSet(ItemStack input, ItemStack result1, ItemStack result2, ItemStack result3) { public SmeltingSet(ItemStack input, ItemStack[] results, boolean isHighSpeed, int centNumber) {
input.stackSize = 1; input.stackSize = 1;
this.input = new PositionedStack(input, 25, 35 - 11); this.input = new PositionedStack(input, 52 - 5, 35 - 11);
this.result1 = new PositionedStack(result1, 128, 26 - 11); this.isHighSpeed = isHighSpeed;
this.result2 = new PositionedStack(result2, 128, 44 - 11); this.centNumber = centNumber;
this.result3 = new PositionedStack(result3, 146, 35 - 11);
for(byte i = 0; i < results.length; i++) {
this.output.add(new PositionedStack(results[i], i % 2 == 0 ? 134 - 5 : 152 - 5, i < 2 ? 26 - 11 : 44 - 11 ));
}
} }
@Override @Override
@ -43,14 +55,13 @@ public class GasCentrifugeRecipeHandler extends TemplateRecipeHandler {
public List<PositionedStack> getOtherStacks() { public List<PositionedStack> getOtherStacks() {
List<PositionedStack> stacks = new ArrayList<PositionedStack>(); List<PositionedStack> stacks = new ArrayList<PositionedStack>();
stacks.add(fuels.get((cycleticks / 48) % fuels.size()).stack); stacks.add(fuels.get((cycleticks / 48) % fuels.size()).stack);
stacks.add(result2); stacks.addAll(output);
stacks.add(result3);
return stacks; return stacks;
} }
@Override @Override
public PositionedStack getResult() { public PositionedStack getResult() {
return result1; return output.get(0);
} }
} }
@ -70,12 +81,7 @@ public class GasCentrifugeRecipeHandler extends TemplateRecipeHandler {
@Override @Override
public String getGuiTexture() { public String getGuiTexture() {
return GUIMachineGasCent.texture.toString(); return RefStrings.MODID + ":textures/gui/nei/gui_nei_centrifuge_gas.png";
}
@Override
public Class<? extends GuiContainer> getGuiClass() {
return GUIMachineGasCent.class;
} }
@Override @Override
@ -93,7 +99,7 @@ public class GasCentrifugeRecipeHandler extends TemplateRecipeHandler {
if((outputId.equals("gascentprocessing")) && getClass() == GasCentrifugeRecipeHandler.class) { if((outputId.equals("gascentprocessing")) && getClass() == GasCentrifugeRecipeHandler.class) {
Map<Object, Object[]> recipes = GasCentrifugeRecipes.getGasCentrifugeRecipes(); Map<Object, Object[]> recipes = GasCentrifugeRecipes.getGasCentrifugeRecipes();
for(Map.Entry<Object, Object[]> recipe : recipes.entrySet()) { for(Map.Entry<Object, Object[]> recipe : recipes.entrySet()) {
this.arecipes.add(new SmeltingSet((ItemStack) recipe.getKey(), (ItemStack) recipe.getValue()[0], (ItemStack) recipe.getValue()[1], (ItemStack) recipe.getValue()[2])); this.arecipes.add(new SmeltingSet((ItemStack) recipe.getKey(), (ItemStack[]) recipe.getValue()[0], (boolean) recipe.getValue()[1], (int) recipe.getValue()[2]));
} }
} else { } else {
super.loadCraftingRecipes(outputId, results); super.loadCraftingRecipes(outputId, results);
@ -104,9 +110,9 @@ public class GasCentrifugeRecipeHandler extends TemplateRecipeHandler {
public void loadCraftingRecipes(ItemStack result) { public void loadCraftingRecipes(ItemStack result) {
Map<Object, Object[]> recipes = GasCentrifugeRecipes.getGasCentrifugeRecipes(); Map<Object, Object[]> recipes = GasCentrifugeRecipes.getGasCentrifugeRecipes();
for(Map.Entry<Object, Object[]> recipe : recipes.entrySet()) { for(Map.Entry<Object, Object[]> recipe : recipes.entrySet()) {
if(NEIServerUtils.areStacksSameType((ItemStack) recipe.getValue()[0], result) || NEIServerUtils.areStacksSameType((ItemStack) recipe.getValue()[1], result) if(NEIServerUtils.areStacksSameType(((ItemStack[]) recipe.getValue()[0])[0], result) || NEIServerUtils.areStacksSameType(((ItemStack[]) recipe.getValue()[0])[1], result)
|| NEIServerUtils.areStacksSameType((ItemStack) recipe.getValue()[2], result)) || NEIServerUtils.areStacksSameType(((ItemStack[]) recipe.getValue()[0])[2], result) || NEIServerUtils.areStacksSameType(((ItemStack[]) recipe.getValue()[0])[3], result))
this.arecipes.add(new SmeltingSet((ItemStack) recipe.getKey(), (ItemStack) recipe.getValue()[0], (ItemStack) recipe.getValue()[1], (ItemStack) recipe.getValue()[2])); this.arecipes.add(new SmeltingSet((ItemStack) recipe.getKey(), (ItemStack[]) recipe.getValue()[0], (boolean) recipe.getValue()[1], (int) recipe.getValue()[2]));
} }
} }
@ -124,7 +130,7 @@ public class GasCentrifugeRecipeHandler extends TemplateRecipeHandler {
Map<Object, Object[]> recipes = GasCentrifugeRecipes.getGasCentrifugeRecipes(); Map<Object, Object[]> recipes = GasCentrifugeRecipes.getGasCentrifugeRecipes();
for(Map.Entry<Object, Object[]> recipe : recipes.entrySet()) { for(Map.Entry<Object, Object[]> recipe : recipes.entrySet()) {
if(compareFluidStacks(ingredient, (ItemStack) recipe.getKey())) if(compareFluidStacks(ingredient, (ItemStack) recipe.getKey()))
this.arecipes.add(new SmeltingSet((ItemStack) recipe.getKey(), (ItemStack) recipe.getValue()[0], (ItemStack) recipe.getValue()[1], (ItemStack) recipe.getValue()[2])); this.arecipes.add(new SmeltingSet((ItemStack) recipe.getKey(), (ItemStack[]) recipe.getValue()[0], (boolean) recipe.getValue()[1], (int) recipe.getValue()[2]));
} }
} }
@ -135,11 +141,42 @@ public class GasCentrifugeRecipeHandler extends TemplateRecipeHandler {
@Override @Override
public void drawExtras(int recipe) { public void drawExtras(int recipe) {
drawProgressBar(3, 51 - 45, 176, 0, 16, 34, 480, 7); drawProgressBar(3, 51 - 45, 176, 0, 16, 34, 480, 7);
drawProgressBar(69, 26, 208, 0, 33, 12, 200, 0);
SmeltingSet set = (SmeltingSet) this.arecipes.get(recipe);
drawProgressBar(79 - 5, 28 - 11, 208, 0, 44, 37, set.isHighSpeed ? 150 - 70 : 150, 0);
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
String centrifuges = set.centNumber + " G. Cents";
fontRenderer.drawString(centrifuges, (50 - fontRenderer.getStringWidth(centrifuges) / 2), 21 - 11, 65280);
} }
public LinkedList<RecipeTransferRect> transferRectsRec = new LinkedList<RecipeTransferRect>();
public LinkedList<RecipeTransferRect> transferRectsGui = new LinkedList<RecipeTransferRect>();
public LinkedList<Class<? extends GuiContainer>> guiRec = new LinkedList<Class<? extends GuiContainer>>();
public LinkedList<Class<? extends GuiContainer>> guiGui = new LinkedList<Class<? extends GuiContainer>>();
@Override @Override
public void loadTransferRects() { public void loadTransferRects() {
transferRects.add(new RecipeTransferRect(new Rectangle(69, 26, 32, 12), "gascentprocessing")); transferRectsGui = new LinkedList<RecipeTransferRect>();
guiGui = new LinkedList<Class<? extends GuiContainer>>();
transferRects.add(new RecipeTransferRect(new Rectangle(79 - 5, 26 - 11, 44, 40), "gascentprocessing"));
transferRectsGui.add(new RecipeTransferRect(new Rectangle(70 - 5, 36 - 11, 36, 12), "gascentprocessing"));
guiGui.add(GUIMachineGasCent.class);
RecipeTransferRectHandler.registerRectsToGuis(getRecipeTransferRectGuis(), transferRects);
RecipeTransferRectHandler.registerRectsToGuis(guiGui, transferRectsGui);
}
@Override
public void drawBackground(int recipe) {
super.drawBackground(recipe);
SmeltingSet set = (SmeltingSet) this.arecipes.get(recipe);
if(set.isHighSpeed)
drawTexturedModalRect(30 - 5, 35 - 11, 192, 0, 16, 16);
} }
} }

View File

@ -18,28 +18,28 @@ public class ContainerMachineGasCent extends Container {
gasCent = tedf; gasCent = tedf;
//Battery
this.addSlotToContainer(new Slot(tedf, 0, 8, 53));
//Fluid ID IO
this.addSlotToContainer(new Slot(tedf, 1, 30, 35));
//Output //Output
this.addSlotToContainer(new SlotMachineOutput(tedf, 2, 133, 26)); for(int i = 0; i < 2; i++) {
this.addSlotToContainer(new SlotMachineOutput(tedf, 3, 133, 44)); for(int j = 0; j < 2; j++) {
this.addSlotToContainer(new SlotMachineOutput(tedf, 4, 151, 35)); this.addSlotToContainer(new SlotMachineOutput(tedf, j + i * 2, 71 + j * 18, 53 + i * 18));
//upgrade
this.addSlotToContainer(new Slot(tedf, 5, 82, 19));
for(int i = 0; i < 3; i++)
{
for(int j = 0; j < 9; j++)
{
this.addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
} }
} }
for(int i = 0; i < 9; i++) //Battery
{ this.addSlotToContainer(new Slot(tedf, 4, 182, 71));
this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 142)); //Fluid ID IO
this.addSlotToContainer(new Slot(tedf, 5, 91, 15));
//upgrade
this.addSlotToContainer(new Slot(tedf, 6, 69, 15));
for(int i = 0; i < 3; i++) {
for(int j = 0; j < 9; j++) {
this.addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, 8 + j * 18, 122 + i * 18));
}
}
for(int i = 0; i < 9; i++) {
this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 180));
} }
} }
@ -51,37 +51,29 @@ public class ContainerMachineGasCent extends Container {
@Override @Override
public ItemStack transferStackInSlot(EntityPlayer player, int index) public ItemStack transferStackInSlot(EntityPlayer player, int index)
{ {
ItemStack var3 = null; ItemStack returnStack = null;
Slot slot = (Slot) this.inventorySlots.get(index); Slot slot = (Slot) this.inventorySlots.get(index);
if (slot != null && slot.getHasStack()) if(slot != null && slot.getHasStack()) {
{
ItemStack stack = slot.getStack(); ItemStack stack = slot.getStack();
var3 = stack.copy(); returnStack = stack.copy();
if (index <= 5) { if(index <= 6) {
if (!this.mergeItemStack(stack, 6, this.inventorySlots.size(), true)) if (!this.mergeItemStack(stack, 7, this.inventorySlots.size(), true)) {
{
return null; return null;
} }
} } else if(!this.mergeItemStack(stack, 4, 7, false)) {
else if (!this.mergeItemStack(stack, 0, 2, false)) return null;
{
if (!this.mergeItemStack(stack, 3, 4, false))
return null;
} }
if (stack.stackSize == 0) if (stack.stackSize == 0) {
{
slot.putStack((ItemStack) null); slot.putStack((ItemStack) null);
} } else {
else
{
slot.onSlotChanged(); slot.onSlotChanged();
} }
} }
return var3; return returnStack;
} }
@Override @Override

View File

@ -9,44 +9,57 @@ import com.hbm.tileentity.machine.TileEntityMachineGasCent;
import com.hbm.util.I18nUtil; import com.hbm.util.I18nUtil;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.resources.I18n; import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
public class GUIMachineGasCent extends GuiInfoContainer { public class GUIMachineGasCent extends GuiInfoContainer {
public static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/centrifuge_gas.png"); public static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/processing/gui_centrifuge_gas.png");
private TileEntityMachineGasCent gasCent; private TileEntityMachineGasCent gasCent;
public GUIMachineGasCent(InventoryPlayer invPlayer, TileEntityMachineGasCent tedf) { public GUIMachineGasCent(InventoryPlayer invPlayer, TileEntityMachineGasCent tedf) {
super(new ContainerMachineGasCent(invPlayer, tedf)); super(new ContainerMachineGasCent(invPlayer, tedf));
gasCent = tedf; gasCent = tedf;
this.xSize = 176; this.xSize = 206;
this.ySize = 168; this.ySize = 204;
} }
@Override @Override
public void drawScreen(int mouseX, int mouseY, float f) { public void drawScreen(int mouseX, int mouseY, float f) {
super.drawScreen(mouseX, mouseY, f); super.drawScreen(mouseX, mouseY, f);
this.drawCustomInfoStat(mouseX, mouseY, guiLeft + 58, guiTop + 30, 8, 33, mouseX, mouseY, new String[] {gasCent.inputTank.getTankType().getName(), gasCent.inputTank.getFill() + " / " + gasCent.inputTank.getMaxFill() + " mB"}); String[] inTankInfo = new String[] {gasCent.inputTank.getTankType().getName(), gasCent.inputTank.getFill() + " / " + gasCent.inputTank.getMaxFill() + " mB"};
this.drawCustomInfoStat(mouseX, mouseY, guiLeft + 114, guiTop + 30, 8, 33, mouseX, mouseY, new String[] {gasCent.outputTank.getTankType().getName(), gasCent.outputTank.getFill() + " / " + gasCent.outputTank.getMaxFill() + " mB"}); if(gasCent.inputTank.getTankType().getIfHighSpeed()) {
if(gasCent.getProcessingSpeed() > gasCent.processingSpeed - 70)
inTankInfo[0] = EnumChatFormatting.DARK_RED + inTankInfo[0];
else
inTankInfo[0] = EnumChatFormatting.GOLD + inTankInfo[0];
}
String[] outTankInfo = new String[] {gasCent.outputTank.getTankType().getName(), gasCent.outputTank.getFill() + " / " + gasCent.outputTank.getMaxFill() + " mB"};
if(gasCent.outputTank.getTankType().getIfHighSpeed())
outTankInfo[0] = EnumChatFormatting.GOLD + outTankInfo[0];
this.drawElectricityInfo(this, mouseX, mouseY, guiLeft + 8, guiTop + 51 - 34, 16, 34, gasCent.power, gasCent.maxPower); this.drawCustomInfoStat(mouseX, mouseY, guiLeft + 15, guiTop + 15, 24, 55, mouseX, mouseY, inTankInfo);
this.drawCustomInfoStat(mouseX, mouseY, guiLeft + 137, guiTop + 15, 25, 55, mouseX, mouseY, outTankInfo);
this.drawElectricityInfo(this, mouseX, mouseY, guiLeft + 182, guiTop + 69 - 52, 16, 52, gasCent.power, gasCent.maxPower);
String[] enrichmentText = I18nUtil.resolveKeyArray("desc.gui.gasCent.enrichment"); String[] enrichmentText = I18nUtil.resolveKeyArray("desc.gui.gasCent.enrichment");
this.drawCustomInfoStat(mouseX, mouseY, guiLeft - 16, guiTop + 16, 16, 16, guiLeft - 8, guiTop + 16 + 16, enrichmentText); this.drawCustomInfoStat(mouseX, mouseY, guiLeft - 12, guiTop + 16, 16, 16, guiLeft - 8, guiTop + 16 + 16, enrichmentText);
String[] transferText = I18nUtil.resolveKeyArray("desc.gui.gasCent.output"); String[] transferText = I18nUtil.resolveKeyArray("desc.gui.gasCent.output");
this.drawCustomInfoStat(mouseX, mouseY, guiLeft - 16, guiTop + 32, 16, 16, guiLeft - 8, guiTop + 32 + 16, transferText); this.drawCustomInfoStat(mouseX, mouseY, guiLeft - 12, guiTop + 32, 16, 16, guiLeft - 8, guiTop + 32 + 16, transferText);
} }
@Override @Override
protected void drawGuiContainerForegroundLayer(int i, int j) { protected void drawGuiContainerForegroundLayer(int i, int j) {
String name = this.gasCent.hasCustomInventoryName() ? this.gasCent.getInventoryName() : I18n.format(this.gasCent.getInventoryName()); String name = this.gasCent.hasCustomInventoryName() ? this.gasCent.getInventoryName() : I18n.format(this.gasCent.getInventoryName());
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752); //this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752);
this.fontRendererObj.drawString(I18n.format("container.inventory"), 8, this.ySize - 96 + 2, 4210752); this.fontRendererObj.drawString(I18n.format("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
} }
@ -56,44 +69,50 @@ public class GUIMachineGasCent extends GuiInfoContainer {
Minecraft.getMinecraft().getTextureManager().bindTexture(texture); Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
int i = (int)gasCent.getPowerRemainingScaled(34); int i = (int)gasCent.getPowerRemainingScaled(52);
drawTexturedModalRect(guiLeft + 8, guiTop + 51 - i, 176, 34 - i, 16, i); drawTexturedModalRect(guiLeft + 182, guiTop + 69 - i, 206, 52 - i, 16, i);
int j = (int)gasCent.getCentrifugeProgressScaled(33); int j = (int)gasCent.getCentrifugeProgressScaled(36);
drawTexturedModalRect(guiLeft + 74, guiTop + 37, 208, 0, j, 12); drawTexturedModalRect(guiLeft + 70, guiTop + 35, 206, 52, j, 13);
int a = gasCent.getTankScaled(31, 0); this.renderTank(guiLeft + 16, guiTop + 16, this.zLevel, 6, 52, gasCent.inputTank.getFill(), gasCent.inputTank.getMaxFill());
switch (gasCent.inputTank.getTankType()) { this.renderTank(guiLeft + 32, guiTop + 16, this.zLevel, 6, 52, gasCent.inputTank.getFill(), gasCent.inputTank.getMaxFill());
case PF6:
drawTexturedModalRect(guiLeft + 58, guiTop + 62 - a, 200, 31 - a, 8, a);
break;
case MUD:
drawTexturedModalRect(guiLeft + 58, guiTop + 62 - a, 192, 63 - a, 8, a);
break;
case MUD_HEAVY:
drawTexturedModalRect(guiLeft + 58, guiTop + 62 - a, 192, 63 - a, 8, a);
break;
case NONE:
break;
default:
drawTexturedModalRect(guiLeft + 58, guiTop + 62 - a, 192, 31 - a, 8, a);
}
int b = gasCent.getTankScaled(31, 1); this.renderTank(guiLeft + 138, guiTop + 16, this.zLevel, 6, 52, gasCent.outputTank.getFill(), gasCent.outputTank.getMaxFill());
switch (gasCent.outputTank.getTankType()) { this.renderTank(guiLeft + 154, guiTop + 16, this.zLevel, 6, 52, gasCent.outputTank.getFill(), gasCent.outputTank.getMaxFill());
case PF6:
drawTexturedModalRect(guiLeft + 114, guiTop + 62 - b, 200, 31 - b, 8, b);
break;
case MUD_HEAVY:
drawTexturedModalRect(guiLeft + 114, guiTop + 62 - b, 192, 63 - b, 8, b);
break;
case NONE:
break;
default:
drawTexturedModalRect(guiLeft + 114, guiTop + 62 - b, 192, 31 - b, 8, b);
}
this.drawInfoPanel(guiLeft - 16, guiTop + 16, 16, 16, 3); this.drawInfoPanel(guiLeft - 12, guiTop + 16, 16, 16, 3);
this.drawInfoPanel(guiLeft - 16, guiTop + 32, 16, 16, 2); this.drawInfoPanel(guiLeft - 12, guiTop + 32, 16, 16, 2);
}
public void renderTank(int x, int y, double z, int width, int height, int fluid, int maxFluid) {
GL11.glEnable(GL11.GL_BLEND);
y += height;
Minecraft.getMinecraft().getTextureManager().bindTexture(gasCent.tank.getTankType().getTexture());
int i = (fluid * height) / maxFluid;
double minX = x;
double maxX = x + width;
double minY = y - height;
double maxY = y - (height - i);
double minV = 1D;
double maxV = 1D - i / 16D;
double minU = 0D;
double maxU = width / 16D;
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.addVertexWithUV(minX, maxY, z, minU, maxV);
tessellator.addVertexWithUV(maxX, maxY, z, maxU, maxV);
tessellator.addVertexWithUV(maxX, minY, z, maxU, minV);
tessellator.addVertexWithUV(minX, minY, z, minU, minV);
tessellator.draw();
GL11.glDisable(GL11.GL_BLEND);
} }
} }

View File

@ -9,36 +9,41 @@ import com.hbm.inventory.FluidStack;
import com.hbm.inventory.fluid.Fluids; import com.hbm.inventory.fluid.Fluids;
import com.hbm.items.ModItems; import com.hbm.items.ModItems;
import com.hbm.items.machine.ItemFluidIcon; import com.hbm.items.machine.ItemFluidIcon;
import com.hbm.util.I18nUtil;
import com.hbm.util.Tuple.Pair;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
public class GasCentrifugeRecipes { public class GasCentrifugeRecipes {
public static enum PseudoFluidType { public static enum PseudoFluidType {
NONE (0, 0, "NONE", "Empty", false, (ItemStack[])null), NONE (0, 0, null, false, (ItemStack[])null),
NUF6 (400, 300, "LEUF6", "Natural UF6", false, new ItemStack(ModItems.nugget_u238, 1)), HEUF6 (300, 0, NONE, true, new ItemStack(ModItems.nugget_u238, 2), new ItemStack(ModItems.nugget_u235, 1), new ItemStack(ModItems.fluorite, 1)),
LEUF6 (300, 200, "MEUF6", "Low Enriched UF6", false, new ItemStack(ModItems.nugget_u238, 1), new ItemStack(ModItems.fluorite, 1)), MEUF6 (200, 100, HEUF6, false, new ItemStack(ModItems.nugget_u238, 1)),
MEUF6 (200, 100, "HEUF6", "Medium Enriched UF6", false, new ItemStack(ModItems.nugget_u238, 1)), LEUF6 (300, 200, MEUF6, false, new ItemStack(ModItems.nugget_u238, 1), new ItemStack(ModItems.fluorite, 1)),
HEUF6 (300, 0, "NONE", "High Enriched UF6", true, new ItemStack(ModItems.nugget_u238, 2), new ItemStack(ModItems.nugget_u235, 1), new ItemStack(ModItems.fluorite, 1)), NUF6 (400, 300, LEUF6, false, new ItemStack(ModItems.nugget_u238, 1)),
PF6 (300, 0, "NONE", "Plutonium Hexafluoride", false, new ItemStack(ModItems.nugget_pu238, 1), new ItemStack(ModItems.nugget_pu_mix, 2), new ItemStack(ModItems.fluorite, 1)), PF6 (300, 0, NONE, false, new ItemStack(ModItems.nugget_pu238, 1), new ItemStack(ModItems.nugget_pu_mix, 2), new ItemStack(ModItems.fluorite, 1)),
MUD (1000, 500, "MUD_HEAVY", "Poisonous Mud", false, new ItemStack(ModItems.powder_lead, 1), new ItemStack(ModItems.dust, 1)), MUD_HEAVY (500, 0, NONE, false, new ItemStack(ModItems.powder_iron, 1), new ItemStack(ModItems.dust, 1), new ItemStack(ModItems.nuclear_waste_tiny, 1)),
MUD_HEAVY (500, 0, "NONE", "Heavy Mud Fraction", false, new ItemStack(ModItems.powder_iron, 1), new ItemStack(ModItems.dust, 1), new ItemStack(ModItems.nuclear_waste_tiny, 1)); MUD (1000, 500, MUD_HEAVY, false, new ItemStack(ModItems.powder_lead, 1), new ItemStack(ModItems.dust, 1));
//TODO for bob: consider more fluid types
//Schraranium Trisulfide for more schrab-containing, pre-SILEX processing using the crystals?
//Gaseous Nuclear Waste: because why not? Large inputs could output Xe-135 and maybe some other fun stuff...
//
int fluidConsumed; int fluidConsumed;
int fluidProduced; int fluidProduced;
String outputFluid; PseudoFluidType outputFluid;
String name;
boolean isHighSpeed; boolean isHighSpeed;
ItemStack[] output; ItemStack[] output;
PseudoFluidType(int fluidConsumed, int fluidProduced, String outputFluid, String name, boolean isHighSpeed, ItemStack... output) { PseudoFluidType(int fluidConsumed, int fluidProduced, PseudoFluidType outputFluid, boolean isHighSpeed, ItemStack... output) {
this.fluidConsumed = fluidConsumed; this.fluidConsumed = fluidConsumed;
this.fluidProduced = fluidProduced; this.fluidProduced = fluidProduced;
this.outputFluid = outputFluid; this.outputFluid = outputFluid;
this.name = name;
this.isHighSpeed = isHighSpeed; this.isHighSpeed = isHighSpeed;
this.output = output; this.output = output;
} }
@ -51,12 +56,12 @@ public class GasCentrifugeRecipes {
return this.fluidProduced; return this.fluidProduced;
} }
public PseudoFluidType getOutputFluid() { public PseudoFluidType getOutputType() {
return this.valueOf(this.outputFluid); return this.outputFluid;
} }
public String getName() { public String getName() {
return this.name; return I18nUtil.resolveKey("hbmpseudofluid.".concat(this.toString().toLowerCase()));
} }
public boolean getIfHighSpeed() { public boolean getIfHighSpeed() {
@ -70,7 +75,8 @@ public class GasCentrifugeRecipes {
}; };
/* Recipe NEI Handler */ /* Recipe NEI Handler */
private static Map<FluidStack, ItemStack[]> gasCent = new HashMap(); //Fluid input; ItemStack[] outputs, isHighSpeed, # of centrifuges
private static Map<FluidStack, Object[]> gasCent = new HashMap();
//Iterators are lots of fun //Iterators are lots of fun
public static Map<Object, Object[]> getGasCentrifugeRecipes() { public static Map<Object, Object[]> getGasCentrifugeRecipes() {
@ -78,10 +84,10 @@ public class GasCentrifugeRecipes {
Iterator itr = gasCent.entrySet().iterator(); Iterator itr = gasCent.entrySet().iterator();
while(itr.hasNext()) { while(itr.hasNext()) {
Map.Entry entry = (Entry) itr.next(); Map.Entry<Object, Object[]> entry = (Entry) itr.next();
FluidStack input = (FluidStack) entry.getKey(); FluidStack input = (FluidStack) entry.getKey();
ItemStack[] out = new ItemStack[4]; ItemStack[] out = new ItemStack[4];
ItemStack[] outputs = (ItemStack[]) entry.getValue(); ItemStack[] outputs = (ItemStack[]) entry.getValue()[0];
for(int j = 0; j < outputs.length; j++) { for(int j = 0; j < outputs.length; j++) {
out[j] = outputs[j].copy(); out[j] = outputs[j].copy();
@ -90,15 +96,20 @@ public class GasCentrifugeRecipes {
if(out[j] == null) if(out[j] == null)
out[j] = new ItemStack(ModItems.nothing); out[j] = new ItemStack(ModItems.nothing);
recipes.put(ItemFluidIcon.make(input.type, input.fill), outputs); recipes.put(ItemFluidIcon.make(input.type, input.fill), new Object[] { out, entry.getValue()[1], entry.getValue()[2] });
} }
return recipes; return recipes;
} }
public static void register() { public static void register() {
gasCent.put(new FluidStack(1200, Fluids.UF6), new ItemStack[] {new ItemStack(ModItems.nugget_u238, 11), new ItemStack(ModItems.nugget_u235, 1), new ItemStack(ModItems.fluorite, 4)}); gasCent.put(new FluidStack(1200, Fluids.UF6), new Object[] { new ItemStack[]
gasCent.put(new FluidStack(900, Fluids.PUF6), new ItemStack[] {new ItemStack(ModItems.nugget_pu238, 3), new ItemStack(ModItems.nugget_pu_mix, 6), new ItemStack(ModItems.fluorite, 3)}); {new ItemStack(ModItems.nugget_u238, 11), new ItemStack(ModItems.nugget_u235, 1), new ItemStack(ModItems.fluorite, 4)}, true, 4 });
gasCent.put(new FluidStack(1000, Fluids.WATZ), new ItemStack[] {new ItemStack(ModItems.powder_iron, 1), new ItemStack(ModItems.powder_lead, 1), new ItemStack(ModItems.nuclear_waste_tiny, 1)}); gasCent.put(new FluidStack(1200, Fluids.UF6), new Object[] { new ItemStack[]
{new ItemStack(ModItems.nugget_u238, 6), new ItemStack(ModItems.nugget_uranium_fuel, 2), new ItemStack(ModItems.fluorite, 4)}, false, 2 });
gasCent.put(new FluidStack(900, Fluids.PUF6), new Object[] { new ItemStack[]
{new ItemStack(ModItems.nugget_pu238, 3), new ItemStack(ModItems.nugget_pu_mix, 6), new ItemStack(ModItems.fluorite, 3)}, false, 1 });
gasCent.put(new FluidStack(1000, Fluids.WATZ), new Object[] { new ItemStack[]
{new ItemStack(ModItems.powder_iron, 1), new ItemStack(ModItems.powder_lead, 1), new ItemStack(ModItems.nuclear_waste_tiny, 1), new ItemStack(ModItems.dust, 2)}, false, 2 });
} }
} }

View File

@ -772,9 +772,9 @@ public class CraftingManager {
addRecipeAuto(new ItemStack(ModItems.upgrade_centrifuge, 1), new Object[] { "PHP", "PUP", "DTD", 'P', ModItems.centrifuge_element, 'H', Blocks.hopper, 'U', ModItems.upgrade_shredder, 'D', ANY_PLASTIC.ingot(), 'T', ModBlocks.machine_transformer }); addRecipeAuto(new ItemStack(ModItems.upgrade_centrifuge, 1), new Object[] { "PHP", "PUP", "DTD", 'P', ModItems.centrifuge_element, 'H', Blocks.hopper, 'U', ModItems.upgrade_shredder, 'D', ANY_PLASTIC.ingot(), 'T', ModBlocks.machine_transformer });
addRecipeAuto(new ItemStack(ModItems.upgrade_crystallizer, 1), new Object[] { "PHP", "CUC", "DTD", 'P', new ItemStack(ModItems.fluid_barrel_full, 1, Fluids.ACID.getID()), 'H', ModItems.circuit_targeting_tier4, 'C', ModBlocks.barrel_steel, 'U', ModItems.upgrade_centrifuge, 'D', ModItems.motor, 'T', ModBlocks.machine_transformer }); addRecipeAuto(new ItemStack(ModItems.upgrade_crystallizer, 1), new Object[] { "PHP", "CUC", "DTD", 'P', new ItemStack(ModItems.fluid_barrel_full, 1, Fluids.ACID.getID()), 'H', ModItems.circuit_targeting_tier4, 'C', ModBlocks.barrel_steel, 'U', ModItems.upgrade_centrifuge, 'D', ModItems.motor, 'T', ModBlocks.machine_transformer });
addRecipeAuto(new ItemStack(ModItems.upgrade_screm, 1), new Object[] { "SUS", "SCS", "SUS", 'S', STEEL.plate(), 'U', ModItems.upgrade_template, 'C', ModItems.crystal_xen }); addRecipeAuto(new ItemStack(ModItems.upgrade_screm, 1), new Object[] { "SUS", "SCS", "SUS", 'S', STEEL.plate(), 'U', ModItems.upgrade_template, 'C', ModItems.crystal_xen });
addRecipeAuto(new ItemStack(ModItems.upgrade_gc_speed, 1), new Object[] {"GNG", "RUR", "GMG", 'R', RUBBER.ingot(), 'M', ModItems.motor, 'G', ModItems.coil_gold, 'N', TCALLOY.ingot(), 'U', ModItems.upgrade_template}); addRecipeAuto(new ItemStack(ModItems.upgrade_gc_speed, 1), new Object[] {"GNG", "RUR", "GMG", 'R', RUBBER.ingot(), 'M', ModItems.motor, 'G', ModItems.coil_gold, 'N', TCALLOY.ingot(), 'U', ModItems.upgrade_template}); //TODO: gate this behind the upwards gate of the oil chain when it exists
addRecipeAuto(new ItemStack(ModItems.upgrade_stack, 1, 0), new Object[] { " C ", "PUP", " C ", 'C', ModItems.circuit_aluminium, 'P', DictFrame.fromOne(ModItems.part_generic, EnumPartType.PISTON_PNEUMATIC), 'U', ModItems.upgrade_template }); addRecipeAuto(new ItemStack(ModItems.upgrade_stack, 1, 0), new Object[] { " C ", "PUP", " C ", 'C', ModItems.circuit_aluminium, 'P', DictFrame.fromOne(ModItems.part_generic, EnumPartType.PISTON_PNEUMATIC), 'U', ModItems.upgrade_template });
addRecipeAuto(new ItemStack(ModItems.upgrade_stack, 1, 1), new Object[] { " C ", "PUP", " C ", 'C', ModItems.circuit_copper, 'P', DictFrame.fromOne(ModItems.part_generic, EnumPartType.PISTON_HYDRAULIC), 'U', new ItemStack(ModItems.upgrade_stack, 1, 0) }); addRecipeAuto(new ItemStack(ModItems.upgrade_stack, 1, 1), new Object[] { " C ", "PUP", " C ", 'C', ModItems.circuit_copper, 'P', DictFrame.fromOne(ModItems.part_generic, EnumPartType.PISTON_HYDRAULIC), 'U', new ItemStack(ModItems.upgrade_stack, 1, 0) });
addRecipeAuto(new ItemStack(ModItems.upgrade_stack, 1, 2), new Object[] { " C ", "PUP", " C ", 'C', ModItems.circuit_red_copper, 'P', DictFrame.fromOne(ModItems.part_generic, EnumPartType.PISTON_ELECTRIC), 'U', new ItemStack(ModItems.upgrade_stack, 1, 1) }); addRecipeAuto(new ItemStack(ModItems.upgrade_stack, 1, 2), new Object[] { " C ", "PUP", " C ", 'C', ModItems.circuit_red_copper, 'P', DictFrame.fromOne(ModItems.part_generic, EnumPartType.PISTON_ELECTRIC), 'U', new ItemStack(ModItems.upgrade_stack, 1, 1) });
addRecipeAuto(new ItemStack(ModItems.upgrade_ejector, 1, 0), new Object[] { " C ", "PUP", " C ", 'C', ModItems.plate_copper, 'P', ModItems.motor, 'U', ModItems.upgrade_template }); addRecipeAuto(new ItemStack(ModItems.upgrade_ejector, 1, 0), new Object[] { " C ", "PUP", " C ", 'C', ModItems.plate_copper, 'P', ModItems.motor, 'U', ModItems.upgrade_template });

View File

@ -4,21 +4,22 @@ import java.util.HashMap;
import com.hbm.blocks.BlockDummyable; import com.hbm.blocks.BlockDummyable;
import com.hbm.interfaces.IFluidAcceptor; import com.hbm.interfaces.IFluidAcceptor;
import com.hbm.interfaces.IFluidContainer;
import com.hbm.interfaces.Spaghetti;
import com.hbm.interfaces.Untested;
import com.hbm.inventory.FluidTank; import com.hbm.inventory.FluidTank;
import com.hbm.inventory.fluid.FluidType; import com.hbm.inventory.fluid.FluidType;
import com.hbm.inventory.fluid.Fluids; import com.hbm.inventory.fluid.Fluids;
import com.hbm.inventory.recipes.GasCentrifugeRecipes.PseudoFluidType; import com.hbm.inventory.recipes.GasCentrifugeRecipes.PseudoFluidType;
import com.hbm.items.ModItems; import com.hbm.items.ModItems;
import com.hbm.items.machine.IItemFluidIdentifier;
import com.hbm.items.machine.ItemFluidIdentifier; import com.hbm.items.machine.ItemFluidIdentifier;
import com.hbm.lib.Library; import com.hbm.lib.Library;
import com.hbm.packet.LoopedSoundPacket; import com.hbm.packet.LoopedSoundPacket;
import com.hbm.packet.PacketDispatcher; import com.hbm.packet.PacketDispatcher;
import com.hbm.tileentity.TileEntityMachineBase; import com.hbm.tileentity.TileEntityMachineBase;
import com.hbm.util.InventoryUtil;
import com.hbm.util.fauxpointtwelve.DirPos;
import api.hbm.energy.IEnergyUser; import api.hbm.energy.IEnergyUser;
import api.hbm.fluid.IFluidStandardReceiver;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
@ -28,10 +29,9 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
@Spaghetti("I still can't believe this was my idea of a 'rework'") //epic!
public class TileEntityMachineGasCent extends TileEntityMachineBase implements IEnergyUser, IFluidContainer, IFluidAcceptor { public class TileEntityMachineGasCent extends TileEntityMachineBase implements IEnergyUser, IFluidAcceptor, IFluidStandardReceiver {
public byte age;
public long power; public long power;
public int progress; public int progress;
public boolean isProgressing; public boolean isProgressing;
@ -42,11 +42,8 @@ public class TileEntityMachineGasCent extends TileEntityMachineBase implements I
public PseudoFluidTank inputTank; public PseudoFluidTank inputTank;
public PseudoFluidTank outputTank; public PseudoFluidTank outputTank;
private static final int[] slots_top = new int[] {0}; private static final int[] slots_io = new int[] { 0, 1, 2, 3 };
private static final int[] slots_bottom = new int[] {2, 3, 4};
private static final int[] slots_side = new int[] { };
@Untested
private static HashMap<FluidType, PseudoFluidType> fluidConversions = new HashMap(); private static HashMap<FluidType, PseudoFluidType> fluidConversions = new HashMap();
static { static {
@ -56,7 +53,7 @@ public class TileEntityMachineGasCent extends TileEntityMachineBase implements I
} }
public TileEntityMachineGasCent() { public TileEntityMachineGasCent() {
super(6); super(7);
tank = new FluidTank(Fluids.UF6, 2000, 0); tank = new FluidTank(Fluids.UF6, 2000, 0);
inputTank = new PseudoFluidTank(PseudoFluidType.NUF6, 8000); inputTank = new PseudoFluidTank(PseudoFluidType.NUF6, 8000);
outputTank = new PseudoFluidTank(PseudoFluidType.LEUF6, 8000); outputTank = new PseudoFluidTank(PseudoFluidType.LEUF6, 8000);
@ -66,10 +63,15 @@ public class TileEntityMachineGasCent extends TileEntityMachineBase implements I
public String getName() { public String getName() {
return "container.gasCentrifuge"; return "container.gasCentrifuge";
} }
@Override
public boolean canExtractItem(int i, ItemStack itemStack, int j) {
return i < 4;
}
@Override @Override
public int[] getAccessibleSlotsFromSide(int side) { public int[] getAccessibleSlotsFromSide(int side) {
return side == 0 ? slots_bottom : side == 1 ? slots_top : slots_side; return slots_io;
} }
@Override @Override
@ -92,11 +94,6 @@ public class TileEntityMachineGasCent extends TileEntityMachineBase implements I
inputTank.writeToNBT(nbt, "inputTank"); inputTank.writeToNBT(nbt, "inputTank");
outputTank.writeToNBT(nbt, "outputTank"); outputTank.writeToNBT(nbt, "outputTank");
} }
@Override
public boolean canExtractItem(int i, ItemStack itemStack, int j) {
return (i != 0 && i != 1) || j == 1;
}
public int getCentrifugeProgressScaled(int i) { public int getCentrifugeProgressScaled(int i) {
return (progress * i) / getProcessingSpeed(); return (progress * i) / getProcessingSpeed();
@ -106,46 +103,23 @@ public class TileEntityMachineGasCent extends TileEntityMachineBase implements I
return (power * i) / maxPower; return (power * i) / maxPower;
} }
public int getTankScaled(int i, int id) {
if(id == 0) {
return (this.inputTank.getFill() * i) / inputTank.getMaxFill();
} else if(id == 1) {
return (this.outputTank.getFill() * i) / outputTank.getMaxFill();
}
return i;
}
private boolean canEnrich() { private boolean canEnrich() {
if(power > 0 && this.inputTank.getFill() >= inputTank.getTankType().getFluidConsumed() && this.outputTank.getFill() + this.inputTank.getTankType().getFluidProduced() <= outputTank.getMaxFill()) { if(power > 0 && this.inputTank.getFill() >= inputTank.getTankType().getFluidConsumed() && this.outputTank.getFill() + this.inputTank.getTankType().getFluidProduced() <= outputTank.getMaxFill()) {
ItemStack[] list = inputTank.getTankType().getOutput(); ItemStack[] list = inputTank.getTankType().getOutput();
if(this.inputTank.getTankType().getIfHighSpeed()) if(this.inputTank.getTankType().getIfHighSpeed())
if(!(slots[5] != null && slots[5].getItem() == ModItems.upgrade_gc_speed)) if(!(slots[6] != null && slots[6].getItem() == ModItems.upgrade_gc_speed))
return false; return false;
if(list == null) if(list == null)
return false; return false;
if(list.length < 1 || list.length > 3) if(list.length < 1)
return false; return false;
for(int i = 0; i < list.length; i++) { if(InventoryUtil.doesArrayHaveSpace(slots, 0, 3, list))
return true;
int slot = i + 2;
if(slots[slot] == null)
continue;
if(slots[slot].getItem() == list[i].getItem() &&
slots[slot].getItemDamage() == list[i].getItemDamage() &&
slots[slot].stackSize + list[i].stackSize <= slots[slot].getMaxStackSize())
continue;
return false;
}
return true;
} }
return false; return false;
@ -158,54 +132,42 @@ public class TileEntityMachineGasCent extends TileEntityMachineBase implements I
inputTank.setFill(inputTank.getFill() - inputTank.getTankType().getFluidConsumed()); inputTank.setFill(inputTank.getFill() - inputTank.getTankType().getFluidConsumed());
outputTank.setFill(outputTank.getFill() + inputTank.getTankType().getFluidProduced()); outputTank.setFill(outputTank.getFill() + inputTank.getTankType().getFluidProduced());
for(byte i = 0; i < output.length && i < 3; i++) { for(byte i = 0; i < output.length; i++)
if(slots[i + 2] == null) { InventoryUtil.tryAddItemToInventory(slots, 0, 3, output[i].copy()); //reference types almost got me again
slots[i + 2] = output[i].copy();
} else {
slots[i + 2].stackSize += output[i].stackSize;
}
}
} }
private void attemptConversion() { private void attemptConversion() {
if(inputTank.getFill() <= inputTank.getMaxFill() && tank.getFill() > 0) { if(inputTank.getFill() < inputTank.getMaxFill() && tank.getFill() > 0) {
int fill = inputTank.getMaxFill() - inputTank.getFill(); int fill = Math.min(inputTank.getMaxFill() - inputTank.getFill(), tank.getFill());
if(tank.getFill() >= fill) { tank.setFill(tank.getFill() - fill);
tank.setFill(tank.getFill() - fill); inputTank.setFill(inputTank.getFill() + fill);
inputTank.setFill(inputTank.getFill() + fill);
} else {
inputTank.setFill(inputTank.getFill() + tank.getFill());
tank.setFill(0);
}
} }
} }
private boolean attemptTransfer(TileEntity te) { private boolean attemptTransfer(TileEntity te) {
if(te instanceof TileEntityMachineGasCent) { if(te instanceof TileEntityMachineGasCent) {
TileEntityMachineGasCent gasCent = (TileEntityMachineGasCent) te; TileEntityMachineGasCent cent = (TileEntityMachineGasCent) te;
if(gasCent.tank.getFill() == 0 && gasCent.tank.getTankType() == this.tank.getTankType()) { if(cent.tank.getFill() == 0 && cent.tank.getTankType() == tank.getTankType()) {
if(gasCent.inputTank.getTankType() != this.outputTank.getTankType()) { if(cent.inputTank.getTankType() != outputTank.getTankType() && outputTank.getTankType() != PseudoFluidType.NONE) {
gasCent.inputTank.setTankType(this.outputTank.getTankType()); cent.inputTank.setTankType(outputTank.getTankType());
gasCent.outputTank.setTankType(this.outputTank.getTankType().getOutputFluid()); cent.outputTank.setTankType(outputTank.getTankType().getOutputType());
} }
if(gasCent.inputTank.getFill() < gasCent.inputTank.getMaxFill() && this.outputTank.getFill() > 0) { //God, why did I forget about the entirety of the fucking math library?
int fill = gasCent.inputTank.getMaxFill() - gasCent.inputTank.getFill(); if(cent.inputTank.getFill() < cent.inputTank.getMaxFill() && outputTank.getFill() > 0) {
int fill = Math.min(cent.inputTank.getMaxFill() - cent.inputTank.getFill(), outputTank.getFill());
if(this.outputTank.getFill() >= fill) { outputTank.setFill(outputTank.getFill() - fill);
this.outputTank.setFill(this.outputTank.getFill() - fill); cent.inputTank.setFill(cent.inputTank.getFill() + fill);
gasCent.inputTank.setFill(gasCent.inputTank.getFill() + fill);
} else {
gasCent.inputTank.setFill(gasCent.inputTank.getFill() + this.outputTank.getFill());
this.outputTank.setFill(0);
}
} }
return false;
return true;
} }
} }
return true;
return false;
} }
public void networkUnpack(NBTTagCompound data) { public void networkUnpack(NBTTagCompound data) {
@ -220,26 +182,25 @@ public class TileEntityMachineGasCent extends TileEntityMachineBase implements I
@Override @Override
public void updateEntity() { public void updateEntity() {
if(!worldObj.isRemote) { if(!worldObj.isRemote) {
this.updateStandardConnections(worldObj, xCoord, yCoord, zCoord); updateConnections();
power = Library.chargeTEFromItems(slots, 0, power, maxPower); power = Library.chargeTEFromItems(slots, 4, power, maxPower);
setTankType(1); setTankType(5);
tank.updateTank(this);
if(inputTank.getTankType() == PseudoFluidType.PF6 || inputTank.getTankType() == PseudoFluidType.NUF6 || inputTank.getTankType() == PseudoFluidType.MUD) { if(fluidConversions.containsValue(inputTank.getTankType())) {
tank.updateTank(xCoord, yCoord, zCoord, worldObj.provider.dimensionId);
attemptConversion(); attemptConversion();
} }
if(canEnrich()) { if(canEnrich()) {
isProgressing = true; isProgressing = true;
this.progress++; this.progress++;
if(slots[5] != null && slots[5].getItem() == ModItems.upgrade_gc_speed) if(slots[6] != null && slots[6].getItem() == ModItems.upgrade_gc_speed)
this.power -= 300; this.power -= 300;
else else
this.power -= 200; this.power -= 200;
@ -251,28 +212,24 @@ public class TileEntityMachineGasCent extends TileEntityMachineBase implements I
if(progress >= getProcessingSpeed()) if(progress >= getProcessingSpeed())
enrich(); enrich();
} else { } else {
isProgressing = false; isProgressing = false;
this.progress = 0; this.progress = 0;
} }
age++; if(worldObj.getTotalWorldTime() % 10 == 0) {
if(age >= 10) {
age = 0;
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset); ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset);
TileEntity te = worldObj.getTileEntity(this.xCoord - dir.offsetX, this.yCoord, this.zCoord - dir.offsetZ); TileEntity te = worldObj.getTileEntity(this.xCoord - dir.offsetX, this.yCoord, this.zCoord - dir.offsetZ);
if(attemptTransfer(te) && this.inputTank.getTankType() == PseudoFluidType.LEUF6) { //*AT THE MOMENT*, there's not really any need for a dedicated method for this. Yet.
if(this.outputTank.getFill() >= 100 && (slots[4] == null || (slots[4].getItem() == ModItems.nugget_uranium_fuel && slots[4].stackSize + 1 <= slots[4].getMaxStackSize()))) { if(!attemptTransfer(te) && this.inputTank.getTankType() == PseudoFluidType.LEUF6) {
this.outputTank.setFill(this.outputTank.getFill() - 100); ItemStack[] converted = new ItemStack[] { new ItemStack(ModItems.nugget_uranium_fuel, 6), new ItemStack(ModItems.fluorite) };
if(slots[4] == null) {
slots[4] = new ItemStack(ModItems.nugget_uranium_fuel, 1); if(this.outputTank.getFill() >= 600 && InventoryUtil.doesArrayHaveSpace(slots, 0, 3, converted)) {
} else { this.outputTank.setFill(this.outputTank.getFill() - 600);
slots[4].stackSize += 1; for(ItemStack stack : converted)
} InventoryUtil.tryAddItemToInventory(slots, 0, 3, stack);
} }
} }
} }
@ -290,6 +247,26 @@ public class TileEntityMachineGasCent extends TileEntityMachineBase implements I
PacketDispatcher.wrapper.sendToAllAround(new LoopedSoundPacket(xCoord, yCoord, zCoord), new TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 50)); PacketDispatcher.wrapper.sendToAllAround(new LoopedSoundPacket(xCoord, yCoord, zCoord), new TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 50));
} }
} }
private void updateConnections() {
for(DirPos pos : getConPos()) {
this.trySubscribe(worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
if(fluidConversions.containsValue(inputTank.getTankType())) {
this.trySubscribe(tank.getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
}
}
}
private DirPos[] getConPos() {
return new DirPos[] {
new DirPos(xCoord, yCoord - 1, zCoord, Library.NEG_Y),
new DirPos(xCoord + 1, yCoord, zCoord, Library.POS_X),
new DirPos(xCoord - 1, yCoord, zCoord, Library.NEG_X),
new DirPos(xCoord, yCoord, zCoord + 1, Library.POS_Z),
new DirPos(xCoord, yCoord, zCoord - 1, Library.NEG_Z)
};
}
@Override @Override
public void setPower(long i) { public void setPower(long i) {
@ -308,58 +285,62 @@ public class TileEntityMachineGasCent extends TileEntityMachineBase implements I
} }
public int getProcessingSpeed() { public int getProcessingSpeed() {
if(slots[5] != null && slots[5].getItem() == ModItems.upgrade_gc_speed) { if(slots[6] != null && slots[6].getItem() == ModItems.upgrade_gc_speed) {
return processingSpeed - 70; return processingSpeed - 70;
} }
return processingSpeed; return processingSpeed;
} }
public void setTankType(int in) {
if(slots[in] != null && slots[in].getItem() instanceof IItemFluidIdentifier) {
IItemFluidIdentifier id = (IItemFluidIdentifier) slots[in].getItem();
FluidType newType = id.getType(null, 0, 0, 0, slots[in]);
if(tank.getTankType() != newType) {
PseudoFluidType pseudo = fluidConversions.get(newType);
if(pseudo != null) {
inputTank.setTankType(pseudo);
outputTank.setTankType(pseudo.getOutputType());
tank.setTankType(newType);
}
}
}
}
@Override
public void setTypeForSync(FluidType type, int index) {
tank.setTankType(type);
}
@Override @Override
public void setFillForSync(int fill, int index) { public void setFillForSync(int fill, int index) {
tank.setFill(fill); tank.setFill(fill);
} }
@Override @Override
public void setTypeForSync(FluidType type, int index) { public void setFluidFill(int fill, FluidType type) {
tank.setTankType(type); if(type == tank.getTankType())
tank.setFill(fill);
} }
public void setTankType(int in) { @Override
public int getFluidFill(FluidType type) {
if(slots[in] != null && slots[in].getItem() instanceof ItemFluidIdentifier) { return tank.getTankType() == type ? tank.getFill() : 0;
FluidType newType = ItemFluidIdentifier.getType(slots[in]);
if(tank.getTankType() != newType) {
PseudoFluidType pseudo = fluidConversions.get(newType);
if(pseudo != null) {
inputTank.setTankType(pseudo);
outputTank.setTankType(pseudo.getOutputFluid());
tank.setTankType(newType);
tank.setFill(0);
}
}
return;
}
} }
@Override @Override
public int getMaxFluidFill(FluidType type) { public int getMaxFluidFill(FluidType type) {
return type.name().equals(this.tank.getTankType().name()) ? tank.getMaxFill() : 0; return tank.getTankType() == type ? tank.getMaxFill() : 0;
} }
@Override @Override
public int getFluidFill(FluidType type) { public FluidTank[] getReceivingTanks() {
return type.name().equals(this.tank.getTankType().name()) ? tank.getFill() : 0; return new FluidTank[] { tank };
} }
@Override
public void setFluidFill(int i, FluidType type) {
if(type.name().equals(tank.getTankType().name()))
tank.setFill(i);
}
AxisAlignedBB bb = null; AxisAlignedBB bb = null;
@Override @Override
@ -394,10 +375,14 @@ public class TileEntityMachineGasCent extends TileEntityMachineBase implements I
public void setTankType(PseudoFluidType type) { public void setTankType(PseudoFluidType type) {
if(this.type.name().equals(type.name())) if(this.type.equals(type))
return; return;
this.type = type; if(type == null)
this.type = PseudoFluidType.NONE;
else
this.type = type;
this.setFill(0); this.setFill(0);
} }

View File

@ -47,17 +47,32 @@ public class TileEntityRBMKBoiler extends TileEntityRBMKSlottedBase implements I
double heatProvided = this.heat - heatCap; double heatProvided = this.heat - heatCap;
if(heatProvided > 0) { if(heatProvided > 0) {
int waterUsed = (int)Math.floor(heatProvided / RBMKDials.getBoilerHeatConsumption(worldObj)); double HEAT_PER_MB_WATER = RBMKDials.getBoilerHeatConsumption(worldObj);
waterUsed = Math.min(waterUsed, feed.getFill()); double steamFactor = getFactorFromSteam(steam.getTankType());
feed.setFill(feed.getFill() - waterUsed); int waterUsed;
int steamProduced = (int)Math.floor((waterUsed * 100) / getFactorFromSteam(steam.getTankType())); int steamProduced;
steam.setFill(steam.getFill() + steamProduced);
if(steam.getFill() > steam.getMaxFill()) { if(steam.getTankType() == Fluids.ULTRAHOTSTEAM) {
steam.setFill(steam.getMaxFill()); steamProduced = (int)Math.floor((heatProvided / HEAT_PER_MB_WATER) * 100D / steamFactor);
waterUsed = (int)Math.floor(steamProduced / 100D * steamFactor);
if(feed.getFill() < waterUsed) {
steamProduced = (int)Math.floor(feed.getFill() * 100D / steamFactor);
waterUsed = (int)Math.floor(steamProduced / 100D * steamFactor);
}
} else {
waterUsed = (int)Math.floor(heatProvided / HEAT_PER_MB_WATER);
waterUsed = Math.min(waterUsed, feed.getFill());
steamProduced = (int)Math.floor((waterUsed * 100D) / steamFactor);
} }
this.heat -= waterUsed * RBMKDials.getBoilerHeatConsumption(worldObj); feed.setFill(feed.getFill() - waterUsed);
steam.setFill(steam.getFill() + steamProduced);
if(steam.getFill() > steam.getMaxFill())
steam.setFill(steam.getMaxFill());
this.heat -= waterUsed * HEAT_PER_MB_WATER;
} }
fillFluidInit(steam.getTankType()); fillFluidInit(steam.getTankType());

View File

@ -761,6 +761,14 @@ hbmfluid.water=Water
hbmfluid.watz=Poisonous Mud hbmfluid.watz=Poisonous Mud
hbmfluid.xenon=Xenon Gas hbmfluid.xenon=Xenon Gas
hbmfluid.xpjuice=Experience Juice hbmfluid.xpjuice=Experience Juice
hbmpseudofluid.none=Empty
hbmpseudofluid.heuf6=Highly Enriched UF6
hbmpseudofluid.meuf6=Medium Enriched UF6
hbmpseudofluid.leuf6=Low Enriched UF6
hbmpseudofluid.nuf6=Natural UF6
hbmpseudofluid.pf6=Plutonium Hexafluoride
hbmpseudofluid.mud_heavy=Heavy Sludge Fraction
hbmpseudofluid.mud=Poisonous Sludge Gas
info.coil=Coil Strength info.coil=Coil Strength
info.templatefolder=Created with %s info.templatefolder=Created with %s

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB