Skip to content

Commit 9790149

Browse files
committed
working
0 parents  commit 9790149

File tree

70 files changed

+1660
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1660
-0
lines changed

.github/workflows/build.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Automatically build the project and run any configured tests for every push
2+
# and submitted pull request. This can help catch issues that only occur on
3+
# certain platforms or Java versions, and provides a first line of defence
4+
# against bad commits.
5+
6+
name: build
7+
on: [ pull_request, push ]
8+
9+
jobs:
10+
build:
11+
strategy:
12+
matrix:
13+
# Use these Java versions
14+
java: [
15+
17, # Current Java LTS & minimum supported by Minecraft
16+
]
17+
# and run on both Linux and Windows
18+
os: [ ubuntu-22.04, windows-2022 ]
19+
runs-on: ${{ matrix.os }}
20+
steps:
21+
- name: checkout repository
22+
uses: actions/checkout@v3
23+
- name: validate gradle wrapper
24+
uses: gradle/wrapper-validation-action@v1
25+
- name: setup jdk ${{ matrix.java }}
26+
uses: actions/setup-java@v3
27+
with:
28+
java-version: ${{ matrix.java }}
29+
distribution: 'microsoft'
30+
- name: make gradle wrapper executable
31+
if: ${{ runner.os != 'Windows' }}
32+
run: chmod +x ./gradlew
33+
- name: build
34+
run: ./gradlew build
35+
- name: capture build artifacts
36+
if: ${{ runner.os == 'Linux' && matrix.java == '17' }} # Only upload artifacts built from latest java on one OS
37+
uses: actions/upload-artifact@v3
38+
with:
39+
name: Artifacts
40+
path: build/libs/

.gitignore

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# gradle
2+
3+
.gradle/
4+
build/
5+
out/
6+
classes/
7+
8+
# eclipse
9+
10+
*.launch
11+
12+
# idea
13+
14+
.idea/
15+
*.iml
16+
*.ipr
17+
*.iws
18+
19+
# vscode
20+
21+
.settings/
22+
.vscode/
23+
bin/
24+
.classpath
25+
.project
26+
27+
# macos
28+
29+
*.DS_Store
30+
31+
# fabric
32+
33+
run/
34+
35+
# java
36+
37+
hs_err_*.log
38+
replay_*.log
39+
*.hprof
40+
*.jfr

1.10-1.12.2/build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apply plugin: "legacy-looming"
2+
3+
dependencies {
4+
minecraft "com.mojang:minecraft:$minecraft_version"
5+
mappings(legacy.yarn(minecraft_version, yarn_build))
6+
}

1.10-1.12.2/gradle.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
minecraft_version=1.12.2
2+
target_version=1.10-1.12.2
3+
yarn_build=514
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package dev.tildejustin.half_heart_hardcore.mixin;
2+
3+
import net.minecraft.client.MinecraftClient;
4+
import net.minecraft.client.gui.DrawableHelper;
5+
import net.minecraft.client.gui.hud.InGameHud;
6+
import net.minecraft.entity.player.ClientPlayerEntity;
7+
import org.spongepowered.asm.mixin.Mixin;
8+
import org.spongepowered.asm.mixin.Unique;
9+
import org.spongepowered.asm.mixin.injection.At;
10+
import org.spongepowered.asm.mixin.injection.Inject;
11+
import org.spongepowered.asm.mixin.injection.Redirect;
12+
import org.spongepowered.asm.mixin.injection.Slice;
13+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
14+
15+
@Mixin(InGameHud.class)
16+
public abstract class InGameHudMixin extends DrawableHelper {
17+
@Unique
18+
private int count = 0;
19+
20+
@Redirect(
21+
method = "renderStatusBars",
22+
at = @At(
23+
value = "INVOKE",
24+
target = "Lnet/minecraft/client/gui/hud/InGameHud;drawTexture(IIIIII)V",
25+
ordinal = 0
26+
),
27+
slice = @Slice(
28+
from = @At(
29+
value = "INVOKE",
30+
target = "Lnet/minecraft/world/level/LevelProperties;isHardcore()Z"
31+
)
32+
)
33+
)
34+
private void skipHeartRendering(InGameHud instance, int x, int y, int u, int v, int width, int height) {
35+
ClientPlayerEntity player = MinecraftClient.getInstance().player;
36+
if (this.count < player.getMaxHealth() + player.getAbsorption()) {
37+
this.drawTexture(x, y, u, v, width, height);
38+
}
39+
this.count++;
40+
}
41+
42+
@Inject(method = "renderStatusBars", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Profiler;swap(Ljava/lang/String;)V", ordinal = 1))
43+
private void resetCount(CallbackInfo ci) {
44+
this.count = 0;
45+
}
46+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package dev.tildejustin.half_heart_hardcore.mixin;
2+
3+
import net.minecraft.world.GameMode;
4+
import net.minecraft.world.level.LevelInfo;
5+
import org.spongepowered.asm.mixin.Mixin;
6+
import org.spongepowered.asm.mixin.injection.At;
7+
import org.spongepowered.asm.mixin.injection.ModifyVariable;
8+
9+
@Mixin(LevelInfo.class)
10+
public abstract class LevelInfoMixin {
11+
@ModifyVariable(
12+
method = "<init>(JLnet/minecraft/world/GameMode;ZZLnet/minecraft/world/level/LevelGeneratorType;)V",
13+
at = @At(
14+
value = "HEAD"
15+
),
16+
ordinal = 0,
17+
argsOnly = true
18+
)
19+
private static GameMode setGameMode(GameMode gameMode) {
20+
return GameMode.SURVIVAL;
21+
}
22+
23+
@ModifyVariable(
24+
method = "<init>(JLnet/minecraft/world/GameMode;ZZLnet/minecraft/world/level/LevelGeneratorType;)V",
25+
at = @At(
26+
value = "HEAD"
27+
),
28+
ordinal = 1,
29+
argsOnly = true
30+
)
31+
private static boolean setHardcore(boolean hardcore) {
32+
return true;
33+
}
34+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package dev.tildejustin.half_heart_hardcore.mixin;
2+
3+
import net.minecraft.entity.LivingEntity;
4+
import net.minecraft.entity.attribute.EntityAttributes;
5+
import net.minecraft.entity.player.PlayerEntity;
6+
import net.minecraft.world.World;
7+
import org.spongepowered.asm.mixin.Mixin;
8+
import org.spongepowered.asm.mixin.injection.At;
9+
import org.spongepowered.asm.mixin.injection.Inject;
10+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
11+
12+
@Mixin(PlayerEntity.class)
13+
public abstract class PlayerEntityMixin extends LivingEntity {
14+
public PlayerEntityMixin(World world) {
15+
super(world);
16+
}
17+
18+
@Inject(method = "initializeAttributes", at = @At(value = "TAIL"))
19+
private void setMaxHealth(CallbackInfo ci) {
20+
this.getAttributeContainer().get(EntityAttributes.GENERIC_MAX_HEALTH).setBaseValue(1);
21+
}
22+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"schemaVersion": 1,
3+
"id": "half-heart-hardcore-mixin",
4+
"version": "${version}",
5+
"name": "Half Heart Hardcore",
6+
"description": "",
7+
"authors": [
8+
"tildejustin"
9+
],
10+
"contact": {
11+
"sources": "https://github.com/tildejustin/half-heart-hardcore"
12+
},
13+
"license": "MIT",
14+
"environment": "*",
15+
"mixins": [
16+
"half-heart-hardcore.mixins.json"
17+
],
18+
"depends": {
19+
"minecraft": ">=1.10 <1.13"
20+
}
21+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"required": true,
3+
"package": "dev.tildejustin.half_heart_hardcore.mixin",
4+
"compatibilityLevel": "JAVA_8",
5+
"mixins": [
6+
"LevelInfoMixin",
7+
"PlayerEntityMixin"
8+
],
9+
"client": [
10+
"InGameHudMixin"
11+
],
12+
"injectors": {
13+
"defaultRequire": 1
14+
}
15+
}

1.13-1.13.2/build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apply plugin: "legacy-looming"
2+
3+
dependencies {
4+
minecraft "com.mojang:minecraft:$minecraft_version"
5+
mappings(legacy.yarn(minecraft_version, yarn_build))
6+
}

0 commit comments

Comments
 (0)