Skip to content

Commit

Permalink
Merge pull request #162 from viciscat/main
Browse files Browse the repository at this point in the history
1.21.3/4 port
  • Loading branch information
tr7zw authored Dec 29, 2024
2 parents 6db876c + 8ce2c86 commit 320d075
Show file tree
Hide file tree
Showing 32 changed files with 407 additions and 157 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
java-version: 21
# to cache gradle files
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
uses: gradle/actions/setup-gradle@v4
with:
gradle-home-cache-cleanup: true
dependency-graph: generate-and-submit
Expand All @@ -28,7 +28,7 @@ jobs:
- name: build
run: ./gradlecw build
- name: capture build artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: Artifacts
path: 'versions/**/build/libs/*.jar'
Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,39 @@ jobs:
name: ${{github.ref_name}}-1.21 - Fabric
files: 'versions/1.21-fabric/build/libs/!(*-@(dev|sources|javadoc|all)).jar'
game-versions: 1.21
- name: Publish-1.21.3-fabric-Curseforge
uses: Kir-Antipov/[email protected]
with:
curseforge-id: 681953
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}
loaders: fabric
name: ${{github.ref_name}}-1.21.3 - Fabric
files: 'versions/1.21.3-fabric/build/libs/!(*-@(dev|sources|javadoc|all)).jar'
game-versions: 1.21.3
- name: Publish-1.21.3-fabric-Modrinth
uses: Kir-Antipov/[email protected]
with:
modrinth-id: DynYZEae
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
loaders: fabric
name: ${{github.ref_name}}-1.21.3 - Fabric
files: 'versions/1.21.3-fabric/build/libs/!(*-@(dev|sources|javadoc|all)).jar'
game-versions: 1.21.3
- name: Publish-1.21.4-fabric-Curseforge
uses: Kir-Antipov/[email protected]
with:
curseforge-id: 681953
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}
loaders: fabric
name: ${{github.ref_name}}-1.21.4 - Fabric
files: 'versions/1.21.4-fabric/build/libs/!(*-@(dev|sources|javadoc|all)).jar'
game-versions: 1.21.4
- name: Publish-1.21.4-fabric-Modrinth
uses: Kir-Antipov/[email protected]
with:
modrinth-id: DynYZEae
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
loaders: fabric
name: ${{github.ref_name}}-1.21.4 - Fabric
files: 'versions/1.21.4-fabric/build/libs/!(*-@(dev|sources|javadoc|all)).jar'
game-versions: 1.21.4
13 changes: 9 additions & 4 deletions Curseforge.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Renders the GUI at a lower fixed framerate (configurable in the settings), freei

## Compatibility

__This is still work in progress software! There will be visual issues/compatibility issues with other mods, please report them on Github!__
__This is still work in progress software! There will be visual issues/compatibility issues with other mods!__

### Affected vanilla features

Expand All @@ -43,21 +43,26 @@ __This is still work in progress software! There will be visual issues/compatibi
- JourneyMap
- ToroHealth Damage Indicator
- BetterF3
- Roughly Enough Items(REI)(has small visual issues with enchants)

### Not compatible

- VulkanMod
- High resolution fonts on signs(disable buffering in the config)
- Caxton(same issue as above)
- Inventorio
- MiniHUD(bug on their side, the fps counter shows the gui fps instead of the world fps)
- Canvas
- Many other mods that render their own GUI elements, the wilder the mod, the more likely it is to not work with this mod.

## FAQ

### Forge support?

Currently not planned, but I might add it in the future.
No.

### Does this work with mod xyz?

I don't know, I haven't tested it with every mod out there. If you find a mod that doesn't work with this mod, please report it on Github.
I don't know, I haven't tested it with every mod out there. If you find a mod that doesn't work with this mod, you can report it on Github(but there is no guarantee that it will be fixed).

### Backport to 1.16.5/1.12.2/1.8.9?

Expand Down
2 changes: 1 addition & 1 deletion formatter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_record_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_after_code_block" value="0"/>
Expand Down
4 changes: 3 additions & 1 deletion settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"versions": [
"1.20.6-fabric",
"1.21-fabric"
"1.21-fabric",
"1.21.3-fabric",
"1.21.4-fabric"
]
}
29 changes: 25 additions & 4 deletions src/main/java/dev/tr7zw/exordium/ExordiumMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class ExordiumMod extends ExordiumModBase implements ClientModInitializer
public void onInitializeClient() {
super.onInitialize();

//#if MC >= 12102
ResourceManagerHelper.get(PackType.CLIENT_RESOURCES)
.registerReloadListener(new SimpleResourceReloadListener<>() {
@Override
Expand All @@ -27,18 +28,38 @@ public ResourceLocation getFabricId() {
}

@Override
public CompletableFuture<Object> load(ResourceManager manager, ProfilerFiller profiler,
Executor executor) {
public CompletableFuture<Object> load(ResourceManager manager, Executor executor) {
return CompletableFuture.completedFuture(null);
}

@Override
public CompletableFuture<Void> apply(Object data, ResourceManager manager, ProfilerFiller profiler,
Executor executor) {
public CompletableFuture<Void> apply(Object data, ResourceManager manager, Executor executor) {
ReloadTracker.reload();
return CompletableFuture.completedFuture(null);
}
});
//#else
//$$ResourceManagerHelper.get(PackType.CLIENT_RESOURCES)
//$$ .registerReloadListener(new SimpleResourceReloadListener<>() {
//$$ @Override
//$$ public ResourceLocation getFabricId() {
//$$ return NMSHelper.getResourceLocation("exordium", "reload_listener");
//$$ }
//$$
//$$ @Override
//$$ public CompletableFuture<Object> load(ResourceManager manager, ProfilerFiller profiler,
//$$ Executor executor) {
//$$ return CompletableFuture.completedFuture(null);
//$$ }
//$$
//$$ @Override
//$$ public CompletableFuture<Void> apply(Object data, ResourceManager manager, ProfilerFiller profiler,
//$$ Executor executor) {
//$$ ReloadTracker.reload();
//$$ return CompletableFuture.completedFuture(null);
//$$ }
//$$ });
//#endif
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
package dev.tr7zw.exordium.components;

import dev.tr7zw.exordium.versionless.config.Config;
import net.minecraft.client.Minecraft;

public interface BufferComponent<T> {

public void captureState(T context);

public boolean hasChanged(int tickCount, T context);

public default boolean enabled(Config.ComponentSettings settings) {
if (Minecraft.getInstance().screen != null) {
// during screens disable due to issues with the blur
return false;
}
return settings.isEnabled();
};

Expand Down
10 changes: 7 additions & 3 deletions src/main/java/dev/tr7zw/exordium/components/BufferInstance.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import dev.tr7zw.exordium.util.ReloadListener;
import dev.tr7zw.exordium.versionless.config.Config;
import lombok.Getter;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.resources.ResourceLocation;

public final class BufferInstance<T> {
Expand All @@ -36,15 +38,15 @@ public final class BufferInstance<T> {
public boolean enabled() {
return component.enabled(settings.get());
}

/**
* Tries to render the buffer. Returns false if the buffer was not rendered and
* the normal render logic should be used.
*
* @param context
* @return
*/
public boolean renderBuffer(int ticks, T context) {
public boolean renderBuffer(int ticks, T context, GuiGraphics guiGraphics) {
if (!enabled()) {
// not enabled, skip
return false;
Expand All @@ -59,6 +61,7 @@ public boolean renderBuffer(int ticks, T context) {

if (updateFrame) {
// start capturing
guiGraphics.flush();
isCapturing = true;
buffer.captureComponent();
return false;
Expand Down Expand Up @@ -88,14 +91,15 @@ private boolean hasUpdate(int ticks, T context) {
*
* @param context
*/
public void postRender(T context) {
public void postRender(T context, GuiGraphics guiGraphics) {
buffer.captureBlendstateSample();
if (!isCapturing) {
// we were not capturing, so nothing to do
return;
}
isCapturing = false;
component.captureState(context);
guiGraphics.flush();
pacing.setCooldown(System.currentTimeMillis() + (1000 / settings.get().getMaxFps()));
buffer.finishCapture();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import dev.tr7zw.exordium.access.HealthAccess;
import dev.tr7zw.exordium.components.BufferComponent;
import dev.tr7zw.exordium.mixin.FoodDataAccessor;
import dev.tr7zw.util.NMSHelper;
import lombok.Getter;
import net.minecraft.client.Minecraft;
Expand Down Expand Up @@ -47,7 +48,7 @@ public void captureState(HealthAccess context) {
lastPlayerHealth = minecraft.player.getHealth();
lastPlayerAbsorption = minecraft.player.getAbsorptionAmount();
lastFoodLevel = minecraft.player.getFoodData().getFoodLevel();
lastExhaustionLevel = minecraft.player.getFoodData().getExhaustionLevel();
lastExhaustionLevel = ((FoodDataAccessor) minecraft.player.getFoodData()).getExhaustionLevel();
hadVisualEffects = minecraft.player.hasEffect(MobEffects.HUNGER)
|| minecraft.player.hasEffect(MobEffects.REGENERATION);
}
Expand All @@ -68,7 +69,7 @@ public boolean hasChanged(int tickCount, HealthAccess context) {
|| lastSaturation != minecraft.player.getFoodData().getSaturationLevel()
|| (hasVisualEffects || (hasVisualEffects != hadVisualEffects && lastRenderedTick != tickCount))
|| lastFoodLevel != minecraft.player.getFoodData().getFoodLevel()
|| lastExhaustionLevel != minecraft.player.getFoodData().getExhaustionLevel()
|| lastExhaustionLevel != ((FoodDataAccessor) minecraft.player.getFoodData()).getExhaustionLevel()
|| lastPlayerHealth != minecraft.player.getHealth() || Mth.ceil(lastPlayerHealth) <= 4
|| lastPlayerAbsorption != minecraft.player.getAbsorptionAmount();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.minecraft.client.AttackIndicatorStatus;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.core.component.DataComponents;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
Expand All @@ -18,7 +19,7 @@ public class HotbarComponent implements BufferComponent<Void> {
private static final ResourceLocation id = NMSHelper.getResourceLocation("minecraft", "hotbar");

private float lastAttackState = 0;
private final BakedModel[] hotbarModels = new BakedModel[10];
private final Object[] hotbarModels = new Object[10];
private final int[] itemPopAnimation = new int[10];
private final int[] itemAmount = new int[10];
private final int[] itemDurability = new int[10];
Expand Down Expand Up @@ -73,14 +74,18 @@ public boolean hasChanged(int tickCount, Void context) {

private void store(ItemStack item, int id, Player player) {
if (item != null && !item.isEmpty()) {
hotbarModels[id] = Minecraft.getInstance().getItemRenderer().getModel(item, player.level(), player, 0);
hotbarModels[id] = getModel(item, player);
itemPopAnimation[id] = item.getPopTime();
itemAmount[id] = item.getCount();
itemDurability[id] = item.getDamageValue();
if (item.isEnchanted()) {
this.hasEnchantedItem = true;
}
if (player.getCooldowns().isOnCooldown(item.getItem())) {
//#if MC >= 12102
if (player.getCooldowns().isOnCooldown(item)) {
//#else
//$$if (player.getCooldowns().isOnCooldown(item.getItem())) {
//#endif
this.cooldownActive = true;
}
} else {
Expand All @@ -102,8 +107,7 @@ private boolean hasChanged(ItemStack item, int id, Player player) {
if (itemDurability[id] != item.getDamageValue()) {
return true;
}
if (Minecraft.getInstance().getItemRenderer().getModel(item, player.level(), player,
0) != hotbarModels[id]) {
if (getModel(item, player) != hotbarModels[id]) {
return true;
}
} else if (hotbarModels[id] != null) {
Expand All @@ -117,4 +121,18 @@ private Player getCameraPlayer() {
return var2 instanceof Player player ? player : null;
}

private Object getModel(ItemStack itemStack, Player player) {
//#if MC >= 12104
// return Math.random(); // FIXME The new ItemModel class/ItemStackRenderState logic is incompatible with all of this
ResourceLocation resourceLocation = (ResourceLocation) itemStack.get(DataComponents.ITEM_MODEL);
if (resourceLocation != null) {
return minecraft.getModelManager().getItemModel(resourceLocation);
} else {
return null;
}
//#else
//$$ return minecraft.getItemRenderer().getModel(itemStack, player.level(), player, 0);
//#endif
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package dev.tr7zw.exordium.components.vanilla;

import dev.tr7zw.exordium.components.BufferComponent;
import dev.tr7zw.exordium.versionless.config.Config.ComponentSettings;
import dev.tr7zw.util.NMSHelper;
import lombok.Getter;
import net.minecraft.client.Minecraft;
Expand Down Expand Up @@ -51,13 +50,4 @@ public boolean hasChanged(int tickCount, Float vignetteBrightness) {
return exordium_state == f;
}

@Override
public boolean enabled(ComponentSettings settings) {
if (MINECRAFT.screen != null) {
// during screens disable due to issues with the blur
return false;
}
return BufferComponent.super.enabled(settings);
}

}
Loading

0 comments on commit 320d075

Please sign in to comment.