From 941225e83b7b35ffe5461394af7d875816ef62ec Mon Sep 17 00:00:00 2001 From: sisby-folk Date: Sun, 28 Jul 2024 21:40:56 +1000 Subject: [PATCH] add and apply editorconfig, fmj templating --- .editorconfig | 19 + build.gradle | 35 +- gradle.properties | 21 +- .../net/modfest/fireblanket/Fireblanket.java | 53 +-- .../fireblanket/FireblanketClient.java | 16 +- .../modfest/fireblanket/FireblanketMixin.java | 90 ++-- .../client/BlamefulRenderCall.java | 8 +- .../fireblanket/client/ClientState.java | 3 - .../client/command/BERMaskCommand.java | 4 +- .../client/command/EntityMaskCommand.java | 12 +- .../client/render/ExtendedVertexFormat.java | 5 +- .../client/render/QuadEmitter.java | 49 ++- .../client/render/RenderLayers.java | 59 ++- .../client/render/RenderRegionRenderer.java | 10 +- .../screen/PlaceCommandBlockScreen.java | 6 +- .../command/CmdFindReplaceCommand.java | 17 +- .../fireblanket/command/CommandUtils.java | 2 +- .../fireblanket/command/DumpCommand.java | 13 +- .../fireblanket/command/RegionCommand.java | 399 +++++++++--------- .../fireblanket/compat/PolyMcAccess.java | 4 +- .../fireblanket/compat/PolyMcCompat.java | 2 +- .../fireblanket/compat/WorldEditCompat.java | 5 +- .../accessor/ClientConnectionAccessor.java | 9 +- .../ClientLoginNetworkHandlerAccessor.java | 7 +- .../accessor/ServerChunkManagerAccessor.java | 7 +- .../ServerLoginNetworkHandlerAccessor.java | 7 +- .../mixin/adventure_fix/MixinEggItem.java | 1 - .../adventure_fix/MixinFlowerPotBlock.java | 16 +- .../fireblanket/mixin/ai/MixinTemptGoal.java | 1 - .../mixin/be_sync/MixinChunkHolder.java | 26 -- .../mixin/block/MixinCommandBlock.java | 3 - .../mixin/block_format/MixinChunkSection.java | 24 +- .../client/MixinClientPlayNetworkHandler.java | 9 +- .../mixin/client/MixinRenderSystem.java | 18 +- .../client/MixinSignBlockEntityRenderer.java | 15 +- .../MixinBlockEntityRenderDispatcher.java | 1 - .../client/be_masking/MixinRebuildTask.java | 7 - .../MixinBufferBuilder.java | 14 +- .../bufferbuilder_opto/MixinVertexFormat.java | 12 +- .../entity_masking/MixinEntityRenderer.java | 25 +- .../entity_ticking/MixinArmorStandEntity.java | 1 - .../entity_ticking/MixinLivingEntity.java | 15 +- .../client/lambdamap/MixinMapRegionFile.java | 6 +- .../MixinBlockEntityRenderDispatcher.java | 14 +- .../MixinEntityRenderDispatcher.java | 13 +- .../render_regions/MixinRegionSubjects.java | 8 +- .../MixinBlockEntityRenderDispatcher.java | 11 +- .../client/timing/MixinEntityRenderer.java | 43 +- .../mixin/client/timing/MixinWorld.java | 9 +- .../client/vbo_opto/MixinShaderProgram.java | 8 +- .../client/vbo_opto/MixinVertexBuffer.java | 3 - .../entity_ticking/MixinDebugStickItem.java | 4 +- .../mixin/entity_ticking/MixinEntity.java | 36 +- .../entity_ticking/MixinMinecraftServer.java | 1 - .../create/MixinSuperGlueEntity.java | 13 +- .../footgun/MixinEntitySelectorOptions.java | 7 +- .../footgun/MixinEntitySelectorReader.java | 28 +- .../mixin/fsc/MixinClientConnection.java | 51 +-- .../mixin/fsc/MixinSizePrepender.java | 4 +- .../mixin/fsc/MixinSplitterHandler.java | 2 +- .../mixin/io_uring/MixinServerNetworkIo.java | 23 +- .../mods/create/AccessorSmartBlockEntity.java | 7 +- .../MixinMechanicalBearingBlockEntity.java | 13 +- .../mods/mythicmetals/MixinCarmotShield.java | 13 +- .../mixin/mods/pehkui/MixinScaleUtils.java | 8 +- .../pswg/MixinComplexCollisionManager.java | 11 +- .../MixinItemPickupGoal.java | 1 - .../mixin/opto/MixinEntitySelector.java | 53 ++- .../mixin/opto/MixinRecipeManager.java | 17 +- .../MixinChunkDataS2CPacket.java | 45 +- .../packet_chunk_cache/MixinWorldChunk.java | 25 +- .../MixinServerChunkManager.java | 29 +- .../mixin/serde/MixinNbtCompound.java | 71 ++-- .../zstd/MixinChunkCompressionFormat.java | 40 +- .../mixin/zstd/MixinLevelStorageSession.java | 12 +- .../mixin/zstd/MixinPersistentState.java | 26 +- .../zstd/MixinPersistentStateManager.java | 63 +-- .../mixin/zstd/MixinRegionFile.java | 14 +- .../mixinsupport/CacheableChunk.java | 8 +- .../ChunkCompressionFormatExt.java | 2 +- .../mixinsupport/FSCConnection.java | 2 +- .../mixinsupport/ForceableArgument.java | 1 + .../mixinsupport/IOUringSupport.java | 13 +- .../mixinsupport/ZestyPlayerSaveHandler.java | 44 +- .../net/modfest/fireblanket/net/BEUpdate.java | 18 +- .../net/BatchedBEUpdatePayload.java | 20 +- .../fireblanket/net/CommandBlockPacket.java | 2 +- .../modfest/fireblanket/net/ZstdDecoder.java | 11 +- .../modfest/fireblanket/net/ZstdEncoder.java | 37 +- .../util/EndlessByteBufInputStream.java | 18 +- .../util/ReassignableOutputStream.java | 4 +- .../fireblanket/world/CachedCompoundBE.java | 3 +- .../fireblanket/world/WorldLoadAppliers.java | 1 - .../world/blocks/FlatBlockstateArray.java | 1 + .../blocks/UpdateSignBlockEntityTypes.java | 6 +- .../world/entity/EntityFilters.java | 4 +- .../fireblanket/world/entity/EntityTick.java | 4 +- .../render_regions/ExplainedRenderRegion.java | 14 +- .../Long2ReferenceMultimap.java | 60 +-- .../world/render_regions/LongMultiset.java | 97 +++-- .../world/render_regions/RegionSubject.java | 8 +- .../render_regions/RegionSyncRequest.java | 239 ++++++----- .../world/render_regions/RenderRegion.java | 53 ++- .../world/render_regions/RenderRegions.java | 141 +++---- .../render_regions/RenderRegionsState.java | 19 +- .../assets/fireblanket/lang/en_us.json | 4 +- src/main/resources/fabric.mod.json | 34 +- src/main/resources/fireblanket.mixins.json | 158 +++---- 108 files changed, 1400 insertions(+), 1408 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..80aa62f --- /dev/null +++ b/.editorconfig @@ -0,0 +1,19 @@ +[*] +indent_size = 4 +indent_style = tab +tab_width = 4 + +[*.java] +ij_java_block_brace_style = end_of_line +ij_java_lambda_brace_style = end_of_line +ij_java_method_brace_style = end_of_line +ij_java_names_count_to_use_import_on_demand = 999 + +[{*.gant,*.groovy,*.gy,*.gradle}] +ij_groovy_block_brace_style = end_of_line +ij_groovy_class_brace_style = end_of_line +ij_groovy_lambda_brace_style = end_of_line +ij_groovy_method_brace_style = end_of_line + +[{*.har,*.json,*.png.mcmeta,mcmod.info,pack.mcmeta}] +ij_json_array_wrapping = split_into_lines diff --git a/build.gradle b/build.gradle index 68172f6..8d8d7c3 100644 --- a/build.gradle +++ b/build.gradle @@ -6,8 +6,7 @@ plugins { } version = "$project.baseVersion+$project.branch" -archivesBaseName = "fireblanket" -group = "net.modfest" +archivesBaseName = project.archivesName repositories { maven { url "https://api.modrinth.com/maven" } @@ -29,25 +28,33 @@ dependencies { modImplementation libs.nettyIoUringClasses modImplementation variantOf(libs.nettyIoUringNative) { classifier "linux-x86_64" } modImplementation libs.zstd - + modImplementation libs.worldeditCore modImplementation libs.worldeditFabric - + shade(libs.nettyIoUringClasses) { transitive = false } shade(variantOf(libs.nettyIoUringNative) { classifier "linux-x86_64" }) { transitive = false } shade(libs.zstd) { transitive = false } } processResources { - final Map map = [ - "version": version.toString(), - "mc" : libs.versions.mc.get(), - "fl" : libs.versions.fl.get(), - "fapi" : libs.versions.fapi.get() + final Map meta = [ + version : version, + modId : modId, + modName : modName, + modDescription: modDescription, + homepage : homepage, + issues : issues, + sources : sources, + license : license, + authors : authors.split(", ").join("\",\n \""), + contributors : contributors.split(", ").join("\",\n \""), + mc : libs.versions.mc.get(), + fl : libs.versions.fl.get(), + fapi : libs.versions.fapi.get() ] - - inputs.properties(map) - filesMatching("*.mod.json") { expand(map) } + inputs.properties meta + filesMatching("fabric.mod.json") { expand meta } } tasks.withType(JavaCompile).configureEach { @@ -75,9 +82,9 @@ java { jar { from("LICENSE") { - rename { "${it}_${project.base.archivesName.get()}"} + rename { "${it}_${project.base.archivesName.get()}" } } - + configurations.shade.resolve().each { from(zipTree(it)) { exclude 'META-INF/MANIFEST.MF' diff --git a/gradle.properties b/gradle.properties index 2f95772..c5c37d5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,11 +1,26 @@ -# Gradle Properties +# Gradle org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 org.gradle.caching=true org.gradle.parallel=true org.gradle.caching.debug=false org.gradle.configureondemand=true -# Enable advanced multi-module optimizations (share tiny-remaper instance between projects) + +# Loom fabric.loom.multiProjectOptimisation=true -# Mod Properties + +# Mod Metadata +archivesName=fireblanket +group=net.modfest +modId=fireblanket +modName=Fireblanket +modDescription=Performance, bugfixes, and utilities for ModFest events. +authors=jaskarth, unascribed +contributors=Patbox, IThundxr +homepage=https://modrinth.com/mod/fireblanket +issues=https://github.com/modfest/fireblanket/issues +sources=https://github.com/modfest/fireblanket +license=AGPL-3.0-or-later + +# Mod Version baseVersion = 0.5.4 branch = 1.21 diff --git a/src/main/java/net/modfest/fireblanket/Fireblanket.java b/src/main/java/net/modfest/fireblanket/Fireblanket.java index 9ccc6e8..967962f 100644 --- a/src/main/java/net/modfest/fireblanket/Fireblanket.java +++ b/src/main/java/net/modfest/fireblanket/Fireblanket.java @@ -63,18 +63,19 @@ public class Fireblanket implements ModInitializer { public static final Identifier REGIONS_UPDATE = Identifier.of("fireblanket", "regions_update"); public static final Logger LOGGER = LoggerFactory.getLogger("Fireblanket"); - - public record QueuedPacket(ClientConnection conn, Packet packet, PacketCallbacks listener) {} - + + public record QueuedPacket(ClientConnection conn, Packet packet, PacketCallbacks listener) { + } + private static final AtomicInteger nextQueue = new AtomicInteger(); - + @SuppressWarnings("unchecked") public static final LinkedBlockingQueue[] PACKET_QUEUES = new LinkedBlockingQueue[4]; - + public static boolean CAN_USE_ZSTD = false; - + public static final ChunkTicketType KEEP_LOADED = ChunkTicketType.create("fireblanket:keep_loaded", ChunkTicketType.FORCED.getArgumentComparator()); - + @Override public void onInitialize() { CommandRegistrationCallback.EVENT.register((dispatcher, access, environment) -> { @@ -83,7 +84,7 @@ public void onInitialize() { RegionCommand.init(base, access); CmdFindReplaceCommand.init(base, access); dispatcher.register(CommandManager.literal("fb") - .redirect(dispatcher.register(base))); + .redirect(dispatcher.register(base))); }); for (Block block : Registries.BLOCK) { @@ -102,7 +103,7 @@ public void onInitialize() { EntityFilters.parse(types); } } - + for (int i = 0; i < PACKET_QUEUES.length; i++) { LinkedBlockingQueue q = new LinkedBlockingQueue<>(); PACKET_QUEUES[i] = q; @@ -110,16 +111,16 @@ public void onInitialize() { while (true) { try { QueuedPacket p = q.take(); - ((ClientConnectionAccessor)p.conn()).fireblanket$sendImmediately(p.packet(), p.listener(), true); + ((ClientConnectionAccessor) p.conn()).fireblanket$sendImmediately(p.packet(), p.listener(), true); } catch (Throwable t) { LOGGER.error("Exception in packet thread", t); } } - }, "Fireblanket async packet send thread #"+(i+1)); + }, "Fireblanket async packet send thread #" + (i + 1)); thread.setDaemon(true); thread.start(); } - + try { // TODO: ZSTD compression does not work with 1.20.2+ packet handling // Native.load(); @@ -143,26 +144,26 @@ public void onInitialize() { } }); } - + ServerLoginNetworking.registerGlobalReceiver(FULL_STREAM_COMPRESSION, (server, handler, understood, buf, synchronizer, responseSender) -> { if (understood) { - ((FSCConnection)((ServerLoginNetworkHandlerAccessor)handler).fireblanket$getConnection()).fireblanket$enableFullStreamCompression(); + ((FSCConnection) ((ServerLoginNetworkHandlerAccessor) handler).fireblanket$getConnection()).fireblanket$enableFullStreamCompression(); } }); - + if (FabricLoader.getInstance().isModLoaded("polymc")) { PolyMcCompat.init(); } - + ServerWorldEvents.LOAD.register((server, world) -> { if (System.getProperty("fireblanket.loadRadius") != null) { if (!world.getRegistryKey().getValue().toString().equals("minecraft:overworld")) return; int radius = Integer.getInteger("fireblanket.loadRadius"); - int min = (int)Math.floor(-radius/16); - int max = (int)Math.ceil(radius/16); - int count = (max-min)*(max-min); - ChunkTicketManager mgr = ((ServerChunkManagerAccessor)world.getChunkManager()).fireblanket$getTicketManager(); - LOGGER.info("Forcing "+count+" chunks to stay loaded (but not ticking)..."); + int min = (int) Math.floor(-radius / 16); + int max = (int) Math.ceil(radius / 16); + int count = (max - min) * (max - min); + ChunkTicketManager mgr = ((ServerChunkManagerAccessor) world.getChunkManager()).fireblanket$getTicketManager(); + LOGGER.info("Forcing " + count + " chunks to stay loaded (but not ticking)..."); int done = 0; long lastReport = System.nanoTime(); Stopwatch sw = Stopwatch.createStarted(); @@ -174,20 +175,20 @@ public void onInitialize() { // one above FULL; out of range, but not so far to unload mgr.addTicketWithLevel(KEEP_LOADED, pos, 34, pos); done++; - if (System.nanoTime()-lastReport > 1_000_000_000) { + if (System.nanoTime() - lastReport > 1_000_000_000) { lastReport = System.nanoTime(); - LOGGER.info(done+"/"+count+" loaded ("+((done*100)/count)+"%)..."); + LOGGER.info(done + "/" + count + " loaded (" + ((done * 100) / count) + "%)..."); } } } - LOGGER.info("Done after "+sw); + LOGGER.info("Done after " + sw); } }); - + ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> { fullRegionSync(handler.player.getServerWorld(), sender::sendPacket); }); - + ServerEntityWorldChangeEvents.AFTER_PLAYER_CHANGE_WORLD.register((player, origin, destination) -> { fullRegionSync(player.getServerWorld(), player.networkHandler::sendPacket); }); diff --git a/src/main/java/net/modfest/fireblanket/FireblanketClient.java b/src/main/java/net/modfest/fireblanket/FireblanketClient.java index f9f901f..8c778f2 100644 --- a/src/main/java/net/modfest/fireblanket/FireblanketClient.java +++ b/src/main/java/net/modfest/fireblanket/FireblanketClient.java @@ -32,9 +32,9 @@ import net.modfest.fireblanket.world.render_regions.RenderRegions; public class FireblanketClient implements ClientModInitializer { - + public static final RenderRegions renderRegions = new RenderRegions(); - + @Override public void onInitializeClient() { ClientCommandRegistrationCallback.EVENT.register((dispatcher, access) -> { @@ -49,12 +49,12 @@ public void onInitializeClient() { base.then(mask); } dispatcher.register(ClientCommandManager.literal("fbc") - .redirect(dispatcher.register(base))); + .redirect(dispatcher.register(base))); }); ClientLoginNetworking.registerGlobalReceiver(Fireblanket.FULL_STREAM_COMPRESSION, (client, handler, buf, listenerAdder) -> { if (Fireblanket.CAN_USE_ZSTD) { - ((FSCConnection)((ClientLoginNetworkHandlerAccessor)handler).fireblanket$getConnection()).fireblanket$enableFullStreamCompression(); + ((FSCConnection) ((ClientLoginNetworkHandlerAccessor) handler).fireblanket$getConnection()).fireblanket$enableFullStreamCompression(); return CompletableFuture.completedFuture(PacketByteBufs.empty()); } else { return CompletableFuture.completedFuture(null); @@ -79,11 +79,9 @@ public void onInitializeClient() { ClientPlayNetworking.registerGlobalReceiver(CommandBlockPacket.ID, (payload, ctx) -> { ctx.client().execute(() -> MinecraftClient.getInstance().setScreen(new PlaceCommandBlockScreen())); }); - + ClientPlayConnectionEvents.DISCONNECT.register((handler, client) -> { - client.send(() -> { - renderRegions.clear(); - }); + client.send(renderRegions::clear); }); } @@ -102,5 +100,5 @@ private static Vec3d getCameraPos() { Vec3d c = mc.gameRenderer.getCamera().getPos(); return c; } - + } diff --git a/src/main/java/net/modfest/fireblanket/FireblanketMixin.java b/src/main/java/net/modfest/fireblanket/FireblanketMixin.java index d4a5b88..f4073d4 100644 --- a/src/main/java/net/modfest/fireblanket/FireblanketMixin.java +++ b/src/main/java/net/modfest/fireblanket/FireblanketMixin.java @@ -36,52 +36,52 @@ public void onLoad(String mixinPackage) { } if (!ignoreRenderingMods && FabricLoader.getInstance().isModLoaded("nvidium")) { Bootstrap.SYSOUT.println(""" - ---------------------------------------------------------------------------------------- - ###### Fireblanket is cowardly refusing to launch the game with Nvidium installed ###### - ---------------------------------------------------------------------------------------- - Due to the amount of mods that change how rendering works, Nvidium can experience - random crashes and other hard to debug issues. From testing in the build server, Nvidium - doesn't have a lot of impact on the types of fps lag that the pack causes. As such, - it is not recommended to use Nvidium with Blanketcon for stability reasons. - ======================================================================================== - If you would like to ignore these warnings and launch anyway, you must add the following - to your JVM arguments: - -Dfireblanket.iSolemnlySwearIWillNotReportRenderingCrashesAndAcceptResponsibilityForBreakage=true - The JVM will now exit. - """); + ---------------------------------------------------------------------------------------- + ###### Fireblanket is cowardly refusing to launch the game with Nvidium installed ###### + ---------------------------------------------------------------------------------------- + Due to the amount of mods that change how rendering works, Nvidium can experience + random crashes and other hard to debug issues. From testing in the build server, Nvidium + doesn't have a lot of impact on the types of fps lag that the pack causes. As such, + it is not recommended to use Nvidium with Blanketcon for stability reasons. + ======================================================================================== + If you would like to ignore these warnings and launch anyway, you must add the following + to your JVM arguments: + -Dfireblanket.iSolemnlySwearIWillNotReportRenderingCrashesAndAcceptResponsibilityForBreakage=true + The JVM will now exit. + """); System.exit(0xDEAD); } if (FabricLoader.getInstance().isModLoaded("entityculling")) { Bootstrap.SYSOUT.println(""" - ---------------------------------------------------------------------------------------- - ### Fireblanket is cowardly refusing to launch the game with EntityCulling installed ### - ---------------------------------------------------------------------------------------- - EntityCulling causes performance issues and hard-to-debug crashes due to poor use of - threading. Sodium's entity culling is already enabled to optimize this behavior, and - Fireblanket contains additional fixes and optimizations for entities that are tuned - specifically for Blanketcon. - ======================================================================================== - You may not override this. The JVM will now exit. - """); + ---------------------------------------------------------------------------------------- + ### Fireblanket is cowardly refusing to launch the game with EntityCulling installed ### + ---------------------------------------------------------------------------------------- + EntityCulling causes performance issues and hard-to-debug crashes due to poor use of + threading. Sodium's entity culling is already enabled to optimize this behavior, and + Fireblanket contains additional fixes and optimizations for entities that are tuned + specifically for Blanketcon. + ======================================================================================== + You may not override this. The JVM will now exit. + """); System.exit(0xDEAD); } if (!ignoreRenderingMods && FabricLoader.getInstance().isModLoaded("bobby")) { Bootstrap.SYSOUT.println(""" - ---------------------------------------------------------------------------------------- - ####### Fireblanket is cowardly refusing to launch the game with Bobby installed ####### - ---------------------------------------------------------------------------------------- - While Bobby can make navigating the map easier, it is causing difficult to debug - issues with chunk culling that keep resulting in false issue reports. We do not ship it - with the pack for a reason — we have had so many other issues to chase and fix that we - simply do not have time to field the Bobby issues. It additionally can cause crashes if - its option to keep block entities in fake chunks is not enabled, so it is not - recommended for use due to stability reasons. - ======================================================================================== - If you would like to ignore these warnings and launch anyway, you must add the following - to your JVM arguments: - -Dfireblanket.iSolemnlySwearIWillNotReportRenderingCrashesAndAcceptResponsibilityForBreakage=true - The JVM will now exit. - """); + ---------------------------------------------------------------------------------------- + ####### Fireblanket is cowardly refusing to launch the game with Bobby installed ####### + ---------------------------------------------------------------------------------------- + While Bobby can make navigating the map easier, it is causing difficult to debug + issues with chunk culling that keep resulting in false issue reports. We do not ship it + with the pack for a reason — we have had so many other issues to chase and fix that we + simply do not have time to field the Bobby issues. It additionally can cause crashes if + its option to keep block entities in fake chunks is not enabled, so it is not + recommended for use due to stability reasons. + ======================================================================================== + If you would like to ignore these warnings and launch anyway, you must add the following + to your JVM arguments: + -Dfireblanket.iSolemnlySwearIWillNotReportRenderingCrashesAndAcceptResponsibilityForBreakage=true + The JVM will now exit. + """); System.exit(0xDEAD); } } @@ -100,7 +100,7 @@ public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { if (mixinClassName.contains("region_chunk_cache")) { return DO_CHUNK_CACHE; } - + if (mixinClassName.contains("lambdamap")) { return !ALLOW_LAMBDAMAP_SAVING; } @@ -116,13 +116,9 @@ public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { if (mixinClassName.contains("footgun")) { return !ALLOW_FOOTGUNS; } - - if (mixinClassName.contains("SplitterHandler") && FabricLoader.getInstance().isModLoaded("krypton")) { - // Conflicts with Krypton, which also lifts the limit - return false; - } - return true; + // Conflicts with Krypton, which also lifts the limit + return !mixinClassName.contains("SplitterHandler") || !FabricLoader.getInstance().isModLoaded("krypton"); } @Override @@ -136,12 +132,12 @@ public List getMixins() { @Override public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { - + } @Override public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { - + } } diff --git a/src/main/java/net/modfest/fireblanket/client/BlamefulRenderCall.java b/src/main/java/net/modfest/fireblanket/client/BlamefulRenderCall.java index 9557ff4..2ecab89 100644 --- a/src/main/java/net/modfest/fireblanket/client/BlamefulRenderCall.java +++ b/src/main/java/net/modfest/fireblanket/client/BlamefulRenderCall.java @@ -6,12 +6,12 @@ public class BlamefulRenderCall implements RenderCall { private final RenderCall delegate; private final Throwable stacktrace; - + public BlamefulRenderCall(RenderCall delegate) { this.delegate = delegate; - this.stacktrace = new Throwable("Created here in thread "+Thread.currentThread().getName()); + this.stacktrace = new Throwable("Created here in thread " + Thread.currentThread().getName()); } - + @Override public void execute() { try { @@ -21,5 +21,5 @@ public void execute() { throw e; } } - + } diff --git a/src/main/java/net/modfest/fireblanket/client/ClientState.java b/src/main/java/net/modfest/fireblanket/client/ClientState.java index a1689e3..ef2127a 100644 --- a/src/main/java/net/modfest/fireblanket/client/ClientState.java +++ b/src/main/java/net/modfest/fireblanket/client/ClientState.java @@ -2,11 +2,8 @@ import net.minecraft.block.entity.BlockEntityType; import net.minecraft.entity.EntityType; -import net.minecraft.util.Identifier; -import org.jetbrains.annotations.Nullable; import java.util.HashSet; -import java.util.List; import java.util.Set; public final class ClientState { diff --git a/src/main/java/net/modfest/fireblanket/client/command/BERMaskCommand.java b/src/main/java/net/modfest/fireblanket/client/command/BERMaskCommand.java index 6f89d38..e0ba1b3 100644 --- a/src/main/java/net/modfest/fireblanket/client/command/BERMaskCommand.java +++ b/src/main/java/net/modfest/fireblanket/client/command/BERMaskCommand.java @@ -73,7 +73,7 @@ public static void init(LiteralArgumentBuilder base, .then(literal("clear") .executes(client -> { int size = ClientState.MASKED_BERS.size(); - MinecraftClient.getInstance().submit(() -> ClientState.MASKED_BERS.clear()); + MinecraftClient.getInstance().submit(ClientState.MASKED_BERS::clear); client.getSource().sendFeedback(Text.literal("Cleared " + size + " BE" + (size == 1 ? "" : "s") + " out of the mask.")); return 0; @@ -83,7 +83,7 @@ public static void init(LiteralArgumentBuilder base, } private static final Dynamic3CommandExceptionType WRONG_TYPE_EXCEPTION = new Dynamic3CommandExceptionType( - (tag, type, expectedType) -> Text.translatable("argument.resource_tag.invalid_type", tag, type, expectedType) + (tag, type, expectedType) -> Text.translatable("argument.resource_tag.invalid_type", tag, type, expectedType) ); public static RegistryEntry.Reference getRegistryEntry(CommandContext context, String name, RegistryKey> registryRef) throws CommandSyntaxException { diff --git a/src/main/java/net/modfest/fireblanket/client/command/EntityMaskCommand.java b/src/main/java/net/modfest/fireblanket/client/command/EntityMaskCommand.java index a900f54..99b5205 100644 --- a/src/main/java/net/modfest/fireblanket/client/command/EntityMaskCommand.java +++ b/src/main/java/net/modfest/fireblanket/client/command/EntityMaskCommand.java @@ -1,14 +1,9 @@ package net.modfest.fireblanket.client.command; -import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.argument; -import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal; - import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.exceptions.Dynamic3CommandExceptionType; - -import com.mojang.serialization.Codec; import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; import net.minecraft.client.MinecraftClient; import net.minecraft.command.CommandRegistryAccess; @@ -24,6 +19,9 @@ import java.util.stream.Collectors; +import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.argument; +import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal; + public class EntityMaskCommand { public static void init(LiteralArgumentBuilder base, CommandRegistryAccess access) { base.then(literal("entity") @@ -75,7 +73,7 @@ public static void init(LiteralArgumentBuilder base, .then(literal("clear") .executes(client -> { int size = ClientState.MASKED_ENTITIES.size(); - MinecraftClient.getInstance().submit(() -> ClientState.MASKED_ENTITIES.clear()); + MinecraftClient.getInstance().submit(ClientState.MASKED_ENTITIES::clear); client.getSource().sendFeedback(Text.literal("Cleared " + size + " entit" + (size == 1 ? "y" : "ies") + " out of the mask.")); return 0; @@ -85,7 +83,7 @@ public static void init(LiteralArgumentBuilder base, } private static final Dynamic3CommandExceptionType WRONG_TYPE_EXCEPTION = new Dynamic3CommandExceptionType( - (tag, type, expectedType) -> Text.translatable("argument.resource_tag.invalid_type", tag, type, expectedType) + (tag, type, expectedType) -> Text.translatable("argument.resource_tag.invalid_type", tag, type, expectedType) ); public static RegistryEntry.Reference getRegistryEntry(CommandContext context, String name, RegistryKey> registryRef) throws CommandSyntaxException { diff --git a/src/main/java/net/modfest/fireblanket/client/render/ExtendedVertexFormat.java b/src/main/java/net/modfest/fireblanket/client/render/ExtendedVertexFormat.java index b8fc82f..07ae837 100644 --- a/src/main/java/net/modfest/fireblanket/client/render/ExtendedVertexFormat.java +++ b/src/main/java/net/modfest/fireblanket/client/render/ExtendedVertexFormat.java @@ -3,7 +3,8 @@ import net.minecraft.client.render.VertexFormatElement; public interface ExtendedVertexFormat { - Element[] fireblanket$getExtendedElements(); + Element[] fireblanket$getExtendedElements(); - static record Element(VertexFormatElement actual, int increment, int byteLength) { } + record Element(VertexFormatElement actual, int increment, int byteLength) { + } } diff --git a/src/main/java/net/modfest/fireblanket/client/render/QuadEmitter.java b/src/main/java/net/modfest/fireblanket/client/render/QuadEmitter.java index 971eb5e..9f3ee4d 100644 --- a/src/main/java/net/modfest/fireblanket/client/render/QuadEmitter.java +++ b/src/main/java/net/modfest/fireblanket/client/render/QuadEmitter.java @@ -3,7 +3,6 @@ import net.minecraft.client.render.LightmapTextureManager; import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.util.math.MatrixStack; -import org.joml.Matrix3f; import org.joml.Matrix4f; public class QuadEmitter { @@ -26,27 +25,27 @@ public static void buildTopFacing(VertexConsumer buffer, MatrixStack.Entry entry Matrix4f model = entry.getPositionMatrix(); // -X, +Z buffer.vertex(model, x1, y, z2).color(r, g, b, a) - .texture(0.0F, 1.0F).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(entry, 0.0F, 1.0F, 0.0F); + .texture(0.0F, 1.0F).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(entry, 0.0F, 1.0F, 0.0F); // +X, +Z buffer.vertex(model, x2, y, z2).color(r, g, b, a) - .texture(1.0F, 1.0F).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(entry, 0.0F, 1.0F, 0.0F); + .texture(1.0F, 1.0F).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(entry, 0.0F, 1.0F, 0.0F); // +X, -Z buffer.vertex(model, x2, y, z1).color(r, g, b, a) - .texture(1.0F, 0.0F).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(entry, 0.0F, 1.0F, 0.0F); + .texture(1.0F, 0.0F).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(entry, 0.0F, 1.0F, 0.0F); // -X, -Z buffer.vertex(model, x1, y, z1).color(r, g, b, a) - .texture(0.0F, 0.0F).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(entry, 0.0F, 1.0F, 0.0F); + .texture(0.0F, 0.0F).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(entry, 0.0F, 1.0F, 0.0F); // Reverse buffer.vertex(model, x1, y, z2).color(r, g, b, a) - .texture(0.0F, 1.0F).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(entry, 0.0F, 1.0F, 0.0F); + .texture(0.0F, 1.0F).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(entry, 0.0F, 1.0F, 0.0F); buffer.vertex(model, x1, y, z1).color(r, g, b, a) - .texture(0.0F, 0.0F).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(entry, 0.0F, 1.0F, 0.0F); + .texture(0.0F, 0.0F).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(entry, 0.0F, 1.0F, 0.0F); buffer.vertex(model, x2, y, z1).color(r, g, b, a) - .texture(1.0F, 0.0F).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(entry, 0.0F, 1.0F, 0.0F); + .texture(1.0F, 0.0F).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(entry, 0.0F, 1.0F, 0.0F); buffer.vertex(model, x2, y, z2).color(r, g, b, a) - .texture(1.0F, 1.0F).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(entry, 0.0F, 1.0F, 0.0F); + .texture(1.0F, 1.0F).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(entry, 0.0F, 1.0F, 0.0F); } public static void buildNorthFacing(VertexConsumer buffer, MatrixStack.Entry entry, float x1, float x2, float y1, float y2, float z, int r, int g, int b, int a) { @@ -54,27 +53,27 @@ public static void buildNorthFacing(VertexConsumer buffer, MatrixStack.Entry ent // -X, +Z buffer.vertex(model, x1, y2, z).color(r, g, b, a) - .texture(0.0F, 1.0F).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(entry, 0.0F, 1.0F, 0.0F); + .texture(0.0F, 1.0F).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(entry, 0.0F, 1.0F, 0.0F); // +X, +Z buffer.vertex(model, x2, y2, z).color(r, g, b, a) - .texture(1.0F, 1.0F).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(entry, 0.0F, 1.0F, 0.0F); + .texture(1.0F, 1.0F).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(entry, 0.0F, 1.0F, 0.0F); // +X, -Z buffer.vertex(model, x2, y1, z).color(r, g, b, a) - .texture(1.0F, 0.0F).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(entry, 0.0F, 1.0F, 0.0F); + .texture(1.0F, 0.0F).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(entry, 0.0F, 1.0F, 0.0F); // -X, -Z buffer.vertex(model, x1, y1, z).color(r, g, b, a) - .texture(0.0F, 0.0F).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(entry, 0.0F, 1.0F, 0.0F); + .texture(0.0F, 0.0F).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(entry, 0.0F, 1.0F, 0.0F); // Reverse buffer.vertex(model, x1, y2, z).color(r, g, b, a) - .texture(0.0F, 1.0F).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(entry, 0.0F, 1.0F, 0.0F); + .texture(0.0F, 1.0F).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(entry, 0.0F, 1.0F, 0.0F); buffer.vertex(model, x1, y1, z).color(r, g, b, a) - .texture(0.0F, 0.0F).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(entry, 0.0F, 1.0F, 0.0F); + .texture(0.0F, 0.0F).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(entry, 0.0F, 1.0F, 0.0F); buffer.vertex(model, x2, y1, z).color(r, g, b, a) - .texture(1.0F, 0.0F).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(entry, 0.0F, 1.0F, 0.0F); + .texture(1.0F, 0.0F).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(entry, 0.0F, 1.0F, 0.0F); buffer.vertex(model, x2, y2, z).color(r, g, b, a) - .texture(1.0F, 1.0F).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(entry, 0.0F, 1.0F, 0.0F); + .texture(1.0F, 1.0F).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(entry, 0.0F, 1.0F, 0.0F); } public static void buildEastFacing(VertexConsumer buffer, MatrixStack.Entry entry, float y1, float y2, float z1, float z2, float x, int r, int g, int b, int a) { @@ -82,26 +81,26 @@ public static void buildEastFacing(VertexConsumer buffer, MatrixStack.Entry entr // -X, +Z buffer.vertex(model, x, y1, z2).color(r, g, b, a) - .texture(0.0F, 1.0F).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(entry, 0.0F, 1.0F, 0.0F); + .texture(0.0F, 1.0F).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(entry, 0.0F, 1.0F, 0.0F); // +X, +Z buffer.vertex(model, x, y2, z2).color(r, g, b, a) - .texture(1.0F, 1.0F).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(entry, 0.0F, 1.0F, 0.0F); + .texture(1.0F, 1.0F).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(entry, 0.0F, 1.0F, 0.0F); // +X, -Z buffer.vertex(model, x, y2, z1).color(r, g, b, a) - .texture(1.0F, 0.0F).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(entry, 0.0F, 1.0F, 0.0F); + .texture(1.0F, 0.0F).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(entry, 0.0F, 1.0F, 0.0F); // -X, -Z buffer.vertex(model, x, y1, z1).color(r, g, b, a) - .texture(0.0F, 0.0F).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(entry, 0.0F, 1.0F, 0.0F); + .texture(0.0F, 0.0F).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(entry, 0.0F, 1.0F, 0.0F); // Reverse buffer.vertex(model, x, y1, z2).color(r, g, b, a) - .texture(0.0F, 1.0F).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(entry, 0.0F, 1.0F, 0.0F); + .texture(0.0F, 1.0F).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(entry, 0.0F, 1.0F, 0.0F); buffer.vertex(model, x, y1, z1).color(r, g, b, a) - .texture(0.0F, 0.0F).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(entry, 0.0F, 1.0F, 0.0F); + .texture(0.0F, 0.0F).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(entry, 0.0F, 1.0F, 0.0F); buffer.vertex(model, x, y2, z1).color(r, g, b, a) - .texture(1.0F, 0.0F).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(entry, 0.0F, 1.0F, 0.0F); + .texture(1.0F, 0.0F).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(entry, 0.0F, 1.0F, 0.0F); buffer.vertex(model, x, y2, z2).color(r, g, b, a) - .texture(1.0F, 1.0F).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(entry, 0.0F, 1.0F, 0.0F); + .texture(1.0F, 1.0F).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(entry, 0.0F, 1.0F, 0.0F); } } \ No newline at end of file diff --git a/src/main/java/net/modfest/fireblanket/client/render/RenderLayers.java b/src/main/java/net/modfest/fireblanket/client/render/RenderLayers.java index 6378e64..403b5ec 100644 --- a/src/main/java/net/modfest/fireblanket/client/render/RenderLayers.java +++ b/src/main/java/net/modfest/fireblanket/client/render/RenderLayers.java @@ -6,52 +6,51 @@ import net.minecraft.client.render.VertexFormat; import net.minecraft.client.render.VertexFormats; import net.minecraft.util.Identifier; -import org.lwjgl.opengl.GL11; import java.util.OptionalDouble; public abstract class RenderLayers extends RenderLayer { public static final RenderLayer TRANSLUCENT_BROKEN_DEPTH = of( - "translucent_broken_depth", VertexFormats.POSITION_COLOR_TEXTURE_LIGHT_NORMAL, - VertexFormat.DrawMode.QUADS, 2097152, true, true, - translucent(TRANSLUCENT_PROGRAM) - .depthTest(new NoDepthTest()) + "translucent_broken_depth", VertexFormats.POSITION_COLOR_TEXTURE_LIGHT_NORMAL, + VertexFormat.DrawMode.QUADS, 2097152, true, true, + translucent(TRANSLUCENT_PROGRAM) + .depthTest(new NoDepthTest()) - .build(true) + .build(true) ); public static final RenderLayer TRANSLUCENT_BOX = of( - "translucent_box", VertexFormats.POSITION_COLOR_TEXTURE_LIGHT_NORMAL, - VertexFormat.DrawMode.QUADS, 2097152, true, true, - translucent(TRANSLUCENT_PROGRAM) - .layering(POLYGON_OFFSET_LAYERING) - .build(true) + "translucent_box", VertexFormats.POSITION_COLOR_TEXTURE_LIGHT_NORMAL, + VertexFormat.DrawMode.QUADS, 2097152, true, true, + translucent(TRANSLUCENT_PROGRAM) + .layering(POLYGON_OFFSET_LAYERING) + .build(true) ); public static final RenderLayer LINES_WIDER = of( - "lines_wider", - VertexFormats.LINES, - VertexFormat.DrawMode.LINES, - 1536, - RenderLayer.MultiPhaseParameters.builder() - .program(LINES_PROGRAM) - .lineWidth(new RenderPhase.LineWidth(OptionalDouble.of(3.75))) - .layering(VIEW_OFFSET_Z_LAYERING) - .transparency(TRANSLUCENT_TRANSPARENCY) - .target(ITEM_ENTITY_TARGET) - .writeMaskState(ALL_MASK) - .cull(DISABLE_CULLING) - .build(false) + "lines_wider", + VertexFormats.LINES, + VertexFormat.DrawMode.LINES, + 1536, + RenderLayer.MultiPhaseParameters.builder() + .program(LINES_PROGRAM) + .lineWidth(new RenderPhase.LineWidth(OptionalDouble.of(3.75))) + .layering(VIEW_OFFSET_Z_LAYERING) + .transparency(TRANSLUCENT_TRANSPARENCY) + .target(ITEM_ENTITY_TARGET) + .writeMaskState(ALL_MASK) + .cull(DISABLE_CULLING) + .build(false) ); public static RenderLayer.MultiPhaseParameters.Builder translucent(RenderPhase.ShaderProgram program) { return RenderLayer.MultiPhaseParameters.builder() - .lightmap(ENABLE_LIGHTMAP) - .program(program) - .texture(new Texture(Identifier.of("textures/misc/white.png"), false, false)) - .transparency(TRANSLUCENT_TRANSPARENCY) - .target(TRANSLUCENT_TARGET) - .cull(RenderPhase.DISABLE_CULLING); + .lightmap(ENABLE_LIGHTMAP) + .program(program) + .texture(new Texture(Identifier.of("textures/misc/white.png"), false, false)) + .transparency(TRANSLUCENT_TRANSPARENCY) + .target(TRANSLUCENT_TARGET) + .cull(RenderPhase.DISABLE_CULLING); } private static final class NoDepthTest extends DepthTest { diff --git a/src/main/java/net/modfest/fireblanket/client/render/RenderRegionRenderer.java b/src/main/java/net/modfest/fireblanket/client/render/RenderRegionRenderer.java index 0608380..2f5bfa1 100644 --- a/src/main/java/net/modfest/fireblanket/client/render/RenderRegionRenderer.java +++ b/src/main/java/net/modfest/fireblanket/client/render/RenderRegionRenderer.java @@ -3,8 +3,6 @@ import com.mojang.blaze3d.systems.RenderSystem; import it.unimi.dsi.fastutil.HashCommon; import net.minecraft.client.MinecraftClient; -import net.minecraft.client.render.Camera; -import net.minecraft.client.render.RenderLayer; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.WorldRenderer; import net.minecraft.client.render.debug.DebugRenderer; @@ -67,10 +65,10 @@ public static void render(MatrixStack matrices, float tickDelta) { matrices.loadIdentity(); DebugRenderer.drawString(matrices, imm, name, - rr.minX() + (rr.maxX() - rr.minX()) / 2.0 + 0.5, - rr.minY() + (rr.maxY() - rr.minY()) / 2.0 + 0.5, - rr.minZ() + (rr.maxZ() - rr.minZ()) / 2.0 + 0.5, - 0xFFFFFF, 0.03F); + rr.minX() + (rr.maxX() - rr.minX()) / 2.0 + 0.5, + rr.minY() + (rr.maxY() - rr.minY()) / 2.0 + 0.5, + rr.minZ() + (rr.maxZ() - rr.minZ()) / 2.0 + 0.5, + 0xFFFFFF, 0.03F); matrices.pop(); } diff --git a/src/main/java/net/modfest/fireblanket/client/screen/PlaceCommandBlockScreen.java b/src/main/java/net/modfest/fireblanket/client/screen/PlaceCommandBlockScreen.java index 80f9704..845af61 100644 --- a/src/main/java/net/modfest/fireblanket/client/screen/PlaceCommandBlockScreen.java +++ b/src/main/java/net/modfest/fireblanket/client/screen/PlaceCommandBlockScreen.java @@ -14,9 +14,9 @@ public PlaceCommandBlockScreen() { protected void init() { super.init(); this.addDrawableChild( - new ButtonWidget.Builder(Text.literal("Continue..."), (bw) -> client.setScreen(null)) - .dimensions((this.width / 2) + 50, (this.height / 2) + 58, 100, 20) - .build() + new ButtonWidget.Builder(Text.literal("Continue..."), (bw) -> client.setScreen(null)) + .dimensions((this.width / 2) + 50, (this.height / 2) + 58, 100, 20) + .build() ); } diff --git a/src/main/java/net/modfest/fireblanket/command/CmdFindReplaceCommand.java b/src/main/java/net/modfest/fireblanket/command/CmdFindReplaceCommand.java index 6a33360..68b995d 100644 --- a/src/main/java/net/modfest/fireblanket/command/CmdFindReplaceCommand.java +++ b/src/main/java/net/modfest/fireblanket/command/CmdFindReplaceCommand.java @@ -1,5 +1,7 @@ package net.modfest.fireblanket.command; +import com.mojang.brigadier.arguments.StringArgumentType; +import com.mojang.brigadier.builder.LiteralArgumentBuilder; import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.CommandBlockBlockEntity; import net.minecraft.command.CommandRegistryAccess; @@ -10,15 +12,12 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.chunk.WorldChunk; -import static net.minecraft.server.command.CommandManager.literal; -import static net.minecraft.server.command.CommandManager.argument; - import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; -import com.mojang.brigadier.arguments.StringArgumentType; -import com.mojang.brigadier.builder.LiteralArgumentBuilder; +import static net.minecraft.server.command.CommandManager.argument; +import static net.minecraft.server.command.CommandManager.literal; public class CmdFindReplaceCommand { public static void init(LiteralArgumentBuilder base, CommandRegistryAccess access) { @@ -29,11 +28,11 @@ public static void init(LiteralArgumentBuilder base, Comman .executes(ctx -> { Pattern p = Pattern.compile(StringArgumentType.getString(ctx, "regex")); String replacement = StringArgumentType.getString(ctx, "replacement"); - + StringBuilder sb = new StringBuilder(); int blocks = 0; int matches = 0; - + ServerWorld world = ctx.getSource().getWorld(); for (ChunkHolder holder : world.getChunkManager().chunkLoadingManager.entryIterator()) { WorldChunk chunk = holder.getWorldChunk(); @@ -66,9 +65,9 @@ public static void init(LiteralArgumentBuilder base, Comman } else { final int fmatches = matches; final int fblocks = blocks; - ctx.getSource().sendFeedback(() -> Text.literal("Replaced "+fmatches+" occurence"+(fmatches == 1 ? "" : "s")+" across "+fblocks+" block"+(fblocks == 1 ? "" : "s")), true); + ctx.getSource().sendFeedback(() -> Text.literal("Replaced " + fmatches + " occurence" + (fmatches == 1 ? "" : "s") + " across " + fblocks + " block" + (fblocks == 1 ? "" : "s")), true); } - + return 0; }) ) diff --git a/src/main/java/net/modfest/fireblanket/command/CommandUtils.java b/src/main/java/net/modfest/fireblanket/command/CommandUtils.java index 33d63c8..fcf9578 100644 --- a/src/main/java/net/modfest/fireblanket/command/CommandUtils.java +++ b/src/main/java/net/modfest/fireblanket/command/CommandUtils.java @@ -4,5 +4,5 @@ import net.minecraft.text.Text; public final class CommandUtils { - public static final DynamicCommandExceptionType GENERIC_EXCEPTION = new DynamicCommandExceptionType(message -> (Text)message); + public static final DynamicCommandExceptionType GENERIC_EXCEPTION = new DynamicCommandExceptionType(message -> (Text) message); } diff --git a/src/main/java/net/modfest/fireblanket/command/DumpCommand.java b/src/main/java/net/modfest/fireblanket/command/DumpCommand.java index bd89d53..e287cbc 100644 --- a/src/main/java/net/modfest/fireblanket/command/DumpCommand.java +++ b/src/main/java/net/modfest/fireblanket/command/DumpCommand.java @@ -1,5 +1,6 @@ package net.modfest.fireblanket.command; +import com.mojang.brigadier.builder.LiteralArgumentBuilder; import it.unimi.dsi.fastutil.objects.Object2IntMap; import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import net.minecraft.block.BlockState; @@ -15,18 +16,14 @@ import net.minecraft.server.world.ChunkHolder; import net.minecraft.server.world.ServerWorld; import net.minecraft.text.Text; -import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockPos; import net.minecraft.world.chunk.WorldChunk; -import static net.minecraft.server.command.CommandManager.literal; - import java.util.ArrayList; import java.util.Collections; -import java.util.Comparator; import java.util.Map; -import com.mojang.brigadier.builder.LiteralArgumentBuilder; +import static net.minecraft.server.command.CommandManager.literal; public class DumpCommand { public static void init(LiteralArgumentBuilder base, CommandRegistryAccess access) { @@ -41,7 +38,7 @@ public static void init(LiteralArgumentBuilder base, Comman if (chunk == null) { continue; } - + for (Map.Entry e : chunk.getBlockEntities().entrySet()) { if (e.getValue() instanceof CommandBlockBlockEntity cbe) { BlockState state = cbe.getCachedState(); @@ -71,7 +68,7 @@ public static void init(LiteralArgumentBuilder base, Comman } } }); - + return 0; }) ) @@ -80,7 +77,7 @@ public static void init(LiteralArgumentBuilder base, Comman for (EntityType type : Registries.ENTITY_TYPE) { server.getSource().sendFeedback(() -> Text.literal(Registries.ENTITY_TYPE.getId(type) + " alwaysUpdateVelocity=" + type.alwaysUpdateVelocity() + " updateDistance(blocks)=" + (type.getMaxTrackDistance() * 16) + " tickInterval=" + type.getTrackTickInterval()), false); } - + return 0; }) ) diff --git a/src/main/java/net/modfest/fireblanket/command/RegionCommand.java b/src/main/java/net/modfest/fireblanket/command/RegionCommand.java index 59a3bfc..ea77a0b 100644 --- a/src/main/java/net/modfest/fireblanket/command/RegionCommand.java +++ b/src/main/java/net/modfest/fireblanket/command/RegionCommand.java @@ -1,14 +1,6 @@ package net.modfest.fireblanket.command; -import static net.minecraft.server.command.CommandManager.argument; -import static net.minecraft.server.command.CommandManager.literal; - -import java.util.Iterator; -import java.util.Locale; -import java.util.UUID; -import java.util.concurrent.CompletableFuture; -import java.util.function.Predicate; - +import com.google.common.collect.Iterables; import com.mojang.brigadier.arguments.StringArgumentType; import com.mojang.brigadier.builder.ArgumentBuilder; import com.mojang.brigadier.builder.LiteralArgumentBuilder; @@ -17,9 +9,6 @@ import com.mojang.brigadier.exceptions.DynamicCommandExceptionType; import com.mojang.brigadier.suggestion.Suggestions; import com.mojang.brigadier.suggestion.SuggestionsBuilder; - -import com.google.common.collect.Iterables; - import it.unimi.dsi.fastutil.longs.LongIterator; import it.unimi.dsi.fastutil.longs.LongIterators; import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; @@ -49,8 +38,17 @@ import net.modfest.fireblanket.world.render_regions.RenderRegions; import net.modfest.fireblanket.world.render_regions.RenderRegionsState; +import java.util.Iterator; +import java.util.Locale; +import java.util.UUID; +import java.util.concurrent.CompletableFuture; +import java.util.function.Predicate; + +import static net.minecraft.server.command.CommandManager.argument; +import static net.minecraft.server.command.CommandManager.literal; + public class RegionCommand { - private static final DynamicCommandExceptionType GENERIC_EXCEPTION = new DynamicCommandExceptionType(message -> (Text)message); + private static final DynamicCommandExceptionType GENERIC_EXCEPTION = new DynamicCommandExceptionType(message -> (Text) message); private static final Predicate WORLDEDIT = ctx -> FabricLoader.getInstance().isModLoaded("worldedit"); @@ -76,10 +74,10 @@ public static void init(LiteralArgumentBuilder base, Comman RenderRegion ol = getRegion(ctx); RenderRegions regions = getRegions(ctx); RenderRegion nw = new RenderRegion(box.getMinX(), box.getMinY(), box.getMinZ(), - box.getMaxX(), box.getMaxY(), box.getMaxZ(), - ol.mode()); + box.getMaxX(), box.getMaxY(), box.getMaxZ(), + ol.mode()); regions.redefine(name, nw); - ctx.getSource().sendFeedback(() -> Text.literal("Redefined region "+name), true); + ctx.getSource().sendFeedback(() -> Text.literal("Redefined region " + name), true); return 1; }) ) @@ -93,10 +91,10 @@ public static void init(LiteralArgumentBuilder base, Comman RenderRegion ol = getRegion(ctx); RenderRegions regions = getRegions(ctx); RenderRegion nw = new RenderRegion(min.getX(), min.getY(), min.getZ(), - max.getX(), max.getY(), max.getZ(), - ol.mode()); + max.getX(), max.getY(), max.getZ(), + ol.mode()); regions.redefine(name, nw); - ctx.getSource().sendFeedback(() -> Text.literal("Redefined region "+name), true); + ctx.getSource().sendFeedback(() -> Text.literal("Redefined region " + name), true); return 1; }) ) @@ -125,7 +123,7 @@ public static void init(LiteralArgumentBuilder base, Comman RenderRegions regions = getRegions(ctx); int count = regions.getRegionsByName().size(); regions.clear(); - ctx.getSource().sendFeedback(() -> Text.literal("Destroyed "+count+" region"+(count == 1 ? "" : "s")), true); + ctx.getSource().sendFeedback(() -> Text.literal("Destroyed " + count + " region" + (count == 1 ? "" : "s")), true); return count; }) ) @@ -135,7 +133,7 @@ public static void init(LiteralArgumentBuilder base, Comman RenderRegion r = getRegion(ctx); RenderRegions regions = getRegions(ctx); regions.remove(r); - ctx.getSource().sendFeedback(() -> Text.literal("Destroyed region "+StringArgumentType.getString(ctx, "name")), true); + ctx.getSource().sendFeedback(() -> Text.literal("Destroyed region " + StringArgumentType.getString(ctx, "name")), true); return 1; }) ) @@ -147,7 +145,7 @@ public static void init(LiteralArgumentBuilder base, Comman if (size == 1) { ctx.getSource().sendMessage(Text.literal("§lThere is 1 region defined")); } else { - ctx.getSource().sendMessage(Text.literal("§lThere are "+size+" regions defined")); + ctx.getSource().sendMessage(Text.literal("§lThere are " + size + " regions defined")); } for (var en : regions.getRegionsByName().entrySet()) { RenderRegion r = en.getValue(); @@ -161,8 +159,8 @@ public static void init(LiteralArgumentBuilder base, Comman case EXCLUSIVE -> "§bexclusive"; case UNKNOWN -> "§dunknown"; }; - ctx.getSource().sendMessage(Text.literal("- §d§o"+en.getKey()+"§r "+mode+"§r ("+ea+"E, "+ba+"B, "+eta+"Et, "+beta+"BEt)")); - ctx.getSource().sendMessage(Text.literal(" "+r.minX()+", "+r.minY()+", "+r.minZ()+" → "+r.maxX()+", "+r.maxY()+", "+r.maxZ())); + ctx.getSource().sendMessage(Text.literal("- §d§o" + en.getKey() + "§r " + mode + "§r (" + ea + "E, " + ba + "B, " + eta + "Et, " + beta + "BEt)")); + ctx.getSource().sendMessage(Text.literal(" " + r.minX() + ", " + r.minY() + ", " + r.minZ() + " → " + r.maxX() + ", " + r.maxY() + ", " + r.maxZ())); } return 1; }) @@ -174,46 +172,46 @@ public static void init(LiteralArgumentBuilder base, Comman RenderRegion r = getRegion(ctx); RenderRegions regions = getRegions(ctx); String mn = r.mode().name(); - ctx.getSource().sendMessage(Text.literal(mn.charAt(0)+mn.toLowerCase(Locale.ROOT).substring(1)+" region "+StringArgumentType.getString(ctx, "name"))); - ctx.getSource().sendMessage(Text.literal(""+r.minX()+", "+r.minY()+", "+r.minZ()+" → "+r.maxX()+", "+r.maxY()+", "+r.maxZ())); + ctx.getSource().sendMessage(Text.literal(mn.charAt(0) + mn.toLowerCase(Locale.ROOT).substring(1) + " region " + StringArgumentType.getString(ctx, "name"))); + ctx.getSource().sendMessage(Text.literal(r.minX() + ", " + r.minY() + ", " + r.minZ() + " → " + r.maxX() + ", " + r.maxY() + ", " + r.maxZ())); var ea = regions.getEntityAttachments(r); if (!ea.isEmpty()) { - ctx.getSource().sendMessage(Text.literal(ea.size()+" entity attachment"+(ea.size() == 1 ? "" : "s")+":")); + ctx.getSource().sendMessage(Text.literal(ea.size() + " entity attachment" + (ea.size() == 1 ? "" : "s") + ":")); for (UUID id : ea) { Entity e = ctx.getSource().getWorld().getEntity(id); if (e == null) { - ctx.getSource().sendMessage(Text.literal(" - "+id+" (unknown)")); + ctx.getSource().sendMessage(Text.literal(" - " + id + " (unknown)")); } else { - ctx.getSource().sendMessage(Text.literal(" - "+id+" ("+Registries.ENTITY_TYPE.getId(e.getType())+" @ "+e.getPos()+")")); + ctx.getSource().sendMessage(Text.literal(" - " + id + " (" + Registries.ENTITY_TYPE.getId(e.getType()) + " @ " + e.getPos() + ")")); } } } var ba = regions.getBlockAttachments(r); if (!ba.isEmpty()) { BlockPos.Mutable mut = new BlockPos.Mutable(); - ctx.getSource().sendMessage(Text.literal(ba.size()+" block attachment"+(ba.size() == 1 ? "" : "s")+":")); + ctx.getSource().sendMessage(Text.literal(ba.size() + " block attachment" + (ba.size() == 1 ? "" : "s") + ":")); for (long posl : ba) { mut.set(posl); BlockEntity be = ctx.getSource().getWorld().getBlockEntity(mut); if (be == null) { - ctx.getSource().sendMessage(Text.literal(" - "+mut.toShortString()+" (unknown)")); + ctx.getSource().sendMessage(Text.literal(" - " + mut.toShortString() + " (unknown)")); } else { - ctx.getSource().sendMessage(Text.literal(" - "+mut.toShortString()+" ("+Registries.BLOCK_ENTITY_TYPE.getId(be.getType())+")")); + ctx.getSource().sendMessage(Text.literal(" - " + mut.toShortString() + " (" + Registries.BLOCK_ENTITY_TYPE.getId(be.getType()) + ")")); } } } var eta = regions.getEntityTypeAttachments(r); if (!eta.isEmpty()) { - ctx.getSource().sendMessage(Text.literal(eta.size()+" entity type attachment"+(eta.size() == 1 ? "" : "s")+":")); + ctx.getSource().sendMessage(Text.literal(eta.size() + " entity type attachment" + (eta.size() == 1 ? "" : "s") + ":")); for (Identifier id : eta) { - ctx.getSource().sendMessage(Text.literal(" - "+id)); + ctx.getSource().sendMessage(Text.literal(" - " + id)); } } var beta = regions.getBlockEntityTypeAttachments(r); if (!beta.isEmpty()) { - ctx.getSource().sendMessage(Text.literal(beta.size()+" block entity type attachment"+(beta.size() == 1 ? "" : "s")+":")); + ctx.getSource().sendMessage(Text.literal(beta.size() + " block entity type attachment" + (beta.size() == 1 ? "" : "s") + ":")); for (Identifier id : beta) { - ctx.getSource().sendMessage(Text.literal(" - "+id)); + ctx.getSource().sendMessage(Text.literal(" - " + id)); } } if (ea.isEmpty() && ba.isEmpty() && eta.isEmpty() && beta.isEmpty()) { @@ -228,14 +226,14 @@ public static void init(LiteralArgumentBuilder base, Comman ) ) .then(literal("resync") - .requires(ctx -> ctx.isExecutedByPlayer()) - .executes(ctx -> { - Fireblanket.fullRegionSync(ctx.getSource().getWorld(), ctx.getSource().getPlayerOrThrow().networkHandler::sendPacket); - return 1; - }) - ) + .requires(ServerCommandSource::isExecutedByPlayer) + .executes(ctx -> { + Fireblanket.fullRegionSync(ctx.getSource().getWorld(), ctx.getSource().getPlayerOrThrow().networkHandler::sendPacket); + return 1; + }) + ) .then(literal("ignore") - .requires(ctx -> ctx.isExecutedByPlayer()) + .requires(ServerCommandSource::isExecutedByPlayer) .then(argument("name", StringArgumentType.string()) .suggests(RegionCommand::suggestRegionNames) .executes(ctx -> { @@ -286,202 +284,203 @@ public static void init(LiteralArgumentBuilder base, Comman ) ); } - + private static ArgumentBuilder applyBranch(CommandRegistryAccess cra, boolean attach) { return literal(attach ? "attach" : "detach") - .then(argument("name", StringArgumentType.string()) - .suggests(RegionCommand::suggestRegionNames) - .then(literal("everything") - .then(literal("from") - .then(literal("region") - .then(argument("src-name", StringArgumentType.string()) - .suggests(RegionCommand::suggestRegionNames) - .executes(ctx -> { - String name = StringArgumentType.getString(ctx, "name"); - RenderRegions rr = getRegions(ctx); - RenderRegion r1 = getRegion(ctx); - RenderRegion r2 = getRegion(ctx, "src-name"); - if (r1 == r2 && attach) - throw CommandUtils.GENERIC_EXCEPTION.create(Text.literal("All of the objects in "+name+" are already attached to "+name+"… wait…")); - applyEntitiesByIdToRegion(ctx, r -> rr.getEntityAttachments(r2), attach); - applyBlocksToRegion(ctx, (Iterable)() -> { - BlockPos.Mutable mut = new BlockPos.Mutable(); - LongIterator li = LongIterators.asLongIterator(rr.getBlockAttachments(r2).iterator()); - return new Iterator() { - @Override - public boolean hasNext() { - return li.hasNext(); - } - @Override - public BlockPos next() { - mut.set(li.nextLong()); - return mut; - } - }; - }, null, attach); - return 1; - }) - ) + .then(argument("name", StringArgumentType.string()) + .suggests(RegionCommand::suggestRegionNames) + .then(literal("everything") + .then(literal("from") + .then(literal("region") + .then(argument("src-name", StringArgumentType.string()) + .suggests(RegionCommand::suggestRegionNames) .executes(ctx -> { + String name = StringArgumentType.getString(ctx, "name"); + RenderRegions rr = getRegions(ctx); + RenderRegion r1 = getRegion(ctx); + RenderRegion r2 = getRegion(ctx, "src-name"); + if (r1 == r2 && attach) + throw CommandUtils.GENERIC_EXCEPTION.create(Text.literal("All of the objects in " + name + " are already attached to " + name + "… wait…")); + applyEntitiesByIdToRegion(ctx, r -> rr.getEntityAttachments(r2), attach); + applyBlocksToRegion(ctx, () -> { + BlockPos.Mutable mut = new BlockPos.Mutable(); + LongIterator li = LongIterators.asLongIterator(rr.getBlockAttachments(r2).iterator()); + return new Iterator<>() { + @Override + public boolean hasNext() { + return li.hasNext(); + } + + @Override + public BlockPos next() { + mut.set(li.nextLong()); + return mut; + } + }; + }, null, attach); return 1; }) ) + .executes(ctx -> { + return 1; + }) + ) + ) + .executes(ctx -> { + if (attach) { + throw CommandUtils.GENERIC_EXCEPTION.create(Text.literal("Cowardly refusing to attach every single block and entity to this region")); + } + RenderRegion r = getRegion(ctx); + RenderRegions regions = getRegions(ctx); + int count = regions.detachAll(r); + ctx.getSource().sendFeedback(() -> Text.literal("Detached " + count + " object" + (count == 1 ? "" : "s") + " from region " + StringArgumentType.getString(ctx, "name")), true); + return count; + }) + ) + .then(literal("entities") + .then(literal("in") + .then(literal("region") + .then(argument("src-name", StringArgumentType.string()) + .suggests(RegionCommand::suggestRegionNames) + .executes(ctx -> { + return applyEntitiesToRegion(ctx, r -> ctx.getSource().getWorld().getOtherEntities(null, getRegion(ctx, "src-name").toBox()), attach); + }) + ) + .executes(ctx -> { + return applyEntitiesToRegion(ctx, r -> ctx.getSource().getWorld().getOtherEntities(null, r.toBox()), attach); + }) + ) + .then(literal("worldedit") + .requires(WORLDEDIT) + .executes(ctx -> { + return applyEntitiesToRegion(ctx, r -> ctx.getSource().getWorld().getOtherEntities(null, toBox(WorldEditCompat.getSelection(ctx))), attach); + }) + ) + ) + .then(literal("from") + .then(literal("region") + .then(argument("src-name", StringArgumentType.string()) + .suggests(RegionCommand::suggestRegionNames) + .executes(ctx -> { + return applyEntitiesToRegion(ctx, r -> ctx.getSource().getWorld().getOtherEntities(null, getRegion(ctx, "src-name").toBox()), attach); + }) + ) ) + ) + .then(argument("entities", EntityArgumentType.entities()) + .executes(ctx -> { + return applyEntitiesToRegion(ctx, r -> EntityArgumentType.getEntities(ctx, "entities"), attach); + }) + ) + ) + .then(literal("block") + .then(argument("position", BlockPosArgumentType.blockPos()) .executes(ctx -> { - if (attach) { - throw CommandUtils.GENERIC_EXCEPTION.create(Text.literal("Cowardly refusing to attach every single block and entity to this region")); - } RenderRegion r = getRegion(ctx); RenderRegions regions = getRegions(ctx); - int count = regions.detachAll(r); - ctx.getSource().sendFeedback(() -> Text.literal("Detached "+count+" object"+(count == 1 ? "" : "s")+" from region "+StringArgumentType.getString(ctx, "name")), true); - return count; + BlockPos pos = BlockPosArgumentType.getBlockPos(ctx, "position"); + if (attach) { + regions.attachBlock(r, pos.asLong()); + } else { + regions.detachBlock(r, pos.asLong()); + } + ctx.getSource().sendFeedback(() -> Text.literal("Attached block at " + pos.toShortString() + " to region " + StringArgumentType.getString(ctx, "name")), true); + return 1; }) ) - .then(literal("entities") - .then(literal("in") - .then(literal("region") - .then(argument("src-name", StringArgumentType.string()) - .suggests(RegionCommand::suggestRegionNames) - .executes(ctx -> { - return applyEntitiesToRegion(ctx, r -> ctx.getSource().getWorld().getOtherEntities(null, getRegion(ctx, "src-name").toBox()), attach); - }) - ) + ) + .then(literal("blocks") + .then(literal("in") + .then(literal("worldedit") + .requires(WORLDEDIT) + .then(argument("filter", BlockPredicateArgumentType.blockPredicate(cra)) .executes(ctx -> { - return applyEntitiesToRegion(ctx, r -> ctx.getSource().getWorld().getOtherEntities(null, r.toBox()), attach); + return applyBlocksToRegion(ctx, WorldEditCompat.getSelection(ctx), BlockPredicateArgumentType.getBlockPredicate(ctx, "filter"), attach); }) ) - .then(literal("worldedit") - .requires(WORLDEDIT) + .then(literal("entities") .executes(ctx -> { - return applyEntitiesToRegion(ctx, r -> ctx.getSource().getWorld().getOtherEntities(null, toBox(WorldEditCompat.getSelection(ctx))), attach); + return applyBlocksToRegion(ctx, WorldEditCompat.getSelection(ctx), cbp -> cbp.getBlockEntity() != null, attach); }) ) - ) - .then(literal("from") - .then(literal("region") - .then(argument("src-name", StringArgumentType.string()) - .suggests(RegionCommand::suggestRegionNames) - .executes(ctx -> { - return applyEntitiesToRegion(ctx, r -> ctx.getSource().getWorld().getOtherEntities(null, getRegion(ctx, "src-name").toBox()), attach); - }) - ) - ) - ) - .then(argument("entities", EntityArgumentType.entities()) - .executes(ctx -> { - return applyEntitiesToRegion(ctx, r -> EntityArgumentType.getEntities(ctx, "entities"), attach); - }) - ) - ) - .then(literal("block") - .then(argument("position", BlockPosArgumentType.blockPos()) .executes(ctx -> { - RenderRegion r = getRegion(ctx); - RenderRegions regions = getRegions(ctx); - BlockPos pos = BlockPosArgumentType.getBlockPos(ctx, "position"); - if (attach) { - regions.attachBlock(r, pos.asLong()); - } else { - regions.detachBlock(r, pos.asLong()); - } - ctx.getSource().sendFeedback(() -> Text.literal("Attached block at "+pos.toShortString()+" to region "+StringArgumentType.getString(ctx, "name")), true); - return 1; + return applyBlocksToRegion(ctx, WorldEditCompat.getSelection(ctx), null, attach); }) ) ) - .then(literal("blocks") - .then(literal("in") - .then(literal("worldedit") - .requires(WORLDEDIT) - .then(argument("filter", BlockPredicateArgumentType.blockPredicate(cra)) - .executes(ctx -> { - return applyBlocksToRegion(ctx, WorldEditCompat.getSelection(ctx), BlockPredicateArgumentType.getBlockPredicate(ctx, "filter"), attach); - }) - ) - .then(literal("entities") - .executes(ctx -> { - return applyBlocksToRegion(ctx, WorldEditCompat.getSelection(ctx), cbp -> cbp.getBlockEntity() != null, attach); - }) - ) + .then(argument("corner1", BlockPosArgumentType.blockPos()) + .then(argument("corner2", BlockPosArgumentType.blockPos()) + .then(literal("entities") .executes(ctx -> { - return applyBlocksToRegion(ctx, WorldEditCompat.getSelection(ctx), null, attach); + BlockPos corner1 = BlockPosArgumentType.getBlockPos(ctx, "corner1"); + BlockPos corner2 = BlockPosArgumentType.getBlockPos(ctx, "corner2"); + return applyBlocksToRegion(ctx, BlockBox.create(corner1, corner2), cbp -> cbp.getBlockEntity() != null, attach); }) ) - ) - .then(argument("corner1", BlockPosArgumentType.blockPos()) - .then(argument("corner2", BlockPosArgumentType.blockPos()) - .then(literal("entities") - .executes(ctx -> { - BlockPos corner1 = BlockPosArgumentType.getBlockPos(ctx, "corner1"); - BlockPos corner2 = BlockPosArgumentType.getBlockPos(ctx, "corner2"); - return applyBlocksToRegion(ctx, BlockBox.create(corner1, corner2), cbp -> cbp.getBlockEntity() != null, attach); - }) - ) - .then(argument("filter", BlockPredicateArgumentType.blockPredicate(cra)) - .executes(ctx -> { - BlockPos corner1 = BlockPosArgumentType.getBlockPos(ctx, "corner1"); - BlockPos corner2 = BlockPosArgumentType.getBlockPos(ctx, "corner2"); - return applyBlocksToRegion(ctx, BlockBox.create(corner1, corner2), BlockPredicateArgumentType.getBlockPredicate(ctx, "filter"), attach); - }) - ) + .then(argument("filter", BlockPredicateArgumentType.blockPredicate(cra)) .executes(ctx -> { BlockPos corner1 = BlockPosArgumentType.getBlockPos(ctx, "corner1"); BlockPos corner2 = BlockPosArgumentType.getBlockPos(ctx, "corner2"); - return applyBlocksToRegion(ctx, BlockBox.create(corner1, corner2), null, attach); + return applyBlocksToRegion(ctx, BlockBox.create(corner1, corner2), BlockPredicateArgumentType.getBlockPredicate(ctx, "filter"), attach); }) ) - ) - ) - .then(literal("be-type") - .then(argument("type", RegistryKeyArgumentType.registryKey(RegistryKeys.BLOCK_ENTITY_TYPE)) .executes(ctx -> { - RenderRegion r = getRegion(ctx); - RenderRegions regions = getRegions(ctx); - Identifier id = ctx.getArgument("type", RegistryKey.class).getValue(); - if (attach) { - regions.attachBlockEntityType(r, id); - } else { - regions.detachBlockEntityType(r, id); - } - ctx.getSource().sendFeedback(() -> Text.literal("Attached block entity type "+id+" to region "+StringArgumentType.getString(ctx, "name")), true); - return 1; + BlockPos corner1 = BlockPosArgumentType.getBlockPos(ctx, "corner1"); + BlockPos corner2 = BlockPosArgumentType.getBlockPos(ctx, "corner2"); + return applyBlocksToRegion(ctx, BlockBox.create(corner1, corner2), null, attach); }) ) ) - .then(literal("entity-type") - .then(argument("type", RegistryKeyArgumentType.registryKey(RegistryKeys.ENTITY_TYPE)) - .executes(ctx -> { - RenderRegion r = getRegion(ctx); - RenderRegions regions = getRegions(ctx); - Identifier id = ctx.getArgument("type", RegistryKey.class).getValue(); - if (attach) { - regions.attachEntityType(r, id); - } else { - regions.detachEntityType(r, id); - } - ctx.getSource().sendFeedback(() -> Text.literal("Attached entity type "+id+" to region "+StringArgumentType.getString(ctx, "name")), true); - return 1; - }) - ) + ) + .then(literal("be-type") + .then(argument("type", RegistryKeyArgumentType.registryKey(RegistryKeys.BLOCK_ENTITY_TYPE)) + .executes(ctx -> { + RenderRegion r = getRegion(ctx); + RenderRegions regions = getRegions(ctx); + Identifier id = ctx.getArgument("type", RegistryKey.class).getValue(); + if (attach) { + regions.attachBlockEntityType(r, id); + } else { + regions.detachBlockEntityType(r, id); + } + ctx.getSource().sendFeedback(() -> Text.literal("Attached block entity type " + id + " to region " + StringArgumentType.getString(ctx, "name")), true); + return 1; + }) + ) + ) + .then(literal("entity-type") + .then(argument("type", RegistryKeyArgumentType.registryKey(RegistryKeys.ENTITY_TYPE)) + .executes(ctx -> { + RenderRegion r = getRegion(ctx); + RenderRegions regions = getRegions(ctx); + Identifier id = ctx.getArgument("type", RegistryKey.class).getValue(); + if (attach) { + regions.attachEntityType(r, id); + } else { + regions.detachEntityType(r, id); + } + ctx.getSource().sendFeedback(() -> Text.literal("Attached entity type " + id + " to region " + StringArgumentType.getString(ctx, "name")), true); + return 1; + }) ) - ); + ) + ); } private static Box toBox(BlockBox bb) { return new Box(bb.getMinX(), bb.getMinY(), bb.getMinZ(), - bb.getMaxX(), bb.getMaxY(), bb.getMaxZ()); + bb.getMaxX(), bb.getMaxY(), bb.getMaxZ()); } - + private static Iterable iterate(BlockBox region) { return BlockPos.iterate(region.getMinX(), region.getMinY(), region.getMinZ(), - region.getMaxX(), region.getMaxY(), region.getMaxZ()); + region.getMaxX(), region.getMaxY(), region.getMaxZ()); } private interface EntitySource { Iterable supply(RenderRegion region) throws CommandSyntaxException; } - + private interface UUIDSource { Iterable supply(RenderRegion region) throws CommandSyntaxException; } @@ -509,22 +508,22 @@ private static int applyBlocksToRegion(CommandContext ctx, if (count == 0) { throw CommandUtils.GENERIC_EXCEPTION.create(Text.literal("None of the blocks matched the filter")); } else { - ctx.getSource().sendFeedback(() -> Text.literal("Attached "+fcount+" block"+(fcount == 1 ? "" : "s")+" to region "+StringArgumentType.getString(ctx, "name")), true); + ctx.getSource().sendFeedback(() -> Text.literal("Attached " + fcount + " block" + (fcount == 1 ? "" : "s") + " to region " + StringArgumentType.getString(ctx, "name")), true); } } else { if (count == 0) { throw CommandUtils.GENERIC_EXCEPTION.create(Text.literal("None of those blocks are attached to the region")); } else { - ctx.getSource().sendFeedback(() -> Text.literal("Detached "+fcount+" block"+(fcount == 1 ? "" : "s")+" from region "+StringArgumentType.getString(ctx, "name")), true); + ctx.getSource().sendFeedback(() -> Text.literal("Detached " + fcount + " block" + (fcount == 1 ? "" : "s") + " from region " + StringArgumentType.getString(ctx, "name")), true); } } return count; } - + private static int applyEntitiesToRegion(CommandContext ctx, EntitySource src, boolean attach) throws CommandSyntaxException { return applyEntitiesByIdToRegion(ctx, r -> Iterables.transform(src.supply(r), Entity::getUuid), attach); } - + private static int applyEntitiesByIdToRegion(CommandContext ctx, UUIDSource src, boolean attach) throws CommandSyntaxException { RenderRegion r = getRegion(ctx); RenderRegions regions = getRegions(ctx); @@ -541,7 +540,7 @@ private static int applyEntitiesByIdToRegion(CommandContext } final int fcount = count; if (attach) { - ctx.getSource().sendFeedback(() -> Text.literal("Attached "+fcount+" entit"+(fcount == 1 ? "y" : "ies")+" to region "+StringArgumentType.getString(ctx, "name")), true); + ctx.getSource().sendFeedback(() -> Text.literal("Attached " + fcount + " entit" + (fcount == 1 ? "y" : "ies") + " to region " + StringArgumentType.getString(ctx, "name")), true); } else { if (count == 0) { if (anything) { @@ -550,7 +549,7 @@ private static int applyEntitiesByIdToRegion(CommandContext throw CommandUtils.GENERIC_EXCEPTION.create(Text.literal("No entities were specified")); } } else { - ctx.getSource().sendFeedback(() -> Text.literal("Detached "+fcount+" entit"+(fcount == 1 ? "y" : "ies")+" from region "+StringArgumentType.getString(ctx, "name")), true); + ctx.getSource().sendFeedback(() -> Text.literal("Detached " + fcount + " entit" + (fcount == 1 ? "y" : "ies") + " from region " + StringArgumentType.getString(ctx, "name")), true); } } return count; @@ -567,7 +566,7 @@ private static RenderRegion getRegion(CommandContext ctx) t private static RenderRegion getRegion(CommandContext ctx, String tgt) throws CommandSyntaxException { String name = StringArgumentType.getString(ctx, tgt); RenderRegion r = getRegions(ctx).getByName(name); - if (r == null) throw CommandUtils.GENERIC_EXCEPTION.create(Text.literal("No render region with name \""+name+"\" exists")); + if (r == null) throw CommandUtils.GENERIC_EXCEPTION.create(Text.literal("No render region with name \"" + name + "\" exists")); return r; } @@ -587,7 +586,7 @@ public static int addRegion(CommandContext ctx, RenderRegio throw CommandUtils.GENERIC_EXCEPTION.create(Text.literal("A region with that name already exists")); } regions.add(name, rr); - ctx.getSource().sendFeedback(() -> Text.literal("Created new "+rr.mode().name().toLowerCase(Locale.ROOT)+" region "+name), true); + ctx.getSource().sendFeedback(() -> Text.literal("Created new " + rr.mode().name().toLowerCase(Locale.ROOT) + " region " + name), true); return 1; } diff --git a/src/main/java/net/modfest/fireblanket/compat/PolyMcAccess.java b/src/main/java/net/modfest/fireblanket/compat/PolyMcAccess.java index 7ec782b..44e6efd 100644 --- a/src/main/java/net/modfest/fireblanket/compat/PolyMcAccess.java +++ b/src/main/java/net/modfest/fireblanket/compat/PolyMcAccess.java @@ -5,9 +5,9 @@ public class PolyMcAccess { public static BooleanSupplier isActive = () -> false; - + public static boolean isActive() { return isActive.getAsBoolean(); } - + } diff --git a/src/main/java/net/modfest/fireblanket/compat/PolyMcCompat.java b/src/main/java/net/modfest/fireblanket/compat/PolyMcCompat.java index ec55390..1cd36d5 100644 --- a/src/main/java/net/modfest/fireblanket/compat/PolyMcCompat.java +++ b/src/main/java/net/modfest/fireblanket/compat/PolyMcCompat.java @@ -12,5 +12,5 @@ public static void init() { return polyPlayer != null && Util.tryGetPolyMap(polyPlayer).isVanillaLikeMap(); }; } - + } diff --git a/src/main/java/net/modfest/fireblanket/compat/WorldEditCompat.java b/src/main/java/net/modfest/fireblanket/compat/WorldEditCompat.java index 19acd0d..cf61c65 100644 --- a/src/main/java/net/modfest/fireblanket/compat/WorldEditCompat.java +++ b/src/main/java/net/modfest/fireblanket/compat/WorldEditCompat.java @@ -12,7 +12,6 @@ import com.sk89q.worldedit.regions.selector.CuboidRegionSelector; import com.sk89q.worldedit.regions.selector.limit.PermissiveSelectorLimits; import com.sk89q.worldedit.world.World; - import net.minecraft.server.command.ServerCommandSource; import net.minecraft.text.Text; import net.minecraft.util.math.BlockBox; @@ -31,7 +30,7 @@ public static BlockBox getSelection(CommandContext ctx) thr if (region instanceof CuboidRegion cr) { BlockVector3 min = cr.getMinimumPoint(); BlockVector3 max = cr.getMaximumPoint(); - return new BlockBox(min.getX(), min.getY(), min.getZ(), max.getX(), max.getY(), max.getZ()); + return new BlockBox(min.x(), min.y(), min.z(), max.x(), max.y(), max.z()); } else { throw CommandUtils.GENERIC_EXCEPTION.create(Text.literal("Only cuboid regions are supported.")); } @@ -47,5 +46,5 @@ public static void setSelection(CommandContext ctx, BlockBo localSession.dispatchCUISelection(FabricAdapter.adaptCommandSource(ctx.getSource())); } - + } diff --git a/src/main/java/net/modfest/fireblanket/mixin/accessor/ClientConnectionAccessor.java b/src/main/java/net/modfest/fireblanket/mixin/accessor/ClientConnectionAccessor.java index 0c878ca..88349db 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/accessor/ClientConnectionAccessor.java +++ b/src/main/java/net/modfest/fireblanket/mixin/accessor/ClientConnectionAccessor.java @@ -1,13 +1,12 @@ package net.modfest.fireblanket.mixin.accessor; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; -import org.spongepowered.asm.mixin.gen.Invoker; - import io.netty.channel.Channel; import net.minecraft.network.ClientConnection; import net.minecraft.network.PacketCallbacks; import net.minecraft.network.packet.Packet; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; +import org.spongepowered.asm.mixin.gen.Invoker; @Mixin(ClientConnection.class) public interface ClientConnectionAccessor { @@ -17,5 +16,5 @@ public interface ClientConnectionAccessor { @Accessor("channel") Channel fireblanket$getChannel(); - + } diff --git a/src/main/java/net/modfest/fireblanket/mixin/accessor/ClientLoginNetworkHandlerAccessor.java b/src/main/java/net/modfest/fireblanket/mixin/accessor/ClientLoginNetworkHandlerAccessor.java index 6af5ce9..ba21da0 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/accessor/ClientLoginNetworkHandlerAccessor.java +++ b/src/main/java/net/modfest/fireblanket/mixin/accessor/ClientLoginNetworkHandlerAccessor.java @@ -1,15 +1,14 @@ package net.modfest.fireblanket.mixin.accessor; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - import net.minecraft.client.network.ClientLoginNetworkHandler; import net.minecraft.network.ClientConnection; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; @Mixin(ClientLoginNetworkHandler.class) public interface ClientLoginNetworkHandlerAccessor { @Accessor("connection") ClientConnection fireblanket$getConnection(); - + } diff --git a/src/main/java/net/modfest/fireblanket/mixin/accessor/ServerChunkManagerAccessor.java b/src/main/java/net/modfest/fireblanket/mixin/accessor/ServerChunkManagerAccessor.java index 3a97bf4..29401a2 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/accessor/ServerChunkManagerAccessor.java +++ b/src/main/java/net/modfest/fireblanket/mixin/accessor/ServerChunkManagerAccessor.java @@ -1,15 +1,14 @@ package net.modfest.fireblanket.mixin.accessor; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - import net.minecraft.server.world.ChunkTicketManager; import net.minecraft.server.world.ServerChunkManager; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; @Mixin(ServerChunkManager.class) public interface ServerChunkManagerAccessor { @Accessor("ticketManager") ChunkTicketManager fireblanket$getTicketManager(); - + } diff --git a/src/main/java/net/modfest/fireblanket/mixin/accessor/ServerLoginNetworkHandlerAccessor.java b/src/main/java/net/modfest/fireblanket/mixin/accessor/ServerLoginNetworkHandlerAccessor.java index a826b54..7fc5ca7 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/accessor/ServerLoginNetworkHandlerAccessor.java +++ b/src/main/java/net/modfest/fireblanket/mixin/accessor/ServerLoginNetworkHandlerAccessor.java @@ -1,15 +1,14 @@ package net.modfest.fireblanket.mixin.accessor; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - import net.minecraft.network.ClientConnection; import net.minecraft.server.network.ServerLoginNetworkHandler; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; @Mixin(ServerLoginNetworkHandler.class) public interface ServerLoginNetworkHandlerAccessor { @Accessor("connection") ClientConnection fireblanket$getConnection(); - + } diff --git a/src/main/java/net/modfest/fireblanket/mixin/adventure_fix/MixinEggItem.java b/src/main/java/net/modfest/fireblanket/mixin/adventure_fix/MixinEggItem.java index 926e9a7..b172f51 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/adventure_fix/MixinEggItem.java +++ b/src/main/java/net/modfest/fireblanket/mixin/adventure_fix/MixinEggItem.java @@ -7,7 +7,6 @@ import net.minecraft.util.TypedActionResult; import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; diff --git a/src/main/java/net/modfest/fireblanket/mixin/adventure_fix/MixinFlowerPotBlock.java b/src/main/java/net/modfest/fireblanket/mixin/adventure_fix/MixinFlowerPotBlock.java index 72a3585..4866e07 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/adventure_fix/MixinFlowerPotBlock.java +++ b/src/main/java/net/modfest/fireblanket/mixin/adventure_fix/MixinFlowerPotBlock.java @@ -1,28 +1,26 @@ package net.modfest.fireblanket.mixin.adventure_fix; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - import net.minecraft.block.BlockState; import net.minecraft.block.FlowerPotBlock; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.ActionResult; -import net.minecraft.util.Hand; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(FlowerPotBlock.class) public class MixinFlowerPotBlock { - @Inject(at=@At("HEAD"), method="onUse", cancellable=true) + @Inject(at = @At("HEAD"), method = "onUse", cancellable = true) public void fireblanket$noStealPotsInAdventure(BlockState state, World world, BlockPos pos, PlayerEntity player, BlockHitResult hit, - CallbackInfoReturnable ci) { + CallbackInfoReturnable ci) { if (!player.canModifyBlocks()) { ci.setReturnValue(ActionResult.FAIL); } } - + } diff --git a/src/main/java/net/modfest/fireblanket/mixin/ai/MixinTemptGoal.java b/src/main/java/net/modfest/fireblanket/mixin/ai/MixinTemptGoal.java index b9ff1ea..2394aca 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/ai/MixinTemptGoal.java +++ b/src/main/java/net/modfest/fireblanket/mixin/ai/MixinTemptGoal.java @@ -8,7 +8,6 @@ public class MixinTemptGoal { /** * @author Jasmine - * * @reason Hey, at least it's better than injecting unconditionally at head. */ @Overwrite diff --git a/src/main/java/net/modfest/fireblanket/mixin/be_sync/MixinChunkHolder.java b/src/main/java/net/modfest/fireblanket/mixin/be_sync/MixinChunkHolder.java index b8e9258..243a062 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/be_sync/MixinChunkHolder.java +++ b/src/main/java/net/modfest/fireblanket/mixin/be_sync/MixinChunkHolder.java @@ -1,35 +1,9 @@ package net.modfest.fireblanket.mixin.be_sync; -import io.netty.buffer.Unpooled; -import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; -import net.minecraft.block.BlockState; -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.nbt.NbtCompound; -import net.minecraft.network.RegistryByteBuf; -import net.minecraft.network.packet.Packet; -import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket; -import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ChunkHolder; -import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkPos; -import net.minecraft.world.World; import net.minecraft.world.chunk.AbstractChunkHolder; -import net.minecraft.world.chunk.WorldChunk; -import net.modfest.fireblanket.net.BEUpdate; -import net.modfest.fireblanket.net.BatchedBEUpdatePayload; -import net.modfest.fireblanket.world.CachedCompoundBE; -import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; @Mixin(ChunkHolder.class) public abstract class MixinChunkHolder extends AbstractChunkHolder { diff --git a/src/main/java/net/modfest/fireblanket/mixin/block/MixinCommandBlock.java b/src/main/java/net/modfest/fireblanket/mixin/block/MixinCommandBlock.java index 6eeb504..b46e74f 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/block/MixinCommandBlock.java +++ b/src/main/java/net/modfest/fireblanket/mixin/block/MixinCommandBlock.java @@ -1,18 +1,15 @@ package net.modfest.fireblanket.mixin.block; -import net.fabricmc.fabric.api.networking.v1.PacketByteBufs; import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; import net.minecraft.block.BlockState; import net.minecraft.block.BlockWithEntity; import net.minecraft.block.CommandBlock; import net.minecraft.entity.LivingEntity; import net.minecraft.item.ItemStack; -import net.minecraft.network.codec.PacketCodec; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import net.modfest.fireblanket.Fireblanket; import net.modfest.fireblanket.net.CommandBlockPacket; import net.modfest.fireblanket.world.RepeatingBlockState; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/net/modfest/fireblanket/mixin/block_format/MixinChunkSection.java b/src/main/java/net/modfest/fireblanket/mixin/block_format/MixinChunkSection.java index 1074b9e..2102cf2 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/block_format/MixinChunkSection.java +++ b/src/main/java/net/modfest/fireblanket/mixin/block_format/MixinChunkSection.java @@ -38,10 +38,15 @@ public abstract class MixinChunkSection { private static final int MASK_BITS = 1048575; - @Shadow @Final private PalettedContainer blockStateContainer; - @Shadow private short nonEmptyBlockCount; - @Shadow private short nonEmptyFluidCount; - @Shadow private short randomTickableBlockCount; + @Shadow + @Final + private PalettedContainer blockStateContainer; + @Shadow + private short nonEmptyBlockCount; + @Shadow + private short nonEmptyFluidCount; + @Shadow + private short randomTickableBlockCount; // 20 bits per block, so 3 blocks per long. ceil(4096/3) --> 1366 private final long[] fireblanket$denseBlockStorage = new long[1366]; @@ -70,7 +75,6 @@ public abstract class MixinChunkSection { /** * @author Jasmine - * * @reason Optimized with flat array */ @Overwrite @@ -88,7 +92,7 @@ public BlockState setBlockState(int x, int y, int z, BlockState state, boolean l try { // Get the old state that we already see long oldBits = this.fireblanket$denseBlockStorage[arrIdx]; - oldState = FlatBlockstateArray.FROM_ID[((int)(oldBits >>> shift) & MASK_BITS)]; + oldState = FlatBlockstateArray.FROM_ID[((int) (oldBits >>> shift) & MASK_BITS)]; // Make data for the new state long newId = Block.STATE_IDS.getRawId(state); @@ -107,8 +111,8 @@ public BlockState setBlockState(int x, int y, int z, BlockState state, boolean l if (this.fireblanket$stamp.get() != stamp) { Map traces = Thread.getAllStackTraces(); String dumps = traces.entrySet().stream() - .map(MixinChunkSection::formatThreadDump) - .collect(Collectors.joining("\n")); + .map(MixinChunkSection::formatThreadDump) + .collect(Collectors.joining("\n")); String error = "Accessing ChunkSection from multiple threads!"; CrashReport crashReport = new CrashReport(error, new IllegalStateException(error)); @@ -153,7 +157,6 @@ private static String formatThreadDump(Map.Entry e) /** * @author Jasmine - * * @reason Optimized with flat array */ @Overwrite @@ -176,7 +179,6 @@ private static int arrayIndex(int x, int y, int z) { /** * @author Jasmine - * * @reason Optimized with flat array. Vanilla duplicates the getBlockState logic, whereas here just calls the * method for simplicity */ @@ -187,7 +189,6 @@ public FluidState getFluidState(int x, int y, int z) { /** * @author Jasmine - * * @reason Flush all updates to the container */ @Overwrite @@ -233,7 +234,6 @@ public PalettedContainer getBlockStateContainer() { /** * @author Jasmine - * * @reason We don't really need this */ @Overwrite diff --git a/src/main/java/net/modfest/fireblanket/mixin/client/MixinClientPlayNetworkHandler.java b/src/main/java/net/modfest/fireblanket/mixin/client/MixinClientPlayNetworkHandler.java index ec51bbb..9112241 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/client/MixinClientPlayNetworkHandler.java +++ b/src/main/java/net/modfest/fireblanket/mixin/client/MixinClientPlayNetworkHandler.java @@ -8,8 +8,9 @@ @Mixin(value = ClientPlayNetworkHandler.class, priority = 10000) public class MixinClientPlayNetworkHandler { - // Get rid of "Received passengers for unknown entity" warning that spams logs - @Redirect(method = "onEntityPassengersSet(Lnet/minecraft/network/packet/s2c/play/EntityPassengersSetS2CPacket;)V", - at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;)V")) - private void fireblanket$yeetPassengerError(Logger instance, String s) {} + // Get rid of "Received passengers for unknown entity" warning that spams logs + @Redirect(method = "onEntityPassengersSet(Lnet/minecraft/network/packet/s2c/play/EntityPassengersSetS2CPacket;)V", + at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;)V")) + private void fireblanket$yeetPassengerError(Logger instance, String s) { + } } diff --git a/src/main/java/net/modfest/fireblanket/mixin/client/MixinRenderSystem.java b/src/main/java/net/modfest/fireblanket/mixin/client/MixinRenderSystem.java index 8a1f924..5c10196 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/client/MixinRenderSystem.java +++ b/src/main/java/net/modfest/fireblanket/mixin/client/MixinRenderSystem.java @@ -1,23 +1,23 @@ package net.modfest.fireblanket.mixin.client; -import java.util.concurrent.ConcurrentLinkedQueue; - +import com.mojang.blaze3d.systems.RenderCall; +import com.mojang.blaze3d.systems.RenderSystem; +import net.modfest.fireblanket.Fireblanket; +import net.modfest.fireblanket.client.BlamefulRenderCall; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.Shadow; -import com.mojang.blaze3d.systems.RenderCall; -import com.mojang.blaze3d.systems.RenderSystem; -import net.modfest.fireblanket.Fireblanket; -import net.modfest.fireblanket.client.BlamefulRenderCall; +import java.util.concurrent.ConcurrentLinkedQueue; @Mixin(RenderSystem.class) public class MixinRenderSystem { - @Shadow @Final + @Shadow + @Final private static ConcurrentLinkedQueue recordingQueue; - + /** * @author Una * @reason Add blame and log when dubious things occur @@ -29,5 +29,5 @@ public static void recordRenderCall(RenderCall renderCall) { } recordingQueue.add(new BlamefulRenderCall(renderCall)); } - + } diff --git a/src/main/java/net/modfest/fireblanket/mixin/client/MixinSignBlockEntityRenderer.java b/src/main/java/net/modfest/fireblanket/mixin/client/MixinSignBlockEntityRenderer.java index b85b406..500b446 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/client/MixinSignBlockEntityRenderer.java +++ b/src/main/java/net/modfest/fireblanket/mixin/client/MixinSignBlockEntityRenderer.java @@ -1,22 +1,21 @@ package net.modfest.fireblanket.mixin.client; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - import net.minecraft.block.entity.SignBlockEntity; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.block.entity.SignBlockEntityRenderer; import net.minecraft.client.util.math.MatrixStack; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; // priority to dodge PictureSign -@Mixin(value=SignBlockEntityRenderer.class, priority=5000) +@Mixin(value = SignBlockEntityRenderer.class, priority = 5000) public class MixinSignBlockEntityRenderer { - @Inject(at=@At("HEAD"), method="render", cancellable=true) + @Inject(at = @At("HEAD"), method = "render", cancellable = true) public void fireblanket$DontRenderHiddenSigns(SignBlockEntity entity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay, CallbackInfo ci) { if (light == 0) ci.cancel(); } - + } diff --git a/src/main/java/net/modfest/fireblanket/mixin/client/be_masking/MixinBlockEntityRenderDispatcher.java b/src/main/java/net/modfest/fireblanket/mixin/client/be_masking/MixinBlockEntityRenderDispatcher.java index ddf9fd2..522d319 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/client/be_masking/MixinBlockEntityRenderDispatcher.java +++ b/src/main/java/net/modfest/fireblanket/mixin/client/be_masking/MixinBlockEntityRenderDispatcher.java @@ -5,7 +5,6 @@ import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher; import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.registry.Registries; import net.modfest.fireblanket.client.ClientState; import net.modfest.fireblanket.client.render.QuadEmitter; import net.modfest.fireblanket.client.render.RenderLayers; diff --git a/src/main/java/net/modfest/fireblanket/mixin/client/be_masking/MixinRebuildTask.java b/src/main/java/net/modfest/fireblanket/mixin/client/be_masking/MixinRebuildTask.java index ab0ac60..5bc55cd 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/client/be_masking/MixinRebuildTask.java +++ b/src/main/java/net/modfest/fireblanket/mixin/client/be_masking/MixinRebuildTask.java @@ -1,14 +1,7 @@ package net.modfest.fireblanket.mixin.client.be_masking; -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.render.block.entity.BlockEntityRenderer; import net.minecraft.client.render.chunk.ChunkBuilder; -import net.modfest.fireblanket.client.ClientState; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(ChunkBuilder.BuiltChunk.RebuildTask.class) public class MixinRebuildTask { diff --git a/src/main/java/net/modfest/fireblanket/mixin/client/bufferbuilder_opto/MixinBufferBuilder.java b/src/main/java/net/modfest/fireblanket/mixin/client/bufferbuilder_opto/MixinBufferBuilder.java index c03b683..81b61f7 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/client/bufferbuilder_opto/MixinBufferBuilder.java +++ b/src/main/java/net/modfest/fireblanket/mixin/client/bufferbuilder_opto/MixinBufferBuilder.java @@ -1,20 +1,8 @@ package net.modfest.fireblanket.mixin.client.bufferbuilder_opto; -import java.nio.ByteBuffer; - +import net.minecraft.client.render.BufferBuilder; import net.minecraft.client.render.VertexConsumer; -import net.minecraft.client.util.BufferAllocator; -import org.lwjgl.system.MemoryUtil; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import net.minecraft.client.render.BufferBuilder; -import net.minecraft.client.render.VertexFormat; -import net.minecraft.client.render.VertexFormatElement; -import net.modfest.fireblanket.client.render.ExtendedVertexFormat; @Mixin(BufferBuilder.class) public abstract class MixinBufferBuilder /*extends FixedColorVertexConsumer*/ implements VertexConsumer { diff --git a/src/main/java/net/modfest/fireblanket/mixin/client/bufferbuilder_opto/MixinVertexFormat.java b/src/main/java/net/modfest/fireblanket/mixin/client/bufferbuilder_opto/MixinVertexFormat.java index 8fb53f2..d8ffe5a 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/client/bufferbuilder_opto/MixinVertexFormat.java +++ b/src/main/java/net/modfest/fireblanket/mixin/client/bufferbuilder_opto/MixinVertexFormat.java @@ -1,18 +1,8 @@ package net.modfest.fireblanket.mixin.client.bufferbuilder_opto; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; - import net.minecraft.client.render.VertexFormat; -import net.minecraft.client.render.VertexFormatElement; import net.modfest.fireblanket.client.render.ExtendedVertexFormat; +import org.spongepowered.asm.mixin.Mixin; @Mixin(VertexFormat.class) public abstract class MixinVertexFormat implements ExtendedVertexFormat { diff --git a/src/main/java/net/modfest/fireblanket/mixin/client/entity_masking/MixinEntityRenderer.java b/src/main/java/net/modfest/fireblanket/mixin/client/entity_masking/MixinEntityRenderer.java index 96f9641..f021932 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/client/entity_masking/MixinEntityRenderer.java +++ b/src/main/java/net/modfest/fireblanket/mixin/client/entity_masking/MixinEntityRenderer.java @@ -5,7 +5,6 @@ import net.minecraft.client.render.entity.EntityRenderer; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.Entity; -import net.minecraft.registry.Registries; import net.minecraft.util.math.Box; import net.modfest.fireblanket.client.ClientState; import net.modfest.fireblanket.client.render.QuadEmitter; @@ -17,19 +16,19 @@ @Mixin(EntityRenderer.class) public class MixinEntityRenderer { - @Inject(method = "render(Lnet/minecraft/entity/Entity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At("HEAD")) - private void fireblanket$renderMaskedEntities(T entity, float yaw, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) { - if (ClientState.MASKED_ENTITIES.contains(entity.getType())) { - VertexConsumer buffer = vertexConsumers.getBuffer(RenderLayers.TRANSLUCENT_BROKEN_DEPTH); + @Inject(method = "render(Lnet/minecraft/entity/Entity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At("HEAD")) + private void fireblanket$renderMaskedEntities(T entity, float yaw, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) { + if (ClientState.MASKED_ENTITIES.contains(entity.getType())) { + VertexConsumer buffer = vertexConsumers.getBuffer(RenderLayers.TRANSLUCENT_BROKEN_DEPTH); - Box box = entity.getBoundingBox().offset(-entity.getX(), -entity.getY(), -entity.getZ()); + Box box = entity.getBoundingBox().offset(-entity.getX(), -entity.getY(), -entity.getZ()); - QuadEmitter.buildBox(buffer, matrices, (float) box.minX, (float) box.maxX, (float) box.minY, (float) box.maxY, (float) box.minZ, (float) box.maxZ, 30, 200, 220, 40); + QuadEmitter.buildBox(buffer, matrices, (float) box.minX, (float) box.maxX, (float) box.minY, (float) box.maxY, (float) box.minZ, (float) box.maxZ, 30, 200, 220, 40); - // Please let this be a normal field trip - if (vertexConsumers instanceof VertexConsumerProvider.Immediate imm) { - imm.draw(); - } - } - } + // Please let this be a normal field trip + if (vertexConsumers instanceof VertexConsumerProvider.Immediate imm) { + imm.draw(); + } + } + } } diff --git a/src/main/java/net/modfest/fireblanket/mixin/client/entity_ticking/MixinArmorStandEntity.java b/src/main/java/net/modfest/fireblanket/mixin/client/entity_ticking/MixinArmorStandEntity.java index 542ff8c..2b2e6d4 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/client/entity_ticking/MixinArmorStandEntity.java +++ b/src/main/java/net/modfest/fireblanket/mixin/client/entity_ticking/MixinArmorStandEntity.java @@ -5,7 +5,6 @@ import net.minecraft.entity.decoration.ArmorStandEntity; import net.minecraft.world.World; import net.modfest.fireblanket.world.entity.EntityTick; - import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; diff --git a/src/main/java/net/modfest/fireblanket/mixin/client/entity_ticking/MixinLivingEntity.java b/src/main/java/net/modfest/fireblanket/mixin/client/entity_ticking/MixinLivingEntity.java index 3bfb343..51b2e54 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/client/entity_ticking/MixinLivingEntity.java +++ b/src/main/java/net/modfest/fireblanket/mixin/client/entity_ticking/MixinLivingEntity.java @@ -6,17 +6,16 @@ import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.ModifyVariable; @Mixin(LivingEntity.class) public abstract class MixinLivingEntity extends Entity { - public MixinLivingEntity(EntityType type, World world) { - super(type, world); - } + public MixinLivingEntity(EntityType type, World world) { + super(type, world); + } - @ModifyVariable(method = {"updateTrackedPositionAndAngles", "updateTrackedHeadRotation"}, at = @At(value = "HEAD"), ordinal = 0) - private int fireblanket$smoothOutClientMovement(int interpolationSteps) { - return Math.max(interpolationSteps, this.getType().getTrackTickInterval()); - } + @ModifyVariable(method = {"updateTrackedPositionAndAngles", "updateTrackedHeadRotation"}, at = @At(value = "HEAD"), ordinal = 0) + private int fireblanket$smoothOutClientMovement(int interpolationSteps) { + return Math.max(interpolationSteps, this.getType().getTrackTickInterval()); + } } diff --git a/src/main/java/net/modfest/fireblanket/mixin/client/lambdamap/MixinMapRegionFile.java b/src/main/java/net/modfest/fireblanket/mixin/client/lambdamap/MixinMapRegionFile.java index 711d317..79027f8 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/client/lambdamap/MixinMapRegionFile.java +++ b/src/main/java/net/modfest/fireblanket/mixin/client/lambdamap/MixinMapRegionFile.java @@ -8,10 +8,10 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Pseudo -@Mixin(targets="dev/lambdaurora/lambdamap/map/storage/MapRegionFile") +@Mixin(targets = "dev/lambdaurora/lambdamap/map/storage/MapRegionFile") public class MixinMapRegionFile { - - @Inject(at=@At("HEAD"), method="saveChunk", cancellable=true) + + @Inject(at = @At("HEAD"), method = "saveChunk", cancellable = true) public void saveChunk(@Coerce Object mapChunk, CallbackInfo ci) { // Does DEFLATE on-thread. Laggy as fuck and we don't need it since we're shipping a // complete map with the pack. diff --git a/src/main/java/net/modfest/fireblanket/mixin/client/render_regions/MixinBlockEntityRenderDispatcher.java b/src/main/java/net/modfest/fireblanket/mixin/client/render_regions/MixinBlockEntityRenderDispatcher.java index 7fde65e..a722377 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/client/render_regions/MixinBlockEntityRenderDispatcher.java +++ b/src/main/java/net/modfest/fireblanket/mixin/client/render_regions/MixinBlockEntityRenderDispatcher.java @@ -1,25 +1,25 @@ package net.modfest.fireblanket.mixin.client.render_regions; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import net.minecraft.block.entity.BlockEntity; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher; import net.minecraft.client.render.block.entity.BlockEntityRenderer; import net.minecraft.client.util.math.MatrixStack; import net.modfest.fireblanket.FireblanketClient; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(BlockEntityRenderDispatcher.class) public class MixinBlockEntityRenderDispatcher { - @Inject(at=@At("HEAD"), method="render(Lnet/minecraft/client/render/block/entity/BlockEntityRenderer;Lnet/minecraft/block/entity/BlockEntity;FLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;)V", cancellable=true) + @Inject(at = @At("HEAD"), method = "render(Lnet/minecraft/client/render/block/entity/BlockEntityRenderer;Lnet/minecraft/block/entity/BlockEntity;FLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;)V", cancellable = true) private static void render(BlockEntityRenderer renderer, BlockEntity be, float delta, MatrixStack matrices, VertexConsumerProvider vcp, - CallbackInfo ci) { + CallbackInfo ci) { if (!FireblanketClient.shouldRender(be)) { ci.cancel(); } } - + } diff --git a/src/main/java/net/modfest/fireblanket/mixin/client/render_regions/MixinEntityRenderDispatcher.java b/src/main/java/net/modfest/fireblanket/mixin/client/render_regions/MixinEntityRenderDispatcher.java index 94e1e7d..e3edc75 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/client/render_regions/MixinEntityRenderDispatcher.java +++ b/src/main/java/net/modfest/fireblanket/mixin/client/render_regions/MixinEntityRenderDispatcher.java @@ -1,23 +1,22 @@ package net.modfest.fireblanket.mixin.client.render_regions; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - import net.minecraft.client.render.Frustum; import net.minecraft.client.render.entity.EntityRenderDispatcher; import net.minecraft.entity.Entity; import net.modfest.fireblanket.FireblanketClient; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(EntityRenderDispatcher.class) public class MixinEntityRenderDispatcher { - @Inject(at=@At("RETURN"), method="shouldRender", cancellable=true) + @Inject(at = @At("RETURN"), method = "shouldRender", cancellable = true) public void shouldRender(Entity entity, Frustum frustum, double x, double y, double z, CallbackInfoReturnable ci) { if (ci.getReturnValueZ() && !FireblanketClient.shouldRender(entity)) { ci.setReturnValue(false); } } - + } diff --git a/src/main/java/net/modfest/fireblanket/mixin/client/render_regions/MixinRegionSubjects.java b/src/main/java/net/modfest/fireblanket/mixin/client/render_regions/MixinRegionSubjects.java index 0a155dc..558654b 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/client/render_regions/MixinRegionSubjects.java +++ b/src/main/java/net/modfest/fireblanket/mixin/client/render_regions/MixinRegionSubjects.java @@ -1,10 +1,9 @@ package net.modfest.fireblanket.mixin.client.render_regions; -import org.spongepowered.asm.mixin.Mixin; - import net.minecraft.block.entity.BlockEntity; import net.minecraft.entity.Entity; import net.modfest.fireblanket.world.render_regions.RegionSubject; +import org.spongepowered.asm.mixin.Mixin; @Mixin({Entity.class, BlockEntity.class}) public class MixinRegionSubjects implements RegionSubject { @@ -12,7 +11,7 @@ public class MixinRegionSubjects implements RegionSubject { private int fireblanket$regionEra = -1; private boolean fireblanket$shouldRender = true; private long fireblanket$viewerPos = Long.MIN_VALUE; - + @Override public int fireblanket$getRegionEra() { return fireblanket$regionEra; @@ -35,6 +34,5 @@ public class MixinRegionSubjects implements RegionSubject { fireblanket$shouldRender = shouldRender; } - - + } diff --git a/src/main/java/net/modfest/fireblanket/mixin/client/timing/MixinBlockEntityRenderDispatcher.java b/src/main/java/net/modfest/fireblanket/mixin/client/timing/MixinBlockEntityRenderDispatcher.java index 28c257d..afd525d 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/client/timing/MixinBlockEntityRenderDispatcher.java +++ b/src/main/java/net/modfest/fireblanket/mixin/client/timing/MixinBlockEntityRenderDispatcher.java @@ -1,15 +1,12 @@ package net.modfest.fireblanket.mixin.client.timing; import net.minecraft.block.entity.BlockEntity; -import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher; import net.minecraft.client.render.debug.DebugRenderer; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.math.BlockPos; import net.modfest.fireblanket.client.ClientState; -import net.modfest.fireblanket.client.render.QuadEmitter; -import net.modfest.fireblanket.client.render.RenderLayers; import net.modfest.fireblanket.mixinsupport.ObservableTicks; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -34,10 +31,10 @@ public class MixinBlockEntityRenderDispatcher { } DebugRenderer.drawString(matrices, vertexConsumers, s, - pos.getX() + 0.5, - pos.getY() + 0.5, - pos.getZ() + 0.5, - color, 0.03F, true, 0, true); + pos.getX() + 0.5, + pos.getY() + 0.5, + pos.getZ() + 0.5, + color, 0.03F, true, 0, true); } } } diff --git a/src/main/java/net/modfest/fireblanket/mixin/client/timing/MixinEntityRenderer.java b/src/main/java/net/modfest/fireblanket/mixin/client/timing/MixinEntityRenderer.java index 74f4c55..2e1d9dd 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/client/timing/MixinEntityRenderer.java +++ b/src/main/java/net/modfest/fireblanket/mixin/client/timing/MixinEntityRenderer.java @@ -1,6 +1,5 @@ package net.modfest.fireblanket.mixin.client.timing; -import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.debug.DebugRenderer; import net.minecraft.client.render.entity.EntityRenderer; @@ -8,8 +7,6 @@ import net.minecraft.entity.Entity; import net.minecraft.util.math.Box; import net.modfest.fireblanket.client.ClientState; -import net.modfest.fireblanket.client.render.QuadEmitter; -import net.modfest.fireblanket.client.render.RenderLayers; import net.modfest.fireblanket.mixinsupport.ObservableTicks; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -18,26 +15,26 @@ @Mixin(EntityRenderer.class) public class MixinEntityRenderer { - @Inject(method = "render(Lnet/minecraft/entity/Entity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At("HEAD")) - private void fireblanket$renderMaskedEntities(T entity, float yaw, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) { - if (ClientState.displayTickTimes && entity instanceof ObservableTicks observed) { - Box box = entity.getBoundingBox(); + @Inject(method = "render(Lnet/minecraft/entity/Entity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At("HEAD")) + private void fireblanket$renderMaskedEntities(T entity, float yaw, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) { + if (ClientState.displayTickTimes && entity instanceof ObservableTicks observed) { + Box box = entity.getBoundingBox(); - long t = observed.fireblanket$getTickTime(); - String s; - int color = 0xFFFFFF; - if (t > 1000) { - t /= 1000; - s = t + " us"; - } else { - s = t + " ns"; - } + long t = observed.fireblanket$getTickTime(); + String s; + int color = 0xFFFFFF; + if (t > 1000) { + t /= 1000; + s = t + " us"; + } else { + s = t + " ns"; + } - DebugRenderer.drawString(matrices, vertexConsumers, s, - box.minX + (box.maxX - box.minX) / 2.0 + 0.5, - box.minY + (box.maxY - box.minY) / 2.0 + 0.5, - box.minZ + (box.maxZ - box.minZ) / 2.0 + 0.5, - color, 0.03F, true, 0, true); - } - } + DebugRenderer.drawString(matrices, vertexConsumers, s, + box.minX + (box.maxX - box.minX) / 2.0 + 0.5, + box.minY + (box.maxY - box.minY) / 2.0 + 0.5, + box.minZ + (box.maxZ - box.minZ) / 2.0 + 0.5, + color, 0.03F, true, 0, true); + } + } } diff --git a/src/main/java/net/modfest/fireblanket/mixin/client/timing/MixinWorld.java b/src/main/java/net/modfest/fireblanket/mixin/client/timing/MixinWorld.java index 6b69a72..0f5baf1 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/client/timing/MixinWorld.java +++ b/src/main/java/net/modfest/fireblanket/mixin/client/timing/MixinWorld.java @@ -1,11 +1,9 @@ package net.modfest.fireblanket.mixin.client.timing; import net.minecraft.block.entity.BlockEntity; -import net.minecraft.client.world.ClientWorld; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.chunk.BlockEntityTickInvoker; -import net.minecraft.world.chunk.WorldChunk; import net.modfest.fireblanket.client.ClientState; import net.modfest.fireblanket.mixinsupport.ObservableTicks; import org.jetbrains.annotations.Nullable; @@ -16,9 +14,12 @@ @Mixin(World.class) public abstract class MixinWorld { - @Shadow @Nullable public abstract BlockEntity getBlockEntity(BlockPos pos); + @Shadow + @Nullable + public abstract BlockEntity getBlockEntity(BlockPos pos); - @Shadow public abstract boolean isClient(); + @Shadow + public abstract boolean isClient(); @Redirect(method = "tickBlockEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/chunk/BlockEntityTickInvoker;tick()V")) private void fireblanket$measureBETick(BlockEntityTickInvoker instance) { diff --git a/src/main/java/net/modfest/fireblanket/mixin/client/vbo_opto/MixinShaderProgram.java b/src/main/java/net/modfest/fireblanket/mixin/client/vbo_opto/MixinShaderProgram.java index 18a2005..1204997 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/client/vbo_opto/MixinShaderProgram.java +++ b/src/main/java/net/modfest/fireblanket/mixin/client/vbo_opto/MixinShaderProgram.java @@ -1,8 +1,6 @@ package net.modfest.fireblanket.mixin.client.vbo_opto; -import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; -import net.minecraft.client.gl.GlUniform; import net.minecraft.client.gl.ShaderProgram; import net.minecraft.client.render.VertexFormat; import net.minecraft.resource.ResourceFactory; @@ -20,7 +18,9 @@ @Mixin(ShaderProgram.class) public class MixinShaderProgram { @Mutable - @Shadow @Final private Map samplers; + @Shadow + @Final + private Map samplers; @Inject(method = "", at = @At("TAIL")) private void fireblanket$injectBetterMap(ResourceFactory factory, String name, VertexFormat format, CallbackInfo ci) { @@ -30,7 +30,7 @@ public class MixinShaderProgram { // TODO: Why does this exist? @Redirect(method = "initializeUniforms", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gl/ShaderProgram;addSampler(Ljava/lang/String;Ljava/lang/Object;)V")) private void fireblanket$optimizeVBODraw(ShaderProgram instance, String name, Object sampler) { - if (((Integer)sampler) != 0) { + if (((Integer) sampler) != 0) { instance.addSampler(name, sampler); } } diff --git a/src/main/java/net/modfest/fireblanket/mixin/client/vbo_opto/MixinVertexBuffer.java b/src/main/java/net/modfest/fireblanket/mixin/client/vbo_opto/MixinVertexBuffer.java index 94902a1..9f76963 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/client/vbo_opto/MixinVertexBuffer.java +++ b/src/main/java/net/modfest/fireblanket/mixin/client/vbo_opto/MixinVertexBuffer.java @@ -1,10 +1,7 @@ package net.modfest.fireblanket.mixin.client.vbo_opto; -import net.minecraft.client.gl.ShaderProgram; import net.minecraft.client.gl.VertexBuffer; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(VertexBuffer.class) public class MixinVertexBuffer { diff --git a/src/main/java/net/modfest/fireblanket/mixin/entity_ticking/MixinDebugStickItem.java b/src/main/java/net/modfest/fireblanket/mixin/entity_ticking/MixinDebugStickItem.java index 82e7e50..e2d576f 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/entity_ticking/MixinDebugStickItem.java +++ b/src/main/java/net/modfest/fireblanket/mixin/entity_ticking/MixinDebugStickItem.java @@ -2,7 +2,6 @@ import net.minecraft.component.DataComponentTypes; import net.minecraft.component.type.NbtComponent; -import net.minecraft.item.tooltip.TooltipType; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.mob.MobEntity; import net.minecraft.entity.player.PlayerEntity; @@ -10,6 +9,7 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemUsageContext; +import net.minecraft.item.tooltip.TooltipType; import net.minecraft.nbt.NbtCompound; import net.minecraft.text.Text; import net.minecraft.util.ActionResult; @@ -59,7 +59,7 @@ public ActionResult useOnEntity(ItemStack stack, PlayerEntity user, LivingEntity } if (nbt.getBoolean(NOMOV)) { - ((ImmmovableLivingEntity)entity).setNoMovement(true); + ((ImmmovableLivingEntity) entity).setNoMovement(true); } user.sendMessage(Text.literal("Successfully applied."), true); diff --git a/src/main/java/net/modfest/fireblanket/mixin/entity_ticking/MixinEntity.java b/src/main/java/net/modfest/fireblanket/mixin/entity_ticking/MixinEntity.java index 8f6cc0d..c6b135e 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/entity_ticking/MixinEntity.java +++ b/src/main/java/net/modfest/fireblanket/mixin/entity_ticking/MixinEntity.java @@ -2,18 +2,13 @@ import it.unimi.dsi.fastutil.objects.Object2DoubleMap; import net.minecraft.entity.Entity; -import net.minecraft.entity.player.PlayerEntity; import net.minecraft.fluid.Fluid; -import net.minecraft.fluid.FluidState; import net.minecraft.nbt.NbtCompound; import net.minecraft.registry.tag.TagKey; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Box; -import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; -import net.minecraft.world.chunk.ChunkSection; import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Overwrite; @@ -21,29 +16,38 @@ @Mixin(value = Entity.class, priority = 900) public abstract class MixinEntity { - @Shadow public abstract boolean isRegionUnloaded(); + @Shadow + public abstract boolean isRegionUnloaded(); - @Shadow private Box boundingBox; + @Shadow + private Box boundingBox; - @Shadow public abstract boolean isPushedByFluids(); + @Shadow + public abstract boolean isPushedByFluids(); - @Shadow public abstract Box getBoundingBox(); + @Shadow + public abstract Box getBoundingBox(); - @Shadow public abstract World getWorld(); + @Shadow + public abstract World getWorld(); - @Shadow public abstract Vec3d getVelocity(); + @Shadow + public abstract Vec3d getVelocity(); - @Shadow protected Object2DoubleMap> fluidHeight; + @Shadow + protected Object2DoubleMap> fluidHeight; - @Shadow public abstract void setVelocity(Vec3d velocity); + @Shadow + public abstract void setVelocity(Vec3d velocity); - @Shadow private BlockPos blockPos; + @Shadow + private BlockPos blockPos; - @Shadow public abstract void readNbt(NbtCompound nbt); + @Shadow + public abstract void readNbt(NbtCompound nbt); /** * @author Jasmine - * * @reason Sure hope people aren't using pistons to move entities */ @Overwrite diff --git a/src/main/java/net/modfest/fireblanket/mixin/entity_ticking/MixinMinecraftServer.java b/src/main/java/net/modfest/fireblanket/mixin/entity_ticking/MixinMinecraftServer.java index 681cde6..a7b8d9a 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/entity_ticking/MixinMinecraftServer.java +++ b/src/main/java/net/modfest/fireblanket/mixin/entity_ticking/MixinMinecraftServer.java @@ -3,7 +3,6 @@ import net.minecraft.server.MinecraftServer; import net.minecraft.server.WorldGenerationProgressListener; import net.modfest.fireblanket.world.WorldLoadAppliers; -import net.modfest.fireblanket.world.entity.EntityFilters; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; diff --git a/src/main/java/net/modfest/fireblanket/mixin/entity_ticking/create/MixinSuperGlueEntity.java b/src/main/java/net/modfest/fireblanket/mixin/entity_ticking/create/MixinSuperGlueEntity.java index f9f79a4..162f985 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/entity_ticking/create/MixinSuperGlueEntity.java +++ b/src/main/java/net/modfest/fireblanket/mixin/entity_ticking/create/MixinSuperGlueEntity.java @@ -1,25 +1,24 @@ package net.modfest.fireblanket.mixin.entity_ticking.create; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityType; +import net.minecraft.world.World; +import net.modfest.fireblanket.world.entity.EntityTick; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Pseudo; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Coerce; import org.spongepowered.asm.mixin.injection.Redirect; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityType; -import net.minecraft.world.World; -import net.modfest.fireblanket.world.entity.EntityTick; - @Pseudo -@Mixin(targets="com.simibubi.create.content.contraptions.glue.SuperGlueEntity") +@Mixin(targets = "com.simibubi.create.content.contraptions.glue.SuperGlueEntity") public abstract class MixinSuperGlueEntity extends Entity { public MixinSuperGlueEntity(EntityType type, World world) { super(type, world); } - @Redirect(method="method_5773", at=@At(value="INVOKE", target="net/minecraft/entity/Entity.tick()V")) + @Redirect(method = "method_5773", at = @At(value = "INVOKE", target = "net/minecraft/entity/Entity.tick()V")) private void fireblanket$noTick(@Coerce Entity instance) { EntityTick.minimalTick(instance); } diff --git a/src/main/java/net/modfest/fireblanket/mixin/footgun/MixinEntitySelectorOptions.java b/src/main/java/net/modfest/fireblanket/mixin/footgun/MixinEntitySelectorOptions.java index 3d4884f..8b9aa17 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/footgun/MixinEntitySelectorOptions.java +++ b/src/main/java/net/modfest/fireblanket/mixin/footgun/MixinEntitySelectorOptions.java @@ -16,12 +16,15 @@ @Mixin(EntitySelectorOptions.class) public abstract class MixinEntitySelectorOptions { - @Shadow private static void putOption(String id, EntitySelectorOptions.SelectorHandler handler, Predicate condition, Text description) { + @Shadow + private static void putOption(String id, EntitySelectorOptions.SelectorHandler handler, Predicate condition, Text description) { throw new IllegalStateException("Unimplemented mixin"); } @SuppressWarnings("rawtypes") - @Shadow @Final private static Map OPTIONS; + @Shadow + @Final + private static Map OPTIONS; @Inject(method = "register", at = @At("TAIL")) private static void injectForce(CallbackInfo info) { diff --git a/src/main/java/net/modfest/fireblanket/mixin/footgun/MixinEntitySelectorReader.java b/src/main/java/net/modfest/fireblanket/mixin/footgun/MixinEntitySelectorReader.java index a4d8d26..f2e54f3 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/footgun/MixinEntitySelectorReader.java +++ b/src/main/java/net/modfest/fireblanket/mixin/footgun/MixinEntitySelectorReader.java @@ -22,16 +22,22 @@ */ @Mixin(EntitySelectorReader.class) public class MixinEntitySelectorReader implements ForceableArgument { - @Shadow private boolean includesNonPlayers; - @Shadow private int limit; - @Shadow private NumberRange.DoubleRange distance; - @Shadow private Double dx; - @Shadow private Double dy; - @Shadow private Double dz; + @Shadow + private boolean includesNonPlayers; + @Shadow + private int limit; + @Shadow + private NumberRange.DoubleRange distance; + @Shadow + private Double dx; + @Shadow + private Double dy; + @Shadow + private Double dz; private boolean forced = false; private static final DynamicCommandExceptionType LIMIT_UNFORCED = new DynamicCommandExceptionType( - count -> Text.stringifiedTranslatable("argument.entity.selector.limit.unforced", count) + count -> Text.stringifiedTranslatable("argument.entity.selector.limit.unforced", count) ); @Override @@ -47,10 +53,10 @@ public boolean isForced() { @Inject(method = "read", at = @At("RETURN")) private void fireblanket$preventFootgun(CallbackInfoReturnable info) throws CommandSyntaxException { if (this.includesNonPlayers - //main anti-footgun: don't allow someone to affect every single entity on the server at once - && (this.limit > 50 && this.distance == NumberRange.DoubleRange.ANY) - && (this.dx == null && this.dy == null && this.dz == null) - && !forced) { + //main anti-footgun: don't allow someone to affect every single entity on the server at once + && (this.limit > 50 && this.distance == NumberRange.DoubleRange.ANY) + && (this.dx == null && this.dy == null && this.dz == null) + && !forced) { throw LIMIT_UNFORCED.create(this.limit); } } diff --git a/src/main/java/net/modfest/fireblanket/mixin/fsc/MixinClientConnection.java b/src/main/java/net/modfest/fireblanket/mixin/fsc/MixinClientConnection.java index 5dabd84..b4b5464 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/fsc/MixinClientConnection.java +++ b/src/main/java/net/modfest/fireblanket/mixin/fsc/MixinClientConnection.java @@ -1,57 +1,44 @@ package net.modfest.fireblanket.mixin.fsc; -import java.io.IOException; -import java.io.UncheckedIOException; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.TimeUnit; - -import net.minecraft.network.listener.PacketListener; -import org.jetbrains.annotations.Nullable; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import com.github.luben.zstd.ZstdOutputStream; - import io.netty.channel.Channel; -import io.netty.channel.ChannelPipeline; import net.minecraft.network.ClientConnection; -import net.minecraft.network.NetworkSide; -import net.minecraft.network.NetworkState; import net.minecraft.network.PacketCallbacks; +import net.minecraft.network.listener.PacketListener; import net.minecraft.network.packet.Packet; -import net.minecraft.network.packet.s2c.play.GameJoinS2CPacket; import net.modfest.fireblanket.Fireblanket; -import net.modfest.fireblanket.util.ReassignableOutputStream; import net.modfest.fireblanket.Fireblanket.QueuedPacket; import net.modfest.fireblanket.mixinsupport.FSCConnection; -import net.modfest.fireblanket.net.ZstdDecoder; -import net.modfest.fireblanket.net.ZstdEncoder; +import org.jetbrains.annotations.Nullable; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; + +import java.util.concurrent.LinkedBlockingQueue; @Mixin(ClientConnection.class) public abstract class MixinClientConnection implements FSCConnection { @Shadow private Channel channel; - + @Shadow - private void sendImmediately(Packet packet, PacketCallbacks callbacks, boolean flush) { throw new AbstractMethodError(); } + private void sendImmediately(Packet packet, PacketCallbacks callbacks, boolean flush) { + throw new AbstractMethodError(); + } - @Shadow private volatile @Nullable PacketListener packetListener; + @Shadow + private volatile @Nullable PacketListener packetListener; - @Shadow public abstract void flush(); + @Shadow + public abstract void flush(); private final LinkedBlockingQueue fireblanket$queue = Fireblanket.getNextQueue(); - private boolean fireblanket$fsc = false; - private boolean fireblanket$fscStarted = false; - + private final boolean fireblanket$fsc = false; + private final boolean fireblanket$fscStarted = false; + /** * With a lot of connections, simply the act of writing packets becomes slow. * Doing this on the server thread reduces TPS for no good reason. - * + * * The client already does networking roughly like this, so the protocol stack is already * designed to expect this behavior. */ @@ -108,5 +95,5 @@ public abstract class MixinClientConnection implements FSCConnection { // public void fireblanket$enableFullStreamCompression() { // fireblanket$fsc = true; // } - + } diff --git a/src/main/java/net/modfest/fireblanket/mixin/fsc/MixinSizePrepender.java b/src/main/java/net/modfest/fireblanket/mixin/fsc/MixinSizePrepender.java index 8dec24d..795596d 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/fsc/MixinSizePrepender.java +++ b/src/main/java/net/modfest/fireblanket/mixin/fsc/MixinSizePrepender.java @@ -8,9 +8,9 @@ @Mixin(SizePrepender.class) public class MixinSizePrepender { - @ModifyConstant(constant=@Constant(intValue=3), method="encode") + @ModifyConstant(constant = @Constant(intValue = 3), method = "encode") public int fireblanket$liftPacketSizeLimit(int orig) { return 5; } - + } diff --git a/src/main/java/net/modfest/fireblanket/mixin/fsc/MixinSplitterHandler.java b/src/main/java/net/modfest/fireblanket/mixin/fsc/MixinSplitterHandler.java index b81c10a..bc6a6dd 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/fsc/MixinSplitterHandler.java +++ b/src/main/java/net/modfest/fireblanket/mixin/fsc/MixinSplitterHandler.java @@ -8,7 +8,7 @@ @Mixin(SplitterHandler.class) public class MixinSplitterHandler { - @ModifyConstant(constant=@Constant(intValue=3), method={"shouldSplit", ""}) + @ModifyConstant(constant = @Constant(intValue = 3), method = {"shouldSplit", ""}) private static int fireblanket$liftPacketSizeLimit(int orig) { return 5; } diff --git a/src/main/java/net/modfest/fireblanket/mixin/io_uring/MixinServerNetworkIo.java b/src/main/java/net/modfest/fireblanket/mixin/io_uring/MixinServerNetworkIo.java index 601e6c8..7881dbe 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/io_uring/MixinServerNetworkIo.java +++ b/src/main/java/net/modfest/fireblanket/mixin/io_uring/MixinServerNetworkIo.java @@ -1,23 +1,22 @@ package net.modfest.fireblanket.mixin.io_uring; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Constant; -import org.spongepowered.asm.mixin.injection.ModifyConstant; -import org.spongepowered.asm.mixin.injection.ModifyVariable; import io.netty.channel.EventLoopGroup; import io.netty.channel.socket.ServerSocketChannel; import io.netty.incubator.channel.uring.IOUring; import io.netty.incubator.channel.uring.IOUringServerSocketChannel; import net.minecraft.server.ServerNetworkIo; -import net.minecraft.util.Lazy; import net.modfest.fireblanket.Fireblanket; import net.modfest.fireblanket.mixinsupport.IOUringSupport; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Constant; +import org.spongepowered.asm.mixin.injection.ModifyConstant; +import org.spongepowered.asm.mixin.injection.ModifyVariable; @Mixin(ServerNetworkIo.class) public class MixinServerNetworkIo { - @ModifyConstant(constant=@Constant(stringValue="Using epoll channel type"), method="bind") + @ModifyConstant(constant = @Constant(stringValue = "Using epoll channel type"), method = "bind") public String fireblanket$fixLogMessage(String orig) { if (IOUringSupport.ENABLED) { if (IOUring.isAvailable()) { @@ -29,21 +28,21 @@ public class MixinServerNetworkIo { } return orig; } - - @ModifyVariable(at=@At(value="INVOKE", target="org/slf4j/Logger.info(Ljava/lang/String;)V", ordinal=0), method="bind", ordinal=0) + + @ModifyVariable(at = @At(value = "INVOKE", target = "org/slf4j/Logger.info(Ljava/lang/String;)V", ordinal = 0), method = "bind", ordinal = 0) public Class fireblanket$useIoUringClass(Class orig) { if (IOUringSupport.ENABLED && IOUring.isAvailable()) { return IOUringServerSocketChannel.class; } return orig; } - - @ModifyVariable(at=@At(value="INVOKE", target="org/slf4j/Logger.info(Ljava/lang/String;)V", ordinal=0), method="bind", ordinal=0) + + @ModifyVariable(at = @At(value = "INVOKE", target = "org/slf4j/Logger.info(Ljava/lang/String;)V", ordinal = 0), method = "bind", ordinal = 0) public EventLoopGroup fireblanket$useIoUringGroup(EventLoopGroup orig) { if (IOUringSupport.ENABLED && IOUring.isAvailable()) { return IOUringSupport.CHANNEL.get(); } return orig; } - + } diff --git a/src/main/java/net/modfest/fireblanket/mixin/mods/create/AccessorSmartBlockEntity.java b/src/main/java/net/modfest/fireblanket/mixin/mods/create/AccessorSmartBlockEntity.java index ffb76b2..cce5d09 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/mods/create/AccessorSmartBlockEntity.java +++ b/src/main/java/net/modfest/fireblanket/mixin/mods/create/AccessorSmartBlockEntity.java @@ -8,6 +8,9 @@ @Pseudo @Mixin(targets = "com.simibubi.create.foundation.blockEntity.SmartBlockEntity") public interface AccessorSmartBlockEntity { - @Accessor(value = "lazyTickRate", remap = false) int fireblanket$getLazyTickRate(); - @Invoker(value = "setLazyTickRate", remap = false) void fireblanket$setLazyTickRate(int r); + @Accessor(value = "lazyTickRate", remap = false) + int fireblanket$getLazyTickRate(); + + @Invoker(value = "setLazyTickRate", remap = false) + void fireblanket$setLazyTickRate(int r); } diff --git a/src/main/java/net/modfest/fireblanket/mixin/mods/create/MixinMechanicalBearingBlockEntity.java b/src/main/java/net/modfest/fireblanket/mixin/mods/create/MixinMechanicalBearingBlockEntity.java index 07b8f8a..b8e36f0 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/mods/create/MixinMechanicalBearingBlockEntity.java +++ b/src/main/java/net/modfest/fireblanket/mixin/mods/create/MixinMechanicalBearingBlockEntity.java @@ -16,22 +16,23 @@ "com.simibubi.create.content.contraptions.bearing.ClockworkBearingBlockEntity" }) public class MixinMechanicalBearingBlockEntity { - @Unique private static final int NEW_DEFAULT_LAZY_RATE = 50; - + @Unique + private static final int NEW_DEFAULT_LAZY_RATE = 50; + @ModifyConstant(method = "", constant = @Constant(intValue = 3), remap = false) private int fireblanket$reduceLazyTickRate(int orig) { return NEW_DEFAULT_LAZY_RATE; } - + @Inject(method = "write", at = @At("RETURN"), remap = false) public void fireblanket$onWrite(NbtCompound tag, boolean clientPacket, CallbackInfo ci) { int i = ((AccessorSmartBlockEntity) this).fireblanket$getLazyTickRate(); - if(i != NEW_DEFAULT_LAZY_RATE) tag.putInt("fbLazy", i); + if (i != NEW_DEFAULT_LAZY_RATE) tag.putInt("fbLazy", i); } - + @Inject(method = "read", at = @At("RETURN"), remap = false) public void fireblanket$onRead(NbtCompound tag, boolean clientPacket, CallbackInfo ci) { int i = tag.getInt("fbLazy"); - if(i > 0) ((AccessorSmartBlockEntity) this).fireblanket$setLazyTickRate(i); + if (i > 0) ((AccessorSmartBlockEntity) this).fireblanket$setLazyTickRate(i); } } diff --git a/src/main/java/net/modfest/fireblanket/mixin/mods/mythicmetals/MixinCarmotShield.java b/src/main/java/net/modfest/fireblanket/mixin/mods/mythicmetals/MixinCarmotShield.java index 9df1adf..74911aa 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/mods/mythicmetals/MixinCarmotShield.java +++ b/src/main/java/net/modfest/fireblanket/mixin/mods/mythicmetals/MixinCarmotShield.java @@ -1,30 +1,29 @@ package net.modfest.fireblanket.mixin.mods.mythicmetals; +import dev.onyxstudios.cca.api.v3.component.ComponentKey; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Pseudo; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; -import dev.onyxstudios.cca.api.v3.component.ComponentKey; - @Pseudo -@Mixin(targets="nourl/mythicmetals/armor/CarmotShield") +@Mixin(targets = "nourl/mythicmetals/armor/CarmotShield") public abstract class MixinCarmotShield { @Shadow public abstract boolean shouldRenderShield(); - + /** * Unconditional sync every tick for every player. Sloooooow. * Make it conditional. */ - @Redirect(at=@At(value="INVOKE", target="dev/onyxstudios/cca/api/v3/component/ComponentKey.sync(Ljava/lang/Object;)V"), - method="tickShield") + @Redirect(at = @At(value = "INVOKE", target = "dev/onyxstudios/cca/api/v3/component/ComponentKey.sync(Ljava/lang/Object;)V"), + method = "tickShield") public void fireblanket$preventSync(ComponentKey key, Object provider) { if (shouldRenderShield()) { key.sync(provider); } } - + } diff --git a/src/main/java/net/modfest/fireblanket/mixin/mods/pehkui/MixinScaleUtils.java b/src/main/java/net/modfest/fireblanket/mixin/mods/pehkui/MixinScaleUtils.java index 5a2d9ef..76394bd 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/mods/pehkui/MixinScaleUtils.java +++ b/src/main/java/net/modfest/fireblanket/mixin/mods/pehkui/MixinScaleUtils.java @@ -1,13 +1,12 @@ package net.modfest.fireblanket.mixin.mods.pehkui; +import net.minecraft.entity.Entity; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.Pseudo; -import net.minecraft.entity.Entity; - @Pseudo -@Mixin(targets="virtuoel.pehkui.util.ScaleUtils") +@Mixin(targets = "virtuoel.pehkui.util.ScaleUtils") public class MixinScaleUtils { /** @@ -18,6 +17,7 @@ public class MixinScaleUtils { public static float getInteractionBoxWidthScale(Entity entity, float tickDelta) { return 1; } + /** * @reason Massive performance hazard. * @author Una @@ -26,5 +26,5 @@ public static float getInteractionBoxWidthScale(Entity entity, float tickDelta) public static float getInteractionBoxHeightScale(Entity entity, float tickDelta) { return 1; } - + } diff --git a/src/main/java/net/modfest/fireblanket/mixin/mods/pswg/MixinComplexCollisionManager.java b/src/main/java/net/modfest/fireblanket/mixin/mods/pswg/MixinComplexCollisionManager.java index 4ba92c9..8498393 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/mods/pswg/MixinComplexCollisionManager.java +++ b/src/main/java/net/modfest/fireblanket/mixin/mods/pswg/MixinComplexCollisionManager.java @@ -1,16 +1,15 @@ package net.modfest.fireblanket.mixin.mods.pswg; -import java.util.Optional; - +import net.minecraft.entity.Entity; +import net.minecraft.util.math.Vec3d; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.Pseudo; -import net.minecraft.entity.Entity; -import net.minecraft.util.math.Vec3d; +import java.util.Optional; @Pseudo -@Mixin(targets="com.parzivail.util.entity.collision.ComplexCollisionManager") +@Mixin(targets = "com.parzivail.util.entity.collision.ComplexCollisionManager") public class MixinComplexCollisionManager { /** @@ -21,5 +20,5 @@ public class MixinComplexCollisionManager { public static Optional adjustMovementForCollisions(Entity entity, Vec3d currentMovement) { return Optional.empty(); } - + } diff --git a/src/main/java/net/modfest/fireblanket/mixin/mods/terracotta_knights/MixinItemPickupGoal.java b/src/main/java/net/modfest/fireblanket/mixin/mods/terracotta_knights/MixinItemPickupGoal.java index bcb3ece..4e73918 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/mods/terracotta_knights/MixinItemPickupGoal.java +++ b/src/main/java/net/modfest/fireblanket/mixin/mods/terracotta_knights/MixinItemPickupGoal.java @@ -6,7 +6,6 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Pseudo; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(targets = "io.github.Bubblie01.terracotta_knights.entities.ai.ItemPickupGoal") diff --git a/src/main/java/net/modfest/fireblanket/mixin/opto/MixinEntitySelector.java b/src/main/java/net/modfest/fireblanket/mixin/opto/MixinEntitySelector.java index 82f24df..8506d11 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/opto/MixinEntitySelector.java +++ b/src/main/java/net/modfest/fireblanket/mixin/opto/MixinEntitySelector.java @@ -27,31 +27,52 @@ @Mixin(EntitySelector.class) public abstract class MixinEntitySelector { - @Shadow protected abstract void checkSourcePermission(ServerCommandSource source) throws CommandSyntaxException; + @Shadow + protected abstract void checkSourcePermission(ServerCommandSource source) throws CommandSyntaxException; - @Shadow @Final private @Nullable String playerName; + @Shadow + @Final + private @Nullable String playerName; - @Shadow @Final private @Nullable UUID uuid; + @Shadow + @Final + private @Nullable UUID uuid; - @Shadow @Final private Function positionOffset; + @Shadow + @Final + private Function positionOffset; - @Shadow protected abstract Predicate getPositionPredicate(Vec3d pos, @Nullable Box box, @Nullable FeatureSet enabledFeatures); + @Shadow + protected abstract Predicate getPositionPredicate(Vec3d pos, @Nullable Box box, @Nullable FeatureSet enabledFeatures); - @Shadow @Final private boolean senderOnly; + @Shadow + @Final + private boolean senderOnly; - @Shadow protected abstract int getAppendLimit(); + @Shadow + protected abstract int getAppendLimit(); - @Shadow public abstract boolean isLocalWorldOnly(); + @Shadow + public abstract boolean isLocalWorldOnly(); - @Shadow protected abstract List getEntities(Vec3d pos, List entities); + @Shadow + protected abstract List getEntities(Vec3d pos, List entities); - @Shadow @Final private NumberRange.DoubleRange distance; + @Shadow + @Final + private NumberRange.DoubleRange distance; - @Shadow @Final private @Nullable Box box; + @Shadow + @Final + private @Nullable Box box; - @Shadow @Nullable protected abstract Box getOffsetBox(Vec3d offset); + @Shadow + @Nullable + protected abstract Box getOffsetBox(Vec3d offset); - @Shadow @Final private List> predicates; + @Shadow + @Final + private List> predicates; /** * @author Jasmine @@ -62,10 +83,10 @@ public List getPlayers(ServerCommandSource source) throws Co this.checkSourcePermission(source); if (this.playerName != null) { ServerPlayerEntity serverPlayerEntity = source.getServer().getPlayerManager().getPlayer(this.playerName); - return serverPlayerEntity == null ? Collections.emptyList() : Lists.newArrayList(serverPlayerEntity); + return serverPlayerEntity == null ? Collections.emptyList() : Lists.newArrayList(serverPlayerEntity); } else if (this.uuid != null) { ServerPlayerEntity serverPlayerEntity = source.getServer().getPlayerManager().getPlayer(this.uuid); - return serverPlayerEntity == null ? Collections.emptyList() : Lists.newArrayList(serverPlayerEntity); + return serverPlayerEntity == null ? Collections.emptyList() : Lists.newArrayList(serverPlayerEntity); } else { Vec3d pos = this.positionOffset.apply(source.getPosition()); Box box = this.getOffsetBox(pos); @@ -90,7 +111,7 @@ public List getPlayers(ServerCommandSource source) throws Co } else { list = Lists.newArrayList(); - for(ServerPlayerEntity serverPlayerEntity3 : source.getServer().getPlayerManager().getPlayerList()) { + for (ServerPlayerEntity serverPlayerEntity3 : source.getServer().getPlayerManager().getPlayerList()) { if (predicate.test(serverPlayerEntity3)) { list.add(serverPlayerEntity3); if (list.size() >= i) { diff --git a/src/main/java/net/modfest/fireblanket/mixin/opto/MixinRecipeManager.java b/src/main/java/net/modfest/fireblanket/mixin/opto/MixinRecipeManager.java index 82a2960..b2a61ba 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/opto/MixinRecipeManager.java +++ b/src/main/java/net/modfest/fireblanket/mixin/opto/MixinRecipeManager.java @@ -1,20 +1,7 @@ package net.modfest.fireblanket.mixin.opto; -import java.util.List; -import java.util.Optional; - -import net.minecraft.recipe.RecipeEntry; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import net.minecraft.inventory.Inventory; import net.minecraft.recipe.RecipeManager; -import net.minecraft.recipe.RecipeType; -import net.minecraft.util.Identifier; -import net.minecraft.util.collection.DefaultedList; -import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Mixin; @Mixin(RecipeManager.class) public class MixinRecipeManager { @@ -62,5 +49,5 @@ public class MixinRecipeManager { // ci.setReturnValue(DefaultedList.of()); // } // } - + } diff --git a/src/main/java/net/modfest/fireblanket/mixin/packet_chunk_cache/MixinChunkDataS2CPacket.java b/src/main/java/net/modfest/fireblanket/mixin/packet_chunk_cache/MixinChunkDataS2CPacket.java index 95552c1..f537b5c 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/packet_chunk_cache/MixinChunkDataS2CPacket.java +++ b/src/main/java/net/modfest/fireblanket/mixin/packet_chunk_cache/MixinChunkDataS2CPacket.java @@ -1,15 +1,5 @@ package net.modfest.fireblanket.mixin.packet_chunk_cache; -import java.util.BitSet; - -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - import net.minecraft.network.packet.s2c.play.ChunkData; import net.minecraft.network.packet.s2c.play.ChunkDataS2CPacket; import net.minecraft.network.packet.s2c.play.LightData; @@ -19,17 +9,28 @@ import net.modfest.fireblanket.compat.PolyMcAccess; import net.modfest.fireblanket.mixinsupport.CacheableChunk; import net.modfest.fireblanket.mixinsupport.CacheableChunk.CachedChunkPacketData; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import java.util.BitSet; @Mixin(ChunkDataS2CPacket.class) public class MixinChunkDataS2CPacket { - - @Shadow @Final + + @Shadow + @Final private ChunkData chunkData; - @Shadow @Final + @Shadow + @Final private LightData lightData; - @Redirect(at=@At(value="NEW", target="net/minecraft/network/packet/s2c/play/ChunkData"), - method="(Lnet/minecraft/world/chunk/WorldChunk;Lnet/minecraft/world/chunk/light/LightingProvider;Ljava/util/BitSet;Ljava/util/BitSet;)V") + @Redirect(at = @At(value = "NEW", target = "net/minecraft/network/packet/s2c/play/ChunkData"), + method = "(Lnet/minecraft/world/chunk/WorldChunk;Lnet/minecraft/world/chunk/light/LightingProvider;Ljava/util/BitSet;Ljava/util/BitSet;)V") public ChunkData fireblanket$useCachedChunkData(WorldChunk chunk) { if (!PolyMcAccess.isActive() && chunk instanceof CacheableChunk cc) { CachedChunkPacketData data = cc.fireblanket$getCachedPacket(); @@ -39,9 +40,9 @@ public class MixinChunkDataS2CPacket { } return new ChunkData(chunk); } - - @Redirect(at=@At(value="NEW", target="net/minecraft/network/packet/s2c/play/LightData"), - method="(Lnet/minecraft/world/chunk/WorldChunk;Lnet/minecraft/world/chunk/light/LightingProvider;Ljava/util/BitSet;Ljava/util/BitSet;)V") + + @Redirect(at = @At(value = "NEW", target = "net/minecraft/network/packet/s2c/play/LightData"), + method = "(Lnet/minecraft/world/chunk/WorldChunk;Lnet/minecraft/world/chunk/light/LightingProvider;Ljava/util/BitSet;Ljava/util/BitSet;)V") public LightData fireblanket$useCachedLightData(ChunkPos pos, LightingProvider lightProvider, BitSet skyBits, BitSet blockBits, WorldChunk chunk) { if (!PolyMcAccess.isActive() && chunk instanceof CacheableChunk cc) { CachedChunkPacketData data = cc.fireblanket$getCachedPacket(); @@ -51,9 +52,9 @@ public class MixinChunkDataS2CPacket { } return new LightData(pos, lightProvider, skyBits, blockBits); } - - @Inject(at=@At("TAIL"), - method="(Lnet/minecraft/world/chunk/WorldChunk;Lnet/minecraft/world/chunk/light/LightingProvider;Ljava/util/BitSet;Ljava/util/BitSet;)V") + + @Inject(at = @At("TAIL"), + method = "(Lnet/minecraft/world/chunk/WorldChunk;Lnet/minecraft/world/chunk/light/LightingProvider;Ljava/util/BitSet;Ljava/util/BitSet;)V") public void fireblanket$saveCachedData(WorldChunk chunk, LightingProvider light, BitSet a, BitSet b, CallbackInfo ci) { if (!PolyMcAccess.isActive() && chunk instanceof CacheableChunk cc) { CachedChunkPacketData data = cc.fireblanket$getCachedPacket(); @@ -62,5 +63,5 @@ public class MixinChunkDataS2CPacket { } } } - + } diff --git a/src/main/java/net/modfest/fireblanket/mixin/packet_chunk_cache/MixinWorldChunk.java b/src/main/java/net/modfest/fireblanket/mixin/packet_chunk_cache/MixinWorldChunk.java index 48dd4a1..5de0c28 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/packet_chunk_cache/MixinWorldChunk.java +++ b/src/main/java/net/modfest/fireblanket/mixin/packet_chunk_cache/MixinWorldChunk.java @@ -1,11 +1,5 @@ package net.modfest.fireblanket.mixin.packet_chunk_cache; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - import net.minecraft.block.BlockState; import net.minecraft.block.entity.BlockEntity; import net.minecraft.registry.Registry; @@ -19,6 +13,11 @@ import net.minecraft.world.chunk.WorldChunk; import net.minecraft.world.gen.chunk.BlendingData; import net.modfest.fireblanket.mixinsupport.CacheableChunk; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(WorldChunk.class) public abstract class MixinWorldChunk extends Chunk implements CacheableChunk { @@ -29,19 +28,21 @@ public MixinWorldChunk(ChunkPos pos, UpgradeData upgradeData, HeightLimitView he private CachedChunkPacketData fireblanket$cachedPacket; - @Inject(at=@At("RETURN"), method="setBlockState") + @Inject(at = @At("RETURN"), method = "setBlockState") public void fireblanket$invalidateOnSetBlockState(BlockPos bp, BlockState bs, boolean moved, CallbackInfoReturnable ci) { fireblanket$cachedPacket = null; } - @Inject(at=@At("RETURN"), method="removeBlockEntity") + + @Inject(at = @At("RETURN"), method = "removeBlockEntity") public void fireblanket$invalidateOnRemoveBlockEntity(BlockPos pos, CallbackInfo ci) { fireblanket$cachedPacket = null; } - @Inject(at=@At("RETURN"), method="setBlockEntity") + + @Inject(at = @At("RETURN"), method = "setBlockEntity") public void fireblanket$invalidateOnSetBlockEntity(BlockEntity be, CallbackInfo ci) { fireblanket$cachedPacket = null; } - + @Override public void setNeedsSaving(boolean needsSaving) { // called by e.g. BlockEntity.markDirty, and also by any mods that need it @@ -49,7 +50,7 @@ public void setNeedsSaving(boolean needsSaving) { super.setNeedsSaving(needsSaving); fireblanket$cachedPacket = null; } - + @Override public CachedChunkPacketData fireblanket$getCachedPacket() { return fireblanket$cachedPacket; @@ -59,5 +60,5 @@ public void setNeedsSaving(boolean needsSaving) { public void fireblanket$setCachedPacket(CachedChunkPacketData pkt) { fireblanket$cachedPacket = pkt; } - + } diff --git a/src/main/java/net/modfest/fireblanket/mixin/region_chunk_cache/MixinServerChunkManager.java b/src/main/java/net/modfest/fireblanket/mixin/region_chunk_cache/MixinServerChunkManager.java index ad4817d..b3a2ce4 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/region_chunk_cache/MixinServerChunkManager.java +++ b/src/main/java/net/modfest/fireblanket/mixin/region_chunk_cache/MixinServerChunkManager.java @@ -8,6 +8,7 @@ import net.minecraft.structure.StructureTemplateManager; import net.minecraft.util.Util; import net.minecraft.util.profiler.Profiler; +import net.minecraft.world.PersistentStateManager; import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.ChunkStatus; @@ -32,17 +33,26 @@ */ @Mixin(ServerChunkManager.class) public abstract class MixinServerChunkManager { - @Shadow @Final Thread serverThread; + @Shadow + @Final + Thread serverThread; - @Shadow @Final ServerWorld world; + @Shadow + @Final + ServerWorld world; - @Shadow @Final private ServerChunkManager.MainThreadExecutor mainThreadExecutor; + @Shadow + @Final + private ServerChunkManager.MainThreadExecutor mainThreadExecutor; - @Shadow protected abstract CompletableFuture> getChunkFuture(int chunkX, int chunkZ, ChunkStatus leastStatus, boolean create); + @Shadow + protected abstract CompletableFuture> getChunkFuture(int chunkX, int chunkZ, ChunkStatus leastStatus, boolean create); - @Shadow public abstract @Nullable Chunk getChunk(int x, int z, ChunkStatus leastStatus, boolean create); + @Shadow + public abstract @Nullable Chunk getChunk(int x, int z, ChunkStatus leastStatus, boolean create); - @Shadow protected abstract void putInCache(long pos, @Nullable Chunk chunk, ChunkStatus status); + @Shadow + protected abstract void putInCache(long pos, @Nullable Chunk chunk, ChunkStatus status); private Chunk[] fireblanket$chunkCache; private ChunkStatus[] fireblanket$chunkStatusCache; @@ -51,7 +61,7 @@ public abstract class MixinServerChunkManager { private int fireblanket$width; @Inject(method = "", at = @At("TAIL")) - private void fireblanket$initData(ServerWorld world, LevelStorage.Session session, DataFixer dataFixer, StructureTemplateManager structureTemplateManager, Executor workerExecutor, ChunkGenerator chunkGenerator, int viewDistance, int simulationDistance, boolean dsync, WorldGenerationProgressListener worldGenerationProgressListener, ChunkStatusChangeListener chunkStatusChangeListener, Supplier persistentStateManagerFactory, CallbackInfo ci) { + private void fireblanket$initData(ServerWorld world, LevelStorage.Session session, DataFixer dataFixer, StructureTemplateManager structureTemplateManager, Executor workerExecutor, ChunkGenerator chunkGenerator, int viewDistance, int simulationDistance, boolean dsync, WorldGenerationProgressListener worldGenerationProgressListener, ChunkStatusChangeListener chunkStatusChangeListener, Supplier persistentStateManagerFactory, CallbackInfo ci) { // Will be real due to mixin plugin if (this.world.getRegistryKey().equals(World.OVERWORLD)) { @@ -71,7 +81,6 @@ public abstract class MixinServerChunkManager { /** * @author Jasmine - * * @reason More optimal to have a cache of a given size */ @Inject(method = "getChunk(IILnet/minecraft/world/chunk/ChunkStatus;Z)Lnet/minecraft/world/chunk/Chunk;", at = @At("HEAD"), cancellable = true) @@ -104,7 +113,7 @@ public abstract class MixinServerChunkManager { // Debug, but let's leave it in: the JIT will uncommon_trap this, so it shouldn't matter if (chunk.getPos().x != x || chunk.getPos().z != z) { throw new IllegalStateException("Fireblanket detected a catastrophic mismatch in its chunk cache. " + - "Please report this to Jasmine with the following information: " + chunk.getPos() + " " + x + " " + z + " " + cacheIdx); + "Please report this to Jasmine with the following information: " + chunk.getPos() + " " + x + " " + z + " " + cacheIdx); } cir.setReturnValue(chunk); @@ -123,7 +132,7 @@ public abstract class MixinServerChunkManager { this.mainThreadExecutor.runTasks(completableFuture::isDone); OptionalChunk optionalChunk = completableFuture.join(); Chunk chunkx = optionalChunk.orElse(null); - if (chunkx == null && create) { + if (chunkx == null) { throw Util.throwOrPause(new IllegalStateException("Chunk not there when requested: " + optionalChunk.getError())); } else { // Put in the cache for next time diff --git a/src/main/java/net/modfest/fireblanket/mixin/serde/MixinNbtCompound.java b/src/main/java/net/modfest/fireblanket/mixin/serde/MixinNbtCompound.java index 00d4547..b9f469c 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/serde/MixinNbtCompound.java +++ b/src/main/java/net/modfest/fireblanket/mixin/serde/MixinNbtCompound.java @@ -25,20 +25,24 @@ @Mixin(NbtCompound.class) public abstract class MixinNbtCompound { @Mutable - @Shadow @Final private Map entries; + @Shadow + @Final + private Map entries; - @Shadow protected abstract CrashReport createCrashReport(String key, NbtType reader, ClassCastException exception); + @Shadow + protected abstract CrashReport createCrashReport(String key, NbtType reader, ClassCastException exception); - @Shadow @Final public static NbtType TYPE; + @Shadow + @Final + public static NbtType TYPE; @Inject(method = "(Ljava/util/Map;)V", at = @At("TAIL")) - private void fireblanket$betterMap(Map entries, CallbackInfo ci) { + private void fireblanket$betterMap(Map entries, CallbackInfo ci) { this.entries = new Object2ObjectOpenHashMap<>(entries); } /** * @author Jasmine - * * @reason Remove unnecessary map lookup */ @Overwrite @@ -46,9 +50,9 @@ public byte getByte(String key) { try { NbtElement nbt = this.entries.get(key); if (contains(nbt, NbtElement.NUMBER_TYPE)) { - return ((AbstractNbtNumber)nbt).byteValue(); + return ((AbstractNbtNumber) nbt).byteValue(); } - } catch (ClassCastException var3) { + } catch (ClassCastException ignored) { } return 0; @@ -56,7 +60,6 @@ public byte getByte(String key) { /** * @author Jasmine - * * @reason Remove unnecessary map lookup */ @Overwrite @@ -64,9 +67,9 @@ public short getShort(String key) { try { NbtElement nbt = this.entries.get(key); if (contains(nbt, NbtElement.NUMBER_TYPE)) { - return ((AbstractNbtNumber)nbt).shortValue(); + return ((AbstractNbtNumber) nbt).shortValue(); } - } catch (ClassCastException var3) { + } catch (ClassCastException ignored) { } return 0; @@ -74,7 +77,6 @@ public short getShort(String key) { /** * @author Jasmine - * * @reason Remove unnecessary map lookup */ @Overwrite @@ -82,9 +84,9 @@ public int getInt(String key) { try { NbtElement nbt = this.entries.get(key); if (contains(nbt, NbtElement.NUMBER_TYPE)) { - return ((AbstractNbtNumber)nbt).intValue(); + return ((AbstractNbtNumber) nbt).intValue(); } - } catch (ClassCastException var3) { + } catch (ClassCastException ignored) { } return 0; @@ -92,7 +94,6 @@ public int getInt(String key) { /** * @author Jasmine - * * @reason Remove unnecessary map lookup */ @Overwrite @@ -100,9 +101,9 @@ public long getLong(String key) { try { NbtElement nbt = this.entries.get(key); if (contains(nbt, NbtElement.NUMBER_TYPE)) { - return ((AbstractNbtNumber)nbt).longValue(); + return ((AbstractNbtNumber) nbt).longValue(); } - } catch (ClassCastException var3) { + } catch (ClassCastException ignored) { } return 0L; @@ -110,7 +111,6 @@ public long getLong(String key) { /** * @author Jasmine - * * @reason Remove unnecessary map lookup */ @Overwrite @@ -118,9 +118,9 @@ public float getFloat(String key) { try { NbtElement nbt = this.entries.get(key); if (contains(nbt, NbtElement.NUMBER_TYPE)) { - return ((AbstractNbtNumber)nbt).floatValue(); + return ((AbstractNbtNumber) nbt).floatValue(); } - } catch (ClassCastException var3) { + } catch (ClassCastException ignored) { } return 0.0F; @@ -128,7 +128,6 @@ public float getFloat(String key) { /** * @author Jasmine - * * @reason Remove unnecessary map lookup */ @Overwrite @@ -136,9 +135,9 @@ public double getDouble(String key) { try { NbtElement nbt = this.entries.get(key); if (contains(nbt, NbtElement.NUMBER_TYPE)) { - return ((AbstractNbtNumber)nbt).doubleValue(); + return ((AbstractNbtNumber) nbt).doubleValue(); } - } catch (ClassCastException var3) { + } catch (ClassCastException ignored) { } return 0.0; @@ -146,7 +145,6 @@ public double getDouble(String key) { /** * @author Jasmine - * * @reason Remove unnecessary map lookup */ @Overwrite @@ -154,9 +152,9 @@ public String getString(String key) { try { NbtElement nbt = this.entries.get(key); if (contains(nbt, NbtElement.STRING_TYPE)) { - return ((NbtElement)nbt).asString(); + return nbt.asString(); } - } catch (ClassCastException var3) { + } catch (ClassCastException ignored) { } return ""; @@ -164,7 +162,6 @@ public String getString(String key) { /** * @author Jasmine - * * @reason Remove unnecessary map lookup */ @Overwrite @@ -172,7 +169,7 @@ public byte[] getByteArray(String key) { try { NbtElement nbt = this.entries.get(key); if (contains(nbt, NbtElement.BYTE_ARRAY_TYPE)) { - return ((NbtByteArray)nbt).getByteArray(); + return ((NbtByteArray) nbt).getByteArray(); } } catch (ClassCastException var3) { throw new CrashException(this.createCrashReport(key, NbtByteArray.TYPE, var3)); @@ -183,7 +180,6 @@ public byte[] getByteArray(String key) { /** * @author Jasmine - * * @reason Remove unnecessary map lookup */ @Overwrite @@ -191,7 +187,7 @@ public int[] getIntArray(String key) { try { NbtElement nbt = this.entries.get(key); if (contains(nbt, NbtElement.INT_ARRAY_TYPE)) { - return ((NbtIntArray)nbt).getIntArray(); + return ((NbtIntArray) nbt).getIntArray(); } } catch (ClassCastException var3) { throw new CrashException(this.createCrashReport(key, NbtIntArray.TYPE, var3)); @@ -202,7 +198,6 @@ public int[] getIntArray(String key) { /** * @author Jasmine - * * @reason Remove unnecessary map lookup */ @Overwrite @@ -210,7 +205,7 @@ public long[] getLongArray(String key) { try { NbtElement nbt = this.entries.get(key); if (contains(nbt, NbtElement.LONG_ARRAY_TYPE)) { - return ((NbtLongArray)nbt).getLongArray(); + return ((NbtLongArray) nbt).getLongArray(); } } catch (ClassCastException var3) { throw new CrashException(this.createCrashReport(key, NbtLongArray.TYPE, var3)); @@ -221,7 +216,6 @@ public long[] getLongArray(String key) { /** * @author Jasmine - * * @reason Remove unnecessary map lookup */ @Overwrite @@ -240,7 +234,6 @@ public NbtCompound getCompound(String key) { /** * @author Jasmine - * * @reason Remove unnecessary map lookup */ @Overwrite @@ -249,7 +242,7 @@ public NbtList getList(String key, int type) { NbtElement nbt = this.entries.get(key); if (nbt != null && nbt.getType() == NbtElement.LIST_TYPE) { - NbtList nbtList = (NbtList)nbt; + NbtList nbtList = (NbtList) nbt; if (!nbtList.isEmpty() && nbtList.getHeldType() != type) { return new NbtList(); @@ -273,11 +266,11 @@ private static boolean contains(NbtElement nbt, int type) { return false; } else { return i == NbtElement.BYTE_TYPE - || i == NbtElement.SHORT_TYPE - || i == NbtElement.INT_TYPE - || i == NbtElement.LONG_TYPE - || i == NbtElement.FLOAT_TYPE - || i == NbtElement.DOUBLE_TYPE; + || i == NbtElement.SHORT_TYPE + || i == NbtElement.INT_TYPE + || i == NbtElement.LONG_TYPE + || i == NbtElement.FLOAT_TYPE + || i == NbtElement.DOUBLE_TYPE; } } } diff --git a/src/main/java/net/modfest/fireblanket/mixin/zstd/MixinChunkCompressionFormat.java b/src/main/java/net/modfest/fireblanket/mixin/zstd/MixinChunkCompressionFormat.java index 401a4b9..f0241e7 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/zstd/MixinChunkCompressionFormat.java +++ b/src/main/java/net/modfest/fireblanket/mixin/zstd/MixinChunkCompressionFormat.java @@ -1,37 +1,37 @@ package net.modfest.fireblanket.mixin.zstd; +import com.github.luben.zstd.ZstdInputStream; +import com.github.luben.zstd.ZstdOutputStream; +import it.unimi.dsi.fastutil.io.FastBufferedInputStream; +import it.unimi.dsi.fastutil.io.FastBufferedOutputStream; import net.minecraft.world.storage.ChunkCompressionFormat; +import net.modfest.fireblanket.mixinsupport.ChunkCompressionFormatExt; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import com.github.luben.zstd.ZstdInputStream; -import com.github.luben.zstd.ZstdOutputStream; - -import it.unimi.dsi.fastutil.io.FastBufferedInputStream; -import it.unimi.dsi.fastutil.io.FastBufferedOutputStream; -import net.modfest.fireblanket.mixinsupport.ChunkCompressionFormatExt; - @Mixin(ChunkCompressionFormat.class) public class MixinChunkCompressionFormat { @Shadow - private static ChunkCompressionFormat add(ChunkCompressionFormat version) { throw new AbstractMethodError(); } - - @Inject(at=@At("TAIL"), method="") + private static ChunkCompressionFormat add(ChunkCompressionFormat version) { + throw new AbstractMethodError(); + } + + @Inject(at = @At("TAIL"), method = "") private static void fireblanket$addZstd(CallbackInfo ci) { add(ChunkCompressionFormatExt.ZSTD = new ChunkCompressionFormat(53, // chosen by fair dice roll. guaranteed to be random. - "ZSTD", - in -> new FastBufferedInputStream(new ZstdInputStream(in)), - out -> { - var z = new ZstdOutputStream(out); - z.setLevel(7); - z.setLong(18); - z.setChecksum(true); - return new FastBufferedOutputStream(z); - })); + "ZSTD", + in -> new FastBufferedInputStream(new ZstdInputStream(in)), + out -> { + var z = new ZstdOutputStream(out); + z.setLevel(7); + z.setLong(18); + z.setChecksum(true); + return new FastBufferedOutputStream(z); + })); } - + } \ No newline at end of file diff --git a/src/main/java/net/modfest/fireblanket/mixin/zstd/MixinLevelStorageSession.java b/src/main/java/net/modfest/fireblanket/mixin/zstd/MixinLevelStorageSession.java index 42bffd0..e45b92f 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/zstd/MixinLevelStorageSession.java +++ b/src/main/java/net/modfest/fireblanket/mixin/zstd/MixinLevelStorageSession.java @@ -1,20 +1,18 @@ package net.modfest.fireblanket.mixin.zstd; +import com.mojang.datafixers.DataFixer; import net.minecraft.world.PlayerSaveHandler; +import net.minecraft.world.level.storage.LevelStorage; +import net.modfest.fireblanket.mixinsupport.ZestyPlayerSaveHandler; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; -import com.mojang.datafixers.DataFixer; - -import net.minecraft.world.level.storage.LevelStorage; -import net.modfest.fireblanket.mixinsupport.ZestyPlayerSaveHandler; - @Mixin(LevelStorage.Session.class) public class MixinLevelStorageSession { - @Redirect(at=@At(value="NEW", target="(Lnet/minecraft/world/level/storage/LevelStorage$Session;Lcom/mojang/datafixers/DataFixer;)Lnet/minecraft/world/PlayerSaveHandler;"), - method="createSaveHandler") + @Redirect(at = @At(value = "NEW", target = "(Lnet/minecraft/world/level/storage/LevelStorage$Session;Lcom/mojang/datafixers/DataFixer;)Lnet/minecraft/world/PlayerSaveHandler;"), + method = "createSaveHandler") public PlayerSaveHandler fireblanket$useZstd(LevelStorage.Session session, DataFixer dataFixer) { return new ZestyPlayerSaveHandler(session, dataFixer); } diff --git a/src/main/java/net/modfest/fireblanket/mixin/zstd/MixinPersistentState.java b/src/main/java/net/modfest/fireblanket/mixin/zstd/MixinPersistentState.java index 996d82e..dfe632d 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/zstd/MixinPersistentState.java +++ b/src/main/java/net/modfest/fireblanket/mixin/zstd/MixinPersistentState.java @@ -1,5 +1,13 @@ package net.modfest.fireblanket.mixin.zstd; +import com.github.luben.zstd.ZstdOutputStream; +import net.minecraft.nbt.NbtCompound; +import net.minecraft.nbt.NbtIo; +import net.minecraft.world.PersistentState; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + import java.io.DataOutputStream; import java.io.File; import java.io.FileOutputStream; @@ -7,25 +15,15 @@ import java.nio.file.Files; import java.nio.file.Path; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -import com.github.luben.zstd.ZstdOutputStream; - -import net.minecraft.nbt.NbtCompound; -import net.minecraft.nbt.NbtIo; -import net.minecraft.world.PersistentState; - @Mixin(PersistentState.class) public class MixinPersistentState { - @Redirect(at=@At(value="INVOKE", target="net/minecraft/nbt/NbtIo.writeCompressed(Lnet/minecraft/nbt/NbtCompound;Ljava/nio/file/Path;)V"), - method="save") + @Redirect(at = @At(value = "INVOKE", target = "net/minecraft/nbt/NbtIo.writeCompressed(Lnet/minecraft/nbt/NbtCompound;Ljava/nio/file/Path;)V"), + method = "save") public void fireblanket$writeZstd(NbtCompound nbt, Path vanilla) throws IOException { String path = vanilla.toAbsolutePath().toString(); if (path.endsWith(".dat")) { - File zstd = new File(path.substring(0, path.length()-4)+".zat"); + File zstd = new File(path.substring(0, path.length() - 4) + ".zat"); try (ZstdOutputStream z = new ZstdOutputStream(new FileOutputStream(zstd))) { z.setChecksum(true); z.setLevel(4); @@ -38,5 +36,5 @@ public class MixinPersistentState { NbtIo.writeCompressed(nbt, vanilla); } } - + } diff --git a/src/main/java/net/modfest/fireblanket/mixin/zstd/MixinPersistentStateManager.java b/src/main/java/net/modfest/fireblanket/mixin/zstd/MixinPersistentStateManager.java index 2ae1da9..4da9de4 100644 --- a/src/main/java/net/modfest/fireblanket/mixin/zstd/MixinPersistentStateManager.java +++ b/src/main/java/net/modfest/fireblanket/mixin/zstd/MixinPersistentStateManager.java @@ -1,59 +1,64 @@ package net.modfest.fireblanket.mixin.zstd; -import java.io.DataInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.Map; -import java.util.function.BiFunction; -import java.util.zip.GZIPInputStream; - -import net.minecraft.registry.RegistryWrapper; -import org.slf4j.Logger; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.Shadow; import com.github.luben.zstd.ZstdInputStream; import com.mojang.datafixers.DataFixer; - import it.unimi.dsi.fastutil.io.FastBufferedInputStream; import net.minecraft.SharedConstants; import net.minecraft.datafixer.DataFixTypes; import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtHelper; import net.minecraft.nbt.NbtIo; +import net.minecraft.registry.RegistryWrapper; import net.minecraft.world.PersistentState; import net.minecraft.world.PersistentStateManager; +import org.slf4j.Logger; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; +import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import java.io.DataInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.Map; +import java.util.function.BiFunction; +import java.util.zip.GZIPInputStream; + @Mixin(PersistentStateManager.class) public abstract class MixinPersistentStateManager { - @Shadow @Final + @Shadow + @Final private static Logger LOGGER; - - @Shadow @Final + + @Shadow + @Final private File directory; - @Shadow @Final + @Shadow + @Final private DataFixer dataFixer; - @Shadow @Final - private Map loadedStates; @Shadow - private File getFile(String id) { throw new AbstractMethodError(); } + private File getFile(String id) { + throw new AbstractMethodError(); + } - @Shadow public abstract NbtCompound readNbt(String id, DataFixTypes dataFixTypes, int currentSaveVersion) throws IOException; + @Shadow + public abstract NbtCompound readNbt(String id, DataFixTypes dataFixTypes, int currentSaveVersion) throws IOException; - @Shadow @Final private RegistryWrapper.WrapperLookup registryLookup; + @Shadow + @Final + private RegistryWrapper.WrapperLookup registryLookup; private File getZstdFile(String id) { - return new File(directory, id+".zat"); + return new File(directory, id + ".zat"); } - + /** * @author Una * @reason Don't check file before calling readNbt @@ -91,7 +96,7 @@ private T readFromFile(BiFunction T readFromFile(BiFunction CHANNEL = new Lazy<>(() -> new IOUringEventLoopGroup(0, new ThreadFactoryBuilder() - .setNameFormat("Netty IO URing Server IO #%d") - .setDaemon(true) - .build()) - ); + .setNameFormat("Netty IO URing Server IO #%d") + .setDaemon(true) + .build()) + ); + - } diff --git a/src/main/java/net/modfest/fireblanket/mixinsupport/ZestyPlayerSaveHandler.java b/src/main/java/net/modfest/fireblanket/mixinsupport/ZestyPlayerSaveHandler.java index 25125f9..4581c0d 100644 --- a/src/main/java/net/modfest/fireblanket/mixinsupport/ZestyPlayerSaveHandler.java +++ b/src/main/java/net/modfest/fireblanket/mixinsupport/ZestyPlayerSaveHandler.java @@ -1,22 +1,9 @@ package net.modfest.fireblanket.mixinsupport; -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.InputStream; -import java.util.Optional; -import java.util.zip.GZIPInputStream; - -import net.minecraft.world.PlayerSaveHandler; -import org.slf4j.Logger; - import com.github.luben.zstd.ZstdInputStream; import com.github.luben.zstd.ZstdOutputStream; import com.mojang.datafixers.DataFixer; import com.mojang.logging.LogUtils; - import it.unimi.dsi.fastutil.io.FastBufferedInputStream; import net.minecraft.datafixer.DataFixTypes; import net.minecraft.entity.player.PlayerEntity; @@ -25,27 +12,38 @@ import net.minecraft.nbt.NbtIo; import net.minecraft.util.Util; import net.minecraft.util.WorldSavePath; +import net.minecraft.world.PlayerSaveHandler; import net.minecraft.world.level.storage.LevelStorage.Session; +import org.slf4j.Logger; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.util.Optional; +import java.util.zip.GZIPInputStream; public class ZestyPlayerSaveHandler extends PlayerSaveHandler { private static final Logger LOGGER = LogUtils.getLogger(); private final File playerDataDir; - + public ZestyPlayerSaveHandler(Session session, DataFixer dataFixer) { super(session, dataFixer); this.playerDataDir = session.getDirectory(WorldSavePath.PLAYERDATA).toFile(); } - + @Override public Optional loadPlayerData(PlayerEntity player) { try { InputStream in; - File zstd = new File(playerDataDir, player.getUuidAsString()+".zat"); + File zstd = new File(playerDataDir, player.getUuidAsString() + ".zat"); if (zstd.isFile()) { in = new FastBufferedInputStream(new ZstdInputStream(new FileInputStream(zstd))); } else { - File vanilla = new File(playerDataDir, player.getUuidAsString()+".dat"); + File vanilla = new File(playerDataDir, player.getUuidAsString() + ".dat"); if (vanilla.isFile()) { in = new FastBufferedInputStream(new GZIPInputStream(new FileInputStream(zstd))); } else { @@ -63,22 +61,22 @@ public Optional loadPlayerData(PlayerEntity player) { return Optional.empty(); } } - + @Override public void savePlayerData(PlayerEntity player) { try { NbtCompound nbt = player.writeNbt(new NbtCompound()); - File tmp = File.createTempFile(player.getUuidAsString()+"-", ".zat", playerDataDir); + File tmp = File.createTempFile(player.getUuidAsString() + "-", ".zat", playerDataDir); try (ZstdOutputStream z = new ZstdOutputStream(new FileOutputStream(tmp))) { z.setChecksum(true); z.setLevel(6); NbtIo.write(nbt, new DataOutputStream(z)); } - File tgt = new File(playerDataDir, player.getUuidAsString()+".zat"); - File backup = new File(playerDataDir, player.getUuidAsString()+".zat_old"); + File tgt = new File(playerDataDir, player.getUuidAsString() + ".zat"); + File backup = new File(playerDataDir, player.getUuidAsString() + ".zat_old"); Util.backupAndReplace(tgt.toPath(), tmp.toPath(), backup.toPath()); - File oldTgt = new File(playerDataDir, player.getUuidAsString()+".dat"); - File oldBackup = new File(playerDataDir, player.getUuidAsString()+".dat_old"); + File oldTgt = new File(playerDataDir, player.getUuidAsString() + ".dat"); + File oldBackup = new File(playerDataDir, player.getUuidAsString() + ".dat_old"); oldTgt.delete(); if (backup.exists()) oldBackup.delete(); } catch (Exception e) { diff --git a/src/main/java/net/modfest/fireblanket/net/BEUpdate.java b/src/main/java/net/modfest/fireblanket/net/BEUpdate.java index 897d5e3..03bad29 100644 --- a/src/main/java/net/modfest/fireblanket/net/BEUpdate.java +++ b/src/main/java/net/modfest/fireblanket/net/BEUpdate.java @@ -9,13 +9,13 @@ import net.minecraft.util.math.BlockPos; public record BEUpdate(BlockPos pos, BlockEntityType type, NbtCompound nbt) { - public static final PacketCodec CODEC = PacketCodec.tuple( - BlockPos.PACKET_CODEC, - BEUpdate::pos, - PacketCodecs.registryValue(RegistryKeys.BLOCK_ENTITY_TYPE), - BEUpdate::type, - PacketCodecs.UNLIMITED_NBT_COMPOUND, - BEUpdate::nbt, - BEUpdate::new - ); + public static final PacketCodec CODEC = PacketCodec.tuple( + BlockPos.PACKET_CODEC, + BEUpdate::pos, + PacketCodecs.registryValue(RegistryKeys.BLOCK_ENTITY_TYPE), + BEUpdate::type, + PacketCodecs.UNLIMITED_NBT_COMPOUND, + BEUpdate::nbt, + BEUpdate::new + ); } diff --git a/src/main/java/net/modfest/fireblanket/net/BatchedBEUpdatePayload.java b/src/main/java/net/modfest/fireblanket/net/BatchedBEUpdatePayload.java index 35067f5..f08a3ea 100644 --- a/src/main/java/net/modfest/fireblanket/net/BatchedBEUpdatePayload.java +++ b/src/main/java/net/modfest/fireblanket/net/BatchedBEUpdatePayload.java @@ -10,15 +10,15 @@ import java.util.List; public record BatchedBEUpdatePayload(List updates) implements CustomPayload { - public static final CustomPayload.Id ID = new CustomPayload.Id<>(Fireblanket.BATCHED_BE_UPDATE); - public static final PacketCodec CODEC = PacketCodec.tuple( - PacketCodecs.collection(ArrayList::new, BEUpdate.CODEC), - BatchedBEUpdatePayload::updates, - BatchedBEUpdatePayload::new - ); + public static final CustomPayload.Id ID = new CustomPayload.Id<>(Fireblanket.BATCHED_BE_UPDATE); + public static final PacketCodec CODEC = PacketCodec.tuple( + PacketCodecs.collection(ArrayList::new, BEUpdate.CODEC), + BatchedBEUpdatePayload::updates, + BatchedBEUpdatePayload::new + ); - @Override - public CustomPayload.Id getId() { - return ID; - } + @Override + public CustomPayload.Id getId() { + return ID; + } } diff --git a/src/main/java/net/modfest/fireblanket/net/CommandBlockPacket.java b/src/main/java/net/modfest/fireblanket/net/CommandBlockPacket.java index f949118..8a971ab 100644 --- a/src/main/java/net/modfest/fireblanket/net/CommandBlockPacket.java +++ b/src/main/java/net/modfest/fireblanket/net/CommandBlockPacket.java @@ -7,7 +7,7 @@ public record CommandBlockPacket() implements CustomPayload { public static final CustomPayload.Id ID = - new CustomPayload.Id<>(Identifier.of("fireblanket", "place_command_block")); + new CustomPayload.Id<>(Identifier.of("fireblanket", "place_command_block")); public static final CommandBlockPacket INST = new CommandBlockPacket(); public static final PacketCodec CODEC = PacketCodec.unit(INST); diff --git a/src/main/java/net/modfest/fireblanket/net/ZstdDecoder.java b/src/main/java/net/modfest/fireblanket/net/ZstdDecoder.java index ade21a7..d4e4b34 100644 --- a/src/main/java/net/modfest/fireblanket/net/ZstdDecoder.java +++ b/src/main/java/net/modfest/fireblanket/net/ZstdDecoder.java @@ -1,7 +1,5 @@ package net.modfest.fireblanket.net; -import java.io.IOException; -import java.util.List; import com.github.luben.zstd.ZstdInputStream; import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufOutputStream; @@ -10,10 +8,13 @@ import io.netty.handler.codec.MessageToMessageDecoder; import net.modfest.fireblanket.util.EndlessByteBufInputStream; +import java.io.IOException; +import java.util.List; + public class ZstdDecoder extends MessageToMessageDecoder { private final ByteBuf inBuf = Unpooled.buffer(); - + private final ZstdInputStream stream; public ZstdDecoder() throws IOException { @@ -29,11 +30,11 @@ protected void decode(ChannelHandlerContext ctx, ByteBuf msg, List out) out.add(buf); inBuf.discardSomeReadBytes(); } - + @Override public void handlerRemoved(ChannelHandlerContext ctx) throws Exception { super.handlerRemoved(ctx); stream.close(); } - + } diff --git a/src/main/java/net/modfest/fireblanket/net/ZstdEncoder.java b/src/main/java/net/modfest/fireblanket/net/ZstdEncoder.java index ac8fc47..c979210 100644 --- a/src/main/java/net/modfest/fireblanket/net/ZstdEncoder.java +++ b/src/main/java/net/modfest/fireblanket/net/ZstdEncoder.java @@ -1,14 +1,6 @@ package net.modfest.fireblanket.net; -import java.io.OutputStream; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledFuture; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.LongAdder; - import com.github.luben.zstd.ZstdOutputStream; - import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufInputStream; import io.netty.buffer.ByteBufOutputStream; @@ -19,33 +11,40 @@ import net.modfest.fireblanket.Fireblanket; import net.modfest.fireblanket.util.ReassignableOutputStream; +import java.io.OutputStream; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.LongAdder; + public class ZstdEncoder extends MessageToByteEncoder { private static final ScheduledExecutorService sched = Executors.newSingleThreadScheduledExecutor(); - + private static final LongAdder inBytes = new LongAdder(); private static final LongAdder outBytes = new LongAdder(); - + static { sched.scheduleAtFixedRate(() -> { - Fireblanket.LOGGER.info("Zstd ratio past 5m: "+((double)inBytes.sumThenReset()/outBytes.sumThenReset())); + Fireblanket.LOGGER.info("Zstd ratio past 5m: " + ((double) inBytes.sumThenReset() / outBytes.sumThenReset())); }, 5, 5, TimeUnit.MINUTES); } - + private final long flushFrequency, unclogFrequency; - + private final ReassignableOutputStream out; private final ZstdOutputStream stream; private ScheduledFuture future = null; - + private long lastFlush = System.nanoTime(); public ZstdEncoder(ReassignableOutputStream out, ZstdOutputStream stream, long flushFrequency) { this.out = out; this.stream = stream; this.flushFrequency = flushFrequency; - this.unclogFrequency = (flushFrequency*3)/2; + this.unclogFrequency = (flushFrequency * 3) / 2; } @Override @@ -58,7 +57,7 @@ protected void encode(ChannelHandlerContext ctx, ByteBuf msg, ByteBuf out) throw this.out.setDelegate(new ByteBufOutputStream(out)); int start = out.writerIndex(); new ByteBufInputStream(msg, false).transferTo(stream); - if (flushFrequency == 0 || System.nanoTime()-lastFlush > flushFrequency) { + if (flushFrequency == 0 || System.nanoTime() - lastFlush > flushFrequency) { lastFlush = System.nanoTime(); stream.flush(); } else { @@ -68,14 +67,14 @@ protected void encode(ChannelHandlerContext ctx, ByteBuf msg, ByteBuf out) throw ch.writeAndFlush(Unpooled.EMPTY_BUFFER); }, unclogFrequency, TimeUnit.NANOSECONDS); } - outBytes.add(out.writerIndex()-start); + outBytes.add(out.writerIndex() - start); this.out.setDelegate(OutputStream.nullOutputStream()); } - + @Override public void handlerRemoved(ChannelHandlerContext ctx) throws Exception { super.handlerRemoved(ctx); stream.close(); } - + } diff --git a/src/main/java/net/modfest/fireblanket/util/EndlessByteBufInputStream.java b/src/main/java/net/modfest/fireblanket/util/EndlessByteBufInputStream.java index db45945..601b9bf 100644 --- a/src/main/java/net/modfest/fireblanket/util/EndlessByteBufInputStream.java +++ b/src/main/java/net/modfest/fireblanket/util/EndlessByteBufInputStream.java @@ -1,14 +1,14 @@ package net.modfest.fireblanket.util; +import io.netty.buffer.ByteBuf; + import java.io.IOException; import java.io.InputStream; -import io.netty.buffer.ByteBuf; - public class EndlessByteBufInputStream extends InputStream { private final ByteBuf buf; - + public EndlessByteBufInputStream(ByteBuf buf) { this.buf = buf; buf.markReaderIndex(); @@ -22,9 +22,9 @@ public int available() throws IOException { @Override public int read() throws IOException { if (!buf.isReadable()) return -1; - return buf.readByte()&0xFF; + return buf.readByte() & 0xFF; } - + @Override public int read(byte[] b, int off, int len) throws IOException { if (!buf.isReadable()) return -1; @@ -32,22 +32,22 @@ public int read(byte[] b, int off, int len) throws IOException { buf.readBytes(b, off, len); return len; } - + @Override public byte[] readAllBytes() throws IOException { byte[] bys = new byte[buf.readableBytes()]; buf.readBytes(bys); return bys; } - + @Override public synchronized void mark(int readlimit) { buf.markReaderIndex(); } - + @Override public synchronized void reset() throws IOException { buf.resetReaderIndex(); } - + } diff --git a/src/main/java/net/modfest/fireblanket/util/ReassignableOutputStream.java b/src/main/java/net/modfest/fireblanket/util/ReassignableOutputStream.java index 705f097..0dd659f 100644 --- a/src/main/java/net/modfest/fireblanket/util/ReassignableOutputStream.java +++ b/src/main/java/net/modfest/fireblanket/util/ReassignableOutputStream.java @@ -6,7 +6,7 @@ public class ReassignableOutputStream extends OutputStream { private OutputStream delegate = OutputStream.nullOutputStream(); - + public void setDelegate(OutputStream delegate) { this.delegate = delegate; } @@ -30,5 +30,5 @@ public void flush() throws IOException { public void close() throws IOException { delegate.close(); } - + } diff --git a/src/main/java/net/modfest/fireblanket/world/CachedCompoundBE.java b/src/main/java/net/modfest/fireblanket/world/CachedCompoundBE.java index d10dadf..c523672 100644 --- a/src/main/java/net/modfest/fireblanket/world/CachedCompoundBE.java +++ b/src/main/java/net/modfest/fireblanket/world/CachedCompoundBE.java @@ -4,7 +4,8 @@ import org.jetbrains.annotations.Nullable; public interface CachedCompoundBE { - @Nullable NbtCompound fireblanket$getCachedCompound(); + @Nullable + NbtCompound fireblanket$getCachedCompound(); void fireblanket$setCachedCompound(NbtCompound nbt); } diff --git a/src/main/java/net/modfest/fireblanket/world/WorldLoadAppliers.java b/src/main/java/net/modfest/fireblanket/world/WorldLoadAppliers.java index ea9ace3..f362d16 100644 --- a/src/main/java/net/modfest/fireblanket/world/WorldLoadAppliers.java +++ b/src/main/java/net/modfest/fireblanket/world/WorldLoadAppliers.java @@ -1,7 +1,6 @@ package net.modfest.fireblanket.world; import net.modfest.fireblanket.world.blocks.FlatBlockstateArray; -import net.modfest.fireblanket.world.blocks.UpdateSignBlockEntityTypes; import net.modfest.fireblanket.world.entity.EntityFilters; public class WorldLoadAppliers { diff --git a/src/main/java/net/modfest/fireblanket/world/blocks/FlatBlockstateArray.java b/src/main/java/net/modfest/fireblanket/world/blocks/FlatBlockstateArray.java index 5d6d437..c8ce2dd 100644 --- a/src/main/java/net/modfest/fireblanket/world/blocks/FlatBlockstateArray.java +++ b/src/main/java/net/modfest/fireblanket/world/blocks/FlatBlockstateArray.java @@ -5,6 +5,7 @@ public class FlatBlockstateArray { public static BlockState[] FROM_ID; + public static void apply() { int size = Block.STATE_IDS.size(); diff --git a/src/main/java/net/modfest/fireblanket/world/blocks/UpdateSignBlockEntityTypes.java b/src/main/java/net/modfest/fireblanket/world/blocks/UpdateSignBlockEntityTypes.java index 4a13da4..9927bec 100644 --- a/src/main/java/net/modfest/fireblanket/world/blocks/UpdateSignBlockEntityTypes.java +++ b/src/main/java/net/modfest/fireblanket/world/blocks/UpdateSignBlockEntityTypes.java @@ -1,6 +1,10 @@ package net.modfest.fireblanket.world.blocks; -import net.minecraft.block.*; +import net.minecraft.block.Block; +import net.minecraft.block.HangingSignBlock; +import net.minecraft.block.SignBlock; +import net.minecraft.block.WallHangingSignBlock; +import net.minecraft.block.WallSignBlock; import net.minecraft.block.entity.BlockEntityType; import net.minecraft.registry.Registries; import net.modfest.fireblanket.Fireblanket; diff --git a/src/main/java/net/modfest/fireblanket/world/entity/EntityFilters.java b/src/main/java/net/modfest/fireblanket/world/entity/EntityFilters.java index 410ab14..7c79400 100644 --- a/src/main/java/net/modfest/fireblanket/world/entity/EntityFilters.java +++ b/src/main/java/net/modfest/fireblanket/world/entity/EntityFilters.java @@ -59,8 +59,8 @@ public static void apply() { for (EntityType type : Registries.ENTITY_TYPE) { Identifier id = Registries.ENTITY_TYPE.getId(type); if (filter.pattern().asMatchPredicate().test(id.toString())) { - ((EntityTypeAccessor)type).setMaxTrackDistance(filter.trackingRangeChunks()); - ((EntityTypeAccessor)type).setTrackTickInterval(filter.tickRate()); + ((EntityTypeAccessor) type).setMaxTrackDistance(filter.trackingRangeChunks()); + ((EntityTypeAccessor) type).setTrackTickInterval(filter.tickRate()); if (filter.forceNoVelcityUpdate()) { FORCE_VELOCITY_UPDATE_OFF.add(type); diff --git a/src/main/java/net/modfest/fireblanket/world/entity/EntityTick.java b/src/main/java/net/modfest/fireblanket/world/entity/EntityTick.java index 3f91765..233a288 100644 --- a/src/main/java/net/modfest/fireblanket/world/entity/EntityTick.java +++ b/src/main/java/net/modfest/fireblanket/world/entity/EntityTick.java @@ -25,7 +25,7 @@ public static void minimalLivingTick(LivingEntity e) { double y = e.getY() + (e.serverY - e.getY()) / e.bodyTrackingIncrements; double z = e.getZ() + (e.serverZ - e.getZ()) / e.bodyTrackingIncrements; double yaw = MathHelper.wrapDegrees(e.serverYaw - e.getYaw()); - e.setYaw(e.getYaw() + (float)yaw / e.bodyTrackingIncrements); + e.setYaw(e.getYaw() + (float) yaw / e.bodyTrackingIncrements); e.setPitch((float) (e.getPitch() + (e.serverPitch - e.getPitch()) / e.bodyTrackingIncrements)); e.bodyYaw = e.getYaw(); --e.bodyTrackingIncrements; @@ -33,7 +33,7 @@ public static void minimalLivingTick(LivingEntity e) { } if (e.headTrackingIncrements > 0) { - e.headYaw += (float)MathHelper.wrapDegrees(e.serverHeadYaw - (double)e.headYaw) / (float)e.headTrackingIncrements; + e.headYaw += (float) MathHelper.wrapDegrees(e.serverHeadYaw - (double) e.headYaw) / (float) e.headTrackingIncrements; --e.headTrackingIncrements; } } diff --git a/src/main/java/net/modfest/fireblanket/world/render_regions/ExplainedRenderRegion.java b/src/main/java/net/modfest/fireblanket/world/render_regions/ExplainedRenderRegion.java index 36f7d37..afbba55 100644 --- a/src/main/java/net/modfest/fireblanket/world/render_regions/ExplainedRenderRegion.java +++ b/src/main/java/net/modfest/fireblanket/world/render_regions/ExplainedRenderRegion.java @@ -1,30 +1,30 @@ package net.modfest.fireblanket.world.render_regions; -import java.util.Set; -import java.util.UUID; - import it.unimi.dsi.fastutil.longs.LongOpenHashSet; import it.unimi.dsi.fastutil.longs.LongSet; import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; import net.minecraft.util.Identifier; +import java.util.Set; +import java.util.UUID; + public class ExplainedRenderRegion { public final String name; public final RenderRegion reg; public boolean blanketDeny; - + public final Set entityAttachments = new ObjectOpenHashSet<>(); public final LongSet blockAttachments = new LongOpenHashSet(); public final Set entityTypeAttachments = new ObjectOpenHashSet<>(); public final Set beTypeAttachments = new ObjectOpenHashSet<>(); - + public ExplainedRenderRegion(String name, RenderRegion reg) { this.name = name; this.reg = reg; } - + public ExplainedRenderRegion copy() { ExplainedRenderRegion nw = new ExplainedRenderRegion(name, reg); nw.blanketDeny = blanketDeny; @@ -34,5 +34,5 @@ public ExplainedRenderRegion copy() { nw.beTypeAttachments.addAll(beTypeAttachments); return nw; } - + } diff --git a/src/main/java/net/modfest/fireblanket/world/render_regions/Long2ReferenceMultimap.java b/src/main/java/net/modfest/fireblanket/world/render_regions/Long2ReferenceMultimap.java index b16a24a..842e997 100644 --- a/src/main/java/net/modfest/fireblanket/world/render_regions/Long2ReferenceMultimap.java +++ b/src/main/java/net/modfest/fireblanket/world/render_regions/Long2ReferenceMultimap.java @@ -1,11 +1,5 @@ package net.modfest.fireblanket.world.render_regions; -import java.util.AbstractCollection; -import java.util.Collection; -import java.util.Iterator; -import java.util.Map; -import java.util.Map.Entry; - import com.google.common.collect.Iterables; import com.google.common.collect.ListMultimap; import com.google.common.collect.Multimap; @@ -16,10 +10,16 @@ import it.unimi.dsi.fastutil.objects.ReferenceList; import it.unimi.dsi.fastutil.objects.ReferenceLists; +import java.util.AbstractCollection; +import java.util.Collection; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; + public class Long2ReferenceMultimap implements ListMultimap { private final Long2ReferenceMap> underlying = new Long2ReferenceOpenHashMap<>(); - + @Override public int size() { int count = 0; @@ -34,11 +34,12 @@ public boolean isEmpty() { return underlying.isEmpty(); } - @Override @Deprecated + @Override + @Deprecated public boolean containsKey(Object key) { return underlying.containsKey(key); } - + public boolean containsKey(long key) { return underlying.containsKey(key); } @@ -51,30 +52,33 @@ public boolean containsValue(Object value) { return false; } - @Override @Deprecated + @Override + @Deprecated public boolean containsEntry(Object key, Object value) { if (key instanceof Long l) return get(l).contains(value); return false; } - + public boolean containsEntry(long key, Object value) { return get(key).contains(value); } - @Override @Deprecated + @Override + @Deprecated public ReferenceList get(Long key) { return get(key.longValue()); } - + public ReferenceList get(long key) { return underlying.getOrDefault(key, ReferenceLists.emptyList()); } - @Override @Deprecated + @Override + @Deprecated public boolean put(Long key, V value) { return put(key.longValue(), value); } - + public boolean put(long key, V value) { ReferenceList li = underlying.get(key); if (li == null) { @@ -84,7 +88,8 @@ public boolean put(long key, V value) { return li.add(value); } - @Override @Deprecated + @Override + @Deprecated public boolean remove(Object key, Object value) { if (key instanceof Long l) return remove(l.longValue(), value); return false; @@ -96,11 +101,12 @@ public boolean remove(long key, Object value) { return li.remove(value); } - @Override @Deprecated + @Override + @Deprecated public boolean putAll(Long key, Iterable values) { return putAll(key.longValue(), values); } - + public boolean putAll(long key, Iterable values) { boolean any = false; for (V v : values) { @@ -109,7 +115,8 @@ public boolean putAll(long key, Iterable values) { return any; } - @Override @Deprecated + @Override + @Deprecated public boolean putAll(Multimap multimap) { boolean any = false; for (var en : multimap.asMap().entrySet()) { @@ -142,7 +149,8 @@ public LongSet keySet() { return underlying.keySet(); } - @Override @Deprecated + @Override + @Deprecated public LongMultiset keys() { LongMultiset ms = new LongMultiset(); for (var en : underlying.long2ReferenceEntrySet()) { @@ -158,7 +166,7 @@ public Collection values() { public Iterator iterator() { return Iterables.concat(underlying.values()).iterator(); } - + @Override public int size() { return Long2ReferenceMultimap.this.size(); @@ -181,14 +189,16 @@ public void clear() { }; } - @Override @Deprecated + @Override + @Deprecated public Collection> entries() { - return (Collection)long2ReferenceEntries(); + return (Collection) long2ReferenceEntries(); } - @Override @Deprecated + @Override + @Deprecated public Map> asMap() { - return (Map)underlying; + return (Map) underlying; } public Collection> long2ReferenceEntries() { diff --git a/src/main/java/net/modfest/fireblanket/world/render_regions/LongMultiset.java b/src/main/java/net/modfest/fireblanket/world/render_regions/LongMultiset.java index e293694..47bb5b0 100644 --- a/src/main/java/net/modfest/fireblanket/world/render_regions/LongMultiset.java +++ b/src/main/java/net/modfest/fireblanket/world/render_regions/LongMultiset.java @@ -1,10 +1,6 @@ package net.modfest.fireblanket.world.render_regions; -import java.util.Collection; -import java.util.Set; - import com.google.common.collect.Multiset; - import it.unimi.dsi.fastutil.longs.AbstractLongIterator; import it.unimi.dsi.fastutil.longs.Long2IntArrayMap; import it.unimi.dsi.fastutil.longs.Long2IntMap; @@ -17,19 +13,23 @@ import it.unimi.dsi.fastutil.objects.ObjectIterator; import it.unimi.dsi.fastutil.objects.ObjectSet; +import java.util.Collection; +import java.util.Set; + public class LongMultiset implements Multiset { public interface Entry extends Multiset.Entry { - - @Override @Deprecated + + @Override + @Deprecated default Long getElement() { return getLongElement(); } - + long getLongElement(); - + } - + private final Long2IntMap underlying = new Long2IntOpenHashMap(); @Override @@ -47,7 +47,8 @@ public T[] toArray(T[] a) { return null; } - @Override @Deprecated + @Override + @Deprecated public boolean addAll(Collection c) { for (Long l : c) { add(l); @@ -69,7 +70,8 @@ public int size() { return count; } - @Override @Deprecated + @Override + @Deprecated public int count(Object element) { if (element instanceof Long l) return count(l.longValue()); return 0; @@ -79,23 +81,25 @@ public int count(long element) { return underlying.get(element); } - @Override @Deprecated + @Override + @Deprecated public int add(Long element, int occurrences) { return add(element.longValue(), occurrences); } - @Override @Deprecated + @Override + @Deprecated public boolean add(Long element) { return add(element.longValue()); } - + public int add(long element, int occurences) { - if (occurences < 0) throw new IllegalArgumentException("occurences cannot be negative ("+occurences+")"); + if (occurences < 0) throw new IllegalArgumentException("occurences cannot be negative (" + occurences + ")"); int old = underlying.get(element); if (occurences == 0) return old; - int count = old+occurences; + int count = old + occurences; if (count < 0) { - throw new IllegalArgumentException("overflow (adding "+occurences+" to "+old+")"); + throw new IllegalArgumentException("overflow (adding " + occurences + " to " + old + ")"); } else if (count == 0) { underlying.remove(element); } else { @@ -103,28 +107,30 @@ public int add(long element, int occurences) { } return old; } - + public boolean add(long element) { add(element, 1); return true; } - @Override @Deprecated + @Override + @Deprecated public int remove(Object element, int occurrences) { if (element instanceof Long l) return remove(l.longValue(), occurrences); return 0; } - @Override @Deprecated + @Override + @Deprecated public boolean remove(Object element) { if (element instanceof Long l) return remove(l.longValue()); return false; } - + public boolean remove(long element) { int old = underlying.get(element); if (old == 0) return false; - int count = old-1; + int count = old - 1; if (count == 0) { underlying.remove(element); } else { @@ -132,12 +138,12 @@ public boolean remove(long element) { } return true; } - + public int remove(long element, int occurences) { - if (occurences < 0) throw new IllegalArgumentException("occurences cannot be negative ("+occurences+")"); + if (occurences < 0) throw new IllegalArgumentException("occurences cannot be negative (" + occurences + ")"); int old = underlying.get(element); if (occurences == 0) return old; - int count = old-occurences; + int count = old - occurences; if (count <= 0) { underlying.remove(element); } else { @@ -146,16 +152,18 @@ public int remove(long element, int occurences) { return old; } - @Override @Deprecated + @Override + @Deprecated public int setCount(Long element, int count) { return setCount(element.longValue(), count); } - @Override @Deprecated + @Override + @Deprecated public boolean setCount(Long element, int oldCount, int newCount) { return setCount(element.longValue(), oldCount, newCount); } - + public int setCount(long element, int count) { return underlying.put(element, count); } @@ -173,11 +181,12 @@ public LongSet elementSet() { return underlying.keySet(); } - @Override @Deprecated + @Override + @Deprecated public Set> entrySet() { - return (Set)longEntrySet(); + return (Set) longEntrySet(); } - + public ObjectSet longEntrySet() { return new AbstractObjectSet() { @@ -214,12 +223,12 @@ public boolean hasNext() { public Entry next() { Long2IntMap.Entry en = entries.next(); return new Entry() { - + @Override public int getCount() { return en.getIntValue(); } - + @Override public long getLongElement() { return en.getLongKey(); @@ -235,15 +244,15 @@ public long getLongElement() { public LongIterator iterator() { return new AbstractLongIterator() { private final ObjectIterator entries = underlying.long2IntEntrySet().iterator(); - + private long element; private int count; - + @Override public boolean hasNext() { return count > 0 || entries.hasNext(); } - + @Override public long nextLong() { if (count <= 0) { @@ -257,17 +266,19 @@ public long nextLong() { }; } - @Override @Deprecated + @Override + @Deprecated public boolean contains(Object element) { if (element instanceof Long l) return underlying.containsKey(l); return false; } - + public boolean contains(long element) { return underlying.containsKey(element); } - @Override @Deprecated + @Override + @Deprecated public boolean containsAll(Collection elements) { for (Object o : elements) { if (!contains(o)) return false; @@ -275,7 +286,8 @@ public boolean containsAll(Collection elements) { return true; } - @Override @Deprecated + @Override + @Deprecated public boolean removeAll(Collection c) { boolean b = false; for (Object o : c) { @@ -284,7 +296,8 @@ public boolean removeAll(Collection c) { return b; } - @Override @Deprecated + @Override + @Deprecated public boolean retainAll(Collection c) { Long2IntMap keep = new Long2IntArrayMap(); for (Object o : c) { @@ -321,5 +334,5 @@ public boolean retainAll(LongCollection c) { underlying.putAll(keep); return true; } - + } diff --git a/src/main/java/net/modfest/fireblanket/world/render_regions/RegionSubject.java b/src/main/java/net/modfest/fireblanket/world/render_regions/RegionSubject.java index fdfcc99..4201631 100644 --- a/src/main/java/net/modfest/fireblanket/world/render_regions/RegionSubject.java +++ b/src/main/java/net/modfest/fireblanket/world/render_regions/RegionSubject.java @@ -3,16 +3,18 @@ public interface RegionSubject { int fireblanket$getRegionEra(); + boolean fireblanket$getShouldRender(); + long fireblanket$getViewerPos(); - + void fireblanket$setCachedState(int era, long viewerPos, boolean shouldRender); - + default Boolean fireblanket$cachedShouldRender(int era, long viewerPos) { if (era == fireblanket$getRegionEra() && fireblanket$getViewerPos() == viewerPos) { return fireblanket$getShouldRender(); } return null; } - + } diff --git a/src/main/java/net/modfest/fireblanket/world/render_regions/RegionSyncRequest.java b/src/main/java/net/modfest/fireblanket/world/render_regions/RegionSyncRequest.java index 821f578..5f16e36 100644 --- a/src/main/java/net/modfest/fireblanket/world/render_regions/RegionSyncRequest.java +++ b/src/main/java/net/modfest/fireblanket/world/render_regions/RegionSyncRequest.java @@ -1,41 +1,48 @@ package net.modfest.fireblanket.world.render_regions; -import java.util.UUID; -import java.util.function.Function; - import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMultimap; - -import io.netty.buffer.Unpooled; import it.unimi.dsi.fastutil.longs.LongIterator; -import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; import net.minecraft.block.entity.BlockEntityType; import net.minecraft.entity.EntityType; import net.minecraft.network.PacketByteBuf; import net.minecraft.network.RegistryByteBuf; import net.minecraft.network.codec.PacketCodec; -import net.minecraft.network.listener.ClientCommonPacketListener; import net.minecraft.network.packet.CustomPayload; -import net.minecraft.network.packet.Packet; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; import net.minecraft.util.Identifier; import net.modfest.fireblanket.Fireblanket; +import net.modfest.fireblanket.world.render_regions.RegionSyncRequest.AddRegion; +import net.modfest.fireblanket.world.render_regions.RegionSyncRequest.AttachBlock; +import net.modfest.fireblanket.world.render_regions.RegionSyncRequest.AttachEntity; +import net.modfest.fireblanket.world.render_regions.RegionSyncRequest.DestroyRegion; +import net.modfest.fireblanket.world.render_regions.RegionSyncRequest.DetachAll; +import net.modfest.fireblanket.world.render_regions.RegionSyncRequest.DetachBlock; +import net.modfest.fireblanket.world.render_regions.RegionSyncRequest.DetachEntity; +import net.modfest.fireblanket.world.render_regions.RegionSyncRequest.FullState; +import net.modfest.fireblanket.world.render_regions.RegionSyncRequest.FullStateLegacy; +import net.modfest.fireblanket.world.render_regions.RegionSyncRequest.InvalidCommand; +import net.modfest.fireblanket.world.render_regions.RegionSyncRequest.RedefineRegion; +import net.modfest.fireblanket.world.render_regions.RegionSyncRequest.RegistryRegionSyncRequest; +import net.modfest.fireblanket.world.render_regions.RegionSyncRequest.Reset; import net.modfest.fireblanket.world.render_regions.RenderRegion.Mode; -import net.modfest.fireblanket.world.render_regions.RegionSyncRequest.*; + +import java.util.UUID; +import java.util.function.Function; public sealed interface RegionSyncRequest extends CustomPayload permits InvalidCommand, FullState, Reset, AddRegion, - DestroyRegion, DetachAll, AttachEntity, AttachBlock, DetachEntity, DetachBlock, RedefineRegion, FullStateLegacy, - RegistryRegionSyncRequest { + DestroyRegion, DetachAll, AttachEntity, AttachBlock, DetachEntity, DetachBlock, RedefineRegion, FullStateLegacy, + RegistryRegionSyncRequest { CustomPayload.Id ID = new CustomPayload.Id<>(Fireblanket.REGIONS_UPDATE); PacketCodec CODEC = PacketCodec.of( - RegionSyncRequest::toPacket, RegionSyncRequest::read + RegionSyncRequest::toPacket, RegionSyncRequest::read ); - public enum RequestType { + enum RequestType { INVALID_COMMAND(InvalidCommand::read, "invalid_command"), FULL_STATE_LEGACY(FullStateLegacy::read, "full_state_legacy"), RESET(Reset::read, "reset"), @@ -61,24 +68,25 @@ public enum RequestType { this.reader = reader; this.id = Identifier.of("fireblanket", name); } - + } - + RequestType type(); - -// static self read(PacketByteBuf buf); + + // static self read(PacketByteBuf buf); void write(PacketByteBuf buf); - + void apply(RenderRegions tgt); - + boolean valid(); - + sealed interface RegistryRegionSyncRequest extends RegionSyncRequest permits AttachEntityType, DetachEntityType, - AttachBlockEntityType, DetachBlockEntityType { - + AttachBlockEntityType, DetachBlockEntityType { + Registry registry(); - + String name(); + Identifier id(); @Override @@ -108,38 +116,38 @@ private static void writeRegion(PacketByteBuf buf, RenderRegion r) { buf.writeVarInt(r.minX()).writeVarInt(r.minY()).writeVarInt(r.minZ()); buf.writeVarInt(r.maxX()).writeVarInt(r.maxY()).writeVarInt(r.maxZ()); } - + private static RenderRegion readRegion(PacketByteBuf buf) { int modeId = buf.readUnsignedByte(); if (modeId >= Mode.VALUES.size()) { - Fireblanket.LOGGER.warn("Unknown region mode id "+modeId); + Fireblanket.LOGGER.warn("Unknown region mode id " + modeId); modeId = 0; } Mode mode = Mode.VALUES.get(modeId); return new RenderRegion(buf.readVarInt(), buf.readVarInt(), buf.readVarInt(), - buf.readVarInt(), buf.readVarInt(), buf.readVarInt(), - mode); + buf.readVarInt(), buf.readVarInt(), buf.readVarInt(), + mode); } - + private static Identifier readId(PacketByteBuf buf, Registry registry) { return registry.getId(registry.get(buf.readVarInt())); } - + private static void writeId(PacketByteBuf buf, Registry registry, Identifier id) { buf.writeVarInt(registry.getRawId(registry.get(id))); } - + static RegionSyncRequest read(RegistryByteBuf buf) { int tid = buf.readUnsignedByte(); if (tid >= RequestType.VALUES.size()) { - Fireblanket.LOGGER.warn("Unknown region sync command id "+tid); + Fireblanket.LOGGER.warn("Unknown region sync command id " + tid); return new InvalidCommand(); } RequestType t = RequestType.VALUES.get(tid); return t.reader.apply(buf); } - - public record InvalidCommand() implements RegionSyncRequest { + + record InvalidCommand() implements RegionSyncRequest { @Override public RequestType type() { @@ -154,7 +162,7 @@ public void write(PacketByteBuf buf) { public static InvalidCommand read(PacketByteBuf buf) { return new InvalidCommand(); } - + @Override public void apply(RenderRegions tgt) { Fireblanket.LOGGER.warn("Attempted to apply invalid command"); @@ -164,13 +172,13 @@ public void apply(RenderRegions tgt) { public boolean valid() { return false; } - + } - - public record FullStateLegacy(ImmutableMap regions, - ImmutableMultimap entityAttachments, - ImmutableMultimap blockAttachments) implements RegionSyncRequest { - + + record FullStateLegacy(ImmutableMap regions, + ImmutableMultimap entityAttachments, + ImmutableMultimap blockAttachments) implements RegionSyncRequest { + @Override public RequestType type() { return RequestType.FULL_STATE_LEGACY; @@ -180,7 +188,7 @@ public RequestType type() { public void write(PacketByteBuf buf) { throw new UnsupportedOperationException(); } - + public static FullStateLegacy read(PacketByteBuf buf) { ImmutableMap.Builder regionsBldr = ImmutableMap.builder(); ImmutableMultimap.Builder entityAttachmentsBldr = ImmutableMultimap.builder(); @@ -201,13 +209,13 @@ public static FullStateLegacy read(PacketByteBuf buf) { } return new FullStateLegacy(regionsBldr.build(), entityAttachmentsBldr.build(), blockAttachmentsBldr.build()); } - + @Override public boolean valid() { return regions != null && entityAttachments != null && blockAttachments != null - && !regions.isEmpty(); + && !regions.isEmpty(); } - + @Override public void apply(RenderRegions tgt) { tgt.clear(); @@ -216,8 +224,8 @@ public void apply(RenderRegions tgt) { blockAttachments.forEach(tgt::attachBlock); } } - - public record Reset(boolean valid) implements RegionSyncRequest { + + record Reset(boolean valid) implements RegionSyncRequest { @Override public RequestType type() { @@ -228,7 +236,7 @@ public RequestType type() { public void write(PacketByteBuf buf) { buf.writeInt(0xDEADDEAD); } - + public static Reset read(PacketByteBuf buf) { return new Reset(buf.readInt() == 0xDEADDEAD); } @@ -237,10 +245,10 @@ public static Reset read(PacketByteBuf buf) { public void apply(RenderRegions tgt) { tgt.clear(); } - + } - - public record AddRegion(String name, RenderRegion region) implements RegionSyncRequest { + + record AddRegion(String name, RenderRegion region) implements RegionSyncRequest { @Override public RequestType type() { @@ -252,11 +260,11 @@ public void write(PacketByteBuf buf) { buf.writeString(name); writeRegion(buf, region); } - + public static AddRegion read(PacketByteBuf buf) { return new AddRegion(buf.readString(), readRegion(buf)); } - + @Override public boolean valid() { return name != null && region != null; @@ -266,10 +274,10 @@ public boolean valid() { public void apply(RenderRegions tgt) { tgt.add(name, region); } - + } - - public record DestroyRegion(String name) implements RegionSyncRequest { + + record DestroyRegion(String name) implements RegionSyncRequest { @Override public RequestType type() { @@ -280,11 +288,11 @@ public RequestType type() { public void write(PacketByteBuf buf) { buf.writeString(name); } - + public static DestroyRegion read(PacketByteBuf buf) { return new DestroyRegion(buf.readString()); } - + @Override public boolean valid() { return name != null; @@ -294,10 +302,10 @@ public boolean valid() { public void apply(RenderRegions tgt) { tgt.remove(tgt.getByName(name)); } - + } - - public record DetachAll(String name) implements RegionSyncRequest { + + record DetachAll(String name) implements RegionSyncRequest { @Override public RequestType type() { @@ -308,11 +316,11 @@ public RequestType type() { public void write(PacketByteBuf buf) { buf.writeString(name); } - + public static DetachAll read(PacketByteBuf buf) { return new DetachAll(buf.readString()); } - + @Override public boolean valid() { return name != null; @@ -323,8 +331,8 @@ public void apply(RenderRegions tgt) { tgt.detachAll(tgt.getByName(name)); } } - - public record AttachEntity(String name, UUID entity) implements RegionSyncRequest { + + record AttachEntity(String name, UUID entity) implements RegionSyncRequest { @Override public RequestType type() { @@ -336,11 +344,11 @@ public void write(PacketByteBuf buf) { buf.writeString(name); buf.writeUuid(entity); } - + public static AttachEntity read(PacketByteBuf buf) { return new AttachEntity(buf.readString(), buf.readUuid()); } - + @Override public boolean valid() { return name != null && entity != null; @@ -350,10 +358,10 @@ public boolean valid() { public void apply(RenderRegions tgt) { tgt.attachEntity(tgt.getByName(name), entity); } - + } - - public record AttachBlock(String name, long pos) implements RegionSyncRequest { + + record AttachBlock(String name, long pos) implements RegionSyncRequest { @Override public RequestType type() { @@ -365,7 +373,7 @@ public void write(PacketByteBuf buf) { buf.writeString(name); buf.writeLong(pos); } - + public static AttachBlock read(PacketByteBuf buf) { return new AttachBlock(buf.readString(), buf.readLong()); } @@ -374,14 +382,15 @@ public static AttachBlock read(PacketByteBuf buf) { public boolean valid() { return name != null; } + @Override public void apply(RenderRegions tgt) { tgt.attachBlock(tgt.getByName(name), pos); } - + } - - public record DetachEntity(String name, UUID entity) implements RegionSyncRequest { + + record DetachEntity(String name, UUID entity) implements RegionSyncRequest { @Override public RequestType type() { @@ -393,11 +402,11 @@ public void write(PacketByteBuf buf) { buf.writeString(name); buf.writeUuid(entity); } - + public static DetachEntity read(PacketByteBuf buf) { return new DetachEntity(buf.readString(), buf.readUuid()); } - + @Override public boolean valid() { return name != null && entity != null; @@ -407,10 +416,10 @@ public boolean valid() { public void apply(RenderRegions tgt) { tgt.detachEntity(tgt.getByName(name), entity); } - + } - - public record DetachBlock(String name, long pos) implements RegionSyncRequest { + + record DetachBlock(String name, long pos) implements RegionSyncRequest { @Override public RequestType type() { @@ -422,11 +431,11 @@ public void write(PacketByteBuf buf) { buf.writeString(name); buf.writeLong(pos); } - + public static DetachBlock read(PacketByteBuf buf) { return new DetachBlock(buf.readString(), buf.readLong()); } - + @Override public boolean valid() { return name != null; @@ -436,10 +445,10 @@ public boolean valid() { public void apply(RenderRegions tgt) { tgt.detachBlock(tgt.getByName(name), pos); } - + } - - public record RedefineRegion(String name, RenderRegion region) implements RegionSyncRequest { + + record RedefineRegion(String name, RenderRegion region) implements RegionSyncRequest { @Override public RequestType type() { @@ -451,11 +460,11 @@ public void write(PacketByteBuf buf) { buf.writeString(name); writeRegion(buf, region); } - + public static RedefineRegion read(PacketByteBuf buf) { return new RedefineRegion(buf.readString(), readRegion(buf)); } - + @Override public boolean valid() { return name != null && region != null; @@ -465,21 +474,21 @@ public boolean valid() { public void apply(RenderRegions tgt) { tgt.redefine(name, region); } - + } - - public record AttachEntityType(String name, Identifier id) implements RegistryRegionSyncRequest> { + + record AttachEntityType(String name, Identifier id) implements RegistryRegionSyncRequest> { @Override public RequestType type() { return RequestType.ATTACH_ENTITY_TYPE; } - + @Override public Registry> registry() { return Registries.ENTITY_TYPE; } - + public static AttachEntityType read(PacketByteBuf buf) { return new AttachEntityType(buf.readString(), readId(buf, Registries.ENTITY_TYPE)); } @@ -488,21 +497,21 @@ public static AttachEntityType read(PacketByteBuf buf) { public void apply(RenderRegions tgt) { tgt.attachEntityType(tgt.getByName(name), id); } - + } - - public record DetachEntityType(String name, Identifier id) implements RegistryRegionSyncRequest> { + + record DetachEntityType(String name, Identifier id) implements RegistryRegionSyncRequest> { @Override public RequestType type() { return RequestType.DETACH_ENTITY_TYPE; } - + @Override public Registry> registry() { return Registries.ENTITY_TYPE; } - + public static DetachEntityType read(PacketByteBuf buf) { return new DetachEntityType(buf.readString(), readId(buf, Registries.ENTITY_TYPE)); } @@ -511,21 +520,21 @@ public static DetachEntityType read(PacketByteBuf buf) { public void apply(RenderRegions tgt) { tgt.detachEntityType(tgt.getByName(name), id); } - + } - - public record AttachBlockEntityType(String name, Identifier id) implements RegistryRegionSyncRequest> { + + record AttachBlockEntityType(String name, Identifier id) implements RegistryRegionSyncRequest> { @Override public RequestType type() { return RequestType.ATTACH_BLOCK_ENTITY_TYPE; } - + @Override public Registry> registry() { return Registries.BLOCK_ENTITY_TYPE; } - + public static AttachBlockEntityType read(PacketByteBuf buf) { return new AttachBlockEntityType(buf.readString(), readId(buf, Registries.BLOCK_ENTITY_TYPE)); } @@ -534,21 +543,21 @@ public static AttachBlockEntityType read(PacketByteBuf buf) { public void apply(RenderRegions tgt) { tgt.attachBlockEntityType(tgt.getByName(name), id); } - + } - - public record DetachBlockEntityType(String name, Identifier id) implements RegistryRegionSyncRequest> { + + record DetachBlockEntityType(String name, Identifier id) implements RegistryRegionSyncRequest> { @Override public RequestType type() { return RequestType.DETACH_BLOCK_ENTITY_TYPE; } - + @Override public Registry> registry() { return Registries.BLOCK_ENTITY_TYPE; } - + public static DetachBlockEntityType read(PacketByteBuf buf) { return new DetachBlockEntityType(buf.readString(), readId(buf, Registries.BLOCK_ENTITY_TYPE)); } @@ -557,11 +566,11 @@ public static DetachBlockEntityType read(PacketByteBuf buf) { public void apply(RenderRegions tgt) { tgt.detachBlockEntityType(tgt.getByName(name), id); } - + } - - public record FullState(ImmutableList regions) implements RegionSyncRequest { - + + record FullState(ImmutableList regions) implements RegionSyncRequest { + @Override public RequestType type() { return RequestType.FULL_STATE; @@ -598,14 +607,14 @@ public void write(PacketByteBuf buf) { for (Identifier id : bet) { writeId(buf, Registries.BLOCK_ENTITY_TYPE, id); } - int len = buf.writerIndex()-start; + int len = buf.writerIndex() - start; buf.markWriterIndex(); buf.writerIndex(sizePos); buf.writeMedium(len); buf.resetWriterIndex(); } } - + public static FullState read(PacketByteBuf buf) { ImmutableList.Builder bldr = ImmutableList.builder(); int regionCount = buf.readVarInt(); @@ -631,17 +640,17 @@ public static FullState read(PacketByteBuf buf) { for (int j = 0; j < beTypeCount; j++) { ex.beTypeAttachments.add(readId(buf, Registries.BLOCK_ENTITY_TYPE)); } - buf.readerIndex(start+len); + buf.readerIndex(start + len); bldr.add(ex); } return new FullState(bldr.build()); } - + @Override public boolean valid() { return regions != null && !regions.isEmpty(); } - + @Override public void apply(RenderRegions tgt) { tgt.clear(); @@ -654,5 +663,5 @@ public void apply(RenderRegions tgt) { } } } - + } diff --git a/src/main/java/net/modfest/fireblanket/world/render_regions/RenderRegion.java b/src/main/java/net/modfest/fireblanket/world/render_regions/RenderRegion.java index 0521a9e..d7d3d15 100644 --- a/src/main/java/net/modfest/fireblanket/world/render_regions/RenderRegion.java +++ b/src/main/java/net/modfest/fireblanket/world/render_regions/RenderRegion.java @@ -1,9 +1,6 @@ package net.modfest.fireblanket.world.render_regions; -import java.util.NoSuchElementException; - import com.google.common.collect.ImmutableList; - import it.unimi.dsi.fastutil.longs.AbstractLongIterator; import it.unimi.dsi.fastutil.longs.LongIterable; import it.unimi.dsi.fastutil.longs.LongIterator; @@ -12,8 +9,10 @@ import net.minecraft.util.math.Box; import net.minecraft.util.math.ChunkSectionPos; +import java.util.NoSuchElementException; + public record RenderRegion(int minX, int minY, int minZ, int maxX, int maxY, int maxZ, Mode mode) { - + public RenderRegion { int x1 = minX; int y1 = minY; @@ -34,12 +33,12 @@ public enum Mode { ; public static final ImmutableList VALUES = ImmutableList.copyOf(values()); } - + public Iterable affectedChunks() { LongIterable li = affectedChunkLongs(); return () -> new AbstractObjectIterator() { private final LongIterator iter = li.iterator(); - + @Override public boolean hasNext() { return iter.hasNext(); @@ -49,18 +48,18 @@ public boolean hasNext() { public ChunkSectionPos next() { return ChunkSectionPos.from(iter.nextLong()); } - + }; } - + public LongIterable affectedChunkLongs() { - int minX = this.minX>>4; - int minY = this.minY>>4; - int minZ = this.minZ>>4; - int maxX = (this.maxX+15)>>4; - int maxY = (this.maxY+15)>>4; - int maxZ = (this.maxZ+15)>>4; - + int minX = this.minX >> 4; + int minY = this.minY >> 4; + int minZ = this.minZ >> 4; + int maxX = (this.maxX + 15) >> 4; + int maxY = (this.maxY + 15) >> 4; + int maxZ = (this.maxZ + 15) >> 4; + int width = (maxX - minX) + 1; int height = (maxY - minY) + 1; int depth = (maxZ - minZ) + 1; @@ -92,34 +91,34 @@ public boolean hasNext() { public boolean contains(BlockPos bp) { return contains(bp.getX(), bp.getY(), bp.getZ()); } - + public boolean contains(int x, int y, int z) { return x >= minX && x <= maxX - && y >= minY && y <= maxY - && z >= minZ && z <= maxZ; + && y >= minY && y <= maxY + && z >= minZ && z <= maxZ; } - + public boolean contains(double x, double y, double z) { - return x >= minX && x < maxX+1 - && y >= minY && y < maxY+1 - && z >= minZ && z < maxZ+1; + return x >= minX && x < maxX + 1 + && y >= minY && y < maxY + 1 + && z >= minZ && z < maxZ + 1; } public Box toBox() { - return new Box(minX, minY, minZ, maxX+1, maxY+1, maxZ+1); + return new Box(minX, minY, minZ, maxX + 1, maxY + 1, maxZ + 1); } - + // reference semantics for performance // technically breaks the record contract. oh well - + @Override public int hashCode() { return System.identityHashCode(this); } - + @Override public boolean equals(Object o) { return o == this; } - + } diff --git a/src/main/java/net/modfest/fireblanket/world/render_regions/RenderRegions.java b/src/main/java/net/modfest/fireblanket/world/render_regions/RenderRegions.java index c223b64..2552e62 100644 --- a/src/main/java/net/modfest/fireblanket/world/render_regions/RenderRegions.java +++ b/src/main/java/net/modfest/fireblanket/world/render_regions/RenderRegions.java @@ -1,14 +1,5 @@ package net.modfest.fireblanket.world.render_regions; -import java.util.Arrays; -import java.util.Collections; -import java.util.Map; -import java.util.Set; -import java.util.UUID; -import java.util.function.Consumer; -import java.util.function.Function; -import java.util.function.Supplier; - import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; import com.google.common.collect.ImmutableList; @@ -16,7 +7,6 @@ import com.google.common.collect.ListMultimap; import com.google.common.collect.Maps; import com.google.common.collect.Multimaps; - import it.unimi.dsi.fastutil.ints.IntArrayList; import it.unimi.dsi.fastutil.ints.IntList; import it.unimi.dsi.fastutil.longs.LongIterator; @@ -44,22 +34,31 @@ import net.modfest.fireblanket.world.render_regions.RegionSyncRequest.FullState; import net.modfest.fireblanket.world.render_regions.RenderRegion.Mode; +import java.util.Arrays; +import java.util.Collections; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.function.Supplier; + public class RenderRegions { private final BiMap regionsByName = HashBiMap.create(); private final Reference2ReferenceMap explaineds = new Reference2ReferenceOpenHashMap<>(); private final Long2ReferenceMultimap regionsByChunkSection = new Long2ReferenceMultimap<>(); - + private final Long2ReferenceMultimap blockRegions = new Long2ReferenceMultimap<>(); private final ListMultimap entityRegions = Multimaps.newListMultimap(new Object2ReferenceOpenHashMap<>(), ReferenceArrayList::new); private final ListMultimap exclusiveEntityTypeRegions = Multimaps.newListMultimap(new Object2ReferenceOpenHashMap<>(), ReferenceArrayList::new); private final ListMultimap exclusiveBeTypeRegions = Multimaps.newListMultimap(new Object2ReferenceOpenHashMap<>(), ReferenceArrayList::new); - + private final Runnable dirtyListener; private final Consumer syncer; - + private boolean dontSync = false; - + private int era = 0; public RenderRegions() { @@ -70,12 +69,12 @@ public RenderRegions(Runnable dirtyListener, Consumer syncer) this.dirtyListener = dirtyListener; this.syncer = syncer; } - + public void markDirty() { era++; if (dirtyListener != null) dirtyListener.run(); } - + public void sync(Supplier supplier) { if (dontSync) return; if (syncer != null) { @@ -98,11 +97,11 @@ public void add(String name, RenderRegion region) { markDirty(); sync(() -> new RegionSyncRequest.AddRegion(name, region)); } - + public void remove(RenderRegion region) { remove(region, true); } - + private void remove(RenderRegion region, boolean clear) { if (region == null) return; detachAll(region, clear); @@ -140,21 +139,21 @@ public void redefine(String name, RenderRegion nw) { dontSync = false; } } - + public FullState toPacket() { return new FullState(ImmutableList.copyOf(Iterables.transform(explaineds.values(), ExplainedRenderRegion::copy))); } - + public Map getRegionsByName() { return Maps.transformValues(regionsByName, ex -> ex.reg); } - + private void removeFromGlobal(ExplainedRenderRegion ex) { ex.reg.affectedChunkLongs().forEach(l -> { regionsByChunkSection.remove(l, ex); }); } - + private void addToGlobal(ExplainedRenderRegion ex) { ex.reg.affectedChunkLongs().forEach(l -> { regionsByChunkSection.put(l, ex); @@ -172,11 +171,11 @@ public void clear() { markDirty(); sync(() -> new RegionSyncRequest.Reset(true)); } - + public void attachEntity(RenderRegion region, Entity e) { attachEntity(region, e.getUuid()); } - + public void attachEntity(RenderRegion region, UUID id) { if (region == null) return; ExplainedRenderRegion ex = explaineds.get(region); @@ -185,11 +184,11 @@ public void attachEntity(RenderRegion region, UUID id) { markDirty(); sync(() -> new RegionSyncRequest.AttachEntity(ex.name, id)); } - + public void attachEntityType(RenderRegion region, EntityType type) { attachEntityType(region, EntityType.getId(type)); } - + public void attachEntityType(RenderRegion region, Identifier id) { if (region == null || id == null) return; ExplainedRenderRegion ex = explaineds.get(region); @@ -201,11 +200,11 @@ public void attachEntityType(RenderRegion region, Identifier id) { markDirty(); sync(() -> new RegionSyncRequest.AttachEntityType(ex.name, id)); } - + public void attachBlock(RenderRegion region, BlockEntity be) { attachBlock(region, be.getPos().asLong()); } - + public void attachBlock(RenderRegion region, long pos) { if (region == null) return; ExplainedRenderRegion ex = explaineds.get(region); @@ -215,11 +214,11 @@ public void attachBlock(RenderRegion region, long pos) { markDirty(); sync(() -> new RegionSyncRequest.AttachBlock(ex.name, pos)); } - + public void attachBlockEntityType(RenderRegion region, BlockEntityType type) { attachBlockEntityType(region, BlockEntityType.getId(type)); } - + public void attachBlockEntityType(RenderRegion region, Identifier id) { if (region == null || id == null) return; ExplainedRenderRegion ex = explaineds.get(region); @@ -231,11 +230,11 @@ public void attachBlockEntityType(RenderRegion region, Identifier id) { markDirty(); sync(() -> new RegionSyncRequest.AttachBlockEntityType(ex.name, id)); } - + public boolean detachEntity(RenderRegion region, Entity e) { return detachEntity(region, e.getUuid()); } - + public boolean detachEntity(RenderRegion region, UUID id) { if (region == null) return false; ExplainedRenderRegion ex = explaineds.get(region); @@ -245,11 +244,11 @@ public boolean detachEntity(RenderRegion region, UUID id) { sync(() -> new RegionSyncRequest.DetachEntity(ex.name, id)); return success; } - + public void detachEntityType(RenderRegion region, EntityType type) { detachEntityType(region, Registries.ENTITY_TYPE.getId(type)); } - + public void detachEntityType(RenderRegion region, Identifier id) { if (region == null) return; ExplainedRenderRegion ex = explaineds.get(region); @@ -259,11 +258,11 @@ public void detachEntityType(RenderRegion region, Identifier id) { markDirty(); sync(() -> new RegionSyncRequest.DetachEntityType(ex.name, id)); } - + public boolean detachBlock(RenderRegion region, BlockEntity be) { return detachBlock(region, be.getPos().asLong()); } - + public boolean detachBlock(RenderRegion region, long pos) { if (region == null) return false; ExplainedRenderRegion ex = explaineds.get(region); @@ -273,11 +272,11 @@ public boolean detachBlock(RenderRegion region, long pos) { sync(() -> new RegionSyncRequest.DetachBlock(ex.name, pos)); return success; } - + public void detachBlockEntityType(RenderRegion region, BlockEntityType type) { detachBlockEntityType(region, Registries.BLOCK_ENTITY_TYPE.getId(type)); } - + public void detachBlockEntityType(RenderRegion region, Identifier id) { if (region == null) return; ExplainedRenderRegion ex = explaineds.get(region); @@ -287,12 +286,12 @@ public void detachBlockEntityType(RenderRegion region, Identifier id) { markDirty(); sync(() -> new RegionSyncRequest.DetachBlockEntityType(ex.name, id)); } - + private void checkBlanketDeny(ExplainedRenderRegion ex) { if (ex.entityAttachments.isEmpty() - && ex.blockAttachments.isEmpty() - && ex.entityTypeAttachments.isEmpty() - && ex.beTypeAttachments.isEmpty()) { + && ex.blockAttachments.isEmpty() + && ex.entityTypeAttachments.isEmpty() + && ex.beTypeAttachments.isEmpty()) { ex.blanketDeny = true; } } @@ -301,7 +300,7 @@ private void checkBlanketDeny(ExplainedRenderRegion ex) { public int detachAll(RenderRegion region) { return detachAll(region, true); } - + private int detachAll(RenderRegion region, boolean clear) { if (region == null) return 0; ExplainedRenderRegion ex = explaineds.get(region); @@ -337,60 +336,60 @@ public RenderRegion getByName(String name) { if (ex == null) return null; return ex.reg; } - + public String getName(RenderRegion region) { return regionsByName.inverse().get(explaineds.get(region)); } - + public LongSet getBlockAttachments(RenderRegion region) { ExplainedRenderRegion ex = explaineds.get(region); if (ex == null) return LongSets.emptySet(); return ex.blockAttachments; } - + public Set getEntityAttachments(RenderRegion region) { ExplainedRenderRegion ex = explaineds.get(region); if (ex == null) return Collections.emptySet(); return ex.entityAttachments; } - + public Set getBlockEntityTypeAttachments(RenderRegion region) { ExplainedRenderRegion ex = explaineds.get(region); if (ex == null) return Collections.emptySet(); return ex.beTypeAttachments; } - + public Set getEntityTypeAttachments(RenderRegion region) { ExplainedRenderRegion ex = explaineds.get(region); if (ex == null) return Collections.emptySet(); return ex.entityTypeAttachments; } - + public boolean shouldRender(double viewerX, double viewerY, double viewerZ, BlockEntity be) { - long viewerPos = BlockPos.asLong((int)viewerX, (int)viewerY, (int)viewerZ); + long viewerPos = BlockPos.asLong((int) viewerX, (int) viewerY, (int) viewerZ); if (be instanceof RegionSubject rs) { Boolean cached = rs.fireblanket$cachedShouldRender(era, viewerPos); if (cached != null) return cached; } boolean res = shouldRender(ex -> ex.beTypeAttachments, BlockEntityType.getId(be.getType()), - exclusiveBeTypeRegions, - blockRegions.get(be.getPos().asLong()), viewerX, viewerY, viewerZ); + exclusiveBeTypeRegions, + blockRegions.get(be.getPos().asLong()), viewerX, viewerY, viewerZ); if (be instanceof RegionSubject rs) { rs.fireblanket$setCachedState(era, viewerPos, res); } return res; } - + public boolean shouldRender(double viewerX, double viewerY, double viewerZ, Entity e) { if (e instanceof PlayerEntity && e.shouldRenderName()) return true; - long viewerPos = BlockPos.asLong((int)viewerX, (int)viewerY, (int)viewerZ); + long viewerPos = BlockPos.asLong((int) viewerX, (int) viewerY, (int) viewerZ); if (e instanceof RegionSubject rs) { Boolean cached = rs.fireblanket$cachedShouldRender(era, viewerPos); if (cached != null) return cached; } boolean res = shouldRender(ex -> ex.entityTypeAttachments, EntityType.getId(e.getType()), - exclusiveEntityTypeRegions, - entityRegions.get(e.getUuid()), viewerX, viewerY, viewerZ); + exclusiveEntityTypeRegions, + entityRegions.get(e.getUuid()), viewerX, viewerY, viewerZ); if (e instanceof RegionSubject rs) { rs.fireblanket$setCachedState(era, viewerPos, res); } @@ -398,16 +397,16 @@ public boolean shouldRender(double viewerX, double viewerY, double viewerZ, Enti } private boolean shouldRender(Function> typeAttachments, Identifier type, - ListMultimap exclusiveTypeRegions, - Iterable assignedRegions, double viewerX, double viewerY, double viewerZ) { + ListMultimap exclusiveTypeRegions, + Iterable assignedRegions, double viewerX, double viewerY, double viewerZ) { boolean anyExclusive = false; - int vX = (int)viewerX; - int vY = (int)viewerY; - int vZ = (int)viewerZ; - long chunkSect = ChunkSectionPos.asLong(vX>>4, vY>>4, vZ>>4); - + int vX = (int) viewerX; + int vY = (int) viewerY; + int vZ = (int) viewerZ; + long chunkSect = ChunkSectionPos.asLong(vX >> 4, vY >> 4, vZ >> 4); + boolean blanketDeny = false; - + // check explicit id/position first for (var rr : assignedRegions) { if (rr == null) continue; @@ -420,7 +419,7 @@ private boolean shouldRender(Function> ty return rr.reg.mode() == Mode.ALLOW; } } - + // fall through to area regions that may have a type match boolean permitted = false; for (var rr : regionsByChunkSection.get(chunkSect)) { @@ -441,7 +440,7 @@ private boolean shouldRender(Function> ty } } if (permitted) return true; - + // exclusive regions not matched above must mean reject for (var rr : exclusiveTypeRegions.get(type)) { if (!rr.reg.contains(viewerX, viewerY, viewerZ)) { @@ -451,7 +450,7 @@ private boolean shouldRender(Function> ty if (anyExclusive) return false; return !blanketDeny; } - + public void readNbt(NbtCompound nbt) { for (String name : nbt.getKeys()) { NbtCompound cmp = nbt.getCompound(name); @@ -461,7 +460,7 @@ public void readNbt(NbtCompound nbt) { add(name, r); int[] entities = cmp.getIntArray("EAtt"); for (int i = 0; i < entities.length; i += 4) { - attachEntity(r, Uuids.toUuid(Arrays.copyOfRange(entities, i, i+4))); + attachEntity(r, Uuids.toUuid(Arrays.copyOfRange(entities, i, i + 4))); } long[] blockentities = cmp.getLongArray("BEAtt"); for (long l : blockentities) { @@ -475,13 +474,13 @@ public void readNbt(NbtCompound nbt) { } } } - + public void writeNbt(NbtCompound nbt) { for (var ex : explaineds.values()) { RenderRegion r = ex.reg; NbtCompound cmp = new NbtCompound(); cmp.putString("Mode", r.mode().name()); - cmp.putIntArray("Box", new int[] { r.minX(), r.minY(), r.minZ(), r.maxX(), r.maxY(), r.maxZ() }); + cmp.putIntArray("Box", new int[]{r.minX(), r.minY(), r.minZ(), r.maxX(), r.maxY(), r.maxZ()}); IntList entities = new IntArrayList(); for (var entityId : ex.entityAttachments) { entities.addAll(IntList.of(Uuids.toIntArray(entityId))); @@ -501,5 +500,5 @@ public void writeNbt(NbtCompound nbt) { nbt.put(ex.name, cmp); } } - + } diff --git a/src/main/java/net/modfest/fireblanket/world/render_regions/RenderRegionsState.java b/src/main/java/net/modfest/fireblanket/world/render_regions/RenderRegionsState.java index f43482f..4d09df9 100644 --- a/src/main/java/net/modfest/fireblanket/world/render_regions/RenderRegionsState.java +++ b/src/main/java/net/modfest/fireblanket/world/render_regions/RenderRegionsState.java @@ -5,12 +5,11 @@ import net.minecraft.registry.RegistryWrapper; import net.minecraft.server.world.ServerWorld; import net.minecraft.world.PersistentState; -import net.modfest.fireblanket.Fireblanket; public class RenderRegionsState extends PersistentState { private final RenderRegions regions; - + public RenderRegionsState(ServerWorld world) { this.regions = new RenderRegions(this::markDirty, req -> { for (var player : world.getPlayers()) { @@ -21,19 +20,19 @@ public RenderRegionsState(ServerWorld world) { public static RenderRegionsState get(ServerWorld world) { return world.getPersistentStateManager().getOrCreate( - new PersistentState.Type<>( - () -> new RenderRegionsState(world), - (nbt, w) -> readNbt(world, nbt), - // Fabric API handles null datafix types - null - ), + new PersistentState.Type<>( + () -> new RenderRegionsState(world), + (nbt, w) -> readNbt(world, nbt), + // Fabric API handles null datafix types + null + ), "fireblanket_render_regions"); } - + public RenderRegions getRegions() { return regions; } - + public static RenderRegionsState readNbt(ServerWorld world, NbtCompound tag) { RenderRegionsState ret = new RenderRegionsState(world); ret.regions.readNbt(tag); diff --git a/src/main/resources/assets/fireblanket/lang/en_us.json b/src/main/resources/assets/fireblanket/lang/en_us.json index bfcfdfb..861f722 100644 --- a/src/main/resources/assets/fireblanket/lang/en_us.json +++ b/src/main/resources/assets/fireblanket/lang/en_us.json @@ -1,4 +1,4 @@ { - "argument.entity.selector.limit.unforced": "Targeting too many entities with no distance filter; add `force=true` to the selector to bypass", - "argument.entity.options.force.description": "Force-allow more than 50 entities targeted with no distance filter" + "argument.entity.selector.limit.unforced": "Targeting too many entities with no distance filter; add `force=true` to the selector to bypass", + "argument.entity.options.force.description": "Force-allow more than 50 entities targeted with no distance filter" } \ No newline at end of file diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 932d9b6..05e34bf 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -1,29 +1,33 @@ { "schemaVersion": 1, - "id": "fireblanket", + "id": "${modId}", "version": "${version}", - "name": "Fireblanket", - "description": "Performance, bugfixes, and utilities for ModFest events.", + "name": "${modName}", + "description": "${modDescription}", "authors": [ - "jaskarth", - "unascribed" + "${authors}" ], "contributors": [ - "Patbox", - "IThundxr" + "${contributors}" ], - "license": "AGPL-3.0-or-later", - "icon": "assets/fireblanket/icon.png", "contact": { - "homepage": "https://github.com/ModFest/fireblanket", - "issues": "https://github.com/ModFest/fireblanket/issues", - "sources": "https://github.com/ModFest/fireblanket" + "homepage": "${homepage}", + "issues": "${issues}", + "sources": "${sources}" }, + "license": "${license}", + "icon": "assets/fireblanket/icon.png", "entrypoints": { - "main": [ "net.modfest.fireblanket.Fireblanket" ], - "client": [ "net.modfest.fireblanket.FireblanketClient" ] + "main": [ + "net.modfest.fireblanket.Fireblanket" + ], + "client": [ + "net.modfest.fireblanket.FireblanketClient" + ] }, - "mixins": [ "fireblanket.mixins.json" ], + "mixins": [ + "fireblanket.mixins.json" + ], "accessWidener": "fireblanket.aw", "depends": { "minecraft": ">=${mc}", diff --git a/src/main/resources/fireblanket.mixins.json b/src/main/resources/fireblanket.mixins.json index 2438587..5efbf6e 100644 --- a/src/main/resources/fireblanket.mixins.json +++ b/src/main/resources/fireblanket.mixins.json @@ -1,81 +1,81 @@ { - "required": true, - "package": "net.modfest.fireblanket.mixin", - "compatibilityLevel": "JAVA_17", - "plugin": "net.modfest.fireblanket.FireblanketMixin", - "mixins": [ - "accessor.BlockEntityTypeAccessor", - "accessor.ClientConnectionAccessor", - "accessor.EntityTypeAccessor", - "accessor.ServerChunkManagerAccessor", - "accessor.ServerLoginNetworkHandlerAccessor", - "adventure_fix.MixinEggItem", - "adventure_fix.MixinFlowerPotBlock", - "ai.MixinTemptGoal", - "be_sync.MixinBlockEntity", - "be_sync.MixinChunkHolder", - "block.MixinCommandBlock", - "block_format.MixinChunkSection", - "entity_ticking.MixinDebugStickItem", - "entity_ticking.MixinEntity", - "entity_ticking.MixinItemGroups", - "entity_ticking.MixinLivingEntity", - "entity_ticking.MixinMinecraftServer", - "entity_ticking.MixinServerChunkLoadingManager", - "entity_ticking.create.MixinSuperGlueEntity", - "footgun.MixinEntitySelectorOptions", - "footgun.MixinEntitySelectorReader", - "fsc.MixinClientConnection", - "fsc.MixinSizePrepender", - "fsc.MixinSplitterHandler", - "io_uring.MixinServerNetworkIo", - "mods.create.AccessorSmartBlockEntity", - "mods.create.MixinMechanicalBearingBlockEntity", - "mods.mythicmetals.MixinCarmotShield", - "mods.pehkui.MixinScaleUtils", - "mods.pswg.MixinComplexCollisionManager", - "mods.terracotta_knights.MixinItemPickupGoal", - "opto.MixinEntitySelector", - "opto.MixinRecipeManager", - "packet_chunk_cache.MixinChunkDataS2CPacket", - "packet_chunk_cache.MixinWorldChunk", - "region_chunk_cache.MixinServerChunkManager", - "serde.MixinNbtCompound", - "serde.MixinServerPlayerEntity", - "sounds.MixinSpyglassItem", - "zstd.MixinChunkCompressionFormat", - "zstd.MixinLevelStorageSession", - "zstd.MixinPersistentState", - "zstd.MixinPersistentStateManager", - "zstd.MixinRegionFile" - ], - "injectors": { - "defaultRequire": 1 - }, - "client": [ - "accessor.ClientLoginNetworkHandlerAccessor", - "client.MixinClientPlayNetworkHandler", - "client.MixinRenderSystem", - "client.MixinSignBlockEntityRenderer", - "client.be_masking.MixinBlockEntityRenderDispatcher", - "client.be_masking.MixinRebuildTask", - "client.be_masking.sodium.MixinChunkRenderRebuildTask", - "client.bufferbuilder_opto.MixinBufferBuilder", - "client.bufferbuilder_opto.MixinVertexFormat", - "client.entity_masking.MixinEntityRenderer", - "client.entity_ticking.MixinArmorStandEntity", - "client.entity_ticking.MixinLivingEntity", - "client.hooks.MixinWorldRenderer", - "client.lambdamap.MixinMapRegionFile", - "client.render_regions.MixinBlockEntityRenderDispatcher", - "client.render_regions.MixinEntityRenderDispatcher", - "client.render_regions.MixinRegionSubjects", - "client.timing.MixinBlockEntityRenderDispatcher", - "client.timing.MixinClientWorld", - "client.timing.MixinEntityRenderer", - "client.timing.MixinObservables", - "client.timing.MixinWorld", - "client.vbo_opto.MixinShaderProgram", - "client.vbo_opto.MixinVertexBuffer" - ] + "required": true, + "package": "net.modfest.fireblanket.mixin", + "compatibilityLevel": "JAVA_17", + "plugin": "net.modfest.fireblanket.FireblanketMixin", + "mixins": [ + "accessor.BlockEntityTypeAccessor", + "accessor.ClientConnectionAccessor", + "accessor.EntityTypeAccessor", + "accessor.ServerChunkManagerAccessor", + "accessor.ServerLoginNetworkHandlerAccessor", + "adventure_fix.MixinEggItem", + "adventure_fix.MixinFlowerPotBlock", + "ai.MixinTemptGoal", + "be_sync.MixinBlockEntity", + "be_sync.MixinChunkHolder", + "block.MixinCommandBlock", + "block_format.MixinChunkSection", + "entity_ticking.MixinDebugStickItem", + "entity_ticking.MixinEntity", + "entity_ticking.MixinItemGroups", + "entity_ticking.MixinLivingEntity", + "entity_ticking.MixinMinecraftServer", + "entity_ticking.MixinServerChunkLoadingManager", + "entity_ticking.create.MixinSuperGlueEntity", + "footgun.MixinEntitySelectorOptions", + "footgun.MixinEntitySelectorReader", + "fsc.MixinClientConnection", + "fsc.MixinSizePrepender", + "fsc.MixinSplitterHandler", + "io_uring.MixinServerNetworkIo", + "mods.create.AccessorSmartBlockEntity", + "mods.create.MixinMechanicalBearingBlockEntity", + "mods.mythicmetals.MixinCarmotShield", + "mods.pehkui.MixinScaleUtils", + "mods.pswg.MixinComplexCollisionManager", + "mods.terracotta_knights.MixinItemPickupGoal", + "opto.MixinEntitySelector", + "opto.MixinRecipeManager", + "packet_chunk_cache.MixinChunkDataS2CPacket", + "packet_chunk_cache.MixinWorldChunk", + "region_chunk_cache.MixinServerChunkManager", + "serde.MixinNbtCompound", + "serde.MixinServerPlayerEntity", + "sounds.MixinSpyglassItem", + "zstd.MixinChunkCompressionFormat", + "zstd.MixinLevelStorageSession", + "zstd.MixinPersistentState", + "zstd.MixinPersistentStateManager", + "zstd.MixinRegionFile" + ], + "injectors": { + "defaultRequire": 1 + }, + "client": [ + "accessor.ClientLoginNetworkHandlerAccessor", + "client.MixinClientPlayNetworkHandler", + "client.MixinRenderSystem", + "client.MixinSignBlockEntityRenderer", + "client.be_masking.MixinBlockEntityRenderDispatcher", + "client.be_masking.MixinRebuildTask", + "client.be_masking.sodium.MixinChunkRenderRebuildTask", + "client.bufferbuilder_opto.MixinBufferBuilder", + "client.bufferbuilder_opto.MixinVertexFormat", + "client.entity_masking.MixinEntityRenderer", + "client.entity_ticking.MixinArmorStandEntity", + "client.entity_ticking.MixinLivingEntity", + "client.hooks.MixinWorldRenderer", + "client.lambdamap.MixinMapRegionFile", + "client.render_regions.MixinBlockEntityRenderDispatcher", + "client.render_regions.MixinEntityRenderDispatcher", + "client.render_regions.MixinRegionSubjects", + "client.timing.MixinBlockEntityRenderDispatcher", + "client.timing.MixinClientWorld", + "client.timing.MixinEntityRenderer", + "client.timing.MixinObservables", + "client.timing.MixinWorld", + "client.vbo_opto.MixinShaderProgram", + "client.vbo_opto.MixinVertexBuffer" + ] }