Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gaia arena check to api #4299

Open
wants to merge 3 commits into
base: 1.19.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Xplat/src/main/java/vazkii/botania/api/BotaniaAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import net.minecraft.world.level.block.Block;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -220,4 +221,12 @@ default void sparkleFX(Level world, double x, double y, double z, float r, float
default void registerCorporeaNodeDetector(CorporeaNodeDetector detector) {

}

default boolean isInGaiaArena(Entity entity) {
justliliandev marked this conversation as resolved.
Show resolved Hide resolved
return isInGaiaArena(entity.getLevel(), entity.getX(), entity.getY(), entity.getZ());
}

default boolean isInGaiaArena(@Nullable Level level, double x, double y, double z) {
justliliandev marked this conversation as resolved.
Show resolved Hide resolved
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.brew.Brew;
Expand All @@ -37,6 +40,7 @@
import vazkii.botania.client.fx.SparkleParticleData;
import vazkii.botania.common.block.flower.functional.SolegnoliaBlockEntity;
import vazkii.botania.common.brew.BotaniaBrews;
import vazkii.botania.common.entity.GaiaGuardianEntity;
import vazkii.botania.common.handler.BotaniaSounds;
import vazkii.botania.common.handler.EquipmentHandler;
import vazkii.botania.common.handler.ManaNetworkHandler;
Expand Down Expand Up @@ -176,7 +180,7 @@ public Ingredient getRepairIngredient() {

@Override
public int apiVersion() {
return 2;
return 3;
}

@Override
Expand Down Expand Up @@ -266,4 +270,17 @@ public void registerPaintableBlock(ResourceLocation block, Function<DyeColor, Bl
public void registerCorporeaNodeDetector(CorporeaNodeDetector detector) {
CorporeaNodeDetectors.register(detector);
}

@Override
public boolean isInGaiaArena(@Nullable Level level, double x, double y, double z) {
if (level == null)
return false;
List<GaiaGuardianEntity> guardianEntities = level.getEntitiesOfClass(GaiaGuardianEntity.class, AABB.ofSize(new Vec3(x, y, z), GaiaGuardianEntity.ARENA_RANGE * 4, GaiaGuardianEntity.ARENA_RANGE * 4, GaiaGuardianEntity.ARENA_RANGE * 4));
for (GaiaGuardianEntity guardianEntity : guardianEntities) {
if (guardianEntity.getSource().distToCenterSqr(x, y, z) < GaiaGuardianEntity.ARENA_RANGE * GaiaGuardianEntity.ARENA_RANGE) {
return true;
}
}
return false;
}
}