new chemplant item IO

This commit is contained in:
Boblet 2022-02-21 15:03:27 +01:00
parent f0938e99e1
commit 96db3e6767
9 changed files with 142 additions and 22 deletions

View File

@ -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<Offer> 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;

View File

@ -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;

View File

@ -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));
}
}

View File

@ -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() {

View File

@ -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) {

View File

@ -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];

Binary file not shown.

After

Width:  |  Height:  |  Size: 500 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 333 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 280 B