Skip to content

Commit c21b88f

Browse files
committed
Updated to Minecraft version 1.21.6
There might be some bugs that I didn't catch but the main functionality and mechanics work (so far at least)
1 parent 4ca5d9b commit c21b88f

27 files changed

+136
-134
lines changed

gradle.properties

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ org.gradle.parallel=true
44

55
# Fabric Properties
66
# check these on https://fabricmc.net/develop
7-
minecraft_version=1.21.5
8-
yarn_mappings=1.21.5+build.1
7+
minecraft_version=1.21.6
8+
yarn_mappings=1.21.6+build.1
99
loader_version=0.16.14
1010
loom_version=1.10-SNAPSHOT
1111

@@ -15,7 +15,7 @@ maven_group=dev.overgrown.thaumaturge
1515
archives_base_name=thaumaturge
1616

1717
# Dependencies
18-
fabric_version=0.127.0+1.21.5
18+
fabric_version=0.127.1+1.21.6
1919

2020
# Mod Menu
21-
modmenu_version=14.0.0-rc.2
21+
modmenu_version=15.0.0-beta.2

src/main/java/dev/overgrown/thaumaturge/ThaumaturgeDataGenerator.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;
66
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
77
import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider;
8-
import net.minecraft.registry.RegistryKeys;
98
import net.minecraft.registry.RegistryWrapper;
109
import net.minecraft.registry.tag.ItemTags;
1110

@@ -15,8 +14,6 @@ public class ThaumaturgeDataGenerator implements DataGeneratorEntrypoint {
1514
@Override
1615
public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) {
1716
FabricDataGenerator.Pack pack = fabricDataGenerator.createPack();
18-
19-
// Remove the redundant cast
2017
pack.addProvider(ItemTagProvider::new);
2118
}
2219

@@ -27,7 +24,7 @@ public ItemTagProvider(FabricDataOutput output, CompletableFuture<RegistryWrappe
2724

2825
@Override
2926
protected void configure(RegistryWrapper.WrapperLookup arg) {
30-
getOrCreateTagBuilder(ItemTags.DYEABLE)
27+
valueLookupBuilder(ItemTags.DYEABLE)
3128
.add(ModItems.BASIC_CASTING_GAUNTLET);
3229
}
3330
}

src/main/java/dev/overgrown/thaumaturge/block/clusters/aer/AbstractAerCrystalBlock.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public AbstractAerCrystalBlock(float height, float width, Settings settings) {
2121
public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) {
2222
if (random.nextInt(10) == 0) {
2323
world.playSound(null, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5,
24-
SoundEvents.BLOCK_SAND_WIND,
24+
SoundEvents.BLOCK_SAND_IDLE,
2525
SoundCategory.BLOCKS, 0.1f, 0.6f + random.nextFloat() * 0.3f);
2626
}
2727

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
package dev.overgrown.thaumaturge.block.vessel;
22

3-
import dev.overgrown.thaumaturge.Thaumaturge;
43
import dev.overgrown.thaumaturge.block.ModBlockEntities;
54
import dev.overgrown.thaumaturge.component.AspectComponent;
65
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
76
import net.minecraft.block.BlockState;
87
import net.minecraft.block.entity.BlockEntity;
9-
import net.minecraft.nbt.NbtCompound;
10-
import net.minecraft.nbt.NbtElement;
11-
import net.minecraft.nbt.NbtOps;
12-
import net.minecraft.registry.RegistryWrapper;
8+
import net.minecraft.storage.ReadView;
9+
import net.minecraft.storage.WriteView;
1310
import net.minecraft.util.math.BlockPos;
1411

12+
import java.util.Optional;
13+
1514
public class VesselBlockEntity extends BlockEntity {
1615
private final AspectComponent aspectComponent = new AspectComponent(new Object2IntOpenHashMap<>());
1716

@@ -29,22 +28,18 @@ public void reset() {
2928
}
3029

3130
@Override
32-
public void readNbt(NbtCompound nbt, RegistryWrapper.WrapperLookup registries) {
33-
super.readNbt(nbt, registries);
31+
protected void readData(ReadView view) {
32+
super.readData(view);
3433
aspectComponent.getMap().clear();
35-
NbtElement aspectsNbt = nbt.get("Aspects");
36-
if (aspectsNbt != null) {
37-
AspectComponent.CODEC.parse(registries.getOps(NbtOps.INSTANCE), aspectsNbt)
38-
.resultOrPartial(Thaumaturge.LOGGER::error)
39-
.ifPresent(comp -> aspectComponent.getMap().putAll(comp.getMap()));
34+
Optional<AspectComponent> aspectsNbt = view.read("Aspects", AspectComponent.CODEC);
35+
if (aspectsNbt.isPresent()) {
36+
aspectComponent.getMap().putAll(aspectsNbt.get().getMap());
4037
}
4138
}
4239

4340
@Override
44-
protected void writeNbt(NbtCompound nbt, RegistryWrapper.WrapperLookup registries) {
45-
super.writeNbt(nbt, registries);
46-
AspectComponent.CODEC.encodeStart(registries.getOps(NbtOps.INSTANCE), aspectComponent)
47-
.resultOrPartial(Thaumaturge.LOGGER::error)
48-
.ifPresent(element -> nbt.put("Aspects", element));
41+
protected void writeData(WriteView view) {
42+
super.writeData(view);
43+
view.put("Aspects", AspectComponent.CODEC, aspectComponent);
4944
}
5045
}

src/main/java/dev/overgrown/thaumaturge/client/render/LaserRenderer.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import net.minecraft.client.render.VertexConsumer;
99
import net.minecraft.client.render.VertexConsumerProvider;
1010
import net.minecraft.client.util.math.MatrixStack;
11-
import net.minecraft.entity.passive.SheepEntity;
1211
import net.minecraft.util.DyeColor;
1312
import net.minecraft.util.Util;
1413
import net.minecraft.util.dynamic.Codecs;
@@ -138,8 +137,8 @@ private static Color computeColor(LaserPart part, int ticks, float partialTick)
138137
int n = l % m;
139138
int o = (l + 1) % m;
140139
float h = ((float) (ticks % rate) + partialTick) / rate;
141-
int p = SheepEntity.getRgbColor(DyeColor.byIndex(n));
142-
int q = SheepEntity.getRgbColor(DyeColor.byIndex(o));
140+
int p = DyeColor.byIndex(n).getSignColor();
141+
int q = DyeColor.byIndex(o).getSignColor();
143142
return new Color(ColorHelper.lerp(h, p, q));
144143
} else {
145144
return part.color;

src/main/java/dev/overgrown/thaumaturge/client/tooltip/AspectTooltipComponent.java

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
import it.unimi.dsi.fastutil.objects.Object2IntMap;
77
import net.minecraft.client.MinecraftClient;
88
import net.minecraft.client.font.TextRenderer;
9+
import net.minecraft.client.gl.RenderPipelines;
910
import net.minecraft.client.gui.DrawContext;
1011
import net.minecraft.client.gui.screen.Screen;
1112
import net.minecraft.client.gui.tooltip.TooltipComponent;
12-
import net.minecraft.client.render.RenderLayer;
1313
import net.minecraft.entity.EquipmentSlot;
1414
import net.minecraft.entity.player.PlayerEntity;
1515
import net.minecraft.item.ItemStack;
@@ -44,9 +44,9 @@ private boolean hasRequiredItems() {
4444
}
4545

4646
private boolean shouldShowTranslation() {
47-
// Check config first, then fall back to items
47+
MinecraftClient client = MinecraftClient.getInstance();
4848
if (AspectConfig.ALWAYS_SHOW_ASPECTS) return true;
49-
return hasRequiredItems() && (AspectConfig.ALWAYS_SHOW_ASPECTS || Screen.hasShiftDown());
49+
return hasRequiredItems() && client.currentScreen != null && Screen.hasShiftDown();
5050
}
5151

5252
@Override
@@ -56,41 +56,46 @@ public int getHeight(TextRenderer textRenderer) {
5656

5757
@Override
5858
public int getWidth(TextRenderer textRenderer) {
59-
boolean showTranslation = Screen.hasShiftDown() && hasRequiredItems();
59+
boolean showTranslation = shouldShowTranslation();
6060
int width = 0;
6161
for (var entry : aspects.object2IntEntrySet()) {
6262
int valueWidth = showTranslation ?
6363
textRenderer.getWidth(entry.getKey().value().getTranslatedName()) :
6464
textRenderer.getWidth(String.valueOf(entry.getIntValue()));
65-
width += 16 + 2 + valueWidth;
65+
width += 16 + 2 + valueWidth + 4; // Added +4 for padding
6666
}
67-
return width + (aspects.size() - 1) * 4;
67+
return width;
6868
}
6969

7070
@Override
7171
public void drawItems(TextRenderer textRenderer, int x, int y, int width, int height, DrawContext context) {
7272
boolean showTranslation = shouldShowTranslation();
7373
int currentX = x;
74+
final int TEXT_COLOR = 0xFFFFFFFF; // White with full opacity
7475

7576
for (var entry : aspects.object2IntEntrySet()) {
76-
if (MinecraftClient.getInstance().world != null) {
77-
int value = entry.getIntValue();
78-
Identifier texture = entry.getKey().value().textureLocation();
79-
80-
context.drawTexture(RenderLayer::getGuiTextured, texture, currentX, y, 0, 0, 16, 16, 16, 16);
81-
82-
if (showTranslation) {
83-
Text aspectName = entry.getKey().value().getTranslatedName().formatted(Formatting.WHITE);
84-
context.drawText(textRenderer, aspectName, currentX + 16 + 2, y + 4, 0xFFFFFF, true);
85-
} else {
86-
String valueStr = String.valueOf(value);
87-
context.drawText(textRenderer, valueStr, currentX + 16 + 2, y + 4, 0xFFFFFF, true);
88-
}
89-
90-
int entryTextWidth = showTranslation ?
91-
textRenderer.getWidth(entry.getKey().value().getTranslatedName()) :
92-
textRenderer.getWidth(String.valueOf(value));
93-
currentX += 16 + 2 + entryTextWidth + 4;
77+
int value = entry.getIntValue();
78+
Identifier texture = entry.getKey().value().textureLocation();
79+
80+
// Draw aspect icon
81+
context.drawTexture(RenderPipelines.GUI_TEXTURED, texture, currentX, y, 0, 0, 16, 16, 16, 16);
82+
83+
int textY = y + 5; // Center text vertically
84+
85+
if (showTranslation) {
86+
// Only show translation name (hide the amount)
87+
Text aspectName = entry.getKey().value().getTranslatedName().formatted(Formatting.WHITE);
88+
context.drawText(textRenderer, aspectName, currentX + 18, textY, TEXT_COLOR, false);
89+
90+
// Only move by name width + padding
91+
currentX += 16 + textRenderer.getWidth(aspectName) + 6;
92+
} else {
93+
// Only show amount (number)
94+
String valueStr = String.valueOf(value);
95+
context.drawText(textRenderer, valueStr, currentX + 18, textY, TEXT_COLOR, false);
96+
97+
// Only move by amount width + padding
98+
currentX += 16 + textRenderer.getWidth(valueStr) + 6;
9499
}
95100
}
96101
}

src/main/java/dev/overgrown/thaumaturge/component/GauntletComponent.java

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
import dev.overgrown.thaumaturge.Thaumaturge;
66
import dev.overgrown.thaumaturge.networking.SpellCastPacket;
77
import dev.overgrown.thaumaturge.spell.SpellHandler;
8+
import net.minecraft.item.Item;
89
import net.minecraft.item.ItemStack;
9-
import net.minecraft.nbt.NbtCompound;
1010
import net.minecraft.network.RegistryByteBuf;
1111
import net.minecraft.network.codec.PacketCodec;
1212
import net.minecraft.network.codec.PacketCodecs;
13+
import net.minecraft.registry.Registries;
14+
import net.minecraft.registry.RegistryKeys;
1315
import net.minecraft.registry.RegistryWrapper;
1416
import net.minecraft.util.Identifier;
1517

@@ -19,35 +21,35 @@
1921
public record GauntletComponent(List<FociEntry> entries) {
2022
public static final GauntletComponent DEFAULT = new GauntletComponent(List.of());
2123

22-
public record FociEntry(SpellCastPacket.SpellTier tier, Identifier aspectId, Identifier modifierId, NbtCompound nbt) {
24+
public record FociEntry(Item item, SpellCastPacket.SpellTier tier, Identifier aspectId, Identifier modifierId) {
25+
public static FociEntry fromItemStack(ItemStack stack, RegistryWrapper.WrapperLookup registries) {
26+
FociComponent component = stack.get(ModComponents.FOCI_COMPONENT);
27+
Identifier aspectId = component != null ? component.aspectId() : null;
28+
Identifier modifierId = component != null ? component.modifierId() : Thaumaturge.identifier("simple");
29+
SpellCastPacket.SpellTier tier = SpellHandler.getFociTier(stack.getItem());
30+
return new FociEntry(stack.getItem(), tier, aspectId, modifierId);
31+
}
32+
2333
public static final Codec<FociEntry> CODEC = RecordCodecBuilder.create(instance ->
2434
instance.group(
35+
Registries.ITEM.getCodec().fieldOf("item").forGetter(FociEntry::item),
2536
SpellCastPacket.SpellTier.CODEC.fieldOf("tier").forGetter(FociEntry::tier),
2637
Identifier.CODEC.fieldOf("aspectId").forGetter(FociEntry::aspectId),
27-
Identifier.CODEC.fieldOf("modifierId").forGetter(FociEntry::modifierId),
28-
NbtCompound.CODEC.fieldOf("nbt").forGetter(FociEntry::nbt)
38+
Identifier.CODEC.fieldOf("modifierId").forGetter(FociEntry::modifierId)
2939
).apply(instance, FociEntry::new)
3040
);
3141

3242
public static final PacketCodec<RegistryByteBuf, FociEntry> PACKET_CODEC = PacketCodec.tuple(
43+
PacketCodecs.registryValue(RegistryKeys.ITEM),
44+
FociEntry::item,
3345
SpellCastPacket.SpellTier.PACKET_CODEC,
3446
FociEntry::tier,
3547
Identifier.PACKET_CODEC,
3648
FociEntry::aspectId,
3749
Identifier.PACKET_CODEC,
3850
FociEntry::modifierId,
39-
PacketCodecs.codec(NbtCompound.CODEC),
40-
FociEntry::nbt,
4151
FociEntry::new
4252
);
43-
44-
public static FociEntry fromItemStack(ItemStack stack, RegistryWrapper.WrapperLookup registries) {
45-
NbtCompound nbt = (NbtCompound) stack.toNbt(registries);
46-
FociComponent component = stack.get(ModComponents.FOCI_COMPONENT);
47-
Identifier aspectId = component != null ? component.aspectId() : null;
48-
SpellCastPacket.SpellTier tier = SpellHandler.getFociTier(stack.getItem());
49-
return new FociEntry(tier, aspectId, Thaumaturge.identifier("simple"), nbt);
50-
}
5153
}
5254

5355
public static final Codec<GauntletComponent> CODEC = RecordCodecBuilder.create(instance ->

src/main/java/dev/overgrown/thaumaturge/event/ModEvents.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,9 @@ else if (player.isSneaking()) {
8585
if (!component.entries().isEmpty()) {
8686
RegistryWrapper.WrapperLookup registries = Objects.requireNonNull(player.getServer()).getRegistryManager();
8787
for (GauntletComponent.FociEntry entry : component.entries()) {
88-
ItemStack fociStack = ItemStack.fromNbt(registries, entry.nbt()).orElse(ItemStack.EMPTY);
89-
if (!fociStack.isEmpty()) {
90-
player.giveItemStack(fociStack);
91-
}
88+
ItemStack fociStack = new ItemStack(entry.item());
89+
fociStack.set(ModComponents.FOCI_COMPONENT, new FociComponent(entry.aspectId(), entry.modifierId()));
90+
player.getInventory().offerOrDrop(fociStack);
9291
}
9392
// Reset gauntlet state
9493
gauntletStack.set(ModComponents.GAUNTLET_STATE, GauntletComponent.DEFAULT);

src/main/java/dev/overgrown/thaumaturge/item/aetheric_goggles/AethericGogglesRenderer.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
1212
import net.fabricmc.api.EnvType;
1313
import net.fabricmc.api.Environment;
14-
import net.fabricmc.fabric.api.client.rendering.v1.HudLayerRegistrationCallback;
1514
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents;
15+
import net.fabricmc.fabric.api.client.rendering.v1.hud.HudElementRegistry;
16+
import net.fabricmc.fabric.api.client.rendering.v1.hud.VanillaHudElements;
1617
import net.minecraft.client.MinecraftClient;
1718
import net.minecraft.client.font.TextRenderer;
1819
import net.minecraft.client.util.math.MatrixStack;
@@ -172,8 +173,8 @@ else if (hit.getType() == HitResult.Type.BLOCK) {
172173
}
173174
});
174175

175-
HudLayerRegistrationCallback.EVENT.register(layeredDrawer -> layeredDrawer.attachLayerAfter(
176-
Identifier.of("minecraft", "misc_overlays"),
176+
HudElementRegistry.attachElementAfter(
177+
VanillaHudElements.MISC_OVERLAYS,
177178
Identifier.of(Thaumaturge.MOD_ID, "aetheric_goggles_hud"),
178179
(context, tickCounter) -> {
179180
if (currentAspects == null || currentAspects.isEmpty() || tooltipPosition == null) return;
@@ -191,7 +192,7 @@ else if (hit.getType() == HitResult.Type.BLOCK) {
191192

192193
tooltip.drawItems(textRenderer, x, y, width, height, context);
193194
}
194-
));
195+
);
195196
}
196197

197198
// Method to center on cross-hair

src/main/java/dev/overgrown/thaumaturge/item/apophenia/Apophenia.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22

33
import dev.overgrown.thaumaturge.component.BookStateComponent;
44
import dev.overgrown.thaumaturge.component.ModComponents;
5-
import net.minecraft.component.type.NbtComponent;
65
import net.minecraft.entity.player.PlayerEntity;
76
import net.minecraft.item.Item;
87
import net.minecraft.item.ItemStack;
9-
import net.minecraft.nbt.NbtCompound;
108
import net.minecraft.sound.SoundCategory;
119
import net.minecraft.sound.SoundEvents;
1210
import net.minecraft.util.ActionResult;

0 commit comments

Comments
 (0)