Posted August 31, 201510 yr Ok so I created a block called PowerTest. Please bare in mind im not the best modder out there im still learning im making this mod to learn more . package com.zombiesurvival.blocks; import com.zombiesurvival.power.pipes.BlockPipe; import com.zombiesurvival.tileentity.PowerTestTileEntity; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.server.gui.IUpdatePlayerListBox; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockPos; import net.minecraft.world.World; public class PowerTest extends BlockContainer { public PowerTest(String unlocalizedName, Material mat) { super(Material.iron); this.setCreativeTab(CreativeTabs.tabBlock); this.setUnlocalizedName(unlocalizedName); } public boolean activated = false; @Override public TileEntity createNewTileEntity(World worldIn, int meta) { return new PowerTestTileEntity(); } public void onNeighborBlockChange(World w, BlockPos pos, IBlockState state, Block nb) { if (!w.isRemote) { //TODO: If Power is already on then it cannot be turned on again if(nb != ModBlocks.pipe) { System.out.println("Power On"); if(BlockPipe.isPoweredGlobal == true) { System.out.println(" We Have Power"); } else if(BlockPipe.isPoweredGlobal == false) { System.out.println(" We Don't Have Power"); } else { System.out.println(" Error"); } } //TODO Change to Else If Statement to check for errors else then it's an error else { System.out.println("Power off"); } } } public boolean pipeNext(World w,int x,int y,int z) { return activated; } public void onBlockActivated() { } } I kow that the stuff im doing in onNeighborBlockChange should be in a method that checks for updates on every tick but it was for testing. In My Block Pipes i created 2 booleans one that's static, (probably so wrong) I honestly think i should be saving this boolean somewhere else but i don't know how/ where. package com.zombiesurvival.power.pipes; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Blocks; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumWorldBlockLayer; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class BlockPipe extends BlockContainer { public boolean isPowered; public static boolean isPoweredGlobal; public BlockPipe(String unlocalizedName, Material mat) { super(mat); float pixel = 1F/16F; //Minx,miny,minz,maxx,maxy,maxz this.setBlockBounds(11*pixel/2,11*pixel/2, 11*pixel/2, 1-11*pixel/2, 1-11*pixel/2, 1-11*pixel/2); this.setCreativeTab(CreativeTabs.tabBlock); this.setUnlocalizedName(unlocalizedName); } public int getRenderType() { return -1; } public boolean isOpaqueCube() { return false; } public boolean renderAsNormalBlock() { return false; } public TileEntity createNewTileEntity(World w, int i) { return new TileEntityPipe(); } @SideOnly(Side.CLIENT) public EnumWorldBlockLayer getBlockLayer() { return EnumWorldBlockLayer.CUTOUT; } public void onNeighborBlockChange(World w, BlockPos pos, IBlockState state, Block nb) { if (!w.isRemote) { //TODO: If Power is already on then it cannot be turned on again if(nb == Blocks.stone) { isPowered = true; if(isPowered = true) { isPoweredGlobal = true; System.out.println("Pipe has Power"); } } //TODO Change to Else If Statement to check for errors else then it's an error else if (nb != Blocks.stone) { isPowered = false; if(isPowered = false) { System.out.println("Pipe doesn't have Power "); isPoweredGlobal = false; } else { //System.out.println("Pipe has Power"); //isPoweredGlobal = true; } } } } } So yeah Thats the code. I know it;s probably all wrong
August 31, 201510 yr There is a lot wrong with your code. And not only Minecraft related stuff, overall programming stuff, e.g.: isPowered = true; if(isPowered = true) {...} There are already 2 things wrong in these lines of code: You set isPowered to true , then you (try) to check if it is true again (of course it's true, you just set it) I said you tried to check if it's true, but you actually set it to true, again... Learn the difference between = and == And this is just the beginning... Also, if this is a mod to 'learn' Minecraft modding, don't start with something big, like an energy system. Start with the basics (basic Block and Item ), and then continue. And I doubt you have enough Java knowledge to mod Minecraft, so unless you can proof you know atleast the basics, go learn Java, and then come back to modding Minecraft. Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.