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

The following are Jave code examples for showing how to use getExtendedProperties() of the net.minecraft.entity.player.EntityPlayer class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: FundamentalChemistry   File: BlockLaserRelay.java   View Source Code Vote up 6 votes
@Override
public boolean onBlockActivated(World world, BlockPos pos,
		IBlockState state, EntityPlayer player, EnumFacing side, float hitX,
		float hitY, float hitZ) 
{
	TileLaserRelay ent = (TileLaserRelay)world.getTileEntity(pos);
	PlayerProperties props = (PlayerProperties)player.getExtendedProperties(PlayerProperties.ID);
		
	if(props != null){
		if(props.p_link != null){ // already linking, try to link to this one
			if(!world.isRemote)
				ent.toggleConnectFrom(props.p_link);
				
			props.p_link = null;
		}
		else{ //not linking, add current coords
			props.p_link = new BlockPos(pos);
		}
	}
	
	return true;
}
 
Example 2
Project: FundamentalChemistry   File: ClientEventHandler.java   View Source Code Vote up 4 votes
@SubscribeEvent
public void onWorldLastRender(RenderWorldLastEvent evt)
{
	World world = Minecraft.getMinecraft().theWorld;
	EntityPlayer player = Minecraft.getMinecraft().thePlayer;
	
   double x = player.lastTickPosX + (player.posX - player.lastTickPosX) * evt.partialTicks;
   double y = player.lastTickPosY + (player.posY - player.lastTickPosY) * evt.partialTicks;
   double z = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * evt.partialTicks;
	
	GlStateManager.pushMatrix();
	GlStateManager.pushAttrib();
	
	GL11.glTranslated(-x, -y, -z);

	GlStateManager.disableTexture2D();
	GlStateManager.disableLighting();
	
	int shade_model = GL11.glGetInteger(GL11.GL_SHADE_MODEL);
	GlStateManager.shadeModel(GL11.GL_SMOOTH);
	
	GL11.glLineWidth(3);

	GL11.glBegin(GL11.GL_LINES);
	
	//display link process
	PlayerProperties props = (PlayerProperties)player.getExtendedProperties(PlayerProperties.ID);

	if(props != null && props.p_link != null 
			&& props.p_link.distanceSq(x,y+1,z) <= FundamentalChemistry.MAX_RELAY_DISTANCE-1f){ //distance check with some margin
		GlStateManager.color(0f,1f,0.5f,1f);
		GL11.glVertex3d(props.p_link.getX()+0.5, props.p_link.getY()+FundamentalChemistry.LASER_HEIGHT, props.p_link.getZ()+0.5);
		GlStateManager.color(0f,0.5f,1f,1f);
		GL11.glVertex3d(x, y+1, z);
	}

	for(TileEntity te : world.loadedTileEntityList){
		if(te instanceof TileLaserRelay){
			TileLaserRelay ent = (TileLaserRelay)te;
			
			// change matrix for absolute coordinates
			BlockPos cpos = ent.getPos();

			for(BlockPos pos : ent.inputs){
				TileEntity ce = te.getWorld().getTileEntity(pos);
				if(ce != null && ce instanceof TileLaserRelay && (player.getPosition().distanceSq(pos.getX(),pos.getY(),pos.getZ()) <= 500 
						|| player.getPosition().distanceSq(cpos.getX(),cpos.getY(),cpos.getZ()) <= 500)){
					//add height shift if it is a circular connections
					TileLaserRelay cent = (TileLaserRelay)ce;
					float shift = 0;
					if(cent.inputs.contains(cpos) && cpos.hashCode() < pos.hashCode())
						shift = 1/16.0f*2;
					
					//draw connection
					GlStateManager.color(0f,0.5f,1f,1f);
					GL11.glVertex3d(cpos.getX()+0.5, cpos.getY()+FundamentalChemistry.LASER_HEIGHT-shift, cpos.getZ()+0.5);
					GlStateManager.color(0f,1f,0.5f,1f);
					GL11.glVertex3d(pos.getX()+0.5, pos.getY()+FundamentalChemistry.LASER_HEIGHT-shift, pos.getZ()+0.5);
				}
			}
		}
	}
	
	GL11.glEnd();
	
	GlStateManager.shadeModel(shade_model);
	
	GlStateManager.enableTexture2D();
	GlStateManager.enableLighting();
	
	GlStateManager.popMatrix();
	GlStateManager.popAttrib();
}
 
Example 3
Project: Ye-Olde-Chat   File: PlayerRoleplayMode.java   View Source Code Vote up 2 votes
/**
 * Returns the players currency instance.
 * @param player
 *        The player to get the currency instance from.
 */
public static final PlayerRoleplayMode get(EntityPlayer player)
{
    return (PlayerRoleplayMode) player.getExtendedProperties(EXT_PROP_NAME);
}