Attempt to fix title updating

This commit is contained in:
fullwall 2022-07-22 00:43:40 +08:00
parent 8c004fc122
commit b89073d4c1
79 changed files with 152 additions and 233 deletions

View File

@ -4,11 +4,13 @@ import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
@ -17,6 +19,7 @@ import com.google.common.base.Splitter;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import net.citizensnpcs.api.CitizensAPI;
import net.citizensnpcs.api.gui.CitizensInventoryClickEvent;
import net.citizensnpcs.api.gui.ClickHandler;
import net.citizensnpcs.api.gui.InputMenus;
@ -69,10 +72,15 @@ public class ShopTrait extends Trait {
public void display(Player sender) {
if (viewPermission != null && !sender.hasPermission(viewPermission))
return;
if (pages.size() == 0) {
sender.sendMessage(ChatColor.RED + "Empty shop");
return;
}
InventoryMenu.createSelfRegistered(new NPCShopViewer(this)).present(sender);
}
public void displayEditor(Player sender) {
InventoryMenu.createSelfRegistered(new NPCShopEditor(this)).present(sender);
InventoryMenu.createSelfRegistered(new NPCShopSettings(this)).present(sender);
}
public String getName() {
@ -174,7 +182,7 @@ public class ShopTrait extends Trait {
edit.setItemStack(new ItemStack(Material.BOOK), "Edit page");
edit.addClickHandler(evt -> {
evt.setCancelled(true);
ctx.getMenu().transition(new NPCShopPageEditor(shop.getOrCreatePage(page)));
ctx.getMenu().transition(new NPCShopPageSettings(shop.getOrCreatePage(page)));
});
}
@ -190,44 +198,6 @@ public class ShopTrait extends Trait {
}
}
@Menu(title = "NPC Shop Editor", type = InventoryType.HOPPER, dimensions = { 0, 5 })
public static class NPCShopEditor extends InventoryMenuPage {
private MenuContext ctx;
private final NPCShop shop;
public NPCShopEditor(NPCShop shop) {
this.shop = shop;
}
@Override
public void initialise(MenuContext ctx) {
this.ctx = ctx;
}
@MenuSlot(slot = { 0, 4 }, material = Material.FEATHER, amount = 1, lore = "Edit shop items")
public void onEditItems(InventoryMenuSlot slot, CitizensInventoryClickEvent event) {
event.setCancelled(true);
ctx.getMenu().transition(new NPCShopContentsEditor(shop));
}
@MenuSlot(slot = { 0, 2 }, material = Material.OAK_SIGN, amount = 1, lore = "Edit shop permission")
public void onPermissionChange(InventoryMenuSlot slot, CitizensInventoryClickEvent event) {
event.setCancelled(true);
ctx.getMenu().transition(InputMenus.stringSetter(shop::getRequiredPermission, shop::setPermission));
}
@MenuSlot(slot = { 0, 0 }, material = Material.BOOK, amount = 1, lore = "Edit shop type")
public void onShopTypeChange(InventoryMenuSlot slot, CitizensInventoryClickEvent event) {
event.setCancelled(true);
ctx.getMenu().transition(InputMenus.<ShopType> picker("Edit shop type", chosen -> {
shop.type = chosen.getValue();
}, Choice.<ShopType> of(ShopType.BUY, Material.DIAMOND, "Players buy items", shop.type == ShopType.BUY),
Choice.of(ShopType.SELL, Material.EMERALD, "Players sell items", shop.type == ShopType.SELL),
Choice.of(ShopType.COMMAND, Material.ENDER_EYE, "Clicks trigger commands only",
shop.type == ShopType.COMMAND)));
}
}
public static class NPCShopItem implements Cloneable {
@Persist
private List<NPCShopAction> cost;
@ -244,6 +214,9 @@ public class ShopTrait extends Trait {
throw new Error(e);
}
}
public void onClick(NPCShop shop, CitizensInventoryClickEvent event) {
}
}
@Menu(title = "NPC Shop Item Editor", type = InventoryType.CHEST, dimensions = { 5, 9 })
@ -319,14 +292,14 @@ public class ShopTrait extends Trait {
}
}
@MenuSlot(slot = { 4, 4 }, material = Material.TNT, amount = 1, lore = "<c>Remove")
@MenuSlot(slot = { 4, 4 }, material = Material.TNT, amount = 1, title = "<c>Remove")
public void onRemove(InventoryMenuSlot slot, CitizensInventoryClickEvent event) {
original = null;
event.setCancelled(true);
ctx.getMenu().transitionBack();
}
@MenuSlot(slot = { 4, 5 }, material = Material.EMERALD_BLOCK, amount = 1, lore = "Save")
@MenuSlot(slot = { 4, 5 }, material = Material.EMERALD_BLOCK, amount = 1, title = "Save")
public void onSave(InventoryMenuSlot slot, CitizensInventoryClickEvent event) {
original = modified;
event.setCancelled(true);
@ -360,11 +333,11 @@ public class ShopTrait extends Trait {
}
@Menu(title = "NPC Shop Page Editor", type = InventoryType.CHEST, dimensions = { 5, 9 })
public static class NPCShopPageEditor extends InventoryMenuPage {
public static class NPCShopPageSettings extends InventoryMenuPage {
private MenuContext ctx;
private final NPCShopPage page;
public NPCShopPageEditor(NPCShopPage page) {
public NPCShopPageSettings(NPCShopPage page) {
this.page = page;
}
@ -390,6 +363,121 @@ public class ShopTrait extends Trait {
}
}
@Menu(title = "NPC Shop Editor", type = InventoryType.CHEST, dimensions = { 1, 9 })
public static class NPCShopSettings extends InventoryMenuPage {
private MenuContext ctx;
private final NPCShop shop;
public NPCShopSettings(NPCShop shop) {
this.shop = shop;
}
@Override
public void initialise(MenuContext ctx) {
this.ctx = ctx;
}
@MenuSlot(slot = { 0, 4 }, material = Material.FEATHER, amount = 1, title = "Edit shop items")
public void onEditItems(InventoryMenuSlot slot, CitizensInventoryClickEvent event) {
event.setCancelled(true);
ctx.getMenu().transition(new NPCShopContentsEditor(shop));
}
@MenuSlot(slot = { 0, 8 }, material = Material.CHEST, amount = 1, title = "Open shop")
public void onOpenShop(InventoryMenuSlot slot, CitizensInventoryClickEvent event) {
event.setCancelled(true);
ctx.getMenu().transition(new NPCShopViewer(shop));
}
@MenuSlot(slot = { 0, 2 }, material = Material.OAK_SIGN, amount = 1, title = "Edit shop permission")
public void onPermissionChange(InventoryMenuSlot slot, CitizensInventoryClickEvent event) {
event.setCancelled(true);
ctx.getMenu().transition(InputMenus.stringSetter(shop::getRequiredPermission, shop::setPermission));
}
@MenuSlot(slot = { 0, 6 }, material = Material.NAME_TAG, amount = 1, title = "Edit shop title")
public void onSetTitle(InventoryMenuSlot slot, CitizensInventoryClickEvent event) {
event.setCancelled(true);
ctx.getMenu().transition(InputMenus.stringSetter(() -> shop.title, newTitle -> {
shop.title = newTitle.isEmpty() ? null : newTitle;
}));
}
@MenuSlot(slot = { 0, 0 }, material = Material.BOOK, amount = 1, title = "Edit shop type")
public void onShopTypeChange(InventoryMenuSlot slot, CitizensInventoryClickEvent event) {
event.setCancelled(true);
ctx.getMenu().transition(InputMenus.<ShopType> picker("Edit shop type", chosen -> {
shop.type = chosen.getValue();
}, Choice.<ShopType> of(ShopType.BUY, Material.DIAMOND, "Players buy items", shop.type == ShopType.BUY),
Choice.of(ShopType.SELL, Material.EMERALD, "Players sell items", shop.type == ShopType.SELL),
Choice.of(ShopType.COMMAND, Material.ENDER_EYE, "Clicks trigger commands only",
shop.type == ShopType.COMMAND)));
}
}
@Menu(title = "Shop", type = InventoryType.CHEST, dimensions = { 5, 9 })
public static class NPCShopViewer extends InventoryMenuPage {
private MenuContext ctx;
private int currentPage = 0;
private final NPCShop shop;
public NPCShopViewer(NPCShop shop) {
this.shop = shop;
}
public void changePage(int newPage) {
this.currentPage = newPage;
NPCShopPage page = shop.pages.get(currentPage);
if (page.title != null && !page.title.isEmpty()) {
Bukkit.getScheduler().runTaskLater(CitizensAPI.getPlugin(), () -> {
ctx.setTitle(page.title);
}, 1);
}
for (int i = 0; i < ctx.getInventory().getSize(); i++) {
ctx.getSlot(i).clear();
NPCShopItem item = page.getItem(i);
if (item == null)
continue;
ctx.getSlot(i).setItemStack(item.display);
ctx.getSlot(i).addClickHandler(evt -> {
evt.setCancelled(true);
item.onClick(shop, evt);
});
}
InventoryMenuSlot prev = ctx.getSlot(4 * 9 + 3);
InventoryMenuSlot next = ctx.getSlot(4 * 9 + 5);
prev.clear();
if (currentPage > 0) {
prev.setItemStack(new ItemStack(Material.FEATHER, 1), "Previous page (" + (currentPage) + ")");
prev.addClickHandler(evt -> {
evt.setCancelled(true);
changePage(currentPage - 1);
});
}
next.clear();
if (currentPage + 1 < shop.pages.size()) {
next.setItemStack(new ItemStack(Material.FEATHER, 1), "Next page (" + (currentPage + 1) + ")");
next.addClickHandler(evt -> {
evt.setCancelled(true);
changePage(currentPage + 1);
});
}
}
@Override
public Inventory createInventory(String title) {
return Bukkit.createInventory(null, 45, shop.title == null || shop.title.isEmpty() ? "Shop" : shop.title);
}
@Override
public void initialise(MenuContext ctx) {
this.ctx = ctx;
changePage(currentPage);
}
}
public enum ShopType {
BUY,
COMMAND,

View File

@ -63,9 +63,6 @@ public class AllayController extends MobEntityController {
public EntityAllayNPC(EntityType<? extends Allay> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -66,7 +66,6 @@ public class AxolotlController extends MobEntityController {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
this.oldMoveController = this.moveControl;
this.moveControl = new MoveControl(this);
this.getAttribute(Attributes.MOVEMENT_SPEED)

View File

@ -52,7 +52,6 @@ public class BatController extends MobEntityController {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
setFlying(false);
}
}

View File

@ -51,9 +51,6 @@ public class BeeController extends MobEntityController {
public EntityBeeNPC(EntityType<? extends Bee> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -51,9 +51,6 @@ public class BlazeController extends MobEntityController {
public EntityBlazeNPC(EntityType<? extends Blaze> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -56,9 +56,6 @@ public class CatController extends MobEntityController {
public EntityCatNPC(EntityType<? extends Cat> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -54,9 +54,6 @@ public class CaveSpiderController extends MobEntityController {
public EntityCaveSpiderNPC(EntityType<? extends CaveSpider> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -56,9 +56,6 @@ public class ChickenController extends MobEntityController {
public EntityChickenNPC(EntityType<? extends Chicken> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -63,7 +63,6 @@ public class CodController extends MobEntityController {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
this.oldMoveController = this.moveControl;
this.moveControl = new MoveControl(this);
}

View File

@ -61,9 +61,6 @@ public class CowController extends MobEntityController {
public EntityCowNPC(EntityType<? extends Cow> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -56,9 +56,6 @@ public class CreeperController extends MobEntityController {
public EntityCreeperNPC(EntityType<? extends Creeper> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -58,7 +58,6 @@ public class DolphinController extends MobEntityController {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
this.oldMoveController = this.moveControl;
this.moveControl = new MoveControl(this);
this.getAttribute(Attributes.MOVEMENT_SPEED)

View File

@ -54,9 +54,6 @@ public class DrownedController extends MobEntityController {
public EntityDrownedNPC(EntityType<? extends Drowned> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -52,9 +52,6 @@ public class EnderDragonController extends MobEntityController {
public EntityEnderDragonNPC(EntityType<? extends EnderDragon> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -57,9 +57,6 @@ public class EndermanController extends MobEntityController {
public EntityEndermanNPC(EntityType<? extends EnderMan> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -54,9 +54,6 @@ public class EndermiteController extends MobEntityController {
public EntityEndermiteNPC(EntityType<? extends Endermite> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -48,9 +48,6 @@ public class EvokerController extends MobEntityController {
public EntityEvokerNPC(EntityType<? extends Evoker> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -50,9 +50,6 @@ public class FoxController extends MobEntityController {
public EntityFoxNPC(EntityType<? extends Fox> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -51,7 +51,6 @@ public class FrogController extends MobEntityController {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
croakAnimationState.start(1);
}
}

View File

@ -45,9 +45,6 @@ public class GhastController extends MobEntityController {
public EntityGhastNPC(EntityType<? extends Ghast> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override
@ -69,7 +66,7 @@ public class GhastController extends MobEntityController {
public void customServerAiStep() {
if (npc != null) {
npc.update();
NMSImpl.updateMinecraftAIState(npc, this);
NMSImpl.updateMinecraftAIState(npc, this);
}
super.customServerAiStep();
}

View File

@ -48,9 +48,6 @@ public class GiantController extends MobEntityController {
public EntityGiantNPC(EntityType<? extends Giant> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -48,9 +48,6 @@ public class GlowSquidController extends MobEntityController {
public EntityGlowSquidNPC(EntityType<? extends GlowSquid> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -50,9 +50,6 @@ public class GoatController extends MobEntityController {
public EntityGoatNPC(EntityType<? extends Goat> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -48,9 +48,6 @@ public class GuardianController extends MobEntityController {
public EntityGuardianNPC(EntityType<? extends Guardian> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -48,9 +48,6 @@ public class GuardianElderController extends MobEntityController {
public EntityGuardianElderNPC(EntityType<? extends ElderGuardian> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -64,7 +64,6 @@ public class HorseController extends MobEntityController {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
org.bukkit.entity.Horse horse = (org.bukkit.entity.Horse) getBukkitEntity();
horse.setDomestication(horse.getMaxDomestication());
baseMovementSpeed = this.getAttribute(Attributes.MOVEMENT_SPEED).getValue();

View File

@ -64,7 +64,6 @@ public class HorseDonkeyController extends MobEntityController {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
((org.bukkit.entity.Donkey) getBukkitEntity())
.setDomestication(((org.bukkit.entity.Donkey) getBukkitEntity()).getMaxDomestication());
baseMovementSpeed = this.getAttribute(Attributes.MOVEMENT_SPEED).getValue();

View File

@ -64,7 +64,6 @@ public class HorseMuleController extends MobEntityController {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
((org.bukkit.entity.Mule) getBukkitEntity())
.setDomestication(((org.bukkit.entity.Mule) getBukkitEntity()).getMaxDomestication());
baseMovementSpeed = this.getAttribute(Attributes.MOVEMENT_SPEED).getValue();

View File

@ -64,7 +64,6 @@ public class HorseSkeletonController extends MobEntityController {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
((org.bukkit.entity.SkeletonHorse) getBukkitEntity())
.setDomestication(((org.bukkit.entity.SkeletonHorse) getBukkitEntity()).getMaxDomestication());
baseMovementSpeed = this.getAttribute(Attributes.MOVEMENT_SPEED).getValue();

View File

@ -64,7 +64,6 @@ public class HorseZombieController extends MobEntityController {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
((org.bukkit.entity.ZombieHorse) getBukkitEntity())
.setDomestication(((org.bukkit.entity.ZombieHorse) getBukkitEntity()).getMaxDomestication());
baseMovementSpeed = this.getAttribute(Attributes.MOVEMENT_SPEED).getValue();

View File

@ -48,9 +48,6 @@ public class IllusionerController extends MobEntityController {
public EntityIllusionerNPC(EntityType<? extends Illusioner> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -48,9 +48,6 @@ public class IronGolemController extends MobEntityController {
public EntityIronGolemNPC(EntityType<? extends IronGolem> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -60,7 +60,6 @@ public class LlamaController extends MobEntityController {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
((org.bukkit.entity.Llama) getBukkitEntity())
.setDomestication(((org.bukkit.entity.Llama) getBukkitEntity()).getMaxDomestication());
}

View File

@ -54,7 +54,6 @@ public class MagmaCubeController extends MobEntityController {
this.npc = (CitizensNPC) npc;
if (npc != null) {
setSize(3, true);
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
this.oldMoveController = this.moveControl;
this.moveControl = new PlayerMoveControl(this);
}

View File

@ -15,6 +15,7 @@ import net.citizensnpcs.nms.v1_19_R1.util.NMSImpl;
import net.citizensnpcs.npc.AbstractEntityController;
import net.citizensnpcs.util.Util;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.level.Level;
public abstract class MobEntityController extends AbstractEntityController {
@ -30,6 +31,9 @@ public abstract class MobEntityController extends AbstractEntityController {
EntityType<?> type = NMSImpl.getEntityType(clazz);
net.minecraft.world.entity.Entity entity = createEntityFromClass(type, ((CraftWorld) at.getWorld()).getHandle(),
npc);
if (entity instanceof Mob) {
NMSImpl.clearGoals(npc, ((Mob) entity).goalSelector, ((Mob) entity).targetSelector);
}
entity.absMoveTo(at.getX(), at.getY(), at.getZ(), at.getYaw(), at.getPitch());
// entity.onGround isn't updated right away - we approximate here so

View File

@ -53,9 +53,6 @@ public class MushroomCowController extends MobEntityController {
public EntityMushroomCowNPC(EntityType<? extends MushroomCow> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -51,9 +51,6 @@ public class OcelotController extends MobEntityController {
public EntityOcelotNPC(EntityType<? extends Ocelot> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -50,9 +50,6 @@ public class PandaController extends MobEntityController {
public EntityPandaNPC(EntityType<? extends Panda> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -48,9 +48,6 @@ public class ParrotController extends MobEntityController {
public EntityParrotNPC(EntityType<? extends Parrot> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -58,7 +58,6 @@ public class PhantomController extends MobEntityController {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
setNoAi(true);
this.oldMoveController = this.moveControl;
this.oldLookController = this.lookControl;

View File

@ -51,9 +51,6 @@ public class PigController extends MobEntityController {
public EntityPigNPC(EntityType<? extends Pig> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -49,9 +49,6 @@ public class PigZombieController extends MobEntityController {
public EntityPigZombieNPC(EntityType<? extends ZombifiedPiglin> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -48,9 +48,6 @@ public class PiglinBruteController extends MobEntityController {
public EntityPiglinBruteNPC(EntityType<? extends PiglinBrute> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -48,9 +48,6 @@ public class PiglinController extends MobEntityController {
public EntityPiglinNPC(EntityType<? extends Piglin> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -50,9 +50,6 @@ public class PillagerController extends MobEntityController {
public EntityPillagerNPC(EntityType<? extends Pillager> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -47,9 +47,6 @@ public class PolarBearController extends MobEntityController {
public EntityPolarBearNPC(EntityType<? extends PolarBear> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -60,7 +60,6 @@ public class PufferFishController extends MobEntityController {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
this.oldMoveController = this.moveControl;
this.moveControl = new MoveControl(this);
}

View File

@ -52,9 +52,6 @@ public class RabbitController extends MobEntityController {
public EntityRabbitNPC(EntityType<? extends Rabbit> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -50,9 +50,6 @@ public class RavagerController extends MobEntityController {
public EntityRavagerNPC(EntityType<? extends Ravager> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -57,7 +57,6 @@ public class SalmonController extends MobEntityController {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
this.oldMoveController = this.moveControl;
this.moveControl = new MoveControl(this);
}

View File

@ -50,9 +50,6 @@ public class SheepController extends MobEntityController {
public EntitySheepNPC(EntityType<? extends Sheep> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -49,9 +49,6 @@ public class ShulkerController extends MobEntityController {
public EntityShulkerNPC(EntityType<? extends Shulker> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -48,9 +48,6 @@ public class SilverfishController extends MobEntityController {
public EntitySilverfishNPC(EntityType<? extends Silverfish> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -48,9 +48,6 @@ public class SkeletonController extends MobEntityController {
public EntitySkeletonNPC(EntityType<? extends Skeleton> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -48,9 +48,6 @@ public class SkeletonStrayController extends MobEntityController {
public EntityStrayNPC(EntityType<? extends Stray> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -48,9 +48,6 @@ public class SkeletonWitherController extends MobEntityController {
public EntitySkeletonWitherNPC(EntityType<? extends WitherSkeleton> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -54,7 +54,6 @@ public class SlimeController extends MobEntityController {
this.npc = (CitizensNPC) npc;
if (npc != null) {
setSize(3, true);
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
this.oldMoveController = this.moveControl;
this.moveControl = new PlayerMoveControl(this);
}

View File

@ -49,9 +49,6 @@ public class SnowmanController extends MobEntityController {
public EntitySnowmanNPC(EntityType<? extends SnowGolem> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -48,9 +48,6 @@ public class SpiderController extends MobEntityController {
public EntitySpiderNPC(EntityType<? extends Spider> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -48,9 +48,6 @@ public class SquidController extends MobEntityController {
public EntitySquidNPC(EntityType<? extends Squid> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -48,9 +48,6 @@ public class StriderController extends MobEntityController {
public EntityStriderNPC(EntityType<? extends Strider> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -58,7 +58,6 @@ public class TadpoleController extends MobEntityController {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
this.oldMoveController = this.moveControl;
this.moveControl = new MoveControl(this);
}

View File

@ -60,7 +60,6 @@ public class TraderLlamaController extends MobEntityController {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
((org.bukkit.entity.TraderLlama) getBukkitEntity())
.setDomestication(((org.bukkit.entity.TraderLlama) getBukkitEntity()).getMaxDomestication());
}

View File

@ -57,7 +57,6 @@ public class TropicalFishController extends MobEntityController {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
this.oldMoveController = this.moveControl;
this.moveControl = new MoveControl(this);
}

View File

@ -55,7 +55,6 @@ public class TurtleController extends MobEntityController {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
this.oldMoveController = this.moveControl;
this.oldJumpController = this.jumpControl;
this.moveControl = new MoveControl(this);

View File

@ -46,7 +46,6 @@ public class VexController extends MobEntityController {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
setNoGravity(true);
}
}

View File

@ -58,7 +58,6 @@ public class VillagerController extends MobEntityController {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
getAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(0.3);
}
}

View File

@ -50,9 +50,6 @@ public class VindicatorController extends MobEntityController {
public EntityVindicatorNPC(EntityType<? extends Vindicator> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -57,9 +57,6 @@ public class WanderingTraderController extends MobEntityController {
public EntityWanderingTraderNPC(EntityType<? extends WanderingTrader> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -48,9 +48,6 @@ public class WardenController extends MobEntityController {
public EntityWardenNPC(EntityType<? extends Warden> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -48,9 +48,6 @@ public class WitchController extends MobEntityController {
public EntityWitchNPC(EntityType<? extends Witch> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -45,9 +45,6 @@ public class WitherController extends MobEntityController {
public EntityWitherNPC(EntityType<? extends WitherBoss> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -52,9 +52,6 @@ public class WolfController extends MobEntityController {
public EntityWolfNPC(EntityType<? extends Wolf> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -48,9 +48,6 @@ public class ZoglinController extends MobEntityController {
public EntityZoglinNPC(EntityType<? extends Zoglin> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -48,9 +48,6 @@ public class ZombieController extends MobEntityController {
public EntityZombieNPC(EntityType<? extends Zombie> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -48,9 +48,6 @@ public class ZombieHuskController extends MobEntityController {
public EntityZombieHuskNPC(EntityType<? extends Husk> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -48,9 +48,6 @@ public class ZombieVillagerController extends MobEntityController {
public EntityZombieVillagerNPC(EntityType<? extends ZombieVillager> types, Level level, NPC npc) {
super(types, level);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
}
}
@Override

View File

@ -292,7 +292,6 @@ import net.minecraft.world.entity.projectile.FishingHook;
import net.minecraft.world.entity.vehicle.AbstractMinecart;
import net.minecraft.world.inventory.AnvilMenu;
import net.minecraft.world.inventory.ContainerLevelAccess;
import net.minecraft.world.inventory.InventoryMenu;
import net.minecraft.world.inventory.MenuType;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
@ -1493,7 +1492,20 @@ public class NMSImpl implements NMSBridge {
menuType = MenuType.CARTOGRAPHY_TABLE;
break;
case CHEST:
menuType = MenuType.GENERIC_9x5;
int sz = view.getTopInventory().getSize();
if (sz > 45) {
menuType = MenuType.GENERIC_9x6;
} else if (sz > 36) {
menuType = MenuType.GENERIC_9x5;
} else if (sz > 27) {
menuType = MenuType.GENERIC_9x4;
} else if (sz > 18) {
menuType = MenuType.GENERIC_9x3;
} else if (sz > 9) {
menuType = MenuType.GENERIC_9x2;
} else {
menuType = MenuType.GENERIC_9x1;
}
break;
case COMPOSTER:
break;
@ -1545,8 +1557,7 @@ public class NMSImpl implements NMSBridge {
menuType = MenuType.CRAFTING;
break;
}
InventoryMenu active = handle.inventoryMenu;
handle.connection.send(new ClientboundOpenScreenPacket(active.containerId, menuType,
handle.connection.send(new ClientboundOpenScreenPacket(handle.inventoryMenu.containerId, menuType,
MutableComponent.create(new LiteralContents(newTitle))));
player.updateInventory();
}