-
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
132 additions
and
141 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
neoforge/src/generated/resources/.cache/9f04af1a65ecbd537eacfe0d0657c2d5e7a40540
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,2 +1,2 @@ | ||
// 1.21.1 2024-10-24T16:35:57.1802687 Languages: en_us for mod: forbidden_arcanus | ||
c4ea19da19c80b17f84e993fd9087f7a2eb20af9 assets/forbidden_arcanus/lang/en_us.json | ||
// 1.21.1 2024-10-28T23:35:10.5863419 Languages: en_us for mod: forbidden_arcanus | ||
904c4138da3eb97be91f5b6228ad94ed7747aee0 assets/forbidden_arcanus/lang/en_us.json |
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
61 changes: 0 additions & 61 deletions
61
neoforge/src/main/java/com/stal111/forbidden_arcanus/common/effect/SpectralEyeEffect.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,11 @@ | ||
package com.stal111.forbidden_arcanus.common.effect; | ||
|
||
import com.stal111.forbidden_arcanus.core.init.ModMobEffects; | ||
import com.stal111.forbidden_arcanus.util.ModUtils; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import net.minecraft.world.entity.monster.Monster; | ||
import net.minecraft.world.entity.ambient.AmbientCreature; | ||
import net.minecraft.world.entity.animal.Animal; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.effect.MobEffect; | ||
import net.minecraft.world.effect.MobEffectInstance; | ||
import net.minecraft.world.effect.MobEffectCategory; | ||
import net.minecraft.world.effect.MobEffects; | ||
import net.minecraft.world.scores.PlayerTeam; | ||
import net.minecraft.world.scores.Scoreboard; | ||
import net.minecraft.world.phys.AABB; | ||
import net.minecraft.ChatFormatting; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Spectral Eye Effect <br> | ||
* Forbidden Arcanus - com.stal111.forbidden_arcanus.common.effect.SpectralEyeEffect | ||
* | ||
* @author stal111 | ||
* @version 1.17.1 - 2.0.0 | ||
*/ | ||
public class SpectralEyeEffect extends MobEffect { | ||
|
||
private static final int EFFECT_RADIUS = 60; | ||
|
||
public SpectralEyeEffect(MobEffectCategory effectCategory, int color) { | ||
super(effectCategory, color); | ||
} | ||
|
||
@Override | ||
public boolean applyEffectTick(LivingEntity entity, int amplifier) { | ||
int i = entity.getEffect(ModMobEffects.SPECTRAL_VISION).getDuration(); | ||
if (!entity.getCommandSenderWorld().isClientSide()) { | ||
Scoreboard scoreboard = entity.getCommandSenderWorld().getServer().getScoreboard(); | ||
PlayerTeam teamPassiveOrNeutral = ModUtils.createTeam(scoreboard, "PassiveOrNeutral", ChatFormatting.GREEN); | ||
PlayerTeam teamHostile = ModUtils.createTeam(scoreboard, "Hostile", ChatFormatting.RED); | ||
PlayerTeam teamWater = ModUtils.createTeam(scoreboard, "Water", ChatFormatting.BLUE); | ||
|
||
double k = entity.getX(); | ||
double l = entity.getY(); | ||
double i1 = entity.getZ(); | ||
|
||
AABB aabb = new AABB(k, l, i1, (k + 1), (l + 1), (i1 + 1)).inflate(EFFECT_RADIUS).expandTowards(0.0D, entity.level().getMaxBuildHeight(), 0.0D); | ||
List<LivingEntity> list = entity.level().getEntitiesOfClass(LivingEntity.class, aabb); | ||
|
||
for(LivingEntity livingEntity : list) { | ||
if (livingEntity instanceof Animal || livingEntity instanceof AmbientCreature) { | ||
scoreboard.addPlayerToTeam(livingEntity.getScoreboardName(), teamPassiveOrNeutral); | ||
} else if (livingEntity instanceof Monster) { | ||
scoreboard.addPlayerToTeam(livingEntity.getScoreboardName(), teamHostile); | ||
} else if (!(livingEntity instanceof Player)) { | ||
scoreboard.addPlayerToTeam(livingEntity.getScoreboardName(), teamWater); | ||
} | ||
livingEntity.addEffect(new MobEffectInstance(MobEffects.GLOWING, 5, 0, true, true, false)); | ||
} | ||
|
||
if (i <= 5) { | ||
ModUtils.removeTeam(scoreboard, teamPassiveOrNeutral); | ||
ModUtils.removeTeam(scoreboard, teamHostile); | ||
ModUtils.removeTeam(scoreboard, teamWater); | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
} |
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
47 changes: 14 additions & 33 deletions
47
neoforge/src/main/java/com/stal111/forbidden_arcanus/common/item/SpectralEyeAmuletItem.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,52 @@ | ||
package com.stal111.forbidden_arcanus.common.item; | ||
|
||
import com.stal111.forbidden_arcanus.ForbiddenArcanus; | ||
import net.minecraft.ChatFormatting; | ||
import com.stal111.forbidden_arcanus.common.item.component.ToggleableState; | ||
import com.stal111.forbidden_arcanus.core.init.ModDataComponents; | ||
import com.stal111.forbidden_arcanus.core.init.ModMobEffects; | ||
import net.minecraft.core.registries.BuiltInRegistries; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.world.InteractionHand; | ||
import net.minecraft.world.InteractionResultHolder; | ||
import net.minecraft.world.effect.MobEffectInstance; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.item.TooltipFlag; | ||
import net.minecraft.world.level.Level; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.util.List; | ||
|
||
/** | ||
* Spectral Eye Amulet Item <br> | ||
* Forbidden Arcanus - com.stal111.forbidden_arcanus.common.item.SpectralEyeAmuletItem | ||
* | ||
* @author stal111 | ||
* @version 1.19 - 2.1.0 | ||
*/ | ||
public class SpectralEyeAmuletItem extends Item { | ||
|
||
public SpectralEyeAmuletItem(Item.Properties properties) { | ||
super(properties); | ||
} | ||
|
||
@Override | ||
public void inventoryTick(@Nonnull ItemStack stack, Level level, @Nonnull Entity entity, int itemSlot, boolean isSelected) { | ||
if (!level.isClientSide() && !this.isDeactivated(stack) && entity instanceof LivingEntity livingEntity) { | ||
//TODO | ||
//livingEntity.addEffect(new MobEffectInstance(ModMobEffects.SPECTRAL_VISION.get(), 40, 0, false, false, true)); | ||
public void inventoryTick(ItemStack stack, Level level, Entity entity, int itemSlot, boolean isSelected) { | ||
if (isActive(stack) && entity instanceof LivingEntity livingEntity) { | ||
livingEntity.addEffect(new MobEffectInstance(BuiltInRegistries.MOB_EFFECT.wrapAsHolder(ModMobEffects.SPECTRAL_VISION.get()), 80, 0, false, false, true)); | ||
} | ||
super.inventoryTick(stack, level, entity, itemSlot, isSelected); | ||
} | ||
|
||
@Nonnull | ||
@Override | ||
public InteractionResultHolder<ItemStack> use(@Nonnull Level level, Player player, @Nonnull InteractionHand hand) { | ||
public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand hand) { | ||
ItemStack stack = player.getItemInHand(hand); | ||
|
||
this.setDeactivated(stack, !this.isDeactivated(stack)); | ||
stack.update(ModDataComponents.TOGGLEABLE_STATE, ToggleableState.DEFAULT, ToggleableState::toggle); | ||
|
||
return InteractionResultHolder.sidedSuccess(stack, level.isClientSide()); | ||
} | ||
|
||
@Override | ||
public void appendHoverText(@NotNull ItemStack stack, @NotNull TooltipContext context, @NotNull List<Component> components, @NotNull TooltipFlag flag) { | ||
super.appendHoverText(stack, context, components, flag); | ||
|
||
Component toggle = Component.translatable("tooltip." + ForbiddenArcanus.MOD_ID + ".toggle").withStyle(ChatFormatting.GRAY); | ||
|
||
boolean deactivated = this.isDeactivated(stack); | ||
components.add(Component.translatable("tooltip." + ForbiddenArcanus.MOD_ID + (deactivated ? ".deactivated" : ".activated")).withStyle(deactivated ? ChatFormatting.RED : ChatFormatting.GREEN).append(" ").append(toggle)); | ||
} | ||
|
||
public boolean isDeactivated(ItemStack stack) { | ||
return false; | ||
//TODO | ||
// return stack.getOrCreateTag().getBoolean("Deactivated"); | ||
public void appendHoverText(ItemStack stack, TooltipContext context, List<Component> tooltipComponents, TooltipFlag tooltipFlag) { | ||
stack.addToTooltip(ModDataComponents.TOGGLEABLE_STATE, context, tooltipComponents::add, tooltipFlag); | ||
} | ||
|
||
public void setDeactivated(ItemStack stack, boolean deactivated) { | ||
//stack.getOrCreateTag().putBoolean("Deactivated", deactivated); | ||
public static boolean isActive(ItemStack stack) { | ||
return stack.getOrDefault(ModDataComponents.TOGGLEABLE_STATE, ToggleableState.DEFAULT).active(); | ||
} | ||
} |
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
49 changes: 49 additions & 0 deletions
49
...ge/src/main/java/com/stal111/forbidden_arcanus/common/item/component/ToggleableState.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.stal111.forbidden_arcanus.common.item.component; | ||
|
||
import com.mojang.serialization.Codec; | ||
import com.mojang.serialization.codecs.RecordCodecBuilder; | ||
import com.stal111.forbidden_arcanus.ForbiddenArcanus; | ||
import net.minecraft.ChatFormatting; | ||
import net.minecraft.Util; | ||
import net.minecraft.network.FriendlyByteBuf; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.network.codec.ByteBufCodecs; | ||
import net.minecraft.network.codec.StreamCodec; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.item.TooltipFlag; | ||
import net.minecraft.world.item.component.TooltipProvider; | ||
|
||
import java.util.function.Consumer; | ||
|
||
public record ToggleableState(boolean active, boolean showInTooltip) implements TooltipProvider { | ||
|
||
public static final Codec<ToggleableState> CODEC = RecordCodecBuilder.create(instance -> instance.group( | ||
Codec.BOOL.optionalFieldOf("active", true).forGetter(ToggleableState::active), | ||
Codec.BOOL.optionalFieldOf("showInTooltip", true).forGetter(ToggleableState::showInTooltip) | ||
).apply(instance, ToggleableState::new)); | ||
|
||
public static final StreamCodec<FriendlyByteBuf, ToggleableState> STREAM_CODEC = StreamCodec.composite( | ||
ByteBufCodecs.BOOL, | ||
ToggleableState::active, | ||
ByteBufCodecs.BOOL, | ||
ToggleableState::showInTooltip, | ||
ToggleableState::new | ||
); | ||
|
||
public static final ToggleableState DEFAULT = new ToggleableState(true, true); | ||
|
||
private static final Component TOGGLE = Component.translatable(Util.makeDescriptionId("item", ForbiddenArcanus.location("toggle_state"))).withStyle(ChatFormatting.GRAY); | ||
private static final Component TOGGLE_ACTIVATED = Component.translatable(Util.makeDescriptionId("item", ForbiddenArcanus.location("toggle_state.activated"))).withStyle(ChatFormatting.GREEN).append(" ").append(TOGGLE); | ||
private static final Component TOGGLE_DEACTIVATED = Component.translatable(Util.makeDescriptionId("item", ForbiddenArcanus.location("toggle_state.deactivated"))).withStyle(ChatFormatting.RED).append(" ").append(TOGGLE); | ||
|
||
public ToggleableState toggle() { | ||
return new ToggleableState(!this.active, this.showInTooltip); | ||
} | ||
|
||
@Override | ||
public void addToTooltip(Item.TooltipContext context, Consumer<Component> tooltipAdder, TooltipFlag tooltipFlag) { | ||
if (this.showInTooltip) { | ||
tooltipAdder.accept(this.active ? TOGGLE_ACTIVATED : TOGGLE_DEACTIVATED); | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
neoforge/src/main/java/com/stal111/forbidden_arcanus/common/item/component/package-info.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
@ParametersAreNonnullByDefault | ||
@MethodsReturnNonnullByDefault | ||
@FieldsAreNonnullByDefault | ||
package com.stal111.forbidden_arcanus.common.item.component; | ||
|
||
import net.minecraft.FieldsAreNonnullByDefault; | ||
import net.minecraft.MethodsReturnNonnullByDefault; | ||
|
||
import javax.annotation.ParametersAreNonnullByDefault; |
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
Oops, something went wrong.