Search in sources :

Example 1 with TextComponentString

use of net.minecraft.util.text.TextComponentString in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class EventsCommon method onPlayerTickEvent.

@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onPlayerTickEvent(PlayerTickEvent event) {
    if (!event.player.worldObj.isRemote && event.player != null) {
        EntityPlayerMP p = (EntityPlayerMP) event.player;
        try {
            if (!(p.connection instanceof CustomNetHandlerPlayServer)) {
                p.connection = new CustomNetHandlerPlayServer(p.connection);
            } else {
                CustomNetHandlerPlayServer customNetHandler = (CustomNetHandlerPlayServer) p.connection;
                if (p.interactionManager.getBlockReachDistance() == CustomNetHandlerPlayServer.dummyBlockReachDist && customNetHandler.ticksSinceLastTry == 2) {
                    p.interactionManager.setBlockReachDistance(((CustomNetHandlerPlayServer) p.connection).lastGoodBlockReachDist);
                }
                customNetHandler.ticksSinceLastTry++;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        Double[] pos = lastPositions.get(p);
        if (pos == null) {
            pos = new Double[3];
            lastPositions.put(p, pos);
        }
        try {
            if (pos[0] != p.posX || pos[2] != p.posZ) {
                // Player has moved
                if (Math.abs(p.posX) > 27000000 || Math.abs(p.posZ) > 27000000) {
                    // Player is outside of world border, tp them back
                    p.attemptTeleport(pos[0], pos[1], pos[2]);
                    p.addChatMessage(new TextComponentString("You can't go beyond 27000000 blocks because airships are stored there!"));
                }
            }
        } catch (NullPointerException e) {
            ValkyrienWarfareMod.VWLogger.log(Level.WARNING, "Nullpointer EventsCommon.java:onPlayerTickEvent");
        }
        pos[0] = p.posX;
        pos[1] = p.posY;
        pos[2] = p.posZ;
    }
}
Also used : CustomNetHandlerPlayServer(ValkyrienWarfareBase.Interaction.CustomNetHandlerPlayServer) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) TextComponentString(net.minecraft.util.text.TextComponentString) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 2 with TextComponentString

use of net.minecraft.util.text.TextComponentString in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class EventsCommon method onRightClick.

@SubscribeEvent
public void onRightClick(PlayerInteractEvent.RightClickBlock event) {
    if (!event.getWorld().isRemote) {
        PhysicsWrapperEntity physObj = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(event.getWorld(), event.getPos());
        if (physObj != null) {
            //Bucket fix, probably not that important
            if (event.getEntityPlayer().getHeldItem(event.getHand()) != null && event.getEntityPlayer().getHeldItem(event.getHand()).getItem() instanceof ItemBucket) {
                event.setResult(Result.ALLOW);
                event.setCanceled(false);
            }
            if (ValkyrienWarfareMod.runAirshipPermissions && !(physObj.wrapping.creator.equals(event.getEntityPlayer().entityUniqueID.toString()) || physObj.wrapping.allowedUsers.contains(event.getEntityPlayer().entityUniqueID.toString()))) {
                event.getEntityPlayer().addChatMessage(new TextComponentString("You need to be added to the airship to do that!" + (physObj.wrapping.creator == null || physObj.wrapping.creator.trim().isEmpty() ? " Try using \"/airshipSettings claim\"!" : "")));
                event.setCanceled(true);
                return;
            }
        }
    }
}
Also used : PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) ItemBucket(net.minecraft.item.ItemBucket) TextComponentString(net.minecraft.util.text.TextComponentString) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 3 with TextComponentString

use of net.minecraft.util.text.TextComponentString in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class EventsCommon method onBlockBreak.

@SubscribeEvent
public void onBlockBreak(BlockEvent.BreakEvent event) {
    if (!event.getWorld().isRemote) {
        PhysicsWrapperEntity physObj = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(event.getWorld(), event.getPos());
        if (physObj != null) {
            if (ValkyrienWarfareMod.runAirshipPermissions && !(physObj.wrapping.creator.equals(event.getPlayer().entityUniqueID.toString()) || physObj.wrapping.allowedUsers.contains(event.getPlayer().entityUniqueID.toString()))) {
                event.getPlayer().addChatMessage(new TextComponentString("You need to be added to the airship to do that!" + (physObj.wrapping.creator == null || physObj.wrapping.creator.trim().isEmpty() ? " Try using \"/airshipSettings claim\"!" : "")));
                event.setCanceled(true);
                return;
            }
            if (physObj.wrapping.shipType == ShipType.Oribtal) {
            //Do not let it break
            }
        }
    }
}
Also used : PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) TextComponentString(net.minecraft.util.text.TextComponentString) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 4 with TextComponentString

use of net.minecraft.util.text.TextComponentString in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class TileEntityCannon method setAngle.

/////////////////////////////////////// End of making shit go boom
/////////////////////////////////////// Angle 'n' ammo
public void setAngle(EntityPlayer playerIn, double angle) {
    Angle += angle;
    if (Angle > 15F) {
        Angle = -15F;
    }
    if (Angle < -15F) {
        Angle = 15F;
    }
    playerIn.addChatComponentMessage(new TextComponentString("Extra Y velocity = " + Float.toString(Angle / 100)));
}
Also used : TextComponentString(net.minecraft.util.text.TextComponentString)

Example 5 with TextComponentString

use of net.minecraft.util.text.TextComponentString in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class TileEntityCannon method fireCannon.

public void fireCannon(World worldIn, EntityPlayer playerIn, BlockPos pos, IBlockState state, EnumFacing side) {
    if (CannonReady) {
        firecannon(worldIn, pos, side, state);
        CannonReady = false;
        CannonCooldown = 0;
    } else {
        playerIn.addChatComponentMessage(new TextComponentString("Cannon needs to be loaded!"));
    }
}
Also used : TextComponentString(net.minecraft.util.text.TextComponentString)

Aggregations

TextComponentString (net.minecraft.util.text.TextComponentString)343 EntityPlayer (net.minecraft.entity.player.EntityPlayer)79 ItemStack (net.minecraft.item.ItemStack)68 BlockPos (net.minecraft.util.math.BlockPos)60 ITextComponent (net.minecraft.util.text.ITextComponent)48 TileEntity (net.minecraft.tileentity.TileEntity)41 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)35 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)32 Colony (com.minecolonies.coremod.colony.Colony)26 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)26 IBlockState (net.minecraft.block.state.IBlockState)23 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)21 Style (net.minecraft.util.text.Style)21 IColony (com.minecolonies.api.colony.IColony)19 ClickEvent (net.minecraft.util.text.event.ClickEvent)19 Entity (net.minecraft.entity.Entity)18 Block (net.minecraft.block.Block)17 World (net.minecraft.world.World)17 ArrayList (java.util.ArrayList)16 ActionResult (net.minecraft.util.ActionResult)13