Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

DarkProd02

Members
  • Joined

  • Last visited

Everything posted by DarkProd02

  1. there is a button or when we click on can start either the server or the client
  2. Hi guys, When i put @Override above a method the retrun an error . My code : package fr.darkprod.archymod.blocks; import javax.annotation.Nullable; import fr.darkprod.archymod.ArchyMod; import fr.darkprod.archymod.tiles.TileInventoryFurnace; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyInteger; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.InventoryHelper; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.EnumBlockRenderType; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class BlockInventoryFurnace extends BlockContainer { public BlockInventoryFurnace(String name,float resistance, float hardness) { super(Material.ROCK); this.setCreativeTab(ArchyMod.ArchyMod); setRegistryName(name); setUnlocalizedName(name); setResistance(resistance); setHardness(hardness); } // Called when the block is placed or loaded client side to get the tile entity for the block // Should return a new instance of the tile entity for the block @Override public TileEntity createNewTileEntity(World worldIn, int meta) { return new TileInventoryFurnace(); } @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { // Uses the gui handler registered to your mod to open the gui for the given gui id // open on the server side only (not sure why you shouldn't open client side too... vanilla doesn't, so we better not either) if (worldIn.isRemote) return true; playerIn.openGui(ArchyMod.instance, ArchyMod.GUI_FURNACE, worldIn, pos.getX(), pos.getY(), pos.getZ()); return true; } // This is where you can do something when the block is broken. In this case drop the inventory's contents @Override public void breakBlock(World worldIn, BlockPos pos, IBlockState state) { TileEntity tileEntity = worldIn.getTileEntity(pos); if (tileEntity instanceof IInventory) { InventoryHelper.dropInventoryItems(worldIn, pos, (IInventory)tileEntity); } // if (inventory != null){ // // For each slot in the inventory // for (int i = 0; i < inventory.getSizeInventory(); i++){ // // If the slot is not empty // if (inventory.getStackInSlot(i) != null) // { // // Create a new entity item with the item stack in the slot // EntityItem item = new EntityItem(worldIn, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, inventory.getStackInSlot(i)); // // // Apply some random motion to the item // float multiplier = 0.1f; // float motionX = worldIn.rand.nextFloat() - 0.5f; // float motionY = worldIn.rand.nextFloat() - 0.5f; // float motionZ = worldIn.rand.nextFloat() - 0.5f; // // item.motionX = motionX * multiplier; // item.motionY = motionY * multiplier; // item.motionZ = motionZ * multiplier; // // // Spawn the item in the world // worldIn.spawnEntityInWorld(item); // } // } // // // Clear the inventory so nothing else (such as another mod) can do anything with the items // inventory.clear(); // } // Super MUST be called last because it removes the tile entity super.breakBlock(worldIn, pos, state); } @Override public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { TileEntity tileEntity = worldIn.getTileEntity(pos); if (tileEntity instanceof TileInventoryFurnace) { TileInventoryFurnace tileInventoryFurnace = (TileInventoryFurnace)tileEntity; int burningSlots = tileInventoryFurnace.numberOfBurningFuelSlots(); burningSlots = MathHelper.clamp(burningSlots, 0, 4); return getDefaultState().withProperty(BURNING_SIDES_COUNT, burningSlots); } return state; } @Override public IBlockState getStateFromMeta(int meta) { return this.getDefaultState(); // return this.getDefaultState().withProperty(BURNING_SIDES_COUNT, Integer.valueOf(meta)); } @Override public int getMetaFromState(IBlockState state) { return 0; // return ((Integer)state.getValue(BURNING_SIDES_COUNT)).intValue(); } // necessary to define which properties your blocks use // will also affect the variants listed in the blockstates model file. See MBE03 for more info. @Override protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, new IProperty[] {BURNING_SIDES_COUNT}); } public static final PropertyInteger BURNING_SIDES_COUNT = PropertyInteger.create("burning_sides_count", 0, 4); // change the furnace emitted light ("block light") depending on how many slots are burning private static final int FOUR_SIDE_LIGHT_VALUE = 15; // light value for four sides burning private static final int ONE_SIDE_LIGHT_VALUE = 8; // light value for a single side burning @Override public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos) { int lightValue = 0; IBlockState blockState = getActualState(getDefaultState(), world, pos); int burningSides = (Integer)blockState.getValue(BURNING_SIDES_COUNT); if (burningSides == 0) { lightValue = 0; } else { // linearly interpolate the light value depending on how many slots are burning lightValue = ONE_SIDE_LIGHT_VALUE + (int)((FOUR_SIDE_LIGHT_VALUE - ONE_SIDE_LIGHT_VALUE) / (4.0 - 1.0) * burningSides); } lightValue = MathHelper.clamp(lightValue, 0, FOUR_SIDE_LIGHT_VALUE); return lightValue; } // the block will render in the SOLID layer. See http://greyminecraftcoder.blogspot.co.at/2014/12/block-rendering-18.html for more information. @SideOnly(Side.CLIENT) public BlockRenderLayer getBlockLayer() { return BlockRenderLayer.SOLID; } // used by the renderer to control lighting and visibility of other blocks. // set to false because this block doesn't fill the entire 1x1x1 space @Override public boolean isOpaqueCube(IBlockState iBlockState) { return false; } // used by the renderer to control lighting and visibility of other blocks, also by // (eg) wall or fence to control whether the fence joins itself to this block // set to false because this block doesn't fill the entire 1x1x1 space @Override public boolean isFullCube(IBlockState iBlockState) { return false; } // render using a BakedModel // required because the default (super method) is INVISIBLE for BlockContainers. @Override public EnumBlockRenderType getRenderType(IBlockState iBlockState) { return EnumBlockRenderType.MODEL; } } and the screenshot :
  3. I run the server in development evironment and blocks are not loaded and in a local server outside the development environment and it does not work
  4. yes i have installed it on server but the mod doesn't work . I will try to update my mod to 1.12.2 and i will see if it work or not
  5. All these conditions do not influence my mod because on client side it works but on server side does not work
  6. Yes of course and what correspond to "issue"?
  7. here it is : https://github.com/darkprod02/archymod
  8. Okeyy i fix the problem but i have another problem when i am in game on ,client part all things works but when i launch the server with my mod ALL BLOCKS are not registers and JEI write : "Tooltip error ,see log" but there is no log with error . How can i correct this?
  9. Hi guys, I have a big problem with my mod : When i try to register an ore in ore dict, the mod give me an error : [14:02:00] [Server thread/WARN] [FML]: **************************************** [14:02:00] [Server thread/WARN] [FML]: * Invalid registration attempt for an Ore Dictionary item with name oreArpaz has occurred. The registration has been denied to prevent crashes. The mod responsible for the registration needs to correct this. [14:02:00] [Server thread/WARN] [FML]: * at net.minecraftforge.oredict.OreDictionary.registerOreImpl(OreDictionary.java:595) [14:02:00] [Server thread/WARN] [FML]: * at net.minecraftforge.oredict.OreDictionary.registerOre(OreDictionary.java:581) [14:02:00] [Server thread/WARN] [FML]: * at fr.darkprod.archymod.ArchyMod.init(ArchyMod.java:64) [14:02:00] [Server thread/WARN] [FML]: * at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [14:02:00] [Server thread/WARN] [FML]: * at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) [14:02:00] [Server thread/WARN] [FML]: * at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)... [14:02:00] [Server thread/WARN] [FML]: **************************************** And when i try to register a smelting recipe ,the mod give me an error too : [14:07:35] [Server thread/ERROR] [FML]: Fatal errors were detected during the transition from INITIALIZATION to POSTINITIALIZATION. Loading cannot continue [14:07:35] [Server thread/ERROR] [FML]: States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored UCHI mcp{9.19} [Minecraft Coder Pack] (minecraft.jar) UCHI FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.10.2-12.18.3.2185.jar) UCHI Forge{12.18.3.2185} [Minecraft Forge] (forgeSrc-1.10.2-12.18.3.2185.jar) UCHE archydium{4.0} [Archymod] (bin) [14:07:35] [Server thread/ERROR] [FML]: The following problems were captured during this phase [14:07:35] [Server thread/ERROR] [FML]: Caught exception from Archymod (archydium) java.lang.NullPointerException at net.minecraft.item.ItemStack.getMetadata(ItemStack.java:287) ~[forgeSrc-1.10.2-12.18.3.2185.jar:?] at net.minecraft.item.crafting.FurnaceRecipes.compareItemStacks(FurnaceRecipes.java:118) ~[forgeSrc-1.10.2-12.18.3.2185.jar:?] at net.minecraft.item.crafting.FurnaceRecipes.getSmeltingResult(FurnaceRecipes.java:104) ~[forgeSrc-1.10.2-12.18.3.2185.jar:?] at net.minecraft.item.crafting.FurnaceRecipes.addSmeltingRecipe(FurnaceRecipes.java:91) ~[forgeSrc-1.10.2-12.18.3.2185.jar:?] at net.minecraft.item.crafting.FurnaceRecipes.addSmelting(FurnaceRecipes.java:83) ~[forgeSrc-1.10.2-12.18.3.2185.jar:?] at net.minecraft.item.crafting.FurnaceRecipes.addSmeltingRecipeForBlock(FurnaceRecipes.java:75) ~[forgeSrc-1.10.2-12.18.3.2185.jar:?] at net.minecraftforge.fml.common.registry.GameRegistry.addSmelting(GameRegistry.java:245) ~[forgeSrc-1.10.2-12.18.3.2185.jar:?] at fr.darkprod.archymod.init.ModRecipes.initAll(ModRecipes.java:48) ~[bin/:?] at fr.darkprod.archymod.ArchyMod.init(ArchyMod.java:62) ~[bin/:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_151] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_151] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_151] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_151] at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:602) ~[forgeSrc-1.10.2-12.18.3.2185.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_151] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_151] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_151] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_151] at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?] at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?] at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:243) ~[forgeSrc-1.10.2-12.18.3.2185.jar:?] at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:221) ~[forgeSrc-1.10.2-12.18.3.2185.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_151] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_151] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_151] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_151] at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?] at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?] at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:145) [LoadController.class:?] at net.minecraftforge.fml.common.Loader.initializeMods(Loader.java:795) [Loader.class:?] at net.minecraftforge.fml.server.FMLServerHandler.finishServerLoading(FMLServerHandler.java:107) [FMLServerHandler.class:?] at net.minecraftforge.fml.common.FMLCommonHandler.onServerStarted(FMLCommonHandler.java:333) [FMLCommonHandler.class:?] at net.minecraft.server.dedicated.DedicatedServer.startServer(DedicatedServer.java:217) [DedicatedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:497) [MinecraftServer.class:?] at java.lang.Thread.run(Unknown Source) [?:1.8.0_151] [14:07:36] [Server thread/ERROR]: Encountered an unexpected exception net.minecraftforge.fml.common.LoaderExceptionModCrash: Caught exception from Archymod (archydium) Caused by: java.lang.NullPointerException at net.minecraft.item.ItemStack.getMetadata(ItemStack.java:287) ~[forgeSrc-1.10.2-12.18.3.2185.jar:?] at net.minecraft.item.crafting.FurnaceRecipes.compareItemStacks(FurnaceRecipes.java:118) ~[forgeSrc-1.10.2-12.18.3.2185.jar:?] at net.minecraft.item.crafting.FurnaceRecipes.getSmeltingResult(FurnaceRecipes.java:104) ~[forgeSrc-1.10.2-12.18.3.2185.jar:?] at net.minecraft.item.crafting.FurnaceRecipes.addSmeltingRecipe(FurnaceRecipes.java:91) ~[forgeSrc-1.10.2-12.18.3.2185.jar:?] at net.minecraft.item.crafting.FurnaceRecipes.addSmelting(FurnaceRecipes.java:83) ~[forgeSrc-1.10.2-12.18.3.2185.jar:?] at net.minecraft.item.crafting.FurnaceRecipes.addSmeltingRecipeForBlock(FurnaceRecipes.java:75) ~[forgeSrc-1.10.2-12.18.3.2185.jar:?] at net.minecraftforge.fml.common.registry.GameRegistry.addSmelting(GameRegistry.java:245) ~[forgeSrc-1.10.2-12.18.3.2185.jar:?] at fr.darkprod.archymod.init.ModRecipes.initAll(ModRecipes.java:48) ~[bin/:?] at fr.darkprod.archymod.ArchyMod.init(ArchyMod.java:62) ~[bin/:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_151] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_151] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_151] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_151] at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:602) ~[forgeSrc-1.10.2-12.18.3.2185.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_151] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_151] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_151] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_151] at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?] at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?] at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:243) ~[LoadController.class:?] at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:221) ~[LoadController.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_151] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_151] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_151] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_151] at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?] at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?] at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:145) ~[LoadController.class:?] at net.minecraftforge.fml.common.Loader.initializeMods(Loader.java:795) ~[Loader.class:?] at net.minecraftforge.fml.server.FMLServerHandler.finishServerLoading(FMLServerHandler.java:107) ~[FMLServerHandler.class:?] at net.minecraftforge.fml.common.FMLCommonHandler.onServerStarted(FMLCommonHandler.java:333) ~[FMLCommonHandler.class:?] at net.minecraft.server.dedicated.DedicatedServer.startServer(DedicatedServer.java:217) ~[DedicatedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:497) [MinecraftServer.class:?] at java.lang.Thread.run(Unknown Source) [?:1.8.0_151] My code is here and here : EDIT : Is for server part Someone can help me?
  10. finally i did it F**K YEAHHH Thx all for answers
  11. ok thx a lot my code is good now? package fr.darkprod.archymod.items; import java.util.Iterator; import java.util.List; import fr.darkprod.archymod.ArchyMod; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.Item; import net.minecraft.item.Item.ToolMaterial; import net.minecraft.item.ItemPickaxe; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.FurnaceRecipes; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraft.world.WorldEntitySpawner; import net.minecraftforge.common.ForgeHooks; public class ItemHammer extends ItemPickaxe { public long time = System.currentTimeMillis(); protected static final Material[] MATERIALS = { Material.ROCK, Material.IRON, Material.ICE, Material.GLASS, Material.PISTON, Material.ANVIL, Material.SNOW, Material.CRAFTED_SNOW, Material.CLAY }; public ItemHammer(String name,Item.ToolMaterial material) { super(material); setCreativeTab(ArchyMod.ArchyMod); setRegistryName(name); setUnlocalizedName(name); } public int getItemEnchantability() { return 0; } public int getItemEnchantability(ItemStack stack) { return 0; } public boolean isBookEnchantable(ItemStack stack, ItemStack book) { return false; } public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) { return false; } public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) { if ((!worldIn.isRemote) && ((entityIn instanceof EntityPlayer))) { EntityPlayer entityPlayer = (EntityPlayer)entityIn; if (entityPlayer.getItemStackFromSlot(EntityEquipmentSlot.MAINHAND) == null) { return; } } } public boolean onBlockDestroyed(ItemStack stack, World worldIn, IBlockState state, BlockPos pos, EntityLivingBase entityLiving) { if ((!worldIn.isRemote) && ((entityLiving instanceof EntityPlayer))) { EntityPlayer player = (EntityPlayer)entityLiving; RayTraceResult raytraceresult = rayTrace(player.getEntityWorld(), player, true); BlockPos[] blockPoses; if (raytraceresult != null) { BlockPos[] blockPosesNS = { new BlockPos(pos.getX() + 1, pos.getY(), pos.getZ()), new BlockPos(pos.getX() + 1, pos.getY() + 1, pos.getZ()), new BlockPos(pos.getX() + 1, pos.getY() - 1, pos.getZ()), new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ()), new BlockPos(pos.getX(), pos.getY(), pos.getZ()), new BlockPos(pos.getX(), pos.getY() - 1, pos.getZ()), new BlockPos(pos.getX() - 1, pos.getY(), pos.getZ()), new BlockPos(pos.getX() - 1, pos.getY() + 1, pos.getZ()), new BlockPos(pos.getX() - 1, pos.getY() - 1, pos.getZ()) }; BlockPos[] blockPosesEW = { new BlockPos(pos.getX(), pos.getY(), pos.getZ() + 1), new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ() + 1), new BlockPos(pos.getX(), pos.getY() - 1, pos.getZ() + 1), new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ()), new BlockPos(pos.getX(), pos.getY(), pos.getZ()), new BlockPos(pos.getX(), pos.getY() - 1, pos.getZ()), new BlockPos(pos.getX(), pos.getY(), pos.getZ() - 1), new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ() - 1), new BlockPos(pos.getX(), pos.getY() - 1, pos.getZ() - 1) }; BlockPos[] blockPosesUD = { new BlockPos(pos.getX() + 1, pos.getY(), pos.getZ()), new BlockPos(pos.getX() + 1, pos.getY(), pos.getZ() + 1), new BlockPos(pos.getX() + 1, pos.getY(), pos.getZ() - 1), new BlockPos(pos.getX(), pos.getY(), pos.getZ() + 1), new BlockPos(pos.getX(), pos.getY(), pos.getZ()), new BlockPos(pos.getX(), pos.getY(), pos.getZ() - 1), new BlockPos(pos.getX() - 1, pos.getY(), pos.getZ()), new BlockPos(pos.getX() - 1, pos.getY(), pos.getZ() + 1), new BlockPos(pos.getX() - 1, pos.getY(), pos.getZ() - 1) }; if (raytraceresult.sideHit.equals(EnumFacing.NORTH)) { blockPoses = blockPosesNS; } else { if (raytraceresult.sideHit.equals(EnumFacing.SOUTH)) { blockPoses = blockPosesNS; } else { if (raytraceresult.sideHit.equals(EnumFacing.EAST)) { blockPoses = blockPosesEW; } else { if (raytraceresult.sideHit.equals(EnumFacing.WEST)) { blockPoses = blockPosesEW; } else { if (raytraceresult.sideHit.equals(EnumFacing.UP)) { blockPoses = blockPosesUD; } else { if (raytraceresult.sideHit.equals(EnumFacing.DOWN)) { blockPoses = blockPosesUD; } else { return super.onBlockDestroyed(stack, worldIn, state, pos, entityLiving); } } } } } } for (BlockPos blockPos : blockPoses) { Boolean isvalidate = Boolean.valueOf(false); int x = blockPos.getX(); int y = blockPos.getY(); int z = blockPos.getZ(); for (Material material : MATERIALS) { if (worldIn.getBlockState(blockPos).getMaterial().equals(material)) { isvalidate = Boolean.valueOf(true); } } if (worldIn.getBlockState(blockPos).getBlock().equals(Blocks.BEDROCK)) { isvalidate = Boolean.valueOf(false); } } if(ForgeHooks.canHarvestBlock(worldIn.getBlockState(pos).getBlock(), player, worldIn, pos)){ if(player.canHarvestBlock(state)) { worldIn.destroyBlock(pos, true); } } } } stack.damageItem(1, entityLiving); return false; } } edit : i tried it the hammer break blocks but he doesn't break blocks in 3x3x1
  12. like this package fr.darkprod.archymod.items; import java.util.Iterator; import java.util.List; import fr.darkprod.archymod.ArchyMod; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.Item; import net.minecraft.item.Item.ToolMaterial; import net.minecraft.item.ItemPickaxe; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.FurnaceRecipes; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.ForgeHooks; public class ItemHammer extends ItemPickaxe { public long time = System.currentTimeMillis(); protected static final Material[] MATERIALS = { Material.ROCK, Material.IRON, Material.ICE, Material.GLASS, Material.PISTON, Material.ANVIL, Material.SNOW, Material.CRAFTED_SNOW, Material.CLAY }; public ItemHammer(String name,Item.ToolMaterial material) { super(material); setCreativeTab(ArchyMod.ArchyMod); setRegistryName(name); setUnlocalizedName(name); } public int getItemEnchantability() { return 0; } public int getItemEnchantability(ItemStack stack) { return 0; } public boolean isBookEnchantable(ItemStack stack, ItemStack book) { return false; } public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) { return false; } public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) { if ((!worldIn.isRemote) && ((entityIn instanceof EntityPlayer))) { EntityPlayer entityPlayer = (EntityPlayer)entityIn; if (entityPlayer.getItemStackFromSlot(EntityEquipmentSlot.MAINHAND) == null) { return; } } } public boolean onBlockDestroyed(ItemStack stack, World worldIn, IBlockState state, BlockPos pos, EntityLivingBase entityLiving) { if ((!worldIn.isRemote) && ((entityLiving instanceof EntityPlayer))) { EntityPlayer player = (EntityPlayer)entityLiving; RayTraceResult raytraceresult = rayTrace(player.getEntityWorld(), player, true); BlockPos[] blockPoses; if (raytraceresult != null) { BlockPos[] blockPosesNS = { new BlockPos(pos.getX() + 1, pos.getY(), pos.getZ()), new BlockPos(pos.getX() + 1, pos.getY() + 1, pos.getZ()), new BlockPos(pos.getX() + 1, pos.getY() - 1, pos.getZ()), new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ()), new BlockPos(pos.getX(), pos.getY(), pos.getZ()), new BlockPos(pos.getX(), pos.getY() - 1, pos.getZ()), new BlockPos(pos.getX() - 1, pos.getY(), pos.getZ()), new BlockPos(pos.getX() - 1, pos.getY() + 1, pos.getZ()), new BlockPos(pos.getX() - 1, pos.getY() - 1, pos.getZ()) }; BlockPos[] blockPosesEW = { new BlockPos(pos.getX(), pos.getY(), pos.getZ() + 1), new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ() + 1), new BlockPos(pos.getX(), pos.getY() - 1, pos.getZ() + 1), new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ()), new BlockPos(pos.getX(), pos.getY(), pos.getZ()), new BlockPos(pos.getX(), pos.getY() - 1, pos.getZ()), new BlockPos(pos.getX(), pos.getY(), pos.getZ() - 1), new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ() - 1), new BlockPos(pos.getX(), pos.getY() - 1, pos.getZ() - 1) }; BlockPos[] blockPosesUD = { new BlockPos(pos.getX() + 1, pos.getY(), pos.getZ()), new BlockPos(pos.getX() + 1, pos.getY(), pos.getZ() + 1), new BlockPos(pos.getX() + 1, pos.getY(), pos.getZ() - 1), new BlockPos(pos.getX(), pos.getY(), pos.getZ() + 1), new BlockPos(pos.getX(), pos.getY(), pos.getZ()), new BlockPos(pos.getX(), pos.getY(), pos.getZ() - 1), new BlockPos(pos.getX() - 1, pos.getY(), pos.getZ()), new BlockPos(pos.getX() - 1, pos.getY(), pos.getZ() + 1), new BlockPos(pos.getX() - 1, pos.getY(), pos.getZ() - 1) }; if (raytraceresult.sideHit.equals(EnumFacing.NORTH)) { blockPoses = blockPosesNS; } else { if (raytraceresult.sideHit.equals(EnumFacing.SOUTH)) { blockPoses = blockPosesNS; } else { if (raytraceresult.sideHit.equals(EnumFacing.EAST)) { blockPoses = blockPosesEW; } else { if (raytraceresult.sideHit.equals(EnumFacing.WEST)) { blockPoses = blockPosesEW; } else { if (raytraceresult.sideHit.equals(EnumFacing.UP)) { blockPoses = blockPosesUD; } else { if (raytraceresult.sideHit.equals(EnumFacing.DOWN)) { blockPoses = blockPosesUD; } else { return super.onBlockDestroyed(stack, worldIn, state, pos, entityLiving); } } } } } } for (BlockPos blockPos : blockPoses) { Boolean isvalidate = Boolean.valueOf(false); int x = blockPos.getX(); int y = blockPos.getY(); int z = blockPos.getZ(); for (Material material : MATERIALS) { if (worldIn.getBlockState(blockPos).getMaterial().equals(material)) { isvalidate = Boolean.valueOf(true); } } if (worldIn.getBlockState(blockPos).getBlock().equals(Blocks.BEDROCK)) { isvalidate = Boolean.valueOf(false); } } if(ForgeHooks.canHarvestBlock(null, player, worldIn, pos)){ if(player.capabilities.isCreativeMode) { } } } } stack.damageItem(1, entityLiving); return false; } }
  13. it still not working package fr.darkprod.archymod.items; import java.util.Iterator; import java.util.List; import fr.darkprod.archymod.ArchyMod; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.Item; import net.minecraft.item.Item.ToolMaterial; import net.minecraft.item.ItemPickaxe; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.FurnaceRecipes; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class ItemHammer extends ItemPickaxe { public long time = System.currentTimeMillis(); protected static final Material[] MATERIALS = { Material.ROCK, Material.IRON, Material.ICE, Material.GLASS, Material.PISTON, Material.ANVIL, Material.SNOW, Material.CRAFTED_SNOW, Material.CLAY }; public ItemHammer(String name,Item.ToolMaterial material) { super(material); setCreativeTab(ArchyMod.ArchyMod); setRegistryName(name); setUnlocalizedName(name); } public int getItemEnchantability() { return 0; } public int getItemEnchantability(ItemStack stack) { return 0; } public boolean isBookEnchantable(ItemStack stack, ItemStack book) { return false; } public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) { return false; } public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) { if ((!worldIn.isRemote) && ((entityIn instanceof EntityPlayer))) { EntityPlayer entityPlayer = (EntityPlayer)entityIn; if (entityPlayer.getItemStackFromSlot(EntityEquipmentSlot.MAINHAND) == null) { return; } } } public boolean onBlockDestroyed(ItemStack stack, World worldIn, IBlockState state, BlockPos pos, EntityLivingBase entityLiving) { if ((!worldIn.isRemote) && ((entityLiving instanceof EntityPlayer))) { EntityPlayer player = (EntityPlayer)entityLiving; RayTraceResult raytraceresult = rayTrace(player.getEntityWorld(), player, true); BlockPos[] blockPoses; if (raytraceresult != null) { BlockPos[] blockPosesNS = { new BlockPos(pos.getX() + 1, pos.getY(), pos.getZ()), new BlockPos(pos.getX() + 1, pos.getY() + 1, pos.getZ()), new BlockPos(pos.getX() + 1, pos.getY() - 1, pos.getZ()), new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ()), new BlockPos(pos.getX(), pos.getY(), pos.getZ()), new BlockPos(pos.getX(), pos.getY() - 1, pos.getZ()), new BlockPos(pos.getX() - 1, pos.getY(), pos.getZ()), new BlockPos(pos.getX() - 1, pos.getY() + 1, pos.getZ()), new BlockPos(pos.getX() - 1, pos.getY() - 1, pos.getZ()) }; BlockPos[] blockPosesEW = { new BlockPos(pos.getX(), pos.getY(), pos.getZ() + 1), new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ() + 1), new BlockPos(pos.getX(), pos.getY() - 1, pos.getZ() + 1), new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ()), new BlockPos(pos.getX(), pos.getY(), pos.getZ()), new BlockPos(pos.getX(), pos.getY() - 1, pos.getZ()), new BlockPos(pos.getX(), pos.getY(), pos.getZ() - 1), new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ() - 1), new BlockPos(pos.getX(), pos.getY() - 1, pos.getZ() - 1) }; BlockPos[] blockPosesUD = { new BlockPos(pos.getX() + 1, pos.getY(), pos.getZ()), new BlockPos(pos.getX() + 1, pos.getY(), pos.getZ() + 1), new BlockPos(pos.getX() + 1, pos.getY(), pos.getZ() - 1), new BlockPos(pos.getX(), pos.getY(), pos.getZ() + 1), new BlockPos(pos.getX(), pos.getY(), pos.getZ()), new BlockPos(pos.getX(), pos.getY(), pos.getZ() - 1), new BlockPos(pos.getX() - 1, pos.getY(), pos.getZ()), new BlockPos(pos.getX() - 1, pos.getY(), pos.getZ() + 1), new BlockPos(pos.getX() - 1, pos.getY(), pos.getZ() - 1) }; if (raytraceresult.sideHit.equals(EnumFacing.NORTH)) { blockPoses = blockPosesNS; } else { if (raytraceresult.sideHit.equals(EnumFacing.SOUTH)) { blockPoses = blockPosesNS; } else { if (raytraceresult.sideHit.equals(EnumFacing.EAST)) { blockPoses = blockPosesEW; } else { if (raytraceresult.sideHit.equals(EnumFacing.WEST)) { blockPoses = blockPosesEW; } else { if (raytraceresult.sideHit.equals(EnumFacing.UP)) { blockPoses = blockPosesUD; } else { if (raytraceresult.sideHit.equals(EnumFacing.DOWN)) { blockPoses = blockPosesUD; } else { return super.onBlockDestroyed(stack, worldIn, state, pos, entityLiving); } } } } } } for (BlockPos blockPos : blockPoses) { Boolean isvalidate = Boolean.valueOf(false); int x = blockPos.getX(); int y = blockPos.getY(); int z = blockPos.getZ(); for (Material material : MATERIALS) { if (worldIn.getBlockState(blockPos).getMaterial().equals(material)) { isvalidate = Boolean.valueOf(true); } } if (worldIn.getBlockState(blockPos).getBlock().equals(Blocks.BEDROCK)) { isvalidate = Boolean.valueOf(false); } } } } stack.damageItem(1, entityLiving); return false; } public static boolean canHarvestBlock(Block block, EntityPlayer player, IBlockAccess world,BlockPos pos) { return true; } }
  14. ok here is my code : public boolean onBlockDestroyed(ItemStack stack, World worldIn, IBlockState state, BlockPos pos, EntityLivingBase entityLiving) { if ((!worldIn.isRemote) && ((entityLiving instanceof EntityPlayer))) { EntityPlayer player = (EntityPlayer)entityLiving; RayTraceResult raytraceresult = rayTrace(player.getEntityWorld(), player, true); if (raytraceresult != null) { BlockPos[] blockPosesNS = { new BlockPos(pos.getX() + 1, pos.getY(), pos.getZ()), new BlockPos(pos.getX() + 1, pos.getY() + 1, pos.getZ()), new BlockPos(pos.getX() + 1, pos.getY() - 1, pos.getZ()), new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ()), new BlockPos(pos.getX(), pos.getY(), pos.getZ()), new BlockPos(pos.getX(), pos.getY() - 1, pos.getZ()), new BlockPos(pos.getX() - 1, pos.getY(), pos.getZ()), new BlockPos(pos.getX() - 1, pos.getY() + 1, pos.getZ()), new BlockPos(pos.getX() - 1, pos.getY() - 1, pos.getZ()) }; BlockPos[] blockPosesEW = { new BlockPos(pos.getX(), pos.getY(), pos.getZ() + 1), new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ() + 1), new BlockPos(pos.getX(), pos.getY() - 1, pos.getZ() + 1), new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ()), new BlockPos(pos.getX(), pos.getY(), pos.getZ()), new BlockPos(pos.getX(), pos.getY() - 1, pos.getZ()), new BlockPos(pos.getX(), pos.getY(), pos.getZ() - 1), new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ() - 1), new BlockPos(pos.getX(), pos.getY() - 1, pos.getZ() - 1) }; BlockPos[] blockPosesUD = { new BlockPos(pos.getX() + 1, pos.getY(), pos.getZ()), new BlockPos(pos.getX() + 1, pos.getY(), pos.getZ() + 1), new BlockPos(pos.getX() + 1, pos.getY(), pos.getZ() - 1), new BlockPos(pos.getX(), pos.getY(), pos.getZ() + 1), new BlockPos(pos.getX(), pos.getY(), pos.getZ()), new BlockPos(pos.getX(), pos.getY(), pos.getZ() - 1), new BlockPos(pos.getX() - 1, pos.getY(), pos.getZ()), new BlockPos(pos.getX() - 1, pos.getY(), pos.getZ() + 1), new BlockPos(pos.getX() - 1, pos.getY(), pos.getZ() - 1) }; BlockPos[] blockPoses; if (raytraceresult.sideHit.equals(EnumFacing.NORTH)) { blockPoses = blockPosesNS; } else { BlockPos[] blockPoses; if (raytraceresult.sideHit.equals(EnumFacing.SOUTH)) { blockPoses = blockPosesNS; } else { BlockPos[] blockPoses; if (raytraceresult.sideHit.equals(EnumFacing.EAST)) { blockPoses = blockPosesEW; } else { BlockPos[] blockPoses; if (raytraceresult.sideHit.equals(EnumFacing.WEST)) { blockPoses = blockPosesEW; } else { BlockPos[] blockPoses; if (raytraceresult.sideHit.equals(EnumFacing.UP)) { blockPoses = blockPosesUD; } else { BlockPos[] blockPoses; if (raytraceresult.sideHit.equals(EnumFacing.DOWN)) { blockPoses = blockPosesUD; } else { return super.onBlockDestroyed(stack, worldIn, state, pos, entityLiving); } } } } } } BlockPos[] blockPoses; for (BlockPos blockPos : blockPoses) { Boolean isvalidate = Boolean.valueOf(false); int x = blockPos.getX(); int y = blockPos.getY(); int z = blockPos.getZ(); for (Material material : MATERIALS) { if (worldIn.getBlockState(blockPos).getMaterial().equals(material)) { isvalidate = Boolean.valueOf(true); } } if (worldIn.getBlockState(blockPos).getBlock().equals(Blocks.BEDROCK)) { isvalidate = Boolean.valueOf(false); } } } } stack.damageItem(1, entityLiving); return false; }
  15. Can you give me the code please?
  16. Yes i tried to do that but this doesn't work
  17. Hi, I tried to make a hammer for my mod ,i tried some code but they don't work . Someone has an idea how? Thanks , DarkProd02

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.