Started by
joshuawl
on
Topic category: Help with Minecraft modding (Java Edition)
I decided to make a smoke machine in my mod that turns on when given a redstone signal. I made it turn on properly and it does work, except for the fact that every smoke machine in the world turns on when I power only one. I used the particle spawing condition that allows paricles to spawn when a variable is true, but using this makes all of them in the world turn on at the same time. I also tried using the spawn particles event, but that wouldn't even spawn any particles at all. Anyone know of a different way I could make this work?
Make 2 blocks :one that spawns particles, one that doesn't. The first one drops the second. It has got a redstone off events taht adds the second block. The second has got a redstone on events that adds the first. Go to the code of the second. Remove the world else where there is else if
Ok you can do this:
Go create 2 blocks in mcreator who both will have the smoke Machine texture.
Name the first SmokeMachine or whatever and the other SmokeMachineActive to be able to separate them from eachother.
Now on the "active" block you add your smoke.
And on the "not active" block you add no smoke
Then you add any event for "Redstone On" onthe "not active" block.
(add just any event, this event will be overwritten later)
Then you add any event for "Redstone Off" on the "active" block.
(This event will be overwritten aswell)
For the "active" block you enter code view so you can edit source code and you scroll down till you find:
"public void neighborChanged(IBlockState state, ..."
Then you overwrite that whole function with this code:
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block neighborBlock, BlockPos fromPos){
super.neighborChanged(state,world,pos,neighborBlock,fromPos);
int i = pos.getX();
int j = pos.getY();
int k = pos.getZ();
if (world.isBlockIndirectlyGettingPowered(new BlockPos(i, j, k))<=0){
if(true){
world.setBlockState(new BlockPos(i, j, k), mcreator_smokeMachine.block.getDefaultState(), 3);
}
}
}
You see the last line of code in this function is:
mcreator_smokeMachine.block.getDefaultState(), 3);
If you named your smoke machine something else than "smokeMachine" you replace "mcreator_smokeMachine" with "mcreator_yourMachineName"
Now, for the "not active" block you enter code view once again and find:
"public void neighborChanged(IBlockState state, ..."
then you overwrite that fuction with this code:
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block neighborBlock, BlockPos fromPos){
super.neighborChanged(state,world,pos,neighborBlock,fromPos);
int i = pos.getX();
int j = pos.getY();
int k = pos.getZ();
if (world.isBlockIndirectlyGettingPowered(new BlockPos(i, j, k))>0){
if(true){
world.setBlockState(new BlockPos(i, j, k), mcreator_smokeMachineActive.block.getDefaultState(), 3);
}
}
}
And oce again, If you named your smoke machine something else than "smokeMachine" you replace "mcreator_smokeMachineActive" with "mcreator_yourMachineNameActive"
If this didn't work, you can download my workspace and compare to see if you missed something.
Download My Workspace
@#2 Thanks! This should work out great, but do you know if it is possible to make it where the active one doesn't appear in the creative inventory? If not it should be fine, it would only annoy me for a little while. :)
@#2.1 I don't know anything about that one, but I could mess around with the code and see if something works
@#2.1.1 OK, thanks. :)
@#2.1 Ahaha! The first thing I tried worked! xD
You just find this line:
block = (BlockSmokeMachineActive) (new BlockSmokeMachineActive().setHardness(2.0F).setResistance(10.0F).setLightLevel(0.0F) .setUnlocalizedName("SmokeMachineActive").setLightOpacity(0).setCreativeTab(CreativeTabs.BUILDING_BLOCKS)); And remove the ".setCreativeTab(CreativeTabs.BUILDING_BLOCKS)" so it looks like this: block = (BlockSmokeMachineActive) (new BlockSmokeMachineActive().setHardness(2.0F).setResistance(10.0F).setLightLevel(0.0F) .setUnlocalizedName("SmokeMachineActive").setLightOpacity(0));I noticed some of the text went off vision so here is all the text:
https://i.gyazo.com/f520977a1c33c4efc1c5d8e3c84d8861.png
@#2.1.2 Thanks, now my creative inventory looks how it should.
@#3 Uh... For some reason when I put an event for the SmokeMachineActive in the redstone off i get an error, but if I also put something in redstone on it works.
@#3.1 just make sure mcreator doesn't overwrite the previous code you've written
upload your mod when it's done, I wanna see it :D
@#4 I plan on doing that, I just need to fix a few things before I do. But mostly everything is done, at least for version 1.0.