Merge branch '1.17'
This commit is contained in:
commit
af368a159d
173 files changed
+2214
-1462
No files matched your search
@@ -32,8 +32,10 @@ import com.mojang.brigadier.CommandDispatcher;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.api.DedicatedServerModInitializer;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.server.command.CommandManager;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.dedicated.command.PerfCommand;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
|
||||
public class CarpetServer // static for now - easier to handle all around the code, its one anyways
|
||||
@@ -113,7 +115,11 @@ public class CarpetServer // static for now - easier to handle all around the co
|
||||
extensions.forEach(e -> e.onTick(server));
|
||||
}
|
||||
|
||||
public static void registerCarpetCommands(CommandDispatcher<ServerCommandSource> dispatcher)
|
||||
@Deprecated
|
||||
public static void registerCarpetCommands(CommandDispatcher<ServerCommandSource> dispatcher) {
|
||||
}
|
||||
|
||||
public static void registerCarpetCommands(CommandDispatcher<ServerCommandSource> dispatcher, CommandManager.RegistrationEnvironment environment)
|
||||
{
|
||||
settingsManager.registerCommand(dispatcher);
|
||||
extensions.forEach(e -> {
|
||||
@@ -137,6 +143,9 @@ public class CarpetServer // static for now - easier to handle all around the co
|
||||
// for all other, they will have them registered when they add themselves
|
||||
extensions.forEach(e -> e.registerCommands(dispatcher));
|
||||
currentCommandDispatcher = dispatcher;
|
||||
|
||||
if (environment != CommandManager.RegistrationEnvironment.DEDICATED)
|
||||
PerfCommand.register(dispatcher);
|
||||
|
||||
if (FabricLoader.getInstance().isDevelopmentEnvironment())
|
||||
TestCommand.register(dispatcher);
|
||||
|
||||
@@ -186,15 +186,17 @@ public class CarpetSettings
|
||||
@Rule( desc = "Players absorb XP instantly, without delay", category = CREATIVE )
|
||||
public static boolean xpNoCooldown = false;
|
||||
|
||||
|
||||
@Rule( desc = "XP orbs combine with other into bigger orbs", category = FEATURE )
|
||||
public static boolean combineXPOrbs = false;
|
||||
|
||||
@Rule(
|
||||
desc = "Empty shulker boxes can stack to 64 when dropped on the ground",
|
||||
extra = "To move them around between inventories, use shift click to move entire stacks",
|
||||
extra = ".. or when manipulated inside the inventories",
|
||||
category = {SURVIVAL, FEATURE}
|
||||
)
|
||||
public static boolean stackableShulkerBoxes = false;
|
||||
public static final int SHULKER_STACK_SIZE = 64;
|
||||
|
||||
@Rule( desc = "Explosions won't destroy blocks", category = {CREATIVE, TNT} )
|
||||
public static boolean explosionNoBlockDamage = false;
|
||||
@@ -316,6 +318,16 @@ public class CarpetSettings
|
||||
)
|
||||
public static boolean hopperCounters = false;
|
||||
|
||||
@Rule(
|
||||
desc = "Allows Budding Amethyst blocks to be moved",
|
||||
extra = {
|
||||
"Allow for them to be moved by pistons",
|
||||
"as well as adds extra drop when mining with silk touch pickaxe"
|
||||
},
|
||||
category = FEATURE
|
||||
)
|
||||
public static boolean movableAmethyst = false;
|
||||
|
||||
@Rule( desc = "Guardians turn into Elder Guardian when struck by lightning", category = FEATURE )
|
||||
public static boolean renewableSponges = false;
|
||||
|
||||
@@ -366,6 +378,13 @@ public class CarpetSettings
|
||||
)
|
||||
public static String commandProfile = "true";
|
||||
|
||||
@Rule(
|
||||
desc = "Required permission level for /perf command",
|
||||
options = {"2", "4"},
|
||||
category = CREATIVE
|
||||
)
|
||||
public static int perfPermissionLevel = 4;
|
||||
|
||||
@Rule(desc = "Enables /log command to monitor events via chat and overlays", category = COMMAND)
|
||||
public static String commandLog = "true";
|
||||
|
||||
@@ -588,8 +607,8 @@ public class CarpetSettings
|
||||
public static boolean waterFlow = true;
|
||||
*/
|
||||
|
||||
@Rule(desc = "One player is required on the server to cause night to pass", category = SURVIVAL)
|
||||
public static boolean onePlayerSleeping = false;
|
||||
//@Rule(desc = "One player is required on the server to cause night to pass", category = SURVIVAL)
|
||||
//public static boolean onePlayerSleeping = false;
|
||||
|
||||
@Rule(
|
||||
desc = "Sets a different motd message on client trying to connect to the server",
|
||||
@@ -620,7 +639,7 @@ public class CarpetSettings
|
||||
Messenger.m(source, "r view distance has to be between 0 and 32");
|
||||
return null;
|
||||
}
|
||||
MinecraftServer server = source.getMinecraftServer();
|
||||
MinecraftServer server = source.getServer();
|
||||
|
||||
if (server.isDedicated())
|
||||
{
|
||||
@@ -754,6 +773,13 @@ public class CarpetSettings
|
||||
)
|
||||
public static boolean renewableBlackstone = false;
|
||||
|
||||
@Rule(
|
||||
desc = "Lava and water generate deepslate and cobbled deepslate instead below Y16",
|
||||
extra = "This rule may change Y value to 0 with 1.18",
|
||||
category = FEATURE
|
||||
)
|
||||
public static boolean renewableDeepslate = false;
|
||||
|
||||
@Rule(desc = "fixes block placement rotation issue when player rotates quickly while placing blocks", category = BUGFIX)
|
||||
public static boolean placementRotationFix = false;
|
||||
|
||||
@@ -810,7 +836,7 @@ public class CarpetSettings
|
||||
public static boolean isCreativeFlying(Entity entity)
|
||||
{
|
||||
// #todo replace after merger to 1.17
|
||||
return CarpetSettings.creativeNoClip && entity instanceof PlayerEntity && (((PlayerEntity) entity).isCreative()) && ((PlayerEntity) entity).abilities.flying;
|
||||
return CarpetSettings.creativeNoClip && entity instanceof PlayerEntity && (((PlayerEntity) entity).isCreative()) && ((PlayerEntity) entity).getAbilities().flying;
|
||||
}
|
||||
|
||||
|
||||
@@ -909,7 +935,7 @@ public class CarpetSettings
|
||||
strict = false,
|
||||
validate = Validator.NONNEGATIVE_NUMBER.class
|
||||
)
|
||||
public static double structureBlockOutlineDistance = 96d;
|
||||
public static int structureBlockOutlineDistance = 96;
|
||||
|
||||
@Rule(
|
||||
desc = "Lightning kills the items that drop when lightning kills an entity",
|
||||
|
||||
@@ -56,7 +56,7 @@ public class CounterCommand
|
||||
HopperCounter counter = HopperCounter.getCounter(color);
|
||||
if (counter == null) throw new CommandException(Messenger.s("Unknown wool color: "+color));
|
||||
|
||||
for (BaseText message: counter.format(source.getMinecraftServer(), realtime, false))
|
||||
for (BaseText message: counter.format(source.getServer(), realtime, false))
|
||||
{
|
||||
source.sendFeedback(message, false);
|
||||
}
|
||||
@@ -72,14 +72,14 @@ public class CounterCommand
|
||||
{
|
||||
if (color == null)
|
||||
{
|
||||
HopperCounter.resetAll(source.getMinecraftServer(), false);
|
||||
HopperCounter.resetAll(source.getServer(), false);
|
||||
Messenger.m(source, "w Restarted all counters");
|
||||
}
|
||||
else
|
||||
{
|
||||
HopperCounter counter = HopperCounter.getCounter(color);
|
||||
if (counter == null) throw new CommandException(Messenger.s("Unknown wool color"));
|
||||
counter.reset(source.getMinecraftServer());
|
||||
counter.reset(source.getServer());
|
||||
Messenger.m(source, "w Restarted "+color+" counter");
|
||||
}
|
||||
return 1;
|
||||
@@ -92,7 +92,7 @@ public class CounterCommand
|
||||
*/
|
||||
private static int listAllCounters(ServerCommandSource source, boolean realtime)
|
||||
{
|
||||
for (BaseText message: HopperCounter.formatAll(source.getMinecraftServer(), realtime))
|
||||
for (BaseText message: HopperCounter.formatAll(source.getServer(), realtime))
|
||||
{
|
||||
source.sendFeedback(message, false);
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ public class LogCommand
|
||||
}
|
||||
private static int unsubFromAll(ServerCommandSource source, String player_name)
|
||||
{
|
||||
PlayerEntity player = source.getMinecraftServer().getPlayerManager().getPlayer(player_name);
|
||||
PlayerEntity player = source.getServer().getPlayerManager().getPlayer(player_name);
|
||||
if (player == null)
|
||||
{
|
||||
Messenger.m(source, "r No player specified");
|
||||
@@ -148,7 +148,7 @@ public class LogCommand
|
||||
}
|
||||
private static int unsubFromLogger(ServerCommandSource source, String player_name, String logname)
|
||||
{
|
||||
PlayerEntity player = source.getMinecraftServer().getPlayerManager().getPlayer(player_name);
|
||||
PlayerEntity player = source.getServer().getPlayerManager().getPlayer(player_name);
|
||||
if (player == null)
|
||||
{
|
||||
Messenger.m(source, "r No player specified");
|
||||
@@ -166,7 +166,7 @@ public class LogCommand
|
||||
|
||||
private static int toggleSubscription(ServerCommandSource source, String player_name, String logName)
|
||||
{
|
||||
PlayerEntity player = source.getMinecraftServer().getPlayerManager().getPlayer(player_name);
|
||||
PlayerEntity player = source.getServer().getPlayerManager().getPlayer(player_name);
|
||||
if (player == null)
|
||||
{
|
||||
Messenger.m(source, "r No player specified");
|
||||
@@ -190,7 +190,7 @@ public class LogCommand
|
||||
}
|
||||
private static int subscribePlayer(ServerCommandSource source, String player_name, String logname, String option)
|
||||
{
|
||||
PlayerEntity player = source.getMinecraftServer().getPlayerManager().getPlayer(player_name);
|
||||
PlayerEntity player = source.getServer().getPlayerManager().getPlayer(player_name);
|
||||
if (player == null)
|
||||
{
|
||||
Messenger.m(source, "r No player specified");
|
||||
|
||||
@@ -13,7 +13,7 @@ import net.minecraft.entity.mob.MobEntity;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.command.argument.BlockPosArgumentType;
|
||||
import net.minecraft.command.argument.EntitySummonArgumentType;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import static net.minecraft.server.command.CommandManager.argument;
|
||||
@@ -46,19 +46,19 @@ public class PerimeterInfoCommand
|
||||
|
||||
private static int perimeterDiagnose(ServerCommandSource source, BlockPos pos, String mobId)
|
||||
{
|
||||
CompoundTag nbttagcompound = new CompoundTag();
|
||||
NbtCompound nbttagcompound = new NbtCompound();
|
||||
MobEntity entityliving = null;
|
||||
if (mobId != null)
|
||||
{
|
||||
nbttagcompound.putString("id", mobId);
|
||||
Entity baseEntity = EntityType.loadEntityWithPassengers(nbttagcompound, source.getWorld(), (entity_1x) -> {
|
||||
entity_1x.refreshPositionAndAngles(new BlockPos(pos.getX(), -10, pos.getZ()), entity_1x.yaw, entity_1x.pitch);
|
||||
entity_1x.refreshPositionAndAngles(new BlockPos(pos.getX(), -10, pos.getZ()), entity_1x.getYaw(), entity_1x. getPitch());
|
||||
return !source.getWorld().tryLoadEntity(entity_1x) ? null : entity_1x;
|
||||
});
|
||||
if (!(baseEntity instanceof MobEntity))
|
||||
{
|
||||
Messenger.m(source, "r /perimeterinfo requires a mob entity to test agains.");
|
||||
if (baseEntity != null) baseEntity.remove();
|
||||
if (baseEntity != null) baseEntity.discard();
|
||||
return 0;
|
||||
}
|
||||
entityliving = (MobEntity) baseEntity;
|
||||
@@ -72,7 +72,7 @@ public class PerimeterInfoCommand
|
||||
{
|
||||
Messenger.m(source, "w ", entityliving.getDisplayName() ,"w : ","wb "+res.specific);
|
||||
res.samples.forEach(bp -> Messenger.m(source, "w ", Messenger.tp("c", bp)));
|
||||
entityliving.remove();
|
||||
entityliving.discard(); // dicard // remove();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ public class PlayerCommand
|
||||
private static ServerPlayerEntity getPlayer(CommandContext<ServerCommandSource> context)
|
||||
{
|
||||
String playerName = StringArgumentType.getString(context, "player");
|
||||
MinecraftServer server = context.getSource().getMinecraftServer();
|
||||
MinecraftServer server = context.getSource().getServer();
|
||||
return server.getPlayerManager().getPlayer(playerName);
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ public class PlayerCommand
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!context.getSource().getMinecraftServer().getPlayerManager().isOperator(sendingPlayer.getGameProfile()))
|
||||
if (!context.getSource().getServer().getPlayerManager().isOperator(sendingPlayer.getGameProfile()))
|
||||
{
|
||||
if (sendingPlayer != player && !(player instanceof EntityPlayerMPFake))
|
||||
{
|
||||
@@ -181,7 +181,7 @@ public class PlayerCommand
|
||||
private static boolean cantSpawn(CommandContext<ServerCommandSource> context)
|
||||
{
|
||||
String playerName = StringArgumentType.getString(context, "player");
|
||||
MinecraftServer server = context.getSource().getMinecraftServer();
|
||||
MinecraftServer server = context.getSource().getServer();
|
||||
PlayerManager manager = server.getPlayerManager();
|
||||
PlayerEntity player = manager.getPlayer(playerName);
|
||||
if (player != null)
|
||||
@@ -189,7 +189,7 @@ public class PlayerCommand
|
||||
Messenger.m(context.getSource(), "r Player ", "rb " + playerName, "r is already logged on");
|
||||
return true;
|
||||
}
|
||||
GameProfile profile = server.getUserCache().findByName(playerName);
|
||||
GameProfile profile = server.getUserCache().findByName(playerName).orElse(null);
|
||||
if (profile == null)
|
||||
{
|
||||
if (!CarpetSettings.allowSpawningOfflinePlayers)
|
||||
@@ -224,9 +224,9 @@ public class PlayerCommand
|
||||
private static int lookAt(CommandContext<ServerCommandSource> context)
|
||||
{
|
||||
return manipulate(context, ap -> {
|
||||
try {
|
||||
//try {
|
||||
ap.lookAt(Vec3ArgumentType.getVec3(context, "position"));
|
||||
} catch (CommandSyntaxException ignored) {}
|
||||
//} catch (CommandSyntaxException ignored) {}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -270,18 +270,18 @@ public class PlayerCommand
|
||||
{
|
||||
ServerPlayerEntity player = context.getSource().getPlayer();
|
||||
mode = player.interactionManager.getGameMode();
|
||||
flying = player.abilities.flying;
|
||||
flying = player.getAbilities().flying;
|
||||
}
|
||||
catch (CommandSyntaxException ignored) {}
|
||||
String playerName = StringArgumentType.getString(context, "player");
|
||||
if (playerName.length()>maxPlayerLength(source.getMinecraftServer()))
|
||||
if (playerName.length()>maxPlayerLength(source.getServer()))
|
||||
{
|
||||
Messenger.m(context.getSource(), "rb Player name: "+playerName+" is too long");
|
||||
return 0;
|
||||
}
|
||||
|
||||
MinecraftServer server = source.getMinecraftServer();
|
||||
if (!World.isInBuildLimit(new BlockPos(pos.x, pos.y, pos.z)))
|
||||
MinecraftServer server = source.getServer();
|
||||
if (!World.isValid(new BlockPos(pos.x, pos.y, pos.z)))
|
||||
{
|
||||
Messenger.m(context.getSource(), "rb Player "+playerName+" cannot be placed outside of the world");
|
||||
return 0;
|
||||
|
||||
@@ -512,9 +512,9 @@ public class ScriptCommand
|
||||
{
|
||||
ServerCommandSource source = context.getSource();
|
||||
CarpetScriptHost host = getHost(context);
|
||||
BlockBox area = new BlockBox(a, b);
|
||||
BlockBox area = BlockBox.create(a, b);
|
||||
CarpetExpression cexpr = new CarpetExpression(host.main, expr, source, origin);
|
||||
int int_1 = area.getBlockCountX() * area.getBlockCountY() * area.getBlockCountZ();
|
||||
int int_1 = area.getBlockCountX() * area.getBlockCountY() * area.getBlockCountZ(); // X Y Z
|
||||
if (int_1 > CarpetSettings.fillLimit)
|
||||
{
|
||||
Messenger.m(source, "r too many blocks to evaluate: " + int_1);
|
||||
@@ -524,11 +524,11 @@ public class ScriptCommand
|
||||
CarpetSettings.impendingFillSkipUpdates.set(!CarpetSettings.fillUpdates);
|
||||
try
|
||||
{
|
||||
for (int x = area.minX; x <= area.maxX; x++)
|
||||
for (int x = area.getMinX(); x <= area.getMaxX(); x++)
|
||||
{
|
||||
for (int y = area.minY; y <= area.maxY; y++)
|
||||
for (int y = area.getMinY(); y <= area.getMaxY(); y++)
|
||||
{
|
||||
for (int z = area.minZ; z <= area.maxZ; z++)
|
||||
for (int z = area.getMinZ(); z <= area.getMaxZ(); z++)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -561,7 +561,7 @@ public class ScriptCommand
|
||||
{
|
||||
ServerCommandSource source = context.getSource();
|
||||
CarpetScriptHost host = getHost(context);
|
||||
BlockBox area = new BlockBox(a, b);
|
||||
BlockBox area = BlockBox.create(a, b);
|
||||
CarpetExpression cexpr = new CarpetExpression(host.main, expr, source, origin);
|
||||
int int_1 = area.getBlockCountX() * area.getBlockCountY() * area.getBlockCountZ();
|
||||
if (int_1 > CarpetSettings.fillLimit)
|
||||
@@ -570,22 +570,22 @@ public class ScriptCommand
|
||||
return 1;
|
||||
}
|
||||
|
||||
boolean[][][] volume = new boolean[area.getBlockCountX()][area.getBlockCountY()][area.getBlockCountZ()];
|
||||
boolean[][][] volume = new boolean[area.getBlockCountX()][area.getBlockCountY()][area.getBlockCountZ()]; //X then Y then Z got messedup
|
||||
|
||||
BlockPos.Mutable mbpos = origin.mutableCopy();
|
||||
ServerWorld world = source.getWorld();
|
||||
|
||||
for (int x = area.minX; x <= area.maxX; x++)
|
||||
for (int x = area.getMinX(); x <= area.getMaxX(); x++)
|
||||
{
|
||||
for (int y = area.minY; y <= area.maxY; y++)
|
||||
for (int y = area.getMinY(); y <= area.getMaxY(); y++)
|
||||
{
|
||||
for (int z = area.minZ; z <= area.maxZ; z++)
|
||||
for (int z = area.getMinZ(); z <= area.getMaxZ(); z++)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (cexpr.fillAndScanCommand(host, x, y, z))
|
||||
{
|
||||
volume[x-area.minX][y-area.minY][z-area.minZ]=true;
|
||||
volume[x-area.getMinX()][y-area.getMinY()][z-area.getMinZ()]=true;
|
||||
}
|
||||
}
|
||||
catch (CarpetExpressionException e)
|
||||
@@ -640,7 +640,7 @@ public class ScriptCommand
|
||||
{
|
||||
if (volume[x][y][z])
|
||||
{
|
||||
mbpos.set(x+area.minX, y+area.minY, z+area.minZ);
|
||||
mbpos.set(x+area.getMinX(), y+area.getMinY(), z+area.getMinZ());
|
||||
if (replacement == null || replacement.test(
|
||||
new CachedBlockPosition( world, mbpos, true)))
|
||||
{
|
||||
@@ -668,7 +668,7 @@ public class ScriptCommand
|
||||
{
|
||||
if (volume[x][y][z])
|
||||
{
|
||||
mbpos.set(x+area.minX, y+area.minY, z+area.minZ);
|
||||
mbpos.set(x+area.getMinX(), y+area.getMinY(), z+area.getMinZ());
|
||||
Block blokc = world.getBlockState(mbpos).getBlock();
|
||||
world.updateNeighbors(mbpos, blokc);
|
||||
}
|
||||
|
||||
@@ -146,8 +146,8 @@ public class SpawnCommand
|
||||
Math.max(a.getY(), b.getY()),
|
||||
Math.max(a.getZ(), b.getZ()) );
|
||||
}
|
||||
SpawnReporter.reset_spawn_stats(source.getMinecraftServer(), false);
|
||||
SpawnReporter.track_spawns = (long) source.getMinecraftServer().getTicks();
|
||||
SpawnReporter.reset_spawn_stats(source.getServer(), false);
|
||||
SpawnReporter.track_spawns = (long) source.getServer().getTicks();
|
||||
SpawnReporter.lower_spawning_limit = lsl;
|
||||
SpawnReporter.upper_spawning_limit = usl;
|
||||
Messenger.m(source, "gi Spawning tracking started.");
|
||||
@@ -157,7 +157,7 @@ public class SpawnCommand
|
||||
private static int stopTracking(ServerCommandSource source)
|
||||
{
|
||||
Messenger.send(source, SpawnReporter.tracking_report(source.getWorld()));
|
||||
SpawnReporter.reset_spawn_stats(source.getMinecraftServer(),false);
|
||||
SpawnReporter.reset_spawn_stats(source.getServer(),false);
|
||||
SpawnReporter.track_spawns = 0L;
|
||||
SpawnReporter.lower_spawning_limit = null;
|
||||
SpawnReporter.upper_spawning_limit = null;
|
||||
@@ -175,19 +175,19 @@ public class SpawnCommand
|
||||
private static int runTest(ServerCommandSource source, int ticks, String counter)
|
||||
{
|
||||
//stop tracking
|
||||
SpawnReporter.reset_spawn_stats(source.getMinecraftServer(),false);
|
||||
SpawnReporter.reset_spawn_stats(source.getServer(),false);
|
||||
//start tracking
|
||||
SpawnReporter.track_spawns = (long) source.getMinecraftServer().getTicks();
|
||||
SpawnReporter.track_spawns = (long) source.getServer().getTicks();
|
||||
//counter reset
|
||||
if (counter == null)
|
||||
{
|
||||
HopperCounter.resetAll(source.getMinecraftServer(), false);
|
||||
HopperCounter.resetAll(source.getServer(), false);
|
||||
}
|
||||
else
|
||||
{
|
||||
HopperCounter hCounter = HopperCounter.getCounter(counter);
|
||||
if (hCounter != null)
|
||||
hCounter.reset(source.getMinecraftServer());
|
||||
hCounter.reset(source.getServer());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package carpet.fakes;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public interface BlockEntityInterface
|
||||
{
|
||||
void setCMPos(BlockPos pos);
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package carpet.fakes;
|
||||
import carpet.script.value.Value;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.tag.Tag;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -13,5 +13,5 @@ public interface BlockPredicateInterface
|
||||
BlockState getCMBlockState();
|
||||
Tag<Block> getCMBlockTag();
|
||||
Map<Value, Value> getCMProperties();
|
||||
CompoundTag getCMDataTag();
|
||||
NbtCompound getCMDataTag();
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package carpet.fakes;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
|
||||
public interface BlockStateArgumentInterface
|
||||
{
|
||||
CompoundTag getCMTag();
|
||||
NbtCompound getCMTag();
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package carpet.fakes;
|
||||
|
||||
import com.mojang.datafixers.util.Either;
|
||||
import net.minecraft.server.world.ChunkHolder;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.util.thread.ThreadExecutor;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
@@ -10,5 +11,5 @@ import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public interface ChunkHolderInterface
|
||||
{
|
||||
CompletableFuture<Either<Chunk, ChunkHolder.Unloaded>> setDefaultProtoChunk(ChunkPos chpos, ThreadExecutor<Runnable> executor);
|
||||
CompletableFuture<Either<Chunk, ChunkHolder.Unloaded>> setDefaultProtoChunk(ChunkPos chpos, ThreadExecutor<Runnable> executor, ServerWorld world);
|
||||
}
|
||||
@@ -5,4 +5,6 @@ public interface ExperienceOrbInterface
|
||||
int getCombineDelay();
|
||||
void setCombineDelay(int what);
|
||||
void setAmount(int what);
|
||||
int getCount();
|
||||
void setCount(int i);
|
||||
}
|
||||
@@ -4,5 +4,5 @@ import net.minecraft.inventory.Inventory;
|
||||
|
||||
public interface InventoryBearerInterface
|
||||
{
|
||||
Inventory getCMInventory();
|
||||
Inventory getCMInventory(); // can be removed in 1.17 due to class_6067
|
||||
}
|
||||
@@ -1,7 +1,10 @@
|
||||
package carpet.fakes;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityLookup;
|
||||
import net.minecraft.world.level.ServerWorldProperties;
|
||||
|
||||
public interface ServerWorldInterface {
|
||||
ServerWorldProperties getWorldPropertiesCM();
|
||||
EntityLookup<Entity> getEntityLookupCMPublic();
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package carpet.fakes;
|
||||
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.entity.EntityLike;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SimpleEntityLookupInterface<T extends EntityLike>
|
||||
{
|
||||
List<T> getChunkEntities(ChunkPos chpos);
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package carpet.fakes;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.HeightLimitView;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.source.BiomeSource;
|
||||
import net.minecraft.world.gen.ChunkRandom;
|
||||
@@ -12,5 +13,5 @@ import net.minecraft.world.gen.feature.FeatureConfig;
|
||||
public interface StructureFeatureInterface<C>
|
||||
{
|
||||
boolean plopAnywhere(ServerWorld world, BlockPos pos, ChunkGenerator generator, boolean wireOnly,Biome biome, FeatureConfig config);
|
||||
boolean shouldStartPublicAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long l, ChunkRandom chunkRandom, int i, int j, Biome biome, ChunkPos chunkPos, C featureConfig);
|
||||
boolean shouldStartPublicAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long l, ChunkRandom chunkRandom, ChunkPos chpos, Biome biome, ChunkPos chunkPos, C featureConfig, HeightLimitView heightLimitView);
|
||||
}
|
||||
@@ -48,8 +48,8 @@ import net.minecraft.world.World;
|
||||
public class BlockRotator
|
||||
{
|
||||
public static boolean flipBlockWithCactus(BlockState state, World world, PlayerEntity player, Hand hand, BlockHitResult hit)
|
||||
{
|
||||
if (!player.abilities.allowModifyWorld || !CarpetSettings.flippinCactus || !player_holds_cactus_mainhand(player))
|
||||
{ //getAbilities()
|
||||
if (!player.getAbilities().allowModifyWorld || !CarpetSettings.flippinCactus || !player_holds_cactus_mainhand(player))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -226,7 +226,7 @@ public class BlockRotator
|
||||
{
|
||||
Direction sourceFace = source.getBlockState().get(DispenserBlock.FACING);
|
||||
World world = source.getWorld();
|
||||
BlockPos blockpos = source.getBlockPos().offset(sourceFace);
|
||||
BlockPos blockpos = source.getPos().offset(sourceFace); // offset
|
||||
BlockState iblockstate = world.getBlockState(blockpos);
|
||||
Block block = iblockstate.getBlock();
|
||||
|
||||
@@ -274,7 +274,7 @@ public class BlockRotator
|
||||
}
|
||||
}
|
||||
// Send block update to the block that just have been rotated.
|
||||
world.updateNeighbor(blockpos, block, source.getBlockPos());
|
||||
world.updateNeighbor(blockpos, block, source.getPos());
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.entity.vehicle.BoatEntity;
|
||||
import net.minecraft.entity.vehicle.MinecartEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.packet.s2c.play.HeldItemChangeS2CPacket;
|
||||
import net.minecraft.network.packet.s2c.play.UpdateSelectedSlotS2CPacket;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
@@ -116,8 +116,8 @@ public class EntityPlayerActionPack
|
||||
case SOUTH: return look(0, 0);
|
||||
case EAST: return look(-90, 0);
|
||||
case WEST: return look(90, 0);
|
||||
case UP: return look(player.yaw, -90);
|
||||
case DOWN: return look(player.yaw, 90);
|
||||
case UP: return look(player.getYaw(), -90);
|
||||
case DOWN: return look(player.getYaw(), 90);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@@ -128,8 +128,8 @@ public class EntityPlayerActionPack
|
||||
|
||||
public EntityPlayerActionPack look(float yaw, float pitch)
|
||||
{
|
||||
player.yaw = yaw % 360;
|
||||
player.pitch = MathHelper.clamp(pitch, -90, 90);
|
||||
player.setYaw(yaw % 360); //setYaw
|
||||
player.setPitch(MathHelper.clamp(pitch, -90, 90)); // setPitch
|
||||
// maybe player.setPositionAndAngles(player.x, player.y, player.z, yaw, MathHelper.clamp(pitch,-90.0F, 90.0F));
|
||||
return this;
|
||||
}
|
||||
@@ -142,7 +142,7 @@ public class EntityPlayerActionPack
|
||||
|
||||
public EntityPlayerActionPack turn(float yaw, float pitch)
|
||||
{
|
||||
return look(player.yaw + yaw, player.pitch + pitch);
|
||||
return look(player.getYaw() + yaw, player.getPitch() + pitch);
|
||||
}
|
||||
|
||||
public EntityPlayerActionPack turn(Vec2f rotation)
|
||||
@@ -254,7 +254,7 @@ public class EntityPlayerActionPack
|
||||
|
||||
private void dropItemFromSlot(int slot, boolean dropAll)
|
||||
{
|
||||
PlayerInventory inv = player.inventory;
|
||||
PlayerInventory inv = player.getInventory(); // getInventory;
|
||||
if (!inv.getStack(slot).isEmpty())
|
||||
player.dropItem(inv.removeStack(slot,
|
||||
dropAll ? inv.getStack(slot).getCount() : 1
|
||||
@@ -263,7 +263,7 @@ public class EntityPlayerActionPack
|
||||
|
||||
public void drop(int selectedSlot, boolean dropAll)
|
||||
{
|
||||
PlayerInventory inv = player.inventory;
|
||||
PlayerInventory inv = player.getInventory(); // getInventory;
|
||||
if (selectedSlot == -2) // all
|
||||
{
|
||||
for (int i = inv.size(); i >= 0; i--)
|
||||
@@ -279,8 +279,8 @@ public class EntityPlayerActionPack
|
||||
|
||||
public void setSlot(int slot)
|
||||
{
|
||||
player.inventory.selectedSlot = slot-1;
|
||||
player.networkHandler.sendPacket(new HeldItemChangeS2CPacket(slot-1));
|
||||
player.getInventory().selectedSlot = slot-1;
|
||||
player.networkHandler.sendPacket(new UpdateSelectedSlotS2CPacket(slot-1));
|
||||
}
|
||||
|
||||
public enum ActionType
|
||||
@@ -312,7 +312,7 @@ public class EntityPlayerActionPack
|
||||
BlockHitResult blockHit = (BlockHitResult) hit;
|
||||
BlockPos pos = blockHit.getBlockPos();
|
||||
Direction side = blockHit.getSide();
|
||||
if (pos.getY() < player.server.getWorldHeight() - (side == Direction.UP ? 1 : 0) && world.canPlayerModifyAt(player, pos))
|
||||
if (pos.getY() < player.getServerWorld().getTopY() - (side == Direction.UP ? 1 : 0) && world.canPlayerModifyAt(player, pos))
|
||||
{
|
||||
ActionResult result = player.interactionManager.interactBlock(player, world, player.getStackInHand(hand), hand, blockHit);
|
||||
if (result.isAccepted())
|
||||
@@ -400,7 +400,7 @@ public class EntityPlayerActionPack
|
||||
boolean blockBroken = false;
|
||||
if (player.interactionManager.getGameMode().isCreative())
|
||||
{
|
||||
player.interactionManager.processBlockBreakingAction(pos, PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, side, player.server.getWorldHeight());
|
||||
player.interactionManager.processBlockBreakingAction(pos, PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, side, player.getServerWorld().getTopY());
|
||||
ap.blockHitDelay = 5;
|
||||
blockBroken = true;
|
||||
}
|
||||
@@ -408,9 +408,9 @@ public class EntityPlayerActionPack
|
||||
{
|
||||
if (ap.currentBlock != null)
|
||||
{
|
||||
player.interactionManager.processBlockBreakingAction(ap.currentBlock, PlayerActionC2SPacket.Action.ABORT_DESTROY_BLOCK, side, player.server.getWorldHeight());
|
||||
player.interactionManager.processBlockBreakingAction(ap.currentBlock, PlayerActionC2SPacket.Action.ABORT_DESTROY_BLOCK, side, player.getServerWorld().getTopY());
|
||||
}
|
||||
player.interactionManager.processBlockBreakingAction(pos, PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, side, player.server.getWorldHeight());
|
||||
player.interactionManager.processBlockBreakingAction(pos, PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, side, player.getServerWorld().getTopY());
|
||||
boolean notAir = !state.isAir();
|
||||
if (notAir && ap.curBlockDamageMP == 0)
|
||||
{
|
||||
@@ -433,7 +433,7 @@ public class EntityPlayerActionPack
|
||||
ap.curBlockDamageMP += state.calcBlockBreakingDelta(player, player.world, pos);
|
||||
if (ap.curBlockDamageMP >= 1)
|
||||
{
|
||||
player.interactionManager.processBlockBreakingAction(pos, PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, side, player.server.getWorldHeight());
|
||||
player.interactionManager.processBlockBreakingAction(pos, PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, side, player.getServerWorld().getTopY());
|
||||
ap.currentBlock = null;
|
||||
ap.blockHitDelay = 5;
|
||||
blockBroken = true;
|
||||
@@ -455,7 +455,7 @@ public class EntityPlayerActionPack
|
||||
EntityPlayerActionPack ap = ((ServerPlayerEntityInterface) player).getActionPack();
|
||||
if (ap.currentBlock == null) return;
|
||||
player.world.setBlockBreakingInfo(-1, ap.currentBlock, -1);
|
||||
player.interactionManager.processBlockBreakingAction(ap.currentBlock, PlayerActionC2SPacket.Action.ABORT_DESTROY_BLOCK, Direction.DOWN, player.server.getWorldHeight());
|
||||
player.interactionManager.processBlockBreakingAction(ap.currentBlock, PlayerActionC2SPacket.Action.ABORT_DESTROY_BLOCK, Direction.DOWN, player.getServerWorld().getTopY());
|
||||
ap.currentBlock = null;
|
||||
}
|
||||
},
|
||||
@@ -487,7 +487,7 @@ public class EntityPlayerActionPack
|
||||
boolean execute(ServerPlayerEntity player, Action action)
|
||||
{
|
||||
player.updateLastActionTime();
|
||||
player.dropSelectedItem(false);
|
||||
player.dropSelectedItem(false); // dropSelectedItem
|
||||
return false;
|
||||
}
|
||||
},
|
||||
@@ -497,7 +497,7 @@ public class EntityPlayerActionPack
|
||||
boolean execute(ServerPlayerEntity player, Action action)
|
||||
{
|
||||
player.updateLastActionTime();
|
||||
player.dropSelectedItem(true);
|
||||
player.dropSelectedItem(true); // dropSelectedItem
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
@@ -24,7 +24,7 @@ import net.minecraft.world.biome.source.BiomeAccess;
|
||||
import net.minecraft.world.gen.ChunkRandom;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.chunk.StructureConfig;
|
||||
import net.minecraft.world.gen.tree.BeehiveTreeDecorator;
|
||||
import net.minecraft.world.gen.treedecorator.BeehiveTreeDecorator;
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeatures;
|
||||
import net.minecraft.world.gen.feature.ConfiguredStructureFeature;
|
||||
@@ -49,7 +49,7 @@ public class FeatureGenerator
|
||||
return custom.plop(world, pos);
|
||||
}
|
||||
Identifier id = new Identifier(featureName);
|
||||
ConfiguredStructureFeature<?, ?> structureFeature = world.getRegistryManager().get(Registry.CONFIGURED_STRUCTURE_FEATURE_WORLDGEN).get(id);
|
||||
ConfiguredStructureFeature<?, ?> structureFeature = world.getRegistryManager().get(Registry.CONFIGURED_STRUCTURE_FEATURE_KEY).get(id);
|
||||
if (structureFeature != null)
|
||||
{
|
||||
return ((StructureFeatureInterface)structureFeature.feature).plopAnywhere(
|
||||
@@ -58,7 +58,7 @@ public class FeatureGenerator
|
||||
|
||||
}
|
||||
|
||||
ConfiguredFeature<?, ?> feature = world.getRegistryManager().get(Registry.CONFIGURED_FEATURE_WORLDGEN).get(id);
|
||||
ConfiguredFeature<?, ?> feature = world.getRegistryManager().get(Registry.CONFIGURED_FEATURE_KEY).get(id);
|
||||
if (feature != null)
|
||||
{
|
||||
CarpetSettings.skipGenerationChecks.set(true);
|
||||
@@ -77,7 +77,7 @@ public class FeatureGenerator
|
||||
public static ConfiguredStructureFeature<?, ?> resolveConfiguredStructure(String name, ServerWorld world, BlockPos pos)
|
||||
{
|
||||
Identifier id = new Identifier(name);
|
||||
ConfiguredStructureFeature<?, ?> configuredStructureFeature = world.getRegistryManager().get(Registry.CONFIGURED_STRUCTURE_FEATURE_WORLDGEN).get(id);
|
||||
ConfiguredStructureFeature<?, ?> configuredStructureFeature = world.getRegistryManager().get(Registry.CONFIGURED_STRUCTURE_FEATURE_KEY).get(id);
|
||||
if (configuredStructureFeature != null) return configuredStructureFeature;
|
||||
StructureFeature<?> structureFeature = Registry.STRUCTURE_FEATURE.get(id);
|
||||
if (structureFeature == null) return null;
|
||||
@@ -113,7 +113,7 @@ public class FeatureGenerator
|
||||
|
||||
private static Thing simpleTree(TreeFeatureConfig config)
|
||||
{
|
||||
config.ignoreFluidCheck();
|
||||
//config.ignoreFluidCheck();
|
||||
return simplePlop(Feature.TREE.configure(config));
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ public class FeatureGenerator
|
||||
{
|
||||
ConfiguredStructureFeature<?, ?> configuredFeature = world.getBiome(pos).getGenerationSettings().method_30978(structure.configure(null));
|
||||
if (configuredFeature.config != null || !tryHard) return configuredFeature;
|
||||
return world.getRegistryManager().get(Registry.CONFIGURED_STRUCTURE_FEATURE_WORLDGEN).getEntries().stream().
|
||||
return world.getRegistryManager().get(Registry.CONFIGURED_STRUCTURE_FEATURE_KEY).getEntries().stream().
|
||||
filter(cS -> cS.getValue().feature == structure).
|
||||
findFirst().map(Map.Entry::getValue).orElse(null);
|
||||
}
|
||||
@@ -158,13 +158,15 @@ public class FeatureGenerator
|
||||
ConfiguredStructureFeature<?, ?> configuredFeature = biome.getGenerationSettings().method_30978(structure.configure(null));
|
||||
if (configuredFeature == null || configuredFeature.config == null) return null;
|
||||
ChunkPos chunkPos2 = structure.getStartChunk(params, seed, chunkRandom, chunkPos.x, chunkPos.z); //find some chunk I guess
|
||||
if (chunkPos.x == chunkPos2.x && chunkPos.z == chunkPos2.z && ((StructureFeatureInterface)structure).shouldStartPublicAt(generator, generator.getBiomeSource(), seed, chunkRandom, chunkPos.x, chunkPos.z, biome, chunkPos, configuredFeature.config)) // should start at
|
||||
// using here world for heightview, rather than chunk since we - unlike vanilla, want to avoid creating any chunks even on the
|
||||
// structure starts level - lets see where would that take us.
|
||||
if (chunkPos.x == chunkPos2.x && chunkPos.z == chunkPos2.z && ((StructureFeatureInterface)structure).shouldStartPublicAt(generator, generator.getBiomeSource(), seed, chunkRandom, chunkPos, biome, chunkPos, configuredFeature.config, world)) // should start at
|
||||
{
|
||||
if (!computeBox) return StructureStart.DEFAULT;
|
||||
StructureManager manager = world.getStructureManager();
|
||||
StructureStart<T> structureStart3 = structure.getStructureStartFactory().create((StructureFeature<T>) configuredFeature.feature, chunkPos.x, chunkPos.z, BlockBox.empty(), 0, seed);
|
||||
StructureStart<T> structureStart3 = structure.getStructureStartFactory().create((StructureFeature<T>) configuredFeature.feature, chunkPos, 0, seed);
|
||||
synchronized (boo) {
|
||||
structureStart3.init(world.getRegistryManager(), generator, manager, chunkPos.x, chunkPos.z, biome, (T) configuredFeature.config);
|
||||
structureStart3.init(world.getRegistryManager(), generator, manager, chunkPos, biome, (T) configuredFeature.config, world);
|
||||
}
|
||||
if (!structureStart3.hasChildren()) return null;
|
||||
return structureStart3;
|
||||
@@ -190,7 +192,7 @@ public class FeatureGenerator
|
||||
new Identifier("bastion/starts"),
|
||||
new Identifier("empty"),
|
||||
ImmutableList.of(
|
||||
Pair.of(StructurePoolElement.method_30435("bastion/units/air_base", StructureProcessorLists.BASTION_GENERIC_DEGRADATION), 1)
|
||||
Pair.of(StructurePoolElement.ofProcessedSingle("bastion/units/air_base", StructureProcessorLists.BASTION_GENERIC_DEGRADATION), 1)
|
||||
),
|
||||
StructurePool.Projection.RIGID
|
||||
), 6),
|
||||
@@ -202,7 +204,7 @@ public class FeatureGenerator
|
||||
new Identifier("bastion/starts"),
|
||||
new Identifier("empty"),
|
||||
ImmutableList.of(
|
||||
Pair.of(StructurePoolElement.method_30435("bastion/hoglin_stable/air_base", StructureProcessorLists.BASTION_GENERIC_DEGRADATION), 1)
|
||||
Pair.of(StructurePoolElement.ofProcessedSingle("bastion/hoglin_stable/air_base", StructureProcessorLists.BASTION_GENERIC_DEGRADATION), 1)
|
||||
),
|
||||
StructurePool.Projection.RIGID
|
||||
), 6),
|
||||
@@ -214,7 +216,7 @@ public class FeatureGenerator
|
||||
new Identifier("bastion/starts"),
|
||||
new Identifier("empty"),
|
||||
ImmutableList.of(
|
||||
Pair.of(StructurePoolElement.method_30435("bastion/treasure/big_air_full", StructureProcessorLists.BASTION_GENERIC_DEGRADATION), 1)
|
||||
Pair.of(StructurePoolElement.ofProcessedSingle("bastion/treasure/big_air_full", StructureProcessorLists.BASTION_GENERIC_DEGRADATION), 1)
|
||||
),
|
||||
StructurePool.Projection.RIGID
|
||||
), 6),
|
||||
@@ -226,7 +228,7 @@ public class FeatureGenerator
|
||||
new Identifier("bastion/starts"),
|
||||
new Identifier("empty"),
|
||||
ImmutableList.of(
|
||||
Pair.of(StructurePoolElement.method_30435("bastion/bridge/starting_pieces/entrance_base", StructureProcessorLists.BASTION_GENERIC_DEGRADATION), 1)
|
||||
Pair.of(StructurePoolElement.ofProcessedSingle("bastion/bridge/starting_pieces/entrance_base", StructureProcessorLists.BASTION_GENERIC_DEGRADATION), 1)
|
||||
),
|
||||
StructurePool.Projection.RIGID
|
||||
), 6),
|
||||
|
||||
@@ -12,7 +12,7 @@ import it.unimi.dsi.fastutil.objects.Object2LongMap;
|
||||
import net.minecraft.block.AbstractBannerBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.MaterialColor;
|
||||
import net.minecraft.block.MapColor;
|
||||
import net.minecraft.block.Stainable;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.DyeItem;
|
||||
@@ -100,7 +100,7 @@ public class HopperCounter
|
||||
{
|
||||
startTick = -1;
|
||||
this.color = color;
|
||||
this.prettyColour = WoolTool.Material2DyeName.getOrDefault(color.getMaterialColor(),"w ") + color.getName();
|
||||
this.prettyColour = WoolTool.Material2DyeName.getOrDefault(color.getMapColor(),"w ") + color.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -229,7 +229,7 @@ public class HopperCounter
|
||||
*/
|
||||
public static int appropriateColor(int color)
|
||||
{
|
||||
if (color == 0) return MaterialColor.WHITE.color;
|
||||
if (color == 0) return MapColor.WHITE.color;
|
||||
int r = (color >> 16 & 255);
|
||||
int g = (color >> 8 & 255);
|
||||
int b = (color & 255);
|
||||
@@ -326,6 +326,8 @@ public class HopperCounter
|
||||
.put(Items.PHANTOM_MEMBRANE,Blocks.BONE_BLOCK)
|
||||
.put(Items.EGG,Blocks.BONE_BLOCK)
|
||||
//.put(Items.,Blocks.)
|
||||
.put(Items.COPPER_INGOT,Blocks.COPPER_BLOCK)
|
||||
.put(Items.AMETHYST_SHARD, Blocks.AMETHYST_BLOCK)
|
||||
.build();
|
||||
|
||||
/**
|
||||
@@ -333,8 +335,8 @@ public class HopperCounter
|
||||
*/
|
||||
public static TextColor fromItem(Item item)
|
||||
{
|
||||
if (DEFAULTS.containsKey(item)) return TextColor.fromRgb(appropriateColor(DEFAULTS.get(item).getDefaultMaterialColor().color));
|
||||
if (item instanceof DyeItem) return TextColor.fromRgb(appropriateColor(((DyeItem) item).getColor().getMaterialColor().color));
|
||||
if (DEFAULTS.containsKey(item)) return TextColor.fromRgb(appropriateColor(DEFAULTS.get(item).getDefaultMapColor().color));
|
||||
if (item instanceof DyeItem) return TextColor.fromRgb(appropriateColor(((DyeItem) item).getColor().getMapColor().color));
|
||||
Block block = null;
|
||||
Identifier id = Registry.ITEM.getId(item);
|
||||
if (item instanceof BlockItem)
|
||||
@@ -347,9 +349,9 @@ public class HopperCounter
|
||||
}
|
||||
if (block != null)
|
||||
{
|
||||
if (block instanceof AbstractBannerBlock) return TextColor.fromRgb(appropriateColor(((AbstractBannerBlock) block).getColor().getMaterialColor().color));
|
||||
if (block instanceof Stainable) return TextColor.fromRgb(appropriateColor( ((Stainable) block).getColor().getMaterialColor().color));
|
||||
return TextColor.fromRgb(appropriateColor( block.getDefaultMaterialColor().color));
|
||||
if (block instanceof AbstractBannerBlock) return TextColor.fromRgb(appropriateColor(((AbstractBannerBlock) block).getColor().getMapColor().color));
|
||||
if (block instanceof Stainable) return TextColor.fromRgb(appropriateColor( ((Stainable) block).getColor().getMapColor().color));
|
||||
return TextColor.fromRgb(appropriateColor( block.getDefaultMapColor().color));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -368,7 +370,7 @@ public class HopperCounter
|
||||
{
|
||||
for (Recipe<?> r: ((RecipeManagerInterface) CarpetServer.minecraft_server.getRecipeManager()).getAllMatching(type, id))
|
||||
{
|
||||
for (Ingredient ingredient: r.getPreviewInputs())
|
||||
for (Ingredient ingredient: r.getIngredients())
|
||||
{
|
||||
for (Collection<ItemStack> stacks : ((IngredientInterface) (Object) ingredient).getRecipeStacks())
|
||||
{
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package carpet.helpers;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
|
||||
public class InventoryHelper
|
||||
{
|
||||
// From nbt/Tag.java createTag()
|
||||
// From nbt/NbtElement.java createTag()
|
||||
public static final int TAG_END = 0;
|
||||
public static final int TAG_BYTE = 1;
|
||||
public static final int TAG_SHORT = 2;
|
||||
@@ -23,12 +23,12 @@ public class InventoryHelper
|
||||
public static boolean cleanUpShulkerBoxTag(ItemStack stack)
|
||||
{
|
||||
boolean changed = false;
|
||||
CompoundTag tag = stack.getTag();
|
||||
NbtCompound tag = stack.getTag();
|
||||
|
||||
if (tag == null || !tag.contains("BlockEntityTag", TAG_COMPOUND))
|
||||
return false;
|
||||
|
||||
CompoundTag bet = tag.getCompound("BlockEntityTag");
|
||||
NbtCompound bet = tag.getCompound("BlockEntityTag");
|
||||
if (bet.contains("Items", TAG_LIST) && bet.getList("Items", TAG_COMPOUND).isEmpty())
|
||||
{
|
||||
bet.remove("Items");
|
||||
@@ -50,12 +50,12 @@ public class InventoryHelper
|
||||
|
||||
public static boolean shulkerBoxHasItems(ItemStack stack)
|
||||
{
|
||||
CompoundTag tag = stack.getTag();
|
||||
NbtCompound tag = stack.getTag();
|
||||
|
||||
if (tag == null || !tag.contains("BlockEntityTag", TAG_COMPOUND))
|
||||
return false;
|
||||
|
||||
CompoundTag bet = tag.getCompound("BlockEntityTag");
|
||||
NbtCompound bet = tag.getCompound("BlockEntityTag");
|
||||
return bet.contains("Items", TAG_LIST) && !bet.getList("Items", TAG_COMPOUND).isEmpty();
|
||||
}
|
||||
}
|
||||
@@ -134,14 +134,14 @@ public class OptimizedExplosion
|
||||
}
|
||||
|
||||
if (!entity.isImmuneToExplosion()) {
|
||||
double d12 = MathHelper.sqrt(entity.squaredDistanceTo(eAccess.getX(), eAccess.getY(), eAccess.getZ())) / (double) f3;
|
||||
double d12 = Math.sqrt(entity.squaredDistanceTo(eAccess.getX(), eAccess.getY(), eAccess.getZ())) / (double) f3;
|
||||
|
||||
if (d12 <= 1.0D) {
|
||||
double d5 = entity.getX() - eAccess.getX();
|
||||
// Change in 1.16 snapshots to fix a bug with TNT jumping
|
||||
double d7 = (entity instanceof TntEntity ? entity.getY() : entity.getEyeY()) - eAccess.getY();
|
||||
double d9 = entity.getZ() - eAccess.getZ();
|
||||
double d13 = (double) MathHelper.sqrt(d5 * d5 + d7 * d7 + d9 * d9);
|
||||
double d13 = (double) Math.sqrt(d5 * d5 + d7 * d7 + d9 * d9);
|
||||
|
||||
if (d13 != 0.0D) {
|
||||
d5 = d5 / d13;
|
||||
@@ -184,7 +184,7 @@ public class OptimizedExplosion
|
||||
PlayerEntity player = (PlayerEntity) entity;
|
||||
|
||||
if (!player.isSpectator()
|
||||
&& (!player.isCreative() || !player.abilities.flying)) {
|
||||
&& (!player.isCreative() || !player.getAbilities().flying)) { //getAbilities
|
||||
e.getAffectedPlayers().put(player, new Vec3d(d5 * d10, d7 * d10, d9 * d10));
|
||||
}
|
||||
}
|
||||
@@ -244,7 +244,7 @@ public class OptimizedExplosion
|
||||
{
|
||||
if (block.shouldDropItemsOnExplosion(e) && world instanceof ServerWorld)
|
||||
{
|
||||
BlockEntity blockEntity = block.hasBlockEntity() ? world.getBlockEntity(blockpos) : null;
|
||||
BlockEntity blockEntity = state.hasBlockEntity() ? world.getBlockEntity(blockpos) : null; //hasBlockEntity()
|
||||
|
||||
LootContext.Builder lootBuilder = (new LootContext.Builder((ServerWorld)eAccess.getWorld()))
|
||||
.random(eAccess.getWorld().random)
|
||||
|
||||
@@ -2,7 +2,7 @@ package carpet.helpers;
|
||||
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import net.minecraft.command.argument.ParticleArgumentType;
|
||||
import net.minecraft.command.argument.ParticleEffectArgumentType;
|
||||
import net.minecraft.particle.ParticleEffect;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
@@ -19,7 +19,7 @@ public class ParticleDisplay
|
||||
{
|
||||
try
|
||||
{
|
||||
return ParticleArgumentType.readParameters(new StringReader(name));
|
||||
return ParticleEffectArgumentType.readParameters(new StringReader(name));
|
||||
}
|
||||
catch (CommandSyntaxException e)
|
||||
{
|
||||
|
||||
@@ -147,7 +147,7 @@ public class TickSpeed
|
||||
time_warp_start_time = 0;
|
||||
if (tick_warp_callback != null)
|
||||
{
|
||||
CommandManager icommandmanager = tick_warp_sender.getMinecraftServer().getCommandManager();
|
||||
CommandManager icommandmanager = tick_warp_sender.getServer().getCommandManager();
|
||||
try
|
||||
{
|
||||
icommandmanager.execute(tick_warp_sender, tick_warp_callback);
|
||||
|
||||
@@ -28,7 +28,7 @@ public class XPcombine
|
||||
first == other || first.world.isClient || first.getServer().getTicks() == lastTickCombine
|
||||
|| !first.isAlive() || !other.isAlive()
|
||||
|| first.getExperienceAmount() > 15000 || other.getExperienceAmount() > 15000
|
||||
|| first.pickupDelay == 32767 || other.pickupDelay == 32767
|
||||
//|| first.pickupDelay == 32767 || other.pickupDelay == 32767
|
||||
|| first.age == -32768 || other.age == -32768
|
||||
|| ((ExperienceOrbInterface)first).getCombineDelay() != 0 || ((ExperienceOrbInterface)other).getCombineDelay() != 0
|
||||
)
|
||||
@@ -37,21 +37,24 @@ public class XPcombine
|
||||
}
|
||||
|
||||
int size = getTextureByXP(first.getExperienceAmount());
|
||||
((ExperienceOrbInterface) first).setAmount(first.getExperienceAmount() + other.getExperienceAmount());
|
||||
((ExperienceOrbInterface) first).setCombineDelay(Math.max(first.pickupDelay, other.pickupDelay));
|
||||
((ExperienceOrbInterface) first).setAmount(
|
||||
first.getExperienceAmount()*((ExperienceOrbInterface) first).getCount() +
|
||||
other.getExperienceAmount()*((ExperienceOrbInterface) other).getCount());
|
||||
((ExperienceOrbInterface) first).setCount(1);
|
||||
//((ExperienceOrbInterface) first).setCombineDelay(Math.max(first.pickupDelay, other.pickupDelay));
|
||||
first.age = Math.min(first.age, other.age);
|
||||
other.remove();
|
||||
other.discard(); //discard
|
||||
|
||||
|
||||
ExperienceOrbEntity newOrb;
|
||||
if (getTextureByXP(first.getExperienceAmount()) != size)
|
||||
{
|
||||
newOrb = new ExperienceOrbEntity(EntityType.EXPERIENCE_ORB, first.world);
|
||||
newOrb.refreshPositionAndAngles(first.getX(), first.getY(), first.getZ(), first.yaw, first.pitch);
|
||||
newOrb.refreshPositionAndAngles(first.getX(), first.getY(), first.getZ(), first.getYaw(), first.getPitch());
|
||||
((ExperienceOrbInterface)newOrb).setAmount(first.getExperienceAmount());
|
||||
|
||||
first.world.spawnEntity(newOrb);
|
||||
first.remove();
|
||||
first.discard(); // discard
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -7,7 +7,9 @@ import carpet.logging.logHelpers.PacketCounter;
|
||||
import carpet.mixins.PlayerListHeaderS2CPacketMixin;
|
||||
import carpet.utils.Messenger;
|
||||
import carpet.utils.SpawnReporter;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.network.packet.s2c.play.PlayerListHeaderS2CPacket;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
@@ -42,10 +44,9 @@ public class HUDController
|
||||
}
|
||||
|
||||
public static Map<ServerPlayerEntity, List<BaseText>> player_huds = new HashMap<>();
|
||||
|
||||
//keyed with player names so unlogged players don't hold the reference
|
||||
//keyed with player names so unlogged players don't hold the reference
|
||||
public static final Map<String, BaseText> scarpet_headers = new HashMap<>();
|
||||
|
||||
|
||||
public static final Map<String, BaseText> scarpet_footers = new HashMap<>();
|
||||
|
||||
public static void resetScarpetHUDs() {
|
||||
@@ -68,9 +69,10 @@ public class HUDController
|
||||
}
|
||||
public static void clear_player(PlayerEntity player)
|
||||
{
|
||||
PlayerListHeaderS2CPacket packet = new PlayerListHeaderS2CPacket();
|
||||
((PlayerListHeaderS2CPacketMixin)packet).setHeader(new LiteralText(""));
|
||||
((PlayerListHeaderS2CPacketMixin)packet).setFooter(new LiteralText(""));
|
||||
PacketByteBuf packetData = new PacketByteBuf(Unpooled.buffer()).writeText(new LiteralText("")).writeText(new LiteralText(""));
|
||||
PlayerListHeaderS2CPacket packet = new PlayerListHeaderS2CPacket(packetData);
|
||||
//((PlayerListHeaderS2CPacketMixin)packet).setHeader(new LiteralText(""));
|
||||
//((PlayerListHeaderS2CPacketMixin)packet).setFooter(new LiteralText(""));
|
||||
((ServerPlayerEntity)player).networkHandler.sendPacket(packet);
|
||||
}
|
||||
|
||||
@@ -121,9 +123,14 @@ public class HUDController
|
||||
if (force!= null) targets.addAll(force);
|
||||
for (ServerPlayerEntity player: targets)
|
||||
{
|
||||
PlayerListHeaderS2CPacket packet = new PlayerListHeaderS2CPacket();
|
||||
((PlayerListHeaderS2CPacketMixin)packet).setHeader(scarpet_headers.getOrDefault(player.getEntityName(), new LiteralText("")));
|
||||
((PlayerListHeaderS2CPacketMixin)packet).setFooter(Messenger.c(player_huds.getOrDefault(player, Collections.emptyList()).toArray(new Object[0])));
|
||||
PacketByteBuf packetData = new PacketByteBuf(Unpooled.buffer()).
|
||||
writeText(scarpet_headers.getOrDefault(player.getEntityName(), new LiteralText(""))).
|
||||
writeText(Messenger.c(player_huds.getOrDefault(player, Collections.emptyList()).toArray(new Object[0])));
|
||||
PlayerListHeaderS2CPacket packet = new PlayerListHeaderS2CPacket(packetData);
|
||||
|
||||
//PlayerListHeaderS2CPacket packet = new PlayerListHeaderS2CPacket();
|
||||
//((PlayerListHeaderS2CPacketMixin)packet).setHeader(scarpet_headers.getOrDefault(player.getEntityName(), new LiteralText("")));
|
||||
//((PlayerListHeaderS2CPacketMixin)packet).setFooter(Messenger.c(player_huds.getOrDefault(player, Collections.emptyList()).toArray(new Object[0])));
|
||||
player.networkHandler.sendPacket(packet);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.block.AbstractCauldronBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.ShulkerBoxBlock;
|
||||
import net.minecraft.block.cauldron.CauldronBehavior;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(AbstractCauldronBlock.class)
|
||||
public class AbstractCauldronBlock_stackableSBoxesMixin
|
||||
{
|
||||
@Redirect(method = "onUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/cauldron/CauldronBehavior;interact(Lnet/minecraft/block/BlockState;Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/Hand;Lnet/minecraft/item/ItemStack;)Lnet/minecraft/util/ActionResult;"))
|
||||
private ActionResult wrapInteractor(CauldronBehavior cauldronBehavior, BlockState blockState, World world, BlockPos blockPos, PlayerEntity playerEntity, Hand hand, ItemStack itemStack)
|
||||
{
|
||||
int count = -1;
|
||||
if (CarpetSettings.stackableShulkerBoxes && itemStack.getItem() instanceof BlockItem && ((BlockItem)itemStack.getItem()).getBlock() instanceof ShulkerBoxBlock)
|
||||
count = itemStack.getCount();
|
||||
ActionResult result = cauldronBehavior.interact(blockState, world, blockPos, playerEntity, hand, itemStack);
|
||||
if (count > 0 && result.isAccepted())
|
||||
{
|
||||
ItemStack current = playerEntity.getStackInHand(hand);
|
||||
if (current.getItem() instanceof BlockItem && ((BlockItem)itemStack.getItem()).getBlock() instanceof ShulkerBoxBlock)
|
||||
current.setCount(count);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ public abstract class ArmorStandEntity_scarpetMarkerMixin extends LivingEntity
|
||||
* Remove all markers that do not belong to any script host and not part of the global one when loaded
|
||||
* @param ci
|
||||
*/
|
||||
@Inject(method = "readCustomDataFromTag", at = @At("HEAD"))
|
||||
@Inject(method = "readCustomDataFromNbt", at = @At("HEAD"))
|
||||
private void checkScarpetMarkerUnloaded(CallbackInfo ci)
|
||||
{
|
||||
if (!world.isClient)
|
||||
@@ -40,13 +40,13 @@ public abstract class ArmorStandEntity_scarpetMarkerMixin extends LivingEntity
|
||||
String hostName = StringUtils.removeStart(owner.get(),prefix);
|
||||
if (!hostName.isEmpty() && CarpetServer.scriptServer.getHostByName(hostName) == null)
|
||||
{
|
||||
remove();
|
||||
discard(); //discard
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
remove();
|
||||
discard(); // discard
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ import carpet.CarpetSettings;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.mojang.serialization.Codec;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.util.collection.Pool;
|
||||
import net.minecraft.world.MobSpawnerLogic;
|
||||
import net.minecraft.world.biome.SpawnSettings;
|
||||
import net.minecraft.world.gen.feature.BastionRemnantFeature;
|
||||
|
||||
@@ -18,7 +20,7 @@ import java.util.List;
|
||||
@Mixin(BastionRemnantFeature.class)
|
||||
public abstract class BastionRemnantFeatureMixin extends JigsawFeature
|
||||
{
|
||||
private static final List<SpawnSettings.SpawnEntry> spawnList = Lists.newArrayList(
|
||||
private static final Pool<SpawnSettings.SpawnEntry> spawnList = Pool.of(
|
||||
new SpawnSettings.SpawnEntry(EntityType.PIGLIN_BRUTE, 5, 1, 2),
|
||||
new SpawnSettings.SpawnEntry(EntityType.PIGLIN, 10, 2, 4),
|
||||
new SpawnSettings.SpawnEntry(EntityType.HOGLIN, 2, 1, 2)
|
||||
@@ -30,10 +32,10 @@ public abstract class BastionRemnantFeatureMixin extends JigsawFeature
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SpawnSettings.SpawnEntry> getMonsterSpawns()
|
||||
public Pool<SpawnSettings.SpawnEntry> getMonsterSpawns()
|
||||
{
|
||||
if (CarpetSettings.piglinsSpawningInBastions)
|
||||
return spawnList;
|
||||
return Collections.emptyList();
|
||||
return SpawnSettings.EMPTY_ENTRY_POOL;
|
||||
}
|
||||
}
|
||||
@@ -10,12 +10,14 @@ import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
@Mixin(BiomeArray.class)
|
||||
public class BiomeArray_cleanLogsMixin
|
||||
{
|
||||
@Redirect(method = "<init>(Lnet/minecraft/util/collection/IndexedIterable;[I)V", at = @At(
|
||||
// this changed in 21w18a - maybe its not needed anymore, please check
|
||||
@SuppressWarnings("UnresolvedMixinReference")
|
||||
@Redirect(method = "<init>(Lnet/minecraft/util/collection/IndexedIterable;Lnet/minecraft/world/HeightLimitView;[I)V", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lorg/apache/logging/log4j/Logger;warn(Ljava/lang/String;)V")
|
||||
target = "Lorg/apache/logging/log4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V")
|
||||
)
|
||||
private void skipLog(Logger logger, String message)
|
||||
private void skipLog(Logger logger, String message, Object p0, Object p1)
|
||||
{
|
||||
if (!CarpetSettings.cleanLogs) logger.warn(message);
|
||||
if (!CarpetSettings.cleanLogs) logger.warn(message, p0, p1);
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.source.BiomeArray;
|
||||
import net.minecraft.world.biome.source.BiomeCoords;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@@ -18,16 +19,20 @@ public class BiomeArray_getBiomeArrayMixin implements BiomeArrayInterface
|
||||
|
||||
@Shadow @Final public static int HORIZONTAL_BIT_MASK;
|
||||
|
||||
@Shadow @Final public static int VERTICAL_BIT_MASK;
|
||||
//@Shadow @Final public static int VERTICAL_BIT_MASK;
|
||||
|
||||
@Shadow @Final private Biome[] data;
|
||||
|
||||
@Shadow @Final private int field_28126;
|
||||
|
||||
@Shadow @Final private int field_28127;
|
||||
|
||||
@Override
|
||||
public void setBiomeAtIndex(BlockPos pos, World world, Biome what)
|
||||
{
|
||||
int int_4 = (pos.getX() >> 2) & HORIZONTAL_BIT_MASK;
|
||||
int int_5 = MathHelper.clamp((pos.getY() >> 2), 0, VERTICAL_BIT_MASK);
|
||||
int int_6 = (pos.getZ() >> 2) & HORIZONTAL_BIT_MASK;
|
||||
int int_4 = BiomeCoords.fromBlock(pos.getX()) & HORIZONTAL_BIT_MASK;
|
||||
int int_5 = MathHelper.clamp(BiomeCoords.fromBlock(pos.getY())-field_28126, 0, field_28127);
|
||||
int int_6 = BiomeCoords.fromBlock(pos.getZ()) & HORIZONTAL_BIT_MASK;
|
||||
data[(int_5 << (HORIZONTAL_SECTION_COUNT + HORIZONTAL_SECTION_COUNT)) | (int_6 << HORIZONTAL_SECTION_COUNT) | int_4] = what;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.fakes.BlockEntityInterface;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Mutable;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(BlockEntity.class)
|
||||
public abstract class BlockEntity_movableBEMixin implements BlockEntityInterface
|
||||
{
|
||||
@Mutable
|
||||
@Shadow @Final protected BlockPos pos;
|
||||
|
||||
public void setCMPos(BlockPos newPos)
|
||||
{
|
||||
pos = newPos;
|
||||
};
|
||||
}
|
||||
@@ -24,7 +24,7 @@ public class BlockItem_creativeNoClipMixin
|
||||
ItemPlacementContext contextOuter, BlockState stateOuter)
|
||||
{
|
||||
PlayerEntity player = contextOuter.getPlayer();
|
||||
if (CarpetSettings.creativeNoClip && player != null && player.isCreative() && player.abilities.flying)
|
||||
if (CarpetSettings.creativeNoClip && player != null && player.isCreative() && player.getAbilities().flying)
|
||||
{
|
||||
// copy from canPlace
|
||||
VoxelShape voxelShape = state.getCollisionShape(world, pos, context);
|
||||
|
||||
@@ -2,7 +2,7 @@ package carpet.mixins;
|
||||
|
||||
import carpet.fakes.BlockStateArgumentInterface;
|
||||
import net.minecraft.command.argument.BlockStateArgument;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -11,10 +11,10 @@ import org.spongepowered.asm.mixin.Shadow;
|
||||
@Mixin(BlockStateArgument.class)
|
||||
public class BlockStateArgument_scarpetMixin implements BlockStateArgumentInterface
|
||||
{
|
||||
@Shadow @Final private @Nullable CompoundTag data;
|
||||
@Shadow @Final private @Nullable NbtCompound data;
|
||||
|
||||
@Override
|
||||
public CompoundTag getCMTag()
|
||||
public NbtCompound getCMTag()
|
||||
{
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.BuddingAmethystBlock;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.block.piston.PistonBehavior;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.enchantment.Enchantments;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.PickaxeItem;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(BuddingAmethystBlock.class)
|
||||
public class BuddingAmethystBlock_movableAmethystMixin extends Block {
|
||||
public BuddingAmethystBlock_movableAmethystMixin(Settings settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "getPistonBehavior(Lnet/minecraft/block/BlockState;)Lnet/minecraft/block/piston/PistonBehavior;", cancellable = true)
|
||||
void getPistonBehavior(BlockState state, CallbackInfoReturnable<PistonBehavior> cir) {
|
||||
if (CarpetSettings.movableAmethyst) cir.setReturnValue(PistonBehavior.NORMAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterBreak(World world, PlayerEntity player, BlockPos pos, BlockState state, @Nullable BlockEntity blockEntity, ItemStack stack) {
|
||||
super.afterBreak(world, player, pos, state, blockEntity, stack);
|
||||
// doing it here rather than though loottables since loottables are loaded on reload
|
||||
// drawback - not controlled via loottables, but hey
|
||||
if (CarpetSettings.movableAmethyst &&
|
||||
stack.getItem() instanceof PickaxeItem &&
|
||||
EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, stack) > 0
|
||||
)
|
||||
dropStack(world, pos, Items.BUDDING_AMETHYST.getDefaultStack());
|
||||
}
|
||||
}
|
||||
@@ -3,12 +3,12 @@ package carpet.mixins;
|
||||
import carpet.utils.WoolTool;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.CarpetBlock;
|
||||
import net.minecraft.block.DyedCarpetBlock;
|
||||
import net.minecraft.item.ItemPlacementContext;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
@Mixin(CarpetBlock.class)
|
||||
@Mixin(DyedCarpetBlock.class) // WoolCarpetBlock
|
||||
public abstract class CarpetBlockMixin extends Block
|
||||
{
|
||||
|
||||
@@ -21,8 +21,8 @@ public abstract class CarpetBlockMixin extends Block
|
||||
{
|
||||
BlockState state = super.getPlacementState(context);
|
||||
if (context.getPlayer() != null && !context.getWorld().isClient)
|
||||
{
|
||||
WoolTool.carpetPlacedAction(((CarpetBlock)(Object)this).getColor(), context.getPlayer(), context.getBlockPos(), (ServerWorld) context.getWorld());
|
||||
{ // getColor()
|
||||
WoolTool.carpetPlacedAction(((DyedCarpetBlock)(Object)this).getDyeColor(), context.getPlayer(), context.getBlockPos(), (ServerWorld) context.getWorld());
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
@Mixin(CauldronBlock.class)
|
||||
public class CauldronBlock_stackableSBoxesMixin
|
||||
{
|
||||
{/*
|
||||
@Inject(method = "onUse", locals = LocalCapture.CAPTURE_FAILHARD, at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/item/ItemStack;hasTag()Z",
|
||||
@@ -30,5 +30,5 @@ public class CauldronBlock_stackableSBoxesMixin
|
||||
{
|
||||
if (CarpetSettings.stackableShulkerBoxes)
|
||||
itemStack5.setCount(itemStack.getCount());
|
||||
}
|
||||
}*/
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package carpet.mixins;
|
||||
import carpet.fakes.ChunkHolderInterface;
|
||||
import com.mojang.datafixers.util.Either;
|
||||
import net.minecraft.server.world.ChunkHolder;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.util.thread.ThreadExecutor;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
@@ -19,19 +20,19 @@ import java.util.concurrent.atomic.AtomicReferenceArray;
|
||||
@Mixin(ChunkHolder.class)
|
||||
public abstract class ChunkHolder_scarpetChunkCreationMixin implements ChunkHolderInterface
|
||||
{
|
||||
@Shadow protected abstract void combineSavingFuture(CompletableFuture<? extends Either<? extends Chunk, ChunkHolder.Unloaded>> newChunkFuture);
|
||||
@Shadow protected abstract void combineSavingFuture(CompletableFuture<? extends Either<? extends Chunk, ChunkHolder.Unloaded>> newChunkFuture, String type);
|
||||
|
||||
@Shadow @Final private AtomicReferenceArray<CompletableFuture<Either<Chunk, ChunkHolder.Unloaded>>> futuresByStatus;
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Either<Chunk, ChunkHolder.Unloaded>> setDefaultProtoChunk(ChunkPos chpos, ThreadExecutor<Runnable> executor)
|
||||
public CompletableFuture<Either<Chunk, ChunkHolder.Unloaded>> setDefaultProtoChunk(ChunkPos chpos, ThreadExecutor<Runnable> executor, ServerWorld world)
|
||||
{
|
||||
int i = ChunkStatus.EMPTY.getIndex();
|
||||
CompletableFuture<Either<Chunk, ChunkHolder.Unloaded>> completableFuture2 = CompletableFuture.supplyAsync(
|
||||
() -> Either.left(new ProtoChunk(chpos, UpgradeData.NO_UPGRADE_DATA)),
|
||||
() -> Either.left(new ProtoChunk(chpos, UpgradeData.NO_UPGRADE_DATA, world)),
|
||||
executor
|
||||
);
|
||||
combineSavingFuture(completableFuture2);
|
||||
combineSavingFuture(completableFuture2, "unfull"); // possible debug data
|
||||
futuresByStatus.set(i, completableFuture2);
|
||||
return completableFuture2;
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ public abstract class CommandManagerMixin
|
||||
@Inject(method = "<init>", at = @At("RETURN"))
|
||||
private void onRegister(CommandManager.RegistrationEnvironment arg, CallbackInfo ci) {
|
||||
CarpetServer.registerCarpetCommands(this.dispatcher);
|
||||
CarpetServer.registerCarpetCommands(this.dispatcher, arg);
|
||||
}
|
||||
|
||||
@Inject(method = "execute", at = @At("HEAD"))
|
||||
|
||||
@@ -7,11 +7,13 @@ import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.screen.ScreenHandler;
|
||||
import net.minecraft.util.collection.DefaultedList;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.List;
|
||||
@@ -19,20 +21,25 @@ import java.util.List;
|
||||
@Mixin(ScreenHandler.class)
|
||||
public abstract class ContainerMixin
|
||||
{
|
||||
@Shadow @Final public List<Slot> slots;
|
||||
|
||||
@Shadow public abstract ItemStack onSlotClick(int int_1, int int_2, SlotActionType slotActionType_1, PlayerEntity playerEntity_1);
|
||||
@Shadow public abstract void onSlotClick(int int_1, int int_2, SlotActionType slotActionType_1, PlayerEntity playerEntity_1);
|
||||
|
||||
@Shadow public abstract void sendContentUpdates();
|
||||
|
||||
@Inject( method = "onSlotClick", at = @At(value = "HEAD"), cancellable = true)
|
||||
private void onThrowClick( int slotId, int clickData, SlotActionType actionType, PlayerEntity playerEntity, CallbackInfoReturnable<ItemStack> cir)
|
||||
@Shadow @Final public DefaultedList<Slot> slots;
|
||||
|
||||
@Shadow protected abstract void endQuickCraft();
|
||||
|
||||
@Shadow public abstract ItemStack getCursorStack();
|
||||
|
||||
@Inject( method = "internalOnSlotClick", at = @At(value = "HEAD"), cancellable = true)
|
||||
private void onThrowClick(int slotId, int clickData, SlotActionType actionType, PlayerEntity playerEntity, CallbackInfo ci)
|
||||
{
|
||||
if (actionType == SlotActionType.THROW && CarpetSettings.ctrlQCraftingFix && playerEntity.inventory.getCursorStack().isEmpty() && slotId >= 0)
|
||||
if (actionType == SlotActionType.THROW && CarpetSettings.ctrlQCraftingFix && this.getCursorStack().isEmpty() && slotId >= 0)
|
||||
{
|
||||
ItemStack itemStack_1 = ItemStack.EMPTY;
|
||||
Slot slot_4 = slots.get(slotId);
|
||||
if (slot_4 != null && slot_4.hasStack() && slot_4.canTakeItems(playerEntity))
|
||||
if (/*slot_4 != null && */slot_4.hasStack() && slot_4.canTakeItems(playerEntity))
|
||||
{
|
||||
if(slotId == 0 && clickData == 1)
|
||||
{
|
||||
@@ -42,8 +49,8 @@ public abstract class ContainerMixin
|
||||
this.onSlotClick(slotId, 0, SlotActionType.THROW, playerEntity);
|
||||
}
|
||||
this.sendContentUpdates();
|
||||
cir.setReturnValue(itemStack_1);
|
||||
cir.cancel();
|
||||
this.endQuickCraft();
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.CoralBlock;
|
||||
import net.minecraft.block.CoralParentBlock;
|
||||
import net.minecraft.block.Fertilizable;
|
||||
import net.minecraft.block.MaterialColor;
|
||||
import net.minecraft.block.MapColor;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.tag.BlockTags;
|
||||
import net.minecraft.tag.FluidTags;
|
||||
@@ -49,12 +49,12 @@ public abstract class CoralBlockMixin implements Fertilizable
|
||||
else
|
||||
coral = new CoralMushroomFeature(DefaultFeatureConfig.CODEC);
|
||||
|
||||
MaterialColor color = blockUnder.getTopMaterialColor(worldIn, pos);
|
||||
MapColor color = blockUnder.getMapColor(worldIn, pos);
|
||||
BlockState proper_block = blockUnder;
|
||||
for (Block block: BlockTags.CORAL_BLOCKS.values())
|
||||
{
|
||||
proper_block = block.getDefaultState();
|
||||
if (proper_block.getTopMaterialColor(worldIn,pos) == color)
|
||||
if (proper_block.getMapColor(worldIn,pos) == color)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -15,11 +15,11 @@ import java.util.Random;
|
||||
public abstract class CoralFeatureMixin implements CoralFeatureInterface
|
||||
{
|
||||
|
||||
@Shadow protected abstract boolean spawnCoral(WorldAccess var1, Random var2, BlockPos var3, BlockState var4);
|
||||
@Shadow protected abstract boolean generateCoral(WorldAccess var1, Random var2, BlockPos var3, BlockState var4);
|
||||
|
||||
@Override
|
||||
public boolean growSpecific(World worldIn, Random random, BlockPos pos, BlockState blockUnder)
|
||||
{
|
||||
return spawnCoral(worldIn, random, pos, blockUnder);
|
||||
return generateCoral(worldIn, random, pos, blockUnder);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraft.util.SystemDetails;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -9,19 +11,16 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import carpet.CarpetServer;
|
||||
import net.minecraft.util.crash.CrashReport;
|
||||
import net.minecraft.util.crash.CrashReportSection;
|
||||
|
||||
@Mixin(CrashReport.class)
|
||||
@Mixin(SystemDetails.class)
|
||||
public abstract class CrashReport_addScarpetAppsMixin
|
||||
{
|
||||
@Shadow
|
||||
public abstract CrashReportSection getSystemDetailsSection();
|
||||
|
||||
@Inject(at = @At("RETURN"), method = "fillSystemDetails")
|
||||
@Shadow public abstract void addSection(String name, Supplier<String> valueSupplier);
|
||||
|
||||
@Inject(method = "<init>", at = @At("RETURN"))
|
||||
private void fillSystemDetails(CallbackInfo info) {
|
||||
if (CarpetServer.scriptServer == null || CarpetServer.scriptServer.modules.isEmpty()) return;
|
||||
getSystemDetailsSection().add("Loaded Scarpet Apps", () -> {
|
||||
addSection("Loaded Scarpet Apps", () -> {
|
||||
return CarpetServer.scriptServer.modules.keySet().stream().collect(Collectors.joining("\n\t\t", "\n\t\t", ""));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import carpet.CarpetSettings;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.mojang.serialization.Codec;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.util.collection.Pool;
|
||||
import net.minecraft.world.biome.SpawnSettings;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
import net.minecraft.world.gen.feature.DesertPyramidFeature;
|
||||
@@ -16,11 +17,11 @@ import java.util.List;
|
||||
@Mixin(DesertPyramidFeature.class)
|
||||
public abstract class DesertPyramidFeatureMixin extends StructureFeature<DefaultFeatureConfig>
|
||||
{
|
||||
private static final List<SpawnSettings.SpawnEntry> MONSTER_SPAWNS;
|
||||
private static final Pool<SpawnSettings.SpawnEntry> MONSTER_SPAWNS;
|
||||
|
||||
static
|
||||
{
|
||||
MONSTER_SPAWNS = Lists.newArrayList(new SpawnSettings.SpawnEntry(EntityType.HUSK, 1, 1, 1));
|
||||
MONSTER_SPAWNS = Pool.of(new SpawnSettings.SpawnEntry(EntityType.HUSK, 1, 1, 1));
|
||||
}
|
||||
|
||||
public DesertPyramidFeatureMixin(Codec<DefaultFeatureConfig> codec)
|
||||
@@ -30,13 +31,13 @@ public abstract class DesertPyramidFeatureMixin extends StructureFeature<Default
|
||||
|
||||
|
||||
@Override
|
||||
public List<SpawnSettings.SpawnEntry> getMonsterSpawns()
|
||||
public Pool<SpawnSettings.SpawnEntry> getMonsterSpawns()
|
||||
{
|
||||
if (CarpetSettings.huskSpawningInTemples)
|
||||
{
|
||||
return MONSTER_SPAWNS;
|
||||
}
|
||||
return Collections.emptyList();
|
||||
return SpawnSettings.EMPTY_ENTRY_POOL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import carpet.CarpetSettings;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.mojang.serialization.Codec;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.util.collection.Pool;
|
||||
import net.minecraft.world.biome.SpawnSettings;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
import net.minecraft.world.gen.feature.EndCityFeature;
|
||||
@@ -16,7 +17,7 @@ import java.util.List;
|
||||
@Mixin(EndCityFeature.class)
|
||||
public abstract class EndCityFeatureMixin extends StructureFeature<DefaultFeatureConfig>
|
||||
{
|
||||
private static final List<SpawnSettings.SpawnEntry> spawnList = Lists.newArrayList(new SpawnSettings.SpawnEntry(EntityType.SHULKER, 10, 4, 4));
|
||||
private static final Pool<SpawnSettings.SpawnEntry> spawnList = Pool.of(new SpawnSettings.SpawnEntry(EntityType.SHULKER, 10, 4, 4));
|
||||
|
||||
public EndCityFeatureMixin(Codec<DefaultFeatureConfig> codec)
|
||||
{
|
||||
@@ -24,10 +25,10 @@ public abstract class EndCityFeatureMixin extends StructureFeature<DefaultFeatur
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SpawnSettings.SpawnEntry> getMonsterSpawns()
|
||||
public Pool<SpawnSettings.SpawnEntry> getMonsterSpawns()
|
||||
{
|
||||
if (CarpetSettings.shulkerSpawningInEndCities)
|
||||
return spawnList;
|
||||
return Collections.emptyList();
|
||||
return SpawnSettings.EMPTY_ENTRY_POOL;
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
@Mixin(EndGatewayBlockEntity.class)
|
||||
public class EndGatewayBlockEntity_creativeNoClipMixin
|
||||
{
|
||||
@Inject(method = "method_30276", cancellable = true, at = @At("HEAD"))
|
||||
@Inject(method = "canTeleport", cancellable = true, at = @At("HEAD"))
|
||||
private static void checkFlyingCreative(Entity entity, CallbackInfoReturnable<Boolean> cir)
|
||||
{
|
||||
if (CarpetSettings.isCreativeFlying(entity)) cir.setReturnValue(false);
|
||||
|
||||
@@ -7,6 +7,7 @@ import net.minecraft.entity.ai.pathing.Path;
|
||||
import net.minecraft.entity.mob.MobEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@@ -22,18 +23,18 @@ public abstract class EntityNavigation_pathfindingMixin
|
||||
@Shadow @Final protected MobEntity entity;
|
||||
|
||||
|
||||
@Shadow /*@Nullable*/ protected abstract Path findPathToAny(Set<BlockPos> set_1, int int_1, boolean boolean_1, int int_2);
|
||||
@Shadow protected @Nullable abstract Path findPathTo(Set<BlockPos> set, int i, boolean bl, int j);
|
||||
|
||||
@Redirect(method = "findPathTo(Lnet/minecraft/util/math/BlockPos;I)Lnet/minecraft/entity/ai/pathing/Path;", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/entity/ai/pathing/EntityNavigation;findPathToAny(Ljava/util/Set;IZI)Lnet/minecraft/entity/ai/pathing/Path;"
|
||||
target = "Lnet/minecraft/entity/ai/pathing/EntityNavigation;findPathTo(Ljava/util/Set;IZI)Lnet/minecraft/entity/ai/pathing/Path;"
|
||||
))
|
||||
private Path pathToBlock(EntityNavigation entityNavigation, Set<BlockPos> set_1, int int_1, boolean boolean_1, int int_2)
|
||||
{
|
||||
if (!LoggerRegistry.__pathfinding)
|
||||
return findPathToAny(set_1, int_1, boolean_1, int_2);
|
||||
return findPathTo(set_1, int_1, boolean_1, int_2);
|
||||
long start = System.nanoTime();
|
||||
Path path = findPathToAny(set_1, int_1, boolean_1, int_2);
|
||||
Path path = findPathTo(set_1, int_1, boolean_1, int_2);
|
||||
long finish = System.nanoTime();
|
||||
float duration = (1.0F*((finish - start)/1000))/1000;
|
||||
set_1.forEach(b -> PathfindingVisualizer.slowPath(entity, Vec3d.ofBottomCenter(b), duration, path != null)); // ground centered position
|
||||
@@ -42,14 +43,14 @@ public abstract class EntityNavigation_pathfindingMixin
|
||||
|
||||
@Redirect(method = "findPathTo(Lnet/minecraft/entity/Entity;I)Lnet/minecraft/entity/ai/pathing/Path;", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/entity/ai/pathing/EntityNavigation;findPathToAny(Ljava/util/Set;IZI)Lnet/minecraft/entity/ai/pathing/Path;"
|
||||
target = "Lnet/minecraft/entity/ai/pathing/EntityNavigation;findPathTo(Ljava/util/Set;IZI)Lnet/minecraft/entity/ai/pathing/Path;"
|
||||
))
|
||||
private Path pathToEntity(EntityNavigation entityNavigation, Set<BlockPos> set_1, int int_1, boolean boolean_1, int int_2)
|
||||
{
|
||||
if (!LoggerRegistry.__pathfinding)
|
||||
return findPathToAny(set_1, int_1, boolean_1, int_2);
|
||||
return findPathTo(set_1, int_1, boolean_1, int_2);
|
||||
long start = System.nanoTime();
|
||||
Path path = findPathToAny(set_1, int_1, boolean_1, int_2);
|
||||
Path path = findPathTo(set_1, int_1, boolean_1, int_2);
|
||||
long finish = System.nanoTime();
|
||||
float duration = (1.0F*((finish - start)/1000))/1000;
|
||||
set_1.forEach(b -> PathfindingVisualizer.slowPath(entity, Vec3d.ofBottomCenter(b), duration, path != null));
|
||||
|
||||
@@ -12,10 +12,13 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
@Mixin(Entity.class)
|
||||
public abstract class Entity_scarpetEventsMixin implements EntityInterface
|
||||
{
|
||||
@Shadow public boolean removed;
|
||||
//@Shadow public boolean removed;
|
||||
|
||||
@Shadow protected int netherPortalTime;
|
||||
@Shadow private int netherPortalCooldown;
|
||||
|
||||
@Shadow public abstract boolean isRemoved();
|
||||
|
||||
private boolean permanentVehicle;
|
||||
|
||||
private final EntityEventsGroup events = new EntityEventsGroup((Entity) (Object)this);
|
||||
@@ -72,7 +75,7 @@ public abstract class Entity_scarpetEventsMixin implements EntityInterface
|
||||
@Inject(method = "remove", at = @At("HEAD"))
|
||||
private void onRemove(CallbackInfo ci)
|
||||
{
|
||||
if (!removed) events.onEvent(EntityEventsGroup.Event.ON_REMOVED);
|
||||
if (!isRemoved()) events.onEvent(EntityEventsGroup.Event.ON_REMOVED); // ! isRemoved()
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -3,19 +3,31 @@ package carpet.mixins;
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.fakes.ExperienceOrbInterface;
|
||||
import carpet.helpers.XPcombine;
|
||||
import net.minecraft.entity.EquipmentSlot;
|
||||
import net.minecraft.entity.ExperienceOrbEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Mixin(ExperienceOrbEntity.class)
|
||||
public abstract class ExperienceOrbEntityMixin implements ExperienceOrbInterface
|
||||
{
|
||||
@Shadow private int amount;
|
||||
|
||||
@Shadow private int pickingCount;
|
||||
|
||||
@Shadow protected abstract int getMendingRepairCost(int repairAmount);
|
||||
|
||||
@Shadow protected abstract int getMendingRepairAmount(int experienceAmount);
|
||||
|
||||
public void setAmount(int amount) { this.amount = amount; }
|
||||
|
||||
public int combineDelay = 50;
|
||||
@@ -45,6 +57,16 @@ public abstract class ExperienceOrbEntityMixin implements ExperienceOrbInterface
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return pickingCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCount(int i) {
|
||||
pickingCount = i;
|
||||
}
|
||||
|
||||
@Inject(method = "onPlayerCollision", at = @At("HEAD"))
|
||||
void removeDelay(PlayerEntity playerEntity_1, CallbackInfo ci)
|
||||
{
|
||||
@@ -52,4 +74,14 @@ public abstract class ExperienceOrbEntityMixin implements ExperienceOrbInterface
|
||||
playerEntity_1.experiencePickUpDelay = 0;
|
||||
}
|
||||
|
||||
@Redirect(method = "onPlayerCollision", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;addExperience(I)V"))
|
||||
void addXP(PlayerEntity playerEntity, int experience)
|
||||
{
|
||||
playerEntity.addExperience(experience);
|
||||
if (CarpetSettings.xpNoCooldown) while(pickingCount > 1)
|
||||
{
|
||||
pickingCount --;
|
||||
playerEntity.addExperience(experience);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
@@ -39,6 +40,8 @@ public abstract class Explosion_scarpetEventMixin
|
||||
|
||||
@Shadow /*@Nullable*/ public abstract /*@Nullable*/ LivingEntity getCausingEntity();
|
||||
|
||||
@Shadow public static float getExposure(Vec3d source, Entity entity) {return 0.0f;}
|
||||
|
||||
private List<Entity> affectedEntities;
|
||||
|
||||
@Inject(method = "<init>(Lnet/minecraft/world/World;Lnet/minecraft/entity/Entity;Lnet/minecraft/entity/damage/DamageSource;Lnet/minecraft/world/explosion/ExplosionBehavior;DDDFZLnet/minecraft/world/explosion/Explosion$DestructionType;)V",
|
||||
@@ -51,13 +54,17 @@ public abstract class Explosion_scarpetEventMixin
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "collectBlocksAndDamageEntities", locals= LocalCapture.CAPTURE_FAILHARD, at=@At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;damage(Lnet/minecraft/entity/damage/DamageSource;F)Z"))
|
||||
private void onExplosion(CallbackInfo ci, Set<BlockPos> s1, float f1, int i1, int i2, int i3, int i4, int i5, int i6, List<Entity> l1, Vec3d v1, int i7, Entity entity)
|
||||
@Redirect(method = "collectBlocksAndDamageEntities", at=@At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/explosion/Explosion;getExposure(Lnet/minecraft/util/math/Vec3d;Lnet/minecraft/entity/Entity;)F")
|
||||
)
|
||||
private float onExplosion(Vec3d source, Entity entity)
|
||||
{
|
||||
if (affectedEntities != null)
|
||||
{
|
||||
affectedEntities.add(entity);
|
||||
}
|
||||
return getExposure(source, entity);
|
||||
}
|
||||
|
||||
@Inject(method = "affectWorld", at = @At("HEAD"))
|
||||
|
||||
@@ -33,9 +33,9 @@ public abstract class FallingBlockEntityMixin extends Entity
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove()
|
||||
public void remove(Entity.RemovalReason arg) // reason
|
||||
{
|
||||
super.remove();
|
||||
super.remove(arg);
|
||||
if (LoggerRegistry.__fallingBlocks && logHelper != null)
|
||||
logHelper.onFinish();
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.entity.SpawnGroup;
|
||||
import net.minecraft.util.collection.Pool;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.SpawnSettings;
|
||||
@@ -25,7 +26,7 @@ public abstract class FlatChunkGeneratorMixin extends ChunkGenerator
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SpawnSettings.SpawnEntry> getEntitySpawnList(Biome biome, StructureAccessor accessor, SpawnGroup group, BlockPos pos)
|
||||
public Pool<SpawnSettings.SpawnEntry> getEntitySpawnList(Biome biome, StructureAccessor accessor, SpawnGroup group, BlockPos pos)
|
||||
{
|
||||
if (CarpetSettings.flatWorldStructureSpawning)
|
||||
{
|
||||
|
||||
@@ -33,7 +33,7 @@ public abstract class FluidBlock_renewableBlackstoneMixin
|
||||
for(Direction direction : Direction.values())
|
||||
{
|
||||
if (direction != Direction.DOWN) {
|
||||
BlockPos blockPos = pos.offset(direction);
|
||||
BlockPos blockPos = pos.offset(direction); // offset
|
||||
if (world.getBlockState(blockPos).isOf(Blocks.BLUE_ICE)) {
|
||||
world.setBlockState(pos, Blocks.BLACKSTONE.getDefaultState());
|
||||
playExtinguishSound(world, pos);
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.FluidBlock;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(FluidBlock.class)
|
||||
public abstract class FluidBlock_renewableDeepslateMixin {
|
||||
|
||||
@Shadow protected abstract void playExtinguishSound(WorldAccess world, BlockPos pos);
|
||||
|
||||
@Inject(method = "receiveNeighborFluids", at = @At(value = "INVOKE",target = "Lnet/minecraft/fluid/FluidState;isStill()Z"), cancellable = true)
|
||||
private void receiveFluidToDeepslate(World world, BlockPos pos, BlockState state, CallbackInfoReturnable<Boolean> cir)
|
||||
{
|
||||
if(CarpetSettings.renewableDeepslate && !world.getFluidState(pos).isStill() && world.getRegistryKey() == World.OVERWORLD && pos.getY() < 16)
|
||||
{
|
||||
world.setBlockState(pos, Blocks.COBBLED_DEEPSLATE.getDefaultState());
|
||||
this.playExtinguishSound(world, pos);
|
||||
cir.setReturnValue(false);
|
||||
cir.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import net.minecraft.entity.SpawnReason;
|
||||
import net.minecraft.entity.mob.ElderGuardianEntity;
|
||||
import net.minecraft.entity.mob.GuardianEntity;
|
||||
import net.minecraft.entity.mob.HostileEntity;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -23,12 +23,12 @@ public abstract class GuardianEntityMixin extends HostileEntity
|
||||
|
||||
@Override
|
||||
public void onStruckByLightning(ServerWorld serverWorld, LightningEntity lightningEntity)
|
||||
{
|
||||
if (!this.world.isClient && !this.removed && CarpetSettings.renewableSponges && !((Object)this instanceof ElderGuardianEntity))
|
||||
{ // isRemoved()
|
||||
if (!this.world.isClient && !this.isRemoved() && CarpetSettings.renewableSponges && !((Object)this instanceof ElderGuardianEntity))
|
||||
{
|
||||
ElderGuardianEntity elderGuardian = new ElderGuardianEntity(EntityType.ELDER_GUARDIAN ,this.world);
|
||||
elderGuardian.refreshPositionAndAngles(this.getX(), this.getY(), this.getZ(), this.yaw, this.pitch);
|
||||
elderGuardian.initialize(serverWorld ,this.world.getLocalDifficulty(elderGuardian.getBlockPos()), SpawnReason.CONVERSION, (EntityData)null, (CompoundTag)null);
|
||||
elderGuardian.refreshPositionAndAngles(this.getX(), this.getY(), this.getZ(), this.getYaw(), this.getPitch());
|
||||
elderGuardian.initialize(serverWorld ,this.world.getLocalDifficulty(elderGuardian.getBlockPos()), SpawnReason.CONVERSION, (EntityData)null, (NbtCompound)null);
|
||||
elderGuardian.setAiDisabled(this.isAiDisabled());
|
||||
|
||||
if (this.hasCustomName())
|
||||
@@ -38,7 +38,7 @@ public abstract class GuardianEntityMixin extends HostileEntity
|
||||
}
|
||||
|
||||
this.world.spawnEntity(elderGuardian);
|
||||
this.remove();
|
||||
this.discard(); // discard remove();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.HopperBlock;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.block.entity.HopperBlockEntity;
|
||||
import net.minecraft.block.entity.LootableContainerBlockEntity;
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.DyeColor;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -20,21 +23,12 @@ import carpet.utils.WoolTool;
|
||||
* The {@link Mixin} which removes items in a hopper if it points into a wool counter, and calls {@link HopperCounter#add}
|
||||
*/
|
||||
@Mixin(HopperBlockEntity.class)
|
||||
public abstract class HopperBlockEntityMixin extends LootableContainerBlockEntity {
|
||||
|
||||
protected HopperBlockEntityMixin(BlockEntityType<?> blockEntityType_1) {
|
||||
super(blockEntityType_1);
|
||||
public abstract class HopperBlockEntityMixin extends LootableContainerBlockEntity
|
||||
{
|
||||
protected HopperBlockEntityMixin(BlockEntityType<?> blockEntityType, BlockPos blockPos, BlockState blockState) {
|
||||
super(blockEntityType, blockPos, blockState);
|
||||
}
|
||||
|
||||
@Shadow
|
||||
public abstract double getHopperX();
|
||||
|
||||
@Shadow
|
||||
public abstract double getHopperY();
|
||||
|
||||
@Shadow
|
||||
public abstract double getHopperZ();
|
||||
|
||||
@Shadow public abstract int size();
|
||||
|
||||
@Shadow public abstract void setStack(int slot, ItemStack stack);
|
||||
@@ -43,21 +37,21 @@ public abstract class HopperBlockEntityMixin extends LootableContainerBlockEntit
|
||||
* A method to remove items from hoppers pointing into wool and count them via {@link HopperCounter#add} method
|
||||
*/
|
||||
@Inject(method = "insert", at = @At("HEAD"), cancellable = true)
|
||||
private void onInsert(CallbackInfoReturnable<Boolean> cir)
|
||||
private static void onInsert(World world, BlockPos blockPos, BlockState blockState, Inventory inventory, CallbackInfoReturnable<Boolean> cir)
|
||||
{
|
||||
if (CarpetSettings.hopperCounters) {
|
||||
DyeColor wool_color = WoolTool.getWoolColorAtPosition(
|
||||
getWorld(),
|
||||
new BlockPos(getHopperX(), getHopperY(), getHopperZ()).offset(this.getCachedState().get(HopperBlock.FACING)));
|
||||
world,
|
||||
blockPos.offset(blockState.get(HopperBlock.FACING))); // offset
|
||||
if (wool_color != null)
|
||||
{
|
||||
for (int i = 0; i < size(); ++i)
|
||||
for (int i = 0; i < inventory.size(); ++i)
|
||||
{
|
||||
if (!this.getStack(i).isEmpty())
|
||||
if (!inventory.getStack(i).isEmpty())
|
||||
{
|
||||
ItemStack itemstack = this.getStack(i);//.copy();
|
||||
HopperCounter.COUNTERS.get(wool_color).add(this.getWorld().getServer(), itemstack);
|
||||
this.setStack(i, ItemStack.EMPTY);
|
||||
ItemStack itemstack = inventory.getStack(i);//.copy();
|
||||
HopperCounter.COUNTERS.get(wool_color).add(world.getServer(), itemstack);
|
||||
inventory.setStack(i, ItemStack.EMPTY);
|
||||
}
|
||||
}
|
||||
cir.setReturnValue(true);
|
||||
|
||||
@@ -24,7 +24,7 @@ public abstract class ItemEntityMixin extends Entity implements ItemEntityInterf
|
||||
{
|
||||
private static final int SHULKERBOX_MAX_STACK_AMOUNT = 64;
|
||||
|
||||
@Shadow private int age;
|
||||
@Shadow private int itemAge;
|
||||
@Shadow private int pickupDelay;
|
||||
|
||||
public ItemEntityMixin(EntityType<?> entityType_1, World world_1) {
|
||||
@@ -34,7 +34,7 @@ public abstract class ItemEntityMixin extends Entity implements ItemEntityInterf
|
||||
@Override
|
||||
public void onStruckByLightning(ServerWorld world, LightningEntity lightning) {
|
||||
if (CarpetSettings.lightningKillsDropsFix) {
|
||||
if (this.age > 8) { //Only kill item if its older then 8 ticks
|
||||
if (this.itemAge > 8) { //Only kill item if its older then 8 ticks
|
||||
super.onStruckByLightning(world, lightning);
|
||||
}
|
||||
} else {
|
||||
@@ -44,7 +44,7 @@ public abstract class ItemEntityMixin extends Entity implements ItemEntityInterf
|
||||
|
||||
@Override
|
||||
public int getAgeCM() {
|
||||
return this.age;
|
||||
return this.itemAge;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -105,12 +105,12 @@ public abstract class ItemEntityMixin extends Entity implements ItemEntityInterf
|
||||
self.setStack(selfStack);
|
||||
|
||||
this.pickupDelay = Math.max(((ItemEntityInterface)other).getPickupDelayCM(), this.pickupDelay);
|
||||
this.age = Math.min(((ItemEntityInterface)other).getAgeCM(), this.age);
|
||||
this.itemAge = Math.min(((ItemEntityInterface)other).getAgeCM(), this.itemAge);
|
||||
|
||||
otherStack.decrement(amount);
|
||||
if (otherStack.isEmpty())
|
||||
{
|
||||
other.remove();
|
||||
other.discard(); // discard remove();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.fluid.FluidState;
|
||||
import net.minecraft.fluid.LavaFluid;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(LavaFluid.class)
|
||||
public abstract class LavaFluid_renewableDeepslateMixin {
|
||||
@Shadow protected abstract void playExtinguishEvent(WorldAccess world, BlockPos pos);
|
||||
|
||||
@Inject(method = "flow", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/Block;getDefaultState()Lnet/minecraft/block/BlockState;"), cancellable = true)
|
||||
private void generateDeepslate(WorldAccess world, BlockPos pos, BlockState state, Direction direction, FluidState fluidState, CallbackInfo ci)
|
||||
{
|
||||
if(CarpetSettings.renewableDeepslate && ((World)world).getRegistryKey() == World.OVERWORLD && pos.getY() < 16)
|
||||
{
|
||||
world.setBlockState(pos, Blocks.DEEPSLATE.getDefaultState(), 3);
|
||||
this.playExtinguishEvent(world, pos);
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,7 @@ public abstract class LivingEntity_creativeFlyMixin extends Entity
|
||||
if (CarpetSettings.creativeFlyDrag != 0.09 && (Object)this instanceof PlayerEntity)
|
||||
{
|
||||
PlayerEntity self = (PlayerEntity)(Object)(this);
|
||||
if (self.abilities.flying && ! onGround )
|
||||
if (self.getAbilities().flying && ! onGround )
|
||||
return (float)(1.0-CarpetSettings.creativeFlyDrag);
|
||||
}
|
||||
return original;
|
||||
@@ -43,7 +43,7 @@ public abstract class LivingEntity_creativeFlyMixin extends Entity
|
||||
if (CarpetSettings.creativeFlySpeed != 1.0D && (Object)this instanceof PlayerEntity)
|
||||
{
|
||||
PlayerEntity self = (PlayerEntity)(Object)(this);
|
||||
if (self.abilities.flying && !onGround)
|
||||
if (self.getAbilities().flying && !onGround)
|
||||
cir.setReturnValue(flyingSpeed* (float)CarpetSettings.creativeFlySpeed);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.helpers.TickSpeed;
|
||||
import carpet.patches.CopyProfilerResult;
|
||||
import carpet.utils.CarpetProfiler;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.ServerTask;
|
||||
import net.minecraft.util.TickDurationMonitor;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraft.util.profiler.EmptyProfileResult;
|
||||
import net.minecraft.util.profiler.ProfileResult;
|
||||
import net.minecraft.util.profiler.Profiler;
|
||||
import net.minecraft.util.thread.ReentrantThreadExecutor;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -17,6 +20,7 @@ import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.function.BooleanSupplier;
|
||||
|
||||
@@ -40,20 +44,25 @@ public abstract class MinecraftServer_tickspeedMixin extends ReentrantThreadExec
|
||||
|
||||
@Shadow protected abstract boolean shouldKeepTicking();
|
||||
|
||||
@Shadow private long field_19248;
|
||||
|
||||
@Shadow protected abstract void method_16208();
|
||||
@Shadow private long nextTickTimestamp;
|
||||
|
||||
@Shadow private volatile boolean loading;
|
||||
|
||||
@Shadow protected abstract void startMonitor(TickDurationMonitor monitor);
|
||||
|
||||
@Shadow private long lastTimeReference;
|
||||
|
||||
@Shadow private boolean waitingForNextTick;
|
||||
|
||||
@Shadow public abstract Iterable<ServerWorld> getWorlds();
|
||||
|
||||
@Shadow private int ticks;
|
||||
|
||||
@Shadow protected abstract void runTasksTillTickEnd();
|
||||
|
||||
@Shadow protected abstract void startTickMetrics();
|
||||
|
||||
@Shadow protected abstract void endTickMetrics();
|
||||
|
||||
@Shadow private boolean needsDebugSetup;
|
||||
CarpetProfiler.ProfilerToken currentSection;
|
||||
|
||||
private float carpetMsptAccum = 0.0f;
|
||||
@@ -115,10 +124,15 @@ public abstract class MinecraftServer_tickspeedMixin extends ReentrantThreadExec
|
||||
this.lastTimeReference = this.timeReference;
|
||||
}
|
||||
|
||||
if (this.needsDebugSetup) {
|
||||
this.needsDebugSetup = false;
|
||||
this.profilerTimings = Pair.of(Util.getMeasuringTimeNano(), ticks);
|
||||
//this.field_33978 = new MinecraftServer.class_6414(Util.getMeasuringTimeNano(), this.ticks);
|
||||
}
|
||||
this.timeReference += msThisTick;//50L;
|
||||
TickDurationMonitor tickDurationMonitor = TickDurationMonitor.create("Server");
|
||||
this.startMonitor(tickDurationMonitor);
|
||||
this.profiler.startTick();
|
||||
//TickDurationMonitor tickDurationMonitor = TickDurationMonitor.create("Server");
|
||||
//this.startMonitor(tickDurationMonitor);
|
||||
this.startTickMetrics();
|
||||
this.profiler.push("tick");
|
||||
this.tick(TickSpeed.time_warp_start_time != 0 ? ()->true : this::shouldKeepTicking);
|
||||
this.profiler.swap("nextTickWait");
|
||||
@@ -127,16 +141,39 @@ public abstract class MinecraftServer_tickspeedMixin extends ReentrantThreadExec
|
||||
while(this.runEveryTask()) {Thread.yield();}
|
||||
}
|
||||
this.waitingForNextTick = true;
|
||||
this.field_19248 = Math.max(Util.getMeasuringTimeMs() + /*50L*/ msThisTick, this.timeReference);
|
||||
this.nextTickTimestamp = Math.max(Util.getMeasuringTimeMs() + /*50L*/ msThisTick, this.timeReference);
|
||||
// run all tasks (this will not do a lot when warping), but that's fine since we already run them
|
||||
this.method_16208();
|
||||
this.runTasksTillTickEnd();
|
||||
this.profiler.pop();
|
||||
this.profiler.endTick();
|
||||
this.endTickMetrics();
|
||||
this.loading = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// just because profilerTimings class is public
|
||||
Pair<Long,Integer> profilerTimings = null;
|
||||
/// overworld around profiler timings
|
||||
@Inject(method = "isDebugRunning", at = @At("HEAD"), cancellable = true)
|
||||
public void isCMDebugRunning(CallbackInfoReturnable<Boolean> cir)
|
||||
{
|
||||
cir.setReturnValue(needsDebugSetup || profilerTimings != null);
|
||||
}
|
||||
@Inject(method = "stopDebug", at = @At("HEAD"), cancellable = true)
|
||||
public void stopCMDebug(CallbackInfoReturnable<ProfileResult> cir)
|
||||
{
|
||||
if (this.profilerTimings == null) {
|
||||
cir.setReturnValue(EmptyProfileResult.INSTANCE);
|
||||
} else {
|
||||
ProfileResult profileResult = new CopyProfilerResult(
|
||||
profilerTimings.getRight(), profilerTimings.getLeft(),
|
||||
this.ticks, Util.getMeasuringTimeNano()
|
||||
);
|
||||
this.profilerTimings = null;
|
||||
cir.setReturnValue(profileResult);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean runEveryTask() {
|
||||
if (super.runTask()) {
|
||||
@@ -194,12 +231,12 @@ public abstract class MinecraftServer_tickspeedMixin extends ReentrantThreadExec
|
||||
CarpetProfiler.end_current_section(currentSection);
|
||||
}
|
||||
|
||||
@Inject(method = "method_16208", at = @At("HEAD"))
|
||||
@Inject(method = "runTasksTillTickEnd", at = @At("HEAD"))
|
||||
private void startAsync(CallbackInfo ci)
|
||||
{
|
||||
currentSection = CarpetProfiler.start_section(null, "Async Tasks", CarpetProfiler.TYPE.GENERAL);
|
||||
}
|
||||
@Inject(method = "method_16208", at = @At(
|
||||
@Inject(method = "runTasksTillTickEnd", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/MinecraftServer;runTasks(Ljava/util/function/BooleanSupplier;)V",
|
||||
shift = At.Shift.BEFORE
|
||||
|
||||
@@ -2,6 +2,7 @@ package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.entity.SpawnGroup;
|
||||
import net.minecraft.util.collection.Pool;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.SpawnSettings;
|
||||
@@ -29,7 +30,7 @@ public abstract class NoiseChunkGenerator_husksSpawnMixin extends ChunkGenerator
|
||||
}
|
||||
|
||||
@Inject(method = "getEntitySpawnList", at = @At("HEAD"), cancellable = true)
|
||||
private void isInsidePyramid(Biome biome, StructureAccessor accessor, SpawnGroup group, BlockPos pos, CallbackInfoReturnable<List<SpawnSettings.SpawnEntry>> cir)
|
||||
private void isInsidePyramid(Biome biome, StructureAccessor accessor, SpawnGroup group, BlockPos pos, CallbackInfoReturnable<Pool<SpawnSettings.SpawnEntry>> cir)
|
||||
{
|
||||
if (CarpetSettings.huskSpawningInTemples && group == SpawnGroup.MONSTER)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.server.dedicated.command.PerfCommand;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(PerfCommand.class)
|
||||
public class PerfCommand_permissionMixin
|
||||
{
|
||||
@SuppressWarnings("UnresolvedMixinReference")
|
||||
@Inject(method = "method_37340(Lnet/minecraft/server/command/ServerCommandSource;)Z", at = @At("HEAD"), cancellable = true)
|
||||
private static void canRun(ServerCommandSource source, CallbackInfoReturnable<Boolean> cir)
|
||||
{
|
||||
cir.setReturnValue(source.hasPermissionLevel(CarpetSettings.perfPermissionLevel));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,25 +1,31 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.MiningToolItem;
|
||||
import net.minecraft.item.PickaxeItem;
|
||||
import net.minecraft.item.ToolMaterial;
|
||||
import net.minecraft.tag.Tag;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
//import org.spongepowered.asm.mixin.injection.At;
|
||||
//import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(PickaxeItem.class)
|
||||
public class PickaxeItem_missingToolsMixin
|
||||
public class PickaxeItem_missingToolsMixin extends MiningToolItem
|
||||
{
|
||||
@Redirect(method = "getMiningSpeedMultiplier", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/block/BlockState;getMaterial()Lnet/minecraft/block/Material;"
|
||||
))
|
||||
private Material getCustomMaterial(BlockState blockState)
|
||||
{
|
||||
Material material = blockState.getMaterial();
|
||||
|
||||
protected PickaxeItem_missingToolsMixin(float attackDamage, float attackSpeed, ToolMaterial material, Tag<Block> tag, Settings settings) {
|
||||
super(attackDamage, attackSpeed, material, tag, settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) {
|
||||
Material material = state.getMaterial();
|
||||
if (CarpetSettings.missingTools && material == Material.GLASS)
|
||||
material = Material.STONE;
|
||||
return material;
|
||||
return miningSpeed;
|
||||
return super.getMiningSpeedMultiplier(stack, state);
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.fakes.InventoryBearerInterface;
|
||||
import net.minecraft.entity.mob.PillagerEntity;
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.inventory.SimpleInventory;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(PillagerEntity.class)
|
||||
public class PillagerEntity_scarpetMixin implements InventoryBearerInterface
|
||||
{
|
||||
@Shadow @Final private SimpleInventory inventory;
|
||||
|
||||
@Override
|
||||
public Inventory getCMInventory()
|
||||
{
|
||||
return inventory;
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import net.minecraft.block.entity.PistonBlockEntity;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
|
||||
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
|
||||
import net.minecraft.client.render.block.entity.BlockEntityRendererFactory;
|
||||
import net.minecraft.client.render.block.entity.PistonBlockEntityRenderer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -16,15 +17,17 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
@Mixin(PistonBlockEntityRenderer.class)
|
||||
public abstract class PistonBlockEntityRenderer_movableTEMixin extends BlockEntityRenderer<PistonBlockEntity>
|
||||
public abstract class PistonBlockEntityRenderer_movableTEMixin implements BlockEntityRenderer<PistonBlockEntity>
|
||||
{
|
||||
public PistonBlockEntityRenderer_movableTEMixin(BlockEntityRenderDispatcher blockEntityRenderDispatcher_1)
|
||||
BlockEntityRenderDispatcher dispatcher;
|
||||
@Inject(method = "<init>", at = @At("TAIL"))
|
||||
private void onInitCM(BlockEntityRendererFactory.Context arguments, CallbackInfo ci)
|
||||
{
|
||||
super(blockEntityRenderDispatcher_1);
|
||||
dispatcher = arguments.getRenderDispatcher();
|
||||
}
|
||||
|
||||
@Inject(method = "render", at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/client/render/block/entity/PistonBlockEntityRenderer;method_3575(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/world/World;ZI)V", ordinal = 3))
|
||||
target = "Lnet/minecraft/client/render/block/entity/PistonBlockEntityRenderer;renderModel(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/world/World;ZI)V", ordinal = 3))
|
||||
private void updateRenderBool(PistonBlockEntity pistonBlockEntity_1, float float_1, MatrixStack matrixStack_1, VertexConsumerProvider 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)
|
||||
{
|
||||
@@ -41,14 +44,14 @@ public abstract class PistonBlockEntityRenderer_movableTEMixin extends BlockEnti
|
||||
BlockEntity carriedBlockEntity = ((PistonBlockEntityInterface) pistonBlockEntity_1).getCarriedBlockEntity();
|
||||
if (carriedBlockEntity != null)
|
||||
{
|
||||
carriedBlockEntity.setPos(pistonBlockEntity_1.getPos());
|
||||
// maybe ??? carriedBlockEntity.setPos(pistonBlockEntity_1.getPos());
|
||||
//((BlockEntityRenderDispatcherInterface) BlockEntityRenderDispatcher.INSTANCE).renderBlockEntityOffset(carriedBlockEntity, float_1, int_1, BlockRenderLayer.field_20799, bufferBuilder_1, pistonBlockEntity_1.getRenderOffsetX(float_1), pistonBlockEntity_1.getRenderOffsetY(float_1), pistonBlockEntity_1.getRenderOffsetZ(float_1));
|
||||
matrixStack_1.translate(
|
||||
pistonBlockEntity_1.getRenderOffsetX(partialTicks),
|
||||
pistonBlockEntity_1.getRenderOffsetY(partialTicks),
|
||||
pistonBlockEntity_1.getRenderOffsetZ(partialTicks)
|
||||
);
|
||||
BlockEntityRenderDispatcher.INSTANCE.render(carriedBlockEntity, partialTicks, matrixStack_1, layeredVertexConsumerStorage_1);
|
||||
dispatcher.render(carriedBlockEntity, partialTicks, matrixStack_1, layeredVertexConsumerStorage_1);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.fakes.BlockEntityInterface;
|
||||
import carpet.fakes.PistonBlockEntityInterface;
|
||||
import carpet.fakes.WorldInterface;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -10,7 +11,7 @@ import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.block.entity.PistonBlockEntity;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -32,13 +33,12 @@ public abstract class PistonBlockEntity_movableTEMixin extends BlockEntity imple
|
||||
private BlockEntity carriedBlockEntity;
|
||||
private boolean renderCarriedBlockEntity = false;
|
||||
private boolean renderSet = false;
|
||||
|
||||
public PistonBlockEntity_movableTEMixin(BlockEntityType<?> blockEntityType_1)
|
||||
{
|
||||
super(blockEntityType_1);
|
||||
|
||||
public PistonBlockEntity_movableTEMixin(BlockEntityType<?> blockEntityType, BlockPos blockPos, BlockState blockState) {
|
||||
super(blockEntityType, blockPos, blockState);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author 2No2Name
|
||||
*/
|
||||
@@ -46,12 +46,23 @@ public abstract class PistonBlockEntity_movableTEMixin extends BlockEntity imple
|
||||
{
|
||||
return carriedBlockEntity;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setWorld(World world) {
|
||||
super.setWorld(world);
|
||||
if (carriedBlockEntity != null) carriedBlockEntity.setWorld(world);
|
||||
}
|
||||
|
||||
public void setCarriedBlockEntity(BlockEntity blockEntity)
|
||||
{
|
||||
this.carriedBlockEntity = blockEntity;
|
||||
if (this.carriedBlockEntity != null)
|
||||
this.carriedBlockEntity.setPos(this.pos);
|
||||
{
|
||||
((BlockEntityInterface)carriedBlockEntity).setCMPos(pos);
|
||||
// this might be little dangerous since pos is final for a hashing reason?
|
||||
if (world != null) carriedBlockEntity.setWorld(world);
|
||||
}
|
||||
// this.carriedBlockEntity.setPos(this.pos);
|
||||
}
|
||||
|
||||
public boolean isRenderModeSet()
|
||||
@@ -75,12 +86,14 @@ public abstract class PistonBlockEntity_movableTEMixin extends BlockEntity imple
|
||||
*/
|
||||
@Redirect(method = "tick", at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
|
||||
private boolean movableTEsetBlockState0(World world, BlockPos blockPos_1, BlockState blockAState_2, int int_1)
|
||||
private static boolean movableTEsetBlockState0(
|
||||
World world, BlockPos blockPos_1, BlockState blockAState_2, int int_1,
|
||||
World world2, BlockPos blockPos, BlockState blockState, PistonBlockEntity pistonBlockEntity)
|
||||
{
|
||||
if (!CarpetSettings.movableBlockEntities)
|
||||
return world.setBlockState(blockPos_1, blockAState_2, int_1);
|
||||
else
|
||||
return ((WorldInterface) (world)).setBlockStateWithBlockEntity(blockPos_1, blockAState_2, this.carriedBlockEntity, int_1);
|
||||
return ((WorldInterface) (world)).setBlockStateWithBlockEntity(blockPos_1, blockAState_2, ((PistonBlockEntityInterface)pistonBlockEntity).getCarriedBlockEntity(), int_1);
|
||||
}
|
||||
|
||||
@Redirect(method = "finish", at = @At(value = "INVOKE",
|
||||
@@ -115,25 +128,26 @@ public abstract class PistonBlockEntity_movableTEMixin extends BlockEntity imple
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "fromTag", at = @At(value = "TAIL"))
|
||||
private void onFromTag(BlockState state, CompoundTag compoundTag_1, CallbackInfo ci)
|
||||
@Inject(method = "readNbt", at = @At(value = "TAIL"))
|
||||
private void onFromTag(NbtCompound NbtCompound_1, CallbackInfo ci)
|
||||
{
|
||||
if (CarpetSettings.movableBlockEntities && compoundTag_1.contains("carriedTileEntityCM", 10))
|
||||
if (CarpetSettings.movableBlockEntities && NbtCompound_1.contains("carriedTileEntityCM", 10))
|
||||
{
|
||||
if (this.pushedBlock.getBlock() instanceof BlockEntityProvider)
|
||||
this.carriedBlockEntity = ((BlockEntityProvider) (this.pushedBlock.getBlock())).createBlockEntity(this.world);
|
||||
this.carriedBlockEntity = ((BlockEntityProvider) (this.pushedBlock.getBlock())).createBlockEntity(pos, pushedBlock);// this.world);
|
||||
if (carriedBlockEntity != null) //Can actually be null, as BlockPistonMoving.createNewTileEntity(...) returns null
|
||||
this.carriedBlockEntity.fromTag(state, compoundTag_1.getCompound("carriedTileEntityCM"));
|
||||
this.carriedBlockEntity.readNbt(NbtCompound_1.getCompound("carriedTileEntityCM"));
|
||||
setCarriedBlockEntity(carriedBlockEntity);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "toTag", at = @At(value = "RETURN", shift = At.Shift.BEFORE))
|
||||
private void onToTag(CompoundTag compoundTag_1, CallbackInfoReturnable<CompoundTag> cir)
|
||||
@Inject(method = "writeNbt", at = @At(value = "RETURN", shift = At.Shift.BEFORE))
|
||||
private void onToTag(NbtCompound NbtCompound_1, CallbackInfoReturnable<NbtCompound> cir)
|
||||
{
|
||||
if (CarpetSettings.movableBlockEntities && this.carriedBlockEntity != null)
|
||||
{
|
||||
//Leave name "carriedTileEntityCM" instead of "carriedBlockEntityCM" for upgrade compatibility with 1.13.2 movable TE
|
||||
compoundTag_1.put("carriedTileEntityCM", this.carriedBlockEntity.toTag(new CompoundTag()));
|
||||
NbtCompound_1.put("carriedTileEntityCM", this.carriedBlockEntity.writeNbt(new NbtCompound()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,8 +8,10 @@ import net.minecraft.block.entity.PistonBlockEntity;
|
||||
import net.minecraft.block.piston.PistonBehavior;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -24,16 +26,16 @@ public abstract class PistonBlockEntity_playerHandlingMixin
|
||||
|
||||
@Shadow public abstract Direction getMovementDirection();
|
||||
|
||||
@Inject(method = "method_23672", at = @At("HEAD"), cancellable = true)
|
||||
@Inject(method = "moveEntity", at = @At("HEAD"), cancellable = true)
|
||||
private static void dontPushSpectators(Direction direction, Entity entity, double d, Direction direction2, CallbackInfo ci)
|
||||
{
|
||||
if (CarpetSettings.creativeNoClip && entity instanceof PlayerEntity && (((PlayerEntity) entity).isCreative()) && ((PlayerEntity) entity).abilities.flying) ci.cancel();
|
||||
if (CarpetSettings.creativeNoClip && entity instanceof PlayerEntity && (((PlayerEntity) entity).isCreative()) && ((PlayerEntity) entity).getAbilities().flying) ci.cancel();
|
||||
}
|
||||
|
||||
@Redirect(method = "pushEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;setVelocity(DDD)V"))
|
||||
private void ignoreAccel(Entity entity, double x, double y, double z)
|
||||
private static void ignoreAccel(Entity entity, double x, double y, double z)
|
||||
{
|
||||
if (CarpetSettings.creativeNoClip && entity instanceof PlayerEntity && (((PlayerEntity) entity).isCreative()) && ((PlayerEntity) entity).abilities.flying) return;
|
||||
if (CarpetSettings.creativeNoClip && entity instanceof PlayerEntity && (((PlayerEntity) entity).isCreative()) && ((PlayerEntity) entity).getAbilities().flying) return;
|
||||
entity.setVelocity(x,y,z);
|
||||
}
|
||||
|
||||
@@ -41,15 +43,16 @@ public abstract class PistonBlockEntity_playerHandlingMixin
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/entity/Entity;getPistonBehavior()Lnet/minecraft/block/piston/PistonBehavior;"
|
||||
))
|
||||
private PistonBehavior moveFakePlayers(Entity entity)
|
||||
private static PistonBehavior moveFakePlayers(Entity entity,
|
||||
World world, BlockPos blockPos, float ff, PistonBlockEntity pistonBlockEntity)
|
||||
{
|
||||
if (entity instanceof EntityPlayerMPFake && pushedBlock.isOf(Blocks.SLIME_BLOCK))
|
||||
if (entity instanceof EntityPlayerMPFake && pistonBlockEntity.getPushedBlock().isOf(Blocks.SLIME_BLOCK))
|
||||
{
|
||||
Vec3d vec3d = entity.getVelocity();
|
||||
double e = vec3d.x;
|
||||
double f = vec3d.y;
|
||||
double g = vec3d.z;
|
||||
Direction direction = getMovementDirection();
|
||||
Direction direction = pistonBlockEntity.getMovementDirection();
|
||||
switch(direction.getAxis()) {
|
||||
case X:
|
||||
e = (double)direction.getOffsetX();
|
||||
|
||||
@@ -50,16 +50,16 @@ public abstract class PistonBlock_movableTEMixin extends FacingBlock
|
||||
block != Blocks.SPAWNER;
|
||||
}
|
||||
|
||||
@Redirect(method = "isMovable", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/Block;hasBlockEntity()Z")) // hasBLockENtity
|
||||
private static boolean ifHasBlockEntity(Block block)
|
||||
@Redirect(method = "isMovable", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;hasBlockEntity()Z"))
|
||||
private static boolean ifHasBlockEntity(BlockState blockState)
|
||||
{
|
||||
if (!block.hasBlockEntity())
|
||||
if (!blockState.hasBlockEntity())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return !(CarpetSettings.movableBlockEntities && isPushableBlockEntity(block));
|
||||
return !(CarpetSettings.movableBlockEntities && isPushableBlockEntity(blockState.getBlock()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ public abstract class PistonBlock_movableTEMixin extends FacingBlock
|
||||
for (int i = 0; i < list_1.size(); ++i)
|
||||
{
|
||||
BlockPos blockpos = list_1.get(i);
|
||||
BlockEntity blockEntity = (list_2.get(i).getBlock().hasBlockEntity()) ? world_1.getBlockEntity(blockpos) : null;
|
||||
BlockEntity blockEntity = (list_2.get(i).hasBlockEntity()) ? world_1.getBlockEntity(blockpos) : null;
|
||||
list1_BlockEntities.get().add(blockEntity);
|
||||
if (blockEntity != null)
|
||||
{
|
||||
@@ -101,34 +101,32 @@ public abstract class PistonBlock_movableTEMixin extends FacingBlock
|
||||
}
|
||||
|
||||
@Inject(method = "move", at = @At(value = "INVOKE", shift = At.Shift.BEFORE,
|
||||
target = "Lnet/minecraft/world/World;setBlockEntity(Lnet/minecraft/util/math/BlockPos;" +
|
||||
"Lnet/minecraft/block/entity/BlockEntity;)V", ordinal = 0),
|
||||
target = "Lnet/minecraft/world/World;addBlockEntity(Lnet/minecraft/block/entity/BlockEntity;)V", ordinal = 0),
|
||||
locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
private void setBlockEntityWithCarried(World world_1, BlockPos blockPos_1, Direction direction_1, boolean boolean_1,
|
||||
CallbackInfoReturnable<Boolean> cir, BlockPos blockPos_2, PistonHandler pistonHandler_1, Map map_1, List list_1,
|
||||
List list_2, List list_3, BlockState[] blockStates_1, Direction direction_2, int int_2,
|
||||
int int_3, BlockPos blockPos_4, BlockState blockState_1)
|
||||
int int_3, BlockPos blockPos_4, BlockState blockState9, BlockState blockState4)
|
||||
{
|
||||
BlockEntity blockEntityPiston = PistonExtensionBlock.createBlockEntityPiston((BlockState) list_2.get(int_3),
|
||||
BlockEntity blockEntityPiston = PistonExtensionBlock.createBlockEntityPiston(blockPos_4, blockState4, (BlockState) list_2.get(int_3),
|
||||
direction_1, boolean_1, false);
|
||||
if (CarpetSettings.movableBlockEntities)
|
||||
((PistonBlockEntityInterface) blockEntityPiston).setCarriedBlockEntity(list1_BlockEntities.get().get(int_3));
|
||||
world_1.setBlockEntity(blockPos_4, blockEntityPiston);
|
||||
world_1.addBlockEntity(blockEntityPiston);
|
||||
//world_1.setBlockEntity(blockPos_4, blockEntityPiston);
|
||||
}
|
||||
|
||||
@Redirect(method = "move", at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/World;setBlockEntity(Lnet/minecraft/util/math/BlockPos;" +
|
||||
"Lnet/minecraft/block/entity/BlockEntity;)V",
|
||||
target = "Lnet/minecraft/world/World;addBlockEntity(Lnet/minecraft/block/entity/BlockEntity;)V",
|
||||
ordinal = 0))
|
||||
private void dontDoAnything(World world, BlockPos blockPos_6, BlockEntity blockEntityPiston)
|
||||
private void dontDoAnything(World world, BlockEntity blockEntity)
|
||||
{
|
||||
}
|
||||
|
||||
@Redirect(method = "move", at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/block/PistonExtensionBlock;createBlockEntityPiston(Lnet/minecraft/block/BlockState;" +
|
||||
"Lnet/minecraft/util/math/Direction;ZZ)Lnet/minecraft/block/entity/BlockEntity;",
|
||||
target = "Lnet/minecraft/block/PistonExtensionBlock;createBlockEntityPiston(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;Lnet/minecraft/block/BlockState;Lnet/minecraft/util/math/Direction;ZZ)Lnet/minecraft/block/entity/BlockEntity;",
|
||||
ordinal = 0))
|
||||
private BlockEntity returnNull(BlockState blockState_1, Direction direction_1, boolean boolean_1, boolean boolean_2)
|
||||
private BlockEntity returnNull(BlockPos blockPos, BlockState blockState, BlockState blockState2, Direction direction, boolean bl, boolean bl2)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -39,21 +39,19 @@ public abstract class PistonHandler_customStickyMixin
|
||||
@Shadow @Final private World world;
|
||||
@Shadow @Final private Direction motionDirection;
|
||||
@Shadow protected abstract boolean tryMove(BlockPos blockPos_1, Direction direction_1);
|
||||
@Shadow private static boolean isBlockSticky(Block block_1) { return false; }
|
||||
@Shadow private static boolean isAdjacentBlockStuck(Block block, Block block2) {return false;}
|
||||
@Shadow protected abstract boolean canMoveAdjacentBlock(BlockPos pos);
|
||||
@Shadow private static boolean isBlockSticky(BlockState block_1) { return false; }
|
||||
@Shadow private static boolean isAdjacentBlockStuck(BlockState block, BlockState block2) {return false;}
|
||||
@Shadow protected abstract boolean tryMoveAdjacentBlock(BlockPos pos);
|
||||
|
||||
// collects information about sticking block when backtracking.
|
||||
private BlockPos currentPos;
|
||||
private BlockState currentState;
|
||||
private BlockState previousState;
|
||||
@Redirect(method = "tryMove", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getBlockState(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/block/BlockState;", ordinal = 0))
|
||||
private BlockState redirectGetBlockState_1_A(World world, BlockPos pos) {
|
||||
return currentState = previousState = world.getBlockState(pos);
|
||||
return currentState = world.getBlockState(pos);
|
||||
}
|
||||
@Redirect(method = "tryMove", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getBlockState(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/block/BlockState;", ordinal = 1))
|
||||
private BlockState redirectGetBlockState_1_B(World world, BlockPos pos) {
|
||||
previousState = currentState;
|
||||
currentPos = pos;
|
||||
return currentState = world.getBlockState(pos);
|
||||
}
|
||||
@@ -64,13 +62,13 @@ public abstract class PistonHandler_customStickyMixin
|
||||
*/
|
||||
@Redirect(method = "tryMove", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/block/piston/PistonHandler;isBlockSticky(Lnet/minecraft/block/Block;)Z",
|
||||
target = "Lnet/minecraft/block/piston/PistonHandler;isBlockSticky(Lnet/minecraft/block/BlockState;)Z",
|
||||
ordinal = 0 )
|
||||
)
|
||||
private boolean redirectIsStickyBlock(Block block_1)
|
||||
private boolean redirectIsStickyBlock(BlockState blockState)
|
||||
{
|
||||
// applies to both MBE chests as well as sticky chains
|
||||
return blockCanBePulled(currentState) || isBlockSticky(block_1);
|
||||
return blockCanBePulled(blockState) || isBlockSticky(blockState);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -107,17 +105,17 @@ public abstract class PistonHandler_customStickyMixin
|
||||
*/
|
||||
@Redirect(method = "tryMove", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/block/piston/PistonHandler;isAdjacentBlockStuck(Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;)Z")
|
||||
target = "Lnet/minecraft/block/piston/PistonHandler;isAdjacentBlockStuck(Lnet/minecraft/block/BlockState;Lnet/minecraft/block/BlockState;)Z")
|
||||
)
|
||||
private boolean isDraggingPreviousBlockBehind(Block previous, Block next)
|
||||
private boolean isDraggingPreviousBlockBehind(BlockState previous, BlockState next)
|
||||
{
|
||||
if (CarpetSettings.doChainStone)
|
||||
{
|
||||
if (previousState.getBlock() == Blocks.CHAIN && isChainOnAxis(previousState, motionDirection))
|
||||
if (previous.getBlock() == Blocks.CHAIN && isChainOnAxis(previous, motionDirection))
|
||||
{
|
||||
if ( (currentState.getBlock() == Blocks.CHAIN && isChainOnAxis(currentState, motionDirection))
|
||||
if ( (next.getBlock() == Blocks.CHAIN && isChainOnAxis(next, motionDirection))
|
||||
|| CarpetSettings.chainStoneStickToAll
|
||||
|| isEndRodOnAxis(currentState, motionDirection.getAxis())
|
||||
|| isEndRodOnAxis(next, motionDirection.getAxis())
|
||||
|| Block.sideCoversSmallSquare(world, currentPos, motionDirection))
|
||||
{
|
||||
return true;
|
||||
@@ -138,7 +136,7 @@ public abstract class PistonHandler_customStickyMixin
|
||||
target = "Ljava/util/List;get(I)Ljava/lang/Object;",
|
||||
shift = At.Shift.AFTER
|
||||
))
|
||||
private void stickToStickySide(BlockPos blockPos_1, Direction direction_1, CallbackInfoReturnable<Boolean> cir, BlockState blockState_1, Block block_1, int int_1, int int_2, int int_4, BlockPos blockPos_3, int int_5, int int_6)
|
||||
private void stickToStickySide(BlockPos blockPos_1, Direction direction_1, CallbackInfoReturnable<Boolean> cir, BlockState blockState_1, int int_1, int int_2, int int_4, BlockPos blockPos_3, int int_5, int int_6)
|
||||
{
|
||||
if (CarpetSettings.movableBlockEntities)
|
||||
{
|
||||
@@ -171,7 +169,7 @@ public abstract class PistonHandler_customStickyMixin
|
||||
BlockState chainState = world.getBlockState(pos);
|
||||
// chain is sideways
|
||||
if (chainState.getBlock() == Blocks.CHAIN && !isChainOnAxis(chainState, motionDirection)
|
||||
&& !this.canMoveAdjacentBlock(pos))
|
||||
&& !this.tryMoveAdjacentBlock(pos))
|
||||
{
|
||||
cir.setReturnValue(false);
|
||||
}
|
||||
@@ -198,7 +196,7 @@ public abstract class PistonHandler_customStickyMixin
|
||||
// stickyDirection = blockState_1.get(FacingBlock.FACING);
|
||||
//}
|
||||
|
||||
return stickyDirection == null || this.tryMove(blockPos_1.offset(stickyDirection), stickyDirection);
|
||||
return stickyDirection == null || this.tryMove(blockPos_1.offset(stickyDirection), stickyDirection); //offset
|
||||
}
|
||||
|
||||
|
||||
@@ -208,18 +206,18 @@ public abstract class PistonHandler_customStickyMixin
|
||||
*/
|
||||
@Inject(method = "tryMove", locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true, at= @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/block/piston/PistonHandler;isBlockSticky(Lnet/minecraft/block/Block;)Z",
|
||||
target = "Lnet/minecraft/block/piston/PistonHandler;isBlockSticky(Lnet/minecraft/block/BlockState;)Z",
|
||||
ordinal = 1,
|
||||
shift = At.Shift.BEFORE
|
||||
)
|
||||
)
|
||||
private void redirectIsStickyBlock(BlockPos pos, Direction dir, CallbackInfoReturnable<Boolean> cir,
|
||||
BlockState blockState, Block block, int i, int j, int l, BlockPos blockPos2, int m, int n, BlockPos blockPos3)
|
||||
BlockState blockState, int i, int j, int l, BlockPos blockPos2, int m, int n, BlockPos blockPos3)
|
||||
{
|
||||
if (CarpetSettings.doChainStone)
|
||||
{
|
||||
BlockState chainState = world.getBlockState(blockPos3);
|
||||
if (chainState.getBlock() == Blocks.CHAIN && !isChainOnAxis(chainState, motionDirection) && !canMoveAdjacentBlock(blockPos3))
|
||||
if (chainState.getBlock() == Blocks.CHAIN && !isChainOnAxis(chainState, motionDirection) && !tryMoveAdjacentBlock(blockPos3))
|
||||
{
|
||||
cir.setReturnValue(false);
|
||||
}
|
||||
@@ -230,9 +228,9 @@ public abstract class PistonHandler_customStickyMixin
|
||||
/**
|
||||
* Custom movement of blocks stuck to the sides of blocks other than slimeblocks like chains
|
||||
*/
|
||||
@Inject(method = "canMoveAdjacentBlock", locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true, at = @At(
|
||||
@Inject(method = "tryMoveAdjacentBlock", locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true, at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/block/piston/PistonHandler;isAdjacentBlockStuck(Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;)Z",
|
||||
target = "Lnet/minecraft/block/piston/PistonHandler;isAdjacentBlockStuck(Lnet/minecraft/block/BlockState;Lnet/minecraft/block/BlockState;)Z",
|
||||
shift = At.Shift.BEFORE
|
||||
))
|
||||
private void otherSideStickyCases(BlockPos pos, CallbackInfoReturnable<Boolean> cir,
|
||||
@@ -266,11 +264,11 @@ public abstract class PistonHandler_customStickyMixin
|
||||
* @param block2
|
||||
* @return
|
||||
*/
|
||||
@Redirect(method = "canMoveAdjacentBlock", at = @At(
|
||||
@Redirect(method = "tryMoveAdjacentBlock", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/block/piston/PistonHandler;isAdjacentBlockStuck(Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;)Z")
|
||||
target = "Lnet/minecraft/block/piston/PistonHandler;isAdjacentBlockStuck(Lnet/minecraft/block/BlockState;Lnet/minecraft/block/BlockState;)Z")
|
||||
)
|
||||
private boolean isStuckSlimeStone(Block block, Block block2)
|
||||
private boolean isStuckSlimeStone(BlockState block, BlockState block2)
|
||||
{
|
||||
return isBlockSticky(block2) && isAdjacentBlockStuck(block, block2);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public abstract class PlayerEntity_creativeNoClipMixin extends LivingEntity
|
||||
)
|
||||
private boolean canClipTroughWorld(PlayerEntity playerEntity)
|
||||
{
|
||||
return playerEntity.isSpectator() || (CarpetSettings.creativeNoClip && playerEntity.isCreative() && playerEntity.abilities.flying);
|
||||
return playerEntity.isSpectator() || (CarpetSettings.creativeNoClip && playerEntity.isCreative() && playerEntity.getAbilities().flying);
|
||||
|
||||
}
|
||||
|
||||
@@ -33,15 +33,15 @@ public abstract class PlayerEntity_creativeNoClipMixin extends LivingEntity
|
||||
)
|
||||
private boolean collidesWithEntities(PlayerEntity playerEntity)
|
||||
{
|
||||
return playerEntity.isSpectator() || (CarpetSettings.creativeNoClip && playerEntity.isCreative() && playerEntity.abilities.flying);
|
||||
return playerEntity.isSpectator() || (CarpetSettings.creativeNoClip && playerEntity.isCreative() && playerEntity.getAbilities().flying);
|
||||
}
|
||||
|
||||
@Redirect(method = "updateSize", at = @At(
|
||||
@Redirect(method = "updatePose", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/entity/player/PlayerEntity;isSpectator()Z")
|
||||
)
|
||||
private boolean spectatorsDontPose(PlayerEntity playerEntity)
|
||||
{
|
||||
return playerEntity.isSpectator() || (CarpetSettings.creativeNoClip && playerEntity.isCreative() && playerEntity.abilities.flying);
|
||||
return playerEntity.isSpectator() || (CarpetSettings.creativeNoClip && playerEntity.isCreative() && playerEntity.getAbilities().flying);
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.damage.DamageSource;
|
||||
import net.minecraft.entity.player.PlayerAbilities;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -24,15 +24,15 @@ public abstract class PlayerEntity_parrotMixin extends LivingEntity
|
||||
|
||||
@Shadow protected abstract void dropShoulderEntities();
|
||||
|
||||
@Shadow public abstract CompoundTag getShoulderEntityLeft();
|
||||
@Shadow public abstract NbtCompound getShoulderEntityLeft();
|
||||
|
||||
@Shadow protected abstract void setShoulderEntityLeft(CompoundTag compoundTag_1);
|
||||
@Shadow protected abstract void setShoulderEntityLeft(NbtCompound NbtCompound_1);
|
||||
|
||||
@Shadow protected abstract void setShoulderEntityRight(CompoundTag compoundTag_1);
|
||||
@Shadow protected abstract void setShoulderEntityRight(NbtCompound NbtCompound_1);
|
||||
|
||||
@Shadow public abstract CompoundTag getShoulderEntityRight();
|
||||
@Shadow public abstract NbtCompound getShoulderEntityRight();
|
||||
|
||||
@Shadow protected abstract void dropShoulderEntity(CompoundTag entityNbt);
|
||||
@Shadow protected abstract void dropShoulderEntity(NbtCompound entityNbt);
|
||||
|
||||
protected PlayerEntity_parrotMixin(EntityType<? extends LivingEntity> entityType_1, World world_1)
|
||||
{
|
||||
@@ -47,7 +47,7 @@ public abstract class PlayerEntity_parrotMixin extends LivingEntity
|
||||
}
|
||||
|
||||
@Inject(method = "tickMovement", at = @At(value = "INVOKE", shift = At.Shift.AFTER, ordinal = 1,
|
||||
target = "Lnet/minecraft/entity/player/PlayerEntity;updateShoulderEntity(Lnet/minecraft/nbt/CompoundTag;)V"))
|
||||
target = "Lnet/minecraft/entity/player/PlayerEntity;updateShoulderEntity(Lnet/minecraft/nbt/NbtCompound;)V"))
|
||||
private void onTickMovement(CallbackInfo ci)
|
||||
{
|
||||
boolean parrots_will_drop = !CarpetSettings.persistentParrots || this.abilities.invulnerable;
|
||||
@@ -67,13 +67,13 @@ public abstract class PlayerEntity_parrotMixin extends LivingEntity
|
||||
protected void dismount_left()
|
||||
{
|
||||
dropShoulderEntity(this.getShoulderEntityLeft());
|
||||
this.setShoulderEntityLeft(new CompoundTag());
|
||||
this.setShoulderEntityLeft(new NbtCompound());
|
||||
}
|
||||
|
||||
protected void dismount_right()
|
||||
{
|
||||
dropShoulderEntity(this.getShoulderEntityRight());
|
||||
this.setShoulderEntityRight(new CompoundTag());
|
||||
this.setShoulderEntityRight(new NbtCompound());
|
||||
}
|
||||
|
||||
@Inject(method = "damage", at = @At(value = "INVOKE", shift = At.Shift.BEFORE,
|
||||
|
||||
@@ -8,14 +8,19 @@ import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.damage.DamageSource;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
import static carpet.script.CarpetEventServer.Event.PLAYER_ATTACKS_ENTITY;
|
||||
import static carpet.script.CarpetEventServer.Event.PLAYER_DEALS_DAMAGE;
|
||||
import static carpet.script.CarpetEventServer.Event.PLAYER_INTERACTS_WITH_ENTITY;
|
||||
import static carpet.script.CarpetEventServer.Event.PLAYER_TAKES_DAMAGE;
|
||||
import static carpet.script.CarpetEventServer.Event.PLAYER_COLLIDES_WITH_ENTITY;
|
||||
|
||||
@@ -53,4 +58,22 @@ public abstract class PlayerEntity_scarpetEventsMixin extends LivingEntity
|
||||
PLAYER_COLLIDES_WITH_ENTITY.onEntityHandAction((ServerPlayerEntity)(Object)this, entity, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "interact", at = @At("HEAD"))
|
||||
private void doInteract(Entity entity, Hand hand, CallbackInfoReturnable<ActionResult> cir)
|
||||
{
|
||||
if (!world.isClient && PLAYER_INTERACTS_WITH_ENTITY.isNeeded())
|
||||
{
|
||||
PLAYER_INTERACTS_WITH_ENTITY.onEntityHandAction((ServerPlayerEntity) (Object)this, entity, hand);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "attack", at = @At("HEAD"))
|
||||
private void onAttack(Entity target, CallbackInfo ci)
|
||||
{
|
||||
if (!world.isClient && PLAYER_ATTACKS_ENTITY.isNeeded() && target.isAttackable())
|
||||
{
|
||||
PLAYER_ATTACKS_ENTITY.onEntityHandAction((ServerPlayerEntity) (Object)this, target, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.network.ClientConnection;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
@@ -31,7 +31,7 @@ public abstract class PlayerManager_fakePlayersMixin
|
||||
private MinecraftServer server;
|
||||
|
||||
@Inject(method = "loadPlayerData", at = @At(value = "RETURN", shift = At.Shift.BEFORE))
|
||||
private void fixStartingPos(ServerPlayerEntity serverPlayerEntity_1, CallbackInfoReturnable<CompoundTag> cir)
|
||||
private void fixStartingPos(ServerPlayerEntity serverPlayerEntity_1, CallbackInfoReturnable<NbtCompound> cir)
|
||||
{
|
||||
if (serverPlayerEntity_1 instanceof EntityPlayerMPFake)
|
||||
{
|
||||
|
||||
@@ -21,7 +21,11 @@ public class PlayerManager_scarpetEventsMixin
|
||||
PLAYER_RESPAWNS.onPlayerEvent(player);
|
||||
}
|
||||
|
||||
@Inject(method = "respawnPlayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayerEntity;onSpawn()V"))
|
||||
@Inject(method = "respawnPlayer", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/network/ServerPlayerEntity;onSpawn()V"
|
||||
//target = "Lnet/minecraft/server/network/ServerPlayerEntity;method_34225()V"
|
||||
))
|
||||
private void invalidatePreviousInstance(ServerPlayerEntity player, boolean alive, CallbackInfoReturnable<ServerPlayerEntity> cir)
|
||||
{
|
||||
((ServerPlayerEntityInterface)player).invalidateEntityObjectReference();
|
||||
|
||||
@@ -18,6 +18,6 @@ public class ReloadCommand_reloadAppsMixin {
|
||||
private static void onReload(CommandContext<ServerCommandSource> context, CallbackInfoReturnable<Integer> cir)
|
||||
{
|
||||
// can't fetch here the reference to the server
|
||||
CarpetServer.onReload(context.getSource().getMinecraftServer());
|
||||
CarpetServer.onReload(context.getSource().getServer());
|
||||
}
|
||||
}
|
||||
@@ -3,10 +3,11 @@ package carpet.mixins;
|
||||
import net.minecraft.scoreboard.ScoreboardCriterion;
|
||||
import net.minecraft.scoreboard.ScoreboardObjective;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Mutable;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(ScoreboardObjective.class)
|
||||
public interface ScoreboardObjective_scarpetMixin {
|
||||
@Accessor("criterion")
|
||||
@Mutable @Accessor("criterion")
|
||||
void setCriterion(ScoreboardCriterion criterion);
|
||||
}
|
||||
@@ -77,7 +77,7 @@ public abstract class ServerChunkManagerMixin implements ServerChunkManagerInter
|
||||
int spawnTries = SpawnReporter.spawn_tries.get(cat);
|
||||
if (!SpawnReporter.local_spawns.containsKey(cat))
|
||||
{
|
||||
if (!cat.isAnimal() || boolean_3)
|
||||
if (!cat.isRare() || boolean_3) // isAnimal
|
||||
{
|
||||
// fill mobcaps for that category so spawn got cancelled
|
||||
SpawnReporter.spawn_ticks_full.put(key,
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.script.CarpetEventServer;
|
||||
import carpet.script.CarpetScriptServer;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.server.world.ServerEntityManager;
|
||||
import net.minecraft.world.entity.EntityLike;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(ServerEntityManager.class)
|
||||
public class ServerEntityManager_scarpetMixin
|
||||
{
|
||||
@Inject(method = "addEntity(Lnet/minecraft/world/entity/EntityLike;Z)Z", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/entity/EntityTrackingStatus;shouldTick()Z"
|
||||
))
|
||||
private void handleAddedEntity(EntityLike entityLike, boolean existing, CallbackInfoReturnable<Boolean> cir)
|
||||
{
|
||||
Entity entity = (Entity)entityLike;
|
||||
CarpetEventServer.Event event = CarpetEventServer.Event.ENTITY_HANDLER.get(entity.getType());
|
||||
if (event != null)
|
||||
{
|
||||
if (event.isNeeded())
|
||||
{
|
||||
event.onEntityAction(entity, !existing);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CarpetScriptServer.LOG.error("Failed to handle entity type " + entity.getType().getTranslationKey());
|
||||
}
|
||||
|
||||
event = CarpetEventServer.Event.ENTITY_LOAD.get(entity.getType());
|
||||
if (event != null)
|
||||
{
|
||||
if (event.isNeeded())
|
||||
{
|
||||
event.onEntityAction(entity, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CarpetScriptServer.LOG.error("Failed to handle entity type " + entity.getType().getTranslationKey());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -51,7 +51,7 @@ public class ServerPlayNetworkHandler_scarpetEventsMixin
|
||||
{
|
||||
@Shadow public ServerPlayerEntity player;
|
||||
|
||||
@Inject(method = "onPlayerInput", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayerEntity;method_14218(FFZZ)V"))
|
||||
@Inject(method = "onPlayerInput", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayerEntity;updateInput(FFZZ)V"))
|
||||
private void checkMoves(PlayerInputC2SPacket p, CallbackInfo ci)
|
||||
{
|
||||
if (PLAYER_RIDES.isNeeded() && (p.getSideways() != 0.0F || p.getForward() != 0.0F || p.isJumping() || p.isSneaking()))
|
||||
@@ -62,7 +62,7 @@ public class ServerPlayNetworkHandler_scarpetEventsMixin
|
||||
|
||||
@Inject(method = "onPlayerAction", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/network/ServerPlayerEntity;dropSelectedItem(Z)Z",
|
||||
target = "Lnet/minecraft/server/network/ServerPlayerEntity;dropSelectedItem(Z)Z", // dropSelectedItem
|
||||
ordinal = 0,
|
||||
shift = At.Shift.BEFORE
|
||||
))
|
||||
@@ -84,7 +84,7 @@ public class ServerPlayNetworkHandler_scarpetEventsMixin
|
||||
|
||||
@Inject(method = "onPlayerAction", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/network/ServerPlayerEntity;dropSelectedItem(Z)Z",
|
||||
target = "Lnet/minecraft/server/network/ServerPlayerEntity;dropSelectedItem(Z)Z", // dropSelectedItem
|
||||
ordinal = 1,
|
||||
shift = At.Shift.BEFORE
|
||||
))
|
||||
@@ -225,16 +225,16 @@ public class ServerPlayNetworkHandler_scarpetEventsMixin
|
||||
PLAYER_DEPLOYS_ELYTRA.onPlayerEvent(player);
|
||||
}
|
||||
|
||||
@Inject(method = "onPlayerInteractEntity", at = @At(
|
||||
/*@Inject(method = "onPlayerInteractEntity", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/network/ServerPlayerEntity;interact(Lnet/minecraft/entity/Entity;Lnet/minecraft/util/Hand;)Lnet/minecraft/util/ActionResult;"
|
||||
))
|
||||
private void onEntityInteract(PlayerInteractEntityC2SPacket playerInteractEntityC2SPacket_1, CallbackInfo ci)
|
||||
{
|
||||
PLAYER_INTERACTS_WITH_ENTITY.onEntityHandAction(player, playerInteractEntityC2SPacket_1.getEntity(player.getServerWorld()), playerInteractEntityC2SPacket_1.getHand());
|
||||
}
|
||||
}*/
|
||||
|
||||
@Inject(method = "onPlayerInteractEntity", at = @At(
|
||||
/*@Inject(method = "onPlayerInteractEntity", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/network/ServerPlayerEntity;attack(Lnet/minecraft/entity/Entity;)V"
|
||||
))
|
||||
@@ -242,7 +242,7 @@ public class ServerPlayNetworkHandler_scarpetEventsMixin
|
||||
{
|
||||
//todo add hit and hand in the future
|
||||
PLAYER_ATTACKS_ENTITY.onEntityHandAction(player, playerInteractEntityC2SPacket_1.getEntity(player.getServerWorld()), null);
|
||||
}
|
||||
}*/
|
||||
|
||||
@Inject(method = "onButtonClick", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayerEntity;updateLastActionTime()V"))
|
||||
private void onItemBeingPickedFromInventory(ButtonClickC2SPacket packet, CallbackInfo ci)
|
||||
@@ -264,7 +264,7 @@ public class ServerPlayNetworkHandler_scarpetEventsMixin
|
||||
{
|
||||
if (PLAYER_SWITCHES_SLOT.isNeeded() && player.getServer() != null && player.getServer().isOnThread())
|
||||
{
|
||||
PLAYER_SWITCHES_SLOT.onSlotSwitch(player, player.inventory.selectedSlot, packet.getSelectedSlot());
|
||||
PLAYER_SWITCHES_SLOT.onSlotSwitch(player, player.getInventory().selectedSlot, packet.getSelectedSlot());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ public abstract class ServerPlayerEntityMixin implements ServerPlayerEntityInter
|
||||
MinecraftServer minecraftServer_1,
|
||||
ServerWorld serverWorld_1,
|
||||
GameProfile gameProfile_1,
|
||||
ServerPlayerInteractionManager serverPlayerInteractionManager_1,
|
||||
CallbackInfo ci)
|
||||
{
|
||||
this.actionPack = new EntityPlayerActionPack((ServerPlayerEntity) (Object) this);
|
||||
|
||||
@@ -82,7 +82,7 @@ public abstract class ServerPlayerEntity_scarpetEventMixin extends PlayerEntity
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(method = "method_14218", at = @At(
|
||||
@Redirect(method = "updateInput", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/network/ServerPlayerEntity;setSneaking(Z)V"
|
||||
))
|
||||
|
||||
@@ -75,6 +75,6 @@ public class ServerPlayerInteractionManager_scarpetEventsMixin implements Server
|
||||
public void setBlockBreakingProgress(int progress)
|
||||
{
|
||||
blockBreakingProgress = MathHelper.clamp(progress, -1, 10);
|
||||
world.setBlockBreakingInfo(-1*this.player.getEntityId(), miningPos, blockBreakingProgress);
|
||||
world.setBlockBreakingInfo(-1*this.player.getId(), miningPos, blockBreakingProgress);
|
||||
}
|
||||
}
|
||||
@@ -14,8 +14,9 @@ import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
@Mixin(ServerWorld.class)
|
||||
public abstract class ServerWorld_fakePlayersMixin
|
||||
{
|
||||
@Shadow /*@Nonnull*/ public abstract MinecraftServer getServer();
|
||||
|
||||
@Shadow /*@Nonnull*/ public abstract MinecraftServer getServer();
|
||||
/*
|
||||
@Shadow private boolean inEntityTick;
|
||||
|
||||
@Redirect( method = "removePlayer", at = @At(
|
||||
@@ -24,7 +25,7 @@ public abstract class ServerWorld_fakePlayersMixin
|
||||
))
|
||||
private void crashRemovePlayer(ServerWorld serverWorld, Entity entity_1, ServerPlayerEntity serverPlayerEntity_1)
|
||||
{
|
||||
if ( !(inEntityTick && serverPlayerEntity_1 instanceof EntityPlayerMPFake) )
|
||||
if ( !(serverPlayerEntity_1 instanceof EntityPlayerMPFake) )
|
||||
serverWorld.removeEntity(entity_1);
|
||||
else
|
||||
getServer().send(new ServerTask(getServer().getTicks(), () ->
|
||||
@@ -33,5 +34,5 @@ public abstract class ServerWorld_fakePlayersMixin
|
||||
serverPlayerEntity_1.onTeleportationDone();
|
||||
}));
|
||||
|
||||
}
|
||||
}*/
|
||||
}
|
||||
@@ -17,7 +17,7 @@ import java.util.stream.Stream;
|
||||
|
||||
@Mixin(ServerWorld.class)
|
||||
public class ServerWorld_onePlayerSleepingMixin
|
||||
{
|
||||
{/* removed due to 1.17 changes
|
||||
@Shadow @Final private List<ServerPlayerEntity> players;
|
||||
|
||||
@Shadow private boolean allPlayersSleeping;
|
||||
@@ -49,5 +49,5 @@ public class ServerWorld_onePlayerSleepingMixin
|
||||
return stream.anyMatch((p) -> !p.isSpectator() && p.isSleepingLongEnough());
|
||||
return stream.noneMatch(predicate);
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
@@ -4,13 +4,16 @@ import carpet.CarpetSettings;
|
||||
import carpet.fakes.ServerWorldInterface;
|
||||
import carpet.script.CarpetEventServer;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityLike;
|
||||
import net.minecraft.entity.LightningEntity;
|
||||
import net.minecraft.entity.damage.DamageSource;
|
||||
import net.minecraft.server.world.ServerEntityManager;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.util.profiler.Profiler;
|
||||
import net.minecraft.world.chunk.WorldChunk;
|
||||
import net.minecraft.world.entity.EntityLookup;
|
||||
import net.minecraft.world.explosion.Explosion;
|
||||
import net.minecraft.world.explosion.ExplosionBehavior;
|
||||
import net.minecraft.world.level.ServerWorldProperties;
|
||||
@@ -19,12 +22,11 @@ import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
import static carpet.script.CarpetEventServer.Event.ENTITY_HANDLER;
|
||||
import static carpet.script.CarpetEventServer.Event.ENTITY_LOAD;
|
||||
import static carpet.script.CarpetEventServer.Event.EXPLOSION;
|
||||
import static carpet.script.CarpetEventServer.Event.LIGHTNING;
|
||||
|
||||
@@ -44,51 +46,29 @@ public class ServerWorld_scarpetMixin implements ServerWorldInterface
|
||||
if (LIGHTNING.isNeeded()) LIGHTNING.onWorldEventFlag((ServerWorld) (Object)this, blockPos, bl2?1:0);
|
||||
}
|
||||
|
||||
|
||||
private ThreadLocal<Boolean> entityJustLoaded = ThreadLocal.withInitial(() -> false);
|
||||
|
||||
@Inject(method = "loadEntityUnchecked", at = @At(
|
||||
/*
|
||||
moved to ServerEntityManager_scarpetMixin in 1.17
|
||||
@Redirect(method = "addEntity", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/world/ServerChunkManager;loadEntity(Lnet/minecraft/entity/Entity;)V"
|
||||
target = "Lnet/minecraft/server/world/ServerEntityManager;addEntity(Lnet/minecraft/world/entity/EntityLike;)Z"
|
||||
))
|
||||
private void onEntityAddedToWorld(Entity entity, CallbackInfo ci)
|
||||
private boolean onEntityAddedToWorld(ServerEntityManager serverEntityManager, EntityLike entityLike)
|
||||
{
|
||||
boolean justLoaded = entityJustLoaded.get();
|
||||
entityJustLoaded.set(false);
|
||||
CarpetEventServer.Event event = ENTITY_HANDLER.get(entity.getType());
|
||||
if (event != null)
|
||||
{
|
||||
if (event.isNeeded())
|
||||
{
|
||||
event.onEntityAction(entity, !justLoaded);
|
||||
Entity entity = (Entity)entityLike;
|
||||
boolean success = serverEntityManager.addEntity(entity);
|
||||
if (success) {
|
||||
CarpetEventServer.Event event = ENTITY_LOAD.get(entity.getType());
|
||||
if (event != null) {
|
||||
if (event.isNeeded()) {
|
||||
event.onEntityAction(entity);
|
||||
}
|
||||
} else {
|
||||
CarpetSettings.LOG.error("Failed to handle entity " + entity.getType().getTranslationKey());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CarpetSettings.LOG.error("Failed to handle entity "+entity.getType().getTranslationKey());
|
||||
}
|
||||
|
||||
// deprecated usage
|
||||
event = ENTITY_LOAD.get(entity.getType());
|
||||
if (event != null)
|
||||
{
|
||||
if (event.isNeeded())
|
||||
{
|
||||
event.onEntityAction(entity, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CarpetSettings.LOG.error("Failed to handle entity "+entity.getType().getTranslationKey());
|
||||
}
|
||||
}
|
||||
|
||||
// 1.16only
|
||||
@Inject(method = "loadEntity", at= @At("HEAD"))
|
||||
private void onSideLoaded(Entity entity, CallbackInfoReturnable<Boolean> cir)
|
||||
{
|
||||
entityJustLoaded.set(true);
|
||||
};
|
||||
return success;
|
||||
}
|
||||
*/
|
||||
|
||||
@Inject(method = "createExplosion", at = @At("HEAD"))
|
||||
private void handleExplosion(/*@Nullable*/ Entity entity, /*@Nullable*/ DamageSource damageSource, /*@Nullable*/ ExplosionBehavior explosionBehavior, double d, double e, double f, float g, boolean bl, Explosion.DestructionType destructionType, CallbackInfoReturnable<Explosion> cir)
|
||||
@@ -100,7 +80,14 @@ public class ServerWorld_scarpetMixin implements ServerWorldInterface
|
||||
@Final
|
||||
@Shadow
|
||||
private ServerWorldProperties worldProperties;
|
||||
@Shadow @Final private ServerEntityManager<Entity> entityManager;
|
||||
|
||||
public ServerWorldProperties getWorldPropertiesCM(){
|
||||
return worldProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityLookup<Entity> getEntityLookupCMPublic() {
|
||||
return entityManager.getLookup();
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ public class ShulkerBoxBlockEntity_creativeNoClipMixin
|
||||
))
|
||||
private PistonBehavior getPistonBehaviourOfNoClipPlayers(Entity entity)
|
||||
{
|
||||
if (CarpetSettings.creativeNoClip && entity instanceof PlayerEntity && (((PlayerEntity) entity).isCreative()) && ((PlayerEntity) entity).abilities.flying)
|
||||
if (CarpetSettings.creativeNoClip && entity instanceof PlayerEntity && (((PlayerEntity) entity).isCreative()) && ((PlayerEntity) entity).getAbilities().flying)
|
||||
return PistonBehavior.IGNORE;
|
||||
return entity.getPistonBehavior();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.fakes.SimpleEntityLookupInterface;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.entity.EntityLike;
|
||||
import net.minecraft.world.entity.EntityTrackingSection;
|
||||
import net.minecraft.world.entity.SectionedEntityCache;
|
||||
import net.minecraft.world.entity.SimpleEntityLookup;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Mixin(SimpleEntityLookup.class)
|
||||
public class SimpleEntityLookup_scarpetMixin<T extends EntityLike> implements SimpleEntityLookupInterface
|
||||
{
|
||||
|
||||
@Shadow @Final private SectionedEntityCache<T> cache;
|
||||
|
||||
@Override
|
||||
public List<T> getChunkEntities(ChunkPos chpos) {
|
||||
return this.cache.getTrackingSections(chpos.toLong()).flatMap(EntityTrackingSection::stream).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -88,18 +88,26 @@ public abstract class SkyLightStorage_scarpetChunkCreationMixin extends LightSto
|
||||
final int dx = Math.abs(dir.getOffsetZ());
|
||||
final int dz = Math.abs(dir.getOffsetX());
|
||||
|
||||
int emptyLightLevel = (neighborCeilingLightArray == null)
|
||||
? (this.isSectionEnabled(ChunkSectionPos.withZeroY(neighborCeilingSectionPos)) ? 0 : 15)
|
||||
: 0;
|
||||
int neighbourY = (neighborLightArray == null)
|
||||
? ChunkSectionPos.getBlockCoord(ChunkSectionPos.unpackY(neighborCeilingSectionPos))
|
||||
: 0;
|
||||
|
||||
for (int t = 0; t < 16; ++t)
|
||||
for (int dy = 0; dy < 16; ++dy)
|
||||
{
|
||||
final long dst = BlockPos.add(pos, ox + t * dx, dy, oz + t * dz);
|
||||
long src = BlockPos.offset(dst, dir);
|
||||
|
||||
if (neighborLightArray == null)
|
||||
src = BlockPos.asLong(BlockPos.unpackLongX(src), ChunkSectionPos.getBlockCoord(ChunkSectionPos.unpackY(neighborCeilingSectionPos)), BlockPos.unpackLongZ(src));
|
||||
long adj_src = (neighborLightArray != null)
|
||||
? src
|
||||
: BlockPos.asLong(BlockPos.unpackLongX(src), neighbourY, BlockPos.unpackLongZ(src));
|
||||
|
||||
final int srcLevel = neighborCeilingLightArray != null ?
|
||||
((ChunkLightProviderInterface) lightProvider).callGetCurrentLevelFromSection(neighborCeilingLightArray, src)
|
||||
: this.isSectionEnabled(ChunkSectionPos.withZeroY(neighborCeilingSectionPos)) ? 0 : 15;
|
||||
final int srcLevel = neighborCeilingLightArray != null
|
||||
? ((ChunkLightProviderInterface) lightProvider).callGetCurrentLevelFromSection(neighborCeilingLightArray, adj_src)
|
||||
: emptyLightLevel;
|
||||
|
||||
levelPropagator.cmInvokeUpdateLevel(src, dst, levelPropagator.cmCallGetPropagatedLevel(src, dst, srcLevel), true);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.helpers.InventoryHelper;
|
||||
import net.minecraft.block.ShulkerBoxBlock;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.screen.slot.Slot;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(Slot.class)
|
||||
public class Slot_stackableSBoxesMixin {
|
||||
@Redirect(method = "insertStack(Lnet/minecraft/item/ItemStack;I)Lnet/minecraft/item/ItemStack;", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/screen/slot/Slot;getMaxItemCount(Lnet/minecraft/item/ItemStack;)I"
|
||||
))
|
||||
private int getMaxCountForSboxes(Slot slot, ItemStack stack)
|
||||
{
|
||||
if (CarpetSettings.stackableShulkerBoxes &&
|
||||
stack.getItem() instanceof BlockItem &&
|
||||
((BlockItem)stack.getItem()).getBlock() instanceof ShulkerBoxBlock &&
|
||||
!InventoryHelper.shulkerBoxHasItems(stack)
|
||||
)
|
||||
{
|
||||
return CarpetSettings.SHULKER_STACK_SIZE;
|
||||
}
|
||||
return slot.getMaxItemCount(stack);
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.SpawnReason;
|
||||
import net.minecraft.entity.mob.MobEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.tag.BlockTags;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -117,8 +117,8 @@ public class SpawnHelperMixin
|
||||
BlockState state = world.getBlockState(blockpos);
|
||||
Block block = state.getBlock();
|
||||
if (
|
||||
block.isIn(BlockTags.FENCES) ||
|
||||
block.isIn(BlockTags.WALLS) ||
|
||||
state.isIn(BlockTags.FENCES) ||
|
||||
state.isIn(BlockTags.WALLS) ||
|
||||
((block instanceof FenceGateBlock) && !state.get(FenceGateBlock.OPEN))
|
||||
)
|
||||
{
|
||||
@@ -175,9 +175,9 @@ public class SpawnHelperMixin
|
||||
|
||||
@Redirect(method = "spawnEntitiesInChunk(Lnet/minecraft/entity/SpawnGroup;Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/world/chunk/Chunk;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/world/SpawnHelper$Checker;Lnet/minecraft/world/SpawnHelper$Runner;)V", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/entity/mob/MobEntity;initialize(Lnet/minecraft/world/ServerWorldAccess;Lnet/minecraft/world/LocalDifficulty;Lnet/minecraft/entity/SpawnReason;Lnet/minecraft/entity/EntityData;Lnet/minecraft/nbt/CompoundTag;)Lnet/minecraft/entity/EntityData;"
|
||||
target = "Lnet/minecraft/entity/mob/MobEntity;initialize(Lnet/minecraft/world/ServerWorldAccess;Lnet/minecraft/world/LocalDifficulty;Lnet/minecraft/entity/SpawnReason;Lnet/minecraft/entity/EntityData;Lnet/minecraft/nbt/NbtCompound;)Lnet/minecraft/entity/EntityData;"
|
||||
))
|
||||
private static EntityData spawnEntity(MobEntity mobEntity, ServerWorldAccess serverWorldAccess, LocalDifficulty difficulty, SpawnReason spawnReason, EntityData entityData, CompoundTag entityTag)
|
||||
private static EntityData spawnEntity(MobEntity mobEntity, ServerWorldAccess serverWorldAccess, LocalDifficulty difficulty, SpawnReason spawnReason, EntityData entityData, NbtCompound entityTag)
|
||||
{
|
||||
if (!SpawnReporter.mock_spawns) // WorldAccess
|
||||
return mobEntity.initialize(serverWorldAccess, difficulty, spawnReason, entityData, entityTag);
|
||||
@@ -279,7 +279,7 @@ public class SpawnHelperMixin
|
||||
|
||||
for(int var8 = 0; var8 < var7; ++var8) {
|
||||
SpawnGroup entityCategory = var6[var8];
|
||||
if ((spawnAnimals || !entityCategory.isPeaceful()) && (spawnMonsters || entityCategory.isPeaceful()) && (shouldSpawnAnimals || !entityCategory.isAnimal()) )
|
||||
if ((spawnAnimals || !entityCategory.isPeaceful()) && (spawnMonsters || entityCategory.isPeaceful()) && (shouldSpawnAnimals || !entityCategory.isRare()) )
|
||||
{
|
||||
RegistryKey<World> dim = world.getRegistryKey(); // getDimensionType;
|
||||
int newCap = (int) ((double)entityCategory.getCapacity()*(Math.pow(2.0,(SpawnReporter.mobcap_exponent/4))));
|
||||
|
||||
@@ -6,7 +6,7 @@ import carpet.script.value.Value;
|
||||
import carpet.script.value.ValueConversions;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.state.property.Property;
|
||||
import net.minecraft.tag.Tag;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
@@ -23,7 +23,7 @@ public class StatePredicate_scarpetMixin implements BlockPredicateInterface
|
||||
|
||||
@Shadow @Final private BlockState state;
|
||||
|
||||
@Shadow @Final /*@Nullable*/ private CompoundTag nbt;
|
||||
@Shadow @Final /*@Nullable*/ private NbtCompound nbt;
|
||||
|
||||
@Shadow @Final private Set<Property<?>> properties;
|
||||
|
||||
@@ -50,7 +50,7 @@ public class StatePredicate_scarpetMixin implements BlockPredicateInterface
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag getCMDataTag()
|
||||
public NbtCompound getCMDataTag()
|
||||
{
|
||||
return nbt;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.block.entity.StructureBlockBlockEntity;
|
||||
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
|
||||
import net.minecraft.client.render.block.entity.StructureBlockBlockEntityRenderer;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(StructureBlockBlockEntityRenderer.class)
|
||||
public abstract class StructureBlockBlockEntityRenderer_mixin implements BlockEntityRenderer<StructureBlockBlockEntity>
|
||||
{
|
||||
@Inject(method = "getRenderDistance", at = @At("HEAD"), cancellable = true)
|
||||
void newLimit(CallbackInfoReturnable<Integer> cir)
|
||||
{
|
||||
if (CarpetSettings.structureBlockOutlineDistance != 96)
|
||||
cir.setReturnValue(CarpetSettings.structureBlockOutlineDistance);
|
||||
}
|
||||
}
|
||||
@@ -17,15 +17,15 @@ public abstract class StructureBlockBlockEntity_fillUpdatesMixin
|
||||
{
|
||||
@Redirect(method = "place", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/structure/Structure;place(Lnet/minecraft/world/ServerWorldAccess;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/structure/StructurePlacementData;Ljava/util/Random;)V"
|
||||
target = "Lnet/minecraft/structure/Structure;place(Lnet/minecraft/world/ServerWorldAccess;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/structure/StructurePlacementData;Ljava/util/Random;I)Z"
|
||||
))
|
||||
private void onStructurePlacen(Structure structure, ServerWorldAccess serverWorldAccess, BlockPos pos, StructurePlacementData placementData, Random random)
|
||||
private boolean onStructurePlacen(Structure structure, ServerWorldAccess serverWorldAccess, BlockPos pos, BlockPos blockPos, StructurePlacementData placementData, Random random, int i)
|
||||
{
|
||||
if(!CarpetSettings.fillUpdates)
|
||||
CarpetSettings.impendingFillSkipUpdates.set(true);
|
||||
try
|
||||
{
|
||||
structure.place(serverWorldAccess, pos, placementData, random);
|
||||
return structure.place(serverWorldAccess, pos, blockPos, placementData, random, i); // serverWorldAccess, pos, placementData, random);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@ import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
public abstract class StructureBlockBlockEntity_limitsMixin
|
||||
{
|
||||
@ModifyConstant(
|
||||
method = "fromTag",
|
||||
method = "readNbt",
|
||||
constant = @Constant(intValue = 48)
|
||||
)
|
||||
private int positiveLimit(int original) {
|
||||
@@ -23,7 +23,7 @@ public abstract class StructureBlockBlockEntity_limitsMixin
|
||||
}
|
||||
|
||||
@ModifyConstant(
|
||||
method = "fromTag",
|
||||
method = "readNbt",
|
||||
constant = @Constant(intValue = -48)
|
||||
)
|
||||
private int negativeLimit(int original) {
|
||||
@@ -34,14 +34,14 @@ public abstract class StructureBlockBlockEntity_limitsMixin
|
||||
method = "saveStructure(Z)Z",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/structure/Structure;saveFromWorld(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/BlockPos;ZLnet/minecraft/block/Block;)V"
|
||||
target = "Lnet/minecraft/structure/Structure;saveFromWorld(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/Vec3i;ZLnet/minecraft/block/Block;)V"
|
||||
),
|
||||
index = 4
|
||||
)
|
||||
private Block ignoredBlock(Block original) {
|
||||
return CarpetSettings.structureBlockIgnoredBlock;
|
||||
}
|
||||
|
||||
/*
|
||||
@Environment(EnvType.CLIENT)
|
||||
@ModifyConstant(
|
||||
method = "getSquaredRenderDistance",
|
||||
@@ -50,4 +50,6 @@ public abstract class StructureBlockBlockEntity_limitsMixin
|
||||
private double outlineRenderDistanceLimit(double original) {
|
||||
return CarpetSettings.structureBlockOutlineDistance;
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import net.minecraft.structure.StructureStart;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.util.math.BlockBox;
|
||||
import net.minecraft.world.HeightLimitView;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.source.BiomeSource;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
@@ -28,7 +29,7 @@ public abstract class StructureFeatureMixin<C extends FeatureConfig> implements
|
||||
|
||||
@Shadow public abstract StructureFeature.StructureStartFactory getStructureStartFactory();
|
||||
|
||||
@Shadow protected abstract boolean shouldStartAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long l, ChunkRandom chunkRandom, int i, int j, Biome biome, ChunkPos chunkPos, C featureConfig);
|
||||
@Shadow protected abstract boolean shouldStartAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long worldSeed, ChunkRandom random, ChunkPos chunkPos, Biome biome, ChunkPos chunkPos2, C featureConfig, HeightLimitView heightLimitView);
|
||||
|
||||
@Override
|
||||
public boolean plopAnywhere(ServerWorld world, BlockPos pos, ChunkGenerator generator, boolean wireOnly, Biome biome, FeatureConfig config)
|
||||
@@ -49,13 +50,13 @@ public abstract class StructureFeatureMixin<C extends FeatureConfig> implements
|
||||
}
|
||||
world.getChunk(j, k).addStructureReference((StructureFeature) (Object)this, chId);
|
||||
|
||||
BlockBox box = structurestart.getBoundingBox();
|
||||
BlockBox box = structurestart.setBoundingBoxFromChildren(); // getBB
|
||||
if (!wireOnly)
|
||||
{
|
||||
structurestart.generateStructure(world, world.getStructureAccessor(), generator, rand,box, new ChunkPos(j, k));
|
||||
}
|
||||
//structurestart.notifyPostProcessAt(new ChunkPos(j, k));
|
||||
int i = Math.max(box.getBlockCountX(),box.getBlockCountZ())/16+1; //size
|
||||
int i = Math.max(box.getBlockCountX(),box.getBlockCountZ())/16+1;
|
||||
|
||||
//int i = getRadius();
|
||||
for (int k1 = j - i; k1 <= j + i; ++k1)
|
||||
@@ -104,10 +105,10 @@ public abstract class StructureFeatureMixin<C extends FeatureConfig> implements
|
||||
if (biome == null)
|
||||
biome_1 = generator.getBiomeSource().getBiomeForNoiseGen((chunkpos.getStartX() + 9) >> 2, 0, (chunkpos.getStartZ() + 9) >> 2 );
|
||||
|
||||
StructureStart structurestart1 = getStructureStartFactory().create((StructureFeature)(Object)this, chunkpos.x, chunkpos.z, BlockBox.empty(),0,worldIn.getSeed());
|
||||
StructureStart structurestart1 = getStructureStartFactory().create((StructureFeature)(Object)this, chunkpos,0,worldIn.getSeed());
|
||||
if (config == null)
|
||||
config = new DefaultFeatureConfig();
|
||||
structurestart1.init(worldIn.getRegistryManager(), generator, worldIn.getStructureManager() , chunkpos.x, chunkpos.z, biome_1, config);
|
||||
structurestart1.init(worldIn.getRegistryManager(), generator, worldIn.getStructureManager() , chunkpos, biome_1, config, ichunk);
|
||||
structurestart = structurestart1.hasChildren() ? structurestart1 : StructureStart.DEFAULT;
|
||||
|
||||
if (structurestart.hasChildren())
|
||||
@@ -120,8 +121,8 @@ public abstract class StructureFeatureMixin<C extends FeatureConfig> implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldStartPublicAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long l, ChunkRandom chunkRandom, int i, int j, Biome biome, ChunkPos chunkPos, C featureConfig)
|
||||
public boolean shouldStartPublicAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long l, ChunkRandom chunkRandom, ChunkPos chpos, Biome biome, ChunkPos chunkPos, C featureConfig, HeightLimitView heightLimitView)
|
||||
{
|
||||
return shouldStartAt(chunkGenerator, biomeSource, l, chunkRandom, i, j, biome, chunkPos, featureConfig);
|
||||
return shouldStartAt(chunkGenerator, biomeSource, l, chunkRandom, chpos, biome, chunkPos, featureConfig, heightLimitView);
|
||||
}
|
||||
}
|
||||
@@ -31,10 +31,10 @@ public class SummonCommandMixin
|
||||
LocalDifficulty localDifficulty_1 = world.getLocalDifficulty(at);
|
||||
boolean boolean_2 = world.getGameRules().getBoolean(GameRules.DO_MOB_SPAWNING) && world.random.nextDouble() < (double)localDifficulty_1.getLocalDifficulty() * 0.01D;
|
||||
if (boolean_2) {
|
||||
SkeletonHorseEntity skeletonHorseEntity_1 = (SkeletonHorseEntity) EntityType.SKELETON_HORSE.create(world);
|
||||
SkeletonHorseEntity skeletonHorseEntity_1 = EntityType.SKELETON_HORSE.create(world);
|
||||
skeletonHorseEntity_1.setTrapped(true);
|
||||
skeletonHorseEntity_1.setBreedingAge(0);
|
||||
skeletonHorseEntity_1.resetPosition(entity.getX(), entity.getY(), entity.getZ());
|
||||
skeletonHorseEntity_1.setPosition(entity.getX(), entity.getY(), entity.getZ());
|
||||
world.spawnEntity(skeletonHorseEntity_1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import carpet.script.value.StringValue;
|
||||
import carpet.script.value.Value;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.tag.Tag;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -21,7 +21,7 @@ public class TagPredicate_scarpetMixin implements BlockPredicateInterface
|
||||
|
||||
@Shadow @Final private Map<String, String> properties;
|
||||
|
||||
@Shadow @Final /*@Nullable*/ private CompoundTag nbt;
|
||||
@Shadow @Final /*@Nullable*/ private NbtCompound nbt;
|
||||
|
||||
@Override
|
||||
public BlockState getCMBlockState()
|
||||
@@ -45,7 +45,7 @@ public class TagPredicate_scarpetMixin implements BlockPredicateInterface
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag getCMDataTag()
|
||||
public NbtCompound getCMDataTag()
|
||||
{
|
||||
return nbt;
|
||||
}
|
||||
|
||||
+20
-10
@@ -12,6 +12,10 @@ import java.util.concurrent.Future;
|
||||
import java.util.function.IntFunction;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import carpet.fakes.SimpleEntityLookupInterface;
|
||||
import carpet.fakes.ServerWorldInterface;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.ServerTask;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
@@ -74,7 +78,7 @@ public abstract class ThreadedAnvilChunkStorage_scarpetChunkCreationMixin implem
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private ServerLightingProvider serverLightingProvider;
|
||||
private ServerLightingProvider lightingProvider;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
@@ -285,12 +289,12 @@ public abstract class ThreadedAnvilChunkStorage_scarpetChunkCreationMixin implem
|
||||
this.currentChunkHolders.get(pos.toLong()).getChunkAt(ChunkStatus.EMPTY, (ThreadedAnvilChunkStorage) (Object) this);
|
||||
final Chunk chunk = this.getCurrentChunk(pos);
|
||||
if (!(chunk.getStatus().isAtLeast(ChunkStatus.LIGHT.getPrevious()))) return;
|
||||
((ServerLightingProviderInterface) this.serverLightingProvider).removeLightData(chunk);
|
||||
((ServerLightingProviderInterface) this.lightingProvider).removeLightData(chunk);
|
||||
this.addRelightTicket(pos);
|
||||
final CompletableFuture<?> lightFuture = this.getRegion (pos, 1, (pos_) -> ChunkStatus.LIGHT)
|
||||
.thenCompose(
|
||||
either -> either.map(
|
||||
list -> ((ServerLightingProviderInterface) this.serverLightingProvider).relight(chunk),
|
||||
list -> ((ServerLightingProviderInterface) this.lightingProvider).relight(chunk),
|
||||
unloaded -> {
|
||||
this.releaseRelightTicket(pos);
|
||||
return CompletableFuture.completedFuture(null);
|
||||
@@ -358,14 +362,20 @@ public abstract class ThreadedAnvilChunkStorage_scarpetChunkCreationMixin implem
|
||||
{
|
||||
final ChunkPos pos = chunk.getPos();
|
||||
|
||||
// remove entities
|
||||
long longPos = pos.toLong();
|
||||
if (this.loadedChunks.contains(longPos) && chunk instanceof WorldChunk)
|
||||
((SimpleEntityLookupInterface<Entity>)((ServerWorldInterface)world).getEntityLookupCMPublic()).getChunkEntities(pos).forEach(entity -> { if (!(entity instanceof PlayerEntity)) entity.discard();});
|
||||
|
||||
|
||||
if (chunk instanceof WorldChunk)
|
||||
((WorldChunk) chunk).setLoadedToWorld(false);
|
||||
|
||||
if (this.loadedChunks.remove(pos.toLong()) && chunk instanceof WorldChunk)
|
||||
this.world.unloadEntities((WorldChunk) chunk);
|
||||
this.world.unloadEntities((WorldChunk) chunk); // block entities only
|
||||
|
||||
((ServerLightingProviderInterface) this.serverLightingProvider).invokeUpdateChunkStatus(pos);
|
||||
((ServerLightingProviderInterface) this.serverLightingProvider).removeLightData(chunk);
|
||||
((ServerLightingProviderInterface) this.lightingProvider).invokeUpdateChunkStatus(pos);
|
||||
((ServerLightingProviderInterface) this.lightingProvider).removeLightData(chunk);
|
||||
|
||||
this.worldGenerationProgressListener.setChunkStatus(pos, null);
|
||||
}
|
||||
@@ -378,8 +388,8 @@ public abstract class ThreadedAnvilChunkStorage_scarpetChunkCreationMixin implem
|
||||
final long pos = cPos.toLong();
|
||||
|
||||
final ChunkHolder oldHolder = this.currentChunkHolders.remove(pos);
|
||||
final ChunkHolder newHolder = new ChunkHolder(cPos, oldHolder.getLevel(), this.serverLightingProvider, this.chunkTaskPrioritySystem, (ChunkHolder.PlayersWatchingChunkProvider) this);
|
||||
((ChunkHolderInterface) newHolder).setDefaultProtoChunk(cPos, this.mainThreadExecutor);
|
||||
final ChunkHolder newHolder = new ChunkHolder(cPos, oldHolder.getLevel(), world, this.lightingProvider, this.chunkTaskPrioritySystem, (ChunkHolder.PlayersWatchingChunkProvider) this);
|
||||
((ChunkHolderInterface) newHolder).setDefaultProtoChunk(cPos, this.mainThreadExecutor, world);
|
||||
this.currentChunkHolders.put(pos, newHolder);
|
||||
|
||||
((ChunkTicketManagerInterface) this.ticketManager).replaceHolder(oldHolder, newHolder);
|
||||
@@ -391,7 +401,7 @@ public abstract class ThreadedAnvilChunkStorage_scarpetChunkCreationMixin implem
|
||||
// Remove light for affected neighbors
|
||||
|
||||
for (final Chunk chunk : affectedNeighbors)
|
||||
((ServerLightingProviderInterface) this.serverLightingProvider).removeLightData(chunk);
|
||||
((ServerLightingProviderInterface) this.lightingProvider).removeLightData(chunk);
|
||||
|
||||
// Schedule relighting of neighbors
|
||||
|
||||
@@ -408,7 +418,7 @@ public abstract class ThreadedAnvilChunkStorage_scarpetChunkCreationMixin implem
|
||||
|
||||
lightFutures.add(this.getRegion (pos, 1, (pos_) -> ChunkStatus.LIGHT).thenCompose(
|
||||
either -> either.map(
|
||||
list -> ((ServerLightingProviderInterface) this.serverLightingProvider).relight(chunk),
|
||||
list -> ((ServerLightingProviderInterface) this.lightingProvider).relight(chunk),
|
||||
unloaded -> {
|
||||
this.releaseRelightTicket(pos);
|
||||
return CompletableFuture.completedFuture(null);
|
||||
|
||||
@@ -33,9 +33,9 @@ public abstract class ThrownEntityMixin extends Entity
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove()
|
||||
public void remove(Entity.RemovalReason arg)
|
||||
{
|
||||
super.remove();
|
||||
super.remove(arg);
|
||||
if (LoggerRegistry.__projectiles && logHelper != null)
|
||||
logHelper.onFinish();
|
||||
}
|
||||
|
||||
Loaded 100 of 173 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user