
norquisd
Members-
Posts
13 -
Joined
-
Last visited
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
norquisd's Achievements

Tree Puncher (2/8)
0
Reputation
-
[1.14.4] Applying Fortune enchantment to BreakEvent
norquisd replied to norquisd's topic in Modder Support
So I checked out that method, and couldn't use it since it calls onBlockDestryoed(), which just got me stuck in a loop and crashed. I did however, essentially take what i needed from the method in order to implement what I want. Thanks! -
[1.14.4] Applying Fortune enchantment to BreakEvent
norquisd replied to norquisd's topic in Modder Support
I'm a little confused as to how this helps me/what difference this makes -
[1.14.4] Applying Fortune enchantment to BreakEvent
norquisd replied to norquisd's topic in Modder Support
How do I pass an event then? -
[1.14.4] Applying Fortune enchantment to BreakEvent
norquisd replied to norquisd's topic in Modder Support
I don't really know what I am trying to make that do to be honest, I just figured it was good practice to register your events. -
Hi, so I am making a mod that functions as a hammer, such that when 1 block is mined all blocks in a square around it also break (3X3X1). I'd like if the enchantment on the tool I use effects how many, say, diamonds drop when a diamond block is broken. Right now, with the following code (similar in y and z directions) in my Hammer class: Vec3d facing = entityLiving.getLookVec(); double faceX= facing.getX(); double faceY= facing.getY(); double faceZ= facing.getZ(); int posX=pos.getX(); int posY=pos.getY(); int posZ=pos.getZ(); PlayerEntity player = (PlayerEntity) entityLiving; if((Math.abs(faceX))>=(Math.abs(faceY))&&(Math.abs(faceX))>=(Math.abs(faceZ))){ for(int i=-1; i<=1; i++) { for(int j=-1; j<=1;j++) { BlockPos newPos= new BlockPos(posX, posY+i, posZ+j); BreakEvent b = new BreakEvent(worldIn, newPos, state, player); player.giveExperiencePoints(b.getExpToDrop()); MinecraftForge.EVENT_BUS.register(b); BlockState blS = worldIn.getBlockState(newPos); Block bl = blS.getBlock(); if (bl!=Blocks.BEDROCK) { worldIn.destroyBlock(newPos, true); } } } } I have it so it does break said blocks, and will give the player the right amount of exp. However, If fortune 3 is applied to the hammer, I'd like for all the blocks in the mined area to function as though they were mined with a fortune 3 pickaxe. I looked at the HarvestBlockEvent subclass, but there were no methods with which I can spawn any entities. How should I go about this? (Also, if I could spawn the exp as the orbs that you would get when breaking a block in vanilla, rather than directly adding exp, that would be a nice addon). Thanks!
-
I got it working as intended thanks!
-
@OnlyIn(Dist.CLIENT) public RayTraceResult func_213324_a(double p_213324_1_, float p_213324_3_, boolean p_213324_4_) { Vec3d vec3d = this.getEyePosition(p_213324_3_); Vec3d vec3d1 = this.getLook(p_213324_3_); Vec3d vec3d2 = vec3d.add(vec3d1.x * p_213324_1_, vec3d1.y * p_213324_1_, vec3d1.z * p_213324_1_); return this.world.rayTraceBlocks(new RayTraceContext(vec3d, vec3d2, RayTraceContext.BlockMode.OUTLINE, p_213324_4_ ? RayTraceContext.FluidMode.ANY : RayTraceContext.FluidMode.NONE, this)); } I'm having a hard time deciphering what is going on though, since the variables names are not helpful.
-
Im confused about what this return type is, or what I even pass to it. Sorry this is literally Day 1 modding for me. Thanks for the block destroy tip also.
-
Ok sorry if I am stupid but I am kind of unfamiliar with the Vec3d() object. I put the following method into my hammer class: public boolean onBlockDestroyed(ItemStack stack, World worldIn, BlockState state, BlockPos pos, LivingEntity entityLiving) { if (!worldIn.isRemote && state.getBlockHardness(worldIn, pos) != 0.0F) { stack.damageItem(1, entityLiving, (p_220038_0_) -> { p_220038_0_.sendBreakAnimation(EquipmentSlotType.MAINHAND); }); Vec3d facing = entityLiving.getLookVec(); PlayerEntity player = (PlayerEntity) entityLiving; BreakEvent b = new BreakEvent(worldIn, pos, state, player); MinecraftForge.EVENT_BUS.register(b); } return true; } Obviously this wouldn't work as is. But as I understand, I just need to pass a BreakEvent for each block perpendicular to the source block. So it amounts to passing b to the Event Bus 8 times, probably in some sort of loop. How do I update the pos so that I get the perpendicular blocks? More specifically, what does my variable facing actually hold?
-
Nevermind, it's in ToolItem, I'll see if I can figure it out from here, thanks!
-
In PickaxeItem.class: public class PickaxeItem extends ToolItem { private static final Set<Block> EFFECTIVE_ON = ImmutableSet.of(Blocks.ACTIVATOR_RAIL, Blocks.COAL_ORE, Blocks.COBBLESTONE, Blocks.DETECTOR_RAIL, Blocks.DIAMOND_BLOCK, Blocks.DIAMOND_ORE, Blocks.POWERED_RAIL, Blocks.GOLD_BLOCK, Blocks.GOLD_ORE, Blocks.ICE, Blocks.IRON_BLOCK, Blocks.IRON_ORE, Blocks.LAPIS_BLOCK, Blocks.LAPIS_ORE, Blocks.MOSSY_COBBLESTONE, Blocks.NETHERRACK, Blocks.PACKED_ICE, Blocks.BLUE_ICE, Blocks.RAIL, Blocks.REDSTONE_ORE, Blocks.SANDSTONE, Blocks.CHISELED_SANDSTONE, Blocks.CUT_SANDSTONE, Blocks.CHISELED_RED_SANDSTONE, Blocks.CUT_RED_SANDSTONE, Blocks.RED_SANDSTONE, Blocks.STONE, Blocks.GRANITE, Blocks.POLISHED_GRANITE, Blocks.DIORITE, Blocks.POLISHED_DIORITE, Blocks.ANDESITE, Blocks.POLISHED_ANDESITE, Blocks.STONE_SLAB, Blocks.SMOOTH_STONE_SLAB, Blocks.SANDSTONE_SLAB, Blocks.PETRIFIED_OAK_SLAB, Blocks.COBBLESTONE_SLAB, Blocks.BRICK_SLAB, Blocks.STONE_BRICK_SLAB, Blocks.NETHER_BRICK_SLAB, Blocks.QUARTZ_SLAB, Blocks.RED_SANDSTONE_SLAB, Blocks.PURPUR_SLAB, Blocks.SMOOTH_QUARTZ, Blocks.SMOOTH_RED_SANDSTONE, Blocks.SMOOTH_SANDSTONE, Blocks.SMOOTH_STONE, Blocks.STONE_BUTTON, Blocks.STONE_PRESSURE_PLATE, Blocks.POLISHED_GRANITE_SLAB, Blocks.SMOOTH_RED_SANDSTONE_SLAB, Blocks.MOSSY_STONE_BRICK_SLAB, Blocks.POLISHED_DIORITE_SLAB, Blocks.MOSSY_COBBLESTONE_SLAB, Blocks.END_STONE_BRICK_SLAB, Blocks.SMOOTH_SANDSTONE_SLAB, Blocks.SMOOTH_QUARTZ_SLAB, Blocks.GRANITE_SLAB, Blocks.ANDESITE_SLAB, Blocks.RED_NETHER_BRICK_SLAB, Blocks.POLISHED_ANDESITE_SLAB, Blocks.DIORITE_SLAB, Blocks.SHULKER_BOX, Blocks.BLACK_SHULKER_BOX, Blocks.BLUE_SHULKER_BOX, Blocks.BROWN_SHULKER_BOX, Blocks.CYAN_SHULKER_BOX, Blocks.GRAY_SHULKER_BOX, Blocks.GREEN_SHULKER_BOX, Blocks.LIGHT_BLUE_SHULKER_BOX, Blocks.LIGHT_GRAY_SHULKER_BOX, Blocks.LIME_SHULKER_BOX, Blocks.MAGENTA_SHULKER_BOX, Blocks.ORANGE_SHULKER_BOX, Blocks.PINK_SHULKER_BOX, Blocks.PURPLE_SHULKER_BOX, Blocks.RED_SHULKER_BOX, Blocks.WHITE_SHULKER_BOX, Blocks.YELLOW_SHULKER_BOX); public PickaxeItem(IItemTier tier, int attackDamageIn, float attackSpeedIn, Item.Properties builder) { super((float)attackDamageIn, attackSpeedIn, tier, EFFECTIVE_ON, builder.addToolType(net.minecraftforge.common.ToolType.PICKAXE, tier.getHarvestLevel())); } /** * Check whether this Item can harvest the given Block */ public boolean canHarvestBlock(BlockState blockIn) { Block block = blockIn.getBlock(); int i = this.getTier().getHarvestLevel(); if (blockIn.getHarvestTool() == net.minecraftforge.common.ToolType.PICKAXE) { return i >= blockIn.getHarvestLevel(); } Material material = blockIn.getMaterial(); return material == Material.ROCK || material == Material.IRON || material == Material.ANVIL; } public float getDestroySpeed(ItemStack stack, BlockState state) { Material material = state.getMaterial(); return material != Material.IRON && material != Material.ANVIL && material != Material.ROCK ? super.getDestroySpeed(stack, state) : this.efficiency; } } I don't see the method you suggested in this class.
-
The way I am thinking about doing this is adding some sort of listener to detect when a player uses the hammer to break a block, to then just execute a command as that player using their coordinates and rotation to calculate what 9 blocks should break.
-
Hi all, I want to make a very simple mod, that just adds a "hammer" (similar to something like Tinkerer's Construct) to the game but only so it mines a 3 wide X 3 high x 1 deep chunk. I have already added the item to the game as a PickaxeItem: @Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD) public static class RegistryEvents { @SubscribeEvent public static void registerItems(final RegistryEvent.Register<Item> event) { event.getRegistry().registerAll( ItemList.hammer = new PickaxeItem(ToolMaterialList.hammer,-6, -2.8f, new Item.Properties().group(ItemGroup.TOOLS)).setRegistryName(location("hammer")) ); logger.info("Items registered."); } private static ResourceLocation location(String name) { return new ResourceLocation(modid, name); } } with hammer being in a seperate enum, defined in the following way: public enum ToolMaterialList implements IItemTier { hammer(5.0f,9.0f,1561,3,25,Items.DIAMOND); private float attackDamage, efficiency; private int durability, harvestLevel, enchantability; private Item repairMaterial; private ToolMaterialList(float attackDamage, float efficiency, int durability, int harvestLevel, int enchantability, Item repairMaterial) { this.attackDamage=attackDamage; this.efficiency=efficiency; this.durability=durability; this.harvestLevel=harvestLevel; this.enchantability=enchantability; this.repairMaterial=repairMaterial; } @Override public float getAttackDamage() { return this.attackDamage; } @Override public float getEfficiency() { return this.efficiency; } @Override public int getEnchantability() { return this.enchantability; } @Override public int getHarvestLevel() { return this.harvestLevel; } @Override public int getMaxUses() { return this.durability; } @Override public Ingredient getRepairMaterial() { return Ingredient.fromItems(this.repairMaterial); } } So the item loads into game with the texture I want but right now if functions pretty much identically to a diamond pickaxe. How can I go about changing the mining radius? Sorry if this is an involved question I just really don't know where to start.