Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
37 changes: 33 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,17 @@ repositories {
maven {
url = "https://cursemaven.com"
content {
includeGroup "curse.maven"
includeGroup("curse.maven")
}
}
maven {
url = "https://maven.valkyrienskies.org"
content {
includeGroup("org.valkyrienskies")
includeGroup("org.valkyrienskies.core")
includeGroup("com.github.LlamaLad7")
includeGroup("com.github.Rubydesic")
includeGroup("org.mapstruct")
}
}
}
Expand Down Expand Up @@ -331,16 +341,16 @@ dependencies {
// DimStorage
compileOnly fg.deobf("curse.maven:dimstorage-353882:${dimstorage_version}")
compileOnly fg.deobf("curse.maven:edivadlib-638508:${edivadlib_version}")
runtimeOnly fg.deobf("curse.maven:dimstorage-353882:${dimstorage_version}")
runtimeOnly fg.deobf("curse.maven:edivadlib-638508:${edivadlib_version}")
// runtimeOnly fg.deobf("curse.maven:dimstorage-353882:${dimstorage_version}")
// runtimeOnly fg.deobf("curse.maven:edivadlib-638508:${edivadlib_version}")

//Powah
compileOnly fg.deobf("curse.maven:powah-633483:${powah_version}")
runtimeOnly fg.deobf("curse.maven:powah-633483:${powah_version}")
runtimeOnly fg.deobf("me.shedaniel.cloth:cloth-config-forge:8.2.88")
runtimeOnly fg.deobf("dev.architectury:architectury-forge:6.2.43")

// Crash utilities. Used to debug the chunky turtle. Can be uncommented if not needed
// Crash utilities. Used to debug the chunky turtle. Can be commented if not needed
runtimeOnly fg.deobf("curse.maven:crash-utilities-371813:4406293")

testImplementation "org.junit.jupiter:junit-jupiter-api:${junit_version}"
Expand All @@ -361,6 +371,25 @@ dependencies {
// Create Crafts & Additions
compileOnly fg.deobf("curse.maven:createaddition-439890:5099757")
// runtimeOnly fg.deobf("curse.maven:createaddition-439890:5099757")

// Valkyrien Skies 2
implementation("org.joml:joml:1.10.4") {
transitive = false
}
implementation("org.joml:joml-primitives:1.10.0") {
transitive = false
}
// implementation fg.deobf("org.valkyrienskies:valkyrienskies-119-common:${vs2_version}")
implementation fg.deobf("org.valkyrienskies:valkyrienskies-119-forge:${vs2_version}") {
transitive = false
}
compileOnly "org.valkyrienskies.core:api:${vs_core_version}"
compileOnly "org.valkyrienskies.core:api-game:${vs_core_version}"
compileOnly "org.valkyrienskies.core:util:${vs_core_version}"
compileOnly "org.valkyrienskies.core:impl:${vs_core_version}"
runtimeOnly fg.deobf("curse.maven:valkyrien-skies-258371:${valkyrien_skies_version}")
runtimeOnly fg.deobf("curse.maven:eureka-ships-654384:${eureka_ships_version}")
runtimeOnly fg.deobf("curse.maven:clockwork-807792:${clockwork_version}")
}


Expand Down
5 changes: 5 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ ae2additions_version=4646599
kotlinforforge_version=3.12.0
appliedmekanistics_version=4734608
dimstorage_version=3927875
valkyrien_skies_version=4994898
eureka_ships_version=5321628
clockwork_version=5171528
vs2_version=2.1.2-beta.1+a04911c932
vs_core_version=1.1.0+2a62e6a823

# Mod dependencies which are needed for other mods
# For minecolonies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@

import de.srendi.advancedperipherals.AdvancedPeripherals;
import de.srendi.advancedperipherals.common.addons.refinedstorage.RefinedStorage;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.InterModComms;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent;
import org.valkyrienskies.core.api.ships.Ship;
import org.valkyrienskies.mod.common.VSGameUtilsKt;
import top.theillusivec4.curios.api.CuriosApi;
import top.theillusivec4.curios.api.SlotResult;
import top.theillusivec4.curios.api.SlotTypeMessage;
Expand All @@ -26,6 +30,7 @@ public class APAddons {
public static final String MEKANISM_MODID = "mekanism";
public static final String AE_ADDITIONS_MODID = "ae2additions";
public static final String APP_MEKANISTICS_MODID = "appmek";
public static final String VALKYRIEN_SKIES_MODID = "valkyrienskies";

public static boolean curiosLoaded;
public static boolean refinedStorageLoaded;
Expand All @@ -34,6 +39,7 @@ public class APAddons {
public static boolean mekanismLoaded;
public static boolean aeAdditionsLoaded;
public static boolean appMekLoaded;
public static boolean vs2Loaded;

// Use static so these checks run as early as possible, so we can use them for our registries
static {
Expand All @@ -45,6 +51,7 @@ public class APAddons {
aeThingsLoaded = modList.isLoaded(AE_THINGS_MODID);
aeAdditionsLoaded = modList.isLoaded(AE_ADDITIONS_MODID);
appMekLoaded = modList.isLoaded(APP_MEKANISTICS_MODID);
vs2Loaded = modList.isLoaded(VALKYRIEN_SKIES_MODID);

if (refinedStorageLoaded)
RefinedStorage.instance = new RefinedStorage();
Expand All @@ -71,4 +78,18 @@ public static ItemStack getCurioGlasses(Player player) {

return curioSlots.get(0).stack();
}

public static boolean isBlockOnShip(Level level, BlockPos pos) {
if (!vs2Loaded) {
return false;
}
return VSGameUtilsKt.isBlockInShipyard(level, pos);
}

public static Ship getVS2Ship(Level level, BlockPos pos) {
if (!vs2Loaded) {
return null;
}
return VSGameUtilsKt.getShipObjectManagingPos(level, pos);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

public class IntegrationPeripheralProvider implements IPeripheralProvider {

private static final String[] SUPPORTED_MODS = new String[]{"botania", "create", "mekanism", "powah", "dimstorage"};
private static final String[] SUPPORTED_MODS = new String[]{"botania", "create", "mekanism", "powah", "dimstorage", "valkyrienskies"};

private static final PriorityQueue<IPeripheralIntegration> integrations = new PriorityQueue<>(Comparator.comparingInt(IPeripheralIntegration::getPriority));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

public enum SphereOperation implements IPeripheralOperation<SphereOperationContext> {
SCAN_BLOCKS(2_000, 8, 16, 0.17),
SCAN_ENTITIES(2_000, 8, 16, 0.17);
SCAN_ENTITIES(2_000, 8, 16, 0.17),
SCAN_SHIPS(2_500, 8 * 3, 16 * 10 /* common view distance */, 0.17);

private final int defaultCooldown;
private final int defaultMaxFreeRadius;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand All @@ -23,6 +24,11 @@ public interface IPeripheralOwner {

@NotNull BlockPos getPos();

@NotNull
default Vec3 getCenterPos() {
return Vec3.atCenterOf(getPos());
}

@NotNull Direction getFacing();

@NotNull FrontAndTop getOrientation();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
import org.apache.commons.lang3.NotImplementedException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -50,6 +51,14 @@ public BlockPos getPos() {
return owner.blockPosition();
}

@NotNull
@Override
public Vec3 getCenterPos() {
Entity owner = pocket.getEntity();
if (owner == null) return new Vec3(0, 0, 0);
return owner.position();
}

@NotNull
@Override
public Direction getFacing() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public final MethodResult sendFormattedMessage(@NotNull IArguments arguments) th
if (!APConfig.PERIPHERALS_CONFIG.chatBoxMultiDimensional.get() && player.getLevel().dimension() != dimension) {
continue;
}
if (CoordUtil.isInRange(getPos(), getLevel(), player, range, maxRange)) {
if (CoordUtil.isInRange(getWorldPos(), getLevel(), player, range, maxRange)) {
player.sendSystemMessage(preparedMessage);
}
}
Expand Down Expand Up @@ -272,7 +272,7 @@ public final MethodResult sendMessage(@NotNull IArguments arguments) throws LuaE
if (!APConfig.PERIPHERALS_CONFIG.chatBoxMultiDimensional.get() && player.getLevel().dimension() != dimension) {
continue;
}
if (CoordUtil.isInRange(getPos(), getLevel(), player, range, maxRange)) {
if (CoordUtil.isInRange(getWorldPos(), getLevel(), player, range, maxRange)) {
player.sendSystemMessage(preparedMessage);
}
}
Expand Down Expand Up @@ -319,7 +319,7 @@ public final MethodResult sendFormattedMessageToPlayer(@NotNull IArguments argum
return MethodResult.of(false, "NOT_SAME_DIMENSION");
}

if (CoordUtil.isInRange(getPos(), getLevel(), player, range, maxRange)) {
if (CoordUtil.isInRange(getWorldPos(), getLevel(), player, range, maxRange)) {
player.sendSystemMessage(preparedMessage);
}
return MethodResult.of(true);
Expand Down Expand Up @@ -377,7 +377,7 @@ public final MethodResult sendFormattedToastToPlayer(@NotNull IArguments argumen
return MethodResult.of(false, "NOT_SAME_DIMENSION");
}

if (CoordUtil.isInRange(getPos(), getLevel(), player, range, maxRange)) {
if (CoordUtil.isInRange(getWorldPos(), getLevel(), player, range, maxRange)) {
ToastToClientPacket packet = new ToastToClientPacket(titleComponent, preparedMessage);
APNetworking.sendTo(packet, player);
}
Expand Down Expand Up @@ -416,7 +416,7 @@ public final MethodResult sendMessageToPlayer(@NotNull IArguments arguments) thr
return MethodResult.of(false, "NOT_SAME_DIMENSION");
}

if (CoordUtil.isInRange(getPos(), getLevel(), player, range, maxRange)) {
if (CoordUtil.isInRange(getWorldPos(), getLevel(), player, range, maxRange)) {
player.sendSystemMessage(preparedMessage, false);
}
return MethodResult.of(true);
Expand Down Expand Up @@ -455,7 +455,7 @@ public final MethodResult sendToastToPlayer(@NotNull IArguments arguments) throw
return MethodResult.of(false, "NOT_SAME_DIMENSION");
}

if (CoordUtil.isInRange(getPos(), getLevel(), player, range, maxRange)) {
if (CoordUtil.isInRange(getWorldPos(), getLevel(), player, range, maxRange)) {
ToastToClientPacket packet = new ToastToClientPacket(Component.literal(title), preparedMessage);
APNetworking.sendTo(packet, player);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public enum DetectionType {

private final boolean block, entity;

private DetectionType(boolean block, boolean entity) {
DetectionType(boolean block, boolean entity) {
this.block = block;
this.entity = entity;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.api.lua.LuaFunction;
import dan200.computercraft.api.lua.MethodResult;
import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.api.pocket.IPocketAccess;
import dan200.computercraft.api.turtle.ITurtleAccess;
import dan200.computercraft.api.turtle.TurtleSide;
Expand All @@ -18,7 +17,6 @@
import de.srendi.advancedperipherals.common.util.LuaConverter;
import de.srendi.advancedperipherals.lib.peripherals.BasePeripheral;
import de.srendi.advancedperipherals.lib.peripherals.IPeripheralPlugin;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceKey;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity;
Expand All @@ -31,6 +29,7 @@
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.levelgen.WorldgenRandom;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.SleepingTimeCheckEvent;
import net.minecraftforge.eventbus.api.Event;
Expand All @@ -50,8 +49,9 @@ public class EnvironmentDetectorPeripheral extends BasePeripheral<IPeripheralOwn
protected EnvironmentDetectorPeripheral(IPeripheralOwner owner) {
super(PERIPHERAL_TYPE, owner);
owner.attachOperation(SCAN_ENTITIES);
for (Function<IPeripheralOwner, IPeripheralPlugin> plugin : PERIPHERAL_PLUGINS)
for (Function<IPeripheralOwner, IPeripheralPlugin> plugin : PERIPHERAL_PLUGINS) {
addPlugin(plugin.apply(owner));
}
}

public EnvironmentDetectorPeripheral(PeripheralBlockEntity<?> tileEntity) {
Expand Down Expand Up @@ -87,24 +87,24 @@ public boolean isEnabled() {

@LuaFunction(mainThread = true)
public final String getBiome() {
Optional<ResourceKey<Biome>> biome = getLevel().getBiome(getPos()).unwrapKey();
Optional<ResourceKey<Biome>> biome = getLevel().getBiome(this.getWorldBlockPos()).unwrapKey();
return biome.map(biomeResourceKey -> biomeResourceKey.location().toString()).orElse("unknown");
}

@LuaFunction(mainThread = true)
public final int getSkyLightLevel() {
return getLevel().getBrightness(LightLayer.SKY, getPos().offset(0, 1, 0));
return getLevel().getBrightness(LightLayer.SKY, this.getWorldBlockPos().offset(0, 1, 0));
}

@LuaFunction(mainThread = true)
public final int getBlockLightLevel() {
return getLevel().getBrightness(LightLayer.BLOCK, getPos().offset(0, 1, 0));
return getLevel().getBrightness(LightLayer.BLOCK, this.getWorldBlockPos().offset(0, 1, 0));
}

@LuaFunction(mainThread = true)
public final int getDayLightLevel() {
Level level = getLevel();
int i = level.getBrightness(LightLayer.SKY, getPos().offset(0, 1, 0)) - level.getSkyDarken();
int i = level.getBrightness(LightLayer.SKY, this.getWorldBlockPos().offset(0, 1, 0)) - level.getSkyDarken();
float f = level.getSunAngle(1.0F);
if (i > 0) {
float f1 = f < (float) Math.PI ? 0.0F : ((float) Math.PI * 2F);
Expand All @@ -122,7 +122,7 @@ public final long getTime() {

@LuaFunction(mainThread = true)
public final boolean isSlimeChunk() {
ChunkPos chunkPos = new ChunkPos(getPos());
ChunkPos chunkPos = new ChunkPos(this.getWorldBlockPos());
return WorldgenRandom.seedSlimeChunk(chunkPos.x, chunkPos.z, ((WorldGenLevel) getLevel()).getSeed(), 987234911L).nextInt(10) == 0;
}

Expand Down Expand Up @@ -196,17 +196,15 @@ public final boolean isSunny() {
}

@LuaFunction(mainThread = true)
public final MethodResult scanEntities(@NotNull IComputerAccess access, @NotNull IArguments arguments) throws LuaException {
public final MethodResult scanEntities(@NotNull IArguments arguments) throws LuaException {
int radius = arguments.getInt(0);
boolean detailed = arguments.count() > 1 ? arguments.getBoolean(1) : false;
return withOperation(SCAN_ENTITIES, new SphereOperationContext(radius), context -> {
if (radius > SCAN_ENTITIES.getMaxCostRadius())
return MethodResult.of(null, "Radius exceeds max value");
return null;
return context.getRadius() > SCAN_ENTITIES.getMaxCostRadius() ? MethodResult.of(null, "Radius exceeds max value") : null;
}, context -> {
BlockPos pos = owner.getPos();
AABB box = new AABB(pos);
List<Map<String, Object>> entities = getLevel().getEntities((Entity) null, box.inflate(radius), entity -> entity instanceof LivingEntity && entity.isAlive()).stream().map(entity -> LuaConverter.completeEntityWithPositionToLua(entity, pos, detailed)).toList();
Vec3 pos = this.getWorldPos();
AABB box = new AABB(pos, pos);
List<Map<String, Object>> entities = getLevel().getEntities((Entity) null, box.inflate(context.getRadius() + 0.5), entity -> entity instanceof LivingEntity && entity.isAlive()).stream().map(entity -> LuaConverter.completeEntityWithPositionToLua(entity, pos, detailed)).toList();
return MethodResult.of(entities);
}, null);
}
Expand Down
Loading
Loading