mirror of
https://github.com/architectury/architectury-api.git
synced 2026-04-01 21:17:45 -05:00
Port to 1.21 (#511)
* 1.21-pre1 * progress * fix MixinGameRenderer * update the access widener * pass removal reason in the player respawn event * Update MixinGameRenderer.java * fix more mixins * fix more 1.21 stuff * Update TestRegistries.java * remove enchantments (it's data driven) * rename 1.20.6 files to 1.21 * update to 1.21-pre4 * lol * fix neoforge * Finish port to 1.21 --------- Co-authored-by: shedaniel <daniel@shedaniel.me>
This commit is contained in:
@@ -47,6 +47,8 @@ import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.renderer.entity.CowRenderer;
|
||||
import net.minecraft.core.component.DataComponents;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.data.registries.VanillaRegistries;
|
||||
import net.minecraft.world.item.CreativeModeTabs;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
@@ -75,9 +77,6 @@ public class TestMod {
|
||||
EnvExecutor.runInEnv(Env.CLIENT, () -> TestMod.Client::initializeClient);
|
||||
CreativeTabRegistry.modifyBuiltin(BuiltInRegistries.CREATIVE_MODE_TAB.get(CreativeModeTabs.BUILDING_BLOCKS), (flags, output, canUseGameMasterBlocks) -> {
|
||||
ItemStack sword = Items.DIAMOND_SWORD.getDefaultInstance();
|
||||
ItemEnchantments.Mutable mutable = new ItemEnchantments.Mutable(ItemEnchantments.EMPTY);
|
||||
mutable.set(Enchantments.SHARPNESS, 10);
|
||||
sword.set(DataComponents.ENCHANTMENTS, mutable.toImmutable());
|
||||
output.acceptBefore(new ItemStack(Items.OAK_WOOD), sword);
|
||||
output.acceptAfter(Blocks.STRIPPED_OAK_LOG, Items.BEDROCK);
|
||||
});
|
||||
|
||||
@@ -26,6 +26,7 @@ import dev.architectury.test.debug.ConsoleMessageSink;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.client.DeltaTracker;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.network.chat.Component;
|
||||
@@ -40,9 +41,9 @@ public class ClientOverlayMessageSink extends ConsoleMessageSink {
|
||||
|
||||
public ClientOverlayMessageSink() {
|
||||
ClientGuiEvent.RENDER_POST.register((screen, graphics, mouseX, mouseY, delta) -> render(graphics, delta));
|
||||
ClientGuiEvent.RENDER_HUD.register((graphics, tickDelta) -> {
|
||||
ClientGuiEvent.RENDER_HUD.register((graphics, delta) -> {
|
||||
if (Minecraft.getInstance().screen == null && !Minecraft.getInstance().gui.getDebugOverlay().showDebugScreen()) {
|
||||
render(graphics, tickDelta);
|
||||
render(graphics, delta);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -53,7 +54,7 @@ public class ClientOverlayMessageSink extends ConsoleMessageSink {
|
||||
messages.add(0, new Message(Component.literal(message), Util.getMillis()));
|
||||
}
|
||||
|
||||
public void render(GuiGraphics graphics, float delta) {
|
||||
public void render(GuiGraphics graphics, DeltaTracker delta) {
|
||||
graphics.pose().pushPose();
|
||||
graphics.pose().scale(0.5f, 0.5f, 1f);
|
||||
var minecraft = Minecraft.getInstance();
|
||||
|
||||
@@ -29,6 +29,7 @@ import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.game.ClientGamePacketListener;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerEntity;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.MobCategory;
|
||||
@@ -46,8 +47,8 @@ public class TestEntity extends Cow {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet<ClientGamePacketListener> getAddEntityPacket() {
|
||||
return NetworkManager.createAddEntityPacket(this);
|
||||
public Packet<ClientGamePacketListener> getAddEntityPacket(ServerEntity entity) {
|
||||
return NetworkManager.createAddEntityPacket(this, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -59,7 +60,7 @@ public class TestEntity extends Cow {
|
||||
compoundTag.putString("DeathCauser", player.getStringUUID());
|
||||
RegistryFriendlyByteBuf buf = new RegistryFriendlyByteBuf(Unpooled.buffer(), this.registryAccess());
|
||||
buf.writeNbt(compoundTag);
|
||||
NetworkManager.sendToPlayer(player, new ResourceLocation("architectury_test", "sync_data"), buf);
|
||||
NetworkManager.sendToPlayer(player, ResourceLocation.fromNamespaceAndPath("architectury_test", "sync_data"), buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ public class DebugEvents {
|
||||
PlayerEvent.PLAYER_QUIT.register(player -> {
|
||||
TestMod.SINK.accept(player.getScoreboardName() + " quit" + logSide(player.level()));
|
||||
});
|
||||
PlayerEvent.PLAYER_RESPAWN.register((player, conqueredEnd) -> {
|
||||
PlayerEvent.PLAYER_RESPAWN.register((player, conqueredEnd, removalReason) -> {
|
||||
if (!conqueredEnd) {
|
||||
TestMod.SINK.accept(player.getScoreboardName() + " respawns " + logSide(player.level()));
|
||||
}
|
||||
|
||||
@@ -44,10 +44,10 @@ public interface TestModNet {
|
||||
|
||||
// An example Server to Client message
|
||||
MessageType SYNC_DATA = NET.registerS2C("sync_data", SyncDataMessage::new);
|
||||
ResourceLocation BIG_DATA = new ResourceLocation(TestMod.MOD_ID, "big_data");
|
||||
ResourceLocation SERVER_TO_CLIENT_TEST = new ResourceLocation(TestMod.MOD_ID, "s2c_test");
|
||||
CustomPacketPayload.Type<ServerToClientTestPayload> SERVER_TO_CLIENT_TEST_PAYLOAD = new CustomPacketPayload.Type<>(new ResourceLocation(TestMod.MOD_ID, "s2c_test_payload"));
|
||||
CustomPacketPayload.Type<BigDataPayload> BIG_DATA_PAYLOAD = new CustomPacketPayload.Type<>(new ResourceLocation(TestMod.MOD_ID, "big_data_payload"));
|
||||
ResourceLocation BIG_DATA = ResourceLocation.fromNamespaceAndPath(TestMod.MOD_ID, "big_data");
|
||||
ResourceLocation SERVER_TO_CLIENT_TEST = ResourceLocation.fromNamespaceAndPath(TestMod.MOD_ID, "s2c_test");
|
||||
CustomPacketPayload.Type<ServerToClientTestPayload> SERVER_TO_CLIENT_TEST_PAYLOAD = new CustomPacketPayload.Type<>(ResourceLocation.fromNamespaceAndPath(TestMod.MOD_ID, "s2c_test_payload"));
|
||||
CustomPacketPayload.Type<BigDataPayload> BIG_DATA_PAYLOAD = new CustomPacketPayload.Type<>(ResourceLocation.fromNamespaceAndPath(TestMod.MOD_ID, "big_data_payload"));
|
||||
String BIG_STRING = StringUtils.repeat('a', 100000);
|
||||
|
||||
static void initialize() {
|
||||
|
||||
@@ -77,7 +77,7 @@ public class TestRegistries {
|
||||
}
|
||||
}
|
||||
|
||||
public static final Registrar<TestInt> INTS = RegistrarManager.get(TestMod.MOD_ID).<TestInt>builder(new ResourceLocation(TestMod.MOD_ID, "ints"))
|
||||
public static final Registrar<TestInt> INTS = RegistrarManager.get(TestMod.MOD_ID).<TestInt>builder(ResourceLocation.fromNamespaceAndPath(TestMod.MOD_ID, "ints"))
|
||||
.syncToClients()
|
||||
.build();
|
||||
public static final DeferredRegister<CreativeModeTab> TABS = DeferredRegister.create(TestMod.MOD_ID, Registries.CREATIVE_MODE_TAB);
|
||||
@@ -95,14 +95,14 @@ public class TestRegistries {
|
||||
|
||||
public static final ArchitecturyFluidAttributes TEST_FLUID_ATTRIBUTES = SimpleArchitecturyFluidAttributes.ofSupplier(() -> TestRegistries.TEST_FLUID_FLOWING, () -> TestRegistries.TEST_FLUID)
|
||||
.convertToSource(true)
|
||||
.flowingTexture(new ResourceLocation("block/water_flow"))
|
||||
.sourceTexture(new ResourceLocation("block/water_still"))
|
||||
.flowingTexture(ResourceLocation.withDefaultNamespace("block/water_flow"))
|
||||
.sourceTexture(ResourceLocation.withDefaultNamespace("block/water_still"))
|
||||
.blockSupplier(() -> TestRegistries.TEST_FLUID_BLOCK)
|
||||
.bucketItemSupplier(() -> TestRegistries.TEST_FLUID_BUCKET)
|
||||
.color(0xFF0000);
|
||||
|
||||
public static final RegistrySupplier<TestInt> TEST_INT = INTS.register(new ResourceLocation(TestMod.MOD_ID, "test_int"), () -> new TestInt(1));
|
||||
public static final RegistrySupplier<TestInt> TEST_INT_2 = INTS.register(new ResourceLocation(TestMod.MOD_ID, "test_int_2"), () -> new TestInt(2));
|
||||
public static final RegistrySupplier<TestInt> TEST_INT = INTS.register(ResourceLocation.fromNamespaceAndPath(TestMod.MOD_ID, "test_int"), () -> new TestInt(1));
|
||||
public static final RegistrySupplier<TestInt> TEST_INT_2 = INTS.register(ResourceLocation.fromNamespaceAndPath(TestMod.MOD_ID, "test_int_2"), () -> new TestInt(2));
|
||||
|
||||
public static final RegistrySupplier<MobEffect> TEST_EFFECT = MOB_EFFECTS.register("test_effect", () ->
|
||||
new MobEffect(MobEffectCategory.NEUTRAL, 0x123456) {
|
||||
|
||||
@@ -32,9 +32,9 @@ import net.minecraft.tags.TagKey;
|
||||
public class TestTags {
|
||||
public static void initialize() {
|
||||
// This will not be present, but it should return an empty tag
|
||||
var heartParticles = TagKey.create(Registries.BLOCK, new ResourceLocation(TestMod.MOD_ID, "heart_particles"));
|
||||
var heartParticles = TagKey.create(Registries.BLOCK, ResourceLocation.fromNamespaceAndPath(TestMod.MOD_ID, "heart_particles"));
|
||||
// This will act like a normal tag, we have emerald block here
|
||||
var heartParticles2 = TagKey.create(Registries.BLOCK, new ResourceLocation(TestMod.MOD_ID, "heart_particles2"));
|
||||
var heartParticles2 = TagKey.create(Registries.BLOCK, ResourceLocation.fromNamespaceAndPath(TestMod.MOD_ID, "heart_particles2"));
|
||||
|
||||
BlockEvent.BREAK.register((world, pos, state, player, xp) -> {
|
||||
if (player != null && !world.isClientSide() && (state.is(heartParticles) || state.is(heartParticles2))) {
|
||||
|
||||
@@ -35,7 +35,7 @@ public class TestWorldGeneration {
|
||||
if (ctx.hasTag(BiomeTags.IS_FOREST)) {
|
||||
mutable.getGenerationProperties().addFeature(GenerationStep.Decoration.TOP_LAYER_MODIFICATION,
|
||||
ResourceKey.create(Registries.PLACED_FEATURE,
|
||||
new ResourceLocation(TestMod.MOD_ID + ":diamond_blocks")));
|
||||
ResourceLocation.fromNamespaceAndPath(TestMod.MOD_ID, "diamond_blocks")));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user