Skip to content

Commit

Permalink
Merge tag '1.4.0+1.19.4' into 1.20.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Estecka committed Jan 30, 2024
2 parents e3b4957 + bbe9ba7 commit 3b0e00a
Show file tree
Hide file tree
Showing 111 changed files with 395 additions and 301 deletions.
15 changes: 2 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@

name: build
on:
push:
tags:
- '*'
- workflow_call
- workflow_dispatch

jobs:
build:
Expand All @@ -20,8 +19,6 @@ jobs:
# and run on both Linux and Windows
os: [ubuntu-22.04, windows-2022]
runs-on: ${{ matrix.os }}
permissions:
contents: write # Required to create releases
steps:
- name: checkout repository
uses: actions/checkout@v3
Expand All @@ -43,11 +40,3 @@ jobs:
with:
name: Artifacts
path: build/libs/
- name: create release
if: ${{ runner.os == 'Linux' && matrix.java == '17' }}
uses: marvinpinto/[email protected]
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
draft: true
prerelease: false
files: "build/libs/*.jar"
26 changes: 26 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: release
on:
push:
tags:
- '*'

jobs:
build:
uses: ./.github/workflows/build.yml
release:
needs: [ build ]
runs-on: ubuntu-22.04
permissions:
contents: write
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: Artifacts
path: ./
- name: Draft release
uses: ncipollo/[email protected]
with:
artifacts: ./*.jar
artifactErrorsFailBuild: true
draft: true
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ When a painting is broken, it will drop the variant-locked item instead of the b
Blank paintings can no longer be placed in survival, but can be used as crafting ingredients.

### Dependencies
Some specific features depend on **[Patched](https://modrinth.com/mod/patched)** (server-side) and **[CIT Resewn](https://modrinth.com/mod/cit-resewn)** (client-side), but both are completely optional.
**[Patched](https://modrinth.com/mod/patched)** (server-side) is required in order to add items to some loot tables. However Invarpaint can still safely run without it.

The mod is mostly optional on client. The worst a client without the mod may experience is a desyncing issue when trying to place a blank painting, or when trying to place a filled painting in too small a space.
Invarpaint is mostly optional on client. The worst a client without the mod may experience is a desyncing issue when trying to place a blank painting, or when trying to place a filled painting in a space that is too small.

## Obtaining paintings
### Trading
Filled paintings can be bought from **Master Shepherds** and **Wandering Traders**. Shepherds no longer sell variantless paintings, this will not retroactively apply to existing shepherds.
Filled paintings can be bought from **Master Shepherds** and **Wandering Traders**. Shepherds no longer sell variantless paintings. (This will not retroactively apply to existing shepherds).

### Looting
This features requires **[Patched](https://modrinth.com/mod/patched)**.
Expand Down Expand Up @@ -53,32 +53,32 @@ This pack can be used together with the cloning one.
- **Cloning:** Contains nothing but the cloning recipe, which is not included in most other presets. Using this pack alone will make paintings closer to banner templates or trimming templates: You can only find new paintings by exploring, but once you find one, you can reuse it indefinitely.


## Inventory painting textures
This feature requires **[CIT Resewn](https://modrinth.com/mod/cit-resewn)**.
## Inventory Icons

Allows filled paintings to have unique textures in the inventory, depending on their variant.
Paintings in the inventory can have unique textures depending on their variant.

This is, strictly speaking, not a feature of Invariable-Paintings. It provides a built-in resource pack that is then used by CIT-Resewn, but does not add any of its own code on top of it.
Invarpaint provides icons for vanilla paintings, but it does not currently generate icons for modded paintings. Those should be provided via resource packs.

Invariable-Paintings only provides the CITs for the vanilla variants. For modded variants, CITs should be provided in an external resource pack. See [the sources](https://github.com/Estecka/mc-invariable-paintings/tree/HEAD/src/client/resources/resourcepacks/vanilla-cit) for an example on how to make one, and refer to [CIT resewn's documentation](https://citresewn.shcm.io/) for additional information.
Custom icons are located at `/textures/<namespace>/item/painting/<variant>.png`, and matched to the variant with the corresponding id. Variants that lack a custom icon will fall back to a generic built-in one.

Having too many painting CITs (around hundreds of them) can put a toll on the game's performances, so the embedded vanilla CITs can be disabled in the resource-pack menu.
Older versions of the mods relied on CIT-resewn, but this is no longer necessary. CIT-resewn is still compatible, and old texture packs should still be able to override Invarpaint's textures. However, switching to Invarpaint's specialized cit logic should be preferred to improve performances.


## Miscellaneous tweaks
### Server-side
- Placement of variant-locked paintings in tight spaces is more forgiving. (Vanilla would require targeting some specific block.)
- Added a new loot function `lock_variant_randomly`, which can applied to painting items in loot tables.
- Added a new loot function `invarpaint:lock_variant_randomly`, which can applied to painting items in loot tables.

### Client-side
- Fixes a vanilla bug whereby paiting items may sometimes appear to be consummed, without actually placing a painting.
- Fixes a vanilla bug whereby paiting items may sometimes appear to be consumed, without actually placing the painting.
- Shows a warning when trying to place a painting in too small a space.
- Slightly reworked the tooltip for painting items.
- Creative players can pick a painting's variant by holding Ctrl.


## Compatibility
Any mod that adds new paintings based on the vanilla system will be compatible, and their paintings will be obtainable through all existing means.

Mods that bypass the vanilla system and implement their own, like _Custom Paintings_ or _Client Paintings_, are not compatible. Amongst the user-defined painting mods I know of, [More Canvases v2](https://modrinth.com/mod/more-canvases) is the one that is compatible with Invariable Paintings.
Mods that bypass the vanilla system and implement their own, like _Custom Paintings_ or _Client Paintings_, are not compatible. Amongst user-defined painting mods, [More Canvases](https://modrinth.com/mod/more-canvases) was made to be compatible with Invariable Paintings.

Mods that give you a Painting selection GUI, or that lets you edit already placed paintings, are not necessarily incompatible on a technical level, but are conceptually incompatible with the idea of collectible paintings.
9 changes: 1 addition & 8 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.3-SNAPSHOT'
id 'fabric-loom' version '1.5-SNAPSHOT'
id 'maven-publish'
}

Expand All @@ -16,8 +16,6 @@ repositories {
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.

maven { url 'https://jitpack.io' }
}

loom {
Expand All @@ -41,11 +39,6 @@ dependencies {
// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

// MixinExtras
include("com.github.LlamaLad7:MixinExtras:0.1.1")
implementation("com.github.LlamaLad7:MixinExtras:0.1.1")
annotationProcessor("com.github.LlamaLad7:MixinExtras:0.1.1")

// Uncomment the following line to enable the deprecated Fabric API modules.
// These are included in the Fabric API production distribution and allow you to update your mod to the latest modules at a later more convenient time.

Expand Down
7 changes: 7 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,10 @@
- Moved the loot tables to a datapack, which can be disabled.
### 1.3.2
- Updated version dependencies

## 1.4
- Added a specialized and more performant CIT logic for painting items. CIT-Resewn is no longer a dependency.
- Painting variants can be picked with Ctrl
- Increased the price of paintings trades.
- "Recycling" preset no longer forbids blank canvas crafting.
- Copied the lootfunction to invarpaint's own namespace. Marked the old one as deprecated.
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ org.gradle.parallel=true
# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.1
loader_version=0.14.22
yarn_mappings=1.20.1+build.10
loader_version=0.15.6

#Fabric api
fabric_version=0.83.1+1.20.1
fabric_version=0.91.0+1.20.1

# Mod Properties
mod_version = 1.3.2
mod_version = 1.4.0
maven_group = tk.estecka.invarpaint
archives_base_name = invariable-paintings
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.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
22 changes: 13 additions & 9 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# 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 @@ -130,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=SC2039,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=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -198,11 +202,11 @@ 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
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
20 changes: 20 additions & 0 deletions port.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minecraft Code Breaking Changes
### 1.19.4
Current master

### 1.20.0
- Crafting recipes and CrafitnScreenHandler receive a `RecipeInputInventory` instead of a `CraftingInventory`.
- Data pack format changed to 15. (Format range not supported in this version.) (Not really a breaking change.)

### 1.20.2
- Recipe constructors no longer take an ID
- Recipe `Serializer` must be backed up by a `Codec`
- Loot functions require a `Codec` instead of a `Serializer`
- Loot functions take conditions as a `List` instead of as an arrays.
- Trades should also be registered for the Trade Rebalance feature.
- CraftingScreenHandler receives recipes wrapped inside a `RecipeEntry`

### 1.20.3
- ~~Text serialization method moved elsewhere~~ (Yarn mapping change)
- Crafting category deserialization method was removed (Avoidable by using other methods)
- The field `CraftingRecipeCategory::CODEC` had its signature changed (Avoidable by getting it from elsewhere)
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
public class InvariablePaintingsClient
implements ClientModInitializer
{
static public final Identifier CIT_MISSING = new Identifier("invarpaint", "item/missing_painting");
static public final Identifier CIT_FILLED = new Identifier("invarpaint", "item/filled_painting");
static public final Identifier CIT_RANDOM = new Identifier("invarpaint", "item/random_painting");
static public final String CIT_PREFIX = "item/painting/";

public void onInitializeClient(){
var mod = FabricLoader.getInstance().getModContainer(MODID).get();
ResourceManagerHelper.registerBuiltinResourcePack(
Expand Down
69 changes: 69 additions & 0 deletions src/client/java/tk/estecka/invarpaint/UnbakedPaintingItem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package tk.estecka.invarpaint;

import java.util.Collection;
import java.util.List;
import java.util.function.Function;
import org.jetbrains.annotations.Nullable;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.Baker;
import net.minecraft.client.render.model.ModelBakeSettings;
import net.minecraft.client.render.model.UnbakedModel;
import net.minecraft.client.render.model.json.JsonUnbakedModel;
import net.minecraft.client.texture.Sprite;
import net.minecraft.client.util.SpriteIdentifier;
import net.minecraft.util.Identifier;

public class UnbakedPaintingItem
implements UnbakedModel
{
static private final String ARBITRARY_MODEL = """
{
"parent": "item/generated",
"textures": {
"layer0": "%s"
}
}
""";

private final Identifier texture;
private final @Nullable Identifier fallback;
public final JsonUnbakedModel inner;

static public JsonUnbakedModel CreateJson(Identifier id){
return JsonUnbakedModel.deserialize(ARBITRARY_MODEL.formatted(id.toString()));
}

public UnbakedPaintingItem(Identifier textureId, @Nullable Identifier fallbackId){
this.texture = textureId.withPrefixedPath("textures/").withSuffixedPath(".png");
this.fallback = fallbackId;
this.inner = CreateJson(textureId);
}

@Override
public Collection<Identifier> getModelDependencies(){
var deps = List.copyOf(inner.getModelDependencies());
deps.add(fallback);
return deps;
}

@Override
public void setParents(Function<Identifier, UnbakedModel> modelLoader){
inner.setParents(modelLoader);
}

/**
* Will only be called when the texture is missing, thanks to the janky
* implementation of `ModelLoader$BakerImpl`.
*/
@Override
public @Nullable BakedModel bake(Baker baker, Function<SpriteIdentifier, Sprite> spriteGetter, ModelBakeSettings settings, Identifier id){
return baker.bake(fallback, settings);
}

public boolean ShouldFallback(){
return this.fallback != null
&& MinecraftClient.getInstance().getResourceManager().getResource(texture).isEmpty()
;
}
}
Loading

0 comments on commit 3b0e00a

Please sign in to comment.