Skip to content

Commit

Permalink
prepare for 1.20.2
Browse files Browse the repository at this point in the history
  • Loading branch information
granny committed Sep 20, 2023
1 parent 1e1f7ae commit cd0128a
Show file tree
Hide file tree
Showing 89 changed files with 345 additions and 199 deletions.
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
2 changes: 2 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- [ ] fix seat offset
- [ ] verify beehive bee count in debug screen works correctly
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-rc2
yarn_mappings=1.20.2-rc2+build.4
loader_version=0.14.22
fabric_version=0.88.1+1.20.1
modmenu_version=7.2.2
fabric_version=0.89.0+1.20.2
modmenu_version=8.0.0-beta.2
configurate_version=4.1.2

maven_group=org.purpurmc.purpur.client
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/purpurmc/purpur/client/entity/Seat.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public Vec3d rotate(LivingEntity entity, Entity passenger) {

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();
double y = entity.getPassengerRidingPos(passenger).y + (double) passenger.getRidingOffset(entity);

return new Vec3d(x, y, z);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,12 @@ public void init() {

@Override
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
renderBackground(context);
context.drawCenteredTextWithShadow(this.textRenderer, this.title, this.centerX, 15, 0xFFFFFFFF);
super.render(context, mouseX, mouseY, delta);
}

@Override
public void renderBackground(DrawContext context) {
public void renderBackground(DrawContext context, int mouseX, int mouseY, float delta) {
if (this.client != null && this.client.world != null) {
context.fillGradient(0, 0, this.width, this.height, 0xF00F4863, 0xF0370038);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public void init() {

@Override
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
renderBackground(context);
renderBackground(context, mouseX, mouseY, delta);

RenderSystem.setShader(GameRenderer::getPositionTexProgram);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
Expand Down Expand Up @@ -261,8 +261,8 @@ public boolean mouseDragged(double mouseX, double mouseY, int button, double del
}

@Override
public boolean mouseScrolled(double mouseX, double mouseY, double amount) {
this.previewZoom += (float) amount;
public boolean mouseScrolled(double mouseX, double mouseY, double horizontalAmount, double verticalAmount) {
this.previewZoom += (float) verticalAmount;
clampZoom();
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,22 @@
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.ButtonTextures;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
import net.minecraft.client.gui.widget.ClickableWidget;
import net.minecraft.client.gui.widget.PressableWidget;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.MathHelper;
import org.purpurmc.purpur.client.config.options.DoubleOption;

public class DoubleButton extends ClickableWidget implements Tickable {
private final static Text PLUS = Text.of("+");
private final static Text MINUS = Text.of("-");
private static final ButtonTextures TEXTURES = new ButtonTextures(new Identifier("widget/button"), new Identifier("widget/button_disabled"), new Identifier("widget/button_highlighted"));

private final DoubleOption option;
private int tooltipDelay;
Expand Down Expand Up @@ -45,8 +49,8 @@ public void renderButton(DrawContext context, int mouseX, int mouseY, float delt
onRelease(0, 0);
}

drawButton(context, MINUS, this.getX(), this.getYImage(this.btn == Btn.MINUS || this.selected == Btn.MINUS));
drawButton(context, PLUS, this.getX() + this.width - this.height, this.getYImage(this.btn == Btn.PLUS || this.selected == Btn.PLUS));
drawButton(context, MINUS, this.getX(), this.btn == Btn.MINUS || this.selected == Btn.MINUS);
drawButton(context, PLUS, this.getX() + this.width - this.height, this.btn == Btn.PLUS || this.selected == Btn.PLUS);

context.drawCenteredTextWithShadow(MinecraftClient.getInstance().textRenderer, this.getMessage(), this.getX() + this.width / 2, this.getY() + (this.height - 8) / 2, (this.active ? 0xFFFFFF : 0xA0A0A0) | MathHelper.ceil(this.alpha * 255.0f) << 24);

Expand All @@ -55,12 +59,11 @@ public void renderButton(DrawContext context, int mouseX, int mouseY, float delt
}
}

private void drawButton(DrawContext context, Text text, int x, int i) {
private void drawButton(DrawContext context, Text text, int x, boolean i) {
RenderSystem.enableDepthTest();
context.setShaderColor(1.0F, 1.0F, 1.0F, this.alpha);
RenderSystem.enableBlend();
this.drawTexture(context, WIDGETS_TEXTURE, x, this.getY(), 0, 46 + i * 20, 0, this.height / 2, this.height, 256, 256);
this.drawTexture(context, WIDGETS_TEXTURE, x + this.height / 2, this.getY(), 200 - this.height / 2, 46 + i * 20, 0, this.height / 2, this.height, 256, 256);
context.drawGuiTexture(TEXTURES.get(this.active, i), x, this.getY(), this.height, this.height);
context.drawCenteredTextWithShadow(MinecraftClient.getInstance().textRenderer, text, x + this.height / 2, this.getY() + (this.height - 8) / 2, (this.active ? 0xFFFFFF : 0xA0A0A0) | MathHelper.ceil(this.alpha * 255.0f) << 24);
}

Expand Down Expand Up @@ -150,15 +153,4 @@ private void addValue(double value) {
this.playDownSound(MinecraftClient.getInstance().getSoundManager());
this.option.set(this.option.get() + value);
}

private int getYImage(boolean hovered) {
int i = 1;
if (!this.active) {
i = 0;
} else if (hovered) {
i = 2;
}

return i;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,23 @@ public void renderButton(DrawContext context, int mouseX, int mouseY, float delt
RenderSystem.setShader(GameRenderer::getPositionTexProgram);
RenderSystem.setShaderTexture(0, MOBS_TEXTURE);
RenderSystem.enableDepthTest();
drawTexture(
context,
context.drawTexture(
MOBS_TEXTURE,
this.getX(),
this.getY(),
this.width * 15,
this.height * 14 + (this.isSelected() ? this.height : 0),
0,
this.width,
this.height,
this.width * 16,
this.height * 16
);
drawTexture(
context,
context.drawTexture(
MOBS_TEXTURE,
this.getX(),
this.getY(),
this.mob.getU() * this.width,
this.mob.getV() * this.height,
0,
this.width,
this.height,
this.width * 16,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,19 @@ private void getWindowTitle(CallbackInfoReturnable<String> cir) {
if (network != null && network.getConnection().isOpen()) {
sb.append(" - ");
String username = client.getSession().getUsername();
ServerInfo serverInfo = this.getCurrentServerEntry();
if (this.server != null && !this.server.isRemote()) {
sb.append(I18n.translate("purpurclient.title.singleplayer", username));
} else if (client.isConnectedToRealms()) {
} else if (serverInfo != null && serverInfo.isRealm()) {
sb.append(I18n.translate("purpurclient.title.multiplayer.realms", username));
} else if (this.server != null || this.getCurrentServerEntry() != null && this.getCurrentServerEntry().isLocal()) {
sb.append(I18n.translate("purpurclient.title.multiplayer.lan", username));
} else {
if (this.getCurrentServerEntry() == null) {
} else if (this.server == null && (serverInfo == null || !serverInfo.isLocal())) {
if (serverInfo == null) {
sb.append(I18n.translate("purpurclient.title.multiplayer.unknown", username));
} else {
sb.append(I18n.translate("purpurclient.title.multiplayer.server", username, this.getCurrentServerEntry().name));
sb.append(I18n.translate("purpurclient.title.multiplayer.server", username, serverInfo.name));
}
} else {
sb.append(I18n.translate("purpurclient.title.multiplayer.lan", username));
}
}
cir.setReturnValue(sb.toString());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package org.purpurmc.purpur.client.mixin.mob;

import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityDimensions;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.passive.AllayEntity;
import net.minecraft.world.World;
import org.joml.Vector3f;
import org.purpurmc.purpur.client.entity.RidableEntity;
import org.spongepowered.asm.mixin.Mixin;

Expand All @@ -15,8 +17,8 @@ public MixinAllay(EntityType<? extends AllayEntity> entityType, World world) {
}

@Override
public double getMountedHeightOffset() {
return (double) getHeight() * getSeats().allay.y;
public Vector3f getPassengerAttachmentPos(Entity passenger, EntityDimensions dimensions, float scaleFactor) {
return super.getPassengerAttachmentPos(passenger, dimensions, scaleFactor).add(0, dimensions.height + (float) getSeats().allay.y, 0);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package org.purpurmc.purpur.client.mixin.mob;

import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityDimensions;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.passive.AxolotlEntity;
import net.minecraft.world.World;
import org.joml.Vector3f;
import org.purpurmc.purpur.client.entity.RidableEntity;
import org.spongepowered.asm.mixin.Mixin;

Expand All @@ -15,8 +17,8 @@ public MixinAxolotl(EntityType<? extends AxolotlEntity> entityType, World world)
}

@Override
public double getMountedHeightOffset() {
return (double) getHeight() * getSeats().axolotl.y;
public Vector3f getPassengerAttachmentPos(Entity passenger, EntityDimensions dimensions, float scaleFactor) {
return super.getPassengerAttachmentPos(passenger, dimensions, scaleFactor).add(0, dimensions.height + (float) getSeats().axolotl.y, 0);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package org.purpurmc.purpur.client.mixin.mob;

import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityDimensions;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.passive.BatEntity;
import net.minecraft.world.World;
import org.joml.Vector3f;
import org.purpurmc.purpur.client.entity.RidableEntity;
import org.spongepowered.asm.mixin.Mixin;

Expand All @@ -15,8 +17,8 @@ public MixinBat(EntityType<? extends BatEntity> entityType, World world) {
}

@Override
public double getMountedHeightOffset() {
return (double) getHeight() * getSeats().bat.y;
public Vector3f getPassengerAttachmentPos(Entity passenger, EntityDimensions dimensions, float scaleFactor) {
return super.getPassengerAttachmentPos(passenger, dimensions, scaleFactor).add(0, dimensions.height + (float) getSeats().bat.y, 0);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package org.purpurmc.purpur.client.mixin.mob;

import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityDimensions;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.passive.BeeEntity;
import net.minecraft.world.World;
import org.joml.Vector3f;
import org.purpurmc.purpur.client.entity.RidableEntity;
import org.spongepowered.asm.mixin.Mixin;

Expand All @@ -15,8 +17,8 @@ public MixinBee(EntityType<? extends BeeEntity> entityType, World world) {
}

@Override
public double getMountedHeightOffset() {
return (double) getHeight() * getSeats().bee.y;
public Vector3f getPassengerAttachmentPos(Entity passenger, EntityDimensions dimensions, float scaleFactor) {
return super.getPassengerAttachmentPos(passenger, dimensions, scaleFactor).add(0, dimensions.height + (float) getSeats().bee.y, 0);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package org.purpurmc.purpur.client.mixin.mob;

import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityDimensions;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.mob.BlazeEntity;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.world.World;
import org.joml.Vector3f;
import org.purpurmc.purpur.client.entity.RidableEntity;
import org.spongepowered.asm.mixin.Mixin;

Expand All @@ -15,8 +17,8 @@ public MixinBlaze(EntityType<? extends BlazeEntity> entityType, World world) {
}

@Override
public double getMountedHeightOffset() {
return (double) getHeight() * getSeats().blaze.y;
public Vector3f getPassengerAttachmentPos(Entity passenger, EntityDimensions dimensions, float scaleFactor) {
return super.getPassengerAttachmentPos(passenger, dimensions, scaleFactor).add(0, dimensions.height + (float) getSeats().blaze.y, 0);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package org.purpurmc.purpur.client.mixin.mob;

import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityDimensions;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.passive.CatEntity;
import net.minecraft.world.World;
import org.joml.Vector3f;
import org.purpurmc.purpur.client.entity.RidableEntity;
import org.spongepowered.asm.mixin.Mixin;

Expand All @@ -15,8 +17,8 @@ public MixinCat(EntityType<? extends CatEntity> entityType, World world) {
}

@Override
public double getMountedHeightOffset() {
return (double) getHeight() * getSeats().cat.y;
public Vector3f getPassengerAttachmentPos(Entity passenger, EntityDimensions dimensions, float scaleFactor) {
return super.getPassengerAttachmentPos(passenger, dimensions, scaleFactor).add(0, dimensions.height + (float) getSeats().cat.y, 0);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package org.purpurmc.purpur.client.mixin.mob;

import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityDimensions;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.mob.CaveSpiderEntity;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.world.World;
import org.joml.Vector3f;
import org.purpurmc.purpur.client.entity.RidableEntity;
import org.spongepowered.asm.mixin.Mixin;

Expand All @@ -15,8 +17,8 @@ public MixinCaveSpider(EntityType<? extends CaveSpiderEntity> entityType, World
}

@Override
public double getMountedHeightOffset() {
return (double) getHeight() * getSeats().caveSpider.y;
public Vector3f getPassengerAttachmentPos(Entity passenger, EntityDimensions dimensions, float scaleFactor) {
return super.getPassengerAttachmentPos(passenger, dimensions, scaleFactor).add(0, dimensions.height + (float) getSeats().caveSpider.y, 0);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package org.purpurmc.purpur.client.mixin.mob;

import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityDimensions;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.passive.ChickenEntity;
import net.minecraft.world.World;
import org.joml.Vector3f;
import org.purpurmc.purpur.client.entity.RidableEntity;
import org.spongepowered.asm.mixin.Mixin;

Expand All @@ -15,8 +17,8 @@ public MixinChicken(EntityType<? extends ChickenEntity> entityType, World world)
}

@Override
public double getMountedHeightOffset() {
return (double) getHeight() * getSeats().chicken.y;
public Vector3f getPassengerAttachmentPos(Entity passenger, EntityDimensions dimensions, float scaleFactor) {
return super.getPassengerAttachmentPos(passenger, dimensions, scaleFactor).add(0, dimensions.height + (float) getSeats().chicken.y, 0);
}

@Override
Expand Down
Loading

0 comments on commit cd0128a

Please sign in to comment.