Run formatter
This commit is contained in:
parent
61c44a831b
commit
08258fd6ef
606 changed files with 13464 additions and 22975 deletions
|
@ -15,20 +15,16 @@ import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
|||
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||
|
||||
public class ChatUtil
|
||||
{
|
||||
public class ChatUtil {
|
||||
private static final int DELETION_ID = 2525277;
|
||||
private static int lastAdded;
|
||||
|
||||
private static void sendNoSpamMessages(ITextComponent[] messages)
|
||||
{
|
||||
private static void sendNoSpamMessages(ITextComponent[] messages) {
|
||||
GuiNewChat chat = Minecraft.getMinecraft().ingameGUI.getChatGUI();
|
||||
for (int i = DELETION_ID + messages.length - 1; i <= lastAdded; i++)
|
||||
{
|
||||
for (int i = DELETION_ID + messages.length - 1; i <= lastAdded; i++) {
|
||||
chat.deleteChatLine(i);
|
||||
}
|
||||
for (int i = 0; i < messages.length; i++)
|
||||
{
|
||||
for (int i = 0; i < messages.length; i++) {
|
||||
chat.printChatMessageWithOptionalDeletion(messages[i], DELETION_ID + i);
|
||||
}
|
||||
lastAdded = DELETION_ID + messages.length - 1;
|
||||
|
@ -37,25 +33,20 @@ public class ChatUtil
|
|||
/**
|
||||
* Returns a standard {@link TextComponentString} for the given
|
||||
* {@link String} .
|
||||
*
|
||||
* @param s
|
||||
* The string to wrap.
|
||||
*
|
||||
*
|
||||
* @param s The string to wrap.
|
||||
* @return An {@link ITextComponent} containing the string.
|
||||
*/
|
||||
public static ITextComponent wrap(String s)
|
||||
{
|
||||
public static ITextComponent wrap(String s) {
|
||||
return new TextComponentString(s);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #wrap(String)
|
||||
*/
|
||||
public static ITextComponent[] wrap(String... s)
|
||||
{
|
||||
public static ITextComponent[] wrap(String... s) {
|
||||
ITextComponent[] ret = new ITextComponent[s.length];
|
||||
for (int i = 0; i < ret.length; i++)
|
||||
{
|
||||
for (int i = 0; i < ret.length; i++) {
|
||||
ret[i] = wrap(s[i]);
|
||||
}
|
||||
return ret;
|
||||
|
@ -64,97 +55,80 @@ public class ChatUtil
|
|||
/**
|
||||
* Returns a translatable chat component for the given string and format
|
||||
* args.
|
||||
*
|
||||
* @param s
|
||||
* The string to format
|
||||
* @param args
|
||||
* The args to apply to the format
|
||||
*
|
||||
* @param s The string to format
|
||||
* @param args The args to apply to the format
|
||||
*/
|
||||
public static ITextComponent wrapFormatted(String s, Object... args)
|
||||
{
|
||||
public static ITextComponent wrapFormatted(String s, Object... args) {
|
||||
return new TextComponentTranslation(s, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Simply sends the passed lines to the player in a chat message.
|
||||
*
|
||||
* @param player
|
||||
* The player to send the chat to
|
||||
* @param lines
|
||||
* The lines to send
|
||||
*
|
||||
* @param player The player to send the chat to
|
||||
* @param lines The lines to send
|
||||
*/
|
||||
public static void sendChat(EntityPlayer player, String... lines)
|
||||
{
|
||||
public static void sendChat(EntityPlayer player, String... lines) {
|
||||
sendChat(player, wrap(lines));
|
||||
}
|
||||
|
||||
/**
|
||||
* Localizes the lines before sending them.
|
||||
*
|
||||
*
|
||||
* @see #sendChat(EntityPlayer, String...)
|
||||
*/
|
||||
public static void sendChatUnloc(EntityPlayer player, String... unlocLines)
|
||||
{
|
||||
public static void sendChatUnloc(EntityPlayer player, String... unlocLines) {
|
||||
sendChat(player, TextHelper.localizeAll(unlocLines));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends all passed chat components to the player.
|
||||
*
|
||||
* @param player
|
||||
* The player to send the chat lines to.
|
||||
* @param lines
|
||||
* The {@link ITextComponent chat components} to send.yes
|
||||
*
|
||||
* @param player The player to send the chat lines to.
|
||||
* @param lines The {@link ITextComponent chat components} to send.yes
|
||||
*/
|
||||
public static void sendChat(EntityPlayer player, ITextComponent... lines)
|
||||
{
|
||||
for (ITextComponent c : lines)
|
||||
{
|
||||
public static void sendChat(EntityPlayer player, ITextComponent... lines) {
|
||||
for (ITextComponent c : lines) {
|
||||
player.sendMessage(c);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Localizes the strings before sending them.
|
||||
*
|
||||
*
|
||||
* @see #sendNoSpamClient(String...)
|
||||
*/
|
||||
public static void sendNoSpamClientUnloc(String... unlocLines)
|
||||
{
|
||||
public static void sendNoSpamClientUnloc(String... unlocLines) {
|
||||
sendNoSpamClient(TextHelper.localizeAll(unlocLines));
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as {@link #sendNoSpamClient(ITextComponent...)}, but wraps the
|
||||
* Strings automatically.
|
||||
*
|
||||
* @param lines
|
||||
* The chat lines to send
|
||||
*
|
||||
*
|
||||
* @param lines The chat lines to send
|
||||
* @see #wrap(String)
|
||||
*/
|
||||
public static void sendNoSpamClient(String... lines)
|
||||
{
|
||||
public static void sendNoSpamClient(String... lines) {
|
||||
sendNoSpamClient(wrap(lines));
|
||||
}
|
||||
|
||||
/**
|
||||
* Skips the packet sending, unsafe to call on servers.
|
||||
*
|
||||
*
|
||||
* @see #sendNoSpam(EntityPlayerMP, ITextComponent...)
|
||||
*/
|
||||
public static void sendNoSpamClient(ITextComponent... lines)
|
||||
{
|
||||
public static void sendNoSpamClient(ITextComponent... lines) {
|
||||
sendNoSpamMessages(lines);
|
||||
}
|
||||
|
||||
/**
|
||||
* Localizes the strings before sending them.
|
||||
*
|
||||
*
|
||||
* @see #sendNoSpam(EntityPlayer, String...)
|
||||
*/
|
||||
public static void sendNoSpamUnloc(EntityPlayer player, String... unlocLines)
|
||||
{
|
||||
public static void sendNoSpamUnloc(EntityPlayer player, String... unlocLines) {
|
||||
sendNoSpam(player, TextHelper.localizeAll(unlocLines));
|
||||
}
|
||||
|
||||
|
@ -162,32 +136,28 @@ public class ChatUtil
|
|||
* @see #wrap(String)
|
||||
* @see #sendNoSpam(EntityPlayer, ITextComponent...)
|
||||
*/
|
||||
public static void sendNoSpam(EntityPlayer player, String... lines)
|
||||
{
|
||||
public static void sendNoSpam(EntityPlayer player, String... lines) {
|
||||
sendNoSpam(player, wrap(lines));
|
||||
}
|
||||
|
||||
/**
|
||||
* First checks if the player is instanceof {@link EntityPlayerMP} before
|
||||
* casting.
|
||||
*
|
||||
*
|
||||
* @see #sendNoSpam(EntityPlayerMP, ITextComponent...)
|
||||
*/
|
||||
public static void sendNoSpam(EntityPlayer player, ITextComponent... lines)
|
||||
{
|
||||
if (player instanceof EntityPlayerMP)
|
||||
{
|
||||
public static void sendNoSpam(EntityPlayer player, ITextComponent... lines) {
|
||||
if (player instanceof EntityPlayerMP) {
|
||||
sendNoSpam((EntityPlayerMP) player, lines);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Localizes the strings before sending them.
|
||||
*
|
||||
*
|
||||
* @see #sendNoSpam(EntityPlayerMP, String...)
|
||||
*/
|
||||
public static void sendNoSpamUnloc(EntityPlayerMP player, String... unlocLines)
|
||||
{
|
||||
public static void sendNoSpamUnloc(EntityPlayerMP player, String... unlocLines) {
|
||||
sendNoSpam(player, TextHelper.localizeAll(unlocLines));
|
||||
}
|
||||
|
||||
|
@ -195,73 +165,60 @@ public class ChatUtil
|
|||
* @see #wrap(String)
|
||||
* @see #sendNoSpam(EntityPlayerMP, ITextComponent...)
|
||||
*/
|
||||
public static void sendNoSpam(EntityPlayerMP player, String... lines)
|
||||
{
|
||||
public static void sendNoSpam(EntityPlayerMP player, String... lines) {
|
||||
sendNoSpam(player, wrap(lines));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a chat message to the client, deleting past messages also sent via
|
||||
* this method.
|
||||
*
|
||||
* <p>
|
||||
* Credit to RWTema for the idea
|
||||
*
|
||||
* @param player
|
||||
* The player to send the chat message to
|
||||
* @param lines
|
||||
* The chat lines to send.
|
||||
*
|
||||
* @param player The player to send the chat message to
|
||||
* @param lines The chat lines to send.
|
||||
*/
|
||||
public static void sendNoSpam(EntityPlayerMP player, ITextComponent... lines)
|
||||
{
|
||||
public static void sendNoSpam(EntityPlayerMP player, ITextComponent... lines) {
|
||||
if (lines.length > 0)
|
||||
BloodMagicPacketHandler.INSTANCE.sendTo(new PacketNoSpamChat(lines), player);
|
||||
}
|
||||
|
||||
/**
|
||||
* @author tterrag1098
|
||||
*
|
||||
* <p>
|
||||
* Ripped from EnderCore (and slightly altered)
|
||||
*/
|
||||
public static class PacketNoSpamChat implements IMessage
|
||||
{
|
||||
public static class PacketNoSpamChat implements IMessage {
|
||||
private ITextComponent[] chatLines;
|
||||
|
||||
public PacketNoSpamChat()
|
||||
{
|
||||
public PacketNoSpamChat() {
|
||||
chatLines = new ITextComponent[0];
|
||||
}
|
||||
|
||||
private PacketNoSpamChat(ITextComponent... lines)
|
||||
{
|
||||
private PacketNoSpamChat(ITextComponent... lines) {
|
||||
// this is guaranteed to be >1 length by accessing methods
|
||||
this.chatLines = lines;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf)
|
||||
{
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeInt(chatLines.length);
|
||||
for (ITextComponent c : chatLines)
|
||||
{
|
||||
for (ITextComponent c : chatLines) {
|
||||
ByteBufUtils.writeUTF8String(buf, ITextComponent.Serializer.componentToJson(c));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf)
|
||||
{
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
chatLines = new ITextComponent[buf.readInt()];
|
||||
for (int i = 0; i < chatLines.length; i++)
|
||||
{
|
||||
for (int i = 0; i < chatLines.length; i++) {
|
||||
chatLines[i] = ITextComponent.Serializer.jsonToComponent(ByteBufUtils.readUTF8String(buf));
|
||||
}
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<PacketNoSpamChat, IMessage>
|
||||
{
|
||||
public static class Handler implements IMessageHandler<PacketNoSpamChat, IMessage> {
|
||||
@Override
|
||||
public IMessage onMessage(final PacketNoSpamChat message, MessageContext ctx)
|
||||
{
|
||||
public IMessage onMessage(final PacketNoSpamChat message, MessageContext ctx) {
|
||||
Minecraft.getMinecraft().addScheduledTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
|
|
@ -5,28 +5,23 @@ import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class GhostItemHelper
|
||||
{
|
||||
public static void setItemGhostAmount(ItemStack stack, int amount)
|
||||
{
|
||||
public class GhostItemHelper {
|
||||
public static void setItemGhostAmount(ItemStack stack, int amount) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
tag.setInteger(Constants.NBT.GHOST_STACK_SIZE, amount);
|
||||
}
|
||||
|
||||
public static int getItemGhostAmount(ItemStack stack)
|
||||
{
|
||||
public static int getItemGhostAmount(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
return tag.getInteger(Constants.NBT.GHOST_STACK_SIZE);
|
||||
}
|
||||
|
||||
public static boolean hasGhostAmount(ItemStack stack)
|
||||
{
|
||||
if (!stack.hasTagCompound())
|
||||
{
|
||||
public static boolean hasGhostAmount(ItemStack stack) {
|
||||
if (!stack.hasTagCompound()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -34,29 +29,25 @@ public class GhostItemHelper
|
|||
return tag.hasKey(Constants.NBT.GHOST_STACK_SIZE);
|
||||
}
|
||||
|
||||
public static void incrementGhostAmout(ItemStack stack, int value)
|
||||
{
|
||||
public static void incrementGhostAmout(ItemStack stack, int value) {
|
||||
int amount = getItemGhostAmount(stack);
|
||||
amount += value;
|
||||
setItemGhostAmount(stack, amount);
|
||||
}
|
||||
|
||||
public static void decrementGhostAmount(ItemStack stack, int value)
|
||||
{
|
||||
public static void decrementGhostAmount(ItemStack stack, int value) {
|
||||
int amount = getItemGhostAmount(stack);
|
||||
amount -= value;
|
||||
setItemGhostAmount(stack, amount);
|
||||
}
|
||||
|
||||
public static ItemStack getStackFromGhost(ItemStack ghostStack)
|
||||
{
|
||||
public static ItemStack getStackFromGhost(ItemStack ghostStack) {
|
||||
ItemStack newStack = ghostStack.copy();
|
||||
NBTHelper.checkNBT(newStack);
|
||||
NBTTagCompound tag = newStack.getTagCompound();
|
||||
int amount = getItemGhostAmount(ghostStack);
|
||||
tag.removeTag(Constants.NBT.GHOST_STACK_SIZE);
|
||||
if (tag.hasNoTags())
|
||||
{
|
||||
if (tag.hasNoTags()) {
|
||||
newStack.setTagCompound(null);
|
||||
}
|
||||
newStack.setCount(amount);
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,21 +1,10 @@
|
|||
package WayofTime.bloodmagic.util.handler;
|
||||
|
||||
import WayofTime.bloodmagic.api.BloodMagicAPI;
|
||||
import WayofTime.bloodmagic.api.altar.EnumAltarComponent;
|
||||
import WayofTime.bloodmagic.util.Utils;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.common.event.FMLInterModComms;
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
|
||||
public class IMCHandler
|
||||
{
|
||||
public class IMCHandler {
|
||||
|
||||
public static void handleIMC(FMLInterModComms.IMCEvent event)
|
||||
{
|
||||
public static void handleIMC(FMLInterModComms.IMCEvent event) {
|
||||
// TODO
|
||||
// for (FMLInterModComms.IMCMessage message : event.getMessages())
|
||||
// {
|
||||
|
|
|
@ -1,17 +1,29 @@
|
|||
package WayofTime.bloodmagic.util.handler.event;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.ConfigHandler;
|
||||
import WayofTime.bloodmagic.annot.Handler;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.registry.RitualRegistry;
|
||||
import WayofTime.bloodmagic.api.ritual.Ritual;
|
||||
import WayofTime.bloodmagic.api.ritual.RitualComponent;
|
||||
import WayofTime.bloodmagic.client.hud.HUDElement;
|
||||
import WayofTime.bloodmagic.client.key.KeyBindings;
|
||||
import WayofTime.bloodmagic.client.render.block.RenderFakeBlocks;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagic;
|
||||
import WayofTime.bloodmagic.item.ItemRitualDiviner;
|
||||
import WayofTime.bloodmagic.item.sigil.ItemSigilHolding;
|
||||
import WayofTime.bloodmagic.network.BloodMagicPacketHandler;
|
||||
import WayofTime.bloodmagic.network.SigilHoldingPacketProcessor;
|
||||
import WayofTime.bloodmagic.tile.TileMasterRitualStone;
|
||||
import WayofTime.bloodmagic.util.GhostItemHelper;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import com.google.common.base.Stopwatch;
|
||||
import com.google.common.collect.SetMultimap;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.block.model.*;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -24,11 +36,7 @@ import net.minecraft.util.math.BlockPos;
|
|||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.ModelBakeEvent;
|
||||
import net.minecraftforge.client.event.MouseEvent;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.client.event.*;
|
||||
import net.minecraftforge.client.event.sound.PlaySoundEvent;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
||||
|
@ -38,36 +46,16 @@ import net.minecraftforge.fml.common.gameevent.InputEvent;
|
|||
import net.minecraftforge.fml.relauncher.ReflectionHelper;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.ConfigHandler;
|
||||
import WayofTime.bloodmagic.annot.Handler;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.registry.RitualRegistry;
|
||||
import WayofTime.bloodmagic.api.ritual.Ritual;
|
||||
import WayofTime.bloodmagic.api.ritual.RitualComponent;
|
||||
import WayofTime.bloodmagic.client.hud.HUDElement;
|
||||
import WayofTime.bloodmagic.client.render.block.RenderFakeBlocks;
|
||||
import WayofTime.bloodmagic.item.ItemRitualDiviner;
|
||||
import WayofTime.bloodmagic.item.sigil.ItemSigilHolding;
|
||||
import WayofTime.bloodmagic.network.BloodMagicPacketHandler;
|
||||
import WayofTime.bloodmagic.network.SigilHoldingPacketProcessor;
|
||||
import WayofTime.bloodmagic.tile.TileMasterRitualStone;
|
||||
import WayofTime.bloodmagic.util.GhostItemHelper;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
|
||||
import com.google.common.base.Stopwatch;
|
||||
import com.google.common.collect.SetMultimap;
|
||||
import java.util.*;
|
||||
|
||||
@Handler
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ClientHandler
|
||||
{
|
||||
public class ClientHandler {
|
||||
// Quick toggle for error suppression. Set to false if you wish to hide model errors.
|
||||
public static final boolean SUPPRESS_ASSET_ERRORS = true;
|
||||
|
||||
public static final List<HUDElement> hudElements = new ArrayList<HUDElement>();
|
||||
public static TextureAtlasSprite ritualStoneBlank;
|
||||
public static TextureAtlasSprite ritualStoneWater;
|
||||
public static TextureAtlasSprite ritualStoneFire;
|
||||
|
@ -75,57 +63,45 @@ public class ClientHandler
|
|||
public static TextureAtlasSprite ritualStoneAir;
|
||||
public static TextureAtlasSprite ritualStoneDawn;
|
||||
public static TextureAtlasSprite ritualStoneDusk;
|
||||
|
||||
public static TextureAtlasSprite blankBloodRune;
|
||||
public static TextureAtlasSprite stoneBrick;
|
||||
public static TextureAtlasSprite glowstone;
|
||||
public static TextureAtlasSprite bloodStoneBrick;
|
||||
public static TextureAtlasSprite beacon;
|
||||
public static TextureAtlasSprite crystalCluster;
|
||||
|
||||
public static Minecraft minecraft = Minecraft.getMinecraft();
|
||||
public static final List<HUDElement> hudElements = new ArrayList<HUDElement>();
|
||||
|
||||
private static TileMasterRitualStone mrsHoloTile;
|
||||
private static Ritual mrsHoloRitual;
|
||||
private static EnumFacing mrsHoloDirection;
|
||||
private static boolean mrsHoloDisplay;
|
||||
|
||||
@SubscribeEvent
|
||||
public void onTooltipEvent(ItemTooltipEvent event)
|
||||
{
|
||||
public void onTooltipEvent(ItemTooltipEvent event) {
|
||||
ItemStack stack = event.getItemStack();
|
||||
if (stack.isEmpty())
|
||||
{
|
||||
if (stack.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (GhostItemHelper.hasGhostAmount(stack))
|
||||
{
|
||||
if (GhostItemHelper.hasGhostAmount(stack)) {
|
||||
int amount = GhostItemHelper.getItemGhostAmount(stack);
|
||||
if (amount == 0)
|
||||
{
|
||||
if (amount == 0) {
|
||||
event.getToolTip().add(TextHelper.localize("tooltip.bloodmagic.ghost.everything"));
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
event.getToolTip().add(TextHelper.localize("tooltip.bloodmagic.ghost.amount", amount));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onSoundEvent(PlaySoundEvent event)
|
||||
{
|
||||
public void onSoundEvent(PlaySoundEvent event) {
|
||||
EntityPlayer player = Minecraft.getMinecraft().player;
|
||||
if (player != null && player.isPotionActive(RegistrarBloodMagic.DEAFNESS))
|
||||
{
|
||||
if (player != null && player.isPotionActive(RegistrarBloodMagic.DEAFNESS)) {
|
||||
event.setResultSound(null);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onTextureStitch(TextureStitchEvent.Pre event)
|
||||
{
|
||||
public void onTextureStitch(TextureStitchEvent.Pre event) {
|
||||
final String BLOCKS = "blocks";
|
||||
|
||||
ritualStoneBlank = forName(event.getMap(), "RitualStone", BLOCKS);
|
||||
|
@ -145,21 +121,17 @@ public class ClientHandler
|
|||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void render(RenderWorldLastEvent event)
|
||||
{
|
||||
public void render(RenderWorldLastEvent event) {
|
||||
EntityPlayerSP player = minecraft.player;
|
||||
World world = player.getEntityWorld();
|
||||
|
||||
if (mrsHoloTile != null)
|
||||
{
|
||||
if (world.getTileEntity(mrsHoloTile.getPos()) instanceof TileMasterRitualStone)
|
||||
{
|
||||
if (mrsHoloTile != null) {
|
||||
if (world.getTileEntity(mrsHoloTile.getPos()) instanceof TileMasterRitualStone) {
|
||||
if (mrsHoloDisplay)
|
||||
renderRitualStones(mrsHoloTile, event.getPartialTicks());
|
||||
else
|
||||
ClientHandler.setRitualHoloToNull();
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
ClientHandler.setRitualHoloToNull();
|
||||
}
|
||||
}
|
||||
|
@ -174,20 +146,16 @@ public class ClientHandler
|
|||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onMouseEvent(MouseEvent event)
|
||||
{
|
||||
public void onMouseEvent(MouseEvent event) {
|
||||
EntityPlayerSP player = Minecraft.getMinecraft().player;
|
||||
|
||||
if (event.getDwheel() != 0 && player != null && player.isSneaking())
|
||||
{
|
||||
if (event.getDwheel() != 0 && player != null && player.isSneaking()) {
|
||||
ItemStack stack = player.getHeldItemMainhand();
|
||||
|
||||
if (!stack.isEmpty())
|
||||
{
|
||||
if (!stack.isEmpty()) {
|
||||
Item item = stack.getItem();
|
||||
|
||||
if (item instanceof ItemSigilHolding)
|
||||
{
|
||||
if (item instanceof ItemSigilHolding) {
|
||||
cycleSigil(stack, player, event.getDwheel());
|
||||
event.setCanceled(true);
|
||||
}
|
||||
|
@ -196,8 +164,7 @@ public class ClientHandler
|
|||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onKey(InputEvent event)
|
||||
{
|
||||
public void onKey(InputEvent event) {
|
||||
if (!minecraft.inGameHasFocus)
|
||||
return;
|
||||
|
||||
|
@ -207,8 +174,7 @@ public class ClientHandler
|
|||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onHudRender(RenderGameOverlayEvent.Pre event)
|
||||
{
|
||||
public void onHudRender(RenderGameOverlayEvent.Pre event) {
|
||||
for (HUDElement element : hudElements)
|
||||
if (element.getElementType() == event.getType() && element.shouldRender(minecraft))
|
||||
element.render(minecraft, event.getResolution(), event.getPartialTicks());
|
||||
|
@ -216,8 +182,7 @@ public class ClientHandler
|
|||
|
||||
// Stolen from Chisel
|
||||
@SubscribeEvent
|
||||
public void onModelBake(ModelBakeEvent event)
|
||||
{
|
||||
public void onModelBake(ModelBakeEvent event) {
|
||||
if (BloodMagic.IS_DEV && SUPPRESS_ASSET_ERRORS)
|
||||
return;
|
||||
|
||||
|
@ -253,8 +218,7 @@ public class ClientHandler
|
|||
|
||||
// For some reason, we need some bad textures to be listed in the Crystal and Node models. This will hide that from the end user.
|
||||
@SubscribeEvent
|
||||
public void onTextureStitch(TextureStitchEvent.Post event)
|
||||
{
|
||||
public void onTextureStitch(TextureStitchEvent.Post event) {
|
||||
if (BloodMagic.IS_DEV && SUPPRESS_ASSET_ERRORS)
|
||||
return;
|
||||
|
||||
|
@ -267,8 +231,7 @@ public class ClientHandler
|
|||
Set<ResourceLocation> toRemove = new HashSet<ResourceLocation>();
|
||||
|
||||
// Find our missing textures and mark them for removal. Cannot directly remove as it would cause a CME
|
||||
if (missingTextures.containsKey(mc))
|
||||
{
|
||||
if (missingTextures.containsKey(mc)) {
|
||||
Set<ResourceLocation> missingMCTextures = missingTextures.get(mc);
|
||||
for (ResourceLocation texture : missingMCTextures)
|
||||
if (texture.getResourcePath().equalsIgnoreCase(String.format(format, "node")) || texture.getResourcePath().equalsIgnoreCase(String.format(format, "crystal")))
|
||||
|
@ -279,36 +242,14 @@ public class ClientHandler
|
|||
missingTextures.get(mc).removeAll(toRemove);
|
||||
|
||||
// Make sure to only remove the bad MC domain if no other textures are missing
|
||||
if (missingTextures.get(mc).isEmpty())
|
||||
{
|
||||
if (missingTextures.get(mc).isEmpty()) {
|
||||
missingTextures.keySet().remove(mc);
|
||||
badTextureDomains.remove(mc);
|
||||
}
|
||||
BloodMagic.instance.logger.debug("Suppressed required texture errors in {}", stopwatch.stop());
|
||||
}
|
||||
|
||||
public static void cycleSigil(ItemStack stack, EntityPlayer player, int dWheel)
|
||||
{
|
||||
int mode = dWheel;
|
||||
if (!ConfigHandler.sigilHoldingSkipsEmptySlots)
|
||||
{
|
||||
mode = ItemSigilHolding.getCurrentItemOrdinal(stack);
|
||||
mode = dWheel < 0 ? ItemSigilHolding.next(mode) : ItemSigilHolding.prev(mode);
|
||||
}
|
||||
|
||||
ItemSigilHolding.cycleToNextSigil(stack, mode);
|
||||
BloodMagicPacketHandler.INSTANCE.sendToServer(new SigilHoldingPacketProcessor(player.inventory.currentItem, mode));
|
||||
ItemStack newStack = ItemSigilHolding.getItemStackInSlot(stack, ItemSigilHolding.getCurrentItemOrdinal(stack));
|
||||
player.sendStatusMessage(newStack.isEmpty() ? new TextComponentString("") : newStack.getTextComponent(), true);
|
||||
}
|
||||
|
||||
private static TextureAtlasSprite forName(TextureMap textureMap, String name, String dir)
|
||||
{
|
||||
return textureMap.registerSprite(new ResourceLocation(Constants.Mod.DOMAIN + dir + "/" + name));
|
||||
}
|
||||
|
||||
private void renderRitualStones(EntityPlayerSP player, float partialTicks)
|
||||
{
|
||||
private void renderRitualStones(EntityPlayerSP player, float partialTicks) {
|
||||
World world = player.getEntityWorld();
|
||||
ItemRitualDiviner ritualDiviner = (ItemRitualDiviner) player.inventory.getCurrentItem().getItem();
|
||||
EnumFacing direction = ritualDiviner.getDirection(player.inventory.getCurrentItem());
|
||||
|
@ -328,40 +269,37 @@ public class ClientHandler
|
|||
double posY = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialTicks;
|
||||
double posZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTicks;
|
||||
|
||||
for (RitualComponent ritualComponent : ritual.getComponents())
|
||||
{
|
||||
for (RitualComponent ritualComponent : ritual.getComponents()) {
|
||||
vX = vec3.add(ritualComponent.getOffset(direction));
|
||||
double minX = vX.getX() - posX;
|
||||
double minY = vX.getY() - posY;
|
||||
double minZ = vX.getZ() - posZ;
|
||||
|
||||
if (!world.getBlockState(vX).isOpaqueCube())
|
||||
{
|
||||
if (!world.getBlockState(vX).isOpaqueCube()) {
|
||||
TextureAtlasSprite texture = null;
|
||||
|
||||
switch (ritualComponent.getRuneType())
|
||||
{
|
||||
case BLANK:
|
||||
texture = ritualStoneBlank;
|
||||
break;
|
||||
case WATER:
|
||||
texture = ritualStoneWater;
|
||||
break;
|
||||
case FIRE:
|
||||
texture = ritualStoneFire;
|
||||
break;
|
||||
case EARTH:
|
||||
texture = ritualStoneEarth;
|
||||
break;
|
||||
case AIR:
|
||||
texture = ritualStoneAir;
|
||||
break;
|
||||
case DAWN:
|
||||
texture = ritualStoneDawn;
|
||||
break;
|
||||
case DUSK:
|
||||
texture = ritualStoneDusk;
|
||||
break;
|
||||
switch (ritualComponent.getRuneType()) {
|
||||
case BLANK:
|
||||
texture = ritualStoneBlank;
|
||||
break;
|
||||
case WATER:
|
||||
texture = ritualStoneWater;
|
||||
break;
|
||||
case FIRE:
|
||||
texture = ritualStoneFire;
|
||||
break;
|
||||
case EARTH:
|
||||
texture = ritualStoneEarth;
|
||||
break;
|
||||
case AIR:
|
||||
texture = ritualStoneAir;
|
||||
break;
|
||||
case DAWN:
|
||||
texture = ritualStoneDawn;
|
||||
break;
|
||||
case DUSK:
|
||||
texture = ritualStoneDusk;
|
||||
break;
|
||||
}
|
||||
|
||||
RenderFakeBlocks.drawFakeBlock(texture, minX, minY, minZ);
|
||||
|
@ -371,8 +309,24 @@ public class ClientHandler
|
|||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
||||
public static void renderRitualStones(TileMasterRitualStone masterRitualStone, float partialTicks)
|
||||
{
|
||||
public static void cycleSigil(ItemStack stack, EntityPlayer player, int dWheel) {
|
||||
int mode = dWheel;
|
||||
if (!ConfigHandler.sigilHoldingSkipsEmptySlots) {
|
||||
mode = ItemSigilHolding.getCurrentItemOrdinal(stack);
|
||||
mode = dWheel < 0 ? ItemSigilHolding.next(mode) : ItemSigilHolding.prev(mode);
|
||||
}
|
||||
|
||||
ItemSigilHolding.cycleToNextSigil(stack, mode);
|
||||
BloodMagicPacketHandler.INSTANCE.sendToServer(new SigilHoldingPacketProcessor(player.inventory.currentItem, mode));
|
||||
ItemStack newStack = ItemSigilHolding.getItemStackInSlot(stack, ItemSigilHolding.getCurrentItemOrdinal(stack));
|
||||
player.sendStatusMessage(newStack.isEmpty() ? new TextComponentString("") : newStack.getTextComponent(), true);
|
||||
}
|
||||
|
||||
private static TextureAtlasSprite forName(TextureMap textureMap, String name, String dir) {
|
||||
return textureMap.registerSprite(new ResourceLocation(Constants.Mod.DOMAIN + dir + "/" + name));
|
||||
}
|
||||
|
||||
public static void renderRitualStones(TileMasterRitualStone masterRitualStone, float partialTicks) {
|
||||
EntityPlayerSP player = minecraft.player;
|
||||
World world = player.getEntityWorld();
|
||||
EnumFacing direction = mrsHoloDirection;
|
||||
|
@ -392,40 +346,37 @@ public class ClientHandler
|
|||
double posY = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialTicks;
|
||||
double posZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTicks;
|
||||
|
||||
for (RitualComponent ritualComponent : ritual.getComponents())
|
||||
{
|
||||
for (RitualComponent ritualComponent : ritual.getComponents()) {
|
||||
vX = vec3.add(ritualComponent.getOffset(direction));
|
||||
double minX = vX.getX() - posX;
|
||||
double minY = vX.getY() - posY;
|
||||
double minZ = vX.getZ() - posZ;
|
||||
|
||||
if (!world.getBlockState(vX).isOpaqueCube())
|
||||
{
|
||||
if (!world.getBlockState(vX).isOpaqueCube()) {
|
||||
TextureAtlasSprite texture = null;
|
||||
|
||||
switch (ritualComponent.getRuneType())
|
||||
{
|
||||
case BLANK:
|
||||
texture = ritualStoneBlank;
|
||||
break;
|
||||
case WATER:
|
||||
texture = ritualStoneWater;
|
||||
break;
|
||||
case FIRE:
|
||||
texture = ritualStoneFire;
|
||||
break;
|
||||
case EARTH:
|
||||
texture = ritualStoneEarth;
|
||||
break;
|
||||
case AIR:
|
||||
texture = ritualStoneAir;
|
||||
break;
|
||||
case DAWN:
|
||||
texture = ritualStoneDawn;
|
||||
break;
|
||||
case DUSK:
|
||||
texture = ritualStoneDusk;
|
||||
break;
|
||||
switch (ritualComponent.getRuneType()) {
|
||||
case BLANK:
|
||||
texture = ritualStoneBlank;
|
||||
break;
|
||||
case WATER:
|
||||
texture = ritualStoneWater;
|
||||
break;
|
||||
case FIRE:
|
||||
texture = ritualStoneFire;
|
||||
break;
|
||||
case EARTH:
|
||||
texture = ritualStoneEarth;
|
||||
break;
|
||||
case AIR:
|
||||
texture = ritualStoneAir;
|
||||
break;
|
||||
case DAWN:
|
||||
texture = ritualStoneDawn;
|
||||
break;
|
||||
case DUSK:
|
||||
texture = ritualStoneDusk;
|
||||
break;
|
||||
}
|
||||
|
||||
RenderFakeBlocks.drawFakeBlock(texture, minX, minY, minZ);
|
||||
|
@ -435,16 +386,14 @@ public class ClientHandler
|
|||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
||||
public static void setRitualHolo(TileMasterRitualStone masterRitualStone, Ritual ritual, EnumFacing direction, boolean displayed)
|
||||
{
|
||||
public static void setRitualHolo(TileMasterRitualStone masterRitualStone, Ritual ritual, EnumFacing direction, boolean displayed) {
|
||||
mrsHoloDisplay = displayed;
|
||||
mrsHoloTile = masterRitualStone;
|
||||
mrsHoloRitual = ritual;
|
||||
mrsHoloDirection = direction;
|
||||
}
|
||||
|
||||
public static void setRitualHoloToNull()
|
||||
{
|
||||
public static void setRitualHoloToNull() {
|
||||
mrsHoloDisplay = false;
|
||||
mrsHoloTile = null;
|
||||
mrsHoloRitual = null;
|
||||
|
|
|
@ -1,10 +1,17 @@
|
|||
package WayofTime.bloodmagic.util.handler.event;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.ConfigHandler;
|
||||
import WayofTime.bloodmagic.annot.Handler;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.event.AltarCraftedEvent;
|
||||
import WayofTime.bloodmagic.api.iface.IUpgradeTrainer;
|
||||
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
|
||||
import WayofTime.bloodmagic.api.util.helper.ItemHelper;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.block.BlockLifeEssence;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
|
||||
import WayofTime.bloodmagic.item.ItemInscriptionTool;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.EnumDyeColor;
|
||||
import net.minecraft.item.ItemBanner;
|
||||
|
@ -16,38 +23,26 @@ import net.minecraftforge.fluids.Fluid;
|
|||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import WayofTime.bloodmagic.ConfigHandler;
|
||||
import WayofTime.bloodmagic.annot.Handler;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.event.AltarCraftedEvent;
|
||||
import WayofTime.bloodmagic.api.iface.IUpgradeTrainer;
|
||||
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
|
||||
import WayofTime.bloodmagic.api.util.helper.ItemHelper;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.item.ItemInscriptionTool;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Handler
|
||||
public class CraftingHandler
|
||||
{
|
||||
public class CraftingHandler {
|
||||
|
||||
// Sets the uses of crafted Inscription Tools to 10
|
||||
@SubscribeEvent
|
||||
public void onAltarCrafted(AltarCraftedEvent event)
|
||||
{
|
||||
if (event.getOutput() == null)
|
||||
{
|
||||
public void onAltarCrafted(AltarCraftedEvent event) {
|
||||
if (event.getOutput() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getOutput().getItem() instanceof ItemInscriptionTool)
|
||||
{
|
||||
if (event.getOutput().getItem() instanceof ItemInscriptionTool) {
|
||||
NBTHelper.checkNBT(event.getOutput());
|
||||
event.getOutput().getTagCompound().setInteger(Constants.NBT.USES, 10);
|
||||
}
|
||||
|
||||
if (event.getOutput().getItem() == ForgeModContainer.getInstance().universalBucket && event.getAltarRecipe().getSyphon() == 1000)
|
||||
{
|
||||
if (event.getOutput().getItem() == ForgeModContainer.getInstance().universalBucket && event.getAltarRecipe().getSyphon() == 1000) {
|
||||
NBTTagCompound bucketTags = FluidUtil.getFilledBucket(new FluidStack(BlockLifeEssence.getLifeEssence(), Fluid.BUCKET_VOLUME)).getTagCompound();
|
||||
event.getOutput().setTagCompound(bucketTags);
|
||||
}
|
||||
|
@ -55,12 +50,9 @@ public class CraftingHandler
|
|||
|
||||
// Handles crafting of: Revealing Upgrade Tome, Elytra Upgrade Tome, Combining Upgrade Tomes, Setting Upgrade for Trainer
|
||||
@SubscribeEvent
|
||||
public void onAnvil(AnvilUpdateEvent event)
|
||||
{
|
||||
if (ConfigHandler.thaumcraftGogglesUpgrade)
|
||||
{
|
||||
if (event.getLeft().getItem() == RegistrarBloodMagicItems.LIVING_ARMOUR_HELMET && event.getRight().getItem() == Constants.Compat.THAUMCRAFT_GOGGLES && !event.getRight().isItemDamaged())
|
||||
{
|
||||
public void onAnvil(AnvilUpdateEvent event) {
|
||||
if (ConfigHandler.thaumcraftGogglesUpgrade) {
|
||||
if (event.getLeft().getItem() == RegistrarBloodMagicItems.LIVING_ARMOUR_HELMET && event.getRight().getItem() == Constants.Compat.THAUMCRAFT_GOGGLES && !event.getRight().isItemDamaged()) {
|
||||
ItemStack output = new ItemStack(RegistrarBloodMagicItems.UPGRADE_TOME);
|
||||
output = NBTHelper.checkNBT(output);
|
||||
ItemHelper.LivingUpgrades.setKey(output, BloodMagic.MODID + ".upgrade.revealing");
|
||||
|
@ -73,10 +65,8 @@ public class CraftingHandler
|
|||
}
|
||||
}
|
||||
|
||||
if (event.getLeft().getItem() == RegistrarBloodMagicItems.SIGIL_HOLDING)
|
||||
{
|
||||
if (event.getRight().getItem() == Items.NAME_TAG)
|
||||
{
|
||||
if (event.getLeft().getItem() == RegistrarBloodMagicItems.SIGIL_HOLDING) {
|
||||
if (event.getRight().getItem() == Items.NAME_TAG) {
|
||||
ItemStack output = event.getLeft().copy();
|
||||
if (!output.hasTagCompound())
|
||||
output.setTagCompound(new NBTTagCompound());
|
||||
|
@ -88,8 +78,7 @@ public class CraftingHandler
|
|||
return;
|
||||
}
|
||||
|
||||
if (event.getRight().getItem() == Items.DYE)
|
||||
{
|
||||
if (event.getRight().getItem() == Items.DYE) {
|
||||
EnumDyeColor dyeColor = ItemBanner.getBaseColor(event.getRight());
|
||||
ItemStack output = event.getLeft().copy();
|
||||
if (!output.hasTagCompound())
|
||||
|
@ -103,8 +92,7 @@ public class CraftingHandler
|
|||
}
|
||||
}
|
||||
|
||||
if (event.getLeft().getItem() == Items.BOOK && event.getRight().getItem() == Items.ELYTRA && !event.getRight().isItemDamaged())
|
||||
{
|
||||
if (event.getLeft().getItem() == Items.BOOK && event.getRight().getItem() == Items.ELYTRA && !event.getRight().isItemDamaged()) {
|
||||
ItemStack output = new ItemStack(RegistrarBloodMagicItems.UPGRADE_TOME);
|
||||
output = NBTHelper.checkNBT(output);
|
||||
ItemHelper.LivingUpgrades.setKey(output, BloodMagic.MODID + ".upgrade.elytra");
|
||||
|
@ -116,16 +104,13 @@ public class CraftingHandler
|
|||
return;
|
||||
}
|
||||
|
||||
if (event.getLeft().getItem() == RegistrarBloodMagicItems.UPGRADE_TOME && event.getRight().getItem() == RegistrarBloodMagicItems.UPGRADE_TOME)
|
||||
{
|
||||
if (event.getLeft().getItem() == RegistrarBloodMagicItems.UPGRADE_TOME && event.getRight().getItem() == RegistrarBloodMagicItems.UPGRADE_TOME) {
|
||||
LivingArmourUpgrade leftUpgrade = ItemHelper.LivingUpgrades.getUpgrade(event.getLeft());
|
||||
if (leftUpgrade != null && !leftUpgrade.isDowngrade() && ItemHelper.LivingUpgrades.getKey(event.getLeft()).equals(ItemHelper.LivingUpgrades.getKey(event.getRight())))
|
||||
{
|
||||
if (leftUpgrade != null && !leftUpgrade.isDowngrade() && ItemHelper.LivingUpgrades.getKey(event.getLeft()).equals(ItemHelper.LivingUpgrades.getKey(event.getRight()))) {
|
||||
int leftLevel = ItemHelper.LivingUpgrades.getLevel(event.getLeft());
|
||||
int rightLevel = ItemHelper.LivingUpgrades.getLevel(event.getRight());
|
||||
|
||||
if (leftLevel == rightLevel && leftLevel < leftUpgrade.getMaxTier() - 1)
|
||||
{
|
||||
if (leftLevel == rightLevel && leftLevel < leftUpgrade.getMaxTier() - 1) {
|
||||
ItemStack outputStack = event.getLeft().copy();
|
||||
ItemHelper.LivingUpgrades.setLevel(outputStack, leftLevel + 1);
|
||||
event.setCost(leftLevel + 2);
|
||||
|
@ -137,17 +122,14 @@ public class CraftingHandler
|
|||
}
|
||||
}
|
||||
|
||||
if (event.getLeft().getItem() instanceof IUpgradeTrainer && event.getRight().getItem() == RegistrarBloodMagicItems.UPGRADE_TOME)
|
||||
{
|
||||
if (event.getLeft().getItem() instanceof IUpgradeTrainer && event.getRight().getItem() == RegistrarBloodMagicItems.UPGRADE_TOME) {
|
||||
LivingArmourUpgrade rightUpgrade = ItemHelper.LivingUpgrades.getUpgrade(event.getRight());
|
||||
if (rightUpgrade != null)
|
||||
{
|
||||
if (rightUpgrade != null) {
|
||||
String key = ItemHelper.LivingUpgrades.getKey(event.getRight());
|
||||
ItemStack outputStack = event.getLeft().copy();
|
||||
List<String> keyList = new ArrayList<String>();
|
||||
keyList.add(key);
|
||||
if (((IUpgradeTrainer) event.getLeft().getItem()).setTrainedUpgrades(outputStack, keyList))
|
||||
{
|
||||
if (((IUpgradeTrainer) event.getLeft().getItem()).setTrainedUpgrades(outputStack, keyList)) {
|
||||
event.setCost(1);
|
||||
|
||||
event.setOutput(outputStack);
|
||||
|
|
|
@ -1,14 +1,41 @@
|
|||
package WayofTime.bloodmagic.util.handler.event;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.ConfigHandler;
|
||||
import WayofTime.bloodmagic.annot.Handler;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.event.ItemBindEvent;
|
||||
import WayofTime.bloodmagic.api.event.SacrificeKnifeUsedEvent;
|
||||
import WayofTime.bloodmagic.api.event.TeleposeEvent;
|
||||
import WayofTime.bloodmagic.api.iface.IBindable;
|
||||
import WayofTime.bloodmagic.api.iface.ISentientTool;
|
||||
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
|
||||
import WayofTime.bloodmagic.api.orb.BloodOrb;
|
||||
import WayofTime.bloodmagic.api.orb.IBloodOrb;
|
||||
import WayofTime.bloodmagic.api.saving.SoulNetwork;
|
||||
import WayofTime.bloodmagic.api.soul.DemonWillHolder;
|
||||
import WayofTime.bloodmagic.api.util.helper.*;
|
||||
import WayofTime.bloodmagic.api_impl.BloodMagicAPI;
|
||||
import WayofTime.bloodmagic.block.BlockAltar;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagic;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
|
||||
import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler;
|
||||
import WayofTime.bloodmagic.entity.mob.EntitySentientSpecter;
|
||||
import WayofTime.bloodmagic.item.ItemAltarMaker;
|
||||
import WayofTime.bloodmagic.item.ItemExperienceBook;
|
||||
import WayofTime.bloodmagic.item.armour.ItemLivingArmour;
|
||||
import WayofTime.bloodmagic.item.gear.ItemPackSacrifice;
|
||||
import WayofTime.bloodmagic.livingArmour.LivingArmour;
|
||||
import WayofTime.bloodmagic.livingArmour.downgrade.LivingArmourUpgradeBattleHungry;
|
||||
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerSelfSacrifice;
|
||||
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeSelfSacrifice;
|
||||
import WayofTime.bloodmagic.network.BloodMagicPacketHandler;
|
||||
import WayofTime.bloodmagic.network.DemonAuraPacketProcessor;
|
||||
import WayofTime.bloodmagic.potion.BMPotionUtils;
|
||||
import WayofTime.bloodmagic.util.ChatUtil;
|
||||
import WayofTime.bloodmagic.util.Utils;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import com.google.common.base.Strings;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
|
@ -50,69 +77,33 @@ import net.minecraftforge.fml.common.eventhandler.Event.Result;
|
|||
import net.minecraftforge.fml.common.eventhandler.EventPriority;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
import WayofTime.bloodmagic.ConfigHandler;
|
||||
import WayofTime.bloodmagic.annot.Handler;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.event.ItemBindEvent;
|
||||
import WayofTime.bloodmagic.api.event.SacrificeKnifeUsedEvent;
|
||||
import WayofTime.bloodmagic.api.event.TeleposeEvent;
|
||||
import WayofTime.bloodmagic.api.iface.IBindable;
|
||||
import WayofTime.bloodmagic.api.iface.ISentientTool;
|
||||
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
|
||||
import WayofTime.bloodmagic.api.orb.IBloodOrb;
|
||||
import WayofTime.bloodmagic.api.saving.SoulNetwork;
|
||||
import WayofTime.bloodmagic.api.soul.DemonWillHolder;
|
||||
import WayofTime.bloodmagic.api.util.helper.BindableHelper;
|
||||
import WayofTime.bloodmagic.api.util.helper.ItemHelper;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
||||
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
||||
import WayofTime.bloodmagic.block.BlockAltar;
|
||||
import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler;
|
||||
import WayofTime.bloodmagic.entity.mob.EntitySentientSpecter;
|
||||
import WayofTime.bloodmagic.item.ItemAltarMaker;
|
||||
import WayofTime.bloodmagic.item.ItemExperienceBook;
|
||||
import WayofTime.bloodmagic.item.armour.ItemLivingArmour;
|
||||
import WayofTime.bloodmagic.item.gear.ItemPackSacrifice;
|
||||
import WayofTime.bloodmagic.livingArmour.LivingArmour;
|
||||
import WayofTime.bloodmagic.livingArmour.downgrade.LivingArmourUpgradeBattleHungry;
|
||||
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerSelfSacrifice;
|
||||
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeSelfSacrifice;
|
||||
import WayofTime.bloodmagic.network.BloodMagicPacketHandler;
|
||||
import WayofTime.bloodmagic.network.DemonAuraPacketProcessor;
|
||||
import WayofTime.bloodmagic.potion.BMPotionUtils;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
|
||||
import WayofTime.bloodmagic.util.ChatUtil;
|
||||
import WayofTime.bloodmagic.util.Utils;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import net.minecraftforge.fml.common.registry.EntityEntry;
|
||||
import net.minecraftforge.fml.common.registry.EntityRegistry;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
@Handler
|
||||
public class GenericHandler
|
||||
{
|
||||
public class GenericHandler {
|
||||
public static Map<EntityPlayer, Double> bounceMap = new HashMap<EntityPlayer, Double>();
|
||||
public static Map<EntityPlayer, Integer> filledHandMap = new HashMap<EntityPlayer, Integer>();
|
||||
private static Map<EntityAnimal, EntityAITarget> targetTaskMap = new HashMap<EntityAnimal, EntityAITarget>();
|
||||
private static Map<EntityAnimal, EntityAIBase> attackTaskMap = new HashMap<EntityAnimal, EntityAIBase>();
|
||||
|
||||
@SubscribeEvent
|
||||
public void onEntityFall(LivingFallEvent event)
|
||||
{
|
||||
if (event.getEntityLiving() instanceof EntityPlayer)
|
||||
{
|
||||
public void onEntityFall(LivingFallEvent event) {
|
||||
if (event.getEntityLiving() instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer) event.getEntityLiving();
|
||||
if (player.isPotionActive(RegistrarBloodMagic.BOUNCE) && !player.isSneaking() && event.getDistance() > 2)
|
||||
{
|
||||
if (player.isPotionActive(RegistrarBloodMagic.BOUNCE) && !player.isSneaking() && event.getDistance() > 2) {
|
||||
event.setDamageMultiplier(0);
|
||||
|
||||
if (player.getEntityWorld().isRemote)
|
||||
{
|
||||
if (player.getEntityWorld().isRemote) {
|
||||
player.motionY *= -0.9;
|
||||
player.fallDistance = 0;
|
||||
bounceMap.put(player, player.motionY);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
player.fallDistance = 0;
|
||||
event.setCanceled(true);
|
||||
}
|
||||
|
@ -121,23 +112,17 @@ public class GenericHandler
|
|||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void playerTickPost(TickEvent.PlayerTickEvent event)
|
||||
{
|
||||
if (event.phase == TickEvent.Phase.END && bounceMap.containsKey(event.player))
|
||||
{
|
||||
public void playerTickPost(TickEvent.PlayerTickEvent event) {
|
||||
if (event.phase == TickEvent.Phase.END && bounceMap.containsKey(event.player)) {
|
||||
event.player.motionY = bounceMap.remove(event.player);
|
||||
}
|
||||
|
||||
if (event.phase == TickEvent.Phase.END)
|
||||
{
|
||||
if (filledHandMap.containsKey(event.player))
|
||||
{
|
||||
if (event.phase == TickEvent.Phase.END) {
|
||||
if (filledHandMap.containsKey(event.player)) {
|
||||
int value = filledHandMap.get(event.player) - 1;
|
||||
if (value <= 0)
|
||||
{
|
||||
if (value <= 0) {
|
||||
filledHandMap.remove(event.player);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
filledHandMap.put(event.player, value);
|
||||
}
|
||||
}
|
||||
|
@ -145,31 +130,24 @@ public class GenericHandler
|
|||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPlayerClick(PlayerInteractEvent event)
|
||||
{
|
||||
if (event.isCancelable() && event.getEntityPlayer().isPotionActive(RegistrarBloodMagic.CONSTRICT))
|
||||
{
|
||||
public void onPlayerClick(PlayerInteractEvent event) {
|
||||
if (event.isCancelable() && event.getEntityPlayer().isPotionActive(RegistrarBloodMagic.CONSTRICT)) {
|
||||
EntityPlayer player = event.getEntityPlayer();
|
||||
int level = player.getActivePotionEffect(RegistrarBloodMagic.CONSTRICT).getAmplifier();
|
||||
if (event.getHand() == EnumHand.OFF_HAND || level > 1)
|
||||
{
|
||||
if (event.getHand() == EnumHand.OFF_HAND || level > 1) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPlayerDropItem(ItemTossEvent event)
|
||||
{
|
||||
public void onPlayerDropItem(ItemTossEvent event) {
|
||||
EntityItem itemEntity = event.getEntityItem();
|
||||
if (itemEntity != null)
|
||||
{
|
||||
if (itemEntity != null) {
|
||||
ItemStack stack = itemEntity.getItem();
|
||||
Item item = stack.getItem();
|
||||
if (stack.hasTagCompound() && item instanceof ISentientTool)
|
||||
{
|
||||
if (((ISentientTool) item).spawnSentientEntityOnDrop(stack, event.getPlayer()))
|
||||
{
|
||||
if (stack.hasTagCompound() && item instanceof ISentientTool) {
|
||||
if (((ISentientTool) item).spawnSentientEntityOnDrop(stack, event.getPlayer())) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
@ -177,8 +155,7 @@ public class GenericHandler
|
|||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onExplosion(ExplosionEvent.Start event)
|
||||
{
|
||||
public void onExplosion(ExplosionEvent.Start event) {
|
||||
World world = event.getWorld();
|
||||
Explosion exp = event.getExplosion();
|
||||
Vec3d position = exp.getPosition();
|
||||
|
@ -186,12 +163,9 @@ public class GenericHandler
|
|||
|
||||
AxisAlignedBB bb = new AxisAlignedBB(position.x - radius, position.y - radius, position.z - radius, position.x + radius, position.y + radius, position.z + radius);
|
||||
List<EntitySentientSpecter> specterList = world.getEntitiesWithinAABB(EntitySentientSpecter.class, bb);
|
||||
if (!specterList.isEmpty())
|
||||
{
|
||||
for (EntitySentientSpecter specter : specterList)
|
||||
{
|
||||
if (specter.absorbExplosion(exp))
|
||||
{
|
||||
if (!specterList.isEmpty()) {
|
||||
for (EntitySentientSpecter specter : specterList) {
|
||||
if (specter.absorbExplosion(exp)) {
|
||||
event.setCanceled(true);
|
||||
return;
|
||||
}
|
||||
|
@ -200,17 +174,14 @@ public class GenericHandler
|
|||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onEntityHurt(LivingHurtEvent event)
|
||||
{
|
||||
public void onEntityHurt(LivingHurtEvent event) {
|
||||
if (event.getEntity().getEntityWorld().isRemote)
|
||||
return;
|
||||
|
||||
if (event.getSource().getTrueSource() instanceof EntityPlayer && !PlayerHelper.isFakePlayer((EntityPlayer) event.getSource().getTrueSource()))
|
||||
{
|
||||
if (event.getSource().getTrueSource() instanceof EntityPlayer && !PlayerHelper.isFakePlayer((EntityPlayer) event.getSource().getTrueSource())) {
|
||||
EntityPlayer player = (EntityPlayer) event.getSource().getTrueSource();
|
||||
|
||||
if (!player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty() && player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).getItem() instanceof ItemPackSacrifice)
|
||||
{
|
||||
if (!player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty() && player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).getItem() instanceof ItemPackSacrifice) {
|
||||
ItemPackSacrifice pack = (ItemPackSacrifice) player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).getItem();
|
||||
|
||||
boolean shouldSyphon = pack.getStoredLP(player.getItemStackFromSlot(EntityEquipmentSlot.CHEST)) < pack.CAPACITY;
|
||||
|
@ -221,16 +192,13 @@ public class GenericHandler
|
|||
ItemHelper.LPContainer.addLPToItem(player.getItemStackFromSlot(EntityEquipmentSlot.CHEST), totalLP, pack.CAPACITY);
|
||||
}
|
||||
|
||||
if (LivingArmour.hasFullSet(player))
|
||||
{
|
||||
if (LivingArmour.hasFullSet(player)) {
|
||||
ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
|
||||
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
|
||||
if (armour != null)
|
||||
{
|
||||
if (armour != null) {
|
||||
|
||||
LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(BloodMagic.MODID + ".upgrade.battleHunger", chestStack);
|
||||
if (upgrade instanceof LivingArmourUpgradeBattleHungry)
|
||||
{
|
||||
if (upgrade instanceof LivingArmourUpgradeBattleHungry) {
|
||||
((LivingArmourUpgradeBattleHungry) upgrade).resetTimer();
|
||||
}
|
||||
}
|
||||
|
@ -238,28 +206,20 @@ public class GenericHandler
|
|||
}
|
||||
}
|
||||
|
||||
private static Map<EntityAnimal, EntityAITarget> targetTaskMap = new HashMap<EntityAnimal, EntityAITarget>();
|
||||
private static Map<EntityAnimal, EntityAIBase> attackTaskMap = new HashMap<EntityAnimal, EntityAIBase>();
|
||||
|
||||
// Handles sending the client the Demon Will Aura updates
|
||||
@SubscribeEvent
|
||||
public void onLivingUpdate(LivingUpdateEvent event)
|
||||
{
|
||||
if (!event.getEntityLiving().getEntityWorld().isRemote)
|
||||
{
|
||||
public void onLivingUpdate(LivingUpdateEvent event) {
|
||||
if (!event.getEntityLiving().getEntityWorld().isRemote) {
|
||||
EntityLivingBase entity = event.getEntityLiving();
|
||||
if (entity instanceof EntityPlayer && entity.ticksExisted % 50 == 0) //TODO: Change to an incremental counter
|
||||
{
|
||||
sendPlayerDemonWillAura((EntityPlayer) entity);
|
||||
}
|
||||
|
||||
if (event.getEntityLiving() instanceof EntityAnimal)
|
||||
{
|
||||
if (event.getEntityLiving() instanceof EntityAnimal) {
|
||||
EntityAnimal animal = (EntityAnimal) event.getEntityLiving();
|
||||
if (animal.isPotionActive(RegistrarBloodMagic.SACRIFICIAL_LAMB))
|
||||
{
|
||||
if (!targetTaskMap.containsKey(animal))
|
||||
{
|
||||
if (animal.isPotionActive(RegistrarBloodMagic.SACRIFICIAL_LAMB)) {
|
||||
if (!targetTaskMap.containsKey(animal)) {
|
||||
EntityAITarget task = new EntityAINearestAttackableTarget<EntityMob>(animal, EntityMob.class, false);
|
||||
EntityAIBase attackTask = new EntityAIAttackMelee(animal, 1.0D, false);
|
||||
animal.targetTasks.addTask(1, task);
|
||||
|
@ -268,14 +228,12 @@ public class GenericHandler
|
|||
attackTaskMap.put(animal, attackTask);
|
||||
}
|
||||
|
||||
if (animal.getAttackTarget() != null && animal.getDistanceSqToEntity(animal.getAttackTarget()) < 4)
|
||||
{
|
||||
if (animal.getAttackTarget() != null && animal.getDistanceSqToEntity(animal.getAttackTarget()) < 4) {
|
||||
animal.getEntityWorld().createExplosion(null, animal.posX, animal.posY + (double) (animal.height / 16.0F), animal.posZ, 2 + animal.getActivePotionEffect(RegistrarBloodMagic.SACRIFICIAL_LAMB).getAmplifier() * 1.5f, false);
|
||||
targetTaskMap.remove(animal);
|
||||
attackTaskMap.remove(animal);
|
||||
}
|
||||
} else if (targetTaskMap.containsKey(animal))
|
||||
{
|
||||
} else if (targetTaskMap.containsKey(animal)) {
|
||||
targetTaskMap.remove(animal);
|
||||
attackTaskMap.remove(animal);
|
||||
}
|
||||
|
@ -284,69 +242,55 @@ public class GenericHandler
|
|||
|
||||
EntityLivingBase entity = event.getEntityLiving();
|
||||
|
||||
if (entity instanceof EntityPlayer)
|
||||
{
|
||||
if (entity instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer) entity;
|
||||
if (player.isSneaking() && player.isPotionActive(RegistrarBloodMagic.CLING) && Utils.isPlayerBesideSolidBlockFace(player) && !player.onGround)
|
||||
{
|
||||
if (player.getEntityWorld().isRemote)
|
||||
{
|
||||
if (player.isSneaking() && player.isPotionActive(RegistrarBloodMagic.CLING) && Utils.isPlayerBesideSolidBlockFace(player) && !player.onGround) {
|
||||
if (player.getEntityWorld().isRemote) {
|
||||
player.motionY = 0;
|
||||
player.motionX *= 0.8;
|
||||
player.motionZ *= 0.8;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
player.fallDistance = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (entity.isPotionActive(MobEffects.NIGHT_VISION))
|
||||
{
|
||||
if (entity.isPotionActive(MobEffects.NIGHT_VISION)) {
|
||||
int duration = entity.getActivePotionEffect(MobEffects.NIGHT_VISION).getDuration();
|
||||
if (duration == Constants.Misc.NIGHT_VISION_CONSTANT_END)
|
||||
{
|
||||
if (duration == Constants.Misc.NIGHT_VISION_CONSTANT_END) {
|
||||
entity.removePotionEffect(MobEffects.NIGHT_VISION);
|
||||
}
|
||||
}
|
||||
|
||||
if (entity.isPotionActive(RegistrarBloodMagic.FIRE_FUSE))
|
||||
{
|
||||
if (entity.isPotionActive(RegistrarBloodMagic.FIRE_FUSE)) {
|
||||
Random random = entity.getEntityWorld().rand;
|
||||
entity.getEntityWorld().spawnParticle(EnumParticleTypes.FLAME, entity.posX + random.nextDouble() * 0.3, entity.posY + random.nextDouble() * 0.3, entity.posZ + random.nextDouble() * 0.3, 0, 0.06d, 0);
|
||||
|
||||
int r = entity.getActivePotionEffect(RegistrarBloodMagic.FIRE_FUSE).getAmplifier();
|
||||
int radius = r + 1;
|
||||
|
||||
if (entity.getActivePotionEffect(RegistrarBloodMagic.FIRE_FUSE).getDuration() <= 3)
|
||||
{
|
||||
if (entity.getActivePotionEffect(RegistrarBloodMagic.FIRE_FUSE).getDuration() <= 3) {
|
||||
entity.getEntityWorld().createExplosion(null, entity.posX, entity.posY, entity.posZ, radius, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (entity.isPotionActive(RegistrarBloodMagic.PLANT_LEECH))
|
||||
{
|
||||
if (entity.isPotionActive(RegistrarBloodMagic.PLANT_LEECH)) {
|
||||
int amplifier = entity.getActivePotionEffect(RegistrarBloodMagic.PLANT_LEECH).getAmplifier();
|
||||
int timeRemaining = entity.getActivePotionEffect(RegistrarBloodMagic.PLANT_LEECH).getDuration();
|
||||
if (timeRemaining % 10 == 0)
|
||||
{
|
||||
if (timeRemaining % 10 == 0) {
|
||||
BMPotionUtils.damageMobAndGrowSurroundingPlants(entity, 2 + amplifier, 1, 0.5 * 3 / (amplifier + 3), 25 * (1 + amplifier));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// @SideOnly(Side.SERVER)
|
||||
public void sendPlayerDemonWillAura(EntityPlayer player)
|
||||
{
|
||||
if (player instanceof EntityPlayerMP)
|
||||
{
|
||||
// @SideOnly(Side.SERVER)
|
||||
public void sendPlayerDemonWillAura(EntityPlayer player) {
|
||||
if (player instanceof EntityPlayerMP) {
|
||||
BlockPos pos = player.getPosition();
|
||||
DemonWillHolder holder = WorldDemonWillHandler.getWillHolder(player.getEntityWorld().provider.getDimension(), pos.getX() >> 4, pos.getZ() >> 4);
|
||||
if (holder != null)
|
||||
{
|
||||
if (holder != null) {
|
||||
BloodMagicPacketHandler.sendTo(new DemonAuraPacketProcessor(holder), (EntityPlayerMP) player);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
BloodMagicPacketHandler.sendTo(new DemonAuraPacketProcessor(new DemonWillHolder()), (EntityPlayerMP) player);
|
||||
}
|
||||
}
|
||||
|
@ -354,12 +298,10 @@ public class GenericHandler
|
|||
|
||||
// Handles destroying altar
|
||||
@SubscribeEvent
|
||||
public void harvestEvent(PlayerEvent.HarvestCheck event)
|
||||
{
|
||||
public void harvestEvent(PlayerEvent.HarvestCheck event) {
|
||||
IBlockState state = event.getTargetBlock();
|
||||
Block block = state.getBlock();
|
||||
if (block instanceof BlockAltar && event.getEntityPlayer() != null && event.getEntityPlayer() instanceof EntityPlayerMP && !event.getEntityPlayer().getHeldItemMainhand().isEmpty() && event.getEntityPlayer().getHeldItemMainhand().getItem() instanceof ItemAltarMaker)
|
||||
{
|
||||
if (block instanceof BlockAltar && event.getEntityPlayer() != null && event.getEntityPlayer() instanceof EntityPlayerMP && !event.getEntityPlayer().getHeldItemMainhand().isEmpty() && event.getEntityPlayer().getHeldItemMainhand().getItem() instanceof ItemAltarMaker) {
|
||||
ItemAltarMaker altarMaker = (ItemAltarMaker) event.getEntityPlayer().getHeldItemMainhand().getItem();
|
||||
ChatUtil.sendNoSpam(event.getEntityPlayer(), TextHelper.localizeEffect("chat.bloodmagic.altarMaker.destroy", altarMaker.destroyAltar(event.getEntityPlayer())));
|
||||
}
|
||||
|
@ -367,16 +309,14 @@ public class GenericHandler
|
|||
|
||||
// Handle Teleposer block blacklist
|
||||
@SubscribeEvent
|
||||
public void onTelepose(TeleposeEvent event)
|
||||
{
|
||||
public void onTelepose(TeleposeEvent event) {
|
||||
if (BloodMagicAPI.INSTANCE.getBlacklist().getTeleposer().contains(event.initialState) || BloodMagicAPI.INSTANCE.getBlacklist().getTeleposer().contains(event.finalState))
|
||||
event.setCanceled(true);
|
||||
}
|
||||
|
||||
// Handle Teleposer entity blacklist
|
||||
@SubscribeEvent
|
||||
public void onTeleposeEntity(TeleposeEvent.Ent event)
|
||||
{
|
||||
public void onTeleposeEntity(TeleposeEvent.Ent event) {
|
||||
EntityEntry entry = EntityRegistry.getEntry(event.entity.getClass());
|
||||
if (BloodMagicAPI.INSTANCE.getBlacklist().getTeleposerEntities().contains(entry.getRegistryName()))
|
||||
event.setCanceled(true);
|
||||
|
@ -384,15 +324,13 @@ public class GenericHandler
|
|||
|
||||
// Sets teleport cooldown for Teleposed entities to 5 ticks (1/4 second) instead of 150 (7.5 seconds)
|
||||
@SubscribeEvent
|
||||
public void onTeleposeEntityPost(TeleposeEvent.Ent.Post event)
|
||||
{
|
||||
public void onTeleposeEntityPost(TeleposeEvent.Ent.Post event) {
|
||||
event.entity.timeUntilPortal = 5;
|
||||
}
|
||||
|
||||
// Handles binding of IBindable's as well as setting a player's highest orb tier
|
||||
@SubscribeEvent
|
||||
public void onInteract(PlayerInteractEvent.RightClickItem event)
|
||||
{
|
||||
public void onInteract(PlayerInteractEvent.RightClickItem event) {
|
||||
if (event.getWorld().isRemote)
|
||||
return;
|
||||
|
||||
|
@ -402,14 +340,11 @@ public class GenericHandler
|
|||
return;
|
||||
|
||||
ItemStack held = event.getItemStack();
|
||||
if (!held.isEmpty() && held.getItem() instanceof IBindable)
|
||||
{
|
||||
if (!held.isEmpty() && held.getItem() instanceof IBindable) {
|
||||
held = NBTHelper.checkNBT(held);
|
||||
IBindable bindable = (IBindable) held.getItem();
|
||||
if (Strings.isNullOrEmpty(bindable.getOwnerUUID(held)))
|
||||
{
|
||||
if (bindable.onBind(player, held))
|
||||
{
|
||||
if (Strings.isNullOrEmpty(bindable.getOwnerUUID(held))) {
|
||||
if (bindable.onBind(player, held)) {
|
||||
String uuid = PlayerHelper.getUUIDFromPlayer(player).toString();
|
||||
ItemBindEvent toPost = new ItemBindEvent(player, uuid, held);
|
||||
if (MinecraftForge.EVENT_BUS.post(toPost) || toPost.getResult() == Result.DENY)
|
||||
|
@ -422,8 +357,7 @@ public class GenericHandler
|
|||
BindableHelper.setItemOwnerName(held, player.getDisplayNameString());
|
||||
}
|
||||
|
||||
if (!held.isEmpty() && held.getItem() instanceof IBloodOrb)
|
||||
{
|
||||
if (!held.isEmpty() && held.getItem() instanceof IBloodOrb) {
|
||||
held = NBTHelper.checkNBT(held);
|
||||
IBloodOrb bloodOrb = (IBloodOrb) held.getItem();
|
||||
SoulNetwork network = NetworkHelper.getSoulNetwork(player);
|
||||
|
@ -438,21 +372,17 @@ public class GenericHandler
|
|||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void selfSacrificeEvent(SacrificeKnifeUsedEvent event)
|
||||
{
|
||||
public void selfSacrificeEvent(SacrificeKnifeUsedEvent event) {
|
||||
EntityPlayer player = event.player;
|
||||
|
||||
if (LivingArmour.hasFullSet(player))
|
||||
{
|
||||
if (LivingArmour.hasFullSet(player)) {
|
||||
ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
|
||||
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
|
||||
if (armour != null)
|
||||
{
|
||||
if (armour != null) {
|
||||
StatTrackerSelfSacrifice.incrementCounter(armour, event.healthDrained / 2);
|
||||
LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(BloodMagic.MODID + ".upgrade.selfSacrifice", chestStack);
|
||||
|
||||
if (upgrade instanceof LivingArmourUpgradeSelfSacrifice)
|
||||
{
|
||||
if (upgrade instanceof LivingArmourUpgradeSelfSacrifice) {
|
||||
double modifier = ((LivingArmourUpgradeSelfSacrifice) upgrade).getSacrificeModifier();
|
||||
|
||||
event.lpAdded = (int) (event.lpAdded * (1 + modifier));
|
||||
|
@ -463,14 +393,12 @@ public class GenericHandler
|
|||
|
||||
// Drop Blood Shards
|
||||
@SubscribeEvent
|
||||
public void onLivingDrops(LivingDropsEvent event)
|
||||
{
|
||||
public void onLivingDrops(LivingDropsEvent event) {
|
||||
EntityLivingBase attackedEntity = event.getEntityLiving();
|
||||
DamageSource source = event.getSource();
|
||||
Entity entity = source.getTrueSource();
|
||||
|
||||
if (entity != null && entity instanceof EntityPlayer)
|
||||
{
|
||||
if (entity != null && entity instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer) entity;
|
||||
ItemStack heldStack = player.getHeldItemMainhand();
|
||||
|
||||
|
@ -483,24 +411,19 @@ public class GenericHandler
|
|||
|
||||
// Experience Tome
|
||||
@SubscribeEvent(priority = EventPriority.LOWEST)
|
||||
public void onExperiencePickup(PlayerPickupXpEvent event)
|
||||
{
|
||||
public void onExperiencePickup(PlayerPickupXpEvent event) {
|
||||
EntityPlayer player = event.getEntityPlayer();
|
||||
ItemStack itemstack = EnchantmentHelper.getEnchantedItem(Enchantments.MENDING, player);
|
||||
|
||||
if (!itemstack.isEmpty() && itemstack.isItemDamaged())
|
||||
{
|
||||
if (!itemstack.isEmpty() && itemstack.isItemDamaged()) {
|
||||
int i = Math.min(xpToDurability(event.getOrb().xpValue), itemstack.getItemDamage());
|
||||
event.getOrb().xpValue -= durabilityToXp(i);
|
||||
itemstack.setItemDamage(itemstack.getItemDamage() - i);
|
||||
}
|
||||
|
||||
if (!player.getEntityWorld().isRemote)
|
||||
{
|
||||
for (ItemStack stack : player.inventory.mainInventory)
|
||||
{
|
||||
if (stack.getItem() instanceof ItemExperienceBook)
|
||||
{
|
||||
if (!player.getEntityWorld().isRemote) {
|
||||
for (ItemStack stack : player.inventory.mainInventory) {
|
||||
if (stack.getItem() instanceof ItemExperienceBook) {
|
||||
ItemExperienceBook.addExperience(stack, event.getOrb().xpValue);
|
||||
event.getOrb().xpValue = 0;
|
||||
break;
|
||||
|
@ -509,13 +432,11 @@ public class GenericHandler
|
|||
}
|
||||
}
|
||||
|
||||
private int xpToDurability(int xp)
|
||||
{
|
||||
private int xpToDurability(int xp) {
|
||||
return xp * 2;
|
||||
}
|
||||
|
||||
private int durabilityToXp(int durability)
|
||||
{
|
||||
private int durabilityToXp(int durability) {
|
||||
return durability / 2;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,20 @@
|
|||
package WayofTime.bloodmagic.util.handler.event;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.annot.Handler;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagic;
|
||||
import WayofTime.bloodmagic.item.armour.ItemLivingArmour;
|
||||
import WayofTime.bloodmagic.livingArmour.LivingArmour;
|
||||
import WayofTime.bloodmagic.livingArmour.downgrade.LivingArmourUpgradeCrippledArm;
|
||||
import WayofTime.bloodmagic.livingArmour.downgrade.LivingArmourUpgradeQuenched;
|
||||
import WayofTime.bloodmagic.livingArmour.downgrade.LivingArmourUpgradeSlowHeal;
|
||||
import WayofTime.bloodmagic.livingArmour.downgrade.LivingArmourUpgradeStormTrooper;
|
||||
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerArrowShot;
|
||||
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerGrimReaperSprint;
|
||||
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerJump;
|
||||
import WayofTime.bloodmagic.livingArmour.upgrade.*;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -25,49 +38,25 @@ import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
|||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
import net.minecraftforge.fml.common.eventhandler.EventPriority;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import WayofTime.bloodmagic.annot.Handler;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
|
||||
import WayofTime.bloodmagic.item.armour.ItemLivingArmour;
|
||||
import WayofTime.bloodmagic.livingArmour.LivingArmour;
|
||||
import WayofTime.bloodmagic.livingArmour.downgrade.LivingArmourUpgradeCrippledArm;
|
||||
import WayofTime.bloodmagic.livingArmour.downgrade.LivingArmourUpgradeQuenched;
|
||||
import WayofTime.bloodmagic.livingArmour.downgrade.LivingArmourUpgradeSlowHeal;
|
||||
import WayofTime.bloodmagic.livingArmour.downgrade.LivingArmourUpgradeStormTrooper;
|
||||
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerArrowShot;
|
||||
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerGrimReaperSprint;
|
||||
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerJump;
|
||||
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeArrowShot;
|
||||
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeGrimReaperSprint;
|
||||
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeJump;
|
||||
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeSpeed;
|
||||
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeStepAssist;
|
||||
|
||||
@Handler
|
||||
public class LivingArmourHandler
|
||||
{
|
||||
public class LivingArmourHandler {
|
||||
@SubscribeEvent
|
||||
public void onEntityHealed(LivingHealEvent event)
|
||||
{
|
||||
if (event.getEntityLiving() instanceof EntityPlayer)
|
||||
{
|
||||
public void onEntityHealed(LivingHealEvent event) {
|
||||
if (event.getEntityLiving() instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer) event.getEntity();
|
||||
if (LivingArmour.hasFullSet(player))
|
||||
{
|
||||
if (LivingArmour.hasFullSet(player)) {
|
||||
ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
|
||||
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
|
||||
if (armour != null)
|
||||
{
|
||||
if (armour != null) {
|
||||
double modifier = 1;
|
||||
LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(BloodMagic.MODID + ".upgrade.slowHeal", chestStack);
|
||||
|
||||
if (upgrade instanceof LivingArmourUpgradeSlowHeal)
|
||||
{
|
||||
if (upgrade instanceof LivingArmourUpgradeSlowHeal) {
|
||||
modifier *= ((LivingArmourUpgradeSlowHeal) upgrade).getHealingModifier();
|
||||
}
|
||||
|
||||
if (modifier != 1)
|
||||
{
|
||||
if (modifier != 1) {
|
||||
event.setAmount((float) (event.getAmount() * modifier));
|
||||
}
|
||||
}
|
||||
|
@ -76,23 +65,18 @@ public class LivingArmourHandler
|
|||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onMiningSpeedCheck(PlayerEvent.BreakSpeed event)
|
||||
{
|
||||
public void onMiningSpeedCheck(PlayerEvent.BreakSpeed event) {
|
||||
EntityPlayer player = event.getEntityPlayer();
|
||||
if (LivingArmour.hasFullSet(player))
|
||||
{
|
||||
if (LivingArmour.hasFullSet(player)) {
|
||||
ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
|
||||
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
|
||||
if (armour != null)
|
||||
{
|
||||
if (armour != null) {
|
||||
double modifier = 1;
|
||||
for (LivingArmourUpgrade upgrade : armour.upgradeMap.values())
|
||||
{
|
||||
for (LivingArmourUpgrade upgrade : armour.upgradeMap.values()) {
|
||||
modifier *= upgrade.getMiningSpeedModifier(player);
|
||||
}
|
||||
|
||||
if (modifier != 1)
|
||||
{
|
||||
if (modifier != 1) {
|
||||
event.setNewSpeed((float) (event.getOriginalSpeed() * modifier));
|
||||
}
|
||||
}
|
||||
|
@ -101,31 +85,24 @@ public class LivingArmourHandler
|
|||
|
||||
// Applies: Storm Trooper
|
||||
@SubscribeEvent
|
||||
public void onEntityJoinedWorld(EntityJoinWorldEvent event)
|
||||
{
|
||||
public void onEntityJoinedWorld(EntityJoinWorldEvent event) {
|
||||
Entity owner = null;
|
||||
if (event.getEntity() instanceof EntityArrow)
|
||||
{
|
||||
if (event.getEntity() instanceof EntityArrow) {
|
||||
owner = ((EntityArrow) event.getEntity()).shootingEntity;
|
||||
} else if (event.getEntity() instanceof EntityThrowable)
|
||||
{
|
||||
} else if (event.getEntity() instanceof EntityThrowable) {
|
||||
owner = ((EntityThrowable) event.getEntity()).getThrower();
|
||||
}
|
||||
|
||||
if (owner instanceof EntityPlayer)
|
||||
{
|
||||
if (owner instanceof EntityPlayer) {
|
||||
Entity projectile = event.getEntity();
|
||||
EntityPlayer player = (EntityPlayer) owner;
|
||||
if (LivingArmour.hasFullSet(player))
|
||||
{
|
||||
if (LivingArmour.hasFullSet(player)) {
|
||||
ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
|
||||
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
|
||||
if (armour != null)
|
||||
{
|
||||
if (armour != null) {
|
||||
LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(BloodMagic.MODID + ".upgrade.stormTrooper", chestStack);
|
||||
|
||||
if (upgrade instanceof LivingArmourUpgradeStormTrooper)
|
||||
{
|
||||
if (upgrade instanceof LivingArmourUpgradeStormTrooper) {
|
||||
float velocityModifier = (float) (((LivingArmourUpgradeStormTrooper) upgrade).getArrowJiggle(player) * Math.sqrt(projectile.motionX * projectile.motionX + projectile.motionY * projectile.motionY + projectile.motionZ * projectile.motionZ));
|
||||
|
||||
projectile.motionX += 2 * (event.getWorld().rand.nextDouble() - 0.5) * velocityModifier;
|
||||
|
@ -138,37 +115,29 @@ public class LivingArmourHandler
|
|||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPlayerClick(PlayerInteractEvent event)
|
||||
{
|
||||
if (event.isCancelable())
|
||||
{
|
||||
public void onPlayerClick(PlayerInteractEvent event) {
|
||||
if (event.isCancelable()) {
|
||||
EntityPlayer player = event.getEntityPlayer();
|
||||
|
||||
if (LivingArmour.hasFullSet(player))
|
||||
{
|
||||
if (LivingArmour.hasFullSet(player)) {
|
||||
ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
|
||||
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
|
||||
if (armour != null)
|
||||
{
|
||||
if (event.getHand() == EnumHand.OFF_HAND)
|
||||
{
|
||||
if (armour != null) {
|
||||
if (event.getHand() == EnumHand.OFF_HAND) {
|
||||
LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(BloodMagic.MODID + ".upgrade.crippledArm", chestStack);
|
||||
|
||||
if (upgrade instanceof LivingArmourUpgradeCrippledArm)
|
||||
{
|
||||
if (upgrade instanceof LivingArmourUpgradeCrippledArm) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (event.getItemStack().getItemUseAction() == EnumAction.DRINK)
|
||||
{
|
||||
if (event.getItemStack().getItemUseAction() == EnumAction.DRINK) {
|
||||
ItemStack drinkStack = event.getItemStack();
|
||||
|
||||
//TODO: See if the item is a splash potion? Those should be usable.
|
||||
LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(BloodMagic.MODID + ".upgrade.quenched", chestStack);
|
||||
|
||||
if (upgrade instanceof LivingArmourUpgradeQuenched)
|
||||
{
|
||||
if (upgrade instanceof LivingArmourUpgradeQuenched) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
@ -179,24 +148,19 @@ public class LivingArmourHandler
|
|||
|
||||
// Applies: Grim Reaper
|
||||
@SubscribeEvent(priority = EventPriority.HIGHEST)
|
||||
public void onEntityDeath(LivingDeathEvent event)
|
||||
{
|
||||
if (event.getEntityLiving() instanceof EntityPlayer)
|
||||
{
|
||||
public void onEntityDeath(LivingDeathEvent event) {
|
||||
if (event.getEntityLiving() instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer) event.getEntityLiving();
|
||||
|
||||
if (LivingArmour.hasFullSet(player))
|
||||
{
|
||||
if (LivingArmour.hasFullSet(player)) {
|
||||
ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
|
||||
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
|
||||
if (armour != null)
|
||||
{
|
||||
if (armour != null) {
|
||||
StatTrackerGrimReaperSprint.incrementCounter(armour);
|
||||
|
||||
LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(BloodMagic.MODID + ".upgrade.grimReaper", chestStack);
|
||||
|
||||
if (upgrade instanceof LivingArmourUpgradeGrimReaperSprint && ((LivingArmourUpgradeGrimReaperSprint) upgrade).canSavePlayer(player))
|
||||
{
|
||||
if (upgrade instanceof LivingArmourUpgradeGrimReaperSprint && ((LivingArmourUpgradeGrimReaperSprint) upgrade).canSavePlayer(player)) {
|
||||
((LivingArmourUpgradeGrimReaperSprint) upgrade).applyEffectOnRebirth(player);
|
||||
event.setCanceled(true);
|
||||
event.setResult(Event.Result.DENY);
|
||||
|
@ -210,26 +174,20 @@ public class LivingArmourHandler
|
|||
|
||||
// Applies: Jump
|
||||
@SubscribeEvent
|
||||
public void onJumpEvent(LivingEvent.LivingJumpEvent event)
|
||||
{
|
||||
if (event.getEntityLiving() instanceof EntityPlayer)
|
||||
{
|
||||
public void onJumpEvent(LivingEvent.LivingJumpEvent event) {
|
||||
if (event.getEntityLiving() instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer) event.getEntityLiving();
|
||||
|
||||
if (LivingArmour.hasFullSet(player))
|
||||
{
|
||||
if (LivingArmour.hasFullSet(player)) {
|
||||
ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
|
||||
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
|
||||
if (armour != null)
|
||||
{
|
||||
if (armour != null) {
|
||||
StatTrackerJump.incrementCounter(armour);
|
||||
|
||||
if (!player.isSneaking())
|
||||
{
|
||||
if (!player.isSneaking()) {
|
||||
LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgradeFromNBT(BloodMagic.MODID + ".upgrade.jump", chestStack);
|
||||
|
||||
if (upgrade instanceof LivingArmourUpgradeJump)
|
||||
{
|
||||
if (upgrade instanceof LivingArmourUpgradeJump) {
|
||||
player.motionY += ((LivingArmourUpgradeJump) upgrade).getJumpModifier();
|
||||
}
|
||||
}
|
||||
|
@ -240,28 +198,21 @@ public class LivingArmourHandler
|
|||
|
||||
// Applies: Step Assist, Speed Boost
|
||||
@SubscribeEvent(priority = EventPriority.HIGHEST)
|
||||
public void onEntityUpdate(LivingEvent.LivingUpdateEvent event)
|
||||
{
|
||||
if (event.getEntityLiving() instanceof EntityPlayer)
|
||||
{
|
||||
public void onEntityUpdate(LivingEvent.LivingUpdateEvent event) {
|
||||
if (event.getEntityLiving() instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer) event.getEntityLiving();
|
||||
boolean hasAssist = false;
|
||||
if (event.getEntityLiving().isPotionActive(RegistrarBloodMagic.BOOST))
|
||||
{
|
||||
if (event.getEntityLiving().isPotionActive(RegistrarBloodMagic.BOOST)) {
|
||||
hasAssist = true;
|
||||
player.stepHeight = Constants.Misc.ALTERED_STEP_HEIGHT;
|
||||
} else
|
||||
{
|
||||
if (LivingArmour.hasFullSet(player))
|
||||
{
|
||||
} else {
|
||||
if (LivingArmour.hasFullSet(player)) {
|
||||
ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
|
||||
LivingArmour armour = ItemLivingArmour.getLivingArmourFromStack(chestStack);
|
||||
if (armour != null)
|
||||
{
|
||||
if (armour != null) {
|
||||
LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(BloodMagic.MODID + ".upgrade.stepAssist", chestStack);
|
||||
|
||||
if (upgrade instanceof LivingArmourUpgradeStepAssist)
|
||||
{
|
||||
if (upgrade instanceof LivingArmourUpgradeStepAssist) {
|
||||
player.stepHeight = ((LivingArmourUpgradeStepAssist) upgrade).getStepAssist();
|
||||
hasAssist = true;
|
||||
}
|
||||
|
@ -274,31 +225,26 @@ public class LivingArmourHandler
|
|||
|
||||
float percentIncrease = 0;
|
||||
|
||||
if (LivingArmour.hasFullSet(player))
|
||||
{
|
||||
if (LivingArmour.hasFullSet(player)) {
|
||||
ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
|
||||
LivingArmour armour = ItemLivingArmour.getLivingArmourFromStack(chestStack);
|
||||
if (armour != null)
|
||||
{
|
||||
if (armour != null) {
|
||||
LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgradeFromNBT(BloodMagic.MODID + ".upgrade.movement", chestStack);
|
||||
|
||||
if (upgrade instanceof LivingArmourUpgradeSpeed)
|
||||
{
|
||||
if (upgrade instanceof LivingArmourUpgradeSpeed) {
|
||||
percentIncrease += 0.1f * ((LivingArmourUpgradeSpeed) upgrade).getSpeedModifier();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (event.getEntityLiving().isPotionActive(RegistrarBloodMagic.BOOST))
|
||||
{
|
||||
if (event.getEntityLiving().isPotionActive(RegistrarBloodMagic.BOOST)) {
|
||||
int i = event.getEntityLiving().getActivePotionEffect(RegistrarBloodMagic.BOOST).getAmplifier();
|
||||
{
|
||||
percentIncrease += (i + 1) * 0.05f;
|
||||
}
|
||||
}
|
||||
|
||||
if (percentIncrease > 0 && (player.onGround || player.capabilities.isFlying) && (Math.abs(player.moveForward) > 0 || Math.abs(player.moveStrafing) > 0))
|
||||
{
|
||||
if (percentIncrease > 0 && (player.onGround || player.capabilities.isFlying) && (Math.abs(player.moveForward) > 0 || Math.abs(player.moveStrafing) > 0)) {
|
||||
player.moveRelative(player.moveStrafing, player.moveForward, player.capabilities.isFlying ? (percentIncrease / 2.0f) : percentIncrease, 0.02F);
|
||||
}
|
||||
}
|
||||
|
@ -307,8 +253,7 @@ public class LivingArmourHandler
|
|||
// Applies: Arrow Shot
|
||||
// Tracks: Arrow Shot
|
||||
@SubscribeEvent
|
||||
public void onArrowFire(ArrowLooseEvent event)
|
||||
{
|
||||
public void onArrowFire(ArrowLooseEvent event) {
|
||||
World world = event.getEntityPlayer().getEntityWorld();
|
||||
ItemStack stack = event.getBow();
|
||||
EntityPlayer player = event.getEntityPlayer();
|
||||
|
@ -316,17 +261,14 @@ public class LivingArmourHandler
|
|||
if (world.isRemote)
|
||||
return;
|
||||
|
||||
if (LivingArmour.hasFullSet(player))
|
||||
{
|
||||
if (LivingArmour.hasFullSet(player)) {
|
||||
ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
|
||||
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
|
||||
if (armour != null)
|
||||
{
|
||||
if (armour != null) {
|
||||
StatTrackerArrowShot.incrementCounter(armour);
|
||||
|
||||
LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(BloodMagic.MODID + ".upgrade.arrowShot", chestStack);
|
||||
if (upgrade instanceof LivingArmourUpgradeArrowShot)
|
||||
{
|
||||
if (upgrade instanceof LivingArmourUpgradeArrowShot) {
|
||||
int charge = event.getCharge();
|
||||
float velocity = (float) charge / 20.0F;
|
||||
velocity = (velocity * velocity + velocity * 2.0F) / 3.0F;
|
||||
|
@ -338,8 +280,7 @@ public class LivingArmourHandler
|
|||
velocity = 1.0F;
|
||||
|
||||
int extraArrows = ((LivingArmourUpgradeArrowShot) upgrade).getExtraArrows();
|
||||
for (int n = 0; n < extraArrows; n++)
|
||||
{
|
||||
for (int n = 0; n < extraArrows; n++) {
|
||||
ItemStack arrowStack = new ItemStack(Items.ARROW);
|
||||
ItemArrow itemarrow = (ItemArrow) ((stack.getItem() instanceof ItemArrow ? arrowStack.getItem() : Items.ARROW));
|
||||
EntityArrow entityarrow = itemarrow.createArrow(world, arrowStack, player);
|
||||
|
|
|
@ -1,6 +1,15 @@
|
|||
package WayofTime.bloodmagic.util.handler.event;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.annot.Handler;
|
||||
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
|
||||
import WayofTime.bloodmagic.item.armour.ItemLivingArmour;
|
||||
import WayofTime.bloodmagic.item.armour.ItemSentientArmour;
|
||||
import WayofTime.bloodmagic.livingArmour.LivingArmour;
|
||||
import WayofTime.bloodmagic.livingArmour.tracker.*;
|
||||
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeDigging;
|
||||
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeExperience;
|
||||
import WayofTime.bloodmagic.util.Utils;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -17,49 +26,23 @@ import net.minecraftforge.event.entity.player.PlayerPickupXpEvent;
|
|||
import net.minecraftforge.event.world.BlockEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.EventPriority;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import WayofTime.bloodmagic.annot.Handler;
|
||||
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
|
||||
import WayofTime.bloodmagic.item.armour.ItemLivingArmour;
|
||||
import WayofTime.bloodmagic.item.armour.ItemSentientArmour;
|
||||
import WayofTime.bloodmagic.livingArmour.LivingArmour;
|
||||
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerArrowProtect;
|
||||
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerCriticalStrike;
|
||||
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerDigging;
|
||||
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerExperience;
|
||||
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerFallProtect;
|
||||
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerGraveDigger;
|
||||
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerHealthboost;
|
||||
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerMeleeDamage;
|
||||
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerNightSight;
|
||||
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerPhysicalProtect;
|
||||
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerSolarPowered;
|
||||
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerSprintAttack;
|
||||
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeDigging;
|
||||
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeExperience;
|
||||
import WayofTime.bloodmagic.util.Utils;
|
||||
|
||||
@Handler
|
||||
public class StatTrackerHandler
|
||||
{
|
||||
public class StatTrackerHandler {
|
||||
|
||||
private static float lastPlayerSwingStrength = 0;
|
||||
|
||||
// Tracks: Digging, DigSlowdown
|
||||
@SubscribeEvent
|
||||
public void blockBreakEvent(BlockEvent.BreakEvent event)
|
||||
{
|
||||
public void blockBreakEvent(BlockEvent.BreakEvent event) {
|
||||
EntityPlayer player = event.getPlayer();
|
||||
if (player != null)
|
||||
{
|
||||
if (LivingArmour.hasFullSet(player))
|
||||
{
|
||||
if (player != null) {
|
||||
if (LivingArmour.hasFullSet(player)) {
|
||||
ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
|
||||
if (chestStack.getItem() instanceof ItemLivingArmour)
|
||||
{
|
||||
if (chestStack.getItem() instanceof ItemLivingArmour) {
|
||||
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
|
||||
|
||||
if (armour != null)
|
||||
{
|
||||
if (armour != null) {
|
||||
StatTrackerDigging.incrementCounter(armour);
|
||||
LivingArmourUpgradeDigging.hasDug(armour);
|
||||
}
|
||||
|
@ -70,25 +53,20 @@ public class StatTrackerHandler
|
|||
|
||||
// Tracks: Health Boost
|
||||
@SubscribeEvent
|
||||
public void onEntityHealed(LivingHealEvent event)
|
||||
{
|
||||
public void onEntityHealed(LivingHealEvent event) {
|
||||
EntityLivingBase healedEntity = event.getEntityLiving();
|
||||
if (!(healedEntity instanceof EntityPlayer))
|
||||
{
|
||||
if (!(healedEntity instanceof EntityPlayer)) {
|
||||
return;
|
||||
}
|
||||
|
||||
EntityPlayer player = (EntityPlayer) healedEntity;
|
||||
|
||||
if (LivingArmour.hasFullSet(player))
|
||||
{
|
||||
if (LivingArmour.hasFullSet(player)) {
|
||||
ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
|
||||
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
|
||||
if (armour != null)
|
||||
{
|
||||
if (armour != null) {
|
||||
StatTrackerHealthboost.incrementCounter(armour, event.getAmount());
|
||||
if (player.getEntityWorld().canSeeSky(player.getPosition()) && player.getEntityWorld().provider.isDaytime())
|
||||
{
|
||||
if (player.getEntityWorld().canSeeSky(player.getPosition()) && player.getEntityWorld().provider.isDaytime()) {
|
||||
StatTrackerSolarPowered.incrementCounter(armour, event.getAmount());
|
||||
}
|
||||
}
|
||||
|
@ -96,31 +74,26 @@ public class StatTrackerHandler
|
|||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onLivingAttack(AttackEntityEvent event)
|
||||
{
|
||||
public void onLivingAttack(AttackEntityEvent event) {
|
||||
lastPlayerSwingStrength = event.getEntityPlayer().getCooledAttackStrength(0);
|
||||
}
|
||||
|
||||
// Tracks: Fall Protect, Arrow Protect, Physical Protect, Grave Digger, Sprint Attack, Critical Strike, Nocturnal Prowess
|
||||
@SubscribeEvent
|
||||
public void entityHurt(LivingHurtEvent event)
|
||||
{
|
||||
public void entityHurt(LivingHurtEvent event) {
|
||||
DamageSource source = event.getSource();
|
||||
Entity sourceEntity = event.getSource().getTrueSource();
|
||||
EntityLivingBase attackedEntity = event.getEntityLiving();
|
||||
|
||||
if (attackedEntity instanceof EntityPlayer)
|
||||
{
|
||||
if (attackedEntity instanceof EntityPlayer) {
|
||||
EntityPlayer attackedPlayer = (EntityPlayer) attackedEntity;
|
||||
|
||||
// Living Armor Handling
|
||||
if (LivingArmour.hasFullSet(attackedPlayer))
|
||||
{
|
||||
if (LivingArmour.hasFullSet(attackedPlayer)) {
|
||||
float amount = Math.min(Utils.getModifiedDamage(attackedPlayer, event.getSource(), event.getAmount()), attackedPlayer.getHealth());
|
||||
ItemStack chestStack = attackedPlayer.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
|
||||
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
|
||||
if (armour != null)
|
||||
{
|
||||
if (armour != null) {
|
||||
if (sourceEntity != null && !source.isMagicDamage() && !source.isProjectile())
|
||||
StatTrackerPhysicalProtect.incrementCounter(armour, amount);
|
||||
|
||||
|
@ -130,36 +103,30 @@ public class StatTrackerHandler
|
|||
if (source.isProjectile())
|
||||
StatTrackerArrowProtect.incrementCounter(armour, amount);
|
||||
}
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
ItemStack chestStack = attackedPlayer.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
|
||||
if (chestStack.getItem() instanceof ItemSentientArmour)
|
||||
{
|
||||
if (chestStack.getItem() instanceof ItemSentientArmour) {
|
||||
ItemSentientArmour armour = (ItemSentientArmour) chestStack.getItem();
|
||||
armour.onPlayerAttacked(chestStack, source, attackedPlayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sourceEntity instanceof EntityPlayer)
|
||||
{
|
||||
if (sourceEntity instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer) sourceEntity;
|
||||
|
||||
// Living Armor Handling
|
||||
if (LivingArmour.hasFullSet(player))
|
||||
{
|
||||
if (LivingArmour.hasFullSet(player)) {
|
||||
ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
|
||||
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
|
||||
if (armour != null)
|
||||
{
|
||||
if (armour != null) {
|
||||
ItemStack mainWeapon = player.getItemStackFromSlot(EntityEquipmentSlot.MAINHAND);
|
||||
|
||||
event.setAmount((float) (event.getAmount() + lastPlayerSwingStrength * armour.getAdditionalDamageOnHit(event.getAmount(), player, attackedEntity, mainWeapon)));
|
||||
|
||||
float amount = Math.min(Utils.getModifiedDamage(attackedEntity, event.getSource(), event.getAmount()), attackedEntity.getHealth());
|
||||
|
||||
if (!source.isProjectile())
|
||||
{
|
||||
if (!source.isProjectile()) {
|
||||
StatTrackerMeleeDamage.incrementCounter(armour, amount);
|
||||
|
||||
if (player.getEntityWorld().getLight(player.getPosition()) <= 9)
|
||||
|
@ -186,19 +153,15 @@ public class StatTrackerHandler
|
|||
|
||||
// Tracks: Experienced
|
||||
@SubscribeEvent(priority = EventPriority.LOW)
|
||||
public void onExperiencePickup(PlayerPickupXpEvent event)
|
||||
{
|
||||
public void onExperiencePickup(PlayerPickupXpEvent event) {
|
||||
EntityPlayer player = event.getEntityPlayer();
|
||||
|
||||
if (LivingArmour.hasFullSet(player))
|
||||
{
|
||||
if (LivingArmour.hasFullSet(player)) {
|
||||
ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
|
||||
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
|
||||
if (armour != null)
|
||||
{
|
||||
if (armour != null) {
|
||||
LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(BloodMagic.MODID + ".upgrade.experienced", chestStack);
|
||||
if (upgrade instanceof LivingArmourUpgradeExperience)
|
||||
{
|
||||
if (upgrade instanceof LivingArmourUpgradeExperience) {
|
||||
double modifier = ((LivingArmourUpgradeExperience) upgrade).getExperienceModifier();
|
||||
double exp = event.getOrb().xpValue * (1 + modifier);
|
||||
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
package WayofTime.bloodmagic.util.handler.event;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import WayofTime.bloodmagic.annot.Handler;
|
||||
import WayofTime.bloodmagic.api.soul.*;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagic;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
|
||||
import WayofTime.bloodmagic.demonAura.PosXY;
|
||||
import WayofTime.bloodmagic.demonAura.WillChunk;
|
||||
import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler;
|
||||
import WayofTime.bloodmagic.entity.projectile.EntitySentientArrow;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
|
@ -25,37 +28,26 @@ import net.minecraftforge.event.world.ChunkDataEvent;
|
|||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
import WayofTime.bloodmagic.annot.Handler;
|
||||
import WayofTime.bloodmagic.api.soul.DemonWillHolder;
|
||||
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||
import WayofTime.bloodmagic.api.soul.IDemonWill;
|
||||
import WayofTime.bloodmagic.api.soul.IDemonWillWeapon;
|
||||
import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler;
|
||||
import WayofTime.bloodmagic.demonAura.PosXY;
|
||||
import WayofTime.bloodmagic.demonAura.WillChunk;
|
||||
import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler;
|
||||
import WayofTime.bloodmagic.entity.projectile.EntitySentientArrow;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
@Handler
|
||||
public class WillHandler
|
||||
{
|
||||
public class WillHandler {
|
||||
|
||||
private final HashMap<Integer, Integer> serverTicks = new HashMap<Integer, Integer>();
|
||||
|
||||
// Adds Will to player
|
||||
@SubscribeEvent
|
||||
public void onItemPickup(EntityItemPickupEvent event)
|
||||
{
|
||||
public void onItemPickup(EntityItemPickupEvent event) {
|
||||
ItemStack stack = event.getItem().getItem();
|
||||
if (stack.getItem() instanceof IDemonWill)
|
||||
{
|
||||
if (stack.getItem() instanceof IDemonWill) {
|
||||
EntityPlayer player = event.getEntityPlayer();
|
||||
EnumDemonWillType pickupType = ((IDemonWill) stack.getItem()).getType(stack);
|
||||
ItemStack remainder = PlayerDemonWillHandler.addDemonWill(player, stack);
|
||||
|
||||
if (remainder == null || ((IDemonWill) stack.getItem()).getWill(pickupType, stack) < 0.0001 || PlayerDemonWillHandler.isDemonWillFull(pickupType, player))
|
||||
{
|
||||
if (remainder == null || ((IDemonWill) stack.getItem()).getWill(pickupType, stack) < 0.0001 || PlayerDemonWillHandler.isDemonWillFull(pickupType, player)) {
|
||||
stack.setCount(0);
|
||||
event.setResult(Event.Result.ALLOW);
|
||||
}
|
||||
|
@ -63,14 +55,11 @@ public class WillHandler
|
|||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onEntityAttacked(LivingDeathEvent event)
|
||||
{
|
||||
if (event.getSource() instanceof EntityDamageSourceIndirect)
|
||||
{
|
||||
public void onEntityAttacked(LivingDeathEvent event) {
|
||||
if (event.getSource() instanceof EntityDamageSourceIndirect) {
|
||||
Entity sourceEntity = event.getSource().getImmediateSource();
|
||||
|
||||
if (sourceEntity instanceof EntitySentientArrow)
|
||||
{
|
||||
if (sourceEntity instanceof EntitySentientArrow) {
|
||||
((EntitySentientArrow) sourceEntity).reimbursePlayer(event.getEntityLiving(), event.getEntityLiving().getMaxHealth());
|
||||
}
|
||||
}
|
||||
|
@ -78,14 +67,12 @@ public class WillHandler
|
|||
|
||||
// Add/Drop Demon Will for Player
|
||||
@SubscribeEvent
|
||||
public void onLivingDrops(LivingDropsEvent event)
|
||||
{
|
||||
public void onLivingDrops(LivingDropsEvent event) {
|
||||
EntityLivingBase attackedEntity = event.getEntityLiving();
|
||||
DamageSource source = event.getSource();
|
||||
Entity entity = source.getTrueSource();
|
||||
|
||||
if (attackedEntity.isPotionActive(RegistrarBloodMagic.SOUL_SNARE) && (attackedEntity instanceof EntityMob || attackedEntity.getEntityWorld().getDifficulty() == EnumDifficulty.PEACEFUL))
|
||||
{
|
||||
if (attackedEntity.isPotionActive(RegistrarBloodMagic.SOUL_SNARE) && (attackedEntity instanceof EntityMob || attackedEntity.getEntityWorld().getDifficulty() == EnumDifficulty.PEACEFUL)) {
|
||||
PotionEffect eff = attackedEntity.getActivePotionEffect(RegistrarBloodMagic.SOUL_SNARE);
|
||||
int lvl = eff.getAmplifier();
|
||||
|
||||
|
@ -94,26 +81,20 @@ public class WillHandler
|
|||
event.getDrops().add(new EntityItem(attackedEntity.getEntityWorld(), attackedEntity.posX, attackedEntity.posY, attackedEntity.posZ, soulStack));
|
||||
}
|
||||
|
||||
if (entity != null && entity instanceof EntityPlayer)
|
||||
{
|
||||
if (entity != null && entity instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer) entity;
|
||||
ItemStack heldStack = player.getHeldItemMainhand();
|
||||
if (heldStack.getItem() instanceof IDemonWillWeapon && !player.getEntityWorld().isRemote)
|
||||
{
|
||||
if (heldStack.getItem() instanceof IDemonWillWeapon && !player.getEntityWorld().isRemote) {
|
||||
IDemonWillWeapon demonWillWeapon = (IDemonWillWeapon) heldStack.getItem();
|
||||
List<ItemStack> droppedSouls = demonWillWeapon.getRandomDemonWillDrop(attackedEntity, player, heldStack, event.getLootingLevel());
|
||||
if (!droppedSouls.isEmpty())
|
||||
{
|
||||
if (!droppedSouls.isEmpty()) {
|
||||
ItemStack remainder;
|
||||
for (ItemStack willStack : droppedSouls)
|
||||
{
|
||||
for (ItemStack willStack : droppedSouls) {
|
||||
remainder = PlayerDemonWillHandler.addDemonWill(player, willStack);
|
||||
|
||||
if (!remainder.isEmpty())
|
||||
{
|
||||
if (!remainder.isEmpty()) {
|
||||
EnumDemonWillType pickupType = ((IDemonWill) remainder.getItem()).getType(remainder);
|
||||
if (((IDemonWill) remainder.getItem()).getWill(pickupType, remainder) >= 0.0001)
|
||||
{
|
||||
if (((IDemonWill) remainder.getItem()).getWill(pickupType, remainder) >= 0.0001) {
|
||||
event.getDrops().add(new EntityItem(attackedEntity.getEntityWorld(), attackedEntity.posX, attackedEntity.posY, attackedEntity.posZ, remainder));
|
||||
}
|
||||
}
|
||||
|
@ -125,24 +106,20 @@ public class WillHandler
|
|||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onServerWorldTick(TickEvent.WorldTickEvent event)
|
||||
{
|
||||
public void onServerWorldTick(TickEvent.WorldTickEvent event) {
|
||||
if (event.world.isRemote)
|
||||
return;
|
||||
|
||||
int dim = event.world.provider.getDimension();
|
||||
if (event.phase == TickEvent.Phase.END)
|
||||
{
|
||||
if (event.phase == TickEvent.Phase.END) {
|
||||
if (!this.serverTicks.containsKey(dim))
|
||||
this.serverTicks.put(dim, 0);
|
||||
|
||||
int ticks = (this.serverTicks.get(dim));
|
||||
|
||||
if (ticks % 20 == 0)
|
||||
{
|
||||
if (ticks % 20 == 0) {
|
||||
CopyOnWriteArrayList<PosXY> dirtyChunks = WorldDemonWillHandler.dirtyChunks.get(dim);
|
||||
if ((dirtyChunks != null) && (dirtyChunks.size() > 0))
|
||||
{
|
||||
if ((dirtyChunks != null) && (dirtyChunks.size() > 0)) {
|
||||
for (PosXY pos : dirtyChunks)
|
||||
event.world.markChunkDirty(new BlockPos(pos.x * 16, 5, pos.y * 16), null);
|
||||
|
||||
|
@ -156,8 +133,7 @@ public class WillHandler
|
|||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void chunkSave(ChunkDataEvent.Save event)
|
||||
{
|
||||
public void chunkSave(ChunkDataEvent.Save event) {
|
||||
int dim = event.getWorld().provider.getDimension();
|
||||
ChunkPos loc = event.getChunk().getPos();
|
||||
|
||||
|
@ -165,8 +141,7 @@ public class WillHandler
|
|||
event.getData().setTag("BloodMagic", nbt);
|
||||
|
||||
WillChunk ac = WorldDemonWillHandler.getWillChunk(dim, loc.x, loc.z);
|
||||
if (ac != null)
|
||||
{
|
||||
if (ac != null) {
|
||||
nbt.setShort("base", ac.getBase());
|
||||
ac.getCurrentWill().writeToNBT(nbt, "current");
|
||||
if (!event.getChunk().isLoaded())
|
||||
|
@ -175,18 +150,15 @@ public class WillHandler
|
|||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void chunkLoad(ChunkDataEvent.Load event)
|
||||
{
|
||||
public void chunkLoad(ChunkDataEvent.Load event) {
|
||||
int dim = event.getWorld().provider.getDimension();
|
||||
if (event.getData().getCompoundTag("BloodMagic").hasKey("base"))
|
||||
{
|
||||
if (event.getData().getCompoundTag("BloodMagic").hasKey("base")) {
|
||||
NBTTagCompound nbt = event.getData().getCompoundTag("BloodMagic");
|
||||
short base = nbt.getShort("base");
|
||||
DemonWillHolder current = new DemonWillHolder();
|
||||
current.readFromNBT(nbt, "current");
|
||||
WorldDemonWillHandler.addWillChunk(dim, event.getChunk(), base, current);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
WorldDemonWillHandler.generateWill(event.getChunk());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,13 +2,11 @@ package WayofTime.bloodmagic.util.helper;
|
|||
|
||||
import java.util.TreeMap;
|
||||
|
||||
public class NumeralHelper
|
||||
{
|
||||
public class NumeralHelper {
|
||||
|
||||
private static final TreeMap<Integer, String> romanNumerals = new TreeMap<Integer, String>();
|
||||
|
||||
static
|
||||
{
|
||||
static {
|
||||
romanNumerals.put(1000, "M");
|
||||
romanNumerals.put(900, "CM");
|
||||
romanNumerals.put(500, "D");
|
||||
|
@ -24,8 +22,7 @@ public class NumeralHelper
|
|||
romanNumerals.put(1, "I");
|
||||
}
|
||||
|
||||
public static String toRoman(int arabic)
|
||||
{
|
||||
public static String toRoman(int arabic) {
|
||||
int convert = romanNumerals.floorKey(arabic);
|
||||
if (arabic == convert)
|
||||
return romanNumerals.get(convert);
|
||||
|
|
|
@ -1,25 +1,19 @@
|
|||
package WayofTime.bloodmagic.util.helper;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import WayofTime.bloodmagic.api.recipe.TartaricForgeRecipe;
|
||||
import WayofTime.bloodmagic.api.registry.AltarRecipeRegistry;
|
||||
import WayofTime.bloodmagic.api.registry.TartaricForgeRecipeRegistry;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
|
||||
public class RecipeHelper
|
||||
{
|
||||
public static IRecipe getRecipeForOutput(ItemStack stack)
|
||||
{
|
||||
for (IRecipe recipe : ForgeRegistries.RECIPES.getValues())
|
||||
{
|
||||
if (recipe != null)
|
||||
{
|
||||
public class RecipeHelper {
|
||||
public static IRecipe getRecipeForOutput(ItemStack stack) {
|
||||
for (IRecipe recipe : ForgeRegistries.RECIPES.getValues()) {
|
||||
if (recipe != null) {
|
||||
ItemStack resultStack = recipe.getRecipeOutput();
|
||||
if (!resultStack.isEmpty())
|
||||
{
|
||||
if (resultStack.getItem() == stack.getItem() && resultStack.getItemDamage() == stack.getItemDamage())
|
||||
{
|
||||
if (!resultStack.isEmpty()) {
|
||||
if (resultStack.getItem() == stack.getItem() && resultStack.getItemDamage() == stack.getItemDamage()) {
|
||||
return recipe;
|
||||
}
|
||||
}
|
||||
|
@ -29,17 +23,12 @@ public class RecipeHelper
|
|||
return null;
|
||||
}
|
||||
|
||||
public static AltarRecipeRegistry.AltarRecipe getAltarRecipeForOutput(ItemStack stack)
|
||||
{
|
||||
for (AltarRecipeRegistry.AltarRecipe recipe : AltarRecipeRegistry.getRecipes().values())
|
||||
{
|
||||
if (recipe != null && !recipe.isFillable())
|
||||
{
|
||||
public static AltarRecipeRegistry.AltarRecipe getAltarRecipeForOutput(ItemStack stack) {
|
||||
for (AltarRecipeRegistry.AltarRecipe recipe : AltarRecipeRegistry.getRecipes().values()) {
|
||||
if (recipe != null && !recipe.isFillable()) {
|
||||
ItemStack resultStack = recipe.getOutput();
|
||||
if (!resultStack.isEmpty())
|
||||
{
|
||||
if (resultStack.getItem() == stack.getItem() && resultStack.getItemDamage() == stack.getItemDamage())
|
||||
{
|
||||
if (!resultStack.isEmpty()) {
|
||||
if (resultStack.getItem() == stack.getItem() && resultStack.getItemDamage() == stack.getItemDamage()) {
|
||||
return recipe;
|
||||
}
|
||||
}
|
||||
|
@ -49,17 +38,12 @@ public class RecipeHelper
|
|||
return null;
|
||||
}
|
||||
|
||||
public static TartaricForgeRecipe getForgeRecipeForOutput(ItemStack stack)
|
||||
{
|
||||
for (TartaricForgeRecipe recipe : TartaricForgeRecipeRegistry.getRecipeList())
|
||||
{
|
||||
if (recipe != null)
|
||||
{
|
||||
public static TartaricForgeRecipe getForgeRecipeForOutput(ItemStack stack) {
|
||||
for (TartaricForgeRecipe recipe : TartaricForgeRecipeRegistry.getRecipeList()) {
|
||||
if (recipe != null) {
|
||||
ItemStack resultStack = recipe.getRecipeOutput();
|
||||
if (!resultStack.isEmpty())
|
||||
{
|
||||
if (resultStack.getItem() == stack.getItem() && resultStack.getItemDamage() == stack.getItemDamage())
|
||||
{
|
||||
if (!resultStack.isEmpty()) {
|
||||
if (resultStack.getItem() == stack.getItem() && resultStack.getItemDamage() == stack.getItemDamage()) {
|
||||
return recipe;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,25 +6,20 @@ import org.apache.commons.lang3.text.WordUtils;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TextHelper
|
||||
{
|
||||
public static String getFormattedText(String string)
|
||||
{
|
||||
public class TextHelper {
|
||||
public static String getFormattedText(String string) {
|
||||
return string.replaceAll("&", "\u00A7");
|
||||
}
|
||||
|
||||
public static String localize(String input, Object... format)
|
||||
{
|
||||
public static String localize(String input, Object... format) {
|
||||
return I18n.translateToLocalFormatted(input, format);
|
||||
}
|
||||
|
||||
public static String localizeEffect(String input, Object... format)
|
||||
{
|
||||
public static String localizeEffect(String input, Object... format) {
|
||||
return getFormattedText(localize(input, format));
|
||||
}
|
||||
|
||||
public static String[] localizeAll(String[] input)
|
||||
{
|
||||
public static String[] localizeAll(String[] input) {
|
||||
String[] ret = new String[input.length];
|
||||
for (int i = 0; i < input.length; i++)
|
||||
ret[i] = localize(input[i]);
|
||||
|
@ -32,8 +27,7 @@ public class TextHelper
|
|||
return ret;
|
||||
}
|
||||
|
||||
public static String[] localizeAllEffect(String[] input)
|
||||
{
|
||||
public static String[] localizeAllEffect(String[] input) {
|
||||
String[] ret = new String[input.length];
|
||||
for (int i = 0; i < input.length; i++)
|
||||
ret[i] = localizeEffect(input[i]);
|
||||
|
@ -41,8 +35,7 @@ public class TextHelper
|
|||
return ret;
|
||||
}
|
||||
|
||||
public static ArrayList<String> localizeAll(List<String> input)
|
||||
{
|
||||
public static ArrayList<String> localizeAll(List<String> input) {
|
||||
ArrayList<String> ret = new ArrayList<String>(input.size());
|
||||
for (int i = 0; i < input.size(); i++)
|
||||
ret.add(i, localize(input.get(i)));
|
||||
|
@ -50,8 +43,7 @@ public class TextHelper
|
|||
return ret;
|
||||
}
|
||||
|
||||
public static ArrayList<String> localizeAllEffect(List<String> input)
|
||||
{
|
||||
public static ArrayList<String> localizeAllEffect(List<String> input) {
|
||||
ArrayList<String> ret = new ArrayList<String>(input.size());
|
||||
for (int i = 0; i < input.size(); i++)
|
||||
ret.add(i, localizeEffect(input.get(i)));
|
||||
|
@ -59,18 +51,15 @@ public class TextHelper
|
|||
return ret;
|
||||
}
|
||||
|
||||
public static String[] cutLongString(String string, int characters)
|
||||
{
|
||||
public static String[] cutLongString(String string, int characters) {
|
||||
return WordUtils.wrap(string, characters, "/cut", false).split("/cut");
|
||||
}
|
||||
|
||||
public static String[] cutLongString(String string)
|
||||
{
|
||||
public static String[] cutLongString(String string) {
|
||||
return cutLongString(string, 30);
|
||||
}
|
||||
|
||||
public static boolean canTranslate(String key)
|
||||
{
|
||||
public static boolean canTranslate(String key) {
|
||||
return I18n.canTranslate(key);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue