Skip to content

Commit

Permalink
1.20.5 port
Browse files Browse the repository at this point in the history
  • Loading branch information
ExDrill committed Apr 23, 2024
1 parent c12c981 commit c757493
Show file tree
Hide file tree
Showing 55 changed files with 233 additions and 365 deletions.
20 changes: 6 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.1-SNAPSHOT'
id 'fabric-loom' version '1.6-SNAPSHOT'
id 'maven-publish'
}

Expand All @@ -22,22 +22,14 @@ loom {

dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings loom.layered() {
officialMojangMappings()
parchment("org.parchmentmc.data:parchment-${project.parchment_version}@zip")
}
mappings loom.officialMojangMappings()

// Fabric
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

// Scribe
modApi "com.github.Team-Abode:scribe:${rootProject.scribe_version}"
include "com.github.Team-Abode:scribe:${rootProject.scribe_version}"

// Fabric ASM
modImplementation "com.github.Chocohead:Fabric-ASM:${fabric_asm_version}"
include "com.github.Chocohead:Fabric-ASM:${fabric_asm_version}"
modApi "com.github.Team-Abode:sketch:${rootProject.sketch_version}"
}

base {
Expand All @@ -53,14 +45,14 @@ processResources {
}

tasks.withType(JavaCompile).configureEach {
it.options.release = 17
it.options.release = 21
}

java {
withSourcesJar()

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}

jar {
Expand Down
12 changes: 5 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@ org.gradle.jvmargs=-Xmx1G
org.gradle.parallel=true

# Fabric Properties
minecraft_version=1.20.4
loader_version=0.15.7
minecraft_version=1.20.5
loader_version=0.15.10

# Mod Properties
mod_version = 2.5.0
mod_version = 2.6.0
maven_group = com.teamabode
archives_base_name = guarding

# Dependencies
fabric_version=0.96.11+1.20.4
scribe_version=1.20.4-0.7.2-alpha
parchment_version=1.20.2:2023.12.10
fabric_asm_version=v2.3
fabric_version=0.97.5+1.20.5
sketch_version=1.20.5-0.9.0
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
8 changes: 5 additions & 3 deletions src/main/java/com/teamabode/guarding/Guarding.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
package com.teamabode.guarding;

import com.chocohead.mm.api.ClassTinkerers;
import com.teamabode.guarding.core.init.*;
import com.teamabode.sketch.core.api.config.Config;
import com.teamabode.sketch.core.api.config.ConfigBuilder;
import net.fabricmc.api.ModInitializer;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.enchantment.EnchantmentCategory;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Guarding implements ModInitializer {
public static final String MOD_ID = "guarding";
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
public static final EnchantmentCategory GUARDING_SHIELD = ClassTinkerers.getEnum(EnchantmentCategory.class, "GUARDING_SHIELD");

public static final TagKey<Item> SHIELD_ENCHANTABLE = TagKey.create(Registries.ITEM, id("enchantable/shield"));

public static final Config CONFIG = new ConfigBuilder(MOD_ID)
.addGroup("general", builder -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.Sheets;
import net.minecraft.core.component.DataComponents;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.ResourceManager;
import net.minecraft.world.item.ItemDisplayContext;
Expand All @@ -33,10 +34,8 @@ public void render(ItemStack stack, ItemDisplayContext displayContext, PoseStack
model.renderToBuffer(poseStack, buffer, light, overlay, 1.0f, 1.0f, 1.0f, 1.0f);

ClientLevel level = Minecraft.getInstance().level;
if (level != null) {
ArmorTrim.getTrim(level.registryAccess(), stack, true).ifPresent(armorTrim -> {
model.renderTrim(poseStack, bufferSource, light, armorTrim);
});
if (level != null && stack.has(DataComponents.TRIM)) {
model.renderTrim(poseStack, bufferSource, light, stack.get(DataComponents.TRIM));
}
if (stack.hasFoil()) {
model.renderGlint(poseStack, bufferSource, light);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@

import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import com.teamabode.guarding.Guarding;
import net.minecraft.advancements.critereon.ContextAwarePredicate;
import net.minecraft.advancements.critereon.CriterionValidator;
import net.minecraft.advancements.critereon.EntityPredicate;
import net.minecraft.advancements.critereon.SimpleCriterionTrigger;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.util.ExtraCodecs;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.storage.loot.LootContext;

Expand All @@ -29,8 +26,8 @@ public Codec<TriggerInstance> codec() {

public record TriggerInstance(Optional<ContextAwarePredicate> player, Optional<ContextAwarePredicate> victim) implements SimpleCriterionTrigger.SimpleInstance {
public static final Codec<TriggerInstance> CODEC = RecordCodecBuilder.create(instance -> instance.group(
ExtraCodecs.strictOptionalField(EntityPredicate.ADVANCEMENT_CODEC, "player").forGetter(TriggerInstance::player),
ExtraCodecs.strictOptionalField(EntityPredicate.ADVANCEMENT_CODEC, "victim").forGetter(TriggerInstance::victim)
EntityPredicate.ADVANCEMENT_CODEC.optionalFieldOf("player").forGetter(TriggerInstance::player),
EntityPredicate.ADVANCEMENT_CODEC.optionalFieldOf("victim").forGetter(TriggerInstance::victim)
).apply(instance, TriggerInstance::new));

public TriggerInstance(Optional<ContextAwarePredicate> player, Optional<ContextAwarePredicate> victim) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,7 @@
public class BarbedEnchantment extends GuardingEnchantment {

public BarbedEnchantment() {
super(Rarity.RARE);
}

public int getMinCost(int level) {
return 20;
}

public int getMaxCost(int level) {
return 50;
super(2, 1, Enchantment.constantCost(20), Enchantment.constantCost(50), 2);
}

protected boolean checkCompatibility(Enchantment other) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
package com.teamabode.guarding.common.enchantment;

import com.teamabode.guarding.Guarding;
import net.fabricmc.fabric.api.tag.convention.v1.ConventionalItemTags;
import net.fabricmc.fabric.api.tag.convention.v2.ConventionalItemTags;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.ShieldItem;
import net.minecraft.world.item.enchantment.Enchantment;

public class GuardingEnchantment extends Enchantment {

public GuardingEnchantment(Rarity rarity) {
super(rarity, Guarding.GUARDING_SHIELD, new EquipmentSlot[]{EquipmentSlot.MAINHAND});
}

public boolean canEnchant(ItemStack stack) {
return stack.is(ConventionalItemTags.SHIELDS) || stack.getItem() instanceof ShieldItem;
public GuardingEnchantment(int weight, int maxLevel, Cost minCost, Cost maxCost, int anvilCost) {
super(Enchantment.definition(Guarding.SHIELD_ENCHANTABLE, weight, maxLevel, minCost, maxCost, anvilCost, EquipmentSlot.MAINHAND));
}
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
package com.teamabode.guarding.common.enchantment;

import net.minecraft.world.item.enchantment.Enchantment;

public class PummelingEnchantment extends GuardingEnchantment {

public PummelingEnchantment() {
super(Rarity.COMMON);
}

public int getMinCost(int level) {
return level * 10;
}

public int getMaxCost(int level) {
return this.getMinCost(level) + 30;
}

public int getMaxLevel() {
return 3;
super(5, 3, Enchantment.dynamicCost(10, 10), Enchantment.dynamicCost(60, 10), 4);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,7 @@
public class RetributionEnchantment extends GuardingEnchantment {

public RetributionEnchantment() {
super(Rarity.RARE);
}

public int getMinCost(int level) {
return level * 25;
}

public int getMaxCost(int level) {
return 50;
}

public int getMaxLevel() {
return 2;
super(2, 2, Enchantment.dynamicCost(10, 25), Enchantment.dynamicCost(55, 25), 4);
}

public boolean isTreasureOnly() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,49 +1,52 @@
package com.teamabode.guarding.common.item;

import com.google.common.base.Suppliers;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Multimap;
import com.teamabode.guarding.core.init.GuardingSounds;
import net.minecraft.core.Holder;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.EquipmentSlotGroup;
import net.minecraft.world.entity.ai.attributes.Attribute;
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.ShieldItem;
import net.minecraft.world.item.component.ItemAttributeModifiers;

import java.util.UUID;
import java.util.function.Supplier;

public class NetheriteShieldItem extends ShieldItem {
private static final UUID MODIIFER_UUID = UUID.fromString("8b128327-f878-4e94-ada2-707cd81b13af");
private final Multimap<Attribute, AttributeModifier> defaultModifiers;
private final Supplier<ItemAttributeModifiers> defaultModifiers;

public NetheriteShieldItem(Properties properties) {
super(properties);

ImmutableMultimap.Builder<Attribute, AttributeModifier> builder = ImmutableMultimap.builder();


builder.put(Attributes.KNOCKBACK_RESISTANCE, new AttributeModifier(NetheriteShieldItem.MODIIFER_UUID, "Shield modifier", 0.1d, AttributeModifier.Operation.ADDITION));
this.defaultModifiers = builder.build();
this.defaultModifiers = Suppliers.memoize(() -> {
ItemAttributeModifiers.Builder builder = ItemAttributeModifiers.builder();
builder.add(Attributes.KNOCKBACK_RESISTANCE, new AttributeModifier(MODIIFER_UUID, "Shield modifier", 0.1d, AttributeModifier.Operation.ADD_VALUE), EquipmentSlotGroup.OFFHAND);
return builder.build();
});
}

public Multimap<Attribute, AttributeModifier> getDefaultAttributeModifiers(EquipmentSlot slot) {
if (slot == EquipmentSlot.OFFHAND) {
return this.defaultModifiers;
}
return super.getDefaultAttributeModifiers(slot);
@Override
public ItemAttributeModifiers getDefaultAttributeModifiers() {
return this.defaultModifiers.get();
}

public int getEnchantmentValue() {
return 15;
}

public SoundEvent getEquipSound() {
public Holder<SoundEvent> getEquipSound() {
return GuardingSounds.ITEM_NETHERITE_SHIELD_EQUIP;
}

public boolean isValidRepairItem(ItemStack stack, ItemStack repairCandidate) {
return repairCandidate.is(Items.NETHERITE_INGOT) || super.isValidRepairItem(stack, repairCandidate);
return repairCandidate.is(Items.NETHERITE_INGOT);
}
}
Loading

0 comments on commit c757493

Please sign in to comment.