Skip to content

Commit

Permalink
Merge branch '1.18.2' into 1.19.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Thutmose committed Nov 7, 2022
2 parents 6e25fbf + 4b889fc commit 8ca2475
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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<Entity> 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();
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/pokecube/core/client/gui/GuiPokedex.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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()
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/pokecube/core/utils/PokemobTracker.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
23 changes: 17 additions & 6 deletions src/main/java/pokecube/legends/entity/WormholeEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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;
Expand All @@ -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));
Expand Down Expand Up @@ -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);

Expand Down
16 changes: 7 additions & 9 deletions src/main/java/pokecube/legends/spawns/WormholeSpawns.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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
Expand Down Expand Up @@ -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()
{
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"replace": false,
"values": [
"pokecube_legends:wormhole",
"minecraft:ender_dragon"
]
}

0 comments on commit 8ca2475

Please sign in to comment.