diff --git a/src/main/java/carpet/CarpetServer.java b/src/main/java/carpet/CarpetServer.java index 9863898972..4d8e88002a 100644 --- a/src/main/java/carpet/CarpetServer.java +++ b/src/main/java/carpet/CarpetServer.java @@ -15,7 +15,6 @@ import carpet.commands.PerimeterInfoCommand; import carpet.commands.PlayerCommand; import carpet.commands.ProfileCommand; -import carpet.fakes.MinecraftServerInterface; import carpet.helpers.ServerTickRateManager; import carpet.script.ScriptCommand; import carpet.commands.SpawnCommand; @@ -119,7 +118,7 @@ public static void onServerLoadedWorlds(MinecraftServer minecraftServer) public static void tick(MinecraftServer server) { - ServerTickRateManager trm = ((MinecraftServerInterface)server).getTickRateManager(); + ServerTickRateManager trm = server.carpet$getTickRateManager(); trm.tick(); HUDController.update_hud(server, null); if (scriptServer != null) scriptServer.tick(); diff --git a/src/main/java/carpet/commands/PlayerCommand.java b/src/main/java/carpet/commands/PlayerCommand.java index 9cfbd1ec16..9fd85d4dd0 100644 --- a/src/main/java/carpet/commands/PlayerCommand.java +++ b/src/main/java/carpet/commands/PlayerCommand.java @@ -4,7 +4,6 @@ import carpet.helpers.EntityPlayerActionPack.Action; import carpet.helpers.EntityPlayerActionPack.ActionType; import carpet.CarpetSettings; -import carpet.fakes.ServerPlayerInterface; import carpet.patches.EntityPlayerMPFake; import carpet.utils.CommandHelper; import carpet.utils.Messenger; @@ -312,7 +311,7 @@ private static int manipulate(CommandContext context, Consum { if (cantManipulate(context)) return 0; ServerPlayer player = getPlayer(context); - action.accept(((ServerPlayerInterface) player).getActionPack()); + action.accept(player.carpet$getActionPack()); return 1; } diff --git a/src/main/java/carpet/commands/SpawnCommand.java b/src/main/java/carpet/commands/SpawnCommand.java index be13686d87..83c27cb04b 100644 --- a/src/main/java/carpet/commands/SpawnCommand.java +++ b/src/main/java/carpet/commands/SpawnCommand.java @@ -1,8 +1,6 @@ package carpet.commands; import carpet.CarpetSettings; -import carpet.fakes.MinecraftServerInterface; -import carpet.fakes.SpawnGroupInterface; import carpet.helpers.HopperCounter; import carpet.helpers.ServerTickRateManager; import carpet.utils.CommandHelper; @@ -180,7 +178,7 @@ private static int runTest(CommandSourceStack source, int ticks, String counter) // tick warp 0 - ServerTickRateManager trm = ((MinecraftServerInterface)source.getServer()).getTickRateManager(); + ServerTickRateManager trm = source.getServer().carpet$getTickRateManager(); trm.requestGameToWarpSpeed(null, 0, null, null); // tick warp given player CommandSourceStack csource = null; @@ -240,7 +238,7 @@ private static int setSpawnRates(CommandSourceStack source, String mobtype, int private static int setMobcaps(CommandSourceStack source, int hostile_cap) { - double desired_ratio = (double)hostile_cap/ ((SpawnGroupInterface)(Object)MobCategory.MONSTER).getInitialSpawnCap(); + double desired_ratio = (double)hostile_cap/ MobCategory.MONSTER.carpet$getInitialSpawnCap(); SpawnReporter.mobcap_exponent = 4.0*Math.log(desired_ratio)/Math.log(2.0); Messenger.m(source, String.format("gi Mobcaps for hostile mobs changed to %d, other groups will follow", hostile_cap)); return 1; diff --git a/src/main/java/carpet/commands/TickCommand.java b/src/main/java/carpet/commands/TickCommand.java index 5b3bcda459..e779c97eba 100644 --- a/src/main/java/carpet/commands/TickCommand.java +++ b/src/main/java/carpet/commands/TickCommand.java @@ -1,7 +1,6 @@ package carpet.commands; import carpet.CarpetSettings; -import carpet.fakes.MinecraftServerInterface; import carpet.helpers.ServerTickRateManager; import carpet.network.ServerNetworkHandler; import carpet.utils.CarpetProfiler; @@ -73,7 +72,7 @@ public static void register(CommandDispatcher dispatcher, Co private static int setTps(CommandSourceStack source, float tps) { - ServerTickRateManager trm = ((MinecraftServerInterface)source.getServer()).getTickRateManager(); + ServerTickRateManager trm = source.getServer().carpet$getTickRateManager(); trm.setTickRate(tps, true); queryTps(source); return (int)tps; @@ -81,7 +80,7 @@ private static int setTps(CommandSourceStack source, float tps) private static int queryTps(CommandSourceStack source) { - ServerTickRateManager trm = ((MinecraftServerInterface)source.getServer()).getTickRateManager(); + ServerTickRateManager trm = source.getServer().carpet$getTickRateManager(); Messenger.m(source, "w Current tps is: ",String.format("wb %.1f", trm.tickrate())); return (int) trm.tickrate(); @@ -90,7 +89,7 @@ private static int queryTps(CommandSourceStack source) private static int setWarp(CommandSourceStack source, int advance, String tail_command) { ServerPlayer player = source.getPlayer(); // may be null - ServerTickRateManager trm = ((MinecraftServerInterface)source.getServer()).getTickRateManager(); + ServerTickRateManager trm = source.getServer().carpet$getTickRateManager(); Component message = trm.requestGameToWarpSpeed(player, advance, tail_command, source); source.sendSuccess(() -> message, false); return 1; @@ -98,7 +97,7 @@ private static int setWarp(CommandSourceStack source, int advance, String tail_c private static int freezeStatus(CommandSourceStack source) { - ServerTickRateManager trm = ((MinecraftServerInterface)source.getServer()).getTickRateManager(); + ServerTickRateManager trm = source.getServer().carpet$getTickRateManager(); if(trm.gameIsPaused()) { Messenger.m(source, "gi Freeze Status: Game is "+(trm.deeplyFrozen()?"deeply ":"")+"frozen"); @@ -112,7 +111,7 @@ private static int freezeStatus(CommandSourceStack source) private static int setFreeze(CommandSourceStack source, boolean isDeep, boolean freeze) { - ServerTickRateManager trm = ((MinecraftServerInterface)source.getServer()).getTickRateManager(); + ServerTickRateManager trm = source.getServer().carpet$getTickRateManager(); trm.setFrozenState(freeze, isDeep); if (trm.gameIsPaused()) { @@ -127,13 +126,13 @@ private static int setFreeze(CommandSourceStack source, boolean isDeep, boolean private static int toggleFreeze(CommandSourceStack source, boolean isDeep) { - ServerTickRateManager trm = ((MinecraftServerInterface)source.getServer()).getTickRateManager(); + ServerTickRateManager trm = source.getServer().carpet$getTickRateManager(); return setFreeze(source, isDeep, !trm.gameIsPaused()); } private static int step(CommandSourceStack source, int advance) { - ServerTickRateManager trm = ((MinecraftServerInterface)source.getServer()).getTickRateManager(); + ServerTickRateManager trm = source.getServer().carpet$getTickRateManager(); trm.stepGameIfPaused(advance); Messenger.m(source, "gi Stepping " + advance + " tick" + (advance != 1 ? "s" : "")); return 1; @@ -141,7 +140,7 @@ private static int step(CommandSourceStack source, int advance) private static int toggleSuperHot(CommandSourceStack source) { - ServerTickRateManager trm = ((MinecraftServerInterface)source.getServer()).getTickRateManager(); + ServerTickRateManager trm = source.getServer().carpet$getTickRateManager(); trm.setSuperHot(!trm.isSuperHot()); ServerNetworkHandler.updateSuperHotStateToConnectedPlayers(source.getServer()); if (trm.isSuperHot()) diff --git a/src/main/java/carpet/fakes/AbstractContainerMenuInterface.java b/src/main/java/carpet/fakes/AbstractContainerMenuInterface.java index 501784d4be..11cd4cdda3 100644 --- a/src/main/java/carpet/fakes/AbstractContainerMenuInterface.java +++ b/src/main/java/carpet/fakes/AbstractContainerMenuInterface.java @@ -7,7 +7,9 @@ public interface AbstractContainerMenuInterface { - DataSlot getDataSlot(int index); - boolean callButtonClickListener(int button, Player player); - boolean callSelectRecipeListener(ServerPlayer player, Recipe recipe, boolean craftAll); + default DataSlot carpet$getDataSlot(int index) { throw new UnsupportedOperationException(); } + + default boolean carpet$notifyButtonClickListeners(int button, Player player) { throw new UnsupportedOperationException(); } + + default boolean carpet$notifySelectRecipeListeners(ServerPlayer player, Recipe recipe, boolean craftAll) { throw new UnsupportedOperationException(); } } diff --git a/src/main/java/carpet/fakes/AbstractHorseInterface.java b/src/main/java/carpet/fakes/AbstractHorseInterface.java new file mode 100644 index 0000000000..91f46aea4f --- /dev/null +++ b/src/main/java/carpet/fakes/AbstractHorseInterface.java @@ -0,0 +1,8 @@ +package carpet.fakes; + +import net.minecraft.world.Container; + +public interface AbstractHorseInterface +{ + default Container carpet$getInventory() { throw new UnsupportedOperationException(); } +} diff --git a/src/main/java/carpet/fakes/BiomeInterface.java b/src/main/java/carpet/fakes/BiomeInterface.java index 3279150a93..8321acfd82 100644 --- a/src/main/java/carpet/fakes/BiomeInterface.java +++ b/src/main/java/carpet/fakes/BiomeInterface.java @@ -2,6 +2,7 @@ import net.minecraft.world.level.biome.Biome; -public interface BiomeInterface { - Biome.ClimateSettings getClimateSettings(); +public interface BiomeInterface +{ + default Biome.ClimateSettings carpet$getClimateSettings() { throw new UnsupportedOperationException(); } } diff --git a/src/main/java/carpet/fakes/BlockEntityInterface.java b/src/main/java/carpet/fakes/BlockEntityInterface.java index 7847ce60b4..c6343e693e 100644 --- a/src/main/java/carpet/fakes/BlockEntityInterface.java +++ b/src/main/java/carpet/fakes/BlockEntityInterface.java @@ -4,5 +4,5 @@ public interface BlockEntityInterface { - void setCMPos(BlockPos pos); + default void carpet$setPos(BlockPos pos) { throw new UnsupportedOperationException(); } } diff --git a/src/main/java/carpet/fakes/BlockInputInterface.java b/src/main/java/carpet/fakes/BlockInputInterface.java new file mode 100644 index 0000000000..bb17553dfb --- /dev/null +++ b/src/main/java/carpet/fakes/BlockInputInterface.java @@ -0,0 +1,8 @@ +package carpet.fakes; + +import net.minecraft.nbt.CompoundTag; + +public interface BlockInputInterface +{ + default CompoundTag carpet$getTag() { throw new UnsupportedOperationException(); } +} diff --git a/src/main/java/carpet/fakes/BlockPistonBehaviourInterface.java b/src/main/java/carpet/fakes/BlockPistonBehaviourInterface.java index b88bf63042..fa1c44273c 100644 --- a/src/main/java/carpet/fakes/BlockPistonBehaviourInterface.java +++ b/src/main/java/carpet/fakes/BlockPistonBehaviourInterface.java @@ -15,10 +15,10 @@ public interface BlockPistonBehaviourInterface { /** * @return whether this block is sticky in any way when moved by pistons */ - boolean isSticky(BlockState state); + boolean carpet$isSticky(BlockState state); /** * @return whether the neighboring block is pulled along if this block is moved by pistons */ - boolean isStickyToNeighbor(Level level, BlockPos pos, BlockState state, BlockPos neighborPos, BlockState neighborState, Direction dir, Direction moveDir); + boolean carpet$isStickyToNeighbor(Level level, BlockPos pos, BlockState state, BlockPos neighborPos, BlockState neighborState, Direction dir, Direction moveDir); } diff --git a/src/main/java/carpet/fakes/BlockPredicateInterface.java b/src/main/java/carpet/fakes/BlockPredicateInterface.java index 833b20799d..a32420fe91 100644 --- a/src/main/java/carpet/fakes/BlockPredicateInterface.java +++ b/src/main/java/carpet/fakes/BlockPredicateInterface.java @@ -9,8 +9,11 @@ public interface BlockPredicateInterface { - BlockState getCMBlockState(); - TagKey getCMBlockTagKey(); - Map getCMProperties(); - CompoundTag getCMDataTag(); + default BlockState carpet$getBlockState() { throw new UnsupportedOperationException(); } + + default TagKey carpet$getTagKey() { throw new UnsupportedOperationException(); } + + default Map carpet$getProperties() { throw new UnsupportedOperationException(); } + + default CompoundTag carpet$getDataTag() { throw new UnsupportedOperationException(); } } diff --git a/src/main/java/carpet/fakes/BlockStateArgumentInterface.java b/src/main/java/carpet/fakes/BlockStateArgumentInterface.java deleted file mode 100644 index 20610ed3a3..0000000000 --- a/src/main/java/carpet/fakes/BlockStateArgumentInterface.java +++ /dev/null @@ -1,8 +0,0 @@ -package carpet.fakes; - -import net.minecraft.nbt.CompoundTag; - -public interface BlockStateArgumentInterface -{ - CompoundTag getCMTag(); -} diff --git a/src/main/java/carpet/fakes/ChunkHolderInterface.java b/src/main/java/carpet/fakes/ChunkHolderInterface.java index e9cd29cf81..600a0ed815 100644 --- a/src/main/java/carpet/fakes/ChunkHolderInterface.java +++ b/src/main/java/carpet/fakes/ChunkHolderInterface.java @@ -10,5 +10,5 @@ public interface ChunkHolderInterface { - CompletableFuture> setDefaultProtoChunk(ChunkPos chpos, BlockableEventLoop executor, ServerLevel world); + default CompletableFuture> carpet$setDefaultProtoChunk(ChunkPos pos, BlockableEventLoop executor, ServerLevel level) { throw new UnsupportedOperationException(); } } diff --git a/src/main/java/carpet/fakes/ChunkMapInterface.java b/src/main/java/carpet/fakes/ChunkMapInterface.java new file mode 100644 index 0000000000..f5ff789d49 --- /dev/null +++ b/src/main/java/carpet/fakes/ChunkMapInterface.java @@ -0,0 +1,17 @@ +package carpet.fakes; + +import java.util.List; +import java.util.Map; +import net.minecraft.server.level.ChunkHolder; +import net.minecraft.world.level.ChunkPos; + +public interface ChunkMapInterface +{ + default Map carpet$regenerateChunkRegion(List requestedChunks) { throw new UnsupportedOperationException(); } + + default void carpet$relightChunk(ChunkPos pos) { throw new UnsupportedOperationException(); } + + default void carpet$releaseRelightTicket(ChunkPos pos) { throw new UnsupportedOperationException(); } + + default Iterable carpet$getChunks() { throw new UnsupportedOperationException(); } +} diff --git a/src/main/java/carpet/fakes/ChunkTicketManagerInterface.java b/src/main/java/carpet/fakes/ChunkTicketManagerInterface.java deleted file mode 100644 index 2a01ed8c6a..0000000000 --- a/src/main/java/carpet/fakes/ChunkTicketManagerInterface.java +++ /dev/null @@ -1,16 +0,0 @@ -package carpet.fakes; - -import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; -import net.minecraft.server.level.ChunkHolder; -import net.minecraft.server.level.Ticket; -import net.minecraft.util.SortedArraySet; -import net.minecraft.world.level.ChunkPos; - -public interface ChunkTicketManagerInterface -{ - void changeSpawnChunks(ChunkPos pos, int distance); - - Long2ObjectOpenHashMap>> getTicketsByPosition(); - - void replaceHolder(ChunkHolder oldHolder, ChunkHolder newHolder); -} diff --git a/src/main/java/carpet/fakes/ClientConnectionInterface.java b/src/main/java/carpet/fakes/ClientConnectionInterface.java deleted file mode 100644 index 127f3ac314..0000000000 --- a/src/main/java/carpet/fakes/ClientConnectionInterface.java +++ /dev/null @@ -1,7 +0,0 @@ -package carpet.fakes; - -import io.netty.channel.Channel; - -public interface ClientConnectionInterface { - void setChannel(Channel channel); -} diff --git a/src/main/java/carpet/fakes/CommandDispatcherInterface.java b/src/main/java/carpet/fakes/CommandDispatcherInterface.java index 473b638a8d..2a8210e660 100644 --- a/src/main/java/carpet/fakes/CommandDispatcherInterface.java +++ b/src/main/java/carpet/fakes/CommandDispatcherInterface.java @@ -1,5 +1,6 @@ package carpet.fakes; -public interface CommandDispatcherInterface { +public interface CommandDispatcherInterface +{ void carpet$unregister(String node); } diff --git a/src/main/java/carpet/fakes/CommandNodeInterface.java b/src/main/java/carpet/fakes/CommandNodeInterface.java index 9401dfb4b8..e2610bd2ae 100644 --- a/src/main/java/carpet/fakes/CommandNodeInterface.java +++ b/src/main/java/carpet/fakes/CommandNodeInterface.java @@ -1,5 +1,6 @@ package carpet.fakes; -public interface CommandNodeInterface { +public interface CommandNodeInterface +{ void carpet$removeChild(String name); } diff --git a/src/main/java/carpet/fakes/ConnectionInterface.java b/src/main/java/carpet/fakes/ConnectionInterface.java new file mode 100644 index 0000000000..e9b3d72aae --- /dev/null +++ b/src/main/java/carpet/fakes/ConnectionInterface.java @@ -0,0 +1,8 @@ +package carpet.fakes; + +import io.netty.channel.Channel; + +public interface ConnectionInterface +{ + default void setChannel(Channel channel) { throw new UnsupportedOperationException(); } // compat with adventure-platform-fabric +} diff --git a/src/main/java/carpet/fakes/CoralFeatureInterface.java b/src/main/java/carpet/fakes/CoralFeatureInterface.java index 915d09b322..8464c6fea5 100644 --- a/src/main/java/carpet/fakes/CoralFeatureInterface.java +++ b/src/main/java/carpet/fakes/CoralFeatureInterface.java @@ -1,6 +1,5 @@ package carpet.fakes; -import java.util.Random; import net.minecraft.core.BlockPos; import net.minecraft.util.RandomSource; import net.minecraft.world.level.Level; @@ -8,5 +7,5 @@ public interface CoralFeatureInterface { - boolean growSpecific(Level worldIn, RandomSource random, BlockPos pos, BlockState blockUnder); + default boolean carpet$growSpecific(Level level, RandomSource random, BlockPos pos, BlockState blockUnder) { throw new UnsupportedOperationException(); } } diff --git a/src/main/java/carpet/fakes/DistanceManagerInterface.java b/src/main/java/carpet/fakes/DistanceManagerInterface.java new file mode 100644 index 0000000000..0663ab1567 --- /dev/null +++ b/src/main/java/carpet/fakes/DistanceManagerInterface.java @@ -0,0 +1,16 @@ +package carpet.fakes; + +import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; +import net.minecraft.server.level.ChunkHolder; +import net.minecraft.server.level.Ticket; +import net.minecraft.util.SortedArraySet; +import net.minecraft.world.level.ChunkPos; + +public interface DistanceManagerInterface +{ + default void carpet$changeSpawnChunks(ChunkPos pos, int distance) { throw new UnsupportedOperationException(); } + + default Long2ObjectOpenHashMap>> carpet$getTicketsByPosition() { throw new UnsupportedOperationException(); } + + default void carpet$replaceHolder(ChunkHolder oldHolder, ChunkHolder newHolder) { throw new UnsupportedOperationException(); } +} diff --git a/src/main/java/carpet/fakes/EntityInterface.java b/src/main/java/carpet/fakes/EntityInterface.java index 80093eda1e..abf92c2a02 100644 --- a/src/main/java/carpet/fakes/EntityInterface.java +++ b/src/main/java/carpet/fakes/EntityInterface.java @@ -4,19 +4,19 @@ public interface EntityInterface { - float getMainYaw(float partialTicks); + default float carpet$getMainYaw(float partialTicks) { throw new UnsupportedOperationException(); } - EntityEventsGroup getEventContainer(); + default EntityEventsGroup carpet$getEventContainer() { throw new UnsupportedOperationException(); } - boolean isPermanentVehicle(); + default boolean carpet$isPermanentVehicle() { throw new UnsupportedOperationException(); } - void setPermanentVehicle(boolean permanent); + default void carpet$setPermanentVehicle(boolean permanent) { throw new UnsupportedOperationException(); } - int getPortalTimer(); + default int carpet$getPortalTimer() { throw new UnsupportedOperationException(); } - void setPortalTimer(int amount); + default void carpet$setPortalTimer(int amount) { throw new UnsupportedOperationException(); } - int getPublicNetherPortalCooldown(); - void setPublicNetherPortalCooldown(int what); + default int carpet$getPublicNetherPortalCooldown() { throw new UnsupportedOperationException(); } + default void carpet$setPublicNetherPortalCooldown(int what) { throw new UnsupportedOperationException(); } } diff --git a/src/main/java/carpet/fakes/IngredientInterface.java b/src/main/java/carpet/fakes/IngredientInterface.java index f6d938547f..293c9271da 100644 --- a/src/main/java/carpet/fakes/IngredientInterface.java +++ b/src/main/java/carpet/fakes/IngredientInterface.java @@ -10,5 +10,5 @@ public interface IngredientInterface * Gets all the stacks of the ingredients for a given item recipe. Also used for {@link carpet.helpers.HopperCounter#guessColor} * to guess the colour of an item to display it prettily */ - List> getRecipeStacks(); + default List> carpet$getRecipeStacks() { throw new UnsupportedOperationException(); } } diff --git a/src/main/java/carpet/fakes/InventoryBearerInterface.java b/src/main/java/carpet/fakes/InventoryBearerInterface.java deleted file mode 100644 index d40a02ea08..0000000000 --- a/src/main/java/carpet/fakes/InventoryBearerInterface.java +++ /dev/null @@ -1,8 +0,0 @@ -package carpet.fakes; - -import net.minecraft.world.Container; - -public interface InventoryBearerInterface -{ - Container getCMInventory(); // can be removed in 1.17 due to class_6067 -} diff --git a/src/main/java/carpet/fakes/ItemEntityInterface.java b/src/main/java/carpet/fakes/ItemEntityInterface.java index 4534bbfe89..646a112cb7 100644 --- a/src/main/java/carpet/fakes/ItemEntityInterface.java +++ b/src/main/java/carpet/fakes/ItemEntityInterface.java @@ -2,5 +2,5 @@ public interface ItemEntityInterface { - int getPickupDelayCM(); + default int carpet$getPickupDelay() { throw new UnsupportedOperationException(); } } diff --git a/src/main/java/carpet/fakes/LevelChunkInterface.java b/src/main/java/carpet/fakes/LevelChunkInterface.java new file mode 100644 index 0000000000..98f4579c51 --- /dev/null +++ b/src/main/java/carpet/fakes/LevelChunkInterface.java @@ -0,0 +1,10 @@ +package carpet.fakes; + +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.state.BlockState; + +public interface LevelChunkInterface +{ + default BlockState carpet$setBlockStateWithBlockEntity(BlockPos pos, BlockState state, BlockEntity blockEntity, boolean movedByPiston) { throw new UnsupportedOperationException(); } +} diff --git a/src/main/java/carpet/fakes/LevelEntityGetterAdapterInterface.java b/src/main/java/carpet/fakes/LevelEntityGetterAdapterInterface.java new file mode 100644 index 0000000000..0c22a69780 --- /dev/null +++ b/src/main/java/carpet/fakes/LevelEntityGetterAdapterInterface.java @@ -0,0 +1,10 @@ +package carpet.fakes; + +import java.util.List; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.entity.EntityAccess; + +public interface LevelEntityGetterAdapterInterface +{ + default List carpet$getChunkEntities(ChunkPos pos) { throw new UnsupportedOperationException(); } +} diff --git a/src/main/java/carpet/fakes/LevelInterface.java b/src/main/java/carpet/fakes/LevelInterface.java index 05da80b4f4..4ac76ac184 100644 --- a/src/main/java/carpet/fakes/LevelInterface.java +++ b/src/main/java/carpet/fakes/LevelInterface.java @@ -16,13 +16,13 @@ public interface LevelInterface { - Map, Entity> getPrecookedMobs(); - - boolean setBlockStateWithBlockEntity(BlockPos blockPos, BlockState blockState, BlockEntity newBlockEntity, int int1); + default Map, Entity> carpet$getPrecookedMobs() { throw new UnsupportedOperationException(); } - List getOtherEntitiesLimited(@Nullable Entity except, AABB box, Predicate predicate, int limit); + default boolean carpet$setBlockStateWithBlockEntity(BlockPos pos, BlockState state, BlockEntity blockEntity, int flags) { throw new UnsupportedOperationException(); } - NeighborUpdater getNeighborUpdater(); + default List carpet$getOtherEntitiesLimited(@Nullable Entity except, AABB box, Predicate predicate, int limit) { throw new UnsupportedOperationException(); } - TickRateManager tickRateManager(); + default NeighborUpdater carpet$getNeighborUpdater() { throw new UnsupportedOperationException(); } + + default TickRateManager carpet$getTickRateManager() { throw new UnsupportedOperationException(); } } diff --git a/src/main/java/carpet/fakes/Lighting_scarpetChunkCreationInterface.java b/src/main/java/carpet/fakes/Lighting_scarpetChunkCreationInterface.java index 7cfdb5fde5..971af6a80f 100644 --- a/src/main/java/carpet/fakes/Lighting_scarpetChunkCreationInterface.java +++ b/src/main/java/carpet/fakes/Lighting_scarpetChunkCreationInterface.java @@ -2,5 +2,5 @@ public interface Lighting_scarpetChunkCreationInterface { - void removeLightData(long pos); + default void carpet$removeLightData(long pos) { throw new UnsupportedOperationException(); } } diff --git a/src/main/java/carpet/fakes/LivingEntityInterface.java b/src/main/java/carpet/fakes/LivingEntityInterface.java index 2dba302ec5..1d29337573 100644 --- a/src/main/java/carpet/fakes/LivingEntityInterface.java +++ b/src/main/java/carpet/fakes/LivingEntityInterface.java @@ -2,6 +2,7 @@ public interface LivingEntityInterface { - void doJumpCM(); // added CM suffix to remove potential collisions with other mods - boolean isJumpingCM(); + default void carpet$doJump() { throw new UnsupportedOperationException(); } + + default boolean carpet$isJumping() { throw new UnsupportedOperationException(); } } diff --git a/src/main/java/carpet/fakes/MinecraftClientInferface.java b/src/main/java/carpet/fakes/MinecraftClientInferface.java deleted file mode 100644 index 6e200c7f02..0000000000 --- a/src/main/java/carpet/fakes/MinecraftClientInferface.java +++ /dev/null @@ -1,6 +0,0 @@ -package carpet.fakes; - -public interface MinecraftClientInferface -{ - float getPausedTickDelta(); -} diff --git a/src/main/java/carpet/fakes/MinecraftInterface.java b/src/main/java/carpet/fakes/MinecraftInterface.java index 63553267b3..34bba9a030 100644 --- a/src/main/java/carpet/fakes/MinecraftInterface.java +++ b/src/main/java/carpet/fakes/MinecraftInterface.java @@ -6,5 +6,7 @@ public interface MinecraftInterface { - Optional getTickRateManager(); + default Optional carpet$getTickRateManager() { throw new UnsupportedOperationException(); } + + default float carpet$getPausePartialTick() { throw new UnsupportedOperationException(); } } diff --git a/src/main/java/carpet/fakes/MinecraftServerInterface.java b/src/main/java/carpet/fakes/MinecraftServerInterface.java index cf3fd479b7..923cfb5b02 100644 --- a/src/main/java/carpet/fakes/MinecraftServerInterface.java +++ b/src/main/java/carpet/fakes/MinecraftServerInterface.java @@ -15,15 +15,19 @@ public interface MinecraftServerInterface { - void forceTick(BooleanSupplier sup); - LevelStorageSource.LevelStorageAccess getCMSession(); - Map, ServerLevel> getCMWorlds(); - void reloadAfterReload(RegistryAccess newRegs); + default void carpet$forceTick(BooleanSupplier isAhead) { throw new UnsupportedOperationException(); } - MinecraftServer.ReloadableResources getResourceManager(); + default LevelStorageSource.LevelStorageAccess carpet$getStorageSource() { throw new UnsupportedOperationException(); } - void addScriptServer(CarpetScriptServer scriptServer); - CarpetScriptServer getScriptServer(); + default Map, ServerLevel> carpet$getLevels() { throw new UnsupportedOperationException(); } - ServerTickRateManager getTickRateManager(); + default void carpet$reloadAfterReload(RegistryAccess newRegs) { throw new UnsupportedOperationException(); } + + default MinecraftServer.ReloadableResources carpet$getResources() { throw new UnsupportedOperationException(); } + + default void carpet$addScriptServer(CarpetScriptServer scriptServer) { throw new UnsupportedOperationException(); } + + default CarpetScriptServer carpet$getScriptServer() { throw new UnsupportedOperationException(); } + + default ServerTickRateManager carpet$getTickRateManager() { throw new UnsupportedOperationException(); } } diff --git a/src/main/java/carpet/fakes/MobCategoryInterface.java b/src/main/java/carpet/fakes/MobCategoryInterface.java new file mode 100644 index 0000000000..9dbcfd5f80 --- /dev/null +++ b/src/main/java/carpet/fakes/MobCategoryInterface.java @@ -0,0 +1,6 @@ +package carpet.fakes; + +public interface MobCategoryInterface +{ + default int carpet$getInitialSpawnCap() { throw new UnsupportedOperationException(); } +} diff --git a/src/main/java/carpet/fakes/MobEntityInterface.java b/src/main/java/carpet/fakes/MobEntityInterface.java deleted file mode 100644 index df0dd02136..0000000000 --- a/src/main/java/carpet/fakes/MobEntityInterface.java +++ /dev/null @@ -1,14 +0,0 @@ -package carpet.fakes; - -import java.util.Map; -import net.minecraft.world.entity.ai.goal.Goal; -import net.minecraft.world.entity.ai.goal.GoalSelector; - -public interface MobEntityInterface -{ - GoalSelector getAI(boolean target); - - Map getTemporaryTasks(); - - void setPersistence(boolean what); -} diff --git a/src/main/java/carpet/fakes/MobInterface.java b/src/main/java/carpet/fakes/MobInterface.java new file mode 100644 index 0000000000..5977f149b2 --- /dev/null +++ b/src/main/java/carpet/fakes/MobInterface.java @@ -0,0 +1,14 @@ +package carpet.fakes; + +import java.util.Map; +import net.minecraft.world.entity.ai.goal.Goal; +import net.minecraft.world.entity.ai.goal.GoalSelector; + +public interface MobInterface +{ + default GoalSelector carpet$getAi(boolean target) { throw new UnsupportedOperationException(); } + + default Map carpet$getTemporaryTasks() { throw new UnsupportedOperationException(); } + + default void carpet$setPersistence(boolean what) { throw new UnsupportedOperationException(); } +} diff --git a/src/main/java/carpet/fakes/PistonBaseBlockInterface.java b/src/main/java/carpet/fakes/PistonBaseBlockInterface.java new file mode 100644 index 0000000000..2b24f33e74 --- /dev/null +++ b/src/main/java/carpet/fakes/PistonBaseBlockInterface.java @@ -0,0 +1,10 @@ +package carpet.fakes; + +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.level.Level; + +public interface PistonBaseBlockInterface +{ + default boolean carpet$getNeighborSignal(Level level, BlockPos pos, Direction facing) { throw new UnsupportedOperationException(); } +} diff --git a/src/main/java/carpet/fakes/PistonBlockEntityInterface.java b/src/main/java/carpet/fakes/PistonBlockEntityInterface.java deleted file mode 100644 index 247fbaab13..0000000000 --- a/src/main/java/carpet/fakes/PistonBlockEntityInterface.java +++ /dev/null @@ -1,12 +0,0 @@ -package carpet.fakes; - -import net.minecraft.world.level.block.entity.BlockEntity; - -public interface PistonBlockEntityInterface -{ - void setCarriedBlockEntity(BlockEntity blockEntity); - BlockEntity getCarriedBlockEntity(); - void setRenderCarriedBlockEntity(boolean b); - boolean getRenderCarriedBlockEntity(); - boolean isRenderModeSet(); -} diff --git a/src/main/java/carpet/fakes/PistonBlockInterface.java b/src/main/java/carpet/fakes/PistonBlockInterface.java deleted file mode 100644 index dcda1741af..0000000000 --- a/src/main/java/carpet/fakes/PistonBlockInterface.java +++ /dev/null @@ -1,10 +0,0 @@ -package carpet.fakes; - -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.world.level.Level; - -public interface PistonBlockInterface -{ - boolean publicShouldExtend(Level world_1, BlockPos blockPos_1, Direction direction_1); -} diff --git a/src/main/java/carpet/fakes/PistonMovingBlockEntityInterface.java b/src/main/java/carpet/fakes/PistonMovingBlockEntityInterface.java new file mode 100644 index 0000000000..c1414f0a23 --- /dev/null +++ b/src/main/java/carpet/fakes/PistonMovingBlockEntityInterface.java @@ -0,0 +1,16 @@ +package carpet.fakes; + +import net.minecraft.world.level.block.entity.BlockEntity; + +public interface PistonMovingBlockEntityInterface +{ + default void carpet$setCarriedBlockEntity(BlockEntity blockEntity) { throw new UnsupportedOperationException(); } + + default BlockEntity carpet$getCarriedBlockEntity() { throw new UnsupportedOperationException(); } + + default void carpet$setRenderCarriedBlockEntity(boolean b) { throw new UnsupportedOperationException(); } + + default boolean carpet$getRenderCarriedBlockEntity() { throw new UnsupportedOperationException(); } + + default boolean carpet$isRenderModeSet() { throw new UnsupportedOperationException(); } +} diff --git a/src/main/java/carpet/fakes/PlayerListHudInterface.java b/src/main/java/carpet/fakes/PlayerListHudInterface.java deleted file mode 100644 index 058ae90dd6..0000000000 --- a/src/main/java/carpet/fakes/PlayerListHudInterface.java +++ /dev/null @@ -1,6 +0,0 @@ -package carpet.fakes; - -public interface PlayerListHudInterface -{ - boolean hasFooterOrHeader(); -} diff --git a/src/main/java/carpet/fakes/PlayerTabOverlayInterface.java b/src/main/java/carpet/fakes/PlayerTabOverlayInterface.java new file mode 100644 index 0000000000..1020abfb09 --- /dev/null +++ b/src/main/java/carpet/fakes/PlayerTabOverlayInterface.java @@ -0,0 +1,6 @@ +package carpet.fakes; + +public interface PlayerTabOverlayInterface +{ + default boolean carpet$hasFooterOrHeader() { throw new UnsupportedOperationException(); } +} diff --git a/src/main/java/carpet/fakes/PrimedTntInterface.java b/src/main/java/carpet/fakes/PrimedTntInterface.java new file mode 100644 index 0000000000..845d3658bc --- /dev/null +++ b/src/main/java/carpet/fakes/PrimedTntInterface.java @@ -0,0 +1,6 @@ +package carpet.fakes; + +public interface PrimedTntInterface +{ + default int carpet$getMergedTnt() { throw new UnsupportedOperationException(); } +} diff --git a/src/main/java/carpet/fakes/RandomStateInterface.java b/src/main/java/carpet/fakes/RandomStateInterface.java new file mode 100644 index 0000000000..39055e8882 --- /dev/null +++ b/src/main/java/carpet/fakes/RandomStateInterface.java @@ -0,0 +1,8 @@ +package carpet.fakes; + +import net.minecraft.world.level.levelgen.DensityFunction; + +public interface RandomStateInterface +{ + default DensityFunction.Visitor carpet$getVisitor() { throw new UnsupportedOperationException(); } +} diff --git a/src/main/java/carpet/fakes/RandomStateVisitorAccessor.java b/src/main/java/carpet/fakes/RandomStateVisitorAccessor.java deleted file mode 100644 index d423bb5289..0000000000 --- a/src/main/java/carpet/fakes/RandomStateVisitorAccessor.java +++ /dev/null @@ -1,7 +0,0 @@ -package carpet.fakes; - -import net.minecraft.world.level.levelgen.DensityFunction; - -public interface RandomStateVisitorAccessor { - DensityFunction.Visitor getVisitor(); -} diff --git a/src/main/java/carpet/fakes/RecipeManagerInterface.java b/src/main/java/carpet/fakes/RecipeManagerInterface.java index ff130d003e..db81f7674f 100644 --- a/src/main/java/carpet/fakes/RecipeManagerInterface.java +++ b/src/main/java/carpet/fakes/RecipeManagerInterface.java @@ -13,5 +13,5 @@ public interface RecipeManagerInterface * Gets all the recipes for a given item. Also used for {@link carpet.helpers.HopperCounter#guessColor} to guess the * colour of an item to display it prettily */ - List> getAllMatching(final RecipeType type, final ResourceLocation output, final RegistryAccess registryAccess); + default List> carpet$getAllMatching(final RecipeType type, final ResourceLocation output, final RegistryAccess registryAccess) { throw new UnsupportedOperationException(); } } diff --git a/src/main/java/carpet/fakes/RedStoneWireBlockInterface.java b/src/main/java/carpet/fakes/RedStoneWireBlockInterface.java new file mode 100644 index 0000000000..d6638d12c2 --- /dev/null +++ b/src/main/java/carpet/fakes/RedStoneWireBlockInterface.java @@ -0,0 +1,14 @@ +package carpet.fakes; + +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.BlockState; + +public interface RedStoneWireBlockInterface +{ + default BlockState carpet$updateLogicPublic(Level level, BlockPos pos, BlockState state) { throw new UnsupportedOperationException(); } + + default void carpet$setShouldSignal(boolean shouldSignal) { throw new UnsupportedOperationException(); } + + default boolean carpet$getShouldSignal() { throw new UnsupportedOperationException(); } +} diff --git a/src/main/java/carpet/fakes/RedstoneWireBlockInterface.java b/src/main/java/carpet/fakes/RedstoneWireBlockInterface.java deleted file mode 100644 index 8d6b771696..0000000000 --- a/src/main/java/carpet/fakes/RedstoneWireBlockInterface.java +++ /dev/null @@ -1,11 +0,0 @@ -package carpet.fakes; - -import net.minecraft.core.BlockPos; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.state.BlockState; - -public interface RedstoneWireBlockInterface { - BlockState updateLogicPublic(Level world_1, BlockPos blockPos_1, BlockState blockState_1); - void setWiresGivePower(boolean wiresGivePower); - boolean getWiresGivePower(); -} diff --git a/src/main/java/carpet/fakes/ServerGamePacketListenerImplInterface.java b/src/main/java/carpet/fakes/ServerGamePacketListenerImplInterface.java index fbd0f834e6..ab0248bf89 100644 --- a/src/main/java/carpet/fakes/ServerGamePacketListenerImplInterface.java +++ b/src/main/java/carpet/fakes/ServerGamePacketListenerImplInterface.java @@ -2,6 +2,7 @@ import net.minecraft.network.Connection; -public interface ServerGamePacketListenerImplInterface { - Connection getConnection(); +public interface ServerGamePacketListenerImplInterface +{ + default Connection carpet$getConnection() { throw new UnsupportedOperationException(); } } diff --git a/src/main/java/carpet/fakes/ServerLevelInterface.java b/src/main/java/carpet/fakes/ServerLevelInterface.java new file mode 100644 index 0000000000..facc288895 --- /dev/null +++ b/src/main/java/carpet/fakes/ServerLevelInterface.java @@ -0,0 +1,12 @@ +package carpet.fakes; + +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.entity.LevelEntityGetter; +import net.minecraft.world.level.storage.ServerLevelData; + +public interface ServerLevelInterface +{ + default ServerLevelData carpet$getLevelData() { throw new UnsupportedOperationException(); } + + default LevelEntityGetter carpet$getEntityGetter() { throw new UnsupportedOperationException(); } +} diff --git a/src/main/java/carpet/fakes/ServerLightingProviderInterface.java b/src/main/java/carpet/fakes/ServerLightingProviderInterface.java index 780c21b9ea..2634207f9f 100644 --- a/src/main/java/carpet/fakes/ServerLightingProviderInterface.java +++ b/src/main/java/carpet/fakes/ServerLightingProviderInterface.java @@ -6,11 +6,11 @@ public interface ServerLightingProviderInterface { - void invokeUpdateChunkStatus(ChunkPos pos); + default void carpet$updateChunkStatus(ChunkPos pos) { throw new UnsupportedOperationException(); } - void removeLightData(ChunkAccess chunk); + default void carpet$removeLightData(ChunkAccess chunk) { throw new UnsupportedOperationException(); } - CompletableFuture relight(ChunkAccess chunk); + default CompletableFuture carpet$relight(ChunkAccess chunk) { throw new UnsupportedOperationException(); } - void resetLight(ChunkAccess chunk, ChunkPos pos); + default void carpet$resetLight(ChunkAccess chunk, ChunkPos pos) { throw new UnsupportedOperationException(); } } diff --git a/src/main/java/carpet/fakes/ServerPlayerGameModeInterface.java b/src/main/java/carpet/fakes/ServerPlayerGameModeInterface.java new file mode 100644 index 0000000000..f67701aa18 --- /dev/null +++ b/src/main/java/carpet/fakes/ServerPlayerGameModeInterface.java @@ -0,0 +1,12 @@ +package carpet.fakes; + +import net.minecraft.core.BlockPos; + +public interface ServerPlayerGameModeInterface +{ + default BlockPos carpet$getCurrentBreakingBlock() { throw new UnsupportedOperationException(); } + + default int carpet$getCurrentBlockBreakingProgress() { throw new UnsupportedOperationException(); } + + default void carpet$setBlockBreakingProgress(int progress) { throw new UnsupportedOperationException(); } +} diff --git a/src/main/java/carpet/fakes/ServerPlayerInteractionManagerInterface.java b/src/main/java/carpet/fakes/ServerPlayerInteractionManagerInterface.java deleted file mode 100644 index 6fcf2a0e57..0000000000 --- a/src/main/java/carpet/fakes/ServerPlayerInteractionManagerInterface.java +++ /dev/null @@ -1,12 +0,0 @@ -package carpet.fakes; - -import net.minecraft.core.BlockPos; - -public interface ServerPlayerInteractionManagerInterface -{ - BlockPos getCurrentBreakingBlock(); - - int getCurrentBlockBreakingProgress(); - - void setBlockBreakingProgress(int progress); -} diff --git a/src/main/java/carpet/fakes/ServerPlayerInterface.java b/src/main/java/carpet/fakes/ServerPlayerInterface.java index 06fea590e6..f1bc95e8b7 100644 --- a/src/main/java/carpet/fakes/ServerPlayerInterface.java +++ b/src/main/java/carpet/fakes/ServerPlayerInterface.java @@ -4,8 +4,11 @@ public interface ServerPlayerInterface { - EntityPlayerActionPack getActionPack(); - void invalidateEntityObjectReference(); - boolean isInvalidEntityObject(); - String getLanguage(); + default EntityPlayerActionPack carpet$getActionPack() { throw new UnsupportedOperationException(); } + + default void carpet$invalidateEntityObjectReference() { throw new UnsupportedOperationException(); } + + default boolean carpet$isInvalidEntityObject() { throw new UnsupportedOperationException(); } + + default String carpet$getLanguage() { throw new UnsupportedOperationException(); } } diff --git a/src/main/java/carpet/fakes/ServerWorldInterface.java b/src/main/java/carpet/fakes/ServerWorldInterface.java deleted file mode 100644 index 8617acad2b..0000000000 --- a/src/main/java/carpet/fakes/ServerWorldInterface.java +++ /dev/null @@ -1,10 +0,0 @@ -package carpet.fakes; - -import net.minecraft.world.entity.Entity; -import net.minecraft.world.level.entity.LevelEntityGetter; -import net.minecraft.world.level.storage.ServerLevelData; - -public interface ServerWorldInterface { - ServerLevelData getWorldPropertiesCM(); - LevelEntityGetter getEntityLookupCMPublic(); -} diff --git a/src/main/java/carpet/fakes/SimpleEntityLookupInterface.java b/src/main/java/carpet/fakes/SimpleEntityLookupInterface.java deleted file mode 100644 index 415fc31312..0000000000 --- a/src/main/java/carpet/fakes/SimpleEntityLookupInterface.java +++ /dev/null @@ -1,10 +0,0 @@ -package carpet.fakes; - -import java.util.List; -import net.minecraft.world.level.ChunkPos; -import net.minecraft.world.level.entity.EntityAccess; - -public interface SimpleEntityLookupInterface -{ - List getChunkEntities(ChunkPos chpos); -} diff --git a/src/main/java/carpet/fakes/SpawnGroupInterface.java b/src/main/java/carpet/fakes/SpawnGroupInterface.java deleted file mode 100644 index 6f28807e6e..0000000000 --- a/src/main/java/carpet/fakes/SpawnGroupInterface.java +++ /dev/null @@ -1,6 +0,0 @@ -package carpet.fakes; - -public interface SpawnGroupInterface -{ - int getInitialSpawnCap(); -} diff --git a/src/main/java/carpet/fakes/SpawnHelperInnerInterface.java b/src/main/java/carpet/fakes/SpawnHelperInnerInterface.java deleted file mode 100644 index 6736fcb63a..0000000000 --- a/src/main/java/carpet/fakes/SpawnHelperInnerInterface.java +++ /dev/null @@ -1,8 +0,0 @@ -package carpet.fakes; - -import net.minecraft.world.level.PotentialCalculator; - -public interface SpawnHelperInnerInterface -{ - PotentialCalculator getPotentialCalculator(); -} diff --git a/src/main/java/carpet/fakes/SpawnStateInterface.java b/src/main/java/carpet/fakes/SpawnStateInterface.java new file mode 100644 index 0000000000..49c3284ea6 --- /dev/null +++ b/src/main/java/carpet/fakes/SpawnStateInterface.java @@ -0,0 +1,8 @@ +package carpet.fakes; + +import net.minecraft.world.level.PotentialCalculator; + +public interface SpawnStateInterface +{ + default PotentialCalculator carpet$getPotentialCalculator() { throw new UnsupportedOperationException(); } +} diff --git a/src/main/java/carpet/fakes/ThreadedAnvilChunkStorageInterface.java b/src/main/java/carpet/fakes/ThreadedAnvilChunkStorageInterface.java deleted file mode 100644 index fd1fa762f6..0000000000 --- a/src/main/java/carpet/fakes/ThreadedAnvilChunkStorageInterface.java +++ /dev/null @@ -1,17 +0,0 @@ -package carpet.fakes; - -import java.util.List; -import java.util.Map; -import net.minecraft.server.level.ChunkHolder; -import net.minecraft.world.level.ChunkPos; - -public interface ThreadedAnvilChunkStorageInterface -{ - Map regenerateChunkRegion(List requestedChunks); - - void relightChunk(ChunkPos pos); - - void releaseRelightTicket(ChunkPos pos); - - Iterable getChunksCM(); -} diff --git a/src/main/java/carpet/fakes/TntEntityInterface.java b/src/main/java/carpet/fakes/TntEntityInterface.java deleted file mode 100644 index b509324878..0000000000 --- a/src/main/java/carpet/fakes/TntEntityInterface.java +++ /dev/null @@ -1,6 +0,0 @@ -package carpet.fakes; - -public interface TntEntityInterface -{ - int getMergedTNT(); -} diff --git a/src/main/java/carpet/fakes/WorldChunkInterface.java b/src/main/java/carpet/fakes/WorldChunkInterface.java deleted file mode 100644 index d93b0a1de2..0000000000 --- a/src/main/java/carpet/fakes/WorldChunkInterface.java +++ /dev/null @@ -1,10 +0,0 @@ -package carpet.fakes; - -import net.minecraft.core.BlockPos; -import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.world.level.block.state.BlockState; - -public interface WorldChunkInterface -{ - BlockState setBlockStateWithBlockEntity(BlockPos blockPos, BlockState newBlockState, BlockEntity newBlockEntity, boolean boolean1); -} diff --git a/src/main/java/carpet/helpers/BlockRotator.java b/src/main/java/carpet/helpers/BlockRotator.java index 6794f9bbe5..11795feb78 100644 --- a/src/main/java/carpet/helpers/BlockRotator.java +++ b/src/main/java/carpet/helpers/BlockRotator.java @@ -1,6 +1,5 @@ package carpet.helpers; -import carpet.fakes.PistonBlockInterface; import net.minecraft.core.BlockPos; import net.minecraft.core.BlockSource; import net.minecraft.core.Direction; @@ -61,9 +60,9 @@ public static ItemStack dispenserRotate(BlockSource source, ItemStack stack) if (block instanceof DirectionalBlock || block instanceof DispenserBlock) { Direction face = blockstate.getValue(DirectionalBlock.FACING); - if (block instanceof PistonBaseBlock && ( + if (block instanceof PistonBaseBlock piston && ( blockstate.getValue(PistonBaseBlock.EXTENDED) - || ( ((PistonBlockInterface)block).publicShouldExtend(world, blockpos, face) && (new PistonStructureResolver(world, blockpos, face, true)).resolve() ) + || (piston.carpet$getNeighborSignal(world, blockpos, face) && (new PistonStructureResolver(world, blockpos, face, true)).resolve() ) ) ) { diff --git a/src/main/java/carpet/helpers/EntityPlayerActionPack.java b/src/main/java/carpet/helpers/EntityPlayerActionPack.java index e0601ea28c..bc5c098cd1 100644 --- a/src/main/java/carpet/helpers/EntityPlayerActionPack.java +++ b/src/main/java/carpet/helpers/EntityPlayerActionPack.java @@ -1,6 +1,5 @@ package carpet.helpers; -import carpet.fakes.ServerPlayerInterface; import java.util.EnumMap; import java.util.HashMap; import java.util.List; @@ -292,7 +291,7 @@ public enum ActionType @Override boolean execute(ServerPlayer player, Action action) { - EntityPlayerActionPack ap = ((ServerPlayerInterface) player).getActionPack(); + EntityPlayerActionPack ap = player.carpet$getActionPack(); if (ap.itemUseCooldown > 0) { ap.itemUseCooldown--; @@ -361,7 +360,7 @@ boolean execute(ServerPlayer player, Action action) @Override void inactiveTick(ServerPlayer player, Action action) { - EntityPlayerActionPack ap = ((ServerPlayerInterface) player).getActionPack(); + EntityPlayerActionPack ap = player.carpet$getActionPack(); ap.itemUseCooldown = 0; player.releaseUsingItem(); } @@ -383,7 +382,7 @@ boolean execute(ServerPlayer player, Action action) { return true; } case BLOCK: { - EntityPlayerActionPack ap = ((ServerPlayerInterface) player).getActionPack(); + EntityPlayerActionPack ap = player.carpet$getActionPack(); if (ap.blockHitDelay > 0) { ap.blockHitDelay--; @@ -454,7 +453,7 @@ else if (ap.currentBlock == null || !ap.currentBlock.equals(pos)) @Override void inactiveTick(ServerPlayer player, Action action) { - EntityPlayerActionPack ap = ((ServerPlayerInterface) player).getActionPack(); + EntityPlayerActionPack ap = player.carpet$getActionPack(); if (ap.currentBlock == null) return; player.level().destroyBlockProgress(-1, ap.currentBlock, -1); player.gameMode.handleBlockBreakAction(ap.currentBlock, ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK, Direction.DOWN, player.level().getMaxBuildHeight(), -1); diff --git a/src/main/java/carpet/helpers/FertilizableCoral.java b/src/main/java/carpet/helpers/FertilizableCoral.java index 9c8bd43dde..a502b0f02d 100644 --- a/src/main/java/carpet/helpers/FertilizableCoral.java +++ b/src/main/java/carpet/helpers/FertilizableCoral.java @@ -1,6 +1,5 @@ package carpet.helpers; -import carpet.fakes.CoralFeatureInterface; import net.minecraft.core.BlockPos; import net.minecraft.core.Holder; import net.minecraft.core.HolderSet; @@ -69,7 +68,7 @@ public default void performBonemeal(ServerLevel worldIn, RandomSource random, Bl } worldIn.setBlock(pos, Blocks.WATER.defaultBlockState(), Block.UPDATE_NONE); - if (!((CoralFeatureInterface)coral).growSpecific(worldIn, random, pos, properBlock)) + if (!coral.carpet$growSpecific(worldIn, random, pos, properBlock)) { worldIn.setBlock(pos, blockUnder, 3); } diff --git a/src/main/java/carpet/helpers/HopperCounter.java b/src/main/java/carpet/helpers/HopperCounter.java index 5bcedeca45..fbcbb042cc 100644 --- a/src/main/java/carpet/helpers/HopperCounter.java +++ b/src/main/java/carpet/helpers/HopperCounter.java @@ -1,8 +1,6 @@ package carpet.helpers; import carpet.CarpetServer; -import carpet.fakes.IngredientInterface; -import carpet.fakes.RecipeManagerInterface; import carpet.utils.Messenger; import it.unimi.dsi.fastutil.objects.Object2LongLinkedOpenHashMap; import it.unimi.dsi.fastutil.objects.Object2LongMap; @@ -373,11 +371,11 @@ public static TextColor guessColor(Item item, RegistryAccess registryAccess) ResourceLocation id = registryAccess.registryOrThrow(Registries.ITEM).getKey(item); for (RecipeType type: registryAccess.registryOrThrow(Registries.RECIPE_TYPE)) { - for (Recipe r: ((RecipeManagerInterface) CarpetServer.minecraft_server.getRecipeManager()).getAllMatching(type, id, registryAccess)) + for (Recipe r: CarpetServer.minecraft_server.getRecipeManager().carpet$getAllMatching(type, id, registryAccess)) { for (Ingredient ingredient: r.getIngredients()) { - for (Collection stacks : ((IngredientInterface) (Object) ingredient).getRecipeStacks()) + for (Collection stacks : ingredient.carpet$getRecipeStacks()) { for (ItemStack iStak : stacks) { diff --git a/src/main/java/carpet/helpers/RedstoneWireTurbo.java b/src/main/java/carpet/helpers/RedstoneWireTurbo.java index 33aa2ddcf6..d8a1567491 100644 --- a/src/main/java/carpet/helpers/RedstoneWireTurbo.java +++ b/src/main/java/carpet/helpers/RedstoneWireTurbo.java @@ -13,7 +13,6 @@ import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.RedStoneWireBlock; import net.minecraft.world.level.block.state.BlockState; -import carpet.fakes.RedstoneWireBlockInterface; public class RedstoneWireTurbo { @@ -438,7 +437,7 @@ private void updateNode(final Level worldIn, final UpdateNode upd1, final int la // UpdateNode object. BlockState newState; if (old_current_change) { - newState = ((RedstoneWireBlockInterface)wire).updateLogicPublic(worldIn, pos, oldState); + newState = wire.carpet$updateLogicPublic(worldIn, pos, oldState); } else { // Looking up block state is slow. This accelerator includes a version of // calculateCurrentChanges that uses cahed wire values for a @@ -780,7 +779,7 @@ public BlockState updateSurroundingRedstone(final Level worldIn, final BlockPos // Check this block's neighbors and see if its power level needs to change // Use the calculateCurrentChanges method in RedstoneWireBlock since we have no // cached block states at this point. - final BlockState newState = ((RedstoneWireBlockInterface)wire).updateLogicPublic(worldIn, pos, state); + final BlockState newState = wire.carpet$updateLogicPublic(worldIn, pos, state); // If no change, exit if (newState == state) { @@ -853,14 +852,14 @@ private BlockState calculateCurrentChanges(final Level worldIn, final UpdateNode j = getMaxCurrentStrength(upd, j); int l = 0; - ((RedstoneWireBlockInterface)wire).setWiresGivePower(false); + wire.carpet$setShouldSignal(false); // Unfortunately, World.isBlockIndirectlyGettingPowered is complicated, // and I'm not ready to try to replicate even more functionality from // elsewhere in Minecraft into this accelerator. So sadly, we must // suffer the performance hit of this very expensive call. If there // is consistency to what this call returns, we may be able to cache it. final int k = worldIn.getBestNeighborSignal(upd.self); - ((RedstoneWireBlockInterface)wire).setWiresGivePower(true); + wire.carpet$setShouldSignal(true); // The variable 'k' holds the maximum redstone power value of any adjacent blocks. // If 'k' has the highest level of all neighbors, then the power level of this diff --git a/src/main/java/carpet/helpers/TickSpeed.java b/src/main/java/carpet/helpers/TickSpeed.java index e74be60eb3..074bf90fde 100644 --- a/src/main/java/carpet/helpers/TickSpeed.java +++ b/src/main/java/carpet/helpers/TickSpeed.java @@ -3,7 +3,6 @@ import java.util.Optional; import java.util.function.BiConsumer; -import carpet.fakes.MinecraftServerInterface; import net.minecraft.commands.CommandSourceStack; import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerPlayer; @@ -15,7 +14,7 @@ public class TickSpeed { private static Optional gTRM() { if (CarpetServer.minecraft_server == null) return Optional.empty(); - return Optional.of(((MinecraftServerInterface)CarpetServer.minecraft_server).getTickRateManager()); + return Optional.of(CarpetServer.minecraft_server.carpet$getTickRateManager()); } public static boolean process_entities() { diff --git a/src/main/java/carpet/logging/HUDController.java b/src/main/java/carpet/logging/HUDController.java index 6167883945..a357d6abaa 100644 --- a/src/main/java/carpet/logging/HUDController.java +++ b/src/main/java/carpet/logging/HUDController.java @@ -1,7 +1,6 @@ package carpet.logging; import carpet.CarpetServer; -import carpet.fakes.MinecraftServerInterface; import carpet.helpers.HopperCounter; import carpet.helpers.ServerTickRateManager; import carpet.logging.logHelpers.PacketCounter; @@ -118,7 +117,7 @@ public static void update_hud(MinecraftServer server, List force) private static Component [] send_tps_display(MinecraftServer server) { OptionalDouble averageTPS = Arrays.stream(server.tickTimes).average(); - ServerTickRateManager trm = ((MinecraftServerInterface)server).getTickRateManager(); + ServerTickRateManager trm = server.carpet$getTickRateManager(); if (averageTPS.isEmpty()) { return new Component[]{Component.literal("No TPS data available")}; diff --git a/src/main/java/carpet/mixins/AbstractContainerMenuSubclasses_scarpetMixin.java b/src/main/java/carpet/mixins/AbstractContainerMenuSubclasses_scarpetMixin.java index 1b72742f42..f7ed4f08e6 100644 --- a/src/main/java/carpet/mixins/AbstractContainerMenuSubclasses_scarpetMixin.java +++ b/src/main/java/carpet/mixins/AbstractContainerMenuSubclasses_scarpetMixin.java @@ -1,6 +1,5 @@ package carpet.mixins; -import carpet.fakes.AbstractContainerMenuInterface; import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.inventory.EnchantmentMenu; @@ -16,14 +15,17 @@ //classes that override onButtonClick @Mixin({EnchantmentMenu.class, LecternMenu.class, LoomMenu.class, StonecutterMenu.class}) -public abstract class AbstractContainerMenuSubclasses_scarpetMixin extends AbstractContainerMenu { - protected AbstractContainerMenuSubclasses_scarpetMixin(MenuType type, int syncId) { +public abstract class AbstractContainerMenuSubclasses_scarpetMixin extends AbstractContainerMenu +{ + private AbstractContainerMenuSubclasses_scarpetMixin(MenuType type, int syncId) + { super(type, syncId); } @Inject(method = "clickMenuButton", at = @At("HEAD"), cancellable = true) - private void buttonClickCallback(Player player, int id, CallbackInfoReturnable cir) { - if(((AbstractContainerMenuInterface) this).callButtonClickListener(id,player)) + private void buttonClickCallback(Player player, int id, CallbackInfoReturnable cir) + { + if(carpet$notifyButtonClickListeners(id,player)) cir.cancel(); } } diff --git a/src/main/java/carpet/mixins/AbstractContainerMenu_scarpetMixin.java b/src/main/java/carpet/mixins/AbstractContainerMenu_scarpetMixin.java index 3f3fe6ce53..7daaa5ad5d 100644 --- a/src/main/java/carpet/mixins/AbstractContainerMenu_scarpetMixin.java +++ b/src/main/java/carpet/mixins/AbstractContainerMenu_scarpetMixin.java @@ -49,7 +49,7 @@ private void callCloseListener(Player player, CallbackInfo ci) { } @Override - public boolean callButtonClickListener(int button, Player player) { + public boolean carpet$notifyButtonClickListeners(int button, Player player) { if(!(player instanceof ServerPlayer serverPlayerEntity)) return false; for(ContainerListener screenHandlerListener : containerListeners) { if(screenHandlerListener instanceof ScreenValue.ScarpetScreenHandlerListener scarpetScreenHandlerListener) { @@ -61,7 +61,7 @@ public boolean callButtonClickListener(int button, Player player) { } @Override - public boolean callSelectRecipeListener(ServerPlayer player, Recipe recipe, boolean craftAll) { + public boolean carpet$notifySelectRecipeListeners(ServerPlayer player, Recipe recipe, boolean craftAll) { for(ContainerListener screenHandlerListener : containerListeners) { if(screenHandlerListener instanceof ScreenValue.ScarpetScreenHandlerListener scarpetScreenHandlerListener) { if(scarpetScreenHandlerListener.onSelectRecipe(player, recipe, craftAll)) @@ -72,7 +72,7 @@ public boolean callSelectRecipeListener(ServerPlayer player, Recipe recipe, b } @Override - public DataSlot getDataSlot(int index) { + public DataSlot carpet$getDataSlot(int index) { return this.dataSlots.get(index); } } \ No newline at end of file diff --git a/src/main/java/carpet/mixins/AbstractMinecart_scarpetEventsMixin.java b/src/main/java/carpet/mixins/AbstractMinecart_scarpetEventsMixin.java index dd9a16b4a0..3f03fcc267 100644 --- a/src/main/java/carpet/mixins/AbstractMinecart_scarpetEventsMixin.java +++ b/src/main/java/carpet/mixins/AbstractMinecart_scarpetEventsMixin.java @@ -1,6 +1,5 @@ package carpet.mixins; -import carpet.fakes.EntityInterface; import carpet.script.EntityEventsGroup; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; @@ -23,6 +22,6 @@ public AbstractMinecart_scarpetEventsMixin(EntityType type, Level world) private void onTickCall(CallbackInfo ci) { // calling extra on_tick because falling blocks do not fall back to super tick call - ((EntityInterface)this).getEventContainer().onEvent(EntityEventsGroup.Event.ON_TICK); + carpet$getEventContainer().onEvent(EntityEventsGroup.Event.ON_TICK); } } \ No newline at end of file diff --git a/src/main/java/carpet/mixins/BarrierBlock_updateSuppressionBlockMixin.java b/src/main/java/carpet/mixins/BarrierBlock_updateSuppressionBlockMixin.java index a4f2cc528d..ba32b9c486 100644 --- a/src/main/java/carpet/mixins/BarrierBlock_updateSuppressionBlockMixin.java +++ b/src/main/java/carpet/mixins/BarrierBlock_updateSuppressionBlockMixin.java @@ -1,7 +1,6 @@ package carpet.mixins; import carpet.CarpetSettings; -import carpet.fakes.LevelInterface; import net.minecraft.world.level.redstone.NeighborUpdater; import net.minecraft.util.RandomSource; import org.spongepowered.asm.mixin.Mixin; @@ -35,7 +34,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 = ((LevelInterface)level).getNeighborUpdater(); + NeighborUpdater updater = level.carpet$getNeighborUpdater(); if (updater instanceof CollectingNeighborUpdaterAccessor cnua) cnua.setCount(cnua.getMaxChainedNeighborUpdates()-CarpetSettings.updateSuppressionBlock); } diff --git a/src/main/java/carpet/mixins/Biome_scarpetMixin.java b/src/main/java/carpet/mixins/Biome_scarpetMixin.java index 496c2bd487..0eb59818a7 100644 --- a/src/main/java/carpet/mixins/Biome_scarpetMixin.java +++ b/src/main/java/carpet/mixins/Biome_scarpetMixin.java @@ -11,7 +11,7 @@ public class Biome_scarpetMixin implements BiomeInterface { private Biome.ClimateSettings climateSettings; @Override - public Biome.ClimateSettings getClimateSettings() { + public Biome.ClimateSettings carpet$getClimateSettings() { return climateSettings; } } diff --git a/src/main/java/carpet/mixins/BlockEntity_movableBEMixin.java b/src/main/java/carpet/mixins/BlockEntity_movableBEMixin.java index a043624435..5e50b258df 100644 --- a/src/main/java/carpet/mixins/BlockEntity_movableBEMixin.java +++ b/src/main/java/carpet/mixins/BlockEntity_movableBEMixin.java @@ -14,8 +14,8 @@ public abstract class BlockEntity_movableBEMixin implements BlockEntityInterface @Mutable @Shadow @Final protected BlockPos worldPosition; - public void setCMPos(BlockPos newPos) + public void carpet$setPos(BlockPos newPos) { worldPosition = newPos; - }; + } } diff --git a/src/main/java/carpet/mixins/BlockInput_scarpetMixin.java b/src/main/java/carpet/mixins/BlockInput_scarpetMixin.java index 44261a653a..04943fdade 100644 --- a/src/main/java/carpet/mixins/BlockInput_scarpetMixin.java +++ b/src/main/java/carpet/mixins/BlockInput_scarpetMixin.java @@ -1,6 +1,6 @@ package carpet.mixins; -import carpet.fakes.BlockStateArgumentInterface; +import carpet.fakes.BlockInputInterface; import net.minecraft.commands.arguments.blocks.BlockInput; import net.minecraft.nbt.CompoundTag; import org.jetbrains.annotations.Nullable; @@ -9,12 +9,12 @@ import org.spongepowered.asm.mixin.Shadow; @Mixin(BlockInput.class) -public class BlockInput_scarpetMixin implements BlockStateArgumentInterface +public class BlockInput_scarpetMixin implements BlockInputInterface { @Shadow @Final private @Nullable CompoundTag tag; @Override - public CompoundTag getCMTag() + public CompoundTag carpet$getTag() { return tag; } diff --git a/src/main/java/carpet/mixins/BlockPredicate_scarpetMixin.java b/src/main/java/carpet/mixins/BlockPredicate_scarpetMixin.java index ed4c5886e0..704f52e084 100644 --- a/src/main/java/carpet/mixins/BlockPredicate_scarpetMixin.java +++ b/src/main/java/carpet/mixins/BlockPredicate_scarpetMixin.java @@ -28,19 +28,19 @@ public class BlockPredicate_scarpetMixin implements BlockPredicateInterface @Shadow @Final private Set> properties; @Override - public BlockState getCMBlockState() + public BlockState carpet$getBlockState() { return state; } @Override - public TagKey getCMBlockTagKey() + public TagKey carpet$getTagKey() { return null; } @Override - public Map getCMProperties() + public Map carpet$getProperties() { return properties.stream().collect(Collectors.toMap( p -> StringValue.of(p.getName()), @@ -50,7 +50,7 @@ public Map getCMProperties() } @Override - public CompoundTag getCMDataTag() + public CompoundTag carpet$getDataTag() { return nbt; } diff --git a/src/main/java/carpet/mixins/BoundTickingBlockEntity_tickMixin.java b/src/main/java/carpet/mixins/BoundTickingBlockEntity_tickMixin.java index bc8a76917f..4e7f08ce5a 100644 --- a/src/main/java/carpet/mixins/BoundTickingBlockEntity_tickMixin.java +++ b/src/main/java/carpet/mixins/BoundTickingBlockEntity_tickMixin.java @@ -1,6 +1,5 @@ package carpet.mixins; -import carpet.fakes.LevelInterface; import carpet.helpers.TickRateManager; import carpet.utils.CarpetProfiler; import net.minecraft.core.BlockPos; @@ -33,12 +32,12 @@ private void startTileEntitySection(CallbackInfo ci) value = "INVOKE", target = "Lnet/minecraft/world/level/block/entity/BlockEntityTicker;tick(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/entity/BlockEntity;)V" )) - private void checkProcessBEs(BlockEntityTicker blockEntityTicker, Level world, BlockPos pos, BlockState state, T blockEntity) + private void checkProcessBEs(BlockEntityTicker blockEntityTicker, Level level, BlockPos pos, BlockState state, T blockEntity) { - TickRateManager tickRateManager = ((LevelInterface)world).tickRateManager(); + TickRateManager tickRateManager = level.carpet$getTickRateManager(); if (tickRateManager.runsNormally()) { - blockEntityTicker.tick(world, pos, state, blockEntity); + blockEntityTicker.tick(level, pos, state, blockEntity); } } diff --git a/src/main/java/carpet/mixins/ChainBlock_customStickyMixin.java b/src/main/java/carpet/mixins/ChainBlock_customStickyMixin.java index c7e3d727d7..ed2267a20d 100644 --- a/src/main/java/carpet/mixins/ChainBlock_customStickyMixin.java +++ b/src/main/java/carpet/mixins/ChainBlock_customStickyMixin.java @@ -20,12 +20,12 @@ public class ChainBlock_customStickyMixin implements BlockPistonBehaviourInterface { @Override - public boolean isSticky(BlockState state) { + public boolean carpet$isSticky(BlockState state) { return CarpetSettings.chainStone.enabled(); } @Override - public boolean isStickyToNeighbor(Level level, BlockPos pos, BlockState state, BlockPos neighborPos, BlockState neighborState, Direction dir, Direction moveDir) { + public boolean carpet$isStickyToNeighbor(Level level, BlockPos pos, BlockState state, BlockPos neighborPos, BlockState neighborState, Direction dir, Direction moveDir) { Axis axis = state.getValue(ChainBlock.AXIS); if (axis != dir.getAxis()) { diff --git a/src/main/java/carpet/mixins/ChestBlock_customStickyMixin.java b/src/main/java/carpet/mixins/ChestBlock_customStickyMixin.java index b31483615c..23e7fa611b 100644 --- a/src/main/java/carpet/mixins/ChestBlock_customStickyMixin.java +++ b/src/main/java/carpet/mixins/ChestBlock_customStickyMixin.java @@ -19,12 +19,12 @@ public class ChestBlock_customStickyMixin implements BlockPistonBehaviourInterface { @Override - public boolean isSticky(BlockState state) { + public boolean carpet$isSticky(BlockState state) { return CarpetSettings.movableBlockEntities; } @Override - public boolean isStickyToNeighbor(Level level, BlockPos pos, BlockState state, BlockPos neighborPos, BlockState neighborState, Direction dir, Direction moveDir) { + public boolean carpet$isStickyToNeighbor(Level level, BlockPos pos, BlockState state, BlockPos neighborPos, BlockState neighborState, Direction dir, Direction moveDir) { if (!neighborState.is((Block)(Object)this)) { return false; } diff --git a/src/main/java/carpet/mixins/ChunkHolder_scarpetChunkCreationMixin.java b/src/main/java/carpet/mixins/ChunkHolder_scarpetChunkCreationMixin.java index 786e0c8c93..79367f3f63 100644 --- a/src/main/java/carpet/mixins/ChunkHolder_scarpetChunkCreationMixin.java +++ b/src/main/java/carpet/mixins/ChunkHolder_scarpetChunkCreationMixin.java @@ -26,11 +26,11 @@ public abstract class ChunkHolder_scarpetChunkCreationMixin implements ChunkHold @Shadow @Final private AtomicReferenceArray>> futures; @Override - public CompletableFuture> setDefaultProtoChunk(ChunkPos chpos, BlockableEventLoop executor, ServerLevel world) + public CompletableFuture> carpet$setDefaultProtoChunk(ChunkPos pos, BlockableEventLoop executor, ServerLevel level) { int i = ChunkStatus.EMPTY.getIndex(); CompletableFuture> completableFuture2 = CompletableFuture.supplyAsync( - () -> Either.left(new ProtoChunk(chpos, UpgradeData.EMPTY, world, world.registryAccess().registryOrThrow(Registries.BIOME), null)), // todo figure out what that does - maybe add an option to reset with blending enabled..? + () -> Either.left(new ProtoChunk(pos, UpgradeData.EMPTY, level, level.registryAccess().registryOrThrow(Registries.BIOME), null)), // todo figure out what that does - maybe add an option to reset with blending enabled..? executor ); updateChunkToSave(completableFuture2, "unfull"); // possible debug data diff --git a/src/main/java/carpet/mixins/ChunkMap_scarpetChunkCreationMixin.java b/src/main/java/carpet/mixins/ChunkMap_scarpetChunkCreationMixin.java index 913c9bca1d..44eda5c1b8 100644 --- a/src/main/java/carpet/mixins/ChunkMap_scarpetChunkCreationMixin.java +++ b/src/main/java/carpet/mixins/ChunkMap_scarpetChunkCreationMixin.java @@ -12,8 +12,7 @@ import java.util.function.IntFunction; import java.util.stream.Collectors; -import carpet.fakes.SimpleEntityLookupInterface; -import carpet.fakes.ServerWorldInterface; +import carpet.fakes.LevelEntityGetterAdapterInterface; import net.minecraft.Util; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.server.MinecraftServer; @@ -46,10 +45,7 @@ import com.mojang.datafixers.util.Either; -import carpet.fakes.ChunkHolderInterface; -import carpet.fakes.ChunkTicketManagerInterface; -import carpet.fakes.ServerLightingProviderInterface; -import carpet.fakes.ThreadedAnvilChunkStorageInterface; +import carpet.fakes.ChunkMapInterface; import carpet.script.utils.WorldTools; import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap; import it.unimi.dsi.fastutil.longs.LongSet; @@ -60,7 +56,7 @@ import static carpet.script.CarpetEventServer.Event.CHUNK_LOADED; @Mixin(ChunkMap.class) -public abstract class ChunkMap_scarpetChunkCreationMixin implements ThreadedAnvilChunkStorageInterface +public abstract class ChunkMap_scarpetChunkCreationMixin implements ChunkMapInterface { @Shadow @Final @@ -180,7 +176,7 @@ private void addRelightTicket(final ChunkPos pos) } @Override - public void releaseRelightTicket(final ChunkPos pos) + public void carpet$releaseRelightTicket(final ChunkPos pos) { this.mainThreadExecutor.tell(Util.name( () -> this.distanceManager.removeRegionTicket(TicketType.LIGHT, pos, 1, pos), @@ -280,7 +276,7 @@ private ChunkAccess getCurrentChunk(final ChunkPos pos) } @Override - public void relightChunk(ChunkPos pos) + public void carpet$relightChunk(ChunkPos pos) { this.addTicket(pos); this.tickTicketManager(); @@ -289,15 +285,15 @@ public void relightChunk(ChunkPos pos) this.updatingChunkMap.get(pos.toLong()).getOrScheduleFuture(ChunkStatus.EMPTY, (ChunkMap) (Object) this); final ChunkAccess chunk = this.getCurrentChunk(pos); if (!(chunk.getStatus().isOrAfter(ChunkStatus.LIGHT.getParent()))) return; - ((ServerLightingProviderInterface) this.lightEngine).removeLightData(chunk); + this.lightEngine.carpet$removeLightData(chunk); this.addRelightTicket(pos); ChunkHolder chunkHolder = this.updatingChunkMap.get(pos.toLong()); final CompletableFuture lightFuture = this.getChunkRangeFuture(chunkHolder, 1, (pos_) -> ChunkStatus.LIGHT) .thenCompose( either -> either.map( - list -> ((ServerLightingProviderInterface) this.lightEngine).relight(chunk), + list -> this.lightEngine.carpet$relight(chunk), unloaded -> { - this.releaseRelightTicket(pos); + this.carpet$releaseRelightTicket(pos); return CompletableFuture.completedFuture(null); } ) @@ -306,7 +302,7 @@ public void relightChunk(ChunkPos pos) } @Override - public Map regenerateChunkRegion(final List requestedChunksList) + public Map carpet$regenerateChunkRegion(final List requestedChunksList) { final Object2IntMap report = new Object2IntOpenHashMap<>(); final Set requestedChunks = new HashSet<>(requestedChunksList); @@ -366,7 +362,7 @@ public Map regenerateChunkRegion(final List requested // remove entities long longPos = pos.toLong(); if (this.entitiesInLevel.contains(longPos) && chunk instanceof LevelChunk) - ((SimpleEntityLookupInterface)((ServerWorldInterface)level).getEntityLookupCMPublic()).getChunkEntities(pos).forEach(entity -> { if (!(entity instanceof Player)) entity.discard();}); + ((LevelEntityGetterAdapterInterface)level.carpet$getEntityGetter()).carpet$getChunkEntities(pos).forEach(entity -> { if (!(entity instanceof Player)) entity.discard();}); if (chunk instanceof LevelChunk) @@ -375,8 +371,8 @@ public Map regenerateChunkRegion(final List requested if (this.entitiesInLevel.remove(pos.toLong()) && chunk instanceof LevelChunk) this.level.unload((LevelChunk) chunk); // block entities only - ((ServerLightingProviderInterface) this.lightEngine).invokeUpdateChunkStatus(pos); - ((ServerLightingProviderInterface) this.lightEngine).removeLightData(chunk); + this.lightEngine.carpet$updateChunkStatus(pos); + this.lightEngine.carpet$removeLightData(chunk); this.progressListener.onStatusChange(pos, null); } @@ -390,10 +386,10 @@ public Map regenerateChunkRegion(final List requested final ChunkHolder oldHolder = this.updatingChunkMap.remove(pos); final ChunkHolder newHolder = new ChunkHolder(cPos, oldHolder.getTicketLevel(), level, this.lightEngine, this.queueSorter, (ChunkHolder.PlayerProvider) this); - ((ChunkHolderInterface) newHolder).setDefaultProtoChunk(cPos, this.mainThreadExecutor, level); // enable chunk blending? + newHolder.carpet$setDefaultProtoChunk(cPos, this.mainThreadExecutor, level); // enable chunk blending? this.updatingChunkMap.put(pos, newHolder); - ((ChunkTicketManagerInterface) this.distanceManager).replaceHolder(oldHolder, newHolder); + this.distanceManager.carpet$replaceHolder(oldHolder, newHolder); } this.modified = true; @@ -459,7 +455,7 @@ public Map regenerateChunkRegion(final List requested // Remove light for affected neighbors for (final ChunkAccess chunk : affectedNeighbors) - ((ServerLightingProviderInterface) this.lightEngine).removeLightData(chunk); + this.lightEngine.carpet$removeLightData(chunk); // Schedule relighting of neighbors @@ -476,9 +472,9 @@ public Map regenerateChunkRegion(final List requested lightFutures.add(this.getChunkRangeFuture (this.updatingChunkMap.get(pos.toLong()), 1, (pos_) -> ChunkStatus.LIGHT).thenCompose( either -> either.map( - list -> ((ServerLightingProviderInterface) this.lightEngine).relight(chunk), + list -> this.lightEngine.carpet$relight(chunk), unloaded -> { - this.releaseRelightTicket(pos); + this.carpet$releaseRelightTicket(pos); return CompletableFuture.completedFuture(null); } ) @@ -496,7 +492,7 @@ public Map regenerateChunkRegion(final List requested } @Override - public Iterable getChunksCM() { + public Iterable carpet$getChunks() { return getChunks(); } } diff --git a/src/main/java/carpet/mixins/ClientLevel_tickSpeedMixin.java b/src/main/java/carpet/mixins/ClientLevel_tickSpeedMixin.java index 12a5b6cf33..ce101af304 100644 --- a/src/main/java/carpet/mixins/ClientLevel_tickSpeedMixin.java +++ b/src/main/java/carpet/mixins/ClientLevel_tickSpeedMixin.java @@ -21,7 +21,7 @@ private void onInit(CallbackInfo ci) } @Override - public TickRateManager tickRateManager() + public TickRateManager carpet$getTickRateManager() { return tickRateManager; } diff --git a/src/main/java/carpet/mixins/Connection_packetCounterMixin.java b/src/main/java/carpet/mixins/Connection_packetCounterMixin.java index c7159e7329..e62d72a375 100644 --- a/src/main/java/carpet/mixins/Connection_packetCounterMixin.java +++ b/src/main/java/carpet/mixins/Connection_packetCounterMixin.java @@ -1,11 +1,9 @@ package carpet.mixins; -import carpet.fakes.ClientConnectionInterface; +import carpet.fakes.ConnectionInterface; import carpet.logging.logHelpers.PacketCounter; import io.netty.channel.Channel; import io.netty.channel.ChannelHandlerContext; -import io.netty.util.concurrent.Future; -import io.netty.util.concurrent.GenericFutureListener; import net.minecraft.network.Connection; import net.minecraft.network.PacketSendListener; import net.minecraft.network.protocol.Packet; @@ -17,7 +15,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(Connection.class) -public abstract class Connection_packetCounterMixin implements ClientConnectionInterface +public abstract class Connection_packetCounterMixin implements ConnectionInterface { // Add to the packet counter whenever a packet is received. @Inject(method = "channelRead0", at = @At("HEAD")) diff --git a/src/main/java/carpet/mixins/CoralFeature_renewableCoralMixin.java b/src/main/java/carpet/mixins/CoralFeature_renewableCoralMixin.java index f2d3800f82..96d60b3898 100644 --- a/src/main/java/carpet/mixins/CoralFeature_renewableCoralMixin.java +++ b/src/main/java/carpet/mixins/CoralFeature_renewableCoralMixin.java @@ -5,7 +5,6 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import java.util.Random; import net.minecraft.core.BlockPos; import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelAccessor; @@ -16,11 +15,11 @@ public abstract class CoralFeature_renewableCoralMixin implements CoralFeatureInterface { - @Shadow protected abstract boolean placeFeature(LevelAccessor var1, RandomSource var2, BlockPos var3, BlockState var4); + @Shadow protected abstract boolean placeFeature(LevelAccessor level, RandomSource random, BlockPos pos, BlockState blockUnder); @Override - public boolean growSpecific(Level worldIn, RandomSource random, BlockPos pos, BlockState blockUnder) + public boolean carpet$growSpecific(Level level, RandomSource random, BlockPos pos, BlockState blockUnder) { - return placeFeature(worldIn, random, pos, blockUnder); + return placeFeature(level, random, pos, blockUnder); } } diff --git a/src/main/java/carpet/mixins/DirectionMixin.java b/src/main/java/carpet/mixins/DirectionMixin.java index ac5d14e287..7f26643392 100644 --- a/src/main/java/carpet/mixins/DirectionMixin.java +++ b/src/main/java/carpet/mixins/DirectionMixin.java @@ -1,7 +1,6 @@ package carpet.mixins; import carpet.CarpetSettings; -import carpet.fakes.EntityInterface; import carpet.helpers.BlockRotator; import net.minecraft.core.Direction; import net.minecraft.world.entity.Entity; @@ -22,7 +21,7 @@ private static float getYaw(Entity entity, float float_1) } else { - yaw = ((EntityInterface) entity).getMainYaw(float_1); + yaw = entity.carpet$getMainYaw(float_1); } if (BlockRotator.flippinEligibility(entity)) { diff --git a/src/main/java/carpet/mixins/Display_scarpetEventMixin.java b/src/main/java/carpet/mixins/Display_scarpetEventMixin.java index c69feb098a..5a5afe5a13 100644 --- a/src/main/java/carpet/mixins/Display_scarpetEventMixin.java +++ b/src/main/java/carpet/mixins/Display_scarpetEventMixin.java @@ -1,6 +1,5 @@ package carpet.mixins; -import carpet.fakes.EntityInterface; import carpet.script.EntityEventsGroup; import net.minecraft.world.entity.Display; import net.minecraft.world.entity.Entity; @@ -23,6 +22,6 @@ public Display_scarpetEventMixin(final EntityType entityType, final Level lev private void onTickCall(CallbackInfo ci) { // calling extra on_tick because displays don't tick - ((EntityInterface)this).getEventContainer().onEvent(EntityEventsGroup.Event.ON_TICK); + carpet$getEventContainer().onEvent(EntityEventsGroup.Event.ON_TICK); } } diff --git a/src/main/java/carpet/mixins/DistanceManager_scarpetChunkCreationMixin.java b/src/main/java/carpet/mixins/DistanceManager_scarpetChunkCreationMixin.java index 694aed4999..ba2359c0b0 100644 --- a/src/main/java/carpet/mixins/DistanceManager_scarpetChunkCreationMixin.java +++ b/src/main/java/carpet/mixins/DistanceManager_scarpetChunkCreationMixin.java @@ -7,17 +7,17 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import carpet.fakes.ChunkTicketManagerInterface; +import carpet.fakes.DistanceManagerInterface; @Mixin(DistanceManager.class) -public abstract class DistanceManager_scarpetChunkCreationMixin implements ChunkTicketManagerInterface +public abstract class DistanceManager_scarpetChunkCreationMixin implements DistanceManagerInterface { @Shadow @Final private Set chunksToUpdateFutures; @Override - public void replaceHolder(final ChunkHolder oldHolder, final ChunkHolder newHolder) + public void carpet$replaceHolder(final ChunkHolder oldHolder, final ChunkHolder newHolder) { this.chunksToUpdateFutures.remove(oldHolder); this.chunksToUpdateFutures.add(newHolder); diff --git a/src/main/java/carpet/mixins/DistanceManager_scarpetMixin.java b/src/main/java/carpet/mixins/DistanceManager_scarpetMixin.java index 120f1f4ac4..69cc77928b 100644 --- a/src/main/java/carpet/mixins/DistanceManager_scarpetMixin.java +++ b/src/main/java/carpet/mixins/DistanceManager_scarpetMixin.java @@ -1,6 +1,6 @@ package carpet.mixins; -import carpet.fakes.ChunkTicketManagerInterface; +import carpet.fakes.DistanceManagerInterface; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; import net.minecraft.server.level.DistanceManager; import net.minecraft.server.level.Ticket; @@ -10,12 +10,12 @@ import org.spongepowered.asm.mixin.Shadow; @Mixin(DistanceManager.class) -public abstract class DistanceManager_scarpetMixin implements ChunkTicketManagerInterface +public abstract class DistanceManager_scarpetMixin implements DistanceManagerInterface { @Shadow @Final private Long2ObjectOpenHashMap>> tickets; @Override - public Long2ObjectOpenHashMap>> getTicketsByPosition() + public Long2ObjectOpenHashMap>> carpet$getTicketsByPosition() { return tickets; } diff --git a/src/main/java/carpet/mixins/DistanceManager_spawnChunksMixin.java b/src/main/java/carpet/mixins/DistanceManager_spawnChunksMixin.java index e4a24c65ea..31792940cc 100644 --- a/src/main/java/carpet/mixins/DistanceManager_spawnChunksMixin.java +++ b/src/main/java/carpet/mixins/DistanceManager_spawnChunksMixin.java @@ -1,6 +1,6 @@ package carpet.mixins; -import carpet.fakes.ChunkTicketManagerInterface; +import carpet.fakes.DistanceManagerInterface; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; import net.minecraft.server.level.DistanceManager; import net.minecraft.server.level.Ticket; @@ -15,7 +15,7 @@ import java.util.Iterator; @Mixin(DistanceManager.class) -public abstract class DistanceManager_spawnChunksMixin implements ChunkTicketManagerInterface +public abstract class DistanceManager_spawnChunksMixin implements DistanceManagerInterface { @Shadow @Final private Long2ObjectOpenHashMap>> tickets; @@ -24,7 +24,7 @@ public abstract class DistanceManager_spawnChunksMixin implements ChunkTicketMan @Shadow public abstract void addRegionTicket(TicketType type, ChunkPos pos, int radius, T argument); @Override - public void changeSpawnChunks(ChunkPos chunkPos, int distance) + public void carpet$changeSpawnChunks(ChunkPos chunkPos, int distance) { long pos = chunkPos.toLong(); SortedArraySet> set = tickets.get(pos); diff --git a/src/main/java/carpet/mixins/EndCrystal_scarpetEventsMixin.java b/src/main/java/carpet/mixins/EndCrystal_scarpetEventsMixin.java index d7d261a4de..ac8daa577b 100644 --- a/src/main/java/carpet/mixins/EndCrystal_scarpetEventsMixin.java +++ b/src/main/java/carpet/mixins/EndCrystal_scarpetEventsMixin.java @@ -1,6 +1,5 @@ package carpet.mixins; -import carpet.fakes.EntityInterface; import carpet.script.EntityEventsGroup; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; @@ -23,6 +22,6 @@ public EndCrystal_scarpetEventsMixin(EntityType type, Level world) private void onTickCall(CallbackInfo ci) { // calling extra on_tick because falling blocks do not fall back to super tick call - ((EntityInterface)this).getEventContainer().onEvent(EntityEventsGroup.Event.ON_TICK); + carpet$getEventContainer().onEvent(EntityEventsGroup.Event.ON_TICK); } -} \ No newline at end of file +} diff --git a/src/main/java/carpet/mixins/EntityMixin.java b/src/main/java/carpet/mixins/EntityMixin.java index 6c2223adeb..ee87a50dcb 100644 --- a/src/main/java/carpet/mixins/EntityMixin.java +++ b/src/main/java/carpet/mixins/EntityMixin.java @@ -27,7 +27,7 @@ public abstract class EntityMixin implements EntityInterface @Shadow public Level level; @Override - public float getMainYaw(float partialTicks) + public float carpet$getMainYaw(float partialTicks) { return partialTicks == 1.0F ? this.yRot : Mth.lerp(partialTicks, this.yRotO, this.yRot); } diff --git a/src/main/java/carpet/mixins/Entity_scarpetEventsMixin.java b/src/main/java/carpet/mixins/Entity_scarpetEventsMixin.java index 7a576b466c..5ec999580f 100644 --- a/src/main/java/carpet/mixins/Entity_scarpetEventsMixin.java +++ b/src/main/java/carpet/mixins/Entity_scarpetEventsMixin.java @@ -29,43 +29,43 @@ public abstract class Entity_scarpetEventsMixin implements EntityInterface private Vec3 pos1, motion; @Override - public EntityEventsGroup getEventContainer() + public EntityEventsGroup carpet$getEventContainer() { return events; } @Override - public boolean isPermanentVehicle() + public boolean carpet$isPermanentVehicle() { return permanentVehicle; } @Override - public void setPermanentVehicle(boolean permanent) + public void carpet$setPermanentVehicle(boolean permanent) { permanentVehicle = permanent; } @Override - public int getPublicNetherPortalCooldown() + public int carpet$getPublicNetherPortalCooldown() { return portalCooldown; } @Override - public void setPublicNetherPortalCooldown(int what) + public void carpet$setPublicNetherPortalCooldown(int what) { portalCooldown = what; } @Override - public int getPortalTimer() + public int carpet$getPortalTimer() { return portalTime; } @Override - public void setPortalTimer(int amount) + public void carpet$setPortalTimer(int amount) { portalTime = amount; } diff --git a/src/main/java/carpet/mixins/FallingBlockEntity_scarpetEventsMixin.java b/src/main/java/carpet/mixins/FallingBlockEntity_scarpetEventsMixin.java index d3ee411b6a..0d9efd4540 100644 --- a/src/main/java/carpet/mixins/FallingBlockEntity_scarpetEventsMixin.java +++ b/src/main/java/carpet/mixins/FallingBlockEntity_scarpetEventsMixin.java @@ -1,6 +1,5 @@ package carpet.mixins; -import carpet.fakes.EntityInterface; import carpet.script.EntityEventsGroup; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; @@ -23,6 +22,6 @@ public FallingBlockEntity_scarpetEventsMixin(EntityType type, Level world) private void onTickCall(CallbackInfo ci) { // calling extra on_tick because falling blocks do not fall back to super tick call - ((EntityInterface)this).getEventContainer().onEvent(EntityEventsGroup.Event.ON_TICK); + carpet$getEventContainer().onEvent(EntityEventsGroup.Event.ON_TICK); } } diff --git a/src/main/java/carpet/mixins/Gui_tablistMixin.java b/src/main/java/carpet/mixins/Gui_tablistMixin.java index f6ab98acb5..52bd77fe9a 100644 --- a/src/main/java/carpet/mixins/Gui_tablistMixin.java +++ b/src/main/java/carpet/mixins/Gui_tablistMixin.java @@ -1,6 +1,5 @@ package carpet.mixins; -import carpet.fakes.PlayerListHudInterface; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.components.PlayerTabOverlay; @@ -22,7 +21,7 @@ public abstract class Gui_tablistMixin @Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;isLocalServer()Z")) private boolean onDraw(Minecraft minecraftClient) { - return this.minecraft.isLocalServer() && !((PlayerListHudInterface) tabList).hasFooterOrHeader(); + return this.minecraft.isLocalServer() && !tabList.carpet$hasFooterOrHeader(); } } diff --git a/src/main/java/carpet/mixins/HangingEntity_scarpetEventsMixin.java b/src/main/java/carpet/mixins/HangingEntity_scarpetEventsMixin.java index 981770f380..db7cba6d01 100644 --- a/src/main/java/carpet/mixins/HangingEntity_scarpetEventsMixin.java +++ b/src/main/java/carpet/mixins/HangingEntity_scarpetEventsMixin.java @@ -1,6 +1,5 @@ package carpet.mixins; -import carpet.fakes.EntityInterface; import carpet.script.EntityEventsGroup; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; @@ -23,6 +22,6 @@ public HangingEntity_scarpetEventsMixin(EntityType type, Level world) private void onTickCall(CallbackInfo ci) { // calling extra on_tick because falling blocks do not fall back to super tick call - ((EntityInterface)this).getEventContainer().onEvent(EntityEventsGroup.Event.ON_TICK); + carpet$getEventContainer().onEvent(EntityEventsGroup.Event.ON_TICK); } } \ No newline at end of file diff --git a/src/main/java/carpet/mixins/HorseBaseEntity_scarpetMixin.java b/src/main/java/carpet/mixins/HorseBaseEntity_scarpetMixin.java index 4e74292db6..3f7253097b 100644 --- a/src/main/java/carpet/mixins/HorseBaseEntity_scarpetMixin.java +++ b/src/main/java/carpet/mixins/HorseBaseEntity_scarpetMixin.java @@ -1,6 +1,6 @@ package carpet.mixins; -import carpet.fakes.InventoryBearerInterface; +import carpet.fakes.AbstractHorseInterface; import net.minecraft.world.Container; import net.minecraft.world.SimpleContainer; import net.minecraft.world.entity.animal.horse.AbstractHorse; @@ -8,13 +8,13 @@ import org.spongepowered.asm.mixin.Shadow; @Mixin(AbstractHorse.class) -public class HorseBaseEntity_scarpetMixin implements InventoryBearerInterface +public class HorseBaseEntity_scarpetMixin implements AbstractHorseInterface { @Shadow protected SimpleContainer inventory; @Override - public Container getCMInventory() + public Container carpet$getInventory() { return inventory; } diff --git a/src/main/java/carpet/mixins/Ingredient_scarpetMixin.java b/src/main/java/carpet/mixins/Ingredient_scarpetMixin.java index 4d33697e80..f37b6951a1 100644 --- a/src/main/java/carpet/mixins/Ingredient_scarpetMixin.java +++ b/src/main/java/carpet/mixins/Ingredient_scarpetMixin.java @@ -17,7 +17,7 @@ public class Ingredient_scarpetMixin implements IngredientInterface @Shadow @Final private Ingredient.Value[] values; @Override - public List> getRecipeStacks() + public List> carpet$getRecipeStacks() { return Arrays.stream(values).map(Ingredient.Value::getItems).toList(); } diff --git a/src/main/java/carpet/mixins/ItemEntityMixin.java b/src/main/java/carpet/mixins/ItemEntityMixin.java index 04731b2105..b32bd3597a 100644 --- a/src/main/java/carpet/mixins/ItemEntityMixin.java +++ b/src/main/java/carpet/mixins/ItemEntityMixin.java @@ -42,7 +42,7 @@ public void thunderHit(ServerLevel world, LightningBolt lightning) { } @Override - public int getPickupDelayCM() { + public int carpet$getPickupDelay() { return this.pickupDelay; } @@ -96,7 +96,7 @@ private void tryStackShulkerBoxes(ItemEntity other, CallbackInfo ci) selfStack.grow(amount); self.setItem(selfStack); - this.pickupDelay = Math.max(((ItemEntityInterface)other).getPickupDelayCM(), this.pickupDelay); + this.pickupDelay = Math.max(other.carpet$getPickupDelay(), this.pickupDelay); this.age = Math.min(other.getAge(), this.age); otherStack.shrink(amount); diff --git a/src/main/java/carpet/mixins/LayerLightEngine_scarpetChunkCreationMixin.java b/src/main/java/carpet/mixins/LayerLightEngine_scarpetChunkCreationMixin.java index a4e7c6a7b3..5975647fe9 100644 --- a/src/main/java/carpet/mixins/LayerLightEngine_scarpetChunkCreationMixin.java +++ b/src/main/java/carpet/mixins/LayerLightEngine_scarpetChunkCreationMixin.java @@ -16,8 +16,8 @@ public abstract class LayerLightEngine_scarpetChunkCreationMixin implements Ligh protected LayerLightSectionStorage storage; @Override - public void removeLightData(final long pos) + public void carpet$removeLightData(final long pos) { - ((Lighting_scarpetChunkCreationInterface) this.storage).removeLightData(pos); + this.storage.carpet$removeLightData(pos); } } diff --git a/src/main/java/carpet/mixins/LayerLightSectionStorage_scarpetChunkCreationMixin.java b/src/main/java/carpet/mixins/LayerLightSectionStorage_scarpetChunkCreationMixin.java index 7f41c737cd..983fefbd09 100644 --- a/src/main/java/carpet/mixins/LayerLightSectionStorage_scarpetChunkCreationMixin.java +++ b/src/main/java/carpet/mixins/LayerLightSectionStorage_scarpetChunkCreationMixin.java @@ -35,7 +35,7 @@ public abstract class LayerLightSectionStorage_scarpetChunkCreationMixin impleme protected Long2ObjectMap queuedSections; @Override - public void removeLightData(long cPos) + public void carpet$removeLightData(long cPos) { for (int y = -1; y < 17; ++y) diff --git a/src/main/java/carpet/mixins/LevelChunk_movableBEMixin.java b/src/main/java/carpet/mixins/LevelChunk_movableBEMixin.java index 9ea443017d..b1a29c4ad7 100644 --- a/src/main/java/carpet/mixins/LevelChunk_movableBEMixin.java +++ b/src/main/java/carpet/mixins/LevelChunk_movableBEMixin.java @@ -1,7 +1,7 @@ package carpet.mixins; import carpet.CarpetSettings; -import carpet.fakes.WorldChunkInterface; +import carpet.fakes.LevelChunkInterface; import net.minecraft.core.BlockPos; import net.minecraft.core.Registry; import net.minecraft.world.level.ChunkPos; @@ -27,7 +27,7 @@ import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(LevelChunk.class) -public abstract class LevelChunk_movableBEMixin extends ChunkAccess implements WorldChunkInterface +public abstract class LevelChunk_movableBEMixin extends ChunkAccess implements LevelChunkInterface { @Shadow @Final @@ -72,49 +72,48 @@ private BlockEntity ifGetBlockEntity(LevelChunk worldChunk, BlockPos blockPos_1, */ /* @Nullable */ // todo update me to the new version - public BlockState setBlockStateWithBlockEntity(BlockPos blockPos_1, BlockState newBlockState, BlockEntity newBlockEntity, - boolean boolean_1) + public BlockState carpet$setBlockStateWithBlockEntity(BlockPos pos, BlockState state, BlockEntity blockEntity, boolean movedByPiston) { - int x = blockPos_1.getX() & 15; - int y = blockPos_1.getY(); - int z = blockPos_1.getZ() & 15; + int x = pos.getX() & 15; + int y = pos.getY(); + int z = pos.getZ() & 15; LevelChunkSection chunkSection = this.getSection(this.getSectionIndex(y)); if (chunkSection.hasOnlyAir()) { - if (newBlockState.isAir()) + if (state.isAir()) { return null; } } boolean boolean_2 = chunkSection.hasOnlyAir(); - BlockState oldBlockState = chunkSection.setBlockState(x, y & 15, z, newBlockState); - if (oldBlockState == newBlockState) + BlockState oldBlockState = chunkSection.setBlockState(x, y & 15, z, state); + if (oldBlockState == state) { return null; } else { - Block newBlock = newBlockState.getBlock(); + Block newBlock = state.getBlock(); Block oldBlock = oldBlockState.getBlock(); - ((Heightmap) this.heightmaps.get(Heightmap.Types.MOTION_BLOCKING)).update(x, y, z, newBlockState); - ((Heightmap) this.heightmaps.get(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES)).update(x, y, z, newBlockState); - ((Heightmap) this.heightmaps.get(Heightmap.Types.OCEAN_FLOOR)).update(x, y, z, newBlockState); - ((Heightmap) this.heightmaps.get(Heightmap.Types.WORLD_SURFACE)).update(x, y, z, newBlockState); + ((Heightmap) this.heightmaps.get(Heightmap.Types.MOTION_BLOCKING)).update(x, y, z, state); + ((Heightmap) this.heightmaps.get(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES)).update(x, y, z, state); + ((Heightmap) this.heightmaps.get(Heightmap.Types.OCEAN_FLOOR)).update(x, y, z, state); + ((Heightmap) this.heightmaps.get(Heightmap.Types.WORLD_SURFACE)).update(x, y, z, state); boolean boolean_3 = chunkSection.hasOnlyAir(); if (boolean_2 != boolean_3) { - this.level.getChunkSource().getLightEngine().updateSectionStatus(blockPos_1, boolean_3); + this.level.getChunkSource().getLightEngine().updateSectionStatus(pos, boolean_3); } if (!this.level.isClientSide) { if (!(oldBlock instanceof MovingPistonBlock))//this is a movableTE special case, if condition wasn't there it would remove the blockentity that was carried for some reason - oldBlockState.onRemove(this.level, blockPos_1, newBlockState, boolean_1);//this kills it + oldBlockState.onRemove(this.level, pos, state, movedByPiston);//this kills it } else if (oldBlock != newBlock && oldBlock instanceof EntityBlock) { - this.level.removeBlockEntity(blockPos_1); + this.level.removeBlockEntity(pos); } if (chunkSection.getBlockState(x, y & 15, z).getBlock() != newBlock) @@ -126,7 +125,7 @@ else if (oldBlock != newBlock && oldBlock instanceof EntityBlock) BlockEntity oldBlockEntity = null; if (oldBlockState.hasBlockEntity()) { - oldBlockEntity = this.getBlockEntity(blockPos_1, LevelChunk.EntityCreationType.CHECK); + oldBlockEntity = this.getBlockEntity(pos, LevelChunk.EntityCreationType.CHECK); if (oldBlockEntity != null) { oldBlockEntity.setBlockState(oldBlockState); @@ -136,22 +135,22 @@ else if (oldBlock != newBlock && oldBlock instanceof EntityBlock) if (oldBlockState.hasBlockEntity()) { - if (newBlockEntity == null) + if (blockEntity == null) { - newBlockEntity = ((EntityBlock) newBlock).newBlockEntity(blockPos_1, newBlockState); + blockEntity = ((EntityBlock) newBlock).newBlockEntity(pos, state); } - if (newBlockEntity != oldBlockEntity && newBlockEntity != null) + if (blockEntity != oldBlockEntity && blockEntity != null) { - newBlockEntity.clearRemoved(); - this.level.setBlockEntity(newBlockEntity); - newBlockEntity.setBlockState(newBlockState); - updateBlockEntityTicker(newBlockEntity); + blockEntity.clearRemoved(); + this.level.setBlockEntity(blockEntity); + blockEntity.setBlockState(state); + updateBlockEntityTicker(blockEntity); } } if (!this.level.isClientSide) { - newBlockState.onPlace(this.level, blockPos_1, oldBlockState, boolean_1); //This can call setblockstate! (e.g. hopper does) + state.onPlace(this.level, pos, oldBlockState, movedByPiston); //This can call setblockstate! (e.g. hopper does) } this.unsaved = true; // shouldSave diff --git a/src/main/java/carpet/mixins/LevelEntityGetterAdapter_scarpetMixin.java b/src/main/java/carpet/mixins/LevelEntityGetterAdapter_scarpetMixin.java index 51ae92127c..a69ac89d64 100644 --- a/src/main/java/carpet/mixins/LevelEntityGetterAdapter_scarpetMixin.java +++ b/src/main/java/carpet/mixins/LevelEntityGetterAdapter_scarpetMixin.java @@ -1,6 +1,6 @@ package carpet.mixins; -import carpet.fakes.SimpleEntityLookupInterface; +import carpet.fakes.LevelEntityGetterAdapterInterface; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -14,14 +14,14 @@ import net.minecraft.world.level.entity.LevelEntityGetterAdapter; @Mixin(LevelEntityGetterAdapter.class) -public class LevelEntityGetterAdapter_scarpetMixin implements SimpleEntityLookupInterface +public class LevelEntityGetterAdapter_scarpetMixin implements LevelEntityGetterAdapterInterface { @Shadow @Final private EntitySectionStorage sectionStorage; @Override - public List getChunkEntities(ChunkPos chpos) { - return this.sectionStorage.getExistingSectionsInChunk(chpos.toLong()).flatMap(EntitySection::getEntities).collect(Collectors.toList()); + public List carpet$getChunkEntities(ChunkPos pos) { + return this.sectionStorage.getExistingSectionsInChunk(pos.toLong()).flatMap(EntitySection::getEntities).collect(Collectors.toList()); } } diff --git a/src/main/java/carpet/mixins/LevelLightEngine_scarpetChunkCreationMixin.java b/src/main/java/carpet/mixins/LevelLightEngine_scarpetChunkCreationMixin.java index 55bb324cc4..3bfe2d92f2 100644 --- a/src/main/java/carpet/mixins/LevelLightEngine_scarpetChunkCreationMixin.java +++ b/src/main/java/carpet/mixins/LevelLightEngine_scarpetChunkCreationMixin.java @@ -20,12 +20,12 @@ public abstract class LevelLightEngine_scarpetChunkCreationMixin implements Ligh private LightEngine skyEngine; @Override - public void removeLightData(final long pos) + public void carpet$removeLightData(final long pos) { if (this.blockEngine != null) - ((Lighting_scarpetChunkCreationInterface) this.blockEngine).removeLightData(pos); + this.blockEngine.carpet$removeLightData(pos); if (this.skyEngine != null) - ((Lighting_scarpetChunkCreationInterface) this.skyEngine).removeLightData(pos); + this.skyEngine.carpet$removeLightData(pos); } } diff --git a/src/main/java/carpet/mixins/LevelRenderer_pausedShakeMixin.java b/src/main/java/carpet/mixins/LevelRenderer_pausedShakeMixin.java index 2c38ffb871..4a59094bc7 100644 --- a/src/main/java/carpet/mixins/LevelRenderer_pausedShakeMixin.java +++ b/src/main/java/carpet/mixins/LevelRenderer_pausedShakeMixin.java @@ -1,7 +1,5 @@ package carpet.mixins; -import carpet.fakes.LevelInterface; -import carpet.fakes.MinecraftClientInferface; import carpet.helpers.TickRateManager; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.ClientLevel; @@ -28,9 +26,9 @@ public class LevelRenderer_pausedShakeMixin private float changeTickPhase(float previous) { initial = previous; - TickRateManager trm = ((LevelInterface)level).tickRateManager(); + TickRateManager trm = level.carpet$getTickRateManager(); if (!trm.runsNormally()) - return ((MinecraftClientInferface)minecraft).getPausedTickDelta(); + return minecraft.carpet$getPausePartialTick(); return previous; } @@ -45,5 +43,4 @@ private float changeTickPhaseBack(float previous) // this may not set with optifine bitch return initial==-1234.0f?previous:initial; } - } diff --git a/src/main/java/carpet/mixins/Level_getOtherEntitiesLimited.java b/src/main/java/carpet/mixins/Level_getOtherEntitiesLimited.java index 4a6b4a7573..1d6bb06d89 100644 --- a/src/main/java/carpet/mixins/Level_getOtherEntitiesLimited.java +++ b/src/main/java/carpet/mixins/Level_getOtherEntitiesLimited.java @@ -23,7 +23,7 @@ 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!"); @Override - public List getOtherEntitiesLimited(@Nullable Entity except, AABB box, Predicate predicate, int limit) { + public List carpet$getOtherEntitiesLimited(@Nullable Entity except, AABB box, Predicate predicate, int limit) { this.getProfiler().incrementCounter("getEntities"); // visit AtomicInteger checkedEntities = new AtomicInteger(); List list = Lists.newArrayList(); diff --git a/src/main/java/carpet/mixins/Level_movableBEMixin.java b/src/main/java/carpet/mixins/Level_movableBEMixin.java index d5820368ae..050a2390d4 100644 --- a/src/main/java/carpet/mixins/Level_movableBEMixin.java +++ b/src/main/java/carpet/mixins/Level_movableBEMixin.java @@ -1,6 +1,5 @@ package carpet.mixins; -import carpet.fakes.WorldChunkInterface; import carpet.fakes.LevelInterface; import net.minecraft.core.BlockPos; import net.minecraft.server.level.FullChunkStatus; @@ -58,71 +57,71 @@ public abstract class Level_movableBEMixin implements LevelInterface, LevelAcces * @author 2No2Name */ @Override - public boolean setBlockStateWithBlockEntity(BlockPos blockPos_1, BlockState blockState_1, BlockEntity newBlockEntity, int int_1) + public boolean carpet$setBlockStateWithBlockEntity(BlockPos pos, BlockState state, BlockEntity blockEntity, int flags) { - if (isOutsideBuildHeight(blockPos_1) || !this.isClientSide && isDebug()) return false; - LevelChunk worldChunk_1 = this.getChunkAt(blockPos_1); - Block block_1 = blockState_1.getBlock(); + if (isOutsideBuildHeight(pos) || !this.isClientSide && isDebug()) return false; + LevelChunk chunk = this.getChunkAt(pos); + Block block = state.getBlock(); - BlockState blockState_2; - if (newBlockEntity != null && block_1 instanceof EntityBlock) + BlockState prevState; + if (blockEntity != null && block instanceof EntityBlock) { - blockState_2 = ((WorldChunkInterface) worldChunk_1).setBlockStateWithBlockEntity(blockPos_1, blockState_1, newBlockEntity, (int_1 & 64) != 0); - if (newBlockEntity instanceof LidBlockEntity) + prevState = chunk.carpet$setBlockStateWithBlockEntity(pos, state, blockEntity, (flags & 64) != 0); + if (blockEntity instanceof LidBlockEntity) { - scheduleTick(blockPos_1, block_1, 5); + scheduleTick(pos, block, 5); } } else { - blockState_2 = worldChunk_1.setBlockState(blockPos_1, blockState_1, (int_1 & 64) != 0); + prevState = chunk.setBlockState(pos, state, (flags & 64) != 0); } - if (blockState_2 == null) + if (prevState == null) { return false; } else { - BlockState blockState_3 = this.getBlockState(blockPos_1); + BlockState newState = this.getBlockState(pos); - if (blockState_3 != blockState_2 && (blockState_3.getLightBlock((BlockGetter) this, blockPos_1) != blockState_2.getLightBlock((BlockGetter) this, blockPos_1) || blockState_3.getLightEmission() != blockState_2.getLightEmission() || blockState_3.useShapeForLightOcclusion() || blockState_2.useShapeForLightOcclusion())) + if (newState != prevState && (newState.getLightBlock((BlockGetter) this, pos) != prevState.getLightBlock((BlockGetter) this, pos) || newState.getLightEmission() != prevState.getLightEmission() || newState.useShapeForLightOcclusion() || prevState.useShapeForLightOcclusion())) { ProfilerFiller profiler = getProfiler(); profiler.push("queueCheckLight"); - this.getChunkSource().getLightEngine().checkBlock(blockPos_1); + this.getChunkSource().getLightEngine().checkBlock(pos); profiler.pop(); } - if (blockState_3 == blockState_1) + if (newState == state) { - if (blockState_2 != blockState_3) + if (prevState != newState) { - this.setBlocksDirty(blockPos_1, blockState_2, blockState_3); + this.setBlocksDirty(pos, prevState, newState); } - if ((int_1 & 2) != 0 && (!this.isClientSide || (int_1 & 4) == 0) && (this.isClientSide || worldChunk_1.getFullStatus() != null && worldChunk_1.getFullStatus().isOrAfter(FullChunkStatus.BLOCK_TICKING))) + if ((flags & 2) != 0 && (!this.isClientSide || (flags & 4) == 0) && (this.isClientSide || chunk.getFullStatus() != null && chunk.getFullStatus().isOrAfter(FullChunkStatus.BLOCK_TICKING))) { - this.sendBlockUpdated(blockPos_1, blockState_2, blockState_1, int_1); + this.sendBlockUpdated(pos, prevState, state, flags); } - if (!this.isClientSide && (int_1 & 1) != 0) + if (!this.isClientSide && (flags & 1) != 0) { - this.updateNeighborsAt(blockPos_1, blockState_2.getBlock()); - if (blockState_1.hasAnalogOutputSignal()) + this.updateNeighborsAt(pos, prevState.getBlock()); + if (state.hasAnalogOutputSignal()) { - updateNeighbourForOutputSignal(blockPos_1, block_1); + updateNeighbourForOutputSignal(pos, block); } } - if ((int_1 & 16) == 0) + if ((flags & 16) == 0) { - int int_2 = int_1 & -34; - blockState_2.updateIndirectNeighbourShapes(this, blockPos_1, int_2); // prepare - blockState_1.updateNeighbourShapes(this, blockPos_1, int_2); // updateNeighbours - blockState_1.updateIndirectNeighbourShapes(this, blockPos_1, int_2); // prepare + int flagsForNeighborUpdate = flags & -34; + prevState.updateIndirectNeighbourShapes(this, pos, flagsForNeighborUpdate); + state.updateNeighbourShapes(this, pos, flagsForNeighborUpdate); + state.updateIndirectNeighbourShapes(this, pos, flagsForNeighborUpdate); } - this.onBlockStateChange(blockPos_1, blockState_2, blockState_3); + this.onBlockStateChange(pos, prevState, newState); } return true; } diff --git a/src/main/java/carpet/mixins/Level_tickMixin.java b/src/main/java/carpet/mixins/Level_tickMixin.java index 146c00cec5..5db02aa624 100644 --- a/src/main/java/carpet/mixins/Level_tickMixin.java +++ b/src/main/java/carpet/mixins/Level_tickMixin.java @@ -31,12 +31,12 @@ public abstract class Level_tickMixin implements LevelInterface @Override @Unique - public NeighborUpdater getNeighborUpdater() { + public NeighborUpdater carpet$getNeighborUpdater() { return this.neighborUpdater; } @Override - public Map, Entity> getPrecookedMobs() + public Map, Entity> carpet$getPrecookedMobs() { return precookedMobs; } @@ -54,7 +54,7 @@ private void endBlockEntities(CallbackInfo ci) { @Inject(method = "guardEntityTick", at = @At("HEAD"), cancellable = true) private void startEntity(Consumer consumer_1, Entity e, CallbackInfo ci) { - TickRateManager trm = tickRateManager(); + TickRateManager trm = carpet$getTickRateManager(); if (!trm.shouldEntityTick(e)) { ci.cancel(); @@ -67,6 +67,4 @@ private void startEntity(Consumer consumer_1, Entity e, CallbackInfo ci) private void endEntity(Consumer call, Entity e, CallbackInfo ci) { CarpetProfiler.end_current_entity_section(entitySection); } - - } diff --git a/src/main/java/carpet/mixins/LivingEntity_maxCollisionsMixin.java b/src/main/java/carpet/mixins/LivingEntity_maxCollisionsMixin.java index f7168f9a93..6cd7b11db4 100644 --- a/src/main/java/carpet/mixins/LivingEntity_maxCollisionsMixin.java +++ b/src/main/java/carpet/mixins/LivingEntity_maxCollisionsMixin.java @@ -1,7 +1,6 @@ package carpet.mixins; import carpet.CarpetSettings; -import carpet.fakes.LevelInterface; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -38,7 +37,7 @@ private void tickPushingReplacement(CallbackInfo ci) { if (CarpetSettings.maxEntityCollisions > 0) { maxEntityCramming = this.level().getGameRules().getInt(GameRules.RULE_MAX_ENTITY_CRAMMING); - entities = ((LevelInterface) this.level()).getOtherEntitiesLimited( + entities = this.level().carpet$getOtherEntitiesLimited( this, this.getBoundingBox(), EntitySelector.pushableBy(this), diff --git a/src/main/java/carpet/mixins/LivingEntity_scarpetEventsMixin.java b/src/main/java/carpet/mixins/LivingEntity_scarpetEventsMixin.java index fe4614205f..22d8b6b94a 100644 --- a/src/main/java/carpet/mixins/LivingEntity_scarpetEventsMixin.java +++ b/src/main/java/carpet/mixins/LivingEntity_scarpetEventsMixin.java @@ -1,6 +1,5 @@ package carpet.mixins; -import carpet.fakes.EntityInterface; import carpet.fakes.LivingEntityInterface; import carpet.script.EntityEventsGroup; import net.minecraft.server.level.ServerPlayer; @@ -34,7 +33,7 @@ public LivingEntity_scarpetEventsMixin(EntityType type, Level world) @Inject(method = "die", at = @At("HEAD")) private void onDeathCall(DamageSource damageSource_1, CallbackInfo ci) { - ((EntityInterface)this).getEventContainer().onEvent(EntityEventsGroup.Event.ON_DEATH, damageSource_1.getMsgId()); + carpet$getEventContainer().onEvent(EntityEventsGroup.Event.ON_DEATH, damageSource_1.getMsgId()); } @Inject(method = "actuallyHurt", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD, at = @At( @@ -44,7 +43,7 @@ private void onDeathCall(DamageSource damageSource_1, CallbackInfo ci) )) private void entityTakingDamage(DamageSource source, float amount, CallbackInfo ci) { - ((EntityInterface)this).getEventContainer().onEvent(EntityEventsGroup.Event.ON_DAMAGE, amount, source); + carpet$getEventContainer().onEvent(EntityEventsGroup.Event.ON_DAMAGE, amount, source); // this is not applicable since its not a playr for sure //if (entity instanceof ServerPlayerEntity && PLAYER_TAKES_DAMAGE.isNeeded()) //{ @@ -59,13 +58,13 @@ private void entityTakingDamage(DamageSource source, float amount, CallbackInfo } @Override - public void doJumpCM() + public void carpet$doJump() { jumpFromGround(); } @Override - public boolean isJumpingCM() + public boolean carpet$isJumping() { return jumping; } diff --git a/src/main/java/carpet/mixins/MinecraftMixin.java b/src/main/java/carpet/mixins/MinecraftMixin.java index c7105a35f1..54afe7b6dc 100644 --- a/src/main/java/carpet/mixins/MinecraftMixin.java +++ b/src/main/java/carpet/mixins/MinecraftMixin.java @@ -1,6 +1,5 @@ package carpet.mixins; -import carpet.fakes.LevelInterface; import carpet.helpers.TickRateManager; import carpet.fakes.MinecraftInterface; import carpet.network.CarpetClient; @@ -29,18 +28,18 @@ private void onCloseGame(Screen screen, CallbackInfo ci) @Inject(at = @At("HEAD"), method = "tick") private void onClientTick(CallbackInfo info) { if (this.level != null) { - getTickRateManager().ifPresent(TickRateManager::tick); + carpet$getTickRateManager().ifPresent(TickRateManager::tick); // hope server doesn't need to tick - should be handled by the server on its own - if (!getTickRateManager().map(TickRateManager::runsNormally).orElse(true)) + if (!carpet$getTickRateManager().map(TickRateManager::runsNormally).orElse(true)) CarpetClient.shapes.renewShapes(); } } @Override - public Optional getTickRateManager() + public Optional carpet$getTickRateManager() { if (this.level != null) { - return Optional.of(((LevelInterface)this.level).tickRateManager()); + return Optional.of(this.level.carpet$getTickRateManager()); } return Optional.empty(); } diff --git a/src/main/java/carpet/mixins/MinecraftServer_scarpetMixin.java b/src/main/java/carpet/mixins/MinecraftServer_scarpetMixin.java index 1dcbfffd75..df8f4e6b80 100644 --- a/src/main/java/carpet/mixins/MinecraftServer_scarpetMixin.java +++ b/src/main/java/carpet/mixins/MinecraftServer_scarpetMixin.java @@ -63,7 +63,7 @@ public MinecraftServer_scarpetMixin(String string_1) @Shadow @Final private StructureTemplateManager structureTemplateManager; @Override - public void forceTick(BooleanSupplier isAhead) + public void carpet$forceTick(BooleanSupplier isAhead) { nextTickTime = lastOverloadWarning = Util.getMillis(); tickServer(isAhead); @@ -71,13 +71,13 @@ public void forceTick(BooleanSupplier isAhead) } @Override - public LevelStorageSource.LevelStorageAccess getCMSession() + public LevelStorageSource.LevelStorageAccess carpet$getStorageSource() { return storageSource; } @Override - public Map, ServerLevel> getCMWorlds() + public Map, ServerLevel> carpet$getLevels() { return levels; } @@ -88,7 +88,7 @@ public Map, ServerLevel> getCMWorlds() )) public void tickTasks(BooleanSupplier booleanSupplier_1, CallbackInfo ci) { - if (!getTickRateManager().runsNormally()) + if (!carpet$getTickRateManager().runsNormally()) { return; } @@ -98,7 +98,7 @@ public void tickTasks(BooleanSupplier booleanSupplier_1, CallbackInfo ci) } @Override - public void reloadAfterReload(RegistryAccess newRegs) + public void carpet$reloadAfterReload(RegistryAccess newRegs) { resources.managers().updateRegistryTags(newRegs); getPlayerList().saveAll(); @@ -108,19 +108,19 @@ public void reloadAfterReload(RegistryAccess newRegs) } @Override - public MinecraftServer.ReloadableResources getResourceManager() + public MinecraftServer.ReloadableResources carpet$getResources() { return resources; } @Override - public void addScriptServer(final CarpetScriptServer scriptServer) + public void carpet$addScriptServer(final CarpetScriptServer scriptServer) { this.scriptServer = scriptServer; } @Override - public CarpetScriptServer getScriptServer() + public CarpetScriptServer carpet$getScriptServer() { return scriptServer; } diff --git a/src/main/java/carpet/mixins/MinecraftServer_tickspeedMixin.java b/src/main/java/carpet/mixins/MinecraftServer_tickspeedMixin.java index 6daa46bb98..a99dd59154 100644 --- a/src/main/java/carpet/mixins/MinecraftServer_tickspeedMixin.java +++ b/src/main/java/carpet/mixins/MinecraftServer_tickspeedMixin.java @@ -77,7 +77,7 @@ private void onInit(CallbackInfo ci) } @Override - public ServerTickRateManager getTickRateManager() + public ServerTickRateManager carpet$getTickRateManager() { return serverTickRateManager; } diff --git a/src/main/java/carpet/mixins/Minecraft_pausedShakeMixin.java b/src/main/java/carpet/mixins/Minecraft_pausedShakeMixin.java index 1ba011463d..e037698af6 100644 --- a/src/main/java/carpet/mixins/Minecraft_pausedShakeMixin.java +++ b/src/main/java/carpet/mixins/Minecraft_pausedShakeMixin.java @@ -1,17 +1,17 @@ package carpet.mixins; -import carpet.fakes.MinecraftClientInferface; +import carpet.fakes.MinecraftInterface; import net.minecraft.client.Minecraft; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @Mixin(Minecraft.class) -public class Minecraft_pausedShakeMixin implements MinecraftClientInferface +public class Minecraft_pausedShakeMixin implements MinecraftInterface { @Shadow private float pausePartialTick; @Override - public float getPausedTickDelta() + public float carpet$getPausePartialTick() { return pausePartialTick; } diff --git a/src/main/java/carpet/mixins/MobCategory_spawnMixin.java b/src/main/java/carpet/mixins/MobCategory_spawnMixin.java index dcbf87c9aa..6d158d5f4d 100644 --- a/src/main/java/carpet/mixins/MobCategory_spawnMixin.java +++ b/src/main/java/carpet/mixins/MobCategory_spawnMixin.java @@ -1,6 +1,6 @@ package carpet.mixins; -import carpet.fakes.SpawnGroupInterface; +import carpet.fakes.MobCategoryInterface; import carpet.utils.SpawnReporter; import net.minecraft.world.entity.MobCategory; import org.spongepowered.asm.mixin.Final; @@ -11,7 +11,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(MobCategory.class) -public class MobCategory_spawnMixin implements SpawnGroupInterface +public class MobCategory_spawnMixin implements MobCategoryInterface { @Shadow @Final private int max; @@ -22,7 +22,7 @@ private void getModifiedCapacity(CallbackInfoReturnable cir) } @Override - public int getInitialSpawnCap() + public int carpet$getInitialSpawnCap() { return max; } diff --git a/src/main/java/carpet/mixins/MobMixin.java b/src/main/java/carpet/mixins/MobMixin.java index bd6b217eaa..1a51d3c9af 100644 --- a/src/main/java/carpet/mixins/MobMixin.java +++ b/src/main/java/carpet/mixins/MobMixin.java @@ -1,6 +1,6 @@ package carpet.mixins; -import carpet.fakes.MobEntityInterface; +import carpet.fakes.MobInterface; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -12,7 +12,7 @@ import net.minecraft.world.entity.ai.goal.GoalSelector; @Mixin(Mob.class) -public abstract class MobMixin implements MobEntityInterface +public abstract class MobMixin implements MobInterface { @Shadow @Final protected GoalSelector targetSelector; @Shadow @Final protected GoalSelector goalSelector; @@ -20,19 +20,19 @@ public abstract class MobMixin implements MobEntityInterface public final Map temporaryTasks = new HashMap<>(); @Override - public GoalSelector getAI(boolean target) + public GoalSelector carpet$getAi(boolean target) { return target?targetSelector:goalSelector; } @Override - public Map getTemporaryTasks() + public Map carpet$getTemporaryTasks() { return temporaryTasks; } @Override - public void setPersistence(boolean what) + public void carpet$setPersistence(boolean what) { persistenceRequired = what; } diff --git a/src/main/java/carpet/mixins/NaturalSpawnerMixin.java b/src/main/java/carpet/mixins/NaturalSpawnerMixin.java index fc470860dc..d71d8c8052 100644 --- a/src/main/java/carpet/mixins/NaturalSpawnerMixin.java +++ b/src/main/java/carpet/mixins/NaturalSpawnerMixin.java @@ -1,7 +1,6 @@ package carpet.mixins; import carpet.CarpetSettings; -import carpet.fakes.LevelInterface; import carpet.utils.SpawnReporter; import org.apache.commons.lang3.tuple.Pair; import org.spongepowered.asm.mixin.Final; @@ -135,31 +134,31 @@ private static boolean doesNotCollide(ServerLevel world, AABB bb) value = "INVOKE", target = "Lnet/minecraft/world/entity/EntityType;create(Lnet/minecraft/world/level/Level;)Lnet/minecraft/world/entity/Entity;" )) - private static Entity create(EntityType entityType, Level world_1) + private static Entity create(EntityType entityType, Level level) { if (CarpetSettings.lagFreeSpawning) { - Map, Entity> precookedMobs = ((LevelInterface)world_1).getPrecookedMobs(); + Map, Entity> precookedMobs = level.carpet$getPrecookedMobs(); if (precookedMobs.containsKey(entityType)) //this mob has been 's but not used yet return precookedMobs.get(entityType); - Entity e = entityType.create(world_1); + Entity e = entityType.create(level); precookedMobs.put(entityType, e); return e; } - return entityType.create(world_1); + return entityType.create(level); } @Redirect(method = "spawnCategoryForPosition(Lnet/minecraft/world/entity/MobCategory;Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/level/chunk/ChunkAccess;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/NaturalSpawner$SpawnPredicate;Lnet/minecraft/world/level/NaturalSpawner$AfterSpawnCallback;)V", at = @At( value = "INVOKE", target = "Lnet/minecraft/server/level/ServerLevel;addFreshEntityWithPassengers(Lnet/minecraft/world/entity/Entity;)V" )) - private static void spawnEntity(ServerLevel world, Entity entity_1, + private static void spawnEntity(ServerLevel level, Entity entity_1, MobCategory group, ServerLevel world2, ChunkAccess chunk, BlockPos pos, NaturalSpawner.SpawnPredicate checker, NaturalSpawner.AfterSpawnCallback runner) { if (CarpetSettings.lagFreeSpawning) // we used the mob - next time we will create a new one when needed - ((LevelInterface) world).getPrecookedMobs().remove(entity_1.getType()); + level.carpet$getPrecookedMobs().remove(entity_1.getType()); if (SpawnReporter.trackingSpawns() && SpawnReporter.local_spawns != null) { @@ -170,7 +169,7 @@ private static void spawnEntity(ServerLevel world, Entity entity_1, entity_1.blockPosition()); } if (!SpawnReporter.mockSpawns) - world.addFreshEntityWithPassengers(entity_1); + level.addFreshEntityWithPassengers(entity_1); //world.spawnEntity(entity_1); } diff --git a/src/main/java/carpet/mixins/PistonBaseBlock_movableBEMixin.java b/src/main/java/carpet/mixins/PistonBaseBlock_movableBEMixin.java index 4aef5956b6..46fe200c7e 100644 --- a/src/main/java/carpet/mixins/PistonBaseBlock_movableBEMixin.java +++ b/src/main/java/carpet/mixins/PistonBaseBlock_movableBEMixin.java @@ -1,7 +1,6 @@ package carpet.mixins; import carpet.CarpetSettings; -import carpet.fakes.PistonBlockEntityInterface; import com.google.common.collect.Lists; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; @@ -13,6 +12,7 @@ import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.piston.MovingPistonBlock; import net.minecraft.world.level.block.piston.PistonBaseBlock; +import net.minecraft.world.level.block.piston.PistonMovingBlockEntity; import net.minecraft.world.level.block.piston.PistonStructureResolver; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.PushReaction; @@ -114,10 +114,10 @@ private void setBlockEntityWithCarried(Level world_1, BlockPos blockPos_1, Direc List list_2, List list_3, BlockState[] blockStates_1, Direction direction_2, int int_2, int int_3, BlockPos blockPos_4, BlockState blockState9, BlockState blockState4) { - BlockEntity blockEntityPiston = MovingPistonBlock.newMovingBlockEntity(blockPos_4, blockState4, list_2.get(int_3), - direction_1, boolean_1, false); + PistonMovingBlockEntity blockEntityPiston = (PistonMovingBlockEntity)MovingPistonBlock.newMovingBlockEntity( + blockPos_4, blockState4, list_2.get(int_3), direction_1, boolean_1, false); if (CarpetSettings.movableBlockEntities) - ((PistonBlockEntityInterface) blockEntityPiston).setCarriedBlockEntity(list1_BlockEntities.get().get(int_3)); + blockEntityPiston.carpet$setCarriedBlockEntity(list1_BlockEntities.get().get(int_3)); world_1.setBlockEntity(blockEntityPiston); //world_1.setBlockEntity(blockPos_4, blockEntityPiston); } diff --git a/src/main/java/carpet/mixins/PistonBaseBlock_rotatorBlockMixin.java b/src/main/java/carpet/mixins/PistonBaseBlock_rotatorBlockMixin.java index 225a7eb44c..bf5a637b51 100644 --- a/src/main/java/carpet/mixins/PistonBaseBlock_rotatorBlockMixin.java +++ b/src/main/java/carpet/mixins/PistonBaseBlock_rotatorBlockMixin.java @@ -1,6 +1,6 @@ package carpet.mixins; -import carpet.fakes.PistonBlockInterface; +import carpet.fakes.PistonBaseBlockInterface; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.world.level.Level; @@ -10,13 +10,13 @@ import org.spongepowered.asm.mixin.Shadow; @Mixin(PistonBaseBlock.class) -public abstract class PistonBaseBlock_rotatorBlockMixin implements PistonBlockInterface +public abstract class PistonBaseBlock_rotatorBlockMixin implements PistonBaseBlockInterface { - @Shadow protected abstract boolean getNeighborSignal(SignalGetter world_1, BlockPos blockPos_1, Direction direction_1); + @Shadow protected abstract boolean getNeighborSignal(SignalGetter level, BlockPos pos, Direction facing); @Override - public boolean publicShouldExtend(Level world_1, BlockPos blockPos_1, Direction direction_1) + public boolean carpet$getNeighborSignal(Level level, BlockPos pos, Direction facing) { - return getNeighborSignal(world_1, blockPos_1,direction_1); + return getNeighborSignal(level, pos, facing); } } diff --git a/src/main/java/carpet/mixins/PistonHeadRenderer_movableBEMixin.java b/src/main/java/carpet/mixins/PistonHeadRenderer_movableBEMixin.java index 87df4e3485..35d2fb48bd 100644 --- a/src/main/java/carpet/mixins/PistonHeadRenderer_movableBEMixin.java +++ b/src/main/java/carpet/mixins/PistonHeadRenderer_movableBEMixin.java @@ -1,7 +1,6 @@ package carpet.mixins; import carpet.CarpetSettings; -import carpet.fakes.PistonBlockEntityInterface; import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; @@ -31,17 +30,17 @@ private void onInitCM(BlockEntityRendererProvider.Context arguments, CallbackInf private void updateRenderBool(PistonMovingBlockEntity pistonBlockEntity_1, float float_1, PoseStack matrixStack_1, MultiBufferSource layeredVertexConsumerStorage_1, int int_1, int int_2, CallbackInfo ci) //private void updateRenderBool(PistonBlockEntity pistonBlockEntity_1, double double_1, double double_2, double double_3, float float_1, class_4587 class_4587_1, class_4597 class_4597_1, int int_1, CallbackInfo ci) { - if (!((PistonBlockEntityInterface) pistonBlockEntity_1).isRenderModeSet()) - ((PistonBlockEntityInterface) pistonBlockEntity_1).setRenderCarriedBlockEntity(CarpetSettings.movableBlockEntities && ((PistonBlockEntityInterface) pistonBlockEntity_1).getCarriedBlockEntity() != null); + if (!pistonBlockEntity_1.carpet$isRenderModeSet()) + pistonBlockEntity_1.carpet$setRenderCarriedBlockEntity(CarpetSettings.movableBlockEntities && pistonBlockEntity_1.carpet$getCarriedBlockEntity() != null); } @Inject(method = "render", at = @At("RETURN"), locals = LocalCapture.NO_CAPTURE) private void endMethod3576(PistonMovingBlockEntity pistonBlockEntity_1, float partialTicks, PoseStack matrixStack_1, MultiBufferSource layeredVertexConsumerStorage_1, int int_1, int init_2, CallbackInfo ci) { - if (((PistonBlockEntityInterface) pistonBlockEntity_1).getRenderCarriedBlockEntity()) + if (pistonBlockEntity_1.carpet$getRenderCarriedBlockEntity()) { - BlockEntity carriedBlockEntity = ((PistonBlockEntityInterface) pistonBlockEntity_1).getCarriedBlockEntity(); + BlockEntity carriedBlockEntity = pistonBlockEntity_1.carpet$getCarriedBlockEntity(); if (carriedBlockEntity != null) { // maybe ??? carriedBlockEntity.setPos(pistonBlockEntity_1.getPos()); diff --git a/src/main/java/carpet/mixins/PistonMovingBlockEntity_movableBEMixin.java b/src/main/java/carpet/mixins/PistonMovingBlockEntity_movableBEMixin.java index 9fee32a5cc..638621cbe1 100644 --- a/src/main/java/carpet/mixins/PistonMovingBlockEntity_movableBEMixin.java +++ b/src/main/java/carpet/mixins/PistonMovingBlockEntity_movableBEMixin.java @@ -1,9 +1,7 @@ package carpet.mixins; import carpet.CarpetSettings; -import carpet.fakes.BlockEntityInterface; -import carpet.fakes.PistonBlockEntityInterface; -import carpet.fakes.LevelInterface; +import carpet.fakes.PistonMovingBlockEntityInterface; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.level.Level; @@ -22,7 +20,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(PistonMovingBlockEntity.class) -public abstract class PistonMovingBlockEntity_movableBEMixin extends BlockEntity implements PistonBlockEntityInterface +public abstract class PistonMovingBlockEntity_movableBEMixin extends BlockEntity implements PistonMovingBlockEntityInterface { @Shadow private boolean isSourcePiston; @@ -41,7 +39,7 @@ public PistonMovingBlockEntity_movableBEMixin(BlockEntityType blockEntityType /** * @author 2No2Name */ - public BlockEntity getCarriedBlockEntity() + public BlockEntity carpet$getCarriedBlockEntity() { return carriedBlockEntity; } @@ -52,29 +50,29 @@ public void setLevel(Level world) { if (carriedBlockEntity != null) carriedBlockEntity.setLevel(world); } - public void setCarriedBlockEntity(BlockEntity blockEntity) + public void carpet$setCarriedBlockEntity(BlockEntity blockEntity) { this.carriedBlockEntity = blockEntity; if (this.carriedBlockEntity != null) { - ((BlockEntityInterface)carriedBlockEntity).setCMPos(worldPosition); + carriedBlockEntity.carpet$setPos(worldPosition); // this might be little dangerous since pos is final for a hashing reason? if (level != null) carriedBlockEntity.setLevel(level); } // this.carriedBlockEntity.setPos(this.pos); } - public boolean isRenderModeSet() + public boolean carpet$isRenderModeSet() { return renderSet; } - public boolean getRenderCarriedBlockEntity() + public boolean carpet$getRenderCarriedBlockEntity() { return renderCarriedBlockEntity; } - public void setRenderCarriedBlockEntity(boolean b) + public void carpet$setRenderCarriedBlockEntity(boolean b) { renderCarriedBlockEntity = b; renderSet = true; @@ -86,24 +84,24 @@ public void setRenderCarriedBlockEntity(boolean b) @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;setBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;I)Z")) private static boolean movableTEsetBlockState0( - Level world, BlockPos blockPos_1, BlockState blockAState_2, int int_1, + Level level, BlockPos blockPos_1, BlockState blockAState_2, int int_1, Level world2, BlockPos blockPos, BlockState blockState, PistonMovingBlockEntity pistonBlockEntity) { if (!CarpetSettings.movableBlockEntities) - return world.setBlock(blockPos_1, blockAState_2, int_1); + return level.setBlock(blockPos_1, blockAState_2, int_1); else - return ((LevelInterface) (world)).setBlockStateWithBlockEntity(blockPos_1, blockAState_2, ((PistonBlockEntityInterface)pistonBlockEntity).getCarriedBlockEntity(), int_1); + return level.carpet$setBlockStateWithBlockEntity(blockPos_1, blockAState_2, pistonBlockEntity.carpet$getCarriedBlockEntity(), int_1); } @Redirect(method = "finalTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;setBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;I)Z")) - private boolean movableTEsetBlockState1(Level world, BlockPos blockPos_1, BlockState blockState_2, int int_1) + private boolean movableTEsetBlockState1(Level level, BlockPos blockPos_1, BlockState blockState_2, int int_1) { if (!CarpetSettings.movableBlockEntities) - return world.setBlock(blockPos_1, blockState_2, int_1); + return level.setBlock(blockPos_1, blockState_2, int_1); else { - boolean ret = ((LevelInterface) (world)).setBlockStateWithBlockEntity(blockPos_1, blockState_2, this.carriedBlockEntity, int_1); + boolean ret = level.carpet$setBlockStateWithBlockEntity(blockPos_1, blockState_2, this.carriedBlockEntity, int_1); this.carriedBlockEntity = null; //this will cancel the finishHandleBroken return ret; } @@ -122,7 +120,7 @@ private void finishHandleBroken(CallbackInfo cir) blockState_2 = Blocks.AIR.defaultBlockState(); else blockState_2 = Block.updateFromNeighbourShapes(this.movedState, this.level, this.worldPosition); - ((LevelInterface) (this.level)).setBlockStateWithBlockEntity(this.worldPosition, blockState_2, this.carriedBlockEntity, 3); + this.level.carpet$setBlockStateWithBlockEntity(this.worldPosition, blockState_2, this.carriedBlockEntity, 3); this.level.destroyBlock(this.worldPosition, false, null); } } @@ -136,7 +134,7 @@ private void onFromTag(CompoundTag NbtCompound_1, CallbackInfo ci) this.carriedBlockEntity = ((EntityBlock) (this.movedState.getBlock())).newBlockEntity(worldPosition, movedState);// this.world); if (carriedBlockEntity != null) //Can actually be null, as BlockPistonMoving.createNewTileEntity(...) returns null this.carriedBlockEntity.load(NbtCompound_1.getCompound("carriedTileEntityCM")); - setCarriedBlockEntity(carriedBlockEntity); + carpet$setCarriedBlockEntity(carriedBlockEntity); } } diff --git a/src/main/java/carpet/mixins/PistonStructureResolver_customStickyMixin.java b/src/main/java/carpet/mixins/PistonStructureResolver_customStickyMixin.java index 88ab4fd8f1..578bd53e7b 100644 --- a/src/main/java/carpet/mixins/PistonStructureResolver_customStickyMixin.java +++ b/src/main/java/carpet/mixins/PistonStructureResolver_customStickyMixin.java @@ -37,7 +37,7 @@ public class PistonStructureResolver_customStickyMixin { ) private static void isSticky(BlockState state, CallbackInfoReturnable cir) { if (state.getBlock() instanceof BlockPistonBehaviourInterface behaviourInterface){ - cir.setReturnValue(behaviourInterface.isSticky(state)); + cir.setReturnValue(behaviourInterface.carpet$isSticky(state)); } } @@ -68,7 +68,7 @@ private void captureBlockLinePositions(BlockPos pos, Direction fromDir, Callback ) private boolean onAddBlockLineCanStickToEachOther(BlockState state, BlockState behindState) { if (state.getBlock() instanceof BlockPistonBehaviourInterface behaviourInterface) { - return behaviourInterface.isStickyToNeighbor(level, pos_addBlockLine, state, behindPos_addBlockLine, behindState, pushDirection.getOpposite(), pushDirection); + return behaviourInterface.carpet$isStickyToNeighbor(level, pos_addBlockLine, state, behindPos_addBlockLine, behindState, pushDirection.getOpposite(), pushDirection); } return canStickToEachOther(state, behindState); @@ -101,7 +101,7 @@ private void captureNeighborPositions(BlockPos pos, CallbackInfoReturnable cir) { - ((ServerPlayerInterface)player).invalidateEntityObjectReference(); + player.carpet$invalidateEntityObjectReference(); } @Inject(method = "reloadResources", at = @At("HEAD")) diff --git a/src/main/java/carpet/mixins/PlayerTabOverlayMixin.java b/src/main/java/carpet/mixins/PlayerTabOverlayMixin.java index 7fe502033a..ebc72ab987 100644 --- a/src/main/java/carpet/mixins/PlayerTabOverlayMixin.java +++ b/src/main/java/carpet/mixins/PlayerTabOverlayMixin.java @@ -1,19 +1,19 @@ package carpet.mixins; -import carpet.fakes.PlayerListHudInterface; +import carpet.fakes.PlayerTabOverlayInterface; import net.minecraft.client.gui.components.PlayerTabOverlay; import net.minecraft.network.chat.Component; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @Mixin(PlayerTabOverlay.class) -public abstract class PlayerTabOverlayMixin implements PlayerListHudInterface +public abstract class PlayerTabOverlayMixin implements PlayerTabOverlayInterface { @Shadow private Component footer; @Shadow private Component header; @Override - public boolean hasFooterOrHeader() + public boolean carpet$hasFooterOrHeader() { return footer != null || header != null; } diff --git a/src/main/java/carpet/mixins/Player_scarpetEventsMixin.java b/src/main/java/carpet/mixins/Player_scarpetEventsMixin.java index 31720265f6..28a0f27d57 100644 --- a/src/main/java/carpet/mixins/Player_scarpetEventsMixin.java +++ b/src/main/java/carpet/mixins/Player_scarpetEventsMixin.java @@ -1,6 +1,5 @@ package carpet.mixins; -import carpet.fakes.EntityInterface; import carpet.script.EntityEventsGroup; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.InteractionHand; @@ -39,7 +38,7 @@ protected Player_scarpetEventsMixin(EntityType type, Lev private void playerTakingDamage(DamageSource source, float amount, CallbackInfo ci) { // version of LivingEntity_scarpetEventsMixin::entityTakingDamage - ((EntityInterface)this).getEventContainer().onEvent(EntityEventsGroup.Event.ON_DAMAGE, amount, source); + carpet$getEventContainer().onEvent(EntityEventsGroup.Event.ON_DAMAGE, amount, source); if (PLAYER_TAKES_DAMAGE.isNeeded()) { if(PLAYER_TAKES_DAMAGE.onDamage(this, amount, source)) { diff --git a/src/main/java/carpet/mixins/PrimedTntMixin.java b/src/main/java/carpet/mixins/PrimedTntMixin.java index 82c085745c..1d099ccbdc 100644 --- a/src/main/java/carpet/mixins/PrimedTntMixin.java +++ b/src/main/java/carpet/mixins/PrimedTntMixin.java @@ -1,6 +1,6 @@ package carpet.mixins; -import carpet.fakes.TntEntityInterface; +import carpet.fakes.PrimedTntInterface; import carpet.CarpetSettings; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -13,12 +13,11 @@ import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.item.PrimedTnt; -import net.minecraft.world.level.Explosion; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; @Mixin(PrimedTnt.class) -public abstract class PrimedTntMixin extends Entity implements TntEntityInterface +public abstract class PrimedTntMixin extends Entity implements PrimedTntInterface { @Shadow public abstract int getFuse(); @@ -99,7 +98,7 @@ private void tryMergeTnt(CallbackInfo ci) if(tntVelocity.x == 0 && tntVelocity.y == 0 && tntVelocity.z == 0 && this.getX() == entityTNTPrimed.getX() && this.getZ() == entityTNTPrimed.getZ() && this.getY() == entityTNTPrimed.getY() && getFuse() == entityTNTPrimed.getFuse()){ - mergedTNT += ((TntEntityInterface) entityTNTPrimed).getMergedTNT(); + mergedTNT += entityTNTPrimed.carpet$getMergedTnt(); entityTNTPrimed.discard(); // discard remove(); } } @@ -119,7 +118,7 @@ private void setMergeable(CallbackInfo ci) } @Override - public int getMergedTNT() { + public int carpet$getMergedTnt() { return mergedTNT; } } \ No newline at end of file diff --git a/src/main/java/carpet/mixins/PrimedTnt_scarpetEventsMixin.java b/src/main/java/carpet/mixins/PrimedTnt_scarpetEventsMixin.java index 591f8d9f04..d9a2836d47 100644 --- a/src/main/java/carpet/mixins/PrimedTnt_scarpetEventsMixin.java +++ b/src/main/java/carpet/mixins/PrimedTnt_scarpetEventsMixin.java @@ -1,6 +1,5 @@ package carpet.mixins; -import carpet.fakes.EntityInterface; import carpet.script.EntityEventsGroup; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; @@ -23,6 +22,6 @@ public PrimedTnt_scarpetEventsMixin(EntityType type, Level world) private void onTickCall(CallbackInfo ci) { // calling extra on_tick because falling blocks do not fall back to super tick call - ((EntityInterface)this).getEventContainer().onEvent(EntityEventsGroup.Event.ON_TICK); + carpet$getEventContainer().onEvent(EntityEventsGroup.Event.ON_TICK); } } \ No newline at end of file diff --git a/src/main/java/carpet/mixins/RandomState_ScarpetMixin.java b/src/main/java/carpet/mixins/RandomState_ScarpetMixin.java index 2e855238ac..0d9d4d6e33 100644 --- a/src/main/java/carpet/mixins/RandomState_ScarpetMixin.java +++ b/src/main/java/carpet/mixins/RandomState_ScarpetMixin.java @@ -1,6 +1,6 @@ package carpet.mixins; -import carpet.fakes.RandomStateVisitorAccessor; +import carpet.fakes.RandomStateInterface; import net.minecraft.world.level.levelgen.DensityFunction; import net.minecraft.world.level.levelgen.RandomState; import org.spongepowered.asm.mixin.Mixin; @@ -9,7 +9,7 @@ import org.spongepowered.asm.mixin.injection.ModifyArg; @Mixin(RandomState.class) -public class RandomState_ScarpetMixin implements RandomStateVisitorAccessor { +public class RandomState_ScarpetMixin implements RandomStateInterface { @Unique private DensityFunction.Visitor visitor; @@ -27,7 +27,7 @@ private DensityFunction.Visitor captureVisitor(DensityFunction.Visitor visitor) } @Override - public DensityFunction.Visitor getVisitor() { + public DensityFunction.Visitor carpet$getVisitor() { return this.visitor; } } diff --git a/src/main/java/carpet/mixins/RecipeBookMenu_scarpetMixin.java b/src/main/java/carpet/mixins/RecipeBookMenu_scarpetMixin.java index c13ba04724..9bb72d9965 100644 --- a/src/main/java/carpet/mixins/RecipeBookMenu_scarpetMixin.java +++ b/src/main/java/carpet/mixins/RecipeBookMenu_scarpetMixin.java @@ -1,7 +1,8 @@ package carpet.mixins; -import carpet.fakes.AbstractContainerMenuInterface; import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.inventory.MenuType; import net.minecraft.world.inventory.RecipeBookMenu; import net.minecraft.world.item.crafting.Recipe; import org.spongepowered.asm.mixin.Mixin; @@ -10,10 +11,17 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(RecipeBookMenu.class) -public class RecipeBookMenu_scarpetMixin { +public abstract class RecipeBookMenu_scarpetMixin extends AbstractContainerMenu +{ + private RecipeBookMenu_scarpetMixin(MenuType type, int syncId) + { + super(type, syncId); + } + @Inject(method = "handlePlacement",at = @At("HEAD"), cancellable = true) - private void selectRecipeCallback(boolean craftAll, Recipe recipe, ServerPlayer player, CallbackInfo ci) { - if(((AbstractContainerMenuInterface) this).callSelectRecipeListener(player,recipe,craftAll)) + private void selectRecipeCallback(boolean craftAll, Recipe recipe, ServerPlayer player, CallbackInfo ci) + { + if(carpet$notifySelectRecipeListeners(player,recipe,craftAll)) ci.cancel(); } } diff --git a/src/main/java/carpet/mixins/RecipeManager_scarpetMixin.java b/src/main/java/carpet/mixins/RecipeManager_scarpetMixin.java index 217e8aef11..cdf2d8e60b 100644 --- a/src/main/java/carpet/mixins/RecipeManager_scarpetMixin.java +++ b/src/main/java/carpet/mixins/RecipeManager_scarpetMixin.java @@ -26,7 +26,7 @@ public class RecipeManager_scarpetMixin implements RecipeManagerInterface @Shadow private Map, Map>> recipes; @Override - public List> getAllMatching(RecipeType type, ResourceLocation output, final RegistryAccess registryAccess) + public List> carpet$getAllMatching(RecipeType type, ResourceLocation output, final RegistryAccess registryAccess) { Map> typeRecipes = recipes.get(type); // happens when mods add recipe to the registry without updating recipe manager diff --git a/src/main/java/carpet/mixins/RedstoneWireBlock_fastMixin.java b/src/main/java/carpet/mixins/RedstoneWireBlock_fastMixin.java index 0ac25bd107..5c015ed7c5 100644 --- a/src/main/java/carpet/mixins/RedstoneWireBlock_fastMixin.java +++ b/src/main/java/carpet/mixins/RedstoneWireBlock_fastMixin.java @@ -1,7 +1,7 @@ package carpet.mixins; import carpet.CarpetSettings; -import carpet.fakes.RedstoneWireBlockInterface; +import carpet.fakes.RedStoneWireBlockInterface; import carpet.helpers.RedstoneWireTurbo; import com.google.common.collect.Sets; import org.spongepowered.asm.mixin.Mixin; @@ -24,21 +24,21 @@ import static net.minecraft.world.level.block.RedStoneWireBlock.POWER; @Mixin(RedStoneWireBlock.class) -public abstract class RedstoneWireBlock_fastMixin implements RedstoneWireBlockInterface { +public abstract class RedstoneWireBlock_fastMixin implements RedStoneWireBlockInterface { @Shadow - private void updatePowerStrength(Level world_1, BlockPos blockPos_1, BlockState blockState_1) { } + private void updatePowerStrength(Level level, BlockPos pos, BlockState state) { } @Shadow private int calculateTargetStrength(Level world, BlockPos pos) { return 0; } @Override @Accessor("shouldSignal") - public abstract void setWiresGivePower(boolean wiresGivePower); + public abstract void carpet$setShouldSignal(boolean shouldSignal); @Override @Accessor("shouldSignal") - public abstract boolean getWiresGivePower(); + public abstract boolean carpet$getShouldSignal(); // = @@ -52,56 +52,56 @@ private void onRedstoneWireBlockCTOR(BlockBehaviour.Properties settings, Callbac // = - public void fastUpdate(Level world, BlockPos pos, BlockState state, BlockPos source) { + public void fastUpdate(Level level, BlockPos pos, BlockState state, BlockPos source) { // [CM] fastRedstoneDust -- update based on carpet rule if (CarpetSettings.fastRedstoneDust) { - wireTurbo.updateSurroundingRedstone(world, pos, state, source); + wireTurbo.updateSurroundingRedstone(level, pos, state, source); return; } - updatePowerStrength(world, pos, state); + updatePowerStrength(level, pos, state); } /** * @author theosib, soykaf, gnembon */ @Inject(method = "updatePowerStrength", at = @At("HEAD"), cancellable = true) - private void updateLogicAlternative(Level world, BlockPos pos, BlockState state, CallbackInfo cir) { + private void updateLogicAlternative(Level level, BlockPos pos, BlockState state, CallbackInfo cir) { if (CarpetSettings.fastRedstoneDust) { - updateLogicPublic(world, pos, state); + carpet$updateLogicPublic(level, pos, state); cir.cancel(); } } @Override - public BlockState updateLogicPublic(Level world_1, BlockPos blockPos_1, BlockState blockState_1) { - int i = this.calculateTargetStrength(world_1, blockPos_1); - BlockState blockState = blockState_1; - if (blockState_1.getValue(POWER) != i) { - blockState_1 = blockState_1.setValue(POWER, i); - if (world_1.getBlockState(blockPos_1) == blockState) { + public BlockState carpet$updateLogicPublic(Level level, BlockPos pos, BlockState state) { + int i = this.calculateTargetStrength(level, pos); + BlockState prevState = state; + if (state.getValue(POWER) != i) { + state = state.setValue(POWER, i); + if (level.getBlockState(pos) == prevState) { // [Space Walker] suppress shape updates and emit those manually to // bypass the new neighbor update stack. - if (world_1.setBlock(blockPos_1, blockState_1, Block.UPDATE_KNOWN_SHAPE | Block.UPDATE_CLIENTS)) - wireTurbo.updateNeighborShapes(world_1, blockPos_1, blockState_1); + if (level.setBlock(pos, state, Block.UPDATE_KNOWN_SHAPE | Block.UPDATE_CLIENTS)) + wireTurbo.updateNeighborShapes(level, pos, state); } if (!CarpetSettings.fastRedstoneDust) { Set set = Sets.newHashSet(); - set.add(blockPos_1); + set.add(pos); Direction[] var6 = Direction.values(); int var7 = var6.length; for (int var8 = 0; var8 < var7; ++var8) { Direction direction = var6[var8]; - set.add(blockPos_1.relative(direction)); + set.add(pos.relative(direction)); } for (BlockPos blockPos : set) { - world_1.updateNeighborsAt(blockPos, blockState_1.getBlock()); + level.updateNeighborsAt(blockPos, state.getBlock()); } } } - return blockState_1; + return state; } // = diff --git a/src/main/java/carpet/mixins/ServerChunkCache_tickMixin.java b/src/main/java/carpet/mixins/ServerChunkCache_tickMixin.java index 34d69c3eb6..a190f1931b 100644 --- a/src/main/java/carpet/mixins/ServerChunkCache_tickMixin.java +++ b/src/main/java/carpet/mixins/ServerChunkCache_tickMixin.java @@ -1,7 +1,5 @@ package carpet.mixins; -import carpet.fakes.MinecraftServerInterface; -import carpet.fakes.ThreadedAnvilChunkStorageInterface; import carpet.helpers.ServerTickRateManager; import carpet.utils.CarpetProfiler; import net.minecraft.server.level.DistanceManager; @@ -77,15 +75,15 @@ private void stopSpawningSection(CallbackInfo ci) value = "INVOKE", target = "Lnet/minecraft/server/level/ServerLevel;isDebug()Z" )) - private boolean skipChunkTicking(ServerLevel serverWorld) + private boolean skipChunkTicking(ServerLevel level) { - boolean debug = serverWorld.isDebug(); - if (!((MinecraftServerInterface)serverWorld.getServer()).getTickRateManager().runsNormally()) + boolean debug = level.isDebug(); + if (!level.getServer().carpet$getTickRateManager().runsNormally()) { // simplified chunk tick iteration assuming world is frozen otherwise as suggested by Hadron67 // to be kept in sync with the original injection source if (!debug){ - List holders = Lists.newArrayList(((ThreadedAnvilChunkStorageInterface)chunkMap).getChunksCM()); + List holders = Lists.newArrayList(chunkMap.carpet$getChunks()); Collections.shuffle(holders); for (ChunkHolder holder: holders){ Optional optional = holder.getTickingChunkFuture().getNow(ChunkHolder.UNLOADED_LEVEL_CHUNK).left(); @@ -107,7 +105,7 @@ private void pauseTicketSystem(DistanceManager distanceManager) { // pausing expiry of tickets // that will prevent also chunks from unloading, so require a deep frozen state - ServerTickRateManager trm = ((MinecraftServerInterface) level.getServer()).getTickRateManager(); + ServerTickRateManager trm = level.getServer().carpet$getTickRateManager(); if (!trm.runsNormally() && trm.deeplyFrozen()) return; distanceManager.purgeStaleTickets(); } diff --git a/src/main/java/carpet/mixins/ServerFunctionManager_tickMixin.java b/src/main/java/carpet/mixins/ServerFunctionManager_tickMixin.java index 471525435b..5a661c39e8 100644 --- a/src/main/java/carpet/mixins/ServerFunctionManager_tickMixin.java +++ b/src/main/java/carpet/mixins/ServerFunctionManager_tickMixin.java @@ -1,6 +1,5 @@ package carpet.mixins; -import carpet.fakes.MinecraftServerInterface; import carpet.utils.CarpetProfiler; import net.minecraft.server.MinecraftServer; import net.minecraft.server.ServerFunctionManager; @@ -20,7 +19,7 @@ public class ServerFunctionManager_tickMixin @Inject(method = "tick", at = @At("HEAD"), cancellable = true) private void beforeDatapacks(CallbackInfo ci) { - if (! ((MinecraftServerInterface)server).getTickRateManager().runsNormally()) + if (!server.carpet$getTickRateManager().runsNormally()) { ci.cancel(); } diff --git a/src/main/java/carpet/mixins/ServerGamePacketListenerImpl_coreMixin.java b/src/main/java/carpet/mixins/ServerGamePacketListenerImpl_coreMixin.java index 3d23a71c8f..0f072e8de3 100644 --- a/src/main/java/carpet/mixins/ServerGamePacketListenerImpl_coreMixin.java +++ b/src/main/java/carpet/mixins/ServerGamePacketListenerImpl_coreMixin.java @@ -31,7 +31,7 @@ private void onPlayerDisconnect(Component reason, CallbackInfo ci) { } @Override - public Connection getConnection() { + public Connection carpet$getConnection() { return connection; } } diff --git a/src/main/java/carpet/mixins/ServerGamePacketListenerImpl_tickMixin.java b/src/main/java/carpet/mixins/ServerGamePacketListenerImpl_tickMixin.java index 7c8e131503..b9985403cd 100644 --- a/src/main/java/carpet/mixins/ServerGamePacketListenerImpl_tickMixin.java +++ b/src/main/java/carpet/mixins/ServerGamePacketListenerImpl_tickMixin.java @@ -1,6 +1,5 @@ package carpet.mixins; -import carpet.fakes.MinecraftServerInterface; import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket; import net.minecraft.network.protocol.game.ServerboundPlayerInputPacket; import net.minecraft.server.level.ServerPlayer; @@ -27,7 +26,7 @@ private void checkMoves(ServerboundPlayerInputPacket p, CallbackInfo ci) { if (p.getXxa() != 0.0F || p.getZza() != 0.0F || p.isJumping() || p.isShiftKeyDown()) { - ((MinecraftServerInterface)player.getServer()).getTickRateManager().resetPlayerActivity(); + player.getServer().carpet$getTickRateManager().resetPlayerActivity(); } } @@ -53,7 +52,7 @@ private void checkMove(ServerboundMovePlayerPacket p, CallbackInfo ci) { lastMoved = movedBy; lastMovedTick = player.getServer().getTickCount(); - ((MinecraftServerInterface)player.getServer()).getTickRateManager().resetPlayerActivity(); + player.getServer().carpet$getTickRateManager().resetPlayerActivity(); } } } diff --git a/src/main/java/carpet/mixins/ServerLevel_scarpetMixin.java b/src/main/java/carpet/mixins/ServerLevel_scarpetMixin.java index 4fb5295d44..0d13c9dffe 100644 --- a/src/main/java/carpet/mixins/ServerLevel_scarpetMixin.java +++ b/src/main/java/carpet/mixins/ServerLevel_scarpetMixin.java @@ -1,6 +1,6 @@ package carpet.mixins; -import carpet.fakes.ServerWorldInterface; +import carpet.fakes.ServerLevelInterface; import net.minecraft.core.BlockPos; import net.minecraft.core.Holder; import net.minecraft.core.RegistryAccess; @@ -39,7 +39,7 @@ import static carpet.script.CarpetEventServer.Event.CHUNK_UNLOADED; @Mixin(ServerLevel.class) -public abstract class ServerLevel_scarpetMixin extends Level implements ServerWorldInterface +public abstract class ServerLevel_scarpetMixin extends Level implements ServerLevelInterface { protected ServerLevel_scarpetMixin(WritableLevelData writableLevelData, ResourceKey resourceKey, RegistryAccess registryAccess, Holder holder, Supplier supplier, boolean bl, boolean bl2, long l, int i) { @@ -96,13 +96,13 @@ private void handleChunkUnload(LevelChunk levelChunk, CallbackInfo ci) @Unique @Override - public ServerLevelData getWorldPropertiesCM(){ + public ServerLevelData carpet$getLevelData(){ return serverLevelData; } @Unique @Override - public LevelEntityGetter getEntityLookupCMPublic() { + public LevelEntityGetter carpet$getEntityGetter() { return entityManager.getEntityGetter(); } } diff --git a/src/main/java/carpet/mixins/ServerLevel_tickMixin.java b/src/main/java/carpet/mixins/ServerLevel_tickMixin.java index 3150311a83..14a4946bf9 100644 --- a/src/main/java/carpet/mixins/ServerLevel_tickMixin.java +++ b/src/main/java/carpet/mixins/ServerLevel_tickMixin.java @@ -1,7 +1,6 @@ package carpet.mixins; import carpet.fakes.LevelInterface; -import carpet.fakes.MinecraftServerInterface; import carpet.helpers.TickRateManager; import carpet.utils.CarpetProfiler; import net.minecraft.core.Holder; @@ -33,9 +32,9 @@ protected ServerLevel_tickMixin(final WritableLevelData writableLevelData, final } @Override - public TickRateManager tickRateManager() + public TickRateManager carpet$getTickRateManager() { - return ((MinecraftServerInterface)getServer()).getTickRateManager(); + return getServer().carpet$getTickRateManager(); } @Shadow protected abstract void runBlockEvents(); @@ -167,13 +166,13 @@ private void endRandomTicks(CallbackInfo ci) { )) private void tickWorldBorder(WorldBorder worldBorder) { - if (tickRateManager().runsNormally()) worldBorder.tick(); + if (carpet$getTickRateManager().runsNormally()) worldBorder.tick(); } @Inject(method = "advanceWeatherCycle", cancellable = true, at = @At("HEAD")) private void tickWeather(CallbackInfo ci) { - if (!tickRateManager().runsNormally()) ci.cancel(); + if (!carpet$getTickRateManager().runsNormally()) ci.cancel(); } @Redirect(method = "tick", at = @At( @@ -182,7 +181,7 @@ private void tickWeather(CallbackInfo ci) )) private void tickTimeConditionally(ServerLevel serverWorld) { - if (tickRateManager().runsNormally()) tickTime(); + if (carpet$getTickRateManager().runsNormally()) tickTime(); } @Redirect(method = "tick", at = @At( @@ -191,7 +190,7 @@ private void tickTimeConditionally(ServerLevel serverWorld) )) private boolean tickPendingBlocks(ServerLevel serverWorld) { - if (!tickRateManager().runsNormally()) return true; + if (!carpet$getTickRateManager().runsNormally()) return true; return serverWorld.isDebug(); // isDebug() } @@ -201,7 +200,7 @@ private boolean tickPendingBlocks(ServerLevel serverWorld) )) private void tickConditionally(Raids raidManager) { - if (tickRateManager().runsNormally()) raidManager.tick(); + if (carpet$getTickRateManager().runsNormally()) raidManager.tick(); } @Redirect(method = "tick", at = @At( @@ -210,6 +209,6 @@ private void tickConditionally(Raids raidManager) )) private void tickConditionally(ServerLevel serverWorld) { - if (tickRateManager().runsNormally()) runBlockEvents(); + if (carpet$getTickRateManager().runsNormally()) runBlockEvents(); } } diff --git a/src/main/java/carpet/mixins/ServerPlayerGameMode_scarpetEventsMixin.java b/src/main/java/carpet/mixins/ServerPlayerGameMode_scarpetEventsMixin.java index 163d34cedb..398e535b65 100644 --- a/src/main/java/carpet/mixins/ServerPlayerGameMode_scarpetEventsMixin.java +++ b/src/main/java/carpet/mixins/ServerPlayerGameMode_scarpetEventsMixin.java @@ -1,6 +1,6 @@ package carpet.mixins; -import carpet.fakes.ServerPlayerInteractionManagerInterface; +import carpet.fakes.ServerPlayerGameModeInterface; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; @@ -24,9 +24,8 @@ import static carpet.script.CarpetEventServer.Event.PLAYER_BREAK_BLOCK; import static carpet.script.CarpetEventServer.Event.PLAYER_INTERACTS_WITH_BLOCK; - @Mixin(ServerPlayerGameMode.class) -public class ServerPlayerGameMode_scarpetEventsMixin implements ServerPlayerInteractionManagerInterface +public class ServerPlayerGameMode_scarpetEventsMixin implements ServerPlayerGameModeInterface { @Shadow public ServerPlayer player; @@ -63,21 +62,21 @@ private void onBlockActivated(ServerPlayer serverPlayerEntity, Level world, Item } @Override - public BlockPos getCurrentBreakingBlock() + public BlockPos carpet$getCurrentBreakingBlock() { if (!isDestroyingBlock) return null; return destroyPos; } @Override - public int getCurrentBlockBreakingProgress() + public int carpet$getCurrentBlockBreakingProgress() { if (!isDestroyingBlock) return -1; return lastSentState; } @Override - public void setBlockBreakingProgress(int progress) + public void carpet$setBlockBreakingProgress(int progress) { lastSentState = Mth.clamp(progress, -1, 10); level.destroyBlockProgress(-1*this.player.getId(), destroyPos, lastSentState); diff --git a/src/main/java/carpet/mixins/ServerPlayer_actionPackMixin.java b/src/main/java/carpet/mixins/ServerPlayer_actionPackMixin.java index 6eda0884df..887c9aeafb 100644 --- a/src/main/java/carpet/mixins/ServerPlayer_actionPackMixin.java +++ b/src/main/java/carpet/mixins/ServerPlayer_actionPackMixin.java @@ -18,7 +18,7 @@ public abstract class ServerPlayer_actionPackMixin implements ServerPlayerInterf @Unique public EntityPlayerActionPack actionPack; @Override - public EntityPlayerActionPack getActionPack() + public EntityPlayerActionPack carpet$getActionPack() { return actionPack; } diff --git a/src/main/java/carpet/mixins/ServerPlayer_scarpetEventMixin.java b/src/main/java/carpet/mixins/ServerPlayer_scarpetEventMixin.java index 4f41fc067f..4e3da1f14a 100644 --- a/src/main/java/carpet/mixins/ServerPlayer_scarpetEventMixin.java +++ b/src/main/java/carpet/mixins/ServerPlayer_scarpetEventMixin.java @@ -1,6 +1,5 @@ package carpet.mixins; -import carpet.fakes.EntityInterface; import carpet.fakes.ServerPlayerInterface; import carpet.script.EntityEventsGroup; import com.mojang.authlib.GameProfile; @@ -76,7 +75,7 @@ private void grabStat(Stat stat, int amount, CallbackInfo ci) @Inject(method = "die", at = @At("HEAD")) private void onDeathEvent(DamageSource source, CallbackInfo ci) { - ((EntityInterface)this).getEventContainer().onEvent(EntityEventsGroup.Event.ON_DEATH, source.getMsgId()); + carpet$getEventContainer().onEvent(EntityEventsGroup.Event.ON_DEATH, source.getMsgId()); if (PLAYER_DIES.isNeeded()) { PLAYER_DIES.onPlayerEvent((ServerPlayer) (Object)this); @@ -89,7 +88,7 @@ private void onDeathEvent(DamageSource source, CallbackInfo ci) )) private void setSneakingConditionally(ServerPlayer serverPlayerEntity, boolean sneaking) { - if (!((EntityInterface)serverPlayerEntity.getVehicle()).isPermanentVehicle()) // won't since that method makes sure its not null + if (!serverPlayerEntity.getVehicle().carpet$isPermanentVehicle()) // won't since that method makes sure its not null serverPlayerEntity.setShiftKeyDown(sneaking); } @@ -119,13 +118,13 @@ private void atChangeDimension(ServerLevel destination, CallbackInfoReturnable getCMBlockTagKey() + public TagKey carpet$getTagKey() { // might be good to explose the holder set nature of it. return tag.unwrap().left().orElse(null); } @Override - public Map getCMProperties() + public Map carpet$getProperties() { return vagueProperties.entrySet().stream().collect(Collectors.toMap( e -> new StringValue(e.getKey()), @@ -47,7 +47,7 @@ public Map getCMProperties() } @Override - public CompoundTag getCMDataTag() + public CompoundTag carpet$getDataTag() { return nbt; } diff --git a/src/main/java/carpet/mixins/ThreadedLevelLightEngine_scarpetChunkCreationMixin.java b/src/main/java/carpet/mixins/ThreadedLevelLightEngine_scarpetChunkCreationMixin.java index 964fa8edac..2339873238 100644 --- a/src/main/java/carpet/mixins/ThreadedLevelLightEngine_scarpetChunkCreationMixin.java +++ b/src/main/java/carpet/mixins/ThreadedLevelLightEngine_scarpetChunkCreationMixin.java @@ -17,9 +17,7 @@ import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.gen.Invoker; -import carpet.fakes.Lighting_scarpetChunkCreationInterface; import carpet.fakes.ServerLightingProviderInterface; -import carpet.fakes.ThreadedAnvilChunkStorageInterface; @Mixin(ThreadedLevelLightEngine.class) public abstract class ThreadedLevelLightEngine_scarpetChunkCreationMixin extends LevelLightEngine implements ServerLightingProviderInterface @@ -38,24 +36,24 @@ private ThreadedLevelLightEngine_scarpetChunkCreationMixin(final LightChunkGette @Override @Invoker("updateChunkStatus") - public abstract void invokeUpdateChunkStatus(ChunkPos pos); + public abstract void carpet$updateChunkStatus(ChunkPos pos); @Override - public void removeLightData(final ChunkAccess chunk) + public void carpet$removeLightData(final ChunkAccess chunk) { ChunkPos pos = chunk.getPos(); chunk.setLightCorrect(false); this.addTask(pos.x, pos.z, () -> 0, ThreadedLevelLightEngine.TaskType.PRE_UPDATE, Util.name(() -> { super.setLightEnabled(pos, false); - ((Lighting_scarpetChunkCreationInterface) this).removeLightData(SectionPos.getZeroNode(SectionPos.asLong(pos.x, 0, pos.z))); + carpet$removeLightData(SectionPos.getZeroNode(SectionPos.asLong(pos.x, 0, pos.z))); }, () -> "Remove light data " + pos )); } @Override - public CompletableFuture relight(ChunkAccess chunk) + public CompletableFuture carpet$relight(ChunkAccess chunk) { ChunkPos pos = chunk.getPos(); @@ -88,7 +86,7 @@ public CompletableFuture relight(ChunkAccess chunk) return CompletableFuture.runAsync( Util.name(() -> { chunk.setLightCorrect(true); - ((ThreadedAnvilChunkStorageInterface) this.chunkMap).releaseRelightTicket(pos); + this.chunkMap.carpet$releaseRelightTicket(pos); }, () -> "Release relight ticket " + pos ), diff --git a/src/main/java/carpet/mixins/ThreadedLevelLightEngine_scarpetMixin.java b/src/main/java/carpet/mixins/ThreadedLevelLightEngine_scarpetMixin.java index 901654e2eb..84a127b0e0 100644 --- a/src/main/java/carpet/mixins/ThreadedLevelLightEngine_scarpetMixin.java +++ b/src/main/java/carpet/mixins/ThreadedLevelLightEngine_scarpetMixin.java @@ -28,7 +28,7 @@ public ThreadedLevelLightEngine_scarpetMixin(LightChunkGetter chunkProvider, boo } @Override - public void resetLight(ChunkAccess chunk, ChunkPos pos) + public void carpet$resetLight(ChunkAccess chunk, ChunkPos pos) { //super.setRetainData(pos, false); //super.setLightEnabled(pos, false); diff --git a/src/main/java/carpet/mixins/Timer_tickSpeedMixin.java b/src/main/java/carpet/mixins/Timer_tickSpeedMixin.java index fdf61ef18e..4e45988db9 100644 --- a/src/main/java/carpet/mixins/Timer_tickSpeedMixin.java +++ b/src/main/java/carpet/mixins/Timer_tickSpeedMixin.java @@ -1,6 +1,5 @@ package carpet.mixins; -import carpet.fakes.MinecraftInterface; import carpet.helpers.TickRateManager; import net.minecraft.client.Minecraft; import net.minecraft.client.Timer; @@ -17,10 +16,10 @@ public class Timer_tickSpeedMixin { value = "FIELD", target = "Lnet/minecraft/client/Timer;msPerTick:F" )) - private float adjustTickSpeed(Timer counter) { + private float adjustTickSpeed(Timer timer) { if (CarpetSettings.smoothClientAnimations) { - Optional trm = ((MinecraftInterface)Minecraft.getInstance()).getTickRateManager(); + Optional trm = Minecraft.getInstance().carpet$getTickRateManager(); if (trm.isPresent() && trm.get().runsNormally()) { return Math.max(50.0f, trm.get().mspt()); diff --git a/src/main/java/carpet/network/ClientNetworkHandler.java b/src/main/java/carpet/network/ClientNetworkHandler.java index 6b8ed288cf..24d0060ded 100644 --- a/src/main/java/carpet/network/ClientNetworkHandler.java +++ b/src/main/java/carpet/network/ClientNetworkHandler.java @@ -5,7 +5,6 @@ import carpet.CarpetSettings; import carpet.api.settings.CarpetRule; import carpet.api.settings.InvalidRuleValueException; -import carpet.fakes.LevelInterface; import carpet.helpers.TickRateManager; import carpet.api.settings.SettingsManager; import io.netty.buffer.Unpooled; @@ -69,20 +68,20 @@ public class ClientNetworkHandler } }); dataHandlers.put("TickRate", (p, t) -> { - TickRateManager tickRateManager = ((LevelInterface)p.clientLevel).tickRateManager(); + TickRateManager tickRateManager = p.clientLevel.carpet$getTickRateManager(); tickRateManager.setTickRate(((NumericTag) t).getAsFloat()); }); dataHandlers.put("TickingState", (p, t) -> { CompoundTag tickingState = (CompoundTag)t; - TickRateManager tickRateManager = ((LevelInterface)p.clientLevel).tickRateManager(); + TickRateManager tickRateManager = p.clientLevel.carpet$getTickRateManager(); tickRateManager.setFrozenState(tickingState.getBoolean("is_paused"), tickingState.getBoolean("deepFreeze")); }); dataHandlers.put("SuperHotState", (p, t) -> { - TickRateManager tickRateManager = ((LevelInterface)p.clientLevel).tickRateManager(); + TickRateManager tickRateManager = p.clientLevel.carpet$getTickRateManager(); tickRateManager.setSuperHot(((ByteTag) t).equals(ByteTag.ONE)); }); dataHandlers.put("TickPlayerActiveTimeout", (p, t) -> { - TickRateManager tickRateManager = ((LevelInterface)p.clientLevel).tickRateManager(); + TickRateManager tickRateManager = p.clientLevel.carpet$getTickRateManager(); tickRateManager.setPlayerActiveTimeout(((NumericTag) t).getAsInt()); }); dataHandlers.put("scShape", (p, t) -> { // deprecated // and unused // should remove for 1.17 diff --git a/src/main/java/carpet/network/ServerNetworkHandler.java b/src/main/java/carpet/network/ServerNetworkHandler.java index 9a429ab23b..8286cfdaa1 100644 --- a/src/main/java/carpet/network/ServerNetworkHandler.java +++ b/src/main/java/carpet/network/ServerNetworkHandler.java @@ -4,12 +4,8 @@ import carpet.CarpetSettings; import carpet.api.settings.CarpetRule; import carpet.api.settings.RuleHelper; -import carpet.fakes.CarpetPacketPayload; -import carpet.fakes.MinecraftServerInterface; -import carpet.fakes.ServerGamePacketListenerImplInterface; import carpet.helpers.ServerTickRateManager; import carpet.script.utils.SnoopyCommandSource; -import io.netty.buffer.Unpooled; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -89,7 +85,7 @@ public void writeData(final FriendlyByteBuf t) public static void onPlayerJoin(ServerPlayer playerEntity) { if (true) return; - if (!((ServerGamePacketListenerImplInterface)playerEntity.connection).getConnection().isMemoryConnection()) + if (!playerEntity.connection.carpet$getConnection().isMemoryConnection()) { playerEntity.connection.send( make( output -> { output.writeVarInt(CarpetClient.HI); @@ -249,7 +245,7 @@ public static void sendCustomCommand(ServerPlayer player, String command, Tag da public static void onPlayerLoggedOut(ServerPlayer player) { validCarpetPlayers.remove(player); - if (!((ServerGamePacketListenerImplInterface)player.connection).getConnection().isMemoryConnection()) + if (!player.connection.carpet$getConnection().isMemoryConnection()) remoteCarpetPlayers.remove(player); } @@ -288,13 +284,13 @@ private DataBuilder(MinecraftServer server) } private DataBuilder withTickRate() { - ServerTickRateManager trm = ((MinecraftServerInterface)server).getTickRateManager(); + ServerTickRateManager trm = server.carpet$getTickRateManager(); tag.putFloat("TickRate", trm.tickrate()); return this; } private DataBuilder withFrozenState() { - ServerTickRateManager trm = ((MinecraftServerInterface)server).getTickRateManager(); + ServerTickRateManager trm = server.carpet$getTickRateManager(); CompoundTag tickingState = new CompoundTag(); tickingState.putBoolean("is_paused", trm.gameIsPaused()); tickingState.putBoolean("deepFreeze", trm.deeplyFrozen()); @@ -303,13 +299,13 @@ private DataBuilder withFrozenState() } private DataBuilder withSuperHotState() { - ServerTickRateManager trm = ((MinecraftServerInterface)server).getTickRateManager(); + ServerTickRateManager trm = server.carpet$getTickRateManager(); tag.putBoolean("SuperHotState", trm.isSuperHot()); return this; } private DataBuilder withTickPlayerActiveTimeout() { - ServerTickRateManager trm = ((MinecraftServerInterface)server).getTickRateManager(); + ServerTickRateManager trm = server.carpet$getTickRateManager(); tag.putInt("TickPlayerActiveTimeout", trm.getPlayerActiveTimeout()); return this; } diff --git a/src/main/java/carpet/patches/EntityPlayerMPFake.java b/src/main/java/carpet/patches/EntityPlayerMPFake.java index 6c8cb8d885..449b69e6f9 100644 --- a/src/main/java/carpet/patches/EntityPlayerMPFake.java +++ b/src/main/java/carpet/patches/EntityPlayerMPFake.java @@ -28,7 +28,6 @@ import net.minecraft.world.level.block.entity.SkullBlockEntity; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.Vec3; -import carpet.fakes.ServerPlayerInterface; import carpet.utils.Messenger; import java.util.concurrent.atomic.AtomicReference; @@ -68,7 +67,7 @@ public static EntityPlayerMPFake createFake(String username, MinecraftServer ser } EntityPlayerMPFake instance = new EntityPlayerMPFake(server, worldIn, gameprofile, false); instance.fixStartingPosition = () -> instance.moveTo(pos.x, pos.y, pos.z, (float) yaw, (float) pitch); - server.getPlayerList().placeNewPlayer(new FakeClientConnection(PacketFlow.SERVERBOUND), instance, 0); + server.getPlayerList().placeNewPlayer(new FakeConnection(PacketFlow.SERVERBOUND), instance, 0); instance.teleportTo(worldIn, pos.x, pos.y, pos.z, (float) yaw, (float) pitch); instance.setHealth(20.0F); instance.unsetRemoved(); @@ -90,12 +89,12 @@ public static EntityPlayerMPFake createShadow(MinecraftServer server, ServerPlay GameProfile gameprofile = player.getGameProfile(); EntityPlayerMPFake playerShadow = new EntityPlayerMPFake(server, worldIn, gameprofile, true); playerShadow.setChatSession(player.getChatSession()); - server.getPlayerList().placeNewPlayer(new FakeClientConnection(PacketFlow.SERVERBOUND), playerShadow, 0); + server.getPlayerList().placeNewPlayer(new FakeConnection(PacketFlow.SERVERBOUND), playerShadow, 0); playerShadow.setHealth(player.getHealth()); playerShadow.connection.teleport(player.getX(), player.getY(), player.getZ(), player.getYRot(), player.getXRot()); playerShadow.gameMode.changeGameModeForPlayer(player.gameMode.getGameModeForPlayer()); - ((ServerPlayerInterface) playerShadow).getActionPack().copyFrom(((ServerPlayerInterface) player).getActionPack()); + playerShadow.carpet$getActionPack().copyFrom(player.carpet$getActionPack()); playerShadow.setMaxUpStep(0.6F); playerShadow.entityData.set(DATA_PLAYER_MODE_CUSTOMISATION, player.getEntityData().get(DATA_PLAYER_MODE_CUSTOMISATION)); diff --git a/src/main/java/carpet/patches/FakeClientConnection.java b/src/main/java/carpet/patches/FakeConnection.java similarity index 70% rename from src/main/java/carpet/patches/FakeClientConnection.java rename to src/main/java/carpet/patches/FakeConnection.java index bb9e9ea84e..591c38626c 100644 --- a/src/main/java/carpet/patches/FakeClientConnection.java +++ b/src/main/java/carpet/patches/FakeConnection.java @@ -1,18 +1,17 @@ package carpet.patches; -import carpet.fakes.ClientConnectionInterface; import io.netty.channel.embedded.EmbeddedChannel; import net.minecraft.network.Connection; import net.minecraft.network.protocol.PacketFlow; -public class FakeClientConnection extends Connection +public class FakeConnection extends Connection { - public FakeClientConnection(PacketFlow p) + public FakeConnection(PacketFlow p) { super(p); // compat with adventure-platform-fabric. This does NOT trigger other vanilla handlers for establishing a channel // also makes #isOpen return true, allowing enderpearls to teleport fake players - ((ClientConnectionInterface)this).setChannel(new EmbeddedChannel()); + setChannel(new EmbeddedChannel()); } @Override @@ -24,4 +23,4 @@ public void setReadOnly() public void handleDisconnection() { } -} \ No newline at end of file +} diff --git a/src/main/java/carpet/patches/TickSyncedBorderExtent.java b/src/main/java/carpet/patches/TickSyncedBorderExtent.java index a9e8917a10..43b226bf66 100644 --- a/src/main/java/carpet/patches/TickSyncedBorderExtent.java +++ b/src/main/java/carpet/patches/TickSyncedBorderExtent.java @@ -1,7 +1,6 @@ package carpet.patches; import carpet.CarpetServer; -import carpet.fakes.MinecraftServerInterface; import carpet.helpers.ServerTickRateManager; import net.minecraft.server.MinecraftServer; import net.minecraft.util.Mth; @@ -96,7 +95,7 @@ public long getLerpRemainingTime() else { ms = Arrays.stream(server.tickTimes).average().orElseThrow(IllegalStateException::new) * 1.0E-6D; - ServerTickRateManager trm = ((MinecraftServerInterface)server).getTickRateManager(); + ServerTickRateManager trm = server.carpet$getTickRateManager(); if (!trm.isInWarpSpeed()) { ms = Math.max(ms, trm.mspt()); diff --git a/src/main/java/carpet/script/api/WorldAccess.java b/src/main/java/carpet/script/api/WorldAccess.java index 6ac0586117..56ccdb86f6 100644 --- a/src/main/java/carpet/script/api/WorldAccess.java +++ b/src/main/java/carpet/script/api/WorldAccess.java @@ -439,7 +439,7 @@ else if (!("any".equals(statusString))) } Value weather = lv.get(0); - ServerLevelData worldProperties = Vanilla.ServerLevel_getWorldProperties(world); + ServerLevelData worldProperties = Vanilla.ServerLevel_getLevelData(world); if (lv.size() == 1) { return new NumericValue(switch (weather.getString().toLowerCase(Locale.ROOT)) @@ -640,7 +640,7 @@ else if (!("any".equals(statusString))) { ServerLevel world = ((CarpetContext) c).level(); DistanceManager foo = world.getChunkSource().chunkMap.getDistanceManager(); - Long2ObjectOpenHashMap>> levelTickets = Vanilla.ChunkTicketManager_getTicketsByPosition(foo); + Long2ObjectOpenHashMap>> levelTickets = Vanilla.DistanceManager_getTicketsByPosition(foo); List res = new ArrayList<>(); if (lv.isEmpty()) diff --git a/src/main/java/carpet/script/external/Carpet.java b/src/main/java/carpet/script/external/Carpet.java index d4f92f2dd3..4d4809ff14 100644 --- a/src/main/java/carpet/script/external/Carpet.java +++ b/src/main/java/carpet/script/external/Carpet.java @@ -5,7 +5,6 @@ import carpet.api.settings.CarpetRule; import carpet.api.settings.RuleHelper; import carpet.api.settings.SettingsManager; -import carpet.fakes.MinecraftServerInterface; import carpet.logging.HUDController; import carpet.network.ServerNetworkHandler; import carpet.patches.EntityPlayerMPFake; @@ -87,7 +86,7 @@ public static Runnable startProfilerSection(String name) public static void MinecraftServer_addScriptServer(MinecraftServer server, CarpetScriptServer scriptServer) { - ((MinecraftServerInterface) server).addScriptServer(scriptServer); + server.carpet$addScriptServer(scriptServer); } public static boolean isValidCarpetPlayer(ServerPlayer player) @@ -133,7 +132,7 @@ public static String isModdedPlayer(Player p) public static boolean isTickProcessingPaused(MinecraftServer server) { - return !((MinecraftServerInterface)server).getTickRateManager().runsNormally(); + return !server.carpet$getTickRateManager().runsNormally(); } public static void handleExtensionsAPI(CarpetExpression expression) diff --git a/src/main/java/carpet/script/external/Vanilla.java b/src/main/java/carpet/script/external/Vanilla.java index 67470b4d62..a4e5f2311d 100644 --- a/src/main/java/carpet/script/external/Vanilla.java +++ b/src/main/java/carpet/script/external/Vanilla.java @@ -1,26 +1,8 @@ package carpet.script.external; import carpet.CarpetSettings; -import carpet.fakes.BiomeInterface; import carpet.fakes.BlockPredicateInterface; -import carpet.fakes.BlockStateArgumentInterface; -import carpet.fakes.ChunkTicketManagerInterface; import carpet.fakes.CommandDispatcherInterface; -import carpet.fakes.EntityInterface; -import carpet.fakes.IngredientInterface; -import carpet.fakes.InventoryBearerInterface; -import carpet.fakes.ItemEntityInterface; -import carpet.fakes.LivingEntityInterface; -import carpet.fakes.MinecraftServerInterface; -import carpet.fakes.MobEntityInterface; -import carpet.fakes.RandomStateVisitorAccessor; -import carpet.fakes.RecipeManagerInterface; -import carpet.fakes.AbstractContainerMenuInterface; -import carpet.fakes.ServerPlayerInterface; -import carpet.fakes.ServerPlayerInteractionManagerInterface; -import carpet.fakes.ServerWorldInterface; -import carpet.fakes.SpawnHelperInnerInterface; -import carpet.fakes.ThreadedAnvilChunkStorageInterface; import carpet.mixins.Objective_scarpetMixin; import carpet.mixins.PoiRecord_scarpetMixin; import carpet.mixins.Scoreboard_scarpetMixin; @@ -95,27 +77,27 @@ public class Vanilla { public static void MinecraftServer_forceTick(MinecraftServer server, BooleanSupplier sup) { - ((MinecraftServerInterface) server).forceTick(sup); + server.carpet$forceTick(sup); } public static void ChunkMap_relightChunk(ChunkMap chunkMap, ChunkPos pos) { - ((ThreadedAnvilChunkStorageInterface) chunkMap).relightChunk(pos); + chunkMap.carpet$relightChunk(pos); } public static Map ChunkMap_regenerateChunkRegion(ChunkMap chunkMap, List requestedChunks) { - return ((ThreadedAnvilChunkStorageInterface) chunkMap).regenerateChunkRegion(requestedChunks); + return chunkMap.carpet$regenerateChunkRegion(requestedChunks); } public static List> Ingredient_getRecipeStacks(Ingredient ingredient) { - return ((IngredientInterface) (Object) ingredient).getRecipeStacks(); + return ingredient.carpet$getRecipeStacks(); } public static List> RecipeManager_getAllMatching(RecipeManager recipeManager, RecipeType type, ResourceLocation output, RegistryAccess registryAccess) { - return ((RecipeManagerInterface) recipeManager).getAllMatching(type, output, registryAccess); + return recipeManager.carpet$getAllMatching(type, output, registryAccess); } public static int NaturalSpawner_MAGIC_NUMBER() @@ -125,7 +107,7 @@ public static int NaturalSpawner_MAGIC_NUMBER() public static PotentialCalculator SpawnState_getPotentialCalculator(NaturalSpawner.SpawnState spawnState) { - return ((SpawnHelperInnerInterface) spawnState).getPotentialCalculator(); + return spawnState.carpet$getPotentialCalculator(); } public static void Objective_setCriterion(Objective objective, ObjectiveCriteria criterion) @@ -138,34 +120,34 @@ public static Map> Scoreboard_getObjectivesBy return ((Scoreboard_scarpetMixin) scoreboard).getObjectivesByCriterion(); } - public static ServerLevelData ServerLevel_getWorldProperties(ServerLevel world) + public static ServerLevelData ServerLevel_getLevelData(ServerLevel level) { - return ((ServerWorldInterface) world).getWorldPropertiesCM(); + return level.carpet$getLevelData(); } - public static Long2ObjectOpenHashMap>> ChunkTicketManager_getTicketsByPosition(DistanceManager ticketManager) + public static Long2ObjectOpenHashMap>> DistanceManager_getTicketsByPosition(DistanceManager distanceManager) { - return ((ChunkTicketManagerInterface) ticketManager).getTicketsByPosition(); + return distanceManager.carpet$getTicketsByPosition(); } public static DensityFunction.Visitor RandomState_getVisitor(RandomState randomState) { - return ((RandomStateVisitorAccessor) (Object) randomState).getVisitor(); + return randomState.carpet$getVisitor(); } public static CompoundTag BlockInput_getTag(BlockInput blockInput) { - return ((BlockStateArgumentInterface) blockInput).getCMTag(); + return blockInput.carpet$getTag(); } public static CarpetScriptServer MinecraftServer_getScriptServer(MinecraftServer server) { - return ((MinecraftServerInterface) server).getScriptServer(); + return server.carpet$getScriptServer(); } public static Biome.ClimateSettings Biome_getClimateSettings(Biome biome) { - return ((BiomeInterface) (Object) biome).getClimateSettings(); + return biome.carpet$getClimateSettings(); } public static ThreadLocal skipGenerationChecks(ServerLevel level) @@ -205,107 +187,107 @@ public static MapValue getServerMods(MinecraftServer server) public static LevelStorageSource.LevelStorageAccess MinecraftServer_storageSource(MinecraftServer server) { - return ((MinecraftServerInterface) server).getCMSession(); + return server.carpet$getStorageSource(); } public static BlockPos ServerPlayerGameMode_getCurrentBlockPosition(ServerPlayerGameMode gameMode) { - return ((ServerPlayerInteractionManagerInterface) gameMode).getCurrentBreakingBlock(); + return gameMode.carpet$getCurrentBreakingBlock(); } public static int ServerPlayerGameMode_getCurrentBlockBreakingProgress(ServerPlayerGameMode gameMode) { - return ((ServerPlayerInteractionManagerInterface) gameMode).getCurrentBlockBreakingProgress(); + return gameMode.carpet$getCurrentBlockBreakingProgress(); } public static void ServerPlayerGameMode_setBlockBreakingProgress(ServerPlayerGameMode gameMode, int progress) { - ((ServerPlayerInteractionManagerInterface) gameMode).setBlockBreakingProgress(progress); + gameMode.carpet$setBlockBreakingProgress(progress); } public static boolean ServerPlayer_isInvalidEntityObject(ServerPlayer player) { - return ((ServerPlayerInterface) player).isInvalidEntityObject(); + return player.carpet$isInvalidEntityObject(); } public static String ServerPlayer_getLanguage(ServerPlayer player) { - return ((ServerPlayerInterface) player).getLanguage(); + return player.carpet$getLanguage(); } public static GoalSelector Mob_getAI(Mob mob, boolean target) { - return ((MobEntityInterface) mob).getAI(target); + return mob.carpet$getAi(target); } public static Map Mob_getTemporaryTasks(Mob mob) { - return ((MobEntityInterface) mob).getTemporaryTasks(); + return mob.carpet$getTemporaryTasks(); } public static void Mob_setPersistence(Mob mob, boolean what) { - ((MobEntityInterface) mob).setPersistence(what); + mob.carpet$setPersistence(what); } public static EntityEventsGroup Entity_getEventContainer(Entity entity) { - return ((EntityInterface) entity).getEventContainer(); + return entity.carpet$getEventContainer(); } public static boolean Entity_isPermanentVehicle(Entity entity) { - return ((EntityInterface) entity).isPermanentVehicle(); + return entity.carpet$isPermanentVehicle(); } public static void Entity_setPermanentVehicle(Entity entity, boolean permanent) { - ((EntityInterface) entity).setPermanentVehicle(permanent); + entity.carpet$setPermanentVehicle(permanent); } public static int Entity_getPortalTimer(Entity entity) { - return ((EntityInterface) entity).getPortalTimer(); + return entity.carpet$getPortalTimer(); } public static void Entity_setPortalTimer(Entity entity, int amount) { - ((EntityInterface) entity).setPortalTimer(amount); + entity.carpet$setPortalTimer(amount); } public static int Entity_getPublicNetherPortalCooldown(Entity entity) { - return ((EntityInterface) entity).getPublicNetherPortalCooldown(); + return entity.carpet$getPublicNetherPortalCooldown(); } public static void Entity_setPublicNetherPortalCooldown(Entity entity, int what) { - ((EntityInterface) entity).setPublicNetherPortalCooldown(what); + entity.carpet$setPublicNetherPortalCooldown(what); } public static int ItemEntity_getPickupDelay(ItemEntity entity) { - return ((ItemEntityInterface) entity).getPickupDelayCM(); + return entity.carpet$getPickupDelay(); } public static boolean LivingEntity_isJumping(LivingEntity entity) { - return ((LivingEntityInterface) entity).isJumpingCM(); + return entity.carpet$isJumping(); } public static void LivingEntity_setJumping(LivingEntity entity) { - ((LivingEntityInterface) entity).doJumpCM(); + entity.carpet$doJump(); } public static Container AbstractHorse_getInventory(AbstractHorse horse) { - return ((InventoryBearerInterface) horse).getCMInventory(); + return horse.carpet$getInventory(); } - public static DataSlot AbstractContainerMenu_getDataSlot(AbstractContainerMenu handler, int index) + public static DataSlot AbstractContainerMenu_getDataSlot(AbstractContainerMenu menu, int index) { - return ((AbstractContainerMenuInterface) handler).getDataSlot(index); + return menu.carpet$getDataSlot(index); } public static void CommandDispatcher_unregisterCommand(CommandDispatcher dispatcher, String name) @@ -362,8 +344,7 @@ public record BlockPredicatePayload(BlockState state, TagKey tagKey, Map< public static BlockPredicatePayload of(Predicate blockPredicate) { BlockPredicateInterface predicateData = (BlockPredicateInterface) blockPredicate; - return new BlockPredicatePayload(predicateData.getCMBlockState(), predicateData.getCMBlockTagKey(), predicateData.getCMProperties(), predicateData.getCMDataTag()); + return new BlockPredicatePayload(predicateData.carpet$getBlockState(), predicateData.carpet$getTagKey(), predicateData.carpet$getProperties(), predicateData.carpet$getDataTag()); } } - } diff --git a/src/main/java/carpet/utils/SpawnChunks.java b/src/main/java/carpet/utils/SpawnChunks.java index 1d7042ca1a..7815562d6d 100644 --- a/src/main/java/carpet/utils/SpawnChunks.java +++ b/src/main/java/carpet/utils/SpawnChunks.java @@ -1,8 +1,8 @@ package carpet.utils; -import carpet.fakes.ChunkTicketManagerInterface; import net.minecraft.core.BlockPos; import net.minecraft.server.level.DistanceManager; +import net.minecraft.server.level.ServerChunkCache; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.level.ChunkPos; @@ -15,7 +15,8 @@ public static void changeSpawnSize(ServerLevel overworld, int size) overworld.getLevelData().getYSpawn(), overworld.getLevelData().getZSpawn() )); - DistanceManager ticketManager = overworld.getChunkSource().chunkMap.getDistanceManager(); - ((ChunkTicketManagerInterface)ticketManager).changeSpawnChunks(centerChunk, size); + ServerChunkCache chunkCache = overworld.getChunkSource(); + DistanceManager distanceManager = chunkCache.chunkMap.getDistanceManager(); + distanceManager.carpet$changeSpawnChunks(centerChunk, size); } } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 0cc0168dfe..ddf3e1ff5d 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -36,5 +36,127 @@ "minecraft": ">1.19.4", "fabricloader": ">=0.14.18", "java": ">=17" + }, + + "custom": { + "loom:injected_interfaces": { + "net/minecraft/class_1703": [ + "carpet/fakes/AbstractContainerMenuInterface" + ], + "net/minecraft/class_1496": [ + "carpet/fakes/AbstractHorseInterface" + ], + "net/minecraft/class_1959": [ + "carpet/fakes/BiomeInterface" + ], + "net/minecraft/class_2586": [ + "carpet/fakes/BlockEntityInterface" + ], + "net/minecraft/class_2247": [ + "carpet/fakes/BlockInputInterface" + ], + "net/minecraft/class_2252\u0024class_2253": [ + "carpet/fakes/BlockPredicateInterface" + ], + "net/minecraft/class_2252\u0024class_2255": [ + "carpet/fakes/BlockPredicateInterface" + ], + "net/minecraft/class_3193": [ + "carpet/fakes/ChunkHolderInterface" + ], + "net/minecraft/class_3898": [ + "carpet/fakes/ChunkMapInterface" + ], + "net/minecraft/class_2535": [ + "carpet/fakes/ConnectionInterface" + ], + "net/minecraft/class_2978": [ + "carpet/fakes/CoralFeatureInterface" + ], + "net/minecraft/class_3204": [ + "carpet/fakes/DistanceManagerInterface" + ], + "net/minecraft/class_1297": [ + "carpet/fakes/EntityInterface" + ], + "net/minecraft/class_1856": [ + "carpet/fakes/IngredientInterface" + ], + "net/minecraft/class_1542": [ + "carpet/fakes/ItemEntityInterface" + ], + "net/minecraft/class_2818": [ + "carpet/fakes/LevelChunkInterface" + ], + "net/minecraft/class_638": [ + "carpet/fakes/LevelInterface" + ], + "net/minecraft/class_1937": [ + "carpet/fakes/LevelInterface" + ], + "net/minecraft/class_3558": [ + "carpet/fakes/Lighting_scarpetChunkCreationInterface" + ], + "net/minecraft/class_3560": [ + "carpet/fakes/Lighting_scarpetChunkCreationInterface" + ], + "net/minecraft/class_3568": [ + "carpet/fakes/Lighting_scarpetChunkCreationInterface" + ], + "net/minecraft/class_1309": [ + "carpet/fakes/LivingEntityInterface" + ], + "net/minecraft/class_310": [ + "carpet/fakes/MinecraftInterface" + ], + "net/minecraft/class_1311": [ + "carpet/fakes/MobCategoryInterface" + ], + "net/minecraft/class_1308": [ + "carpet/fakes/MobInterface" + ], + "net/minecraft/class_2665": [ + "carpet/fakes/PistonBaseBlockInterface" + ], + "net/minecraft/class_2669": [ + "carpet/fakes/PistonMovingBlockEntityInterface" + ], + "net/minecraft/class_355": [ + "carpet/fakes/PlayerTabOverlayInterface" + ], + "net/minecraft/class_1541": [ + "carpet/fakes/PrimedTntInterface" + ], + "net/minecraft/class_7138": [ + "carpet/fakes/RandomStateInterface" + ], + "net/minecraft/class_1863": [ + "carpet/fakes/RecipeManagerInterface" + ], + "net/minecraft/class_2457": [ + "carpet/fakes/RedStoneWireBlockInterface" + ], + "net/minecraft/class_3244": [ + "carpet/fakes/ServerGamePacketListenerImplInterface" + ], + "net/minecraft/class_3218": [ + "carpet/fakes/ServerLevelInterface" + ], + "net/minecraft/class_1948\u0024class_5262": [ + "carpet/fakes/SpawnStateInterface" + ], + "net/minecraft/class_3227": [ + "carpet/fakes/ServerLightingProviderInterface" + ], + "net/minecraft/class_3225": [ + "carpet/fakes/ServerPlayerGameModeInterface" + ], + "net/minecraft/class_3222": [ + "carpet/fakes/ServerPlayerInterface" + ], + "net/minecraft/server/MinecraftServer": [ + "carpet/fakes/MinecraftServerInterface" + ] + } } }