Skip to content

Commit

Permalink
Release 1.7.10.2501.3
Browse files Browse the repository at this point in the history
-Fixed crash when with debug overlay visible
  • Loading branch information
Wilyicaro committed Jan 10, 2025
1 parent 55ec9f1 commit 22c5499
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 16 deletions.
11 changes: 11 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,16 @@ tasks.withType(JavaCompile) {
options.release = isJava21 ? 21 : 17
}

def buildJar = tasks.create("buildJar", Copy.class) {
into("${rootProject.layout.getBuildDirectory().get()}/libs/$mod_version")
}

afterEvaluate {
buildJar.dependsOn(remapJar)
buildJar.from(remapJar.archiveFile)
build.finalizedBy(buildJar)
}

java {
withSourcesJar()
sourceCompatibility = isJava21 ? JavaVersion.VERSION_21 : JavaVersion.VERSION_17
Expand Down Expand Up @@ -150,6 +160,7 @@ ext {
}
}


processResources {
def version_range = mc_version_range

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx3072M
enabled_platforms=fabric,forge,neoforge

archives_base_name=Legacy4J
mod_version=1.7.10.2501.2
mod_version=1.7.10.2501.3
mod_id=legacy
mod_license=MIT
mod_name=Legacy4J
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/wily/legacy/Legacy4J.java
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ public static int getDyeColor(DyeColor dyeColor){
}

public static float getItemDamageModifier(ItemStack stack){
if (LegacyConfig.legacyCombat.get()){
if (LegacyConfig.hasCommonConfigEnabled(LegacyConfig.legacyCombat)){
if (stack.getItem() instanceof SwordItem) return 1;
else if (stack.getItem() instanceof ShovelItem) return -0.5f;
else if (stack.getItem() instanceof PickaxeItem) return 1;
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/wily/legacy/config/LegacyConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import wily.factoryapi.FactoryAPI;
import wily.factoryapi.FactoryAPIClient;
import wily.factoryapi.base.ArbitrarySupplier;
import wily.factoryapi.base.Bearer;
import wily.factoryapi.base.network.CommonNetwork;
Expand Down Expand Up @@ -222,6 +223,10 @@ static <T> LegacyConfig<T> create(String key, ArbitrarySupplier<LegacyConfigDisp
LegacyConfig<Boolean> legacySwordBlocking = COMMON_STORAGE.register(createCommonBoolean("legacySwordBlocking", ()-> new LegacyConfigDisplay<>(LegacyConfig.legacySwordBlocking.getKey()), false, b-> {}));


static boolean hasCommonConfigEnabled(LegacyConfig<Boolean> config) {
return config.get() && (!FactoryAPI.isClient() || FactoryAPIClient.hasModOnServer);
}

static <T> void decodeConfigs(Map<String,? extends LegacyConfig<?>> configs, Dynamic<T> dynamic, Consumer<LegacyConfig<?>> afterDecode){
dynamic.asMapOpt().result().ifPresent(m->m.forEach(p-> p.getFirst().asString().result().ifPresent(s-> {
LegacyConfig<?> config = configs.get(s);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ private void applyItemTransforms(PoseStack poseStack, float h, HumanoidArm human

@Inject(method = "renderArmWithItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/ItemInHandRenderer;applyItemArmTransform(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/world/entity/HumanoidArm;F)V", shift = At.Shift.AFTER, ordinal = 4))
private void renderArmWithItemBlockAnim(AbstractClientPlayer abstractClientPlayer, float f, float g, InteractionHand interactionHand, float h, ItemStack itemStack, float i, PoseStack poseStack, MultiBufferSource multiBufferSource, int j, CallbackInfo ci) {
if (LegacyConfig.legacySwordBlocking.get()) {
if (LegacyConfig.hasCommonConfigEnabled(LegacyConfig.legacySwordBlocking)) {
boolean bl = interactionHand == InteractionHand.MAIN_HAND;
HumanoidArm humanoidArm = bl ? abstractClientPlayer.getMainArm() : abstractClientPlayer.getMainArm().getOpposite();
this.applyItemArmAttackTransform(poseStack, humanoidArm, h);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/wily/legacy/mixin/base/ItemStackMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ private void replaceNeoForgeAttributesEvent(ItemStack stack, Consumer<Component>

@Redirect(method = "addModifierTooltip", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/ai/attributes/AttributeModifier;is(Lnet/minecraft/resources/ResourceLocation;)Z"))
private boolean addModifierTooltip(AttributeModifier instance, ResourceLocation location) {
return !LegacyConfig.legacyCombat.get() && instance.is(location);
return !LegacyConfig.hasCommonConfigEnabled(LegacyConfig.legacyCombat) && instance.is(location);
}

@Inject(method = "addModifierTooltip", at = @At("HEAD"), cancellable = true)
private void addModifierTooltip(Consumer<Component> consumer, Player player, Holder<Attribute> holder, AttributeModifier attributeModifier, CallbackInfo ci) {
if (LegacyConfig.legacyCombat.get() && attributeModifier.is(Item.BASE_ATTACK_SPEED_ID)) ci.cancel();
if (LegacyConfig.hasCommonConfigEnabled(LegacyConfig.legacyCombat) && attributeModifier.is(Item.BASE_ATTACK_SPEED_ID)) ci.cancel();
}

@Redirect(method = "addModifierTooltip", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/ai/attributes/AttributeModifier;amount()D"))
Expand All @@ -96,7 +96,7 @@ private void addAttributeTooltips(ItemStack instance, EquipmentSlotGroup equipme
forEachModifier(equipmentSlotGroup, (holder, attributeModifier)->{
if (noSpace.get()){
consumer.accept(CommonComponents.EMPTY);
if (!LegacyConfig.legacyCombat.get()) consumer.accept(Component.translatable("item.modifiers." + equipmentSlotGroup.getSerializedName()).withStyle(ChatFormatting.GRAY));
if (!LegacyConfig.hasCommonConfigEnabled(LegacyConfig.legacyCombat)) consumer.accept(Component.translatable("item.modifiers." + equipmentSlotGroup.getSerializedName()).withStyle(ChatFormatting.GRAY));
noSpace.set(false);
}
this.addModifierTooltip(consumer, player, holder, attributeModifier);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ public void isBlocking(CallbackInfoReturnable<Boolean> cir) {
//?}
@Inject(method = "getDamageAfterArmorAbsorb", at = @At("RETURN"), cancellable = true)
protected void getDamageAfterArmorAbsorb(DamageSource damageSource, float f, CallbackInfoReturnable<Float> cir) {
if (!damageSource.is(DamageTypeTags.BYPASSES_ARMOR) && LegacyConfig.legacySwordBlocking.get() && useItem.getItem() instanceof SwordItem) cir.setReturnValue(cir.getReturnValue()/2);
if (!damageSource.is(DamageTypeTags.BYPASSES_ARMOR) && LegacyConfig.hasCommonConfigEnabled(LegacyConfig.legacySwordBlocking) && useItem.getItem() instanceof SwordItem) cir.setReturnValue(cir.getReturnValue()/2);
}
}
4 changes: 2 additions & 2 deletions src/main/java/wily/legacy/mixin/base/PlayerMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void aiStep(CallbackInfo ci) {

@Inject(method = "resetAttackStrengthTicker", at = @At(value = "HEAD"), cancellable = true)
protected void resetAttackStrengthTicker(CallbackInfo ci) {
if (LegacyConfig.legacyCombat.get()) ci.cancel();
if (LegacyConfig.hasCommonConfigEnabled(LegacyConfig.legacyCombat)) ci.cancel();
}

@Redirect(method = "attack", at = @At(value = "INVOKE", target = /*? if <1.20.5 {*//*"Lnet/minecraft/world/entity/player/Player;getAttributeValue(Lnet/minecraft/world/entity/ai/attributes/Attribute;)D"*//*?} else {*/"Lnet/minecraft/world/entity/player/Player;getAttributeValue(Lnet/minecraft/core/Holder;)D"/*?}*/))
Expand All @@ -76,7 +76,7 @@ protected double modifyAttackDamage(Player instance,/*? if <1.20.5 {*//*Attribut

@ModifyVariable(method = "attack", at = @At(value = "STORE"), ordinal = 3)
protected boolean modifyAttackDamage(boolean original) {
return !LegacyConfig.legacyCombat.get() && original;
return !LegacyConfig.hasCommonConfigEnabled(LegacyConfig.legacyCombat) && original;
}

}
6 changes: 3 additions & 3 deletions src/main/java/wily/legacy/mixin/base/SwordItemMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ public SwordItemMixin(Properties properties) {

@Override
public int getUseDuration(ItemStack itemStack/*? if >=1.20.5 {*/, LivingEntity livingEntity/*?}*/) {
if (LegacyConfig.legacySwordBlocking.get()) return 7200;
if (LegacyConfig.hasCommonConfigEnabled(LegacyConfig.legacySwordBlocking)) return 7200;
return super.getUseDuration(itemStack/*? if >=1.20.5 {*/, livingEntity/*?}*/);
}

//? <=1.21.1 {
public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand interactionHand) {
if (LegacyConfig.legacySwordBlocking.get()) {
if (LegacyConfig.hasCommonConfigEnabled(LegacyConfig.legacySwordBlocking)) {
player.startUsingItem(interactionHand);
return InteractionResultHolder.consume( player.getItemInHand(interactionHand));
}
Expand All @@ -47,7 +47,7 @@ public InteractionResultHolder<ItemStack> use(Level level, Player player, Intera

@Override
public /*? if <1.21.2 {*/UseAnim/*?} else {*//*ItemUseAnimation*//*?}*/ getUseAnimation(ItemStack itemStack) {
if (LegacyConfig.legacySwordBlocking.get()) return /*? if <1.21.2 {*/UseAnim/*?} else {*//*ItemUseAnimation*//*?}*/.BLOCK;
if (LegacyConfig.hasCommonConfigEnabled(LegacyConfig.legacySwordBlocking)) return /*? if <1.21.2 {*/UseAnim/*?} else {*//*ItemUseAnimation*//*?}*/.BLOCK;
return super.getUseAnimation(itemStack);
}
}
7 changes: 3 additions & 4 deletions src/main/java/wily/legacy/mixin/base/client/gui/GuiMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@


@Mixin(Gui.class)

public abstract class GuiMixin implements ControlTooltip.Event {
@Shadow @Final
private Minecraft minecraft;
Expand Down Expand Up @@ -108,14 +107,14 @@ public void renderVignette(GuiGraphics guiGraphics, Entity entity, CallbackInfo
ci.cancel();
}

@Redirect(method = "renderCrosshair", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/OptionInstance;get()Ljava/lang/Object;"))
@Redirect(method = "renderCrosshair", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/OptionInstance;get()Ljava/lang/Object;", ordinal = 1))
public Object renderCrosshair(OptionInstance<AttackIndicatorStatus> instance) {
return LegacyConfig.legacyCombat.get() ? AttackIndicatorStatus.OFF : instance.get();
return LegacyConfig.hasCommonConfigEnabled(LegacyConfig.legacyCombat) ? AttackIndicatorStatus.OFF : instance.get();
}

@Redirect(method = /*? if >=1.20.5 {*/"renderItemHotbar"/*?} else {*//*"renderHotbar"*//*?}*/, at = @At(value = "INVOKE", target = "Lnet/minecraft/client/OptionInstance;get()Ljava/lang/Object;"))
public Object renderItemHotbar(OptionInstance<AttackIndicatorStatus> instance) {
return LegacyConfig.legacyCombat.get() ? AttackIndicatorStatus.OFF : instance.get();
return LegacyConfig.hasCommonConfigEnabled(LegacyConfig.legacyCombat) ? AttackIndicatorStatus.OFF : instance.get();
}

@Inject(method = "renderCrosshair", at = @At("HEAD"), cancellable = true)
Expand Down

0 comments on commit 22c5499

Please sign in to comment.