oh boy it's 2 in the morning

This commit is contained in:
Bob 2022-05-01 01:38:26 +02:00
parent ef921967c0
commit 739a6b4b47
15 changed files with 243 additions and 116 deletions

View File

@ -232,4 +232,21 @@ public class MachineBattery extends BlockContainer implements ILookOverlay {
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text); ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text);
} }
@Override
public boolean hasComparatorInputOverride() {
return true;
}
@Override
public int getComparatorInputOverride(World world, int x, int y, int z, int side) {
TileEntity te = world.getTileEntity(x, y, z);
if(!(te instanceof TileEntityMachineBattery))
return 0;
TileEntityMachineBattery battery = (TileEntityMachineBattery) te;
return battery.getComparatorPower();
}
} }

View File

@ -29,7 +29,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
public class ReactorResearch extends BlockDummyable implements IMultiblock { public class ReactorResearch extends BlockDummyable {
public ReactorResearch(Material mat) { public ReactorResearch(Material mat) {
super(mat); super(mat);

View File

@ -5,7 +5,6 @@ import java.util.Random;
import com.hbm.blocks.BlockDummyable; import com.hbm.blocks.BlockDummyable;
import com.hbm.blocks.ModBlocks; import com.hbm.blocks.ModBlocks;
import com.hbm.interfaces.IMultiblock;
import com.hbm.items.ModItems; import com.hbm.items.ModItems;
import com.hbm.main.MainRegistry; import com.hbm.main.MainRegistry;
import com.hbm.packet.AuxParticlePacketNT; import com.hbm.packet.AuxParticlePacketNT;
@ -24,7 +23,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
public class ZirnoxDestroyed extends BlockDummyable implements IMultiblock { public class ZirnoxDestroyed extends BlockDummyable {
public ZirnoxDestroyed(Material mat) { public ZirnoxDestroyed(Material mat) {
super(mat); super(mat);

View File

@ -45,33 +45,59 @@ public class GUIMachineBattery extends GuiInfoContainer {
else else
deltaText = EnumChatFormatting.YELLOW + "+" + deltaText; deltaText = EnumChatFormatting.YELLOW + "+" + deltaText;
String[] info = { String[] info = { BobMathUtil.getShortNumber(battery.power) + "/" + BobMathUtil.getShortNumber(battery.getMaxPower()) + "HE", deltaText };
BobMathUtil.getShortNumber(battery.power) + "/" + BobMathUtil.getShortNumber(battery.getMaxPower()) + "HE",
deltaText
};
this.drawCustomInfoStat(mouseX, mouseY, guiLeft + 62, guiTop + 69 - 52, 52, 52, mouseX, mouseY, info); this.drawCustomInfoStat(mouseX, mouseY, guiLeft + 62, guiTop + 69 - 52, 52, 52, mouseX, mouseY, info);
String[] text = new String[] { "Click the buttons on the right", String[] text = new String[] { "Click the buttons on the right", "to change battery behavior for", "when redstone is or isn't applied." };
"to change battery behavior for",
"when redstone is or isn't applied." };
this.drawCustomInfoStat(mouseX, mouseY, guiLeft - 16, guiTop + 36, 16, 16, guiLeft - 8, guiTop + 36 + 16, text); this.drawCustomInfoStat(mouseX, mouseY, guiLeft - 16, guiTop + 36, 16, 16, guiLeft - 8, guiTop + 36 + 16, text);
if(battery.childLock) {
String[] childLock = new String[] {
EnumChatFormatting.RED + "Child Safety Lock for Buffer Mode",
EnumChatFormatting.ITALIC + "What is Buffer Mode?",
"Buffer Mode simply combines the input and output modes",
"of the battery. " + EnumChatFormatting.RED + "NO, DON'T STOP READING YET.",
"It absolutely does no more than that. It's not an omniscient",
"load-balancer that somehow knows where you want to direct most of",
"your energy to. Batteries - obviously - still receive energy when in",
"Buffer Mode, which means that combining multiple batteries in Buffer",
"Mode will cause them to constantly send energy back and forth,",
"with only a small share going out to whatever it is you want powered.",
"This can be solved easily by either only using Buffer Mode when",
"actually necessary or by switching to another mode if required.",
"Diodes may also help curb the \"ping-ponging\" of energy.",
"",
EnumChatFormatting.ITALIC + "What is Buffer Mode not?",
"Something to use for every single battery because \"I want to have",
"batteries send and receive anyway\". Rule of thumb: Use your brain,",
"use diodes, actually think about how load distribution should work in",
"your power grid."
};
this.drawCustomInfoStat(mouseX, mouseY, guiLeft + 152, guiTop + 35, 16, 16, guiLeft - 80, guiTop, childLock);
}
} }
protected void mouseClicked(int x, int y, int i) { protected void mouseClicked(int x, int y, int i) {
super.mouseClicked(x, y, i); super.mouseClicked(x, y, i);
if(guiLeft + 133 <= x && guiLeft + 133 + 18 > x && guiTop + 16 < y && guiTop + 16 + 18 >= y) { if(guiLeft + 133 <= x && guiLeft + 133 + 18 > x && guiTop + 16 < y && guiTop + 16 + 18 >= y) {
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F)); mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
PacketDispatcher.wrapper.sendToServer(new AuxButtonPacket(battery.xCoord, battery.yCoord, battery.zCoord, 0, 0)); PacketDispatcher.wrapper.sendToServer(new AuxButtonPacket(battery.xCoord, battery.yCoord, battery.zCoord, 0, 0));
} }
if(guiLeft + 133 <= x && guiLeft + 133 + 18 > x && guiTop + 52 < y && guiTop + 52 + 18 >= y) { if(guiLeft + 133 <= x && guiLeft + 133 + 18 > x && guiTop + 52 < y && guiTop + 52 + 18 >= y) {
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F)); mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
PacketDispatcher.wrapper.sendToServer(new AuxButtonPacket(battery.xCoord, battery.yCoord, battery.zCoord, 0, 1)); PacketDispatcher.wrapper.sendToServer(new AuxButtonPacket(battery.xCoord, battery.yCoord, battery.zCoord, 0, 1));
} }
if(guiLeft + 152 <= x && guiLeft + 152 + 16 > x && guiTop + 35 < y && guiTop + 35 + 16 >= y) {
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
PacketDispatcher.wrapper.sendToServer(new AuxButtonPacket(battery.xCoord, battery.yCoord, battery.zCoord, 0, 2));
}
} }
@Override @Override
@ -90,7 +116,7 @@ public class GUIMachineBattery extends GuiInfoContainer {
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
if(battery.power > 0) { if(battery.power > 0) {
int i = (int)battery.getPowerRemainingScaled(52); int i = (int) battery.getPowerRemainingScaled(52);
drawTexturedModalRect(guiLeft + 62, guiTop + 69 - i, 176, 52 - i, 52, i); drawTexturedModalRect(guiLeft + 62, guiTop + 69 - i, 176, 52 - i, 52, i);
} }
@ -100,6 +126,9 @@ public class GUIMachineBattery extends GuiInfoContainer {
int j = battery.redHigh; int j = battery.redHigh;
drawTexturedModalRect(guiLeft + 133, guiTop + 52, 176, 52 + j * 18, 18, 18); drawTexturedModalRect(guiLeft + 133, guiTop + 52, 176, 52 + j * 18, 18, 18);
if(!battery.childLock)
drawTexturedModalRect(guiLeft + 152, guiTop + 35, 176, 124, 16, 16);
this.drawInfoPanel(guiLeft - 16, guiTop + 36, 16, 16, 2); this.drawInfoPanel(guiLeft - 16, guiTop + 36, 16, 16, 2);
} }
} }

View File

@ -525,7 +525,6 @@ public class ChemplantRecipes extends SerializableRecipe {
for(FluidStack output : chem.outputFluids) { if(output != null) this.writeFluidStack(output, writer); } for(FluidStack output : chem.outputFluids) { if(output != null) this.writeFluidStack(output, writer); }
writer.endArray(); writer.endArray();
//Item OUT //Item OUT
MainRegistry.logger.info("Trying to write output items");
writer.name("itemOutput").beginArray(); writer.name("itemOutput").beginArray();
for(ItemStack output : chem.outputs) { if(output != null) this.writeItemStack(output, writer); } for(ItemStack output : chem.outputs) { if(output != null) this.writeItemStack(output, writer); }
writer.endArray(); writer.endArray();
@ -535,6 +534,13 @@ public class ChemplantRecipes extends SerializableRecipe {
} }
} }
public String getComment() {
return "Rules: All in- and output arrays need to be present, even if empty. IDs need to be unique, but not sequential. It's safe if you add your own"
+ " recipes starting with ID 1000. Template order depends on the order of the recipes in this JSON file. The 'name' field is responsible for"
+ " the texture being loaded for the template. Custom dynamic texture generation is not yet implemented, you will have to throw the texture into"
+ " the JAR manually.";
}
@Override @Override
public void deleteRecipes() { public void deleteRecipes() {
this.indexMapping.clear(); this.indexMapping.clear();

View File

@ -1,16 +1,21 @@
package com.hbm.inventory.recipes; package com.hbm.inventory.recipes;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.stream.JsonWriter;
import com.hbm.inventory.RecipesCommon.ComparableStack; import com.hbm.inventory.RecipesCommon.ComparableStack;
import com.hbm.inventory.recipes.loader.SerializableRecipe;
import com.hbm.items.ModItems; import com.hbm.items.ModItems;
import com.hbm.tileentity.machine.TileEntityHadron.EnumHadronState; import com.hbm.tileentity.machine.TileEntityHadron.EnumHadronState;
import net.minecraft.init.Items; import net.minecraft.init.Items;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
public class HadronRecipes { public class HadronRecipes extends SerializableRecipe {
/* /*
* Since we're dealing with like 10 or so recipes, using a HashMap (or to combine two keys, a HashMap *in* a HashMap) * Since we're dealing with like 10 or so recipes, using a HashMap (or to combine two keys, a HashMap *in* a HashMap)
@ -28,7 +33,8 @@ public class HadronRecipes {
* Having multiple recipes with different momentum requirements (at most I would expect 2) isn't exactly necessary * Having multiple recipes with different momentum requirements (at most I would expect 2) isn't exactly necessary
* since the thing differentiates between ring and line accelerator mode, and line accelerators are by design always shorter anyway. * since the thing differentiates between ring and line accelerator mode, and line accelerators are by design always shorter anyway.
*/ */
public static void register() { @Override
public void registerDefaults() {
recipes.add(new HadronRecipe( recipes.add(new HadronRecipe(
new ItemStack(ModItems.particle_hydrogen), new ItemStack(ModItems.particle_hydrogen),
@ -155,12 +161,69 @@ public class HadronRecipes {
public boolean analysisOnly; public boolean analysisOnly;
public HadronRecipe(ItemStack in1, ItemStack in2, int momentum, ItemStack out1, ItemStack out2, boolean analysisOnly) { public HadronRecipe(ItemStack in1, ItemStack in2, int momentum, ItemStack out1, ItemStack out2, boolean analysisOnly) {
this.in1 = new ComparableStack(in1); this.in1 = new ComparableStack(in1).makeSingular();
this.in2 = new ComparableStack(in2); this.in2 = new ComparableStack(in2).makeSingular();
this.momentum = momentum; this.momentum = momentum;
this.out1 = out1; this.out1 = out1;
this.out2 = out2; this.out2 = out2;
this.out1.stackSize = 1;
this.out2.stackSize = 1;
this.analysisOnly = analysisOnly; this.analysisOnly = analysisOnly;
} }
} }
@Override
public String getFileName() {
return "hbmHadronCollider.json";
}
@Override
public Object getRecipeObject() {
return this.recipes;
}
@Override
public void readRecipe(JsonElement recipe) {
JsonObject obj = (JsonObject) recipe;
int momentum = obj.get("momentum").getAsInt();
boolean lineMode = obj.get("lineMode").getAsBoolean();
ItemStack[] in = this.readItemStackArray(obj.get("inputs").getAsJsonArray());
ItemStack[] out = this.readItemStackArray(obj.get("outputs").getAsJsonArray());
this.recipes.add(new HadronRecipe(
in[0],
in[1],
momentum,
out[0],
out[1],
lineMode
));
}
@Override
public void writeRecipe(Object recipe, JsonWriter writer) throws IOException {
HadronRecipe rec = (HadronRecipe) recipe;
writer.name("momentum").value(rec.momentum);
writer.name("lineMode").value(rec.analysisOnly);
writer.name("inputs").beginArray();
this.writeItemStack(rec.in1.toStack(), writer);
this.writeItemStack(rec.in2.toStack(), writer);
writer.endArray();
writer.name("outputs").beginArray();
this.writeItemStack(rec.out1, writer);
this.writeItemStack(rec.out2, writer);
writer.endArray();
}
public String getComment() {
return "Rules: Both in- and output stacks cannot be null. Stacksizes are set to 1 for all stacks.";
}
@Override
public void deleteRecipes() {
this.recipes.clear();
}
} }

View File

@ -20,8 +20,7 @@ import com.hbm.inventory.RecipesCommon.ComparableStack;
import com.hbm.inventory.RecipesCommon.OreDictStack; import com.hbm.inventory.RecipesCommon.OreDictStack;
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.ChemplantRecipes; import com.hbm.inventory.recipes.*;
import com.hbm.inventory.recipes.FuelPoolRecipes;
import com.hbm.items.ModItems; import com.hbm.items.ModItems;
import com.hbm.main.MainRegistry; import com.hbm.main.MainRegistry;
@ -39,6 +38,7 @@ public abstract class SerializableRecipe {
public static void registerAllHandlers() { public static void registerAllHandlers() {
recipeHandlers.add(new ChemplantRecipes()); recipeHandlers.add(new ChemplantRecipes());
recipeHandlers.add(new HadronRecipes());
recipeHandlers.add(new FuelPoolRecipes()); recipeHandlers.add(new FuelPoolRecipes());
} }
@ -90,6 +90,10 @@ public abstract class SerializableRecipe {
/** Deletes all existing recipes, currenly unused */ /** Deletes all existing recipes, currenly unused */
public abstract void deleteRecipes(); public abstract void deleteRecipes();
public String getComment() {
return null;
}
/* /*
* JSON R/W WRAPPERS * JSON R/W WRAPPERS
*/ */
@ -115,6 +119,11 @@ public abstract class SerializableRecipe {
JsonWriter writer = new JsonWriter(new FileWriter(template)); JsonWriter writer = new JsonWriter(new FileWriter(template));
writer.setIndent(" "); //pretty formatting writer.setIndent(" "); //pretty formatting
writer.beginObject(); //initial '{' writer.beginObject(); //initial '{'
if(this.getComment() != null) {
writer.name("comment").value(this.getComment());
}
writer.name("recipes").beginArray(); //all recipes are stored in an array called "recipes" writer.name("recipes").beginArray(); //all recipes are stored in an array called "recipes"
for(Object recipe : recipeList) { for(Object recipe : recipeList) {
@ -153,7 +162,7 @@ public abstract class SerializableRecipe {
int meta = array.size() > 3 ? array.get(3).getAsInt() : 2; int meta = array.size() > 3 ? array.get(3).getAsInt() : 2;
return new ComparableStack(item, stacksize, meta); return new ComparableStack(item, stacksize, meta);
} }
if("dict".equals("type")) { if("dict".equals(type)) {
String dict = array.get(1).getAsString(); String dict = array.get(1).getAsString();
return new OreDictStack(dict, stacksize); return new OreDictStack(dict, stacksize);
} }

View File

@ -10,7 +10,7 @@ import java.util.Map.Entry;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import com.hbm.extprop.HbmPlayerProps; import com.hbm.extprop.HbmLivingProps;
import com.hbm.handler.radiation.ChunkRadiationManager; import com.hbm.handler.radiation.ChunkRadiationManager;
import com.hbm.util.I18nUtil; import com.hbm.util.I18nUtil;
@ -566,34 +566,29 @@ public class ArmorFSB extends ItemArmor implements IArmorDisableModel {
if(world.getTotalWorldTime() % 5 == 0) { if(world.getTotalWorldTime() % 5 == 0) {
int x = check(world, (int) entity.posX, (int) entity.posY, (int) entity.posZ); float x = HbmLivingProps.getRadBuf((EntityLivingBase)entity);
if(x > 0) { if(x > 1E-5) {
List<Integer> list = new ArrayList<Integer>();
if(x < 1) if(x > 0) {
list.add(0); List<Integer> list = new ArrayList<Integer>();
if(x < 5)
list.add(0);
if(x < 10)
list.add(1);
if(x > 5 && x < 15)
list.add(2);
if(x > 10 && x < 20)
list.add(3);
if(x > 15 && x < 25)
list.add(4);
if(x > 20 && x < 30)
list.add(5);
if(x > 25)
list.add(6);
int r = list.get(world.rand.nextInt(list.size())); if(x < 1) list.add(0);
if(x < 5) list.add(0);
if(x < 10) list.add(1);
if(x > 5 && x < 15) list.add(2);
if(x > 10 && x < 20) list.add(3);
if(x > 15 && x < 25) list.add(4);
if(x > 20 && x < 30) list.add(5);
if(x > 25) list.add(6);
if(r > 0) int r = list.get(world.rand.nextInt(list.size()));
world.playSoundAtEntity(entity, "hbm:item.geiger" + r, 1.0F, 1.0F);
} else if(world.rand.nextInt(50) == 0) { if(r > 0)
world.playSoundAtEntity(entity, "hbm:item.geiger" + (1 + world.rand.nextInt(1)), 1.0F, 1.0F); world.playSoundAtEntity(entity, "hbm:item.geiger" + r, 1.0F, 1.0F);
} else if(world.rand.nextInt(50) == 0) {
world.playSoundAtEntity(entity, "hbm:item.geiger" + (1 + world.rand.nextInt(1)), 1.0F, 1.0F);
}
} }
} }
} }

View File

@ -42,22 +42,14 @@ public class ItemGeigerCounter extends Item {
if(x > 1E-5) { if(x > 1E-5) {
List<Integer> list = new ArrayList<Integer>(); List<Integer> list = new ArrayList<Integer>();
if(x < 1) if(x < 1) list.add(0);
list.add(0); if(x < 5) list.add(0);
if(x < 5) if(x < 10) list.add(1);
list.add(0); if(x > 5 && x < 15) list.add(2);
if(x < 10) if(x > 10 && x < 20) list.add(3);
list.add(1); if(x > 15 && x < 25) list.add(4);
if(x > 5 && x < 15) if(x > 20 && x < 30) list.add(5);
list.add(2); if(x > 25) list.add(6);
if(x > 10 && x < 20)
list.add(3);
if(x > 15 && x < 25)
list.add(4);
if(x > 20 && x < 30)
list.add(5);
if(x > 25)
list.add(6);
int r = list.get(rand.nextInt(list.size())); int r = list.get(rand.nextInt(list.size()));

View File

@ -960,9 +960,9 @@ public class MainRegistry {
TileEntityNukeFurnace.registerFuels(); TileEntityNukeFurnace.registerFuels();
BreederRecipes.registerRecipes(); BreederRecipes.registerRecipes();
AssemblerRecipes.loadRecipes(); AssemblerRecipes.loadRecipes();
//ChemplantRecipes.register(); //moved to SerializableRecipe //ChemplantRecipes.register(); moved to SerializableRecipe
CyclotronRecipes.register(); CyclotronRecipes.register();
HadronRecipes.register(); //HadronRecipes.register(); moved to SerializableRecipe
MagicRecipes.register(); MagicRecipes.register();
SILEXRecipes.register(); SILEXRecipes.register();
AnvilRecipes.register(); AnvilRecipes.register();

View File

@ -242,7 +242,7 @@ public class ModEventHandlerRenderer {
public static int currentBrightness = 0; public static int currentBrightness = 0;
public static int lastBrightness = 0; public static int lastBrightness = 0;
@SubscribeEvent /*@SubscribeEvent
public void onOverlayRender(RenderGameOverlayEvent.Pre event) { public void onOverlayRender(RenderGameOverlayEvent.Pre event) {
if(event.type == ElementType.PORTAL) { if(event.type == ElementType.PORTAL) {
@ -306,5 +306,5 @@ public class ModEventHandlerRenderer {
GL11.glPopMatrix(); GL11.glPopMatrix();
} }
} }*/
} }

View File

@ -165,11 +165,20 @@ public class AuxButtonPacket implements IMessage {
if(m.id == 0) { if(m.id == 0) {
bat.redLow = (short) ((bat.redLow + 1) % 4); bat.redLow = (short) ((bat.redLow + 1) % 4);
if(bat.redLow == 1 && bat.childLock)
bat.redLow++;
bat.markDirty(); bat.markDirty();
} }
if(m.id == 1) { if(m.id == 1) {
bat.redHigh = (short) ((bat.redHigh + 1) % 4); bat.redHigh = (short) ((bat.redHigh + 1) % 4);
if(bat.redHigh == 1 && bat.childLock)
bat.redHigh++;
bat.markDirty();
}
if(m.id == 2) {
bat.childLock = !bat.childLock;
bat.markDirty(); bat.markDirty();
} }
} }

View File

@ -2,13 +2,17 @@ package com.hbm.render.tileentity;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import com.hbm.lib.RefStrings;
import com.hbm.main.ResourceManager; import com.hbm.main.ResourceManager;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
public class RenderFrackingTower extends TileEntitySpecialRenderer { public class RenderFrackingTower extends TileEntitySpecialRenderer {
public static final ResourceLocation pipe_tex = new ResourceLocation(RefStrings.MODID, "textures/blocks/pipe_silver.png");
@Override @Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) { public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) {
@ -23,6 +27,14 @@ public class RenderFrackingTower extends TileEntitySpecialRenderer {
ResourceManager.fracking_tower.renderAll(); ResourceManager.fracking_tower.renderAll();
GL11.glShadeModel(GL11.GL_FLAT); GL11.glShadeModel(GL11.GL_FLAT);
GL11.glTranslated(0, 0.5, 0);
bindTexture(pipe_tex);
ResourceManager.pipe_neo.renderPart("pX");
ResourceManager.pipe_neo.renderPart("nX");
ResourceManager.pipe_neo.renderPart("pZ");
ResourceManager.pipe_neo.renderPart("nZ");
GL11.glEnable(GL11.GL_CULL_FACE); GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glPopMatrix(); GL11.glPopMatrix();
} }

View File

@ -10,8 +10,8 @@ import api.hbm.energy.IEnergyConnector;
import api.hbm.energy.IEnergyUser; import api.hbm.energy.IEnergyUser;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityMachineBattery extends TileEntityMachineBase implements IEnergyUser { public class TileEntityMachineBattery extends TileEntityMachineBase implements IEnergyUser {
@ -29,8 +29,10 @@ public class TileEntityMachineBattery extends TileEntityMachineBase implements I
public static final int mode_none = 3; public static final int mode_none = 3;
public short redLow = 0; public short redLow = 0;
public short redHigh = 2; public short redHigh = 2;
public boolean childLock = true;
public boolean conducts = false; //public boolean conducts = false;
public byte lastRedstone = 0;
private static final int[] slots_top = new int[] {0}; private static final int[] slots_top = new int[] {0};
private static final int[] slots_bottom = new int[] {0, 1}; private static final int[] slots_bottom = new int[] {0, 1};
@ -79,21 +81,12 @@ public class TileEntityMachineBattery extends TileEntityMachineBase implements I
@Override @Override
public void readFromNBT(NBTTagCompound nbt) { public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt); super.readFromNBT(nbt);
NBTTagList list = nbt.getTagList("items", 10);
this.power = nbt.getLong("power"); this.power = nbt.getLong("power");
this.redLow = nbt.getShort("redLow"); this.redLow = nbt.getShort("redLow");
this.redHigh = nbt.getShort("redHigh"); this.redHigh = nbt.getShort("redHigh");
this.childLock = nbt.getBoolean("childLock");
slots = new ItemStack[getSizeInventory()]; this.lastRedstone = nbt.getByte("lastRedstone");
for(int i = 0; i < list.tagCount(); i++) {
NBTTagCompound nbt1 = list.getCompoundTagAt(i);
byte b0 = nbt1.getByte("slot");
if(b0 >= 0 && b0 < slots.length) {
slots[b0] = ItemStack.loadItemStackFromNBT(nbt1);
}
}
} }
@Override @Override
@ -103,18 +96,8 @@ public class TileEntityMachineBattery extends TileEntityMachineBase implements I
nbt.setLong("power", power); nbt.setLong("power", power);
nbt.setShort("redLow", redLow); nbt.setShort("redLow", redLow);
nbt.setShort("redHigh", redHigh); nbt.setShort("redHigh", redHigh);
nbt.setBoolean("childLock", childLock);
NBTTagList list = new NBTTagList(); nbt.setByte("lastRedstone", lastRedstone);
for(int i = 0; i < slots.length; i++) {
if(slots[i] != null) {
NBTTagCompound nbt1 = new NBTTagCompound();
nbt1.setByte("slot", (byte) i);
slots[i].writeToNBT(nbt1);
list.appendTag(nbt1);
}
}
nbt.setTag("items", list);
} }
@Override @Override
@ -146,6 +129,12 @@ public class TileEntityMachineBattery extends TileEntityMachineBase implements I
return (power * i) / this.getMaxPower(); return (power * i) / this.getMaxPower();
} }
public byte getComparatorPower() {
if(power == 0) return 0;
double frac = (double) this.power / (double) this.getMaxPower() * 15D;
return (byte) (MathHelper.clamp_int((int) frac + 1, 0, 15)); //to combat eventual rounding errors with the FEnSU's stupid maxPower
}
@Override @Override
public void updateEntity() { public void updateEntity() {
@ -157,6 +146,11 @@ public class TileEntityMachineBattery extends TileEntityMachineBase implements I
this.transmitPower(); this.transmitPower();
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
byte comp = this.getComparatorPower();
if(comp != this.lastRedstone)
this.markDirty();
this.lastRedstone = comp;
power = Library.chargeTEFromItems(slots, 0, power, getMaxPower()); power = Library.chargeTEFromItems(slots, 0, power, getMaxPower());
power = Library.chargeItemsFromTE(slots, 1, power, getMaxPower()); power = Library.chargeItemsFromTE(slots, 1, power, getMaxPower());
@ -164,6 +158,7 @@ public class TileEntityMachineBattery extends TileEntityMachineBase implements I
nbt.setLong("power", (power + prevPower) / 2); nbt.setLong("power", (power + prevPower) / 2);
nbt.setShort("redLow", redLow); nbt.setShort("redLow", redLow);
nbt.setShort("redHigh", redHigh); nbt.setShort("redHigh", redHigh);
nbt.setBoolean("childLock", childLock);
this.networkPack(nbt, 20); this.networkPack(nbt, 20);
} }
@ -226,6 +221,7 @@ public class TileEntityMachineBattery extends TileEntityMachineBase implements I
this.power = nbt.getLong("power"); this.power = nbt.getLong("power");
this.redLow = nbt.getShort("redLow"); this.redLow = nbt.getShort("redLow");
this.redHigh = nbt.getShort("redHigh"); this.redHigh = nbt.getShort("redHigh");
this.childLock = nbt.getBoolean("childLock");
} }
@Override @Override

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB