Skip to content

Commit

Permalink
Improve CQR golden feather tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
ACGaming committed Sep 16, 2023
1 parent bd2030a commit 06c5b6d
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.PlayerEvent;

import mod.acgaming.universaltweaks.UniversalTweaks;
import mod.acgaming.universaltweaks.config.UTConfig;

// Courtesy of Focamacho
@Mod.EventBusSubscriber
@Mod.EventBusSubscriber(modid = UniversalTweaks.MODID)
public class UTVanillaEvents
{
@SubscribeEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2164,7 +2164,6 @@ public static class ChiselCategory

public static class ChocolateQuestCategory
{
@Config.RequiresMcRestart
@Config.Name("Legacy Golden Feather")
@Config.Comment("Restores the golden feather behavior from the original Better Dungeons mod")
public boolean utCQRGoldenFeatherToggle = true;
Expand Down Expand Up @@ -2650,7 +2649,7 @@ public static class TinkersConstructCategory
({
"Hides tool/bow materials in the 'Materials and You' book",
"Syntax: material",
"Enabling debug logging prints all materials on opening the book"
"Enabling debug logging prints all materials on game launch"
})
public String[] utTConMaterialBlacklist = new String[] {};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package mod.acgaming.universaltweaks.mods.cqrepoured;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemStack;
import net.minecraftforge.event.entity.living.LivingFallEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

import mod.acgaming.universaltweaks.UniversalTweaks;
import mod.acgaming.universaltweaks.config.UTConfig;
import team.cqr.cqrepoured.init.CQRItems;

@Mod.EventBusSubscriber(modid = UniversalTweaks.MODID)
public class UTGoldenFeatherEvent
{
@SubscribeEvent
public static void onLivingFallEvent(LivingFallEvent event)
{
if (UTConfig.MOD_INTEGRATION.CHOCOLATE_QUEST.utCQRGoldenFeatherToggle && event.getDistance() > 0.0F && event.getEntityLiving() instanceof EntityPlayer)
{
EntityPlayer player = (EntityPlayer) event.getEntityLiving();
ItemStack mainhand = player.getItemStackFromSlot(EntityEquipmentSlot.MAINHAND);
ItemStack offhand = player.getItemStackFromSlot(EntityEquipmentSlot.OFFHAND);
if (mainhand.getItem() != CQRItems.FEATHER_GOLDEN && offhand.getItem() != CQRItems.FEATHER_GOLDEN)
{
for (ItemStack stack : player.inventory.mainInventory)
{
if (stack.getItem() == CQRItems.FEATHER_GOLDEN)
{
stack.damageItem((int) event.getDistance(), player);
event.setDistance(0.0F);
return;
}
}
}
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package mod.acgaming.universaltweaks.mods.cqrepoured.mixin;

import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.world.World;
Expand All @@ -21,17 +20,7 @@ public class UTGoldenFeatherItemMixin extends ItemLore
public void utGoldenFeatherItem(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected, CallbackInfo ci)
{
if (!UTConfig.MOD_INTEGRATION.CHOCOLATE_QUEST.utCQRGoldenFeatherToggle) return;
if (entity.fallDistance >= 3)
{
// Handle item damage and fall distance in the server world...
if (!world.isRemote)
{
stack.damageItem(1, (EntityLivingBase) entity);
entity.fallDistance = 0;
}
// ...and particles in the client world
else world.spawnParticle(EnumParticleTypes.CLOUD, entity.posX, entity.posY, entity.posZ, (itemRand.nextFloat() - 0.5) / 2, -0.5, (itemRand.nextFloat() - 0.5) / 2);
}
if (entity.fallDistance >= 3) world.spawnParticle(EnumParticleTypes.CLOUD, entity.posX, entity.posY, entity.posZ, (itemRand.nextFloat() - 0.5) / 2, -0.5, (itemRand.nextFloat() - 0.5) / 2);
super.onUpdate(stack, world, entity, itemSlot, isSelected);
ci.cancel();
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/mixins.mods.cqrepoured.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"refmap": "universaltweaks.refmap.json",
"minVersion": "0.8",
"compatibilityLevel": "JAVA_8",
"mixins": ["UTGoldenFeatherEventMixin", "UTGoldenFeatherItemMixin"]
"mixins": ["UTGoldenFeatherItemMixin"]
}

0 comments on commit 06c5b6d

Please sign in to comment.