use of net.minecraft.server.v1_10_R1.Container in project PublicCrafters by BananaPuncher714.
the class CustomTileEntityContainerWorkbench method createMenu.
/**
* This is an ITileEntityContainer method that returns a new container for whatever tile entity
*/
@Override
public Container createMenu(int id, PlayerInventory inv, EntityHuman ent) {
CustomInventoryCrafting crafting = manager.benches.get(bloc);
if (crafting == null) {
crafting = new CustomInventoryCrafting(bloc, manager, new SelfContainer(id), 3, 3);
manager.put(bloc, crafting);
}
IInventory inventory = crafting.resultInventory;
InventoryCraftResult result;
if (inventory instanceof InventoryCraftResult || inventory == null) {
result = new InventoryCraftResult();
crafting.resultInventory = result;
} else {
result = (InventoryCraftResult) inventory;
}
Container container = new CustomContainerWorkbench(id, ent.getBukkitEntity(), bloc, crafting, result);
crafting.addContainer(container);
return container;
}
use of net.minecraft.server.v1_10_R1.Container in project PublicCrafters by BananaPuncher714.
the class CustomInventoryCrafting method splitStack.
@Override
public ItemStack splitStack(int i, int j) {
ItemStack itemstack = ContainerUtil.a(items, i, j);
if (!itemstack.isEmpty()) {
for (Container container : containers) {
container.a(this);
}
}
// Update the armorstand grid
display.update();
return itemstack;
}
use of net.minecraft.server.v1_10_R1.Container 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_10_R1.Container 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_10_R1.Container in project PublicCrafters by BananaPuncher714.
the class CustomTileEntityContainerWorkbench method createMenu.
/**
* This is an ITileEntityContainer method that returns a new container for whatever tile entity
*/
@Override
public Container createMenu(int id, PlayerInventory inv, EntityHuman ent) {
CustomInventoryCrafting crafting = manager.benches.get(bloc);
if (crafting == null) {
crafting = new CustomInventoryCrafting(bloc, manager, new SelfContainer(id), 3, 3);
manager.put(bloc, crafting);
}
IInventory inventory = crafting.resultInventory;
InventoryCraftResult result;
if (inventory instanceof InventoryCraftResult || inventory == null) {
result = new InventoryCraftResult();
crafting.resultInventory = result;
} else {
result = (InventoryCraftResult) inventory;
}
Container container = new CustomContainerWorkbench(id, ent.getBukkitEntity(), bloc, crafting, result);
crafting.addContainer(container);
return container;
}
Aggregations