Add Veridium Poisoning
All checks were successful
EnergonRelics/pipeline/head This commit looks good
All checks were successful
EnergonRelics/pipeline/head This commit looks good
This commit is contained in:
parent
48c0ee8ebe
commit
5e0d956b37
@ -17,6 +17,7 @@ import com.thebrokenrail.energonrelics.block.SwitchBlock;
|
|||||||
import com.thebrokenrail.energonrelics.block.util.SimpleBlock;
|
import com.thebrokenrail.energonrelics.block.util.SimpleBlock;
|
||||||
import com.thebrokenrail.energonrelics.item.MultimeterItem;
|
import com.thebrokenrail.energonrelics.item.MultimeterItem;
|
||||||
import com.thebrokenrail.energonrelics.item.NetworkChipItem;
|
import com.thebrokenrail.energonrelics.item.NetworkChipItem;
|
||||||
|
import com.thebrokenrail.energonrelics.potion.CustomPotions;
|
||||||
import net.fabricmc.api.ModInitializer;
|
import net.fabricmc.api.ModInitializer;
|
||||||
import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
|
import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
@ -104,5 +105,7 @@ public class EnergonRelics implements ModInitializer {
|
|||||||
BLOCK_BREAKER_BLOCK.register("block_breaker");
|
BLOCK_BREAKER_BLOCK.register("block_breaker");
|
||||||
|
|
||||||
Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "veridium_powder"), VERIDIUM_POWDER_ITEM);
|
Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "veridium_powder"), VERIDIUM_POWDER_ITEM);
|
||||||
|
|
||||||
|
CustomPotions.register();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
package com.thebrokenrail.energonrelics.mixin;
|
||||||
|
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.potion.Potion;
|
||||||
|
import net.minecraft.recipe.BrewingRecipeRegistry;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||||
|
|
||||||
|
@Mixin(BrewingRecipeRegistry.class)
|
||||||
|
public interface BrewingRecipeRegistryAccessor {
|
||||||
|
@Invoker
|
||||||
|
static void callRegisterPotionRecipe(Potion input, Item item, Potion output) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,61 @@
|
|||||||
|
package com.thebrokenrail.energonrelics.mixin;
|
||||||
|
|
||||||
|
import com.thebrokenrail.energonrelics.potion.CustomPotions;
|
||||||
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
import net.minecraft.entity.attribute.EntityAttribute;
|
||||||
|
import net.minecraft.entity.attribute.EntityAttributes;
|
||||||
|
import net.minecraft.entity.data.DataTracker;
|
||||||
|
import net.minecraft.entity.data.TrackedData;
|
||||||
|
import net.minecraft.entity.data.TrackedDataHandlerRegistry;
|
||||||
|
import net.minecraft.entity.effect.StatusEffect;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
import org.spongepowered.asm.mixin.Unique;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
|
@Mixin(LivingEntity.class)
|
||||||
|
public abstract class MixinLivingEntity {
|
||||||
|
@Unique
|
||||||
|
private static final TrackedData<Boolean> HAS_VERIDIUM_POISONING = DataTracker.registerData(LivingEntity.class, TrackedDataHandlerRegistry.BOOLEAN);
|
||||||
|
|
||||||
|
@Shadow
|
||||||
|
public abstract boolean hasStatusEffect(StatusEffect effect);
|
||||||
|
|
||||||
|
@Shadow
|
||||||
|
public abstract void setHealth(float health);
|
||||||
|
|
||||||
|
@Shadow
|
||||||
|
public abstract float getHealth();
|
||||||
|
|
||||||
|
@Inject(at = @At("RETURN"), method = "initDataTracker")
|
||||||
|
public void initDataTracker(CallbackInfo info) {
|
||||||
|
((LivingEntity) (Object) this).getDataTracker().startTracking(HAS_VERIDIUM_POISONING, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(at = @At("RETURN"), method = "onTrackedDataSet")
|
||||||
|
public void onTrackedDataSet(TrackedData<?> data, CallbackInfo info) {
|
||||||
|
if (HAS_VERIDIUM_POISONING.equals(data)) {
|
||||||
|
setHealth(getHealth());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(at = @At("HEAD"), method = "tick")
|
||||||
|
public void tick(CallbackInfo info) {
|
||||||
|
if (!((LivingEntity) (Object) this).getEntityWorld().isClient()) {
|
||||||
|
boolean hasVeridiumPoisoning = hasStatusEffect(CustomPotions.VERIDIUM_POISONING_EFFECT.statusEffect);
|
||||||
|
if (((LivingEntity) (Object) this).getDataTracker().get(HAS_VERIDIUM_POISONING) != hasVeridiumPoisoning) {
|
||||||
|
((LivingEntity) (Object) this).getDataTracker().set(HAS_VERIDIUM_POISONING, hasVeridiumPoisoning);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(at = @At("HEAD"), method = "getAttributeValue", cancellable = true)
|
||||||
|
public void getAttributeValue(EntityAttribute attribute, CallbackInfoReturnable<Double> info) {
|
||||||
|
if (EntityAttributes.GENERIC_MAX_HEALTH.equals(attribute) && ((LivingEntity) (Object) this).getDataTracker().get(HAS_VERIDIUM_POISONING)) {
|
||||||
|
info.setReturnValue(0.5d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,53 @@
|
|||||||
|
package com.thebrokenrail.energonrelics.potion;
|
||||||
|
|
||||||
|
import com.thebrokenrail.energonrelics.EnergonRelics;
|
||||||
|
import com.thebrokenrail.energonrelics.mixin.BrewingRecipeRegistryAccessor;
|
||||||
|
import net.minecraft.entity.effect.StatusEffect;
|
||||||
|
import net.minecraft.entity.effect.StatusEffectInstance;
|
||||||
|
import net.minecraft.entity.effect.StatusEffectType;
|
||||||
|
import net.minecraft.item.Items;
|
||||||
|
import net.minecraft.potion.Potion;
|
||||||
|
import net.minecraft.potion.Potions;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
import net.minecraft.util.registry.Registry;
|
||||||
|
|
||||||
|
public class CustomPotions {
|
||||||
|
public static class CustomPotion {
|
||||||
|
private static class CustomStatusEffect extends StatusEffect {
|
||||||
|
private CustomStatusEffect(StatusEffectType type, int color) {
|
||||||
|
super(type, color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public final StatusEffect statusEffect;
|
||||||
|
private final Potion potion;
|
||||||
|
private final Potion longPotion;
|
||||||
|
|
||||||
|
private CustomPotion(StatusEffect statusEffect, Potion potion, Potion longPotion) {
|
||||||
|
this.statusEffect = statusEffect;
|
||||||
|
this.potion = potion;
|
||||||
|
this.longPotion = longPotion;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CustomPotion VERIDIUM_POISONING_EFFECT;
|
||||||
|
|
||||||
|
public static void register() {
|
||||||
|
VERIDIUM_POISONING_EFFECT = registerEffect("veridium_poisoning", 16711909);
|
||||||
|
registerBrewingRecipes();
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("SameParameterValue")
|
||||||
|
private static CustomPotion registerEffect(String name, int color) {
|
||||||
|
StatusEffect effect = Registry.register(Registry.STATUS_EFFECT, new Identifier(EnergonRelics.NAMESPACE, name), new CustomPotion.CustomStatusEffect(StatusEffectType.HARMFUL, color));
|
||||||
|
Potion potion = Registry.register(Registry.POTION, new Identifier(EnergonRelics.NAMESPACE, name), new Potion(EnergonRelics.NAMESPACE + '.' + name, new StatusEffectInstance(effect, 1800)));
|
||||||
|
Potion longPotion = Registry.register(Registry.POTION, new Identifier(EnergonRelics.NAMESPACE, "long_" + name), new Potion(EnergonRelics.NAMESPACE + '.' + name, new StatusEffectInstance(effect, 4800)));
|
||||||
|
return new CustomPotion(effect, potion, longPotion);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void registerBrewingRecipes() {
|
||||||
|
BrewingRecipeRegistryAccessor.callRegisterPotionRecipe(Potions.AWKWARD, EnergonRelics.VERIDIUM_POWDER_ITEM, VERIDIUM_POISONING_EFFECT.potion);
|
||||||
|
BrewingRecipeRegistryAccessor.callRegisterPotionRecipe(VERIDIUM_POISONING_EFFECT.potion, Items.REDSTONE, VERIDIUM_POISONING_EFFECT.longPotion);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -28,5 +28,10 @@
|
|||||||
"death.attack.energonrelics.defensive_laser.player": "%s was evaporated by a laser whilst fighting %s",
|
"death.attack.energonrelics.defensive_laser.player": "%s was evaporated by a laser whilst fighting %s",
|
||||||
"block.energonrelics.research_complex_generator": "Research Complex Generator",
|
"block.energonrelics.research_complex_generator": "Research Complex Generator",
|
||||||
"block.energonrelics.block_breaker": "Block Breaker",
|
"block.energonrelics.block_breaker": "Block Breaker",
|
||||||
"item.energonrelics.veridium_powder": "Veridium Powder"
|
"item.energonrelics.veridium_powder": "Veridium Powder",
|
||||||
|
"effect.energonrelics.veridium_poisoning": "Veridium Poisoning",
|
||||||
|
"item.minecraft.potion.effect.energonrelics.veridium_poisoning": "Potion of Veridium Poisoning",
|
||||||
|
"item.minecraft.splash_potion.effect.energonrelics.veridium_poisoning": "Splash Potion of Veridium Poisoning",
|
||||||
|
"item.minecraft.lingering_potion.effect.energonrelics.veridium_poisoning": "Lingering Potion of Veridium Poisoning",
|
||||||
|
"item.minecraft.tipped_arrow.effect.energonrelics.veridium_poisoning": "Arrow of Veridium Poisoning"
|
||||||
}
|
}
|
Binary file not shown.
After Width: | Height: | Size: 7.2 KiB |
@ -6,8 +6,10 @@
|
|||||||
"MixinAbstractFileResourcePack"
|
"MixinAbstractFileResourcePack"
|
||||||
],
|
],
|
||||||
"mixins": [
|
"mixins": [
|
||||||
|
"BrewingRecipeRegistryAccessor",
|
||||||
"DamageSourceAccessor",
|
"DamageSourceAccessor",
|
||||||
"MixinDefaultBiomeFeatures",
|
"MixinDefaultBiomeFeatures",
|
||||||
|
"MixinLivingEntity",
|
||||||
"MixinWorld",
|
"MixinWorld",
|
||||||
"RenderPhaseAccessor"
|
"RenderPhaseAccessor"
|
||||||
],
|
],
|
||||||
|
Reference in New Issue
Block a user