Hi, my problem is no error or so and you didn't cover GUI's in your tutorials but hopefully you can help me nevertheless.
I was creating a new GUI with simmilar functionality like the Enchantment GUI, so i did a copy and tried to get it shown.
I display it on itemRightclick
public ItemStack onItemRightClick(ItemStack _itemStack, World _world, EntityPlayer _entityPlayer)
{
System.out.println(" creating instance of GUI: GuiRuneEnchant");
guiRuneEnchant = new GuiRuneEnchant(_entityPlayer.inventory, _world, (int)_entityPlayer.posX, (int)_entityPlayer.posY, (int)_entityPlayer.posZ);
System.out.println(" Attempting to open GUI: GuiRuneEnchant");
ModLoader.getMinecraftInstance().displayGuiScreen(guiRuneEnchant);
return _itemStack;
}
guiRuneEnchant gets created but getting unloaded (and closed) immediately without showing.
directly after calling displayGuiScreen() the close Method of the GUI (onGuiClosed()) is getting called.
Any idea what i did wrong?
I would suggest that you post a topic in mod development, you will likely get better answers
on a side note, could some one provide me with an index of the blocks with their hardness, resistance, etc.?
looked at block. java but its hard trying to find everything.
They are about two "pages" up from the bottom of Block.java, all the chunks that say stuff like this:
stone = (new BlockStone(1, 1)).setHardness(1.5F).setResistance(10F).setStepSound(soundStoneFootstep).setBlockName("stone");
There is a line for each block in the game (except modded ones of course)
For the tools to be enchantable, register them like this in the mod_Namehere class.
public static final Item newsword = ItemSword(600).setItemName("Sword);
Along with the EnumToolMaterial namehere. Didn't really work with forge much.
To use one of those classes like ItemSword or ItemPickaxe, you must use EnumToolMaterial as that is what their constructor states. We are using a different Enum for the materials so you cannot do that.
Rollback Post to RevisionRollBack
“Computers are incredibly fast, accurate and stupid; humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination."
For the ore generation can you be more specific on how to edit the size of the vien. I don't see any 3's inside of a bracket (like you said) when I'm trying to mod my ore generation. I've tested it out, and your default code gives me more ore in the vien than a coal vien for my ore which is rarer than diamonds. I would really like to know how to fix this. Thanks =].
AWESOME with the crop tutorial! Although I kinda liked the old way you did tutorials, just explaining underneath the code. Everything gets a little more easier that way... But if this is easier for you, then I don't have a problem with it. But new modders might not know those are comments.
EDIT: Also I looked through the tutorial but not very closely, does the crop have to have eight stages or can it just have like three?
Thanks for the feedback. I added in a bit more at the bottom of the tutorial about the different stages. Let me know if you need any more help with it.
Rollback Post to RevisionRollBack
“Computers are incredibly fast, accurate and stupid; humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination."
For peat's sake...how many times do I have to come to this topic? ._.
ANYWAY. I am trying to make an NPC run from you when yo come near him, and he should run as fast as the player. When I started using his code, I had movespeed set to 0.8f, and after a few other tests, he is now set 10f, but he isn't any faster. What the heck is going on? o_o
package net.minecraft.src;
import java.util.Random;
public class innocentvillager extends EntityCreature
{
public innocentvillager(World world)
{
super(world);
texture = "/mangmod/iv.png";
moveSpeed = 10F;
tasks.addTask(0, new EntityAIAvoidEntity(this, net.minecraft.src.EntityPlayer.class, 20F, 0.25F, 0.3F));
tasks.addTask(1, new EntityAIAvoidEntity(this, net.minecraft.src.EntityMob.class, 20F, 0.25F, 0.3F));
tasks.addTask(2, new EntityAIWatchClosest(this, net.minecraft.src.EntityPlayer.class, 30F));
tasks.addTask(3, new EntityAIWatchClosest(this, net.minecraft.src.EntityMob.class, 30F));
tasks.addTask(4, new EntityAISwimming(this));;
tasks.addTask(5, new EntityAIWander(this, 0.2F));
tasks.addTask(6, new EntityAILookIdle(this));
tasks.addTask(7, new EntityAIOpenDoor(this, true));
}
public boolean isAIEnabled()
{
return true;
}
public int getMaxHealth()
{
return 20;
}
protected String getLivingSound()
{
return "mob.villager.default";
}
protected String getHurtSound()
{
return "mob.villager.defaulthurt";
}
protected String getDeathSound()
{
return "mob.villager.defaultdeath";
}
protected int getDropItemId(){
return Item.appleRed.shiftedIndex;
}
protected boolean canDespawn()
{
return false;
}
public ItemStack getHeldItem()
{
return defaultHeldItem;
}
static
{
defaultHeldItem = new ItemStack(Item.appleRed, 1);
}
private static final ItemStack defaultHeldItem;
}
I am writing a tutorial on it now seeing as so many people have been asking for it. If I don't respond it is because I am too busy. I will get to your reply eventually so there is no point in asking again especially if yours is the last post on the page still. The tutorial will be uploaded tomorrow.
For peat's sake...how many times do I have to come to this topic? ._.
ANYWAY. I am trying to make an NPC run from you when yo come near him, and he should run as fast as the player. When I started using his code, I had movespeed set to 0.8f, and after a few other tests, he is now set 10f, but he isn't any faster. What the heck is going on? o_o
package net.minecraft.src;
import java.util.Random;
public class innocentvillager extends EntityCreature
{
public innocentvillager(World world)
{
super(world);
texture = "/mangmod/iv.png";
moveSpeed = 10F;
tasks.addTask(0, new EntityAIAvoidEntity(this, net.minecraft.src.EntityPlayer.class, 20F, 0.25F, 0.3F));
tasks.addTask(1, new EntityAIAvoidEntity(this, net.minecraft.src.EntityMob.class, 20F, 0.25F, 0.3F));
tasks.addTask(2, new EntityAIWatchClosest(this, net.minecraft.src.EntityPlayer.class, 30F));
tasks.addTask(3, new EntityAIWatchClosest(this, net.minecraft.src.EntityMob.class, 30F));
tasks.addTask(4, new EntityAISwimming(this));;
tasks.addTask(5, new EntityAIWander(this, 0.2F));
tasks.addTask(6, new EntityAILookIdle(this));
tasks.addTask(7, new EntityAIOpenDoor(this, true));
}
public boolean isAIEnabled()
{
return true;
}
public int getMaxHealth()
{
return 20;
}
protected String getLivingSound()
{
return "mob.villager.default";
}
protected String getHurtSound()
{
return "mob.villager.defaulthurt";
}
protected String getDeathSound()
{
return "mob.villager.defaultdeath";
}
protected int getDropItemId(){
return Item.appleRed.shiftedIndex;
}
protected boolean canDespawn()
{
return false;
}
public ItemStack getHeldItem()
{
return defaultHeldItem;
}
static
{
defaultHeldItem = new ItemStack(Item.appleRed, 1);
}
private static final ItemStack defaultHeldItem;
}
“Computers are incredibly fast, accurate and stupid; humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination."
I am writing a tutorial on it now seeing as so many people have been asking for it. If I don't respond it is because I am too busy. I will get to your reply eventually so there is no point in asking again especially if yours is the last post on the page still. The tutorial will be uploaded tomorrow.
-snip-
Asterisk didn't do anything, he is the same speed at 2F and 10F.
Hmm. Maybe that is the maximum. I didn't think it was but things seem to go strange when AI is added.
Rollback Post to RevisionRollBack
“Computers are incredibly fast, accurate and stupid; humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination."
I have a quick question: How would you make a name appear over a custom NPC, like the player name tags in SMP? All the other tutorials that I have found covering this are outdated and confusing.
Thanks for any help,
CNSoup
Rollback Post to RevisionRollBack
"To know who you are without any delusions or sympathy is a moment of revelation that no one experiences unscathed." -Christopher Paolini
i need some help on with my coding my electric fence, everything is where it should be (or so i think) by I get an error. i only included the important bits. I seem to get an erorr on the 'super' part of BlockElectricFence and i have no idea why.
CODE:mod_electricfence.java
public static Block electricFenceIdle = (new BlockElectricFence (181, false, ModLoader.addOverride("/terrain.png", "/mods/electricfenceoff.png"),Material.iron, 1, true)).setHardness(5F).setResistance(10F).setBlockName("Electric Fence");
public static Block electricFenceActive = (new BlockElectricFence (182, true, ModLoader.addOverride("/terrain.png", "/mods/electricfenceoff.png"),Material.iron, 1, true)).setHardness(5F).setResistance(10F).setBlockName("Electric Fence");
CODE:BlockElectricFence.java
package net.minecraft.src;
import java.util.Random;
public class BlockElectricFence extends BlockPaneMod
{
private final boolean powered;
public BlockElectricFence(int par1, boolean par2,int par3, Material par4Material, int par5, boolean par6)
{
super(par1, par3, par4Material);
sideTextureIndex = par5;
canDropItself = par6;
powered = par2;
if (par2)
{
setLightValue(0.375F);
blockIndexInTexture++;
isActive = true;
}
else
{
isActive = false;
}
}
public boolean isActive;
public void onBlockAdded(World par1World, int par2, int par3, int par4)
{
if (!par1World.isRemote)
{
if (powered && !par1World.isBlockIndirectlyGettingPowered(par2, par3, par4))
{
par1World.scheduleBlockUpdate(par2, par3, par4, blockID, 4);
}
else if (!powered && par1World.isBlockIndirectlyGettingPowered(par2, par3, par4))
{
par1World.setBlockWithNotify(par2, par3, par4, mod_electricfence.electricFenceActive.blockID);
}
}
}
/**
* Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
* their own) Args: x, y, z, neighbor blockID
*/
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
{
if (!par1World.isRemote)
{
if (powered && !par1World.isBlockIndirectlyGettingPowered(par2, par3, par4))
{
par1World.scheduleBlockUpdate(par2, par3, par4, blockID, 1);
}
else if (!powered && par1World.isBlockIndirectlyGettingPowered(par2, par3, par4))
{
par1World.setBlockWithNotify(par2, par3, par4, mod_electricfence.electricFenceActive.blockID);
}
}
}
/**
* Ticks the block if it's been scheduled
*/
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
{
if (!par1World.isRemote && powered && !par1World.isBlockIndirectlyGettingPowered(par2, par3, par4))
{
par1World.setBlockWithNotify(par2, par3, par4, mod_electricfence.electricFenceIdle.blockID);
}
}
public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity)
{
if (isActive == true)
{
par5Entity.attackEntityFrom(DamageSource.generic, 6);
}
}
}
CODE:BlockPaneMod.java
package net.minecraft.src;
import java.util.ArrayList;
import java.util.Random;
public class BlockPaneMod extends Block
{
/**
* Holds the texture index of the side of the pane (the thin lateral side)
*/
public int sideTextureIndex;
/**
* If this field is true, the pane block drops itself when destroyed (like the iron fences), otherwise, it's just
* destroyed (like glass panes)
*/
public final boolean canDropItself;
public BlockPaneMod(int par1, boolean par2,int par3, Material par4material, int par5, boolean par6)
{
super(par1, par3, par4material);
sideTextureIndex = par5;
canDropItself = par6;
powered = par2;
}
/**
* Returns the ID of the items to drop on destruction.
*/
public int idDropped(int par3, Random par4Random, int par5)
{
if (!canDropItself)
{
return 0;
}
else
{
return super.idDropped(par3, par4Random, par5);
}
}
/**
* Is this block (a) opaque and (B) a full 1m cube? This determines whether or not to render the shared face of two
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
*/
public boolean isOpaqueCube()
{
return false;
}
/**
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
*/
public boolean renderAsNormalBlock()
{
return false;
}
/**
* The type of render function that is called for this block
*/
public int getRenderType()
{
return 18;
}
/**
* Returns true if the given side of this block type should be rendered, if the adjacent block is at the given
* coordinates. Args: blockAccess, x, y, z, side
*/
public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
{
int i = par1IBlockAccess.getBlockId(par2, par3, par4);
if (i == blockID)
{
return false;
}
else
{
return super.shouldSideBeRendered(par1IBlockAccess, par2, par3, par4, par5);
}
}
/**
* Adds to the supplied array any colliding bounding boxes with the passed in bounding box. Args: world, x, y, z,
* axisAlignedBB, arrayList
*/
public void getCollidingBoundingBoxes(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, ArrayList par6ArrayList)
{
boolean flag = canThisPaneConnectToThisBlockID(par1World.getBlockId(par2, par3, par4 - 1));
boolean flag1 = canThisPaneConnectToThisBlockID(par1World.getBlockId(par2, par3, par4 + 1));
boolean flag2 = canThisPaneConnectToThisBlockID(par1World.getBlockId(par2 - 1, par3, par4));
boolean flag3 = canThisPaneConnectToThisBlockID(par1World.getBlockId(par2 + 1, par3, par4));
if (flag2 && flag3 || !flag2 && !flag3 && !flag && !flag1)
{
setBlockBounds(0.0F, 0.0F, 0.4375F, 1.0F, 1.0F, 0.5625F);
super.getCollidingBoundingBoxes(par1World, par2, par3, par4, par5AxisAlignedBB, par6ArrayList);
}
else if (flag2 && !flag3)
{
setBlockBounds(0.0F, 0.0F, 0.4375F, 0.5F, 1.0F, 0.5625F);
super.getCollidingBoundingBoxes(par1World, par2, par3, par4, par5AxisAlignedBB, par6ArrayList);
}
else if (!flag2 && flag3)
{
setBlockBounds(0.5F, 0.0F, 0.4375F, 1.0F, 1.0F, 0.5625F);
super.getCollidingBoundingBoxes(par1World, par2, par3, par4, par5AxisAlignedBB, par6ArrayList);
}
if (flag && flag1 || !flag2 && !flag3 && !flag && !flag1)
{
setBlockBounds(0.4375F, 0.0F, 0.0F, 0.5625F, 1.0F, 1.0F);
super.getCollidingBoundingBoxes(par1World, par2, par3, par4, par5AxisAlignedBB, par6ArrayList);
}
else if (flag && !flag1)
{
setBlockBounds(0.4375F, 0.0F, 0.0F, 0.5625F, 1.0F, 0.5F);
super.getCollidingBoundingBoxes(par1World, par2, par3, par4, par5AxisAlignedBB, par6ArrayList);
}
else if (!flag && flag1)
{
setBlockBounds(0.4375F, 0.0F, 0.5F, 0.5625F, 1.0F, 1.0F);
super.getCollidingBoundingBoxes(par1World, par2, par3, par4, par5AxisAlignedBB, par6ArrayList);
}
}
/**
* Sets the block's bounds for rendering it as an item
*/
public void setBlockBoundsForItemRender()
{
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
/**
* Updates the blocks bounds based on its current state. Args: world, x, y, z
*/
public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
{
float f = 0.4375F;
float f1 = 0.5625F;
float f2 = 0.4375F;
float f3 = 0.5625F;
boolean flag = canThisPaneConnectToThisBlockID(par1IBlockAccess.getBlockId(par2, par3, par4 - 1));
boolean flag1 = canThisPaneConnectToThisBlockID(par1IBlockAccess.getBlockId(par2, par3, par4 + 1));
boolean flag2 = canThisPaneConnectToThisBlockID(par1IBlockAccess.getBlockId(par2 - 1, par3, par4));
boolean flag3 = canThisPaneConnectToThisBlockID(par1IBlockAccess.getBlockId(par2 + 1, par3, par4));
if (flag2 && flag3 || !flag2 && !flag3 && !flag && !flag1)
{
f = 0.0F;
f1 = 1.0F;
}
else if (flag2 && !flag3)
{
f = 0.0F;
}
else if (!flag2 && flag3)
{
f1 = 1.0F;
}
if (flag && flag1 || !flag2 && !flag3 && !flag && !flag1)
{
f2 = 0.0F;
f3 = 1.0F;
}
else if (flag && !flag1)
{
f2 = 0.0F;
}
else if (!flag && flag1)
{
f3 = 1.0F;
}
setBlockBounds(f, 0.0F, f2, f1, 1.0F, f3);
}
/**
* Returns the texture index of the thin side of the pane.
*/
public int getSideTextureIndex()
{
return sideTextureIndex;
}
/**
* Gets passed in the blockID of the block adjacent and supposed to return true if its allowed to connect to the
* type of blockID passed in. Args: blockID
*/
public final boolean canThisPaneConnectToThisBlockID(int par1)
{
return Block.opaqueCubeLookup[par1] || par1 == blockID || par1 == Block.glass.blockID;
}
//regular block code
private final boolean powered;
public boolean isActive;
public void onBlockAdded(World world, int i, int j, int k)
{
}
public void onNeighborBlockChange(World world, int i, int j, int k, int l)
{
}
public void updateTick(World world, int i, int j, int k, Random random)
{
}
public void onEntityCollidedWithBlock(World world, int i, int j, int k, Entity entity)
{
}
}
i need some help on with my coding my electric fence, everything is where it should be (or so i think) by I get an error. i only included the important bits. I seem to get an erorr on the 'super' part of BlockElectricFence and i have no idea why.
CODE:mod_electricfence.java
public static Block electricFenceIdle = (new BlockElectricFence (181, false, ModLoader.addOverride("/terrain.png", "/mods/electricfenceoff.png"),Material.iron, 1, true)).setHardness(5F).setResistance(10F).setBlockName("Electric Fence");
public static Block electricFenceActive = (new BlockElectricFence (182, true, ModLoader.addOverride("/terrain.png", "/mods/electricfenceoff.png"),Material.iron, 1, true)).setHardness(5F).setResistance(10F).setBlockName("Electric Fence");
CODE:BlockElectricFence.java
package net.minecraft.src;
import java.util.Random;
public class BlockElectricFence extends BlockPaneMod
{
private final boolean powered;
public BlockElectricFence(int par1, boolean par2,int par3, Material par4Material, int par5, boolean par6)
{
super(par1, par3, par4Material);
sideTextureIndex = par5;
canDropItself = par6;
powered = par2;
if (par2)
{
setLightValue(0.375F);
blockIndexInTexture++;
isActive = true;
}
else
{
isActive = false;
}
}
public boolean isActive;
public void onBlockAdded(World par1World, int par2, int par3, int par4)
{
if (!par1World.isRemote)
{
if (powered && !par1World.isBlockIndirectlyGettingPowered(par2, par3, par4))
{
par1World.scheduleBlockUpdate(par2, par3, par4, blockID, 4);
}
else if (!powered && par1World.isBlockIndirectlyGettingPowered(par2, par3, par4))
{
par1World.setBlockWithNotify(par2, par3, par4, mod_electricfence.electricFenceActive.blockID);
}
}
}
/**
* Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
* their own) Args: x, y, z, neighbor blockID
*/
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
{
if (!par1World.isRemote)
{
if (powered && !par1World.isBlockIndirectlyGettingPowered(par2, par3, par4))
{
par1World.scheduleBlockUpdate(par2, par3, par4, blockID, 1);
}
else if (!powered && par1World.isBlockIndirectlyGettingPowered(par2, par3, par4))
{
par1World.setBlockWithNotify(par2, par3, par4, mod_electricfence.electricFenceActive.blockID);
}
}
}
/**
* Ticks the block if it's been scheduled
*/
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
{
if (!par1World.isRemote && powered && !par1World.isBlockIndirectlyGettingPowered(par2, par3, par4))
{
par1World.setBlockWithNotify(par2, par3, par4, mod_electricfence.electricFenceIdle.blockID);
}
}
public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity)
{
if (isActive == true)
{
par5Entity.attackEntityFrom(DamageSource.generic, 6);
}
}
}
CODE:BlockPaneMod.java
package net.minecraft.src;
import java.util.ArrayList;
import java.util.Random;
public class BlockPaneMod extends Block
{
/**
* Holds the texture index of the side of the pane (the thin lateral side)
*/
public int sideTextureIndex;
/**
* If this field is true, the pane block drops itself when destroyed (like the iron fences), otherwise, it's just
* destroyed (like glass panes)
*/
public final boolean canDropItself;
public BlockPaneMod(int par1, boolean par2,int par3, Material par4material, int par5, boolean par6)
{
super(par1, par3, par4material);
sideTextureIndex = par5;
canDropItself = par6;
powered = par2;
}
/**
* Returns the ID of the items to drop on destruction.
*/
public int idDropped(int par3, Random par4Random, int par5)
{
if (!canDropItself)
{
return 0;
}
else
{
return super.idDropped(par3, par4Random, par5);
}
}
/**
* Is this block (a) opaque and (B) a full 1m cube? This determines whether or not to render the shared face of two
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
*/
public boolean isOpaqueCube()
{
return false;
}
/**
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
*/
public boolean renderAsNormalBlock()
{
return false;
}
/**
* The type of render function that is called for this block
*/
public int getRenderType()
{
return 18;
}
/**
* Returns true if the given side of this block type should be rendered, if the adjacent block is at the given
* coordinates. Args: blockAccess, x, y, z, side
*/
public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
{
int i = par1IBlockAccess.getBlockId(par2, par3, par4);
if (i == blockID)
{
return false;
}
else
{
return super.shouldSideBeRendered(par1IBlockAccess, par2, par3, par4, par5);
}
}
/**
* Adds to the supplied array any colliding bounding boxes with the passed in bounding box. Args: world, x, y, z,
* axisAlignedBB, arrayList
*/
public void getCollidingBoundingBoxes(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, ArrayList par6ArrayList)
{
boolean flag = canThisPaneConnectToThisBlockID(par1World.getBlockId(par2, par3, par4 - 1));
boolean flag1 = canThisPaneConnectToThisBlockID(par1World.getBlockId(par2, par3, par4 + 1));
boolean flag2 = canThisPaneConnectToThisBlockID(par1World.getBlockId(par2 - 1, par3, par4));
boolean flag3 = canThisPaneConnectToThisBlockID(par1World.getBlockId(par2 + 1, par3, par4));
if (flag2 && flag3 || !flag2 && !flag3 && !flag && !flag1)
{
setBlockBounds(0.0F, 0.0F, 0.4375F, 1.0F, 1.0F, 0.5625F);
super.getCollidingBoundingBoxes(par1World, par2, par3, par4, par5AxisAlignedBB, par6ArrayList);
}
else if (flag2 && !flag3)
{
setBlockBounds(0.0F, 0.0F, 0.4375F, 0.5F, 1.0F, 0.5625F);
super.getCollidingBoundingBoxes(par1World, par2, par3, par4, par5AxisAlignedBB, par6ArrayList);
}
else if (!flag2 && flag3)
{
setBlockBounds(0.5F, 0.0F, 0.4375F, 1.0F, 1.0F, 0.5625F);
super.getCollidingBoundingBoxes(par1World, par2, par3, par4, par5AxisAlignedBB, par6ArrayList);
}
if (flag && flag1 || !flag2 && !flag3 && !flag && !flag1)
{
setBlockBounds(0.4375F, 0.0F, 0.0F, 0.5625F, 1.0F, 1.0F);
super.getCollidingBoundingBoxes(par1World, par2, par3, par4, par5AxisAlignedBB, par6ArrayList);
}
else if (flag && !flag1)
{
setBlockBounds(0.4375F, 0.0F, 0.0F, 0.5625F, 1.0F, 0.5F);
super.getCollidingBoundingBoxes(par1World, par2, par3, par4, par5AxisAlignedBB, par6ArrayList);
}
else if (!flag && flag1)
{
setBlockBounds(0.4375F, 0.0F, 0.5F, 0.5625F, 1.0F, 1.0F);
super.getCollidingBoundingBoxes(par1World, par2, par3, par4, par5AxisAlignedBB, par6ArrayList);
}
}
/**
* Sets the block's bounds for rendering it as an item
*/
public void setBlockBoundsForItemRender()
{
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
/**
* Updates the blocks bounds based on its current state. Args: world, x, y, z
*/
public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
{
float f = 0.4375F;
float f1 = 0.5625F;
float f2 = 0.4375F;
float f3 = 0.5625F;
boolean flag = canThisPaneConnectToThisBlockID(par1IBlockAccess.getBlockId(par2, par3, par4 - 1));
boolean flag1 = canThisPaneConnectToThisBlockID(par1IBlockAccess.getBlockId(par2, par3, par4 + 1));
boolean flag2 = canThisPaneConnectToThisBlockID(par1IBlockAccess.getBlockId(par2 - 1, par3, par4));
boolean flag3 = canThisPaneConnectToThisBlockID(par1IBlockAccess.getBlockId(par2 + 1, par3, par4));
if (flag2 && flag3 || !flag2 && !flag3 && !flag && !flag1)
{
f = 0.0F;
f1 = 1.0F;
}
else if (flag2 && !flag3)
{
f = 0.0F;
}
else if (!flag2 && flag3)
{
f1 = 1.0F;
}
if (flag && flag1 || !flag2 && !flag3 && !flag && !flag1)
{
f2 = 0.0F;
f3 = 1.0F;
}
else if (flag && !flag1)
{
f2 = 0.0F;
}
else if (!flag && flag1)
{
f3 = 1.0F;
}
setBlockBounds(f, 0.0F, f2, f1, 1.0F, f3);
}
/**
* Returns the texture index of the thin side of the pane.
*/
public int getSideTextureIndex()
{
return sideTextureIndex;
}
/**
* Gets passed in the blockID of the block adjacent and supposed to return true if its allowed to connect to the
* type of blockID passed in. Args: blockID
*/
public final boolean canThisPaneConnectToThisBlockID(int par1)
{
return Block.opaqueCubeLookup[par1] || par1 == blockID || par1 == Block.glass.blockID;
}
//regular block code
private final boolean powered;
public boolean isActive;
public void onBlockAdded(World world, int i, int j, int k)
{
}
public void onNeighborBlockChange(World world, int i, int j, int k, int l)
{
}
public void updateTick(World world, int i, int j, int k, Random random)
{
}
public void onEntityCollidedWithBlock(World world, int i, int j, int k, Entity entity)
{
}
}
thank you for helping
the Abomination
You need to put all of the constructors arguments into the super statement.
I have a quick question: How would you make a name appear over a custom NPC, like the player name tags in SMP? All the other tutorials that I have found covering this are outdated and confusing.
“Computers are incredibly fast, accurate and stupid; humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination."
I get a problem after compiling and using my mod. I need to have the mod on a FOLDER called minecraft.jar with the textures. If I zip up the folder to make it an actual JAR, the game will crash with an "image cant be found" exception. To clarify, with a folder called minecraft.jar, it will work. The game will crash if I make minecraft into an actual jar after installing my mod.
With the multiple potion effects, do you know how to make a chance of something happening? Like a 10% chance of getting poisoned? Kinda like the normal .setPotionEffect when making the public static final for the item.
and do some math ^^. You could use the random function and test the result.
In your Itemclass you should then do all the poisonevents in the function "onItemUsed" or something like that.
Thats what I would do, but I am a newbie
o.0 uhh, I don't really understand... I don't know things like that. Just recipes, ore gen, food, blocks, items and such.
o.0 uhh, I don't really understand... I don't know things like that. Just recipes, ore gen, food, blocks, items and such.
I would do what Keydara suggested. Example below:
//this all goes inside the onFoodEaten method.
int i = Random.nextInt(9);
if(i == 5)
{
//Potion Effects in here.
}
We set i to be equal to Random.nextInt(9). The nextInt method gets a random number between 0 and the number given. In this case that number is 9. Yes, even though that number is 9, it is a 1 in 10 chance. This is because 0 can be selected as well. Then if just says "if i is equal to 5, then apply the specfied potion effect/s". Don't forget to import Random like Keydara showed.
Rollback Post to RevisionRollBack
“Computers are incredibly fast, accurate and stupid; humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination."
To post a comment, please login or register a new account.
EntityLightningBolt entitylightningbolt = new EntityLightningBolt(par0World, par2EntityPlayer,
but i cant figure out what the other variable in it are:
(EntityLightningBolt)
EntityLightningBolt(World par1World, double par2, double par4, double par6)
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumI would suggest that you post a topic in mod development, you will likely get better answers
They are about two "pages" up from the bottom of Block.java, all the chunks that say stuff like this:
stone = (new BlockStone(1, 1)).setHardness(1.5F).setResistance(10F).setStepSound(soundStoneFootstep).setBlockName("stone");There is a line for each block in the game (except modded ones of course)
To use one of those classes like ItemSword or ItemPickaxe, you must use EnumToolMaterial as that is what their constructor states. We are using a different Enum for the materials so you cannot do that.
together they are powerful beyond imagination."
Sorry, I've fixed it up.
Thanks for the feedback. I added in a bit more at the bottom of the tutorial about the different stages. Let me know if you need any more help with it.
together they are powerful beyond imagination."
How do you make your new food edible even when your not hungry?EDIT: I worked out how to do that, but I need help with adding multiple potion effects to food.
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumANYWAY. I am trying to make an NPC run from you when yo come near him, and he should run as fast as the player. When I started using his code, I had movespeed set to 0.8f, and after a few other tests, he is now set 10f, but he isn't any faster. What the heck is going on? o_o
package net.minecraft.src; import java.util.Random; public class innocentvillager extends EntityCreature { public innocentvillager(World world) { super(world); texture = "/mangmod/iv.png"; moveSpeed = 10F; tasks.addTask(0, new EntityAIAvoidEntity(this, net.minecraft.src.EntityPlayer.class, 20F, 0.25F, 0.3F)); tasks.addTask(1, new EntityAIAvoidEntity(this, net.minecraft.src.EntityMob.class, 20F, 0.25F, 0.3F)); tasks.addTask(2, new EntityAIWatchClosest(this, net.minecraft.src.EntityPlayer.class, 30F)); tasks.addTask(3, new EntityAIWatchClosest(this, net.minecraft.src.EntityMob.class, 30F)); tasks.addTask(4, new EntityAISwimming(this));; tasks.addTask(5, new EntityAIWander(this, 0.2F)); tasks.addTask(6, new EntityAILookIdle(this)); tasks.addTask(7, new EntityAIOpenDoor(this, true)); } public boolean isAIEnabled() { return true; } public int getMaxHealth() { return 20; } protected String getLivingSound() { return "mob.villager.default"; } protected String getHurtSound() { return "mob.villager.defaulthurt"; } protected String getDeathSound() { return "mob.villager.defaultdeath"; } protected int getDropItemId(){ return Item.appleRed.shiftedIndex; } protected boolean canDespawn() { return false; } public ItemStack getHeldItem() { return defaultHeldItem; } static { defaultHeldItem = new ItemStack(Item.appleRed, 1); } private static final ItemStack defaultHeldItem; }I am writing a tutorial on it now seeing as so many people have been asking for it. If I don't respond it is because I am too busy. I will get to your reply eventually so there is no point in asking again especially if yours is the last post on the page still. The tutorial will be uploaded tomorrow.
Try using
- Use an asterisk.
together they are powerful beyond imagination."
Thanks, i really appreciate it
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumHmm. Maybe that is the maximum. I didn't think it was but things seem to go strange when AI is added.
together they are powerful beyond imagination."
This is the last thing then i'll be off
Yes i did put it before .setitemName
Thanks for any help,
CNSoup
CODE:mod_electricfence.java
public static Block electricFenceIdle = (new BlockElectricFence (181, false, ModLoader.addOverride("/terrain.png", "/mods/electricfenceoff.png"),Material.iron, 1, true)).setHardness(5F).setResistance(10F).setBlockName("Electric Fence"); public static Block electricFenceActive = (new BlockElectricFence (182, true, ModLoader.addOverride("/terrain.png", "/mods/electricfenceoff.png"),Material.iron, 1, true)).setHardness(5F).setResistance(10F).setBlockName("Electric Fence");CODE:BlockElectricFence.java
package net.minecraft.src; import java.util.Random; public class BlockElectricFence extends BlockPaneMod { private final boolean powered; public BlockElectricFence(int par1, boolean par2,int par3, Material par4Material, int par5, boolean par6) { super(par1, par3, par4Material); sideTextureIndex = par5; canDropItself = par6; powered = par2; if (par2) { setLightValue(0.375F); blockIndexInTexture++; isActive = true; } else { isActive = false; } } public boolean isActive; public void onBlockAdded(World par1World, int par2, int par3, int par4) { if (!par1World.isRemote) { if (powered && !par1World.isBlockIndirectlyGettingPowered(par2, par3, par4)) { par1World.scheduleBlockUpdate(par2, par3, par4, blockID, 4); } else if (!powered && par1World.isBlockIndirectlyGettingPowered(par2, par3, par4)) { par1World.setBlockWithNotify(par2, par3, par4, mod_electricfence.electricFenceActive.blockID); } } } /** * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are * their own) Args: x, y, z, neighbor blockID */ public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5) { if (!par1World.isRemote) { if (powered && !par1World.isBlockIndirectlyGettingPowered(par2, par3, par4)) { par1World.scheduleBlockUpdate(par2, par3, par4, blockID, 1); } else if (!powered && par1World.isBlockIndirectlyGettingPowered(par2, par3, par4)) { par1World.setBlockWithNotify(par2, par3, par4, mod_electricfence.electricFenceActive.blockID); } } } /** * Ticks the block if it's been scheduled */ public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) { if (!par1World.isRemote && powered && !par1World.isBlockIndirectlyGettingPowered(par2, par3, par4)) { par1World.setBlockWithNotify(par2, par3, par4, mod_electricfence.electricFenceIdle.blockID); } } public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity) { if (isActive == true) { par5Entity.attackEntityFrom(DamageSource.generic, 6); } } }CODE:BlockPaneMod.java
package net.minecraft.src; import java.util.ArrayList; import java.util.Random; public class BlockPaneMod extends Block { /** * Holds the texture index of the side of the pane (the thin lateral side) */ public int sideTextureIndex; /** * If this field is true, the pane block drops itself when destroyed (like the iron fences), otherwise, it's just * destroyed (like glass panes) */ public final boolean canDropItself; public BlockPaneMod(int par1, boolean par2,int par3, Material par4material, int par5, boolean par6) { super(par1, par3, par4material); sideTextureIndex = par5; canDropItself = par6; powered = par2; } /** * Returns the ID of the items to drop on destruction. */ public int idDropped(int par3, Random par4Random, int par5) { if (!canDropItself) { return 0; } else { return super.idDropped(par3, par4Random, par5); } } /** * Is this block (a) opaque and (B) a full 1m cube? This determines whether or not to render the shared face of two * adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block. */ public boolean isOpaqueCube() { return false; } /** * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc) */ public boolean renderAsNormalBlock() { return false; } /** * The type of render function that is called for this block */ public int getRenderType() { return 18; } /** * Returns true if the given side of this block type should be rendered, if the adjacent block is at the given * coordinates. Args: blockAccess, x, y, z, side */ public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) { int i = par1IBlockAccess.getBlockId(par2, par3, par4); if (i == blockID) { return false; } else { return super.shouldSideBeRendered(par1IBlockAccess, par2, par3, par4, par5); } } /** * Adds to the supplied array any colliding bounding boxes with the passed in bounding box. Args: world, x, y, z, * axisAlignedBB, arrayList */ public void getCollidingBoundingBoxes(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, ArrayList par6ArrayList) { boolean flag = canThisPaneConnectToThisBlockID(par1World.getBlockId(par2, par3, par4 - 1)); boolean flag1 = canThisPaneConnectToThisBlockID(par1World.getBlockId(par2, par3, par4 + 1)); boolean flag2 = canThisPaneConnectToThisBlockID(par1World.getBlockId(par2 - 1, par3, par4)); boolean flag3 = canThisPaneConnectToThisBlockID(par1World.getBlockId(par2 + 1, par3, par4)); if (flag2 && flag3 || !flag2 && !flag3 && !flag && !flag1) { setBlockBounds(0.0F, 0.0F, 0.4375F, 1.0F, 1.0F, 0.5625F); super.getCollidingBoundingBoxes(par1World, par2, par3, par4, par5AxisAlignedBB, par6ArrayList); } else if (flag2 && !flag3) { setBlockBounds(0.0F, 0.0F, 0.4375F, 0.5F, 1.0F, 0.5625F); super.getCollidingBoundingBoxes(par1World, par2, par3, par4, par5AxisAlignedBB, par6ArrayList); } else if (!flag2 && flag3) { setBlockBounds(0.5F, 0.0F, 0.4375F, 1.0F, 1.0F, 0.5625F); super.getCollidingBoundingBoxes(par1World, par2, par3, par4, par5AxisAlignedBB, par6ArrayList); } if (flag && flag1 || !flag2 && !flag3 && !flag && !flag1) { setBlockBounds(0.4375F, 0.0F, 0.0F, 0.5625F, 1.0F, 1.0F); super.getCollidingBoundingBoxes(par1World, par2, par3, par4, par5AxisAlignedBB, par6ArrayList); } else if (flag && !flag1) { setBlockBounds(0.4375F, 0.0F, 0.0F, 0.5625F, 1.0F, 0.5F); super.getCollidingBoundingBoxes(par1World, par2, par3, par4, par5AxisAlignedBB, par6ArrayList); } else if (!flag && flag1) { setBlockBounds(0.4375F, 0.0F, 0.5F, 0.5625F, 1.0F, 1.0F); super.getCollidingBoundingBoxes(par1World, par2, par3, par4, par5AxisAlignedBB, par6ArrayList); } } /** * Sets the block's bounds for rendering it as an item */ public void setBlockBoundsForItemRender() { setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } /** * Updates the blocks bounds based on its current state. Args: world, x, y, z */ public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) { float f = 0.4375F; float f1 = 0.5625F; float f2 = 0.4375F; float f3 = 0.5625F; boolean flag = canThisPaneConnectToThisBlockID(par1IBlockAccess.getBlockId(par2, par3, par4 - 1)); boolean flag1 = canThisPaneConnectToThisBlockID(par1IBlockAccess.getBlockId(par2, par3, par4 + 1)); boolean flag2 = canThisPaneConnectToThisBlockID(par1IBlockAccess.getBlockId(par2 - 1, par3, par4)); boolean flag3 = canThisPaneConnectToThisBlockID(par1IBlockAccess.getBlockId(par2 + 1, par3, par4)); if (flag2 && flag3 || !flag2 && !flag3 && !flag && !flag1) { f = 0.0F; f1 = 1.0F; } else if (flag2 && !flag3) { f = 0.0F; } else if (!flag2 && flag3) { f1 = 1.0F; } if (flag && flag1 || !flag2 && !flag3 && !flag && !flag1) { f2 = 0.0F; f3 = 1.0F; } else if (flag && !flag1) { f2 = 0.0F; } else if (!flag && flag1) { f3 = 1.0F; } setBlockBounds(f, 0.0F, f2, f1, 1.0F, f3); } /** * Returns the texture index of the thin side of the pane. */ public int getSideTextureIndex() { return sideTextureIndex; } /** * Gets passed in the blockID of the block adjacent and supposed to return true if its allowed to connect to the * type of blockID passed in. Args: blockID */ public final boolean canThisPaneConnectToThisBlockID(int par1) { return Block.opaqueCubeLookup[par1] || par1 == blockID || par1 == Block.glass.blockID; } //regular block code private final boolean powered; public boolean isActive; public void onBlockAdded(World world, int i, int j, int k) { } public void onNeighborBlockChange(World world, int i, int j, int k, int l) { } public void updateTick(World world, int i, int j, int k, Random random) { } public void onEntityCollidedWithBlock(World world, int i, int j, int k, Entity entity) { } }thank you for helping
the Abomination
You haven't followed the tutorial. You need the ItemNameherePickaxe, etc. classes aswell.
You need to put all of the constructors arguments into the super statement.
Strength has a tutorial on that here.
together they are powerful beyond imagination."
o.0 uhh, I don't really understand... I don't know things like that. Just recipes, ore gen, food, blocks, items and such.
I would do what Keydara suggested. Example below:
//this all goes inside the onFoodEaten method. int i = Random.nextInt(9); if(i == 5) { //Potion Effects in here. }We set i to be equal to Random.nextInt(9). The nextInt method gets a random number between 0 and the number given. In this case that number is 9. Yes, even though that number is 9, it is a 1 in 10 chance. This is because 0 can be selected as well. Then if just says "if i is equal to 5, then apply the specfied potion effect/s". Don't forget to import Random like Keydara showed.
together they are powerful beyond imagination."