Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated to 1.20.6 #179

Merged
merged 20 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
matrix:
# Use these Java versions
java: [
17 # Minimum supported by Minecraft
21 # Minimum supported by Minecraft
]
# and run on both Linux and Windows
os: [ubuntu-20.04, windows-latest]
Expand All @@ -32,7 +32,7 @@ jobs:
- name: build
run: ./gradlew build
- name: capture build artifacts
if: ${{ runner.os == 'Linux' && matrix.java == '17' }} # Only upload artifacts built from the latest java on one OS
if: ${{ runner.os == 'Linux' && matrix.java == '21' }} # Only upload artifacts built from the latest java on one OS
uses: actions/upload-artifact@v2
with:
name: Artifacts
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ library is distributed via [jitpack.io](https://jitpack.io/#CrimsonDawn45/Fabric

#### put this in gradle.properties
```properties
fabric_shield_lib_version=1.7.2-1.20.2
fabric_shield_lib_version=1.7.2-1.20.6
```

#### build.gradle under repositories just above dependencies
Expand Down
14 changes: 5 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
plugins {
id 'fabric-loom' version '1.4-SNAPSHOT'
id 'fabric-loom' version '1.6-SNAPSHOT'
id 'maven-publish'
}

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

archivesBaseName = project.archives_base_name
version = project.mod_version
Expand Down Expand Up @@ -39,10 +39,6 @@ dependencies {
include "maven.modrinth:midnightlib:${project.midnightlib_version}"
}

loom {
accessWidenerPath = file("src/main/resources/fabricshieldlib.accesswidener")
}

processResources {
inputs.property "version", project.version

Expand All @@ -53,7 +49,7 @@ processResources {

tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
it.options.release = 17
it.options.release = 21
}

java {
Expand All @@ -80,4 +76,4 @@ publishing {
}
repositories {
}
}
}
14 changes: 7 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/develop/
minecraft_version=1.20.4
yarn_mappings=1.20.4+build.2
loader_version=0.15.1
minecraft_version=1.20.6
yarn_mappings=1.20.6+build.3
loader_version=0.15.11

# Mod Properties
mod_version=1.7.2-1.20.4
mod_version=1.7.2-1.20.6
maven_group=com.github.crimsondawn45
archives_base_name=FabricShieldLib

# Dependencies
fabric_version=0.91.1+1.20.4
mod_menu_version=9.0.0-pre.1
midnightlib_version=1.5.2-fabric
fabric_version=0.100.0+1.20.6
mod_menu_version=10.0.0-beta.1
midnightlib_version=1.5.5-fabric

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.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
4 changes: 2 additions & 2 deletions jitpack.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
before_install:
- export SDKMAN_DIR="/home/jitpack/sdkman" && curl -s "https://get.sdkman.io" | bash
- source "/home/jitpack/sdkman/bin/sdkman-init.sh"
- sdk install java 17.0.2-open
- sdk use java 17.0.2-open
- sdk install java 21.0.2-open
- sdk use java 21.0.2-open

# Thanks to Jamalam360 for fixing this.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroups;
import net.minecraft.item.Items;
import net.minecraft.item.ShieldItem;
import net.minecraft.recipe.RecipeType;
import net.minecraft.recipe.SpecialRecipeSerializer;
import net.minecraft.registry.Registries;
Expand All @@ -35,6 +36,9 @@
@SuppressWarnings("ALL")
public class FabricShieldLib implements ModInitializer {

public static ShieldItem testshield;


/**
* Fabric Shield Lib's mod id.
*/
Expand Down Expand Up @@ -90,12 +94,13 @@ public void onInitialize() {
logger.warn("FABRIC SHIELD LIB DEVELOPMENT CODE RAN!!!, if you are not in a development environment this is very bad! Test items and test enchantments will be ingame!");

//Register Custom Shield
fabric_banner_shield = Registry.register(Registries.ITEM, new Identifier(MOD_ID, "fabric_banner_shield"),
new FabricBannerShieldItem(new Item.Settings().maxDamage(336), 85, 9, Items.OAK_PLANKS, Items.SPRUCE_PLANKS));
fabric_shield = Registry.register(Registries.ITEM, new Identifier(MOD_ID, "fabric_shield"),
new FabricShieldItem(new Item.Settings().maxDamage(336), 100, 9, Items.OAK_PLANKS, Items.SPRUCE_PLANKS));
reflect_enchantment = Registry.register(Registries.ENCHANTMENT, new Identifier(MOD_ID, "reflect_enchantment"),
new FabricShieldEnchantment(Enchantment.Rarity.COMMON, false, false));
fabric_banner_shield = Registry.register(Registries.ITEM, new Identifier(MOD_ID, "fabric_banner_shield"), new FabricBannerShieldItem(new Item.Settings().maxDamage(336), 85, 9, Items.OAK_PLANKS, Items.SPRUCE_PLANKS));

fabric_shield = Registry.register(Registries.ITEM, new Identifier(MOD_ID, "fabric_shield"), new FabricShieldItem(new Item.Settings().maxDamage(336), 100, 9, Items.OAK_PLANKS, Items.SPRUCE_PLANKS));

reflect_enchantment = Registry.register(Registries.ENCHANTMENT, new Identifier(MOD_ID, "reflect_enchantment"), new FabricShieldEnchantment(2, 1, new Enchantment.Cost(1, 5), new Enchantment.Cost(1, 7), 5, false, false, true));

testshield = Registry.register(Registries.ITEM, new Identifier(MOD_ID, "test_shield"), new ShieldItem(new Item.Settings().maxDamage(336)));

ItemGroupEvents.modifyEntriesEvent(ItemGroups.COMBAT).register(entries -> {
entries.addAfter(Items.SHIELD,fabric_banner_shield);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@

import com.github.crimsondawn45.fabricshieldlib.lib.config.FabricShieldLibConfig;
import com.github.crimsondawn45.fabricshieldlib.lib.event.ShieldSetModelCallback;
import com.github.crimsondawn45.fabricshieldlib.lib.object.FabricBannerShieldItem;
import com.github.crimsondawn45.fabricshieldlib.lib.object.FabricShield;
import com.mojang.datafixers.util.Pair;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.item.v1.ItemTooltipCallback;
import net.fabricmc.fabric.api.client.rendering.v1.BuiltinItemRendererRegistry;
import net.fabricmc.fabric.api.client.rendering.v1.EntityModelLayerRegistry;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.block.entity.BannerBlockEntity;
import net.minecraft.block.entity.BannerPattern;
import net.minecraft.client.item.TooltipContext;
import net.minecraft.client.item.TooltipType;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.block.entity.BannerBlockEntityRenderer;
Expand All @@ -22,9 +18,10 @@
import net.minecraft.client.texture.SpriteAtlasTexture;
import net.minecraft.client.util.SpriteIdentifier;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.component.type.BannerPatternsComponent;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.text.Text;
import net.minecraft.util.ActionResult;
import net.minecraft.util.DyeColor;
Expand All @@ -33,6 +30,8 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;


public class FabricShieldLibClient implements ClientModInitializer {

Expand All @@ -53,7 +52,7 @@ public void onInitializeClient() {
* Register tooltip callback this is the same as mixing into the end of:
* ItemStack.getTooltip()
*/
ItemTooltipCallback.EVENT.register((stack, context, tooltip) -> {
ItemTooltipCallback.EVENT.register((stack, context, type, tooltip) -> {

if(FabricShieldLibConfig.enable_tooltips) {

Expand All @@ -62,17 +61,17 @@ public void onInitializeClient() {
FabricShield shield = (FabricShield) stack.getItem();

//Add any custom tooltips
shield.appendShieldTooltip(stack, tooltip, context);
shield.appendTooltip(stack, context, tooltip, type);

//Add cooldown tooltip
if(shield.displayTooltip()) {
getCooldownTooltip(stack, context,tooltip, shield.getCoolDownTicks());
getCooldownTooltip(stack, type ,tooltip, shield.getCoolDownTicks());
}
}

//Display tooltip for vanilla shield
if(stack.getItem().equals(Items.SHIELD)) {
getCooldownTooltip(stack, context,tooltip, 100);
getCooldownTooltip(stack, type,tooltip, 100);
}
}
});
Expand Down Expand Up @@ -104,33 +103,35 @@ public void onInitializeClient() {
* Uses params from the mixin method, and the model and sprite identifiers made by the player.
*/
public static void renderBanner(ItemStack stack, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay, ShieldEntityModel model, SpriteIdentifier base, SpriteIdentifier base_nopattern){
boolean bl = stack.getSubNbt("BlockEntityTag") != null;
BannerPatternsComponent bannerPatternsComponent = (BannerPatternsComponent)stack.getOrDefault(DataComponentTypes.BANNER_PATTERNS, BannerPatternsComponent.DEFAULT);
DyeColor dyeColor2 = (DyeColor)stack.get(DataComponentTypes.BASE_COLOR);
boolean bl = !bannerPatternsComponent.layers().isEmpty() || dyeColor2 != null;
matrices.push();
matrices.scale(1.0F, -1.0F, -1.0F);
SpriteIdentifier spriteIdentifier = bl ? base : base_nopattern;
VertexConsumer vertexConsumer = spriteIdentifier.getSprite().getTextureSpecificVertexConsumer(ItemRenderer.getDirectItemGlintConsumer(vertexConsumers, model.getLayer(spriteIdentifier.getAtlasId()), true, stack.hasGlint()));
model.getHandle().render(matrices, vertexConsumer, light, overlay, 1.0F, 1.0F, 1.0F, 1.0F);
if (bl) {
List<Pair<RegistryEntry<BannerPattern>, DyeColor>> list = BannerBlockEntity.getPatternsFromNbt(FabricBannerShieldItem.getColor(stack), BannerBlockEntity.getPatternListNbt(stack));
BannerBlockEntityRenderer.renderCanvas(matrices, vertexConsumers, light, overlay, model.getPlate(), spriteIdentifier, false, list, stack.hasGlint());
BannerBlockEntityRenderer.renderCanvas(matrices, vertexConsumers, light, overlay, model.getPlate(), spriteIdentifier, false, (DyeColor) Objects.requireNonNullElse(dyeColor2, DyeColor.WHITE), bannerPatternsComponent, stack.hasGlint());
} else {
model.getPlate().render(matrices, vertexConsumer, light, overlay, 1.0F, 1.0F, 1.0F, 1.0F);
}

matrices.pop();
}

/**
* Shield tooltip thing.
*/
public static List<Text> getCooldownTooltip(ItemStack stack, TooltipContext context, List<Text> tooltip, int cooldownTicks) {
public static List<Text> getCooldownTooltip(ItemStack stack, TooltipType type, List<Text> tooltip, int cooldownTicks) {

List<Text> advanced = new ArrayList<Text>();

/*
* These all loop in reverse to grab the first instance of a match
* at the end of the tooltip
*/
if(context.isAdvanced()) {
if(type.isAdvanced()) {

//Grab durability
if(stack.isDamaged()) {
Expand Down Expand Up @@ -162,7 +163,7 @@ public static List<Text> getCooldownTooltip(ItemStack stack, TooltipContext cont
}

//Grab nbt string
if(stack.hasNbt()) {
if(!stack.getComponents().isEmpty()) {
for(int i = tooltip.size() - 1; i > 0; i--) {

Text text = tooltip.get(i);
Expand Down Expand Up @@ -204,7 +205,7 @@ public static List<Text> getCooldownTooltip(ItemStack stack, TooltipContext cont
.append(Text.translatable("fabricshieldlib.shield_tooltip.end")));

//Append advanced info
if(context.isAdvanced()) {
if(type.isAdvanced()) {
tooltip.addAll(advanced);
}
return tooltip;
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.block.DispenserBlock;
import net.minecraft.client.item.ModelPredicateProviderRegistry;
import net.minecraft.client.item.TooltipContext;
import net.minecraft.client.item.TooltipType;
import net.minecraft.client.render.entity.model.ShieldEntityModel;
import net.minecraft.client.util.SpriteIdentifier;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.*;
import net.minecraft.recipe.Ingredient;
Expand Down Expand Up @@ -134,24 +135,21 @@ private void RegisterModelPredicate() {
}

public String getTranslationKey(ItemStack stack) {
if (stack.getSubNbt("BlockEntityTag") != null) {
DyeColor dyeColor = (DyeColor)stack.get(DataComponentTypes.BASE_COLOR);
if (dyeColor != null) {
String key = this.getTranslationKey();
return key + "." + getColor(stack).getName();
return key + "." + dyeColor.getName();
} else {
return super.getTranslationKey(stack);
}
}

public static DyeColor getColor(ItemStack stack) {
return DyeColor.byId(stack.getOrCreateSubNbt("BlockEntityTag").getInt("Base"));
}

public void appendTooltip(ItemStack stack, World world, List<Text> tooltip, TooltipContext context) {
BannerItem.appendBannerTooltip(stack, tooltip);
}

@Override
public void appendShieldTooltip(ItemStack stack, List<Text> tooltip, TooltipContext context) {
public void appendTooltip(ItemStack stack, Item.TooltipContext context, List<Text> tooltip, TooltipType type) {
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.crimsondawn45.fabricshieldlib.lib.object;

import net.minecraft.client.item.TooltipContext;
import net.minecraft.client.item.TooltipType;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.text.Text;

Expand Down Expand Up @@ -39,6 +40,6 @@ default boolean displayTooltip() {
* @param tooltip current tooltip
* @param context context
*/
default void appendShieldTooltip(ItemStack stack, List<Text> tooltip, TooltipContext context) {
default void appendTooltip(ItemStack stack, Item.TooltipContext context, List<Text> tooltip, TooltipType type) {
}
}
Loading
Loading