From 1f28a7c9f52a619cb211cc353758d9d7b215aa19 Mon Sep 17 00:00:00 2001 From: MartinTheDragon Date: Wed, 9 Mar 2022 16:56:53 +0100 Subject: [PATCH 1/4] Backport the faster fallout algorithm --- src/main/java/com/hbm/config/BombConfig.java | 8 +- .../hbm/entity/effect/EntityFalloutRain.java | 143 ++++++++++-------- 2 files changed, 85 insertions(+), 66 deletions(-) diff --git a/src/main/java/com/hbm/config/BombConfig.java b/src/main/java/com/hbm/config/BombConfig.java index efc6befa0..68443e8e9 100644 --- a/src/main/java/com/hbm/config/BombConfig.java +++ b/src/main/java/com/hbm/config/BombConfig.java @@ -80,17 +80,13 @@ public class BombConfig { Property propBlastSpeed = config.get(CATEGORY_NUKE, "6.01_blastSpeed", 1024); propBlastSpeed.comment = "Base speed of MK3 system (old and schrabidium) detonations (Blocks / tick)"; blastSpeed = propBlastSpeed.getInt(); - // fallout range + // new explosion speed Property propFalloutRange = config.get(CATEGORY_NUKE, "6.02_blastSpeedNew", 1024); propFalloutRange.comment = "Base speed of MK4 system (new) detonations (Blocks / tick)"; mk4 = propFalloutRange.getInt(); - // fallout speed + // fallout range Property falloutRangeProp = config.get(CATEGORY_NUKE, "6.03_falloutRange", 100); falloutRangeProp.comment = "Radius of fallout area (base radius * value in percent)"; falloutRange = falloutRangeProp.getInt(); - // new explosion speed - Property falloutSpeed = config.get(CATEGORY_NUKE, "6.04_falloutSpeed", 256); - falloutSpeed.comment = "Blocks processed per tick by the fallout rain"; - fSpeed = falloutSpeed.getInt(); } } diff --git a/src/main/java/com/hbm/entity/effect/EntityFalloutRain.java b/src/main/java/com/hbm/entity/effect/EntityFalloutRain.java index ef7f89280..9e8330252 100644 --- a/src/main/java/com/hbm/entity/effect/EntityFalloutRain.java +++ b/src/main/java/com/hbm/entity/effect/EntityFalloutRain.java @@ -1,24 +1,23 @@ package com.hbm.entity.effect; import com.hbm.blocks.ModBlocks; -import com.hbm.config.BombConfig; import com.hbm.config.RadiationConfig; import com.hbm.config.VersatileConfig; import com.hbm.saveddata.AuxSavedData; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.Entity; import net.minecraft.init.Blocks; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.Vec3; +import net.minecraft.world.ChunkCoordIntPair; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; +import java.util.*; + public class EntityFalloutRain extends Entity { - - public int revProgress; - public int radProgress; + private boolean firstTick = true; // Of course Vanilla has it private in Entity... public EntityFalloutRain(World p_i1582_1_) { super(p_i1582_1_); @@ -35,47 +34,28 @@ public class EntityFalloutRain extends Entity { @Override public void onUpdate() { - if(!worldObj.isRemote) { - - for(int i = 0; i < BombConfig.fSpeed; i++) { - - Vec3 vec = Vec3.createVectorHelper(radProgress * 0.5, 0, 0); - double circum = radProgress * 2 * Math.PI * 2; - - /// - if(circum == 0) - circum = 1; - /// - - double part = 360D / circum; - - vec.rotateAroundY((float) (part * revProgress)); - - int x = (int) (posX + vec.xCoord); - int z = (int) (posZ + vec.zCoord); - - //int y = worldObj.getHeightValue(x, z) - 1; - - //if(worldObj.getBlock(x, y, z) == Blocks.grass) - // worldObj.setBlock(x, y, z, ModBlocks.waste_earth); - - double dist = radProgress * 100 / getScale() * 0.5; - - stomp(x, z, dist); - - revProgress++; - - if(revProgress > circum) { - revProgress = 0; - radProgress++; - } - - if(radProgress > getScale() * 2D) { - this.setDead(); - } - } - + if (firstTick) { + if (chunksToProcess.isEmpty() && outerChunksToProcess.isEmpty()) gatherChunks(); + firstTick = false; + } + + if (!chunksToProcess.isEmpty()) { + long chunkPos = chunksToProcess.remove(chunksToProcess.size() - 1); // Just so it doesn't shift the whole list every time + int chunkPosX = (int) (chunkPos & Integer.MAX_VALUE); + int chunkPosZ = (int) (chunkPos >> 32 & Integer.MAX_VALUE); + for (int x = chunkPosX << 4; x <= (chunkPosX << 4) + 16; x++) for (int z = chunkPosZ << 4; z <= (chunkPosZ << 4) + 16; z++) + stomp(x, z, Math.hypot(x - posX, z - posZ) * 100 / getScale()); + } else if (!outerChunksToProcess.isEmpty()) { + long chunkPos = outerChunksToProcess.remove(outerChunksToProcess.size() - 1); + int chunkPosX = (int) (chunkPos & Integer.MAX_VALUE); + int chunkPosZ = (int) (chunkPos >> 32 & Integer.MAX_VALUE); + for (int x = chunkPosX << 4; x <= (chunkPosX << 4) + 16; x++) for (int z = chunkPosZ << 4; z <= (chunkPosZ << 4) + 16; z++) { + double distance = Math.hypot(x - posX, z - posZ); + if (distance <= getScale()) stomp(x, z, distance * 100 / getScale()); + } + } else setDead(); + if(this.isDead) { if(RadiationConfig.rain > 0 && getScale() > 150) { worldObj.getWorldInfo().setRaining(true); @@ -87,6 +67,32 @@ public class EntityFalloutRain extends Entity { } } } + + private final List chunksToProcess = new ArrayList<>(); + private final List outerChunksToProcess = new ArrayList<>(); + + // Is it worth the effort to split this into a method that can be called over multiple ticks? I'd say it's fast enough anyway... + private void gatherChunks() { + Set chunks = new LinkedHashSet<>(); // LinkedHashSet preserves insertion order + Set outerChunks = new LinkedHashSet<>(); + int outerRange = getScale(); + for (int angle = 0; angle <= 720; angle++) { // TODO Make this adjust to the fallout's scale + Vec3 vector = Vec3.createVectorHelper(outerRange, 0, 0); + vector.rotateAroundY((float) (angle / 180.0 * Math.PI)); // Ugh, mutable data classes (also, ugh, radians; it uses degrees in 1.18; took me two hours to debug) + outerChunks.add(ChunkCoordIntPair.chunkXZ2Int((int) (posX + vector.xCoord) >> 4, (int) (posZ + vector.zCoord) >> 4)); + } + for (int distance = 0; distance <= outerRange; distance += 8) for (int angle = 0; angle <= 720; angle++) { + Vec3 vector = Vec3.createVectorHelper(distance, 0, 0); + vector.rotateAroundY((float) (angle / 180.0 * Math.PI)); + long chunkCoord = ChunkCoordIntPair.chunkXZ2Int((int) (posX + vector.xCoord) >> 4, (int) (posZ + vector.zCoord) >> 4); + if (!outerChunks.contains(chunkCoord)) chunks.add(chunkCoord); + } + + chunksToProcess.addAll(chunks); + outerChunksToProcess.addAll(outerChunks); + Collections.reverse(chunksToProcess); // So it starts nicely from the middle + Collections.reverse(outerChunksToProcess); + } private void stomp(int x, int z, double dist) { @@ -103,7 +109,7 @@ public class EntityFalloutRain extends Entity { if(b != ModBlocks.fallout && (ab == Blocks.air || (ab.isReplaceable(worldObj, x, y + 1, z) && !ab.getMaterial().isLiquid()))) { - double d = (double) radProgress / (double) getScale() * 0.5; + double d = dist / 100; double chance = 0.05 - Math.pow((d - 0.6) * 0.5, 2); @@ -219,33 +225,50 @@ public class EntityFalloutRain extends Entity { @Override protected void entityInit() { - this.dataWatcher.addObject(16, Integer.valueOf(0)); + this.dataWatcher.addObject(16, 0); } @Override - protected void readEntityFromNBT(NBTTagCompound p_70037_1_) { - setScale(p_70037_1_.getInteger("scale")); - revProgress = p_70037_1_.getInteger("revProgress"); - radProgress = p_70037_1_.getInteger("radProgress"); + protected void readEntityFromNBT(NBTTagCompound tag) { + setScale(tag.getInteger("scale")); + chunksToProcess.addAll(readChunksFromIntArray(tag.getIntArray("chunks"))); + outerChunksToProcess.addAll(readChunksFromIntArray(tag.getIntArray("outerChunks"))); + } + + private Collection readChunksFromIntArray(int[] data) { + List coords = new ArrayList<>(); + boolean firstPart = true; + int x = 0; + for (int coord : data) { + if (firstPart) x = coord; + else coords.add(ChunkCoordIntPair.chunkXZ2Int(x, coord)); + firstPart = !firstPart; + } + return coords; } @Override - protected void writeEntityToNBT(NBTTagCompound p_70014_1_) { - p_70014_1_.setInteger("scale", getScale()); - p_70014_1_.setInteger("revProgress", revProgress); - p_70014_1_.setInteger("radProgress", radProgress); - + protected void writeEntityToNBT(NBTTagCompound tag) { + tag.setInteger("scale", getScale()); + tag.setIntArray("chunks", writeChunksToIntArray(chunksToProcess)); + tag.setIntArray("outerChunks", writeChunksToIntArray(outerChunksToProcess)); + } + + private int[] writeChunksToIntArray(List coords) { + int[] data = new int[coords.size() * 2]; + for (int i = 0; i < coords.size(); i++) { + data[i * 2] = (int) (coords.get(i) & Integer.MAX_VALUE); + data[i * 2 + 1] = (int) (coords.get(i) >> 32 & Integer.MAX_VALUE); + } + return data; } public void setScale(int i) { - - this.dataWatcher.updateObject(16, Integer.valueOf(i)); + this.dataWatcher.updateObject(16, i); } public int getScale() { - int scale = this.dataWatcher.getWatchableObjectInt(16); - return scale == 0 ? 1 : scale; } } From 4cf9d64d8eb095093d651c06a00599c6333d4806 Mon Sep 17 00:00:00 2001 From: MartinTheDragon Date: Wed, 9 Mar 2022 18:38:47 +0100 Subject: [PATCH 2/4] Make the fallout chunk precision self-adjusting --- .../com/hbm/entity/effect/EntityFalloutRain.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/hbm/entity/effect/EntityFalloutRain.java b/src/main/java/com/hbm/entity/effect/EntityFalloutRain.java index 9e8330252..a9a012c4a 100644 --- a/src/main/java/com/hbm/entity/effect/EntityFalloutRain.java +++ b/src/main/java/com/hbm/entity/effect/EntityFalloutRain.java @@ -76,14 +76,17 @@ public class EntityFalloutRain extends Entity { Set chunks = new LinkedHashSet<>(); // LinkedHashSet preserves insertion order Set outerChunks = new LinkedHashSet<>(); int outerRange = getScale(); - for (int angle = 0; angle <= 720; angle++) { // TODO Make this adjust to the fallout's scale + // Basically defines something like the step size, but as indirect proportion. The actual angle used for rotation will always end up at 360° for angle == adjustedMaxAngle + // So yea, I mathematically worked out that 20 is a good value for this, with the minimum possible being 18 in order to reach all chunks + int adjustedMaxAngle = 20 * outerRange / 32; // step size = 20 * chunks / 2 + for (int angle = 0; angle <= adjustedMaxAngle; angle++) { Vec3 vector = Vec3.createVectorHelper(outerRange, 0, 0); - vector.rotateAroundY((float) (angle / 180.0 * Math.PI)); // Ugh, mutable data classes (also, ugh, radians; it uses degrees in 1.18; took me two hours to debug) + vector.rotateAroundY((float) (angle * Math.PI / 180.0 / (adjustedMaxAngle / 360.0))); // Ugh, mutable data classes (also, ugh, radians; it uses degrees in 1.18; took me two hours to debug) outerChunks.add(ChunkCoordIntPair.chunkXZ2Int((int) (posX + vector.xCoord) >> 4, (int) (posZ + vector.zCoord) >> 4)); } - for (int distance = 0; distance <= outerRange; distance += 8) for (int angle = 0; angle <= 720; angle++) { + for (int distance = 0; distance <= outerRange; distance += 8) for (int angle = 0; angle <= adjustedMaxAngle; angle++) { Vec3 vector = Vec3.createVectorHelper(distance, 0, 0); - vector.rotateAroundY((float) (angle / 180.0 * Math.PI)); + vector.rotateAroundY((float) (angle * Math.PI / 180.0 / (adjustedMaxAngle / 360.0))); long chunkCoord = ChunkCoordIntPair.chunkXZ2Int((int) (posX + vector.xCoord) >> 4, (int) (posZ + vector.zCoord) >> 4); if (!outerChunks.contains(chunkCoord)) chunks.add(chunkCoord); } @@ -93,7 +96,7 @@ public class EntityFalloutRain extends Entity { Collections.reverse(chunksToProcess); // So it starts nicely from the middle Collections.reverse(outerChunksToProcess); } - + private void stomp(int x, int z, double dist) { int depth = 0; From fdfc7a40a4630bf15d1151082442cdea3aec12cd Mon Sep 17 00:00:00 2001 From: MartinTheDragon Date: Fri, 11 Mar 2022 17:17:16 +0100 Subject: [PATCH 3/4] Delay fallout chunks and adjust ore chances --- src/main/java/com/hbm/config/BombConfig.java | 5 +- .../hbm/entity/effect/EntityFalloutRain.java | 47 +++++++++++-------- 2 files changed, 32 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/hbm/config/BombConfig.java b/src/main/java/com/hbm/config/BombConfig.java index 68443e8e9..8e325df4f 100644 --- a/src/main/java/com/hbm/config/BombConfig.java +++ b/src/main/java/com/hbm/config/BombConfig.java @@ -23,7 +23,7 @@ public class BombConfig { public static int mk4 = 1024; public static int blastSpeed = 1024; public static int falloutRange = 100; - public static int fSpeed = 256; + public static int fDelay = 4; public static int limitExplosionLifespan = 0; public static void loadFromConfig(Configuration config) { @@ -88,5 +88,8 @@ public class BombConfig { Property falloutRangeProp = config.get(CATEGORY_NUKE, "6.03_falloutRange", 100); falloutRangeProp.comment = "Radius of fallout area (base radius * value in percent)"; falloutRange = falloutRangeProp.getInt(); + Property falloutDelayProp = config.get(CATEGORY_NUKE, "6.04_falloutDelay", 4); + falloutDelayProp.comment = "How many ticks to wait for the next fallout chunk computation"; + fDelay = falloutDelayProp.getInt(); } } diff --git a/src/main/java/com/hbm/entity/effect/EntityFalloutRain.java b/src/main/java/com/hbm/entity/effect/EntityFalloutRain.java index a9a012c4a..67963d3ef 100644 --- a/src/main/java/com/hbm/entity/effect/EntityFalloutRain.java +++ b/src/main/java/com/hbm/entity/effect/EntityFalloutRain.java @@ -1,6 +1,7 @@ package com.hbm.entity.effect; import com.hbm.blocks.ModBlocks; +import com.hbm.config.BombConfig; import com.hbm.config.RadiationConfig; import com.hbm.config.VersatileConfig; import com.hbm.saveddata.AuxSavedData; @@ -32,6 +33,8 @@ public class EntityFalloutRain extends Entity { this.isImmuneToFire = true; } + private int tickDelay = BombConfig.fDelay; + @Override public void onUpdate() { if(!worldObj.isRemote) { @@ -40,23 +43,28 @@ public class EntityFalloutRain extends Entity { firstTick = false; } - if (!chunksToProcess.isEmpty()) { - long chunkPos = chunksToProcess.remove(chunksToProcess.size() - 1); // Just so it doesn't shift the whole list every time - int chunkPosX = (int) (chunkPos & Integer.MAX_VALUE); - int chunkPosZ = (int) (chunkPos >> 32 & Integer.MAX_VALUE); - for (int x = chunkPosX << 4; x <= (chunkPosX << 4) + 16; x++) for (int z = chunkPosZ << 4; z <= (chunkPosZ << 4) + 16; z++) - stomp(x, z, Math.hypot(x - posX, z - posZ) * 100 / getScale()); - } else if (!outerChunksToProcess.isEmpty()) { - long chunkPos = outerChunksToProcess.remove(outerChunksToProcess.size() - 1); - int chunkPosX = (int) (chunkPos & Integer.MAX_VALUE); - int chunkPosZ = (int) (chunkPos >> 32 & Integer.MAX_VALUE); - for (int x = chunkPosX << 4; x <= (chunkPosX << 4) + 16; x++) for (int z = chunkPosZ << 4; z <= (chunkPosZ << 4) + 16; z++) { - double distance = Math.hypot(x - posX, z - posZ); - if (distance <= getScale()) stomp(x, z, distance * 100 / getScale()); - } - } else setDead(); + if (tickDelay == 0) { + tickDelay = BombConfig.fDelay; + if (!chunksToProcess.isEmpty()) { + long chunkPos = chunksToProcess.remove(chunksToProcess.size() - 1); // Just so it doesn't shift the whole list every time + int chunkPosX = (int) (chunkPos & Integer.MAX_VALUE); + int chunkPosZ = (int) (chunkPos >> 32 & Integer.MAX_VALUE); + for (int x = chunkPosX << 4; x <= (chunkPosX << 4) + 16; x++) for (int z = chunkPosZ << 4; z <= (chunkPosZ << 4) + 16; z++) + stomp(x, z, Math.hypot(x - posX, z - posZ) * 100 / getScale()); + } else if (!outerChunksToProcess.isEmpty()) { + long chunkPos = outerChunksToProcess.remove(outerChunksToProcess.size() - 1); + int chunkPosX = (int) (chunkPos & Integer.MAX_VALUE); + int chunkPosZ = (int) (chunkPos >> 32 & Integer.MAX_VALUE); + for (int x = chunkPosX << 4; x <= (chunkPosX << 4) + 16; x++) for (int z = chunkPosZ << 4; z <= (chunkPosZ << 4) + 16; z++) { + double distance = Math.hypot(x - posX, z - posZ); + if (distance <= getScale()) stomp(x, z, distance * 100 / getScale()); + } + } else setDead(); + } - if(this.isDead) { + tickDelay--; + + if(this.isDead) { if(RadiationConfig.rain > 0 && getScale() > 150) { worldObj.getWorldInfo().setRaining(true); worldObj.getWorldInfo().setThundering(true); @@ -97,6 +105,7 @@ public class EntityFalloutRain extends Entity { Collections.reverse(outerChunksToProcess); } + // TODO cache chunks? private void stomp(int x, int z, double dist) { int depth = 0; @@ -154,7 +163,7 @@ public class EntityFalloutRain extends Entity { return; } else if(b == Blocks.sand) { - if(rand.nextInt(60) == 0) + if(rand.nextInt(20) == 0) worldObj.setBlock(x, y, z, meta == 0 ? ModBlocks.waste_trinitite : ModBlocks.waste_trinitite_red); return; } @@ -171,9 +180,9 @@ public class EntityFalloutRain extends Entity { else if (b == Blocks.coal_ore) { int ra = rand.nextInt(150); - if (ra < 7) { + if (ra < 20) { worldObj.setBlock(x, y, z, Blocks.diamond_ore); - } else if (ra < 10) { + } else if (ra < 30) { worldObj.setBlock(x, y, z, Blocks.emerald_ore); } return; From caa9394a922d8c809547e2af34c35b6ef76b9514 Mon Sep 17 00:00:00 2001 From: Bob Date: Sat, 12 Mar 2022 20:00:11 +0100 Subject: [PATCH 4/4] chemfac fluid IO finished, water cooling --- .../java/com/hbm/interfaces/IFluidSource.java | 12 + .../com/hbm/inventory/OreDictManager.java | 25 ++ .../com/hbm/inventory/gui/GUIChemfac.java | 6 + .../inventory/recipes/AssemblerRecipes.java | 17 +- src/main/java/com/hbm/lib/Library.java | 13 +- .../hbm/render/tileentity/RenderChemfac.java | 11 +- .../hbm/tileentity/TileEntityProxyCombo.java | 53 ++++- .../machine/TileEntityDiFurnaceRTG.java | 6 +- .../machine/TileEntityMachineChemfac.java | 218 +++++++++++++++-- .../machine/TileEntityMachineChemplant.java | 8 + .../TileEntityMachineChemplantBase.java | 220 +++++++++++++----- src/main/resources/assets/hbm/lang/en_US.lang | 2 +- .../hbm/textures/items/grenade_kyiv.png | Bin 0 -> 549 bytes .../textures/items/grenade_kyiv.png.mcmeta | 3 + 14 files changed, 501 insertions(+), 93 deletions(-) create mode 100644 src/main/resources/assets/hbm/textures/items/grenade_kyiv.png create mode 100644 src/main/resources/assets/hbm/textures/items/grenade_kyiv.png.mcmeta diff --git a/src/main/java/com/hbm/interfaces/IFluidSource.java b/src/main/java/com/hbm/interfaces/IFluidSource.java index 832556246..4bd871582 100644 --- a/src/main/java/com/hbm/interfaces/IFluidSource.java +++ b/src/main/java/com/hbm/interfaces/IFluidSource.java @@ -13,4 +13,16 @@ public interface IFluidSource extends IFluidContainer { boolean getTact(); List getFluidList(FluidType type); void clearFluidList(FluidType type); + + public default void setFluidFillForTransfer(int fill, FluidType type) { + this.setFluidFill(fill, type); + } + + public default int getFluidFillForTransfer(FluidType type) { + return this.getFluidFill(type); + } + + public default void transferFluid(int amount, FluidType type) { + this.setFluidFillForTransfer(this.getFluidFillForTransfer(type) - amount, type); + } } diff --git a/src/main/java/com/hbm/inventory/OreDictManager.java b/src/main/java/com/hbm/inventory/OreDictManager.java index e7378d2cf..e70a3fe3f 100644 --- a/src/main/java/com/hbm/inventory/OreDictManager.java +++ b/src/main/java/com/hbm/inventory/OreDictManager.java @@ -143,21 +143,32 @@ public class OreDictManager { /* * STABLE */ + /** TITANIUM */ public static final DictFrame TI = new DictFrame("Titanium"); + /** COPPER */ public static final DictFrame CU = new DictFrame("Copper"); public static final DictFrame MINGRADE = new DictFrame("Mingrade"); public static final DictFrame ALLOY = new DictFrame("AdvancedAlloy"); + /** TUNGSTEN */ public static final DictFrame W = new DictFrame("Tungsten"); + /** ALUMINUM */ public static final DictFrame AL = new DictFrame("Aluminum"); public static final DictFrame STEEL = new DictFrame("Steel"); + /** TECHNETIUM STEEL */ public static final DictFrame TCALLOY = new DictFrame("TcAlloy"); + /** LEAD */ public static final DictFrame PB = new DictFrame("Lead"); //public static final DictFrame BI = new DictFrame("Bismuth"); + /** TANTALUM */ public static final DictFrame TA = new DictFrame("Tantalum"); public static final DictFrame COLTAN = new DictFrame("Coltan"); + /** NIOBIUM */ public static final DictFrame NB = new DictFrame("Niobium"); + /** BERYLLIUM */ public static final DictFrame BE = new DictFrame("Beryllium"); + /** COBALT */ public static final DictFrame CO = new DictFrame("Cobalt"); + /** BORON */ public static final DictFrame B = new DictFrame("Boron"); public static final DictFrame GRAPHITE = new DictFrame("Graphite"); public static final DictFrame DURA = new DictFrame("DuraSteel"); @@ -177,8 +188,11 @@ public class OreDictManager { /* * DUST AND GEM ORES */ + /** SULFUR */ public static final DictFrame S = new DictFrame("Sulfur"); + /** SALTPETER/NITER */ public static final DictFrame KNO = new DictFrame("Saltpeter"); + /** FLUORITE */ public static final DictFrame F = new DictFrame("Fluorite"); public static final DictFrame LIGNITE = new DictFrame("Lignite"); public static final DictFrame COALCOKE = new DictFrame("CoalCoke"); @@ -190,6 +204,7 @@ public class OreDictManager { /* * HAZARDS, MISC */ + /** LITHIUM */ public static final DictFrame LI = new DictFrame("Lithium"); /* * PHOSPHORUS @@ -208,18 +223,28 @@ public class OreDictManager { /* * RARE EARTHS */ + /** LANTHANUM */ public static final DictFrame LA = new DictFrame("Lanthanum"); + /** ZIRCONIUM */ public static final DictFrame ZR = new DictFrame("Zirconium"); + /** NEODYMIUM */ public static final DictFrame ND = new DictFrame("Neodymium"); + /** CERIUM */ public static final DictFrame CE = new DictFrame("Cerium"); /* * NITAN */ + /** IODINE */ public static final DictFrame I = new DictFrame("Iodine"); + /** ASTATINE */ public static final DictFrame AT = new DictFrame("Astatine"); + /** CAESIUM */ public static final DictFrame CS = new DictFrame("Caesium"); + /** STRONTIUM */ public static final DictFrame ST = new DictFrame("Strontium"); + /** BROMINE */ public static final DictFrame BR = new DictFrame("Bromine"); + /** TENNESSINE */ public static final DictFrame TS = new DictFrame("Tennessine") ; /* * FISSION FRAGMENTS diff --git a/src/main/java/com/hbm/inventory/gui/GUIChemfac.java b/src/main/java/com/hbm/inventory/gui/GUIChemfac.java index bed51516f..997794883 100644 --- a/src/main/java/com/hbm/inventory/gui/GUIChemfac.java +++ b/src/main/java/com/hbm/inventory/gui/GUIChemfac.java @@ -40,6 +40,9 @@ public class GUIChemfac extends GuiInfoContainer { chemfac.tanks[i * 4 + 2].renderTankInfo(this, mouseX, mouseY, offX + 102, offY + 45 - 32, 5, 34); chemfac.tanks[i * 4 + 3].renderTankInfo(this, mouseX, mouseY, offX + 107, offY + 45 - 32, 5, 34); } + + chemfac.water.renderTankInfo(this, mouseX, mouseY, guiLeft + 233, guiTop + 108, 9, 54); + chemfac.steam.renderTankInfo(this, mouseX, mouseY, guiLeft + 242, guiTop + 108, 9, 54); } @Override @@ -74,6 +77,9 @@ public class GUIChemfac extends GuiInfoContainer { chemfac.tanks[i * 4 + 2].renderTank(offX + 103, offY + 46, this.zLevel, 3, 32); chemfac.tanks[i * 4 + 3].renderTank(offX + 108, offY + 46, this.zLevel, 3, 32); } + + chemfac.water.renderTank(guiLeft + 234, guiTop + 161, this.zLevel, 7, 52); + chemfac.steam.renderTank(guiLeft + 243, guiTop + 161, this.zLevel, 7, 52); if(Keyboard.isKeyDown(Keyboard.KEY_LMENU)) for(int i = 0; i < this.inventorySlots.inventorySlots.size(); i++) { diff --git a/src/main/java/com/hbm/inventory/recipes/AssemblerRecipes.java b/src/main/java/com/hbm/inventory/recipes/AssemblerRecipes.java index 654135df1..8bf7a8761 100644 --- a/src/main/java/com/hbm/inventory/recipes/AssemblerRecipes.java +++ b/src/main/java/com/hbm/inventory/recipes/AssemblerRecipes.java @@ -766,14 +766,27 @@ public class AssemblerRecipes { makeRecipe(new ComparableStack(ModBlocks.machine_deuterium_extractor, 1), new AStack[] { new ComparableStack(ModItems.deuterium_filter, 1), new ComparableStack(ModItems.sulfur, 12), - new OreDictStack("plateSteel", 8), - new OreDictStack("plateAluminum", 4), + new OreDictStack(STEEL.plate(), 8), + new OreDictStack(AL.plate(), 4), new ComparableStack(ModItems.pipes_steel), new ComparableStack(ModItems.board_copper, 2), new ComparableStack(ModItems.turbine_titanium, 2), new ComparableStack(ModItems.circuit_aluminium, 3) }, 100); + makeRecipe(new ComparableStack(ModBlocks.machine_chemfac, 1), new AStack[] { + new OreDictStack(STEEL.ingot(), 48), + new OreDictStack(TCALLOY.ingot(), 8), + new OreDictStack(NB.ingot(), 4), + new OreDictStack(RUBBER.ingot(), 16), + new ComparableStack(ModItems.hull_big_steel, 6), + new ComparableStack(ModItems.tank_steel, 8), + new ComparableStack(ModItems.motor_desh, 4), + new ComparableStack(ModItems.coil_tungsten, 24), + new ComparableStack(ModItems.pipes_steel, 1), + new ComparableStack(ModItems.circuit_gold, 3) + }, 400); + makeRecipe(new ComparableStack(ModItems.missile_shuttle, 1), new AStack[] { new ComparableStack(ModItems.missile_generic, 2), new ComparableStack(ModItems.missile_strong, 1), diff --git a/src/main/java/com/hbm/lib/Library.java b/src/main/java/com/hbm/lib/Library.java index ecfb05daa..483b0368b 100644 --- a/src/main/java/com/hbm/lib/Library.java +++ b/src/main/java/com/hbm/lib/Library.java @@ -368,10 +368,8 @@ public class Library { return power; } - //TODO: jesus christ kill it //Flut-Füll gesteuerter Energieübertragungsalgorithmus //Flood fill controlled energy transmission algorithm - //TODO: bring back the @Cursed annotation just for garbage like this public static void ffgeua(int x, int y, int z, boolean newTact, Object that, World worldObj) { /* @@ -620,21 +618,20 @@ public class Library { int size = that.getFluidList(type).size(); if(size > 0) { - int part = that.getFluidFill(type) / size; + int part = that.getFluidFillForTransfer(type) / size; for(IFluidAcceptor consume : that.getFluidList(type)) { if(consume.getFluidFillForReceive(type) < consume.getMaxFluidFillForReceive(type)) { if(consume.getMaxFluidFillForReceive(type) - consume.getFluidFillForReceive(type) >= part) { - that.setFluidFill(that.getFluidFill(type) - part, type); + that.transferFluid(part, type); consume.receiveFluid(part, type); - //consume.setFluidFillForReceive(consume.getFluidFillForReceive(type) + part, type); } else { - that.setFluidFill(that.getFluidFill(type) - (consume.getMaxFluidFillForReceive(type) - consume.getFluidFillForReceive(type)), type); - consume.receiveFluid(consume.getMaxFluidFillForReceive(type) - consume.getFluidFillForReceive(type), type); - //consume.setFluidFillForReceive(consume.getMaxFluidFillForReceive(type), type); + int transfer = consume.getMaxFluidFillForReceive(type) - consume.getFluidFillForReceive(type); + that.transferFluid(transfer, type); + consume.receiveFluid(transfer, type); } } } diff --git a/src/main/java/com/hbm/render/tileentity/RenderChemfac.java b/src/main/java/com/hbm/render/tileentity/RenderChemfac.java index 597450cca..5dcbc6926 100644 --- a/src/main/java/com/hbm/render/tileentity/RenderChemfac.java +++ b/src/main/java/com/hbm/render/tileentity/RenderChemfac.java @@ -4,6 +4,7 @@ import org.lwjgl.opengl.GL11; import com.hbm.blocks.BlockDummyable; import com.hbm.main.ResourceManager; +import com.hbm.tileentity.machine.TileEntityMachineChemfac; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; @@ -17,7 +18,9 @@ public class RenderChemfac extends TileEntitySpecialRenderer { GL11.glEnable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_CULL_FACE); - switch(tileEntity.getBlockMetadata() - BlockDummyable.offset) { + TileEntityMachineChemfac chemfac = (TileEntityMachineChemfac) tileEntity; + + switch(chemfac.getBlockMetadata() - BlockDummyable.offset) { case 5: GL11.glRotatef(180, 0F, 1F, 0F); break; case 2: GL11.glRotatef(270, 0F, 1F, 0F); break; case 4: GL11.glRotatef(0, 0F, 1F, 0F); break; @@ -30,18 +33,18 @@ public class RenderChemfac extends TileEntitySpecialRenderer { bindTexture(ResourceManager.chemfac_tex); ResourceManager.chemfac.renderPart("Main"); - float slowdown = 2.5F; + float rot = chemfac.prevRot + (chemfac.rot - chemfac.prevRot) * f; GL11.glPushMatrix(); GL11.glTranslated(1, 0, 0); - GL11.glRotated(System.currentTimeMillis() % (int)(360 * slowdown) / slowdown + f, 0, -1, 0); + GL11.glRotated(rot, 0, -1, 0); GL11.glTranslated(-1, 0, 0); ResourceManager.chemfac.renderPart("Fan1"); GL11.glPopMatrix(); GL11.glPushMatrix(); GL11.glTranslated(-1, 0, 0); - GL11.glRotated(System.currentTimeMillis() % (int)(360 * slowdown) / slowdown + f, 0, -1, 0); + GL11.glRotated(rot, 0, -1, 0); GL11.glTranslated(1, 0, 0); ResourceManager.chemfac.renderPart("Fan2"); GL11.glPopMatrix(); diff --git a/src/main/java/com/hbm/tileentity/TileEntityProxyCombo.java b/src/main/java/com/hbm/tileentity/TileEntityProxyCombo.java index 511bd5be4..e95a6f523 100644 --- a/src/main/java/com/hbm/tileentity/TileEntityProxyCombo.java +++ b/src/main/java/com/hbm/tileentity/TileEntityProxyCombo.java @@ -1,9 +1,8 @@ package com.hbm.tileentity; -import java.util.List; import com.hbm.interfaces.IFluidAcceptor; -import com.hbm.inventory.FluidTank; +import com.hbm.interfaces.IFluidContainer; import com.hbm.inventory.fluid.FluidType; import api.hbm.energy.IEnergyConnector; @@ -46,8 +45,8 @@ public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergy if(!fluid) return; - if(getTile() instanceof IFluidAcceptor) { - ((IFluidAcceptor)getTile()).setFillForSync(fill, index); + if(getTile() instanceof IFluidContainer) { + ((IFluidContainer)getTile()).setFillForSync(fill, index); } } @@ -57,8 +56,44 @@ public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergy if(!fluid) return; + if(getTile() instanceof IFluidContainer) { + ((IFluidContainer)getTile()).setFluidFill(fill, type); + } + } + + @Override + public int getFluidFillForReceive(FluidType type) { + + if(!fluid) + return 0; + if(getTile() instanceof IFluidAcceptor) { - ((IFluidAcceptor)getTile()).setFluidFill(fill, type); + return ((IFluidAcceptor)getTile()).getFluidFillForReceive(type); + } + return 0; + } + + @Override + public int getMaxFluidFillForReceive(FluidType type) { + + if(!fluid) + return 0; + + if(getTile() instanceof IFluidAcceptor) { + return ((IFluidAcceptor)getTile()).getMaxFluidFillForReceive(type); + } + + return 0; + } + + @Override + public void receiveFluid(int amount, FluidType type) { + + if(!fluid) + return; + + if(getTile() instanceof IFluidAcceptor) { + ((IFluidAcceptor)getTile()).receiveFluid(amount, type); } } @@ -68,8 +103,8 @@ public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergy if(!fluid) return; - if(getTile() instanceof IFluidAcceptor) { - ((IFluidAcceptor)getTile()).setTypeForSync(type, index); + if(getTile() instanceof IFluidContainer) { + ((IFluidContainer)getTile()).setTypeForSync(type, index); } } @@ -79,8 +114,8 @@ public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergy if(!fluid) return 0; - if(getTile() instanceof IFluidAcceptor) { - return ((IFluidAcceptor)getTile()).getFluidFill(type); + if(getTile() instanceof IFluidContainer) { + return ((IFluidContainer)getTile()).getFluidFill(type); } return 0; diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityDiFurnaceRTG.java b/src/main/java/com/hbm/tileentity/machine/TileEntityDiFurnaceRTG.java index 9129571bc..595b46434 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityDiFurnaceRTG.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityDiFurnaceRTG.java @@ -2,7 +2,6 @@ package com.hbm.tileentity.machine; import com.hbm.blocks.machine.MachineDiFurnaceRTG; import com.hbm.inventory.recipes.MachineRecipes; -import com.hbm.items.machine.ItemRTGPellet; import com.hbm.util.RTGUtil; import com.hbm.tileentity.TileEntityMachineBase; @@ -164,6 +163,11 @@ public class TileEntityDiFurnaceRTG extends TileEntityMachineBase return side == 0 ? new int[] {2} : side == 1 ? new int[] {0} : new int[] {1}; } + @Override + public boolean canExtractItem(int slot, ItemStack stack, int side) { + return slot == 2; + } + @Override public String getName() { return "container.diFurnaceRTG"; diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemfac.java b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemfac.java index 688bf4c79..abee64b9c 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemfac.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemfac.java @@ -1,22 +1,40 @@ package com.hbm.tileentity.machine; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Random; import com.hbm.blocks.BlockDummyable; import com.hbm.interfaces.IFluidAcceptor; +import com.hbm.inventory.FluidTank; +import com.hbm.inventory.UpgradeManager; import com.hbm.inventory.fluid.FluidType; +import com.hbm.inventory.fluid.Fluids; +import com.hbm.items.machine.ItemMachineUpgrade.UpgradeType; +import com.hbm.lib.Library; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.ChunkCoordinates; import net.minecraftforge.common.util.ForgeDirection; public class TileEntityMachineChemfac extends TileEntityMachineChemplantBase { + + float rotSpeed; + public float rot; + public float prevRot; + + public FluidTank water; + public FluidTank steam; public TileEntityMachineChemfac() { super(77); + + water = new FluidTank(Fluids.WATER, 64_000, tanks.length); + steam = new FluidTank(Fluids.SPENTSTEAM, 64_000, tanks.length + 1); } @Override @@ -25,6 +43,22 @@ public class TileEntityMachineChemfac extends TileEntityMachineChemplantBase { if(!worldObj.isRemote) { + this.speed = 100; + this.consumption = 100; + + UpgradeManager.eval(slots, 1, 4); + + int speedLevel = Math.min(UpgradeManager.getLevel(UpgradeType.SPEED), 6); + int powerLevel = Math.min(UpgradeManager.getLevel(UpgradeType.POWER), 3); + int overLevel = UpgradeManager.getLevel(UpgradeType.OVERDRIVE); + + this.speed -= speedLevel * 15; + this.consumption += speedLevel * 300; + this.speed += powerLevel * 5; + this.consumption -= powerLevel * 30; + this.speed /= (overLevel + 1); + this.consumption *= (overLevel + 1); + NBTTagCompound data = new NBTTagCompound(); data.setLong("power", this.power); data.setIntArray("progress", this.progress); @@ -34,22 +68,49 @@ public class TileEntityMachineChemfac extends TileEntityMachineChemplantBase { for(int i = 0; i < tanks.length; i++) { tanks[i].writeToNBT(data, "t" + i); } + water.writeToNBT(data, "w"); + steam.writeToNBT(data, "s"); this.networkPack(data, 150); } else { - if(this.worldObj.getTotalWorldTime() % 5 == 0) { + float maxSpeed = 30F; + + if(isProgressing) { - ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset).getOpposite(); - ForgeDirection rot = dir.getRotation(ForgeDirection.UP); - Random rand = worldObj.rand; + rotSpeed += 0.1; - double x = xCoord + 0.5 - rot.offsetX * 0.5; - double y = yCoord + 3; - double z = zCoord + 0.5 - rot.offsetZ * 0.5; - - worldObj.spawnParticle("cloud", x + dir.offsetX * 1.5 + rand.nextGaussian() * 0.15, y, z + dir.offsetZ * 1.5 + rand.nextGaussian() * 0.15, 0.0, 0.15, 0.0); - worldObj.spawnParticle("cloud", x - dir.offsetX * 0.5 + rand.nextGaussian() * 0.15, y, z - dir.offsetZ * 0.5 + rand.nextGaussian() * 0.15, 0.0, 0.15, 0.0); + if(rotSpeed > maxSpeed) + rotSpeed = maxSpeed; + + if(rotSpeed == maxSpeed && this.worldObj.getTotalWorldTime() % 5 == 0) { + + ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset).getOpposite(); + ForgeDirection rot = dir.getRotation(ForgeDirection.UP); + Random rand = worldObj.rand; + + double x = xCoord + 0.5 - rot.offsetX * 0.5; + double y = yCoord + 3; + double z = zCoord + 0.5 - rot.offsetZ * 0.5; + + worldObj.spawnParticle("cloud", x + dir.offsetX * 1.5 + rand.nextGaussian() * 0.15, y, z + dir.offsetZ * 1.5 + rand.nextGaussian() * 0.15, 0.0, 0.15, 0.0); + worldObj.spawnParticle("cloud", x - dir.offsetX * 0.5 + rand.nextGaussian() * 0.15, y, z - dir.offsetZ * 0.5 + rand.nextGaussian() * 0.15, 0.0, 0.15, 0.0); + } + } else { + + rotSpeed -= 0.1; + + if(rotSpeed < 0) + rotSpeed = 0; + } + + prevRot = rot; + + rot += rotSpeed; + + if(rot >= 360) { + rot -= 360; + prevRot -= 360; } } } @@ -64,6 +125,25 @@ public class TileEntityMachineChemfac extends TileEntityMachineChemplantBase { for(int i = 0; i < tanks.length; i++) { tanks[i].readFromNBT(nbt, "t" + i); } + water.readFromNBT(nbt, "w"); + steam.readFromNBT(nbt, "s"); + } + + private int getWaterRequired() { + return 1000 / this.speed; + } + + @Override + protected boolean canProcess(int index) { + return super.canProcess(index) && this.water.getFill() >= getWaterRequired() && this.steam.getFill() + getWaterRequired() <= this.steam.getMaxFill(); + } + + + @Override + protected void process(int index) { + super.process(index); + this.water.setFill(this.water.getFill() - getWaterRequired()); + this.steam.setFill(this.steam.getFill() + getWaterRequired()); } @Override @@ -74,26 +154,53 @@ public class TileEntityMachineChemfac extends TileEntityMachineChemplantBase { @Override public void fillFluidInit(FluidType type) { + ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset); + ForgeDirection rot = dir.getRotation(ForgeDirection.UP); + + for(int i = 0; i < 6; i++) { + fillFluid(xCoord + dir.offsetX * (2 - i) + rot.offsetX * 3, yCoord + 4, zCoord + dir.offsetZ * (2 - i) + rot.offsetZ * 3, this.getTact(), type); + fillFluid(xCoord + dir.offsetX * (2 - i) - rot.offsetX * 2, yCoord + 4, zCoord + dir.offsetZ * (2 - i) - rot.offsetZ * 2, this.getTact(), type); + + for(int j = 0; j < 2; j++) { + fillFluid(xCoord + dir.offsetX * (2 - i) + rot.offsetX * 5, yCoord + 1 + j, zCoord + dir.offsetZ * (2 - i) + rot.offsetZ * 5, this.getTact(), type); + fillFluid(xCoord + dir.offsetX * (2 - i) - rot.offsetX * 4, yCoord + 1 + j, zCoord + dir.offsetZ * (2 - i) - rot.offsetZ * 4, this.getTact(), type); + } + } } @Override public void fillFluid(int x, int y, int z, boolean newTact, FluidType type) { - + Library.transmitFluid(x, y, z, newTact, this, worldObj, type); } @Override public boolean getTact() { - return false; + return this.worldObj.getTotalWorldTime() % 20 < 10; } + private HashMap> fluidMap = new HashMap(); + @Override public List getFluidList(FluidType type) { - return new ArrayList(); + + List list = fluidMap.get(type); + + if(list == null) { + list = new ArrayList(); + fluidMap.put(type, list); + } + + return list; } @Override public void clearFluidList(FluidType type) { + List list = fluidMap.get(type); + + if(list != null) { + list.clear(); + } } @Override @@ -116,20 +223,95 @@ public class TileEntityMachineChemfac extends TileEntityMachineChemplantBase { return new int[] {5 + index * 9, 8 + index * 9, 9 + index * 9, 12 + index * 9}; } + ChunkCoordinates[] inpos; + ChunkCoordinates[] outpos; + @Override public ChunkCoordinates[] getInputPositions() { - return new ChunkCoordinates[0]; + + if(inpos != null) + return inpos; + + ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset); + ForgeDirection rot = dir.getRotation(ForgeDirection.UP); + + inpos = new ChunkCoordinates[] { + new ChunkCoordinates(xCoord + dir.offsetX * 4 - rot.offsetX * 1, yCoord, zCoord + dir.offsetZ * 4 - rot.offsetZ * 1), + new ChunkCoordinates(xCoord - dir.offsetX * 5 + rot.offsetX * 2, yCoord, zCoord - dir.offsetZ * 5 + rot.offsetZ * 2), + new ChunkCoordinates(xCoord - dir.offsetX * 2 - rot.offsetX * 4, yCoord, zCoord - dir.offsetZ * 2 - rot.offsetZ * 4), + new ChunkCoordinates(xCoord + dir.offsetX * 1 + rot.offsetX * 5, yCoord, zCoord + dir.offsetZ * 1 + rot.offsetZ * 5) + }; + + return inpos; } @Override public ChunkCoordinates[] getOutputPositions() { - return new ChunkCoordinates[0]; + + if(outpos != null) + return outpos; + + ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset); + ForgeDirection rot = dir.getRotation(ForgeDirection.UP); + + outpos = new ChunkCoordinates[] { + new ChunkCoordinates(xCoord + dir.offsetX * 4 + rot.offsetX * 2, yCoord, zCoord + dir.offsetZ * 4 + rot.offsetZ * 2), + new ChunkCoordinates(xCoord - dir.offsetX * 5 - rot.offsetX * 1, yCoord, zCoord - dir.offsetZ * 5 - rot.offsetZ * 1), + new ChunkCoordinates(xCoord + dir.offsetX * 1 - rot.offsetX * 4, yCoord, zCoord + dir.offsetZ * 1 - rot.offsetZ * 4), + new ChunkCoordinates(xCoord - dir.offsetX * 2 + rot.offsetX * 5, yCoord, zCoord - dir.offsetZ * 2 + rot.offsetZ * 5) + }; + + return outpos; + } + + @Override + public void readFromNBT(NBTTagCompound nbt) { + super.readFromNBT(nbt); + water.readFromNBT(nbt, "w"); + steam.readFromNBT(nbt, "s"); + } + + @Override + public void writeToNBT(NBTTagCompound nbt) { + super.writeToNBT(nbt); + water.writeToNBT(nbt, "w"); + steam.writeToNBT(nbt, "s"); } @Override public String getName() { return "container.machineChemFac"; } + + @Override + protected List inTanks() { + + List inTanks = super.inTanks(); + inTanks.add(water); + + return inTanks; + } + + @Override + protected List outTanks() { + + List outTanks = super.outTanks(); + outTanks.add(steam); + + return outTanks; + } + + @Override + public int getMaxFluidFillForReceive(FluidType type) { + /*int fill = this.getMaxFluidFill(type); + + if(type == Fluids.WATER) + fill += water.getMaxFill(); + + return fill;*/ + + return super.getMaxFluidFillForReceive(type); + } AxisAlignedBB bb = null; @@ -149,4 +331,10 @@ public class TileEntityMachineChemfac extends TileEntityMachineChemplantBase { return bb; } + + @Override + @SideOnly(Side.CLIENT) + public double getMaxRenderDistanceSquared() { + return 65536.0D; + } } diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemplant.java b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemplant.java index 59fb4b457..940071fc7 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemplant.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemplant.java @@ -23,6 +23,8 @@ import com.hbm.tileentity.TileEntityMachineBase; import com.hbm.util.InventoryUtil; import api.hbm.energy.IEnergyUser; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -526,6 +528,12 @@ public class TileEntityMachineChemplant extends TileEntityMachineBase implements return bb; } + + @Override + @SideOnly(Side.CLIENT) + public double getMaxRenderDistanceSquared() { + return 65536.0D; + } @Override public boolean isPlaying() { diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemplantBase.java b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemplantBase.java index 38f54b8a4..177d69c80 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemplantBase.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemplantBase.java @@ -19,6 +19,7 @@ import com.hbm.util.InventoryUtil; import api.hbm.energy.IEnergyUser; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChunkCoordinates; @@ -71,11 +72,12 @@ public abstract class TileEntityMachineChemplantBase extends TileEntityMachineBa unloadItems(i); } - if(worldObj.getTotalWorldTime() % 1 == 0) { + if(worldObj.getTotalWorldTime() % 10 == 0) { - for(int i = 0; i < count; i++) { - this.fillFluidInit(tanks[i * 4 + 2].getTankType()); - this.fillFluidInit(tanks[i * 4 + 3].getTankType()); + for(FluidTank tank : this.outTanks()) { + if(tank.getTankType() != Fluids.NONE && tank.getFill() > 0) { + this.fillFluidInit(tank.getTankType()); + } } } @@ -91,7 +93,7 @@ public abstract class TileEntityMachineChemplantBase extends TileEntityMachineBa } } - private boolean canProcess(int index) { + protected boolean canProcess(int index) { int template = getTemplateIndex(index); @@ -143,7 +145,7 @@ public abstract class TileEntityMachineChemplantBase extends TileEntityMachineBa return InventoryUtil.doesArrayHaveSpace(slots, indices[2], indices[3], recipe.outputs); } - private void process(int index) { + protected void process(int index) { this.power -= this.consumption; this.progress[index]++; @@ -307,36 +309,26 @@ public abstract class TileEntityMachineChemplantBase extends TileEntityMachineBa } @Override - public void setFillForSync(int fill, int index) { - if(index >= 0 && index < tanks.length) tanks[index].setFill(fill); - } + public void setFillForSync(int fill, int index) { } @Override - public void setFluidFill(int fill, FluidType type) { - - //TODO: figure this shit out - //also this won't work anyway since there's no difference as of now between setting in or output tanks - //the recent rework tried to implement that difference but we all know how that went - - /*for(FluidTank tank : tanks) { - if(tank.getTankType() == type) { - tank.setFill(fill); - return; - } - }*/ - } + public void setFluidFill(int fill, FluidType type) { } @Override - public void setTypeForSync(FluidType type, int index) { - if(index >= 0 && index < tanks.length) tanks[index].setTankType(type); - } + public void setTypeForSync(FluidType type, int index) { } @Override public int getFluidFill(FluidType type) { int fill = 0; - for(FluidTank tank : tanks) { + for(FluidTank tank : inTanks()) { + if(tank.getTankType() == type) { + fill += tank.getFill(); + } + } + + for(FluidTank tank : outTanks()) { if(tank.getTankType() == type) { fill += tank.getFill(); } @@ -350,12 +342,11 @@ public abstract class TileEntityMachineChemplantBase extends TileEntityMachineBa public int getMaxFluidFill(FluidType type) { int maxFill = 0; - int count = getRecipeCount(); - for(int i = 0; i < count; i++) { - - if(tanks[i * 4].getTankType() == type) maxFill += tanks[i * 4].getMaxFill(); - if(tanks[i * 4 + 1].getTankType() == type) maxFill += tanks[i * 4 + 1].getMaxFill(); + for(FluidTank tank : inTanks()) { + if(tank.getTankType() == type) { + maxFill += tank.getMaxFill(); + } } return maxFill; @@ -366,22 +357,39 @@ public abstract class TileEntityMachineChemplantBase extends TileEntityMachineBa int fill = 0; - for(FluidTank tank : tanks) { - if(tank.index % 4 < 2 && tank.getTankType() == type) { + for(FluidTank tank : inTanks()) { + if(tank.getTankType() == type) { fill += tank.getFill(); } } return fill; } + + protected List inTanks() { + + List inTanks = new ArrayList(); + + for(int i = 0; i < tanks.length; i++) { + FluidTank tank = tanks[i]; + if(tank.index % 4 < 2) { + inTanks.add(tank); + } + } + + return inTanks; + } @Override public void receiveFluid(int amount, FluidType type) { + if(amount <= 0) + return; + List rec = new ArrayList(); - for(FluidTank tank : tanks) { - if(tank.index % 4 < 2 && tank.getTankType() == type) { + for(FluidTank tank : inTanks()) { + if(tank.getTankType() == type) { rec.add(tank); } } @@ -390,31 +398,137 @@ public abstract class TileEntityMachineChemplantBase extends TileEntityMachineBa return; int demand = 0; + List weight = new ArrayList(); for(FluidTank tank : rec) { - demand += tank.getMaxFill() - tank.getFill(); + int fillWeight = tank.getMaxFill() - tank.getFill(); + demand += fillWeight; + weight.add(fillWeight); } - int part = demand / rec.size(); // dividing ints rounds down anyway - - for(FluidTank tank : rec) { - tank.setFill(tank.getFill() + part); - demand -= part; - } - - //getting rid of annoying rounding errors - if(demand > 0) { + for(int i = 0; i < rec.size(); i++) { - while(demand > 0) { - - FluidTank tank = rec.get(worldObj.rand.nextInt(rec.size())); - if(tank.getFill() < tank.getMaxFill()) { - //we do single mB steps because the distribution is more even this way and honestly the remainder can't possibly be that big - tank.setFill(tank.getFill() + 1); - demand--; - } + if(demand <= 0) + break; + + FluidTank tank = rec.get(i); + int fillWeight = weight.get(i); + int part = (int) ((long)amount * (long)fillWeight / (long)demand); + + tank.setFill(tank.getFill() + part); + } + } + + @Override + public int getFluidFillForTransfer(FluidType type) { + + int fill = 0; + + for(FluidTank tank : outTanks()) { + if(tank.getTankType() == type) { + fill += tank.getFill(); } } + + return fill; + } + + @Override + public void transferFluid(int amount, FluidType type) { + + /* + * this whole new fluid mumbo jumbo extra abstraction layer might just be a bandaid + * on the gushing wound that is the current fluid systemm but i'll be damned if it + * didn't at least do what it's supposed to. half a decade and we finally have multi + * tank support for tanks with matching fluid types!! + */ + if(amount <= 0) + return; + + List send = new ArrayList(); + + for(FluidTank tank : outTanks()) { + if(tank.getTankType() == type) { + send.add(tank); + } + } + + if(send.size() == 0) + return; + + int offer = 0; + List weight = new ArrayList(); + + for(FluidTank tank : send) { + int fillWeight = tank.getFill(); + offer += fillWeight; + weight.add(fillWeight); + } + + int tracker = amount; + + for(int i = 0; i < send.size(); i++) { + + FluidTank tank = send.get(i); + int fillWeight = weight.get(i); + int part = amount * fillWeight / offer; + + tank.setFill(tank.getFill() - part); + tracker -= part; + } + + //making sure to properly deduct even the last mB lost by rounding errors + for(int i = 0; i < 100 && tracker > 0; i++) { + + FluidTank tank = send.get(i % send.size()); + + if(tank.getFill() > 0) { + int total = Math.min(tank.getFill(), tracker); + tracker -= total; + tank.setFill(tank.getFill() - total); + } + } + } + + protected List outTanks() { + + List outTanks = new ArrayList(); + + for(int i = 0; i < tanks.length; i++) { + FluidTank tank = tanks[i]; + if(tank.index % 4 > 1) { + outTanks.add(tank); + } + } + + return outTanks; + } + + @Override + public void readFromNBT(NBTTagCompound nbt) { + super.readFromNBT(nbt); + + this.power = nbt.getLong("power"); + this.progress = nbt.getIntArray("progress"); + + if(progress.length == 0) + progress = new int[this.getRecipeCount()]; + + for(int i = 0; i < tanks.length; i++) { + tanks[i].readFromNBT(nbt, "t" + i); + } + } + + @Override + public void writeToNBT(NBTTagCompound nbt) { + super.writeToNBT(nbt); + + nbt.setLong("power", power); + nbt.setIntArray("progress", progress); + + for(int i = 0; i < tanks.length; i++) { + tanks[i].writeToNBT(nbt, "t" + i); + } } public abstract int getRecipeCount(); diff --git a/src/main/resources/assets/hbm/lang/en_US.lang b/src/main/resources/assets/hbm/lang/en_US.lang index 8c145e77f..4b012c416 100644 --- a/src/main/resources/assets/hbm/lang/en_US.lang +++ b/src/main/resources/assets/hbm/lang/en_US.lang @@ -1831,7 +1831,7 @@ item.ingot_asbestos.name=Asbestos Sheet item.ingot_asbestos.desc=§o\"Filled with life, self-doubt and asbestos. That comes with the air.\"§r item.ingot_au198.name=Gold-198 Ingot item.ingot_australium.name=Australium Ingot -item.ingot_bakelite.name=Bakelite Ingot +item.ingot_bakelite.name=Bakelite Bar item.ingot_beryllium.name=Beryllium Ingot item.ingot_bismuth.name=Bismuth Ingot item.ingot_boron.name=Boron Ingot diff --git a/src/main/resources/assets/hbm/textures/items/grenade_kyiv.png b/src/main/resources/assets/hbm/textures/items/grenade_kyiv.png new file mode 100644 index 0000000000000000000000000000000000000000..5ff1ac82885f02ea217ecb1e03f9ff6dfde5fe8a GIT binary patch literal 549 zcmV+=0^0qFP)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01m_e01m_fl`9S#00007bV*G`2i*Yy z3nLXciI?vH00E^*L_t(o!|j(bNW(xBhX1QzhEf*?69?(!5;|lrbS_SA9dr;uK`B@l z2XQP?hpH5dh)$V=f{O)l3w9A43ZdYjs2#LZ21~)B@EmMn)5bQJQc=hcM{daX?s9j0 z;jQk2)FO#-3K$9V*e3)`G5-^nh&~m!S{jhgJ1K(-}^u43z_XYJxhtW zLPj}Dssggj#`l5mga7RV$AiS_gTe0${BSvIE5dkukcx)!R=Y$b7J{zT@$iAc?hDmY n!@Cc9u7U3Z-v>kYL1#Vz>gDks!j9;)00000NkvXXu0mjf0Z`<+ literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/hbm/textures/items/grenade_kyiv.png.mcmeta b/src/main/resources/assets/hbm/textures/items/grenade_kyiv.png.mcmeta new file mode 100644 index 000000000..dd1bedb12 --- /dev/null +++ b/src/main/resources/assets/hbm/textures/items/grenade_kyiv.png.mcmeta @@ -0,0 +1,3 @@ +{ + "animation": {} +}