Merge remote-tracking branch 'upstream/master'

This commit is contained in:
SenseiKiwi 2014-01-22 04:50:51 -04:00
commit 1971b97dc4
2 changed files with 58 additions and 32 deletions

View file

@ -223,7 +223,7 @@ public class BlockRift extends Block implements ITileEntityProvider
{ {
return; return;
} }
if(worldObj.rand.nextBoolean()) if(worldObj.rand.nextInt(7)==0)
{ {
ItemStack thread = new ItemStack(mod_pocketDim.itemWorldThread,1); ItemStack thread = new ItemStack(mod_pocketDim.itemWorldThread,1);
@ -251,6 +251,14 @@ public class BlockRift extends Block implements ITileEntityProvider
} }
} }
/**
* Lets pistons push through rifts, destroying them
*/
@Override
public int getMobilityFlag()
{
return 1;
}
/** /**
* regulates the render effect, especially when multiple rifts start to link up. Has 3 main parts- Grows toward and away from nearest rft, bends toward it, and a randomization function * regulates the render effect, especially when multiple rifts start to link up. Has 3 main parts- Grows toward and away from nearest rft, bends toward it, and a randomization function

View file

@ -7,6 +7,9 @@ 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.block.Block;
import net.minecraft.entity.DataWatcher; import net.minecraft.entity.DataWatcher;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
@ -43,8 +46,8 @@ public class TileEntityRift extends TileEntity
private static Random random = new Random(); private static Random random = new Random();
private int age = 0; private int age = 0;
private int count = 0; private int updateTimer = 0;
private int count2 = 0; private int riftCloseTimer = 0;
public int xOffset = 0; public int xOffset = 0;
public int yOffset = 0; public int yOffset = 0;
public int zOffset = 0; public int zOffset = 0;
@ -59,13 +62,18 @@ public class TileEntityRift extends TileEntity
@Override @Override
public void updateEntity() public void updateEntity()
{ {
//Invalidate this tile entity if it shouldn't exist //Determines if rift should render white closing particles and spread closing effect to other rifts nearby
if (!this.worldObj.isRemote && PocketManager.getLink(xCoord, yCoord, zCoord, worldObj.provider.dimensionId) == null) if (this.shouldClose)
{
closeRift();
}
else if( PocketManager.getLink(xCoord, yCoord, zCoord, worldObj.provider.dimensionId) == null)
{ {
this.invalidate(); this.invalidate();
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;
} }
@ -73,6 +81,7 @@ public class TileEntityRift extends TileEntity
if (worldObj.getBlockId(xCoord, yCoord, zCoord) != mod_pocketDim.blockRift.blockID) if (worldObj.getBlockId(xCoord, yCoord, zCoord) != mod_pocketDim.blockRift.blockID)
{ {
worldObj.removeBlockTileEntity(xCoord, yCoord, zCoord);
this.invalidate(); this.invalidate();
return; return;
} }
@ -89,20 +98,19 @@ public class TileEntityRift extends TileEntity
**/ **/
//This code should execute once every 10 seconds //This code should execute once every 10 seconds
count++; if (updateTimer > 200)
if (count > 200)
{ {
this.spawnEndermen(); this.spawnEndermen();
this.calculateOldParticleOffset(); //this also calculates the distance for the particle stuff.
this.grow(mod_pocketDim.properties); this.grow(mod_pocketDim.properties);
count = 0; updateTimer = 0;
} }
else if(updateTimer==0)
//Determines if rift should render white closing particles and spread closing effect to other rifts nearby
if (this.shouldClose)
{ {
closeRift(); this.calculateOldParticleOffset(); //this also calculates the distance for the particle stuff.
} }
updateTimer++;
} }
@Override @Override
@ -181,7 +189,7 @@ public class TileEntityRift extends TileEntity
private void closeRift() private void closeRift()
{ {
NewDimData dimension = PocketManager.getDimensionData(worldObj); NewDimData dimension = PocketManager.getDimensionData(worldObj);
if (count2 == 20) if (riftCloseTimer == 20)
{ {
ArrayList<DimLink> rifts= dimension.findRiftsInRange(worldObj, 6, xCoord, yCoord, zCoord); ArrayList<DimLink> rifts= dimension.findRiftsInRange(worldObj, 6, xCoord, yCoord, zCoord);
if (rifts.size()>0) if (rifts.size()>0)
@ -190,30 +198,31 @@ public class TileEntityRift extends TileEntity
{ {
Point4D location = riftToClose.source(); Point4D location = riftToClose.source();
TileEntityRift rift = (TileEntityRift) worldObj.getBlockTileEntity(location.getX(), location.getY(), location.getZ()); TileEntityRift rift = (TileEntityRift) worldObj.getBlockTileEntity(location.getX(), location.getY(), location.getZ());
if (rift != null&&rift.shouldClose!=true) if (rift != null)
{ {
rift.shouldClose = true; rift.shouldClose = true;
rift.onInventoryChanged(); rift.onInventoryChanged();
} }
} }
} }
} }
if (count2 > 40) if (riftCloseTimer > 40)
{ {
this.invalidate(); this.invalidate();
if (dimension.getLink(xCoord, yCoord, zCoord) != null) if(!this.worldObj.isRemote)
{ {
if(!this.worldObj.isRemote) DimLink link = PocketManager.getLink(this.xCoord, this.yCoord, this.zCoord, worldObj);
if(link!=null)
{ {
dimension.deleteLink(xCoord, yCoord, zCoord); dimension.deleteLink(link);
} }
worldObj.playSound(xCoord, yCoord, zCoord, "mods.DimDoors.sfx.riftClose", (float) .7, 1, true);
worldObj.setBlockToAir(xCoord, yCoord, zCoord);
} }
worldObj.setBlockToAir(xCoord, yCoord, zCoord);
worldObj.playSound(xCoord, yCoord, zCoord, "mods.DimDoors.sfx.riftClose", (float) .7, 1, true);
this.worldObj.removeBlockTileEntity(xCoord, yCoord, zCoord);
return;
} }
count2++; riftCloseTimer++;
} }
private void calculateOldParticleOffset() private void calculateOldParticleOffset()
@ -308,7 +317,7 @@ public class TileEntityRift extends TileEntity
public void grow(DDProperties properties) public void grow(DDProperties properties)
{ {
if (worldObj.isRemote || hasGrownRifts || !properties.RiftSpreadEnabled if (worldObj.isRemote || hasGrownRifts || !properties.RiftSpreadEnabled
|| random.nextInt(MAX_RIFT_SPREAD_CHANCE) < RIFT_SPREAD_CHANCE) || random.nextInt(MAX_RIFT_SPREAD_CHANCE) < RIFT_SPREAD_CHANCE || this.shouldClose)
{ {
return; return;
} }
@ -345,7 +354,16 @@ public class TileEntityRift extends TileEntity
MovingObjectPosition hit = worldObj.clip(position, spreadTarget, false); MovingObjectPosition hit = worldObj.clip(position, spreadTarget, false);
if (hit == null || !mod_pocketDim.blockRift.isBlockImmune(worldObj, hit.blockX, hit.blockY, hit.blockZ)) if (hit == null || !mod_pocketDim.blockRift.isBlockImmune(worldObj, hit.blockX, hit.blockY, hit.blockZ))
{ {
dimension.createChildLink(x, y, z, link); if(hit!=null)
{
dimension.createChildLink(hit.blockX, hit.blockY, hit.blockZ, link);
this.worldObj.setBlock(hit.blockX, hit.blockY, hit.blockZ, mod_pocketDim.blockRift.blockID);
}
else
{
dimension.createChildLink(x,y,z,link);
this.worldObj.setBlock(x,y,z, mod_pocketDim.blockRift.blockID);
}
hasGrownRifts = true; hasGrownRifts = true;
break; break;
} }
@ -366,8 +384,8 @@ public class TileEntityRift extends TileEntity
{ {
super.readFromNBT(nbt); super.readFromNBT(nbt);
this.renderingCenters = new HashMap<Integer, double[]>(); this.renderingCenters = new HashMap<Integer, double[]>();
this.count = nbt.getInteger("count"); this.updateTimer = nbt.getInteger("count");
this.count2 = nbt.getInteger("count2"); this.riftCloseTimer = nbt.getInteger("count2");
this.xOffset = nbt.getInteger("xOffset"); this.xOffset = nbt.getInteger("xOffset");
this.yOffset = nbt.getInteger("yOffset"); this.yOffset = nbt.getInteger("yOffset");
this.zOffset = nbt.getInteger("zOffset"); this.zOffset = nbt.getInteger("zOffset");
@ -382,8 +400,8 @@ public class TileEntityRift extends TileEntity
{ {
super.writeToNBT(nbt); super.writeToNBT(nbt);
nbt.setInteger("age", this.age); nbt.setInteger("age", this.age);
nbt.setInteger("count", this.count); nbt.setInteger("count", this.updateTimer);
nbt.setInteger("count2", this.count2); nbt.setInteger("count2", this.riftCloseTimer);
nbt.setBoolean("grownRifts",this.hasGrownRifts); nbt.setBoolean("grownRifts",this.hasGrownRifts);
nbt.setInteger("xOffset", this.xOffset); nbt.setInteger("xOffset", this.xOffset);
nbt.setInteger("yOffset", this.yOffset); nbt.setInteger("yOffset", this.yOffset);