Skip to content

Commit

Permalink
Add 1.16 support
Browse files Browse the repository at this point in the history
  • Loading branch information
altrisi committed Jun 23, 2022
1 parent e453649 commit 5747d8b
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 11 deletions.
13 changes: 8 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
plugins {
id 'fabric-loom' version '0.11-SNAPSHOT'
id 'maven-publish'
id "io.github.p03w.machete" version "1.0.11"
id "io.github.p03w.machete" version "1.1.2"
}

sourceCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_14
targetCompatibility = JavaVersion.VERSION_1_8

archivesBaseName = project.archives_base_name
Expand All @@ -24,11 +24,14 @@ dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings loom.officialMojangMappings()
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
annotationProcessor 'com.github.bsideup.jabel:jabel-javac-plugin:0.4.2'
}

machete {
// Enable local variable table stripping. We don't reference those, so they will never appear in NPEs
optimizations.stripLVT = true
lvtStriping.enabled = true
// Enable source file striping. We only have mixins, and those aren't present in stacktraces anyway
sourceFileStriping.enabled = true
}

processResources {
Expand All @@ -40,8 +43,8 @@ processResources {
}

tasks.withType(JavaCompile).configureEach {
// Minecraft 1.17 (21w19a) upwards uses Java 16.
it.options.release = 16
// Minecraft 1.16 provides Java 8.
it.options.release = 8
}

java {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.17.1
minecraft_version=1.16.5
loader_version=0.12.12

# Mod Properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,24 @@

import net.minecraft.world.entity.vehicle.AbstractMinecart;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.ItemLike;

@Mixin(AbstractMinecart.class)
public abstract class AbstractMinecartMixin {
@Shadow
public abstract ItemStack getPickResult();
public abstract AbstractMinecart.Type getMinecartType();

@Redirect(method = "destroy", at = @At(value = "NEW", target = "net/minecraft/world/item/ItemStack"))
private ItemStack dropFullCart(ItemLike itemLike) {
return getPickResult();
return new ItemStack(switch (getMinecartType()) {
case RIDEABLE -> Items.MINECART;
case FURNACE -> Items.FURNACE_MINECART;
case HOPPER -> Items.HOPPER_MINECART;
case CHEST -> Items.CHEST_MINECART;
case TNT -> Items.TNT_MINECART;
// Those shouldn't drop
case COMMAND_BLOCK, SPAWNER -> Items.AIR;
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@Mixin({MinecartChest.class, MinecartHopper.class, MinecartFurnace.class, MinecartTNT.class})
public class MinecartSubclassesMixin {
@Redirect(method = "destroy", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/GameRules;getBoolean(Lnet/minecraft/world/level/GameRules$Key;)Z"))
private boolean dontDropComponent(GameRules gameRules, GameRules.Key<GameRules.BooleanValue> key) {
private boolean noComponent(GameRules gameRules, GameRules.Key<GameRules.BooleanValue> key) {
return false;
}
}
2 changes: 1 addition & 1 deletion src/main/resources/dropfullcarts.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"required": true,
"minVersion": "0.8",
"package": "altrisi.mods.dropfullcarts.mixin",
"compatibilityLevel": "JAVA_16",
"compatibilityLevel": "JAVA_8",
"mixins": [
"AbstractMinecartMixin",
"MinecartSubclassesMixin"
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@

"depends": {
"fabricloader": ">=0.12.12",
"minecraft": ">=1.17.1"
"minecraft": ">=1.16.1"
}
}

0 comments on commit 5747d8b

Please sign in to comment.