From 96db3e6767feb4d718cbc6485c7d65e63111420a Mon Sep 17 00:00:00 2001 From: Boblet Date: Mon, 21 Feb 2022 15:03:27 +0100 Subject: [PATCH] new chemplant item IO --- .../com/hbm/handler/BobmazonOfferFactory.java | 44 ++++++-- .../hbm/hazard/type/HazardTypeRadiation.java | 2 - .../hbm/tileentity/machine/TileEntityFEL.java | 13 +-- .../TileEntityMachineChemplantNew.java | 101 ++++++++++++++++++ .../java/com/hbm/util/ContaminationUtil.java | 2 +- src/main/java/com/hbm/util/InventoryUtil.java | 2 +- .../hbm/textures/items/parts_legendary_1.png | Bin 0 -> 500 bytes .../hbm/textures/items/parts_legendary_2.png | Bin 0 -> 333 bytes .../hbm/textures/items/parts_legendary_3.png | Bin 0 -> 280 bytes 9 files changed, 142 insertions(+), 22 deletions(-) create mode 100644 src/main/resources/assets/hbm/textures/items/parts_legendary_1.png create mode 100644 src/main/resources/assets/hbm/textures/items/parts_legendary_2.png create mode 100644 src/main/resources/assets/hbm/textures/items/parts_legendary_3.png diff --git a/src/main/java/com/hbm/handler/BobmazonOfferFactory.java b/src/main/java/com/hbm/handler/BobmazonOfferFactory.java index aedfbdfd2..cb8a10966 100644 --- a/src/main/java/com/hbm/handler/BobmazonOfferFactory.java +++ b/src/main/java/com/hbm/handler/BobmazonOfferFactory.java @@ -10,6 +10,7 @@ import com.hbm.inventory.gui.GUIScreenBobmazon.Requirement; import com.hbm.items.ModItems; import com.hbm.items.machine.ItemBattery; import com.hbm.items.special.ItemKitCustom; +import com.hbm.items.special.ItemKitNBT; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; @@ -238,22 +239,45 @@ public class BobmazonOfferFactory { new ItemStack(Items.paper, 64), new ItemStack(Items.dye, 64) ), Requirement.HIDDEN, 64)); + + special.add(new Offer(ItemKitCustom.create("Maid's Cleaning Utensils", "For the heard to reach spots", 0x00ff00, 0x008000, + new ItemStack(ModItems.gun_calamity), + new ItemStack(ModItems.ammo_50bmg_chlorophyte, 64), + new ItemStack(ModItems.ammo_50bmg_chlorophyte, 64), + new ItemStack(ModItems.ammo_50bmg_chlorophyte, 64), + new ItemStack(ModItems.ammo_50bmg_star, 64), + new ItemStack(ModItems.ammo_50bmg_star, 64), + new ItemStack(ModItems.gun_supershotgun), + new ItemStack(ModItems.ammo_12gauge_du, 64), + new ItemStack(ModItems.ammo_12gauge_du, 64), + new ItemStack(ModItems.ammo_12gauge_shrapnel, 64), + new ItemStack(ModItems.ammo_12gauge_shrapnel, 64), + new ItemStack(ModItems.ammo_12gauge_marauder, 4), + new ItemStack(ModItems.gun_sauer), + new ItemStack(ModItems.ammo_4gauge, 64), + new ItemStack(ModItems.ammo_4gauge_claw, 64), + new ItemStack(ModItems.ammo_4gauge_kampf, 64), + new ItemStack(ModItems.ammo_4gauge_flechette, 64), + new ItemStack(ModItems.ammo_4gauge_void, 64) + ), Requirement.HIDDEN, 64)); + + special.add(new Offer(ItemKitNBT.create( + new ItemStack(ModItems.rod_of_discord).setStackDisplayName("Cock Joke"), + new ItemStack(ModItems.canned_jizz, 64).setStackDisplayName("Class A Horse Semen"), + new ItemStack(ModItems.pipe_lead).setStackDisplayName("Get Nutted, Dumbass"), + new ItemStack(ModItems.gem_alexandrite) + ).setStackDisplayName("The Nut Bucket"), Requirement.HIDDEN, 64)); } public static List getOffers(ItemStack stack) { if(stack != null) { - if(stack.getItem() == ModItems.bobmazon_materials) - return materials; - if(stack.getItem() == ModItems.bobmazon_machines) - return machines; - if(stack.getItem() == ModItems.bobmazon_weapons) - return weapons; - if(stack.getItem() == ModItems.bobmazon_tools) - return tools; - if(stack.getItem() == ModItems.bobmazon_hidden) - return special; + if(stack.getItem() == ModItems.bobmazon_materials) return materials; + if(stack.getItem() == ModItems.bobmazon_machines) return machines; + if(stack.getItem() == ModItems.bobmazon_weapons) return weapons; + if(stack.getItem() == ModItems.bobmazon_tools) return tools; + if(stack.getItem() == ModItems.bobmazon_hidden) return special; } return null; diff --git a/src/main/java/com/hbm/hazard/type/HazardTypeRadiation.java b/src/main/java/com/hbm/hazard/type/HazardTypeRadiation.java index ccd9d6251..622e6af7d 100644 --- a/src/main/java/com/hbm/hazard/type/HazardTypeRadiation.java +++ b/src/main/java/com/hbm/hazard/type/HazardTypeRadiation.java @@ -3,10 +3,8 @@ package com.hbm.hazard.type; import java.util.List; import com.hbm.config.GeneralConfig; -import com.hbm.handler.ArmorModHandler; import com.hbm.hazard.modifier.HazardModifier; import com.hbm.items.ModItems; -import com.hbm.items.armor.ItemModGloves; import com.hbm.util.ContaminationUtil; import com.hbm.util.I18nUtil; import com.hbm.util.ContaminationUtil.ContaminationType; diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityFEL.java b/src/main/java/com/hbm/tileentity/machine/TileEntityFEL.java index ccfcf5b65..f3f564292 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityFEL.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityFEL.java @@ -6,20 +6,19 @@ import java.util.List; import com.hbm.blocks.BlockDummyable; import com.hbm.blocks.ModBlocks; import com.hbm.blocks.machine.MachineSILEX; -import com.hbm.extprop.HbmLivingProps; import com.hbm.interfaces.Spaghetti; import com.hbm.items.machine.ItemFELCrystal; import com.hbm.items.machine.ItemFELCrystal.EnumWavelengths; import com.hbm.lib.Library; import com.hbm.main.MainRegistry; -import com.hbm.packet.AuxElectricityPacket; -import com.hbm.packet.PacketDispatcher; import com.hbm.tileentity.TileEntityMachineBase; +import com.hbm.util.ContaminationUtil; +import com.hbm.util.ContaminationUtil.ContaminationType; +import com.hbm.util.ContaminationUtil.HazardType; import api.hbm.energy.IEnergyUser; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; -import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; @@ -95,8 +94,8 @@ public class TileEntityFEL extends TileEntityMachineBase implements IEnergyUser case VISIBLE: entity.addPotionEffect(new PotionEffect(Potion.blindness.id, 60 * 60 * 65536, 0)); case IR: case UV: entity.setFire(10); break; - case GAMMA: HbmLivingProps.incrementRadiation(entity, 25); break; - case DRX: HbmLivingProps.incrementDigamma(entity, 0.1F); break; + case GAMMA: ContaminationUtil.contaminate(entity, HazardType.RADIATION, ContaminationType.CREATIVE, 25); break; + case DRX: ContaminationUtil.applyDigammaData(entity, 0.1F); break; } } @@ -166,8 +165,6 @@ public class TileEntityFEL extends TileEntityMachineBase implements IEnergyUser data.setBoolean("valid", missingValidSilex); data.setInteger("distance", distance); this.networkPack(data, 250); - - PacketDispatcher.wrapper.sendToAllAround(new AuxElectricityPacket(xCoord, yCoord, zCoord, power), new TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 50)); } } diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemplantNew.java b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemplantNew.java index 8b7e1943c..794ef4395 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemplantNew.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemplantNew.java @@ -20,8 +20,10 @@ import com.hbm.tileentity.TileEntityMachineBase; 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.minecraftforge.common.util.ForgeDirection; public class TileEntityMachineChemplantNew extends TileEntityMachineBase implements IEnergyUser, IFluidSource, IFluidAcceptor { @@ -77,6 +79,9 @@ public class TileEntityMachineChemplantNew extends TileEntityMachineBase impleme tanks[2].unloadTank(9, 11, slots); tanks[3].unloadTank(10, 12, slots); + loadItems(); + unloadItems(); + if(worldObj.getTotalWorldTime() % 10 == 0) { this.fillFluidInit(tanks[2].getTankType()); this.fillFluidInit(tanks[3].getTankType()); @@ -230,6 +235,102 @@ public class TileEntityMachineChemplantNew extends TileEntityMachineBase impleme InventoryUtil.tryAddItemToInventory(slots, 5, 8, out); } } + + //TODO: move this into a util class + private void loadItems() { + + ChemRecipe recipe = ChemplantRecipes.indexMapping.get(slots[4].getItemDamage()); + + if(recipe != null) { + + ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset); + + int x = xCoord - dir.offsetX * 2; + int z = zCoord - dir.offsetZ * 2; + + TileEntity te = worldObj.getTileEntity(x, yCoord, z); + + if(te instanceof IInventory) { + + IInventory inv = (IInventory) te; + + for(AStack ingredient : recipe.inputs) { + + if(!InventoryUtil.doesArrayHaveIngredients(slots, 13, 16, ingredient)) { + + for(int i = 0; i < inv.getSizeInventory(); i++) { + + ItemStack stack = inv.getStackInSlot(i); + if(ingredient.matchesRecipe(stack, true)) { + + for(int j = 13; j <= 16; j++) { + + if(slots[j] != null && slots[j].stackSize < slots[j].getMaxStackSize() & InventoryUtil.doesStackDataMatch(slots[j], stack)) { + inv.decrStackSize(i, 1); + slots[j].stackSize++; + return; + } + } + + for(int j = 13; j <= 16; j++) { + + if(slots[j] == null) { + slots[j] = stack.copy(); + slots[j].stackSize = 1; + inv.decrStackSize(i, 1); + return; + } + } + } + } + } + } + } + } + } + + private void unloadItems() { + + ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset); + + int x = xCoord - dir.offsetX * 2; + int z = zCoord - dir.offsetZ * 2; + + TileEntity te = worldObj.getTileEntity(x, yCoord, z); + + if(te instanceof IInventory) { + + IInventory inv = (IInventory) te; + + for(int i = 5; i <= 8; i++) { + + ItemStack out = slots[i]; + + if(out != null) { + + for(int j = 0; j < inv.getSizeInventory(); j++) { + ItemStack target = inv.getStackInSlot(i); + + if(InventoryUtil.doesStackDataMatch(out, target) && target.stackSize < target.getMaxStackSize()) { + this.decrStackSize(i, 1); + target.stackSize++; + return; + } + } + + for(int j = 0; j < inv.getSizeInventory(); j++) { + + if(inv.getStackInSlot(j) == null) { + inv.setInventorySlotContents(j, out.copy()); + inv.getStackInSlot(j).stackSize = 1; + this.decrStackSize(i, 1); + return; + } + } + } + } + } + } @Override public long getPower() { diff --git a/src/main/java/com/hbm/util/ContaminationUtil.java b/src/main/java/com/hbm/util/ContaminationUtil.java index 9943a3ee2..521a82c4a 100644 --- a/src/main/java/com/hbm/util/ContaminationUtil.java +++ b/src/main/java/com/hbm/util/ContaminationUtil.java @@ -283,7 +283,7 @@ public class ContaminationUtil { * This system is nice but the cont types are a bit confusing. Cont types should have much better names and multiple cont types should be applicable. */ @SuppressWarnings("incomplete-switch") //just shut up - @Deprecated // instead of this does-everything-but-nothing-well solution, please use the ArmorRegistry to check for protection and the HBM Props for applying contamination + //instead of this does-everything-but-nothing-well solution, please use the ArmorRegistry to check for protection and the HBM Props for applying contamination. still good for regular radiation tho public static boolean contaminate(EntityLivingBase entity, HazardType hazard, ContaminationType cont, float amount) { if(hazard == HazardType.RADIATION) { diff --git a/src/main/java/com/hbm/util/InventoryUtil.java b/src/main/java/com/hbm/util/InventoryUtil.java index 62186a921..5fb87cfb1 100644 --- a/src/main/java/com/hbm/util/InventoryUtil.java +++ b/src/main/java/com/hbm/util/InventoryUtil.java @@ -392,7 +392,7 @@ public class InventoryUtil { return new ItemStack[0][0]; } - public static boolean doesArrayHaveIngredients(ItemStack[] array, int start, int end, AStack[] ingredients) { + public static boolean doesArrayHaveIngredients(ItemStack[] array, int start, int end, AStack... ingredients) { ItemStack[] copy = ItemStackUtil.carefulCopyArrayTruncate(array, start, end); AStack[] req = new AStack[ingredients.length]; diff --git a/src/main/resources/assets/hbm/textures/items/parts_legendary_1.png b/src/main/resources/assets/hbm/textures/items/parts_legendary_1.png new file mode 100644 index 0000000000000000000000000000000000000000..55fb0bd03a10d89ef3d8ee43808c7b71aaa0b504 GIT binary patch literal 500 zcmV(j;e^)B8dewUY*_x*gIpYT5v z_>Kg=BmeX_@E!T}?Tsvwfowml3P88pl`ssY2wWrsStJ8vQUdt={*aq=j)t4fCaqSB zFbw4~2>{sXJT_*l)dszOgR_erDedl`TW1&F1>n`&x#f9N6ZtX;==F#En7=b1z{$~& zG`#`9Dyq}-Jh5$?dv}i6xL;?p{VWHL;%jukQjx)AGO+-`-h$I(?p6-@^zk$Y>c52< zENAlb>uUhoPhQgLbaITjWJj~Re{L zK@IB}Ysq*l853OBrCcuOBLu!9A4X5*U~gRx_SVf>%XlnlyDcwl+mxh~lEM=7I*;P( q+^m7f>yXATLR1U!#bv7D}zrP$?iY552A$c5$WolxX zn&fdLZ7h!?xxX^y=6qi)Qg&-;`Z^YO^!Z6eT|KYSO1^Vye^sesOLzg6YFQOwMh+< zhdkD(#k6hM@;u|;`SmZ-fBbo4;pn?3Xj;Lx{@2QF-rMc}r6(pNBQv`y?_5+Q#LRryZ_X@^s>FA9DwPj%pDwp^_S~z(0|YMuJw1et942;@Om9-pteG`| ak->J?y5$AMr?vyV#^CAd=d#Wzp$PyP-E_bJ literal 0 HcmV?d00001