use of org.bukkit.craftbukkit.v.inventory.CraftItemStack in project Arclight by IzzelAliz.
the class AbstractFurnaceTileEntityMixin method arclight$furnaceBurn.
@Inject(method = "tick", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/tileentity/AbstractFurnaceTileEntity;getBurnTime(Lnet/minecraft/item/ItemStack;)I"))
public void arclight$furnaceBurn(CallbackInfo ci) {
ItemStack itemStack = this.items.get(1);
CraftItemStack fuel = CraftItemStack.asCraftMirror(itemStack);
arclight$burnEvent = new FurnaceBurnEvent(CraftBlock.at(this.world, this.pos), fuel, getBurnTime(itemStack));
Bukkit.getPluginManager().callEvent(arclight$burnEvent);
if (arclight$burnEvent.isCancelled()) {
ci.cancel();
arclight$burnEvent = null;
}
}
use of org.bukkit.craftbukkit.v.inventory.CraftItemStack in project Arclight by IzzelAliz.
the class AbstractFurnaceTileEntityMixin method smelt.
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
private void smelt(@Nullable IRecipe<?> p_214007_1_) {
if (p_214007_1_ != null && this.canSmelt(p_214007_1_)) {
ItemStack itemstack = this.items.get(0);
ItemStack itemstack1 = p_214007_1_.getRecipeOutput();
ItemStack itemstack2 = this.items.get(2);
CraftItemStack source = CraftItemStack.asCraftMirror(itemstack);
org.bukkit.inventory.ItemStack result = CraftItemStack.asBukkitCopy(itemstack1);
FurnaceSmeltEvent event = new FurnaceSmeltEvent(CraftBlock.at(world, pos), source, result);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
result = event.getResult();
itemstack1 = CraftItemStack.asNMSCopy(result);
if (!itemstack1.isEmpty()) {
if (itemstack2.isEmpty()) {
this.items.set(2, itemstack1.copy());
} else if (CraftItemStack.asCraftMirror(itemstack2).isSimilar(result)) {
itemstack2.grow(itemstack1.getCount());
} else {
return;
}
}
if (!this.world.isRemote) {
this.setRecipeUsed(p_214007_1_);
}
if (itemstack.getItem() == Blocks.WET_SPONGE.asItem() && !this.items.get(1).isEmpty() && this.items.get(1).getItem() == Items.BUCKET) {
this.items.set(1, new ItemStack(Items.WATER_BUCKET));
}
itemstack.shrink(1);
}
}
use of org.bukkit.craftbukkit.v.inventory.CraftItemStack in project Arclight by IzzelAliz.
the class HopperTileEntityMixin method arclight$moveItem.
@Redirect(method = "transferItemsOut", at = @At(value = "INVOKE", target = "Lnet/minecraft/tileentity/HopperTileEntity;putStackInInventoryAllSlots(Lnet/minecraft/inventory/IInventory;Lnet/minecraft/inventory/IInventory;Lnet/minecraft/item/ItemStack;Lnet/minecraft/util/Direction;)Lnet/minecraft/item/ItemStack;"))
public ItemStack arclight$moveItem(IInventory source, IInventory destination, ItemStack stack, Direction direction) {
CraftItemStack original = CraftItemStack.asCraftMirror(stack);
Inventory destinationInventory;
// Have to special case large chests as they work oddly
if (destination instanceof DoubleSidedInventory) {
destinationInventory = new CraftInventoryDoubleChest(((DoubleSidedInventory) destination));
} else {
destinationInventory = ((IInventoryBridge) destination).getOwner().getInventory();
}
InventoryMoveItemEvent event = new InventoryMoveItemEvent(this.getOwner().getInventory(), original.clone(), destinationInventory, true);
Bukkit.getPluginManager().callEvent(event);
if (arclight$moveItem = event.isCancelled()) {
// Delay hopper checks
this.setTransferCooldown(8);
return null;
}
return HopperTileEntity.putStackInInventoryAllSlots(source, destination, CraftItemStack.asNMSCopy(event.getItem()), direction);
}
use of org.bukkit.craftbukkit.v.inventory.CraftItemStack in project Arclight by IzzelAliz.
the class HopperTileEntityMixin method arclight$pullItem.
@Redirect(method = "pullItemFromSlot", at = @At(value = "INVOKE", target = "Lnet/minecraft/tileentity/HopperTileEntity;putStackInInventoryAllSlots(Lnet/minecraft/inventory/IInventory;Lnet/minecraft/inventory/IInventory;Lnet/minecraft/item/ItemStack;Lnet/minecraft/util/Direction;)Lnet/minecraft/item/ItemStack;"))
private static ItemStack arclight$pullItem(IInventory source, IInventory destination, ItemStack stack, Direction direction) {
CraftItemStack original = CraftItemStack.asCraftMirror(stack);
Inventory sourceInventory;
// Have to special case large chests as they work oddly
if (source instanceof DoubleSidedInventory) {
sourceInventory = new CraftInventoryDoubleChest(((DoubleSidedInventory) source));
} else {
sourceInventory = ((IInventoryBridge) source).getOwner().getInventory();
}
InventoryMoveItemEvent event = new InventoryMoveItemEvent(sourceInventory, original.clone(), ((IInventoryBridge) destination).getOwner().getInventory(), false);
Bukkit.getPluginManager().callEvent(event);
if (arclight$moveItem = event.isCancelled()) {
if (destination instanceof HopperTileEntity) {
// Delay hopper checks
((HopperTileEntity) destination).setTransferCooldown(8);
} else if (destination instanceof HopperMinecartEntity) {
// Delay hopper minecart checks
((HopperMinecartEntity) destination).setTransferTicker(4);
}
return null;
}
return HopperTileEntity.putStackInInventoryAllSlots(source, destination, CraftItemStack.asNMSCopy(event.getItem()), direction);
}
use of org.bukkit.craftbukkit.v.inventory.CraftItemStack in project Arclight by IzzelAliz.
the class SmokingRecipeMixin method bridge$toBukkitRecipe.
@Override
public Recipe bridge$toBukkitRecipe() {
CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
CraftSmokingRecipe recipe = new CraftSmokingRecipe(CraftNamespacedKey.fromMinecraft(this.getId()), result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookTime);
recipe.setGroup(this.group);
return recipe;
}
Aggregations