mirror of
https://github.com/GoldChick/ExtraBotany.git
synced 2024-10-27 19:30:08 +08:00
v0.1.6.2
This commit is contained in:
parent
4eaf1179a5
commit
604976e7a6
@ -20,7 +20,7 @@ apply plugin: 'maven-publish'
|
||||
// apply MixinGradle
|
||||
apply plugin: 'org.spongepowered.mixin'
|
||||
|
||||
version = '1.18.2-0.1.6.2'
|
||||
version = '1.18.2-0.1.6.3'
|
||||
group = 'extrabotany' //'com.yourname.modid' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
archivesBaseName = 'extrabotany'
|
||||
|
||||
|
@ -455,6 +455,7 @@
|
||||
"item.extrabotany.potato_chip": "Potato Chip",
|
||||
"item.extrabotany.power_glove": "Power Glove",
|
||||
"item.extrabotany.primo_gem": "Primogem",
|
||||
"item.extrabotany.puredaisy_pendant": "Pure Daisy Pendant",
|
||||
"item.extrabotany.pylon": "Sims",
|
||||
"item.extrabotany.red_scarf": "Red Scarf",
|
||||
"item.extrabotany.reward_bag_a": "Reward Bag Eins",
|
||||
|
@ -457,6 +457,7 @@
|
||||
"item.extrabotany.potato_chip": "\u85AF\u7247",
|
||||
"item.extrabotany.power_glove": "\u5F3A\u529B\u624B\u5957",
|
||||
"item.extrabotany.primo_gem": "\u539F\u77F3",
|
||||
"item.extrabotany.puredaisy_pendant": "\u767D\u96CF\u83CA\u9879\u94FE",
|
||||
"item.extrabotany.pylon": "\u6A21\u62DF\u4EBA\u751F",
|
||||
"item.extrabotany.red_scarf": "\u7EA2\u9886\u5DFE",
|
||||
"item.extrabotany.reward_bag_a": "\u5956\u52B1\u888BEins",
|
||||
|
@ -1,7 +1,10 @@
|
||||
package chick.extrabotany.common.base;
|
||||
|
||||
import chick.extrabotany.common.baubles.NatureOrb;
|
||||
import chick.extrabotany.xplat.IXplatAbstractions;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
||||
@ -24,11 +27,17 @@ public class ManaRulerHandler
|
||||
var stack = event.getItemStack();
|
||||
if (stack.getItem() instanceof ItemManaRing)
|
||||
{
|
||||
var cap = stack.getCapability(BotaniaForgeCapabilities.MANA_ITEM);
|
||||
if (cap.resolve().isPresent())
|
||||
var cap = vazkii.botania.xplat.IXplatAbstractions.INSTANCE.findManaItem(stack);
|
||||
if (cap != null)
|
||||
{
|
||||
var item = cap.resolve().get();
|
||||
event.getToolTip().add(2, new TextComponent("Mana:" + item.getMana() + "/" + item.getMaxMana()).withStyle(ChatFormatting.AQUA));
|
||||
event.getToolTip().add(2, new TextComponent("Mana:" + cap.getMana() + "/" + cap.getMaxMana()).withStyle(ChatFormatting.AQUA));
|
||||
}
|
||||
} else if (stack.getItem() instanceof NatureOrb)
|
||||
{
|
||||
var cap = IXplatAbstractions.INSTANCE.findNatureOrbItem(stack);
|
||||
if (cap != null)
|
||||
{
|
||||
event.getToolTip().add(2, new TranslatableComponent("extrabotany.nature_orb", cap.getNature(), cap.getMaxNature()).withStyle(ChatFormatting.GRAY));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package chick.extrabotany.common.baubles;
|
||||
|
||||
import chick.extrabotany.ExtraBotany;
|
||||
import chick.extrabotany.api.cap.INatureOrbItem;
|
||||
import chick.extrabotany.common.entities.ego.EntityEGO;
|
||||
import chick.extrabotany.xplat.IXplatAbstractions;
|
||||
@ -7,11 +8,9 @@ import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.network.protocol.game.ClientboundRemoveMobEffectPacket;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
@ -21,8 +20,15 @@ import net.minecraft.world.item.TooltipFlag;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.living.PotionEvent;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import vazkii.botania.api.mana.ManaItemHandler;
|
||||
import vazkii.botania.client.fx.SparkleParticleData;
|
||||
import vazkii.botania.common.handler.EquipmentHandler;
|
||||
import vazkii.botania.common.handler.ModSounds;
|
||||
import vazkii.botania.common.helper.ItemNBTHelper;
|
||||
import vazkii.botania.common.item.equipment.bauble.ItemBauble;
|
||||
|
||||
@ -37,13 +43,11 @@ public class NatureOrb extends ItemBauble
|
||||
public NatureOrb(Properties props)
|
||||
{
|
||||
super(props);
|
||||
MinecraftForge.EVENT_BUS.addListener(this::clearBadPotions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendHoverText(ItemStack stack, Level world, List<Component> tooltip, TooltipFlag flags)
|
||||
private void addText(@Nullable INatureOrbItem manaItem, List<Component> tooltip)
|
||||
{
|
||||
super.appendHoverText(stack, world, tooltip, flags);
|
||||
var manaItem = IXplatAbstractions.INSTANCE.findNatureOrbItem(stack);
|
||||
if (manaItem != null)
|
||||
{
|
||||
tooltip.add(new TranslatableComponent("extrabotany.nature_orb", manaItem.getNature(), manaItem.getMaxNature()).withStyle(ChatFormatting.GRAY));
|
||||
@ -99,33 +103,53 @@ public class NatureOrb extends ItemBauble
|
||||
}
|
||||
}
|
||||
}
|
||||
if (orbItem.getNature() > 400000)
|
||||
{
|
||||
if (player.tickCount % 40 == 0)
|
||||
{
|
||||
clearPotions(stack, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void clearPotions(ItemStack stack, Player player)
|
||||
public void clearBadPotions(PotionEvent.PotionApplicableEvent event)
|
||||
{
|
||||
var orb = IXplatAbstractions.INSTANCE.findNatureOrbItem(stack);
|
||||
if (orb != null)
|
||||
LivingEntity living = event.getEntityLiving();
|
||||
var stack = EquipmentHandler.findOrEmpty(this, event.getEntityLiving());
|
||||
if (stack != null)
|
||||
{
|
||||
player.getActiveEffects().stream()
|
||||
.filter(effect -> !effect.getEffect().isBeneficial())
|
||||
.filter(effect -> effect.getCurativeItems().stream().anyMatch(e -> e.is(Items.MILK_BUCKET)))
|
||||
.map(MobEffectInstance::getEffect)
|
||||
.distinct().forEach(potion ->
|
||||
var orb = IXplatAbstractions.INSTANCE.findNatureOrbItem(stack);
|
||||
int am = event.getPotionEffect().getAmplifier() + 1;
|
||||
float t = ((float) event.getPotionEffect().getDuration() / 600.0F);
|
||||
|
||||
int consume = (int) (1000 * am * am * t);
|
||||
if (orb != null && orb.getNature() >= consume)
|
||||
{
|
||||
var ef = event.getPotionEffect().getEffect();
|
||||
if (!ef.isBeneficial() && ef.getCurativeItems().stream().anyMatch(p -> p.is(Items.MILK_BUCKET)))
|
||||
{
|
||||
if (living instanceof Player p)
|
||||
{
|
||||
player.removeEffect(potion);
|
||||
orb.addNature(-1000);
|
||||
player.getCooldowns().addCooldown(this, 3);
|
||||
((ServerLevel) player.level).getChunkSource().broadcastAndSend(player, new ClientboundRemoveMobEffectPacket(player.getId(), potion));
|
||||
});
|
||||
if (p.getCooldowns().getCooldownPercent(this, 0) > 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
p.getCooldowns().addCooldown(this, 5 * 20);
|
||||
ManaItemHandler.instance().dispatchManaExact(stack, p, consume / am, true);
|
||||
}
|
||||
event.setResult(Event.Result.DENY);
|
||||
orb.addNature(-consume);
|
||||
|
||||
living.level.playSound(null, living.getX(), living.getY(), living.getZ(), ModSounds.holyCloak, SoundSource.PLAYERS, 1F, 1F);
|
||||
for (int i = 0; i < 30; i++)
|
||||
{
|
||||
double x = living.getX() + Math.random() * living.getBbWidth() * 2 - living.getBbWidth();
|
||||
double y = living.getY() + Math.random() * living.getBbHeight();
|
||||
double z = living.getZ() + Math.random() * living.getBbWidth() * 2 - living.getBbWidth();
|
||||
boolean yellow = Math.random() > 0.5;
|
||||
float r = yellow ? 1F : 0.3F;
|
||||
float g = yellow ? 1F : 0.3F;
|
||||
float b = yellow ? 0.3F : 1F;
|
||||
SparkleParticleData data = SparkleParticleData.sparkle(0.8F + (float) Math.random() * 0.4F, r, g, b, 3);
|
||||
living.level.addParticle(data, x, y, z, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -173,7 +197,7 @@ public class NatureOrb extends ItemBauble
|
||||
@Override
|
||||
public void addNature(int x)
|
||||
{
|
||||
ItemNBTHelper.setInt(stack, TAG_NATURE, Math.min(getMaxNature(), getNature() + x) / stack.getCount());
|
||||
ItemNBTHelper.setInt(stack, TAG_NATURE, Mth.clamp(getNature() + x, 0, getMaxNature()) / stack.getCount());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -177,7 +177,6 @@ public class TilePowerFrame extends TileSimpleInventory
|
||||
{
|
||||
boolean multi = MULTIBLOCK_ADV.get().validate(level, worldPosition) != null;
|
||||
|
||||
ExtraBotany.LOGGER.debug("sb250 multi:" + multi);
|
||||
int redstoneSignal = 0;
|
||||
for (Direction dir : Direction.values())
|
||||
{
|
||||
|
@ -0,0 +1,22 @@
|
||||
package chick.extrabotany.common.events;
|
||||
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraftforge.event.entity.living.LivingEvent;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
/**
|
||||
* post when addEffect ends
|
||||
*/
|
||||
public class EntityAddEffectReturnEvent extends LivingEvent
|
||||
{
|
||||
public MobEffectInstance mobEffectInstance;
|
||||
|
||||
public EntityAddEffectReturnEvent(MobEffectInstance mobEffectInstance, LivingEntity entity)
|
||||
{
|
||||
super(entity);
|
||||
this.mobEffectInstance = mobEffectInstance;
|
||||
}
|
||||
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
package chick.extrabotany.common.events;
|
||||
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
public class EntityEffectEvent extends Event
|
||||
{
|
||||
public MobEffectInstance mobEffectInstance;
|
||||
public Entity entity;
|
||||
|
||||
public EntityEffectEvent(MobEffectInstance mobEffectInstance, Entity entity)
|
||||
{
|
||||
this.mobEffectInstance = mobEffectInstance;
|
||||
this.entity = entity;
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package chick.extrabotany.datagen;
|
||||
|
||||
import chick.extrabotany.ExtraBotany;
|
||||
import chick.extrabotany.common.base.ConfigHandler;
|
||||
import chick.extrabotany.common.optional.EXBOTCompat;
|
||||
import chick.extrabotany.common.optional.tconstruct.TConCompat;
|
||||
import chick.extrabotany.datagen.lang.EN_USLanguageProvider;
|
||||
@ -40,7 +41,7 @@ public class DataGenerators
|
||||
generator.addProvider(new ZH_CNLanguageProvider(generator, "zh_cn"));
|
||||
}
|
||||
|
||||
if (ModList.get().isLoaded(EXBOTCompat.TCON_ID))
|
||||
if (ModList.get().isLoaded(EXBOTCompat.TCON_ID) && ConfigHandler.COMMON.doCompat.get())
|
||||
{
|
||||
TConCompat.tConDatagen(event);
|
||||
}
|
||||
|
@ -1,22 +1,10 @@
|
||||
package chick.extrabotany.forge.mixin.client;
|
||||
|
||||
import chick.extrabotany.common.events.EntityEffectEvent;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
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 vazkii.botania.api.item.TinyPotatoRenderEvent;
|
||||
|
||||
@Mixin(LivingEntity.class)
|
||||
public class MixinLivingEntity
|
||||
{
|
||||
@Inject(at = @At("HEAD"), method = "addEffect(Lnet/minecraft/world/effect/MobEffectInstance;Lnet/minecraft/world/entity/Entity;)Z")
|
||||
private void onGetEffect(MobEffectInstance mobEffectInstance, Entity entity, CallbackInfoReturnable<Boolean> cir)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new EntityEffectEvent(mobEffectInstance, entity));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user