use of com.minecolonies.api.inventory.container.ContainerCrafting in project minecolonies by Minecolonies.
the class TransferRecipeCraftingTeachingMessage method onExecute.
@Override
public void onExecute(final NetworkEvent.Context ctxIn, final boolean isLogicalServer) {
final PlayerEntity player = ctxIn.getSender();
if (player.containerMenu instanceof ContainerCrafting) {
final ContainerCrafting container = (ContainerCrafting) player.containerMenu;
if (complete) {
container.handleSlotClick(container.getSlot(1), itemStacks.getOrDefault(0, ItemStackUtils.EMPTY));
container.handleSlotClick(container.getSlot(2), itemStacks.getOrDefault(1, ItemStackUtils.EMPTY));
container.handleSlotClick(container.getSlot(3), itemStacks.getOrDefault(2, ItemStackUtils.EMPTY));
container.handleSlotClick(container.getSlot(4), itemStacks.getOrDefault(3, ItemStackUtils.EMPTY));
container.handleSlotClick(container.getSlot(5), itemStacks.getOrDefault(4, ItemStackUtils.EMPTY));
container.handleSlotClick(container.getSlot(6), itemStacks.getOrDefault(5, ItemStackUtils.EMPTY));
container.handleSlotClick(container.getSlot(7), itemStacks.getOrDefault(6, ItemStackUtils.EMPTY));
container.handleSlotClick(container.getSlot(8), itemStacks.getOrDefault(7, ItemStackUtils.EMPTY));
container.handleSlotClick(container.getSlot(9), itemStacks.getOrDefault(8, ItemStackUtils.EMPTY));
} else {
container.handleSlotClick(container.getSlot(1), itemStacks.getOrDefault(0, ItemStackUtils.EMPTY));
container.handleSlotClick(container.getSlot(2), itemStacks.getOrDefault(1, ItemStackUtils.EMPTY));
container.handleSlotClick(container.getSlot(3), itemStacks.getOrDefault(3, ItemStackUtils.EMPTY));
container.handleSlotClick(container.getSlot(4), itemStacks.getOrDefault(4, ItemStackUtils.EMPTY));
}
container.broadcastChanges();
} else if (player.containerMenu instanceof ContainerCraftingFurnace) {
final ContainerCraftingFurnace container = (ContainerCraftingFurnace) player.containerMenu;
container.setFurnaceInput(itemStacks.getOrDefault(0, ItemStack.EMPTY));
} else if (player.containerMenu instanceof ContainerCraftingBrewingstand) {
final ContainerCraftingBrewingstand container = (ContainerCraftingBrewingstand) player.containerMenu;
container.setInput(itemStacks.getOrDefault(0, ItemStack.EMPTY));
container.setContainer(itemStacks.getOrDefault(1, ItemStack.EMPTY));
}
}
use of com.minecolonies.api.inventory.container.ContainerCrafting in project minecolonies by Minecolonies.
the class OpenCraftingGUIMessage method onExecute.
@Override
protected void onExecute(final NetworkEvent.Context ctxIn, final boolean isLogicalServer, final IColony colony, final IBuilding building) {
final ServerPlayerEntity player = ctxIn.getSender();
if (player == null) {
return;
}
final AbstractCraftingBuildingModule module = building.getModuleMatching(AbstractCraftingBuildingModule.class, m -> m.getId().equals(id));
if (module.canLearn(ModCraftingTypes.SMELTING)) {
NetworkHooks.openGui(player, new INamedContainerProvider() {
@NotNull
@Override
public ITextComponent getDisplayName() {
return new StringTextComponent("Furnace Crafting GUI");
}
@NotNull
@Override
public Container createMenu(final int id, @NotNull final PlayerInventory inv, @NotNull final PlayerEntity player) {
return new ContainerCraftingFurnace(id, inv, building.getID(), module.getId());
}
}, buffer -> new PacketBuffer(buffer.writeBlockPos(building.getID()).writeUtf(module.getId())));
} else if (module.canLearn(ModCraftingTypes.BREWING)) {
NetworkHooks.openGui(player, new INamedContainerProvider() {
@NotNull
@Override
public ITextComponent getDisplayName() {
return new StringTextComponent("Brewing Crafting GUI");
}
@NotNull
@Override
public Container createMenu(final int id, @NotNull final PlayerInventory inv, @NotNull final PlayerEntity player) {
return new ContainerCraftingBrewingstand(id, inv, building.getID(), module.getId());
}
}, buffer -> new PacketBuffer(buffer.writeBlockPos(building.getID()).writeUtf(module.getId())));
} else {
NetworkHooks.openGui(player, new INamedContainerProvider() {
@NotNull
@Override
public ITextComponent getDisplayName() {
return new StringTextComponent("Crafting GUI");
}
@NotNull
@Override
public Container createMenu(final int id, @NotNull final PlayerInventory inv, @NotNull final PlayerEntity player) {
return new ContainerCrafting(id, inv, module.canLearn(ModCraftingTypes.LARGE_CRAFTING), building.getID(), module.getId());
}
}, buffer -> new PacketBuffer(buffer.writeBoolean(module.canLearn(ModCraftingTypes.LARGE_CRAFTING))).writeBlockPos(building.getID()).writeUtf(module.getId()));
}
}
use of com.minecolonies.api.inventory.container.ContainerCrafting in project minecolonies by ldtteam.
the class OpenCraftingGUIMessage method onExecute.
@Override
protected void onExecute(final NetworkEvent.Context ctxIn, final boolean isLogicalServer, final IColony colony, final IBuilding building) {
final ServerPlayerEntity player = ctxIn.getSender();
if (player == null) {
return;
}
final AbstractCraftingBuildingModule module = building.getModuleMatching(AbstractCraftingBuildingModule.class, m -> m.getId().equals(id));
if (module.canLearnFurnaceRecipes()) {
NetworkHooks.openGui(player, new INamedContainerProvider() {
@NotNull
@Override
public ITextComponent getDisplayName() {
return new StringTextComponent("Furnace Crafting GUI");
}
@NotNull
@Override
public Container createMenu(final int id, @NotNull final PlayerInventory inv, @NotNull final PlayerEntity player) {
return new ContainerCraftingFurnace(id, inv, building.getID(), module.getId());
}
}, buffer -> new PacketBuffer(buffer.writeBlockPos(building.getID()).writeUtf(module.getId())));
} else {
NetworkHooks.openGui(player, new INamedContainerProvider() {
@NotNull
@Override
public ITextComponent getDisplayName() {
return new StringTextComponent("Crafting GUI");
}
@NotNull
@Override
public Container createMenu(final int id, @NotNull final PlayerInventory inv, @NotNull final PlayerEntity player) {
return new ContainerCrafting(id, inv, module.canLearnLargeRecipes(), building.getID(), module.getId());
}
}, buffer -> new PacketBuffer(buffer.writeBoolean(module.canLearnLargeRecipes())).writeBlockPos(building.getID()).writeUtf(module.getId()));
}
}
use of com.minecolonies.api.inventory.container.ContainerCrafting in project minecolonies by ldtteam.
the class TransferRecipeCraftingTeachingMessage method onExecute.
@Override
public void onExecute(final NetworkEvent.Context ctxIn, final boolean isLogicalServer) {
final PlayerEntity player = ctxIn.getSender();
if (player.containerMenu instanceof ContainerCrafting) {
final ContainerCrafting container = (ContainerCrafting) player.containerMenu;
if (complete) {
container.handleSlotClick(container.getSlot(1), itemStacks.getOrDefault(0, ItemStackUtils.EMPTY));
container.handleSlotClick(container.getSlot(2), itemStacks.getOrDefault(1, ItemStackUtils.EMPTY));
container.handleSlotClick(container.getSlot(3), itemStacks.getOrDefault(2, ItemStackUtils.EMPTY));
container.handleSlotClick(container.getSlot(4), itemStacks.getOrDefault(3, ItemStackUtils.EMPTY));
container.handleSlotClick(container.getSlot(5), itemStacks.getOrDefault(4, ItemStackUtils.EMPTY));
container.handleSlotClick(container.getSlot(6), itemStacks.getOrDefault(5, ItemStackUtils.EMPTY));
container.handleSlotClick(container.getSlot(7), itemStacks.getOrDefault(6, ItemStackUtils.EMPTY));
container.handleSlotClick(container.getSlot(8), itemStacks.getOrDefault(7, ItemStackUtils.EMPTY));
container.handleSlotClick(container.getSlot(9), itemStacks.getOrDefault(8, ItemStackUtils.EMPTY));
} else {
container.handleSlotClick(container.getSlot(1), itemStacks.getOrDefault(0, ItemStackUtils.EMPTY));
container.handleSlotClick(container.getSlot(2), itemStacks.getOrDefault(1, ItemStackUtils.EMPTY));
container.handleSlotClick(container.getSlot(3), itemStacks.getOrDefault(3, ItemStackUtils.EMPTY));
container.handleSlotClick(container.getSlot(4), itemStacks.getOrDefault(4, ItemStackUtils.EMPTY));
}
container.broadcastChanges();
} else if (player.containerMenu instanceof ContainerCraftingFurnace) {
final ContainerCraftingFurnace container = (ContainerCraftingFurnace) player.containerMenu;
container.setFurnaceInput(itemStacks.getOrDefault(0, ItemStack.EMPTY));
}
}
Aggregations