[1.8.1] On/Off Light Block
+4
groxmapper
the undecided t
austin56101
Strengthowns
8 posters
MC Modding :: Modding :: Singleplayer Modding :: Tutorials
Page 1 of 2
Page 1 of 2 • 1, 2
[1.8.1] On/Off Light Block
This tutorial is about how to make a block that gives off light but can be switched on and off.
1. After making those files, make two block textures called "NamehereOff" and "NamehereOn".
2. In "mod_Namehere" at the bottom in "static" on the 3rd and 5th line, where it says 249 and 248, that is the block ID so you can change it to what ever you want.
3. All of this should recompile fine without any errors.
Please read the block tutorial for more help!
BlockNamehere
BlockNamehere
- Code:
package net.minecraft.src;
import java.util.Random;
public class BlockNamehere extends Block
{
public BlockNamehere(int i, int j, boolean flag)
{
super(i, Material.ground);
blockIndexInTexture = j;
isActive = flag;
if(isActive)
{
super.setLightValue(1.0F);
}
}
public int idDropped(int i, Random random)
{
return mod_Namehere.NamehereOff.blockID;
}
public void onNeighborBlockChange(World world, int i, int j, int k, int l)
{
if(world.isBlockIndirectlyGettingPowered(i, j, k))
{
world.setBlockWithNotify(i, j, k, mod_Namehere.NamehereOn.blockID);
} else
{
world.setBlockWithNotify(i, j, k, mod_Namehere.NamehereOff.blockID);
}
}
private boolean isActive;
}
mod_Namehere
- Code:
package net.minecraft.src;
public class mod_Namehere extends BaseMod
{
public mod_Namehere()
{
ModLoader.RegisterBlock(NamehereOn);
ModLoader.RegisterBlock(NamehereOff);
ModLoader.AddName(NamehereOn, "Namehere");
ModLoader.AddName(NamehereOff, "Namehere");
ModLoader.AddRecipe(new ItemStack(NamehereOff, 1), new Object[] {
"XXX", "X@X", "XXX", Character.valueOf('X'), Block.glass, Character.valueOf('@'), Block.torchWood
});
}
public String Version()
{
return "1.6.6";
}
public static Block NamehereOn;
public static Block NamehereOff;
public static int NamehereTextureOff;
public static int NamehereTextureOn;
static
{
NamehereTextureOff = ModLoader.getUniqueSpriteIndex("/terrain.png");
NamehereTextureOn = ModLoader.getUniqueSpriteIndex("/terrain.png");
NamehereOn = (new BlockNamehere(249, NamehereTextureOn, true)).setHardness(0.3F).setResistance(5000.0F).setBlockName("NamehereOn");
NamehereOff = (new BlockNamehere(248, NamehereTextureOff, false)).setHardness(0.3F).setResistance(5000.0F).setBlockName("NamehereOff");
ModLoader.addOverride("/terrain.png", "/NamehereOff.png", NamehereTextureOff);
ModLoader.addOverride("/terrain.png", "/NamehereOn.png", NamehereTextureOn);
}
}
Help: BOTH
1. After making those files, make two block textures called "NamehereOff" and "NamehereOn".
2. In "mod_Namehere" at the bottom in "static" on the 3rd and 5th line, where it says 249 and 248, that is the block ID so you can change it to what ever you want.
3. All of this should recompile fine without any errors.
Last edited by Strengthowns on Wed Oct 26, 2011 1:23 am; edited 1 time in total
Re: [1.8.1] On/Off Light Block
Just wanted to let you know it works with 1.8.1
Also can you code It to preform a strobe action?
Like on this block you can set it up on a clock and it wors
But I want a code versIon if possible?
Also can you code It to preform a strobe action?
Like on this block you can set it up on a clock and it wors
But I want a code versIon if possible?
austin56101- Moderator
- Posts : 85
Join date : 2011-10-22
Age : 28
Location : Cali!
Re: [1.8.1] On/Off Light Block
I have never done this before but, if you maybe set up a tick rate and update the light to be on or off every tick, it might work.
Re: [1.8.1] On/Off Light Block
o well do you mind trying it?
austin56101- Moderator
- Posts : 85
Join date : 2011-10-22
Age : 28
Location : Cali!
Re: [1.8.1] On/Off Light Block
I've done it, but you need to really spam a redstone tick clock(if you use stranegth's code) or (what I also added) is make it swap on right click, then spam that. (somehow it's spamproof - never broke once) you also need to make sure the setrequiresselfnotify thing is used, otherwise the light doesn't update that quickly.
I thought I was the only one to make something like this, but I should've known stength knows all
I thought I was the only one to make something like this, but I should've known stength knows all
Last edited by groxmapper on Tue Oct 25, 2011 3:14 am; edited 1 time in total
groxmapper- Member
- Posts : 27
Join date : 2011-10-24
Re: [1.8.1] On/Off Light Block
Might lagg/crash a majority of people using it.
breakyorself- Member
- Posts : 60
Join date : 2011-10-19
Re: [1.8.1] On/Off Light Block
breakyorself wrote:Might lagg/crash a majority of people using it.
Actually it doesn't cause any sort of crash, the amount of updates will lag yes but only if your using an ungodly amount of the lgiht blocks.
groxmapper- Member
- Posts : 27
Join date : 2011-10-24
Re: [1.8.1] On/Off Light Block
groxmapper wrote:breakyorself wrote:Might lagg/crash a majority of people using it.
Actually it doesn't cause any sort of crash, the amount of updates will lag yes but only if your using an ungodly amount of the lgiht blocks.
you mind making a tut?
austin56101- Moderator
- Posts : 85
Join date : 2011-10-22
Age : 28
Location : Cali!
Re: [1.8.1] On/Off Light Block
i was gonna try coding where it stays powered but the light spams on and off
Re: [1.8.1] On/Off Light Block
im still not very good at ticks ect..
:/
:/
austin56101- Moderator
- Posts : 85
Join date : 2011-10-22
Age : 28
Location : Cali!
Re: [1.8.1] On/Off Light Block
i tried doing it like so:
- Spoiler:
- Code:
package net.minecraft.src;
import java.util.Random;
public class Blockstrobe extends Block
{
public Blockstrobe(int i, int j, boolean flag)
{
super(i, Material.ground);
blockIndexInTexture = j;
isActive = flag;
if(isActive)
{
super.setLightValue(1.0F);
}
}
public int idDropped(int i, Random random)
{
return mod_test.strobeOff.blockID;
}
public void onNeighborBlockChange(World world, int i, int j, int k, int l)
{
if(world.isBlockIndirectlyGettingPowered(i, j, k))
{ boolean flag = false;
while (flag = false) {
world.setBlockWithNotify(i, j, k, mod_test.strobeOn.blockID);
try {
Thread.sleep(900);
} catch (InterruptedException e) {
e.printStackTrace();
}
assert !flag; }
while (flag = true) {
world.setBlockWithNotify(i, j, k, mod_test.strobeOff.blockID);
try {
Thread.sleep(900);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
else
{
world.setBlockWithNotify(i, j, k, mod_test.strobeOff.blockID);
}
}
private boolean isActive;
}
Re: [1.8.1] On/Off Light Block
- Code:
public void updateTick(World world, int i, int j, int k, Random random)
{
boolean flag = func_30002_h(world, i, j, k);
for(; torchUpdates.size() > 0 && world.getWorldTime() - ((RedstoneUpdateInfo)torchUpdates.get(0)).updateTime > 100L; torchUpdates.remove(0)) { }
if(torchActive)
{
if(flag)
{
world.setBlockAndMetadataWithNotify(i, j, k, Block.torchRedstoneIdle.blockID, world.getBlockMetadata(i, j, k));
if(checkForBurnout(world, i, j, k, true))
{
world.playSoundEffect((float)i + 0.5F, (float)j + 0.5F, (float)k + 0.5F, "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
for(int l = 0; l < 5; l++)
{
double d = (double)i + random.nextDouble() * 0.59999999999999998D + 0.20000000000000001D;
double d1 = (double)j + random.nextDouble() * 0.59999999999999998D + 0.20000000000000001D;
double d2 = (double)k + random.nextDouble() * 0.59999999999999998D + 0.20000000000000001D;
world.spawnParticle("smoke", d, d1, d2, 0.0D, 0.0D, 0.0D);
}
}
}
}
cant you edit this somehow?
and place the isActive right now
austin56101- Moderator
- Posts : 85
Join date : 2011-10-22
Age : 28
Location : Cali!
Re: [1.8.1] On/Off Light Block
O well also you can change title to [1.8.1]
It still works lol
It still works lol
austin56101- Moderator
- Posts : 85
Join date : 2011-10-22
Age : 28
Location : Cali!
Re: [1.8.1] On/Off Light Block
that will crash due to the fact being youve not only set an strobe BUt no time in between and seeing how its done it gets more laggy and seeing how fast things process you would see why this would be an issuethe undecided t wrote:i tried doing it like so:but it freezes mc
- Spoiler:
- Code:
package net.minecraft.src;
import java.util.Random;
public class Blockstrobe extends Block
{
public Blockstrobe(int i, int j, boolean flag)
{
super(i, Material.ground);
blockIndexInTexture = j;
isActive = flag;
if(isActive)
{
super.setLightValue(1.0F);
}
}
public int idDropped(int i, Random random)
{
return mod_test.strobeOff.blockID;
}
public void onNeighborBlockChange(World world, int i, int j, int k, int l)
{
if(world.isBlockIndirectlyGettingPowered(i, j, k))
{ boolean flag = false;
while (flag = false) {
world.setBlockWithNotify(i, j, k, mod_test.strobeOn.blockID);
try {
Thread.sleep(900);
} catch (InterruptedException e) {
e.printStackTrace();
}
assert !flag; }
while (flag = true) {
world.setBlockWithNotify(i, j, k, mod_test.strobeOff.blockID);
try {
Thread.sleep(900);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
else
{
world.setBlockWithNotify(i, j, k, mod_test.strobeOff.blockID);
}
}
private boolean isActive;
}
Re: [1.8.1] On/Off Light Block
Maybe a slower one?
austin56101- Moderator
- Posts : 85
Join date : 2011-10-22
Age : 28
Location : Cali!
Re: [1.8.1] On/Off Light Block
yer but he needs to include an integer that is a pause maybe doing something like
- Code:
if redcurrent = true { for(i=0,i++) while (i>10) pause [amount of time] i=0
Re: [1.8.1] On/Off Light Block
Well you can do a working strobe using this code
But I was talking about a coded strobe
But I was talking about a coded strobe
austin56101- Moderator
- Posts : 85
Join date : 2011-10-22
Age : 28
Location : Cali!
Re: [1.8.1] On/Off Light Block
Well there is the like.. Grrrr forgot the mod name but it's released on the minecraft forums and it a huge mod were u can auto mine with pipes
And there's oil
Anyway the pipes in that mod perform a glowing strobish action
And there's oil
Anyway the pipes in that mod perform a glowing strobish action
austin56101- Moderator
- Posts : 85
Join date : 2011-10-22
Age : 28
Location : Cali!
Re: [1.8.1] On/Off Light Block
how would I do this the other way Eg if I put fuel in lets say a super furnace that it would activate some redstone
Page 1 of 2 • 1, 2
Similar topics
» [1.8.1] Block
» How Do I Add A Block For 1.2.5
» [1.8.1] Advanced Block
» [1.8.1] Explosive Block
» [unsolved]furnace like block 1.8.1/1.0.0/1.1
» How Do I Add A Block For 1.2.5
» [1.8.1] Advanced Block
» [1.8.1] Explosive Block
» [unsolved]furnace like block 1.8.1/1.0.0/1.1
MC Modding :: Modding :: Singleplayer Modding :: Tutorials
Page 1 of 2
Permissions in this forum:
You cannot reply to topics in this forum