Skip to content

Commit

Permalink
23w45a porting fixes (#3421)
Browse files Browse the repository at this point in the history
  • Loading branch information
apple502j authored Nov 16, 2023
1 parent 23e8616 commit a2e8758
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;

import net.minecraft.block.Blocks;
import net.minecraft.command.argument.DimensionArgumentType;
Expand Down Expand Up @@ -51,6 +52,7 @@ public class FabricDimensionTest implements ModInitializer {
// The dimension options refer to the JSON-file in the dimension subfolder of the data pack,
// which will always share its ID with the world that is created from it
private static final RegistryKey<DimensionOptions> DIMENSION_KEY = RegistryKey.of(RegistryKeys.DIMENSION, new Identifier("fabric_dimension", "void"));
private static final SimpleCommandExceptionType FAILED_EXCEPTION = new SimpleCommandExceptionType(Text.literal("Teleportation failed!"));

private static RegistryKey<World> WORLD_KEY = RegistryKey.of(RegistryKeys.WORLD, DIMENSION_KEY.getValue());

Expand Down Expand Up @@ -110,7 +112,7 @@ public void onInitialize() {
});
}

private int swapTargeted(CommandContext<ServerCommandSource> context) {
private int swapTargeted(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
ServerPlayerEntity player = context.getSource().getPlayer();

if (player == null) {
Expand All @@ -126,7 +128,7 @@ private int swapTargeted(CommandContext<ServerCommandSource> context) {
FabricDimensions.teleport(player, modWorld, target);

if (player.getWorld() != modWorld) {
throw new RuntimeException("Teleportation failed!");
throw FAILED_EXCEPTION.create();
}

modWorld.setBlockState(new BlockPos(0, 100, 0), Blocks.DIAMOND_BLOCK.getDefaultState());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,12 @@ protected FabricBlockSettings(AbstractBlock.Settings settings) {
this.instrument(otherAccessor.getInstrument());
thisAccessor.setReplaceable(otherAccessor.getReplaceable());

// Not copied in vanilla: field definition order
// Vanilla did not copy those fields until 23w45a, which introduced
// copyShallow method (maintaining the behavior previously used by the copy method)
// and the copy method that copies those fields as well. copyShallow is now
// deprecated. To maintain compatibility and since this behavior seems to be the
// more proper way, this copies all the fields, not just the shallow ones.
// Fields are added by field definition order.
this.jumpVelocityMultiplier(otherAccessor.getJumpVelocityMultiplier());
this.drops(otherAccessor.getLootTableId());
this.allowsSpawning(otherAccessor.getAllowsSpawningPredicate());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ public BlockSetTypeBuilder buttonClickOnSound(SoundEvent buttonClickOnSound) {
public static BlockSetTypeBuilder copyOf(BlockSetTypeBuilder builder) {
BlockSetTypeBuilder copy = new BlockSetTypeBuilder();
copy.openableByHand(builder.openableByHand);
copy.openableByWindCharge(builder.openableByWindCharge);
copy.buttonActivatedByArrows(builder.buttonActivatedByArrows);
copy.pressurePlateActivationRule(builder.pressurePlateActivationRule);
copy.soundGroup(builder.soundGroup);
Expand All @@ -234,6 +235,7 @@ public static BlockSetTypeBuilder copyOf(BlockSetTypeBuilder builder) {
public static BlockSetTypeBuilder copyOf(BlockSetType setType) {
BlockSetTypeBuilder copy = new BlockSetTypeBuilder();
copy.openableByHand(setType.canOpenByHand());
copy.openableByWindCharge(setType.canOpenByWindCharge());
copy.buttonActivatedByArrows(setType.canButtonBeActivatedByArrows());
copy.pressurePlateActivationRule(setType.pressurePlateSensitivity());
copy.soundGroup(setType.soundType());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ transitive-accessible field net/minecraft/client/MinecraftClient attackCooldown
transitive-accessible method net/minecraft/block/Blocks createFlowerPotBlock (Lnet/minecraft/block/Block;)Lnet/minecraft/block/Block;
transitive-accessible method net/minecraft/block/Blocks createLeavesBlock (Lnet/minecraft/sound/BlockSoundGroup;)Lnet/minecraft/block/Block;
transitive-accessible method net/minecraft/block/Blocks createLogBlock (Lnet/minecraft/block/MapColor;Lnet/minecraft/block/MapColor;)Lnet/minecraft/block/Block;
transitive-accessible method net/minecraft/block/Blocks createLogBlock (Lnet/minecraft/block/MapColor;Lnet/minecraft/block/MapColor;Lnet/minecraft/sound/BlockSoundGroup;)Lnet/minecraft/block/Block;
transitive-accessible method net/minecraft/block/Blocks createNetherStemBlock (Lnet/minecraft/block/MapColor;)Lnet/minecraft/block/Block;
transitive-accessible method net/minecraft/block/Blocks createStoneButtonBlock ()Lnet/minecraft/block/Block;
transitive-accessible method net/minecraft/block/Blocks createWoodenButtonBlock (Lnet/minecraft/block/BlockSetType;)Lnet/minecraft/block/Block;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ transitive-accessible field net/minecraft/client/MinecraftClient attackCooldown
transitive-accessible method net/minecraft/block/Blocks createFlowerPotBlock (Lnet/minecraft/block/Block;)Lnet/minecraft/block/Block;
transitive-accessible method net/minecraft/block/Blocks createLeavesBlock (Lnet/minecraft/sound/BlockSoundGroup;)Lnet/minecraft/block/Block;
transitive-accessible method net/minecraft/block/Blocks createLogBlock (Lnet/minecraft/block/MapColor;Lnet/minecraft/block/MapColor;)Lnet/minecraft/block/Block;
transitive-accessible method net/minecraft/block/Blocks createLogBlock (Lnet/minecraft/block/MapColor;Lnet/minecraft/block/MapColor;Lnet/minecraft/sound/BlockSoundGroup;)Lnet/minecraft/block/Block;
transitive-accessible method net/minecraft/block/Blocks createNetherStemBlock (Lnet/minecraft/block/MapColor;)Lnet/minecraft/block/Block;
transitive-accessible method net/minecraft/block/Blocks createStoneButtonBlock ()Lnet/minecraft/block/Block;
transitive-accessible method net/minecraft/block/Blocks createWoodenButtonBlock (Lnet/minecraft/block/BlockSetType;)Lnet/minecraft/block/Block;
Expand Down

0 comments on commit a2e8758

Please sign in to comment.