Advertisement
jayhillx

strippedlogs class01

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