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

1.20.4 #119

Open
wants to merge 6 commits into
base: 1.20
Choose a base branch
from
Open
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 HEADER
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) ${YEAR} LambdAurora <[email protected]>, Emi
Copyright (c) ${CREATION_YEAR} LambdAurora <[email protected]>, Emi

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
Expand All @@ -13,4 +13,4 @@ GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.

;;year_selection: file
#year_selection file
10 changes: 2 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins {
id 'org.quiltmc.loom' version '1.2.+'
id 'java-library'
id 'maven-publish'
id 'org.quiltmc.gradle.licenser' version '2.0.+'
id 'dev.yumi.gradle.licenser' version '1.1.+'
id 'com.modrinth.minotaur' version '2.+'
id 'com.matthewprenger.cursegradle' version '1.4.+'
}
Expand Down Expand Up @@ -70,13 +70,7 @@ dependencies {
mappings "org.quiltmc:quilt-mappings:${minecraft_version}+build.${project.quilt_mappings}:intermediary-v2"
modImplementation "org.quiltmc:quilt-loader:${project.loader_version}"

modImplementation include("org.quiltmc.qsl.core:crash_info:${project.qsl_version}+${project.minecraft_version}")
modImplementation include("org.quiltmc.qsl.core:resource_loader:${project.qsl_version}+${project.minecraft_version}")
modImplementation include("org.quiltmc.qsl.management:client_command:${project.qsl_version}+${project.minecraft_version}")
include("org.quiltmc.qsl.core:qsl_base:${project.qsl_version}+${project.minecraft_version}")
include("org.quiltmc.qsl.core:lifecycle_events:${project.qsl_version}+${project.minecraft_version}")
modImplementation include("org.quiltmc.qsl.data:tags:${project.qsl_version}+${project.minecraft_version}")
modImplementation include("org.quiltmc.qsl.gui:tooltip:${project.qsl_version}+${project.minecraft_version}")
modImplementation "org.quiltmc:qsl:${project.qsl_version}+${project.minecraft_version}"

// Only for ModMenu
/*modLocalRuntime("com.terraformersmc:modmenu:3.1.0") {
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
org.gradle.jvmargs=-Xmx1G

# Fabric properties
minecraft_version=1.20
quilt_mappings=1
loader_version=0.18.5
minecraft_version=1.20.4
quilt_mappings=3
loader_version=0.24.0

qsl_version=6.0.1
qsl_version=8.0.0-alpha.10

# Mod properties
mod_version=1.8.1
mod_version=1.9.0
maven_group=io.github.queerbric
archives_base_name=inspecio
modrinth_id=a93H3mKU
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
19 changes: 12 additions & 7 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -133,26 +131,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -197,6 +198,10 @@ if "$cygwin" || "$msys" ; then
done
fi


# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
Expand Down
22 changes: 10 additions & 12 deletions src/main/java/io/github/queerbric/inspecio/Inspecio.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
import io.github.queerbric.inspecio.api.InspecioEntrypoint;
import io.github.queerbric.inspecio.api.InventoryProvider;
import net.minecraft.block.Block;
import net.minecraft.block.DispenserBlock;
import net.minecraft.block.HopperBlock;
import net.minecraft.block.ShulkerBoxBlock;
import net.minecraft.block.dispenser.DispenserBlock;
import net.minecraft.entity.effect.StatusEffect;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.inventory.Inventories;
Expand All @@ -31,15 +31,14 @@
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtElement;
import net.minecraft.registry.Registries;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.tag.TagKey;
import net.minecraft.text.Text;
import net.minecraft.util.DyeColor;
import net.minecraft.util.Formatting;
import net.minecraft.util.Identifier;
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.random.LegacySimpleRandom;
import net.minecraft.util.random.RandomGenerator;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.Nullable;
Expand All @@ -65,8 +64,6 @@ public class Inspecio implements ClientModInitializer {
RegistryKeys.ITEM, new Identifier(NAMESPACE, "hidden_effects"),
TagType.CLIENT_FALLBACK
);
public static final RandomGenerator COMMON_RANDOM = new LegacySimpleRandom(System.currentTimeMillis());
public static final Identifier GUI_ICONS_TEXTURE = new Identifier("textures/gui/icons.png");
private static InspecioConfig config = InspecioConfig.defaultConfig();
private static ModContainer mod;

Expand Down Expand Up @@ -214,15 +211,16 @@ public static void removeVanillaTooltips(List<Text> tooltips, int fromIndex) {
}

public static @Nullable StatusEffectInstance getRawEffectFromTag(NbtCompound tag, String tagKey) {
if (tag == null) {
if (tag.contains(tagKey, NbtElement.STRING_TYPE)) {
Identifier identifier = Identifier.tryParse(tag.getString(tagKey));
StatusEffect statusEffect = Registries.STATUS_EFFECT.get(identifier);
if(statusEffect == null){
return null;
}
return new StatusEffectInstance(statusEffect, 200, 1);
} else {
return null;
}
if (tag.contains(tagKey, NbtElement.INT_TYPE)) {
var effect = StatusEffect.byRawId(tag.getInt(tagKey));
if (effect != null)
return new StatusEffectInstance(effect, 200, 0);
}
return null;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.mojang.serialization.JsonOps;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.block.*;
import net.minecraft.block.dispenser.DispenserBlock;
import net.minecraft.util.math.MathHelper;
import org.jetbrains.annotations.Nullable;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,21 @@ public Optional<TooltipData> getTooltipData(ItemStack stack) {
if (effectsConfig.hasBeacon() && this.getBlock() instanceof BeaconBlock) {
var blockEntityTag = BlockItem.getBlockEntityNbtFromStack(stack);
var effectsList = new ArrayList<StatusEffectInstance>();
var primary = Inspecio.getRawEffectFromTag(blockEntityTag, "Primary");
var secondary = Inspecio.getRawEffectFromTag(blockEntityTag, "Secondary");

if (primary != null && primary.equals(secondary)) {
primary = new StatusEffectInstance(primary.getEffectType(), 200, 1);
secondary = null;
}
if (primary != null)
effectsList.add(primary);
if (secondary != null)
effectsList.add(secondary);

if (blockEntityTag != null) {
var primary = Inspecio.getRawEffectFromTag(blockEntityTag, "primary_effect");
var secondary = Inspecio.getRawEffectFromTag(blockEntityTag, "secondary_effect");

if (primary != null && primary.equals(secondary)) {
primary = new StatusEffectInstance(primary.getEffectType(), 200, 1);
secondary = null;
}
if (primary != null)
effectsList.add(primary);
if (secondary != null)
effectsList.add(secondary);
}
return Optional.of(new StatusEffectTooltipComponent(effectsList, 1F));
} else if (this.getBlock() instanceof BeehiveBlock) {
var data = BeesTooltipComponent.of(stack);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@
import net.minecraft.client.gui.tooltip.TooltipComponent;
import net.minecraft.item.ArmorItem;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;
import org.quiltmc.qsl.tooltip.api.ConvertibleTooltipData;

import java.util.Optional;

public class ArmorTooltipComponent implements ConvertibleTooltipData, TooltipComponent {
private static final Identifier ARMOR_HALF_TEXTURE = new Identifier("hud/armor_half");
private static final Identifier ARMOR_FULL_TEXTURE = new Identifier("hud/armor_full");
private final int prot;

public ArmorTooltipComponent(int prot) {
Expand Down Expand Up @@ -66,10 +69,10 @@ public int getWidth(TextRenderer textRenderer) {
@Override
public void drawItems(TextRenderer textRenderer, int x, int y, GuiGraphics graphics) {
for (int i = 0; i < this.prot / 2; i++) {
graphics.drawTexture(Inspecio.GUI_ICONS_TEXTURE, x + i * 9, y, 34, 9, 9, 9, 256, 256);
graphics.drawGuiTexture(ARMOR_FULL_TEXTURE, x + i * 9, y, 9, 9);
}
if (this.prot % 2 == 1) {
graphics.drawTexture(Inspecio.GUI_ICONS_TEXTURE, x + this.prot / 2 * 9, y, 25, 9, 9, 9, 256, 256);
graphics.drawGuiTexture(ARMOR_HALF_TEXTURE,x + this.prot / 2 * 9, y, 9, 9);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import java.util.Optional;

/**
* Represents a tooltip component which displays bees from a beehive.
* Represents a tooltip component which displays entities from a bucket.
*
* @author LambdAurora
* @version 1.8.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,17 @@
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.tooltip.TooltipComponent;
import net.minecraft.item.FoodComponent;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.MathHelper;
import org.quiltmc.qsl.tooltip.api.ConvertibleTooltipData;

public record FoodTooltipComponent(int hunger, float saturation) implements ConvertibleTooltipData, TooltipComponent {

private static final Identifier FOOD_EMPTY_TEXTURE = new Identifier("hud/food_empty");
private static final Identifier FOOD_HALF_TEXTURE = new Identifier("hud/food_half");
private static final Identifier FOOD_FULL_TEXTURE = new Identifier("hud/food_full");
private static final Identifier HUNGER_OUTLINE = new Identifier(Inspecio.NAMESPACE, "textures/tooltips/hunger_outline.png");

public FoodTooltipComponent(FoodComponent component) {
this(component.getHunger(), component.getHunger() * component.getSaturationModifier());
}
Expand Down Expand Up @@ -76,7 +83,7 @@ public void drawItems(TextRenderer textRenderer, int x, int y, GuiGraphics graph
if (foodConfig.hasHunger()) {
for (int i = 0; i < (this.hunger + 1) / 2; i++) {
pos.wrap(i);
graphics.drawTexture(Inspecio.GUI_ICONS_TEXTURE, pos.x, pos.y, 16, 27, 9, 9, 256, 256);
graphics.drawGuiTexture(FOOD_EMPTY_TEXTURE, pos.x, pos.y, 9, 9);
pos.moveForward();
}
}
Expand All @@ -94,7 +101,7 @@ public void drawItems(TextRenderer textRenderer, int x, int y, GuiGraphics graph
if (this.saturation - i < 1f) {
width = Math.round(width * (saturation - i));
}
graphics.drawTexture(Inspecio.GUI_ICONS_TEXTURE, pos.x, pos.y, 25, 27, width, 9, 256, 256);
graphics.drawTexture(HUNGER_OUTLINE, pos.x, pos.y, 0, 0, width, 9, 9, 9);

pos.moveForward();
}
Expand All @@ -107,13 +114,13 @@ public void drawItems(TextRenderer textRenderer, int x, int y, GuiGraphics graph

for (int i = 0; i < this.hunger / 2; i++) {
pos.wrap(i);
graphics.drawTexture(Inspecio.GUI_ICONS_TEXTURE, pos.x, pos.y, 52, 27, 9, 9, 256, 256);
graphics.drawGuiTexture(FOOD_FULL_TEXTURE, pos.x, pos.y, 9, 9);
pos.moveForward();
}

if (this.hunger % 2 == 1) {
pos.wrap(this.hunger / 2);
graphics.drawTexture(Inspecio.GUI_ICONS_TEXTURE, pos.x, pos.y, 61, 27, 9, 9, 256, 256);
graphics.drawGuiTexture(FOOD_HALF_TEXTURE, pos.x, pos.y, 9, 9);
}
}

Expand All @@ -129,13 +136,13 @@ public void drawItems(TextRenderer textRenderer, int x, int y, GuiGraphics graph

for (int i = 0; i < intSaturation / 2; i++) {
pos.wrap(i);
graphics.drawTexture(Inspecio.GUI_ICONS_TEXTURE, pos.x, pos.y, 52, 27, 9, 9, 256, 256);
graphics.drawGuiTexture(FOOD_FULL_TEXTURE, pos.x, pos.y, 9, 9);
pos.moveForward();
}

if (intSaturation % 2 == 1) {
pos.wrap(intSaturation / 2);
graphics.drawTexture(Inspecio.GUI_ICONS_TEXTURE, pos.x, pos.y, 61, 27, 9, 9, 256, 256);
graphics.drawGuiTexture(FOOD_HALF_TEXTURE, pos.x, pos.y, 9, 9);
}

RenderSystem.setShaderColor(1.f, 1.f, 1.f, 1.f);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
* @since 1.0.0
*/
public class InventoryTooltipComponent implements ConvertibleTooltipData, TooltipComponent {
private static final Identifier STATS_ICONS_TEXTURE = new Identifier("textures/gui/container/stats_icons.png");
private static final Identifier SLOT_TEXTURE = new Identifier("container/slot");
private final List<ItemStack> inventory;
private final int columns;
private final DyeColor color;
Expand Down Expand Up @@ -128,7 +128,7 @@ public static void drawSlot(GuiGraphics graphics, int x, int y, int z, float[] c
if (color == null)
color = new float[]{1.f, 1.f, 1.f};
RenderSystem.setShaderColor(color[0], color[1], color[2], 1.f);
graphics.drawTexture(STATS_ICONS_TEXTURE, x, y, z, 0.f, 0.f, 18, 18, 128, 128);
graphics.drawGuiTexture(SLOT_TEXTURE, x, y, z, 18, 18);
RenderSystem.setShaderColor(1.f, 1.f, 1.f, 1.f);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
import com.mojang.blaze3d.vertex.VertexConsumer;
import io.github.queerbric.inspecio.Inspecio;
import io.github.queerbric.inspecio.SignTooltipMode;
import net.minecraft.block.AbstractSignBlock;
import net.minecraft.block.entity.SignText;
import net.minecraft.block.sign.AbstractSignBlock;
import net.minecraft.block.sign.SignType;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.GuiGraphics;
Expand All @@ -49,7 +50,6 @@
import net.minecraft.text.Text;
import net.minecraft.util.DyeColor;
import net.minecraft.util.Identifier;
import net.minecraft.util.SignType;
import net.minecraft.util.math.Axis;
import org.joml.Matrix4f;
import org.quiltmc.qsl.tooltip.api.ConvertibleTooltipData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void sendStatus(World world, BlockPos pos, int eventType) {
};
logic.readNbt(client.world, client.player.getBlockPos(), nbt);

var entity = logic.getRenderedEntity(client.world, Inspecio.COMMON_RANDOM, client.player.getBlockPos());
var entity = logic.getRenderedEntity(client.world, client.player.getBlockPos());
if (entity != null) {
return Optional.of(new SpawnEntityTooltipComponent(entitiesConfig.getMobSpawnerConfig(), entity));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ private String getStatusEffectName(StatusEffectInstance statusEffectInstance) {
}

private Text getDuration(int index, StatusEffectInstance statusEffect) {
var duration = StatusEffectUtil.durationToString(statusEffect, multiplier);
var duration = StatusEffectUtil.durationToString(statusEffect, multiplier, 1.f);

if (this.chances.size() > index && this.chances.getFloat(index) < 1f) {
duration = duration.copy().append(" - " + (int) (this.chances.getFloat(index) * 100f) + "%");
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/main/resources/quilt.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
"depends": [
{
"id": "minecraft",
"versions": "~1.20"
"versions": "1.20.4"
},
{
"id": "quilt_loader",
"versions": ">=0.17.11"
"versions": ">=0.24.0"
},
"quilt_client_command",
"quilt_resource_loader",
Expand Down