diff --git a/src/main/java/pokecube/core/ai/brain/sensors/InterestingMobs.java b/src/main/java/pokecube/core/ai/brain/sensors/InterestingMobs.java index f11a2a83ae..cdd045b8da 100644 --- a/src/main/java/pokecube/core/ai/brain/sensors/InterestingMobs.java +++ b/src/main/java/pokecube/core/ai/brain/sensors/InterestingMobs.java @@ -45,7 +45,8 @@ public static boolean canPokemobMate(final IPokemob pokemob) if (pokemob.getPokedexEntry().isGMax()) return false; if (!pokemob.isRoutineEnabled(AIRoutine.MATE)) return false; if (pokemob.getCombatState(CombatStates.MATEFIGHT)) return true; - if (pokemob.getCombatState(CombatStates.BATTLING) || BrainUtils.hasAttackTarget(pokemob.getEntity())) return false; + if (pokemob.getCombatState(CombatStates.BATTLING) || BrainUtils.hasAttackTarget(pokemob.getEntity())) + return false; return true; } @@ -88,7 +89,7 @@ protected void doTick(final ServerLevel worldIn, final LivingEntity entityIn) final AABB mateBox = entityIn.getBoundingBox().inflate(dh, dv, dh); final AABB checkBox = entityIn.getBoundingBox().inflate(s, s, s); final List list = worldIn.getEntitiesOfClass(Entity.class, checkBox, (hit) -> { - return hit != entityIn && hit.isAlive(); + return hit != entityIn; }); list.sort(Comparator.comparingDouble(entityIn::distanceToSqr)); final Brain brain = entityIn.getBrain(); diff --git a/src/main/java/pokecube/core/client/gui/GuiPokedex.java b/src/main/java/pokecube/core/client/gui/GuiPokedex.java index a8ac487351..ac2735e3bc 100644 --- a/src/main/java/pokecube/core/client/gui/GuiPokedex.java +++ b/src/main/java/pokecube/core/client/gui/GuiPokedex.java @@ -111,28 +111,24 @@ public void handleButton(final int button) if (button == 1) { GuiPokedex.pokedexEntry = Pokedex.getInstance().getNext(GuiPokedex.pokedexEntry, 1); - this.pokemobTextField.setValue(I18n.get(GuiPokedex.pokedexEntry.getUnlocalizedName())); this.initList(); PacketPokedex.updateWatchEntry(GuiPokedex.pokedexEntry); } else if (button == 2) { GuiPokedex.pokedexEntry = Pokedex.getInstance().getPrevious(GuiPokedex.pokedexEntry, 1); - this.pokemobTextField.setValue(I18n.get(GuiPokedex.pokedexEntry.getUnlocalizedName())); this.initList(); PacketPokedex.updateWatchEntry(GuiPokedex.pokedexEntry); } else if (button == 3) { GuiPokedex.pokedexEntry = Pokedex.getInstance().getNext(GuiPokedex.pokedexEntry, 10); - this.pokemobTextField.setValue(I18n.get(GuiPokedex.pokedexEntry.getUnlocalizedName())); this.initList(); PacketPokedex.updateWatchEntry(GuiPokedex.pokedexEntry); } else if (button == 4) { GuiPokedex.pokedexEntry = Pokedex.getInstance().getPrevious(GuiPokedex.pokedexEntry, 10); - this.pokemobTextField.setValue(I18n.get(GuiPokedex.pokedexEntry.getUnlocalizedName())); this.initList(); PacketPokedex.updateWatchEntry(GuiPokedex.pokedexEntry); } @@ -174,9 +170,11 @@ private void initList() MutableComponent page; page = TComponent.translatable("entity.pokecube." + GuiPokedex.pokedexEntry.getTrimmedName() + ".dexDesc"); + this.pokemobTextField.setValue(I18n.get(GuiPokedex.pokedexEntry.getUnlocalizedName())); var list = Lists.newArrayList(this.font.split(page, 100)); list.add(TComponent.literal("").getVisualOrderText()); - page = pokedexEntry.getDescription(this.pokemob.getCustomHolder()); + var holder = this.pokemob != null ? this.pokemob.getCustomHolder() : null; + page = pokedexEntry.getDescription(holder); list.addAll(this.font.split(page, 100)); final IClickListener listen = new IClickListener() diff --git a/src/main/java/pokecube/core/utils/PokemobTracker.java b/src/main/java/pokecube/core/utils/PokemobTracker.java index b546a55500..291656826f 100644 --- a/src/main/java/pokecube/core/utils/PokemobTracker.java +++ b/src/main/java/pokecube/core/utils/PokemobTracker.java @@ -249,9 +249,8 @@ public static int countPokemobs(final LevelAccessor world, final AABB box, final if (world instanceof Level level) key = level.dimension(); final MobEntry[] mobList = tracker.liveMobs.getOrDefault(key, new ArrayList<>()).toArray(new MobEntry[0]); int num = 0; - for (final MobEntry e : mobList) if (box.contains(e.getPos().getX(), e.getPos().getY(), e.getPos().getZ()) - && e.pokemob.getEntity().isAlive() && matches.test(e.pokemob)) - num++; + for (final MobEntry e : mobList) + if (box.contains(e.getPos().getX(), e.getPos().getY(), e.getPos().getZ()) && matches.test(e.pokemob)) num++; return num; } diff --git a/src/main/java/pokecube/legends/entity/WormholeEntity.java b/src/main/java/pokecube/legends/entity/WormholeEntity.java index fc5b9acceb..20d583790d 100644 --- a/src/main/java/pokecube/legends/entity/WormholeEntity.java +++ b/src/main/java/pokecube/legends/entity/WormholeEntity.java @@ -50,6 +50,7 @@ import pokecube.api.PokecubeAPI; import pokecube.api.entity.pokemob.IPokemob; import pokecube.api.entity.pokemob.PokemobCaps; +import pokecube.core.PokecubeCore; import pokecube.core.eventhandlers.EventsHandler; import pokecube.core.utils.EntityTools; import pokecube.legends.init.EntityInit; @@ -161,15 +162,21 @@ public void deserializeNBT(final Tag nbt) public static void onTeleport(final EntityTeleportEvent event) { - final Level world = event.getEntity().level; + Entity entity = event.getEntity(); + final Level world = entity.level; if (world.isClientSide()) return; if (!(world instanceof ServerLevel)) return; + final long lastTp = entity.getPersistentData().getLong("pokecube_legends:uwh_use") + + WormholeEntity.wormholeReUseDelay; + final long now = Tracker.instance().getTick(); + + if (now < lastTp) return; + final IWormholeWorld holes = world.getCapability(WormholeSpawns.WORMHOLES_CAP).orElse(null); if (holes == null) return; - final double chance = ItemList.is(WormholeSpawns.SPACE_WORMS, event.getEntity()) - ? WormholeSpawns.teleWormholeChanceWorms + final double chance = ItemList.is(WormholeSpawns.SPACE_WORMS, entity) ? WormholeSpawns.teleWormholeChanceWorms : WormholeSpawns.teleWormholeChanceNormal; final RandomSource rand = world.getRandom(); @@ -182,7 +189,7 @@ public static void onTeleport(final EntityTeleportEvent event) // If it is a pokemob, check if holding a location linker, if so, use // that for destination of the wormhole! - final IPokemob pokemob = PokemobCaps.getPokemobFor(event.getEntity()); + final IPokemob pokemob = PokemobCaps.getPokemobFor(entity); if (pokemob != null) { ILinkStorage link = null; @@ -194,7 +201,7 @@ public static void onTeleport(final EntityTeleportEvent event) } if (link != null) { - GlobalPos linked_pos = link.getLinkedPos(event.getEntity()); + GlobalPos linked_pos = link.getLinkedPos(entity); if (linked_pos != null) { linked_pos = GlobalPos.of(linked_pos.dimension(), linked_pos.pos().above(2)); @@ -439,12 +446,16 @@ protected void pushEntities() if (!list.isEmpty()) for (Entity entity : list) { entity = EntityTools.getCoreEntity(entity); + + // These cannot go through a wormhole. + if (ItemList.is(WormholeSpawns.SPACE_ANCHORED, entity)) continue; + final long lastTp = entity.getPersistentData().getLong("pokecube_legends:uwh_use") + WormholeEntity.wormholeReUseDelay; final long now = Tracker.instance().getTick(); final UUID uuid = entity.getUUID(); if (now < lastTp || tpd.contains(uuid)) continue; - PokecubeAPI.logDebug("Transfering {} through a wormhole!", entity); + if (PokecubeCore.getConfig().debug_misc) PokecubeAPI.logInfo("Transfering {} through a wormhole!", entity); tpd.add(uuid); entity.getPersistentData().putLong("pokecube_legends:uwh_use", now); diff --git a/src/main/java/pokecube/legends/spawns/WormholeSpawns.java b/src/main/java/pokecube/legends/spawns/WormholeSpawns.java index 5360f23277..3113219b9b 100644 --- a/src/main/java/pokecube/legends/spawns/WormholeSpawns.java +++ b/src/main/java/pokecube/legends/spawns/WormholeSpawns.java @@ -68,8 +68,7 @@ public CompoundTag serializeNBT() { final CompoundTag nbt = new CompoundTag(); final ListTag list = new ListTag(); - for (final BlockPos pos : this.getWormholes()) - list.add(NbtUtils.writeBlockPos(pos)); + for (final BlockPos pos : this.getWormholes()) list.add(NbtUtils.writeBlockPos(pos)); nbt.put("wormholes", list); return nbt; } @@ -79,8 +78,7 @@ public void deserializeNBT(final CompoundTag nbt) { this.getWormholes().clear(); final ListTag list = nbt.getList("wormholes", 10); - for (final Tag tag : list) - this.getWormholes().add(NbtUtils.readBlockPos((CompoundTag) tag)); + for (final Tag tag : list) this.getWormholes().add(NbtUtils.readBlockPos((CompoundTag) tag)); } @Override @@ -109,14 +107,15 @@ public void removeWormhole(final BlockPos pos) static WormholeSpawns INSTANCE = new WormholeSpawns(); - public static double randomWormholeChance = 0.00001; + public static double randomWormholeChance = 0.00001; public static double randomWormholeDistance = 64; - public static double randomWormholeSpacing = 128; + public static double randomWormholeSpacing = 128; public static double teleWormholeChanceNormal = 0.01; - public static double teleWormholeChanceWorms = 0.75; + public static double teleWormholeChanceWorms = 0.75; public static final ResourceLocation SPACE_WORMS = new ResourceLocation(Reference.ID, "space_worm"); + public static final ResourceLocation SPACE_ANCHORED = new ResourceLocation(Reference.ID, "space_anchored"); public static void init() { @@ -183,8 +182,7 @@ public void onTickEnd(final ServerLevel world) final BlockPos p = WormholeSpawns.getWormholePos(world, v.getPos()); final Vector3 pos = new Vector3().set(p); - for (final BlockPos p2 : holes.getWormholes()) - if (p2.closerThan(pos.getPos(), wormholeSpacing)) return; + for (final BlockPos p2 : holes.getWormholes()) if (p2.closerThan(pos.getPos(), wormholeSpacing)) return; final WormholeEntity wormhole = EntityInit.WORMHOLE.get().create(world); pos.moveEntity(wormhole); diff --git a/src/main/resources/data/pokecube_legends/tags/entity_types/space_anchored.json b/src/main/resources/data/pokecube_legends/tags/entity_types/space_anchored.json new file mode 100644 index 0000000000..c37b12eb5c --- /dev/null +++ b/src/main/resources/data/pokecube_legends/tags/entity_types/space_anchored.json @@ -0,0 +1,7 @@ +{ + "replace": false, + "values": [ + "pokecube_legends:wormhole", + "minecraft:ender_dragon" + ] +} \ No newline at end of file