It's really not that hard. You basically just have to copy the existing GenLayers where necessary (any of the ones that have to do with biomes), and then, in your base GenLayer (which is basically just a copy of GenLayer.java), replace the proper class names with yours.
Hello, I installed the forge version and I got this error, did I decompile it wrong? I used fernflower since forge needs it.
By the way, this api is awesome, I tried the modloader version and it worked great!
Here's the error:
== ERRORS FOUND ==
src\minecraft\net\minecraft\src\DimensionAPI.java:138: error: '(' or '[' expected
World var10000 = new World;
^
- src\minecraft\net\minecraft\src\DimensionAPI.java:140: error: <identifier> expected
var10000.<init>(var1.theWorld, WorldProvider.getProviderForDimension(var5));
^
19:05:04 - 2 errors
If you could lend some advise on how to fix it, I would appreciate it. Thanks.
Basically what VirtualArts said. Replace line 138 with:
World var10000 = new World(var1.theWorld, WorldProvider.getProviderForDimension(var5));
... and get rid of line 140, I guess. If that doesn't work, download the sources of the Forge version and replace that file with the source file.
Add a class called TeleporterBase that makes it easier for people to add teleporters for their own dimension. It accepts 2 parameters, the frame block and the portal block. You use it like this:
public Teleporter getTeleporter()
{
return new TeleporterBase(Block.dirt, mod_Dimension.portalBlock);
}
Here is the code:
package net.minecraft.src;
import java.util.Random;
public class TeleporterBase extends Teleporter
{
private Random random;
Block frame;
Block portal;
public TeleporterBase(Block frame, Block portal)
{
random = new Random();
this.frame = frame;
this.portal = portal;
}
public void placeInPortal(World par1World, Entity par2Entity)
{
if (par1World.worldProvider.worldType == 1)
{
int i = MathHelper.floor_double(par2Entity.posX);
int j = MathHelper.floor_double(par2Entity.posY) - 1;
int k = MathHelper.floor_double(par2Entity.posZ);
int l = 1;
int i1 = 0;
for (int j1 = -2; j1 <= 2; j1++)
{
for (int k1 = -2; k1 <= 2; k1++)
{
for (int l1 = -1; l1 < 3; l1++)
{
int i2 = i + k1 * l + j1 * i1;
int j2 = j + l1;
int k2 = (k + k1 * i1) - j1 * l;
boolean flag = l1 < 0;
par1World.setBlockWithNotify(i2, j2, k2, flag ? frame.blockID : 0);
}
}
}
par2Entity.setLocationAndAngles(i, j, k, par2Entity.rotationYaw, 0.0F);
par2Entity.motionX = par2Entity.motionY = par2Entity.motionZ = 0.0D;
return;
}
if (placeInExistingPortal(par1World, par2Entity))
{
return;
}
else
{
createPortal(par1World, par2Entity);
placeInExistingPortal(par1World, par2Entity);
return;
}
}
public boolean placeInExistingPortal(World par1World, Entity par2Entity)
{
char c = '\200';
double d = -1D;
int i = 0;
int j = 0;
int k = 0;
int l = MathHelper.floor_double(par2Entity.posX);
int i1 = MathHelper.floor_double(par2Entity.posZ);
for (int j1 = l - c; j1 <= l + c; j1++)
{
double d1 = ((double)j1 + 0.5D) - par2Entity.posX;
for (int j2 = i1 - c; j2 <= i1 + c; j2++)
{
double d3 = ((double)j2 + 0.5D) - par2Entity.posZ;
for (int k2 = 127; k2 >= 0; k2--)
{
if (par1World.getBlockId(j1, k2, j2) != portal.blockID)
{
continue;
}
for (; par1World.getBlockId(j1, k2 - 1, j2) == portal.blockID; k2--) { }
double d5 = ((double)k2 + 0.5D) - par2Entity.posY;
double d7 = d1 * d1 + d5 * d5 + d3 * d3;
if (d < 0.0D || d7 < d)
{
d = d7;
i = j1;
j = k2;
k = j2;
}
}
}
}
if (d >= 0.0D)
{
int k1 = i;
int l1 = j;
int i2 = k;
double d2 = (double)k1 + 0.5D;
double d4 = (double)l1 + 0.5D;
double d6 = (double)i2 + 0.5D;
if (par1World.getBlockId(k1 - 1, l1, i2) == portal.blockID)
{
d2 -= 0.5D;
}
if (par1World.getBlockId(k1 + 1, l1, i2) == portal.blockID)
{
d2 += 0.5D;
}
if (par1World.getBlockId(k1, l1, i2 - 1) == portal.blockID)
{
d6 -= 0.5D;
}
if (par1World.getBlockId(k1, l1, i2 + 1) == portal.blockID)
{
d6 += 0.5D;
}
par2Entity.setLocationAndAngles(d2, d4, d6, par2Entity.rotationYaw, 0.0F);
par2Entity.motionX = par2Entity.motionY = par2Entity.motionZ = 0.0D;
return true;
}
else
{
return false;
}
}
public boolean createPortal(World par1World, Entity par2Entity)
{
byte byte0 = 16;
double d = -1D;
int i = MathHelper.floor_double(par2Entity.posX);
int j = MathHelper.floor_double(par2Entity.posY);
int k = MathHelper.floor_double(par2Entity.posZ);
int l = i;
int i1 = j;
int j1 = k;
int k1 = 0;
int l1 = random.nextInt(4);
for (int i2 = i - byte0; i2 <= i + byte0; i2++)
{
double d1 = ((double)i2 + 0.5D) - par2Entity.posX;
for (int j3 = k - byte0; j3 <= k + byte0; j3++)
{
double d3 = ((double)j3 + 0.5D) - par2Entity.posZ;
for (int k4 = 127; k4 >= 0; k4--)
{
if (!par1World.isAirBlock(i2, k4, j3))
{
continue;
}
for (; k4 > 0 && par1World.isAirBlock(i2, k4 - 1, j3); k4--) { }
label0:
for (int k5 = l1; k5 < l1 + 4; k5++)
{
int l6 = k5 % 2;
int i8 = 1 - l6;
if (k5 % 4 >= 2)
{
l6 = -l6;
i8 = -i8;
}
for (int j9 = 0; j9 < 3; j9++)
{
for (int k10 = 0; k10 < 4; k10++)
{
for (int l11 = -1; l11 < 4; l11++)
{
int j12 = i2 + (k10 - 1) * l6 + j9 * i8;
int l12 = k4 + l11;
int j13 = (j3 + (k10 - 1) * i8) - j9 * l6;
if (l11 < 0 && !par1World.getBlockMaterial(j12, l12, j13).isSolid() || l11 >= 0 && !par1World.isAirBlock(j12, l12, j13))
{
break label0;
}
}
}
}
double d5 = ((double)k4 + 0.5D) - par2Entity.posY;
double d7 = d1 * d1 + d5 * d5 + d3 * d3;
if (d < 0.0D || d7 < d)
{
d = d7;
l = i2;
i1 = k4;
j1 = j3;
k1 = k5 % 4;
}
}
}
}
}
if (d < 0.0D)
{
for (int j2 = i - byte0; j2 <= i + byte0; j2++)
{
double d2 = ((double)j2 + 0.5D) - par2Entity.posX;
for (int k3 = k - byte0; k3 <= k + byte0; k3++)
{
double d4 = ((double)k3 + 0.5D) - par2Entity.posZ;
for (int l4 = 127; l4 >= 0; l4--)
{
if (!par1World.isAirBlock(j2, l4, k3))
{
continue;
}
for (; l4 > 0 && par1World.isAirBlock(j2, l4 - 1, k3); l4--) { }
label1:
for (int l5 = l1; l5 < l1 + 2; l5++)
{
int i7 = l5 % 2;
int j8 = 1 - i7;
for (int k9 = 0; k9 < 4; k9++)
{
for (int l10 = -1; l10 < 4; l10++)
{
int i12 = j2 + (k9 - 1) * i7;
int k12 = l4 + l10;
int i13 = k3 + (k9 - 1) * j8;
if (l10 < 0 && !par1World.getBlockMaterial(i12, k12, i13).isSolid() || l10 >= 0 && !par1World.isAirBlock(i12, k12, i13))
{
break label1;
}
}
}
double d6 = ((double)l4 + 0.5D) - par2Entity.posY;
double d8 = d2 * d2 + d6 * d6 + d4 * d4;
if (d < 0.0D || d8 < d)
{
d = d8;
l = j2;
i1 = l4;
j1 = k3;
k1 = l5 % 2;
}
}
}
}
}
}
int k2 = k1;
int l2 = l;
int i3 = i1;
int l3 = j1;
int i4 = k2 % 2;
int j4 = 1 - i4;
if (k2 % 4 >= 2)
{
i4 = -i4;
j4 = -j4;
}
if (d < 0.0D)
{
if (i1 < 70)
{
i1 = 70;
}
if (i1 > 118)
{
i1 = 118;
}
i3 = i1;
for (int i5 = -1; i5 <= 1; i5++)
{
for (int i6 = 1; i6 < 3; i6++)
{
for (int j7 = -1; j7 < 3; j7++)
{
int k8 = l2 + (i6 - 1) * i4 + i5 * j4;
int l9 = i3 + j7;
int i11 = (l3 + (i6 - 1) * j4) - i5 * i4;
boolean flag = j7 < 0;
par1World.setBlockWithNotify(k8, l9, i11, flag ? frame.blockID : 0);
}
}
}
}
for (int j5 = 0; j5 < 4; j5++)
{
par1World.editingBlocks = true;
for (int j6 = 0; j6 < 4; j6++)
{
for (int k7 = -1; k7 < 4; k7++)
{
int l8 = l2 + (j6 - 1) * i4;
int i10 = i3 + k7;
int j11 = l3 + (j6 - 1) * j4;
boolean flag1 = j6 == 0 || j6 == 3 || k7 == -1 || k7 == 3;
par1World.setBlockWithNotify(l8, i10, j11, flag1 ? frame.blockID : portal.blockID);
}
}
par1World.editingBlocks = false;
for (int k6 = 0; k6 < 4; k6++)
{
for (int l7 = -1; l7 < 4; l7++)
{
int i9 = l2 + (k6 - 1) * i4;
int j10 = i3 + l7;
int k11 = l3 + (k6 - 1) * j4;
par1World.notifyBlocksOfNeighborChange(i9, j10, k11, par1World.getBlockId(i9, j10, k11));
}
}
}
return true;
}
}
I Tried following your "mini" tutorial and it gave me this error(Even tho i used getLeavingMessage)
ERROR:
== MCP 6.0 (data: 6.0, client: 1.2.3, server: 1.2.3) ==
# found jad, jad patches, ff patches, osx patches, srgs, name csvs, doc csvs, pa
ram csvs, astyle, astyle config
== Recompiling client ==
> Cleaning bin
> Recompiling
'"C:\Program Files\Java\jdk1.7.0_03\bin\javac" -g -source 1.6 -target 1.6 -class
path "lib;lib\*;jars\...' failed : 1
== ERRORS FOUND ==
warning: [options] bootstrap class path not set in conjunction with -source 1.6
src\minecraft\net\minecraft\src\BlockDreamPortal.java:6: error: BlockDreamPort
al is not abstract and does not override abstract method getLeavingMessage() in
BlockDreamBase
public class BlockDreamPortal extends BlockPortalBase
^
1 error
1 warning
==================
!! Can not find server sources, try decompiling !!
and BlockDreamPortal:
package net.minecraft.src;
import java.util.List;
import java.util.ArrayList;
public class BlockDreamPortal extends BlockPortalBase
{
//Look in BlockPortalBase.java to see the full array of hooks you can use for your portal block.
public BlockDreamPortal(int i)
{
super(i, ModLoader.getUniqueSpriteIndex("/terrain.png"), Material.portal);
//Get a unique sprite index for the portal texture so that it doesn't override another
//texture.
}
public WorldProviderBase getDimension()
{
return new WorldProviderDream();
}
public Teleporter getTeleporter()
{
return new TeleporterDream();
}
public String getEnteringMessage()
{
return "Entering the Dream Dimension";
}
public String getLeavingMessage()
{
return "Leaving the Dream Dimension";
}
//You can get to this dimension from the overworld (0) and Nether (-1).
public List canTeleportFromDimension()
{
ArrayList list = new ArrayList();
list.add(0);
list.add(-1);
return list;
}
//You should probably make the portal non-solid so you can step into it...
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k)
{
return null;
}
//... and make it transparent/translucent also.
public boolean isOpaqueCube()
{
return false;
}
public boolean displayPortalOverlay()
{
return true;
}
public int getOverlayTexture()
{
return blockIndexInTexture;
}
public String getVersion()
{
return "1.2.3";
}
}
I've updated the API to include a few new features. If you are working from v1.1, you won't have to change anything in your code. (In other words, it's not mandatory that you update anything to the newer version.)
Add a class called TeleporterBase that makes it easier for people to add teleporters for their own dimension. It accepts 2 parameters, the frame block and the portal block. You use it like this:
-snip-
I've now added this in version 1.2 (TeleporterCustom.java), but I used my own code in order to include optional metadata sensitivity. Thanks for the suggestion and sample code.
I still can't figure it out how to add multiple biomes , this is what i did ;
i made a new WorldChunkManagertn.java file
i copied the originall WorldChunkManager.java into the WorldChunkManagertn.java
i replaced all the names to WorldChunkManagertn
After this do i need to make a new BiomeGenBase.java and copy it to my new BiomGenBase.java .
And then make a new Genlayertn.java and copy the originall GenLayer.java in that new file and replace the names.
Is that what i have to do ?
VirtualArts
That's basically what you have to do. You don't have to make your own BiomeGenBase, though; you can register the biomes in your mod_ file. You also only have to make new GenLayers where your dimension is different from the overworld (i.e. any that handle biomes).
It depends on how you want it to be activated. Use blockActivated in the portal frame's file or onItemUse in the file of the item that activates it. Implement my IItemUse interface if both the item and block are already present in the game. After that, make the game detect whether the frame block is present (if(world.getBlockId...)), and then make the portal spawn if the correct structure is in place. You can borrow code from the Nether portal (the method tryToCreatePortal) for this.
EDIT: I sat down and created it myself. Wasn't that hard. I'll just paste the code here. It teleports you on contact with given entity. Code is mostly taken from ItemTeleporterBase.
Yes, you should be able to implement the ISpecialTeleportation interface for entity-based teleportation. That's why I added that class.
public static final Block EugatnomPortal = (new BlockEugatnomPortal(132)
.setHardness(-1F).setStepSound(Block.soundGlassFootstep).setLightValue(0.75F).setBlockName("eugatnomPortal"));
An error shows up under "BlockEugatnomPortal" saying "Cannot instantiate the type BlockEugatnomPortal"
public static final Block EugatnomPortal = (new BlockEugatnomPortal(132)
.setHardness(-1F).setStepSound(Block.soundGlassFootstep).setLightValue(0.75F).setBlockName("eugatnomPortal"));
An error shows up under "BlockEugatnomPortal" saying "Cannot instantiate the type BlockEugatnomPortal"
Maybe you should change it to this:
public static final Block EugatnomPortal = (new BlockEugatnomPortal(132))
.setHardness(-1F).setStepSound(Block.soundGlassFootstep).setLightValue(0.75F).setBlockName("eugatnomPortal");
Oh I found the problem, I forgot that the BlockEugatnomPortal was giving me an error at the "public class BlockEugatnomPortal extends BlockPortalBase" so I changed it to public abstract class, but "public static final Block ePortal" in mod_Eugatnom file couldn't read that
It depends on how you want it to be activated. Use blockActivated in the portal frame's file or onItemUse in the file of the item that activates it. Implement my IItemUse interface if both the item and block are already present in the game. After that, make the game detect whether the frame block is present (if(world.getBlockId...)), and then make the portal spawn if the correct structure is in place. You can borrow code from the Nether portal (the method tryToCreatePortal) for this.
umm... yeah... code plz?
Rollback Post to RevisionRollBack
The creeper was once the crowning jewel of Minecraft... Until those retarded Endermen... FIGHT FOR CREEPER RIGHTS!!! SUPPORT THE CREEP MOD!
Firtsly, Thank You for the Excelent API, is Amazing.
Second, I think all is right, but My Portal not Work...
Do You can help me with this? The Game Start Normally, The problem is with the Portal, Not ignite.
In My Mod:
//Dimension
public mod_moonbase() {
DimensionAPI.registerDimension(new WorldProviderBlueAsteroid()); }
In WorldGen:
package net.minecraft.src;
public class WorldProviderBlueAsteroid extends WorldProviderBase
{
public int getDimensionID()
{
return 3;
}
public boolean renderClouds()
{
return false;
}
public boolean renderVoidFog()
{
return true;
}
public float setSunSize()
{
return 3.5F;
}
public float setMoonSize()
{
return 0.5F;
}
public boolean renderStars()
{
return true;
}
public boolean darkenSkyDuringRain()
{
return false;
}
public String getRespawnMessage()
{
return "Welcome to Moon!.";
}
public void registerWorldChunkManager()
{
worldChunkMgr = new WorldChunkManagerBlueAsteroid(worldObj);
}
public IChunkProvider getChunkProvider()
{
return new ChunkProviderBlueAsteroid(worldObj, worldObj.getSeed(), hasNoSky);
}
}
In Chunk Manager:
package net.minecraft.src;
import java.util.*;
public class WorldChunkManagerBlueAsteroid extends WorldChunkManager
{
private GenLayer genBiomes;
/** A GenLayer containing the indices into BiomeGenBase.biomeList[] */
private GenLayer biomeIndexLayer;
/** The BiomeCache object for this world. */
private BiomeCache biomeCache;
/** A list of biomes that the player can spawn in. */
private List biomesToSpawnIn;
protected WorldChunkManagerBlueAsteroid()
{
biomeCache = new BiomeCache(this);
biomesToSpawnIn = new ArrayList();
biomesToSpawnIn.add(BiomeGenBase.BlueAsteroid);
}
public WorldChunkManagerBlueAsteroid(long par1, WorldType par3WorldType)
{
this();
GenLayer agenlayer[] = GenLayer.func_48425_a(par1, par3WorldType);
genBiomes = agenlayer[0];
biomeIndexLayer = agenlayer[1];
}
public WorldChunkManagerBlueAsteroid(World par1World)
{
this(par1World.getSeed(), par1World.getWorldInfo().getTerrainType());
}
/**
* Gets the list of valid biomes for the player to spawn in.
*/
public List getBiomesToSpawnIn()
{
return biomesToSpawnIn;
}
/**
* Returns the BiomeGenBase related to the x, z position on the world.
*/
public BiomeGenBase getBiomeGenAt(int par1, int par2)
{
return biomeCache.getBiomeGenAt(par1, par2);
}
/**
* Returns a list of rainfall values for the specified blocks. Args: listToReuse, x, z, width, length.
*/
public float[] getRainfall(float par1ArrayOfFloat[], int par2, int par3, int par4, int par5)
{
IntCache.resetIntCache();
if (par1ArrayOfFloat == null || par1ArrayOfFloat.length < par4 * par5)
{
par1ArrayOfFloat = new float[par4 * par5];
}
int ai[] = biomeIndexLayer.getInts(par2, par3, par4, par5);
for (int i = 0; i < par4 * par5; i++)
{
float f = (float)BiomeGenBase.biomeList[ai[i]].getIntRainfall() / 65536F;
if (f > 1.0F)
{
f = 1.0F;
}
par1ArrayOfFloat[i] = f;
}
return par1ArrayOfFloat;
}
/**
* Return an adjusted version of a given temperature based on the y height
*/
public float getTemperatureAtHeight(float par1, int par2)
{
return par1;
}
/**
* Returns a list of temperatures to use for the specified blocks. Args: listToReuse, x, y, width, length
*/
public float[] getTemperatures(float par1ArrayOfFloat[], int par2, int par3, int par4, int par5)
{
IntCache.resetIntCache();
if (par1ArrayOfFloat == null || par1ArrayOfFloat.length < par4 * par5)
{
par1ArrayOfFloat = new float[par4 * par5];
}
int ai[] = biomeIndexLayer.getInts(par2, par3, par4, par5);
for (int i = 0; i < par4 * par5; i++)
{
float f = (float)BiomeGenBase.biomeList[ai[i]].getIntTemperature() / 65536F;
if (f > 1.0F)
{
f = 1.0F;
}
par1ArrayOfFloat[i] = f;
}
return par1ArrayOfFloat;
}
/**
* Returns an array of biomes for the location input.
*/
public BiomeGenBase[] getBiomesForGeneration(BiomeGenBase par1ArrayOfBiomeGenBase[], int par2, int par3, int par4, int par5)
{
IntCache.resetIntCache();
if (par1ArrayOfBiomeGenBase == null || par1ArrayOfBiomeGenBase.length < par4 * par5)
{
par1ArrayOfBiomeGenBase = new BiomeGenBase[par4 * par5];
}
int ai[] = genBiomes.getInts(par2, par3, par4, par5);
for (int i = 0; i < par4 * par5; i++)
{
par1ArrayOfBiomeGenBase[i] = BiomeGenBase.biomeList[ai[i]];
}
return par1ArrayOfBiomeGenBase;
}
/**
* Returns biomes to use for the blocks and loads the other data like temperature and humidity onto the
* WorldChunkManager Args: oldBiomeList, x, z, width, depth
*/
public BiomeGenBase[] loadBlockGeneratorData(BiomeGenBase par1ArrayOfBiomeGenBase[], int par2, int par3, int par4, int par5)
{
return getBiomeGenAt(par1ArrayOfBiomeGenBase, par2, par3, par4, par5, true);
}
/**
* Return a list of biomes for the specified blocks. Args: listToReuse, x, y, width, length, cacheFlag (if false,
* don't check biomeCache to avoid infinite loop in BiomeCacheBlock)
*/
public BiomeGenBase[] getBiomeGenAt(BiomeGenBase par1ArrayOfBiomeGenBase[], int par2, int par3, int par4, int par5, boolean par6)
{
IntCache.resetIntCache();
if (par1ArrayOfBiomeGenBase == null || par1ArrayOfBiomeGenBase.length < par4 * par5)
{
par1ArrayOfBiomeGenBase = new BiomeGenBase[par4 * par5];
}
if (par6 && par4 == 16 && par5 == 16 && (par2 & 0xf) == 0 && (par3 & 0xf) == 0)
{
BiomeGenBase abiomegenbase[] = biomeCache.getCachedBiomes(par2, par3);
System.arraycopy(abiomegenbase, 0, par1ArrayOfBiomeGenBase, 0, par4 * par5);
return par1ArrayOfBiomeGenBase;
}
int ai[] = biomeIndexLayer.getInts(par2, par3, par4, par5);
for (int i = 0; i < par4 * par5; i++)
{
par1ArrayOfBiomeGenBase[i] = BiomeGenBase.biomeList[ai[i]];
}
return par1ArrayOfBiomeGenBase;
}
/**
* checks given Chunk's Biomes against List of allowed ones
*/
public boolean areBiomesViable(int par1, int par2, int par3, List par4List)
{
int i = par1 - par3 >> 2;
int j = par2 - par3 >> 2;
int k = par1 + par3 >> 2;
int l = par2 + par3 >> 2;
int i1 = (k - i) + 1;
int j1 = (l - j) + 1;
int ai[] = genBiomes.getInts(i, j, i1, j1);
for (int k1 = 0; k1 < i1 * j1; k1++)
{
BiomeGenBase biomegenbase = BiomeGenBase.biomeList[ai[k1]];
if (!par4List.contains(biomegenbase))
{
return false;
}
}
return true;
}
/**
* Finds a valid position within a range, that is once of the listed biomes.
*/
public ChunkPosition findBiomePosition(int par1, int par2, int par3, List par4List, Random par5Random)
{
int i = par1 - par3 >> 2;
int j = par2 - par3 >> 2;
int k = par1 + par3 >> 2;
int l = par2 + par3 >> 2;
int i1 = (k - i) + 1;
int j1 = (l - j) + 1;
int ai[] = genBiomes.getInts(i, j, i1, j1);
ChunkPosition chunkposition = null;
int k1 = 0;
for (int l1 = 0; l1 < ai.length; l1++)
{
int i2 = i + l1 % i1 << 2;
int j2 = j + l1 / i1 << 2;
BiomeGenBase biomegenbase = BiomeGenBase.biomeList[ai[l1]];
if (par4List.contains(biomegenbase) && (chunkposition == null || par5Random.nextInt(k1 + 1) == 0))
{
chunkposition = new ChunkPosition(i2, 0, j2);
k1++;
}
}
return chunkposition;
}
/**
* Calls the WorldChunkManager's biomeCache.cleanupCache()
*/
public void cleanupCache()
{
biomeCache.cleanupCache();
}
}
In PortalBlock:
package net.minecraft.src;
import java.util.Random;
import java.util.*;
public class BlockEclipse extends BlockPortalBase
{
public BlockEclipse(int i, int j)
{
super(i, j, Material.portal);
}
public int idDropped(int i, Random random)
{
return mod_moonbase.Eclipse.blockID;
}
public int quantityDropped(Random random)
{
return 1;
}
//required:
public WorldProviderBase getDimension()
{
return new WorldProviderBlueAsteroid();
}
public Teleporter getTeleporter()
{
return new TeleporterBlueAsteroid();
}
public String getEnteringMessage()
{
return "Entering in the Moon";
}
public String getLeavingMessage()
{
return "Leaving of The Moon";
}
//not required:
public boolean isPortalImmediate()
{
return false;//does have a delay
}
public boolean displayPortalAnimation()
{
return true;//displays Nether portal animation
}
public List canTeleportFromDimension()
{
ArrayList arraylist = new ArrayList();
arraylist.add(Integer.valueOf(0));//player can teleport from overworld to this dimension
arraylist.add(Integer.valueOf(-1));//player can teleport from Nether to this dimension
return arraylist;
}
public int returnsPlayerToDimension()
{
return 0;//returns player to the Nether
}
public double getDistanceRatio()
{
return 0.2D;//slow travel
}
public int getPortalDelay()
{
return 150;//default
}
public int getBlockTextureFromSideAndMetadata(int i, int j)
{
return getBlockTextureFromSide(i);
}
public int getBlockTextureFromSide(int i)
{
if (i == 0)
{
return mod_moonbase.EclipseBottom;
}
if (i == 1)
{
return mod_moonbase.EclipseBottom;
}
else
{
return mod_moonbase.EclipseSides;
}
}
}
In teleporter:
package net.minecraft.src;
public class TeleporterBlueAsteroid extends Teleporter{
}
Hey can you edit worldgen and all that using this API?
This API doesn't touch world gen, as you can already do just about anything in your new dimension's files (the ChunkProvider, specifically) as far as world gen goes. Look at my reply below for adding world gen to your dimension.
Not a a classic generation, i want to generate in a new dimension.
generateSurface is for generation in Normal dimension, for Nether must use a WorldGenNether, but for new dimension i don't find the good Worldgen :/
What VirtualArts said; place all world gen for your dimension under the populate method in your ChunkProvider.
The code for it is mostly already in the game; look at the method tryToCreatePortal in BlockPortal, and use either blockActivated or onItemUse to call it.
public Teleporter getTeleporter()
{
return new TeleporterExample()
}
I'm not so sure what to do with this... Thanks for the API! And how big do the moon and sun have to be?
Edit: How do I add an ignite type of thing? Like the flint and steel?
Edit... again: And, what do I do with this? Sorry I'm a total modding noob...
public void registerWorldChunkManager()
{
worldChunkMgr = new WorldChunkManagerExample(worldObj);
}
public IChunkProvider getChunkProvider()
{
return new ChunkProviderExample(worldObj, worldObj.getWorldSeed());
}
}
It's really not that hard. You basically just have to copy the existing GenLayers where necessary (any of the ones that have to do with biomes), and then, in your base GenLayer (which is basically just a copy of GenLayer.java), replace the proper class names with yours.
Basically what VirtualArts said. Replace line 138 with:
... and get rid of line 140, I guess. If that doesn't work, download the sources of the Forge version and replace that file with the source file.
Um, they should be under Instructions for Modders like all the important stuff is.
It might not be working because of that Minecraft bug. I guess I should go ahead and release a patch for that today.
Super cool Api, I'm going to start making my dimension
thanks for the help
Add a class called TeleporterBase that makes it easier for people to add teleporters for their own dimension. It accepts 2 parameters, the frame block and the portal block. You use it like this:
Here is the code:
ERROR:
and BlockDreamPortal:
I've always kept them in the changelog.
I really can't tell what it is. Maybe I'll include a biome generation tutorial at some point, but please don't wait for it.
I've now added this in version 1.2 (TeleporterCustom.java), but I used my own code in order to include optional metadata sensitivity. Thanks for the suggestion and sample code.
Huh, I don't know what's going wrong there... what is BlockDreamBase, though?
Yes to both.
That's basically what you have to do. You don't have to make your own BiomeGenBase, though; you can register the biomes in your mod_ file. You also only have to make new GenLayers where your dimension is different from the overworld (i.e. any that handle biomes).
I'll keep updating it as long as a superior client/server dimension API doesn't come up.
hmm... you shouldn't be getting those errors, the code looks fine. Reinstall MCP?
It depends on how you want it to be activated. Use blockActivated in the portal frame's file or onItemUse in the file of the item that activates it. Implement my IItemUse interface if both the item and block are already present in the game. After that, make the game detect whether the frame block is present (if(world.getBlockId...)), and then make the portal spawn if the correct structure is in place. You can borrow code from the Nether portal (the method tryToCreatePortal) for this.
Put world generation under the populate method in your ChunkProvider, and get rid of biomegenbase.decorate if it's present there.
Yes, you should be able to implement the ISpecialTeleportation interface for entity-based teleportation. That's why I added that class.
An error shows up under "BlockEugatnomPortal" saying "Cannot instantiate the type BlockEugatnomPortal"
Maybe you should change it to this:
Firtsly, Thank You for the Excelent API, is Amazing.
Second, I think all is right, but My Portal not Work...
Do You can help me with this? The Game Start Normally, The problem is with the Portal, Not ignite.
In My Mod:
In WorldGen:
In Chunk Manager:
In teleporter:
I'm Put in Spoilers, for Not "Flood" the Topic
Thank You.
This API doesn't touch world gen, as you can already do just about anything in your new dimension's files (the ChunkProvider, specifically) as far as world gen goes. Look at my reply below for adding world gen to your dimension.
What VirtualArts said; place all world gen for your dimension under the populate method in your ChunkProvider.
The code for it is mostly already in the game; look at the method tryToCreatePortal in BlockPortal, and use either blockActivated or onItemUse to call it.
Um... what exactly is the problem?
Did you code it to ignite? It won't do so automatically, as there are a near infinite number of possibilities on how you could activate a portal.
I'm try only Walk and Not Get the Dimension...
Probably Not... But without Inginite, The Portal Need start right?
I'm not so sure what to do with this... Thanks for the API! And how big do the moon and sun have to be?
Edit: How do I add an ignite type of thing? Like the flint and steel?
Edit... again: And, what do I do with this? Sorry I'm a total modding noob...