Skip to content

Commit 9e578e6

Browse files
committed
24w21a - broken shapes
1 parent 7a1e152 commit 9e578e6

18 files changed

+274
-235
lines changed

gradle.properties

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

44
# Fabric Properties
55
# check https://fabricmc.net/develop/
6-
minecraft_version=24w20a
6+
minecraft_version=24w21a
77
loader_version=0.15.11
88
jsr305_version=3.0.2
99
fabric_version=0.97.8+1.20.6
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/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/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 = "canChangeDimensions", 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
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package carpet.mixins;
2+
3+
import carpet.fakes.PortalProcessorInterface;
4+
import net.minecraft.world.entity.PortalProcessor;
5+
import org.spongepowered.asm.mixin.Mixin;
6+
import org.spongepowered.asm.mixin.Shadow;
7+
8+
@Mixin(PortalProcessor.class)
9+
public class PortalProcessor_scarpetMixin implements PortalProcessorInterface
10+
{
11+
12+
@Shadow private int portalTime;
13+
14+
@Override
15+
public void setPortalTime(int time)
16+
{
17+
portalTime = time;
18+
}
19+
}

src/main/java/carpet/mixins/ServerGamePacketListenerImpl_coreMixin.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import carpet.CarpetServer;
44
import carpet.fakes.ServerGamePacketListenerImplInterface;
55
import net.minecraft.network.Connection;
6+
import net.minecraft.network.DisconnectionDetails;
67
import net.minecraft.network.chat.Component;
78
import net.minecraft.server.MinecraftServer;
89
import net.minecraft.server.level.ServerPlayer;
@@ -26,8 +27,8 @@ public ServerGamePacketListenerImpl_coreMixin(final MinecraftServer minecraftSer
2627
}
2728

2829
@Inject(method = "onDisconnect", at = @At("HEAD"))
29-
private void onPlayerDisconnect(Component reason, CallbackInfo ci) {
30-
CarpetServer.onPlayerLoggedOut(this.player, reason);
30+
private void onPlayerDisconnect(DisconnectionDetails reason, CallbackInfo ci) {
31+
CarpetServer.onPlayerLoggedOut(this.player, reason.reason());
3132
}
3233

3334
@Override

src/main/java/carpet/mixins/ServerPlayer_scarpetEventMixin.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -97,20 +97,20 @@ private void setSneakingConditionally(ServerPlayer serverPlayerEntity, boolean s
9797
private ResourceKey<Level> previousDimension;
9898

9999
@Inject(method = "changeDimension", at = @At("HEAD"))
100-
private void logPreviousCoordinates(DimensionTransitionSupplier serverWorld, CallbackInfoReturnable<Entity> cir)
100+
private void logPreviousCoordinates(DimensionTransition serverWorld, CallbackInfoReturnable<Entity> cir)
101101
{
102102
previousLocation = position();
103103
previousDimension = level().dimension(); //dimension type
104104
}
105105

106106
@Inject(method = "changeDimension", at = @At("RETURN"))
107-
private void atChangeDimension(DimensionTransitionSupplier destinationP, CallbackInfoReturnable<Entity> cir)
107+
private void atChangeDimension(DimensionTransition destinationP, CallbackInfoReturnable<Entity> cir)
108108
{
109109
if (PLAYER_CHANGES_DIMENSION.isNeeded())
110110
{
111111
ServerPlayer player = (ServerPlayer) (Object)this;
112-
DimensionTransition destinationTransition = destinationP.get();
113-
ServerLevel destination = destinationTransition.newDimension();
112+
DimensionTransition destinationTransition = destinationP;
113+
ServerLevel destination = destinationTransition.newLevel();
114114
Vec3 to = null;
115115
if (!wonGame || previousDimension != Level.END || destination.dimension() != Level.OVERWORLD)
116116
{

src/main/java/carpet/mixins/TheEndGatewayBlockEntity_creativeNoClipMixin.java

+1-5
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,5 @@
1111
@Mixin(TheEndGatewayBlockEntity.class)
1212
public class TheEndGatewayBlockEntity_creativeNoClipMixin
1313
{
14-
@Inject(method = "canEntityTeleport", cancellable = true, at = @At("HEAD"))
15-
private static void checkFlyingCreative(Entity entity, CallbackInfoReturnable<Boolean> cir)
16-
{
17-
if (CarpetSettings.isCreativeFlying(entity)) cir.setReturnValue(false);
18-
}
14+
// removeme
1915
}

src/main/java/carpet/network/CarpetClient.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public void write(FriendlyByteBuf output)
4545
private static LocalPlayer clientPlayer = null;
4646
private static boolean isServerCarpet = false;
4747
public static String serverCarpetVersion;
48-
public static final ResourceLocation CARPET_CHANNEL = new ResourceLocation("carpet", "hello");
48+
public static final ResourceLocation CARPET_CHANNEL = ResourceLocation.fromNamespaceAndPath("carpet", "hello");
4949

5050
public static void gameJoined(LocalPlayer player)
5151
{

src/main/java/carpet/patches/EntityPlayerMPFake.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.mojang.authlib.GameProfile;
55
import net.minecraft.core.BlockPos;
66
import net.minecraft.core.UUIDUtil;
7+
import net.minecraft.network.DisconnectionDetails;
78
import net.minecraft.network.chat.Component;
89
import net.minecraft.network.chat.contents.TranslatableContents;
910
import net.minecraft.network.protocol.PacketFlow;
@@ -30,6 +31,7 @@
3031
import net.minecraft.world.level.Level;
3132
import net.minecraft.world.level.block.entity.SkullBlockEntity;
3233
import net.minecraft.world.level.block.state.BlockState;
34+
import net.minecraft.world.level.portal.DimensionTransition;
3335
import net.minecraft.world.phys.Vec3;
3436
import carpet.fakes.ServerPlayerInterface;
3537
import carpet.utils.Messenger;
@@ -147,10 +149,10 @@ public void kill(Component reason)
147149
shakeOff();
148150

149151
if (reason.getContents() instanceof TranslatableContents text && text.getKey().equals("multiplayer.disconnect.duplicate_login")) {
150-
this.connection.onDisconnect(reason);
152+
this.connection.onDisconnect(new DisconnectionDetails(reason));
151153
} else {
152154
this.server.tell(new TickTask(this.server.getTickCount(), () -> {
153-
this.connection.onDisconnect(reason);
155+
this.connection.onDisconnect(new DisconnectionDetails(reason));
154156
}));
155157
}
156158
}
@@ -213,7 +215,7 @@ protected void checkFallDamage(double y, boolean onGround, BlockState state, Blo
213215
}
214216

215217
@Override
216-
public Entity changeDimension(DimensionTransitionSupplier serverLevel)
218+
public Entity changeDimension(DimensionTransition serverLevel)
217219
{
218220
super.changeDimension(serverLevel);
219221
if (wonGame) {

src/main/java/carpet/script/command/CommandArgument.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,7 @@ protected void configure(Map<String, Value> config, CarpetScriptHost host) throw
890890
{
891891
throw error("Custom sting type requires options passed as a list" + " for custom type " + suffix);
892892
}
893-
validOptions = ((ListValue) optionsValue).getItems().stream().map(v -> new ResourceLocation(v.getString())).collect(Collectors.toSet());
893+
validOptions = ((ListValue) optionsValue).getItems().stream().map(v -> ResourceLocation.parse(v.getString())).collect(Collectors.toSet());
894894
}
895895
}
896896
}

src/main/java/carpet/script/utils/FeatureGenerator.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public static synchronized Boolean plop(String featureName, ServerLevel world, B
7575
{
7676
return custom.apply(world).plop(world, pos);
7777
}
78-
ResourceLocation id = new ResourceLocation(featureName);
78+
ResourceLocation id = ResourceLocation.parse(featureName);
7979
Structure structure = world.registryAccess().registryOrThrow(Registries.STRUCTURE).get(id);
8080
if (structure != null)
8181
{
@@ -129,7 +129,7 @@ public static synchronized Boolean plop(String featureName, ServerLevel world, B
129129
@Nullable
130130
public static Structure resolveConfiguredStructure(String name, ServerLevel world, BlockPos pos)
131131
{
132-
ResourceLocation id = new ResourceLocation(name);
132+
ResourceLocation id = ResourceLocation.parse(name);
133133
Structure configuredStructureFeature = world.registryAccess().registryOrThrow(Registries.STRUCTURE).get(id);
134134
if (configuredStructureFeature != null)
135135
{

src/main/java/carpet/script/utils/InputValidator.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public static ResourceLocation identifierOf(String string)
2323
{
2424
try
2525
{
26-
return new ResourceLocation(string);
26+
return ResourceLocation.parse(string);
2727
}
2828
catch (ResourceLocationException iie)
2929
{

src/main/java/carpet/script/utils/ShapeDispatcher.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ protected void init(Map<String, Value> options, RegistryAccess regs)
375375

376376
key = 0;
377377
followEntity = -1;
378-
shapeDimension = ResourceKey.create(Registries.DIMENSION, new ResourceLocation(options.get("dim").getString()));
378+
shapeDimension = ResourceKey.create(Registries.DIMENSION, ResourceLocation.parse(options.get("dim").getString()));
379379
if (options.containsKey("follow"))
380380
{
381381
followEntity = NumericValue.asNumber(options.getOrDefault("follow", optional.get("follow"))).getInt();

0 commit comments

Comments
 (0)