use of net.minecraft.item.ItemStack in project BluePower by Qmunity.
the class IOHelper method dropInventory.
public static void dropInventory(World world, int x, int y, int z) {
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (!(tileEntity instanceof IInventory)) {
return;
}
IInventory inventory = (IInventory) tileEntity;
for (int i = 0; i < inventory.getSizeInventory(); i++) {
ItemStack itemStack = inventory.getStackInSlot(i);
if (itemStack != null && itemStack.stackSize > 0) {
spawnItemInWorld(world, itemStack, x, y, z);
}
}
}
use of net.minecraft.item.ItemStack in project BluePower by Qmunity.
the class GateNullCell method drawHighlight.
@Override
public boolean drawHighlight(QMovingObjectPosition mop, EntityPlayer player, float frame) {
Vec3d hit = new Vec3d(mop.hitVec).sub(mop.blockX, mop.blockY, mop.blockZ).rotateUndo(getFace(), Vec3d.center);
Vec3 pos = player.getPosition(frame);
ItemStack held = player.getCurrentEquippedItem();
if (held == null)
return false;
if (held.getItem() instanceof ItemPart) {
IPart part = ((ItemPart) held.getItem()).createPart(held, player, null, null);
if (part == null)
return false;
if (!(part instanceof PartRedwireFaceUninsulated))
return false;
PartRedwireFace wire = (PartRedwireFace) part;
RenderHelper renderer = RenderHelper.instance;
renderer.fullReset();
renderer.setRenderCoords(getWorld(), getX(), getY(), getZ());
double height = 2 / 16D;
IIcon wireIcon = IconSupplier.wire;
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
Tessellator.instance.startDrawingQuads();
Tessellator.instance.addTranslation((float) -pos.xCoord, (float) -pos.yCoord, (float) -pos.zCoord);
{
switch(getFace()) {
case DOWN:
break;
case UP:
renderer.addTransformation(new Rotation(180, 180, 0, Vec3d.center));
break;
case NORTH:
renderer.addTransformation(new Rotation(90, 0, 0, Vec3d.center));
break;
case SOUTH:
renderer.addTransformation(new Rotation(-90, 0, 0, Vec3d.center));
break;
case WEST:
renderer.addTransformation(new Rotation(0, 0, -90, Vec3d.center));
break;
case EAST:
renderer.addTransformation(new Rotation(0, 0, 90, Vec3d.center));
break;
default:
break;
}
int rotation = getRotation();
if (rotation != -1)
renderer.addTransformation(new Rotation(0, 90 * -rotation, 0));
renderer.setOpacity(0.5);
renderer.setColor(WireHelper.getColorForPowerLevel(wire.getRedwireType(ForgeDirection.UNKNOWN), (byte) (255 / 2)));
ForgeDirection dir = ForgeDirection.NORTH;
if (getRotation() % 2 == 1)
dir = dir.getRotation(getFace());
if (hit.getY() > 2 / 16D) {
if (typeB == null) {
renderer.renderBox(new Vec3dCube(0 / 16D, 2 / 16D, 7 / 16D, 2 / 16D, 10 / 16D, 9 / 16D), wireIcon);
renderer.renderBox(new Vec3dCube(14 / 16D, 2 / 16D, 7 / 16D, 16 / 16D, 10 / 16D, 9 / 16D), wireIcon);
renderer.renderBox(new Vec3dCube(0 / 16D, 10 / 16D, 7 / 16D, 16 / 16D, 12 / 16D, 9 / 16D), wireIcon);
}
} else {
if (typeA == null)
renderer.renderBox(new Vec3dCube(7 / 16D, 2 / 16D, 0 / 16D, 9 / 16D, 2 / 16D + height, 16 / 16D), wireIcon);
}
renderer.fullReset();
}
Tessellator.instance.addTranslation((float) pos.xCoord, (float) pos.yCoord, (float) pos.zCoord);
Tessellator.instance.draw();
GL11.glDisable(GL11.GL_BLEND);
return true;
} else if (held.getItem() instanceof IScrewdriver) {
// List<Vec3dCube> l = new ArrayList<Vec3dCube>();
// super.addBoxes(l);
// boolean def = false;
// for (Vec3dCube c : l)
// if (mop.getCube().equals(c.clone().rotate(getFace(), Vec3d.center).rotate(0, 90 * -getRotation(), 0, Vec3d.center)))
// def = true;
// if (def || hit.getY() <= 2 / 16D) {
// Vec3dCube c = Vec3dCube.merge(getSelectionBoxes()).expand(0.001);
//
// GL11.glEnable(GL11.GL_BLEND);
// GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
// GL11.glDisable(GL11.GL_TEXTURE_2D);
// GL11.glColor4f(0, 0, 0, 0.4F);
// GL11.glLineWidth(2);
// GL11.glDepthMask(true);
// GL11.glPushMatrix();
//
// Tessellator var2 = Tessellator.instance;
// var2.startDrawing(3);
// Tessellator.instance.addTranslation((float) -pos.xCoord + getX(), (float) -pos.yCoord + getY(), (float) -pos.zCoord
// + getZ());
// var2.addVertex(c.getMinX(), c.getMinY(), c.getMinZ());
// var2.addVertex(c.getMaxX(), c.getMinY(), c.getMinZ());
// var2.addVertex(c.getMaxX(), c.getMinY(), c.getMaxZ());
// var2.addVertex(c.getMinX(), c.getMinY(), c.getMaxZ());
// var2.addVertex(c.getMinX(), c.getMinY(), c.getMinZ());
// var2.draw();
// var2.startDrawing(3);
// var2.addVertex(c.getMinX(), c.getMaxY(), c.getMinZ());
// var2.addVertex(c.getMaxX(), c.getMaxY(), c.getMinZ());
// var2.addVertex(c.getMaxX(), c.getMaxY(), c.getMaxZ());
// var2.addVertex(c.getMinX(), c.getMaxY(), c.getMaxZ());
// var2.addVertex(c.getMinX(), c.getMaxY(), c.getMinZ());
// var2.draw();
// var2.startDrawing(1);
// var2.addVertex(c.getMinX(), c.getMinY(), c.getMinZ());
// var2.addVertex(c.getMinX(), c.getMaxY(), c.getMinZ());
// var2.addVertex(c.getMaxX(), c.getMinY(), c.getMinZ());
// var2.addVertex(c.getMaxX(), c.getMaxY(), c.getMinZ());
// var2.addVertex(c.getMaxX(), c.getMinY(), c.getMaxZ());
// var2.addVertex(c.getMaxX(), c.getMaxY(), c.getMaxZ());
// var2.addVertex(c.getMinX(), c.getMinY(), c.getMaxZ());
// var2.addVertex(c.getMinX(), c.getMaxY(), c.getMaxZ());
// Tessellator.instance.addTranslation((float) pos.xCoord - getX(), (float) pos.yCoord - getY(), (float) pos.zCoord - getZ());
// var2.draw();
//
// GL11.glPopMatrix();
// GL11.glDepthMask(false);
// GL11.glEnable(GL11.GL_TEXTURE_2D);
// GL11.glDisable(GL11.GL_BLEND);
//
// return true;
// }
//
// return true;
}
return false;
}
use of net.minecraft.item.ItemStack in project BluePower by Qmunity.
the class GateNullCell method getStackWithData.
public static ItemStack getStackWithData(GateNullCell gate) {
ItemStack is = PartManager.getPartInfo("nullcell").getStack();
if (is.getTagCompound() == null)
is.setTagCompound(new NBTTagCompound());
NBTTagCompound tag = new NBTTagCompound();
gate.writeToNBT(tag);
is.getTagCompound().setTag("tileData", tag);
is.getTagCompound().setBoolean("hideSilkyTooltip", true);
return is;
}
use of net.minecraft.item.ItemStack in project BluePower by Qmunity.
the class AlloyFurnaceRegistry method addRecipe.
@Override
public void addRecipe(ItemStack craftingResult, Object... requiredItems) {
if (craftingResult == null || craftingResult.getItem() == null)
throw new NullPointerException("Can't register an Alloy Furnace recipe with a null output stack or item");
ItemStack[] requiredStacks = new ItemStack[requiredItems.length];
for (int i = 0; i < requiredStacks.length; i++) {
if (requiredItems[i] instanceof ItemStack) {
requiredStacks[i] = (ItemStack) requiredItems[i];
} else if (requiredItems[i] instanceof Item) {
requiredStacks[i] = new ItemStack((Item) requiredItems[i], 1, OreDictionary.WILDCARD_VALUE);
} else if (requiredItems[i] instanceof Block) {
requiredStacks[i] = new ItemStack(Item.getItemFromBlock((Block) requiredItems[i]), 1, OreDictionary.WILDCARD_VALUE);
} else {
throw new IllegalArgumentException("Alloy Furnace crafting ingredients can only be ItemStack, Item or Block!");
}
}
addRecipe(new StandardAlloyFurnaceRecipe(craftingResult, requiredStacks));
}
use of net.minecraft.item.ItemStack in project BluePower by Qmunity.
the class AlloyFurnaceRegistry method generateRecyclingRecipes.
@SuppressWarnings("unchecked")
public void generateRecyclingRecipes() {
Collections.addAll(blacklist, Config.alloyFurnaceBlacklist);
List<Item> blacklist = new ArrayList<Item>();
for (String configString : this.blacklist) {
Item item = GameData.getItemRegistry().getObject(configString);
if (item != null) {
blacklist.add(item);
} else {
BluePower.log.info("Config entry \"" + configString + "\" not an existing item/block name! Will not be added to the blacklist");
}
}
List<ItemStack> registeredRecycledItems = new ArrayList<ItemStack>();
List<ItemStack> registeredResultItems = new ArrayList<ItemStack>();
List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList();
for (IRecipe recipe : recipes) {
int recyclingAmount = 0;
ItemStack currentlyRecycledInto = null;
for (ItemStack recyclingItem : bufferedRecyclingItems) {
try {
if (recipe instanceof ShapedRecipes) {
ShapedRecipes shaped = (ShapedRecipes) recipe;
if (shaped.recipeItems != null) {
for (ItemStack input : shaped.recipeItems) {
if (input != null && ItemStackUtils.isItemFuzzyEqual(input, recyclingItem)) {
ItemStack moltenDownItem = getRecyclingStack(recyclingItem);
if (currentlyRecycledInto == null || ItemStackUtils.isItemFuzzyEqual(currentlyRecycledInto, moltenDownItem)) {
currentlyRecycledInto = moltenDownItem;
recyclingAmount += moltenDownItem.stackSize;
}
}
}
}
} else if (recipe instanceof ShapelessRecipes) {
ShapelessRecipes shapeless = (ShapelessRecipes) recipe;
if (shapeless.recipeItems != null) {
for (ItemStack input : (List<ItemStack>) shapeless.recipeItems) {
if (input != null && ItemStackUtils.isItemFuzzyEqual(input, recyclingItem)) {
ItemStack moltenDownItem = getRecyclingStack(recyclingItem);
if (currentlyRecycledInto == null || ItemStackUtils.isItemFuzzyEqual(currentlyRecycledInto, moltenDownItem)) {
currentlyRecycledInto = moltenDownItem;
recyclingAmount += moltenDownItem.stackSize;
}
}
}
}
} else if (recipe instanceof ShapedOreRecipe) {
ShapedOreRecipe shapedOreRecipe = (ShapedOreRecipe) recipe;
if (shapedOreRecipe.getInput() != null) {
for (Object input : shapedOreRecipe.getInput()) {
if (input != null) {
List<ItemStack> itemList;
if (input instanceof ItemStack) {
itemList = new ArrayList<ItemStack>();
itemList.add((ItemStack) input);
} else {
itemList = (List<ItemStack>) input;
}
for (ItemStack item : itemList) {
if (item != null && ItemStackUtils.isItemFuzzyEqual(item, recyclingItem)) {
ItemStack moltenDownItem = getRecyclingStack(recyclingItem);
if (currentlyRecycledInto == null || ItemStackUtils.isItemFuzzyEqual(currentlyRecycledInto, moltenDownItem)) {
currentlyRecycledInto = moltenDownItem;
recyclingAmount += moltenDownItem.stackSize;
}
break;
}
}
}
}
}
} else if (recipe instanceof ShapelessOreRecipe) {
ShapelessOreRecipe shapeless = (ShapelessOreRecipe) recipe;
for (Object input : shapeless.getInput()) {
if (input != null) {
List<ItemStack> itemList;
if (input instanceof ItemStack) {
itemList = new ArrayList<ItemStack>();
itemList.add((ItemStack) input);
} else {
itemList = (List<ItemStack>) input;
}
for (ItemStack item : itemList) {
if (item != null && ItemStackUtils.isItemFuzzyEqual(item, recyclingItem)) {
ItemStack moltenDownItem = getRecyclingStack(recyclingItem);
if (currentlyRecycledInto == null || ItemStackUtils.isItemFuzzyEqual(currentlyRecycledInto, moltenDownItem)) {
currentlyRecycledInto = moltenDownItem;
recyclingAmount += moltenDownItem.stackSize;
}
break;
}
}
}
}
}
} catch (Throwable e) {
BluePower.log.error("Error when generating an Alloy Furnace recipe for item " + recyclingItem.getDisplayName() + ", recipe output: " + recipe.getRecipeOutput().getDisplayName());
e.printStackTrace();
}
}
if (recyclingAmount > 0 && recipe.getRecipeOutput().stackSize > 0) {
boolean shouldAdd = true;
for (int i = 0; i < registeredRecycledItems.size(); i++) {
if (ItemStackUtils.isItemFuzzyEqual(registeredRecycledItems.get(i), recipe.getRecipeOutput())) {
if (registeredResultItems.get(i).stackSize < recyclingAmount) {
shouldAdd = false;
break;
} else {
registeredResultItems.remove(i);
registeredRecycledItems.remove(i);
i--;
}
}
}
if (shouldAdd) {
if (blacklist.contains(recipe.getRecipeOutput().getItem())) {
BluePower.log.info("Skipped adding item/block " + recipe.getRecipeOutput().getDisplayName() + " to the Alloy Furnace recipes.");
continue;
}
ItemStack resultItem = new ItemStack(currentlyRecycledInto.getItem(), Math.min(64, recyclingAmount), currentlyRecycledInto.getItemDamage());
registeredResultItems.add(resultItem);
registeredRecycledItems.add(recipe.getRecipeOutput());
}
}
}
for (int i = 0; i < registeredResultItems.size(); i++) {
addRecipe(registeredResultItems.get(i), registeredRecycledItems.get(i));
}
}
Aggregations