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);
}
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);
}
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;
}
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;
}
Aggregations