Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
doctor4t committed Feb 12, 2024
2 parents 0aa04ca + 88980b4 commit c20bae2
Show file tree
Hide file tree
Showing 16 changed files with 48 additions and 102 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Rat's Mischief 2.0.1 - 1.19.2
------------------------------------------------------
- Fixed a server crash caused by the MialeeMisc library
- Fixed Rat Master Armour slim arms not being slim

------------------------------------------------------
Rat's Mischief 2.0 - 1.19.2
Expand Down
3 changes: 0 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@ dependencies {
// mialee misc
modImplementation include("xyz.amymialee:mialeemisc:${project.mialeemisc_version}")

// elegant armor
modLocalImplementation("xyz.amymialee:elegantarmour:${project.elegantarmour_version}") { transitive = false }

// ok zoomer
// runtimeOnly("com.github.EnnuiL:OkZoomer:1.19.2-SNAPSHOT")

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ cca_version=5.0.2
carpet_version=1.19.1-1.4.83+v220727
geckolib_version=geckolib-quilt-1.19:3.1.41
mixin_extras_version=0.2.0-beta.4
mialeemisc_version=1.0.38
mialeemisc_version=1.0.39
pal_version = 1.6.0
requiem_version = 2.0.0-beta.16.stripped
automatone_version = 0.9.0
Expand Down

This file was deleted.

This file was deleted.

10 changes: 5 additions & 5 deletions src/main/java/ladysnake/ratsmischief/common/item/RatItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,10 @@ public RatEntity getRatFromItem(World world, ItemStack ratItemStack, Vec3d spawn

@Override
public void appendTooltip(ItemStack stack, @Nullable World world, List<Text> tooltip, TooltipContext context) {
NbtCompound ratTag = getRatTag(stack, world);
MutableText ratType = Text.translatable("type.ratsmischief." + getRatType(stack).name().toLowerCase());
var ratTag = getRatTag(stack, world);
var ratType = Text.translatable("type.ratsmischief." + getRatType(stack).name().toLowerCase());

Style style = EMPTY.withColor(Formatting.DARK_GRAY);
var style = EMPTY.withColor(Formatting.DARK_GRAY);
if (ratTag.getString("RatType").equals(RatEntity.Type.GOLD.name())) {
style = EMPTY.withColor(Formatting.GOLD);
}
Expand All @@ -182,8 +182,8 @@ public void appendTooltip(ItemStack stack, @Nullable World world, List<Text> too
}

// potion genes
Identifier potionId = new Identifier(ratTag.getString("PotionGene"));
StatusEffect statusEffect = Registry.STATUS_EFFECT.get(potionId);
var potionId = new Identifier(ratTag.getString("PotionGene"));
var statusEffect = Registry.STATUS_EFFECT.get(potionId);
if (statusEffect != null) {
tooltip.add(Text.translatable("item.ratsmischief.rat.tooltip.potion").setStyle(EMPTY.withColor(Formatting.GRAY)).append(MialeeText.withColor(Text.translatable(statusEffect.getTranslationKey()).setStyle(EMPTY), statusEffect.getColor())));
}
Expand Down
45 changes: 29 additions & 16 deletions src/main/java/ladysnake/ratsmischief/common/item/RatPouchItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,23 @@
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtElement;
import net.minecraft.nbt.NbtList;
import net.minecraft.text.MutableText;
import net.minecraft.text.Style;
import static net.minecraft.text.Style.EMPTY;
import net.minecraft.text.Text;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Formatting;
import net.minecraft.util.Hand;
import net.minecraft.util.Identifier;
import net.minecraft.util.TypedActionResult;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
import xyz.amymialee.mialeemisc.util.MialeeText;

import java.util.List;
import java.util.function.Predicate;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

import static net.minecraft.text.Style.EMPTY;

public class RatPouchItem extends Item {
private static final Predicate<RatEntity> CLOSEST_RAT_PREDICATE = (ratEntity) -> ratEntity.isTamed();
private final int size;
Expand Down Expand Up @@ -90,7 +89,7 @@ public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand han

@Override
public ActionResult useOnEntity(ItemStack stack, PlayerEntity user, LivingEntity entity, Hand hand) {
NbtList NbtList = user.getStackInHand(hand).getOrCreateSubNbt(RatsMischief.MOD_ID).getList("rats", NbtType.COMPOUND);
NbtList NbtList = user.getStackInHand(hand).getOrCreateSubNbt(RatsMischief.MOD_ID).getList("rats", NbtElement.COMPOUND_TYPE);

if (NbtList.size() < this.size && entity instanceof RatEntity && ((RatEntity) entity).getOwnerUuid() != null && ((RatEntity) entity).getOwnerUuid().equals(user.getUuid())) {
NbtCompound NbtCompound = new NbtCompound();
Expand All @@ -109,26 +108,40 @@ public ActionResult useOnEntity(ItemStack stack, PlayerEntity user, LivingEntity

@Override
public void appendTooltip(ItemStack stack, @Nullable World world, List<Text> tooltip, TooltipContext context) {
NbtList NbtList = stack.getOrCreateSubNbt(RatsMischief.MOD_ID).getList("rats", NbtType.COMPOUND);
var NbtList = stack.getOrCreateSubNbt(RatsMischief.MOD_ID).getList("rats", NbtElement.COMPOUND_TYPE);

tooltip.add(Text.translatable("item.ratsmischief.rat_pouch.tooltip.capacity", NbtList.size(), this.size).setStyle(EMPTY.withColor(Formatting.GRAY)));

for (NbtElement ratTag : NbtList) {
MutableText ratType = Text.translatable("type.ratsmischief." + ((NbtCompound) ratTag).getString("RatType").toLowerCase());

Style style = EMPTY.withColor(Formatting.DARK_GRAY);
for (var ratTag : NbtList) {
var style = EMPTY.withColor(Formatting.DARK_GRAY);
if (((NbtCompound) ratTag).getString("RatType").equals(RatEntity.Type.GOLD.name())) {
style = EMPTY.withColor(Formatting.GOLD);
}
var ratType = Text.translatable("type.ratsmischief." + ((NbtCompound) ratTag).getString("RatType").toLowerCase()).setStyle(style);

// name
var text = ratType;
if (((NbtCompound) ratTag).contains("CustomName")) {
Matcher matcher = Pattern.compile("\\{\"text\":\"(.+)\"\\}").matcher(((NbtCompound) ratTag).getString("CustomName"));
var matcher = Pattern.compile("\\{\"text\":\"(.+)\"\\}").matcher(((NbtCompound) ratTag).getString("CustomName"));
if (matcher.find()) {
String name = matcher.group(1);
tooltip.add(Text.literal(name).append(" (").append(ratType).append(")").setStyle(style));
var name = matcher.group(1);
text = Text.literal(name).append(" (").append(ratType).append(")");
}
} else {
tooltip.add(ratType.setStyle(style));
}

// spy
if (((NbtCompound) ratTag).getBoolean("Spy")) {
text = text.append(" (").append(Text.translatable("item.ratsmischief.rat.tooltip.spy").setStyle(EMPTY.withColor(Formatting.DARK_GREEN))).append(")");
}

// potion genes
var potionId = new Identifier(((NbtCompound) ratTag).getString("PotionGene"));
var statusEffect = Registry.STATUS_EFFECT.get(potionId);
if (statusEffect != null) {
text = text.append(" (").append(Text.translatable("item.ratsmischief.rat.tooltip.potion").setStyle(EMPTY.withColor(Formatting.GRAY)).append(MialeeText.withColor(Text.translatable(statusEffect.getTranslationKey()).setStyle(EMPTY), statusEffect.getColor()))).append(")");
}

tooltip.add(text);
}

super.appendTooltip(stack, world, tooltip, context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
import net.minecraft.client.render.entity.EntityRendererFactory;

public interface EntityRendererWrapper {
EntityRendererFactory.Context getContext();
EntityRendererFactory.Context mischief$getContext();
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package ladysnake.ratsmischief.common.util;

public interface PlayerEntityRendererWrapper {
boolean isSlim();
boolean mischief$isSlim();
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import ladysnake.ratsmischief.common.item.RatMasterArmorItem;
import ladysnake.ratsmischief.common.item.RatMasterCloakItem;
import ladysnake.ratsmischief.common.item.RatMasterHoodItem;
import ladysnake.ratsmischief.common.item.RatMasterMaskItem;
import ladysnake.ratsmischief.common.util.EntityRendererWrapper;
import ladysnake.ratsmischief.common.util.PlayerEntityRendererWrapper;
import net.minecraft.client.render.OverlayTexture;
Expand Down Expand Up @@ -54,7 +53,7 @@ public ArmorFeatureRendererMixin(FeatureRendererContext<T, M> context) {
private void mischief$init(FeatureRendererContext<T, M> context, A leggingsModel, A bodyModel, CallbackInfo ci) {
if (context instanceof EntityRendererWrapper wrapper) {
if (context instanceof PlayerEntityRendererWrapper playerWrapper) {
this.slim = playerWrapper.isSlim();
this.slim = playerWrapper.mischief$isSlim();
}
this.leggingsModel = new PlayerEntityModel<>(wrapper.getContext().getPart(RatsMischiefClient.RAT_MASTER_ARMOR_INNER_LAYER), false);
this.playerModel = new PlayerEntityModel<>(wrapper.getContext().getPart(this.slim ? RatsMischiefClient.RAT_MASTER_ARMOR_OUTER_LAYER_SLIM : RatsMischiefClient.RAT_MASTER_ARMOR_OUTER_LAYER), this.slim);
Expand All @@ -67,10 +66,6 @@ public ArmorFeatureRendererMixin(FeatureRendererContext<T, M> context) {
if (itemStack.getItem() instanceof RatMasterArmorItem) {
this.renderRatArmor(matrices, vertexConsumers, entity, armorSlot, light);
ci.cancel();
return;
}
if (armorSlot == EquipmentSlot.HEAD && RatMasterMaskItem.isWearingMask(entity)) {
ci.cancel();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class EntityRendererMixin<T extends Entity> implements EntityRendererWrap
}

@Override
public EntityRendererFactory.Context getContext() {
public EntityRendererFactory.Context mischief$getContext() {
return this.context;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
@Mixin(PlayerEntityRenderer.class)
public abstract class PlayerEntityRendererMixin extends LivingEntityRenderer<AbstractClientPlayerEntity, PlayerEntityModel<AbstractClientPlayerEntity>> implements PlayerEntityRendererWrapper {
@Unique
private boolean isSlim = false;
private boolean isSlim = true;

public PlayerEntityRendererMixin(EntityRendererFactory.Context ctx, PlayerEntityModel<AbstractClientPlayerEntity> model, float shadowRadius) {
super(ctx, model, shadowRadius);
Expand All @@ -36,7 +36,7 @@ public PlayerEntityRendererMixin(EntityRendererFactory.Context ctx, PlayerEntity
}
}

@Inject(method = "<init>", at = @At("TAIL"))
@Inject(method = "<init>", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/PlayerEntityRenderer;addFeature(Lnet/minecraft/client/render/entity/feature/FeatureRenderer;)Z", ordinal = 0))
private void mischief$masterArmor(EntityRendererFactory.Context ctx, boolean slim, CallbackInfo ci) {
this.isSlim = slim;
}
Expand All @@ -57,7 +57,7 @@ public PlayerEntityRendererMixin(EntityRendererFactory.Context ctx, PlayerEntity
}

@Override
public boolean isSlim() {
public boolean mischief$isSlim() {
return this.isSlim;
}
}

This file was deleted.

7 changes: 2 additions & 5 deletions src/main/resources/assets/ratsmischief/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,14 @@
"type.ratsmischief.husky": "Husky",
"type.ratsmischief.chocolate": "Chocolate",
"type.ratsmischief.light_brown": "Light Brown",
"type.ratsmischief.russian_blue": "Russian Blue",
"type.ratsmischief.blue": "Russian Blue",
"type.ratsmischief.gold": "Gold",
"type.ratsmischief.doctor4t": "doctor4t",
"type.ratsmischief.rat_kid": "Rat Kid",
"type.ratsmischief.ratater": "Ratater",
"type.ratsmischief.jorato": "Jorato",
"type.ratsmischief.jerma": "Jerma",
"type.ratsmischief.hollow": "Hollow",
"type.ratsmischief.rateline": "Rateline",
"type.ratsmischief.remy": "Remy",
"type.ratsmischief.biggie_cheese": "Biggie Cheese",
"type.ratsmischief.arathain": "Arathain",
"type.ratsmischief.astronyu": "astronyu",

"enchantment.ratsmischief.rat_curse" : "Curse of the Rat",
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/quilt.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"doctor4t": "Owner",
"Arathain": "Artist",
"Luxintrus": "Artist",
"Pyrofab": "Contributor"
"Pyrofab": "Contributor",
"AmyMialee": "Programmer"
},
"icon": "assets/ratsmischief/icon.png"
},
Expand Down
3 changes: 1 addition & 2 deletions src/main/resources/ratsmischief.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
"client.HeadFeatureRendererMixin",
"client.HeldItemRendererMixin",
"client.ItemEntityRendererMixin",
"client.PlayerEntityRendererMixin",
"compat.ElegantArmour$SlimArmorFeatureRendererMixin"
"client.PlayerEntityRendererMixin"
],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit c20bae2

Please sign in to comment.