From 6fff2b6195394b7a16607ad2e005ea038bc19b3e Mon Sep 17 00:00:00 2001 From: Boblet Date: Fri, 28 Jun 2024 14:03:17 +0200 Subject: [PATCH] slopper --- .../java/com/hbm/inventory/fluid/Fluids.java | 4 +- .../machine/TileEntityMachineOreSlopper.java | 164 ++++++++++++++++++ .../assets/hbm/textures/gui/fluids/slop.png | Bin 0 -> 554 bytes .../hbm/textures/models/tank/tank_SLOP.png | Bin 0 -> 1091 bytes 4 files changed, 167 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/assets/hbm/textures/gui/fluids/slop.png create mode 100644 src/main/resources/assets/hbm/textures/models/tank/tank_SLOP.png diff --git a/src/main/java/com/hbm/inventory/fluid/Fluids.java b/src/main/java/com/hbm/inventory/fluid/Fluids.java index 77e01d676..97e4d45d1 100644 --- a/src/main/java/com/hbm/inventory/fluid/Fluids.java +++ b/src/main/java/com/hbm/inventory/fluid/Fluids.java @@ -176,6 +176,7 @@ public class Fluids { public static FluidType FULLERENE; public static FluidType STELLAR_FLUX; public static FluidType VITRIOL; + public static FluidType SLOP; /* Lagacy names for compatibility purposes */ @Deprecated public static FluidType ACID; //JAOPCA uses this, apparently @@ -377,7 +378,8 @@ public class Fluids { NAPHTHA_DS = new FluidType("NAPHTHA_DS", 0x63614E, 2, 1, 0, EnumSymbol.NONE).addContainers(new CD_Canister(0x5F6D44)).addTraits(LIQUID, VISCOUS, P_FUEL); LIGHTOIL_DS = new FluidType("LIGHTOIL_DS", 0x63543E, 1, 2, 0, EnumSymbol.NONE).addContainers(new CD_Canister(0xB46B52)).addTraits(LIQUID, P_FUEL); STELLAR_FLUX = new FluidType("STELLAR_FLUX", 0xE300FF, 0, 4, 4, EnumSymbol.ANTIMATTER).addTraits(ANTI, GASEOUS); - VITRIOL = new FluidType(140, "VITRIOL", 0x6E5222, 2, 0, 1, EnumSymbol.NONE).addTraits(LIQUID, VISCOUS); + VITRIOL = new FluidType("VITRIOL", 0x6E5222, 2, 0, 1, EnumSymbol.NONE).addTraits(LIQUID, VISCOUS); + SLOP = new FluidType(141, "SLOP", 0x929D45, 0, 0, 0, EnumSymbol.NONE).addTraits(LIQUID, VISCOUS); // ^ ^ ^ ^ ^ ^ ^ ^ //ADD NEW FLUIDS HERE diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineOreSlopper.java b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineOreSlopper.java index 1fdbe4de6..dccefcab4 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineOreSlopper.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineOreSlopper.java @@ -1,31 +1,195 @@ package com.hbm.tileentity.machine; import com.hbm.inventory.container.ContainerOreSlopper; +import com.hbm.inventory.fluid.FluidType; +import com.hbm.inventory.fluid.Fluids; +import com.hbm.inventory.fluid.tank.FluidTank; import com.hbm.inventory.gui.GUIOreSlopper; +import com.hbm.items.ModItems; +import com.hbm.items.special.ItemBedrockOreBase; +import com.hbm.items.special.ItemBedrockOreNew; +import com.hbm.items.special.ItemBedrockOreNew.BedrockOreGrade; +import com.hbm.items.special.ItemBedrockOreNew.BedrockOreType; +import com.hbm.lib.Library; import com.hbm.tileentity.IGUIProvider; import com.hbm.tileentity.TileEntityMachineBase; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; import net.minecraft.client.gui.GuiScreen; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; +import net.minecraft.item.ItemStack; import net.minecraft.world.World; public class TileEntityMachineOreSlopper extends TileEntityMachineBase implements IGUIProvider { + + public long power; + public static final long maxPower = 1_000_000; + + public static final int waterUsedBase = 1_000; + public int waterUsed = waterUsedBase; + public static final long consumptionBase = 200; + public long consumption = consumptionBase; + + public float progress; + public boolean processing; + + public SlopperAnimation animation = SlopperAnimation.LOWERING; + public float slider; + public float prevSlider; + public float bucket; + public float prevBucket; + public int delay; + + public static FluidTank[] tanks; + public double[] ores = new double[BedrockOreType.values().length]; public TileEntityMachineOreSlopper() { super(11); + tanks = new FluidTank[2]; + tanks[0] = new FluidTank(Fluids.WATER, 16_000); + tanks[1] = new FluidTank(Fluids.SLOP, 16_000); } @Override public String getName() { return "container.machineOreSlopper"; } + + public static enum SlopperAnimation { + LOWERING, LIFTING, MOVE_SHREDDER, DUMPING, MOVE_BUCKET + } @Override public void updateEntity() { + if(!worldObj.isRemote) { + + this.power = Library.chargeTEFromItems(slots, 0, power, maxPower); + + tanks[0].setType(1, slots); + FluidType conversion = this.getFluidOutput(tanks[0].getTankType()); + if(conversion != null) tanks[1].setTankType(conversion); + + this.processing = false; + + if(canSlop()) { + this.power -= this.consumption; + this.progress += 1F/200F; + this.processing = true; + boolean markDirty = false; + + while(progress >= 1F && canSlop()) { + progress -= 1F; + + for(BedrockOreType type : BedrockOreType.values()) { + ores[type.ordinal()] += ItemBedrockOreBase.getOreAmount(slots[2], type); + } + + this.decrStackSize(2, 1); + this.tanks[0].setFill(this.tanks[0].getFill() - waterUsed); + this.tanks[1].setFill(this.tanks[1].getFill() + waterUsed); + markDirty = true; + } + + if(markDirty) this.markDirty(); + + } else { + this.progress = 0; + } + + for(BedrockOreType type : BedrockOreType.values()) { + ItemStack output = ItemBedrockOreNew.make(BedrockOreGrade.BASE, type); + outer: while(ores[type.ordinal()] >= 1) { + for(int i = 3; i <= 8; i++) if(slots[i] != null && slots[i].getItem() == output.getItem() && slots[i].getItemDamage() == output.getItemDamage() && slots[i].stackSize < output.getMaxStackSize()) { + slots[i].stackSize++; ores[type.ordinal()] -= 1F; continue outer; + } + for(int i = 3; i <= 8; i++) if(slots[i] == null) { + slots[i] = output; ores[type.ordinal()] -= 1F; continue outer; + } + } + } + + } else { + + this.prevSlider = this.slider; + this.prevBucket = this.bucket; + + if(this.processing) { + + if(delay > 0) { + delay--; + return; + } + + switch(animation) { + case LOWERING: + this.bucket += 1F/40F; + if(bucket >= 1F) { + bucket = 1F; + animation = SlopperAnimation.LIFTING; + delay = 20; + } + break; + case LIFTING: + this.bucket -= 1F/40F; + if(bucket <= 0) { + bucket = 0F; + animation = SlopperAnimation.MOVE_SHREDDER; + delay = 10; + } + break; + case MOVE_SHREDDER: + this.slider += 1/60F; + if(slider >= 1F) { + slider = 1F; + animation = SlopperAnimation.DUMPING; + delay = 60; + } + break; + case DUMPING: + animation = SlopperAnimation.MOVE_BUCKET; + break; + case MOVE_BUCKET: + this.slider -= 1/60F; + if(slider <= 0F) { + animation = SlopperAnimation.LOWERING; + delay = 10; + } + break; + } + } + } + } + + @Override public void serialize(ByteBuf buf) { + super.serialize(buf); + buf.writeLong(power); + buf.writeFloat(progress); + buf.writeBoolean(processing); + } + + @Override public void deserialize(ByteBuf buf) { + super.deserialize(buf); + this.power = buf.readLong(); + this.progress = buf.readFloat(); + this.processing = buf.readBoolean(); + } + + public boolean canSlop() { + if(this.getFluidOutput(tanks[0].getTankType()) == null) return false; + if(tanks[0].getFill() < waterUsed) return false; + if(tanks[1].getFill() + waterUsed > tanks[1].getMaxFill()) return false; + if(power < consumption) return false; + + return slots[2] != null && slots[2].getItem() == ModItems.bedrock_ore_base; + } + + public FluidType getFluidOutput(FluidType input) { + if(input == Fluids.WATER) return Fluids.SLOP; + return null; } @Override diff --git a/src/main/resources/assets/hbm/textures/gui/fluids/slop.png b/src/main/resources/assets/hbm/textures/gui/fluids/slop.png new file mode 100644 index 0000000000000000000000000000000000000000..4d521d5856042b92c6851c213fe426b7498a2046 GIT binary patch literal 554 zcmV+_0@eMAP)^#*4Fy}XbR@;>YcTcRxWd_1h4 z2!uhDbnBkF{^#G{zy1KU);NxXX_|1((OTnL=XnC)y{Gq%nGr&GoT)0UHTHc6AjZhL zu7nU!Rkm$IRhg!Vr>7_OeW$gCa}E)~mr{n(G)?53NhuLRp!d!ta2y8!&N%=|Da06& zZQF3pal75dtF=~o@8p~j5kd%f@5wojt*Q?TA~M=Kj$;(B>x!x(A`c~zVe#|xlMn*i zw&9m$8NfmaqcEj}s$yn8n3x&!JQHK2_l}4N=Xs*4s4Bg8oO9%yF*9nd!?&3MjP_L( zf5E$!sxr?rDWx$P@BJ7hK<}Lp0%nH4=>FeEt(8*BU~r!2$UsVIbOIpH&(C=8Nhz@` z%Lq|QX-vU;&$29-8Tb30`~5yx_?+`-M?_FnN+~$!2AAvN%gYO9Mk$3_>!Sk^q4&;t zp2Qf36*J>@y8(>iudgrO-`|Nb{*AJ8Zuq*WzrMcm_V&j0_&m=e1EmyNYa`;4bEdU+ z%@kGT07*qoM6N<$f@38IHvj+t literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/hbm/textures/models/tank/tank_SLOP.png b/src/main/resources/assets/hbm/textures/models/tank/tank_SLOP.png new file mode 100644 index 0000000000000000000000000000000000000000..7e99ca01c85d1b9ba7c33d01e05a6b755d54e904 GIT binary patch literal 1091 zcmeAS@N?(olHy`uVBq!ia0vp^RY2Us!3HEZPulwcNU;<`sUZYbI*$fEhA*lrx^=c@_dS_61mkD9lM`lOS6-- zR$3y7S7NWPTb$>+`$v|D6?60Bx7Q0FO-CmG5$MJ6A;1V3{5orzOjwYH+vEG}oSWPbj1ai-X#NwM<3eFJ~h zD7@HZ{NQt}d8=8IQ~H6|yWhQlN9-y3qNmTY3#eNj=b+TOClD&n_Gqe-82h2lqm3($ENO$OyHm}ozHOU_NOZIVYi#*5 ziBjo9>Ki7V|n+E|cOn6M~9hC}_`UME$zyKV-)nJm%KB|U3(9~`+R)|phOFegH$ z!>jr6;kAz$xpG;6{<^8{8uf8i&F;SQ#TOSTKayVmum8kfV0dL7U2U~nQDD8&p=)9p zJz{e$?n^((ya)>X%pgRI#?eZON zpvY2))9lK8?hsYt@+0!0%g5c}1xeqydIK|*HMR&IS>2RaucV~3_+#LNpLMcb-pZ95|1v)JDQfw?fUp)xuD=ozva^RA8)%CJz00xognklyT0tHmtSrP z4}D_vXlhfE;^|i2z!bqpp&=dNZc}!Dl<1ae`sviYgL_u+L{|~6y*Z*sU&r6YZC`XP&c#aMhgK@64kn0(VDj7J3RQbU5{v6 o2(A}$-P0uek)WvI(be@%@2ie7T$$VrEEO0$UHx3vIVCg!0Q)QZvH$=8 literal 0 HcmV?d00001