
Minothor
Members-
Posts
63 -
Joined
Everything posted by Minothor
-
[Resolved][1.7.2] Custom Log causing crash when rendered
Minothor replied to Minothor's topic in Modder Support
Here's the Latest run: package minothor.bab.blocks; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.util.IIcon; import net.minecraft.block.*; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.world.World; public class blockStrippedOak extends BlockRotatedPillar{ public blockStrippedOak() { super(Material.wood); setBlockName("BlockStrippedOak"); setHarvestLevel("axe",0); setHardness(0.5F); setStepSound(Block.soundTypeWood); // TODO Auto-generated constructor stub } @SideOnly(Side.CLIENT) protected IIcon[] icons; @SideOnly(Side.CLIENT) @Override public void registerIcons(IIconRegister par1IconRegister) { this.icons = new IIcon[2]; System.out.println("Icon Array Length: "+ icons.length); this.icons[0] = par1IconRegister.registerIcon("bigassbarrels" + ":" + "StrippedLog"); System.out.println("icons 0 :" + icons[0]); this.icons[1] = par1IconRegister.registerIcon("bigassbarrels" + ":" + "StrippedLog"); System.out.println("icons 1 :" + icons[1]); } @SideOnly(Side.CLIENT) @Override public IIcon getSideIcon(int side) { switch(side) { case 0: return this.icons[0]; case 1: return this.icons[0]; default: return this.icons[1]; } } public int onBlockPlaced (World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metaD) { /*int j1 = par9 & 3; byte b0 = 0; switch (par5) { case 0: case 1: b0 = 0; break; case 2: case 3: b0 = 8; break; case 4: case 5: b0 = 4; } return j1 | b0; */ System.out.println("Placed against side: " + side); System.out.println("Side / 2: " + (side/2)); System.out.println("Side % 2: " + (side%2)); return metaD; } } and the console output: -
[Resolved][1.7.2] Custom Log causing crash when rendered
Minothor replied to Minothor's topic in Modder Support
In my case, I'm using getSideIcon when extendind BlockRotatedPillar and getIcon with plain old Block. Neither one is working and it appears to be when I'm calling RegisterIcon() Here's the class as it currently stands, commenting out the fuctions was the only way to stop it auto-crashing the game until I can work out what's up when I try to register the icons. package minothor.bab.blocks; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.util.IIcon; import net.minecraft.block.*; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.world.World; public class blockStrippedOak extends Block{ public blockStrippedOak() { super(Material.wood); setBlockName("BlockStrippedOak"); setHarvestLevel("axe",0); setHardness(0.5F); setStepSound(Block.soundTypeWood); // TODO Auto-generated constructor stub } @SideOnly(Side.CLIENT) protected IIcon[] icons; @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister par1IconRegister) { this.icons = new IIcon[2]; System.out.println("Icon Array Length: "+ icons.length); this.icons[0] = par1IconRegister.registerIcon("bigassbarrels" + ":" + "StrippedLog"); System.out.println("icons 0 :" + icons[0]); this.icons[1] = par1IconRegister.registerIcon("bigassbarrels" + ":" + "StrippedLog"); System.out.println("icons 1 :" + icons[1]); } /*@SideOnly(Side.CLIENT) @Override public IIcon getIcon(int side, int meta) { switch(side) { case 0: return this.icons[0]; case 1: return this.icons[0]; default: return this.icons[1]; } } */ public int onBlockPlaced (World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metaD) { // This metadata code comes from Natura's Darkwood Log, pasted here as a reminder and notepad of sorts. /*int j1 = par9 & 3; byte b0 = 0; switch (par5) { case 0: case 1: b0 = 0; break; case 2: case 3: b0 = 8; break; case 4: case 5: b0 = 4; } return j1 | b0; */ System.out.println("Placed against side: " + side); System.out.println("Side / 2: " + (side/2)); System.out.println("Side % 2: " + (side%2)); return metaD; } } -
[Resolved][1.7.2] Custom Log causing crash when rendered
Minothor replied to Minothor's topic in Modder Support
Hi Silas, Not Yet I'm afraid, assigning text name is working if I have it instead of any GetIcon/GetSideIcon code. At the moment that best I've managed is to isolate it down to a NullPointer exception in the getIcon return so for some reason, the icons array is getting filled with Null Objects. I can't say if this is the same problem for you, we could both be missing something completely obvious. -
Cheers Sequiturian, I'm looking into that now and it looks very promising! I'm hoping that I can register the listener inside the block code though, I really don't want to be calling any shunt() functions from the main class.
-
Hi all, sorry, but hopefully this question is a quickie.. does anyone know how to get the int of the side that was clicked during an onBlockClicked() call? Here's the class I'm working on, apologies for the poor code annotation, it's a block of cork that can be moved with a mallet and if it detects planks above it, will check for a valid barrel structure (up next). Cheers in advance! Nick B (Minothor) package minothor.bab.blocks; import net.minecraft.block.*; import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.world.World; public class blockCork extends Block{ public blockCork(){ super(Material.wood); setBlockName("BlockCork"); setHarvestLevel("axe",0); setHardness(0.5F); setStepSound(Block.soundTypeCloth); }; @Override public void onBlockClicked(World CurrentWorld, int x, int y, int z, EntityPlayer player) { // TODO Auto-generated method stub if(player.inventory.getStackInSlot(player.inventory.currentItem).getUnlocalizedName().equals("item.WoodenMallet")){ System.out.println("Ow! what was that for?"); //Testing Mallet Recognition //Test side 4 shunt(CurrentWorld,x,y,z,4); } } public void checkStructure(int x, int y, int z){ } public void shunt(World CurrentWorld,int x, int y, int z, int side){ boolean flood = false; //(whether or not to fill space with water) int OldX = x, OldY = y, OldZ = z; int ShuntAxis = (int) Math.floor(side/2); // 0 = Y, 1 = Z, 2 = X; int ShuntDir = side % 2; // 0 = Negative Direction, 1 = Positive if (ShuntDir==0){ //Turns the 0 into -1. ShuntDir--; } switch(ShuntAxis){ case 0: y = y-ShuntDir; break; case 1: z = z-ShuntDir; break; case 2: x = x-ShuntDir; break; } if((CurrentWorld.getBlock(x, y, z)==Blocks.air)||(CurrentWorld.getBlock(x, y, z)==Blocks.water)){ if(CurrentWorld.getBlock(x, y, z)==Blocks.water){ flood = true; } CurrentWorld.setBlock(x, y, z, this); CurrentWorld.setBlockToAir(OldX, OldY, OldZ); if(flood){ CurrentWorld.setBlock(OldX, OldY, OldZ, Blocks.water); //Add Splash Sound Here }else{ //Add Sand/Gravel Step Sound Here } if(CurrentWorld.getBlock(x, (y+1), z)==Blocks.planks){ checkStructure(x,y,z); } } } }[/Code]
-
[Resolved][1.7.2] Custom Log causing crash when rendered
Minothor replied to Minothor's topic in Modder Support
Cheers for explaining @Override's functionality in greater depth Sequiturian. I've tried extending blockLog instead of blockRotatedPillar, but I get all kinds of issues with methods not accepting overrides unless they're made final, usually happens with the protected ones. I think I'll have to try and transplant over more code than I first thought. I'll update this thread if I can get it working. Cheers to everyone who has taken the time to reply so far though! -
[1.7.2]Block that only lets water Through
Minothor replied to PeterRDevries's topic in Modder Support
I think your best bet would be to copy/implement the code that handles fluid flowing/spreading, then listen for block updates around your block. If it detects water above or next to it, replace any air blocks beside or below it with flowing water rendered at a height relative to the source (initially triggered) side . When the source side is air again or down to one height level, no longer support the flowing water blocks around it. Hope this makes sense, trying to type this on my Phone before my brother needs a lift to cubs. simplified psuedo code: on (block update) { Check faces{ If air, set as output; If water, set as input; Calc block's "water height" While (input) support flowing water on outputs } } -
[Resolved][1.7.2] Custom Log causing crash when rendered
Minothor replied to Minothor's topic in Modder Support
Cheers Link, the trouble I'm getting there though, is that Eclipse screams at me that BlockRotatedPillar must implement getSideIcon() (I was looking at the wood log source code to try and make this function in an identical manner, just without the metadata subblocks. I did originally have @Override on each method originally, I majorly derped a bit then, I made the assumption that the client side annotation would override as well. -
Hi all, sorry for appearing so often with these questions. I'm trying to make a custom log that will replace an oak log and keep it's orientation (right click an oak tree with an axe, the bark is stripped off and will regrow over time) but so far, although eclipse isn't throwing up any errors with the code, I've clearly buggered up somewhere. The texture icon fails to load and if the block is displayed in a creative tab, search tab or such, the client crashes out immediately. Block Class: Main Class: Console Log: Image: <assets.bigassbarrels.textures.blocks> Cheers again for any help offered, Modding is proving frustrating, but bloody fun too!
-
Sorry, me again, is there any way of listening for right mouse button clicks on vanilla tools (specifically axes) that doesn't involve access modifiers or listening to every single right click then checking the tool in hand? I suppose, what I'm asking really, is this: Is there any way to have a function that only listens for rightclicks when a specific tool type is in hand at that moment? (background fluff: I'm hoping to make it possible to right click oak logs with any axe to strip the bark (cork) off. I don't want to add in another type of axe just for stripping bark) Cheers in advance. -Nick B (Minothor)
-
Items not registering - Likely a Rookie mistake
Minothor replied to Minothor's topic in Modder Support
D'oh! Cheers Sieben and Stijn! It was a rookie error after all! -
Could anyone possibly help me out with what is probably a really rookie error? I started coding my mod in 1.6.4 and had the items loading, tab working etc. I've since decided to scrap working on 1.6.4 since 1.8 is due soon among other things. I've been watching ScratchForFun's 1.7 tuts (e.g. )to get my head around the changes. For some bizarre reason however, the code, while throwing out no errors in the editor or at Runtime, just isn't loading the items. Nothing seems to appear in the creative tab or game, the tab and it's language localisation however, are working fine. I'll admit, I haven't studied Java since uni so I'l rather rusty, but I really can't see what's going wrong and if it's a truly idiotic mistake I will gladly hang my head in shame. (Hey it's how we improve, no?) Many thanks in advance, -NJB (Minothor) Main class: minothor.bab.proxy: (blank templates at the moment) assets.BigAssBarrels.lang: item.StrippedBark.name=Stripped Bark item.BottleCork.name=Bottle Cork itemGroup.tabBAB=Bigass Barrels assets.BigAssBarrels.textures.items: (contents attached to post) BottleCork.png: StrippedBark.png: https://lh6.googleusercontent.com/-Pssc9gpqzg8/UyGlSVY_BmI/AAAAAAAABpU/bRo-u4y34Ao/s800/StrippedBark.png[/img] Console Output (no errors from BAB as far as I can see): p.s. if it's of any help to anyone wanting to look over the project as it stands within my environment, I also have the Saros plugin for eclipse installed.