use of minechem.item.bucket.MinechemBucketItem in project Minechem by iopleke.
the class RadiationMoleculeHandler method handleRadiationMoleculeBucket.
public RadiationInfo handleRadiationMoleculeBucket(World world, ItemStack itemStack, IInventory inventory, double x, double y, double z) {
PotionChemical[] decayedChemicals = getDecayedMolecule((MoleculeEnum) ((MinechemBucketItem) itemStack.getItem()).chemical);
for (int i = 0; i < decayedChemicals.length; i++) {
decayedChemicals[i].amount *= 8 * itemStack.stackSize;
}
ItemStack[] items = toItemStacks(decayedChemicals);
for (int i = 1; i < items.length; i++) {
ItemStack stack = MinechemUtil.addItemToInventory(inventory, items[i]);
if (stack != null) {
MinechemUtil.throwItemStack(world, itemStack, x, y, z);
}
}
Item item = items[0].getItem();
if (item instanceof MoleculeItem) {
itemStack.func_150996_a(MinechemBucketHandler.getInstance().buckets.get(FluidHelper.moleculeBlocks.get(FluidHelper.molecules.get(MoleculeItem.getMolecule(items[0])))));
} else if (item instanceof ElementItem) {
itemStack.func_150996_a(MinechemBucketHandler.getInstance().buckets.get(FluidHelper.elementsBlocks.get(FluidHelper.elements.get(ElementItem.getElement(items[0])))));
}
itemStack.stackSize = (items[0].stackSize / 8);
itemStack.setTagCompound(items[0].stackTagCompound);
return ElementItem.initiateRadioactivity(itemStack, world);
}
use of minechem.item.bucket.MinechemBucketItem in project Minechem by iopleke.
the class ChemicalBucketNEIRecipeHandler method loadCraftingRecipes.
@Override
public void loadCraftingRecipes(ItemStack result) {
if (result.getItem() instanceof MinechemBucketItem) {
MinechemBucketItem bucket = (MinechemBucketItem) result.getItem();
List<ItemStack> recipe = new ArrayList<ItemStack>();
Item type = bucket.chemical instanceof ElementEnum ? MinechemItemsRegistration.element : MinechemItemsRegistration.molecule;
int meta = bucket.chemical instanceof ElementEnum ? ((ElementEnum) bucket.chemical).atomicNumber() : ((MoleculeEnum) bucket.chemical).id();
for (int i = 0; i < 4; i++) recipe.add(new ItemStack(type, 1, meta));
recipe.add(new ItemStack(Items.bucket));
for (int i = 0; i < 4; i++) recipe.add(new ItemStack(type, 1, meta));
arecipes.add(new CachedShapelessRecipe(recipe, result));
} else if (Compare.isStackAnElement(result)) {
ItemStack recipe = new ItemStack(MinechemBucketHandler.getInstance().getBucket(ElementItem.getElement(result)));
arecipes.add(new CachedShapelessRecipe(new ItemStack[] { recipe }, new ItemStack(result.getItem(), 8, result.getItemDamage())));
} else if (Compare.isStackAMolecule(result)) {
ItemStack recipe = new ItemStack(MinechemBucketHandler.getInstance().getBucket(MoleculeItem.getMolecule(result)));
arecipes.add(new CachedShapelessRecipe(new ItemStack[] { recipe }, new ItemStack(result.getItem(), 8, result.getItemDamage())));
}
}
use of minechem.item.bucket.MinechemBucketItem in project Minechem by iopleke.
the class ChemicalBucketNEIRecipeHandler method loadUsageRecipes.
@Override
public void loadUsageRecipes(ItemStack ingredient) {
if (ingredient.getItem() == Items.bucket) {
arecipes.add(new CachedChemicalBucketRecipe());
} else if (Compare.isStackAnElement(ingredient)) {
MinechemBucketItem bucketItem = MinechemBucketHandler.getInstance().getBucket(ElementItem.getElement(ingredient));
if (bucketItem == null)
return;
ItemStack result = new ItemStack(bucketItem);
List<ItemStack> recipe = new ArrayList<ItemStack>();
for (int i = 0; i < 4; i++) recipe.add(new ItemStack(ingredient.getItem(), 1, ingredient.getItemDamage()));
recipe.add(new ItemStack(Items.bucket));
for (int i = 0; i < 4; i++) recipe.add(new ItemStack(ingredient.getItem(), 1, ingredient.getItemDamage()));
arecipes.add(new CachedShapelessRecipe(recipe, result));
} else if (Compare.isStackAMolecule(ingredient)) {
MinechemBucketItem bucketItem = MinechemBucketHandler.getInstance().getBucket(MoleculeItem.getMolecule(ingredient));
if (bucketItem == null)
return;
ItemStack result = new ItemStack(bucketItem);
List<ItemStack> recipe = new ArrayList<ItemStack>();
for (int i = 0; i < 4; i++) recipe.add(new ItemStack(ingredient.getItem(), 1, ingredient.getItemDamage()));
recipe.add(new ItemStack(Items.bucket));
for (int i = 0; i < 4; i++) recipe.add(new ItemStack(ingredient.getItem(), 1, ingredient.getItemDamage()));
arecipes.add(new CachedShapelessRecipe(recipe, result));
}
}
use of minechem.item.bucket.MinechemBucketItem in project Minechem by iopleke.
the class ChemicalFluidReactionHandler method checkEntityItem.
public void checkEntityItem(World world, EntityItem entityItem) {
ItemStack itemStack = entityItem.getEntityItem();
if (itemStack.stackSize <= 0) {
return;
}
Item item = itemStack.getItem();
MinechemChemicalType chemicalA = null;
if (item instanceof MinechemBucketItem) {
chemicalA = MinechemUtil.getChemical(((MinechemBucketItem) item).fluid);
}
if (chemicalA != null && (world.isMaterialInBB(entityItem.boundingBox, Material.water) || world.isMaterialInBB(entityItem.boundingBox, MinechemFluidBlock.materialFluidBlock))) {
int x = MathHelper.floor_double(entityItem.posX);
int y = MathHelper.floor_double(entityItem.posY);
int z = MathHelper.floor_double(entityItem.posZ);
Block block = world.getBlock(x, y, z);
MinechemChemicalType chemicalB = MinechemUtil.getChemical(block);
if (chemicalB != null) {
ChemicalFluidReactionRule rule = new ChemicalFluidReactionRule(chemicalA, chemicalB);
if (reactionRules.containsKey(rule)) {
chemicalReaction(world, entityItem, x, y, z, rule, !(MinechemUtil.canDrain(world, block, x, y, z)));
itemStack.stackSize--;
entityItem.setEntityItemStack(itemStack);
if (itemStack.stackSize <= 0) {
world.removeEntity(entityItem);
}
MinechemUtil.throwItemStack(world, new ItemStack(Items.bucket), x, y, z);
}
}
}
}
use of minechem.item.bucket.MinechemBucketItem in project Minechem by iopleke.
the class MinechemBucketReceiver method dispense.
@Override
public ItemStack dispense(IBlockSource blockSource, ItemStack itemstack) {
EnumFacing enumfacing = BlockDispenser.func_149937_b(blockSource.getBlockMetadata());
World world = blockSource.getWorld();
int x = blockSource.getXInt() + enumfacing.getFrontOffsetX();
int y = blockSource.getYInt() + enumfacing.getFrontOffsetY();
int z = blockSource.getZInt() + enumfacing.getFrontOffsetZ();
Block front = world.getBlock(x, y, z);
if (front instanceof MinechemFluidBlock) {
MinechemBucketItem item = MinechemBucketHandler.getInstance().buckets.get(front);
ItemStack newstack = new ItemStack(item);
TileEntity tile = world.getTileEntity(x, y, z);
if (tile != null && item.chemical.radioactivity() != RadiationEnum.stable) {
RadiationInfo.setRadiationInfo(((RadiationFluidTileEntity) tile).info, newstack);
}
world.func_147480_a(x, y, z, true);
itemstack.stackSize--;
if (itemstack.stackSize <= 0) {
return newstack;
} else {
TileEntity inventoryTile = blockSource.getBlockTileEntity();
if (inventoryTile instanceof IInventory) {
ItemStack stack = MinechemUtil.addItemToInventory((IInventory) blockSource.getBlockTileEntity(), newstack);
if (stack != null) {
MinechemUtil.throwItemStack(world, stack, x, y, z);
}
} else {
MinechemUtil.throwItemStack(world, newstack, x, y, z);
}
}
return itemstack;
}
return source.dispense(blockSource, itemstack);
}
Aggregations