Search in sources :

Example 11 with EntityAttributeModifier

use of net.minecraft.entity.attribute.EntityAttributeModifier in project Reborn12K by SlayeRRROAR.

the class PowerArmorMixin method constructor.

@Inject(method = "<init>", at = @At(value = "RETURN"))
private void constructor(ArmorMaterial material, EquipmentSlot slot, Item.Settings settings, CallbackInfo ci) {
    UUID uUID = MODIFIERS[slot.getEntitySlotId()];
    if (material == Armors.POWER_ARMOR) {
        ImmutableMultimap.Builder<EntityAttribute, EntityAttributeModifier> builder = ImmutableMultimap.builder();
        this.attributeModifiers.forEach(builder::put);
        builder.put(EntityAttributes.GENERIC_KNOCKBACK_RESISTANCE, new EntityAttributeModifier(uUID, "Armor knockback resistance", this.knockbackResistance, EntityAttributeModifier.Operation.ADDITION));
        this.attributeModifiers = builder.build();
    }
}
Also used : EntityAttribute(net.minecraft.entity.attribute.EntityAttribute) ImmutableMultimap(com.google.common.collect.ImmutableMultimap) UUID(java.util.UUID) EntityAttributeModifier(net.minecraft.entity.attribute.EntityAttributeModifier) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 12 with EntityAttributeModifier

use of net.minecraft.entity.attribute.EntityAttributeModifier in project Reborn12K by SlayeRRROAR.

the class ThelositeMixin method constructor.

@Inject(method = "<init>", at = @At(value = "RETURN"))
private void constructor(ArmorMaterial material, EquipmentSlot slot, Item.Settings settings, CallbackInfo ci) {
    UUID uUID = MODIFIERS[slot.getEntitySlotId()];
    if (material == Armors.THELOSITE_ARMOR) {
        ImmutableMultimap.Builder<EntityAttribute, EntityAttributeModifier> builder = ImmutableMultimap.builder();
        this.attributeModifiers.forEach(builder::put);
        builder.put(EntityAttributes.GENERIC_KNOCKBACK_RESISTANCE, new EntityAttributeModifier(uUID, "Armor knockback resistance", this.knockbackResistance, EntityAttributeModifier.Operation.ADDITION));
        this.attributeModifiers = builder.build();
    }
}
Also used : EntityAttribute(net.minecraft.entity.attribute.EntityAttribute) ImmutableMultimap(com.google.common.collect.ImmutableMultimap) UUID(java.util.UUID) EntityAttributeModifier(net.minecraft.entity.attribute.EntityAttributeModifier) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 13 with EntityAttributeModifier

use of net.minecraft.entity.attribute.EntityAttributeModifier in project Reborn12K by SlayeRRROAR.

the class ArcheositeMixin method constructor.

@Inject(method = "<init>", at = @At(value = "RETURN"))
private void constructor(ArmorMaterial material, EquipmentSlot slot, Item.Settings settings, CallbackInfo ci) {
    UUID uUID = MODIFIERS[slot.getEntitySlotId()];
    if (material == Armors.ARCHEOSITE_ARMOR) {
        ImmutableMultimap.Builder<EntityAttribute, EntityAttributeModifier> builder = ImmutableMultimap.builder();
        this.attributeModifiers.forEach(builder::put);
        builder.put(EntityAttributes.GENERIC_KNOCKBACK_RESISTANCE, new EntityAttributeModifier(uUID, "Armor knockback resistance", this.knockbackResistance, EntityAttributeModifier.Operation.ADDITION));
        this.attributeModifiers = builder.build();
    }
}
Also used : EntityAttribute(net.minecraft.entity.attribute.EntityAttribute) ImmutableMultimap(com.google.common.collect.ImmutableMultimap) UUID(java.util.UUID) EntityAttributeModifier(net.minecraft.entity.attribute.EntityAttributeModifier) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 14 with EntityAttributeModifier

use of net.minecraft.entity.attribute.EntityAttributeModifier in project UHC-Mod by CasualUHC.

the class GameManager method startCountDown.

public void startCountDown() {
    PlayerUtils.messageEveryPlayer(new LiteralText("Please stand still during the countdown so you don't fall when you get teleported!").formatted(Formatting.GOLD));
    // We repeat the code with interval 1 second
    AtomicInteger integer = new AtomicInteger(10);
    ScheduledFuture<?> future = this.EXECUTOR.scheduleAtFixedRate(() -> {
        int i = integer.getAndDecrement();
        PlayerUtils.forEveryPlayer(playerEntity -> {
            playerEntity.networkHandler.sendPacket(new TitleS2CPacket(new LiteralText(String.valueOf(i)).formatted(Formatting.GREEN)));
            playerEntity.playSound(SoundEvents.BLOCK_NOTE_BLOCK_PLING, SoundCategory.MASTER, 1.0F, 3.0F);
        });
    }, 0, 1, TimeUnit.SECONDS);
    this.FUTURES.add(future);
    this.FUTURES.add(this.EXECUTOR.schedule(() -> {
        future.cancel(true);
        PlayerUtils.forEveryPlayer(playerEntity -> {
            playerEntity.networkHandler.sendPacket(new TitleS2CPacket(new LiteralText("Good Luck!").formatted(Formatting.GOLD, Formatting.BOLD)));
            playerEntity.playSound(SoundEvents.BLOCK_NOTE_BLOCK_BELL, SoundCategory.MASTER, 1.0F, 1.0F);
            playerEntity.getHungerManager().setSaturationLevel(20F);
            EntityAttributeInstance instance = playerEntity.getAttributes().getCustomInstance(EntityAttributes.GENERIC_MAX_HEALTH);
            if (instance != null) {
                instance.removeModifier(PlayerUtils.HEALTH_BOOST);
                instance.addPersistentModifier(new EntityAttributeModifier(PlayerUtils.HEALTH_BOOST, "Health Boost", GameSettings.HEALTH.getValue(), EntityAttributeModifier.Operation.MULTIPLY_BASE));
            }
            playerEntity.setHealth(playerEntity.getMaxHealth());
        });
        // Pushing back to main thread
        MinecraftServer server = UHCMod.UHC_SERVER;
        PlayerUtils.forEveryPlayer(playerEntity -> {
            if (!TeamUtils.isNonTeam(playerEntity.getScoreboardTeam()) && !playerEntity.isSpectator()) {
                ((ServerPlayerMixinInterface) playerEntity).setCoordsBoolean(true);
                playerEntity.changeGameMode(GameMode.SURVIVAL);
                playerEntity.sendMessage(new LiteralText("You can disable the coordinates above your hotbar by using /coords"), false);
                playerEntity.getInventory().clear();
                PlayerUtils.setPlayerPlaying(playerEntity, true);
            } else {
                playerEntity.changeGameMode(GameMode.SPECTATOR);
            }
        });
        server.execute(() -> {
            server.getCommandManager().execute(server.getCommandSource(), "/fill 24 250 24 -25 289 -25 air");
            server.getCommandManager().execute(server.getCommandSource(), "/spreadplayers 0 0 500 2900 true @e[type=player]");
            Events.ON_ACTIVE.trigger();
        });
    }, 10, TimeUnit.SECONDS));
}
Also used : NbtIo(net.minecraft.nbt.NbtIo) LiteralText(net.minecraft.text.LiteralText) GameRules(net.minecraft.world.GameRules) ScheduledFuture(java.util.concurrent.ScheduledFuture) UHCDataBase(net.casualuhc.uhcmod.utils.Networking.UHCDataBase) ServerCommandSource(net.minecraft.server.command.ServerCommandSource) TitleS2CPacket(net.minecraft.network.packet.s2c.play.TitleS2CPacket) UHCMod(net.casualuhc.uhcmod.UHCMod) Random(java.util.Random) EntityAttributes(net.minecraft.entity.attribute.EntityAttributes) ArrayList(java.util.ArrayList) ServerPlayerMixinInterface(net.casualuhc.uhcmod.interfaces.ServerPlayerMixinInterface) StructurePlacementData(net.minecraft.structure.StructurePlacementData) MinecraftServer(net.minecraft.server.MinecraftServer) IntRuleMixinInterface(net.casualuhc.uhcmod.interfaces.IntRuleMixinInterface) SoundEvents(net.minecraft.sound.SoundEvents) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) GameMode(net.minecraft.world.GameMode) MutableText(net.minecraft.text.MutableText) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) net.casualuhc.uhcmod.utils(net.casualuhc.uhcmod.utils) GameSettings(net.casualuhc.uhcmod.utils.GameSetting.GameSettings) Events(net.casualuhc.uhcmod.utils.Event.Events) SoundCategory(net.minecraft.sound.SoundCategory) Difficulty(net.minecraft.world.Difficulty) EntityAttributeModifier(net.minecraft.entity.attribute.EntityAttributeModifier) AbstractTeam(net.minecraft.scoreboard.AbstractTeam) Structure(net.minecraft.structure.Structure) BlockPos(net.minecraft.util.math.BlockPos) IOException(java.io.IOException) EntityAttributeInstance(net.minecraft.entity.attribute.EntityAttributeInstance) CommandManager(net.minecraft.server.command.CommandManager) Executors(java.util.concurrent.Executors) TimeUnit(java.util.concurrent.TimeUnit) NbtCompound(net.minecraft.nbt.NbtCompound) Formatting(net.minecraft.util.Formatting) List(java.util.List) InputStream(java.io.InputStream) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) TitleS2CPacket(net.minecraft.network.packet.s2c.play.TitleS2CPacket) EntityAttributeModifier(net.minecraft.entity.attribute.EntityAttributeModifier) EntityAttributeInstance(net.minecraft.entity.attribute.EntityAttributeInstance) LiteralText(net.minecraft.text.LiteralText) MinecraftServer(net.minecraft.server.MinecraftServer)

Example 15 with EntityAttributeModifier

use of net.minecraft.entity.attribute.EntityAttributeModifier in project gobber_fabric-1.17 by kwpugh.

the class ArmorItemMixinKnockback method gobberConstructor.

@Inject(method = "<init>", at = @At(value = "RETURN"))
private void gobberConstructor(ArmorMaterial material, EquipmentSlot slot, Item.Settings settings, CallbackInfo ci) {
    UUID uUID = MODIFIERS[slot.getEntitySlotId()];
    if (material == ItemInit.GOBBER_ARMOR_MATERIAL || material == ItemInit.GOBBER_NETHER_ARMOR_MATERIAL || material == ItemInit.GOBBER_END_ARMOR_MATERIAL || material == ItemInit.GOBBER_DRAGON_ARMOR_MATERIAL) {
        ImmutableMultimap.Builder<EntityAttribute, EntityAttributeModifier> builder = ImmutableMultimap.builder();
        this.attributeModifiers.forEach(builder::put);
        builder.put(EntityAttributes.GENERIC_KNOCKBACK_RESISTANCE, new EntityAttributeModifier(uUID, "Armor knockback resistance", this.knockbackResistance, EntityAttributeModifier.Operation.ADDITION));
        this.attributeModifiers = builder.build();
    }
}
Also used : EntityAttribute(net.minecraft.entity.attribute.EntityAttribute) ImmutableMultimap(com.google.common.collect.ImmutableMultimap) UUID(java.util.UUID) EntityAttributeModifier(net.minecraft.entity.attribute.EntityAttributeModifier) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

EntityAttributeModifier (net.minecraft.entity.attribute.EntityAttributeModifier)30 EntityAttribute (net.minecraft.entity.attribute.EntityAttribute)19 ImmutableMultimap (com.google.common.collect.ImmutableMultimap)10 Inject (org.spongepowered.asm.mixin.injection.Inject)10 UUID (java.util.UUID)9 EntityAttributeInstance (net.minecraft.entity.attribute.EntityAttributeInstance)9 Map (java.util.Map)6 Trinket (dev.emi.trinkets.api.Trinket)3 EquipmentSlot (net.minecraft.entity.EquipmentSlot)3 ItemStack (net.minecraft.item.ItemStack)3 LiteralText (net.minecraft.text.LiteralText)3 TrinketSlots (dev.emi.trinkets.api.TrinketSlots)2 ArrayList (java.util.ArrayList)2 Events (net.casualuhc.uhcmod.utils.Event.Events)2 GameSettings (net.casualuhc.uhcmod.utils.GameSetting.GameSettings)2 UHCDataBase (net.casualuhc.uhcmod.utils.Networking.UHCDataBase)2 EntityAttributes (net.minecraft.entity.attribute.EntityAttributes)2 ListTag (net.minecraft.nbt.ListTag)2 ServerCommandSource (net.minecraft.server.command.ServerCommandSource)2 JsonParseException (com.google.gson.JsonParseException)1