This commit is contained in:
gnembon committed 2025-04-30 14:11:25 +02:00
1 parent d45f5ba05a
commit ef6ebac7fb
11 files changed
+88 -43

No files matched your search

@@ -15,6 +15,10 @@ import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.piston.PistonMovingBlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.storage.TagValueInput;
import net.minecraft.world.level.storage.TagValueOutput;
import net.minecraft.world.level.storage.ValueInput;
import net.minecraft.world.level.storage.ValueOutput;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
@@ -134,25 +138,25 @@ public abstract class PistonMovingBlockEntity_movableBEMixin extends BlockEntity
}
@Inject(method = "loadAdditional", at = @At(value = "TAIL"))
private void onFromTag(CompoundTag NbtCompound_1, HolderLookup.Provider registries, CallbackInfo ci)
private void onFromTag(ValueInput valueInput, CallbackInfo ci)
{
if (CarpetSettings.movableBlockEntities && NbtCompound_1.contains("carriedTileEntityCM"))
{
if (this.movedState.getBlock() instanceof EntityBlock)
this.carriedBlockEntity = ((EntityBlock) (this.movedState.getBlock())).newBlockEntity(worldPosition, movedState);// this.world);
if (carriedBlockEntity != null) //Can actually be null, as BlockPistonMoving.createNewTileEntity(...) returns null
this.carriedBlockEntity.loadWithComponents(NbtCompound_1.getCompound("carriedTileEntityCM").orElseThrow(), registries);
setCarriedBlockEntity(carriedBlockEntity);
}
if (CarpetSettings.movableBlockEntities)
valueInput.child("carriedTileEntityCM").ifPresent(tag -> {
if (this.movedState.getBlock() instanceof EntityBlock)
this.carriedBlockEntity = ((EntityBlock) (this.movedState.getBlock())).newBlockEntity(worldPosition, movedState);// this.world);
if (carriedBlockEntity != null) //Can actually be null, as BlockPistonMoving.createNewTileEntity(...) returns null
this.carriedBlockEntity.loadWithComponents(tag);
setCarriedBlockEntity(carriedBlockEntity);
});
}
@Inject(method = "saveAdditional", at = @At(value = "RETURN", shift = At.Shift.BEFORE))
private void onToTag(CompoundTag NbtCompound_1, HolderLookup.Provider registries, CallbackInfo ci)
private void onToTag(ValueOutput valueOutput, CallbackInfo ci)
{
if (CarpetSettings.movableBlockEntities && this.carriedBlockEntity != null)
if (CarpetSettings.movableBlockEntities && this.carriedBlockEntity != null && valueOutput instanceof TagValueOutput output)
{
//Leave name "carriedTileEntityCM" instead of "carriedBlockEntityCM" for upgrade compatibility with 1.13.2 movable TE
NbtCompound_1.put("carriedTileEntityCM", this.carriedBlockEntity.saveWithoutMetadata(registries));
this.carriedBlockEntity.saveWithoutMetadata(output.child("carriedTileEntityCM"));
}
}
}
@@ -10,6 +10,8 @@ import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.network.CommonListenerCookie;
import net.minecraft.server.network.ServerGamePacketListenerImpl;
import net.minecraft.server.players.PlayerList;
import net.minecraft.util.ProblemReporter;
import net.minecraft.world.level.storage.ValueInput;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@@ -20,6 +22,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import carpet.patches.NetHandlerPlayServerFake;
import carpet.patches.EntityPlayerMPFake;
import java.util.Optional;
@Mixin(PlayerList.class)
public abstract class PlayerList_fakePlayersMixin
{
@@ -28,11 +32,11 @@ public abstract class PlayerList_fakePlayersMixin
private MinecraftServer server;
@Inject(method = "load", at = @At(value = "RETURN", shift = At.Shift.BEFORE))
private void fixStartingPos(ServerPlayer serverPlayerEntity_1, CallbackInfoReturnable<CompoundTag> cir)
private void fixStartingPos(ServerPlayer serverPlayer, ProblemReporter problemReporter, CallbackInfoReturnable<Optional<ValueInput>> cir)
{
if (serverPlayerEntity_1 instanceof EntityPlayerMPFake)
if (serverPlayer instanceof EntityPlayerMPFake)
{
((EntityPlayerMPFake) serverPlayerEntity_1).fixStartingPosition.run();
((EntityPlayerMPFake) serverPlayer).fixStartingPosition.run();
}
}