Skip to content

Commit

Permalink
last 1.20.1 update things
Browse files Browse the repository at this point in the history
  • Loading branch information
DerToaster98 committed Jun 18, 2023
1 parent a8af8ce commit 5c1b2f0
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 50 deletions.
42 changes: 1 addition & 41 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ java.toolchain.languageVersion = JavaLanguageVersion.of(17) // Mojang ships Java
minecraft {
mappings channel: "${mappingsChannel}", version: "${mappingsVersion}"

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

runs {
client {
Expand Down Expand Up @@ -82,46 +82,6 @@ mixin {
debug.export = true
}

// Generate a fixed tsrg file after generating the default tsrg file
createMcpToSrg {
outputs.upToDateWhen {false}
doLast {
fixFG5TsrgForMixinAP(output.get().asFile, file("${buildDir}/fixMcpToSrg/output.tsrg"))
}
}

// Tell mixin to use the fixed TSRG file
mixin {
reobfSrgFile = file("${buildDir}/fixMcpToSrg/output.tsrg")
}

// Function that actually fixes the TSRG file
static def fixFG5TsrgForMixinAP(File inFile, File outFile) {
// Make directory if needed
outFile.parentFile.mkdirs()

try (Scanner scanner = new Scanner(inFile); PrintWriter out = new PrintWriter(outFile)) {
boolean firstLine = true
while (scanner.hasNextLine()) {
String next = scanner.nextLine()

// Skip first 'tsrg left right' header line
if (firstLine) {
firstLine = false
continue
}

// Skip 'static' indicators
if (next.trim() == "static") {
continue
}

// Export line otherwise
out.println(next)
}
}
}

jar.finalizedBy('reobfJar')

// Example for how to get properties into the manifest for reading by the runtime..
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package de.dertoaster.crossbowverhaul;

import de.dertoaster.crossbowverhaul.mixin.accessor.AccessorLootTable;
import de.dertoaster.crossbowverhaul.mixin.accessor.AccessorLootTableBuilder;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.level.storage.loot.LootPool;
Expand Down Expand Up @@ -27,8 +29,8 @@ public static void onLootTableLoad(LootTableLoadEvent event) {
)
)
);
for(LootPool pool : lt.pools) {
builder.pools.add(pool);
for(LootPool pool : ((AccessorLootTable)lt).getPools()) {
((AccessorLootTableBuilder)builder).getPools().add(pool);
}
event.setTable(
builder.build()
Expand All @@ -44,8 +46,8 @@ else if(event.getName().equals(EntityType.PIGLIN.getDefaultLootTable()) || event
)
)
);
for(LootPool pool : lt.pools) {
builder.pools.add(pool);
for(LootPool pool : ((AccessorLootTable)lt).getPools()) {
((AccessorLootTableBuilder)builder).getPools().add(pool);
}
event.setTable(
builder.build()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package de.dertoaster.crossbowverhaul.mixin.accessor;

import java.util.List;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

import net.minecraft.world.level.storage.loot.LootPool;
import net.minecraft.world.level.storage.loot.LootTable;

@Mixin(LootTable.class)
public interface AccessorLootTable {

@Accessor
List<LootPool> getPools();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package de.dertoaster.crossbowverhaul.mixin.accessor;

import java.util.List;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

import net.minecraft.world.level.storage.loot.LootPool;
import net.minecraft.world.level.storage.loot.LootTable;

@Mixin(LootTable.Builder.class)
public interface AccessorLootTableBuilder {

@Accessor
List<LootPool> getPools();

}
5 changes: 1 addition & 4 deletions src/main/resources/META-INF/accesstransformer.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,4 @@ public net.minecraft.world.item.CrossbowItem m_40853_(ILnet/minecraft/world/item

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

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

public net.minecraft.world.level.storage.loot.LootTable f_79109_ # pools
public net.minecraft.world.level.storage.loot.LootTable$Builder f_79156_ # pools
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
4 changes: 3 additions & 1 deletion src/main/resources/crossbowverhaul.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"compatibilityLevel": "JAVA_17",
"refmap": "crossbowverhaul.refmap.json",
"mixins": [
"MixinCrossbowItem"
"MixinCrossbowItem",
"accessor.AccessorLootTable",
"accessor.AccessorLootTableBuilder"
],
"minVersion": "0.8",
"client": [
Expand Down

0 comments on commit 5c1b2f0

Please sign in to comment.