diff --git a/src/main/java/carpet/CarpetServer.java b/src/main/java/carpet/CarpetServer.java index 94fb270498..657e73c46a 100644 --- a/src/main/java/carpet/CarpetServer.java +++ b/src/main/java/carpet/CarpetServer.java @@ -14,7 +14,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; @@ -29,7 +28,6 @@ import carpet.api.settings.SettingsManager; import carpet.logging.HUDController; import carpet.script.external.Carpet; -import carpet.script.external.Vanilla; import carpet.script.utils.ParticleParser; import carpet.utils.MobAI; import carpet.utils.SpawnReporter; @@ -128,7 +126,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(); @@ -195,7 +193,7 @@ public static void onPlayerLoggedOut(ServerPlayer player, Component reason) LoggerRegistry.playerDisconnected(player); extensions.forEach(e -> e.onPlayerLoggedOut(player)); // first case client, second case server - CarpetScriptServer runningScriptServer = (player.getServer() == null) ? scriptServer : Vanilla.MinecraftServer_getScriptServer(player.getServer()); + CarpetScriptServer runningScriptServer = (player.getServer() == null) ? scriptServer : player.getServer().carpet$getScriptServer(); if (runningScriptServer != null && !runningScriptServer.stopAll) { runningScriptServer.onPlayerLoggedOut(player, reason); } @@ -215,8 +213,8 @@ public static void onServerClosed(MinecraftServer server) { if (scriptServer != null) scriptServer.onClose(); // this is a mess, will cleanip onlly when global reference is gone - if (!Vanilla.MinecraftServer_getScriptServer(server).stopAll) { - Vanilla.MinecraftServer_getScriptServer(server).onClose(); + if (!server.carpet$getScriptServer().stopAll) { + server.carpet$getScriptServer().onClose(); } scriptServer = null; 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 b3edf1c56a..98ab88bd7a 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; @@ -199,7 +197,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; @@ -259,7 +257,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..01e6237e2f 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..81e377ca2e 100644 --- a/src/main/java/carpet/fakes/BiomeInterface.java +++ b/src/main/java/carpet/fakes/BiomeInterface.java @@ -3,5 +3,5 @@ import net.minecraft.world.level.biome.Biome; public interface BiomeInterface { - Biome.ClimateSettings getClimateSettings(); + default Biome.ClimateSettings carpet$getClimateSettings() { throw new UnsupportedOperationException(); } } diff --git a/src/main/java/carpet/fakes/BlockBehaviourInterface.java b/src/main/java/carpet/fakes/BlockBehaviourInterface.java index 289c0743ab..fc0e5de617 100644 --- a/src/main/java/carpet/fakes/BlockBehaviourInterface.java +++ b/src/main/java/carpet/fakes/BlockBehaviourInterface.java @@ -6,15 +6,13 @@ import net.minecraft.world.level.block.state.BlockState; public interface BlockBehaviourInterface { - /** * @return whether this block is sticky in any way when moved by pistons */ - public boolean isSticky(BlockState state); + default boolean carpet$isSticky(BlockState state) { throw new UnsupportedOperationException(); } /** * @return whether the neighboring block is pulled along if this block is moved by pistons */ - public boolean isStickyToNeighbor(Level level, BlockPos pos, BlockState state, BlockPos neighborPos, BlockState neighborState, Direction dir, Direction moveDir); - + default boolean carpet$isStickyToNeighbor(Level level, BlockPos pos, BlockState state, BlockPos neighborPos, BlockState neighborState, Direction dir, Direction moveDir) { 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/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/ClientLevelInterface.java b/src/main/java/carpet/fakes/ClientLevelInterface.java index 6ecdf58a1e..5c09e76eb5 100644 --- a/src/main/java/carpet/fakes/ClientLevelInterface.java +++ b/src/main/java/carpet/fakes/ClientLevelInterface.java @@ -4,5 +4,5 @@ public interface ClientLevelInterface { - TickRateManager getTickRateManager(); + default TickRateManager carpet$getTickRateManager() { throw new UnsupportedOperationException(); } } diff --git a/src/main/java/carpet/fakes/CommandDispatcherInterface.java b/src/main/java/carpet/fakes/CommandDispatcherInterface.java index 473b638a8d..9cc839bb5c 100644 --- a/src/main/java/carpet/fakes/CommandDispatcherInterface.java +++ b/src/main/java/carpet/fakes/CommandDispatcherInterface.java @@ -1,5 +1,5 @@ package carpet.fakes; public interface CommandDispatcherInterface { - void carpet$unregister(String node); + default void carpet$unregister(String node) { throw new UnsupportedOperationException(); } } diff --git a/src/main/java/carpet/fakes/CommandNodeInterface.java b/src/main/java/carpet/fakes/CommandNodeInterface.java index 9401dfb4b8..885d888875 100644 --- a/src/main/java/carpet/fakes/CommandNodeInterface.java +++ b/src/main/java/carpet/fakes/CommandNodeInterface.java @@ -1,5 +1,5 @@ package carpet.fakes; public interface CommandNodeInterface { - void carpet$removeChild(String name); + default void carpet$removeChild(String name) { throw new UnsupportedOperationException(); } } diff --git a/src/main/java/carpet/fakes/ConnectionInterface.java b/src/main/java/carpet/fakes/ConnectionInterface.java new file mode 100644 index 0000000000..f0faaae9b0 --- /dev/null +++ b/src/main/java/carpet/fakes/ConnectionInterface.java @@ -0,0 +1,7 @@ +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..4a5bd225c7 --- /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 chpos) { throw new UnsupportedOperationException(); } +} diff --git a/src/main/java/carpet/fakes/LevelInterface.java b/src/main/java/carpet/fakes/LevelInterface.java index 583da75774..d8e897c133 100644 --- a/src/main/java/carpet/fakes/LevelInterface.java +++ b/src/main/java/carpet/fakes/LevelInterface.java @@ -15,11 +15,11 @@ 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 blockPos, BlockState blockState, BlockEntity newBlockEntity, int int1) { throw new UnsupportedOperationException(); } - NeighborUpdater getNeighborUpdater(); + default List carpet$getOtherEntitiesLimited(@Nullable Entity except, AABB box, Predicate predicate, int limit) { throw new UnsupportedOperationException(); } + + default NeighborUpdater carpet$getNeighborUpdater() { 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..20f2a3ebd5 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$getPausedPartialTick() { throw new UnsupportedOperationException(); } } diff --git a/src/main/java/carpet/fakes/MinecraftServerInterface.java b/src/main/java/carpet/fakes/MinecraftServerInterface.java index cf3fd479b7..f5d502dbda 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 hasTimeLeft) { 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$getResourceManager() { 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..bd9f8d76d6 --- /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$shouldRenderCarriedBlockEntity() { 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/RandomStateInterface.java b/src/main/java/carpet/fakes/RandomStateInterface.java new file mode 100644 index 0000000000..bfb9eb0410 --- /dev/null +++ b/src/main/java/carpet/fakes/RandomStateInterface.java @@ -0,0 +1,7 @@ +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..c686a9af05 --- /dev/null +++ b/src/main/java/carpet/fakes/RedStoneWireBlockInterface.java @@ -0,0 +1,13 @@ +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$shouldSignal() { 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 index b509324878..90a8fd8118 100644 --- a/src/main/java/carpet/fakes/TntEntityInterface.java +++ b/src/main/java/carpet/fakes/TntEntityInterface.java @@ -2,5 +2,5 @@ public interface TntEntityInterface { - int getMergedTNT(); + default int carpet$getMergedTnt() { throw new UnsupportedOperationException(); } } 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..e0a07d432e 100644 --- a/src/main/java/carpet/helpers/BlockRotator.java +++ b/src/main/java/carpet/helpers/BlockRotator.java @@ -1,6 +1,6 @@ package carpet.helpers; -import carpet.fakes.PistonBlockInterface; +import carpet.fakes.PistonBaseBlockInterface; import net.minecraft.core.BlockPos; import net.minecraft.core.BlockSource; import net.minecraft.core.Direction; @@ -63,7 +63,7 @@ public static ItemStack dispenserRotate(BlockSource source, ItemStack stack) Direction face = blockstate.getValue(DirectionalBlock.FACING); if (block instanceof PistonBaseBlock && ( blockstate.getValue(PistonBaseBlock.EXTENDED) - || ( ((PistonBlockInterface)block).publicShouldExtend(world, blockpos, face) && (new PistonStructureResolver(world, blockpos, face, true)).resolve() ) + || ( ((PistonBaseBlockInterface)block).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 c1116af662..a6ef35cb39 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..c6531efa0a 100644 --- a/src/main/java/carpet/helpers/HopperCounter.java +++ b/src/main/java/carpet/helpers/HopperCounter.java @@ -2,7 +2,6 @@ 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 +372,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 : ((IngredientInterface) (Object) 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..33864dcc85 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; @@ -23,7 +22,7 @@ protected AbstractContainerMenuSubclasses_scarpetMixin(MenuType type, int syn @Inject(method = "clickMenuButton", at = @At("HEAD"), cancellable = true) private void buttonClickCallback(Player player, int id, CallbackInfoReturnable cir) { - if(((AbstractContainerMenuInterface) this).callButtonClickListener(id,player)) + if(this.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/BlockBehaviour_customStickyMixin.java b/src/main/java/carpet/mixins/BlockBehaviour_customStickyMixin.java index 55fc78b4f9..d21d8a7dbc 100644 --- a/src/main/java/carpet/mixins/BlockBehaviour_customStickyMixin.java +++ b/src/main/java/carpet/mixins/BlockBehaviour_customStickyMixin.java @@ -14,12 +14,12 @@ public class BlockBehaviour_customStickyMixin implements BlockBehaviourInterface { @Override - public boolean isSticky(BlockState state) { + public boolean carpet$isSticky(BlockState state) { return false; } @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) { return false; } } diff --git a/src/main/java/carpet/mixins/BlockEntity_movableBEMixin.java b/src/main/java/carpet/mixins/BlockEntity_movableBEMixin.java index a043624435..f933f7ce22 100644 --- a/src/main/java/carpet/mixins/BlockEntity_movableBEMixin.java +++ b/src/main/java/carpet/mixins/BlockEntity_movableBEMixin.java @@ -14,7 +14,7 @@ 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 370fd25cb8..dab46f8b7a 100644 --- a/src/main/java/carpet/mixins/BoundTickingBlockEntity_tickMixin.java +++ b/src/main/java/carpet/mixins/BoundTickingBlockEntity_tickMixin.java @@ -1,10 +1,9 @@ package carpet.mixins; -import carpet.fakes.ClientLevelInterface; -import carpet.fakes.MinecraftServerInterface; import carpet.helpers.TickRateManager; import carpet.helpers.ServerTickRateManager; import carpet.utils.CarpetProfiler; +import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.level.Level; @@ -36,18 +35,19 @@ 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) { // these two branches are identical, but we need to check the world type and inferfaces - if (world.isClientSide()) { + if (level.isClientSide()) { // client - TickRateManager tickRateManager = ((ClientLevelInterface)world).getTickRateManager(); - if (tickRateManager.runsNormally()) blockEntityTicker.tick(world, pos, state, blockEntity); + ClientLevel clientLevel = (ClientLevel) level; + TickRateManager tickRateManager = clientLevel.carpet$getTickRateManager(); + if (tickRateManager.runsNormally()) blockEntityTicker.tick(level, pos, state, blockEntity); } else { // server - ServerLevel serverWorld = (ServerLevel) world; - ServerTickRateManager serverTickRateManager = ((MinecraftServerInterface)serverWorld.getServer()).getTickRateManager(); - if (serverTickRateManager.runsNormally()) blockEntityTicker.tick(world, pos, state, blockEntity); + ServerLevel serverWorld = (ServerLevel) level; + ServerTickRateManager serverTickRateManager = serverWorld.getServer().carpet$getTickRateManager(); + if (serverTickRateManager.runsNormally()) 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 9cad0aea61..3057a1e8aa 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 BlockBehaviourInterface { @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 6b98c1f84d..d6be986576 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 BlockBehaviourInterface { @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 8345096652..64244775b0 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.server.MinecraftServer; import net.minecraft.server.TickTask; @@ -34,6 +33,7 @@ import net.minecraft.world.level.chunk.ChunkStatus; import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.world.level.chunk.storage.RegionFile; + import org.apache.commons.lang3.tuple.Pair; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -45,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; @@ -59,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 @@ -179,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), @@ -279,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(); @@ -288,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); } ) @@ -305,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); @@ -365,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) @@ -374,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); } @@ -389,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; @@ -456,7 +453,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 @@ -473,9 +470,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); } ) @@ -493,7 +490,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 50d0de5e04..19910290a1 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 getTickRateManager() + 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 f83380ab2c..b61679dc63 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..900b58470d 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; @@ -19,8 +18,8 @@ public abstract class CoralFeature_renewableCoralMixin implements CoralFeatureIn @Shadow protected abstract boolean placeFeature(LevelAccessor var1, RandomSource var2, BlockPos var3, BlockState var4); @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..4dbf017636 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..83a1495804 100644 --- a/src/main/java/carpet/mixins/Gui_tablistMixin.java +++ b/src/main/java/carpet/mixins/Gui_tablistMixin.java @@ -1,6 +1,6 @@ package carpet.mixins; -import carpet.fakes.PlayerListHudInterface; +import carpet.fakes.PlayerTabOverlayInterface; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.components.PlayerTabOverlay; @@ -22,7 +22,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/HoneyBlock_customStickyMixin.java b/src/main/java/carpet/mixins/HoneyBlock_customStickyMixin.java index d103e399e9..93c723007f 100644 --- a/src/main/java/carpet/mixins/HoneyBlock_customStickyMixin.java +++ b/src/main/java/carpet/mixins/HoneyBlock_customStickyMixin.java @@ -15,12 +15,12 @@ public class HoneyBlock_customStickyMixin implements BlockBehaviourInterface { @Override - public boolean isSticky(BlockState state) { + public boolean carpet$isSticky(BlockState state) { return true; } @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) { return !neighborState.is(Blocks.SLIME_BLOCK); } } 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..a5db7f6bf7 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(((ItemEntityInterface)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..b88c2b03ba 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); + ((Lighting_scarpetChunkCreationInterface) 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..b10b2dabb0 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,13 +14,13 @@ 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) { + public List carpet$getChunkEntities(ChunkPos chpos) { return this.sectionStorage.getExistingSectionsInChunk(chpos.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 941f61ac32..e1e5b0ecbb 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.ClientLevelInterface; -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 = ((ClientLevelInterface)level).getTickRateManager(); + TickRateManager trm = level.carpet$getTickRateManager(); if (!trm.runsNormally()) - return ((MinecraftClientInferface)minecraft).getPausedTickDelta(); + return minecraft.carpet$getPausedPartialTick(); return previous; } 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 24d97c96f9..9aa83992d7 100644 --- a/src/main/java/carpet/mixins/Level_movableBEMixin.java +++ b/src/main/java/carpet/mixins/Level_movableBEMixin.java @@ -1,6 +1,6 @@ package carpet.mixins; -import carpet.fakes.WorldChunkInterface; +import carpet.fakes.LevelChunkInterface; import carpet.fakes.LevelInterface; import net.minecraft.core.BlockPos; import net.minecraft.server.level.FullChunkStatus; @@ -57,16 +57,16 @@ public abstract class Level_movableBEMixin implements LevelInterface, LevelAcces /** * @author 2No2Name */ - public boolean setBlockStateWithBlockEntity(BlockPos blockPos_1, BlockState blockState_1, BlockEntity newBlockEntity, int int_1) + public boolean carpet$setBlockStateWithBlockEntity(BlockPos blockPos_1, BlockState blockState_1, BlockEntity newBlockEntity, int int_1) { if (isOutsideBuildHeight(blockPos_1) || !this.isClientSide && isDebug()) return false; - LevelChunk worldChunk_1 = this.getChunkAt(blockPos_1); + LevelChunk chunk = this.getChunkAt(blockPos_1); Block block_1 = blockState_1.getBlock(); BlockState blockState_2; if (newBlockEntity != null && block_1 instanceof EntityBlock) { - blockState_2 = ((WorldChunkInterface) worldChunk_1).setBlockStateWithBlockEntity(blockPos_1, blockState_1, newBlockEntity, (int_1 & 64) != 0); + blockState_2 = chunk.carpet$setBlockStateWithBlockEntity(blockPos_1, blockState_1, newBlockEntity, (int_1 & 64) != 0); if (newBlockEntity instanceof LidBlockEntity) { scheduleTick(blockPos_1, block_1, 5); @@ -74,7 +74,7 @@ public boolean setBlockStateWithBlockEntity(BlockPos blockPos_1, BlockState bloc } else { - blockState_2 = worldChunk_1.setBlockState(blockPos_1, blockState_1, (int_1 & 64) != 0); + blockState_2 = chunk.setBlockState(blockPos_1, blockState_1, (int_1 & 64) != 0); } if (blockState_2 == null) @@ -100,7 +100,7 @@ public boolean setBlockStateWithBlockEntity(BlockPos blockPos_1, BlockState bloc this.setBlocksDirty(blockPos_1, blockState_2, blockState_3); } - 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 ((int_1 & 2) != 0 && (!this.isClientSide || (int_1 & 4) == 0) && (this.isClientSide || chunk.getFullStatus() != null && chunk.getFullStatus().isOrAfter(FullChunkStatus.BLOCK_TICKING))) { this.sendBlockUpdated(blockPos_1, blockState_2, blockState_1, int_1); } diff --git a/src/main/java/carpet/mixins/Level_tickMixin.java b/src/main/java/carpet/mixins/Level_tickMixin.java index d562dbfb7b..ae73b6a836 100644 --- a/src/main/java/carpet/mixins/Level_tickMixin.java +++ b/src/main/java/carpet/mixins/Level_tickMixin.java @@ -1,8 +1,6 @@ package carpet.mixins; -import carpet.fakes.ClientLevelInterface; import carpet.fakes.LevelInterface; -import carpet.fakes.MinecraftServerInterface; import carpet.helpers.TickRateManager; import carpet.helpers.ServerTickRateManager; import carpet.utils.CarpetProfiler; @@ -37,11 +35,11 @@ public abstract class Level_tickMixin implements LevelInterface @Override @Unique - public NeighborUpdater getNeighborUpdater() { + public NeighborUpdater carpet$getNeighborUpdater() { return this.neighborUpdater; } - public Map, Entity> getPrecookedMobs() + public Map, Entity> carpet$getPrecookedMobs() { return precookedMobs; } @@ -64,7 +62,7 @@ private void startEntity(Consumer consumer_1, Entity e, CallbackInfo ci) if (!isClientSide) { ServerLevel serverLevel = (ServerLevel) (Object) this; - ServerTickRateManager trm = ((MinecraftServerInterface)serverLevel.getServer()).getTickRateManager(); + ServerTickRateManager trm = serverLevel.getServer().carpet$getTickRateManager(); if (!(trm.runsNormally() || (e instanceof Player))) { ci.cancel(); @@ -73,7 +71,7 @@ private void startEntity(Consumer consumer_1, Entity e, CallbackInfo ci) else { ClientLevel clientLevel = (ClientLevel) (Object) this; - TickRateManager trm = ((ClientLevelInterface)clientLevel).getTickRateManager(); + TickRateManager trm = clientLevel.carpet$getTickRateManager(); if (!(trm.runsNormally() || (e instanceof Player) || trm.isSuperHot() && e.getControllingPassenger() instanceof Player)) { ci.cancel(); 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 525d05371f..fa65cebe97 100644 --- a/src/main/java/carpet/mixins/MinecraftMixin.java +++ b/src/main/java/carpet/mixins/MinecraftMixin.java @@ -1,7 +1,5 @@ package carpet.mixins; -import carpet.CarpetServer; -import carpet.fakes.ClientLevelInterface; import carpet.helpers.TickRateManager; import carpet.fakes.MinecraftInterface; import carpet.network.CarpetClient; @@ -17,7 +15,7 @@ import java.util.Optional; @Mixin(Minecraft.class) -public class MinecraftMixin implements MinecraftInterface +public abstract class MinecraftMixin implements MinecraftInterface { @Shadow public ClientLevel level; @@ -30,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(((ClientLevelInterface)this.level).getTickRateManager()); + 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..0e70a988ac 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$getResourceManager() { 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..35e4a1670d 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 abstract class Minecraft_pausedShakeMixin implements MinecraftInterface { @Shadow private float pausePartialTick; @Override - public float getPausedTickDelta() + public float carpet$getPausedPartialTick() { 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 4f9eb3dd49..9f99d5d4ef 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.track_spawns > 0L && SpawnReporter.local_spawns != null) { @@ -170,7 +169,7 @@ private static void spawnEntity(ServerLevel world, Entity entity_1, entity_1.blockPosition()); } if (!SpawnReporter.mock_spawns) - 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..9467fb2957 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$shouldRenderCarriedBlockEntity()) { - 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..99f1ea059f 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$shouldRenderCarriedBlockEntity() { 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 13abaec9eb..176b2d6ef9 100644 --- a/src/main/java/carpet/mixins/PistonStructureResolver_customStickyMixin.java +++ b/src/main/java/carpet/mixins/PistonStructureResolver_customStickyMixin.java @@ -31,7 +31,7 @@ public class PistonStructureResolver_customStickyMixin { ) ) private static void isSticky(BlockState state, CallbackInfoReturnable cir) { - cir.setReturnValue(((BlockBehaviourInterface)state.getBlock()).isSticky(state)); + cir.setReturnValue(state.getBlock().carpet$isSticky(state)); } // fields that are needed because @Redirects cannot capture locals @@ -60,7 +60,7 @@ private void captureBlockLinePositions(BlockPos pos, Direction fromDir, Callback ) ) private boolean onAddBlockLineCanStickToEachOther(BlockState state, BlockState behindState) { - return ((BlockBehaviourInterface)state.getBlock()).isStickyToNeighbor(level, pos_addBlockLine, state, behindPos_addBlockLine, behindState, pushDirection.getOpposite(), pushDirection); + return state.getBlock().carpet$isStickyToNeighbor(level, pos_addBlockLine, state, behindPos_addBlockLine, behindState, pushDirection.getOpposite(), pushDirection); } // fields that are needed because @Redirects cannot capture locals @@ -89,6 +89,6 @@ private void captureNeighborPositions(BlockPos pos, CallbackInfoReturnable cir) { - ((ServerPlayerInterface)player).invalidateEntityObjectReference(); + player.carpet$invalidateEntityObjectReference(); } @Inject(method = "reloadResources", at = @At("HEAD")) private void reloadCommands(CallbackInfo ci) { - Vanilla.MinecraftServer_getScriptServer(server).reAddCommands(); + server.carpet$getScriptServer().reAddCommands(); } } 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..17b4a9af99 100644 --- a/src/main/java/carpet/mixins/PrimedTntMixin.java +++ b/src/main/java/carpet/mixins/PrimedTntMixin.java @@ -99,7 +99,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 += ((TntEntityInterface) entityTNTPrimed).carpet$getMergedTnt(); entityTNTPrimed.discard(); // discard remove(); } } @@ -119,7 +119,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..e5b45d99a8 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,15 @@ 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 id) + { + super(type, id); + } + @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)) + if(this.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..3ef310c619 100644 --- a/src/main/java/carpet/mixins/RecipeManager_scarpetMixin.java +++ b/src/main/java/carpet/mixins/RecipeManager_scarpetMixin.java @@ -4,7 +4,6 @@ import com.google.common.collect.Lists; import net.minecraft.core.Registry; import net.minecraft.core.RegistryAccess; -import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; import net.minecraft.world.item.Item; import org.spongepowered.asm.mixin.Mixin; @@ -26,7 +25,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..e6b820dfe1 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,7 +24,7 @@ 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) { } @@ -34,11 +34,11 @@ private void updatePowerStrength(Level world_1, BlockPos blockPos_1, BlockState @Override @Accessor("shouldSignal") - public abstract void setWiresGivePower(boolean wiresGivePower); + public abstract void carpet$setShouldSignal(boolean wiresGivePower); @Override @Accessor("shouldSignal") - public abstract boolean getWiresGivePower(); + public abstract boolean carpet$shouldSignal(); // = @@ -67,13 +67,13 @@ public void fastUpdate(Level world, BlockPos pos, BlockState state, BlockPos sou @Inject(method = "updatePowerStrength", at = @At("HEAD"), cancellable = true) private void updateLogicAlternative(Level world, BlockPos pos, BlockState state, CallbackInfo cir) { if (CarpetSettings.fastRedstoneDust) { - updateLogicPublic(world, pos, state); + carpet$updateLogicPublic(world, pos, state); cir.cancel(); } } @Override - public BlockState updateLogicPublic(Level world_1, BlockPos blockPos_1, BlockState blockState_1) { + public BlockState carpet$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) { diff --git a/src/main/java/carpet/mixins/ServerChunkCache_tickMixin.java b/src/main/java/carpet/mixins/ServerChunkCache_tickMixin.java index 34d69c3eb6..60199a91b2 100644 --- a/src/main/java/carpet/mixins/ServerChunkCache_tickMixin.java +++ b/src/main/java/carpet/mixins/ServerChunkCache_tickMixin.java @@ -1,7 +1,6 @@ package carpet.mixins; -import carpet.fakes.MinecraftServerInterface; -import carpet.fakes.ThreadedAnvilChunkStorageInterface; +import carpet.fakes.ChunkMapInterface; import carpet.helpers.ServerTickRateManager; import carpet.utils.CarpetProfiler; import net.minecraft.server.level.DistanceManager; @@ -80,12 +79,12 @@ private void stopSpawningSection(CallbackInfo ci) private boolean skipChunkTicking(ServerLevel serverWorld) { boolean debug = serverWorld.isDebug(); - if (!((MinecraftServerInterface)serverWorld.getServer()).getTickRateManager().runsNormally()) + if (!serverWorld.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 +106,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 d9a8efcf2d..abab26fad1 100644 --- a/src/main/java/carpet/mixins/ServerGamePacketListenerImpl_coreMixin.java +++ b/src/main/java/carpet/mixins/ServerGamePacketListenerImpl_coreMixin.java @@ -26,7 +26,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 927f3a2fea..76783e634e 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 @@ @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) { @@ -95,12 +95,12 @@ private void handleChunkUnload(LevelChunk levelChunk, CallbackInfo ci) @Shadow @Final private PersistentEntitySectionManager entityManager; @Override - public ServerLevelData getWorldPropertiesCM(){ + public ServerLevelData carpet$getLevelData(){ return serverLevelData; } @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 f68add3867..5ec48aca6e 100644 --- a/src/main/java/carpet/mixins/ServerLevel_tickMixin.java +++ b/src/main/java/carpet/mixins/ServerLevel_tickMixin.java @@ -1,6 +1,5 @@ package carpet.mixins; -import carpet.fakes.MinecraftServerInterface; import carpet.utils.CarpetProfiler; import net.minecraft.core.Holder; import net.minecraft.core.RegistryAccess; @@ -159,13 +158,13 @@ private void endRandomTicks(CallbackInfo ci) { )) private void tickWorldBorder(WorldBorder worldBorder) { - if (((MinecraftServerInterface)getServer()).getTickRateManager().runsNormally()) worldBorder.tick(); + if (getServer().carpet$getTickRateManager().runsNormally()) worldBorder.tick(); } @Inject(method = "advanceWeatherCycle", cancellable = true, at = @At("HEAD")) private void tickWeather(CallbackInfo ci) { - if (!((MinecraftServerInterface)getServer()).getTickRateManager().runsNormally()) ci.cancel(); + if (!getServer().carpet$getTickRateManager().runsNormally()) ci.cancel(); } @Redirect(method = "tick", at = @At( @@ -174,7 +173,7 @@ private void tickWeather(CallbackInfo ci) )) private void tickTimeConditionally(ServerLevel serverWorld) { - if (((MinecraftServerInterface)getServer()).getTickRateManager().runsNormally()) tickTime(); + if (getServer().carpet$getTickRateManager().runsNormally()) tickTime(); } @Redirect(method = "tick", at = @At( @@ -183,7 +182,7 @@ private void tickTimeConditionally(ServerLevel serverWorld) )) private boolean tickPendingBlocks(ServerLevel serverWorld) { - if (!((MinecraftServerInterface)getServer()).getTickRateManager().runsNormally()) return true; + if (!getServer().carpet$getTickRateManager().runsNormally()) return true; return serverWorld.isDebug(); // isDebug() } @@ -193,7 +192,7 @@ private boolean tickPendingBlocks(ServerLevel serverWorld) )) private void tickConditionally(Raids raidManager) { - if (((MinecraftServerInterface)getServer()).getTickRateManager().runsNormally()) raidManager.tick(); + if (getServer().carpet$getTickRateManager().runsNormally()) raidManager.tick(); } @Redirect(method = "tick", at = @At( @@ -202,6 +201,6 @@ private void tickConditionally(Raids raidManager) )) private void tickConditionally(ServerLevel serverWorld) { - if (((MinecraftServerInterface)getServer()).getTickRateManager().runsNormally()) runBlockEvents(); + if (getServer().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..b2b7180126 100644 --- a/src/main/java/carpet/mixins/Timer_tickSpeedMixin.java +++ b/src/main/java/carpet/mixins/Timer_tickSpeedMixin.java @@ -20,7 +20,7 @@ public class Timer_tickSpeedMixin { private float adjustTickSpeed(Timer counter) { if (CarpetSettings.smoothClientAnimations) { - Optional trm = ((MinecraftInterface)Minecraft.getInstance()).getTickRateManager(); + Optional trm = ((MinecraftInterface)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 ab7950f542..f6da96cfb8 100644 --- a/src/main/java/carpet/network/ClientNetworkHandler.java +++ b/src/main/java/carpet/network/ClientNetworkHandler.java @@ -67,20 +67,20 @@ public class ClientNetworkHandler } }); dataHandlers.put("TickRate", (p, t) -> { - TickRateManager tickRateManager = ((ClientLevelInterface)p.clientLevel).getTickRateManager(); + TickRateManager tickRateManager = p.clientLevel.carpet$getTickRateManager(); tickRateManager.setTickRate(((NumericTag) t).getAsFloat()); }); dataHandlers.put("TickingState", (p, t) -> { CompoundTag tickingState = (CompoundTag)t; - TickRateManager tickRateManager = ((ClientLevelInterface)p.clientLevel).getTickRateManager(); + TickRateManager tickRateManager = p.clientLevel.carpet$getTickRateManager(); tickRateManager.setFrozenState(tickingState.getBoolean("is_paused"), tickingState.getBoolean("deepFreeze")); }); dataHandlers.put("SuperHotState", (p, t) -> { - TickRateManager tickRateManager = ((ClientLevelInterface)p.clientLevel).getTickRateManager(); + TickRateManager tickRateManager = p.clientLevel.carpet$getTickRateManager(); tickRateManager.setSuperHot(((ByteTag) t).equals(ByteTag.ONE)); }); dataHandlers.put("TickPlayerActiveTimeout", (p, t) -> { - TickRateManager tickRateManager = ((ClientLevelInterface)p.clientLevel).getTickRateManager(); + 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 3a0a0ee80f..747c415389 100644 --- a/src/main/java/carpet/network/ServerNetworkHandler.java +++ b/src/main/java/carpet/network/ServerNetworkHandler.java @@ -4,8 +4,6 @@ import carpet.CarpetSettings; import carpet.api.settings.CarpetRule; import carpet.api.settings.RuleHelper; -import carpet.fakes.MinecraftServerInterface; -import carpet.fakes.ServerGamePacketListenerImplInterface; import carpet.helpers.ServerTickRateManager; import carpet.script.utils.SnoopyCommandSource; import carpet.api.settings.SettingsManager; @@ -54,7 +52,7 @@ public static void handleData(FriendlyByteBuf data, ServerPlayer player) public static void onPlayerJoin(ServerPlayer playerEntity) { - if (!((ServerGamePacketListenerImplInterface)playerEntity.connection).getConnection().isMemoryConnection()) + if (!playerEntity.connection.carpet$getConnection().isMemoryConnection()) { playerEntity.connection.send(new ClientboundCustomPayloadPacket( CarpetClient.CARPET_CHANNEL, @@ -221,7 +219,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); } @@ -260,13 +258,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()); @@ -275,13 +273,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 2c4b8fc023..b11da59633 100644 --- a/src/main/java/carpet/patches/EntityPlayerMPFake.java +++ b/src/main/java/carpet/patches/EntityPlayerMPFake.java @@ -27,7 +27,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; @@ -67,7 +66,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); + server.getPlayerList().placeNewPlayer(new FakeConnection(PacketFlow.SERVERBOUND), instance); instance.teleportTo(worldIn, pos.x, pos.y, pos.z, (float) yaw, (float) pitch); instance.setHealth(20.0F); instance.unsetRemoved(); @@ -89,12 +88,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); + server.getPlayerList().placeNewPlayer(new FakeConnection(PacketFlow.SERVERBOUND), playerShadow); 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..a5a0d6e8aa 100644 --- a/src/main/java/carpet/patches/FakeClientConnection.java +++ b/src/main/java/carpet/patches/FakeConnection.java @@ -1,18 +1,18 @@ 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()); + this.setChannel(new EmbeddedChannel()); } @Override @@ -24,4 +24,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/CarpetEventServer.java b/src/main/java/carpet/script/CarpetEventServer.java index c749b47be1..416477000d 100644 --- a/src/main/java/carpet/script/CarpetEventServer.java +++ b/src/main/java/carpet/script/CarpetEventServer.java @@ -251,7 +251,7 @@ public boolean call(Supplier> argumentSupplier, Supplier ctx, String hostName, FunctionArgument funcSpec, List paramNames) throws CommandSyntaxException { Runnable token = Carpet.startProfilerSection("Scarpet command"); - CarpetScriptServer scriptServer = Vanilla.MinecraftServer_getScriptServer(ctx.getSource().getServer()); + CarpetScriptServer scriptServer = ctx.getSource().getServer().carpet$getScriptServer(); CarpetScriptHost cHost = scriptServer.modules.get(hostName).retrieveOwnForExecution(ctx.getSource()); List argNames = funcSpec.function.getArguments(); if ((argNames.size() - funcSpec.args.size()) != paramNames.size()) diff --git a/src/main/java/carpet/script/EntityEventsGroup.java b/src/main/java/carpet/script/EntityEventsGroup.java index 7f59f210f9..02c85a9abe 100644 --- a/src/main/java/carpet/script/EntityEventsGroup.java +++ b/src/main/java/carpet/script/EntityEventsGroup.java @@ -46,7 +46,7 @@ public void onEvent(Event type, Object... args) { return; } - CarpetScriptServer scriptServer = Vanilla.MinecraftServer_getScriptServer(entity.getServer()); + CarpetScriptServer scriptServer = entity.getServer().carpet$getScriptServer(); if (scriptServer.stopAll) { return; // executed after world is closin down diff --git a/src/main/java/carpet/script/ScriptCommand.java b/src/main/java/carpet/script/ScriptCommand.java index 7ea254405b..56741f72ae 100644 --- a/src/main/java/carpet/script/ScriptCommand.java +++ b/src/main/java/carpet/script/ScriptCommand.java @@ -140,7 +140,7 @@ private static CompletableFuture suggestDownloadableApps( private static CarpetScriptServer ss(CommandContext context) { - return Vanilla.MinecraftServer_getScriptServer(context.getSource().getServer()); + return context.getSource().getServer().carpet$getScriptServer(); } public static void register(CommandDispatcher dispatcher, CommandBuildContext commandBuildContext) diff --git a/src/main/java/carpet/script/api/Auxiliary.java b/src/main/java/carpet/script/api/Auxiliary.java index 3ad9f989ec..bcf421d759 100644 --- a/src/main/java/carpet/script/api/Auxiliary.java +++ b/src/main/java/carpet/script/api/Auxiliary.java @@ -1,6 +1,5 @@ package carpet.script.api; -import carpet.script.external.Vanilla; import carpet.script.utils.FeatureGenerator; import carpet.script.argument.FileArgument; import carpet.script.CarpetContext; @@ -768,7 +767,7 @@ else if (!interactable && targetBlock == null) try { scriptServer.tickDepth++; - Vanilla.MinecraftServer_forceTick(server, () -> System.nanoTime() - scriptServer.tickStart < 50000000L); + server.carpet$forceTick(() -> System.nanoTime() - scriptServer.tickStart < 50000000L); if (!lv.isEmpty()) { long msTotal = NumericValue.asNumber(lv.get(0)).getLong(); @@ -814,7 +813,7 @@ else if (!interactable && targetBlock == null) BlockArgument locator = BlockArgument.findIn(cc, lv, 0); BlockPos pos = locator.block.getPos(); ServerLevel world = cc.level(); - Vanilla.ChunkMap_relightChunk(world.getChunkSource().chunkMap, new ChunkPos(pos)); + world.getChunkSource().chunkMap.carpet$relightChunk(new ChunkPos(pos)); WorldTools.forceChunkUpdate(pos, world); return Value.TRUE; }); diff --git a/src/main/java/carpet/script/api/Inventories.java b/src/main/java/carpet/script/api/Inventories.java index 327ea5fcf0..4337fb6dff 100644 --- a/src/main/java/carpet/script/api/Inventories.java +++ b/src/main/java/carpet/script/api/Inventories.java @@ -6,7 +6,6 @@ import carpet.script.exception.InternalExpressionException; import carpet.script.exception.ThrowStatement; import carpet.script.exception.Throwables; -import carpet.script.external.Vanilla; import carpet.script.utils.InputValidator; import carpet.script.value.BooleanValue; import carpet.script.value.EntityValue; @@ -115,7 +114,7 @@ public static void apply(Expression expression) throw new InternalExpressionException("Unknown recipe type: "+recipeType); } } - List> recipes = Vanilla.RecipeManager_getAllMatching(cc.server().getRecipeManager(), type, InputValidator.identifierOf(recipeName), cc.registryAccess()); + List> recipes = cc.server().getRecipeManager().carpet$getAllMatching(type, InputValidator.identifierOf(recipeName), cc.registryAccess()); if (recipes.isEmpty()) { return Value.NULL; @@ -130,7 +129,7 @@ public static void apply(Expression expression) // I am flattening ingredient lists per slot. // consider recipe_data('wooden_sword','crafting') and ('iron_nugget', 'blasting') and notice difference // in depths of lists. - List> stacks = Vanilla.Ingredient_getRecipeStacks(ingredient); + List> stacks = ingredient.carpet$getRecipeStacks(); if (stacks.isEmpty()) { ingredientValue.add(Value.NULL); diff --git a/src/main/java/carpet/script/api/Monitoring.java b/src/main/java/carpet/script/api/Monitoring.java index 5f232af020..8f5f4fe784 100644 --- a/src/main/java/carpet/script/api/Monitoring.java +++ b/src/main/java/carpet/script/api/Monitoring.java @@ -3,13 +3,13 @@ import carpet.script.CarpetContext; import carpet.script.Expression; import carpet.script.exception.InternalExpressionException; -import carpet.script.external.Vanilla; import carpet.script.utils.SystemInfo; import carpet.script.value.ListValue; import carpet.script.value.MapValue; import carpet.script.value.NumericValue; import carpet.script.value.StringValue; import carpet.script.value.Value; +import carpet.utils.SpawnReporter; import it.unimi.dsi.fastutil.objects.Object2IntMap; import java.util.Arrays; @@ -64,7 +64,7 @@ public static void apply(Expression expression) Map retDict = new HashMap<>(); for (MobCategory category : mobcounts.keySet()) { - int currentCap = category.getMaxInstancesPerChunk() * chunks / Vanilla.NaturalSpawner_MAGIC_NUMBER(); + int currentCap = category.getMaxInstancesPerChunk() * chunks / SpawnReporter.MAGIC_NUMBER; retDict.put( new StringValue(category.getSerializedName().toLowerCase(Locale.ROOT)), ListValue.of( @@ -82,7 +82,7 @@ public static void apply(Expression expression) } return ListValue.of( new NumericValue(mobcounts.getInt(cat)), - new NumericValue((long) cat.getMaxInstancesPerChunk() * chunks / Vanilla.NaturalSpawner_MAGIC_NUMBER()) + new NumericValue((long) cat.getMaxInstancesPerChunk() * chunks / SpawnReporter.MAGIC_NUMBER) ); }); } diff --git a/src/main/java/carpet/script/api/WorldAccess.java b/src/main/java/carpet/script/api/WorldAccess.java index eb757a9b8f..a33f17ac5f 100644 --- a/src/main/java/carpet/script/api/WorldAccess.java +++ b/src/main/java/carpet/script/api/WorldAccess.java @@ -438,7 +438,7 @@ else if (!("any".equals(statusString))) } Value weather = lv.get(0); - ServerLevelData worldProperties = Vanilla.ServerLevel_getWorldProperties(world); + ServerLevelData worldProperties = world.carpet$getLevelData(); if (lv.size() == 1) { return new NumericValue(switch (weather.getString().toLowerCase(Locale.ROOT)) @@ -639,7 +639,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 = foo.carpet$getTicketsByPosition(); List res = new ArrayList<>(); if (lv.isEmpty()) @@ -1634,7 +1634,7 @@ LivingEntity getIndirectSourceEntity() Value[] result = new Value[]{Value.NULL}; ((CarpetContext) c).server().executeBlocking(() -> { - Map report = Vanilla.ChunkMap_regenerateChunkRegion(world.getChunkSource().chunkMap, requestedChunks); + Map report = world.getChunkSource().chunkMap.carpet$regenerateChunkRegion(requestedChunks); result[0] = MapValue.wrap(report.entrySet().stream().collect(Collectors.toMap( e -> new StringValue(e.getKey()), e -> new NumericValue(e.getValue()) @@ -1662,7 +1662,7 @@ LivingEntity getIndirectSourceEntity() requiredCharge = NumericValue.asNumber(lv.get(locator.offset)).getDouble(); } NaturalSpawner.SpawnState charger = cc.level().getChunkSource().getLastSpawnState(); - return charger == null ? Value.NULL : new NumericValue(Vanilla.SpawnState_getPotentialCalculator(charger).getPotentialEnergyChange(pos, requiredCharge) + return charger == null ? Value.NULL : new NumericValue(charger.carpet$getPotentialCalculator().getPotentialEnergyChange(pos, requiredCharge) ); }); @@ -1790,7 +1790,7 @@ public static double sampleNoise(NoiseRouter router, ServerLevel level, String w noiseBasedChunkGenerator.generatorSettings().value(), level.registryAccess().lookupOrThrow(Registries.NOISE), level.getSeed() ); - DensityFunction.Visitor visitor = Vanilla.RandomState_getVisitor(randomState); + DensityFunction.Visitor visitor = randomState.carpet$getVisitor(); return densityFunction.mapAll(visitor); } diff --git a/src/main/java/carpet/script/command/CommandArgument.java b/src/main/java/carpet/script/command/CommandArgument.java index 93276819fd..9e345295eb 100644 --- a/src/main/java/carpet/script/command/CommandArgument.java +++ b/src/main/java/carpet/script/command/CommandArgument.java @@ -4,7 +4,6 @@ import carpet.script.CarpetScriptServer; import carpet.script.argument.FunctionArgument; import carpet.script.external.Carpet; -import carpet.script.external.Vanilla; import carpet.script.value.BlockValue; import carpet.script.value.BooleanValue; import carpet.script.value.EntityValue; @@ -136,7 +135,7 @@ public static CommandSyntaxException error(String text) new VanillaUnconfigurableArgument("block", BlockStateArgument::block, (c, p) -> { BlockInput result = BlockStateArgument.getBlock(c, p); - return new BlockValue(result.getState(), c.getSource().getLevel(), Vanilla.BlockInput_getTag(result)); + return new BlockValue(result.getState(), c.getSource().getLevel(), result.carpet$getTag()); }, param -> (ctx, builder) -> ctx.getArgument(param, BlockStateArgument.class).listSuggestions(ctx, builder) ), diff --git a/src/main/java/carpet/script/external/Carpet.java b/src/main/java/carpet/script/external/Carpet.java index 21182959dc..f75e008f29 100644 --- a/src/main/java/carpet/script/external/Carpet.java +++ b/src/main/java/carpet/script/external/Carpet.java @@ -6,7 +6,6 @@ import carpet.api.settings.RuleHelper; import carpet.api.settings.SettingsManager; import carpet.api.settings.Validator; -import carpet.fakes.MinecraftServerInterface; import carpet.logging.HUDController; import carpet.network.ServerNetworkHandler; import carpet.patches.EntityPlayerMPFake; @@ -89,7 +88,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) @@ -135,7 +134,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..5d4a57c11f 100644 --- a/src/main/java/carpet/script/external/Vanilla.java +++ b/src/main/java/carpet/script/external/Vanilla.java @@ -1,133 +1,45 @@ package carpet.script.external; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.function.Predicate; + +import com.mojang.brigadier.CommandDispatcher; + 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; import carpet.network.ServerNetworkHandler; -import carpet.script.CarpetScriptServer; -import carpet.script.EntityEventsGroup; import carpet.script.value.MapValue; import carpet.script.value.StringValue; import carpet.script.value.Value; import carpet.utils.CommandHelper; -import carpet.utils.SpawnReporter; -import com.mojang.brigadier.CommandDispatcher; -import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; + import net.fabricmc.loader.api.FabricLoader; import net.fabricmc.loader.api.ModContainer; + import net.minecraft.commands.CommandSourceStack; -import net.minecraft.commands.arguments.blocks.BlockInput; -import net.minecraft.core.BlockPos; -import net.minecraft.core.RegistryAccess; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.Tag; -import net.minecraft.resources.ResourceLocation; import net.minecraft.server.MinecraftServer; -import net.minecraft.server.level.ChunkMap; -import net.minecraft.server.level.DistanceManager; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; -import net.minecraft.server.level.ServerPlayerGameMode; -import net.minecraft.server.level.Ticket; import net.minecraft.tags.TagKey; -import net.minecraft.util.SortedArraySet; -import net.minecraft.world.Container; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.entity.Mob; -import net.minecraft.world.entity.ai.goal.Goal; -import net.minecraft.world.entity.ai.goal.GoalSelector; import net.minecraft.world.entity.ai.village.poi.PoiRecord; -import net.minecraft.world.entity.animal.horse.AbstractHorse; -import net.minecraft.world.entity.item.ItemEntity; -import net.minecraft.world.inventory.AbstractContainerMenu; -import net.minecraft.world.inventory.DataSlot; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.crafting.Ingredient; -import net.minecraft.world.item.crafting.Recipe; -import net.minecraft.world.item.crafting.RecipeManager; -import net.minecraft.world.item.crafting.RecipeType; -import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.GameRules; -import net.minecraft.world.level.NaturalSpawner; -import net.minecraft.world.level.PotentialCalculator; -import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.pattern.BlockInWorld; -import net.minecraft.world.level.levelgen.DensityFunction; -import net.minecraft.world.level.levelgen.RandomState; -import net.minecraft.world.level.storage.LevelStorageSource; -import net.minecraft.world.level.storage.ServerLevelData; import net.minecraft.world.scores.Objective; import net.minecraft.world.scores.Scoreboard; import net.minecraft.world.scores.criteria.ObjectiveCriteria; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.function.BooleanSupplier; -import java.util.function.Predicate; - public class Vanilla { - public static void MinecraftServer_forceTick(MinecraftServer server, BooleanSupplier sup) - { - ((MinecraftServerInterface) server).forceTick(sup); - } - - public static void ChunkMap_relightChunk(ChunkMap chunkMap, ChunkPos pos) - { - ((ThreadedAnvilChunkStorageInterface) chunkMap).relightChunk(pos); - } - - public static Map ChunkMap_regenerateChunkRegion(ChunkMap chunkMap, List requestedChunks) - { - return ((ThreadedAnvilChunkStorageInterface) chunkMap).regenerateChunkRegion(requestedChunks); - } - - public static List> Ingredient_getRecipeStacks(Ingredient ingredient) - { - return ((IngredientInterface) (Object) ingredient).getRecipeStacks(); - } - - public static List> RecipeManager_getAllMatching(RecipeManager recipeManager, RecipeType type, ResourceLocation output, RegistryAccess registryAccess) - { - return ((RecipeManagerInterface) recipeManager).getAllMatching(type, output, registryAccess); - } - - public static int NaturalSpawner_MAGIC_NUMBER() - { - return SpawnReporter.MAGIC_NUMBER; - } - - public static PotentialCalculator SpawnState_getPotentialCalculator(NaturalSpawner.SpawnState spawnState) - { - return ((SpawnHelperInnerInterface) spawnState).getPotentialCalculator(); - } - public static void Objective_setCriterion(Objective objective, ObjectiveCriteria criterion) { ((Objective_scarpetMixin) objective).setCriterion(criterion); @@ -138,36 +50,6 @@ public static Map> Scoreboard_getObjectivesBy return ((Scoreboard_scarpetMixin) scoreboard).getObjectivesByCriterion(); } - public static ServerLevelData ServerLevel_getWorldProperties(ServerLevel world) - { - return ((ServerWorldInterface) world).getWorldPropertiesCM(); - } - - public static Long2ObjectOpenHashMap>> ChunkTicketManager_getTicketsByPosition(DistanceManager ticketManager) - { - return ((ChunkTicketManagerInterface) ticketManager).getTicketsByPosition(); - } - - public static DensityFunction.Visitor RandomState_getVisitor(RandomState randomState) - { - return ((RandomStateVisitorAccessor) (Object) randomState).getVisitor(); - } - - public static CompoundTag BlockInput_getTag(BlockInput blockInput) - { - return ((BlockStateArgumentInterface) blockInput).getCMTag(); - } - - public static CarpetScriptServer MinecraftServer_getScriptServer(MinecraftServer server) - { - return ((MinecraftServerInterface) server).getScriptServer(); - } - - public static Biome.ClimateSettings Biome_getClimateSettings(Biome biome) - { - return ((BiomeInterface) (Object) biome).getClimateSettings(); - } - public static ThreadLocal skipGenerationChecks(ServerLevel level) { // not sure does vanilla care at all - needs checking return CarpetSettings.skipGenerationChecks; @@ -203,111 +85,6 @@ public static MapValue getServerMods(MinecraftServer server) return MapValue.wrap(ret); } - public static LevelStorageSource.LevelStorageAccess MinecraftServer_storageSource(MinecraftServer server) - { - return ((MinecraftServerInterface) server).getCMSession(); - } - - public static BlockPos ServerPlayerGameMode_getCurrentBlockPosition(ServerPlayerGameMode gameMode) - { - return ((ServerPlayerInteractionManagerInterface) gameMode).getCurrentBreakingBlock(); - } - - public static int ServerPlayerGameMode_getCurrentBlockBreakingProgress(ServerPlayerGameMode gameMode) - { - return ((ServerPlayerInteractionManagerInterface) gameMode).getCurrentBlockBreakingProgress(); - } - - public static void ServerPlayerGameMode_setBlockBreakingProgress(ServerPlayerGameMode gameMode, int progress) - { - ((ServerPlayerInteractionManagerInterface) gameMode).setBlockBreakingProgress(progress); - } - - public static boolean ServerPlayer_isInvalidEntityObject(ServerPlayer player) - { - return ((ServerPlayerInterface) player).isInvalidEntityObject(); - } - - public static String ServerPlayer_getLanguage(ServerPlayer player) - { - return ((ServerPlayerInterface) player).getLanguage(); - } - - public static GoalSelector Mob_getAI(Mob mob, boolean target) - { - return ((MobEntityInterface) mob).getAI(target); - } - - public static Map Mob_getTemporaryTasks(Mob mob) - { - return ((MobEntityInterface) mob).getTemporaryTasks(); - } - - public static void Mob_setPersistence(Mob mob, boolean what) - { - ((MobEntityInterface) mob).setPersistence(what); - } - - public static EntityEventsGroup Entity_getEventContainer(Entity entity) - { - return ((EntityInterface) entity).getEventContainer(); - } - - public static boolean Entity_isPermanentVehicle(Entity entity) - { - return ((EntityInterface) entity).isPermanentVehicle(); - } - - public static void Entity_setPermanentVehicle(Entity entity, boolean permanent) - { - ((EntityInterface) entity).setPermanentVehicle(permanent); - } - - public static int Entity_getPortalTimer(Entity entity) - { - return ((EntityInterface) entity).getPortalTimer(); - } - - public static void Entity_setPortalTimer(Entity entity, int amount) - { - ((EntityInterface) entity).setPortalTimer(amount); - } - - public static int Entity_getPublicNetherPortalCooldown(Entity entity) - { - return ((EntityInterface) entity).getPublicNetherPortalCooldown(); - } - - public static void Entity_setPublicNetherPortalCooldown(Entity entity, int what) - { - ((EntityInterface) entity).setPublicNetherPortalCooldown(what); - } - - public static int ItemEntity_getPickupDelay(ItemEntity entity) - { - return ((ItemEntityInterface) entity).getPickupDelayCM(); - } - - public static boolean LivingEntity_isJumping(LivingEntity entity) - { - return ((LivingEntityInterface) entity).isJumpingCM(); - } - - public static void LivingEntity_setJumping(LivingEntity entity) - { - ((LivingEntityInterface) entity).doJumpCM(); - } - - public static Container AbstractHorse_getInventory(AbstractHorse horse) - { - return ((InventoryBearerInterface) horse).getCMInventory(); - } - - public static DataSlot AbstractContainerMenu_getDataSlot(AbstractContainerMenu handler, int index) - { - return ((AbstractContainerMenuInterface) handler).getDataSlot(index); - } - public static void CommandDispatcher_unregisterCommand(CommandDispatcher dispatcher, String name) { ((CommandDispatcherInterface) dispatcher).carpet$unregister(name); @@ -362,8 +139,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/script/utils/AppStoreManager.java b/src/main/java/carpet/script/utils/AppStoreManager.java index 76ebccf86a..4ef7e24f87 100644 --- a/src/main/java/carpet/script/utils/AppStoreManager.java +++ b/src/main/java/carpet/script/utils/AppStoreManager.java @@ -4,7 +4,6 @@ import carpet.script.CarpetScriptServer; import carpet.script.exception.InternalExpressionException; import carpet.script.external.Carpet; -import carpet.script.external.Vanilla; import carpet.script.value.MapValue; import carpet.script.value.StringValue; import carpet.script.value.Value; @@ -279,7 +278,7 @@ private static int downloadScript(CommandSourceStack source, String path, AppInf { return 0; } - boolean success = Vanilla.MinecraftServer_getScriptServer(source.getServer()).addScriptHost(source, nodeInfo.name().replaceFirst("\\.sc$", ""), null, true, false, false, nodeInfo.source()); + boolean success = source.getServer().carpet$getScriptServer().addScriptHost(source, nodeInfo.name().replaceFirst("\\.sc$", ""), null, true, false, false, nodeInfo.source()); return success ? 1 : 0; } diff --git a/src/main/java/carpet/script/utils/BiomeInfo.java b/src/main/java/carpet/script/utils/BiomeInfo.java index 4cd077603f..fae46d03dc 100644 --- a/src/main/java/carpet/script/utils/BiomeInfo.java +++ b/src/main/java/carpet/script/utils/BiomeInfo.java @@ -1,6 +1,5 @@ package carpet.script.utils; -import carpet.script.external.Vanilla; import carpet.script.value.ListValue; import carpet.script.value.NumericValue; import carpet.script.value.StringValue; @@ -30,7 +29,7 @@ public class BiomeInfo put("sky_color", (w, b) -> ValueConversions.ofRGB(b.getSpecialEffects().getSkyColor())); put("water_color", (w, b) -> ValueConversions.ofRGB(b.getSpecialEffects().getWaterColor())); put("water_fog_color", (w, b) -> ValueConversions.ofRGB(b.getSpecialEffects().getWaterFogColor())); - put("humidity", (w, b) -> NumericValue.of(Vanilla.Biome_getClimateSettings(b).downfall())); + put("humidity", (w, b) -> NumericValue.of(b.carpet$getClimateSettings().downfall())); put("precipitation", (w, b) -> StringValue.of(b.getPrecipitationAt(new BlockPos(0, w.getSeaLevel(), 0)).name().toLowerCase(Locale.ROOT))); put("features", (w, b) -> { Registry> registry = w.registryAccess().registryOrThrow(Registries.CONFIGURED_FEATURE); diff --git a/src/main/java/carpet/script/utils/WorldTools.java b/src/main/java/carpet/script/utils/WorldTools.java index 548b760457..563a4c3217 100644 --- a/src/main/java/carpet/script/utils/WorldTools.java +++ b/src/main/java/carpet/script/utils/WorldTools.java @@ -1,7 +1,6 @@ package carpet.script.utils; //import carpet.fakes.MinecraftServerInterface; -import carpet.script.external.Vanilla; //import net.fabricmc.api.EnvType; //import net.fabricmc.api.Environment; import net.minecraft.Util; @@ -61,7 +60,7 @@ public static boolean canHasChunk(ServerLevel world, ChunkPos chpos, @Nullable M } return region.hasChunk(chpos); } - Path regionsFolder = Vanilla.MinecraftServer_storageSource(world.getServer()).getDimensionPath(world.dimension()).resolve("region"); + Path regionsFolder = world.getServer().carpet$getStorageSource().getDimensionPath(world.dimension()).resolve("region"); Path regionPath = regionsFolder.resolve(currentRegionName); if (!regionPath.toFile().exists()) { diff --git a/src/main/java/carpet/script/value/EntityValue.java b/src/main/java/carpet/script/value/EntityValue.java index 24565a1dd7..aed62fc285 100644 --- a/src/main/java/carpet/script/value/EntityValue.java +++ b/src/main/java/carpet/script/value/EntityValue.java @@ -1,6 +1,5 @@ package carpet.script.value; -import carpet.script.external.Vanilla; import carpet.script.utils.Tracer; import carpet.script.CarpetContext; import carpet.script.CarpetScriptServer; @@ -131,7 +130,7 @@ public static Collection getEntitiesFromSelector(CommandSource public Entity getEntity() { - if (entity instanceof final ServerPlayer serverPlayer && Vanilla.ServerPlayer_isInvalidEntityObject(serverPlayer)) + if (entity instanceof final ServerPlayer serverPlayer && serverPlayer.carpet$isInvalidEntityObject()) { ServerPlayer newPlayer = entity.getServer().getPlayerList().getPlayer(entity.getUUID()); if (newPlayer != null) @@ -444,7 +443,7 @@ public Value get(String what, @Nullable Value arg) put("is_ridden", (e, a) -> BooleanValue.of(e.isVehicle())); put("passengers", (e, a) -> ListValue.wrap(e.getPassengers().stream().map(EntityValue::new))); put("mount", (e, a) -> (e.getVehicle() != null) ? new EntityValue(e.getVehicle()) : Value.NULL); - put("unmountable", (e, a) -> BooleanValue.of(Vanilla.Entity_isPermanentVehicle(e))); + put("unmountable", (e, a) -> BooleanValue.of(e.carpet$isPermanentVehicle())); // deprecated put("tags", (e, a) -> ListValue.wrap(e.getTags().stream().map(StringValue::new))); @@ -500,9 +499,9 @@ public Value get(String what, @Nullable Value arg) put("offering_flower", (e, a) -> e instanceof final IronGolem ig ? BooleanValue.of(ig.getOfferFlowerTick() > 0) : Value.NULL); put("item", (e, a) -> e instanceof final ItemEntity ie ? ValueConversions.of(ie.getItem(), e.getServer().registryAccess()) : e instanceof final ItemFrame frame ? ValueConversions.of(frame.getItem(), e.getServer().registryAccess()) : Value.NULL); put("count", (e, a) -> (e instanceof final ItemEntity ie) ? new NumericValue(ie.getItem().getCount()) : Value.NULL); - put("pickup_delay", (e, a) -> (e instanceof final ItemEntity ie) ? new NumericValue(Vanilla.ItemEntity_getPickupDelay(ie)) : Value.NULL); - put("portal_cooldown", (e, a) -> new NumericValue(Vanilla.Entity_getPublicNetherPortalCooldown(e))); - put("portal_timer", (e, a) -> new NumericValue(Vanilla.Entity_getPortalTimer(e))); + put("pickup_delay", (e, a) -> (e instanceof final ItemEntity ie) ? new NumericValue(ie.carpet$getPickupDelay()) : Value.NULL); + put("portal_cooldown", (e, a) -> new NumericValue(e.carpet$getPublicNetherPortalCooldown())); + put("portal_timer", (e, a) -> new NumericValue(e.carpet$getPortalTimer())); // ItemEntity -> despawn timer via ssGetAge put("is_baby", (e, a) -> (e instanceof final LivingEntity le) ? BooleanValue.of(le.isBaby()) : Value.NULL); put("target", (e, a) -> { @@ -539,7 +538,7 @@ public Value get(String what, @Nullable Value arg) put("swimming", (e, a) -> e.isSwimming() ? Value.TRUE : Value.FALSE); put("swinging", (e, a) -> e instanceof final LivingEntity le ? BooleanValue.of(le.swinging) : Value.NULL); put("air", (e, a) -> new NumericValue(e.getAirSupply())); - put("language", (e, a) -> !(e instanceof final ServerPlayer p) ? NULL : StringValue.of(Vanilla.ServerPlayer_getLanguage(p))); + put("language", (e, a) -> !(e instanceof final ServerPlayer p) ? NULL : StringValue.of(p.carpet$getLanguage())); put("persistence", (e, a) -> e instanceof final Mob mob ? BooleanValue.of(mob.isPersistenceRequired()) : Value.NULL); put("hunger", (e, a) -> e instanceof final Player player ? new NumericValue(player.getFoodData().getFoodLevel()) : Value.NULL); put("saturation", (e, a) -> e instanceof final Player player ? new NumericValue(player.getFoodData().getSaturationLevel()) : Value.NULL); @@ -549,7 +548,7 @@ public Value get(String what, @Nullable Value arg) put("xp_level", (e, a) -> e instanceof final Player player ? new NumericValue(player.experienceLevel) : Value.NULL); put("xp_progress", (e, a) -> e instanceof final Player player ? new NumericValue(player.experienceProgress) : Value.NULL); put("score", (e, a) -> e instanceof final Player player ? new NumericValue(player.getScore()) : Value.NULL); - put("jumping", (e, a) -> e instanceof final LivingEntity le ? Vanilla.LivingEntity_isJumping(le) ? Value.TRUE : Value.FALSE : Value.NULL); + put("jumping", (e, a) -> e instanceof final LivingEntity le ? le.carpet$isJumping() ? Value.TRUE : Value.FALSE : Value.NULL); put("gamemode", (e, a) -> e instanceof final ServerPlayer sp ? new StringValue(sp.gameMode.getGameModeForPlayer().getName()) : Value.NULL); put("path", (e, a) -> { if (e instanceof final Mob mob) @@ -699,7 +698,7 @@ public Value get(String what, @Nullable Value arg) put("active_block", (e, a) -> { if (e instanceof final ServerPlayer sp) { - BlockPos pos = Vanilla.ServerPlayerGameMode_getCurrentBlockPosition(sp.gameMode); + BlockPos pos = sp.gameMode.carpet$getCurrentBreakingBlock(); if (pos == null) { return Value.NULL; @@ -712,7 +711,7 @@ public Value get(String what, @Nullable Value arg) put("breaking_progress", (e, a) -> { if (e instanceof final ServerPlayer sp) { - int progress = Vanilla.ServerPlayerGameMode_getCurrentBlockBreakingProgress (sp.gameMode); + int progress = sp.gameMode.carpet$getCurrentBlockBreakingProgress(); return progress < 0 ? Value.NULL : new NumericValue(progress); } return Value.NULL; @@ -1206,7 +1205,7 @@ private static void updateVelocity(Entity e, double scale) { v = Value.TRUE; } - Vanilla.Mob_setPersistence(mob, v.getBoolean()); + mob.carpet$setPersistence(v.getBoolean()); }); put("dismount", (e, v) -> e.stopRiding()); @@ -1220,7 +1219,7 @@ private static void updateVelocity(Entity e, double scale) sp.connection.send(new ClientboundSetPassengersPacket(e)); } }); - put("unmountable", (e, v) -> Vanilla.Entity_setPermanentVehicle(e, v == null || v.getBoolean())); + put("unmountable", (e, v) -> e.carpet$setPermanentVehicle(v == null || v.getBoolean())); put("drop_passengers", (e, v) -> e.ejectPassengers()); put("mount_passengers", (e, v) -> { if (v == null) @@ -1310,8 +1309,8 @@ else if (v instanceof final ListValue lv) if (v.isNull()) { ec.restrictTo(BlockPos.ZERO, -1); - Map tasks = Vanilla.Mob_getTemporaryTasks(ec); - Vanilla.Mob_getAI(ec, false).removeGoal(tasks.get("home")); + Map tasks = ec.carpet$getTemporaryTasks(); + ec.carpet$getAi(false).removeGoal(tasks.get("home")); tasks.remove("home"); return; } @@ -1343,12 +1342,12 @@ else if (v instanceof final ListValue lv) } ec.restrictTo(pos, distance); - Map tasks = Vanilla.Mob_getTemporaryTasks(ec); + Map tasks = ec.carpet$getTemporaryTasks(); if (!tasks.containsKey("home")) { Goal task = new MoveTowardsRestrictionGoal(ec, 1.0D); tasks.put("home", task); - Vanilla.Mob_getAI(ec, false).addGoal(10, task); + ec.carpet$getAi(false).addGoal(10, task); } }); //requires mixing @@ -1424,7 +1423,7 @@ else if (a.isNull()) { throw new InternalExpressionException("'portal_cooldown' requires a value to set"); } - Vanilla.Entity_setPublicNetherPortalCooldown(e, NumericValue.asNumber(v).getInt()); + e.carpet$setPublicNetherPortalCooldown(NumericValue.asNumber(v).getInt()); }); put("portal_timer", (e, v) -> @@ -1433,7 +1432,7 @@ else if (a.isNull()) { throw new InternalExpressionException("'portal_timer' requires a value to set"); } - Vanilla.Entity_setPortalTimer(e, NumericValue.asNumber(v).getInt()); + e.carpet$setPortalTimer(NumericValue.asNumber(v).getInt()); }); put("ai", (e, v) -> @@ -1551,7 +1550,7 @@ else if (v instanceof final ListValue lv) put("jump", (e, v) -> { if (e instanceof final LivingEntity le) { - Vanilla.LivingEntity_setJumping(le); + le.carpet$doJump(); } else { @@ -1665,7 +1664,7 @@ else if (v instanceof final ListValue lv) if (e instanceof final ServerPlayer sp) { int progress = (a == null || a.isNull()) ? -1 : NumericValue.asNumber(a).getInt(); - Vanilla.ServerPlayerGameMode_setBlockBreakingProgress(sp.gameMode, progress); + sp.gameMode.carpet$setBlockBreakingProgress(progress); } }); @@ -1733,7 +1732,7 @@ public void setEvent(CarpetContext cc, String eventName, FunctionValue fun, List { throw new InternalExpressionException("Unknown entity event: " + eventName); } - Vanilla.Entity_getEventContainer(getEntity()).addEvent(event, cc.host, fun, args); + getEntity().carpet$getEventContainer().addEvent(event, cc.host, fun, args); } @Override diff --git a/src/main/java/carpet/script/value/NBTSerializableValue.java b/src/main/java/carpet/script/value/NBTSerializableValue.java index 2c367517ef..eeff5fa902 100644 --- a/src/main/java/carpet/script/value/NBTSerializableValue.java +++ b/src/main/java/carpet/script/value/NBTSerializableValue.java @@ -4,7 +4,6 @@ import carpet.script.exception.InternalExpressionException; import carpet.script.exception.ThrowStatement; import carpet.script.exception.Throwables; -import carpet.script.external.Vanilla; import carpet.script.utils.EquipmentInventory; import com.mojang.brigadier.StringReader; import com.mojang.brigadier.exceptions.CommandSyntaxException; @@ -293,7 +292,7 @@ else if (e instanceof final InventoryCarrier io) } else if (e instanceof final AbstractHorse ibi) { - inv = Vanilla.AbstractHorse_getInventory(ibi); // horse only + inv = ibi.carpet$getInventory(); // horse only } else if (e instanceof final LivingEntity le) { diff --git a/src/main/java/carpet/script/value/ScreenValue.java b/src/main/java/carpet/script/value/ScreenValue.java index faa177b798..26922f7fca 100644 --- a/src/main/java/carpet/script/value/ScreenValue.java +++ b/src/main/java/carpet/script/value/ScreenValue.java @@ -280,7 +280,7 @@ private DataSlot getPropertyForType(Class scree { if (screenHandlerClass.isInstance(this.screenHandler)) { - return Vanilla.AbstractContainerMenu_getDataSlot(this.screenHandler, propertyIndex); + return this.screenHandler.carpet$getDataSlot(propertyIndex); } if (!this.isOpen()) { diff --git a/src/main/java/carpet/utils/SpawnChunks.java b/src/main/java/carpet/utils/SpawnChunks.java index 1d7042ca1a..5be55c5ea9 100644 --- a/src/main/java/carpet/utils/SpawnChunks.java +++ b/src/main/java/carpet/utils/SpawnChunks.java @@ -1,6 +1,6 @@ package carpet.utils; -import carpet.fakes.ChunkTicketManagerInterface; +import carpet.fakes.DistanceManagerInterface; import net.minecraft.core.BlockPos; import net.minecraft.server.level.DistanceManager; import net.minecraft.server.level.ServerLevel; @@ -16,6 +16,6 @@ public static void changeSpawnSize(ServerLevel overworld, int size) overworld.getLevelData().getZSpawn() )); DistanceManager ticketManager = overworld.getChunkSource().chunkMap.getDistanceManager(); - ((ChunkTicketManagerInterface)ticketManager).changeSpawnChunks(centerChunk, size); + ticketManager.carpet$changeSpawnChunks(centerChunk, size); } } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 0cc0168dfe..e8db871f38 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -36,5 +36,124 @@ "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_4970": [ + "carpet/fakes/BlockBehaviourInterface" + ], + "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_638": [ + "carpet/fakes/ClientLevelInterface" + ], + "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_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_2669": [ + "carpet/fakes/PistonMovingBlockEntityInterface" + ], + "net/minecraft/class_355": [ + "carpet/fakes/PlayerTabOverlayInterface" + ], + "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" + ] + } } }