mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-19 03:39:17 +00:00
Dodge ring
This commit is contained in:
1 parent
d406f987c3
commit
23f6260902
8 files changed
+176
-2
No files matched your search
@@ -236,6 +236,7 @@ public final class BotaniaCreativeTab extends CreativeTabs {
|
||||
addItem(ModItems.magnetRing);
|
||||
addItem(ModItems.magnetRingGreater);
|
||||
addItem(ModItems.swapRing);
|
||||
addItem(ModItems.dodgeRing);
|
||||
addItem(ModItems.reachRing);
|
||||
addItem(ModItems.pixieRing);
|
||||
addItem(ModItems.travelBelt);
|
||||
|
||||
@@ -39,6 +39,7 @@ import vazkii.botania.common.item.equipment.bauble.ItemAuraRing;
|
||||
import vazkii.botania.common.item.equipment.bauble.ItemBaubleCosmetic;
|
||||
import vazkii.botania.common.item.equipment.bauble.ItemBloodPendant;
|
||||
import vazkii.botania.common.item.equipment.bauble.ItemDivaCharm;
|
||||
import vazkii.botania.common.item.equipment.bauble.ItemDodgeRing;
|
||||
import vazkii.botania.common.item.equipment.bauble.ItemFlightTiara;
|
||||
import vazkii.botania.common.item.equipment.bauble.ItemGoldenLaurel;
|
||||
import vazkii.botania.common.item.equipment.bauble.ItemGreaterAuraRing;
|
||||
@@ -265,6 +266,7 @@ public final class ModItems {
|
||||
public static Item sextant;
|
||||
public static Item speedUpBelt;
|
||||
public static Item baubleBox;
|
||||
public static Item dodgeRing;
|
||||
|
||||
public static void init() {
|
||||
lexicon = new ItemLexicon();
|
||||
@@ -412,7 +414,8 @@ public final class ModItems {
|
||||
sextant = new ItemSextant();
|
||||
speedUpBelt = new ItemSpeedUpBelt();
|
||||
baubleBox = new ItemBaubleBox();
|
||||
|
||||
dodgeRing = new ItemDodgeRing();
|
||||
|
||||
OreDictionary.registerOre(LibOreDict.LEXICON, lexicon);
|
||||
for(int i = 0; i < 16; i++) {
|
||||
OreDictionary.registerOre(LibOreDict.PETAL[i], new ItemStack(petal, 1, i));
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
/**
|
||||
* 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, 12:56:22 (GMT)]
|
||||
*/
|
||||
package vazkii.botania.common.item.equipment.bauble;
|
||||
|
||||
import baubles.api.BaubleType;
|
||||
import baubles.api.BaublesApi;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.InputEvent.KeyInputEvent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import vazkii.botania.api.mana.IManaUsingItem;
|
||||
import vazkii.botania.client.core.handler.ClientTickHandler;
|
||||
import vazkii.botania.common.core.helper.ItemNBTHelper;
|
||||
import vazkii.botania.common.core.helper.Vector3;
|
||||
import vazkii.botania.common.lib.LibItemNames;
|
||||
import vazkii.botania.common.network.PacketDodge;
|
||||
import vazkii.botania.common.network.PacketHandler;
|
||||
|
||||
public class ItemDodgeRing extends ItemBauble {
|
||||
|
||||
public static final String TAG_DODGE_COOLDOWN = "dodgeCooldown";
|
||||
int leftDown, rightDown;
|
||||
|
||||
public ItemDodgeRing() {
|
||||
super(LibItemNames.DODGE_RING);
|
||||
|
||||
if(FMLCommonHandler.instance().getSide().isClient())
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void onKeyDown(KeyInputEvent event) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
IInventory baublesInv = BaublesApi.getBaubles(mc.thePlayer);
|
||||
ItemStack ringStack = baublesInv.getStackInSlot(1);
|
||||
if(ringStack == null || !(ringStack.getItem() instanceof ItemDodgeRing)) {
|
||||
ringStack = baublesInv.getStackInSlot(2);
|
||||
if(ringStack == null || !(ringStack.getItem() instanceof ItemDodgeRing))
|
||||
return;
|
||||
}
|
||||
|
||||
if(ItemNBTHelper.getInt(ringStack, TAG_DODGE_COOLDOWN, 0) > 0)
|
||||
return;
|
||||
|
||||
int threshold = 4;
|
||||
if(mc.gameSettings.keyBindLeft.isKeyDown()) {
|
||||
int oldLeft = leftDown;
|
||||
leftDown = ClientTickHandler.ticksInGame;
|
||||
|
||||
if(leftDown - oldLeft < threshold)
|
||||
dodge(mc.thePlayer, true);
|
||||
} else if(mc.gameSettings.keyBindRight.isKeyDown()) {
|
||||
int oldRight = rightDown;
|
||||
rightDown = ClientTickHandler.ticksInGame;
|
||||
|
||||
if(rightDown - oldRight < threshold)
|
||||
dodge(mc.thePlayer, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWornTick(ItemStack stack, EntityLivingBase player) {
|
||||
int cd = ItemNBTHelper.getInt(stack, TAG_DODGE_COOLDOWN, 0);
|
||||
if(cd > 0)
|
||||
ItemNBTHelper.setInt(stack, TAG_DODGE_COOLDOWN, cd - 1);
|
||||
}
|
||||
|
||||
public void dodge(EntityPlayer player, boolean left) {
|
||||
if(!player.onGround || player.moveForward > 0.2 || player.moveForward < 0.2)
|
||||
return;
|
||||
|
||||
Vector3 lookVec = new Vector3(player.getLookVec());
|
||||
Vector3 sideVec = lookVec.crossProduct(new Vector3(0, left ? -1 : 1, 0)).multiply(1.25);
|
||||
|
||||
player.motionX = sideVec.x;
|
||||
player.motionY = sideVec.y;
|
||||
player.motionZ = sideVec.z;
|
||||
|
||||
PacketHandler.sendToServer(new PacketDodge());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaubleType getBaubleType(ItemStack arg0) {
|
||||
return BaubleType.RING;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -159,6 +159,7 @@ public final class LibItemNames {
|
||||
public static final String SEXTANT = "sextant";
|
||||
public static final String SPEED_UP_BELT = "speedUpBelt";
|
||||
public static final String BAUBLE_BOX = "baubleBox";
|
||||
public static final String DODGE_RING = "dodgeRing";
|
||||
|
||||
public static final String[] LENS_NAMES = new String[] {
|
||||
"lensNormal",
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* 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 baubles.api.BaublesApi;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||
import vazkii.botania.api.sound.BotaniaSoundEvents;
|
||||
import vazkii.botania.common.core.helper.ItemNBTHelper;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
import vazkii.botania.common.item.equipment.bauble.ItemDodgeRing;
|
||||
import vazkii.botania.common.item.equipment.tool.terrasteel.ItemTerraSword;
|
||||
|
||||
public class PacketDodge implements IMessage {
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {}
|
||||
|
||||
public static class Handler implements IMessageHandler<PacketDodge, IMessage> {
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketDodge message, MessageContext ctx) {
|
||||
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
|
||||
player.mcServer.addScheduledTask(() -> {
|
||||
player.worldObj.playSound(null, player.posX, player.posY, player.posZ, BotaniaSoundEvents.dash, SoundCategory.PLAYERS, 1F, 1F);
|
||||
|
||||
IInventory baublesInv = BaublesApi.getBaubles(player);
|
||||
ItemStack ringStack = baublesInv.getStackInSlot(1);
|
||||
if(ringStack == null || !(ringStack.getItem() instanceof ItemDodgeRing)) {
|
||||
ringStack = baublesInv.getStackInSlot(2);
|
||||
if(ringStack == null || !(ringStack.getItem() instanceof ItemDodgeRing))
|
||||
ctx.getServerHandler().kickPlayerFromServer("Invalid Dodge Packet");
|
||||
}
|
||||
|
||||
player.addExhaustion(0.3F);
|
||||
ItemNBTHelper.setInt(ringStack, ItemDodgeRing.TAG_DODGE_COOLDOWN, 10);
|
||||
});
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,7 +6,6 @@ import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
@@ -19,6 +18,7 @@ public final class PacketHandler {
|
||||
public static void init() {
|
||||
HANDLER.registerMessage(PacketBotaniaEffect.Handler.class, PacketBotaniaEffect.class, 0, Side.CLIENT);
|
||||
HANDLER.registerMessage(PacketLeftClick.Handler.class, PacketLeftClick.class, 1, Side.SERVER);
|
||||
HANDLER.registerMessage(PacketDodge.Handler.class, PacketDodge.class, 1, Side.SERVER);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user