Skip to content

Commit

Permalink
Fixed lilypad spawning
Browse files Browse the repository at this point in the history
  • Loading branch information
dries007 committed Jan 19, 2016
1 parent 661d006 commit 73a086f
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions src/main/java/net/doubledoordev/d3core/util/FMLEventHandler.java
Expand Up @@ -39,6 +39,7 @@
import cpw.mods.fml.relauncher.Side;
import net.doubledoordev.d3core.D3Core;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.IChatComponent;
Expand Down Expand Up @@ -115,23 +116,32 @@ public void playerLoggedInEvent(PlayerEvent.PlayerLoggedInEvent event)
e.printStackTrace();
}
}

if (lilypad) lilypad(event.player);
}

@SubscribeEvent
public void playerRespawnEvent(PlayerEvent.PlayerRespawnEvent event)
{
if (lilypad)
{
World world = event.player.worldObj;
int x = (int)(event.player.posX);
int y = (int)(event.player.posY);
int z = (int)(event.player.posZ);
if (lilypad) lilypad(event.player);
}

if (x < 0) x --;
if (z < 0) z --;
private void lilypad(EntityPlayer player)
{
World world = player.worldObj;
int x = (int)(player.posX);
int y = (int)(player.posY);
int z = (int)(player.posZ);

if (x < 0) x --;
if (z < 0) z --;

while (world.getBlock(x, y, z).getMaterial() == Material.air) y--;
if (world.getBlock(x, y, z).getMaterial() == Material.water) world.setBlock(x, y + 1, z, Blocks.waterlily);
while (world.getBlock(x, y, z).getMaterial() == Material.water) y++;
while (world.getBlock(x, y, z).getMaterial() == Material.air) y--;
if (world.getBlock(x, y, z).getMaterial() == Material.water)
{
world.setBlock(x, y + 1, z, Blocks.waterlily);
player.setPositionAndUpdate(x + 0.5, y + 2, z + 0.5);
}
}
}

0 comments on commit 73a086f

Please sign in to comment.