Posted May 15, 20205 yr 1.15.I want my block(i'll call it x) to consume whatever block im rightclicking with. i already did the consuming part but if you right click with a block it consumes one and places one next to x. how can i make it so you cant use x to place blocks near it?
May 15, 20205 yr Show your code. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
May 15, 20205 yr Author Spoiler package com.martiblq.washing_mod.events; import java.util.Random; import com.martiblq.washing_mod.WashingMod; import net.minecraft.block.Block; import net.minecraft.block.Blocks; import net.minecraft.entity.ai.attributes.IAttributeInstance; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus; @Mod.EventBusSubscriber(modid= WashingMod.MOD_ID, bus = Bus.FORGE, value = Dist.CLIENT) public class onItemsUsedOnWasherEvent { @SubscribeEvent public static void onItemUsedOnWasherEvent(RightClickBlock event) { PlayerEntity player = event.getPlayer(); World world = event.getWorld(); Block block = world.getBlockState(event.getPos()).getBlock(); ItemStack heldItemStack = event.getItemStack(); Item heldItem = heldItemStack.getItem(); int max = 100; int min = 1; int range = max - min + 1; //gravel if (heldItem == Items.GRAVEL && block == Blocks.BEDROCK&& !world.isRemote) { //player.inventory.addItemStackToInventory(new ItemStack(Items.DIRT)); heldItemStack.shrink(1); int nugget= (int) (Math.random()*range)+min; if(nugget< 11) { player.inventory.addItemStackToInventory(new ItemStack(Items.GOLD_NUGGET)); } int flint= (int) (Math.random()*range)+min; //3 if(flint>50) { player.inventory.addItemStackToInventory(new ItemStack(Items.FLINT)); player.inventory.addItemStackToInventory(new ItemStack(Items.FLINT)); player.inventory.addItemStackToInventory(new ItemStack(Items.FLINT)); } //2 else { player.inventory.addItemStackToInventory(new ItemStack(Items.FLINT)); player.inventory.addItemStackToInventory(new ItemStack(Items.FLINT)); } } } } the event the block Spoiler package com.martiblq.washing_mod.objects.blocks; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.util.Direction; import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import net.minecraftforge.event.entity.player.PlayerInteractEvent; public class Washer extends Block { public Washer() { super(Block.Properties.create(Material.WOOD) .hardnessAndResistance(2F, 3F) .sound(SoundType.WOOD) ); } @Override public int getFlammability(BlockState state, IBlockReader world, BlockPos pos, Direction face) { return 20; } } i want it so if you rightclick on the block you don't place blocks
May 15, 20205 yr Cancel the event. I believe that that event is one that is cancelable, and if canceled, does not process the placement effect. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.