Merge remote-tracking branch 'upstream/master' into R1.4.0-improvements

This commit is contained in:
SenseiKiwi 2013-07-14 23:32:53 -04:00
commit df452e930f
28 changed files with 343 additions and 351 deletions

View file

@ -1,12 +1,16 @@
package StevenDimDoors.mod_pocketDim;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.Random;
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
import StevenDimDoors.mod_pocketDim.helpers.yCoordHelper;
import StevenDimDoors.mod_pocketDim.ticking.MobObelisk;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.entity.Entity;
import net.minecraft.world.World;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.ITickHandler;
@ -19,6 +23,11 @@ public class CommonTickHandler implements ITickHandler
public int tickCount=0;
public int tickCount2=0;
private static DDProperties properties = null;
public static ArrayList<int[]> chunksToPopulate= new ArrayList<int[]>();
public static final int MAX_MONOLITH_SPAWNING_CHANCE = 100;
private static final int MAX_MONOLITH_SPAWN_Y = 245;
private static final int CHUNK_SIZE = 16;
public CommonTickHandler()
{
@ -40,6 +49,22 @@ public class CommonTickHandler implements ITickHandler
{
if (type.equals(EnumSet.of(TickType.SERVER)))
{
if(!CommonTickHandler.chunksToPopulate.isEmpty())
{
for(int[] chunkData : CommonTickHandler.chunksToPopulate)
{
if(chunkData[0]==properties.LimboDimensionID)
{
this.placeMonolithsInLimbo(chunkData[0], chunkData[1], chunkData[2]);
}
else
{
this.placeMonolithsInPockets(chunkData[0], chunkData[1], chunkData[2]);
}
}
}
CommonTickHandler.chunksToPopulate.clear();
}
}
@ -53,6 +78,134 @@ public class CommonTickHandler implements ITickHandler
return null;
}
private void placeMonolithsInPockets(int worldID, int chunkX, int chunkZ)
{
World worldObj = dimHelper.getWorld(worldID);
DimData dimData = dimHelper.dimList.get(worldObj.provider.dimensionId);
int sanity = 0;
int blockID = 0;
boolean didSpawn=false;
if (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(worldObj.getSeed());
long factorA = random.nextLong() / 2L * 2L + 1L;
long factorB = random.nextLong() / 2L * 2L + 1L;
random.setSeed((long)chunkX * factorA + (long)chunkZ * factorB ^ worldObj.getSeed());
int x, y, z;
do
{
//Select a random column within the chunk
x = chunkX * CHUNK_SIZE + random.nextInt(CHUNK_SIZE);
z = chunkZ * CHUNK_SIZE + random.nextInt(CHUNK_SIZE);
y = MAX_MONOLITH_SPAWN_Y;
blockID = worldObj.getBlockId(x, y, z);
while (blockID == 0 &&y>0)
{
y--;
blockID = worldObj.getBlockId(x, y, z);
}
while(blockID == mod_pocketDim.blockDimWall.blockID&&y>0)
{
y--;
blockID = worldObj.getBlockId(x, y, z);
}
while (blockID == 0 &&y>0)
{
y--;
blockID = worldObj.getBlockId(x, y, z);
}
if(y > 0)
{
int jumpSanity=0;
int jumpHeight=0;
do
{
jumpHeight = y+random.nextInt(10);
jumpSanity++;
}
while(!worldObj.isAirBlock(x,jumpHeight+6 , z)&&jumpSanity<20);
Entity mob = new MobObelisk(worldObj);
mob.setLocationAndAngles(x, jumpHeight, z, 1, 1);
worldObj.spawnEntityInWorld(mob);
didSpawn=true;
}
sanity++;
}
while (sanity<5&&!didSpawn);
}
private void placeMonolithsInLimbo(int worldID, int var2, int var3)
{
World world = dimHelper.getWorld(worldID);
if (rand.nextInt(MAX_MONOLITH_SPAWNING_CHANCE) < properties.MonolithSpawningChance)
{
int y =0;
int x = var2*16 + rand.nextInt(16);
int z = var3*16 + rand.nextInt(16);
int yTest;
do
{
x = var2*16 + rand.nextInt(16);
z = var3*16 + rand.nextInt(16);
while(world.getBlockId(x, y, z)==0&&y<255)
{
y++;
}
y = yCoordHelper.getFirstUncovered(world,x , y+2, z);
yTest=yCoordHelper.getFirstUncovered(world,x , y+5, z);
if(yTest>245)
{
return;
}
int jumpSanity=0;
int jumpHeight=0;
do
{
jumpHeight = y+rand.nextInt(25);
jumpSanity++;
}
while(!world.isAirBlock(x,jumpHeight+6 , z)&&jumpSanity<20);
Entity mob = new MobObelisk(world);
mob.setLocationAndAngles(x, jumpHeight, z, 1, 1);
world.spawnEntityInWorld(mob);
}
while (yTest > y);
}
}
//replaces rifts in game that have been destroyed/have blocks placed over them.
private void onTickInGame()
{

View file

@ -208,7 +208,7 @@ public class DDProperties
"Sets whether dungeon rifts generate in dimensions other than Limbo").getBoolean(true);
MonolithSpawningChance = config.get(Configuration.CATEGORY_GENERAL, "Monolith Spawning Chance", 28,
"Sets the chance (out of " + LimboGenerator.MAX_MONOLITH_SPAWNING_CHANCE + ") that Monoliths will " +
"Sets the chance (out of " + CommonTickHandler.MAX_MONOLITH_SPAWNING_CHANCE + ") that Monoliths will " +
"spawn in a given Limbo chunk. The default chance is 28.").getInt();
ClusterGenerationChance = config.get(Configuration.CATEGORY_GENERAL, "Cluster Generation Chance", 3,

View file

@ -232,7 +232,7 @@ public class DimData implements Serializable
return null;
}
public ArrayList<LinkData> printAllLinkData()
public ArrayList<LinkData> getLinksInDim()
{
//TODO: We might want to modify this function, but I'm afraid of breaking something right now.
//To begin with, the name is wrong. This doesn't print anything! >_o ~SenseiKiwi

View file

@ -7,6 +7,11 @@ import java.util.List;
import java.util.Random;
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
import StevenDimDoors.mod_pocketDim.items.ItemRiftBlade;
import StevenDimDoors.mod_pocketDim.world.LimboGenerator;
import StevenDimDoors.mod_pocketDim.world.LimboProvider;
import StevenDimDoors.mod_pocketDim.world.PocketGenerator;
import StevenDimDoors.mod_pocketDim.world.pocketProvider;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.relauncher.Side;
@ -17,6 +22,7 @@ import net.minecraft.client.Minecraft;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.monster.EntityEnderman;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
@ -27,11 +33,13 @@ import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraftforge.client.event.sound.SoundLoadEvent;
import net.minecraftforge.event.Event.Result;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.entity.living.LivingFallEvent;
import net.minecraftforge.event.entity.player.PlayerDropsEvent;
import net.minecraftforge.event.entity.player.PlayerEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.event.terraingen.PopulateChunkEvent;
import net.minecraftforge.event.world.WorldEvent;
public class EventHookContainer
@ -46,7 +54,6 @@ public class EventHookContainer
}
@SideOnly(Side.CLIENT)
@ForgeSubscribe
public void onSoundLoad(SoundLoadEvent event)
{
@ -60,7 +67,6 @@ public class EventHookContainer
@ForgeSubscribe
public void onWorldLoad(WorldEvent.Load event)
{
if(!mod_pocketDim.hasInitDims&&event.world.provider.dimensionId==0&&!event.world.isRemote)
{
System.out.println("Registering Pocket Dims");
@ -69,9 +75,7 @@ public class EventHookContainer
dimHelper.dimList.clear();
dimHelper.instance.interDimLinkList.clear();
dimHelper.instance.initPockets();
}
for(Integer ids : dimHelper.getIDs())
{
World world = dimHelper.getWorld(ids);
@ -79,140 +83,72 @@ public class EventHookContainer
if(dimHelper.dimList.containsKey(world.provider.dimensionId))
{
for(LinkData link:dimHelper.dimList.get(world.provider.dimensionId).printAllLinkData())
//TODO added temporary Try/catch block to prevent a crash here, getLinksInDim needs to be looked at
try
{
if(linkCount>100)
{
break;
}
linkCount++;
int blocktoReplace = world.getBlockId(link.locXCoord, link.locYCoord, link.locZCoord);
if(!mod_pocketDim.blocksImmuneToRift.contains(blocktoReplace))
{
dimHelper.getWorld(link.locDimID).setBlock(link.locXCoord, link.locYCoord, link.locZCoord, properties.RiftBlockID);
}
for(LinkData link:dimHelper.dimList.get(world.provider.dimensionId).getLinksInDim())
{
if(linkCount>100)
{
break;
}
linkCount++;
int blocktoReplace = world.getBlockId(link.locXCoord, link.locYCoord, link.locZCoord);
if(!mod_pocketDim.blocksImmuneToRift.contains(blocktoReplace))
{
dimHelper.getWorld(link.locDimID).setBlock(link.locXCoord, link.locYCoord, link.locZCoord, properties.RiftBlockID);
}
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
}
@ForgeSubscribe
public void EntityJoinWorldEvent(net.minecraftforge.event.entity.EntityJoinWorldEvent event)
{
if(event.entity instanceof EntityPlayer)
if(event.entity instanceof EntityPlayer)
{
// System.out.println(event.entity.worldObj.provider.dimensionId);
// System.out.println(event.entity.worldObj.provider.dimensionId);
// PacketDispatcher.sendPacketToPlayer(DimUpdatePacket.sendPacket(event.world.provider.dimensionId,1),(Player) event.entity);
}
}
@ForgeSubscribe
public void onPlayerFall(LivingFallEvent event)
{
event.setCanceled(event.entity.worldObj.provider.dimensionId==properties.LimboDimensionID);
event.setCanceled(event.entity.worldObj.provider.dimensionId==properties.LimboDimensionID);
}
@ForgeSubscribe
public void onPlayerInteract(PlayerInteractEvent event)
{
/**
if(event.entityPlayer.worldObj.provider.dimensionId==properties.LimboDimensionID&&event.action==PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK)
{
int x = event.x;
int y = event.y;
int z = event.z;
if(event.entityPlayer.getHeldItem()!=null)
{
if(event.entityPlayer.getHeldItem().getItem() instanceof ItemBlock)
{
// if(event.entityPlayer instanceof EntityPlayerMP)
if(event.entityPlayer instanceof EntityPlayerMP)
{
Point3D point = new Point3D(x,y,z);
dimHelper.blocksToDecay.add(point);
}
}
else
{
event.setCanceled(true);
}
}
}
**/
}
// @ForgeSubscribe
public void onPlayerEvent(PlayerEvent event)
{
/**
if(!event.entity.worldObj.isRemote)
{
ItemStack item = event.entityPlayer.inventory.getCurrentItem();
if(item!=null)
{
if(item.getItem() instanceof ItemRiftBlade)
{
List<EntityLiving> list = event.entity.worldObj.getEntitiesWithinAABB(EntityLiving.class, AxisAlignedBB.getBoundingBox( event.entityPlayer.posX-7,event.entityPlayer.posY-7, event.entityPlayer.posZ-7, event.entityPlayer.posX+7,event.entityPlayer.posY+7, event.entityPlayer.posZ+7));
list.remove(event.entity);
for(EntityLiving ent : list)
{
Vec3 var3 = event.entityPlayer.getLook(1.0F).normalize();
Vec3 var4 = event.entityPlayer.worldObj.getWorldVec3Pool().getVecFromPool(ent.posX - event.entityPlayer.posX, ent.boundingBox.minY + (double)((ent.height) / 2.0F) - ( event.entityPlayer.posY + (double) event.entityPlayer.getEyeHeight()), ent.posZ - event.entityPlayer.posZ);
double var5 = var4.lengthVector();
var4 = var4.normalize();
double var7 = var3.dotProduct(var4);
if( (var7+.1) > 1.0D - 0.025D / var5 ? event.entityPlayer.canEntityBeSeen(ent) : false)
{
System.out.println(list.size());
ItemRiftBlade.class.cast(item.getItem()).teleportToEntity(item,ent, event.entityPlayer);
break;
//ItemRiftBlade.class.cast(item.getItem()).teleportTo(event.entityPlayer, ent.posX, ent.posY, ent.posZ);
}
}
}
}
}
**/
}
@ForgeSubscribe
public void onPlayerDrops(PlayerDropsEvent event)
{

View file

@ -22,7 +22,7 @@ public class BlockDimWall extends Block
{
super(i, Material.ground);
setTickRandomly(true);
this.setCreativeTab(CreativeTabs.tabBlock);
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);

View file

@ -32,7 +32,7 @@ public class BlockLimbo extends Block
{
super(i, Material.ground);
setTickRandomly(false);
this.setCreativeTab(CreativeTabs.tabBlock);
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);

View file

@ -33,7 +33,6 @@ public class ExitDoor extends dimDoor
{
super(par1, Material.wood);
// this.blockIndexInTexture = 19;
// TODO Auto-generated constructor stub

View file

@ -21,7 +21,7 @@ public class dimHatch extends BlockTrapDoor
public dimHatch(int par1,int par2, Material par2Material)
{
super(par1, Material.iron);
this.setCreativeTab(CreativeTabs.tabTransport);
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
// this.setTextureFile("/PocketBlockTextures.png");
// this.blockIndexInTexture = 16;
}

View file

@ -23,8 +23,10 @@ public class linkDimDoor extends dimDoor
{
private Icon blockIconBottom;
public linkDimDoor(int par1, Material material) {
super(par1, material);
// TODO Auto-generated constructor stub
}

View file

@ -28,6 +28,7 @@ public class linkExitDoor extends ExitDoor
//this.blockIndexInTexture = 20;
// TODO Auto-generated constructor stub
}
@SideOnly(Side.CLIENT)

View file

@ -57,7 +57,7 @@ public class CommandDeleteAllLinks extends DDCommandBase
if(dimHelper.dimList.containsKey(targetDim))
{
DimData dim = dimHelper.dimList.get(targetDim);
ArrayList<LinkData> linksInDim = dim.printAllLinkData();
ArrayList<LinkData> linksInDim = dim.getLinksInDim();
for (LinkData link : linksInDim)
{

View file

@ -61,7 +61,7 @@ public class CommandDeleteDimensionData extends DDCommandBase
for(DimData dimData :dimHelper.dimList.values())
{
Collection<LinkData> links= new ArrayList<LinkData>();
links.addAll( dimData.printAllLinkData());
links.addAll( dimData.getLinksInDim());
for(LinkData link : links)
{

View file

@ -58,7 +58,7 @@ public class CommandDeleteRifts extends DDCommandBase
if(dimHelper.dimList.containsKey(targetDim))
{
DimData dim = dimHelper.dimList.get(targetDim);
ArrayList<LinkData> linksInDim = dim.printAllLinkData();
ArrayList<LinkData> linksInDim = dim.getLinksInDim();
for(LinkData link : linksInDim)
{

View file

@ -56,7 +56,7 @@ public class CommandPrintDimensionData extends DDCommandBase
return DDCommandResult.UNREGISTERED_DIMENSION;
}
ArrayList<LinkData> links = dimData.printAllLinkData();
ArrayList<LinkData> links = dimData.getLinksInDim();
sender.sendChatToPlayer("Dimension ID = " + dimData.dimID);
sender.sendChatToPlayer("Dimension Depth = " + dimData.depth);

View file

@ -47,7 +47,7 @@ public class CommandPruneDimensions extends DDCommandBase
for (DimData data : allDims)
{
for (LinkData link : data.printAllLinkData())
for (LinkData link : data.getLinksInDim())
{
linkedDimensions.add(link.destDimID);
}

View file

@ -15,6 +15,7 @@ import net.minecraft.block.BlockContainer;
import net.minecraft.util.WeightedRandom;
import net.minecraft.world.World;
import StevenDimDoors.mod_pocketDim.DDProperties;
import StevenDimDoors.mod_pocketDim.DimData;
import StevenDimDoors.mod_pocketDim.DungeonGenerator;
import StevenDimDoors.mod_pocketDim.LinkData;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
@ -531,6 +532,7 @@ public class DungeonHelper
int depth = dimHelper.instance.getDimDepth(incoming.locDimID);
int depthWeight = rand.nextInt(depth + 2) + rand.nextInt(depth + 2) - 2;
int count = 10;
boolean flag = true;
try
@ -648,6 +650,11 @@ public class DungeonHelper
{
flag = false;
}
if(getDungeonDataInChain(dimHelper.dimList.get(incoming.locDimID)).contains(dungeon))
{
flag=false;
}
}
while (!flag && count > 0);
}
@ -718,4 +725,36 @@ public class DungeonHelper
WeightedContainer<DungeonGenerator> resultContainer = (WeightedContainer<DungeonGenerator>) WeightedRandom.getRandomItem(random, weights);
return (resultContainer != null) ? resultContainer.getData() : null;
}
public static ArrayList<DungeonGenerator> getDungeonDataInChain(DimData dimData)
{
DimData startingDim = dimHelper.dimList.get(dimHelper.instance.getLinkDataFromCoords(dimData.exitDimLink.destXCoord, dimData.exitDimLink.destYCoord, dimData.exitDimLink.destZCoord, dimData.exitDimLink.destDimID).destDimID);
return getDungeonDataBelow(startingDim);
}
private static ArrayList<DungeonGenerator> getDungeonDataBelow(DimData dimData)
{
ArrayList<DungeonGenerator> dungeonData = new ArrayList<DungeonGenerator>();
if(dimData.dungeonGenerator!=null)
{
dungeonData.add(dimData.dungeonGenerator);
for(LinkData link : dimData.getLinksInDim())
{
if(dimHelper.dimList.containsKey(link.destDimID))
{
if(dimHelper.dimList.get(link.destDimID).dungeonGenerator!=null&&dimHelper.instance.getDimDepth(link.destDimID)==dimData.depth+1)
{
for(DungeonGenerator dungeonGen :getDungeonDataBelow(dimHelper.dimList.get(link.destDimID)) )
{
if(!dungeonData.contains(dungeonGen))
{
dungeonData.add(dungeonGen);
}
}
}
}
}
}
return dungeonData;
}
}

View file

@ -824,7 +824,7 @@ public class dimHelper extends DimensionManager
DeleteFolder.deleteFolder(save);
dimData.hasBeenFilled = false;
dimData.hasDoor = false;
for(LinkData link : dimData.printAllLinkData())
for(LinkData link : dimData.getLinksInDim())
{
link.hasGennedDoor = false;
LinkData linkOut = this.getLinkDataFromCoords(link.destXCoord, link.destYCoord, link.destZCoord, link.destDimID);
@ -1248,7 +1248,7 @@ public class dimHelper extends DimensionManager
{
break;
}
linksInDim = dimData.printAllLinkData();
linksInDim = dimData.getLinksInDim();
if(!linksInDim.isEmpty())
{
break;

View file

@ -22,7 +22,7 @@ public class ItemChaosDoor extends itemDimDoor
{
super(par1, par2Material);
this.doorMaterial = par2Material;
this.setCreativeTab(CreativeTabs.tabTransport);
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
}
public void registerIcons(IconRegister par1IconRegister)
{

View file

@ -32,7 +32,7 @@ public class ItemRiftBlade extends itemDimDoor
super(par1, par2Material);
// this.setTextureFile("/PocketBlockTextures.png");
this.setCreativeTab(CreativeTabs.tabTransport);
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
this.setMaxStackSize(1);
// this.itemIcon=5;

View file

@ -27,14 +27,9 @@ public class ItemStabilizedRiftSignature extends itemLinkSignature
{
super(par);
this.setMaxStackSize(1);
// this.setTextureFile("/PocketBlockTextures.png");
this.setCreativeTab(CreativeTabs.tabTransport);
// this.itemIndex=5;
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
this.setMaxDamage(0);
this.hasSubtypes=true;
//TODO move to proxy
if (properties == null)
properties = DDProperties.instance();
}
@ -44,8 +39,6 @@ public class ItemStabilizedRiftSignature extends itemLinkSignature
public boolean hasEffect(ItemStack par1ItemStack)
{
// adds effect if item has a link stored
if(par1ItemStack.hasTagCompound())
{
if(par1ItemStack.stackTagCompound.getBoolean("isCreated"))
@ -53,14 +46,12 @@ public class ItemStabilizedRiftSignature extends itemLinkSignature
return true;
}
}
return false;
return false;
}
public void registerIcons(IconRegister par1IconRegister)
{
this.itemIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName().replace("item.", ""));
}
@Override
@ -69,38 +60,23 @@ public class ItemStabilizedRiftSignature extends itemLinkSignature
int key;
LinkData linkData;
int thisWorldID=par3World.provider.dimensionId;
Integer[] linkCoords =this.readFromNBT(par1ItemStack);
//par1ItemStack= par2EntityPlayer.getCurrentEquippedItem();
Integer[] linkCoords =this.readFromNBT(par1ItemStack);
//System.out.println(key);
int offset = 2;
if(par1ItemStack.getTagCompound()!=null)
{
int offset = 2;
if(par1ItemStack.getTagCompound()!=null)
{
if(par1ItemStack.getTagCompound().getBoolean("isCreated"))
{
boolean hasEnder = false;
// checks to see if the item has a link stored, if so, it creates it
// checks to see if the item has a link stored, if so, it creates it
if(par2EntityPlayer.inventory.hasItem(Item.enderPearl.itemID)||par2EntityPlayer.inventory.hasItem(properties.StableFabricItemID))
{
if(!par2EntityPlayer.inventory.consumeInventoryItem(properties.StableFabricItemID))
{
par2EntityPlayer.inventory.consumeInventoryItem(Item.enderPearl.itemID);
}
hasEnder=true;
}
if(par3World.getBlockId(par4, par5, par6)==Block.snow.blockID)
{
offset = 1;
@ -110,7 +86,6 @@ public class ItemStabilizedRiftSignature extends itemLinkSignature
if(dimHelper.instance.getLinkDataFromCoords(linkCoords[0], linkCoords[1], linkCoords[2], par3World)==null)
{
dimHelper.instance.createLink(linkCoords[3], par3World.provider.dimensionId, linkCoords[0], linkCoords[1], linkCoords[2],par4, par5+offset, par6);
}
dimHelper.instance.createLink(par3World.provider.dimensionId, linkCoords[3], par4, par5+offset, par6, linkCoords[0], linkCoords[1], linkCoords[2]);
par2EntityPlayer.sendChatToPlayer("Rift Created");
@ -119,37 +94,20 @@ public class ItemStabilizedRiftSignature extends itemLinkSignature
{
par2EntityPlayer.sendChatToPlayer("No Ender Pearls!");
}
}
}
else if(!par3World.isRemote)
{
if(par3World.getBlockId(par4, par5, par6)==Block.snow.blockID)
{
offset = 1;
}
//otherwise, it creates the first half of the link. Next click will complete it.
key= dimHelper.instance.createUniqueInterDimLinkKey();
this.writeToNBT(par1ItemStack, par4, par5+offset, par6,par3World.provider.dimensionId);
par2EntityPlayer.sendChatToPlayer("Rift Signature Stored");
}
//dimHelper.instance.save();
}
else if(!par3World.isRemote)
{
if(par3World.getBlockId(par4, par5, par6)==Block.snow.blockID)
{
offset = 1;
}
//otherwise, it creates the first half of the link. Next click will complete it.
key= dimHelper.instance.createUniqueInterDimLinkKey();
this.writeToNBT(par1ItemStack, par4, par5+offset, par6,par3World.provider.dimensionId);
par2EntityPlayer.sendChatToPlayer("Rift Signature Stored");
}
return true;
}
@SideOnly(Side.CLIENT)
@ -159,7 +117,6 @@ public class ItemStabilizedRiftSignature extends itemLinkSignature
*/
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{
if(par1ItemStack.hasTagCompound())
{
if(par1ItemStack.stackTagCompound.getBoolean("isCreated"))
@ -167,9 +124,7 @@ public class ItemStabilizedRiftSignature extends itemLinkSignature
Integer[] coords = this.readFromNBT(par1ItemStack);
par3List.add(String.valueOf("Leads to dim "+coords[3] +" with depth "+dimHelper.instance.getDimDepth(dimHelper.instance.getDimDepth(coords[3]))));
par3List.add("at x="+coords[0]+" y="+coords[1]+" z="+coords[2]);
}
}
else
{
@ -177,33 +132,27 @@ public class ItemStabilizedRiftSignature extends itemLinkSignature
par3List.add ("second click creates two rifts,");
par3List.add("that link the first location");
par3List.add("with the second location");
}
}
public void writeToNBT(ItemStack itemStack,int x, int y, int z, int dimID)
{
NBTTagCompound tag;
if(itemStack.hasTagCompound())
{
tag = itemStack.getTagCompound();
}
else
{
tag= new NBTTagCompound();
}
tag.setInteger("linkX", x);
tag.setInteger("linkY", y);
tag.setInteger("linkZ", z);
tag.setInteger("linkDimID", dimID);
tag.setBoolean("isCreated", true);
itemStack.setTagCompound(tag);
NBTTagCompound tag;
if(itemStack.hasTagCompound())
{
tag = itemStack.getTagCompound();
}
else
{
tag= new NBTTagCompound();
}
tag.setInteger("linkX", x);
tag.setInteger("linkY", y);
tag.setInteger("linkZ", z);
tag.setInteger("linkDimID", dimID);
tag.setBoolean("isCreated", true);
itemStack.setTagCompound(tag);
}
/**
@ -211,7 +160,6 @@ public class ItemStabilizedRiftSignature extends itemLinkSignature
*/
public Integer[] readFromNBT(ItemStack itemStack)
{
NBTTagCompound tag;
Integer[] linkCoords = new Integer[5];
if(itemStack.hasTagCompound())
@ -226,11 +174,8 @@ public class ItemStabilizedRiftSignature extends itemLinkSignature
linkCoords[1]=tag.getInteger("linkY");
linkCoords[2]=tag.getInteger("linkZ");
linkCoords[3]=tag.getInteger("linkDimID");
}
return linkCoords;
}

View file

@ -33,7 +33,7 @@ public class ItemStableFabric extends Item
{
super(par1);
// this.setitemIcon(Item.doorWood.getIconFromDamage(0));
this.setCreativeTab(CreativeTabs.tabTransport);
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
}
public void registerIcons(IconRegister par1IconRegister)

View file

@ -31,7 +31,7 @@ public class itemDimDoor extends ItemDoor
{
super(par1, par2Material);
this.setMaxStackSize(64);
this.setCreativeTab(CreativeTabs.tabTransport);
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
if (properties == null)
properties = DDProperties.instance();
}

View file

@ -22,7 +22,7 @@ public class itemExitDoor extends itemDimDoor
{
super(par1, par2Material);
this.doorMaterial = par2Material;
this.setCreativeTab(CreativeTabs.tabTransport);
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
}

View file

@ -29,7 +29,7 @@ public class itemLinkSignature extends Item
super(par1);
this.setMaxStackSize(1);
// this.setTextureFile("/PocketBlockTextures.png");
this.setCreativeTab(CreativeTabs.tabTransport);
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
// this.itemIcon=5;
this.setMaxDamage(0);

View file

@ -28,7 +28,7 @@ public class itemRiftRemover extends Item
super(par1);
this.setMaxStackSize(1);
// this.setTextureFile("/PocketBlockTextures.png");
this.setCreativeTab(CreativeTabs.tabTransport);
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
// this.itemIcon=6;
this.setMaxDamage(5);

View file

@ -6,6 +6,7 @@ import java.util.HashMap;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityEggInfo;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.item.EntityItem;
@ -134,6 +135,23 @@ public class mod_pocketDim
public static long genTime;
public static int teleTimer = 0;
public static CreativeTabs dimDoorsCreativeTab = new CreativeTabs("dimDoorsCreativeTab")
{
@Override
public ItemStack getIconItemStack()
{
return new ItemStack(mod_pocketDim.itemDimDoor, 1, 0);
}
@Override
public String getTranslatedTabLabel()
{
return "Dimensional Doors";
}
};
@PreInit
public void PreInit(FMLPreInitializationEvent event)
{
@ -218,6 +236,8 @@ public class mod_pocketDim
LanguageRegistry.addName(itemDimDoor, "Dimensional Door");
LanguageRegistry.addName(itemRiftBlade , "Rift Blade");
LanguageRegistry.instance().addStringLocalization("itemGroup.dimDoorsCustomTab", "en_US", "Dimensional Doors Items");
TickRegistry.registerTickHandler(new ClientTickHandler(), Side.CLIENT);
TickRegistry.registerTickHandler(new CommonTickHandler(), Side.SERVER);
@ -403,13 +423,13 @@ public class mod_pocketDim
CommandPrintDimensionData.instance().register(event);
CommandPruneDimensions.instance().register(event);
CommandStartDungeonCreation.instance().register(event);
dimHelper.instance.load();
if(!dimHelper.dimList.containsKey(properties.LimboDimensionID))
{
dimHelper.dimList.put(properties.LimboDimensionID, new DimData( properties.LimboDimensionID, false, 0, new LinkData()));
}
}
}

View file

@ -3,6 +3,7 @@ package StevenDimDoors.mod_pocketDim.world;
import java.util.List;
import java.util.Random;
import StevenDimDoors.mod_pocketDim.CommonTickHandler;
import StevenDimDoors.mod_pocketDim.DDProperties;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
@ -33,7 +34,6 @@ import net.minecraftforge.event.terraingen.ChunkProviderEvent;
public class LimboGenerator extends ChunkProviderGenerate implements IChunkProvider
{
public static final int MAX_MONOLITH_SPAWNING_CHANCE = 100;
private static Random rand;
/** A NoiseGeneratorOctaves used in generating terrain */
@ -158,15 +158,17 @@ public class LimboGenerator extends ChunkProviderGenerate implements IChunkProvi
this.rand.setSeed((long)par1 * 341873128712L + (long)par2 * 132897987541L);
byte[] var3 = new byte[32768];
this.generateTerrain(par1, par2, var3);
this.caveGenerator.generate(this, this.worldObj, par1, par2, var3);
Chunk var4 = new Chunk(this.worldObj, var3, par1, par2);
var4.generateSkylightMap();
if(!var4.isTerrainPopulated)
{
var4.isTerrainPopulated=true;
CommonTickHandler.chunksToPopulate.add(new int[] {properties.LimboDimensionID,par1,par2});
}
return var4;
}
@Override
@ -178,50 +180,7 @@ public class LimboGenerator extends ChunkProviderGenerate implements IChunkProvi
@Override
public void populate(IChunkProvider var1, int var2, int var3)
{
if (rand.nextInt(MAX_MONOLITH_SPAWNING_CHANCE) < properties.MonolithSpawningChance)
{
int y =0;
int x = var2*16 + rand.nextInt(16);
int z = var3*16 + rand.nextInt(16);
int yTest;
do
{
x = var2*16 + rand.nextInt(16);
z = var3*16 + rand.nextInt(16);
while(this.worldObj.getBlockId(x, y, z)==0&&y<255)
{
y++;
}
y = yCoordHelper.getFirstUncovered(this.worldObj,x , y+2, z);
yTest=yCoordHelper.getFirstUncovered(this.worldObj,x , y+5, z);
if(yTest>245)
{
return;
}
int jumpSanity=0;
int jumpHeight=0;
do
{
jumpHeight = y+rand.nextInt(25);
jumpSanity++;
}
while(!this.worldObj.isAirBlock(x,jumpHeight+6 , z)&&jumpSanity<20);
Entity mob = new MobObelisk(this.worldObj);
mob.setLocationAndAngles(x, jumpHeight, z, 1, 1);
this.worldObj.spawnEntityInWorld(mob);
}
while (yTest > y);
}
}
@Override

View file

@ -13,6 +13,8 @@ import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.ChunkProviderGenerate;
import StevenDimDoors.mod_pocketDim.CommonTickHandler;
import StevenDimDoors.mod_pocketDim.DDProperties;
import StevenDimDoors.mod_pocketDim.DimData;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
@ -23,13 +25,17 @@ public class PocketGenerator extends ChunkProviderGenerate implements IChunkProv
{
private World worldObj;
private static final int MAX_MONOLITH_SPAWN_Y = 245;
private static final int CHUNK_SIZE = 16;
private DDProperties properties = null;
public PocketGenerator(World par1World, long par2, boolean par4)
{
super(par1World, par2, par4);
this.worldObj = par1World;
if (properties == null)
properties = DDProperties.instance();
}
@Override
@ -50,6 +56,12 @@ public class PocketGenerator extends ChunkProviderGenerate implements IChunkProv
Chunk chunk = new Chunk(worldObj, var3, chunkX, chunkZ);
if(!chunk.isTerrainPopulated)
{
chunk.isTerrainPopulated=true;
CommonTickHandler.chunksToPopulate.add(new int[] {chunk.worldObj.provider.dimensionId,chunkX,chunkZ});
}
return chunk;
}
@ -62,81 +74,7 @@ public class PocketGenerator extends ChunkProviderGenerate implements IChunkProv
@Override
public void populate(IChunkProvider chunkProvider, int chunkX, int chunkZ)
{
//Check whether we want to populate this chunk with Monoliths.
DimData dimData = dimHelper.dimList.get(worldObj.provider.dimensionId);
int sanity = 0;
int blockID = 0;
boolean didSpawn=false;
if (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(worldObj.getSeed());
long factorA = random.nextLong() / 2L * 2L + 1L;
long factorB = random.nextLong() / 2L * 2L + 1L;
random.setSeed((long)chunkX * factorA + (long)chunkZ * factorB ^ worldObj.getSeed());
int x, y, z;
do
{
//Select a random column within the chunk
x = chunkX * CHUNK_SIZE + random.nextInt(CHUNK_SIZE);
z = chunkZ * CHUNK_SIZE + random.nextInt(CHUNK_SIZE);
y = MAX_MONOLITH_SPAWN_Y;
blockID = worldObj.getBlockId(x, y, z);
while (blockID == 0 &&y>0)
{
y--;
blockID = worldObj.getBlockId(x, y, z);
}
while(blockID == mod_pocketDim.blockDimWall.blockID&&y>0)
{
y--;
blockID = worldObj.getBlockId(x, y, z);
}
while (blockID == 0 &&y>0)
{
y--;
blockID = worldObj.getBlockId(x, y, z);
}
if(y > 0)
{
int jumpSanity=0;
int jumpHeight=0;
do
{
jumpHeight = y+random.nextInt(10);
jumpSanity++;
}
while(!this.worldObj.isAirBlock(x,jumpHeight+6 , z)&&jumpSanity<20);
Entity mob = new MobObelisk(worldObj);
mob.setLocationAndAngles(x, jumpHeight, z, 1, 1);
worldObj.spawnEntityInWorld(mob);
didSpawn=true;
}
sanity++;
}
while (sanity<5&&!didSpawn);
}
@Override