Jump to content

Hubmac

Members
  • Posts

    2
  • Joined

  • Last visited

Hubmac's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Ok thanks, it works. I still have a question, how can I download "ServerPlayerEntity" in my case I convert "LivingEntity" to "ServerPlayerEntity" but is there any way to get "ServerPlayerEntity" from anywhere
  2. Hi there i have problem with my mod. I create this mod for learning forge. Mod adds new item to minecraft and in the overided method "OnBlockDestroyed" i give to player 2 diamonds but when i click on this item in inventory dissapear or when i drop this item. Code: package com.example.examplemod; import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.player.ClientPlayerEntity; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.util.datafix.fixes.ItemStackUUID; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.ToolType; import net.minecraftforge.fml.common.registry.GameRegistry; public class Hammer extends Item { public Hammer() { super(new Item.Properties().group(ItemGroup.TOOLS).maxStackSize(4).addToolType(ToolType.AXE, 3).defaultMaxDamage(100).maxDamage(200)); } @Override public boolean onBlockDestroyed(ItemStack itemStack, World world, BlockState blockState, BlockPos blockPos, LivingEntity livingEntity) { ClientPlayerEntity clientPlayerEntity = Minecraft.getInstance().player; clientPlayerEntity.sendChatMessage("You destroy: "+ blockState.getBlock().getRegistryName()); clientPlayerEntity.inventory.addItemStackToInventory(new ItemStack(Items.DIAMOND, 2)); return super.onBlockDestroyed(itemStack, world, blockState, blockPos, livingEntity); } }
×
×
  • Create New...

Important Information

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