use of net.minecraft.server.v1_14_R1.ItemStack in project PublicCrafters by BananaPuncher714.
the class CustomInventoryCrafting method setDefaults.
private void setDefaults() {
try {
// Set items
Field field = InventoryCrafting.class.getDeclaredField("items");
field.setAccessible(true);
items = (List<ItemStack>) field.get(this);
} catch (Exception e) {
e.printStackTrace();
}
}
use of net.minecraft.server.v1_14_R1.ItemStack in project PublicCrafters by BananaPuncher714.
the class CustomContainerWorkbench method b.
/**
* This might be for when the inventory closes?
*/
@Override
public void b(EntityHuman entity) {
super.b(entity);
// Make sure the craft inventory stops watching this container
craftInventory.removeContainer(this);
if (craftInventory.transaction.isEmpty() && PublicCrafters.getInstance().isDropItem()) {
if (!world.isClientSide) {
for (int i = 0; i < 9; i++) {
ItemStack itemstack = craftInventory.splitWithoutUpdate(i);
if (itemstack != null) {
entity.drop(itemstack, false);
}
}
setCraftResult();
craftInventory.update();
}
}
}
use of net.minecraft.server.v1_14_R1.ItemStack in project PublicCrafters by BananaPuncher714.
the class CustomInventoryCrafting method splitStack.
@Override
public ItemStack splitStack(int i, int j) {
if (items[i] != null) {
if (items[i].count <= j) {
ItemStack itemstack = this.items[i];
items[i] = null;
for (Container container : containers) {
container.a(this);
}
display.update();
return itemstack;
}
ItemStack itemstack = items[i].cloneAndSubtract(j);
if (this.items[i].count == 0) {
this.items[i] = null;
}
for (Container container : containers) {
container.a(this);
}
display.update();
return itemstack;
}
for (Container container : containers) {
container.a(this);
}
display.update();
return null;
}
use of net.minecraft.server.v1_14_R1.ItemStack in project PublicCrafters by BananaPuncher714.
the class CustomInventoryCrafting method remove.
@Override
public void remove() {
display.stop();
for (int i = 0; i < items.length; i++) {
ItemStack item = items[i];
items[i] = CraftItemStack.asNMSCopy(new org.bukkit.inventory.ItemStack(Material.AIR));
org.bukkit.inventory.ItemStack is = CraftItemStack.asBukkitCopy(item);
if (is.getType() != Material.AIR) {
bloc.getWorld().dropItem(bloc.clone().add(.5, .9, .5), is);
}
}
}
use of net.minecraft.server.v1_14_R1.ItemStack in project PublicCrafters by BananaPuncher714.
the class CustomContainerWorkbench method shiftClick.
@Override
public ItemStack shiftClick(EntityHuman entityhuman, int i) {
ItemStack itemstack = ItemStack.a;
Slot slot = (Slot) theseSlots.get(i);
if ((slot != null) && (slot.hasItem())) {
ItemStack itemstack1 = slot.getItem();
itemstack = itemstack1.cloneItemStack();
if (i == 0) {
itemstack1.getItem().b(itemstack1, world, entityhuman);
if (!a(itemstack1, 10, 46, true)) {
return ItemStack.a;
}
slot.a(itemstack1, itemstack);
} else if ((i >= 10) && (i < 37)) {
if (!a(itemstack1, 37, 46, false)) {
return ItemStack.a;
}
} else if ((i >= 37) && (i < 46)) {
if (!a(itemstack1, 10, 37, false)) {
return ItemStack.a;
}
} else if (!a(itemstack1, 10, 46, false)) {
return ItemStack.a;
}
if (itemstack1.isEmpty()) {
slot.set(ItemStack.a);
} else {
slot.d();
}
if (itemstack1.getCount() == itemstack.getCount()) {
return ItemStack.a;
}
ItemStack itemstack2 = slot.a(entityhuman, itemstack1);
if (i == 0) {
entityhuman.drop(itemstack2, false);
}
}
return itemstack;
}
Aggregations