Jump to content

Recommended Posts

Posted

I am trying to make a mod that has a block that affects the movement of a player when they are within a radius of the block. I have found some methods in the forge api, but I can't seem to get anything to work.

 

My code accesses the net.minecraft.world.World methods as well as the net.minecraft.entity.player.EntityPlayer package to access nearby players.

 

My code doesn't do anything, my guess is it just grabs null references for the player/world. I also think the block might not be affecting the player because the code might only run through one time when it is first instantiated into the world.

 

Any thoughts would be helpful, here is the code.

 

protected CustomBlock(Material p_i45394_1_) {
	super(p_i45394_1_);
	this.setBlockName("CustomBlock");
	this.setCreativeTab(CreativeTabs.tabBlock);
	this.setHardness(50);
	this.setResistance(2000);
	this.setBlockTextureName(StringLibrary.MODID + ":dense_block");
	this.setPlayerMovement(1.0D,1.0D,1.0D, 5.0D);
}

private void setPlayerMovement(double moveX, double moveY, double moveZ, double distance) {
	World world = Minecraft.getMinecraft().theWorld;
	TileEntityCamp camp = new TileEntityCamp();
	if(world != null){
		EntityPlayer player = world.getClosestPlayer(camp.xCoord,camp.yCoord,camp.zCoord,distance);
		if(player != null)
		{
			player.isDead = true;
		}
	}

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.