some texturework, NBT-driven kits
@ -2272,6 +2272,7 @@ public class ModItems {
|
||||
public static Item hazmat_kit;
|
||||
public static Item hazmat_red_kit;
|
||||
public static Item hazmat_grey_kit;
|
||||
public static Item kit_custom;
|
||||
|
||||
public static Item loot_10;
|
||||
public static Item loot_15;
|
||||
@ -4604,6 +4605,7 @@ public class ModItems {
|
||||
hazmat_kit = new ItemStarterKit().setUnlocalizedName("hazmat_kit").setMaxStackSize(1).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":hazmat_kit");
|
||||
hazmat_red_kit = new ItemStarterKit().setUnlocalizedName("hazmat_red_kit").setMaxStackSize(1).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":hazmat_red_kit");
|
||||
hazmat_grey_kit = new ItemStarterKit().setUnlocalizedName("hazmat_grey_kit").setMaxStackSize(1).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":hazmat_grey_kit");
|
||||
kit_custom = new ItemKitCustom().setUnlocalizedName("kit_custom").setMaxStackSize(1).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":kit");
|
||||
|
||||
loot_10 = new ItemLootCrate().setUnlocalizedName("loot_10").setMaxStackSize(1).setCreativeTab(MainRegistry.missileTab).setTextureName(RefStrings.MODID + ":loot_10");
|
||||
loot_15 = new ItemLootCrate().setUnlocalizedName("loot_15").setMaxStackSize(1).setCreativeTab(MainRegistry.missileTab).setTextureName(RefStrings.MODID + ":loot_15");
|
||||
@ -7875,6 +7877,7 @@ public class ModItems {
|
||||
GameRegistry.registerItem(hazmat_kit, hazmat_kit.getUnlocalizedName());
|
||||
GameRegistry.registerItem(hazmat_red_kit, hazmat_red_kit.getUnlocalizedName());
|
||||
GameRegistry.registerItem(hazmat_grey_kit, hazmat_grey_kit.getUnlocalizedName());
|
||||
GameRegistry.registerItem(kit_custom, kit_custom.getUnlocalizedName());
|
||||
GameRegistry.registerItem(euphemium_kit, euphemium_kit.getUnlocalizedName());
|
||||
GameRegistry.registerItem(letter, letter.getUnlocalizedName());
|
||||
|
||||
|
||||
110
src/main/java/com/hbm/items/special/ItemKitCustom.java
Normal file
@ -0,0 +1,110 @@
|
||||
package com.hbm.items.special;
|
||||
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.util.ItemStackUtil;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemKitCustom extends Item {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
IIcon overlay1;
|
||||
@SideOnly(Side.CLIENT)
|
||||
IIcon overlay2;
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
|
||||
|
||||
ItemStack[] stacks = ItemStackUtil.readStacksFromNBT(stack);
|
||||
|
||||
if(stacks != null) {
|
||||
|
||||
for(ItemStack item : stacks) {
|
||||
if(item != null) {
|
||||
player.inventory.addItemStackToInventory(item.copy());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stack.stackSize--;
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getRenderPasses(int metadata) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister reg) {
|
||||
super.registerIcons(reg);
|
||||
|
||||
this.overlay1 = reg.registerIcon(this.getIconString() + "_1");
|
||||
this.overlay2 = reg.registerIcon(this.getIconString() + "_2");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean requiresMultipleRenderPasses() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIconFromDamageForRenderPass(int meta, int pass) {
|
||||
return pass == 1 ? this.overlay1 : pass == 2 ? this.overlay2 : super.getIconFromDamageForRenderPass(meta, pass);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getColorFromItemStack(ItemStack stack, int pass) {
|
||||
if(pass == 1)
|
||||
return getColor(stack, 1);
|
||||
if(pass == 2)
|
||||
return getColor(stack, 2);
|
||||
return 0xffffff;
|
||||
}
|
||||
|
||||
public static ItemStack create(String name, String lore, int color1, int color2, ItemStack... contents) {
|
||||
ItemStack stack = new ItemStack(ModItems.kit_custom);
|
||||
|
||||
stack.stackTagCompound = new NBTTagCompound();
|
||||
|
||||
setColor(stack, color1, 1);
|
||||
setColor(stack, color2, 2);
|
||||
|
||||
if(lore != null) ItemStackUtil.addTooltipToStack(stack, lore.split("\\$"));
|
||||
stack.setStackDisplayName(EnumChatFormatting.RESET + name);
|
||||
ItemStackUtil.addStacksToNBT(stack, contents);
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
public static void setColor(ItemStack stack, int color, int index) {
|
||||
|
||||
if(!stack.hasTagCompound())
|
||||
stack.stackTagCompound = new NBTTagCompound();
|
||||
|
||||
stack.stackTagCompound.setInteger("color" + index, color);
|
||||
}
|
||||
|
||||
public static int getColor(ItemStack stack, int index) {
|
||||
|
||||
if(!stack.hasTagCompound())
|
||||
return 0;
|
||||
|
||||
return stack.stackTagCompound.getInteger("color" + index);
|
||||
}
|
||||
}
|
||||
@ -3,6 +3,7 @@ package com.hbm.items.special;
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.interfaces.Spaghetti;
|
||||
import com.hbm.inventory.fluid.Fluids;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.items.machine.ItemBattery;
|
||||
@ -22,12 +23,10 @@ import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@Deprecated //not deprecated per se but please stop using it wherever possible
|
||||
@Spaghetti("i do not care how much 'optimization' you want to throw at this dumpster fire but there's no saving grace here")
|
||||
public class ItemStarterKit extends Item {
|
||||
|
||||
public ItemStarterKit() {
|
||||
this.maxStackSize = 1;
|
||||
}
|
||||
|
||||
private void giveHaz(World world, EntityPlayer p, int tier) {
|
||||
|
||||
for(int i = 0; i < 4; i++) {
|
||||
|
||||
@ -2,18 +2,15 @@ package com.hbm.items.tool;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.items.special.ItemKitCustom;
|
||||
import com.hbm.lib.Library;
|
||||
import com.hbm.tileentity.conductor.TileEntityFluidDuct;
|
||||
import com.hbm.tileentity.conductor.TileEntityFluidDuctSimple;
|
||||
|
||||
import api.hbm.energy.IEnergyConductor;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@ -25,33 +22,17 @@ public class ItemWandD extends Item {
|
||||
if(world.isRemote)
|
||||
return stack;
|
||||
|
||||
MovingObjectPosition pos = Library.rayTrace(player, 500, 1);
|
||||
MovingObjectPosition pos = Library.rayTrace(player, 500, 1, false, true, false);
|
||||
|
||||
if(pos != null) {
|
||||
|
||||
int x = pos.blockX;
|
||||
int z = pos.blockZ;
|
||||
//int y = world.getHeightValue(x, z);
|
||||
int y = pos.blockY;
|
||||
List<EntityLiving> list = world.getEntitiesWithinAABB(EntityLiving.class, player.boundingBox.expand(150, 150, 150));
|
||||
|
||||
Block b = world.getBlock(x, y, z);
|
||||
if(b instanceof BlockDummyable) {
|
||||
int[] core = ((BlockDummyable)b).findCore(world, x, y, z);
|
||||
x = core[0];
|
||||
y = core[1];
|
||||
z = core[2];
|
||||
}
|
||||
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
/*if(te instanceof IEnergyConductor) {
|
||||
IEnergyConductor con = (IEnergyConductor) te;
|
||||
player.addChatComponentMessage(new ChatComponentText("" + con.getPowerNet()));
|
||||
}*/
|
||||
|
||||
if(te instanceof TileEntityFluidDuctSimple) {
|
||||
|
||||
player.addChatComponentMessage(new ChatComponentText("" + ((TileEntityFluidDuctSimple)te).getType().getUnlocalizedName()));
|
||||
player.addChatComponentMessage(new ChatComponentText("" + ((TileEntityFluidDuctSimple)te).getType().getID()));
|
||||
for(EntityLiving e : list) {
|
||||
e.setRevengeTarget(player);
|
||||
e.setAttackTarget(player);
|
||||
e.setLastAttacker(player);
|
||||
e.getNavigator().tryMoveToXYZ(player.posX, player.posY, player.posZ, 2);
|
||||
}
|
||||
|
||||
//CellularDungeonFactory.meteor.generate(world, x, y, z, world.rand);
|
||||
|
||||
@ -9,7 +9,7 @@ import net.minecraft.util.EnumChatFormatting;
|
||||
public class ItemStackUtil {
|
||||
|
||||
/**
|
||||
* UNSAFE! Will ignore all existing tags and override them! In its current state, only fit for items we know don't have any display tags!
|
||||
* UNSAFE! Will ignore all existing display tags and override them! In its current state, only fit for items we know don't have any display tags!
|
||||
* Will, however, respect existing NBT tags
|
||||
* @param stack
|
||||
* @param lines
|
||||
@ -29,4 +29,43 @@ public class ItemStackUtil {
|
||||
display.setTag("Lore", lore);
|
||||
stack.stackTagCompound.setTag("display", display);
|
||||
}
|
||||
|
||||
public static void addStacksToNBT(ItemStack stack, ItemStack... stacks) {
|
||||
|
||||
if(!stack.hasTagCompound())
|
||||
stack.stackTagCompound = new NBTTagCompound();
|
||||
|
||||
NBTTagList tags = new NBTTagList();
|
||||
|
||||
for(int i = 0; i < stacks.length; i++) {
|
||||
if(stacks[i] != null) {
|
||||
NBTTagCompound slotNBT = new NBTTagCompound();
|
||||
slotNBT.setByte("slot", (byte) i);
|
||||
stacks[i].writeToNBT(slotNBT);
|
||||
tags.appendTag(slotNBT);
|
||||
}
|
||||
}
|
||||
stack.stackTagCompound.setTag("items", tags);
|
||||
}
|
||||
|
||||
public static ItemStack[] readStacksFromNBT(ItemStack stack) {
|
||||
|
||||
if(!stack.hasTagCompound())
|
||||
return null;
|
||||
|
||||
NBTTagList list = stack.stackTagCompound.getTagList("items", 10);
|
||||
int count = list.tagCount();
|
||||
|
||||
ItemStack[] stacks = new ItemStack[count];
|
||||
|
||||
for(int i = 0; i < count; i++) {
|
||||
NBTTagCompound slotNBT = list.getCompoundTagAt(i);
|
||||
byte slot = slotNBT.getByte("slot");
|
||||
if(slot >= 0 && slot < stacks.length) {
|
||||
stacks[slot] = ItemStack.loadItemStackFromNBT(slotNBT);
|
||||
}
|
||||
}
|
||||
|
||||
return stacks;
|
||||
}
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 709 B After Width: | Height: | Size: 839 B |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 706 B After Width: | Height: | Size: 873 B |
BIN
src/main/resources/assets/hbm/textures/items/kit.png
Normal file
|
After Width: | Height: | Size: 222 B |
BIN
src/main/resources/assets/hbm/textures/items/kit_1.png
Normal file
|
After Width: | Height: | Size: 108 B |
BIN
src/main/resources/assets/hbm/textures/items/kit_2.png
Normal file
|
After Width: | Height: | Size: 105 B |
BIN
src/main/resources/assets/hbm/textures/items/kit_toolbox.png
Normal file
|
After Width: | Height: | Size: 245 B |
|
After Width: | Height: | Size: 209 B |