Search in sources :

Example 1 with SimpleNamedScreenHandlerFactory

use of net.minecraft.screen.SimpleNamedScreenHandlerFactory in project bewitchment by MoriyaShiine.

the class BaphometEntity method interactMob.

@Override
protected ActionResult interactMob(PlayerEntity player, Hand hand) {
    if (!world.isClient && isAlive() && getTarget() == null && BewitchmentAPI.isPledged(player, getPledgeID())) {
        if (BWUtil.rejectTrades(this)) {
            return ActionResult.FAIL;
        }
        if (getCurrentCustomer() == null) {
            setCurrentCustomer(player);
        }
        if (!getOffers().isEmpty()) {
            SyncContractsPacket.send(player);
            player.openHandledScreen(new SimpleNamedScreenHandlerFactory((id, playerInventory, customer) -> new BaphometScreenHandler(id, this), getDisplayName())).ifPresent(syncId -> SyncDemonTradesPacket.send(player, this, syncId));
        } else {
            setCurrentCustomer(null);
        }
    }
    return ActionResult.success(world.isClient);
}
Also used : SimpleNamedScreenHandlerFactory(net.minecraft.screen.SimpleNamedScreenHandlerFactory) BaphometScreenHandler(moriyashiine.bewitchment.client.screen.BaphometScreenHandler)

Example 2 with SimpleNamedScreenHandlerFactory

use of net.minecraft.screen.SimpleNamedScreenHandlerFactory in project bewitchment by MoriyaShiine.

the class DemonEntity method interactMob.

@Override
protected ActionResult interactMob(PlayerEntity player, Hand hand) {
    if (!world.isClient && isAlive() && getTarget() == null) {
        if (BWUtil.rejectTrades(this)) {
            return ActionResult.FAIL;
        }
        if (getCurrentCustomer() == null) {
            setCurrentCustomer(player);
        }
        if (!getOffers().isEmpty()) {
            SyncContractsPacket.send(player);
            player.openHandledScreen(new SimpleNamedScreenHandlerFactory((id, playerInventory, customer) -> new DemonScreenHandler(id, this), getDisplayName())).ifPresent(syncId -> SyncDemonTradesPacket.send(player, this, syncId));
        } else {
            setCurrentCustomer(null);
        }
    }
    return ActionResult.success(world.isClient);
}
Also used : SimpleNamedScreenHandlerFactory(net.minecraft.screen.SimpleNamedScreenHandlerFactory) DemonScreenHandler(moriyashiine.bewitchment.client.screen.DemonScreenHandler)

Example 3 with SimpleNamedScreenHandlerFactory

use of net.minecraft.screen.SimpleNamedScreenHandlerFactory in project KahzerxMod by otakucraft.

the class SpoofExtension method spoofInv.

public int spoofInv(ServerCommandSource source, String playerE) throws CommandSyntaxException {
    int invSize = 54;
    int hotBarSize = 9;
    int hotBarStartPos = 27;
    int invStartPos = 9;
    Inventory inventory = new SimpleInventory(invSize);
    ServerPlayerEntity player = source.getPlayer();
    ServerPlayerEntity player2 = source.getServer().getPlayerManager().getPlayer(playerE);
    assert player2 != null;
    for (int i = 0; i < player2.getInventory().main.size(); i++) {
        if (i < hotBarSize) {
            inventory.setStack(i + hotBarStartPos, player2.getInventory().main.get(i));
        } else {
            inventory.setStack(i - invStartPos, player2.getInventory().main.get(i));
        }
    }
    int armorSlotStartPos = 45;
    for (int j = 0; j < player2.getInventory().armor.size(); j++) {
        inventory.setStack(j + armorSlotStartPos, player2.getInventory().armor.get(j));
    }
    int offHandSlotPos = 36;
    inventory.setStack(offHandSlotPos, player2.getInventory().offHand.get(0));
    ScreenHandlerListener listener = new ScreenHandlerListener() {

        @Override
        public void onSlotUpdate(ScreenHandler handler, int slotId, ItemStack stack) {
        // source.getServer().getPlayerManager().saveAllPlayerData();
        }

        @Override
        public void onPropertyUpdate(ScreenHandler handler, int property, int value) {
        }
    };
    player.openHandledScreen(new SimpleNamedScreenHandlerFactory((i, playerInventory, playerEntity) -> {
        GenericContainerScreenHandler invCont = GenericContainerScreenHandler.createGeneric9x6(i, playerInventory, inventory);
        invCont.addListener(listener);
        return invCont;
    }, new LiteralText(String.format("%s stop hax >:(", player.getName().getString()))));
    return 1;
}
Also used : ExtensionSettings(com.kahzerx.kahzerxmod.extensions.ExtensionSettings) LiteralText(net.minecraft.text.LiteralText) ScreenHandler(net.minecraft.screen.ScreenHandler) CommandDispatcher(com.mojang.brigadier.CommandDispatcher) GenericExtension(com.kahzerx.kahzerxmod.extensions.GenericExtension) EnderChestInventory(net.minecraft.inventory.EnderChestInventory) ServerCommandSource(net.minecraft.server.command.ServerCommandSource) ScreenHandlerListener(net.minecraft.screen.ScreenHandlerListener) SimpleNamedScreenHandlerFactory(net.minecraft.screen.SimpleNamedScreenHandlerFactory) Extensions(com.kahzerx.kahzerxmod.Extensions) Inventory(net.minecraft.inventory.Inventory) SimpleInventory(net.minecraft.inventory.SimpleInventory) ItemStack(net.minecraft.item.ItemStack) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) CommandSyntaxException(com.mojang.brigadier.exceptions.CommandSyntaxException) GenericContainerScreenHandler(net.minecraft.screen.GenericContainerScreenHandler) ScreenHandlerListener(net.minecraft.screen.ScreenHandlerListener) GenericContainerScreenHandler(net.minecraft.screen.GenericContainerScreenHandler) SimpleNamedScreenHandlerFactory(net.minecraft.screen.SimpleNamedScreenHandlerFactory) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) ScreenHandler(net.minecraft.screen.ScreenHandler) GenericContainerScreenHandler(net.minecraft.screen.GenericContainerScreenHandler) ItemStack(net.minecraft.item.ItemStack) EnderChestInventory(net.minecraft.inventory.EnderChestInventory) Inventory(net.minecraft.inventory.Inventory) SimpleInventory(net.minecraft.inventory.SimpleInventory) SimpleInventory(net.minecraft.inventory.SimpleInventory) LiteralText(net.minecraft.text.LiteralText)

Example 4 with SimpleNamedScreenHandlerFactory

use of net.minecraft.screen.SimpleNamedScreenHandlerFactory in project KahzerxMod by otakucraft.

the class SpoofExtension method spoofEC.

public int spoofEC(ServerCommandSource source, String playerE) throws CommandSyntaxException {
    ServerPlayerEntity player = source.getPlayer();
    ServerPlayerEntity player2 = source.getServer().getPlayerManager().getPlayer(playerE);
    if (player2 != null) {
        EnderChestInventory enderChestInventory = player2.getEnderChestInventory();
        // Generar la pantalla de enderChest.
        player.openHandledScreen(new SimpleNamedScreenHandlerFactory((i, playerInventory, playerEntity) -> GenericContainerScreenHandler.createGeneric9x3(i, playerInventory, enderChestInventory), new LiteralText(String.format("%s stop hax >:(", player.getName().getString()))));
    } else {
        source.sendFeedback(new LiteralText("player offline"), false);
    }
    return 1;
}
Also used : ExtensionSettings(com.kahzerx.kahzerxmod.extensions.ExtensionSettings) LiteralText(net.minecraft.text.LiteralText) ScreenHandler(net.minecraft.screen.ScreenHandler) CommandDispatcher(com.mojang.brigadier.CommandDispatcher) GenericExtension(com.kahzerx.kahzerxmod.extensions.GenericExtension) EnderChestInventory(net.minecraft.inventory.EnderChestInventory) ServerCommandSource(net.minecraft.server.command.ServerCommandSource) ScreenHandlerListener(net.minecraft.screen.ScreenHandlerListener) SimpleNamedScreenHandlerFactory(net.minecraft.screen.SimpleNamedScreenHandlerFactory) Extensions(com.kahzerx.kahzerxmod.Extensions) Inventory(net.minecraft.inventory.Inventory) SimpleInventory(net.minecraft.inventory.SimpleInventory) ItemStack(net.minecraft.item.ItemStack) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) CommandSyntaxException(com.mojang.brigadier.exceptions.CommandSyntaxException) GenericContainerScreenHandler(net.minecraft.screen.GenericContainerScreenHandler) SimpleNamedScreenHandlerFactory(net.minecraft.screen.SimpleNamedScreenHandlerFactory) EnderChestInventory(net.minecraft.inventory.EnderChestInventory) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) LiteralText(net.minecraft.text.LiteralText)

Aggregations

SimpleNamedScreenHandlerFactory (net.minecraft.screen.SimpleNamedScreenHandlerFactory)4 Extensions (com.kahzerx.kahzerxmod.Extensions)2 ExtensionSettings (com.kahzerx.kahzerxmod.extensions.ExtensionSettings)2 GenericExtension (com.kahzerx.kahzerxmod.extensions.GenericExtension)2 CommandDispatcher (com.mojang.brigadier.CommandDispatcher)2 CommandSyntaxException (com.mojang.brigadier.exceptions.CommandSyntaxException)2 EnderChestInventory (net.minecraft.inventory.EnderChestInventory)2 Inventory (net.minecraft.inventory.Inventory)2 SimpleInventory (net.minecraft.inventory.SimpleInventory)2 ItemStack (net.minecraft.item.ItemStack)2 GenericContainerScreenHandler (net.minecraft.screen.GenericContainerScreenHandler)2 ScreenHandler (net.minecraft.screen.ScreenHandler)2 ScreenHandlerListener (net.minecraft.screen.ScreenHandlerListener)2 ServerCommandSource (net.minecraft.server.command.ServerCommandSource)2 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)2 LiteralText (net.minecraft.text.LiteralText)2 BaphometScreenHandler (moriyashiine.bewitchment.client.screen.BaphometScreenHandler)1 DemonScreenHandler (moriyashiine.bewitchment.client.screen.DemonScreenHandler)1