Files
Botania/src/main/java/vazkii/botania/common/network/PacketDodge.java
T
Hubry 05c88fd62a Make handling of curios centralized and add handling for no curios (#2913)
Minor fixes to cosmetic bauble rendering (GL stack overflows),
include the missed belt in belt curios
2019-06-24 18:45:59 -07:00

51 lines
1.8 KiB
Java

/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
* File Created @ [22/09/2016, 13:06:44 (GMT)]
*/
package vazkii.botania.common.network;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketBuffer;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraftforge.fml.network.NetworkEvent;
import vazkii.botania.common.core.handler.EquipmentHandler;
import vazkii.botania.common.core.handler.ModSounds;
import vazkii.botania.common.core.helper.ItemNBTHelper;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.item.equipment.bauble.ItemDodgeRing;
import java.util.function.Supplier;
public class PacketDodge {
public static void encode(PacketDodge msg, PacketBuffer buf) {}
public static PacketDodge decode(PacketBuffer buf) {
return new PacketDodge();
}
public static void handle(PacketDodge msg, Supplier<NetworkEvent.Context> ctx) {
ctx.get().enqueueWork(() -> {
EntityPlayerMP player = ctx.get().getSender();
player.world.playSound(null, player.posX, player.posY, player.posZ, ModSounds.dash, SoundCategory.PLAYERS, 1F, 1F);
ItemStack ringStack = EquipmentHandler.findOrEmpty(ModItems.dodgeRing, player);
if(ringStack.isEmpty()) {
player.connection.disconnect(new TextComponentTranslation("botaniamisc.invalidDodge"));
return;
}
player.addExhaustion(0.3F);
ItemNBTHelper.setInt(ringStack, ItemDodgeRing.TAG_DODGE_COOLDOWN, ItemDodgeRing.MAX_CD);
});
ctx.get().setPacketHandled(true);
}
}