
Hannibal The Cannibal
Members-
Posts
4 -
Joined
-
Last visited
Converted
-
Gender
Undisclosed
-
Personal Text
I am new!
Hannibal The Cannibal's Achievements

Tree Puncher (2/8)
0
Reputation
-
[1.7.10] world.setBlock method
Hannibal The Cannibal replied to Hannibal The Cannibal's topic in Modder Support
I'll start a new 1.9 workspace, and be sure keep in mind the Tile Entity information. Thanks! I've forgotten how long it's been since 1.7.10 was 'new'. EDIT: Went ahead and made these changes to my mod, and it behaves exactly how it should! thanks, again! -
[1.7.10] world.setBlock method
Hannibal The Cannibal replied to Hannibal The Cannibal's topic in Modder Support
I'll start a new 1.9 workspace, and be sure keep in mind the Tile Entity information. Thanks! I've forgotten how long it's been since 1.7.10 was 'new'. EDIT: Went ahead and made these changes to my mod, and it behaves exactly how it should! thanks, again! -
[1.7.10] world.setBlock method
Hannibal The Cannibal replied to Hannibal The Cannibal's topic in Modder Support
I am currently working on my first real minecraft mod. I have a bit over a year in Java experience, and know how to use google so I've already tried looking for solutions to my issue. My mod is 'grey-goo' inspired, with the idea that my mod's 'goo' blocks, over time randomly replace other adjacent blocks with itself, who then go one to spread and so forth until you've got an entire chunk of land 'transformed/devoured' by this 'goo block' So for i have a block, and a tile entity. Main Mod Class: package com.mymods.virusmod; import com.mymods.virusmod.blocks.BasicBlock; import com.mymods.virusmod.tileentities.BasicEntity; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.registry.GameRegistry; import net.minecraft.block.Block; //import net.minecraft.block.Block; import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; @Mod(modid = "VirusMod", version = "0.0.0") public class VirusMod { public static final BasicBlock basicBlock = new BasicBlock(); @EventHandler public void preInit(FMLPreInitializationEvent event){ GameRegistry.registerBlock(basicBlock,"BasicBlock"); BasicEntity.addMapping(BasicEntity.class, "BasicEntity"); } @EventHandler public void init(FMLInitializationEvent event){ } @EventHandler public void postInit(FMLInitializationEvent event){ } } My 'Basic Block' Class package com.mymods.virusmod.blocks; import com.mymods.virusmod.tileentities.BasicEntity; import net.minecraft.block.Block; import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; public class BasicBlock extends Block implements ITileEntityProvider{ public BasicBlock() { super(Material.ground); setBlockTextureName("anvil_base"); setCreativeTab(CreativeTabs.tabBlock); setHardness(2.0F); setResistance(6.0F); setLightLevel(1.0F); setBlockName("BasicBlock"); setHarvestLevel("pickaxe", 3); } @Override public TileEntity createNewTileEntity(World world, int p_149915_2_) { return new BasicEntity(); } @Override public void breakBlock(World world, int x, int y, int z, Block block, int stuff) { super.breakBlock(world, x, y, z, block, stuff); world.removeTileEntity(x, y, z); } } And finally the Basic Entity Class, where the magic happens: package com.mymods.virusmod.tileentities; import java.util.ArrayList; import java.util.Random; import com.mymods.virusmod.VirusMod; import net.minecraft.block.Block; import net.minecraft.tileentity.TileEntity; public class BasicEntity extends TileEntity{ spackage com.mymods.virusmod.tileentities; import java.util.ArrayList; import java.util.Random; import com.mymods.virusmod.VirusMod; import net.minecraft.block.Block; import net.minecraft.tileentity.TileEntity; public class BasicEntity extends TileEntity{ static final int MIN_ALTITUDE = 50; static Random rand = new Random(); static final int COUNTER_DELAY = 20; int counter = COUNTER_DELAY; static final ArrayList<Block> blackList = new ArrayList<Block>(){{ add(Block.getBlockFromName("air")); add(VirusMod.basicBlock); }}; @Override public void updateEntity() { if(yCoord > MIN_ALTITUDE){ counter--; if(counter < 0){ counter = COUNTER_DELAY; if(rand.nextInt(100) < 5){ infectAdjacent(); } } } } public void infectAdjacent(){ for(int x = -1; x < 2;x++){ for(int y = -1; y < 2; y++){ for(int z = -1; z < 2; z++){ if(!(x == 0 && y == 0 && z == 0)){ Block target; target = worldObj.getBlock(x+ this.xCoord, y+ this.yCoord, z+ this.zCoord); boolean isTarget = true; for(Block b : blackList){ if(target == b){ isTarget = false; break; } } if(isTarget){ if(rand.nextInt(100) < 30){ worldObj.setBlock(x+xCoord, y+ yCoord, z+zCoord, VirusMod.basicBlock,0,1); } } } } } } } public boolean canUpdate(){ return true; } } What happens at the moment, is very strange. I place down a 'virus/grey goo' block, and after a few seconds it infects an adjacent block or two and so on. However, if i place another block on SOME of these newly infected goos, they instantly revert to what they were before, and in a few seconds are infected again by adjacent goos. The amount of times for me to be be able to watch a block be infected, place any block on it(by right clicking) watch it revert, be infected by nearby viruses until it stops reverting is anywhere between 1 and 10. I believe the only reason for this would be the 'setblock' method. worldObj.setBlock(x+xCoord, y+ yCoord, z+zCoord, VirusMod.basicBlock,0,1); I am setting the metadata of the new block to 0, this doesn't do anything as my blocks do not use any metadata, and the 'flag' is set to 1, because it makes no difference to my block whether i set it from 1-4. If anyone could give any input on how i may be using setBlock() wrong, please respond! Thanks so much for the help. -
I am currently working on my first real minecraft mod. I have a bit over a year in Java experience, and know how to use google so I've already tried looking for solutions to my issue. My mod is 'grey-goo' inspired, with the idea that my mod's 'goo' blocks, over time randomly replace other adjacent blocks with itself, who then go one to spread and so forth until you've got an entire chunk of land 'transformed/devoured' by this 'goo block' So for i have a block, and a tile entity. Main Mod Class: package com.mymods.virusmod; import com.mymods.virusmod.blocks.BasicBlock; import com.mymods.virusmod.tileentities.BasicEntity; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.registry.GameRegistry; import net.minecraft.block.Block; //import net.minecraft.block.Block; import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; @Mod(modid = "VirusMod", version = "0.0.0") public class VirusMod { public static final BasicBlock basicBlock = new BasicBlock(); @EventHandler public void preInit(FMLPreInitializationEvent event){ GameRegistry.registerBlock(basicBlock,"BasicBlock"); BasicEntity.addMapping(BasicEntity.class, "BasicEntity"); } @EventHandler public void init(FMLInitializationEvent event){ } @EventHandler public void postInit(FMLInitializationEvent event){ } } My 'Basic Block' Class package com.mymods.virusmod.blocks; import com.mymods.virusmod.tileentities.BasicEntity; import net.minecraft.block.Block; import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; public class BasicBlock extends Block implements ITileEntityProvider{ public BasicBlock() { super(Material.ground); setBlockTextureName("anvil_base"); setCreativeTab(CreativeTabs.tabBlock); setHardness(2.0F); setResistance(6.0F); setLightLevel(1.0F); setBlockName("BasicBlock"); setHarvestLevel("pickaxe", 3); } @Override public TileEntity createNewTileEntity(World world, int p_149915_2_) { return new BasicEntity(); } @Override public void breakBlock(World world, int x, int y, int z, Block block, int stuff) { super.breakBlock(world, x, y, z, block, stuff); world.removeTileEntity(x, y, z); } } And finally the Basic Entity Class, where the magic happens: package com.mymods.virusmod.tileentities; import java.util.ArrayList; import java.util.Random; import com.mymods.virusmod.VirusMod; import net.minecraft.block.Block; import net.minecraft.tileentity.TileEntity; public class BasicEntity extends TileEntity{ spackage com.mymods.virusmod.tileentities; import java.util.ArrayList; import java.util.Random; import com.mymods.virusmod.VirusMod; import net.minecraft.block.Block; import net.minecraft.tileentity.TileEntity; public class BasicEntity extends TileEntity{ static final int MIN_ALTITUDE = 50; static Random rand = new Random(); static final int COUNTER_DELAY = 20; int counter = COUNTER_DELAY; static final ArrayList<Block> blackList = new ArrayList<Block>(){{ add(Block.getBlockFromName("air")); add(VirusMod.basicBlock); }}; @Override public void updateEntity() { if(yCoord > MIN_ALTITUDE){ counter--; if(counter < 0){ counter = COUNTER_DELAY; if(rand.nextInt(100) < 5){ infectAdjacent(); } } } } public void infectAdjacent(){ for(int x = -1; x < 2;x++){ for(int y = -1; y < 2; y++){ for(int z = -1; z < 2; z++){ if(!(x == 0 && y == 0 && z == 0)){ Block target; target = worldObj.getBlock(x+ this.xCoord, y+ this.yCoord, z+ this.zCoord); boolean isTarget = true; for(Block b : blackList){ if(target == b){ isTarget = false; break; } } if(isTarget){ if(rand.nextInt(100) < 30){ worldObj.setBlock(x+xCoord, y+ yCoord, z+zCoord, VirusMod.basicBlock,0,1); } } } } } } } public boolean canUpdate(){ return true; } } What happens at the moment, is very strange. I place down a 'virus/grey goo' block, and after a few seconds it infects an adjacent block or two and so on. However, if i place another block on SOME of these newly infected goos, they instantly revert to what they were before, and in a few seconds are infected again by adjacent goos. The amount of times for me to be be able to watch a block be infected, place any block on it(by right clicking) watch it revert, be infected by nearby viruses until it stops reverting is anywhere between 1 and 10. I believe the only reason for this would be the 'setblock' method. worldObj.setBlock(x+xCoord, y+ yCoord, z+zCoord, VirusMod.basicBlock,0,1); I am setting the metadata of the new block to 0, this doesn't do anything as my blocks do not use any metadata, and the 'flag' is set to 1, because it makes no difference to my block whether i set it from 1-4. If anyone could give any input on how i may be using setBlock() wrong, please respond! Thanks so much for the help.