Skip to content

Commit 099a7a1

Browse files
committed
Update to 1.20, and make configurable
1 parent 81ef8ef commit 099a7a1

13 files changed

Lines changed: 137 additions & 97 deletions

build.gradle

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
id 'fabric-loom' version '0.12-SNAPSHOT'
2+
id 'fabric-loom' version '1.4-SNAPSHOT'
33
id 'maven-publish'
44
}
55

@@ -40,18 +40,7 @@ dependencies {
4040
minecraft "com.mojang:minecraft:${project.minecraft_version}"
4141
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
4242
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
43-
modImplementation "net.fabricmc.fabric-api:fabric-api:0.57.0+1.19"
44-
45-
// Only used so I actually have frames when testing.
46-
modRuntimeOnly "curse.maven:ferritecore-fabric-459857:3824694"
47-
modRuntimeOnly "maven.modrinth:lazydfu:0.1.3"
48-
modRuntimeOnly "maven.modrinth:lithium:mc1.19-0.8.0"
49-
modRuntimeOnly "maven.modrinth:starlight:1.1.1+1.19"
50-
modRuntimeOnly "maven.modrinth:sodium:mc1.19-0.4.2"
51-
52-
// Added because otherwise Sodium physically will not function in testing.
53-
// I have no idea why.
54-
runtimeOnly 'org.joml:joml:1.10.4'
43+
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
5544
}
5645

5746
processResources {

gradle.properties

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
org.gradle.jvmargs=-Xmx1G
33
# Fabric Properties
44
# check these on https://modmuss50.me/fabric.html
5-
minecraft_version=1.19
6-
yarn_mappings=1.19+build.4
7-
loader_version=0.14.6
5+
minecraft_version=1.20.1
6+
yarn_mappings=1.20.1+build.4
7+
loader_version=0.14.21
88
# Mod Properties
9-
mod_version=1.0.0+1.19
9+
mod_version=1.1.0+1.20
1010
maven_group=xyz.bluspring
1111
archives_base_name=TechnobladeNeverDies
1212

13+
fabric_version=0.91.0+1.20.1
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,60 @@
11
package xyz.bluspring.technobladeneverdies;
22

3+
import com.google.gson.GsonBuilder;
4+
import com.google.gson.JsonObject;
5+
import com.google.gson.JsonParser;
36
import net.fabricmc.api.ModInitializer;
7+
import net.fabricmc.loader.api.FabricLoader;
48
import net.minecraft.sound.SoundEvent;
59
import net.minecraft.util.Identifier;
610

11+
import java.io.File;
12+
import java.io.IOException;
13+
import java.nio.file.Files;
14+
715
public class TechnobladeNeverDies implements ModInitializer {
8-
public static SoundEvent BRUH_SOUND_EVENT = new SoundEvent(new Identifier("technoneverdies:technoneverdies.bruh"));
9-
public static SoundEvent PHIL_SOUND_EVENT = new SoundEvent(new Identifier("technoneverdies:technoneverdies.phil_look_out"));
16+
public static SoundEvent BRUH_SOUND_EVENT = SoundEvent.of(new Identifier("technoneverdies:technoneverdies.bruh"));
17+
public static SoundEvent PHIL_SOUND_EVENT = SoundEvent.of(new Identifier("technoneverdies:technoneverdies.phil_look_out"));
18+
19+
public static boolean shouldReplaceSplashes = true;
20+
public static boolean shouldReplaceTitleIcon = true;
21+
public static boolean shouldReplaceTechnoPigSounds = true;
1022

1123
@Override
1224
public void onInitialize() {
25+
var configFile = new File(FabricLoader.getInstance().getConfigDir().toFile(), "technoblade_never_dies.json");
26+
27+
if (configFile.exists()) {
28+
try {
29+
var data = Files.readString(configFile.toPath());
30+
var json = JsonParser.parseString(data).getAsJsonObject();
31+
32+
if (json.has("shouldReplaceSplashes")) {
33+
shouldReplaceSplashes = json.get("shouldReplaceSplashes").getAsBoolean();
34+
}
35+
36+
if (json.has("shouldReplaceTitleIcon")) {
37+
shouldReplaceTitleIcon = json.get("shouldReplaceTitleIcon").getAsBoolean();
38+
}
39+
40+
if (json.has("shouldReplaceTechnoPigSounds")) {
41+
shouldReplaceTechnoPigSounds = json.get("shouldReplaceTechnoPigSounds").getAsBoolean();
42+
}
43+
} catch (IOException e) {
44+
throw new RuntimeException(e);
45+
}
46+
} else {
47+
var json = new JsonObject();
48+
json.addProperty("shouldReplaceSplashes", shouldReplaceSplashes);
49+
json.addProperty("shouldReplaceTitleIcon", shouldReplaceTitleIcon);
50+
json.addProperty("shouldReplaceTechnoPigSounds", shouldReplaceTechnoPigSounds);
1351

52+
try {
53+
configFile.createNewFile();
54+
Files.writeString(configFile.toPath(), new GsonBuilder().setPrettyPrinting().create().toJson(json));
55+
} catch (IOException e) {
56+
throw new RuntimeException(e);
57+
}
58+
}
1459
}
1560
}

src/main/java/xyz/bluspring/technobladeneverdies/mixin/ClientPlayNetworkHandlerMixin.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import net.minecraft.entity.EntityType;
77
import net.minecraft.entity.passive.PigEntity;
88
import net.minecraft.entity.player.PlayerEntity;
9+
import net.minecraft.registry.entry.RegistryEntry;
910
import net.minecraft.sound.SoundCategory;
1011
import net.minecraft.sound.SoundEvent;
1112
import net.minecraft.sound.SoundEvents;
@@ -15,17 +16,15 @@
1516
import org.spongepowered.asm.mixin.injection.Redirect;
1617
import xyz.bluspring.technobladeneverdies.TechnobladeNeverDies;
1718

18-
import java.util.List;
19-
2019
@Mixin(ClientPlayNetworkHandler.class)
2120
public class ClientPlayNetworkHandlerMixin {
22-
@Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/world/ClientWorld;playSound(Lnet/minecraft/entity/player/PlayerEntity;DDDLnet/minecraft/sound/SoundEvent;Lnet/minecraft/sound/SoundCategory;FFJ)V"), method = "onPlaySound")
23-
public void replaceSoundIfTechnoblade(ClientWorld instance, PlayerEntity except, double x, double y, double z, SoundEvent sound, SoundCategory category, float volume, float pitch, long seed) {
24-
if (sound.equals(SoundEvents.ENTITY_PIG_AMBIENT)) {
21+
@Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/world/ClientWorld;playSound(Lnet/minecraft/entity/player/PlayerEntity;DDDLnet/minecraft/registry/entry/RegistryEntry;Lnet/minecraft/sound/SoundCategory;FFJ)V"), method = "onPlaySound")
22+
public void replaceSoundIfTechnoblade(ClientWorld instance, PlayerEntity except, double x, double y, double z, RegistryEntry<SoundEvent> sound, SoundCategory category, float volume, float pitch, long seed) {
23+
if (sound.matchesId(SoundEvents.ENTITY_PIG_AMBIENT.getId()) && TechnobladeNeverDies.shouldReplaceTechnoPigSounds) {
2524
var pigEntitiesInGeneralArea = instance.getEntitiesByClass(PigEntity.class, new Box(x - 0.15, y - 0.15, z - 0.15, x + 0.15, y + 0.15, z + 0.15), livingEntity -> true);
2625

2726
if (pigEntitiesInGeneralArea.isEmpty()) {
28-
instance.playSound(except, x, y, z, sound, category, volume, pitch);
27+
instance.playSound(except, x, y, z, sound, category, volume, pitch, seed);
2928
return;
3029
}
3130

@@ -40,18 +39,19 @@ public void replaceSoundIfTechnoblade(ClientWorld instance, PlayerEntity except,
4039
}
4140
}
4241

43-
instance.playSound(except, x, y, z, sound, category, volume, pitch);
42+
instance.playSound(except, x, y, z, sound, category, volume, pitch, seed);
4443
}
4544

46-
@Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/world/ClientWorld;playSoundFromEntity(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/entity/Entity;Lnet/minecraft/sound/SoundEvent;Lnet/minecraft/sound/SoundCategory;FFJ)V"), method = "onPlaySoundFromEntity")
47-
public void replaceSoundEntityIfTechnoblade(ClientWorld instance, PlayerEntity except, Entity entity, SoundEvent sound, SoundCategory category, float volume, float pitch, long seed) {
45+
@Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/world/ClientWorld;playSoundFromEntity(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/entity/Entity;Lnet/minecraft/registry/entry/RegistryEntry;Lnet/minecraft/sound/SoundCategory;FFJ)V"), method = "onPlaySoundFromEntity")
46+
public void replaceSoundEntityIfTechnoblade(ClientWorld instance, PlayerEntity except, Entity entity, RegistryEntry<SoundEvent> sound, SoundCategory category, float volume, float pitch, long seed) {
4847
if (
4948
entity.getType() == EntityType.PIG &&
5049
entity.hasCustomName() &&
51-
entity.getCustomName().getString().equalsIgnoreCase("technoblade")
50+
entity.getCustomName().getString().equalsIgnoreCase("technoblade") &&
51+
TechnobladeNeverDies.shouldReplaceTechnoPigSounds
5252
) {
5353
if (sound.equals(SoundEvents.ENTITY_PIG_AMBIENT)) {
54-
instance.playSoundFromEntity(except, entity, TechnobladeNeverDies.BRUH_SOUND_EVENT, category, volume, pitch, seed);
54+
instance.playSoundFromEntity(except, entity, TechnobladeNeverDies.BRUH_SOUND_EVENT, category, volume, pitch);
5555
}
5656
} else {
5757
instance.playSoundFromEntity(except, entity, sound, category, volume, pitch, seed);
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package xyz.bluspring.technobladeneverdies.mixin;
2+
3+
import net.minecraft.client.gui.DrawContext;
4+
import net.minecraft.client.gui.LogoDrawer;
5+
import net.minecraft.util.Identifier;
6+
import org.spongepowered.asm.mixin.Final;
7+
import org.spongepowered.asm.mixin.Mixin;
8+
import org.spongepowered.asm.mixin.Shadow;
9+
import org.spongepowered.asm.mixin.Unique;
10+
import org.spongepowered.asm.mixin.injection.At;
11+
import org.spongepowered.asm.mixin.injection.Inject;
12+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
13+
import xyz.bluspring.technobladeneverdies.TechnobladeNeverDies;
14+
15+
@Mixin(LogoDrawer.class)
16+
public class LogoDrawerMixin {
17+
@Shadow @Final private boolean ignoreAlpha;
18+
@Unique
19+
private static final Identifier TECHNO_TITLE_TEXTURE = new Identifier("technoneverdies", "textures/gui/title.png");
20+
21+
@Inject(method = "draw(Lnet/minecraft/client/gui/DrawContext;IFI)V", at = @At("HEAD"), cancellable = true)
22+
private void drawTechnoLogo(DrawContext context, int screenWidth, float alpha, int y, CallbackInfo ci) {
23+
if (!TechnobladeNeverDies.shouldReplaceTitleIcon)
24+
return;
25+
26+
context.setShaderColor(1.0F, 1.0F, 1.0F, this.ignoreAlpha ? 1.0F : alpha);
27+
int i = screenWidth / 2 - 128;
28+
context.drawTexture(TECHNO_TITLE_TEXTURE, i, y - 30, 0.0F, 0.0F, 256, 128, 256, 128);
29+
ci.cancel();
30+
}
31+
}

src/main/java/xyz/bluspring/technobladeneverdies/mixin/PigEntityRendererMixin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import org.spongepowered.asm.mixin.injection.At;
1111
import org.spongepowered.asm.mixin.injection.Inject;
1212
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
13-
import xyz.bluspring.technobladeneverdies.renderer.CrownFeatureRenderer;
13+
import xyz.bluspring.technobladeneverdies.renderer.PigCrownFeatureRenderer;
1414

1515
@Mixin(PigEntityRenderer.class)
1616
public abstract class PigEntityRendererMixin extends MobEntityRenderer<PigEntity, PigEntityModel<PigEntity>> {
@@ -20,7 +20,7 @@ public PigEntityRendererMixin(EntityRendererFactory.Context context, PigEntityMo
2020

2121
@Inject(at = @At("TAIL"), method = "<init>")
2222
public void addCrownFeature(EntityRendererFactory.Context context, CallbackInfo ci) {
23-
this.addFeature(new CrownFeatureRenderer<PigEntity, PigEntityModel<PigEntity>>(
23+
this.addFeature(new PigCrownFeatureRenderer<PigEntity, PigEntityModel<PigEntity>>(
2424
this,
2525
new PigEntityModel(context.getPart(EntityModelLayers.PIG_SADDLE)))
2626
);

src/main/java/xyz/bluspring/technobladeneverdies/mixin/SplashTextResourceSupplierMixin.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@
88
import org.spongepowered.asm.mixin.injection.Inject;
99
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
1010
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
11+
import xyz.bluspring.technobladeneverdies.TechnobladeNeverDies;
1112

1213
import java.util.List;
1314

1415
@Mixin(SplashTextResourceSupplier.class)
1516
public class SplashTextResourceSupplierMixin {
1617
@Inject(at = @At("RETURN"), method = "prepare(Lnet/minecraft/resource/ResourceManager;Lnet/minecraft/util/profiler/Profiler;)Ljava/util/List;", locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true)
1718
public void customAddTechnoSplash(ResourceManager resourceManager, Profiler profiler, CallbackInfoReturnable<List<String>> cir) {
18-
boolean technobladeOnly = true;
19+
boolean technobladeOnly = TechnobladeNeverDies.shouldReplaceSplashes;
1920
List<String> list = new java.util.ArrayList<>(technobladeOnly ? List.of() : cir.getReturnValue());
2021

2122
list.add("Technoblade never dies!");
Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,42 @@
11
package xyz.bluspring.technobladeneverdies.mixin;
22

3-
import com.mojang.blaze3d.systems.RenderSystem;
43
import net.minecraft.client.MinecraftClient;
4+
import net.minecraft.client.gui.DrawContext;
55
import net.minecraft.client.gui.screen.TitleScreen;
6-
import net.minecraft.client.util.math.MatrixStack;
6+
import net.minecraft.client.texture.TextureManager;
77
import net.minecraft.util.Identifier;
8-
import net.minecraft.util.Util;
98
import net.minecraft.util.math.MathHelper;
109
import org.spongepowered.asm.mixin.Final;
1110
import org.spongepowered.asm.mixin.Mixin;
1211
import org.spongepowered.asm.mixin.Shadow;
12+
import org.spongepowered.asm.mixin.Unique;
1313
import org.spongepowered.asm.mixin.injection.At;
1414
import org.spongepowered.asm.mixin.injection.Inject;
15-
import org.spongepowered.asm.mixin.injection.Redirect;
1615
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
16+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
1717
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
18+
import xyz.bluspring.technobladeneverdies.TechnobladeNeverDies;
1819

19-
import java.util.function.BiConsumer;
20+
import java.util.concurrent.CompletableFuture;
21+
import java.util.concurrent.Executor;
2022

2123
@Mixin(TitleScreen.class)
2224
public class TitleScreenMixin {
2325
@Shadow @Final private boolean doBackgroundFade;
2426
@Shadow private long backgroundFadeStart;
27+
@Unique
2528
private static final Identifier TECHNO_TITLE_TEXTURE = new Identifier("technoneverdies", "textures/gui/title.png");
2629

27-
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/TitleScreen;drawWithOutline(IILjava/util/function/BiConsumer;)V"), method = "render", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD)
28-
public void modifyTitleTexture(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo ci, float f, int i, int j) {
29-
var titleScreen = (TitleScreen) (Object) this;
30-
31-
RenderSystem.setShaderTexture(0, TECHNO_TITLE_TEXTURE);
32-
33-
titleScreen.drawWithOutline(j, 30, (x, y) -> {
34-
TitleScreen.drawTexture(matrices, x + 10, y - 35, 0, 0, 256, 128, 256, 128);
35-
});
30+
@Inject(method = "loadTexturesAsync", at = @At("RETURN"), cancellable = true)
31+
private static void appendTechnoTexture(TextureManager textureManager, Executor executor, CallbackInfoReturnable<CompletableFuture<Void>> cir) {
32+
cir.setReturnValue(CompletableFuture.allOf(cir.getReturnValue(), textureManager.loadTextureAsync(TECHNO_TITLE_TEXTURE, executor)));
3633
}
3734

38-
@Inject(at = @At("TAIL"), method = "render")
39-
public void addCreditText(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo ci) {
40-
float f = this.doBackgroundFade ? (float)(Util.getMeasuringTimeMs() - this.backgroundFadeStart) / 1000.0f : 1.0f;
41-
float g = this.doBackgroundFade ? MathHelper.clamp(f - 1.0f, 0.0f, 1.0f) : 1.0f;
42-
int l = MathHelper.ceil(g * 255.0f) << 24;
43-
44-
TitleScreen.drawStringWithShadow(matrices, MinecraftClient.getInstance().textRenderer, "Title text made by @MrBrose_ on Twitter", 2, ((TitleScreen) (Object) this).height - 20, 0xFFFFFF | l);
35+
@Inject(at = @At("TAIL"), method = "render", locals = LocalCapture.CAPTURE_FAILHARD)
36+
public void addCreditText(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci, float f, float g) {
37+
if (TechnobladeNeverDies.shouldReplaceTitleIcon) {
38+
int l = MathHelper.ceil(g * 255.0F) << 24;
39+
context.drawTextWithShadow(MinecraftClient.getInstance().textRenderer, "Title text made by @MrBrose_ on Twitter", 2, ((TitleScreen) (Object) this).height - 20, 0xFFFFFF | l);
40+
}
4541
}
46-
47-
@Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/TitleScreen;drawWithOutline(IILjava/util/function/BiConsumer;)V"), method = "render")
48-
public void removeMinecraftText(TitleScreen instance, int i, int j, BiConsumer biConsumer) {}
49-
50-
@Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/TitleScreen;drawTexture(Lnet/minecraft/client/util/math/MatrixStack;IIFFIIII)V"), method = "render")
51-
public void removeEditionText(MatrixStack matrixStack, int i, int j, float m, float n, int o, int p, int q, int r) {}
5242
}

src/main/java/xyz/bluspring/technobladeneverdies/model/PigCrownModel.java

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)