1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-12-14 20:20:30 +00:00

Update to latest Fabric

- Use Fabric FakePlayer class
 - Remove redundant explosion accessor
This commit is contained in:
Jonathan Coates 2023-05-04 18:47:22 +01:00
parent 34928257c6
commit 232c051526
No known key found for this signature in database
GPG Key ID: B9E431FF07C98D06
6 changed files with 7 additions and 316 deletions

View File

@ -7,8 +7,8 @@
# Minecraft # Minecraft
# MC version is specified in gradle.properties, as we need that in settings.gradle. # MC version is specified in gradle.properties, as we need that in settings.gradle.
# Remember to update corresponding versions in fabric.mod.json/mods.toml # Remember to update corresponding versions in fabric.mod.json/mods.toml
fabric-api = "0.78.0+1.19.4" fabric-api = "0.80.0+1.19.4"
fabric-loader = "0.14.17" fabric-loader = "0.14.19"
forge = "45.0.42" forge = "45.0.42"
forgeSpi = "6.0.0" forgeSpi = "6.0.0"
mixin = "0.8.5" mixin = "0.8.5"

View File

@ -1,19 +0,0 @@
// SPDX-FileCopyrightText: 2022 The CC: Tweaked Developers
//
// SPDX-License-Identifier: MPL-2.0
package dan200.computercraft.mixin;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.Explosion;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import javax.annotation.Nullable;
@Mixin(Explosion.class)
public interface ExplosionAccessor {
@Nullable
@Accessor("source")
Entity computercraft$getExploder();
}

View File

@ -6,7 +6,6 @@ package dan200.computercraft.shared.turtle.blocks;
import dan200.computercraft.annotations.ForgeOverride; import dan200.computercraft.annotations.ForgeOverride;
import dan200.computercraft.api.turtle.TurtleSide; import dan200.computercraft.api.turtle.TurtleSide;
import dan200.computercraft.mixin.ExplosionAccessor;
import dan200.computercraft.shared.computer.blocks.AbstractComputerBlock; import dan200.computercraft.shared.computer.blocks.AbstractComputerBlock;
import dan200.computercraft.shared.computer.blocks.AbstractComputerBlockEntity; import dan200.computercraft.shared.computer.blocks.AbstractComputerBlockEntity;
import dan200.computercraft.shared.computer.core.ComputerFamily; import dan200.computercraft.shared.computer.core.ComputerFamily;
@ -148,7 +147,7 @@ public class TurtleBlock extends AbstractComputerBlock<TurtleBlockEntity> implem
@ForgeOverride @ForgeOverride
public float getExplosionResistance(BlockState state, BlockGetter world, BlockPos pos, Explosion explosion) { public float getExplosionResistance(BlockState state, BlockGetter world, BlockPos pos, Explosion explosion) {
var exploder = ((ExplosionAccessor) explosion).computercraft$getExploder(); var exploder = explosion.getDirectSourceEntity();
if (getFamily() == ComputerFamily.ADVANCED || exploder instanceof LivingEntity || exploder instanceof AbstractHurtingProjectile) { if (getFamily() == ComputerFamily.ADVANCED || exploder instanceof LivingEntity || exploder instanceof AbstractHurtingProjectile) {
return 2000; return 2000;
} }

View File

@ -7,8 +7,7 @@
"defaultRequire": 1 "defaultRequire": 1
}, },
"mixins": [ "mixins": [
"CacheUpdaterMixin", "CacheUpdaterMixin"
"ExplosionAccessor"
], ],
"refmap": "computercraft.refmap.json" "refmap": "computercraft.refmap.json"
} }

View File

@ -1,245 +0,0 @@
// SPDX-FileCopyrightText: 2022 The CC: Tweaked Developers
//
// SPDX-License-Identifier: MPL-2.0
package dan200.computercraft.shared.platform;
import net.minecraft.network.Connection;
import net.minecraft.network.PacketSendListener;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.PlayerChatMessage;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.PacketFlow;
import net.minecraft.network.protocol.game.*;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.network.ServerGamePacketListenerImpl;
import javax.annotation.Nullable;
class FakeNetHandler extends ServerGamePacketListenerImpl {
protected static final Connection CONNECTION = new Connection(PacketFlow.CLIENTBOUND);
FakeNetHandler(ServerPlayer player) {
super(player.getLevel().getServer(), CONNECTION, player);
}
@Override
public void tick() {
}
@Override
public void resetPosition() {
}
@Override
public void disconnect(Component textComponent) {
}
@Override
public void handlePlayerInput(ServerboundPlayerInputPacket packet) {
}
@Override
public void handleMoveVehicle(ServerboundMoveVehiclePacket packet) {
}
@Override
public void handleAcceptTeleportPacket(ServerboundAcceptTeleportationPacket packet) {
}
@Override
public void handleRecipeBookSeenRecipePacket(ServerboundRecipeBookSeenRecipePacket packet) {
}
@Override
public void handleRecipeBookChangeSettingsPacket(ServerboundRecipeBookChangeSettingsPacket packet) {
}
@Override
public void handleSeenAdvancements(ServerboundSeenAdvancementsPacket packet) {
}
@Override
public void handleCustomCommandSuggestions(ServerboundCommandSuggestionPacket packet) {
}
@Override
public void handleSetCommandBlock(ServerboundSetCommandBlockPacket packet) {
}
@Override
public void handleSetCommandMinecart(ServerboundSetCommandMinecartPacket packet) {
}
@Override
public void handlePickItem(ServerboundPickItemPacket packet) {
}
@Override
public void handleRenameItem(ServerboundRenameItemPacket packet) {
}
@Override
public void handleSetBeaconPacket(ServerboundSetBeaconPacket packet) {
}
@Override
public void handleSetStructureBlock(ServerboundSetStructureBlockPacket packet) {
}
@Override
public void handleSetJigsawBlock(ServerboundSetJigsawBlockPacket packet) {
}
@Override
public void handleJigsawGenerate(ServerboundJigsawGeneratePacket packet) {
}
@Override
public void handleSelectTrade(ServerboundSelectTradePacket packet) {
}
@Override
public void handleEditBook(ServerboundEditBookPacket packet) {
}
@Override
public void handleEntityTagQuery(ServerboundEntityTagQuery packet) {
}
@Override
public void handleBlockEntityTagQuery(ServerboundBlockEntityTagQuery packet) {
}
@Override
public void handleMovePlayer(ServerboundMovePlayerPacket packet) {
}
@Override
public void handlePlayerAction(ServerboundPlayerActionPacket packet) {
}
@Override
public void handleUseItemOn(ServerboundUseItemOnPacket packet) {
}
@Override
public void handleUseItem(ServerboundUseItemPacket packet) {
}
@Override
public void handleTeleportToEntityPacket(ServerboundTeleportToEntityPacket packet) {
}
@Override
public void handleResourcePackResponse(ServerboundResourcePackPacket packet) {
}
@Override
public void handlePaddleBoat(ServerboundPaddleBoatPacket packet) {
}
@Override
public void handlePong(ServerboundPongPacket packet) {
}
@Override
public void onDisconnect(Component reason) {
}
@Override
public void ackBlockChangesUpTo(int i) {
}
@Override
public void send(Packet<?> packet, @Nullable PacketSendListener packetSendListener) {
}
@Override
public void handleSetCarriedItem(ServerboundSetCarriedItemPacket packet) {
}
@Override
public void handleChat(ServerboundChatPacket packet) {
}
@Override
public void handleChatCommand(ServerboundChatCommandPacket serverboundChatCommandPacket) {
}
@Override
public void handleChatSessionUpdate(ServerboundChatSessionUpdatePacket serverboundChatSessionUpdatePacket) {
}
@Override
public void handleChatAck(ServerboundChatAckPacket serverboundChatAckPacket) {
}
@Override
public void handleAnimate(ServerboundSwingPacket packet) {
}
@Override
public void handlePlayerCommand(ServerboundPlayerCommandPacket packet) {
}
@Override
public void addPendingMessage(PlayerChatMessage playerChatMessage) {
}
@Override
public void handleInteract(ServerboundInteractPacket packet) {
}
@Override
public void handleClientCommand(ServerboundClientCommandPacket packet) {
}
@Override
public void handleContainerClose(ServerboundContainerClosePacket packet) {
}
@Override
public void handleContainerClick(ServerboundContainerClickPacket packet) {
}
@Override
public void handlePlaceRecipe(ServerboundPlaceRecipePacket packet) {
}
@Override
public void handleContainerButtonClick(ServerboundContainerButtonClickPacket packet) {
}
@Override
public void handleSetCreativeModeSlot(ServerboundSetCreativeModeSlotPacket packet) {
}
@Override
public void handleSignUpdate(ServerboundSignUpdatePacket packet) {
}
@Override
public void handleKeepAlive(ServerboundKeepAlivePacket packet) {
}
@Override
public void handlePlayerAbilities(ServerboundPlayerAbilitiesPacket packet) {
}
@Override
public void handleClientInformation(ServerboundClientInformationPacket packet) {
}
@Override
public void handleCustomPayload(ServerboundCustomPayloadPacket packet) {
}
@Override
public void handleChangeDifficulty(ServerboundChangeDifficultyPacket packet) {
}
@Override
public void handleLockDifficulty(ServerboundLockDifficultyPacket packet) {
}
}

View File

@ -6,51 +6,18 @@ package dan200.computercraft.shared.platform;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.stats.Stat;
import net.minecraft.world.MenuProvider;
import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityDimensions; import net.minecraft.world.entity.EntityDimensions;
import net.minecraft.world.entity.Pose; import net.minecraft.world.entity.Pose;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import javax.annotation.Nullable; final class FakePlayer extends net.fabricmc.fabric.api.entity.FakePlayer {
import java.util.OptionalInt;
final class FakePlayer extends ServerPlayer {
private FakePlayer(ServerLevel serverLevel, GameProfile gameProfile) { private FakePlayer(ServerLevel serverLevel, GameProfile gameProfile) {
super(serverLevel.getServer(), serverLevel, gameProfile); super(serverLevel, gameProfile);
connection = new FakeNetHandler(this);
} }
static FakePlayer create(ServerLevel serverLevel, GameProfile profile) { static FakePlayer create(ServerLevel serverLevel, GameProfile profile) {
// Restore the previous player's advancements. See #564. return new FakePlayer(serverLevel, profile);
var playerList = serverLevel.getServer().getPlayerList();
var currentPlayer = playerList.getPlayer(profile.getId());
var fakePlayer = new FakePlayer(serverLevel, profile);
if (currentPlayer != null) fakePlayer.getAdvancements().setPlayer(currentPlayer);
return fakePlayer;
}
@Override
public void tick() {
}
@Override
public void doTick() {
super.doTick();
}
@Override
public void awardStat(Stat<?> stat, int increment) {
}
@Override
public boolean isInvulnerableTo(DamageSource source) {
return true;
} }
@Override @Override
@ -62,16 +29,6 @@ final class FakePlayer extends ServerPlayer {
public void die(DamageSource damageSource) { public void die(DamageSource damageSource) {
} }
@Override
public OptionalInt openMenu(@Nullable MenuProvider menu) {
return OptionalInt.empty();
}
@Override
public boolean startRiding(Entity vehicle, boolean force) {
return false;
}
@Override @Override
public float getStandingEyeHeight(Pose pose, EntityDimensions dimensions) { public float getStandingEyeHeight(Pose pose, EntityDimensions dimensions) {
return 0; return 0;