From c8690ec68dd790388fae3fdf181a8d86f86c1ec1 Mon Sep 17 00:00:00 2001 From: FX - PR0CESS Date: Mon, 4 Apr 2022 18:12:37 -0400 Subject: [PATCH 1/9] Changed Rule: `updateSuppressionBlock` to match new update suppression --- src/main/java/carpet/CarpetSettings.java | 43 +-- ...rierBlock_updateSuppressionBlockMixin.java | 26 +- .../CollectingNeighborUpdaterAccessor.java | 13 + .../java/carpet/mixins/LevelAccessor.java | 12 + src/main/resources/carpet.mixins.json | 352 +++++++++--------- 5 files changed, 219 insertions(+), 227 deletions(-) create mode 100644 src/main/java/carpet/mixins/CollectingNeighborUpdaterAccessor.java create mode 100644 src/main/java/carpet/mixins/LevelAccessor.java diff --git a/src/main/java/carpet/CarpetSettings.java b/src/main/java/carpet/CarpetSettings.java index f8803ef5c2..5e740d60bd 100644 --- a/src/main/java/carpet/CarpetSettings.java +++ b/src/main/java/carpet/CarpetSettings.java @@ -54,7 +54,6 @@ public class CarpetSettings public static boolean chainStoneStickToAll = false; public static Block structureBlockIgnoredBlock = Blocks.STRUCTURE_VOID; public static final int vanillaStructureBlockLimit = 48; - public static int updateSuppressionBlockSetting = -1; private static class LanguageValidator extends Validator { @Override public String validate(CommandSourceStack source, ParsedRule currentRule, String newValue, String string) { @@ -1045,14 +1044,14 @@ public String validate(CommandSourceStack source, ParsedRule currentRule public static boolean lightningKillsDropsFix = false; @Rule( - desc = "Placing an activator rail on top of a barrier block will update suppress when the rail turns off.", - extra = {"Entering an integer will make the update suppression block auto-reset","Integer entered is the delay in ticks for it to reset"}, - category = {CREATIVE, "extras"}, - options = {"false","true","1","6"}, + desc = "Placing an activator rail on top of a barrier block will fill the neighbor updater stack when the rail turns off.", + extra = {"The integer entered is the amount of updates that should be left in the stack", "-1 turns it off"}, + category = CREATIVE, + options = {"-1","0","10","50"}, strict = false, validate = updateSuppressionBlockModes.class ) - public static String updateSuppressionBlock = "false"; + public static int updateSuppressionBlock = -1; @Rule( desc = "Fixes update suppression causing server crashes.", @@ -1060,38 +1059,12 @@ public String validate(CommandSourceStack source, ParsedRule currentRule ) public static boolean updateSuppressionCrashFix = false; - public static int getInteger(String s) { - try { - return Integer.parseInt(s); - } catch(NumberFormatException e) { - return -1; - } - } - - private static class updateSuppressionBlockModes extends Validator { + private static class updateSuppressionBlockModes extends Validator { @Override - public String validate(CommandSourceStack source, ParsedRule currentRule, String newValue, String string) { - if (!currentRule.get().equals(newValue)) { - if (newValue.equalsIgnoreCase("false")) { - updateSuppressionBlockSetting = -1; - } else if (newValue.equalsIgnoreCase("true")) { - updateSuppressionBlockSetting = 0; - } else { - int parsedInt = getInteger(newValue); - if (parsedInt <= 0) { - updateSuppressionBlockSetting = -1; - return "false"; - } else { - updateSuppressionBlockSetting = parsedInt; - } - } - } + public Integer validate(CommandSourceStack source, ParsedRule currentRule, Integer newValue, String string) { + if (newValue < -1) newValue = -1; return newValue; } - @Override - public String description() { - return "Cannot be negative, can be true, false, or # > 0"; - } } @Rule( diff --git a/src/main/java/carpet/mixins/BarrierBlock_updateSuppressionBlockMixin.java b/src/main/java/carpet/mixins/BarrierBlock_updateSuppressionBlockMixin.java index ea9cff3227..9573acd57e 100644 --- a/src/main/java/carpet/mixins/BarrierBlock_updateSuppressionBlockMixin.java +++ b/src/main/java/carpet/mixins/BarrierBlock_updateSuppressionBlockMixin.java @@ -1,6 +1,8 @@ package carpet.mixins; import carpet.CarpetSettings; +import net.minecraft.world.level.redstone.CollectingNeighborUpdater; +import net.minecraft.world.level.redstone.NeighborUpdater; import org.spongepowered.asm.mixin.Mixin; import java.util.Random; @@ -22,33 +24,33 @@ public class BarrierBlock_updateSuppressionBlockMixin extends Block { public BarrierBlock_updateSuppressionBlockMixin(Properties settings) { super(settings); } @Override - public int getSignal(BlockState state, BlockGetter world, BlockPos pos, Direction direction) { + public int getSignal(BlockState state, BlockGetter level, BlockPos pos, Direction direction) { return (shouldPower && direction == Direction.DOWN) ? 15 : 0; } @Override - public void neighborChanged(BlockState state, Level world, BlockPos pos, Block block, BlockPos fromPos, boolean notify) { - if (CarpetSettings.updateSuppressionBlockSetting != -1) { + public void neighborChanged(BlockState state, Level level, BlockPos pos, Block block, BlockPos fromPos, boolean notify) { + if (CarpetSettings.updateSuppressionBlock != -1) { if (fromPos.equals(pos.above())) { - BlockState stateAbove = world.getBlockState(fromPos); + BlockState stateAbove = level.getBlockState(fromPos); if (stateAbove.is(Blocks.ACTIVATOR_RAIL) && !stateAbove.getValue(PoweredRailBlock.POWERED)) { - if (CarpetSettings.updateSuppressionBlockSetting > 0) { - world.scheduleTick(pos, this, CarpetSettings.updateSuppressionBlockSetting); - } - throw new StackOverflowError("updateSuppressionBlock"); + level.scheduleTick(pos, this, 1); + NeighborUpdater updater = ((LevelAccessor)level).getNeighborUpdater(); + if (updater instanceof CollectingNeighborUpdaterAccessor cnua) + cnua.setCount(cnua.getMaxChainedNeighborUpdates()-CarpetSettings.updateSuppressionBlock); } } } - super.neighborChanged(state, world, pos, block, fromPos, notify); + super.neighborChanged(state, level, pos, block, fromPos, notify); } @Override - public void tick(BlockState state, ServerLevel world, BlockPos pos, Random random) { + public void tick(BlockState state, ServerLevel level, BlockPos pos, Random random) { BlockPos posAbove = pos.above(); - BlockState stateAbove = world.getBlockState(posAbove); + BlockState stateAbove = level.getBlockState(posAbove); if (stateAbove.is(Blocks.ACTIVATOR_RAIL) && !stateAbove.getValue(PoweredRailBlock.POWERED)) { shouldPower = true; - world.setBlock(posAbove, stateAbove.setValue(PoweredRailBlock.POWERED, true), 3); + level.setBlock(posAbove, stateAbove.setValue(PoweredRailBlock.POWERED, true), 3); shouldPower = false; } } diff --git a/src/main/java/carpet/mixins/CollectingNeighborUpdaterAccessor.java b/src/main/java/carpet/mixins/CollectingNeighborUpdaterAccessor.java new file mode 100644 index 0000000000..8e2621869f --- /dev/null +++ b/src/main/java/carpet/mixins/CollectingNeighborUpdaterAccessor.java @@ -0,0 +1,13 @@ +package carpet.mixins; + +import net.minecraft.world.level.redstone.CollectingNeighborUpdater; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(CollectingNeighborUpdater.class) +public interface CollectingNeighborUpdaterAccessor { + @Accessor("count") + void setCount(int count); + @Accessor("maxChainedNeighborUpdates") + int getMaxChainedNeighborUpdates(); +} diff --git a/src/main/java/carpet/mixins/LevelAccessor.java b/src/main/java/carpet/mixins/LevelAccessor.java new file mode 100644 index 0000000000..054f7375c7 --- /dev/null +++ b/src/main/java/carpet/mixins/LevelAccessor.java @@ -0,0 +1,12 @@ +package carpet.mixins; + +import net.minecraft.world.level.Level; +import net.minecraft.world.level.redstone.NeighborUpdater; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(Level.class) +public interface LevelAccessor { + @Accessor("neighborUpdater") + NeighborUpdater getNeighborUpdater(); +} diff --git a/src/main/resources/carpet.mixins.json b/src/main/resources/carpet.mixins.json index c7239d9d22..2830ab7f2c 100644 --- a/src/main/resources/carpet.mixins.json +++ b/src/main/resources/carpet.mixins.json @@ -4,214 +4,206 @@ "package": "carpet.mixins", "compatibilityLevel": "JAVA_16", "mixins": [ + "AbstractArrow_extremeMixin", + "AbstractArrowMixin", + "AbstractCauldronBlock_stackableSBoxesMixin", + "AbstractContainerMenu_ctrlQCraftingMixin", + "AbstractContainerMenu_scarpetMixin", + "AbstractContainerMenu_stackableSBoxesMixin", + "AbstractContainerMenuSubclasses_scarpetMixin", + "AbstractMinecart_scarpetEventsMixin", + "ArmorStand_scarpetMarkerMixin", "BarrierBlock_updateSuppressionBlockMixin", - "SpawnState_scarpetMixin", - "MobCategory_spawnMixin", - "Commands_customCommandsMixin", - "ServerGamePacketListenerImplMixin", - - "PerfCommand_permissionMixin", - "FillCommandMixin", - "CloneCommands_fillUpdatesMixin", - "SetBlockCommand_fillUpdatesMixin", - "ForceLoadCommand_forceLoadLimitMixin", + "Blaze_extremeMixin", + "BlazeAttackGoal_extremeMixin", + "BlockEntity_movableBEMixin", "BlockInput_fillUpdatesMixin", - "Level_fillUpdatesMixin", - "LevelChunk_fillUpdatesMixin", - "StructureBlockEntity_fillUpdatesMixin", - "StructureBlockEntity_limitsMixin", - "ServerboundSetStructureBlockPacketMixin", - "StructureTemplate_fillUpdatesMixin", - "ServerGamePacketListenerImpl_interactionUpdatesMixin", - "FlowingFluid_liquidDamageDisabledMixin", - "ServerStatus_motdMixin", - "MinecraftServer_pingPlayerSampleLimit", - - "MinecraftServer_coreMixin", - - "MinecraftServer_tickspeedMixin", - "Level_tickMixin", - "ServerLevel_tickMixin", + "BlockInput_scarpetMixin", + "BlockItem_creativeNoClipMixin", + "BlockItem_scarpetEventMixin", + "BlockLightSectionStorage_scarpetChunkCreationMixin", + "BlockPredicate_scarpetMixin", "BoundTickingBlockEntity_tickMixin", - "ServerChunkCache_tickMixin", + "BuddingAmethystBlock_movableAmethystMixin", + "ChunkGenerator_customMobSpawnsMixin", + "ChunkGenerator_scarpetMixin", + "ChunkHolder_scarpetChunkCreationMixin", + "ChunkMap_creativePlayersLoadChunksMixin", + "ChunkMap_scarpetChunkCreationMixin", "ChunkMap_tickMixin", + "CloneCommands_fillUpdatesMixin", + "CollectingNeighborUpdaterAccessor", + "Commands_customCommandsMixin", + "Connection_packetCounterMixin", + "Containers_extremeMixin", + "CoralFanBlock_renewableCoralMixin", + "CoralFeature_renewableCoralMixin", + "CoralPlantBlock_renewableCoralMixin", + "DefaultDispenseItemBehavior_extremeBehavioursMixin", + "DirectionMixin", + "DispenserBlock_cactusMixin", + "DispenserBlock_qcMixin", + "DistanceManager_scarpetChunkCreationMixin", + "DistanceManager_scarpetMixin", + "DistanceManager_spawnChunksMixin", "DistanceManager_tickMixin", - "ServerFunctionManager_tickMixin", - "ChunkMap_scarpetChunkCreationMixin", - "LevelEntityGetterAdapter_scarpetMixin", - "ChunkHolder_scarpetChunkCreationMixin", - "ThreadedLevelLightEngine_scarpetMixin", "DynamicGraphMinFixedPoint_resetChunkInterface", - "DistanceManager_scarpetChunkCreationMixin", - "LevelLightEngine_scarpetChunkCreationMixin", + "EndCrystal_scarpetEventsMixin", + "Entity_scarpetEventsMixin", + "EntityMixin", + "ExperienceOrb_xpNoCooldownMixin", + "Explosion_optimizedTntMixin", + "Explosion_scarpetEventMixin", + "ExplosionAccessor", + "FallingBlockEntity_scarpetEventsMixin", + "FallingBlockEntityMixin", + "FillCommandMixin", + "FireworkRocketEntity_extremeMixin", + "FishingHook_extremeMixin", + "FlatLevelSource_structuresMixin", + "FlowingFluid_liquidDamageDisabledMixin", + "ForceLoadCommand_forceLoadLimitMixin", + "Guardian_renewableSpongesMixin", + "HangingEntity_scarpetEventsMixin", + "HopperBlock_cactusMixin", + "HopperBlockEntity_counterMixin", + "HorseBaseEntity_scarpetMixin", + "Husk_templesMixin", + "InfestedBlock_gravelMixin", + "Ingredient_scarpetMixin", + "Inventory_scarpetEventMixin", + "ItemEntityMixin", + "LavaFluid_renewableDeepslateMixin", "LayerLightEngine_scarpetChunkCreationMixin", "LayerLightSectionStorage_scarpetChunkCreationMixin", - "BlockLightSectionStorage_scarpetChunkCreationMixin", - "SkyLightSectionStorage_scarpetChunkCreationMixin", - "DistanceManager_spawnChunksMixin", - "ServerLevel_spawnChunksMixin", - "ThreadedLevelLightEngine_scarpetChunkCreationMixin", - "DistanceManager_spawnChunksMixin", - "ServerLevel_spawnChunksMixin", - "LivingEntity_cleanLogsMixin", - "MobMixin", - "ServerEntity_leashFixMixin", - "Villager_aiMixin", - "Player_fakePlayersMixin", - "ServerGamePacketListenerImpl_coreMixin", - "ServerGamePacketListenerImpl_tickMixin", - "MinecraftServer_scarpetMixin", - "ExperienceOrb_xpNoCooldownMixin", - "Player_xpNoCooldownMixin", - "ServerboundPlayerActionPacketMixin", - "ServerPlayerMixin", - "PlayerList_coreMixin", - "PlayerList_fakePlayersMixin", - "RedstoneWireBlock_fastMixin", - "WoolCarpetBlock_placeMixin", - "SummonCommand_lightningMixin", - "PistonHandler_pushLimitMixin", - "PoweredRailBlock_powerLimitMixin", - "LivingEntity_maxCollisionsMixin", + "Level_fillUpdatesMixin", "Level_getOtherEntitiesLimited", - "CoralPlantBlock_renewableCoralMixin", - "CoralFanBlock_renewableCoralMixin", - "CoralFeature_renewableCoralMixin", - "BuddingAmethystBlock_movableAmethystMixin", + "Level_movableBEMixin", + "Level_scarpetPlopMixin", + "Level_tickMixin", + "Level_updateSuppressionCrashFixMixin", + "LevelAccessor", + "LevelChunk_fillUpdatesMixin", + "LevelChunk_movableBEMixin", + "LevelEntityGetterAdapter_scarpetMixin", + "LevelLightEngine_scarpetChunkCreationMixin", "LiquidBlock_renewableBlackstoneMixin", "LiquidBlock_renewableDeepslateMixin", - "LavaFluid_renewableDeepslateMixin", - "Level_scarpetPlopMixin", - "WorldGenRegion_scarpetPlopMixin", - "StructurePiece_scarpetPlopMixin", - "PlacedFeature_scarpetMixin", - "PieceGeneratorSupplier_plopMixin", - "ServerGamePacketListenerImpl_scarpetEventsMixin", - "ServerPlayerGameMode_scarpetEventsMixin", - "Player_parrotMixin", - "SaplingBlock_desertShrubsMixin", - "EntityMixin", - "FlatLevelSource_structuresMixin", - "ChunkGenerator_scarpetMixin", - "Guardian_renewableSpongesMixin", - "Husk_templesMixin", - "ChunkGenerator_customMobSpawnsMixin", - "ServerChunkCacheMixin", + "LivingEntity_cleanLogsMixin", + "LivingEntity_creativeFlyMixin", + "LivingEntity_maxCollisionsMixin", + "LivingEntity_scarpetEventsMixin", + "MerchantResultSlot_scarpetEventMixin", + "MinecraftServer_coreMixin", + "MinecraftServer_pingPlayerSampleLimit", + "MinecraftServer_scarpetMixin", + "MinecraftServer_tickspeedMixin", + "MinecraftServer_updateSuppressionCrashFixMixin", + "Mob_extremeMixin", + "MobCategory_spawnMixin", + "MobMixin", "NaturalSpawnerMixin", - - "DirectionMixin", - "ServerPlayerGameMode_cactusMixin", - "HopperBlock_cactusMixin", - "UseOnContext_cactusMixin", - "DispenserBlock_cactusMixin", + "NoiseSampler_scarpetMixin", + "Objective_scarpetMixin", + "PathNavigation_pathfindingMixin", + "PerfCommand_permissionMixin", + "PersistentEntitySectionManager_scarpetMixin", + "PickaxeItem_missingToolsMixin", + "PieceGeneratorSupplier_plopMixin", + "PistonBaseBlock_movableBEMixin", + "PistonBaseBlock_qcMixin", "PistonBaseBlock_rotatorBlockMixin", - "ServerGamePacketListenerImpl_antiCheatDisabledMixin", + "PistonHandler_customStickyMixin", + "PistonHandler_pushLimitMixin", + "PistonMovingBlockEntity_movableBEMixin", + "PistonMovingBlockEntity_playerHandlingMixin", + "PlacedFeature_scarpetMixin", "Player_antiCheatDisabledMixin", - "ServerPlayerGameMode_antiCheatMixin", - "HopperBlockEntity_counterMixin", - "AbstractContainerMenu_ctrlQCraftingMixin", - "Connection_packetCounterMixin", - "AbstractCauldronBlock_stackableSBoxesMixin", - "Slot_stackableSBoxesMixin", - "AbstractContainerMenu_stackableSBoxesMixin", - "ItemEntityMixin", - "TntBlock_noUpdateMixin", - "Explosion_optimizedTntMixin", - "ExplosionAccessor", - "Explosion_scarpetEventMixin", - "PrimedTntMixin", - "AbstractArrowMixin", - "FallingBlockEntityMixin", - "ThrowableProjectileMixin", - "PathNavigation_pathfindingMixin", - - "InfestedBlock_gravelMixin", + "Player_creativeNoClipMixin", + "Player_fakePlayersMixin", + "Player_parrotMixin", "Player_portalDelayMixin", - "PistonBaseBlock_qcMixin", - "DispenserBlock_qcMixin", - - "PickaxeItem_missingToolsMixin", - "DefaultDispenseItemBehavior_extremeBehavioursMixin", - "Containers_extremeMixin", - "FishingHook_extremeMixin", - "SkeletonTrapGoal_extremeMixin", - "FireworkRocketEntity_extremeMixin", - "Blaze_extremeMixin", - "BlazeAttackGoal_extremeMixin", - "Mob_extremeMixin", - "AbstractArrow_extremeMixin", - "Projectile_extremeMixin", - "WitherBoss_extremeMixin", - "ArmorStand_scarpetMarkerMixin", - "Entity_scarpetEventsMixin", - "LivingEntity_scarpetEventsMixin", "Player_scarpetEventsMixin", - "ServerPlayer_scarpetEventMixin", - "AbstractMinecart_scarpetEventsMixin", - "EndCrystal_scarpetEventsMixin", - "FallingBlockEntity_scarpetEventsMixin", - "HangingEntity_scarpetEventsMixin", - "PrimedTnt_scarpetEventsMixin", - "BlockItem_scarpetEventMixin", + "Player_xpNoCooldownMixin", + "PlayerList_coreMixin", + "PlayerList_fakePlayersMixin", "PlayerList_scarpetEventsMixin", - "Inventory_scarpetEventMixin", - "Objective_scarpetMixin", - "Scoreboard_scarpetMixin", "PlayerTeam_scarpetMixin", - "MerchantResultSlot_scarpetEventMixin", - "AbstractContainerMenu_scarpetMixin", - "AbstractContainerMenuSubclasses_scarpetMixin", - "RecipeBookMenu_scarpetMixin", - "DistanceManager_scarpetMixin", "PoiRecord_scarpetMixin", - "ServerLevel_scarpetMixin", - "PersistentEntitySectionManager_scarpetMixin", + "PoweredRailBlock_powerLimitMixin", + "PrimedTnt_scarpetEventsMixin", + "PrimedTntMixin", + "Projectile_extremeMixin", + "QuantizedSpaghettiRarityMixin_scarpetMixin", + "RecipeBookMenu_scarpetMixin", + "RecipeManager_scarpetMixin", + "RedstoneWireBlock_fastMixin", "ReloadCommand_reloadAppsMixin", + "SaplingBlock_desertShrubsMixin", + "Scoreboard_scarpetMixin", + "SculkSensorBlock_rangeMixin", + "ServerboundPlayerActionPacketMixin", + "ServerboundSetStructureBlockPacketMixin", + "ServerChunkCache_tickMixin", + "ServerChunkCacheMixin", + "ServerEntity_leashFixMixin", + "ServerFunctionManager_tickMixin", + "ServerGamePacketListenerImpl_antiCheatDisabledMixin", + "ServerGamePacketListenerImpl_coreMixin", + "ServerGamePacketListenerImpl_interactionUpdatesMixin", + "ServerGamePacketListenerImpl_scarpetEventsMixin", + "ServerGamePacketListenerImpl_tickMixin", + "ServerGamePacketListenerImplMixin", + "ServerLevel_scarpetMixin", + "ServerLevel_spawnChunksMixin", + "ServerLevel_tickMixin", + "ServerPlayer_scarpetEventMixin", + "ServerPlayer_updateSuppressionCrashFixMixin", + "ServerPlayerGameMode_antiCheatMixin", + "ServerPlayerGameMode_cactusMixin", + "ServerPlayerGameMode_scarpetEventsMixin", + "ServerPlayerMixin", + "ServerStatus_motdMixin", + "SetBlockCommand_fillUpdatesMixin", + "ShulkerBoxBlockEntity_creativeNoClipMixin", + "SkeletonTrapGoal_extremeMixin", + "SkyLightSectionStorage_scarpetChunkCreationMixin", + "Slot_stackableSBoxesMixin", + "SpawnState_scarpetMixin", + "StandingAndWallBlockItem_creativeNoClipMixin", + "StructureBlockEntity_fillUpdatesMixin", + "StructureBlockEntity_limitsMixin", + "StructurePiece_scarpetPlopMixin", + "StructureTemplate_fillUpdatesMixin", + "SummonCommand_lightningMixin", "SystemReport_addScarpetAppsMixin", - - "RecipeManager_scarpetMixin", - "Ingredient_scarpetMixin", - "BlockInput_scarpetMixin", - "BlockPredicate_scarpetMixin", "TagPredicate_scarpetMixin", - "HorseBaseEntity_scarpetMixin", - "NoiseSampler_scarpetMixin", - "QuantizedSpaghettiRarityMixin_scarpetMixin", - - "BlockEntity_movableBEMixin", - "PistonBaseBlock_movableBEMixin", - "PistonMovingBlockEntity_movableBEMixin", - "Level_movableBEMixin", - "LevelChunk_movableBEMixin", - "PistonHandler_customStickyMixin", - "Player_creativeNoClipMixin", - "PistonMovingBlockEntity_playerHandlingMixin", - "BlockItem_creativeNoClipMixin", - "StandingAndWallBlockItem_creativeNoClipMixin", - "ShulkerBoxBlockEntity_creativeNoClipMixin", "TheEndGatewayBlockEntity_creativeNoClipMixin", - "LivingEntity_creativeFlyMixin", - "Level_updateSuppressionCrashFixMixin", - "MinecraftServer_updateSuppressionCrashFixMixin", - "ServerPlayer_updateSuppressionCrashFixMixin", - "ChunkMap_creativePlayersLoadChunksMixin", - "SculkSensorBlock_rangeMixin" + "ThreadedLevelLightEngine_scarpetChunkCreationMixin", + "ThreadedLevelLightEngine_scarpetMixin", + "ThrowableProjectileMixin", + "TntBlock_noUpdateMixin", + "UseOnContext_cactusMixin", + "Villager_aiMixin", + "WitherBoss_extremeMixin", + "WoolCarpetBlock_placeMixin", + "WorldGenRegion_scarpetPlopMixin" ], "client": [ - "Timer_tickSpeedMixin", - "MinecraftMixin", - "Minecraft_pausedShakeMixin", - "LevelRenderer_pausedShakeMixin", + "ClientPacketListener_customPacketsMixin", + "DebugRenderer_scarpetRenderMixin", "Gui_tablistMixin", - "PlayerTabOverlayMixin", + "LevelRenderer_creativeNoClipMixin", + "LevelRenderer_fogOffMixin", + "LevelRenderer_pausedShakeMixin", + "LevelRenderer_scarpetRenderMixin", + "LocalPlayer_clientCommandMixin", + "Minecraft_pausedShakeMixin", + "MinecraftMixin", "PistonHeadRenderer_movableBEMixin", + "PlayerTabOverlayMixin", "StructureBlockRenderer_mixin", - "LocalPlayer_clientCommandMixin", - "LevelRenderer_fogOffMixin", - "LevelRenderer_creativeNoClipMixin", - "ClientPacketListener_customPacketsMixin", - "DebugRenderer_scarpetRenderMixin", - "LevelRenderer_scarpetRenderMixin" + "Timer_tickSpeedMixin" ], "server": [ ], From ee6a993727cde52664e9bfed1360d9ea2e3b5da1 Mon Sep 17 00:00:00 2001 From: FX - PR0CESS Date: Mon, 4 Apr 2022 19:07:57 -0400 Subject: [PATCH 2/9] Make it easier to use --- .../carpet/mixins/BarrierBlock_updateSuppressionBlockMixin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/carpet/mixins/BarrierBlock_updateSuppressionBlockMixin.java b/src/main/java/carpet/mixins/BarrierBlock_updateSuppressionBlockMixin.java index 9573acd57e..566d40857c 100644 --- a/src/main/java/carpet/mixins/BarrierBlock_updateSuppressionBlockMixin.java +++ b/src/main/java/carpet/mixins/BarrierBlock_updateSuppressionBlockMixin.java @@ -50,7 +50,7 @@ public void tick(BlockState state, ServerLevel level, BlockPos pos, Random rando BlockState stateAbove = level.getBlockState(posAbove); if (stateAbove.is(Blocks.ACTIVATOR_RAIL) && !stateAbove.getValue(PoweredRailBlock.POWERED)) { shouldPower = true; - level.setBlock(posAbove, stateAbove.setValue(PoweredRailBlock.POWERED, true), 3); + level.setBlock(posAbove, stateAbove.setValue(PoweredRailBlock.POWERED, true), Block.UPDATE_CLIENTS | Block.UPDATE_NONE); shouldPower = false; } } From f4ddd2ec648ceff924a0809b4b73fbdf9d647663 Mon Sep 17 00:00:00 2001 From: FX - PR0CESS Date: Mon, 4 Apr 2022 19:13:38 -0400 Subject: [PATCH 3/9] Carpets mixin file will be the death of me --- src/main/resources/carpet.mixins.json | 354 +++++++++++++------------- 1 file changed, 182 insertions(+), 172 deletions(-) diff --git a/src/main/resources/carpet.mixins.json b/src/main/resources/carpet.mixins.json index 2830ab7f2c..3501661c3e 100644 --- a/src/main/resources/carpet.mixins.json +++ b/src/main/resources/carpet.mixins.json @@ -4,206 +4,216 @@ "package": "carpet.mixins", "compatibilityLevel": "JAVA_16", "mixins": [ - "AbstractArrow_extremeMixin", - "AbstractArrowMixin", - "AbstractCauldronBlock_stackableSBoxesMixin", - "AbstractContainerMenu_ctrlQCraftingMixin", - "AbstractContainerMenu_scarpetMixin", - "AbstractContainerMenu_stackableSBoxesMixin", - "AbstractContainerMenuSubclasses_scarpetMixin", - "AbstractMinecart_scarpetEventsMixin", - "ArmorStand_scarpetMarkerMixin", "BarrierBlock_updateSuppressionBlockMixin", - "Blaze_extremeMixin", - "BlazeAttackGoal_extremeMixin", - "BlockEntity_movableBEMixin", - "BlockInput_fillUpdatesMixin", - "BlockInput_scarpetMixin", - "BlockItem_creativeNoClipMixin", - "BlockItem_scarpetEventMixin", - "BlockLightSectionStorage_scarpetChunkCreationMixin", - "BlockPredicate_scarpetMixin", - "BoundTickingBlockEntity_tickMixin", - "BuddingAmethystBlock_movableAmethystMixin", - "ChunkGenerator_customMobSpawnsMixin", - "ChunkGenerator_scarpetMixin", - "ChunkHolder_scarpetChunkCreationMixin", - "ChunkMap_creativePlayersLoadChunksMixin", - "ChunkMap_scarpetChunkCreationMixin", - "ChunkMap_tickMixin", - "CloneCommands_fillUpdatesMixin", - "CollectingNeighborUpdaterAccessor", + "SpawnState_scarpetMixin", + "MobCategory_spawnMixin", "Commands_customCommandsMixin", - "Connection_packetCounterMixin", - "Containers_extremeMixin", - "CoralFanBlock_renewableCoralMixin", - "CoralFeature_renewableCoralMixin", - "CoralPlantBlock_renewableCoralMixin", - "DefaultDispenseItemBehavior_extremeBehavioursMixin", - "DirectionMixin", - "DispenserBlock_cactusMixin", - "DispenserBlock_qcMixin", - "DistanceManager_scarpetChunkCreationMixin", - "DistanceManager_scarpetMixin", - "DistanceManager_spawnChunksMixin", - "DistanceManager_tickMixin", - "DynamicGraphMinFixedPoint_resetChunkInterface", - "EndCrystal_scarpetEventsMixin", - "Entity_scarpetEventsMixin", - "EntityMixin", - "ExperienceOrb_xpNoCooldownMixin", - "Explosion_optimizedTntMixin", - "Explosion_scarpetEventMixin", - "ExplosionAccessor", - "FallingBlockEntity_scarpetEventsMixin", - "FallingBlockEntityMixin", + "ServerGamePacketListenerImplMixin", + + "PerfCommand_permissionMixin", "FillCommandMixin", - "FireworkRocketEntity_extremeMixin", - "FishingHook_extremeMixin", - "FlatLevelSource_structuresMixin", - "FlowingFluid_liquidDamageDisabledMixin", + "CloneCommands_fillUpdatesMixin", + "SetBlockCommand_fillUpdatesMixin", "ForceLoadCommand_forceLoadLimitMixin", - "Guardian_renewableSpongesMixin", - "HangingEntity_scarpetEventsMixin", - "HopperBlock_cactusMixin", - "HopperBlockEntity_counterMixin", - "HorseBaseEntity_scarpetMixin", - "Husk_templesMixin", - "InfestedBlock_gravelMixin", - "Ingredient_scarpetMixin", - "Inventory_scarpetEventMixin", - "ItemEntityMixin", - "LavaFluid_renewableDeepslateMixin", - "LayerLightEngine_scarpetChunkCreationMixin", - "LayerLightSectionStorage_scarpetChunkCreationMixin", + "BlockInput_fillUpdatesMixin", "Level_fillUpdatesMixin", - "Level_getOtherEntitiesLimited", - "Level_movableBEMixin", - "Level_scarpetPlopMixin", - "Level_tickMixin", - "Level_updateSuppressionCrashFixMixin", - "LevelAccessor", "LevelChunk_fillUpdatesMixin", - "LevelChunk_movableBEMixin", + "StructureBlockEntity_fillUpdatesMixin", + "StructureBlockEntity_limitsMixin", + "ServerboundSetStructureBlockPacketMixin", + "StructureTemplate_fillUpdatesMixin", + "ServerGamePacketListenerImpl_interactionUpdatesMixin", + "FlowingFluid_liquidDamageDisabledMixin", + "ServerStatus_motdMixin", + "MinecraftServer_pingPlayerSampleLimit", + + "MinecraftServer_coreMixin", + + "MinecraftServer_tickspeedMixin", + "Level_tickMixin", + "ServerLevel_tickMixin", + "BoundTickingBlockEntity_tickMixin", + "ServerChunkCache_tickMixin", + "ChunkMap_tickMixin", + "DistanceManager_tickMixin", + "ServerFunctionManager_tickMixin", + "ChunkMap_scarpetChunkCreationMixin", "LevelEntityGetterAdapter_scarpetMixin", + "ChunkHolder_scarpetChunkCreationMixin", + "ThreadedLevelLightEngine_scarpetMixin", + "DynamicGraphMinFixedPoint_resetChunkInterface", + "DistanceManager_scarpetChunkCreationMixin", "LevelLightEngine_scarpetChunkCreationMixin", - "LiquidBlock_renewableBlackstoneMixin", - "LiquidBlock_renewableDeepslateMixin", + "LayerLightEngine_scarpetChunkCreationMixin", + "LayerLightSectionStorage_scarpetChunkCreationMixin", + "BlockLightSectionStorage_scarpetChunkCreationMixin", + "SkyLightSectionStorage_scarpetChunkCreationMixin", + "DistanceManager_spawnChunksMixin", + "ServerLevel_spawnChunksMixin", + "ThreadedLevelLightEngine_scarpetChunkCreationMixin", + "DistanceManager_spawnChunksMixin", + "ServerLevel_spawnChunksMixin", "LivingEntity_cleanLogsMixin", - "LivingEntity_creativeFlyMixin", - "LivingEntity_maxCollisionsMixin", - "LivingEntity_scarpetEventsMixin", - "MerchantResultSlot_scarpetEventMixin", - "MinecraftServer_coreMixin", - "MinecraftServer_pingPlayerSampleLimit", - "MinecraftServer_scarpetMixin", - "MinecraftServer_tickspeedMixin", - "MinecraftServer_updateSuppressionCrashFixMixin", - "Mob_extremeMixin", - "MobCategory_spawnMixin", "MobMixin", - "NaturalSpawnerMixin", - "NoiseSampler_scarpetMixin", - "Objective_scarpetMixin", - "PathNavigation_pathfindingMixin", - "PerfCommand_permissionMixin", - "PersistentEntitySectionManager_scarpetMixin", - "PickaxeItem_missingToolsMixin", - "PieceGeneratorSupplier_plopMixin", - "PistonBaseBlock_movableBEMixin", - "PistonBaseBlock_qcMixin", - "PistonBaseBlock_rotatorBlockMixin", - "PistonHandler_customStickyMixin", - "PistonHandler_pushLimitMixin", - "PistonMovingBlockEntity_movableBEMixin", - "PistonMovingBlockEntity_playerHandlingMixin", - "PlacedFeature_scarpetMixin", - "Player_antiCheatDisabledMixin", - "Player_creativeNoClipMixin", + "ServerEntity_leashFixMixin", + "Villager_aiMixin", "Player_fakePlayersMixin", - "Player_parrotMixin", - "Player_portalDelayMixin", - "Player_scarpetEventsMixin", + "ServerGamePacketListenerImpl_coreMixin", + "ServerGamePacketListenerImpl_tickMixin", + "MinecraftServer_scarpetMixin", + "ExperienceOrb_xpNoCooldownMixin", "Player_xpNoCooldownMixin", + "ServerboundPlayerActionPacketMixin", + "ServerPlayerMixin", "PlayerList_coreMixin", "PlayerList_fakePlayersMixin", - "PlayerList_scarpetEventsMixin", - "PlayerTeam_scarpetMixin", - "PoiRecord_scarpetMixin", - "PoweredRailBlock_powerLimitMixin", - "PrimedTnt_scarpetEventsMixin", - "PrimedTntMixin", - "Projectile_extremeMixin", - "QuantizedSpaghettiRarityMixin_scarpetMixin", - "RecipeBookMenu_scarpetMixin", - "RecipeManager_scarpetMixin", "RedstoneWireBlock_fastMixin", - "ReloadCommand_reloadAppsMixin", + "WoolCarpetBlock_placeMixin", + "SummonCommand_lightningMixin", + "PistonHandler_pushLimitMixin", + "PoweredRailBlock_powerLimitMixin", + "LivingEntity_maxCollisionsMixin", + "Level_getOtherEntitiesLimited", + "CoralPlantBlock_renewableCoralMixin", + "CoralFanBlock_renewableCoralMixin", + "CoralFeature_renewableCoralMixin", + "BuddingAmethystBlock_movableAmethystMixin", + "LiquidBlock_renewableBlackstoneMixin", + "LiquidBlock_renewableDeepslateMixin", + "LavaFluid_renewableDeepslateMixin", + "Level_scarpetPlopMixin", + "WorldGenRegion_scarpetPlopMixin", + "StructurePiece_scarpetPlopMixin", + "PlacedFeature_scarpetMixin", + "PieceGeneratorSupplier_plopMixin", + "ServerGamePacketListenerImpl_scarpetEventsMixin", + "ServerPlayerGameMode_scarpetEventsMixin", + "Player_parrotMixin", "SaplingBlock_desertShrubsMixin", - "Scoreboard_scarpetMixin", - "SculkSensorBlock_rangeMixin", - "ServerboundPlayerActionPacketMixin", - "ServerboundSetStructureBlockPacketMixin", - "ServerChunkCache_tickMixin", + "EntityMixin", + "FlatLevelSource_structuresMixin", + "ChunkGenerator_scarpetMixin", + "Guardian_renewableSpongesMixin", + "Husk_templesMixin", + "ChunkGenerator_customMobSpawnsMixin", "ServerChunkCacheMixin", - "ServerEntity_leashFixMixin", - "ServerFunctionManager_tickMixin", + "NaturalSpawnerMixin", + + "DirectionMixin", + "ServerPlayerGameMode_cactusMixin", + "HopperBlock_cactusMixin", + "UseOnContext_cactusMixin", + "DispenserBlock_cactusMixin", + "PistonBaseBlock_rotatorBlockMixin", "ServerGamePacketListenerImpl_antiCheatDisabledMixin", - "ServerGamePacketListenerImpl_coreMixin", - "ServerGamePacketListenerImpl_interactionUpdatesMixin", - "ServerGamePacketListenerImpl_scarpetEventsMixin", - "ServerGamePacketListenerImpl_tickMixin", - "ServerGamePacketListenerImplMixin", - "ServerLevel_scarpetMixin", - "ServerLevel_spawnChunksMixin", - "ServerLevel_tickMixin", - "ServerPlayer_scarpetEventMixin", - "ServerPlayer_updateSuppressionCrashFixMixin", + "Player_antiCheatDisabledMixin", "ServerPlayerGameMode_antiCheatMixin", - "ServerPlayerGameMode_cactusMixin", - "ServerPlayerGameMode_scarpetEventsMixin", - "ServerPlayerMixin", - "ServerStatus_motdMixin", - "SetBlockCommand_fillUpdatesMixin", - "ShulkerBoxBlockEntity_creativeNoClipMixin", - "SkeletonTrapGoal_extremeMixin", - "SkyLightSectionStorage_scarpetChunkCreationMixin", + "HopperBlockEntity_counterMixin", + "AbstractContainerMenu_ctrlQCraftingMixin", + "Connection_packetCounterMixin", + "AbstractCauldronBlock_stackableSBoxesMixin", "Slot_stackableSBoxesMixin", - "SpawnState_scarpetMixin", - "StandingAndWallBlockItem_creativeNoClipMixin", - "StructureBlockEntity_fillUpdatesMixin", - "StructureBlockEntity_limitsMixin", - "StructurePiece_scarpetPlopMixin", - "StructureTemplate_fillUpdatesMixin", - "SummonCommand_lightningMixin", + "AbstractContainerMenu_stackableSBoxesMixin", + "ItemEntityMixin", + "TntBlock_noUpdateMixin", + "Explosion_optimizedTntMixin", + "ExplosionAccessor", + "Explosion_scarpetEventMixin", + "PrimedTntMixin", + "AbstractArrowMixin", + "FallingBlockEntityMixin", + "ThrowableProjectileMixin", + "PathNavigation_pathfindingMixin", + + "InfestedBlock_gravelMixin", + "Player_portalDelayMixin", + "PistonBaseBlock_qcMixin", + "DispenserBlock_qcMixin", + + "PickaxeItem_missingToolsMixin", + "DefaultDispenseItemBehavior_extremeBehavioursMixin", + "Containers_extremeMixin", + "FishingHook_extremeMixin", + "SkeletonTrapGoal_extremeMixin", + "FireworkRocketEntity_extremeMixin", + "Blaze_extremeMixin", + "BlazeAttackGoal_extremeMixin", + "Mob_extremeMixin", + "AbstractArrow_extremeMixin", + "Projectile_extremeMixin", + "WitherBoss_extremeMixin", + "ArmorStand_scarpetMarkerMixin", + "Entity_scarpetEventsMixin", + "LivingEntity_scarpetEventsMixin", + "Player_scarpetEventsMixin", + "ServerPlayer_scarpetEventMixin", + "AbstractMinecart_scarpetEventsMixin", + "EndCrystal_scarpetEventsMixin", + "FallingBlockEntity_scarpetEventsMixin", + "HangingEntity_scarpetEventsMixin", + "PrimedTnt_scarpetEventsMixin", + "BlockItem_scarpetEventMixin", + "PlayerList_scarpetEventsMixin", + "Inventory_scarpetEventMixin", + "Objective_scarpetMixin", + "Scoreboard_scarpetMixin", + "PlayerTeam_scarpetMixin", + "MerchantResultSlot_scarpetEventMixin", + "AbstractContainerMenu_scarpetMixin", + "AbstractContainerMenuSubclasses_scarpetMixin", + "RecipeBookMenu_scarpetMixin", + "DistanceManager_scarpetMixin", + "PoiRecord_scarpetMixin", + "ServerLevel_scarpetMixin", + "PersistentEntitySectionManager_scarpetMixin", + "ReloadCommand_reloadAppsMixin", "SystemReport_addScarpetAppsMixin", + + "RecipeManager_scarpetMixin", + "Ingredient_scarpetMixin", + "BlockInput_scarpetMixin", + "BlockPredicate_scarpetMixin", "TagPredicate_scarpetMixin", + "HorseBaseEntity_scarpetMixin", + "NoiseSampler_scarpetMixin", + "QuantizedSpaghettiRarityMixin_scarpetMixin", + + "BlockEntity_movableBEMixin", + "PistonBaseBlock_movableBEMixin", + "PistonMovingBlockEntity_movableBEMixin", + "Level_movableBEMixin", + "LevelChunk_movableBEMixin", + "PistonHandler_customStickyMixin", + "Player_creativeNoClipMixin", + "PistonMovingBlockEntity_playerHandlingMixin", + "BlockItem_creativeNoClipMixin", + "StandingAndWallBlockItem_creativeNoClipMixin", + "ShulkerBoxBlockEntity_creativeNoClipMixin", "TheEndGatewayBlockEntity_creativeNoClipMixin", - "ThreadedLevelLightEngine_scarpetChunkCreationMixin", - "ThreadedLevelLightEngine_scarpetMixin", - "ThrowableProjectileMixin", - "TntBlock_noUpdateMixin", - "UseOnContext_cactusMixin", - "Villager_aiMixin", - "WitherBoss_extremeMixin", - "WoolCarpetBlock_placeMixin", - "WorldGenRegion_scarpetPlopMixin" + "LivingEntity_creativeFlyMixin", + "Level_updateSuppressionCrashFixMixin", + "MinecraftServer_updateSuppressionCrashFixMixin", + "ServerPlayer_updateSuppressionCrashFixMixin", + "ChunkMap_creativePlayersLoadChunksMixin", + "SculkSensorBlock_rangeMixin", + "LevelAccessor", + "CollectingNeighborUpdaterAccessor" ], "client": [ - "ClientPacketListener_customPacketsMixin", - "DebugRenderer_scarpetRenderMixin", - "Gui_tablistMixin", - "LevelRenderer_creativeNoClipMixin", - "LevelRenderer_fogOffMixin", - "LevelRenderer_pausedShakeMixin", - "LevelRenderer_scarpetRenderMixin", - "LocalPlayer_clientCommandMixin", - "Minecraft_pausedShakeMixin", + "Timer_tickSpeedMixin", "MinecraftMixin", - "PistonHeadRenderer_movableBEMixin", + "Minecraft_pausedShakeMixin", + "LevelRenderer_pausedShakeMixin", + "Gui_tablistMixin", "PlayerTabOverlayMixin", + "PistonHeadRenderer_movableBEMixin", "StructureBlockRenderer_mixin", - "Timer_tickSpeedMixin" + "LocalPlayer_clientCommandMixin", + "LevelRenderer_fogOffMixin", + "LevelRenderer_creativeNoClipMixin", + "ClientPacketListener_customPacketsMixin", + "DebugRenderer_scarpetRenderMixin", + "LevelRenderer_scarpetRenderMixin" ], "server": [ ], From 90c3395017f1928dd2d5ddd211f22ff947a6a371 Mon Sep 17 00:00:00 2001 From: FX - PR0CESS Date: Thu, 7 Apr 2022 23:43:41 -0400 Subject: [PATCH 4/9] Renamed `WorldInterface` to `LevelInterface` Merged LevelAccessor with LevelInterface --- .../{WorldInterface.java => LevelInterface.java} | 5 ++++- .../BarrierBlock_updateSuppressionBlockMixin.java | 4 ++-- src/main/java/carpet/mixins/LevelAccessor.java | 12 ------------ .../carpet/mixins/Level_getOtherEntitiesLimited.java | 4 ++-- .../java/carpet/mixins/Level_movableBEMixin.java | 4 ++-- src/main/java/carpet/mixins/Level_tickMixin.java | 11 +++++++++-- .../mixins/LivingEntity_maxCollisionsMixin.java | 4 ++-- src/main/java/carpet/mixins/NaturalSpawnerMixin.java | 6 +++--- .../PistonMovingBlockEntity_movableBEMixin.java | 8 ++++---- 9 files changed, 28 insertions(+), 30 deletions(-) rename src/main/java/carpet/fakes/{WorldInterface.java => LevelInterface.java} (84%) delete mode 100644 src/main/java/carpet/mixins/LevelAccessor.java diff --git a/src/main/java/carpet/fakes/WorldInterface.java b/src/main/java/carpet/fakes/LevelInterface.java similarity index 84% rename from src/main/java/carpet/fakes/WorldInterface.java rename to src/main/java/carpet/fakes/LevelInterface.java index b631f28227..583da75774 100644 --- a/src/main/java/carpet/fakes/WorldInterface.java +++ b/src/main/java/carpet/fakes/LevelInterface.java @@ -1,5 +1,6 @@ package carpet.fakes; +import net.minecraft.world.level.redstone.NeighborUpdater; import org.jetbrains.annotations.Nullable; import java.util.List; @@ -12,11 +13,13 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.AABB; -public interface WorldInterface +public interface LevelInterface { Map, Entity> getPrecookedMobs(); boolean setBlockStateWithBlockEntity(BlockPos blockPos, BlockState blockState, BlockEntity newBlockEntity, int int1); List getOtherEntitiesLimited(@Nullable Entity except, AABB box, Predicate predicate, int limit); + + NeighborUpdater getNeighborUpdater(); } diff --git a/src/main/java/carpet/mixins/BarrierBlock_updateSuppressionBlockMixin.java b/src/main/java/carpet/mixins/BarrierBlock_updateSuppressionBlockMixin.java index 566d40857c..32d9e96c78 100644 --- a/src/main/java/carpet/mixins/BarrierBlock_updateSuppressionBlockMixin.java +++ b/src/main/java/carpet/mixins/BarrierBlock_updateSuppressionBlockMixin.java @@ -1,7 +1,7 @@ package carpet.mixins; import carpet.CarpetSettings; -import net.minecraft.world.level.redstone.CollectingNeighborUpdater; +import carpet.fakes.LevelInterface; import net.minecraft.world.level.redstone.NeighborUpdater; import org.spongepowered.asm.mixin.Mixin; @@ -35,7 +35,7 @@ public void neighborChanged(BlockState state, Level level, BlockPos pos, Block b BlockState stateAbove = level.getBlockState(fromPos); if (stateAbove.is(Blocks.ACTIVATOR_RAIL) && !stateAbove.getValue(PoweredRailBlock.POWERED)) { level.scheduleTick(pos, this, 1); - NeighborUpdater updater = ((LevelAccessor)level).getNeighborUpdater(); + NeighborUpdater updater = ((LevelInterface)level).getNeighborUpdater(); if (updater instanceof CollectingNeighborUpdaterAccessor cnua) cnua.setCount(cnua.getMaxChainedNeighborUpdates()-CarpetSettings.updateSuppressionBlock); } diff --git a/src/main/java/carpet/mixins/LevelAccessor.java b/src/main/java/carpet/mixins/LevelAccessor.java deleted file mode 100644 index 054f7375c7..0000000000 --- a/src/main/java/carpet/mixins/LevelAccessor.java +++ /dev/null @@ -1,12 +0,0 @@ -package carpet.mixins; - -import net.minecraft.world.level.Level; -import net.minecraft.world.level.redstone.NeighborUpdater; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Mixin(Level.class) -public interface LevelAccessor { - @Accessor("neighborUpdater") - NeighborUpdater getNeighborUpdater(); -} diff --git a/src/main/java/carpet/mixins/Level_getOtherEntitiesLimited.java b/src/main/java/carpet/mixins/Level_getOtherEntitiesLimited.java index dbe06add67..4a6b4a7573 100644 --- a/src/main/java/carpet/mixins/Level_getOtherEntitiesLimited.java +++ b/src/main/java/carpet/mixins/Level_getOtherEntitiesLimited.java @@ -1,6 +1,6 @@ package carpet.mixins; -import carpet.fakes.WorldInterface; +import carpet.fakes.LevelInterface; import com.google.common.collect.Lists; import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; @@ -18,7 +18,7 @@ import net.minecraft.world.phys.AABB; @Mixin(Level.class) -public abstract class Level_getOtherEntitiesLimited implements WorldInterface { +public abstract class Level_getOtherEntitiesLimited implements LevelInterface { private static final RuntimeException CONTROL_FLOW_EXCEPTION = new RuntimeException("Should be caught for control flow in World_getOtherEntitiesLimited!"); diff --git a/src/main/java/carpet/mixins/Level_movableBEMixin.java b/src/main/java/carpet/mixins/Level_movableBEMixin.java index 770caefd5f..151f215f39 100644 --- a/src/main/java/carpet/mixins/Level_movableBEMixin.java +++ b/src/main/java/carpet/mixins/Level_movableBEMixin.java @@ -1,7 +1,7 @@ package carpet.mixins; import carpet.fakes.WorldChunkInterface; -import carpet.fakes.WorldInterface; +import carpet.fakes.LevelInterface; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ChunkHolder; import net.minecraft.util.profiling.ProfilerFiller; @@ -19,7 +19,7 @@ import org.spongepowered.asm.mixin.Shadow; @Mixin(Level.class) -public abstract class Level_movableBEMixin implements WorldInterface, LevelAccessor +public abstract class Level_movableBEMixin implements LevelInterface, LevelAccessor { @Shadow @Final diff --git a/src/main/java/carpet/mixins/Level_tickMixin.java b/src/main/java/carpet/mixins/Level_tickMixin.java index ea1ecb86e3..b644853dd1 100644 --- a/src/main/java/carpet/mixins/Level_tickMixin.java +++ b/src/main/java/carpet/mixins/Level_tickMixin.java @@ -1,8 +1,9 @@ package carpet.mixins; -import carpet.fakes.WorldInterface; +import carpet.fakes.LevelInterface; import carpet.helpers.TickSpeed; import carpet.utils.CarpetProfiler; +import net.minecraft.world.level.redstone.NeighborUpdater; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -19,14 +20,20 @@ import net.minecraft.world.level.Level; @Mixin(Level.class) -public abstract class Level_tickMixin implements WorldInterface +public abstract class Level_tickMixin implements LevelInterface { @Shadow @Final public boolean isClientSide; + @Shadow @Final protected NeighborUpdater neighborUpdater; CarpetProfiler.ProfilerToken currentSection; CarpetProfiler.ProfilerToken entitySection; Map, Entity> precookedMobs = new HashMap<>(); + @Override + public NeighborUpdater getNeighborUpdater() { + return this.neighborUpdater; + } + public Map, Entity> getPrecookedMobs() { return precookedMobs; diff --git a/src/main/java/carpet/mixins/LivingEntity_maxCollisionsMixin.java b/src/main/java/carpet/mixins/LivingEntity_maxCollisionsMixin.java index 9c07ebf19c..4a65060cdb 100644 --- a/src/main/java/carpet/mixins/LivingEntity_maxCollisionsMixin.java +++ b/src/main/java/carpet/mixins/LivingEntity_maxCollisionsMixin.java @@ -1,7 +1,7 @@ package carpet.mixins; import carpet.CarpetSettings; -import carpet.fakes.WorldInterface; +import carpet.fakes.LevelInterface; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -39,7 +39,7 @@ private void tickPushingReplacement(CallbackInfo ci) { if (CarpetSettings.maxEntityCollisions > 0) { maxEntityCramming = this.level.getGameRules().getInt(GameRules.RULE_MAX_ENTITY_CRAMMING); - entities = ((WorldInterface) this.level).getOtherEntitiesLimited( + entities = ((LevelInterface) this.level).getOtherEntitiesLimited( this, this.getBoundingBox(), EntitySelector.pushableBy(this), diff --git a/src/main/java/carpet/mixins/NaturalSpawnerMixin.java b/src/main/java/carpet/mixins/NaturalSpawnerMixin.java index d59c5ab867..4f9eb3dd49 100644 --- a/src/main/java/carpet/mixins/NaturalSpawnerMixin.java +++ b/src/main/java/carpet/mixins/NaturalSpawnerMixin.java @@ -1,7 +1,7 @@ package carpet.mixins; import carpet.CarpetSettings; -import carpet.fakes.WorldInterface; +import carpet.fakes.LevelInterface; import carpet.utils.SpawnReporter; import org.apache.commons.lang3.tuple.Pair; import org.spongepowered.asm.mixin.Final; @@ -139,7 +139,7 @@ private static Entity create(EntityType entityType, Level world_1) { if (CarpetSettings.lagFreeSpawning) { - Map, Entity> precookedMobs = ((WorldInterface)world_1).getPrecookedMobs(); + Map, Entity> precookedMobs = ((LevelInterface)world_1).getPrecookedMobs(); if (precookedMobs.containsKey(entityType)) //this mob has been 's but not used yet return precookedMobs.get(entityType); @@ -159,7 +159,7 @@ private static void spawnEntity(ServerLevel world, Entity entity_1, { if (CarpetSettings.lagFreeSpawning) // we used the mob - next time we will create a new one when needed - ((WorldInterface) world).getPrecookedMobs().remove(entity_1.getType()); + ((LevelInterface) world).getPrecookedMobs().remove(entity_1.getType()); if (SpawnReporter.track_spawns > 0L && SpawnReporter.local_spawns != null) { diff --git a/src/main/java/carpet/mixins/PistonMovingBlockEntity_movableBEMixin.java b/src/main/java/carpet/mixins/PistonMovingBlockEntity_movableBEMixin.java index 76d1116627..9fee32a5cc 100644 --- a/src/main/java/carpet/mixins/PistonMovingBlockEntity_movableBEMixin.java +++ b/src/main/java/carpet/mixins/PistonMovingBlockEntity_movableBEMixin.java @@ -3,7 +3,7 @@ import carpet.CarpetSettings; import carpet.fakes.BlockEntityInterface; import carpet.fakes.PistonBlockEntityInterface; -import carpet.fakes.WorldInterface; +import carpet.fakes.LevelInterface; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.level.Level; @@ -92,7 +92,7 @@ private static boolean movableTEsetBlockState0( if (!CarpetSettings.movableBlockEntities) return world.setBlock(blockPos_1, blockAState_2, int_1); else - return ((WorldInterface) (world)).setBlockStateWithBlockEntity(blockPos_1, blockAState_2, ((PistonBlockEntityInterface)pistonBlockEntity).getCarriedBlockEntity(), int_1); + return ((LevelInterface) (world)).setBlockStateWithBlockEntity(blockPos_1, blockAState_2, ((PistonBlockEntityInterface)pistonBlockEntity).getCarriedBlockEntity(), int_1); } @Redirect(method = "finalTick", at = @At(value = "INVOKE", @@ -103,7 +103,7 @@ private boolean movableTEsetBlockState1(Level world, BlockPos blockPos_1, BlockS return world.setBlock(blockPos_1, blockState_2, int_1); else { - boolean ret = ((WorldInterface) (world)).setBlockStateWithBlockEntity(blockPos_1, blockState_2, this.carriedBlockEntity, int_1); + boolean ret = ((LevelInterface) (world)).setBlockStateWithBlockEntity(blockPos_1, blockState_2, this.carriedBlockEntity, int_1); this.carriedBlockEntity = null; //this will cancel the finishHandleBroken return ret; } @@ -122,7 +122,7 @@ private void finishHandleBroken(CallbackInfo cir) blockState_2 = Blocks.AIR.defaultBlockState(); else blockState_2 = Block.updateFromNeighbourShapes(this.movedState, this.level, this.worldPosition); - ((WorldInterface) (this.level)).setBlockStateWithBlockEntity(this.worldPosition, blockState_2, this.carriedBlockEntity, 3); + ((LevelInterface) (this.level)).setBlockStateWithBlockEntity(this.worldPosition, blockState_2, this.carriedBlockEntity, 3); this.level.destroyBlock(this.worldPosition, false, null); } } From b1140d17fc95f545645b7e96ac9d8cd9f9ffdbb4 Mon Sep 17 00:00:00 2001 From: FX - PR0CESS Date: Thu, 7 Apr 2022 23:46:27 -0400 Subject: [PATCH 5/9] Fix issues with 22w14a & resolve issues --- .../mixins/BarrierBlock_updateSuppressionBlockMixin.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/carpet/mixins/BarrierBlock_updateSuppressionBlockMixin.java b/src/main/java/carpet/mixins/BarrierBlock_updateSuppressionBlockMixin.java index a1b6d8bc04..a4f2cc528d 100644 --- a/src/main/java/carpet/mixins/BarrierBlock_updateSuppressionBlockMixin.java +++ b/src/main/java/carpet/mixins/BarrierBlock_updateSuppressionBlockMixin.java @@ -6,7 +6,6 @@ import net.minecraft.util.RandomSource; import org.spongepowered.asm.mixin.Mixin; -import java.util.Random; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.server.level.ServerLevel; @@ -46,7 +45,7 @@ public void neighborChanged(BlockState state, Level level, BlockPos pos, Block b } @Override - public void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) { + public void tick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { BlockPos posAbove = pos.above(); BlockState stateAbove = level.getBlockState(posAbove); if (stateAbove.is(Blocks.ACTIVATOR_RAIL) && !stateAbove.getValue(PoweredRailBlock.POWERED)) { From a0efa367c75e9df6a4f606d93f349b8b2138f9c3 Mon Sep 17 00:00:00 2001 From: Fx Morin Date: Wed, 20 Apr 2022 10:53:32 -0400 Subject: [PATCH 6/9] Update src/main/java/carpet/mixins/Level_tickMixin.java Add @Unique Co-authored-by: altrisi --- src/main/java/carpet/mixins/Level_tickMixin.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/carpet/mixins/Level_tickMixin.java b/src/main/java/carpet/mixins/Level_tickMixin.java index b644853dd1..3f2e105212 100644 --- a/src/main/java/carpet/mixins/Level_tickMixin.java +++ b/src/main/java/carpet/mixins/Level_tickMixin.java @@ -30,6 +30,7 @@ public abstract class Level_tickMixin implements LevelInterface Map, Entity> precookedMobs = new HashMap<>(); @Override + @Unique public NeighborUpdater getNeighborUpdater() { return this.neighborUpdater; } From 93b927e58c60c2c5a36a9b1adcc73e8d08b2cc15 Mon Sep 17 00:00:00 2001 From: FX - PR0CESS Date: Wed, 20 Apr 2022 11:15:08 -0400 Subject: [PATCH 7/9] Naming, brackets, and description --- src/main/java/carpet/CarpetSettings.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/carpet/CarpetSettings.java b/src/main/java/carpet/CarpetSettings.java index c6f116d322..f547f6fd76 100644 --- a/src/main/java/carpet/CarpetSettings.java +++ b/src/main/java/carpet/CarpetSettings.java @@ -1039,7 +1039,7 @@ public String validate(CommandSourceStack source, ParsedRule currentRule @Rule( desc = "Lightning kills the items that drop when lightning kills an entity", extra = {"Setting to true will prevent lightning from killing drops", "Fixes [MC-206922](https://bugs.mojang.com/browse/MC-206922)."}, - category = {BUGFIX} + category = BUGFIX ) public static boolean lightningKillsDropsFix = false; @@ -1049,22 +1049,26 @@ public String validate(CommandSourceStack source, ParsedRule currentRule category = CREATIVE, options = {"-1","0","10","50"}, strict = false, - validate = updateSuppressionBlockModes.class + validate = UpdateSuppressionBlockModes.class ) public static int updateSuppressionBlock = -1; @Rule( desc = "Fixes update suppression causing server crashes.", - category = {BUGFIX} + category = BUGFIX ) public static boolean updateSuppressionCrashFix = false; - private static class updateSuppressionBlockModes extends Validator { + private static class UpdateSuppressionBlockModes extends Validator { @Override public Integer validate(CommandSourceStack source, ParsedRule currentRule, Integer newValue, String string) { if (newValue < -1) newValue = -1; return newValue; } + @Override + public String description() { + return "This value represents the amount of updates required before the logger logs them"; + } } @Rule( From 4d34dccc185ff19da975d96e4d23d28395825baa Mon Sep 17 00:00:00 2001 From: FX - PR0CESS Date: Wed, 20 Apr 2022 11:16:25 -0400 Subject: [PATCH 8/9] Return null on invalid --- src/main/java/carpet/CarpetSettings.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/carpet/CarpetSettings.java b/src/main/java/carpet/CarpetSettings.java index f547f6fd76..21a88cbcde 100644 --- a/src/main/java/carpet/CarpetSettings.java +++ b/src/main/java/carpet/CarpetSettings.java @@ -1062,12 +1062,11 @@ public String validate(CommandSourceStack source, ParsedRule currentRule private static class UpdateSuppressionBlockModes extends Validator { @Override public Integer validate(CommandSourceStack source, ParsedRule currentRule, Integer newValue, String string) { - if (newValue < -1) newValue = -1; - return newValue; + return newValue < -1 ? null : newValue; } @Override public String description() { - return "This value represents the amount of updates required before the logger logs them"; + return "This value represents the amount of updates required before the logger logs them. Must be -1 or larger"; } } From e69f170a20aeaddef0c52082673036c2ea3bb8a0 Mon Sep 17 00:00:00 2001 From: FX - PR0CESS Date: Wed, 20 Apr 2022 11:22:15 -0400 Subject: [PATCH 9/9] Fix remaining refactoring issues --- src/main/java/carpet/mixins/Level_tickMixin.java | 1 + src/main/resources/carpet.mixins.json | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/carpet/mixins/Level_tickMixin.java b/src/main/java/carpet/mixins/Level_tickMixin.java index 3f2e105212..cde0cdc192 100644 --- a/src/main/java/carpet/mixins/Level_tickMixin.java +++ b/src/main/java/carpet/mixins/Level_tickMixin.java @@ -7,6 +7,7 @@ import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; diff --git a/src/main/resources/carpet.mixins.json b/src/main/resources/carpet.mixins.json index 3501661c3e..a3b84423c1 100644 --- a/src/main/resources/carpet.mixins.json +++ b/src/main/resources/carpet.mixins.json @@ -196,7 +196,6 @@ "ServerPlayer_updateSuppressionCrashFixMixin", "ChunkMap_creativePlayersLoadChunksMixin", "SculkSensorBlock_rangeMixin", - "LevelAccessor", "CollectingNeighborUpdaterAccessor" ], "client": [