|
5 | 5 | import galena.oreganized.content.block.MoltenLeadCauldronBlock;
|
6 | 6 | import galena.oreganized.content.entity.GargoyleBlockEntity;
|
7 | 7 | import galena.oreganized.content.item.ScribeItem;
|
| 8 | +import galena.oreganized.index.OAttributes; |
8 | 9 | import galena.oreganized.index.OBlocks;
|
9 | 10 | import galena.oreganized.index.OEffects;
|
10 | 11 | import galena.oreganized.index.OFluids;
|
|
19 | 20 | import net.minecraft.world.InteractionHand;
|
20 | 21 | import net.minecraft.world.effect.MobEffectInstance;
|
21 | 22 | import net.minecraft.world.effect.MobEffects;
|
| 23 | +import net.minecraft.world.entity.EquipmentSlot; |
22 | 24 | import net.minecraft.world.entity.LivingEntity;
|
| 25 | +import net.minecraft.world.entity.ai.attributes.AttributeModifier; |
23 | 26 | import net.minecraft.world.entity.player.Player;
|
| 27 | +import net.minecraft.world.item.DiggerItem; |
24 | 28 | import net.minecraft.world.item.ItemStack;
|
25 | 29 | import net.minecraft.world.item.Items;
|
| 30 | +import net.minecraft.world.item.SwordItem; |
26 | 31 | import net.minecraft.world.level.Level;
|
27 | 32 | import net.minecraft.world.level.block.Block;
|
28 | 33 | import net.minecraft.world.level.block.Blocks;
|
29 | 34 | import net.minecraft.world.level.block.state.BlockState;
|
30 | 35 | import net.minecraftforge.common.ToolAction;
|
31 | 36 | import net.minecraftforge.common.ToolActions;
|
| 37 | +import net.minecraftforge.event.ItemAttributeModifierEvent; |
32 | 38 | import net.minecraftforge.event.TickEvent;
|
33 | 39 | import net.minecraftforge.event.entity.living.LivingEntityUseItemEvent;
|
34 | 40 | import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
35 | 41 | import net.minecraftforge.event.level.BlockEvent;
|
| 42 | +import net.minecraftforge.eventbus.api.EventPriority; |
36 | 43 | import net.minecraftforge.eventbus.api.SubscribeEvent;
|
37 | 44 | import net.minecraftforge.fml.common.Mod;
|
38 | 45 |
|
| 46 | +import java.util.UUID; |
| 47 | + |
39 | 48 | @Mod.EventBusSubscriber(modid = Oreganized.MOD_ID)
|
40 | 49 | public class PlayerEvents {
|
41 | 50 |
|
@@ -143,4 +152,24 @@ public static void onBlockBreak(final BlockEvent.BreakEvent event) {
|
143 | 152 | event.setExpToDrop(0);
|
144 | 153 | }
|
145 | 154 | }
|
| 155 | + |
| 156 | + @SubscribeEvent(priority = EventPriority.LOW) |
| 157 | + public static void onItemAttributes(ItemAttributeModifierEvent event) { |
| 158 | + var stack = event.getItemStack(); |
| 159 | + var mods = event.getModifiers(); |
| 160 | + |
| 161 | + if (event.getSlotType() != EquipmentSlot.MAINHAND) return; |
| 162 | + |
| 163 | + if (stack.is(OTags.Items.HAS_KINETIC_DAMAGE) && !mods.containsKey(OAttributes.KINETIC_DAMAGE.get())) { |
| 164 | + var damage = stack.getItem() instanceof DiggerItem item |
| 165 | + ? item.getAttackDamage() |
| 166 | + : stack.getItem() instanceof SwordItem item |
| 167 | + ? item.getDamage() |
| 168 | + : 2.0F; |
| 169 | + event.addModifier(OAttributes.KINETIC_DAMAGE.get(), new AttributeModifier( |
| 170 | + UUID.fromString("0191ff58-54d7-711d-8a94-692379277c23"), "Kinetic Damage", damage / 3, AttributeModifier.Operation.ADDITION) |
| 171 | + ); |
| 172 | + } |
| 173 | + } |
| 174 | + |
146 | 175 | }
|
0 commit comments