Skip to content

Commit

Permalink
v1.20.2 (#32)
Browse files Browse the repository at this point in the history
All seat offset config options have been reset to 0 with this update.
  • Loading branch information
granny authored Sep 25, 2023
1 parent 1e1f7ae commit 31480ad
Show file tree
Hide file tree
Showing 95 changed files with 462 additions and 705 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: Build
on: [ push ]
on:
push:
branches:
- master

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ PurpurClient is designed to work together with [Purpur](https://github.com/Purpu

</div>

### Current Features in 1.20.1:
### Current Features in 1.20.2:

* Customizable mob passenger offsets
* Adds bee counts inside beehives to debug screen¹
Expand Down
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ dependencies {
minecraft("com.mojang:minecraft:${project.minecraft_version}")
mappings("net.fabricmc:yarn:${project.yarn_mappings}:v2")
modImplementation("net.fabricmc:fabric-loader:${project.loader_version}")
modImplementation("net.fabricmc.fabric-api:fabric-api:${project.fabric_version}")
modImplementation("net.fabricmc.fabric-api:fabric-api:${project.fabric_version}") {
exclude(module = "fabric-api-deprecated")
}
modImplementation("com.terraformersmc:modmenu:${project.modmenu_version}")

// this is dumb as hell. bloats jar way too much. todo: switch to a different config provider
Expand Down
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
org.gradle.jvmargs=-Xmx2G

minecraft_version=1.20.1
yarn_mappings=1.20.1+build.10
minecraft_version=1.20.2
yarn_mappings=1.20.2+build.1
loader_version=0.14.22
fabric_version=0.88.1+1.20.1
modmenu_version=7.2.2
fabric_version=0.89.1+1.20.2
modmenu_version=8.0.0-beta.2
configurate_version=4.1.2

maven_group=org.purpurmc.purpur.client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
@ConfigSerializable
@SuppressWarnings("CanBeFinal")
public class Config {
public int configVersion = 1;
public boolean beeCountInDebug = true;
public boolean useSplashScreen = true;
public boolean useWindowTitle = true;
Expand Down
31 changes: 28 additions & 3 deletions src/main/java/org/purpurmc/purpur/client/config/ConfigManager.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.purpurmc.purpur.client.config;

import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import net.fabricmc.loader.api.FabricLoader;
import org.spongepowered.configurate.CommentedConfigurationNode;
import org.spongepowered.configurate.hocon.HoconConfigurationLoader;
Expand All @@ -9,6 +11,7 @@

public class ConfigManager {
private Path configFile;
private Path backupConfigFile;
private Config config;

private static HoconConfigurationLoader loader(final Path path) {
Expand All @@ -25,21 +28,33 @@ public Config getConfig() {
}

public void reload() {
final Path file;
final Path config;
try {
file = this.getConfigFile();
config = this.getConfigFile();
} catch (final IOException e) {
throw rethrow(e);
}

boolean hasConfigVersion = false;
try {
final HoconConfigurationLoader loader = loader(file);
final HoconConfigurationLoader loader = loader(config);
final CommentedConfigurationNode node = loader.load();
hasConfigVersion = node.hasChild("config-version");
this.config = node.get(Config.class);
} catch (IOException e) {
rethrow(e);
}

if (!hasConfigVersion) {
try {
Path backupConfig = this.getBackupConfigFile();
Files.copy(configFile, backupConfig, StandardCopyOption.REPLACE_EXISTING);
} catch (IOException e) {
rethrow(e);
}
this.config.seats.setAllSeats(0, 0, 0);
}

this.save();
}

Expand All @@ -54,6 +69,16 @@ public void save() {
}
}

@SuppressWarnings("RedundantThrows")
private Path getBackupConfigFile() throws IOException {
if (this.backupConfigFile != null) {
return this.backupConfigFile;
}
final Path configDir = FabricLoader.getInstance().getConfigDir();
this.backupConfigFile = configDir.resolve("purpurclient.conf.backup");
return this.backupConfigFile;
}

@SuppressWarnings("RedundantThrows")
private Path getConfigFile() throws IOException {
if (this.configFile != null) {
Expand Down
234 changes: 157 additions & 77 deletions src/main/java/org/purpurmc/purpur/client/config/Seats.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,83 +7,163 @@
@ConfigSerializable
@SuppressWarnings("CanBeFinal")
public class Seats {
public Seat axolotl = new Seat(-0.25D, 0.4D, 0.0D);
public Seat allay = new Seat(-0.17D, 0.62D, 0.0D);
public Seat bat = new Seat(-0.25D, 0.5D, 0.0D);
public Seat bee = new Seat(-0.1D, 0.6D, 0.0D);
public Seat blaze = new Seat(-0.13D, 0.86D, 0.0D);
public Seat cat = new Seat(0.0D, 0.4D, 0.0D);
public Seat caveSpider = new Seat(-0.17D, 0.68D, 0.0D);
public Seat chicken = new Seat(-0.15D, 0.7D, 0.0D);
public Seat cod = new Seat(-0.25D, 0.15D, 0.0D);
public Seat cow = new Seat(-0.21D, 0.84D, 0.0D);
public Seat creeper = new Seat(-0.13D, 0.83D, 0.0D);
public Seat dolphin = new Seat(0.05D, 0.6D, 0.0D);
public Seat donkey = new Seat(0.0D, 0.62D, 0.0D);
public Seat drowned = new Seat(-0.14D, 0.93D, 0.0D);
public Seat elderGuardian = new Seat(0.0D, 1.07D, 0.0D);
public Seat enderDragon = new Seat(0.0D, 0.4D, 0.0D);
public Seat enderman = new Seat(-0.12D, 0.9D, 0.0D);
public Seat endermite = new Seat(-0.05D, 0.16D, 0.0D);
public Seat evoker = new Seat(-0.12D, 0.91D, 0.0D);
public Seat fox = new Seat(-0.25D, 0.6D, 0.0D);
public Seat frog = new Seat(-0.3D, 0.35D, 0.0D);
public Seat ghast = new Seat(0.0D, 0.96D, 0.0D);
public Seat giant = new Seat(0.0D, 0.98D, 0.0D);
public Seat glowSquid = new Seat(0.0D, 0.75D, 0.0D);
public Seat goat = new Seat(-0.1D, 0.7D, 0.0D);
public Seat guardian = new Seat(-0.15D, 0.94D, 0.0D);
public Seat hoglin = new Seat(0.0D, 0.92D, 0.0D);
public Seat horse = new Seat(0.0D, 0.78D, 0.0D);
public Seat husk = new Seat(-0.13D, 0.98D, 0.0D);
public Seat illusioner = new Seat(-0.14D, 0.93D, 0.0D);
public Seat ironGolem = new Seat(-0.25D, 0.7D, 0.0D);
public Seat llama = new Seat(-0.17D, 0.63D, 0.0D);
public Seat magmaCube = new Seat(-0.1D, 0.82D, 0.0D);
public Seat mooshroom = new Seat(-0.21D, 0.84D, 0.0D);
public Seat mule = new Seat(-0.05D, 0.63D, 0.0D);
public Seat ocelot = new Seat(0.0D, 0.6D, 0.0D);
public Seat panda = new Seat(0.0D, 0.85D, 0.0D);
public Seat parrot = new Seat(-0.15D, 0.3D, 0.0D);
public Seat phantom = new Seat(-0.1D, 0.23D, 0.0D);
public Seat pig = new Seat(0.0D, 0.75D, 0.0D);
public Seat piglin = new Seat(-0.13D, 0.92D, 0.0D);
public Seat piglinBrute = new Seat(-0.13D, 0.92D, 0.0D);
public Seat pillager = new Seat(-0.13D, 0.92D, 0.0D);
public Seat polarBear = new Seat(0.2D, 0.82D, 0.0D);
public Seat pufferfish = new Seat(-0.1D, 0.25D, 0.0D);
public Seat rabbit = new Seat(-0.25D, 0.3D, 0.0D);
public Seat ravager = new Seat(-0.25D, 0.93D, 0.0D);
public Seat salmon = new Seat(-0.1D, 0.5D, 0.0D);
public Seat sheep = new Seat(-0.13D, 0.78D, 0.0D);
public Seat shulker = new Seat(-0.2D, 0.8D, 0.0D);
public Seat silverfish = new Seat(-0.22D, 0.2D, 0.0D);
public Seat skeleton = new Seat(-0.13D, 0.9D, 0.0D);
public Seat skeletonHorse = new Seat(-0.05D, 0.7D, 0.0D);
public Seat slime = new Seat(-0.1D, 0.82D, 0.0D);
public Seat snowGolem = new Seat(-0.13D, 0.9D, 0.0D);
public Seat spider = new Seat(-0.25D, 0.67D, 0.0D);
public Seat squid = new Seat(0.0D, 0.75D, 0.0D);
public Seat stray = new Seat(-0.13D, 0.9D, 0.0D);
public Seat strider = new Seat(-0.2D, 0.91D, 0.0D);
public Seat tadpole = new Seat(-0.15D, -0.1D, 0.0D);
public Seat traderLlama = new Seat(-0.17D, 0.63D, 0.0D);
public Seat tropicalFish = new Seat(-0.1D, 0.1D, 0.0D);
public Seat turtle = new Seat(-0.25D, 0.9D, 0.0D);
public Seat vex = new Seat(-0.3D, 0.52D, 0.0D);
public Seat villager = new Seat(-0.13D, 0.92D, 0.0D);
public Seat vindicator = new Seat(-0.13D, 0.92D, 0.0D);
public Seat wanderingTrader = new Seat(-0.13D, 0.91D, 0.0D);
public Seat warden = new Seat(-0.25D, 1.0D, 0.0D);
public Seat witch = new Seat(-0.13D, 0.92D, 0.0D);
public Seat wither = new Seat(-0.1D, 0.94D, 0.0D);
public Seat witherSkeleton = new Seat(-0.17D, 0.92D, 0.0D);
public Seat wolf = new Seat(-0.2D, 0.75D, 0.0D);
public Seat zoglin = new Seat(0.0D, 0.92D, 0.0D);
public Seat zombie = new Seat(-0.13D, 0.92D, 0.0D);
public Seat zombieHorse = new Seat(-0.05D, 0.69D, 0.0D);
public Seat zombieVillager = new Seat(-0.13D, 0.98D, 0.0D);
public Seat zombifiedPiglin = new Seat(-0.13D, 0.92D, 0.0D);
public Seat axolotl = new Seat(0.0D, 0.0D, 0.0D);
public Seat allay = new Seat(0.0D, 0.0D, 0.0D);
public Seat bat = new Seat(0.0D, 0.0D, 0.0D);
public Seat bee = new Seat(0.0D, 0.0D, 0.0D);
public Seat blaze = new Seat(0.0D, 0.0D, 0.0D);
public Seat cat = new Seat(0.0D, 0.0D, 0.0D);
public Seat caveSpider = new Seat(0.0D, 0.0D, 0.0D);
public Seat chicken = new Seat(0.0D, 0.0D, 0.0D);
public Seat cod = new Seat(0.0D, 0.0D, 0.0D);
public Seat cow = new Seat(0.0D, 0.0D, 0.0D);
public Seat creeper = new Seat(0.0D, 0.0D, 0.0D);
public Seat dolphin = new Seat(0.0D, 0.0D, 0.0D);
public Seat donkey = new Seat(0.0D, 0.0D, 0.0D);
public Seat drowned = new Seat(0.0D, 0.0D, 0.0D);
public Seat elderGuardian = new Seat(0.0D, 0.0D, 0.0D);
public Seat enderDragon = new Seat(0.0D, 0.0D, 0.0D);
public Seat enderman = new Seat(0.0D, 0.0D, 0.0D);
public Seat endermite = new Seat(0.0D, 0.0D, 0.0D);
public Seat evoker = new Seat(0.0D, 0.0D, 0.0D);
public Seat fox = new Seat(0.0D, 0.0D, 0.0D);
public Seat frog = new Seat(0.0D, 0.0D, 0.0D);
public Seat ghast = new Seat(0.0D, 0.0D, 0.0D);
public Seat giant = new Seat(0.0D, 0.0D, 0.0D);
public Seat glowSquid = new Seat(0.0D, 0.0D, 0.0D);
public Seat goat = new Seat(0.0D, 0.0D, 0.0D);
public Seat guardian = new Seat(0.0D, 0.0D, 0.0D);
public Seat hoglin = new Seat(0.0D, 0.0D, 0.0D);
public Seat horse = new Seat(0.0D, 0.0D, 0.0D);
public Seat husk = new Seat(0.0D, 0.0D, 0.0D);
public Seat illusioner = new Seat(0.0D, 0.0D, 0.0D);
public Seat ironGolem = new Seat(0.0D, 0.0D, 0.0D);
public Seat llama = new Seat(0.0D, 0.0D, 0.0D);
public Seat magmaCube = new Seat(0.0D, 0.0D, 0.0D);
public Seat mooshroom = new Seat(0.0D, 0.0D, 0.0D);
public Seat mule = new Seat(0.0D, 0.0D, 0.0D);
public Seat ocelot = new Seat(0.0D, 0.0D, 0.0D);
public Seat panda = new Seat(0.0D, 0.0D, 0.0D);
public Seat parrot = new Seat(0.0D, 0.0D, 0.0D);
public Seat phantom = new Seat(0.0D, 0.0D, 0.0D);
public Seat pig = new Seat(0.0D, 0.0D, 0.0D);
public Seat piglin = new Seat(0.0D, 0.0D, 0.0D);
public Seat piglinBrute = new Seat(0.0D, 0.0D, 0.0D);
public Seat pillager = new Seat(0.0D, 0.0D, 0.0D);
public Seat polarBear = new Seat(0.0D, 0.0D, 0.0D);
public Seat pufferfish = new Seat(0.0D, 0.0D, 0.0D);
public Seat rabbit = new Seat(0.0D, 0.0D, 0.0D);
public Seat ravager = new Seat(0.0D, 0.0D, 0.0D);
public Seat salmon = new Seat(0.0D, 0.0D, 0.0D);
public Seat sheep = new Seat(0.0D, 0.0D, 0.0D);
public Seat shulker = new Seat(0.0D, 0.0D, 0.0D);
public Seat silverfish = new Seat(0.0D, 0.0D, 0.0D);
public Seat skeleton = new Seat(0.0D, 0.0D, 0.0D);
public Seat skeletonHorse = new Seat(0.0D, 0.0D, 0.0D);
public Seat slime = new Seat(0.0D, 0.0D, 0.0D);
public Seat snowGolem = new Seat(0.0D, 0.0D, 0.0D);
public Seat spider = new Seat(0.0D, 0.0D, 0.0D);
public Seat squid = new Seat(0.0D, 0.0D, 0.0D);
public Seat stray = new Seat(0.0D, 0.0D, 0.0D);
public Seat strider = new Seat(0.0D, 0.0D, 0.0D);
public Seat tadpole = new Seat(0.0D, 0.0D, 0.0D);
public Seat traderLlama = new Seat(0.0D, 0.0D, 0.0D);
public Seat tropicalFish = new Seat(0.0D, 0.0D, 0.0D);
public Seat turtle = new Seat(0.0D, 0.0D, 0.0D);
public Seat vex = new Seat(0.0D, 0.0D, 0.0D);
public Seat villager = new Seat(0.0D, 0.0D, 0.0D);
public Seat vindicator = new Seat(0.0D, 0.0D, 0.0D);
public Seat wanderingTrader = new Seat(0.0D, 0.0D, 0.0D);
public Seat warden = new Seat(0.0D, 0.0D, 0.0D);
public Seat witch = new Seat(0.0D, 0.0D, 0.0D);
public Seat wither = new Seat(0.0D, 0.0D, 0.0D);
public Seat witherSkeleton = new Seat(0.0D, 0.0D, 0.0D);
public Seat wolf = new Seat(0.0D, 0.0D, 0.0D);
public Seat zoglin = new Seat(0.0D, 0.0D, 0.0D);
public Seat zombie = new Seat(0.0D, 0.0D, 0.0D);
public Seat zombieHorse = new Seat(0.0D, 0.0D, 0.0D);
public Seat zombieVillager = new Seat(0.0D, 0.0D, 0.0D);
public Seat zombifiedPiglin = new Seat(0.0D, 0.0D, 0.0D);

public void setAllSeats(double x, double y, double z) {
axolotl.setSeat(z, y, z);
allay.setSeat(z, y, z);
bat.setSeat(z, y, z);
bee.setSeat(z, y, z);
blaze.setSeat(z, y, z);
cat.setSeat(z, y, z);
caveSpider.setSeat(z, y, z);
chicken.setSeat(z, y, z);
cod.setSeat(z, y, z);
cow.setSeat(z, y, z);
creeper.setSeat(z, y, z);
dolphin.setSeat(z, y, z);
donkey.setSeat(z, y, z);
drowned.setSeat(z, y, z);
elderGuardian.setSeat(z, y, z);
enderDragon.setSeat(z, y, z);
enderman.setSeat(z, y, z);
endermite.setSeat(z, y, z);
evoker.setSeat(z, y, z);
fox.setSeat(z, y, z);
frog.setSeat(z, y, z);
ghast.setSeat(z, y, z);
giant.setSeat(z, y, z);
glowSquid.setSeat(z, y, z);
goat.setSeat(z, y, z);
guardian.setSeat(z, y, z);
hoglin.setSeat(z, y, z);
horse.setSeat(z, y, z);
husk.setSeat(z, y, z);
illusioner.setSeat(z, y, z);
ironGolem.setSeat(z, y, z);
llama.setSeat(z, y, z);
magmaCube.setSeat(z, y, z);
mooshroom.setSeat(z, y, z);
mule.setSeat(z, y, z);
ocelot.setSeat(z, y, z);
panda.setSeat(z, y, z);
parrot.setSeat(z, y, z);
phantom.setSeat(z, y, z);
pig.setSeat(z, y, z);
piglin.setSeat(z, y, z);
piglinBrute.setSeat(z, y, z);
pillager.setSeat(z, y, z);
polarBear.setSeat(z, y, z);
pufferfish.setSeat(z, y, z);
rabbit.setSeat(z, y, z);
ravager.setSeat(z, y, z);
salmon.setSeat(z, y, z);
sheep.setSeat(z, y, z);
shulker.setSeat(z, y, z);
silverfish.setSeat(z, y, z);
skeleton.setSeat(z, y, z);
skeletonHorse.setSeat(z, y, z);
slime.setSeat(z, y, z);
snowGolem.setSeat(z, y, z);
spider.setSeat(z, y, z);
squid.setSeat(z, y, z);
stray.setSeat(z, y, z);
strider.setSeat(z, y, z);
tadpole.setSeat(z, y, z);
traderLlama.setSeat(z, y, z);
tropicalFish.setSeat(z, y, z);
turtle.setSeat(z, y, z);
vex.setSeat(z, y, z);
villager.setSeat(z, y, z);
vindicator.setSeat(z, y, z);
wanderingTrader.setSeat(z, y, z);
warden.setSeat(z, y, z);
witch.setSeat(z, y, z);
wither.setSeat(z, y, z);
witherSkeleton.setSeat(z, y, z);
wolf.setSeat(z, y, z);
zoglin.setSeat(z, y, z);
zombie.setSeat(z, y, z);
zombieHorse.setSeat(z, y, z);
zombieVillager.setSeat(z, y, z);
zombifiedPiglin.setSeat(z, y, z);
}

public Seat getSeat(Mob mob) {
return switch (mob) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@
import org.purpurmc.purpur.client.config.Seats;

public interface RidableEntity {
default void updatePassengerPosition(Entity passenger, Seat seat) {
LivingEntity entity = (LivingEntity) this;
if (entity.hasPassenger(passenger)) {
Vec3d vec = seat.rotate(entity, passenger);
passenger.setPosition(vec.x, vec.y, vec.z);
}
}

default Seats getSeats() {
return PurpurClient.instance().getConfig().seats;
}
Expand Down
14 changes: 4 additions & 10 deletions src/main/java/org/purpurmc/purpur/client/entity/Seat.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,9 @@ public Seat(double x, double y, double z) {
this.z = z;
}

public Vec3d rotate(LivingEntity entity, Entity passenger) {
float angle = -entity.bodyYaw * Constants.DEG2RAD - Constants.HALF_PI;
double cos = MathHelper.cos(angle);
double sin = MathHelper.sin(angle);

double x = (this.x * cos + this.z * sin) + entity.getX();
double z = (this.z * cos - this.x * sin) + entity.getZ();
double y = entity.getY() + entity.getMountedHeightOffset() + passenger.getHeightOffset();

return new Vec3d(x, y, z);
public void setSeat(double x, double y, double z) {
this.x = x;
this.y = y;
this.z = z;
}
}
Loading

0 comments on commit 31480ad

Please sign in to comment.