Skip to content

Commit

Permalink
1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
extclp committed Jun 16, 2024
2 parents 717f540 + e8ea849 commit ffa38ec
Show file tree
Hide file tree
Showing 32 changed files with 351 additions and 280 deletions.
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ For core carpet functionality, this is the right place. Check available download

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!

## auto crafting table

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

## scarpet app store

If you want to browse or contribute to the scarpet app store check available apps, go [here](https://github.com/gnembon/scarpet), its free!
Expand Down
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check https://fabricmc.net/develop/
minecraft_version=24w18a
minecraft_version=1.21
loader_version=0.15.11
jsr305_version=3.0.2
fabric_version=0.97.8+1.20.6
fabric_version=0.99.2+1.21

# Mod Properties
mod_version = 1.4.142
mod_version = 1.4.147
maven_group = carpet
archives_base_name = fabric-carpet

# Release Action properties for Curseforge and Snapshots
# The Curseforge versions "names" or ids for the main branch (comma separated: 1.16.4,1.16.5)
# This is needed because CF uses too vague names for prereleases and release candidates
# Can also be the version ID directly coming from https://minecraft.curseforge.com/api/game/versions?token=[API_TOKEN]
release-curse-versions = Minecraft 1.21:1.21-Snapshot
release-curse-versions = Minecraft 1.21:1.21
# Whether or not to build another branch on release
release-extra-branch = false
# The name of the second branch to release
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/carpet/CarpetSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import carpet.utils.CommandHelper;
import carpet.utils.Messenger;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.SemanticVersion;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
Expand Down Expand Up @@ -48,7 +49,10 @@
public class CarpetSettings
{
public static final String carpetVersion = FabricLoader.getInstance().getModContainer("carpet").orElseThrow().getMetadata().getVersion().toString();
public static final String releaseTarget = "1.20.5";
public static final int [] releaseTarget = {
((SemanticVersion)FabricLoader.getInstance().getModContainer("minecraft").orElseThrow().getMetadata().getVersion()).getVersionComponent(1),
((SemanticVersion)FabricLoader.getInstance().getModContainer("minecraft").orElseThrow().getMetadata().getVersion()).getVersionComponent(2)
};
public static final Logger LOG = LoggerFactory.getLogger("carpet");
public static final ThreadLocal<Boolean> skipGenerationChecks = ThreadLocal.withInitial(() -> false);
public static final ThreadLocal<Boolean> impendingFillSkipUpdates = ThreadLocal.withInitial(() -> false);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/carpet/fakes/ChunkHolderInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@

public interface ChunkHolderInterface
{
CompletableFuture<ChunkResult<ChunkAccess>> setDefaultProtoChunk(ChunkPos chpos, BlockableEventLoop<Runnable> executor, ServerLevel world);
//CompletableFuture<ChunkResult<ChunkAccess>> setDefaultProtoChunk(ChunkPos chpos, BlockableEventLoop<Runnable> executor, ServerLevel world);
}
6 changes: 6 additions & 0 deletions src/main/java/carpet/fakes/PortalProcessorInterface.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package carpet.fakes;

public interface PortalProcessorInterface
{
void setPortalTime(int time);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

import java.util.List;
import java.util.Map;
import net.minecraft.server.level.ChunkHolder;
import net.minecraft.world.level.ChunkPos;

public interface ThreadedAnvilChunkStorageInterface
{
Map<String, Integer> regenerateChunkRegion(List<ChunkPos> requestedChunks);
//Map<String, Integer> regenerateChunkRegion(List<ChunkPos> requestedChunks);

void relightChunk(ChunkPos pos);
//void relightChunk(ChunkPos pos);

void releaseRelightTicket(ChunkPos pos);
//void releaseRelightTicket(ChunkPos pos);

//Iterable<ChunkHolder> getChunksCM();
}
4 changes: 2 additions & 2 deletions src/main/java/carpet/mixins/AbstractArrowMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public abstract class AbstractArrowMixin extends Entity
private TrajectoryLogHelper logHelper;
public AbstractArrowMixin(EntityType<?> entityType_1, Level world_1) { super(entityType_1, world_1); }

@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"))
private void addLogger(final EntityType entityType, final Level level, final ItemStack itemStack, final ItemStack weapon, final CallbackInfo ci)
@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"))
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)
{
if (LoggerRegistry.__projectiles && !level.isClientSide)
logHelper = new TrajectoryLogHelper("projectiles");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@
@Mixin(ChunkHolder.class)
public abstract class ChunkHolder_scarpetChunkCreationMixin implements ChunkHolderInterface
{
@Shadow protected abstract void updateChunkToSave(CompletableFuture<? extends ChunkResult<? extends ChunkAccess>> newChunkFuture, String type);
//@Shadow protected abstract void updateChunkToSave(CompletableFuture<? extends ChunkResult<? extends ChunkAccess>> newChunkFuture, String type);

@Shadow @Final private AtomicReferenceArray<CompletableFuture<ChunkResult<ChunkAccess>>> futures;
//@Shadow @Final private AtomicReferenceArray<CompletableFuture<ChunkResult<ChunkAccess>>> futures;

/*
@Override
public CompletableFuture<ChunkResult<ChunkAccess>> setDefaultProtoChunk(ChunkPos chpos, BlockableEventLoop<Runnable> executor, ServerLevel world)
{
Expand All @@ -37,4 +38,5 @@ public CompletableFuture<ChunkResult<ChunkAccess>> setDefaultProtoChunk(ChunkPos
futures.set(i, completableFuture2);
return completableFuture2;
}
*/
}
39 changes: 29 additions & 10 deletions src/main/java/carpet/mixins/ChunkMap_scarpetChunkCreationMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.TickTask;
import net.minecraft.server.level.ChunkHolder;
import net.minecraft.server.level.ChunkLevel;
import net.minecraft.server.level.ChunkMap;
import net.minecraft.server.level.ChunkMap.DistanceManager;
import net.minecraft.server.level.ChunkResult;
Expand Down Expand Up @@ -64,10 +65,6 @@ public abstract class ChunkMap_scarpetChunkCreationMixin implements ThreadedAnvi
@Final
private ServerLevel level;

@Shadow
@Final
private LongSet entitiesInLevel;

@Shadow
@Final
private Long2ObjectLinkedOpenHashMap<ChunkHolder> updatingChunkMap;
Expand Down Expand Up @@ -111,6 +108,10 @@ public abstract class ChunkMap_scarpetChunkCreationMixin implements ThreadedAnvi

// in protoChunkToFullChunk
// fancier version of the one below, ensuring that the event is triggered when the chunk is actually loaded.

/*
@Inject(method = "method_17227", at = @At("HEAD"), remap = false)
private void onChunkGeneratedStart(ChunkHolder chunkHolder, ChunkAccess chunkAccess, CallbackInfoReturnable<ChunkAccess> cir)
{
Expand Down Expand Up @@ -146,6 +147,8 @@ private void onChunkGeneratedEnd(ChunkHolder chunkHolder, ChunkAccess chunk, Cal
}
}
*/

/* simple but a version that doesn't guarantee that the chunk is actually loaded
@Inject(method = "convertToFullChunk", at = @At("HEAD"))
private void onChunkGeneratedEnd(ChunkHolder chunkHolder, CallbackInfoReturnable<CompletableFuture<ChunkResult<ChunkAccess>>> cir)
Expand All @@ -167,7 +170,7 @@ private void onChunkGeneratedEnd(ChunkHolder chunkHolder, CallbackInfoReturnable
@Unique
private void addTicket(ChunkPos pos, ChunkStatus status)
{ // UNKNOWN
this.distanceManager.addTicket(TicketType.UNKNOWN, pos, 33 + ChunkStatus.getDistance(status), pos);
this.distanceManager.addTicket(TicketType.UNKNOWN, pos, 33 + ChunkLevel.byStatus(status), pos);
}

@Unique
Expand All @@ -176,6 +179,8 @@ private void addTicket(ChunkPos pos)
this.addTicket(pos, ChunkStatus.EMPTY);
}


/*
@Unique
private void addRelightTicket(ChunkPos pos)
{
Expand All @@ -190,7 +195,7 @@ public void releaseRelightTicket(ChunkPos pos)
() -> "release relight ticket " + pos
));
}

*/
@Unique
private void tickTicketManager()
{
Expand All @@ -214,6 +219,8 @@ private Set<ChunkPos> getExistingChunks(Set<ChunkPos> requestedChunks)
return ret;
}


/*
@Unique
private Set<ChunkPos> loadExistingChunksFromDisk(Set<ChunkPos> requestedChunks)
{
Expand Down Expand Up @@ -329,6 +336,8 @@ public void relightChunk(ChunkPos pos)
this.waitFor(lightFuture);
}
/*
@Override
public Map<String, Integer> regenerateChunkRegion(List<ChunkPos> requestedChunksList)
{
Expand Down Expand Up @@ -385,7 +394,7 @@ public Map<String, Integer> regenerateChunkRegion(List<ChunkPos> requestedChunks
{
ChunkAccess chunk = this.getCurrentChunk(pos);
if (chunk.getStatus().isOrAfter(ChunkStatus.LIGHT.getParent()))
if (chunk.getPersistedStatus().isOrAfter(ChunkStatus.LIGHT.getParent()))
{
affectedNeighbors.add(chunk);
}
Expand All @@ -399,7 +408,7 @@ public Map<String, Integer> regenerateChunkRegion(List<ChunkPos> requestedChunks
// remove entities
long longPos = pos.toLong();
if (this.entitiesInLevel.contains(longPos) && chunk instanceof LevelChunk)
if (chunk instanceof LevelChunk)
{
((SimpleEntityLookupInterface<Entity>) ((ServerWorldInterface) level).getEntityLookupCMPublic()).getChunkEntities(pos).forEach(entity -> {
if (!(entity instanceof Player))
Expand All @@ -415,7 +424,7 @@ public Map<String, Integer> regenerateChunkRegion(List<ChunkPos> requestedChunks
((LevelChunk) chunk).setLoaded(false);
}
if (this.entitiesInLevel.remove(pos.toLong()) && chunk instanceof LevelChunk)
if (chunk instanceof LevelChunk)
{
this.level.unload((LevelChunk) chunk); // block entities only
}
Expand Down Expand Up @@ -450,7 +459,7 @@ public Map<String, Integer> regenerateChunkRegion(List<ChunkPos> requestedChunks
// Also, this is needed to ensure chunks are saved to disk
Map<ChunkPos, ChunkStatus> targetGenerationStatus = affectedChunks.stream().collect(
Collectors.toMap(ChunkAccess::getPos, ChunkAccess::getStatus)
Collectors.toMap(ChunkAccess::getPos, ChunkAccess::getPersistedStatus)
);
for (Entry<ChunkPos, ChunkStatus> entry : targetGenerationStatus.entrySet())
Expand Down Expand Up @@ -547,4 +556,14 @@ public Map<String, Integer> regenerateChunkRegion(List<ChunkPos> requestedChunks
return report;
}
@Override
public Iterable<ChunkHolder> getChunksCM()
{
return getChunks();
}
*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import carpet.network.CarpetClient;
import net.minecraft.client.multiplayer.ClientCommonPacketListenerImpl;
import net.minecraft.network.DisconnectionDetails;
import net.minecraft.network.chat.Component;
import net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket;
import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -13,7 +14,7 @@
public class ClientCommonPacketListenerImpl_customPacketMixin
{
@Inject(method = "onDisconnect", at = @At("HEAD"))
private void onCMDisconnected(Component reason, CallbackInfo ci)
private void onCMDisconnected(DisconnectionDetails reason, CallbackInfo ci)
{
CarpetClient.disconnect();
}
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/carpet/mixins/Entity_scarpetEventsMixin.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package carpet.mixins;

import carpet.fakes.EntityInterface;
import carpet.fakes.PortalProcessorInterface;
import carpet.script.EntityEventsGroup;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.PortalProcessor;
import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -15,13 +18,13 @@ public abstract class Entity_scarpetEventsMixin implements EntityInterface
{
//@Shadow public boolean removed;

@Shadow protected int portalTime;
@Shadow private int portalCooldown;

@Shadow public abstract boolean isRemoved();

@Shadow private Vec3 position, deltaMovement;

@Shadow @Nullable public PortalProcessor portalProcess;
private boolean permanentVehicle;

private final EntityEventsGroup events = new EntityEventsGroup((Entity) (Object)this);
Expand Down Expand Up @@ -61,13 +64,13 @@ public void setPublicNetherPortalCooldown(int what)
@Override
public int getPortalTimer()
{
return portalTime;
return portalProcess.getPortalTime();
}

@Override
public void setPortalTimer(int amount)
{
portalTime = amount;
((PortalProcessorInterface)portalProcess).setPortalTime(amount);
}

@Inject(method = "tick", at = @At("HEAD"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import carpet.script.utils.ShapesRenderer;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Camera;
import net.minecraft.client.DeltaTracker;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.renderer.LevelRenderer;
Expand Down Expand Up @@ -36,14 +37,14 @@ private void addRenderers(Minecraft minecraft, EntityRenderDispatcher entityRend
//target = "Lnet/minecraft/client/render/BufferBuilderStorage;getEntityVertexConsumers()Lnet/minecraft/client/render/VertexConsumerProvider$Immediate;", shift = At.Shift.AFTER
//target = "Lnet/minecraft/client/render/WorldRenderer;renderChunkDebugInfo(Lnet/minecraft/client/render/Camera;)V", shift = At.Shift.AFTER // before return
))
private void renderScarpetThings(float tickDelta, long limitTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightTexture lightmapTextureManager, Matrix4f modelViewMatrix, Matrix4f matrix4f, CallbackInfo ci)
private void renderScarpetThings(final DeltaTracker deltaTracker, final boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightTexture lightmapTextureManager, Matrix4f modelViewMatrix, Matrix4f matrix4f, CallbackInfo ci)
{
// in normal circumstances we want to render shapes at the very end so it appears correctly behind stuff.
// we might actually not need to play with render hooks here.
//if (!FabricAPIHooks.WORLD_RENDER_EVENTS && CarpetClient.shapes != null )
if (CarpetClient.shapes != null)
{
CarpetClient.shapes.render(modelViewMatrix, camera, tickDelta);
CarpetClient.shapes.render(modelViewMatrix, camera, deltaTracker.getGameTimeDeltaPartialTick(false));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package carpet.mixins;

import carpet.CarpetSettings;
import carpet.patches.EntityPlayerMPFake;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
Expand Down Expand Up @@ -47,4 +48,12 @@ private void flyingAltSpeed(float slipperiness, CallbackInfoReturnable<Float> ci
cir.setReturnValue( getFlyingSpeed() * (float)CarpetSettings.creativeFlySpeed);
}
}

@Inject(method = "canUsePortal", at = @At("HEAD"), cancellable = true)
private void canChangeDimensions(CallbackInfoReturnable<Boolean> cir)
{
if (CarpetSettings.isCreativeFlying(this)) {
cir.setReturnValue(false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.players.PlayerList;
import net.minecraft.world.entity.Entity;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
Expand All @@ -24,9 +25,9 @@ public class PlayerList_scarpetEventsMixin
@Shadow @Final private MinecraftServer server;

@Inject(method = "respawn", at = @At("HEAD"))
private void onRespawn(ServerPlayer player, boolean olive, CallbackInfoReturnable<ServerPlayer> cir)
private void onResp(ServerPlayer serverPlayer, boolean olive, Entity.RemovalReason removalReason, CallbackInfoReturnable<ServerPlayer> cir)
{
PLAYER_RESPAWNS.onPlayerEvent(player);
PLAYER_RESPAWNS.onPlayerEvent(serverPlayer);
}

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

0 comments on commit ffa38ec

Please sign in to comment.