-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
13 changed files
with
186 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
plugins { | ||
id 'fabric-loom' version '0.6-SNAPSHOT' | ||
id 'fabric-loom' version '0.7-SNAPSHOT' | ||
id 'maven-publish' | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
org.gradle.jvmargs=-Xmx1G | ||
|
||
# Fabric Properties | ||
# check these on https://modmuss50.me/fabric.html | ||
# check these e.g. on https://spaceclouds42.github.io/fabric-versions | ||
minecraft_version=1.16.5 | ||
yarn_mappings=1.16.5+build.6 | ||
loader_version=0.11.3 | ||
fabric_api_version=0.32.5+1.16 | ||
fabric_api_version=0.32.9+1.16 | ||
|
||
# Mod Properties | ||
mod_version=1.1 | ||
mod_version=1.2 | ||
maven_group=fourmisain | ||
archives_base_name=KeepHeadNames |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
pluginManagement { | ||
repositories { | ||
jcenter() | ||
maven { | ||
name = 'Fabric' | ||
url = 'https://maven.fabricmc.net/' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/main/java/fourmisain/keepheadnames/mixin/LootFunctionTypesAccessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package fourmisain.keepheadnames.mixin; | ||
|
||
import net.minecraft.loot.function.LootFunction; | ||
import net.minecraft.loot.function.LootFunctionType; | ||
import net.minecraft.loot.function.LootFunctionTypes; | ||
import net.minecraft.util.JsonSerializer; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.gen.Invoker; | ||
|
||
@Mixin(LootFunctionTypes.class) | ||
public interface LootFunctionTypesAccessor { | ||
@Invoker("register") | ||
static LootFunctionType register(String id, JsonSerializer<? extends LootFunction> jsonSerializer) { | ||
throw new AssertionError(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
src/main/java/fourmisain/keepheadnames/util/CopyLoreLootFunction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package fourmisain.keepheadnames.util; | ||
|
||
import com.google.common.collect.ImmutableSet; | ||
import com.google.gson.JsonDeserializationContext; | ||
import com.google.gson.JsonObject; | ||
import com.google.gson.JsonSerializationContext; | ||
import fourmisain.keepheadnames.KeepHeadNames; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.loot.condition.LootCondition; | ||
import net.minecraft.loot.context.LootContext; | ||
import net.minecraft.loot.context.LootContextParameter; | ||
import net.minecraft.loot.context.LootContextParameters; | ||
import net.minecraft.loot.function.ConditionalLootFunction; | ||
import net.minecraft.loot.function.LootFunctionType; | ||
import net.minecraft.util.JsonHelper; | ||
|
||
import java.util.Set; | ||
|
||
import static fourmisain.keepheadnames.KeepHeadNames.setLore; | ||
|
||
public class CopyLoreLootFunction extends ConditionalLootFunction { | ||
private final CopyLoreLootFunction.Source source; | ||
|
||
private CopyLoreLootFunction(LootCondition[] conditions, CopyLoreLootFunction.Source source) { | ||
super(conditions); | ||
this.source = source; | ||
} | ||
|
||
public LootFunctionType getType() { | ||
return KeepHeadNames.COPY_LORE; | ||
} | ||
|
||
public Set<LootContextParameter<?>> getRequiredParameters() { | ||
return ImmutableSet.of(this.source.parameter); | ||
} | ||
|
||
public ItemStack process(ItemStack itemStack, LootContext context) { | ||
Object object = context.get(this.source.parameter); | ||
|
||
if (object instanceof Loreable) { | ||
Loreable loreable = (Loreable)object; | ||
setLore(itemStack, loreable.getLore()); | ||
} | ||
|
||
return itemStack; | ||
} | ||
|
||
public static ConditionalLootFunction.Builder<?> builder(CopyLoreLootFunction.Source source) { | ||
return builder((conditions) -> new CopyLoreLootFunction(conditions, source)); | ||
} | ||
|
||
public static class Serializer extends ConditionalLootFunction.Serializer<CopyLoreLootFunction> { | ||
public void toJson(JsonObject jsonObject, CopyLoreLootFunction copyNameLootFunction, JsonSerializationContext jsonSerializationContext) { | ||
super.toJson(jsonObject, copyNameLootFunction, jsonSerializationContext); | ||
jsonObject.addProperty("source", copyNameLootFunction.source.name); | ||
} | ||
|
||
public CopyLoreLootFunction fromJson(JsonObject jsonObject, JsonDeserializationContext jsonDeserializationContext, LootCondition[] lootConditions) { | ||
CopyLoreLootFunction.Source source = CopyLoreLootFunction.Source.valueOf(JsonHelper.getString(jsonObject, "source")); | ||
return new CopyLoreLootFunction(lootConditions, source); | ||
} | ||
} | ||
|
||
public enum Source { | ||
THIS("this", LootContextParameters.THIS_ENTITY), | ||
KILLER("killer", LootContextParameters.KILLER_ENTITY), | ||
KILLER_PLAYER("killer_player", LootContextParameters.LAST_DAMAGE_PLAYER), | ||
BLOCK_ENTITY("block_entity", LootContextParameters.BLOCK_ENTITY); | ||
|
||
public final String name; | ||
public final LootContextParameter<?> parameter; | ||
|
||
Source(String name, LootContextParameter<?> parameter) { | ||
this.name = name; | ||
this.parameter = parameter; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package fourmisain.keepheadnames.util; | ||
|
||
import net.minecraft.nbt.ListTag; | ||
|
||
public interface Loreable { | ||
void setLore(ListTag lore); | ||
ListTag getLore(); | ||
} |
2 changes: 1 addition & 1 deletion
2
...ourmisain/keepheadnames/NameSettable.java → ...sain/keepheadnames/util/NameSettable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package fourmisain.keepheadnames; | ||
package fourmisain.keepheadnames.util; | ||
|
||
import net.minecraft.text.Text; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters