use of net.minecraft.item.ItemGlassBottle in project GregTech by GregTechCE.
the class PotionFluids method onCapabilityAttach.
/*
* Attaches capabilities to potion items, so they can be emptied to drain contained potion
* and transform into empty glass bottles
* Also allows filing glass bottles with liquid potion to get potion item
*/
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onCapabilityAttach(AttachCapabilitiesEvent<ItemStack> event) {
ItemStack itemStack = event.getObject();
if (itemStack.getItem() instanceof ItemPotion) {
ResourceLocation resourceLocation = new ResourceLocation("gregtech", "fluid_container");
PotionItemFluidHandler fluidHandler = new PotionItemFluidHandler(itemStack);
event.addCapability(resourceLocation, fluidHandler);
} else if (itemStack.getItem() instanceof ItemGlassBottle) {
ResourceLocation resourceLocation = new ResourceLocation("gregtech", "fluid_container");
GlassBottleFluidHandler fluidHandler = new GlassBottleFluidHandler(itemStack, event.getCapabilities().values());
event.addCapability(resourceLocation, fluidHandler);
}
}
Aggregations