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.

Branders

Members
  • Joined

  • Last visited

  1. Sadly it did not work. All other methods worked but not PlaceEvent
  2. // SpawnerEventHandler.java // All imports @Mod.EventBusSubscriber public class SpawnerEventHandler { /** * When we harvest a block * Return spawner block when harvested with silk touch */ @SubscribeEvent public void onBlockHarvestDrops(BlockEvent.HarvestDropsEvent event) { if(event.getState().getBlock() == Blocks.SPAWNER) { NBTTagList list = event.getHarvester().getHeldItemMainhand().getEnchantmentTagList(); // Check if silk touch enchant is on the tool if(CheckSilkTouch(list)) event.getDrops().add(new ItemStack(Blocks.SPAWNER, 1)); } } /** * When a block is destroyed * Prevent XP drop when spawner is harvested with silk touch */ @SubscribeEvent public void onBlockBreakEvent(BlockEvent.BreakEvent event) { // Check if a spawner broke if(event.getState().getBlock() == Blocks.SPAWNER) { NBTTagList list = event.getPlayer().getHeldItemMainhand().getEnchantmentTagList(); // Return 0 EXP when harvested with silk touch if(CheckSilkTouch(list)) event.setExpToDrop(0); } } /** * Called when player places a block * * -> This does not happen */ @SubscribeEvent public void onBlockPlaced(BlockEvent.PlaceEvent event) { System.out.println("This does not happen"); } /** * Check a tools item enchantment list contains Silk Touch enchant * * @param NBTTagList of enchantment * @return true/false */ private boolean CheckSilkTouch(NBTTagList list) { // Check list string contains silk touch if(list.getString().indexOf("minecraft:silk_touch") != -1) return true; else return false; } } // SpawnerMod.java // all imports ... @Mod("spawnermod") public class SpawnerMod { public SpawnerMod() { SpawnerEventHandler spawnerEventHandler = new SpawnerEventHandler(); MinecraftForge.EVENT_BUS.register(spawnerEventHandler); } } This is the code for both of my files
  3. Having troubles with BlockEvent.PlaceEvent not getting fired when placing blocks while other events such as BlockEvent.BreakEvent is working just fine. All events is in a class called SpawnerEventHandler with @Mod.EventBusSubscriber on it and this class is registred in root mod constructor via: SpawnerEventHandler spawnerEventHandler = new SpawnerEventHandler(); MinecraftForge.EVENT_BUS.register(spawnerEventHandler); Any suggestions on how to get info when player places down a block? Thanks in advance.

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.