Everything posted by HappyKiller1O1
-
[1.8][SOLVED]"Silently" catching entity tracking error when creating my entity
The error is line 29 of ItemBlockCoalGun which, I think, the entity is hitting the player and it doesn't know what to do. Check if the entity hit is not the player? I'm not really sure but, I think maybe the entity is being spawned incorrectly.
-
[1.7.10] [UNSOLVED] Ticking memory exception/NullPointerException...
It does if it somehow gets called from EntityClientPlayerMP. What is i, j and k? Try using the player.posXYZ and cast them to Integers.
-
I'm really struggling to make a lightning sword
Omg I actually did that. Yeah, Item not Block.
-
[RESOLVED][1.7.10] Force the unloading of a dimension
Why force unload it? If you're on a server, and the dimension is unloaded when one person leaves and one is still in it; the player still in it would die. ALL dimensions are loaded when the game/server is started and unloaded when the server is stopped. There is really no need to unload the dimension just, send them to the new one.
-
[1.7.10] [UNSOLVED] Ticking memory exception/NullPointerException...
You should try using: FMLNetwokHandler.openGui(); Also, coolAlias has a tutorial on the minecraft forum about how to make a backpack. It's far more complex than you may expect.
-
I'm really struggling to make a lightning sword
He is right ^ All I can say is, check the Block.java class for hitEntity and override it. Then do the necessary checks (like for server and such) and spawn the lightning if they are met.
-
[1.7.10][SOLVED]A few questions...
If you can't interact with it, it means the texture is there but not the server data. Make sure you spawn it on server side ONLY
-
[1.7.10] Why does a stack's NBTTagCompound return null?
I'm sorry for not understanding what you said a few days ago. I was quite tired. Thanks for helping me.
-
[1.7.10] Why does a stack's NBTTagCompound return null?
Oh, you mean create it when the first block is broken? Dear God I am blind.
-
I'm really struggling to make a lightning sword
I actually didn't realize there was a method for that. Excuse my ignorance!
-
[1.7.10][SOLVED]A few questions...
1) That means it only destroyed the block on the client. You need to make sure the server is destroying it as well. 2) You'd need to use the onBlockActivated method and then, spawn the entity by setting it (EntityCreeper creeper = new EntityCreeper(It's params)) and then, spawning it (world.spawnEntityInWorld(creeper)). Hope that helps.
-
I'm really struggling to make a lightning sword
Well first, you most likely should use an event like "LivingHurtEvent" then, check if it is your sword and, if so: grab the entity being hit and it's position then spawn the lightning.
-
[1.7.10] Why does a stack's NBTTagCompound return null?
I'm not sure what you're going at. I might sound ignorant towards Java but I am still learning. You said to create a new thread but I have no clue how to do that. EDIT: Sorry! You said no new thread is required! I read it wrong. I'm not sure what your answer is though.
-
[1.7.10] Play sound on item pickup?
Wouldn't she have to cancel the default sound when picking up an item before calling her own sound?
-
[1.7.10] Alternatives for onCreated?
So, I am trying to set an NBTTagCompound for the stack when the item is created. Problem is, when you shift click the item out of the crafting result slot; it makes the tag null. Is there a better, more reliable/efficient way of setting a NBTTagCompound for a stack?
-
[1.7.10] Item not displaying Durability?
This is so weird; one day my item displayed the durability on the tooltip for it and, the next day it doesn't. I have no clue what could make it not display it but maybe you guy's could find something? Here are my classes: Main Item Class NOTE: I already tried not setting a NBTTagCompound, removing addInformation and, made sure it is registered as an Item: package com.happykiller.crewmod.items.tools; import java.util.List; import net.minecraft.block.Block; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemPickaxe; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.MathHelper; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; import net.minecraftforge.common.ForgeHooks; import com.happykiller.crewmod.CrewMod; import com.happykiller.crewmod.client.gui.GuiId; import com.happykiller.crewmod.lib.LogHelper; import com.happykiller.crewmod.lib.MR; import com.happykiller.crewmod.server.EntityHelper; import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.common.network.internal.FMLNetworkHandler; public class CrewHammer extends ItemPickaxe { public CrewHammer(ToolMaterial tm) { super(tm); this.setCreativeTab(CrewMod.tabCrewTools); this.setUnlocalizedName("CrewHammer"); this.setTextureName(MR.TNAME + "CrewHammer"); this.setFull3D(); this.setMaxStackSize(1); } public void onCreated(ItemStack stack, World world, EntityPlayer player) { System.out.println("CALLED"); //if(!world.isRemote) { LogHelper.logInfo("THE STACK: " + stack); //NBTTagCompound cmp = stack.getTagCompound(); LogHelper.logInfo("TAG: " + stack.getTagCompound()); fixNBT(stack); /*if(cmp == null) { LogHelper.logWarn("No tag was set, creating a new one..."); cmp = new NBTTagCompound(); cmp.setString("MiningSize", "3x3"); stack.setTagCompound(cmp); }*/ //LogHelper.logInfo(cmp.toString()); LogHelper.logInfo("Stack Compound Tag: " + stack.getTagCompound()); LogHelper.logInfo("Stack Tag (HammerTag): " + stack.getTagCompound().getTag("HammerTag")); //} } /*public void onCreated(ItemStack stack, World world, EntityPlayer player) { if(world.isRemote) return; NBTTagCompound cmp = stack.stackTagCompound; if(cmp == null) { System.out.println("NBT TAG SET"); cmp = new NBTTagCompound(); stack.stackTagCompound = cmp; } this.fixNBT(stack); System.out.println(stack.stackTagCompound); cmp.setString("MiningSize", "3x3"); }*/ public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean flag) { list.add(EnumChatFormatting.RED + "Use SHIFT + Right-Click to"); list.add(EnumChatFormatting.RED + "open the modification menu."); list.add(""); list.add(EnumChatFormatting.GREEN + "Hit Left-ALT to open the"); list.add(EnumChatFormatting.GREEN + "quick change menu."); } public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { if(player.isSneaking()) { FMLNetworkHandler.openGui(player, CrewMod.instance, GuiId.guiCrewHammerID, world, (int)player.posX, (int)player.posY, (int)player.posZ); } return stack; } public static void fixNBT(ItemStack stack){ if(stack.stackTagCompound == null) { LogHelper.logWarn("[CrewHammer] " + "The ItemStack NBTTagCompound was null. Attempting fix..."); stack.stackTagCompound = new NBTTagCompound(); } if(!stack.stackTagCompound.hasKey("HammerTag")) { stack.stackTagCompound.setTag("HammerTag", new NBTTagCompound()); LogHelper.logWarn("[CrewHammer] " + "The ItemStack did not contain the key 'HammerTag'. Attempting fix..."); } if(!stack.stackTagCompound.hasKey("MiningSize")) { LogHelper.logWarn("[CrewHammer] " + "The ItemStack did not contain the key 'MiningSize'. Attempting fix..."); stack.stackTagCompound.setString("MiningSize", "3x3"); } } /*public static void fixNBT(ItemStack stack){ NBTTagCompound cmp = stack.stackTagCompound; if(cmp == null) { System.out.println("CMP WAS NULL, FIXING..."); stack.stackTagCompound = new NBTTagCompound(); cmp = stack.stackTagCompound; } if(!cmp.hasKey("MiningSize")){ System.out.println("MiningSize WAS NULL, FIXING..."); cmp.setString("MiningSize", "1x1"); } stack.stackTagCompound = cmp; }*/ /*public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int x, int y, int z, EntityLivingBase entity) { EntityPlayer player = (EntityPlayer)entity; LogHelper.logInfo("CALLED"); LogHelper.logInfo("STACK: " + stack); LogHelper.logInfo("TAG: " + stack.getTagCompound()); if(world != null && player != null) { LogHelper.logInfo("WORLD WAS NOT NULL NOR WAS PLAYER"); MovingObjectPosition mop = player.rayTrace(5.0D, 1.0F); int sideHit = -1; if(!world.isRemote) sideHit = mop.sideHit; if(player.inventory.getCurrentItem() != null) { if(player.inventory.getCurrentItem().getItem().equals(CrewMod.crewHammer)) { int direction = MathHelper.floor_double((double)(player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; //ItemStack hammer = stack; //System.out.println("ITEM IN HAND IS CREW HAMMER"); //Block block = event.block; //World world = event.world; //int x = event.x; //int y = event.y; //int z = event.z; //CrewHammer.fixNBT(hammer); //NBTTagCompound cmp = hammer.stackTagCompound; //if(event.isCanceled()) //return; String miningArea = null; if(stack.hasTagCompound()) { miningArea = stack.getTagCompound().getString("MiningSize"); //System.out.println("CMP WAS NOT NULL"); } LogHelper.logInfo(miningArea); this.breakBlock(world, player, stack, x, y, z, direction, miningArea, sideHit); }else { super.onBlockDestroyed(stack, world, block, x, y, z, entity); } }else { super.onBlockDestroyed(stack, world, block, x, y, z, entity); } } return true; } /** * Used for breaking an area of blocks depending on the miningSize. * * @param world Instance of the Minecraft world. * @param player Player breaking the block. * @param stack Stack in the player's hand. * @param x X coordinate of the block to be broken. * @param y Y coordinate of the block to be broken. * @param z Z coordinate of the block to be broken. * @param playerFacing The direction the player is facing: NORTH, SOUTH, EAST or, WEST. * @param miningArea The area of blocks to be destroyed: 1x1 = 0, 3x3 = 1, 5x5 = 2, 7x7 = 3. */ public void breakBlock(World world, EntityPlayer player, ItemStack stack, int x, int y, int z, int playerFacing, String miningArea, int sideHit) { //TODO Fix RayTrace! System.out.println("BREAK BLOCK RUN"); Block block = world.getBlock(x, y, z); int meta = world.getBlockMetadata(x, y, z); /*MovingObjectPosition mop = player.rayTrace(5.0D, 1.0F); if(mop == null) { LogHelper.logErr("[CrewHammer] " + "Ray Trace has failed!"); return; }*/ //int sideHit = -1; //if(world.isRemote) // sideHit = mop.sideHit; //else // return; LogHelper.logInfo("[CrewHammer] Side Hit: " + sideHit); int refX = x; int refY = y; int refZ = z; if(!isEffective(block, meta, stack)) return; int miningSize = 0; if(miningArea != null) { if(miningArea.equals("3x3")) miningSize = 1; else if(miningArea == "5x5") miningSize = 2; else if(miningArea == "7x7") miningSize = 3; else miningSize = 0; }else { LogHelper.logErr("[CrewHammer] The Mining Area was null!"); } System.out.println(miningArea); System.out.println(miningSize); if(playerFacing == 0 || playerFacing == 2) { //System.out.println("PLAYER FACING 0 or 2"); if(miningSize == 0) { return; }else if(miningSize == 1) { System.out.println("MINING IS 3x3"); this.destroyBlockIfAllowed(world, stack, player, x, y + 1, z, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x - 1, y + 1, z, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x + 1, y + 1, z, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y - 1, z, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x - 1, y - 1, z, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x + 1, y - 1, z, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x - 1, y, z, true, refX, refY, refZ, sideHit, 0, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x + 1, y, z, true, refX, refY, refZ, sideHit, 0, playerFacing); }else if(miningSize == 2) { this.destroyBlockIfAllowed(world, stack, player, x, y + 1, z, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x - 1, y + 1, z, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x + 1, y + 1, z, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x - 2, y + 1, z, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x + 2, y + 1, z, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y - 1, z, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x - 1, y - 1, z, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x + 1, y - 1, z, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x - 2, y - 1, z, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x + 2, y - 1, z, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x - 1, y, z, true, refX, refY, refZ, sideHit, 0, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x + 1, y, z, true, refX, refY, refZ, sideHit, 0, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x - 2, y, z, true, refX, refY, refZ, sideHit, 0, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x + 2, y, z, true, refX, refY, refZ, sideHit, 0, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x - 1, y + 2, z, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x + 1, y + 2, z, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x - 2, y + 2, z, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x + 2, y + 2, z, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y + 2, z, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x - 1, y - 2, z, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x + 1, y - 2, z, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x - 2, y - 2, z, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x + 2, y - 2, z, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y - 2, z, true, refX, refY, refZ, sideHit, 2, playerFacing); }else { this.destroyBlockIfAllowed(world, stack, player, x, y + 1, z, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x - 1, y + 1, z, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x + 1, y + 1, z, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x - 2, y + 1, z, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x + 2, y + 1, z, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x - 3, y + 1, z, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x + 3, y + 1, z, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y - 1, z, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x - 1, y - 1, z, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x + 1, y - 1, z, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x - 2, y - 1, z, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x + 2, y - 1, z, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x - 3, y - 1, z, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x + 3, y - 1, z, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x - 1, y, z, true, refX, refY, refZ, sideHit, 0, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x + 1, y, z, true, refX, refY, refZ, sideHit, 0, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x - 2, y, z, true, refX, refY, refZ, sideHit, 0, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x + 2, y, z, true, refX, refY, refZ, sideHit, 0, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x - 3, y, z, true, refX, refY, refZ, sideHit, 0, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x + 3, y, z, true, refX, refY, refZ, sideHit, 0, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x - 1, y + 2, z, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x + 1, y + 2, z, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x - 2, y + 2, z, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x + 2, y + 2, z, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x - 3, y + 2, z, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x + 3, y + 2, z, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y + 2, z, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x - 1, y - 2, z, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x + 1, y - 2, z, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x - 2, y - 2, z, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x + 2, y - 2, z, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x - 3, y - 2, z, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x + 3, y - 2, z, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y - 2, z, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x - 1, y + 3, z, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x + 1, y + 3, z, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x - 2, y + 3, z, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x + 2, y + 3, z, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x - 3, y + 3, z, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x + 3, y + 3, z, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y + 3, z, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x - 1, y - 3, z, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x + 1, y - 3, z, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x - 2, y - 3, z, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x + 2, y - 3, z, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x - 3, y - 3, z, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x + 3, y - 3, z, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y - 3, z, true, refX, refY, refZ, sideHit, 2, playerFacing); } }else { //System.out.println("PLAYER FACING 1 or 3"); if(miningSize == 0) { return; }else if(miningSize == 1) { this.destroyBlockIfAllowed(world, stack, player, x, y + 1, z, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y + 1, z - 1, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y + 1, z + 1, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y - 1, z, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y - 1, z - 1, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y - 1, z + 1, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y, z - 1, true, refX, refY, refZ, sideHit, 0, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y, z + 1, true, refX, refY, refZ, sideHit, 0, playerFacing); }else if(miningSize == 2) { this.destroyBlockIfAllowed(world, stack, player, x, y + 1, z, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y + 1, z - 1, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y + 1, z + 1, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y + 1, z - 2, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y + 1, z + 2, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y - 1, z, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y - 1, z - 1, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y - 1, z + 1, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y - 1, z - 2, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y - 1, z + 2, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y, z - 1, true, refX, refY, refZ, sideHit, 0, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y, z + 1, true, refX, refY, refZ, sideHit, 0, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y, z - 2, true, refX, refY, refZ, sideHit, 0, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y, z + 2, true, refX, refY, refZ, sideHit, 0, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y + 2, z - 1, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y + 2, z + 1, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y + 2, z - 2, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y + 2, z + 2, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y + 2, z, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y - 2, z - 1, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y - 2, z + 1, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y - 2, z - 2, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y - 2, z + 2, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y - 2, z, true, refX, refY, refZ, sideHit, 2, playerFacing); }else { this.destroyBlockIfAllowed(world, stack, player, x, y + 1, z, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y + 1, z - 1, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y + 1, z + 1, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y + 1, z - 2, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y + 1, z + 2, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y + 1, z - 3, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y + 1, z + 3, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y - 1, z, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y - 1, z - 1, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y - 1, z + 1, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y - 1, z - 2, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y - 1, z + 2, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y - 1, z - 3, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y - 1, z + 3, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y, z - 1, true, refX, refY, refZ, sideHit, 0, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y, z + 1, true, refX, refY, refZ, sideHit, 0, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y, z - 2, true, refX, refY, refZ, sideHit, 0, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y, z + 2, true, refX, refY, refZ, sideHit, 0, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y, z - 3, true, refX, refY, refZ, sideHit, 0, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y, z + 3, true, refX, refY, refZ, sideHit, 0, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y + 2, z - 1, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y + 2, z + 1, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y + 2, z - 2, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y + 2, z + 2, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y + 2, z - 3, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y + 2, z + 3, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y + 2, z, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y - 2, z - 1, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y - 2, z + 1, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y - 2, z - 2, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y - 2, z + 2, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y - 2, z - 3, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y - 2, z + 3, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y - 2, z, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y + 3, z - 1, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y + 3, z + 1, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y + 3, z - 2, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y + 3, z + 2, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y + 3, z - 3, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y + 3, z + 3, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y + 3, z, true, refX, refY, refZ, sideHit, 1, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y - 3, z - 1, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y - 3, z + 1, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y - 3, z - 2, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y - 3, z + 2, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y - 3, z - 3, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y - 3, z + 3, true, refX, refY, refZ, sideHit, 2, playerFacing); this.destroyBlockIfAllowed(world, stack, player, x, y - 3, z, true, refX, refY, refZ, sideHit, 2, playerFacing); } } } /** * Destroys a block at the given coords if allowed. * * @param world The instance of the World. * @param player The player destroying said block. * @param x X Coordinate of the block to be destroyed. * @param y Y Coordinate of the block to be destroyed. * @param z Z Coordinate of the block to be destroyed. * @param addDrops If true, adds drops to the block broken. * @param refX Reference point X of the center block if destroying multiple ones. * @param refY Reference point Y of the center block if destroying multiple ones. * @param refZ Reference point Z of the center block if destroying multiple ones. * @param Ymodifer Used to determine if the Y variable is added to or, subtracted from. 0 = Nothing, 1 = Added to, 2 = Subtracted from. * @param playerDirection The direction the player is facing: NORTH, SOUTH, EAST or, WEST. */ public void destroyBlockIfAllowed(World world, ItemStack stack, EntityPlayer player, int x, int y, int z, boolean addDrops, int refX, int refY, int refZ, int sideHit, int Ymodifer, int playerDirection) { int actualX = x; int actualY = y; int actualZ = z; if(sideHit == 0 || sideHit == 1) { //System.out.println("Z updated"); actualY = refY; int amountToAdd = refY > y ? refY - y : y - refY; if(playerDirection == 0 || playerDirection == 2) { if(Ymodifer == 0) actualZ += 0; else if(Ymodifer == 1) actualZ += amountToAdd; else actualZ -= amountToAdd; }else { if(Ymodifer == 0) actualX += 0; else if(Ymodifer == 1) actualX += amountToAdd; else actualX -= amountToAdd; } /*System.out.println("Z: " + actualZ); System.out.println(additionZ); System.out.println("Y: " + y); System.out.println("refY: " + refY);*/ } if(world.isAirBlock(actualX, actualY, actualZ)) return; Block block = world.getBlock(actualX, actualY, actualZ); int meta = world.getBlockMetadata(actualX, actualY, actualZ); if(!isEffective(block, meta, stack)) return; Block refBlock = world.getBlock(refX, refY, refZ); // float refStrength = ForgeHooks.blockStrength(refBlock, player, world, refX, refY, refZ); // float strength = ForgeHooks.blockStrength(block, player, world, actualX, actualY , actualZ); float refStrength = refBlock.getBlockHardness(world, refX, refY, refZ); float strength = block.getBlockHardness(world, actualX, actualY, actualZ); //System.out.println("REFSTRENGTH: " + refStrength); //System.out.println("STRENGTH: " + strength); float strDifference = strength/refStrength; System.out.println(strDifference); if(!ForgeHooks.canHarvestBlock(block, player, meta) || strength <= -1 || strDifference > 10) return; if(block.getExpDrop(world, meta, EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, stack)) > 0) block.dropXpOnBlockBreak(world, actualX, actualY, actualZ, block.getExpDrop(world, meta, 0)); world.func_147480_a(actualX, actualY, actualZ, addDrops); int damage = stack.getItemDamage() + 1; if(!player.capabilities.isCreativeMode) stack.setItemDamage(damage); } public boolean isEffective(Block block, int meta, ItemStack stack) { if(ForgeHooks.canToolHarvestBlock(block, meta, stack)) return true; return false; } /*//Makes it so the item stays in the crafting grid public boolean doesContainerItemLeaveCraftingGrid(ItemStack stack) { return false; } //Tells the game your item has a container item public boolean hasContainerItem() { return true; } //Sets teh container item public ItemStack getContainerItem(ItemStack itemStack) { itemStack.attemptDamageItem(1, itemRand); return itemStack; }*/ } Main Class where I register it: package com.happykiller.crewmod; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.Item.ToolMaterial; import net.minecraft.item.ItemFood; import net.minecraft.item.ItemPickaxe; import net.minecraft.item.ItemSeeds; import net.minecraft.item.ItemStack; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.EnumHelper; import com.happykiller.crewmod.blocks.LavaBlock; import com.happykiller.crewmod.blocks.ShopBlock; import com.happykiller.crewmod.blocks.WubWubBlock; import com.happykiller.crewmod.blocks.crops.BlockCorn; import com.happykiller.crewmod.blocks.crops.CornCropStart; import com.happykiller.crewmod.events.EventsFML; import com.happykiller.crewmod.events.EventsForge; import com.happykiller.crewmod.food.IceCream; import com.happykiller.crewmod.items.CrewCoin; import com.happykiller.crewmod.items.CrewGem; import com.happykiller.crewmod.items.ItemLavaBlock; import com.happykiller.crewmod.items.ShopItem; import com.happykiller.crewmod.items.VillagerHeart; import com.happykiller.crewmod.items.tools.CrewHammer; import com.happykiller.crewmod.items.tools.LightningRod; import com.happykiller.crewmod.items.tools.TrapPickaxe; import com.happykiller.crewmod.lib.LogHelper; import com.happykiller.crewmod.lib.MR; import com.happykiller.crewmod.packets.PacketRegistry; import com.happykiller.crewmod.proxy.CommonProxy; import com.happykiller.crewmod.register.RegisterCrafting; import com.happykiller.crewmod.register.RegisterSmelting; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.registry.GameRegistry; @Mod(modid = MR.MODID, name = MR.NAME, version = MR.VERSION) public class CrewMod { @Instance(MR.MODID) public static CrewMod instance; @SidedProxy(clientSide = "com.happykiller.crewmod.proxy.ClientProxy", serverSide = "com.happykiller.crewmod.proxy.CommonProxy") public static CommonProxy proxy; public static Item crewGem; public static Item iceCream; public static Item crewCoin; public static Item shopItem; public static Item villagerHeart; public static Block wubWubBlock; public static Block shopBlock; public static Block emeraldLavaBlock; public static Block diamondLavaBlock; public static Block goldLavaBlock; public static Block ironLavaBlock; public static CornCropStart cornCropStart; public static BlockCorn cornBlock; public static Item seedsCorn; public static Item cobCorn; public static Item cookedCorn; public static Item trapPickaxe; public static Item lightningRod; /* Crew Tools */ public static Item crewHammer; /* Tool Materials */ public static final ToolMaterial trapBreaker = EnumHelper.addToolMaterial("trapBreaker", 2, 20, 6.0F, 2.0F, 0); public static final ToolMaterial crewTools = EnumHelper.addToolMaterial("crewTools", 4, 3500, 12.0F, 6.0F, ; @EventHandler public void preInit(FMLPreInitializationEvent event) { //FINISH SHOP GUI'S PacketRegistry.registerNetwork(); PacketRegistry.registerAllPackets(); /* Items */ crewGem = new CrewGem(); crewCoin = new CrewCoin(); shopItem = new ShopItem(); villagerHeart = new VillagerHeart(); iceCream = new IceCream(8, 0.6F, false); cobCorn = new ItemFood(2, 0.2F, false).setUnlocalizedName("CornCob").setTextureName(MR.TNAME + "cobCorn").setCreativeTab(tabCrewFood); cookedCorn = new ItemFood(6, 0.4F, false).setUnlocalizedName("CookedCorn").setTextureName(MR.TNAME + "cookedCorn").setCreativeTab(tabCrewFood); /* Item Registry */ GameRegistry.registerItem(crewGem, "CrewGem"); GameRegistry.registerItem(iceCream, "IceCream"); GameRegistry.registerItem(crewCoin, "CrewCoin"); GameRegistry.registerItem(shopItem, "ShopItem"); GameRegistry.registerItem(villagerHeart, "VillagerHeart"); GameRegistry.registerItem(cobCorn, "CornCob"); GameRegistry.registerItem(cookedCorn, "CookedCorn"); /* Blocks */ wubWubBlock = new WubWubBlock(Material.rock); shopBlock = new ShopBlock(Material.rock); emeraldLavaBlock = new LavaBlock(Material.rock).setBlockName("EmeraldLB").setBlockTextureName("emerald_ore"); diamondLavaBlock = new LavaBlock(Material.rock).setBlockName("DiamondLB").setBlockTextureName("diamond_ore"); goldLavaBlock = new LavaBlock(Material.rock).setBlockName("GoldLB").setBlockTextureName("gold_ore"); ironLavaBlock = new LavaBlock(Material.rock).setBlockName("IronLB").setBlockTextureName("iron_ore"); /* Block Registry */ GameRegistry.registerBlock(wubWubBlock, "WubWubBlock"); GameRegistry.registerBlock(shopBlock, "ShopBlock"); GameRegistry.registerBlock(emeraldLavaBlock, ItemLavaBlock.class, "EmeraldLB"); GameRegistry.registerBlock(diamondLavaBlock, ItemLavaBlock.class, "DiamondLB"); GameRegistry.registerBlock(goldLavaBlock, ItemLavaBlock.class, "GoldLB"); GameRegistry.registerBlock(ironLavaBlock, ItemLavaBlock.class, "IronLB"); /* Crop Blocks */ cornCropStart = new CornCropStart(); cornBlock = new BlockCorn(); /* Crop Block Registry */ GameRegistry.registerBlock(cornCropStart, "CornCrop"); GameRegistry.registerBlock(cornBlock, "CornBlock"); /* Crop Items */ seedsCorn = new ItemSeeds(cornCropStart, Blocks.farmland).setUnlocalizedName("CornSeeds").setTextureName(MR.TNAME + "CornSeeds").setCreativeTab(tabCrewFood); /* Crop Item Registry */ GameRegistry.registerItem(seedsCorn, "CornSeeds"); /* Tools */ trapPickaxe = new TrapPickaxe(trapBreaker); lightningRod = new LightningRod(); crewHammer = new CrewHammer(crewTools); /* Tool Registry */ GameRegistry.registerItem(trapPickaxe, "TrapPickaxe"); GameRegistry.registerItem(lightningRod, "LightningRod"); GameRegistry.registerItem(crewHammer, "CrewHammer"); /* Tile Entity Registry */ //GameRegistry.registerTileEntity(TileEntityShopBlock.class, "tileEntityShopBlock"); LogHelper.logInfo("Pre-Init succesfully loaded!"); } @EventHandler public void init(FMLInitializationEvent event) { RegisterCrafting.addAllRecipes(); RegisterSmelting.addAllSmelting(); MinecraftForge.EVENT_BUS.register(new EventsForge()); FMLCommonHandler.instance().bus().register(new EventsFML()); proxy.initialize(); LogHelper.logInfo("Init succesfully loaded!"); } @EventHandler public void postInit(FMLPostInitializationEvent event) { LogHelper.logInfo("Post-Init succesfully loaded!"); } /* Creative Tabs */ public static CreativeTabs tabCrewBlocks = new CreativeTabs("tabCrewBlocks") { @Override public Item getTabIconItem() { return new ItemStack(wubWubBlock).getItem(); }; }; public static CreativeTabs tabCrewMaterials = new CreativeTabs("tabCrewMaterials") { @Override public Item getTabIconItem() { return new ItemStack(crewGem).getItem(); }; }; public static CreativeTabs tabCrewFood = new CreativeTabs("tabCrewFood") { @Override public Item getTabIconItem() { return new ItemStack(iceCream).getItem(); }; }; public static CreativeTabs tabCrewTools = new CreativeTabs("tabCrewTools") { @Override public Item getTabIconItem() { return new ItemStack(trapPickaxe).getItem(); }; }; }
-
[1.7.10] Add to variable on item pickup, then delete the item?
Now see, in theory: that would work. But, when I was debugging it with Erino, the stackSize was ALWAYS 0 when it was picked up.
-
[1.6.4/1.7.10] help with modding a boss
It doesn't move because you need to set the target. EntityAIWander would let it move freely.
-
mcmod.info problem
Is the mcmod.info in your assets folder of your mod? If not, try it there when compiled. I'm honestly not sure what could be happening and I do remember hearing about problems concerning it.
-
[1.7.10] Add to variable on item pickup, then delete the item?
I've actually tried this and, you can't get the stack size. For some reason, the entityItem doesn't save the stack size so, you just have to set the maxStackSize of the coin to 1 and have it pickup like .5% slower.
-
[1.7.10] Duplicate paths in Eclipse
Yes, after updating the workspace and I deleted the class that happened. After creating a new workspace and adding my .java's back to it; it seemed to fix it.
-
[1.7.10] Why does a stack's NBTTagCompound return null?
Well, because I need to set the TAG when the item is created and, there is no other method to do that.
-
[1.7.10] RayTracing from server
Yes but, how? When I called EntityPlayer#rayTrace under the onBlockDestroyed method, first it said the correct side hit which came from the client (5) but then, the server gave the incorrect one (1). It seems like the server only looks at the player feet?
-
[1.7.10] Why does a stack's NBTTagCompound return null?
Because I call that method in the onCreated so I can run it?
-
[1.7.10] RayTracing from server
So basically, I am using the onBlockDestroyed method in my Item class to perform extra block breaks and such. With that, I need to obtain the side of the block that was hit in order to accomplish what I want to achieve. With this, I do believe I can't be using the CLIENT only method EntityPlayer#rayTrace(double, float). So, that's why I am asking if there is a way to do this through the server rather than the client? I do believe I'd need to maybe get the side from the client then tell the server but, I am not sure.
IPS spam blocked by CleanTalk.