Skip to content

Commit 5c1b2f0

Browse files
committed
last 1.20.1 update things
1 parent a8af8ce commit 5c1b2f0

File tree

6 files changed

+45
-50
lines changed

6 files changed

+45
-50
lines changed

build.gradle

+1-41
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ java.toolchain.languageVersion = JavaLanguageVersion.of(17) // Mojang ships Java
1515
minecraft {
1616
mappings channel: "${mappingsChannel}", version: "${mappingsVersion}"
1717

18-
accessTransformer = 'src/main/resources/META-INF/accesstransformer.cfg'
18+
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
1919

2020
runs {
2121
client {
@@ -82,46 +82,6 @@ mixin {
8282
debug.export = true
8383
}
8484

85-
// Generate a fixed tsrg file after generating the default tsrg file
86-
createMcpToSrg {
87-
outputs.upToDateWhen {false}
88-
doLast {
89-
fixFG5TsrgForMixinAP(output.get().asFile, file("${buildDir}/fixMcpToSrg/output.tsrg"))
90-
}
91-
}
92-
93-
// Tell mixin to use the fixed TSRG file
94-
mixin {
95-
reobfSrgFile = file("${buildDir}/fixMcpToSrg/output.tsrg")
96-
}
97-
98-
// Function that actually fixes the TSRG file
99-
static def fixFG5TsrgForMixinAP(File inFile, File outFile) {
100-
// Make directory if needed
101-
outFile.parentFile.mkdirs()
102-
103-
try (Scanner scanner = new Scanner(inFile); PrintWriter out = new PrintWriter(outFile)) {
104-
boolean firstLine = true
105-
while (scanner.hasNextLine()) {
106-
String next = scanner.nextLine()
107-
108-
// Skip first 'tsrg left right' header line
109-
if (firstLine) {
110-
firstLine = false
111-
continue
112-
}
113-
114-
// Skip 'static' indicators
115-
if (next.trim() == "static") {
116-
continue
117-
}
118-
119-
// Export line otherwise
120-
out.println(next)
121-
}
122-
}
123-
}
124-
12585
jar.finalizedBy('reobfJar')
12686

12787
// Example for how to get properties into the manifest for reading by the runtime..

src/main/java/de/dertoaster/crossbowverhaul/EventHandlerForge.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package de.dertoaster.crossbowverhaul;
22

3+
import de.dertoaster.crossbowverhaul.mixin.accessor.AccessorLootTable;
4+
import de.dertoaster.crossbowverhaul.mixin.accessor.AccessorLootTableBuilder;
35
import net.minecraft.resources.ResourceLocation;
46
import net.minecraft.world.entity.EntityType;
57
import net.minecraft.world.level.storage.loot.LootPool;
@@ -27,8 +29,8 @@ public static void onLootTableLoad(LootTableLoadEvent event) {
2729
)
2830
)
2931
);
30-
for(LootPool pool : lt.pools) {
31-
builder.pools.add(pool);
32+
for(LootPool pool : ((AccessorLootTable)lt).getPools()) {
33+
((AccessorLootTableBuilder)builder).getPools().add(pool);
3234
}
3335
event.setTable(
3436
builder.build()
@@ -44,8 +46,8 @@ else if(event.getName().equals(EntityType.PIGLIN.getDefaultLootTable()) || event
4446
)
4547
)
4648
);
47-
for(LootPool pool : lt.pools) {
48-
builder.pools.add(pool);
49+
for(LootPool pool : ((AccessorLootTable)lt).getPools()) {
50+
((AccessorLootTableBuilder)builder).getPools().add(pool);
4951
}
5052
event.setTable(
5153
builder.build()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package de.dertoaster.crossbowverhaul.mixin.accessor;
2+
3+
import java.util.List;
4+
5+
import org.spongepowered.asm.mixin.Mixin;
6+
import org.spongepowered.asm.mixin.gen.Accessor;
7+
8+
import net.minecraft.world.level.storage.loot.LootPool;
9+
import net.minecraft.world.level.storage.loot.LootTable;
10+
11+
@Mixin(LootTable.class)
12+
public interface AccessorLootTable {
13+
14+
@Accessor
15+
List<LootPool> getPools();
16+
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package de.dertoaster.crossbowverhaul.mixin.accessor;
2+
3+
import java.util.List;
4+
5+
import org.spongepowered.asm.mixin.Mixin;
6+
import org.spongepowered.asm.mixin.gen.Accessor;
7+
8+
import net.minecraft.world.level.storage.loot.LootPool;
9+
import net.minecraft.world.level.storage.loot.LootTable;
10+
11+
@Mixin(LootTable.Builder.class)
12+
public interface AccessorLootTableBuilder {
13+
14+
@Accessor
15+
List<LootPool> getPools();
16+
17+
}

src/main/resources/META-INF/accesstransformer.cfg

+1-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,4 @@ public net.minecraft.world.item.CrossbowItem m_40853_(ILnet/minecraft/world/item
1313

1414
public net.minecraft.world.item.CrossbowItem m_40894_(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/LivingEntity;Lnet/minecraft/world/InteractionHand;Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/item/ItemStack;FZFFF)V #shootProjectile
1515

16-
public net.minecraft.world.item.CrossbowItem m_40905_(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/LivingEntity;Lnet/minecraft/world/item/ItemStack;)V #onCrossbowShot
17-
18-
public net.minecraft.world.level.storage.loot.LootTable f_79109_ # pools
19-
public net.minecraft.world.level.storage.loot.LootTable$Builder f_79156_ # pools
16+
public net.minecraft.world.item.CrossbowItem m_40905_(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/LivingEntity;Lnet/minecraft/world/item/ItemStack;)V #onCrossbowShot

src/main/resources/crossbowverhaul.mixins.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
"compatibilityLevel": "JAVA_17",
55
"refmap": "crossbowverhaul.refmap.json",
66
"mixins": [
7-
"MixinCrossbowItem"
7+
"MixinCrossbowItem",
8+
"accessor.AccessorLootTable",
9+
"accessor.AccessorLootTableBuilder"
810
],
911
"minVersion": "0.8",
1012
"client": [

0 commit comments

Comments
 (0)