Posted March 17, 201411 yr 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] https://lh6.googleusercontent.com/-z5frUimWWu0/U4Wuz9xle4I/AAAAAAAABsE/q3eMXJIDXIM/s800/EmeraldCasinoSig.png[/img]
March 18, 201411 yr You could handle this event: ForgeEventFactory.onPlayerInteract(thisPlayerMP, Action.LEFT_CLICK_BLOCK, par1, par2, par3, par4); It happens in the code that calls onBlockClicked. The parameters might tell you something. -S- (if I helped, please click Thank and applaud) http://6upnqa.dm2301.livefilestore.com/y2mtf-vG7Tqq1TiiVpIm53KWj7294NDPoHfSHHb4PzZiMAUfRCfK0UY0MwOu7Q3zTBNVTKqWjr2-xgBfFRpQT5p-QivtvknPpoABMNUw9br9WuZcBFkjePhnAbW500gVm-P/sequiturian.png[/img]
March 18, 201411 yr Author 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. https://lh6.googleusercontent.com/-z5frUimWWu0/U4Wuz9xle4I/AAAAAAAABsE/q3eMXJIDXIM/s800/EmeraldCasinoSig.png[/img]
April 26, 201411 yr Hi, I know maybe it's too late to reply to your question but I've got the solution. For the glitchy shadow you have to add this line in your constructor of your slab class: useNeighborBrightness = true; And to prevent the 0.5 blocks upper positioning you have to follow what says "MCZaphelon" in this post: http://www.minecraftforum.net/topic/2432754-172forge-modding-slab-problem/ I hope this could help you and anyone else who have the same problem.
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.