-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from Badtz13/bone_enchantments_R1
Adds Hog, Greed, and Fiery effect
- Loading branch information
Showing
33 changed files
with
179 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package me.woach.bone.effects; | ||
|
||
import net.minecraft.enchantment.Enchantment; | ||
import net.minecraft.enchantment.EnchantmentTarget; | ||
import net.minecraft.entity.EquipmentSlot; | ||
|
||
public abstract class BoneEffect extends Enchantment { | ||
protected BoneEffect(Rarity weight, EnchantmentTarget target, EquipmentSlot... slotTypes) { | ||
super(weight, target, slotTypes); | ||
} | ||
|
||
@Override | ||
public boolean isAvailableForEnchantedBookOffer() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean isAvailableForRandomSelection() { | ||
return false; | ||
} | ||
} |
12 changes: 5 additions & 7 deletions
12
src/main/java/me/woach/bone/effects/BoneEffectRegistry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package me.woach.bone.effects; | ||
|
||
import net.minecraft.enchantment.EnchantmentTarget; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.entity.EquipmentSlot; | ||
import net.minecraft.entity.LivingEntity; | ||
|
||
public class FieryEffect extends BoneEffect { | ||
|
||
protected FieryEffect() { | ||
super(Rarity.RARE, EnchantmentTarget.WEAPON, EquipmentSlot.MAINHAND); | ||
} | ||
|
||
@Override | ||
public void onTargetDamaged(LivingEntity user, Entity target, int level) { | ||
if (target instanceof LivingEntity) { | ||
target.setFireTicks(4 * 20 * level); | ||
} | ||
|
||
super.onTargetDamaged(user, target, level); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package me.woach.bone.effects; | ||
|
||
import net.minecraft.enchantment.EnchantmentTarget; | ||
import net.minecraft.entity.EquipmentSlot; | ||
|
||
public class HogEffect extends BoneEffect{ | ||
|
||
protected HogEffect() { | ||
super(Rarity.RARE, EnchantmentTarget.ARMOR_HEAD, EquipmentSlot.HEAD); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package me.woach.bone.mixin; | ||
|
||
import me.woach.bone.effects.BoneEffectRegistry; | ||
import net.minecraft.enchantment.EnchantmentHelper; | ||
import net.minecraft.entity.LivingEntity; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(EnchantmentHelper.class) | ||
public class greedMimicsLooting { | ||
|
||
@Inject(method = "getLooting", at = @At("RETURN"), cancellable = true) | ||
private static void useGreed(LivingEntity entity, CallbackInfoReturnable<Integer> cir) { | ||
int greedLevel = EnchantmentHelper.getEquipmentLevel(BoneEffectRegistry.GREED.get(), entity); | ||
if (greedLevel > cir.getReturnValue()) | ||
cir.setReturnValue(greedLevel); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package me.woach.bone.mixin; | ||
|
||
import me.woach.bone.Bone; | ||
import me.woach.bone.effects.BoneEffectRegistry; | ||
import net.minecraft.enchantment.EnchantmentHelper; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.entity.EntityType; | ||
import net.minecraft.entity.EquipmentSlot; | ||
import net.minecraft.entity.LivingEntity; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.world.World; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(LivingEntity.class) | ||
public abstract class hogDecreasesEating extends Entity { | ||
|
||
@Shadow public abstract ItemStack getEquippedStack(EquipmentSlot var1); | ||
|
||
@Shadow protected int itemUseTimeLeft; | ||
|
||
public hogDecreasesEating(EntityType<?> type, World world) { | ||
super(type, world); | ||
} | ||
|
||
@Inject(method = "tickItemStackUsage", at = @At("HEAD")) | ||
private void extraTicksOnFoodWithHog(ItemStack stack, CallbackInfo ci) { | ||
if (stack.isFood()) { | ||
ItemStack helmet = this.getEquippedStack(EquipmentSlot.HEAD); | ||
int hogLevel = EnchantmentHelper.getLevel(BoneEffectRegistry.HOG.get(), helmet); | ||
if (hogLevel != 0) { | ||
if (this.itemUseTimeLeft % (5 - hogLevel) == 0) { | ||
this.itemUseTimeLeft -= 1; | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"enabled": true, | ||
"effect": "bone:sonar", | ||
"entity": "minecraft:entities/bat" | ||
"entity": "minecraft/bat" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"enabled": true, | ||
"chance": 125, | ||
"effect": "bone:firey", | ||
"entity": "minecraft:blaze" | ||
} |
Oops, something went wrong.