hadron power plug crashfix, IV bag

This commit is contained in:
Boblet 2021-11-25 15:41:19 +01:00
parent a224d56cae
commit 337891905f
9 changed files with 89 additions and 4 deletions

View File

@ -130,6 +130,9 @@ public class ConsumableRecipes {
CraftingManager.addRecipeAuto(new ItemStack(ModItems.med_bag, 1), new Object[] { "LLL", "SIS", "LLL", 'L', ModItems.plate_polymer, 'S', ModItems.syringe_metal_stimpak, 'I', ModItems.pill_iodine });
CraftingManager.addRecipeAuto(new ItemStack(ModItems.med_bag, 1), new Object[] { "LL", "SI", "LL", 'L', ModItems.plate_polymer, 'S', ModItems.syringe_metal_super, 'I', ModItems.radaway });
//IV Bags
CraftingManager.addRecipeAuto(new ItemStack(ModItems.iv_blood, 4), new Object[] { "S", "I", "S", 'S', ModItems.plate_polymer, 'I', IRON.plate() });
//Radaway
CraftingManager.addRecipeAuto(new ItemStack(ModItems.radaway, 1), new Object[] { "S", "M", "W", 'S', ModItems.plate_polymer, 'M', ModBlocks.mush, 'W', Items.potionitem });
CraftingManager.addRecipeAuto(new ItemStack(ModItems.radaway_strong, 1), new Object[] { "S", "M", "W", 'S', Items.pumpkin_seeds, 'M', ModBlocks.mush, 'W', ModItems.radaway });
@ -172,7 +175,7 @@ public class ConsumableRecipes {
CraftingManager.addRecipeAuto(new ItemStack(ModItems.industrial_magnet, 1), new Object[] { "SMS", " B ", "SMS", 'S', STEEL.ingot(), 'M', ModItems.horseshoe_magnet, 'B', ModBlocks.fusion_conductor });
CraftingManager.addRecipeAuto(new ItemStack(ModItems.heart_container, 1), new Object[] { "HAH", "ACA", "HAH", 'H', ModItems.heart_piece, 'A', AL.ingot(), 'C', ModItems.coin_creeper });
CraftingManager.addRecipeAuto(new ItemStack(ModItems.heart_booster, 1), new Object[] { "GHG", "MCM", "GHG", 'G', GOLD.ingot(), 'H', ModItems.heart_container, 'M', ModItems.morning_glory, 'C', ModItems.coin_maskman });
CraftingManager.addRecipeAuto(new ItemStack(ModItems.heart_fab, 1), new Object[] { "GHG", "MCM", "GHG", 'G', ModItems.billet_polonium, 'H', ModItems.heart_booster, 'M', ModItems.canteen_fab, 'C', ModItems.coin_worm });
CraftingManager.addRecipeAuto(new ItemStack(ModItems.heart_fab, 1), new Object[] { "GHG", "MCM", "GHG", 'G', PO210.billet(), 'H', ModItems.heart_booster, 'M', ModItems.canteen_fab, 'C', ModItems.coin_worm });
CraftingManager.addRecipeAuto(new ItemStack(ModItems.ink, 1), new Object[] { "FPF", "PIP", "FPF", 'F', new ItemStack(Blocks.red_flower, 1, OreDictionary.WILDCARD_VALUE), 'P', ModItems.armor_polish, 'I', KEY_BLACK });
CraftingManager.addRecipeAuto(new ItemStack(ModItems.bathwater_mk2, 1), new Object[] { "MWM", "WBW", "MWM", 'M', ModItems.bottle_mercury, 'W', ModItems.nuclear_waste, 'B', ModItems.bathwater });
CraftingManager.addRecipeAuto(new ItemStack(ModItems.back_tesla, 1), new Object[] { "DGD", "GTG", "DGD", 'D', ModItems.ducttape, 'G', ModItems.wire_gold, 'T', ModBlocks.tesla });

View File

@ -37,6 +37,7 @@ import net.minecraft.item.ItemSoup;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumChatFormatting;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.EnumHelper;
@ -840,6 +841,8 @@ public class ModItems {
public static Item syringe_metal_super;
public static Item syringe_taint;
public static Item syringe_mkunicorn;
public static Item iv_empty;
public static Item iv_blood;
public static Item radaway;
public static Item radaway_strong;
public static Item radaway_flush;
@ -3263,6 +3266,18 @@ public class ModItems {
syringe_metal_super = new ItemSyringe().setUnlocalizedName("syringe_metal_super").setFull3D().setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":syringe_metal_super");
syringe_taint = new ItemSyringe().setUnlocalizedName("syringe_taint").setFull3D().setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":syringe_taint");
syringe_mkunicorn = new ItemSyringe().setUnlocalizedName("syringe_mkunicorn").setFull3D().setCreativeTab(null).setTextureName(RefStrings.MODID + ":syringe_mkunicorn");
iv_empty = new ItemSimpleConsumable().setUseActionServer((stack, user) -> {
stack.stackSize--;
user.attackEntityFrom(DamageSource.magic, 5F);
ItemSimpleConsumable.tryAddItem(user, new ItemStack(ModItems.iv_blood)); //are references resolved when the lambda is created or when it is called? must run some tests on this
}).setUnlocalizedName("iv_empty").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":iv_empty");
iv_blood = new ItemSimpleConsumable().setUseActionServer((stack, user) -> {
stack.stackSize--;
user.heal(5F);
ItemSimpleConsumable.tryAddItem(user, new ItemStack(ModItems.iv_empty));
}).setUnlocalizedName("iv_empty").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":iv_blood");
med_bag = new ItemSyringe().setUnlocalizedName("med_bag").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":med_bag");
radaway = new ItemSyringe().setUnlocalizedName("radaway").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":radaway");
radaway_strong = new ItemSyringe().setUnlocalizedName("radaway_strong").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":radaway_strong");
@ -7470,6 +7485,8 @@ public class ModItems {
GameRegistry.registerItem(syringe_taint, syringe_taint.getUnlocalizedName());
GameRegistry.registerItem(syringe_mkunicorn, syringe_mkunicorn.getUnlocalizedName());
GameRegistry.registerItem(med_bag, med_bag.getUnlocalizedName());
GameRegistry.registerItem(iv_empty, iv_empty.getUnlocalizedName());
GameRegistry.registerItem(iv_blood, iv_blood.getUnlocalizedName());
GameRegistry.registerItem(radaway, radaway.getUnlocalizedName());
GameRegistry.registerItem(radaway_strong, radaway_strong.getUnlocalizedName());
GameRegistry.registerItem(radaway_flush, radaway_flush.getUnlocalizedName());

View File

@ -0,0 +1,61 @@
package com.hbm.items.special;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import com.hbm.items.ModItems;
import com.hbm.util.Tuple.Pair;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class ItemSimpleConsumable extends Item {
//if java is giving me the power of generics and delegates then i'm going to use them, damn it!
private BiConsumer<ItemStack, EntityPlayer> useAction;
private BiConsumer<ItemStack, EntityPlayer> useActionServer;
private BiConsumer<ItemStack, Pair<EntityLivingBase, EntityLivingBase>> hitAction;
private BiConsumer<ItemStack, Pair<EntityLivingBase, EntityLivingBase>> hitActionServer;
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
if(this.useAction != null)
this.useAction.accept(stack, player);
if(!world.isRemote && this.useActionServer != null)
this.useActionServer.accept(stack, player);
return stack;
}
@Override
public boolean hitEntity(ItemStack stack, EntityLivingBase entity, EntityLivingBase entityPlayer) {
if(this.hitAction != null)
this.hitAction.accept(stack, new Pair(entity, entityPlayer));
if(!entity.worldObj.isRemote && this.hitActionServer != null)
this.hitActionServer.accept(stack, new Pair(entity, entityPlayer));
return false;
}
public static void tryAddItem(EntityLivingBase entity, ItemStack stack) {
if(entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) entity;
if(!player.inventory.addItemStackToInventory(stack)) {
player.dropPlayerItemWithRandomChoice(stack, false);
}
}
}
//this formatting style probably already has a name but i will call it "the greg"
public ItemSimpleConsumable setUseAction( BiConsumer<ItemStack, EntityPlayer> delegate) { this.useAction = delegate; return this; }
public ItemSimpleConsumable setUseActionServer( BiConsumer<ItemStack, EntityPlayer> delegate) { this.useActionServer = delegate; return this; }
public ItemSimpleConsumable setHitAction( BiConsumer<ItemStack, Pair<EntityLivingBase, EntityLivingBase>> delegate) { this.hitAction = delegate; return this; }
public ItemSimpleConsumable setHitActionServer( BiConsumer<ItemStack, Pair<EntityLivingBase, EntityLivingBase>> delegate) { this.hitActionServer = delegate; return this; }
}

View File

@ -14,7 +14,7 @@ public class TileEntityHadronPower extends TileEntity implements IEnergyUser {
@Override
public boolean canUpdate() {
return this.worldObj.getTotalWorldTime() % 20 == 0;
return this.worldObj != null && this.worldObj.getTotalWorldTime() % 20 == 0;
}
@Override

View File

@ -52,8 +52,8 @@ public class LootGenerator {
addItemWithDeviation(loot, world.rand, new ItemStack(syringe), 0.125, i * 0.03125, 0.25);
}
int type = world.rand.nextInt(5);
Item syringe = type < 2 ? ModItems.radaway : type < 4 ? ModItems.radx : ModItems.siox;
int type = world.rand.nextInt(8);
Item syringe = type < 2 ? ModItems.radaway : type < 4 ? ModItems.radx : type < 7 ? ModItems.iv_blood : ModItems.siox;
addItemWithDeviation(loot, world.rand, new ItemStack(syringe), -0.25, 0, -0.125);
}
}

View File

@ -1593,6 +1593,8 @@ item.insert_polonium.name=Poloniumeinlage
item.insert_steel.name=Schwere Stahleinlage
item.insert_xsapi.name=XSAPI-Einlage
item.insert_yharonite.name=Yharoniteinlage
item.iv_blood.name=Blutbeutel
item.iv_empty.name=Infusionsbeutel
item.jackt.name=Verdammt stylische Kugeljacke
item.jackt2.name=Verdammt stylische Kugeljacke 2: Tokyo Drift
item.jetpack_boost.name=Boosterrucksack

View File

@ -1661,6 +1661,8 @@ item.insert_polonium.name=Polonium Insert
item.insert_steel.name=Heavy Steel Insert
item.insert_xsapi.name=XSAPI Insert
item.insert_yharonite.name=Yharonite Insert
item.iv_blood.name=Blood Bag
item.iv_empty.name=IV Bag
item.jackt.name=Damn Stylish Ballistic Jacket
item.jackt2.name=Damn Stylish Ballistic Jacket 2: Tokyo Drift
item.jetpack_boost.name=Boostpack

Binary file not shown.

After

Width:  |  Height:  |  Size: 482 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 251 B