Java Code Examples for net.minecraft.entity.player.EntityPlayer#getCommandSenderName()

The following examples show how to use net.minecraft.entity.player.EntityPlayer#getCommandSenderName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DataFamiliar.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void equipTick(World world, EntityPlayer player, Aspect aspect) {
    if(world.isRemote) return;

    FamiliarData data = new FamiliarData(player.getCommandSenderName(), aspect.getTag());

    IInventory baublesInv = BaublesApi.getBaubles(player);
    if(baublesInv.getStackInSlot(0) == null) {
        handleUnequip(world, player, aspect);
        return;
    }

    if(familiarControllers.get(player) == null || !playersWithFamiliar.contains(data)) {
        handleEquip(world, player, aspect);
    }

    familiarControllers.get(player).tick();
}
 
Example 2
Source File: RegisteredFamiliarAI_Old.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void tick(int ticksSoFar, World world, EntityPlayer parent, ItemStack itemStack) {
    int rangeInc = ((ItemFamiliar_Old) itemStack.getItem()).getAttackRangeIncrease(itemStack);

    List<EntityLivingBase> lastTargetters = getPotentialTargets(world, parent, rangeInc);
    if(lastTargetters.size() == 0) {
        FamiliarAIController_Old.cleanTargetterList(parent);
        return;
    }
    EntityLivingBase mob = lastTargetters.get(world.rand.nextInt(lastTargetters.size()));
    if(mob.isDead || mob instanceof EntityPlayer) {
        FamiliarAIController_Old.cleanTargetterList(parent);
        return;
    }

    mob.attackEntityFrom(DamageSource.magic, ((ItemFamiliar_Old) itemStack.getItem()).getAttackStrength(itemStack));

    world.playSoundEffect(mob.posX + 0.5, mob.posY + 0.5, mob.posZ + 0.5, "thaumcraft:zap", 0.8F, 1.0F);

    PacketFamiliarBolt bolt = new PacketFamiliarBolt(parent.getCommandSenderName(), (float) mob.posX, (float) mob.posY, (float) mob.posZ, 6, true);
    PacketHandler.INSTANCE.sendToAllAround(bolt, new NetworkRegistry.TargetPoint(mob.worldObj.provider.dimensionId, mob.posX, mob.posY, mob.posZ, 32));
    FamiliarAIController_Old.cleanTargetterList(parent);
}
 
Example 3
Source File: QCraft.java    From qcraft-mod with Apache License 2.0 6 votes vote down vote up
public static void verifyUnverifiedLuggage( EntityPlayer instigator, EntityPlayer player )
{
    String username = player.getCommandSenderName();
    if( s_unverifiedLuggage.containsKey( username ) )
    {
        Set<byte[]> luggageSet = s_unverifiedLuggage.remove( username );

        boolean teleported = false;
        Iterator<byte[]> it = luggageSet.iterator();
        while( it.hasNext() )
        {
            byte[] signedLuggageData = it.next();
            if( unpackLuggage( instigator, player, signedLuggageData, true, teleported, true ) )
            {
                teleported = true;
            }
        }
    }
}
 
Example 4
Source File: FamiliarHandlerClient.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SideOnly(Side.CLIENT)
public static void playerRenderEvent(EntityPlayer player, float partialTicks) {
    String ownerName = player.getCommandSenderName();
    if(!clientFamiliars.containsKey(ownerName)) return;

    ExFamiliarData data = clientFamiliars.get(ownerName);
    PartialEntityFamiliar fam = data.familiar;

    Aspect aspect = Aspect.getAspect(data.data.aspectTag);

    if(ENTITY_WISP == null) ENTITY_WISP = new EntityWisp(new FakeWorld());
    ENTITY_WISP.setType(aspect.getTag());
    ENTITY_WISP.ticksExisted = fam.dummyEntity.ticksExisted;
    GL11.glPushMatrix();
    if(fam.owner == null || fam.owner.get() == null) {
        fam.owner = new WeakReference<EntityPlayer>(player);
    }
    EntityPlayer current = Minecraft.getMinecraft().thePlayer;
    double diffX = fam.renderX - current.posX + player.posX;
    double diffY = fam.renderY - current.posY + player.posY + 0.5;
    double diffZ = fam.renderZ - current.posZ + player.posZ;

    String currentPl = current.getCommandSenderName();
    String otherPl = player.getCommandSenderName();

    if(!currentPl.equals(otherPl)) {
        diffY += 1.32;

        EntityLivingBase entity = Minecraft.getMinecraft().renderViewEntity;
        diffX -= ((entity.posX - entity.lastTickPosX) * partialTicks);
        diffY -= ((entity.posY - entity.lastTickPosY) * partialTicks);
        diffZ -= ((entity.posZ - entity.lastTickPosZ) * partialTicks);
    }

    ItemRenderFamiliar.renderEntityWispFor(fam.owner.get(), ENTITY_WISP, diffX, diffY, diffZ, 0, partialTicks);
    GL11.glPopMatrix();
}
 
Example 5
Source File: DataFamiliar.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void handleEquip(World world, EntityPlayer player, Aspect aspect) {
    if(world.isRemote) return;

    String playerName = player.getCommandSenderName();
    FamiliarData data = new FamiliarData(playerName, aspect.getTag());

    if(!addClientQueue.contains(data)) addClientQueue.add(data);
    if(!playersWithFamiliar.contains(data)) playersWithFamiliar.add(data);
    markDirty();

    if(!familiarControllers.containsKey(player)) {
        FamiliarController controller = new FamiliarController(player);
        familiarControllers.put(player, controller);
    }
}
 
Example 6
Source File: DataFamiliar.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void handleUnequip(World world, EntityPlayer player, Aspect aspect) {
    if(world.isRemote) return;

    String playerName = player.getCommandSenderName();
    FamiliarData data = new FamiliarData(playerName, aspect.getTag());

    if(!removeClientQueue.contains(data)) removeClientQueue.add(data);
    if(playersWithFamiliar.contains(data)) playersWithFamiliar.remove(data);
    markDirty();

    familiarControllers.remove(player);
}
 
Example 7
Source File: TileInfusionClaw.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
public boolean setOwner(EntityPlayer player) {
    World world = getWorldObj();
    if(!world.isRemote && isValidOwner(player)) {
        this.player = player.getCommandSenderName();

        markForUpdate();

        return true;
    }
    return false;
}
 
Example 8
Source File: QCraft.java    From qcraft-mod with Apache License 2.0 5 votes vote down vote up
public static void addUnverifiedLuggage( EntityPlayer player, byte[] luggage )
{
    String username = player.getCommandSenderName();
    if( !s_unverifiedLuggage.containsKey( username ) )
    {
        s_unverifiedLuggage.put( username, new HashSet<byte[]>() );
    }

    Set<byte[]> luggageSet = s_unverifiedLuggage.get( username );
    if( !luggageSet.contains( luggage ) )
    {
        luggageSet.add( luggage );
    }
}
 
Example 9
Source File: QCraft.java    From qcraft-mod with Apache License 2.0 5 votes vote down vote up
public static void clearUnverifiedLuggage( EntityPlayer player )
{
    String username = player.getCommandSenderName();
    if( s_unverifiedLuggage.containsKey( username ) )
    {
        s_unverifiedLuggage.remove( username );
    }
}
 
Example 10
Source File: SetPlayerModelMessage.java    From Et-Futurum with The Unlicense 4 votes vote down vote up
public SetPlayerModelMessage(EntityPlayer player, boolean isAlex) {
	playerName = player.getCommandSenderName();
	this.isAlex = isAlex;
}
 
Example 11
Source File: WirelessPart.java    From WirelessRedstone with MIT License 4 votes vote down vote up
public void setupPlacement(EntityPlayer player, int side) {
    setSide(side ^ 1);
    setRotation(Rotation.getSidedRotation(player, side) ^ 2);
    owner = player.getCommandSenderName();
}
 
Example 12
Source File: EntityDrone.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
public EntityDrone(World world, EntityPlayer player){
    this(world);
    playerUUID = player.getGameProfile().getId().toString();
    playerName = player.getCommandSenderName();
}
 
Example 13
Source File: TileEntityPIM.java    From OpenPeripheral-Addons with MIT License 4 votes vote down vote up
@Override
public String getInventoryName() {
	EntityPlayer player = getPlayer();
	return player != null? player.getCommandSenderName() : "pim";
}
 
Example 14
Source File: TileEntityDisplayPedestal.java    From Artifacts with MIT License 4 votes vote down vote up
@Override
public boolean isUseableByPlayer(EntityPlayer entityplayer) {
	boolean sendNamePacket = false;
	
	if(entityplayer.worldObj.isRemote) {
		return false;
	}
	
	if( (ownerName == null || ownerName.equals("")) && (ownerUUID == null || ownerUUID.equals(new UUID(0, 0))) ) {
		ownerName = entityplayer.getCommandSenderName();
		ownerUUID = entityplayer.getUniqueID();
		this.markDirty();
		sendNamePacket = true;
	}
	
	if(ownerName.equals(entityplayer.getCommandSenderName()) && (ownerName == null || !ownerUUID.equals(entityplayer.getUniqueID()))) {
		ownerUUID = entityplayer.getUniqueID();
		this.markDirty();
	}
	
	if((ownerName == null || !ownerName.equals(entityplayer.getCommandSenderName())) && ownerUUID.equals(entityplayer.getUniqueID())) {
		ownerName = entityplayer.getCommandSenderName();
		this.markDirty();
		sendNamePacket = true;
	}
	
	if(sendNamePacket) {
		PacketBuffer out = new PacketBuffer(Unpooled.buffer());
		out.writeInt(PacketHandlerClient.PEDESTAL);
		out.writeInt(xCoord);
		out.writeInt(yCoord);
		out.writeInt(zCoord);
		out.writeInt(ownerName.length());
		for(int i = 0; i < ownerName.length(); i++) {
			out.writeChar(ownerName.charAt(i));
		}
		SToCMessage namePacket = new SToCMessage(out);
		DragonArtifacts.artifactNetworkWrapper.sendToAll(namePacket);
	}
	
	if(!(ownerName.equals(entityplayer.getCommandSenderName()) && ownerUUID.equals(entityplayer.getUniqueID()))) {
		return false;
	}
	
	return worldObj.getTileEntity(xCoord, yCoord, zCoord) == this && entityplayer.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64;
}