THE UPDATE
Merging months of dev work into master. The update is playable, but untested.
This commit is contained in:
@@ -3,7 +3,7 @@ package StevenDimDoors.mod_pocketDim.ticking;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.core.DDTeleporter;
|
||||
import cpw.mods.fml.common.ITickHandler;
|
||||
import cpw.mods.fml.common.TickType;
|
||||
|
||||
@@ -43,9 +43,9 @@ public class CommonTickHandler implements ITickHandler, IRegularTickSender
|
||||
|
||||
//TODO: Stuck this in here because it's already rather hackish.
|
||||
//We should standardize this as an IRegularTickReceiver in the future. ~SenseiKiwi
|
||||
if (mod_pocketDim.teleTimer > 0)
|
||||
if (DDTeleporter.cooldown > 0)
|
||||
{
|
||||
mod_pocketDim.teleTimer--;
|
||||
DDTeleporter.cooldown--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
185
StevenDimDoors/mod_pocketDim/ticking/LimboDecay.java
Normal file
185
StevenDimDoors/mod_pocketDim/ticking/LimboDecay.java
Normal file
@@ -0,0 +1,185 @@
|
||||
package StevenDimDoors.mod_pocketDim.ticking;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.world.ChunkCoordIntPair;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
|
||||
/**
|
||||
* Provides methods for applying Limbo decay. Limbo decay refers to the effect that most blocks placed in Limbo
|
||||
* naturally change into stone, then cobble, then gravel, and finally Unraveled Fabric as time passes.
|
||||
*/
|
||||
public class LimboDecay implements IRegularTickReceiver {
|
||||
|
||||
private static final int MAX_DECAY_SPREAD_CHANCE = 100;
|
||||
private static final int DECAY_SPREAD_CHANCE = 50;
|
||||
private static final int CHUNK_SIZE = 16;
|
||||
private static final int SECTION_HEIGHT = 16;
|
||||
private static final int LIMBO_DECAY_INTERVAL = 10; //Apply spread decay every 10 ticks
|
||||
|
||||
//Provides a reversed list of the block IDs that blocks cycle through during decay.
|
||||
private final int[] decaySequence;
|
||||
|
||||
private final Random random;
|
||||
private final DDProperties properties;
|
||||
private final int[] blocksImmuneToDecay;
|
||||
|
||||
public LimboDecay(IRegularTickSender tickSender, DDProperties properties)
|
||||
{
|
||||
decaySequence = new int[] {
|
||||
properties.LimboBlockID,
|
||||
Block.gravel.blockID,
|
||||
Block.cobblestone.blockID,
|
||||
Block.stone.blockID
|
||||
};
|
||||
|
||||
blocksImmuneToDecay = new int[] {
|
||||
properties.LimboBlockID,
|
||||
properties.PermaFabricBlockID,
|
||||
properties.TransientDoorID,
|
||||
properties.DimensionalDoorID,
|
||||
properties.WarpDoorID,
|
||||
properties.RiftBlockID,
|
||||
properties.UnstableDoorID
|
||||
};
|
||||
|
||||
this.properties = properties;
|
||||
this.random = new Random();
|
||||
tickSender.registerForTicking(this, LIMBO_DECAY_INTERVAL, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies fast Limbo decay periodically.
|
||||
*/
|
||||
@Override
|
||||
public void notifyTick()
|
||||
{
|
||||
applyRandomFastDecay();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the blocks orthogonally around a given location (presumably the location of an Unraveled Fabric block)
|
||||
* and applies Limbo decay to them. This gives the impression that decay spreads outward from Unraveled Fabric.
|
||||
*/
|
||||
public void applySpreadDecay(World world, int x, int y, int z)
|
||||
{
|
||||
//Check if we randomly apply decay spread or not. This can be used to moderate the frequency of
|
||||
//full spread decay checks, which can also shift its performance impact on the game.
|
||||
if (random.nextInt(MAX_DECAY_SPREAD_CHANCE) < DECAY_SPREAD_CHANCE)
|
||||
{
|
||||
//Apply decay to the blocks above, below, and on all four sides.
|
||||
//World.getBlockId() implements bounds checking, so we don't have to worry about reaching out of the world
|
||||
decayBlock(world, x - 1, y, z);
|
||||
decayBlock(world, x + 1, y, z);
|
||||
decayBlock(world, x, y, z - 1);
|
||||
decayBlock(world, x, y, z + 1);
|
||||
decayBlock(world, x, y - 1, z);
|
||||
decayBlock(world, x, y + 1, z);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Picks random blocks from each active chunk in Limbo and, if decay is applicable, converts them directly to Unraveled Fabric.
|
||||
* This decay method is designed to stop players from avoiding Limbo decay by building floating structures.
|
||||
*/
|
||||
private void applyRandomFastDecay()
|
||||
{
|
||||
int x, y, z;
|
||||
int sectionY;
|
||||
int limboHeight;
|
||||
World limbo = DimensionManager.getWorld(properties.LimboDimensionID);
|
||||
|
||||
if (limbo != null)
|
||||
{
|
||||
limboHeight = limbo.getHeight();
|
||||
|
||||
//Obtain the coordinates of active chunks in Limbo. For each section of each chunk,
|
||||
//pick a random block and try to apply fast decay.
|
||||
for (Object coordObject : limbo.activeChunkSet)
|
||||
{
|
||||
ChunkCoordIntPair chunkCoord = (ChunkCoordIntPair) coordObject;
|
||||
|
||||
//Loop through each chunk section and fast-decay a random block
|
||||
//Apply the changes using the world object instead of directly to the chunk so that clients are always notified.
|
||||
for (sectionY = 0; sectionY < limboHeight; sectionY += SECTION_HEIGHT)
|
||||
{
|
||||
x = chunkCoord.chunkXPos * CHUNK_SIZE + random.nextInt(CHUNK_SIZE);
|
||||
z = chunkCoord.chunkZPos * CHUNK_SIZE + random.nextInt(CHUNK_SIZE);
|
||||
y = sectionY + random.nextInt(SECTION_HEIGHT);
|
||||
decayBlockFast(limbo, x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a block can be decayed and, if so, changes it directly into Unraveled Fabric.
|
||||
*/
|
||||
private boolean decayBlockFast(World world, int x, int y, int z)
|
||||
{
|
||||
int blockID = world.getBlockId(x, y, z);
|
||||
if (canDecayBlock(blockID))
|
||||
{
|
||||
world.setBlock(x, y, z, properties.LimboBlockID);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a block can be decayed and, if so, changes it to the next block ID along the decay sequence.
|
||||
*/
|
||||
private boolean decayBlock(World world, int x, int y, int z)
|
||||
{
|
||||
int index;
|
||||
int blockID = world.getBlockId(x, y, z);
|
||||
if (canDecayBlock(blockID))
|
||||
{
|
||||
//Loop over the block IDs that decay can go through.
|
||||
//Find an index matching the current blockID, if any.
|
||||
for (index = 0; index < decaySequence.length; index++)
|
||||
{
|
||||
if (decaySequence[index] == blockID)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//Since the decay sequence is a reversed list, the block ID in the index before our match
|
||||
//is the block ID we should change this block into. A trick in this approach is that if
|
||||
//we loop over the array without finding a match, then (index - 1) will contain the
|
||||
//last ID in the array, which is the first one that all blocks decay into.
|
||||
//We assume that Unraveled Fabric is NOT decayable. Otherwise, this will go out of bounds!
|
||||
|
||||
world.setBlock(x, y, z, decaySequence[index - 1]);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a block can decay. We will not decay air, certain DD blocks, or containers.
|
||||
*/
|
||||
private boolean canDecayBlock(int blockID)
|
||||
{
|
||||
if (blockID == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int k = 0; k < blocksImmuneToDecay.length; k++)
|
||||
{
|
||||
if (blockID == blocksImmuneToDecay[k])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Block block = Block.blocksList[blockID];
|
||||
return (block == null || !(block instanceof BlockContainer));
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package StevenDimDoors.mod_pocketDim.ticking;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.GameRules;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.DimData;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.yCoordHelper;
|
||||
import StevenDimDoors.mod_pocketDim.util.ChunkLocation;
|
||||
|
||||
public class LimboGatewayGenerator implements IRegularTickReceiver
|
||||
{
|
||||
|
||||
@Override
|
||||
public void notifyTick()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,12 +9,14 @@ import net.minecraft.entity.monster.IMob;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.LinkData;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.core.DDTeleporter;
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
import StevenDimDoors.mod_pocketDim.world.LimboProvider;
|
||||
import StevenDimDoors.mod_pocketDim.world.PocketProvider;
|
||||
|
||||
@@ -24,7 +26,7 @@ public class MobMonolith extends EntityFlying implements IMob
|
||||
float soundTime = 0;
|
||||
int aggro = 0;
|
||||
byte textureState = 0;
|
||||
|
||||
|
||||
float scaleFactor = 0;
|
||||
int aggroMax;
|
||||
int destX=0;
|
||||
@@ -86,16 +88,14 @@ public class MobMonolith extends EntityFlying implements IMob
|
||||
@Override
|
||||
public void onEntityUpdate()
|
||||
{
|
||||
if(!(this.worldObj.provider instanceof LimboProvider ||this.worldObj.provider instanceof PocketProvider))
|
||||
if (!(this.worldObj.provider instanceof LimboProvider || this.worldObj.provider instanceof PocketProvider))
|
||||
{
|
||||
this.setDead();
|
||||
}
|
||||
|
||||
|
||||
byte b0 = this.dataWatcher.getWatchableObjectByte(16);
|
||||
|
||||
this.texture="/mods/DimDoors/textures/mobs/Monolith"+b0+".png";
|
||||
|
||||
|
||||
super.onEntityUpdate();
|
||||
|
||||
if (this.isEntityAlive() && this.isEntityInsideOpaqueBlock())
|
||||
@@ -103,12 +103,9 @@ public class MobMonolith extends EntityFlying implements IMob
|
||||
this.setDead();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
EntityPlayer entityPlayer = this.worldObj.getClosestPlayerToEntity(this, 30);
|
||||
|
||||
if(entityPlayer != null)
|
||||
if (entityPlayer != null)
|
||||
{
|
||||
if(this.soundTime<=0)
|
||||
{
|
||||
@@ -116,83 +113,54 @@ public class MobMonolith extends EntityFlying implements IMob
|
||||
this.soundTime=100;
|
||||
}
|
||||
|
||||
|
||||
|
||||
this.faceEntity(entityPlayer, 1, 1);
|
||||
|
||||
if(shouldAttackPlayer(entityPlayer))
|
||||
if (shouldAttackPlayer(entityPlayer))
|
||||
{
|
||||
{
|
||||
|
||||
}
|
||||
if(aggro<470)
|
||||
if (aggro<470)
|
||||
{
|
||||
if(rand.nextInt(11)>this.textureState||this.aggro>=300||rand.nextInt(13)>this.textureState&&this.aggroMax>this.aggro)
|
||||
if (rand.nextInt(11)>this.textureState||this.aggro>=300||rand.nextInt(13)>this.textureState&&this.aggroMax>this.aggro)
|
||||
{
|
||||
aggro++;
|
||||
}
|
||||
|
||||
|
||||
if(this.worldObj.provider instanceof PocketProvider||this.worldObj.getClosestPlayerToEntity(this, 5)!=null)
|
||||
if (this.worldObj.provider instanceof PocketProvider||this.worldObj.getClosestPlayerToEntity(this, 5)!=null)
|
||||
{
|
||||
|
||||
aggro++;
|
||||
aggro++;
|
||||
|
||||
if(rand.nextBoolean())
|
||||
if (rand.nextBoolean())
|
||||
{
|
||||
aggro++;
|
||||
}
|
||||
|
||||
}
|
||||
if(aggro>430&&this.soundTime<100)
|
||||
if (aggro>430&&this.soundTime<100)
|
||||
{
|
||||
//this.worldObj.playSoundAtEntity(entityPlayer,"mods.DimDoors.sfx.tearing",2, 1);
|
||||
this.worldObj.playSoundEffect(entityPlayer.posX, entityPlayer.posY, entityPlayer.posZ,"mods.DimDoors.sfx.tearing",2F, 1F);
|
||||
|
||||
this.soundTime=100;
|
||||
|
||||
}
|
||||
if(aggro>445&&this.soundTime<200)
|
||||
if (aggro>445&&this.soundTime<200)
|
||||
{
|
||||
//this.worldObj.playSoundAtEntity(entityPlayer,"mods.DimDoors.sfx.tearing",5, 1);
|
||||
this.worldObj.playSoundEffect(entityPlayer.posX, entityPlayer.posY, entityPlayer.posZ,"mods.DimDoors.sfx.tearing",5F, 1F);
|
||||
|
||||
this.soundTime=200;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
else if(!this.worldObj.isRemote&&!entityPlayer.capabilities.isCreativeMode)
|
||||
else if (!this.worldObj.isRemote && !entityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
LinkData link = new LinkData(this.worldObj.provider.dimensionId, properties.LimboDimensionID, (int)this.posX, (int)this.posY, (int)this.posZ, (int)this.posX+rand.nextInt(500)-250, (int)this.posY+500, (int)this.posZ+rand.nextInt(500)-250, false,0);
|
||||
|
||||
dimHelper.instance.traverseDimDoor(worldObj, link, entityPlayer);
|
||||
this.aggro=0;
|
||||
|
||||
entityPlayer.worldObj.playSoundAtEntity(entityPlayer,"mods.DimDoors.sfx.crack",13, 1);
|
||||
ChunkCoordinates coords = LimboProvider.getLimboSkySpawn(entityPlayer.worldObj.rand);
|
||||
Point4D destination = new Point4D((int) (coords.posX+entityPlayer.posX), coords.posY, (int) (coords.posZ+entityPlayer.posZ ), mod_pocketDim.properties.LimboDimensionID);
|
||||
DDTeleporter.teleportEntity(entityPlayer, destination, false);
|
||||
|
||||
|
||||
|
||||
|
||||
this.aggro = 0;
|
||||
entityPlayer.worldObj.playSoundAtEntity(entityPlayer,"mods.DimDoors.sfx.crack",13, 1);
|
||||
}
|
||||
if(!(this.worldObj.provider instanceof LimboProvider || this.worldObj.getClosestPlayerToEntity(this, 5)!=null)||this.aggro>300)
|
||||
if (!(this.worldObj.provider instanceof LimboProvider || this.worldObj.getClosestPlayerToEntity(this, 5) != null) || this.aggro > 300)
|
||||
{
|
||||
|
||||
for (int i = 0; i < -1+this.textureState/2; ++i)
|
||||
{
|
||||
entityPlayer.worldObj.spawnParticle("portal", entityPlayer.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, entityPlayer.posY + this.rand.nextDouble() * (double)entityPlayer.height - 0.75D, entityPlayer.posZ + (this.rand.nextDouble() - 0.5D) * (double)entityPlayer.width, (this.rand.nextDouble() - 0.5D) * 2.0D, -this.rand.nextDouble(), (this.rand.nextDouble() - 0.5D) * 2.0D);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -205,12 +173,9 @@ public class MobMonolith extends EntityFlying implements IMob
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if(aggro>0)
|
||||
{
|
||||
aggro--;
|
||||
@@ -221,44 +186,23 @@ public class MobMonolith extends EntityFlying implements IMob
|
||||
}
|
||||
}
|
||||
}
|
||||
if(soundTime>=0)
|
||||
if (soundTime>=0)
|
||||
{
|
||||
soundTime--;
|
||||
}
|
||||
|
||||
|
||||
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
this.textureState= (byte) (this.aggro/25);
|
||||
if(!this.worldObj.isRemote)
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
|
||||
this.dataWatcher.updateObject(16, Byte.valueOf(this.textureState));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private boolean shouldAttackPlayer(EntityPlayer par1EntityPlayer)
|
||||
{
|
||||
return par1EntityPlayer.canEntityBeSeen(this);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private boolean isCourseTraversable(double par1, double par3, double par5, double par7)
|
||||
{
|
||||
double d4 = (par1 - this.posX) / par7;
|
||||
@@ -275,9 +219,9 @@ public class MobMonolith extends EntityFlying implements IMob
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean attackEntityFrom(DamageSource par1DamageSource, int par2)
|
||||
{
|
||||
if(!(par1DamageSource==DamageSource.inWall))
|
||||
@@ -286,6 +230,7 @@ public class MobMonolith extends EntityFlying implements IMob
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void faceEntity(Entity par1Entity, float par2, float par3)
|
||||
{
|
||||
double d0 = par1Entity.posX - this.posX;
|
||||
@@ -311,7 +256,6 @@ public class MobMonolith extends EntityFlying implements IMob
|
||||
this.rotationYaw = f2;
|
||||
this.rotationYawHead=f2;
|
||||
this.renderYawOffset=this.rotationYaw;
|
||||
|
||||
}
|
||||
|
||||
private float updateRotation(float par1, float par2, float par3)
|
||||
@@ -336,8 +280,6 @@ public class MobMonolith extends EntityFlying implements IMob
|
||||
return 0.0F;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
super.writeEntityToNBT(par1NBTTagCompound);
|
||||
@@ -346,9 +288,8 @@ public class MobMonolith extends EntityFlying implements IMob
|
||||
par1NBTTagCompound.setInteger("aggroMax", this.aggroMax);
|
||||
par1NBTTagCompound.setByte("textureState", this.textureState);
|
||||
par1NBTTagCompound.setFloat("scaleFactor", this.scaleFactor);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
@@ -358,31 +299,27 @@ public class MobMonolith extends EntityFlying implements IMob
|
||||
this.aggroMax = par1NBTTagCompound.getInteger("aggroMax");
|
||||
this.textureState = par1NBTTagCompound.getByte("textureState");
|
||||
this.scaleFactor = par1NBTTagCompound.getFloat("scaleFactor");
|
||||
|
||||
}
|
||||
public boolean getCanSpawnHere()
|
||||
{
|
||||
List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this,AxisAlignedBB.getBoundingBox( this.posX-15, posY-4, this.posZ-15, this.posX+15, this.posY+15, this.posZ+15));
|
||||
|
||||
if(this.worldObj.provider.dimensionId==DDProperties.instance().LimboDimensionID)
|
||||
{
|
||||
if(list.size()>0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
else if(this.worldObj.provider instanceof PocketProvider)
|
||||
{
|
||||
if(list.size()>5||this.worldObj.canBlockSeeTheSky((int)this.posX, (int)this.posY, (int)this.posZ))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return this.worldObj.checkNoEntityCollision(this.boundingBox) && this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox).isEmpty() && !this.worldObj.isAnyLiquid(this.boundingBox);
|
||||
}
|
||||
|
||||
public boolean getCanSpawnHere()
|
||||
{
|
||||
List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, AxisAlignedBB.getBoundingBox( this.posX-15, posY-4, this.posZ-15, this.posX+15, this.posY+15, this.posZ+15));
|
||||
|
||||
if(this.worldObj.provider.dimensionId==DDProperties.instance().LimboDimensionID)
|
||||
{
|
||||
if(list.size()>0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else if(this.worldObj.provider instanceof PocketProvider)
|
||||
{
|
||||
if(list.size()>5||this.worldObj.canBlockSeeTheSky((int)this.posX, (int)this.posY, (int)this.posZ))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return this.worldObj.checkNoEntityCollision(this.boundingBox) && this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox).isEmpty() && !this.worldObj.isAnyLiquid(this.boundingBox);
|
||||
}
|
||||
}
|
||||
@@ -7,9 +7,10 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.GameRules;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.DimData;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.yCoordHelper;
|
||||
import StevenDimDoors.mod_pocketDim.util.ChunkLocation;
|
||||
|
||||
@@ -69,23 +70,24 @@ public class MonolithSpawner implements IRegularTickReceiver {
|
||||
|
||||
private void placeMonolithsInPocket(int dimensionID, int chunkX, int chunkZ)
|
||||
{
|
||||
World pocket = dimHelper.getWorld(dimensionID);
|
||||
DimData dimData = dimHelper.instance.getDimData(dimensionID);
|
||||
NewDimData dimension = PocketManager.getDimensionData(dimensionID);
|
||||
World pocket = DimensionManager.getWorld(dimensionID);
|
||||
|
||||
if (pocket == null ||
|
||||
dimension == null ||
|
||||
dimension.dungeon() == null ||
|
||||
dimension.dungeon().isOpen())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int sanity = 0;
|
||||
int blockID = 0;
|
||||
boolean didSpawn = false;
|
||||
|
||||
if (pocket == null ||
|
||||
dimData == null ||
|
||||
dimData.dungeonGenerator == null ||
|
||||
dimData.dungeonGenerator.isOpen)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//The following initialization code is based on code from ChunkProviderGenerate.
|
||||
//It makes our generation depend on the world seed.
|
||||
Random random = new Random(pocket.getSeed());
|
||||
Random random = new Random(pocket.getSeed() ^ 0xA210FE65F20017D6L);
|
||||
long factorA = random.nextLong() / 2L * 2L + 1L;
|
||||
long factorB = random.nextLong() / 2L * 2L + 1L;
|
||||
random.setSeed(chunkX * factorA + chunkZ * factorB ^ pocket.getSeed());
|
||||
@@ -139,7 +141,7 @@ public class MonolithSpawner implements IRegularTickReceiver {
|
||||
|
||||
private void placeMonolithsInLimbo(int dimensionID, int chunkX, int chunkZ)
|
||||
{
|
||||
World limbo = dimHelper.getWorld(dimensionID);
|
||||
World limbo = DimensionManager.getWorld(dimensionID);
|
||||
|
||||
if (limbo == null)
|
||||
{
|
||||
@@ -148,7 +150,7 @@ public class MonolithSpawner implements IRegularTickReceiver {
|
||||
|
||||
//The following initialization code is based on code from ChunkProviderGenerate.
|
||||
//It makes our generation depend on the world seed.
|
||||
Random random = new Random(limbo.getSeed());
|
||||
Random random = new Random(limbo.getSeed() ^ 0xB5130C4ACC71A822L);
|
||||
long factorA = random.nextLong() / 2L * 2L + 1L;
|
||||
long factorB = random.nextLong() / 2L * 2L + 1L;
|
||||
random.setSeed(chunkX * factorA + chunkZ * factorB ^ limbo.getSeed());
|
||||
@@ -192,7 +194,7 @@ public class MonolithSpawner implements IRegularTickReceiver {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isMobSpawningAllowed()
|
||||
public static boolean isMobSpawningAllowed()
|
||||
{
|
||||
//This function is used to retrieve the value of doMobSpawning. The code is the same
|
||||
//as the code used by Minecraft. Jaitsu requested this to make testing easier. ~SenseiKiwi
|
||||
|
||||
@@ -1,75 +1,54 @@
|
||||
package StevenDimDoors.mod_pocketDim.ticking;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.LinkData;
|
||||
import StevenDimDoors.mod_pocketDim.TileEntityRift;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
|
||||
public class RiftRegenerator implements IRegularTickReceiver {
|
||||
|
||||
private static final int RIFT_REGENERATION_INTERVAL = 100; //Regenerate random rifts every 100 ticks
|
||||
|
||||
private DDProperties properties;
|
||||
private static final int RIFT_REGENERATION_INTERVAL = 200; //Regenerate random rifts every 200 ticks
|
||||
private static final int RIFTS_REGENERATED_PER_DIMENSION = 5;
|
||||
|
||||
public RiftRegenerator(IRegularTickSender sender, DDProperties properties)
|
||||
public RiftRegenerator(IRegularTickSender sender)
|
||||
{
|
||||
sender.registerForTicking(this, RIFT_REGENERATION_INTERVAL, false);
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyTick()
|
||||
{
|
||||
regenerate();
|
||||
regenerateRiftsInAllWorlds();
|
||||
}
|
||||
|
||||
private void regenerate()
|
||||
|
||||
public static void regenerateRiftsInAllWorlds()
|
||||
{
|
||||
try
|
||||
{
|
||||
//Regenerate rifts that have been replaced (not permanently removed) by players
|
||||
|
||||
int i = 0;
|
||||
|
||||
while (i < 15 && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER)
|
||||
//Regenerate rifts that have been replaced (not permanently removed) by players
|
||||
DDProperties properties = DDProperties.instance();
|
||||
|
||||
for (NewDimData dimension : PocketManager.getDimensions())
|
||||
{
|
||||
if (dimension.linkCount() > 0)
|
||||
{
|
||||
i++;
|
||||
LinkData link;
|
||||
|
||||
//actually gets the random rift based on the size of the list
|
||||
link = (LinkData) dimHelper.instance.getRandomLinkData(true);
|
||||
|
||||
if (link != null)
|
||||
{
|
||||
World world = dimHelper.getWorld(link.locDimID);
|
||||
|
||||
if (world != null && !mod_pocketDim.blockRift.isBlockImmune(world, link.locXCoord, link.locYCoord, link.locZCoord))
|
||||
{
|
||||
if (dimHelper.instance.getLinkDataFromCoords(link.locXCoord, link.locYCoord, link.locZCoord, link.locDimID) != null)
|
||||
{
|
||||
world.setBlock(link.locXCoord, link.locYCoord, link.locZCoord, properties.RiftBlockID);
|
||||
TileEntityRift rift = (TileEntityRift) world.getBlockTileEntity(link.locXCoord, link.locYCoord, link.locZCoord);
|
||||
if (rift == null)
|
||||
{
|
||||
dimHelper.getWorld(link.locDimID).setBlockTileEntity(link.locXCoord, link.locYCoord, link.locZCoord, new TileEntityRift());
|
||||
}
|
||||
if (rift != null)
|
||||
{
|
||||
rift.hasGrownRifts = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
World world = DimensionManager.getWorld(dimension.id());
|
||||
|
||||
if (world != null)
|
||||
{
|
||||
for (int count = 0; count < RIFTS_REGENERATED_PER_DIMENSION; count++)
|
||||
{
|
||||
DimLink link = dimension.getRandomLink();
|
||||
Point4D source = link.source();
|
||||
if (!mod_pocketDim.blockRift.isBlockImmune(world, source.getX(), source.getY(), source.getZ())&& world.getChunkProvider().chunkExists(source.getX() >> 4, source.getZ() >> 4))
|
||||
{
|
||||
world.setBlock(source.getX(), source.getY(), source.getZ(), properties.RiftBlockID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.err.println("An exception occurred in RiftRegenerator.regenerate():");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user