Enchantment and potions
This commit is contained in:
parent
64f4285fbb
commit
b79339e5bc
13 changed files with 169 additions and 6 deletions
|
@ -5,6 +5,8 @@ import net.fabricmc.api.ModInitializer;
|
|||
import net.minecraft.util.Identifier;
|
||||
|
||||
import ru.betterend.config.MainConfig;
|
||||
import ru.betterend.effects.EndEnchantments;
|
||||
import ru.betterend.effects.EndPotions;
|
||||
import ru.betterend.recipe.CraftingRecipes;
|
||||
import ru.betterend.registry.BiomeRegistry;
|
||||
import ru.betterend.registry.BlockEntityRegistry;
|
||||
|
@ -38,6 +40,8 @@ public class BetterEnd implements ModInitializer {
|
|||
BetterEndBiomeSource.register();
|
||||
ItemTagRegistry.register();
|
||||
BlockTagRegistry.register();
|
||||
EndEnchantments.register();
|
||||
EndPotions.register();
|
||||
CraftingRecipes.register();
|
||||
StructureRegistry.register();
|
||||
}
|
||||
|
|
16
src/main/java/ru/betterend/effects/EndEnchantments.java
Normal file
16
src/main/java/ru/betterend/effects/EndEnchantments.java
Normal file
|
@ -0,0 +1,16 @@
|
|||
package ru.betterend.effects;
|
||||
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.effects.enchantment.EndVeilEnchantment;
|
||||
|
||||
public class EndEnchantments {
|
||||
public final static Enchantment END_VEIL = registerEnchantment("end_veil", new EndVeilEnchantment());
|
||||
|
||||
public static Enchantment registerEnchantment(String name, Enchantment enchantment) {
|
||||
return Registry.register(Registry.ENCHANTMENT, BetterEnd.makeID(name), enchantment);
|
||||
}
|
||||
|
||||
public static void register() {}
|
||||
}
|
29
src/main/java/ru/betterend/effects/EndPotions.java
Normal file
29
src/main/java/ru/betterend/effects/EndPotions.java
Normal file
|
@ -0,0 +1,29 @@
|
|||
package ru.betterend.effects;
|
||||
|
||||
import net.minecraft.entity.effect.StatusEffect;
|
||||
import net.minecraft.entity.effect.StatusEffectInstance;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.Potions;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.mixin.common.BrewingAccessor;
|
||||
import ru.betterend.registry.ItemRegistry;
|
||||
|
||||
public class EndPotions {
|
||||
public final static Potion END_VEIL = registerPotion("end_veil", EndStatusEffects.END_VEIL, 3600);
|
||||
public final static Potion LONG_END_VEIL = registerPotion("long_end_veil", EndStatusEffects.END_VEIL, 9600);
|
||||
|
||||
public static Potion registerPotion(String name, StatusEffect effect, int duration) {
|
||||
return registerPotion(name, new Potion(name, new StatusEffectInstance[]{ new StatusEffectInstance(effect, duration) }));
|
||||
}
|
||||
|
||||
public static Potion registerPotion(String name, Potion potion) {
|
||||
return Registry.register(Registry.POTION, BetterEnd.makeID(name), potion);
|
||||
}
|
||||
|
||||
public static void register() {
|
||||
BrewingAccessor.callRegisterPotionRecipe(Potions.AWKWARD, ItemRegistry.ENDER_DUST, END_VEIL);
|
||||
BrewingAccessor.callRegisterPotionRecipe(END_VEIL, Items.REDSTONE, LONG_END_VEIL);
|
||||
}
|
||||
}
|
15
src/main/java/ru/betterend/effects/EndStatusEffects.java
Normal file
15
src/main/java/ru/betterend/effects/EndStatusEffects.java
Normal file
|
@ -0,0 +1,15 @@
|
|||
package ru.betterend.effects;
|
||||
|
||||
import net.minecraft.entity.effect.StatusEffect;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.effects.status.EndVeilEffect;
|
||||
|
||||
public class EndStatusEffects {
|
||||
|
||||
public final static StatusEffect END_VEIL = registerEffect("end_veil", new EndVeilEffect());
|
||||
|
||||
public static <E extends StatusEffect> StatusEffect registerEffect(String name, E effect) {
|
||||
return Registry.register(Registry.STATUS_EFFECT, BetterEnd.makeID(name), effect);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package ru.betterend.effects.enchantment;
|
||||
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.EnchantmentTarget;
|
||||
import net.minecraft.entity.EquipmentSlot;
|
||||
|
||||
public class EndVeilEnchantment extends Enchantment {
|
||||
|
||||
public EndVeilEnchantment() {
|
||||
super(Enchantment.Rarity.VERY_RARE, EnchantmentTarget.ARMOR_HEAD, new EquipmentSlot[] { EquipmentSlot.HEAD });
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailableForRandomSelection() {
|
||||
return false;
|
||||
}
|
||||
}
|
16
src/main/java/ru/betterend/effects/status/EndVeilEffect.java
Normal file
16
src/main/java/ru/betterend/effects/status/EndVeilEffect.java
Normal file
|
@ -0,0 +1,16 @@
|
|||
package ru.betterend.effects.status;
|
||||
|
||||
import net.minecraft.entity.effect.StatusEffect;
|
||||
import net.minecraft.entity.effect.StatusEffectType;
|
||||
|
||||
public class EndVeilEffect extends StatusEffect {
|
||||
|
||||
public EndVeilEffect() {
|
||||
super(StatusEffectType.BENEFICIAL, 0x0D554A);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canApplyUpdateEffect(int duration, int amplifier) {
|
||||
return false;
|
||||
}
|
||||
}
|
16
src/main/java/ru/betterend/mixin/common/BrewingAccessor.java
Normal file
16
src/main/java/ru/betterend/mixin/common/BrewingAccessor.java
Normal file
|
@ -0,0 +1,16 @@
|
|||
package ru.betterend.mixin.common;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.recipe.BrewingRecipeRegistry;
|
||||
|
||||
@Mixin(BrewingRecipeRegistry.class)
|
||||
public interface BrewingAccessor {
|
||||
@Invoker
|
||||
static void callRegisterPotionRecipe(Potion input, Item item, Potion output) {
|
||||
throw new AssertionError("@Invoker dummy body called");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package ru.betterend.mixin.common;
|
||||
|
||||
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;
|
||||
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.mob.EndermanEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
|
||||
import ru.betterend.effects.EndEnchantments;
|
||||
import ru.betterend.effects.EndStatusEffects;
|
||||
|
||||
@Mixin(EndermanEntity.class)
|
||||
public abstract class EndermanEntityMixin {
|
||||
|
||||
@Inject(method = "isPlayerStaring", at = @At("HEAD"), cancellable = true)
|
||||
private void isPlayerStaring(PlayerEntity player, CallbackInfoReturnable<Boolean> info) {
|
||||
if (player.isCreative() || player.hasStatusEffect(EndStatusEffects.END_VEIL) ||
|
||||
EnchantmentHelper.getEquipmentLevel(EndEnchantments.END_VEIL, player) > 0) {
|
||||
info.setReturnValue(false);
|
||||
info.cancel();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -50,6 +50,17 @@
|
|||
"item.betterend.diamond_hammer": "Diamond Smith Hammer",
|
||||
"item.betterend.netherite_hammer": "Netherite Smith Hammer",
|
||||
|
||||
"effect.betterend.end_veil": "End Veil",
|
||||
"enchantment.betterend.end_veil": "End Veil",
|
||||
"item.minecraft.potion.effect.end_veil": "Potion of End Veil",
|
||||
"item.minecraft.potion.effect.long_end_veil": "Long potion of End Veil",
|
||||
"item.minecraft.splash_potion.effect.end_veil": "Splash potion of End Veil",
|
||||
"item.minecraft.splash_potion.effect.long_end_veil": "Splash potion of End Veil",
|
||||
"item.minecraft.lingering_potion.effect.end_veil": "Lingering potion of End Veil",
|
||||
"item.minecraft.lingering_potion.effect.long_end_veil": "Lingering potion of End Veil",
|
||||
"item.minecraft.tipped_arrow.effect.end_veil": "Arrow of End Veil",
|
||||
"item.minecraft.tipped_arrow.effect.long_end_veil": "Arrow of End Veil",
|
||||
|
||||
"block.betterend.mossy_glowshroom_sapling": "Mossy Glowshroom Sapling",
|
||||
"block.betterend.mossy_glowshroom_cap": "Mossy Glowshroom Cap",
|
||||
"block.betterend.mossy_glowshroom_fur": "Mossy Glowshroom Fur",
|
||||
|
|
|
@ -50,6 +50,17 @@
|
|||
"item.betterend.diamond_hammer": "Алмазный Кузнечный Молот",
|
||||
"item.betterend.netherite_hammer": "Кузнечный Молот из Незерита",
|
||||
|
||||
"effect.betterend.end_veil": "Вуаль Края",
|
||||
"enchantment.betterend.end_veil": "Вуаль Края",
|
||||
"item.minecraft.potion.effect.end_veil": "Зелье Вуали Края",
|
||||
"item.minecraft.potion.effect.long_end_veil": "Долгое зелье Вуали Края",
|
||||
"item.minecraft.splash_potion.effect.end_veil": "Взрывное зелье Вуали Края",
|
||||
"item.minecraft.splash_potion.effect.long_end_veil": "Взрывное зелье Вуали Края",
|
||||
"item.minecraft.lingering_potion.effect.end_veil": "Оседающее зелье Вуали Края",
|
||||
"item.minecraft.lingering_potion.effect.long_end_veil": "Оседающее зелье Вуали Края",
|
||||
"item.minecraft.tipped_arrow.effect.end_veil": "Стрела Вуали Края",
|
||||
"item.minecraft.tipped_arrow.effect.long_end_veil": "Стрела Вуали Края",
|
||||
|
||||
"block.betterend.mossy_glowshroom_sapling": "Саженец мшистого светогриба",
|
||||
"block.betterend.mossy_glowshroom_cap": "Шляпка мшистого светогриба",
|
||||
"block.betterend.mossy_glowshroom_fur": "Волоски мшистого светогриба",
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 841 B |
|
@ -4,19 +4,21 @@
|
|||
"package": "ru.betterend.mixin.common",
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"mixins": [
|
||||
"DimensionTypeMixin",
|
||||
"RecipeManagerMixin",
|
||||
"ServerPlayNetworkHandlerMixin",
|
||||
"TagGroupLoaderMixin",
|
||||
"CraftingScreenHandlerMixin",
|
||||
"DefaultBiomeCreatorMixin",
|
||||
"GenerationSettingsMixin",
|
||||
"AnvilScreenHandlerMixin",
|
||||
"TagGroupLoaderMixin",
|
||||
"EndermanEntityMixin",
|
||||
"LocateCommandMixin",
|
||||
"DimensionTypeMixin",
|
||||
"RecipeManagerMixin",
|
||||
"AbstractBlockMixin",
|
||||
"LivingEntityMixin",
|
||||
"BiomeMixin",
|
||||
"SlimeEntityMixin",
|
||||
"LocateCommandMixin",
|
||||
"DefaultBiomeCreatorMixin"
|
||||
"BrewingAccessor",
|
||||
"BiomeMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue