Skip to content

Commit 45b7648

Browse files
authored
Merge pull request #10 from Team-Symphony/port/1.21.3
Port to 1.21.3
2 parents 8c336b8 + 0c214d2 commit 45b7648

File tree

22 files changed

+96
-89
lines changed

22 files changed

+96
-89
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
1919

2020
- MidnightLib will be replaced by a different config lib
2121

22+
## [0.0.1-alpha+mc1.21.3] - 2024-11-7
23+
24+
### Changed
25+
26+
#### General
27+
28+
- Ported to 1.21.3
29+
- Netherite Horse Armor's protection value is now configurable
30+
2231
## [0.0.1-alpha+mc1.21] - 2024-10-23
2332

2433
### Added

gradle.properties

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

55
# Fabric Properties
66
# check these on https://fabricmc.net/develop
7-
minecraft_version=1.21.1
8-
yarn_mappings=1.21.1+build.3
9-
loader_version=0.16.5
7+
minecraft_version=1.21.3
8+
yarn_mappings=1.21.3+build.2
9+
loader_version=0.16.7
1010

1111
# Mod Properties
12-
mod_version=0.0.1-alpha+mc1.21
12+
mod_version=0.0.1-alpha+mc1.21.3
1313
maven_group=dev.symphony.melody
1414
archives_base_name=melody
1515

1616
# Dependencies
17-
fabric_version=0.105.0+1.21.1
18-
midnightlib_version = 1.6.3-fabric
17+
fabric_version=0.106.1+1.21.3
18+
midnightlib_version = 1.6.4-fabric

gradlew

100644100755
File mode changed.

src/client/java/dev/symphony/melody/map_book/MapBookScreen.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import dev.symphony.melody.item.ModItems;
44
import dev.symphony.melody.item.map_book.MapStateData;
5+
import dev.symphony.melody.mixin.client.map_book.DrawContextAccessor;
56
import net.minecraft.client.gui.DrawContext;
67
import net.minecraft.client.gui.screen.Screen;
78
import net.minecraft.client.gui.widget.ButtonWidget;
@@ -128,7 +129,7 @@ private void renderPlayerIcon(DrawContext context, float x, float z, float rotat
128129
float l = sprite.getMaxU();
129130
float m = sprite.getMaxV();
130131
Matrix4f matrix4f2 = context.getMatrices().peek().getPositionMatrix();
131-
VertexConsumer vertexConsumer2 = context.getVertexConsumers().getBuffer(RenderLayer.getText(sprite.getAtlasId()));
132+
VertexConsumer vertexConsumer2 = ((DrawContextAccessor)context).getVertexConsumers().getBuffer(RenderLayer.getText(sprite.getAtlasId()));
132133
vertexConsumer2.vertex(matrix4f2, -1.0F, 1.0F, -0.1F).color(255, 255, 255, 255).texture(g, h).light(15728880);
133134
vertexConsumer2.vertex(matrix4f2, 1.0F, 1.0F, -0.1F).color(255, 255, 255, 255).texture(l, h).light(15728880);
134135
vertexConsumer2.vertex(matrix4f2, 1.0F, -1.0F, -0.1F).color(255, 255, 255, 255).texture(l, m).light(15728880);

src/client/java/dev/symphony/melody/map_book/MapTile.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,31 @@
11
package dev.symphony.melody.map_book;
22

3+
import dev.symphony.melody.mixin.client.map_book.DrawContextAccessor;
34
import net.minecraft.client.MinecraftClient;
45
import net.minecraft.client.gui.DrawContext;
56
import net.minecraft.client.gui.Drawable;
7+
import net.minecraft.client.render.MapRenderState;
68
import net.minecraft.component.type.MapIdComponent;
79
import net.minecraft.item.map.MapState;
810
import org.jetbrains.annotations.NotNull;
911

1012
public final class MapTile implements Drawable {
1113
@NotNull
1214
private final MapBookScreen screen;
13-
private final MapIdComponent id;
1415
@NotNull
1516
private final MapState mapState;
1617
@NotNull
1718
private final MinecraftClient client;
1819

20+
private final MapRenderState mapRenderState;
21+
1922
public MapTile(@NotNull MapBookScreen screen, MapIdComponent id, @NotNull MapState mapState, @NotNull MinecraftClient client) {
2023
super();
2124
this.screen = screen;
22-
this.id = id;
2325
this.mapState = mapState;
2426
this.client = client;
27+
this.mapRenderState = new MapRenderState();
28+
this.client.getMapRenderer().update(id, mapState, mapRenderState);
2529
}
2630

2731
@Override
@@ -33,7 +37,9 @@ public void render(@NotNull DrawContext context, int mouseX, int mouseY, float d
3337
context.getMatrices().scale(this.screen.getScale(), this.screen.getScale(), -1.0F);
3438
context.getMatrices().translate((double)this.mapState.centerX - (double)offset + (double)this.screen.width / 2.0, (double)this.mapState.centerZ - (double)offset + (double)this.screen.height / 2.0, 0.0);
3539
context.getMatrices().scale(mapScale, mapScale, 1.0F);
36-
this.client.gameRenderer.getMapRenderer().draw(context.getMatrices(), context.getVertexConsumers(), id, this.mapState, true, 15728880);
40+
this.client.getMapRenderer().draw(mapRenderState, context.getMatrices(), ((DrawContextAccessor)context).getVertexConsumers(), true, 15728880);
3741
context.getMatrices().pop();
3842
}
43+
44+
3945
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package dev.symphony.melody.mixin.client.map_book;
2+
3+
import net.minecraft.client.gui.DrawContext;
4+
import net.minecraft.client.render.VertexConsumerProvider;
5+
import org.spongepowered.asm.mixin.Mixin;
6+
import org.spongepowered.asm.mixin.gen.Accessor;
7+
8+
@Mixin(DrawContext.class)
9+
public interface DrawContextAccessor {
10+
@Accessor
11+
VertexConsumerProvider.Immediate getVertexConsumers();
12+
}

src/client/java/dev/symphony/melody/mixin/client/map_book/HeldMapBookRenderingMixin.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
import dev.symphony.melody.item.map_book.MapStateData;
77
import net.minecraft.client.MinecraftClient;
88
import net.minecraft.client.render.item.HeldItemRenderer;
9+
import net.minecraft.component.ComponentType;
910
import net.minecraft.component.DataComponentTypes;
10-
import net.minecraft.item.Item;
11+
import net.minecraft.component.type.MapIdComponent;
1112
import net.minecraft.item.ItemStack;
1213
import net.minecraft.item.Items;
1314
import org.spongepowered.asm.mixin.Final;
@@ -26,12 +27,11 @@ public class HeldMapBookRenderingMixin {
2627
@Unique
2728
private MapStateData nearestMap;
2829

29-
@WrapOperation(at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;isOf(Lnet/minecraft/item/Item;)Z"), method = "renderFirstPersonItem")
30-
private boolean passMapCheck(ItemStack instance, Item item, Operation<Boolean> original) {
31-
if (original.call(instance, item)) return true;
32-
if (client.player == null || client.world == null) return false;
30+
@WrapOperation(at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;contains(Lnet/minecraft/component/ComponentType;)Z"), method = "renderFirstPersonItem")
31+
private boolean passMapCheck(ItemStack instance, ComponentType<MapIdComponent> componentType, Operation<Boolean> original) {
32+
if (!(instance.getItem() instanceof MapBookItem mapBookItem)) return original.call(instance, componentType);
3333

34-
if (!(instance.getItem() instanceof MapBookItem mapBookItem)) return false;
34+
if (client.player == null || client.world == null) return false;
3535
nearestMap = mapBookItem.getNearestMap(instance, client.world, client.player.getPos());
3636
return nearestMap != null;
3737
}

src/client/resources/melody.client.mixins.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"compatibilityLevel": "JAVA_21",
55
"client": [
66
"map_book.CartographyTableScreenMixin",
7+
"map_book.DrawContextAccessor",
78
"map_book.HeldMapBookRenderingMixin",
89
"map_book.MapPositionRequestMixin"
910
],

src/main/java/dev/symphony/melody/Melody.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
import dev.symphony.melody.network.MapBookSyncPayload;
1313

1414
import net.fabricmc.api.ModInitializer;
15+
import net.minecraft.item.equipment.ArmorMaterials;
16+
import net.minecraft.item.equipment.EquipmentType;
1517
import net.minecraft.util.Identifier;
1618
import org.slf4j.Logger;
1719
import org.slf4j.LoggerFactory;
@@ -35,6 +37,9 @@ public void onInitialize() {
3537
ResourceConditionType<MelodyConfigCondition> conditionType = ResourceConditionType.create(Melody.id("config"), MelodyConfigCondition.CODEC);
3638
ResourceConditions.register(conditionType);
3739

40+
// Set Netherite Horse Armor Defense value
41+
ArmorMaterials.NETHERITE.defense().put(EquipmentType.BODY, MelodyConfig.netheriteHorseArmorDefense);
42+
3843
// gay stuff (registry)
3944
ModItemGroups.registerItemGroups();
4045
ModItems.registerItems();

src/main/java/dev/symphony/melody/config/MelodyConfig.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public class MelodyConfig extends MidnightConfig {
1010
@Entry(category = TRANS) public static boolean vehiclesMoveThroughLeaves = true;
1111
@Entry(category = TRANS, isSlider = true, min = 0f, max = 1f) public static float leafSpeedFactor = 0.85f;
1212
@MelodyConfigCondition.ResourceConfigName(config_name = "item/netherite_horse_armor") @Entry(category = TRANS) public static boolean netheriteHorseArmor = true;
13+
@Entry(category = TRANS) public static int netheriteHorseArmorDefense = 15;
1314

1415
public static final String EXPLORATION = "exploration";
1516
@MelodyConfigCondition.ResourceConfigName(config_name = "item/map_book") @Entry(category = EXPLORATION) public static boolean mapBook = true;

0 commit comments

Comments
 (0)