MC Modding
Please register and join the community!

[1.8.1 Mod Making] Creating a new torch!

View previous topic View next topic Go down

[1.8.1 Mod Making] Creating a new torch!

Post by austin56101 on Tue Oct 25, 2011 2:35 am

This is what ill tell you how to make! Very Happy



ok this will go into your mod_BlockElectricTorch.java

Code:
package net.minecraft.src;
import java.util.Random;

public class mod_BlockElectricTorch extends BaseMod
{


   public static final Block blockElectricTorch =
            new BlockElectricTorch(127,0).setHardness(0.0F).setResistance(5.0F).setLightValue(1.0F).setBlockName("BlockElectricTorch");


   public mod_BlockElectricTorch()
   {   

      ModLoader.RegisterBlock(blockElectricTorch);
      blockElectricTorch.blockIndexInTexture = ModLoader.addOverride("/terrain.png","/blockElectricTorch.png");
      ModLoader.AddName(blockElectricTorch, "blockElectricTorch");
      ModLoader.AddRecipe(new ItemStack(blockElectricTorch, 10), new Object[] {
         " * ", Character.valueOf('*'), Block.dirt
      });
   }
   


And this will go into BlockElectricTorch.java

Code:
//THIS CODE GOES INTO YOUR BlockElectricTorch.java FILE! (or whatever you called your block class)
package net.minecraft.src;
import java.util.Random;

public class BlockElectricTorch extends Block
{
   protected BlockElectricTorch(int i, int j)
   {
   
      super(i, j, Material.circuits);
      setTickOnLoad(true);
   }   


   
   
   
   public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k)
    {
        return null;
    }

    public boolean isOpaqueCube()
    {
        return false;
    }

    public boolean renderAsNormalBlock()
    {
        return false;
    }

    public int getRenderType()
    {
        return 2;
    }

    private boolean func_31032_h(World world, int i, int j, int k)
    {
        return world.isBlockNormalCube(i, j, k) || world.getBlockId(i, j, k) == Block.fence.blockID;
    }

    public boolean canPlaceBlockAt(World world, int i, int j, int k)
    {
        if(world.isBlockNormalCube(i - 1, j, k))
        {
            return true;
        }
        if(world.isBlockNormalCube(i + 1, j, k))
        {
            return true;
        }
        if(world.isBlockNormalCube(i, j, k - 1))
        {
            return true;
        }
        if(world.isBlockNormalCube(i, j, k + 1))
        {
            return true;
        }
        return func_31032_h(world, i, j - 1, k);
    }

    public void onBlockPlaced(World world, int i, int j, int k, int l)
    {
        int i1 = world.getBlockMetadata(i, j, k);
        if(l == 1 && func_31032_h(world, i, j - 1, k))
        {
            i1 = 5;
        }
        if(l == 2 && world.isBlockNormalCube(i, j, k + 1))
        {
            i1 = 4;
        }
        if(l == 3 && world.isBlockNormalCube(i, j, k - 1))
        {
            i1 = 3;
        }
        if(l == 4 && world.isBlockNormalCube(i + 1, j, k))
        {
            i1 = 2;
        }
        if(l == 5 && world.isBlockNormalCube(i - 1, j, k))
        {
            i1 = 1;
        }
        world.setBlockMetadataWithNotify(i, j, k, i1);
    }

    public void updateTick(World world, int i, int j, int k, Random random)
    {
        super.updateTick(world, i, j, k, random);
        if(world.getBlockMetadata(i, j, k) == 0)
        {
            onBlockAdded(world, i, j, k);
        }
    }

    public void onBlockAdded(World world, int i, int j, int k)
    {
        if(world.isBlockNormalCube(i - 1, j, k))
        {
            world.setBlockMetadataWithNotify(i, j, k, 1);
        } else
        if(world.isBlockNormalCube(i + 1, j, k))
        {
            world.setBlockMetadataWithNotify(i, j, k, 2);
        } else
        if(world.isBlockNormalCube(i, j, k - 1))
        {
            world.setBlockMetadataWithNotify(i, j, k, 3);
        } else
        if(world.isBlockNormalCube(i, j, k + 1))
        {
            world.setBlockMetadataWithNotify(i, j, k, 4);
        } else
        if(func_31032_h(world, i, j - 1, k))
        {
            world.setBlockMetadataWithNotify(i, j, k, 5);
        }
        dropTorchIfCantStay(world, i, j, k);
    }

    public void onNeighborBlockChange(World world, int i, int j, int k, int l)
    {
        if(dropTorchIfCantStay(world, i, j, k))
        {
            int i1 = world.getBlockMetadata(i, j, k);
            boolean flag = false;
            if(!world.isBlockNormalCube(i - 1, j, k) && i1 == 1)
            {
                flag = true;
            }
            if(!world.isBlockNormalCube(i + 1, j, k) && i1 == 2)
            {
                flag = true;
            }
            if(!world.isBlockNormalCube(i, j, k - 1) && i1 == 3)
            {
                flag = true;
            }
            if(!world.isBlockNormalCube(i, j, k + 1) && i1 == 4)
            {
                flag = true;
            }
            if(!func_31032_h(world, i, j - 1, k) && i1 == 5)
            {
                flag = true;
            }
            if(flag)
            {
                dropBlockAsItem(world, i, j, k, world.getBlockMetadata(i, j, k));
                world.setBlockWithNotify(i, j, k, 0);
            }
        }
    }

    private boolean dropTorchIfCantStay(World world, int i, int j, int k)
    {
        if(!canPlaceBlockAt(world, i, j, k))
        {
            dropBlockAsItem(world, i, j, k, world.getBlockMetadata(i, j, k));
            world.setBlockWithNotify(i, j, k, 0);
            return false;
        } else
        {
            return true;
        }
    }

    public MovingObjectPosition collisionRayTrace(World world, int i, int j, int k, Vec3D vec3d, Vec3D vec3d1)
    {
        int l = world.getBlockMetadata(i, j, k) & 7;
        float f = 0.15F;
        if(l == 1)
        {
            setBlockBounds(0.0F, 0.2F, 0.5F - f, f * 2.0F, 0.8F, 0.5F + f);
        } else
        if(l == 2)
        {
            setBlockBounds(1.0F - f * 2.0F, 0.2F, 0.5F - f, 1.0F, 0.8F, 0.5F + f);
        } else
        if(l == 3)
        {
            setBlockBounds(0.5F - f, 0.2F, 0.0F, 0.5F + f, 0.8F, f * 2.0F);
        } else
        if(l == 4)
        {
            setBlockBounds(0.5F - f, 0.2F, 1.0F - f * 2.0F, 0.5F + f, 0.8F, 1.0F);
        } else
        {
            float f1 = 0.1F;
            setBlockBounds(0.5F - f1, 0.0F, 0.5F - f1, 0.5F + f1, 0.6F, 0.5F + f1);
        }
        return super.collisionRayTrace(world, i, j, k, vec3d, vec3d1);
    }

    public void randomDisplayTick(World world, int i, int j, int k, Random random)
    {
        int l = world.getBlockMetadata(i, j, k);
        double d = (float)i + 0.5F;
        double d1 = (float)j + 0.85F;
        double d2 = (float)k + 0.5F;
        double d3 = 0.2199999988079071D;
        double d4 = 0.27000001072883606D;
        if(l == 1)
        {
            world.spawnParticle("smoke", d - d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
            world.spawnParticle("flame", d - d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
        } else
        if(l == 2)
        {
            world.spawnParticle("smoke", d + d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
            world.spawnParticle("flame", d + d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
        } else
        if(l == 3)
        {
            world.spawnParticle("smoke", d, d1 + d3, d2 - d4, 0.0D, 0.0D, 0.0D);
            world.spawnParticle("flame", d, d1 + d3, d2 - d4, 0.0D, 0.0D, 0.0D);
        } else
        if(l == 4)
        {
            world.spawnParticle("smoke", d, d1 + d3, d2 + d4, 0.0D, 0.0D, 0.0D);
            world.spawnParticle("flame", d, d1 + d3, d2 + d4, 0.0D, 0.0D, 0.0D);
        } else
        {
            world.spawnParticle("smoke", d, d1, d2, 0.0D, 0.0D, 0.0D);
            world.spawnParticle("flame", d, d1, d2, 0.0D, 0.0D, 0.0D);
        }
    }
   
   
   
   
   
   public int idDropped(int i, Random random)
   {
      return mod_BlockElectricTorch.blockElectricTorch.blockID;
   }


   
   
   public int quantityDropped(Random random)
       {
                return 4;
       }
}
Code:
avatar
austin56101
Moderator
Moderator

Posts : 85
Join date : 2011-10-22
Age : 21
Location : Cali!

View user profile

Back to top Go down

Re: [1.8.1 Mod Making] Creating a new torch!

Post by the undecided t on Tue Oct 25, 2011 3:12 am

how would you change the particles?
avatar
the undecided t
Helper

Posts : 45
Join date : 2011-10-20
Age : 21

View user profile http://www.blacklistgaming.org/forums

Back to top Go down

Re: [1.8.1 Mod Making] Creating a new torch!

Post by austin56101 on Tue Oct 25, 2011 3:31 am

the undecided t wrote:how would you change the particles?

in the blockelectrictorch:

Code:
 public void randomDisplayTick(World world, int i, int j, int k, Random random)
    {
        int l = world.getBlockMetadata(i, j, k);
        double d = (float)i + 0.5F;
        double d1 = (float)j + 0.85F;
        double d2 = (float)k + 0.5F;
        double d3 = 0.2199999988079071D;
        double d4 = 0.27000001072883606D;
        if(l == 1)
        {
            world.spawnParticle("smoke", d - d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
            world.spawnParticle("flame", d - d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
        } else
        if(l == 2)
        {
            world.spawnParticle("smoke", d + d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
            world.spawnParticle("flame", d + d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
        } else
        if(l == 3)
        {
            world.spawnParticle("smoke", d, d1 + d3, d2 - d4, 0.0D, 0.0D, 0.0D);
            world.spawnParticle("flame", d, d1 + d3, d2 - d4, 0.0D, 0.0D, 0.0D);
        } else
        if(l == 4)
        {
            world.spawnParticle("smoke", d, d1 + d3, d2 + d4, 0.0D, 0.0D, 0.0D);
            world.spawnParticle("flame", d, d1 + d3, d2 + d4, 0.0D, 0.0D, 0.0D);
        } else
        {
            world.spawnParticle("smoke", d, d1, d2, 0.0D, 0.0D, 0.0D);
            world.spawnParticle("flame", d, d1, d2, 0.0D, 0.0D, 0.0D);
        }
    }

this is were you change the x y z (aka i j k):
Code:

        double d = (float)i + 0.5F;
        double d1 = (float)j + 0.85F;
        double d2 = (float)k + 0.5F;


also were ever it says flame/smoke, you can add other type of particles! Very Happy
avatar
austin56101
Moderator
Moderator

Posts : 85
Join date : 2011-10-22
Age : 21
Location : Cali!

View user profile

Back to top Go down

Re: [1.8.1 Mod Making] Creating a new torch!

Post by the undecided t on Tue Oct 25, 2011 4:21 am

ok cool thats what i was looking for... where would i put the particle .pngs?
avatar
the undecided t
Helper

Posts : 45
Join date : 2011-10-20
Age : 21

View user profile http://www.blacklistgaming.org/forums

Back to top Go down

Re: [1.8.1 Mod Making] Creating a new torch!

Post by austin56101 on Tue Oct 25, 2011 5:02 am

theres like several places
but were i put it is
MpcFOLDER>bin>minecraft>here:)
avatar
austin56101
Moderator
Moderator

Posts : 85
Join date : 2011-10-22
Age : 21
Location : Cali!

View user profile

Back to top Go down

Re: [1.8.1 Mod Making] Creating a new torch!

Post by lcass on Thu Oct 27, 2011 4:36 pm

If you are going to change that you will need to then do for the particles create a new texture for them if your not going ot be using the standard flames and smoke

lcass
Member

Posts : 145
Join date : 2011-10-24
Location : england

View user profile http://www.youtube.com/user/thealcasgroup

Back to top Go down

Re: [1.8.1 Mod Making] Creating a new torch!

Post by PureTryOut on Sat Oct 29, 2011 6:36 pm

I now have BlockElectricTorchOn and BlockElectricTorchOff. So I don't want the ElectricTorchOff to spawn particles.
How can I do that?

PureTryOut
Member

Posts : 4
Join date : 2011-10-29

View user profile

Back to top Go down

Re: [1.8.1 Mod Making] Creating a new torch!

Post by MrCreeper07 on Sat Oct 29, 2011 6:56 pm

hey i got this error just renaming electric in BlockElectricTorch to BlockJiffyTorch on every one of those lines and changed the recipe and got this error

Code:
== ERRORS FOUND ==

src/minecraft/net/minecraft/src/mod_BlockJiffyTorch.java:21: reached end of file while parsing
}
^

1 error
==================
avatar
MrCreeper07
Member

Posts : 18
Join date : 2011-10-23

View user profile

Back to top Go down

Re: [1.8.1 Mod Making] Creating a new torch!

Post by PureTryOut on Sat Oct 29, 2011 7:01 pm

MrCreeper07 wrote:hey i got this error just renaming electric in BlockElectricTorch to BlockJiffyTorch on every one of those lines and changed the recipe and got this error

Code:
== ERRORS FOUND ==

src/minecraft/net/minecraft/src/mod_BlockJiffyTorch.java:21: reached end of file while parsing
}
^

1 error
==================

That means you forgot to place a bracket at the end of the file. Check the last part of the file and place a bracket and it should hopefully work.

PureTryOut
Member

Posts : 4
Join date : 2011-10-29

View user profile

Back to top Go down

Re: [1.8.1 Mod Making] Creating a new torch!

Post by lcass on Sat Oct 29, 2011 7:05 pm

PureTryOut wrote:I now have BlockElectricTorchOn and BlockElectricTorchOff. So I don't want the ElectricTorchOff to spawn particles.
How can I do that?
BTW to do this you will need to copy and invert the code from redstone torch and itemredstone torch (if there is one) it should function properly

lcass
Member

Posts : 145
Join date : 2011-10-24
Location : england

View user profile http://www.youtube.com/user/thealcasgroup

Back to top Go down

Re: [1.8.1 Mod Making] Creating a new torch!

Post by austin56101 on Sat Oct 29, 2011 7:42 pm

MrCreeper07 wrote:hey i got this error just renaming electric in BlockElectricTorch to BlockJiffyTorch on every one of those lines and changed the recipe and got this error

Code:
== ERRORS FOUND ==

src/minecraft/net/minecraft/src/mod_BlockJiffyTorch.java:21: reached end of file while parsing
}
^

1 error
==================

please post your code
avatar
austin56101
Moderator
Moderator

Posts : 85
Join date : 2011-10-22
Age : 21
Location : Cali!

View user profile

Back to top Go down

Re: [1.8.1 Mod Making] Creating a new torch!

Post by MrCreeper07 on Sat Oct 29, 2011 7:47 pm

ok here is the mod_BlockJiffyTorch.
Code:
package net.minecraft.src;
import java.util.Random;

public class mod_BlockJiffyTorch extends BaseMod
{


  public static final Block blockJiffyTorch =
            new BlockJiffyTorch(236,0).setHardness(0.0F).setResistance(5.0F).setLightValue(1.0F).setBlockName("BlockJiffyTorch");


  public mod_BlockJiffyTorch()
  { 

      ModLoader.RegisterBlock(blockJiffyTorch);
      blockJiffyTorch.blockIndexInTexture = ModLoader.addOverride("/terrain.png","/blockJiffyTorch.png");
      ModLoader.AddName(blockJiffyTorch, "blockJiffyTorch");
      ModLoader.AddRecipe(new ItemStack(blockJiffyTorch, 10), new Object[] {
        " * ", Character.valueOf('*'), Block.torchWood
      });
  }
avatar
MrCreeper07
Member

Posts : 18
Join date : 2011-10-23

View user profile

Back to top Go down

Re: [1.8.1 Mod Making] Creating a new torch!

Post by PureTryOut on Sat Oct 29, 2011 7:56 pm

MrCreeper07 wrote:ok here is the mod_BlockJiffyTorch.
Code:
package net.minecraft.src;
import java.util.Random;

public class mod_BlockJiffyTorch extends BaseMod
{


  public static final Block blockJiffyTorch =
            new BlockJiffyTorch(236,0).setHardness(0.0F).setResistance(5.0F).setLightValue(1.0F).setBlockName("BlockJiffyTorch");


  public mod_BlockJiffyTorch()
  { 

      ModLoader.RegisterBlock(blockJiffyTorch);
      blockJiffyTorch.blockIndexInTexture = ModLoader.addOverride("/terrain.png","/blockJiffyTorch.png");
      ModLoader.AddName(blockJiffyTorch, "blockJiffyTorch");
      ModLoader.AddRecipe(new ItemStack(blockJiffyTorch, 10), new Object[] {
        " * ", Character.valueOf('*'), Block.torchWood
      });
  }

Like I said... You're missing a bracket at the end.

Make it this:
Code:
package net.minecraft.src;
import java.util.Random;

public class mod_BlockJiffyTorch extends BaseMod
{


  public static final Block blockJiffyTorch =
            new BlockJiffyTorch(236,0).setHardness(0.0F).setResistance(5.0F).setLightValue(1.0F).setBlockName("BlockJiffyTorch");


  public mod_BlockJiffyTorch()
  { 

      ModLoader.RegisterBlock(blockJiffyTorch);
      blockJiffyTorch.blockIndexInTexture = ModLoader.addOverride("/terrain.png","/blockJiffyTorch.png");
      ModLoader.AddName(blockJiffyTorch, "blockJiffyTorch");
      ModLoader.AddRecipe(new ItemStack(blockJiffyTorch, 10), new Object[] {
        " * ", Character.valueOf('*'), Block.torchWood
      });
  }
}

PureTryOut
Member

Posts : 4
Join date : 2011-10-29

View user profile

Back to top Go down

Re: [1.8.1 Mod Making] Creating a new torch!

Post by MrCreeper07 on Sat Oct 29, 2011 8:42 pm

oh thanks didn't see your post before! Thank you so much!!!
avatar
MrCreeper07
Member

Posts : 18
Join date : 2011-10-23

View user profile

Back to top Go down

Re: [1.8.1 Mod Making] Creating a new torch!

Post by MrCreeper07 on Sat Oct 29, 2011 8:43 pm

also got this error and you already know the code because PureTryOut has it.

Code:
== ERRORS FOUND ==

src/minecraft/net/minecraft/src/mod_BlockJiffyTorch.java:4: net.minecraft.src.mod_BlockJiffyTorch is not abstract and does not override abstract method Version() in net.minecraft.src.BaseMod
public class mod_BlockJiffyTorch extends BaseMod
^

1 error
==================
I know that it extends the wrong thing because this has happened before but what does it extend to?
avatar
MrCreeper07
Member

Posts : 18
Join date : 2011-10-23

View user profile

Back to top Go down

Re: [1.8.1 Mod Making] Creating a new torch!

Post by PureTryOut on Sat Oct 29, 2011 8:51 pm

MrCreeper07 wrote:also got this error and you already know the code because PureTryOut has it.

Code:
== ERRORS FOUND ==

src/minecraft/net/minecraft/src/mod_BlockJiffyTorch.java:4: net.minecraft.src.mod_BlockJiffyTorch is not abstract and does not override abstract method Version() in net.minecraft.src.BaseMod
public class mod_BlockJiffyTorch extends BaseMod
^

1 error
==================
I know that it extends the wrong thing because this has happened before but what does it extend to?
I believe it has to be this:
Code:
public class mod_BlockJiffyTorch extends Block

PureTryOut
Member

Posts : 4
Join date : 2011-10-29

View user profile

Back to top Go down

Re: [1.8.1 Mod Making] Creating a new torch!

Post by MrCreeper07 on Sat Oct 29, 2011 9:20 pm

then i got this error

Code:
== ERRORS FOUND ==

src/minecraft/net/minecraft/src/mod_BlockJiffyTorch.java:13: cannot find symbol
symbol  : constructor Block()
location: class net.minecraft.src.Block
{
^

1 error
==================
now im just confused about modding!!
avatar
MrCreeper07
Member

Posts : 18
Join date : 2011-10-23

View user profile

Back to top Go down

Re: [1.8.1 Mod Making] Creating a new torch!

Post by MrCreeper07 on Sun Oct 30, 2011 12:53 am

OH MY GOSH CAN SOMEONE HELP ME!!!!!! LOOK RIGHT ABOVE THIS!!! HAS THE WORLD STOPED MOVING???
avatar
MrCreeper07
Member

Posts : 18
Join date : 2011-10-23

View user profile

Back to top Go down

Re: [1.8.1 Mod Making] Creating a new torch!

Post by TheFatOne on Sat Nov 05, 2011 10:59 pm

you have to add: public String Version()
{
return "1.7.3";
}

TheFatOne
Member

Posts : 2
Join date : 2011-11-05

View user profile

Back to top Go down

Re: [1.8.1 Mod Making] Creating a new torch!

Post by TheFatOne on Sat Nov 05, 2011 11:17 pm

btw can someone help me with the texture it is like derping up itself

TheFatOne
Member

Posts : 2
Join date : 2011-11-05

View user profile

Back to top Go down

Re: [1.8.1 Mod Making] Creating a new torch!

Post by cosbraa on Sun Nov 06, 2011 5:35 am

how do you make your own particle effects. if i want a blue flame how would i go about making it? in the code it just had "flame"?

cosbraa
Member

Posts : 2
Join date : 2011-11-06

View user profile

Back to top Go down

Re: [1.8.1 Mod Making] Creating a new torch!

Post by Minecraftn00b123 on Mon Nov 21, 2011 10:13 pm

When i craft the torch it looks like a gray square but when i place it down it's fine....?

Minecraftn00b123
Member

Posts : 7
Join date : 2011-11-08

View user profile

Back to top Go down

Re: [1.8.1 Mod Making] Creating a new torch!

Post by MrCreeper07 on Wed Nov 23, 2011 4:04 pm

Minecraftn00b123 wrote:When i craft the torch it looks like a gray square but when i place it down it's fine....?
yeah I got this too. He needs to add more code to it and he hasn't yet
avatar
MrCreeper07
Member

Posts : 18
Join date : 2011-10-23

View user profile

Back to top Go down

Re: [1.8.1 Mod Making] Creating a new torch!

Post by pv9avenger on Thu Mar 08, 2012 8:13 pm

MrCreeper07 wrote:also got this error and you already know the code because PureTryOut has it.

Code:
== ERRORS FOUND ==

src/minecraft/net/minecraft/src/mod_BlockJiffyTorch.java:4: net.minecraft.src.mod_BlockJiffyTorch is not abstract and does not override abstract method Version() in net.minecraft.src.BaseMod
public class mod_BlockJiffyTorch extends BaseMod
^

1 error
==================
I know that it extends the wrong thing because this has happened before but what does it extend to?

oh ya dude i also got this error. it's not the jiffyTorch code thats wrong it the mod_* thats wrong! it's cause you are trying to make a 1.0/1.1 mod then you have to change the

Code:

public string Version()
{
return "1.8.1"
}

to

Code:

public string getVersion()
{
return "1.0/1.1"
}

pv9avenger
Member

Posts : 8
Join date : 2012-01-31
Age : 18
Location : Iceland

View user profile

Back to top Go down

Re: [1.8.1 Mod Making] Creating a new torch!

Post by Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum