Skip to content

Commit ffa38ec

Browse files
committed
1.21
2 parents 717f540 + e8ea849 commit ffa38ec

32 files changed

+351
-280
lines changed

README.md

-4
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ For core carpet functionality, this is the right place. Check available download
3030

3131
Check [carpet-extra](https://github.com/gnembon/carpet-extra/) add-on mod for more whacky and crazy features, including autocrafting, block-placing dispensers, and even chicken-shearing!
3232

33-
## auto crafting table
34-
35-
Due to compatibility issues with vanilla and other mods, download [auto crafting table](https://github.com/gnembon/carpet-autoCraftingTable/releases) by Skyrising as a separate add-on to carpet
36-
3733
## scarpet app store
3834

3935
If you want to browse or contribute to the scarpet app store check available apps, go [here](https://github.com/gnembon/scarpet), its free!

gradle.properties

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@ org.gradle.jvmargs=-Xmx1G
33

44
# Fabric Properties
55
# check https://fabricmc.net/develop/
6-
minecraft_version=24w18a
6+
minecraft_version=1.21
77
loader_version=0.15.11
88
jsr305_version=3.0.2
9-
fabric_version=0.97.8+1.20.6
9+
fabric_version=0.99.2+1.21
1010

1111
# Mod Properties
12-
mod_version = 1.4.142
12+
mod_version = 1.4.147
1313
maven_group = carpet
1414
archives_base_name = fabric-carpet
1515

1616
# Release Action properties for Curseforge and Snapshots
1717
# The Curseforge versions "names" or ids for the main branch (comma separated: 1.16.4,1.16.5)
1818
# This is needed because CF uses too vague names for prereleases and release candidates
1919
# Can also be the version ID directly coming from https://minecraft.curseforge.com/api/game/versions?token=[API_TOKEN]
20-
release-curse-versions = Minecraft 1.21:1.21-Snapshot
20+
release-curse-versions = Minecraft 1.21:1.21
2121
# Whether or not to build another branch on release
2222
release-extra-branch = false
2323
# The name of the second branch to release

src/main/java/carpet/CarpetSettings.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import carpet.utils.CommandHelper;
1111
import carpet.utils.Messenger;
1212
import net.fabricmc.loader.api.FabricLoader;
13+
import net.fabricmc.loader.api.SemanticVersion;
1314
import net.minecraft.commands.CommandSourceStack;
1415
import net.minecraft.core.registries.Registries;
1516
import net.minecraft.resources.ResourceLocation;
@@ -48,7 +49,10 @@
4849
public class CarpetSettings
4950
{
5051
public static final String carpetVersion = FabricLoader.getInstance().getModContainer("carpet").orElseThrow().getMetadata().getVersion().toString();
51-
public static final String releaseTarget = "1.20.5";
52+
public static final int [] releaseTarget = {
53+
((SemanticVersion)FabricLoader.getInstance().getModContainer("minecraft").orElseThrow().getMetadata().getVersion()).getVersionComponent(1),
54+
((SemanticVersion)FabricLoader.getInstance().getModContainer("minecraft").orElseThrow().getMetadata().getVersion()).getVersionComponent(2)
55+
};
5256
public static final Logger LOG = LoggerFactory.getLogger("carpet");
5357
public static final ThreadLocal<Boolean> skipGenerationChecks = ThreadLocal.withInitial(() -> false);
5458
public static final ThreadLocal<Boolean> impendingFillSkipUpdates = ThreadLocal.withInitial(() -> false);

src/main/java/carpet/fakes/ChunkHolderInterface.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99

1010
public interface ChunkHolderInterface
1111
{
12-
CompletableFuture<ChunkResult<ChunkAccess>> setDefaultProtoChunk(ChunkPos chpos, BlockableEventLoop<Runnable> executor, ServerLevel world);
12+
//CompletableFuture<ChunkResult<ChunkAccess>> setDefaultProtoChunk(ChunkPos chpos, BlockableEventLoop<Runnable> executor, ServerLevel world);
1313
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package carpet.fakes;
2+
3+
public interface PortalProcessorInterface
4+
{
5+
void setPortalTime(int time);
6+
}

src/main/java/carpet/fakes/ThreadedAnvilChunkStorageInterface.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22

33
import java.util.List;
44
import java.util.Map;
5+
import net.minecraft.server.level.ChunkHolder;
56
import net.minecraft.world.level.ChunkPos;
67

78
public interface ThreadedAnvilChunkStorageInterface
89
{
9-
Map<String, Integer> regenerateChunkRegion(List<ChunkPos> requestedChunks);
10+
//Map<String, Integer> regenerateChunkRegion(List<ChunkPos> requestedChunks);
1011

11-
void relightChunk(ChunkPos pos);
12+
//void relightChunk(ChunkPos pos);
1213

13-
void releaseRelightTicket(ChunkPos pos);
14+
//void releaseRelightTicket(ChunkPos pos);
15+
16+
//Iterable<ChunkHolder> getChunksCM();
1417
}

src/main/java/carpet/mixins/AbstractArrowMixin.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ public abstract class AbstractArrowMixin extends Entity
2020
private TrajectoryLogHelper logHelper;
2121
public AbstractArrowMixin(EntityType<?> entityType_1, Level world_1) { super(entityType_1, world_1); }
2222

23-
@Inject(method = "<init>(Lnet/minecraft/world/entity/EntityType;Lnet/minecraft/world/level/Level;Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/item/ItemStack;)V", at = @At("RETURN"))
24-
private void addLogger(final EntityType entityType, final Level level, final ItemStack itemStack, final ItemStack weapon, final CallbackInfo ci)
23+
@Inject(method = "<init>(Lnet/minecraft/world/entity/EntityType;DDDLnet/minecraft/world/level/Level;Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/item/ItemStack;)V", at = @At("RETURN"))
24+
private void addLogger(final EntityType entityType, final double x, final double y, final double z, final Level level, final ItemStack itemStack, final ItemStack weapon, final CallbackInfo ci)
2525
{
2626
if (LoggerRegistry.__projectiles && !level.isClientSide)
2727
logHelper = new TrajectoryLogHelper("projectiles");

src/main/java/carpet/mixins/ChunkHolder_scarpetChunkCreationMixin.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@
2121
@Mixin(ChunkHolder.class)
2222
public abstract class ChunkHolder_scarpetChunkCreationMixin implements ChunkHolderInterface
2323
{
24-
@Shadow protected abstract void updateChunkToSave(CompletableFuture<? extends ChunkResult<? extends ChunkAccess>> newChunkFuture, String type);
24+
//@Shadow protected abstract void updateChunkToSave(CompletableFuture<? extends ChunkResult<? extends ChunkAccess>> newChunkFuture, String type);
2525

26-
@Shadow @Final private AtomicReferenceArray<CompletableFuture<ChunkResult<ChunkAccess>>> futures;
26+
//@Shadow @Final private AtomicReferenceArray<CompletableFuture<ChunkResult<ChunkAccess>>> futures;
2727

28+
/*
2829
@Override
2930
public CompletableFuture<ChunkResult<ChunkAccess>> setDefaultProtoChunk(ChunkPos chpos, BlockableEventLoop<Runnable> executor, ServerLevel world)
3031
{
@@ -37,4 +38,5 @@ public CompletableFuture<ChunkResult<ChunkAccess>> setDefaultProtoChunk(ChunkPos
3738
futures.set(i, completableFuture2);
3839
return completableFuture2;
3940
}
41+
*/
4042
}

src/main/java/carpet/mixins/ChunkMap_scarpetChunkCreationMixin.java

+29-10
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import net.minecraft.server.MinecraftServer;
2020
import net.minecraft.server.TickTask;
2121
import net.minecraft.server.level.ChunkHolder;
22+
import net.minecraft.server.level.ChunkLevel;
2223
import net.minecraft.server.level.ChunkMap;
2324
import net.minecraft.server.level.ChunkMap.DistanceManager;
2425
import net.minecraft.server.level.ChunkResult;
@@ -64,10 +65,6 @@ public abstract class ChunkMap_scarpetChunkCreationMixin implements ThreadedAnvi
6465
@Final
6566
private ServerLevel level;
6667

67-
@Shadow
68-
@Final
69-
private LongSet entitiesInLevel;
70-
7168
@Shadow
7269
@Final
7370
private Long2ObjectLinkedOpenHashMap<ChunkHolder> updatingChunkMap;
@@ -111,6 +108,10 @@ public abstract class ChunkMap_scarpetChunkCreationMixin implements ThreadedAnvi
111108

112109
// in protoChunkToFullChunk
113110
// fancier version of the one below, ensuring that the event is triggered when the chunk is actually loaded.
111+
112+
/*
113+
114+
114115
@Inject(method = "method_17227", at = @At("HEAD"), remap = false)
115116
private void onChunkGeneratedStart(ChunkHolder chunkHolder, ChunkAccess chunkAccess, CallbackInfoReturnable<ChunkAccess> cir)
116117
{
@@ -146,6 +147,8 @@ private void onChunkGeneratedEnd(ChunkHolder chunkHolder, ChunkAccess chunk, Cal
146147
}
147148
}
148149
150+
*/
151+
149152
/* simple but a version that doesn't guarantee that the chunk is actually loaded
150153
@Inject(method = "convertToFullChunk", at = @At("HEAD"))
151154
private void onChunkGeneratedEnd(ChunkHolder chunkHolder, CallbackInfoReturnable<CompletableFuture<ChunkResult<ChunkAccess>>> cir)
@@ -167,7 +170,7 @@ private void onChunkGeneratedEnd(ChunkHolder chunkHolder, CallbackInfoReturnable
167170
@Unique
168171
private void addTicket(ChunkPos pos, ChunkStatus status)
169172
{ // UNKNOWN
170-
this.distanceManager.addTicket(TicketType.UNKNOWN, pos, 33 + ChunkStatus.getDistance(status), pos);
173+
this.distanceManager.addTicket(TicketType.UNKNOWN, pos, 33 + ChunkLevel.byStatus(status), pos);
171174
}
172175

173176
@Unique
@@ -176,6 +179,8 @@ private void addTicket(ChunkPos pos)
176179
this.addTicket(pos, ChunkStatus.EMPTY);
177180
}
178181

182+
183+
/*
179184
@Unique
180185
private void addRelightTicket(ChunkPos pos)
181186
{
@@ -190,7 +195,7 @@ public void releaseRelightTicket(ChunkPos pos)
190195
() -> "release relight ticket " + pos
191196
));
192197
}
193-
198+
*/
194199
@Unique
195200
private void tickTicketManager()
196201
{
@@ -214,6 +219,8 @@ private Set<ChunkPos> getExistingChunks(Set<ChunkPos> requestedChunks)
214219
return ret;
215220
}
216221

222+
223+
/*
217224
@Unique
218225
private Set<ChunkPos> loadExistingChunksFromDisk(Set<ChunkPos> requestedChunks)
219226
{
@@ -329,6 +336,8 @@ public void relightChunk(ChunkPos pos)
329336
this.waitFor(lightFuture);
330337
}
331338
339+
/*
340+
332341
@Override
333342
public Map<String, Integer> regenerateChunkRegion(List<ChunkPos> requestedChunksList)
334343
{
@@ -385,7 +394,7 @@ public Map<String, Integer> regenerateChunkRegion(List<ChunkPos> requestedChunks
385394
{
386395
ChunkAccess chunk = this.getCurrentChunk(pos);
387396
388-
if (chunk.getStatus().isOrAfter(ChunkStatus.LIGHT.getParent()))
397+
if (chunk.getPersistedStatus().isOrAfter(ChunkStatus.LIGHT.getParent()))
389398
{
390399
affectedNeighbors.add(chunk);
391400
}
@@ -399,7 +408,7 @@ public Map<String, Integer> regenerateChunkRegion(List<ChunkPos> requestedChunks
399408
400409
// remove entities
401410
long longPos = pos.toLong();
402-
if (this.entitiesInLevel.contains(longPos) && chunk instanceof LevelChunk)
411+
if (chunk instanceof LevelChunk)
403412
{
404413
((SimpleEntityLookupInterface<Entity>) ((ServerWorldInterface) level).getEntityLookupCMPublic()).getChunkEntities(pos).forEach(entity -> {
405414
if (!(entity instanceof Player))
@@ -415,7 +424,7 @@ public Map<String, Integer> regenerateChunkRegion(List<ChunkPos> requestedChunks
415424
((LevelChunk) chunk).setLoaded(false);
416425
}
417426
418-
if (this.entitiesInLevel.remove(pos.toLong()) && chunk instanceof LevelChunk)
427+
if (chunk instanceof LevelChunk)
419428
{
420429
this.level.unload((LevelChunk) chunk); // block entities only
421430
}
@@ -450,7 +459,7 @@ public Map<String, Integer> regenerateChunkRegion(List<ChunkPos> requestedChunks
450459
// Also, this is needed to ensure chunks are saved to disk
451460
452461
Map<ChunkPos, ChunkStatus> targetGenerationStatus = affectedChunks.stream().collect(
453-
Collectors.toMap(ChunkAccess::getPos, ChunkAccess::getStatus)
462+
Collectors.toMap(ChunkAccess::getPos, ChunkAccess::getPersistedStatus)
454463
);
455464
456465
for (Entry<ChunkPos, ChunkStatus> entry : targetGenerationStatus.entrySet())
@@ -547,4 +556,14 @@ public Map<String, Integer> regenerateChunkRegion(List<ChunkPos> requestedChunks
547556
548557
return report;
549558
}
559+
560+
561+
562+
@Override
563+
public Iterable<ChunkHolder> getChunksCM()
564+
{
565+
return getChunks();
566+
}
567+
568+
*/
550569
}

src/main/java/carpet/mixins/ClientCommonPacketListenerImpl_customPacketMixin.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import carpet.network.CarpetClient;
44
import net.minecraft.client.multiplayer.ClientCommonPacketListenerImpl;
5+
import net.minecraft.network.DisconnectionDetails;
56
import net.minecraft.network.chat.Component;
67
import net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket;
78
import org.spongepowered.asm.mixin.Mixin;
@@ -13,7 +14,7 @@
1314
public class ClientCommonPacketListenerImpl_customPacketMixin
1415
{
1516
@Inject(method = "onDisconnect", at = @At("HEAD"))
16-
private void onCMDisconnected(Component reason, CallbackInfo ci)
17+
private void onCMDisconnected(DisconnectionDetails reason, CallbackInfo ci)
1718
{
1819
CarpetClient.disconnect();
1920
}

src/main/java/carpet/mixins/Entity_scarpetEventsMixin.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
package carpet.mixins;
22

33
import carpet.fakes.EntityInterface;
4+
import carpet.fakes.PortalProcessorInterface;
45
import carpet.script.EntityEventsGroup;
56
import net.minecraft.world.entity.Entity;
7+
import net.minecraft.world.entity.PortalProcessor;
68
import net.minecraft.world.phys.Vec3;
9+
import org.jetbrains.annotations.Nullable;
710
import org.spongepowered.asm.mixin.Mixin;
811
import org.spongepowered.asm.mixin.Shadow;
912
import org.spongepowered.asm.mixin.injection.At;
@@ -15,13 +18,13 @@ public abstract class Entity_scarpetEventsMixin implements EntityInterface
1518
{
1619
//@Shadow public boolean removed;
1720

18-
@Shadow protected int portalTime;
1921
@Shadow private int portalCooldown;
2022

2123
@Shadow public abstract boolean isRemoved();
2224

2325
@Shadow private Vec3 position, deltaMovement;
2426

27+
@Shadow @Nullable public PortalProcessor portalProcess;
2528
private boolean permanentVehicle;
2629

2730
private final EntityEventsGroup events = new EntityEventsGroup((Entity) (Object)this);
@@ -61,13 +64,13 @@ public void setPublicNetherPortalCooldown(int what)
6164
@Override
6265
public int getPortalTimer()
6366
{
64-
return portalTime;
67+
return portalProcess.getPortalTime();
6568
}
6669

6770
@Override
6871
public void setPortalTimer(int amount)
6972
{
70-
portalTime = amount;
73+
((PortalProcessorInterface)portalProcess).setPortalTime(amount);
7174
}
7275

7376
@Inject(method = "tick", at = @At("HEAD"))

src/main/java/carpet/mixins/LevelRenderer_scarpetRenderMixin.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import carpet.script.utils.ShapesRenderer;
55
import com.mojang.blaze3d.vertex.PoseStack;
66
import net.minecraft.client.Camera;
7+
import net.minecraft.client.DeltaTracker;
78
import net.minecraft.client.Minecraft;
89
import net.minecraft.client.renderer.GameRenderer;
910
import net.minecraft.client.renderer.LevelRenderer;
@@ -36,14 +37,14 @@ private void addRenderers(Minecraft minecraft, EntityRenderDispatcher entityRend
3637
//target = "Lnet/minecraft/client/render/BufferBuilderStorage;getEntityVertexConsumers()Lnet/minecraft/client/render/VertexConsumerProvider$Immediate;", shift = At.Shift.AFTER
3738
//target = "Lnet/minecraft/client/render/WorldRenderer;renderChunkDebugInfo(Lnet/minecraft/client/render/Camera;)V", shift = At.Shift.AFTER // before return
3839
))
39-
private void renderScarpetThings(float tickDelta, long limitTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightTexture lightmapTextureManager, Matrix4f modelViewMatrix, Matrix4f matrix4f, CallbackInfo ci)
40+
private void renderScarpetThings(final DeltaTracker deltaTracker, final boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightTexture lightmapTextureManager, Matrix4f modelViewMatrix, Matrix4f matrix4f, CallbackInfo ci)
4041
{
4142
// in normal circumstances we want to render shapes at the very end so it appears correctly behind stuff.
4243
// we might actually not need to play with render hooks here.
4344
//if (!FabricAPIHooks.WORLD_RENDER_EVENTS && CarpetClient.shapes != null )
4445
if (CarpetClient.shapes != null)
4546
{
46-
CarpetClient.shapes.render(modelViewMatrix, camera, tickDelta);
47+
CarpetClient.shapes.render(modelViewMatrix, camera, deltaTracker.getGameTimeDeltaPartialTick(false));
4748
}
4849
}
4950
}

src/main/java/carpet/mixins/LivingEntity_creativeFlyMixin.java

+9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package carpet.mixins;
22

33
import carpet.CarpetSettings;
4+
import carpet.patches.EntityPlayerMPFake;
45
import net.minecraft.world.entity.Entity;
56
import net.minecraft.world.entity.EntityType;
67
import net.minecraft.world.entity.LivingEntity;
@@ -47,4 +48,12 @@ private void flyingAltSpeed(float slipperiness, CallbackInfoReturnable<Float> ci
4748
cir.setReturnValue( getFlyingSpeed() * (float)CarpetSettings.creativeFlySpeed);
4849
}
4950
}
51+
52+
@Inject(method = "canUsePortal", at = @At("HEAD"), cancellable = true)
53+
private void canChangeDimensions(CallbackInfoReturnable<Boolean> cir)
54+
{
55+
if (CarpetSettings.isCreativeFlying(this)) {
56+
cir.setReturnValue(false);
57+
}
58+
}
5059
}

src/main/java/carpet/mixins/PlayerList_scarpetEventsMixin.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import net.minecraft.server.MinecraftServer;
88
import net.minecraft.server.level.ServerPlayer;
99
import net.minecraft.server.players.PlayerList;
10+
import net.minecraft.world.entity.Entity;
1011
import org.spongepowered.asm.mixin.Final;
1112
import org.spongepowered.asm.mixin.Mixin;
1213
import org.spongepowered.asm.mixin.Shadow;
@@ -24,9 +25,9 @@ public class PlayerList_scarpetEventsMixin
2425
@Shadow @Final private MinecraftServer server;
2526

2627
@Inject(method = "respawn", at = @At("HEAD"))
27-
private void onRespawn(ServerPlayer player, boolean olive, CallbackInfoReturnable<ServerPlayer> cir)
28+
private void onResp(ServerPlayer serverPlayer, boolean olive, Entity.RemovalReason removalReason, CallbackInfoReturnable<ServerPlayer> cir)
2829
{
29-
PLAYER_RESPAWNS.onPlayerEvent(player);
30+
PLAYER_RESPAWNS.onPlayerEvent(serverPlayer);
3031
}
3132

3233
@Inject(method = "broadcastChatMessage(Lnet/minecraft/network/chat/PlayerChatMessage;Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/network/chat/ChatType$Bound;)V",
@@ -44,7 +45,7 @@ private void cancellableChatMessageEvent(PlayerChatMessage message, ServerPlayer
4445
value = "INVOKE",
4546
target = "Lnet/minecraft/server/level/ServerPlayer;initInventoryMenu()V"
4647
))
47-
private void invalidatePreviousInstance(ServerPlayer player, boolean alive, CallbackInfoReturnable<ServerPlayer> cir)
48+
private void invalidatePreviousInstance(ServerPlayer player, boolean alive, Entity.RemovalReason removalReason, CallbackInfoReturnable<ServerPlayer> cir)
4849
{
4950
((ServerPlayerInterface)player).invalidateEntityObjectReference();
5051
}

0 commit comments

Comments
 (0)