better hadron diagnostics, chemplant + thermal cache fix (?)

This commit is contained in:
Boblet 2022-04-11 16:17:46 +02:00
parent 23eee96fae
commit 4d2bda7820
9 changed files with 109 additions and 32 deletions

View File

@ -1,5 +1,8 @@
package com.hbm.inventory.gui;
import java.util.ArrayList;
import java.util.List;
import org.lwjgl.opengl.GL11;
import com.hbm.inventory.container.ContainerHadron;
@ -14,6 +17,7 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
public class GUIHadron extends GuiInfoContainer {
@ -44,29 +48,37 @@ public class GUIHadron extends GuiInfoContainer {
this.drawCustomInfoStat(mouseX, mouseY, guiLeft + 142, guiTop + 107, 18, 18, mouseX, mouseY, I18nUtil.resolveKeyArray("hadron.modeLine"));
else
this.drawCustomInfoStat(mouseX, mouseY, guiLeft + 142, guiTop + 107, 18, 18, mouseX, mouseY, I18nUtil.resolveKeyArray("hadron.modeCircular"));
List<String> stats = new ArrayList();
stats.add(EnumChatFormatting.YELLOW + I18nUtil.resolveKey("hadron.stats"));
stats.add((hadron.stat_success ? EnumChatFormatting.GREEN : EnumChatFormatting.RED) + I18n.format("hadron." + this.hadron.state.name().toLowerCase()));
if(this.hadron.state.showCoord) stats.add(EnumChatFormatting.RED + I18nUtil.resolveKey("hadron.stats_coord", hadron.stat_x, hadron.stat_y, hadron.stat_z));
stats.add(EnumChatFormatting.GRAY + I18nUtil.resolveKey("hadron.stats_momentum", hadron.stat_charge));
this.drawCustomInfoStat(mouseX, mouseY, guiLeft + 41, guiTop + 92, 25, 11, mouseX, mouseY, stats.toArray(new String[0]));
}
@Override
protected void mouseClicked(int x, int y, int i) {
super.mouseClicked(x, y, i);
//Toggle hadron
if(guiLeft + 19 <= x && guiLeft + 19 + 18 > x && guiTop + 89 < y && guiTop + 89 + 18 >= y) {
super.mouseClicked(x, y, i);
// Toggle hadron
if(guiLeft + 19 <= x && guiLeft + 19 + 18 > x && guiTop + 89 < y && guiTop + 89 + 18 >= y) {
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
PacketDispatcher.wrapper.sendToServer(new AuxButtonPacket(hadron.xCoord, hadron.yCoord, hadron.zCoord, 0, 0));
}
//Toggle analysis chamber
if(guiLeft + 142 <= x && guiLeft + 142 + 18 > x && guiTop + 107 < y && guiTop + 107 + 18 >= y) {
PacketDispatcher.wrapper.sendToServer(new AuxButtonPacket(hadron.xCoord, hadron.yCoord, hadron.zCoord, 0, 0));
}
// Toggle analysis chamber
if(guiLeft + 142 <= x && guiLeft + 142 + 18 > x && guiTop + 107 < y && guiTop + 107 + 18 >= y) {
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
PacketDispatcher.wrapper.sendToServer(new AuxButtonPacket(hadron.xCoord, hadron.yCoord, hadron.zCoord, 0, 1));
}
//Toggle hopper mode
if(guiLeft + 142 <= x && guiLeft + 142 + 18 > x && guiTop + 89 < y && guiTop + 89 + 18 >= y) {
PacketDispatcher.wrapper.sendToServer(new AuxButtonPacket(hadron.xCoord, hadron.yCoord, hadron.zCoord, 0, 1));
}
// Toggle hopper mode
if(guiLeft + 142 <= x && guiLeft + 142 + 18 > x && guiTop + 89 < y && guiTop + 89 + 18 >= y) {
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
PacketDispatcher.wrapper.sendToServer(new AuxButtonPacket(hadron.xCoord, hadron.yCoord, hadron.zCoord, 0, 2));
}
}
PacketDispatcher.wrapper.sendToServer(new AuxButtonPacket(hadron.xCoord, hadron.yCoord, hadron.zCoord, 0, 2));
}
}
@Override
protected void drawGuiContainerForegroundLayer(int i, int j) {

View File

@ -6,6 +6,7 @@ import java.util.List;
import com.hbm.inventory.RecipesCommon;
import com.hbm.inventory.RecipesCommon.ComparableStack;
import com.hbm.items.ModItems;
import com.hbm.tileentity.machine.TileEntityHadron.EnumHadronState;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
@ -112,6 +113,8 @@ public class HadronRecipes {
));
}
public static EnumHadronState returnCode = EnumHadronState.NORESULT;
/**
* Resolves recipes, simple enough.
* @param in1
@ -126,12 +129,16 @@ public class HadronRecipes {
if((r.in1.isApplicable(in1) && r.in2.isApplicable(in2)) ||
(r.in1.isApplicable(in2) && r.in2.isApplicable(in1))) {
if(analysisOnly != r.analysisOnly) returnCode = EnumHadronState.NORESULT_WRONG_MODE;
if(momentum < r.momentum) returnCode = EnumHadronState.NORESULT_TOO_SLOW;
if(momentum >= r.momentum && analysisOnly == r.analysisOnly)
return new ItemStack[] {r.out1, r.out2};
}
}
returnCode = EnumHadronState.NORESULT_WRONG_INGREDIENT;
return null;
}

View File

@ -5,14 +5,12 @@ import com.hbm.packet.AuxGaugePacket;
import com.hbm.packet.NBTPacket;
import com.hbm.packet.PacketDispatcher;
import api.hbm.energy.ILoadedTile;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidTank;

View File

@ -43,6 +43,13 @@ public class TileEntityHadron extends TileEntityMachineBase implements IEnergyUs
private static final int delayNoResult = 60;
private static final int delayError = 100;
public boolean stat_success = false;
public EnumHadronState stat_state = EnumHadronState.IDLE;
public int stat_charge = 0;
public int stat_x = 0;
public int stat_y = 0;
public int stat_z = 0;
public TileEntityHadron() {
super(5);
}
@ -110,6 +117,13 @@ public class TileEntityHadron extends TileEntityMachineBase implements IEnergyUs
data.setBoolean("analysis", analysisOnly);
data.setBoolean("hopperMode", hopperMode);
data.setByte("state", (byte) state.ordinal());
data.setBoolean("stat_success", stat_success);
data.setByte("stat_state", (byte) stat_state.ordinal());
data.setInteger("stat_charge", stat_charge);
data.setInteger("stat_x", stat_x);
data.setInteger("stat_y", stat_y);
data.setInteger("stat_z", stat_z);
this.networkPack(data, 50);
}
}
@ -119,9 +133,10 @@ public class TileEntityHadron extends TileEntityMachineBase implements IEnergyUs
ItemStack[] result = HadronRecipes.getOutput(p.item1, p.item2, p.momentum, analysisOnly);
if(result == null) {
this.state = EnumHadronState.NORESULT;
this.state = HadronRecipes.returnCode;
this.delay = delayNoResult;
worldObj.playSoundEffect(p.posX, p.posY, p.posZ, "random.orb", 2, 0.5F);
this.setStats(this.state, p.momentum, false);
return;
}
@ -150,6 +165,7 @@ public class TileEntityHadron extends TileEntityMachineBase implements IEnergyUs
worldObj.playSoundEffect(p.posX, p.posY, p.posZ, "random.orb", 2, 1F);
this.delay = delaySuccess;
this.state = EnumHadronState.SUCCESS;
this.setStats(this.state, p.momentum, true);
}
@Override
@ -159,6 +175,13 @@ public class TileEntityHadron extends TileEntityMachineBase implements IEnergyUs
this.analysisOnly = data.getBoolean("analysis");
this.hopperMode = data.getBoolean("hopperMode");
this.state = EnumHadronState.values()[data.getByte("state")];
this.stat_success = data.getBoolean("stat_success");
this.stat_state = EnumHadronState.values()[data.getByte("stat_state")];
this.stat_charge = data.getInteger("stat_charge");
this.stat_x = data.getInteger("stat_x");
this.stat_y = data.getInteger("stat_y");
this.stat_z = data.getInteger("stat_z");
}
@Override
@ -261,6 +284,21 @@ public class TileEntityHadron extends TileEntityMachineBase implements IEnergyUs
return false;
}
private void setStats(EnumHadronState state, int count, boolean success) {
this.stat_state = state;
this.stat_charge = count;
this.stat_success = success;
}
private void setExpireStats(EnumHadronState state, int count, int x, int y, int z) {
this.stat_state = state;
this.stat_charge = count;
this.stat_x = x;
this.stat_y = y;
this.stat_z = z;
this.stat_success = false;
}
public class Particle {
//Starting values
@ -307,6 +345,7 @@ public class TileEntityHadron extends TileEntityMachineBase implements IEnergyUs
TileEntityHadron.this.state = reason;
TileEntityHadron.this.delay = delayError;
TileEntityHadron.this.setExpireStats(reason, this.charge, posX, posY, posZ);
}
public boolean isExpired() {
@ -673,22 +712,31 @@ public class TileEntityHadron extends TileEntityMachineBase implements IEnergyUs
PROGRESS(0xffff00),
ANALYSIS(0xffff00),
NORESULT(0xff8000),
NORESULT_TOO_SLOW(0xff8000),
NORESULT_WRONG_INGREDIENT(0xff8000),
NORESULT_WRONG_MODE(0xff8000),
SUCCESS(0x00ff00),
ERROR_NO_CHARGE(0xff0000),
ERROR_NO_ANALYSIS(0xff0000),
ERROR_OBSTRUCTED_CHANNEL(0xff0000),
ERROR_EXPECTED_COIL(0xff0000),
ERROR_MALFORMED_SEGMENT(0xff0000),
ERROR_ANALYSIS_TOO_LONG(0xff0000),
ERROR_ANALYSIS_TOO_SHORT(0xff0000),
ERROR_DIODE_COLLISION(0xff0000),
ERROR_BRANCHING_TURN(0xff0000),
ERROR_GENERIC(0xff0000);
ERROR_NO_CHARGE(0xff0000, true),
ERROR_NO_ANALYSIS(0xff0000, true),
ERROR_OBSTRUCTED_CHANNEL(0xff0000, true),
ERROR_EXPECTED_COIL(0xff0000, true),
ERROR_MALFORMED_SEGMENT(0xff0000, true),
ERROR_ANALYSIS_TOO_LONG(0xff0000, true),
ERROR_ANALYSIS_TOO_SHORT(0xff0000, true),
ERROR_DIODE_COLLISION(0xff0000, true),
ERROR_BRANCHING_TURN(0xff0000, true),
ERROR_GENERIC(0xff0000, true);
public int color;
public boolean showCoord;
private EnumHadronState(int color) {
this(color, false);
}
private EnumHadronState(int color, boolean showCoord) {
this.color = color;
this.showCoord = showCoord;
}
}
}

View File

@ -389,7 +389,7 @@ public class TileEntityMachineChemplant extends TileEntityMachineBase implements
for(int j = 0; j < inv.getSizeInventory(); j++) {
if(inv.getStackInSlot(j) == null) {
if(inv.getStackInSlot(j) == null && inv.isItemValidForSlot(j, out)) {
ItemStack copy = out.copy();
copy.stackSize = 1;
inv.setInventorySlotContents(j, copy);

View File

@ -286,7 +286,7 @@ public abstract class TileEntityMachineChemplantBase extends TileEntityMachineBa
for(int j = 0; j < inv.getSizeInventory(); j++) {
if(inv.getStackInSlot(j) == null) {
if(inv.getStackInSlot(j) == null && inv.isItemValidForSlot(j, out)) {
ItemStack copy = out.copy();
copy.stackSize = 1;
inv.setInventorySlotContents(j, copy);

View File

@ -437,7 +437,13 @@ hadron.idle=Leerlauf
hadron.modeCircular=§eRingbeschleuniger:$Magnete bilden eine Schleife.$Schaltet mehr Rezepte frei.
hadron.modeLine=§eLinearbeschleuniger:$Beschleuniger ended mit Analysekammer.$Weniger Rezepte.
hadron.noresult=Kein Ergebnis.
hadron.noresult_too_slow=Momentum unz.!
hadron.noresult_wrong_ingredient=Falsches Rezept!
hadron.noresult_wrong_mode=Falscher Modus!
hadron.progress=Verarbeite...
hadron.stats=Letztes Ergebnis:
hadron.stats_coord=Position des Fehlers: %s / %s / %s
hadron.stats_momentum=Momentum: %s
hadron.success=Abgeschlossen!
hazard.prot=Schützt vor Gefahren:

View File

@ -630,7 +630,13 @@ hadron.idle=Idle
hadron.modeCircular=§eCircular Accelerator Mode:$Magnets must loop back into core.$Unlocks more recipes.
hadron.modeLine=§eLinear Accelerator Mode:$Accelerator ends with analysis chamber.$Fewer Recipes.
hadron.noresult=No Result.
hadron.noresult_too_slow=Insuff. momentum!
hadron.noresult_wrong_ingredient=Invalid recipe!
hadron.noresult_wrong_mode=Wrong mode!
hadron.progress=In Progress...
hadron.stats=Previous results:
hadron.stats_coord=Erroring position: %s / %s / %s
hadron.stats_momentum=Momentum: %s
hadron.success=Completed!
hazard.prot=Protects against hazards:

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 7.5 KiB