Well, that'd be editing a baseclass and wouldn't be very optimal...
But that's really the only way to do that if you're not using Forge.
Rollback Post to RevisionRollBack
When life gives you a potato, wonder why the heck life just gave you a potato. Why not something else? Like money? Or a combustable lemon? No, you get a potato. Nothing else.
Hey TechGuy, I think Forge tutorials is a great idea, but you should put that (and other tutorial improvements) on hold once the official API comes out so we can learn how to use it.
Hey TechGuy, I think Forge tutorials is a great idea, but you should put that (and other tutorial improvements) on hold once the official API comes out so we can learn how to use it.
Well, my understanding is that it will be somewhat native to what we already know; i.e. it won't be like going from ModLoader to FML, but people won't have to re-learn everything. Plus, people will still probably use Forge/FML/ML even after the initial API release. I hope it's not just a bukkit-API clone, that's kind of a pain...
When life gives you a potato, wonder why the heck life just gave you a potato. Why not something else? Like money? Or a combustable lemon? No, you get a potato. Nothing else.
Well, my understanding is that it will be somewhat native to what we already know; i.e. it won't be like going from ModLoader to FML, but people won't have to re-learn everything. Plus, people will still probably use Forge/FML/ML even after the initial API release. I hope it's not just a bukkit-API clone, that's kind of a pain...
That's good, I wouldn't want to have to learn an entirely new API, but I hope there are new functions that make easier ways of doing things.
Hi, I'm trying to make a block that faces toward the player when it's placed...
This is what I have so far:
public void onBlockPlacedBy(World world, int par2, int par3, int par4, EntityLiving entity)
{
byte var10 = 0;
int var11 = MathHelper.floor_double((double)(entity.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
if(var11 == 0)
{
var10 = 2;
}
if(var11 == 1)
{
var10 = 5;
}
if(var11 == 2)
{
var10 = 3;
}
if(var11 == 3)
{
var10 = 4;
}
world.setBlockMetadataWithNotify(par2, par3, par4 - 1, var10 - 1);
}
public int getBlockTextureFromSideAndMetadata(int i, int j)
{
if(j == 1)
return i == 3 ? mod_Raspberries.freezerFront : i == 2 ? mod_Raspberries.freezerBack : i == 1 || i == 0 ? mod_Raspberries.freezerTop : i == 4 ? mod_Raspberries.freezerLeftSide : i == 5 ? mod_Raspberries.freezerRightSide : mod_Raspberries.freezerRightSide;
else if (j == 2)
return i == 3 ? mod_Raspberries.freezerFront : i == 2 ? mod_Raspberries.freezerBack : i == 1 || i == 0 ? mod_Raspberries.freezerTop : i == 4 ? mod_Raspberries.freezerLeftSide : i == 5 ? mod_Raspberries.freezerRightSide : mod_Raspberries.freezerRightSide;
else if (j == 3)
return i == 3 ? mod_Raspberries.freezerFront : i == 2 ? mod_Raspberries.freezerBack : i == 1 || i == 0 ? mod_Raspberries.freezerTop : i == 4 ? mod_Raspberries.freezerLeftSide : i == 5 ? mod_Raspberries.freezerRightSide : mod_Raspberries.freezerRightSide;
else if (j == 4)
return i == 3 ? mod_Raspberries.freezerFront : i == 2 ? mod_Raspberries.freezerBack : i == 1 || i == 0 ? mod_Raspberries.freezerTop : i == 4 ? mod_Raspberries.freezerLeftSide : i == 5 ? mod_Raspberries.freezerRightSide : mod_Raspberries.freezerRightSide;
else
return mod_Raspberries.freezerBack
}
I got the code for onBlockPlacedBy from BlockChest and I wrote the code for getBlockTextureAndMetadata. What seems to be happening is that the else statement goes every time and it just uses the freezerBack texture. What did I do wrong?
This post still remains unnoticed and not helped...
I am so happy and everything in my mod is working so far except for one thing: My stairs look like an ordinary block, and once again there are no errors. I'm not sure if this is common or not, but here is my coding:
package net.minecraft.src;
import java.util.List;
import java.util.Random;
public class BlockGlass_Stairs extends Block
{
public static final int[][] field_72159_a = new int[][] {{2, 6}, {3, 7}, {2, 3}, {6, 7}, {0, 4}, {1, 5}, {0, 1}, {4, 5}};
public boolean field_72156_cr = false;
private int field_72160_cs = 0;
protected BlockGlass_Stairs(int i, int j)
{
super(i, j, Material.glass);
this.setLightOpacity(0);
this.setCreativeTab(CreativeTabs.tabBlock);
}
public void setBlockBoundsBaseOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
{
if (this.field_72156_cr)
{
this.setBlockBounds(0.5F * (float)(this.field_72160_cs % 2), 0.5F * (float)(this.field_72160_cs / 2 % 2), 0.5F * (float)(this.field_72160_cs / 4 % 2), 0.5F + 0.5F * (float)(this.field_72160_cs % 2), 0.5F + 0.5F * (float)(this.field_72160_cs / 2 % 2), 0.5F + 0.5F * (float)(this.field_72160_cs / 4 % 2));
}
else
{
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
}
public boolean isOpaqueCube()
{
return false;
}
public boolean randerAsNormalBlock()
{
return false;
}
public int genRenderType()
{
return 10;
}
public void addCollidingBlockToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity)
{
int var8 = par1World.getBlockMetadata(par2, par3, par4);
int var9 = var8 & 3;
float var10 = 0.0f;
float var11 = 0.5f;
float var12 = 0.5f;
float var13 = 1.0f;
if ((var8 & 4) != 0)
{
var10 = 0.5f;
var11 = 1.0f;
var12 = 0.0f;
var13 = 0.5f;
}
this.setBlockBounds(0.0F, var10, 0.0F, 1.0F, var11, 1.0F);
super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
if (var9 == 0)
{
this.setBlockBounds(0.5F, var12, 0.0F, 1.0F, var13, 1.0F);
super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
}
else if (var9 == 1)
{
this.setBlockBounds(0.0F, var12, 0.0F, 0.5F, var13, 1.0F);
super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
}
else if (var9 == 2)
{
this.setBlockBounds(0.0F, var12, 0.5F, 1.0F, var13, 1.0F);
super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
}
else if (var9 == 3)
{
this.setBlockBounds(0.0F, var12, 0.0F, 1.0F, var13, 0.5F);
super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
}
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving)
{
int var6 = MathHelper.floor_double((double)(par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
int var7 = par1World.getBlockMetadata(par2, par3, par4) & 4;
if (var6 == 0)
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, 2 | var7);
}
if (var6 == 1)
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, 1 | var7);
}
if (var6 == 2)
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, 3 | var7);
}
if (var6 == 3)
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, 0 | var7);
}
}
public void updateBlockMetadata(World par1World, int par2, int par3, int par4, int par5, float par6, float par7, float par8)
{
if (par5 == 0 || par5 != 1 && (double)par7 > 0.5D)
{
int var9 = par1World.getBlockMetadata(par2, par3, par4);
par1World.setBlockMetadataWithNotify(par2, par3, par4, var9 | 4);
}
}
public MovingObjectPosition collisionRayTrace(World par1World, int par2, int par3, int par4, Vec3 par5Vec3, Vec3 par6Vec3)
{
MovingObjectPosition[] var7 = new MovingObjectPosition[8];
int var8 = par1World.getBlockMetadata(par2, par3, par4);
int var9 = var8 & 3;
boolean var10 = (var8 & 4) == 4;
int[] var11 = field_72159_a[var9 + (var10 ? 4 : 0)];
this.field_72156_cr = true;
int var14;
int var15;
int var16;
for (int var12 = 0; var12 < 8; ++var12)
{
this.field_72160_cs = var12;
int[] var13 = var11;
var14 = var11.length;
for (var15 = 0; var15 < var14; ++var15)
{
var16 = var13[var15];
if (var16 == var12)
{
;
}
}
var7[var12] = super.collisionRayTrace(par1World, par2, par3, par4, par5Vec3, par6Vec3);
}
int[] var21 = var11;
int var24 = var11.length;
for (var14 = 0; var14 < var24; ++var14)
{
var15 = var21[var14];
var7[var15] = null;
}
MovingObjectPosition var23 = null;
double var22 = 0.0D;
MovingObjectPosition[] var25 = var7;
var16 = var7.length;
for (int var17 = 0; var17 < var16; ++var17)
{
MovingObjectPosition var18 = var25[var17];
if (var18 != null)
{
double var19 = var18.hitVec.squareDistanceTo(par6Vec3);
if (var19 > var22)
{
var23 = var18;
var22 = var19;
}
}
}
return var23;
}
}
It's probably something simple, but it is beyond me.
That's good, I wouldn't want to have to learn an entirely new API, but I hope there are new functions that make easier ways of doing things.
But, really though, I doubt that they'll make it something entirely new or complicated; I don't remember if it was Jeb_ or Dinnerbone who said that they were going to make it easy enough so that they'll use it themselves.
Plus, if they were to make a pointless and/or difficult API then people will just keep using Forge or ModLoader.
Oh, and if you're wondering how to set your blocks harvest level without editing a baseclass, you could use ForgeModLoader. They have a really simple way of setting it.
When life gives you a potato, wonder why the heck life just gave you a potato. Why not something else? Like money? Or a combustable lemon? No, you get a potato. Nothing else.
I've made a custom crop, opium. It should have three growth stages however when the seeds are planted instead of starting at the lowest stage they just instantly end up at their final harvestable stage. I followed the tutorial by TechGuy but he hasn't replied to a few posts I've made so I was hoping someone could read over my code.
mod_MUI
package net.minecraft.src;
import java.util.Random;
public class mod_MUI extends BaseMod
{
//OPIUM CROP SETUP
public static final Block opiumblock = new BlockOpiumBlock(165, 0).setBlockName("opiumblock");
public static final Item opiumseeds = new ItemOpiumSeeds(909, opiumblock.blockID, Block.tilledField.blockID).setItemName("opiumseeds");
//CROP STAGES
public static int opiumstageone = ModLoader.addOverride("/terrain.png", "/crops/opiumstageone.png");
public static int opiumstagetwo = ModLoader.addOverride("/terrain.png", "/crops/opiumstagetwo.png");
public static int opiumstagethree = ModLoader.addOverride("/terrain.png", "/crops/opiumstagethree.png");
public void load()
{
/////////
//CROPS//
/////////
//Opium Poppy
opiumblock.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/opoppy.png");
ModLoader.registerBlock(opiumblock);
ModLoader.addName(opiumblock, "Opium Poppy");
//Opium Seeds
opiumseeds.iconIndex = ModLoader.addOverride("/gui/items.png", "/opiumseeds.png");
ModLoader.addName(opiumseeds, "Opium Poppy Seeds");
opiumseeds.setTabToDisplayOn(CreativeTabs.tabMaterials);
}
public String getVersion()
{
return "0.1a";
}
}
BlockOpiumBlock
package net.minecraft.src;
import java.util.Random;
public class BlockOpiumBlock extends BlockFlower
{
public BlockOpiumBlock(int i, int j)
{
super(i, j);
blockIndexInTexture = j;
setTickRandomly(true);
float f = 0.5F;
setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.25F, 0.5F + f);
}
/**
* Gets passed in the blockID of the block below and supposed to return true if its allowed to grow on the type of
* blockID passed in. Args: blockID.
* This basically checks to see if the block below is a tilled field/tilled dirt. If it is true then the crop can grow.
*/
protected boolean canThisPlantGrowOnThisBlockID(int par1)
{
return par1 == Block.tilledField.blockID;
}
/**
* Ticks the block if it's been scheduled. This method gets scheduled to run because of the setTickRandomly part in the constructor of the class.
*/
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
{
super.updateTick(par1World, par2, par3, par4, par5Random);
if (par1World.getBlockLightValue(par2, par3 + 1, par4) >= 9)
{
int i = par1World.getBlockMetadata(par2, par3, par4);
if (i < 3)
{
float f = getGrowthRate(par1World, par2, par3, par4);
if (par5Random.nextInt((int)(25F / f) + 1) == 0)
{
i++;
par1World.setBlockMetadataWithNotify(par2, par3, par4, i);
}
}
}
}
/**
* Gets the growth rate for the crop. Setup to encourage rows by halving growth rate if there is diagonals, crops on
* different sides that aren't opposing, and by adding growth for every crop next to this one (and for crop below
* this one). Args: x, y, z
*/
private float getGrowthRate(World par1World, int par2, int par3, int par4)
{
float f = 1.0F;
int i = par1World.getBlockId(par2, par3, par4 - 1);
int j = par1World.getBlockId(par2, par3, par4 + 1);
int k = par1World.getBlockId(par2 - 1, par3, par4);
int l = par1World.getBlockId(par2 + 1, par3, par4);
int i1 = par1World.getBlockId(par2 - 1, par3, par4 - 1);
int j1 = par1World.getBlockId(par2 + 1, par3, par4 - 1);
int k1 = par1World.getBlockId(par2 + 1, par3, par4 + 1);
int l1 = par1World.getBlockId(par2 - 1, par3, par4 + 1);
boolean flag = k == blockID || l == blockID;
boolean flag1 = i == blockID || j == blockID;
boolean flag2 = i1 == blockID || j1 == blockID || k1 == blockID || l1 == blockID;
for (int i2 = par2 - 1; i2 <= par2 + 1; i2++)
{
for (int j2 = par4 - 1; j2 <= par4 + 1; j2++)
{
int k2 = par1World.getBlockId(i2, par3 - 1, j2);
float f1 = 0.0F;
if (k2 == Block.tilledField.blockID)
{
f1 = 1.0F;
if (par1World.getBlockMetadata(i2, par3 - 1, j2) > 0)
{
f1 = 3F;
}
}
if (i2 != par2 || j2 != par4)
{
f1 /= 4F;
}
f += f1;
}
}
if (flag2 || flag && flag1)
{
f /= 2.0F;
}
return f;
}
/**
* The type of render function that is called for this block. The render type of 6 gets the texture and places it four times around the sides of the block and leaves nothing on the top or bottom.
*/
public int getRenderType()
{
return 1;
}
/**
* Drops the block items with a specified chance of dropping the specified items
*/
public void dropBlockAsItemWithChance(World par1World, int par2, int par3, int par4, int par5, float par6, int par7)
{
float f = 0.7F;
float f1 = par1World.rand.nextFloat() * f + (1.0F - f) * 0.5F;
float f2 = par1World.rand.nextFloat() * f + (1.0F - f) * 0.5F;
float f3 = par1World.rand.nextFloat() * f + (1.0F - f) * 0.5F;
EntityItem entityitem = new EntityItem(par1World, (float)par2 + f1, (float)par3 + f2, (float)par4 + f3, new ItemStack(mod_MUI.opiumblock));
entityitem.delayBeforeCanPickup = 10;
par1World.spawnEntityInWorld(entityitem);
}
/**
* Returns the ID of the items to drop on destruction. "i" is equal to the blocks metadata value(explained slightly more in the getBlockTextureFromSideAndMetadata method below). This means that it will check that that value is equal to 8(the final stage of growth) and if it is then it will drop wheat. It may be fairly obvious, but the 'else' statement means that if the growth state is not equal to 7 then drop nothing (-1 means nothing)
*/
public int idDropped(int i, Random random, int j)
{
if (i == 8)
{
return mod_MUI.opiumblock.blockID;
}
else
{
return -1;
}
}
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random random)
{
return 1;
}
/**
* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata.
* As you may have been able to tell from the line above, "j" is equal to the metadata value of the block. This checks if that value is equal to a certain number then sets the blocks texture to what you have defined.
* The things that are being returned are the ints in your mod_ class which you created and set to your texture for the specific stages of growth.
*/
public int getBlockTextureFromSideAndMetadata(int i, int j)
{
if(j == 0)
{
return blockIndexInTexture;
}
if(j == 1)
{
return mod_MUI.opiumstageone;
}
if(j == 2)
{
return mod_MUI.opiumstagetwo;
}
if(j == 3)
{
return mod_MUI.opiumstagethree;
}
return j;
}
}
ItemOpiumSeeds
package net.minecraft.src;
public class ItemOpiumSeeds extends Item
{
/** The type of block this seed turns into (wheat or pumpkin stems for instance)*/
private int blockType;
/** BlockID of the block the seeds can be planted on. */
private int soilBlockID;
public ItemOpiumSeeds(int i, int j, int k)
{
super(i);
blockType = j;
soilBlockID = k;
}
/**
* Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
* True if something happen and false if it don't. This is for ITEMS, not BLOCKS !
*/
public boolean tryPlaceIntoWorld(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
{
if (par7 != 1)
{
return false;
}
if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6) || !par2EntityPlayer.canPlayerEdit(par4, par5 + 1, par6))
{
return false;
}
int i = par3World.getBlockId(par4, par5, par6);
if (i == soilBlockID && par3World.isAirBlock(par4, par5 + 1, par6))
{
par3World.setBlockWithNotify(par4, par5 + 1, par6, blockType);
par1ItemStack.stackSize--;
return true;
}
else
{
return false;
}
}
}
Also, I was noticing all the containers have "TileEntities". If you are making a container, would you need one of these, and if so, how would you go about coding one?
Also, I was noticing all the containers have "TileEntities". If you are making a container, would you need one of these, and if so, how would you go about coding one?
Well, the TIleEntities are for blocks that store additional data. Like a chest, for example. It's not a normal block; it stores items, and when destroyed drops them. Most of that information is defined in a TileEntities class.
But anyway, yes, you will need a TileEntity class if you want to make a container. Going about coding one would be a lot of copy-paste and editing.
When life gives you a potato, wonder why the heck life just gave you a potato. Why not something else? Like money? Or a combustable lemon? No, you get a potato. Nothing else.
So I just started your tutorials and all. I'm working on the block. I've folled instructions twice, searched for similar problems and still can't get it to work. No errors appear at all. It all runs. But the block won't appear in game. Help would be much appreciated.
Mod_Experiments
package net.minecraft.src;
public class Mod_Experiments extends BaseMod
{
public static final Block pinkBlock = new BlockPinkBlock(160, 0) .setBlockName("Pink Block") .setHardness(0.7F) .setCreativeTab(CreativeTabs.tabAllSearch) .setStepSound(Block.soundGrassFootstep);
awesome mod tutorials, i only wonder how to make blocks only spawn in caves
Well, you could just set the generate so that it would need a block of air nearby in order to spawn, and then set the spawn height to the desired height
I am so happy and everything in my mod is working so far except for one thing: My stairs look like an ordinary block, and once again there are no errors. I'm not sure if this is common or not, but here is my coding:
package net.minecraft.src;
import java.util.List;
import java.util.Random;
public class BlockGlass_Stairs extends Block
{
public static final int[][] field_72159_a = new int[][] {{2, 6}, {3, 7}, {2, 3}, {6, 7}, {0, 4}, {1, 5}, {0, 1}, {4, 5}};
public boolean field_72156_cr = false;
private int field_72160_cs = 0;
protected BlockGlass_Stairs(int i, int j)
{
super(i, j, Material.glass);
this.setLightOpacity(0);
this.setCreativeTab(CreativeTabs.tabBlock);
}
public void setBlockBoundsBaseOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
{
if (this.field_72156_cr)
{
this.setBlockBounds(0.5F * (float)(this.field_72160_cs % 2), 0.5F * (float)(this.field_72160_cs / 2 % 2), 0.5F * (float)(this.field_72160_cs / 4 % 2), 0.5F + 0.5F * (float)(this.field_72160_cs % 2), 0.5F + 0.5F * (float)(this.field_72160_cs / 2 % 2), 0.5F + 0.5F * (float)(this.field_72160_cs / 4 % 2));
}
else
{
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
}
public boolean isOpaqueCube()
{
return false;
}
public boolean randerAsNormalBlock()
{
return false;
}
public int genRenderType()
{
return 10;
}
public void addCollidingBlockToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity)
{
int var8 = par1World.getBlockMetadata(par2, par3, par4);
int var9 = var8 & 3;
float var10 = 0.0f;
float var11 = 0.5f;
float var12 = 0.5f;
float var13 = 1.0f;
if ((var8 & 4) != 0)
{
var10 = 0.5f;
var11 = 1.0f;
var12 = 0.0f;
var13 = 0.5f;
}
this.setBlockBounds(0.0F, var10, 0.0F, 1.0F, var11, 1.0F);
super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
if (var9 == 0)
{
this.setBlockBounds(0.5F, var12, 0.0F, 1.0F, var13, 1.0F);
super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
}
else if (var9 == 1)
{
this.setBlockBounds(0.0F, var12, 0.0F, 0.5F, var13, 1.0F);
super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
}
else if (var9 == 2)
{
this.setBlockBounds(0.0F, var12, 0.5F, 1.0F, var13, 1.0F);
super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
}
else if (var9 == 3)
{
this.setBlockBounds(0.0F, var12, 0.0F, 1.0F, var13, 0.5F);
super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
}
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving)
{
int var6 = MathHelper.floor_double((double)(par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
int var7 = par1World.getBlockMetadata(par2, par3, par4) & 4;
if (var6 == 0)
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, 2 | var7);
}
if (var6 == 1)
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, 1 | var7);
}
if (var6 == 2)
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, 3 | var7);
}
if (var6 == 3)
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, 0 | var7);
}
}
public void updateBlockMetadata(World par1World, int par2, int par3, int par4, int par5, float par6, float par7, float par8)
{
if (par5 == 0 || par5 != 1 && (double)par7 > 0.5D)
{
int var9 = par1World.getBlockMetadata(par2, par3, par4);
par1World.setBlockMetadataWithNotify(par2, par3, par4, var9 | 4);
}
}
public MovingObjectPosition collisionRayTrace(World par1World, int par2, int par3, int par4, Vec3 par5Vec3, Vec3 par6Vec3)
{
MovingObjectPosition[] var7 = new MovingObjectPosition[8];
int var8 = par1World.getBlockMetadata(par2, par3, par4);
int var9 = var8 & 3;
boolean var10 = (var8 & 4) == 4;
int[] var11 = field_72159_a[var9 + (var10 ? 4 : 0)];
this.field_72156_cr = true;
int var14;
int var15;
int var16;
for (int var12 = 0; var12 < 8; ++var12)
{
this.field_72160_cs = var12;
int[] var13 = var11;
var14 = var11.length;
for (var15 = 0; var15 < var14; ++var15)
{
var16 = var13[var15];
if (var16 == var12)
{
;
}
}
var7[var12] = super.collisionRayTrace(par1World, par2, par3, par4, par5Vec3, par6Vec3);
}
int[] var21 = var11;
int var24 = var11.length;
for (var14 = 0; var14 < var24; ++var14)
{
var15 = var21[var14];
var7[var15] = null;
}
MovingObjectPosition var23 = null;
double var22 = 0.0D;
MovingObjectPosition[] var25 = var7;
var16 = var7.length;
for (int var17 = 0; var17 < var16; ++var17)
{
MovingObjectPosition var18 = var25[var17];
if (var18 != null)
{
double var19 = var18.hitVec.squareDistanceTo(par6Vec3);
if (var19 > var22)
{
var23 = var18;
var22 = var19;
}
}
}
return var23;
}
}
It's probably something simple, but it is beyond me.
-
View User Profile
-
View Posts
-
Send Message
Retired StaffWell, that'd be editing a baseclass and wouldn't be very optimal...
But that's really the only way to do that if you're not using Forge.
-
View User Profile
-
View Posts
-
Send Message
Retired StaffWell, my understanding is that it will be somewhat native to what we already know; i.e. it won't be like going from ModLoader to FML, but people won't have to re-learn everything. Plus, people will still probably use Forge/FML/ML even after the initial API release. I hope it's not just a bukkit-API clone, that's kind of a pain...
That's good, I wouldn't want to have to learn an entirely new API, but I hope there are new functions that make easier ways of doing things.
Thank you for the Help!
This post still remains unnoticed and not helped...
package net.minecraft.src; import java.util.List; import java.util.Random; public class BlockGlass_Stairs extends Block { public static final int[][] field_72159_a = new int[][] {{2, 6}, {3, 7}, {2, 3}, {6, 7}, {0, 4}, {1, 5}, {0, 1}, {4, 5}}; public boolean field_72156_cr = false; private int field_72160_cs = 0; protected BlockGlass_Stairs(int i, int j) { super(i, j, Material.glass); this.setLightOpacity(0); this.setCreativeTab(CreativeTabs.tabBlock); } public void setBlockBoundsBaseOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) { if (this.field_72156_cr) { this.setBlockBounds(0.5F * (float)(this.field_72160_cs % 2), 0.5F * (float)(this.field_72160_cs / 2 % 2), 0.5F * (float)(this.field_72160_cs / 4 % 2), 0.5F + 0.5F * (float)(this.field_72160_cs % 2), 0.5F + 0.5F * (float)(this.field_72160_cs / 2 % 2), 0.5F + 0.5F * (float)(this.field_72160_cs / 4 % 2)); } else { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } } public boolean isOpaqueCube() { return false; } public boolean randerAsNormalBlock() { return false; } public int genRenderType() { return 10; } public void addCollidingBlockToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity) { int var8 = par1World.getBlockMetadata(par2, par3, par4); int var9 = var8 & 3; float var10 = 0.0f; float var11 = 0.5f; float var12 = 0.5f; float var13 = 1.0f; if ((var8 & 4) != 0) { var10 = 0.5f; var11 = 1.0f; var12 = 0.0f; var13 = 0.5f; } this.setBlockBounds(0.0F, var10, 0.0F, 1.0F, var11, 1.0F); super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity); if (var9 == 0) { this.setBlockBounds(0.5F, var12, 0.0F, 1.0F, var13, 1.0F); super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity); } else if (var9 == 1) { this.setBlockBounds(0.0F, var12, 0.0F, 0.5F, var13, 1.0F); super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity); } else if (var9 == 2) { this.setBlockBounds(0.0F, var12, 0.5F, 1.0F, var13, 1.0F); super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity); } else if (var9 == 3) { this.setBlockBounds(0.0F, var12, 0.0F, 1.0F, var13, 0.5F); super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity); } this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving) { int var6 = MathHelper.floor_double((double)(par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; int var7 = par1World.getBlockMetadata(par2, par3, par4) & 4; if (var6 == 0) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 2 | var7); } if (var6 == 1) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 1 | var7); } if (var6 == 2) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 3 | var7); } if (var6 == 3) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 0 | var7); } } public void updateBlockMetadata(World par1World, int par2, int par3, int par4, int par5, float par6, float par7, float par8) { if (par5 == 0 || par5 != 1 && (double)par7 > 0.5D) { int var9 = par1World.getBlockMetadata(par2, par3, par4); par1World.setBlockMetadataWithNotify(par2, par3, par4, var9 | 4); } } public MovingObjectPosition collisionRayTrace(World par1World, int par2, int par3, int par4, Vec3 par5Vec3, Vec3 par6Vec3) { MovingObjectPosition[] var7 = new MovingObjectPosition[8]; int var8 = par1World.getBlockMetadata(par2, par3, par4); int var9 = var8 & 3; boolean var10 = (var8 & 4) == 4; int[] var11 = field_72159_a[var9 + (var10 ? 4 : 0)]; this.field_72156_cr = true; int var14; int var15; int var16; for (int var12 = 0; var12 < 8; ++var12) { this.field_72160_cs = var12; int[] var13 = var11; var14 = var11.length; for (var15 = 0; var15 < var14; ++var15) { var16 = var13[var15]; if (var16 == var12) { ; } } var7[var12] = super.collisionRayTrace(par1World, par2, par3, par4, par5Vec3, par6Vec3); } int[] var21 = var11; int var24 = var11.length; for (var14 = 0; var14 < var24; ++var14) { var15 = var21[var14]; var7[var15] = null; } MovingObjectPosition var23 = null; double var22 = 0.0D; MovingObjectPosition[] var25 = var7; var16 = var7.length; for (int var17 = 0; var17 < var16; ++var17) { MovingObjectPosition var18 = var25[var17]; if (var18 != null) { double var19 = var18.hitVec.squareDistanceTo(par6Vec3); if (var19 > var22) { var23 = var18; var22 = var19; } } } return var23; } }-
View User Profile
-
View Posts
-
Send Message
Retired StaffBut, really though, I doubt that they'll make it something entirely new or complicated; I don't remember if it was Jeb_ or Dinnerbone who said that they were going to make it easy enough so that they'll use it themselves.
Plus, if they were to make a pointless and/or difficult API then people will just keep using Forge or ModLoader.
Oh, and if you're wondering how to set your blocks harvest level without editing a baseclass, you could use ForgeModLoader. They have a really simple way of setting it.
-
View User Profile
-
View Posts
-
Send Message
Retired StaffWell, the TIleEntities are for blocks that store additional data. Like a chest, for example. It's not a normal block; it stores items, and when destroyed drops them. Most of that information is defined in a TileEntities class.
But anyway, yes, you will need a TileEntity class if you want to make a container. Going about coding one would be a lot of copy-paste and editing.
Here's a Diamond for your help.
Mod_Experiments
public class Mod_Experiments extends BaseMod
{
public static final Block pinkBlock = new BlockPinkBlock(160, 0) .setBlockName("Pink Block") .setHardness(0.7F) .setCreativeTab(CreativeTabs.tabAllSearch) .setStepSound(Block.soundGrassFootstep);
public void load()
{
pinkBlock.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/PinkBlock.png");
ModLoader.registerBlock(pinkBlock);
ModLoader.addName(pinkBlock, "Pink Block");
}
public String getVersion()
{
return "1.3.2";
}
}
BlockPinkBlock
import java.util.Random;
public class BlockPinkBlock extends Block
{
public BlockPinkBlock(int i, int j)
{
super(i, j, Material.wood);
}
public int idDropped(int i, Random random, int j)
{
return Mod_Experiments.pinkBlock.blockID;
}
public int quantityDropped(Random random)
{
return 1;
}
}
I'm sure it's something stupid I just can't see. I have the latest MCP, Java, etc etc.
Can I drop off the face of the Earth now? >.< *facepalm*
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumYou should look at a vanilla block that does this (like the furnace) and just go from there.
Well, you could just set the generate so that it would need a block of air nearby in order to spawn, and then set the spawn height to the desired height
It got slightly burried.