Various Fixes #166

Merged
SenseiKiwi merged 19 commits from master into master 2014-06-26 23:17:34 +00:00
Showing only changes of commit 364ba11f81 - Show all commits

View File

@@ -1,17 +1,10 @@
package StevenDimDoors.mod_pocketDim.tileentities; package StevenDimDoors.mod_pocketDim.tileentities;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.network.PacketDispatcher;
import net.minecraft.block.Block;
import net.minecraft.entity.DataWatcher;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.monster.EntityEnderman; import net.minecraft.entity.monster.EntityEnderman;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@@ -19,12 +12,8 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.INetworkManager; import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.Packet132TileEntityData; import net.minecraft.network.packet.Packet132TileEntityData;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import StevenDimDoors.mod_pocketDim.ServerPacketHandler; import StevenDimDoors.mod_pocketDim.ServerPacketHandler;
import StevenDimDoors.mod_pocketDim.mod_pocketDim; import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.config.DDProperties; import StevenDimDoors.mod_pocketDim.config.DDProperties;
@@ -76,7 +65,6 @@ public class TileEntityRift extends DDTileEntityBase
if (worldObj.getBlockId(xCoord, yCoord, zCoord) == mod_pocketDim.blockRift.blockID) if (worldObj.getBlockId(xCoord, yCoord, zCoord) == mod_pocketDim.blockRift.blockID)
{ {
worldObj.setBlockToAir(xCoord, yCoord, zCoord); worldObj.setBlockToAir(xCoord, yCoord, zCoord);
worldObj.removeBlockTileEntity(xCoord, yCoord, zCoord);
this.invalidate(); this.invalidate();
return; return;
} }
@@ -101,9 +89,9 @@ public class TileEntityRift extends DDTileEntityBase
**/ **/
//This code should execute once every 10 seconds //This code should execute once every 10 seconds
if (updateTimer > 200) if (updateTimer >= 200)
{ {
this.spawnEndermen(); this.spawnEndermen(mod_pocketDim.properties);
this.grow(mod_pocketDim.properties); this.grow(mod_pocketDim.properties);
updateTimer = 0; updateTimer = 0;
} }
@@ -114,8 +102,6 @@ public class TileEntityRift extends DDTileEntityBase
updateTimer++; updateTimer++;
} }
private void clearBlocksOnRift() private void clearBlocksOnRift()
{ {
//clears blocks for the new rending effect //clears blocks for the new rending effect
@@ -138,25 +124,23 @@ public class TileEntityRift extends DDTileEntityBase
} }
} }
private void spawnEndermen() private void spawnEndermen(DDProperties properties)
{ {
if (worldObj.isRemote) if (worldObj.isRemote || !properties.RiftsSpawnEndermenEnabled)
{ {
return; return;
} }
NewDimData dimension = PocketManager.getDimensionData(worldObj); // Ensure that this rift is only spawning one Enderman at a time, to prevent hordes of Endermen
//Ensure that this rift is only spawning one enderman at a time, to prevent hordes of endermen
Entity entity = worldObj.getEntityByID(this.spawnedEndermenID); Entity entity = worldObj.getEntityByID(this.spawnedEndermenID);
if (entity != null && entity instanceof EntityEnderman) if (entity != null && entity instanceof EntityEnderman)
{ {
return; return;
} }
//enderman will only spawn in groups of rifts
if (random.nextInt(MAX_ENDERMAN_SPAWNING_CHANCE) < ENDERMAN_SPAWNING_CHANCE) if (random.nextInt(MAX_ENDERMAN_SPAWNING_CHANCE) < ENDERMAN_SPAWNING_CHANCE)
{ {
// Endermen will only spawn from groups of rifts
if (updateNearestRift()) if (updateNearestRift())
{ {
List<Entity> list = worldObj.getEntitiesWithinAABB(EntityEnderman.class, List<Entity> list = worldObj.getEntitiesWithinAABB(EntityEnderman.class,
@@ -228,8 +212,7 @@ public class TileEntityRift extends DDTileEntityBase
private void calculateOldParticleOffset() private void calculateOldParticleOffset()
{ {
updateNearestRift(); if (updateNearestRift())
if (nearestRiftData != null)
{ {
Point4D location = nearestRiftData.source(); Point4D location = nearestRiftData.source();
this.xOffset = this.xCoord - location.getX(); this.xOffset = this.xCoord - location.getX();
@@ -371,6 +354,7 @@ public class TileEntityRift extends DDTileEntityBase
nbt.setInteger("spawnedEndermenID", this.spawnedEndermenID); nbt.setInteger("spawnedEndermenID", this.spawnedEndermenID);
} }
@Override
public Packet getDescriptionPacket() public Packet getDescriptionPacket()
{ {
if (PocketManager.getLink(xCoord, yCoord, zCoord, worldObj) != null) if (PocketManager.getLink(xCoord, yCoord, zCoord, worldObj) != null)