diff --git a/build.gradle b/build.gradle index f31ed9b6..eef237fa 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '1.13-SNAPSHOT' + id 'net.fabricmc.fabric-loom' version "${loom_version}" id 'maven-publish' } @@ -18,8 +18,7 @@ loom { dependencies { // To change the versions see the gradle.properties file minecraft "com.mojang:minecraft:${project.minecraft_version}" - mappings loom.officialMojangMappings() - modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" + implementation "net.fabricmc:fabric-loader:${project.loader_version}" // Fabric API. This is technically optional, but you probably want it anyway. //modImplementation "net.fabricmc:fabric:${project.fabric_version}" @@ -43,7 +42,7 @@ tasks.withType(JavaCompile).configureEach { it.options.encoding = "UTF-8" // Minecraft 1.20.5 upwards uses Java 21. - it.options.release = 21 + it.options.release = 25 } java { @@ -52,8 +51,8 @@ java { // If you remove this line, sources will not be generated. withSourcesJar() - sourceCompatibility = JavaVersion.VERSION_21 - targetCompatibility = JavaVersion.VERSION_21 + sourceCompatibility = JavaVersion.VERSION_25 + targetCompatibility = JavaVersion.VERSION_25 } jar { diff --git a/gradle.properties b/gradle.properties index 67c498cf..f9cf694a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,10 +7,9 @@ org.gradle.configuration-cache=false # Fabric Properties # check https://fabricmc.net/develop/ - minecraft_version=1.21.11 - loader_version=0.18.2 - jsr305_version=3.0.2 - fabric_version=0.134.0+1.21.9 + minecraft_version=26.1-snapshot-1 + loader_version=0.18.3 + loom_version=1.14-SNAPSHOT # Mod Properties mod_version = 1.4.193 @@ -21,7 +20,7 @@ org.gradle.configuration-cache=false # The Curseforge versions "names" or ids for the main branch (comma separated: 1.16.4,1.16.5) # This is needed because CF uses too vague names for prereleases and release candidates # Can also be the version ID directly coming from https://minecraft.curseforge.com/api/game/versions?token=[API_TOKEN] - release-curse-versions = Minecraft 1.21:1.21.11 + release-curse-versions = Minecraft 26:26.1-Snapshot # Whether or not to build another branch on release release-extra-branch = false # The name of the second branch to release diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 2e111328..23449a2b 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/src/main/java/carpet/helpers/FertilizableCoral.java b/src/main/java/carpet/helpers/FertilizableCoral.java index 3f7447fe..a588ec31 100644 --- a/src/main/java/carpet/helpers/FertilizableCoral.java +++ b/src/main/java/carpet/helpers/FertilizableCoral.java @@ -75,10 +75,10 @@ public interface FertilizableCoral extends BonemealableBlock { } else { - if (worldIn.random.nextInt(10) == 0) + if (worldIn.getRandom().nextInt(10) == 0) { - BlockPos randomPos = pos.offset(worldIn.random.nextInt(16) - 8, worldIn.random.nextInt(8), worldIn.random.nextInt(16) - 8); - if (coralBlocks.contains(worldIn.getBlockState(randomPos).getBlockHolder())) + BlockPos randomPos = pos.offset(worldIn.getRandom().nextInt(16) - 8, worldIn.getRandom().nextInt(8), worldIn.getRandom().nextInt(16) - 8); + if (worldIn.getBlockState(randomPos).is(BlockTags.CORAL_BLOCKS)) { worldIn.setBlock(randomPos, Blocks.WET_SPONGE.defaultBlockState(), Block.UPDATE_ALL); } diff --git a/src/main/java/carpet/helpers/OptimizedExplosion.java b/src/main/java/carpet/helpers/OptimizedExplosion.java index f35b6027..8bb7c9b5 100644 --- a/src/main/java/carpet/helpers/OptimizedExplosion.java +++ b/src/main/java/carpet/helpers/OptimizedExplosion.java @@ -133,7 +133,7 @@ public class OptimizedExplosion double xInc = (xRel / len) * 0.3; double yInc = (yRel / len) * 0.3; double zInc = (zRel / len) * 0.3; - float rand = eAccess.getLevel().random.nextFloat(); + float rand = eAccess.getLevel().getRandom().nextFloat(); float sizeRand = (CarpetSettings.tntRandomRange >= 0 ? (float) CarpetSettings.tntRandomRange : rand); float size = eAccess.getRadius() * (0.7F + sizeRand * 0.6F); Vec3 vec3 = eAccess.getCenter(); diff --git a/src/main/java/carpet/helpers/ParticleDisplay.java b/src/main/java/carpet/helpers/ParticleDisplay.java index d6f2ee61..75fb25bd 100644 --- a/src/main/java/carpet/helpers/ParticleDisplay.java +++ b/src/main/java/carpet/helpers/ParticleDisplay.java @@ -22,7 +22,7 @@ public class ParticleDisplay Vec3 incvec = to.subtract(from).normalize();// multiply(50/sqrt(lineLengthSq)); for (Vec3 delta = new Vec3(0.0,0.0,0.0); delta.lengthSqr() < lineLengthSq; - delta = delta.add(incvec.scale(player.level().random.nextFloat()))) + delta = delta.add(incvec.scale(player.level().getRandom().nextFloat()))) { player.level().sendParticles( player, diff --git a/src/main/java/carpet/mixins/AbstractContainerMenu_scarpetMixin.java b/src/main/java/carpet/mixins/AbstractContainerMenu_scarpetMixin.java index a1a55eec..fc322904 100644 --- a/src/main/java/carpet/mixins/AbstractContainerMenu_scarpetMixin.java +++ b/src/main/java/carpet/mixins/AbstractContainerMenu_scarpetMixin.java @@ -14,7 +14,7 @@ import java.util.List; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.AbstractContainerMenu; -import net.minecraft.world.inventory.ClickType; +import net.minecraft.world.inventory.ContainerInput; import net.minecraft.world.inventory.ContainerListener; import net.minecraft.world.inventory.DataSlot; @@ -26,7 +26,7 @@ public abstract class AbstractContainerMenu_scarpetMixin implements AbstractCont @Shadow @Final private List dataSlots; @Inject(method = "doClick", at = @At("HEAD"), cancellable = true) - private void callSlotClickListener(int slotIndex, int button, ClickType actionType, Player player, CallbackInfo ci) { + private void callSlotClickListener(int slotIndex, int button, ContainerInput actionType, Player player, CallbackInfo ci) { if(!(player instanceof ServerPlayer serverPlayerEntity)) return; for(ContainerListener screenHandlerListener : this.containerListeners) { if(screenHandlerListener instanceof ScreenValue.ScarpetScreenHandlerListener scarpetScreenHandlerListener) { diff --git a/src/main/java/carpet/mixins/ArmorStand_scarpetMarkerMixin.java b/src/main/java/carpet/mixins/ArmorStand_scarpetMarkerMixin.java index 89339e32..531c3d27 100644 --- a/src/main/java/carpet/mixins/ArmorStand_scarpetMarkerMixin.java +++ b/src/main/java/carpet/mixins/ArmorStand_scarpetMarkerMixin.java @@ -31,10 +31,10 @@ public abstract class ArmorStand_scarpetMarkerMixin extends LivingEntity { if (!level().isClientSide()) { - if (getTags().contains(Auxiliary.MARKER_STRING)) + if (entityTags().contains(Auxiliary.MARKER_STRING)) { String prefix = Auxiliary.MARKER_STRING+"_"; - Optional owner = getTags().stream().filter(s -> s.startsWith(prefix)).findFirst(); + Optional owner = entityTags().stream().filter(s -> s.startsWith(prefix)).findFirst(); if (owner.isPresent()) { String hostName = StringUtils.removeStart(owner.get(),prefix); diff --git a/src/main/java/carpet/mixins/PieceGeneratorSupplier_plopMixin.java b/src/main/java/carpet/mixins/PieceGeneratorSupplier_plopMixin.java index 79c4e1c8..0cd7363a 100644 --- a/src/main/java/carpet/mixins/PieceGeneratorSupplier_plopMixin.java +++ b/src/main/java/carpet/mixins/PieceGeneratorSupplier_plopMixin.java @@ -11,7 +11,7 @@ import net.minecraft.world.level.levelgen.structure.pieces.PieceGeneratorSupplie @Mixin(PieceGeneratorSupplier.class) public interface PieceGeneratorSupplier_plopMixin { - @Redirect(method = "method_39845", at = @At( + @Redirect(method = "lambda$simple$0", at = @At( value = "INVOKE", target = "java/util/function/Predicate.test(Ljava/lang/Object;)Z" ), remap = false) diff --git a/src/main/java/carpet/mixins/ReloadCommand_reloadAppsMixin.java b/src/main/java/carpet/mixins/ReloadCommand_reloadAppsMixin.java index f27abc7a..b5f12673 100644 --- a/src/main/java/carpet/mixins/ReloadCommand_reloadAppsMixin.java +++ b/src/main/java/carpet/mixins/ReloadCommand_reloadAppsMixin.java @@ -11,9 +11,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(ReloadCommand.class) public class ReloadCommand_reloadAppsMixin { - //method_13530(Lcom/mojang/brigadier/context/CommandContext;)I + //lambda$register$0(Lcom/mojang/brigadier/context/CommandContext;)I // internal of register. - @Inject(method = "method_13530", at = @At("TAIL"), remap = false) + @Inject(method = "lambda$register$0", at = @At("TAIL"), remap = false) private static void onReload(CommandContext context, CallbackInfoReturnable cir) { // can't fetch here the reference to the server diff --git a/src/main/java/carpet/mixins/ServerGamePacketListenerImpl_scarpetEventsMixin.java b/src/main/java/carpet/mixins/ServerGamePacketListenerImpl_scarpetEventsMixin.java index 792124b2..42e0f3e0 100644 --- a/src/main/java/carpet/mixins/ServerGamePacketListenerImpl_scarpetEventsMixin.java +++ b/src/main/java/carpet/mixins/ServerGamePacketListenerImpl_scarpetEventsMixin.java @@ -280,7 +280,7 @@ public class ServerGamePacketListenerImpl_scarpetEventsMixin } } - @Inject(method = "method_44356", // lambda of handleChatCommand(ServerboundChatCommandPacket) + @Inject(method = "lambda$handleChatCommand$0", // lambda of handleChatCommand(ServerboundChatCommandPacket) at = @At(value = "HEAD") ) private void onChatCommandMessage(ServerboundChatCommandPacket serverboundChatCommandPacket, CallbackInfo ci) { diff --git a/src/main/java/carpet/mixins/SummonCommand_lightningMixin.java b/src/main/java/carpet/mixins/SummonCommand_lightningMixin.java index 093eabe5..ca0785c2 100644 --- a/src/main/java/carpet/mixins/SummonCommand_lightningMixin.java +++ b/src/main/java/carpet/mixins/SummonCommand_lightningMixin.java @@ -30,7 +30,7 @@ public class SummonCommand_lightningMixin ServerLevel world = (ServerLevel) entity.level(); BlockPos at = entity.blockPosition(); DifficultyInstance localDifficulty_1 = world.getCurrentDifficultyAt(at); - boolean boolean_2 = world.getGameRules().get(GameRules.SPAWN_MOBS) && world.random.nextDouble() < (double)localDifficulty_1.getEffectiveDifficulty() * 0.01D; + boolean boolean_2 = world.getGameRules().get(GameRules.SPAWN_MOBS) && world.getRandom().nextDouble() < (double)localDifficulty_1.getEffectiveDifficulty() * 0.01D; if (boolean_2) { SkeletonHorse skeletonHorseEntity_1 = EntityType.SKELETON_HORSE.create(world, EntitySpawnReason.EVENT); skeletonHorseEntity_1.setTrap(true); diff --git a/src/main/java/carpet/script/CarpetScriptHost.java b/src/main/java/carpet/script/CarpetScriptHost.java index fecd5767..26f7dc7b 100644 --- a/src/main/java/carpet/script/CarpetScriptHost.java +++ b/src/main/java/carpet/script/CarpetScriptHost.java @@ -961,7 +961,7 @@ public class CarpetScriptHost extends ScriptHost String markerName = Auxiliary.MARKER_STRING + "_" + ((getName() == null) ? "" : getName()); for (ServerLevel world : scriptServer().server.getAllLevels()) { - for (Entity e : world.getEntities(EntityType.ARMOR_STAND, (as) -> as.getTags().contains(markerName))) + for (Entity e : world.getEntities(EntityType.ARMOR_STAND, (as) -> as.entityTags().contains(markerName))) { e.discard(); } @@ -1109,7 +1109,7 @@ public class CarpetScriptHost extends ScriptHost } /** - *

Creates a {@link Component} using {@link Messenger} that has the locals in the {@code line} snippet with a hover over + *

Creates a {@link Component} using {@link carper.utils.Messenger} that has the locals in the {@code line} snippet with a hover over * tooltip with the value of the local at that location

* * @param line The line to find references to locals on diff --git a/src/main/java/carpet/script/api/Auxiliary.java b/src/main/java/carpet/script/api/Auxiliary.java index 94969b00..1e9b5e54 100644 --- a/src/main/java/carpet/script/api/Auxiliary.java +++ b/src/main/java/carpet/script/api/Auxiliary.java @@ -434,7 +434,7 @@ public class Auxiliary CarpetContext cc = (CarpetContext) c; int total = 0; String markerName = MARKER_STRING + "_" + ((cc.host.getName() == null) ? "" : cc.host.getName()); - for (Entity e : cc.level().getEntities(EntityType.ARMOR_STAND, as -> as.getTags().contains(markerName))) + for (Entity e : cc.level().getEntities(EntityType.ARMOR_STAND, as -> as.entityTags().contains(markerName))) { total++; e.discard(); diff --git a/src/main/java/carpet/script/api/WorldAccess.java b/src/main/java/carpet/script/api/WorldAccess.java index 403641b5..0b7bd103 100644 --- a/src/main/java/carpet/script/api/WorldAccess.java +++ b/src/main/java/carpet/script/api/WorldAccess.java @@ -703,7 +703,7 @@ public class WorldAccess booleanStateTest(c, "block_tick", lv, (s, p) -> { ServerLevel w = ((CarpetContext) c).level(); - s.randomTick(w, p, w.random); + s.randomTick(w, p, w.getRandom()); return true; })); @@ -713,7 +713,7 @@ public class WorldAccess ServerLevel w = ((CarpetContext) c).level(); if (s.isRandomlyTicking() || s.getFluidState().isRandomlyTicking()) { - s.randomTick(w, p, w.random); + s.randomTick(w, p, w.getRandom()); } return true; })); diff --git a/src/main/java/carpet/script/utils/FeatureGenerator.java b/src/main/java/carpet/script/utils/FeatureGenerator.java index bb11c01c..f6186fd3 100644 --- a/src/main/java/carpet/script/utils/FeatureGenerator.java +++ b/src/main/java/carpet/script/utils/FeatureGenerator.java @@ -89,7 +89,7 @@ public class FeatureGenerator checks.set(true); try { - return configuredFeature.place(world, world.getChunkSource().getGenerator(), world.random, pos); + return configuredFeature.place(world, world.getChunkSource().getGenerator(), world.getRandom(), pos); } finally { @@ -115,7 +115,7 @@ public class FeatureGenerator checks.set(true); try { - return configuredStandard.place(world, world.getChunkSource().getGenerator(), world.random, pos); + return configuredStandard.place(world, world.getChunkSource().getGenerator(), world.getRandom(), pos); } finally { @@ -161,7 +161,7 @@ public class FeatureGenerator checks.set(true); try { - return feature.place(w, w.getChunkSource().getGenerator(), w.random, p); + return feature.place(w, w.getChunkSource().getGenerator(), w.getRandom(), p); } finally { diff --git a/src/main/java/carpet/script/utils/ShapeDispatcher.java b/src/main/java/carpet/script/utils/ShapeDispatcher.java index ac2d5a7e..50899787 100644 --- a/src/main/java/carpet/script/utils/ShapeDispatcher.java +++ b/src/main/java/carpet/script/utils/ShapeDispatcher.java @@ -2245,7 +2245,7 @@ public class ShapeDispatcher int pcount = 0; if (distance < 100) { - RandomSource rand = players.get(0).level().random; + RandomSource rand = players.get(0).level().getRandom(); int particles = (int) (distance / density) + 1; Vec3 towards = to.subtract(from); for (int i = 0; i < particles; i++) diff --git a/src/main/java/carpet/script/utils/ShapesRenderer.java b/src/main/java/carpet/script/utils/ShapesRenderer.java index bfbc1937..fe50ccac 100644 --- a/src/main/java/carpet/script/utils/ShapesRenderer.java +++ b/src/main/java/carpet/script/utils/ShapesRenderer.java @@ -26,7 +26,6 @@ import net.minecraft.client.gui.Font; import net.minecraft.client.gui.components.debug.DebugScreenEntries; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.renderer.ItemBlockRenderTypes; -import net.minecraft.client.renderer.LightTexture; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderBuffers; import net.minecraft.client.renderer.rendertype.RenderType; @@ -43,6 +42,7 @@ import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; import net.minecraft.resources.ResourceKey; +import net.minecraft.util.LightCoordsUtil; import net.minecraft.util.Mth; import net.minecraft.util.ProblemReporter; import net.minecraft.world.item.ItemDisplayContext; @@ -406,7 +406,7 @@ public class ShapesRenderer int light = 0; if (client.level != null) { - light = LightTexture.pack( + light = LightCoordsUtil.pack( shape.blockLight < 0 ? client.level.getBrightness(LightLayer.BLOCK, blockPos) : shape.blockLight, shape.skyLight < 0 ? client.level.getBrightness(LightLayer.SKY, blockPos) : shape.skyLight ); diff --git a/src/main/java/carpet/script/value/EntityValue.java b/src/main/java/carpet/script/value/EntityValue.java index 7065edc3..13f90b6c 100644 --- a/src/main/java/carpet/script/value/EntityValue.java +++ b/src/main/java/carpet/script/value/EntityValue.java @@ -92,6 +92,7 @@ import java.util.Set; import java.util.UUID; import java.util.function.BiConsumer; import java.util.function.BiFunction; +import java.util.function.BiPredicate; import java.util.function.Predicate; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -297,6 +298,8 @@ public class EntityValue extends Value public static final Map byName = new HashMap<>() {{ List> allTypes = BuiltInRegistries.ENTITY_TYPE.stream().toList(); + BiPredicate, TagKey>> is = (type, tag) -> type.builtInRegistryHolder().is(tag); + // nonliving types Set> projectiles = Set.of( EntityType.ARROW, EntityType.DRAGON_FIREBALL, EntityType.FIREWORK_ROCKET, @@ -340,7 +343,7 @@ public class EntityValue extends Value ); Set> living = allTypes.stream().filter(et -> - !deads.contains(et) && !projectiles.contains(et) && !minecarts.contains(et) && !et.is(EntityTypeTags.BOAT) + !deads.contains(et) && !projectiles.contains(et) && !minecarts.contains(et) && !is.test(et, EntityTypeTags.BOAT) ).collect(Collectors.toSet()); Set> regular = allTypes.stream().filter(et -> @@ -364,17 +367,17 @@ public class EntityValue extends Value // combat groups - put("arthropod", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (e.getType().is(EntityTypeTags.ARTHROPOD) && e.isAlive()), allTypes.stream().filter(arthropods::contains))); - put("!arthropod", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (!e.getType().is(EntityTypeTags.ARTHROPOD) && e.isAlive()), allTypes.stream().filter(et -> !arthropods.contains(et) && living.contains(et)))); + put("arthropod", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (is.test(e.getType(), EntityTypeTags.ARTHROPOD) && e.isAlive()), allTypes.stream().filter(arthropods::contains))); + put("!arthropod", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (!is.test(e.getType(), EntityTypeTags.ARTHROPOD) && e.isAlive()), allTypes.stream().filter(et -> !arthropods.contains(et) && living.contains(et)))); - put("undead", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (e.getType().is(EntityTypeTags.UNDEAD) && e.isAlive()), allTypes.stream().filter(undeads::contains))); - put("!undead", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (!e.getType().is(EntityTypeTags.UNDEAD) && e.isAlive()), allTypes.stream().filter(et -> !undeads.contains(et) && living.contains(et)))); + put("undead", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (is.test(e.getType(), EntityTypeTags.UNDEAD) && e.isAlive()), allTypes.stream().filter(undeads::contains))); + put("!undead", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (!is.test(e.getType(), EntityTypeTags.UNDEAD) && e.isAlive()), allTypes.stream().filter(et -> !undeads.contains(et) && living.contains(et)))); - put("aquatic", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (e.getType().is(EntityTypeTags.AQUATIC) && e.isAlive()), allTypes.stream().filter(aquatique::contains))); - put("!aquatic", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (!e.getType().is(EntityTypeTags.AQUATIC) && e.isAlive()), allTypes.stream().filter(et -> !aquatique.contains(et) && living.contains(et)))); + put("aquatic", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (is.test(e.getType(), EntityTypeTags.AQUATIC) && e.isAlive()), allTypes.stream().filter(aquatique::contains))); + put("!aquatic", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (!is.test(e.getType(), EntityTypeTags.AQUATIC) && e.isAlive()), allTypes.stream().filter(et -> !aquatique.contains(et) && living.contains(et)))); - put("illager", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (e.getType().is(EntityTypeTags.ILLAGER) && e.isAlive()), allTypes.stream().filter(illagers::contains))); - put("!illager", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (!e.getType().is(EntityTypeTags.ILLAGER) && e.isAlive()), allTypes.stream().filter(et -> !illagers.contains(et) && living.contains(et)))); + put("illager", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (is.test(e.getType(), EntityTypeTags.ILLAGER) && e.isAlive()), allTypes.stream().filter(illagers::contains))); + put("!illager", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (!is.test(e.getType(), EntityTypeTags.ILLAGER) && e.isAlive()), allTypes.stream().filter(et -> !illagers.contains(et) && living.contains(et)))); put("regular", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> { EntityType type = e.getType(); @@ -457,17 +460,17 @@ public class EntityValue extends Value put("mount", (e, a) -> (e.getVehicle() != null) ? new EntityValue(e.getVehicle()) : Value.NULL); put("unmountable", (e, a) -> BooleanValue.of(Vanilla.Entity_isPermanentVehicle(e))); // deprecated - put("tags", (e, a) -> ListValue.wrap(e.getTags().stream().map(StringValue::new))); + put("tags", (e, a) -> ListValue.wrap(e.entityTags().stream().map(StringValue::new))); - put("scoreboard_tags", (e, a) -> ListValue.wrap(e.getTags().stream().map(StringValue::new))); + put("scoreboard_tags", (e, a) -> ListValue.wrap(e.entityTags().stream().map(StringValue::new))); put("entity_tags", (e, a) -> { EntityType type = e.getType(); return ListValue.wrap(e.level().getServer().registryAccess().lookupOrThrow(Registries.ENTITY_TYPE).getTags().filter(entry -> entry.stream().anyMatch(h -> h.value() == type)).map(entry -> ValueConversions.of(entry))); }); // deprecated - put("has_tag", (e, a) -> BooleanValue.of(e.getTags().contains(a.getString()))); + put("has_tag", (e, a) -> BooleanValue.of(e.entityTags().contains(a.getString()))); - put("has_scoreboard_tag", (e, a) -> BooleanValue.of(e.getTags().contains(a.getString()))); + put("has_scoreboard_tag", (e, a) -> BooleanValue.of(e.entityTags().contains(a.getString()))); put("has_entity_tag", (e, a) -> { Optional>> tag = e.level().getServer().registryAccess().lookupOrThrow(Registries.ENTITY_TYPE).get(TagKey.create(Registries.ENTITY_TYPE, InputValidator.identifierOf(a.getString()))); if (tag.isEmpty()) diff --git a/src/main/java/carpet/script/value/NBTSerializableValue.java b/src/main/java/carpet/script/value/NBTSerializableValue.java index 279a40a9..a46d8981 100644 --- a/src/main/java/carpet/script/value/NBTSerializableValue.java +++ b/src/main/java/carpet/script/value/NBTSerializableValue.java @@ -211,7 +211,7 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa ); if (!list.isEmpty()) { - inventory = (Container) list.get(world.random.nextInt(list.size())); + inventory = (Container) list.get(world.getRandom().nextInt(list.size())); } } diff --git a/src/main/java/carpet/script/value/ScreenValue.java b/src/main/java/carpet/script/value/ScreenValue.java index 3f82f3be..75400726 100644 --- a/src/main/java/carpet/script/value/ScreenValue.java +++ b/src/main/java/carpet/script/value/ScreenValue.java @@ -39,7 +39,7 @@ import net.minecraft.world.inventory.BlastFurnaceMenu; import net.minecraft.world.inventory.BrewingStandMenu; import net.minecraft.world.inventory.CartographyTableMenu; import net.minecraft.world.inventory.ChestMenu; -import net.minecraft.world.inventory.ClickType; +import net.minecraft.world.inventory.ContainerInput; import net.minecraft.world.inventory.ContainerListener; import net.minecraft.world.inventory.CraftingMenu; import net.minecraft.world.inventory.DataSlot; @@ -226,11 +226,11 @@ public class ScreenValue extends Value screenHandler.addSlotListener(new ScarpetScreenHandlerListener() { @Override - public boolean onSlotClick(ServerPlayer player, ClickType actionType, int slot, int button) + public boolean onSlotClick(ServerPlayer player, ContainerInput actionType, int slot, int button) { Map data = new HashMap<>(); data.put(StringValue.of("slot"), slot == AbstractContainerMenu.SLOT_CLICKED_OUTSIDE ? Value.NULL : NumericValue.of(slot)); - if (actionType == ClickType.QUICK_CRAFT) + if (actionType == ContainerInput.QUICK_CRAFT) { data.put(StringValue.of("quick_craft_stage"), NumericValue.of(AbstractContainerMenu.getQuickcraftHeader(button))); button = AbstractContainerMenu.getQuickcraftType(button); @@ -402,7 +402,7 @@ public class ScreenValue extends Value public interface ScarpetScreenHandlerListener extends ContainerListener { - boolean onSlotClick(ServerPlayer player, ClickType actionType, int slot, int button); + boolean onSlotClick(ServerPlayer player, ContainerInput actionType, int slot, int button); boolean onButtonClick(ServerPlayer player, int button); @@ -546,7 +546,7 @@ public class ScreenValue extends Value } } - private static String actionTypeToString(ClickType actionType) + private static String actionTypeToString(ContainerInput actionType) { return switch (actionType) { diff --git a/src/main/java/carpet/utils/PerimeterDiagnostics.java b/src/main/java/carpet/utils/PerimeterDiagnostics.java index 74b4f263..07e3ec82 100644 --- a/src/main/java/carpet/utils/PerimeterDiagnostics.java +++ b/src/main/java/carpet/utils/PerimeterDiagnostics.java @@ -182,7 +182,7 @@ public class PerimeterDiagnostics { el.snapTo(pos.getX() + 0.5F, pos.getY(), pos.getZ()+0.5F, 0.0F, 0.0F); return el.checkSpawnObstruction(worldServer) && el.checkSpawnRules(worldServer, EntitySpawnReason.NATURAL) && - SpawnPlacements.checkSpawnRules(el.getType(),(ServerLevel)el.level(), EntitySpawnReason.NATURAL, el.blockPosition(), el.level().random) && + SpawnPlacements.checkSpawnRules(el.getType(),(ServerLevel)el.level(), EntitySpawnReason.NATURAL, el.blockPosition(), el.level().getRandom()) && worldServer.noCollision(el); // check collision rules once they stop fiddling with them after 1.14.1 } return false; diff --git a/src/main/java/carpet/utils/SpawnReporter.java b/src/main/java/carpet/utils/SpawnReporter.java index 60bf38aa..8651e34c 100644 --- a/src/main/java/carpet/utils/SpawnReporter.java +++ b/src/main/java/carpet/utils/SpawnReporter.java @@ -439,14 +439,14 @@ public class SpawnReporter { float f = x + 0.5F; float f1 = z + 0.5F; - mob.snapTo(f, y, f1, worldIn.random.nextFloat() * 360.0F, 0.0F); + mob.snapTo(f, y, f1, worldIn.getRandom().nextFloat() * 360.0F, 0.0F); fits = worldIn.noCollision(mob); EntityType etype = mob.getType(); for (int i = 0; i < 20; ++i) { if ( - SpawnPlacements.checkSpawnRules(etype,worldIn, EntitySpawnReason.NATURAL, pos, worldIn.random) && + SpawnPlacements.checkSpawnRules(etype,worldIn, EntitySpawnReason.NATURAL, pos, worldIn.getRandom()) && SpawnPlacements.isSpawnPositionOk(etype, worldIn, pos) && mob.checkSpawnRules(worldIn, EntitySpawnReason.NATURAL) // && mob.canSpawn(worldIn) // entity collisions // mostly - except ocelots diff --git a/src/main/resources/carpet.accesswidener b/src/main/resources/carpet.accesswidener index 23c54edf..ef933dbe 100644 --- a/src/main/resources/carpet.accesswidener +++ b/src/main/resources/carpet.accesswidener @@ -1,4 +1,4 @@ -accessWidener v1 named +accessWidener v1 official accessible class net/minecraft/server/level/ChunkMap$DistanceManager accessible class net/minecraft/server/level/ThreadedLevelLightEngine$TaskType