Advertisement
jayhillx

strippedlogs class02

Aug 23rd, 2020
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. @Mod.EventBusSubscriber(modid = MysticsBiomes.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT)
  2. public class ModClientEvents {
  3.  
  4. public static Map<Block, Block> BLOCK_STRIPPING_MAP = new HashMap<>();
  5. public static void onBlockClicked(PlayerInteractEvent.RightClickBlock event) {
  6. if (event.getItemStack().getItem() instanceof AxeItem) {
  7. MysticsBiomes.LOGGER.info("Player stripped log block");
  8. World world = event.getWorld();
  9. BlockPos blockpos = event.getPos();
  10. BlockState blockstate = world.getBlockState(blockpos);
  11. Block block = BLOCK_STRIPPING_MAP.get(blockstate.getBlock());
  12. if (block != null) {
  13. PlayerEntity playerentity = event.getPlayer();
  14. world.playSound(playerentity, blockpos, SoundEvents.ITEM_AXE_STRIP, SoundCategory.BLOCKS, 1.0F, 1.0F);
  15. if (!world.isRemote) {
  16. world.setBlockState(blockpos, block.getDefaultState()
  17. .with(RotatedPillarBlock.AXIS, blockstate.get(RotatedPillarBlock.AXIS)), 11);
  18. if (playerentity != null) {
  19. event.getItemStack().damageItem(1, playerentity, (p_220040_1_) -> p_220040_1_.sendBreakAnimation(event.getHand()));
  20. }
  21. }
  22. }
  23. }
  24. }
  25. static {
  26. BLOCK_STRIPPING_MAP.put(ModBlock.DANDELION_LOG.get(), ModBlock.STRIPPED_DANDELION_LOG.get());
  27. BLOCK_STRIPPING_MAP.put(ModBlock.LEMON_LIME_LOG.get(), ModBlock.STRIPPED_LEMON_LIME_LOG.get());
  28. BLOCK_STRIPPING_MAP.put(ModBlock.SEAFOAM_LOG.get(), ModBlock.STRIPPED_SEAFOAM_LOG.get());
  29. BLOCK_STRIPPING_MAP.put(ModBlock.TROPICAL_LOG.get(), ModBlock.STRIPPED_TROPICAL_LOG.get());
  30. BLOCK_STRIPPING_MAP.put(ModBlock.STRAWBERRRY_LOG.get(), ModBlock.STRIPPED_STRAWBERRY_LOG.get());
  31. BLOCK_STRIPPING_MAP.put(ModBlock.SWEET_STRAWBERRY_LOG.get(), ModBlock.STRIPPED_SWEET_STRAWBERRY_LOG.get());
  32. BLOCK_STRIPPING_MAP.put(ModBlock.LAVENDER_LOG.get(), ModBlock.STRIPPED_LAVENDER_LOG.get());
  33. BLOCK_STRIPPING_MAP.put(ModBlock.MYSTIC_LOG.get(), ModBlock.STRIPPED_MYSTIC_LOG.get());
  34. }
  35. }
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement