diff --git a/src/main/java/de/ellpeck/actuallyadditions/common/ActuallyAdditions.java b/src/main/java/de/ellpeck/actuallyadditions/common/ActuallyAdditions.java index 583d8af18..afec060c8 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/common/ActuallyAdditions.java +++ b/src/main/java/de/ellpeck/actuallyadditions/common/ActuallyAdditions.java @@ -3,7 +3,6 @@ package de.ellpeck.actuallyadditions.common; import de.ellpeck.actuallyadditions.common.blocks.ActuallyBlocks; import de.ellpeck.actuallyadditions.common.config.Config; import de.ellpeck.actuallyadditions.common.items.ActuallyItems; -import net.minecraft.client.resources.I18n; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraftforge.common.MinecraftForge; @@ -50,6 +49,6 @@ public class ActuallyAdditions { } private void clientSetup(FMLClientSetupEvent event) { - ActuallyBlocks.BLOCKS.getEntries().forEach(e -> LOGGER.debug(I18n.format(e.get().getTranslatedName().getString()))); + } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/common/blocks/ActuallyBlocks.java b/src/main/java/de/ellpeck/actuallyadditions/common/blocks/ActuallyBlocks.java index c20b78dd5..16037459d 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/common/blocks/ActuallyBlocks.java +++ b/src/main/java/de/ellpeck/actuallyadditions/common/blocks/ActuallyBlocks.java @@ -135,22 +135,22 @@ public class ActuallyBlocks { public static final RegistryObject BLACK_PILLAR_QUARTZ_SLAB = BLOCKS.register("black_pillar_quartz_slab_block", () -> new SlabBlock(Block.Properties.create(Material.ROCK))); // LAMPS! SO MANY LAMPS - public static final RegistryObject LAMP_WHITE = BLOCKS.register("lamp_white_block", ColoredLampBlock::new); - public static final RegistryObject LAMP_ORANGE = BLOCKS.register("lamp_orange_block", ColoredLampBlock::new); - public static final RegistryObject LAMP_MAGENTA = BLOCKS.register("lamp_magenta_block", ColoredLampBlock::new); - public static final RegistryObject LAMP_LIGHT_BLUE = BLOCKS.register("lamp_light_blue_block", ColoredLampBlock::new); - public static final RegistryObject LAMP_YELLOW = BLOCKS.register("lamp_yellow_block", ColoredLampBlock::new); - public static final RegistryObject LAMP_LIME = BLOCKS.register("lamp_lime_block", ColoredLampBlock::new); - public static final RegistryObject LAMP_PINK = BLOCKS.register("lamp_pink_block", ColoredLampBlock::new); - public static final RegistryObject LAMP_GRAY = BLOCKS.register("lamp_gray_block", ColoredLampBlock::new); - public static final RegistryObject LAMP_LIGHT_GRAY = BLOCKS.register("lamp_light_gray_block", ColoredLampBlock::new); - public static final RegistryObject LAMP_CYAN = BLOCKS.register("lamp_cyan_block", ColoredLampBlock::new); - public static final RegistryObject LAMP_PURPLE = BLOCKS.register("lamp_purple_block", ColoredLampBlock::new); - public static final RegistryObject LAMP_BLUE = BLOCKS.register("lamp_blue_block", ColoredLampBlock::new); - public static final RegistryObject LAMP_BROWN = BLOCKS.register("lamp_brown_block", ColoredLampBlock::new); - public static final RegistryObject LAMP_GREEN = BLOCKS.register("lamp_green_block", ColoredLampBlock::new); - public static final RegistryObject LAMP_RED = BLOCKS.register("lamp_red_block", ColoredLampBlock::new); - public static final RegistryObject LAMP_BLACK = BLOCKS.register("lamp_black_block", ColoredLampBlock::new); + public static final RegistryObject LAMP_WHITE = BLOCKS.register("lamp_white_block", LampBlock::new); + public static final RegistryObject LAMP_ORANGE = BLOCKS.register("lamp_orange_block", LampBlock::new); + public static final RegistryObject LAMP_MAGENTA = BLOCKS.register("lamp_magenta_block", LampBlock::new); + public static final RegistryObject LAMP_LIGHT_BLUE = BLOCKS.register("lamp_light_blue_block", LampBlock::new); + public static final RegistryObject LAMP_YELLOW = BLOCKS.register("lamp_yellow_block", LampBlock::new); + public static final RegistryObject LAMP_LIME = BLOCKS.register("lamp_lime_block", LampBlock::new); + public static final RegistryObject LAMP_PINK = BLOCKS.register("lamp_pink_block", LampBlock::new); + public static final RegistryObject LAMP_GRAY = BLOCKS.register("lamp_gray_block", LampBlock::new); + public static final RegistryObject LAMP_LIGHT_GRAY = BLOCKS.register("lamp_light_gray_block", LampBlock::new); + public static final RegistryObject LAMP_CYAN = BLOCKS.register("lamp_cyan_block", LampBlock::new); + public static final RegistryObject LAMP_PURPLE = BLOCKS.register("lamp_purple_block", LampBlock::new); + public static final RegistryObject LAMP_BLUE = BLOCKS.register("lamp_blue_block", LampBlock::new); + public static final RegistryObject LAMP_BROWN = BLOCKS.register("lamp_brown_block", LampBlock::new); + public static final RegistryObject LAMP_GREEN = BLOCKS.register("lamp_green_block", LampBlock::new); + public static final RegistryObject LAMP_RED = BLOCKS.register("lamp_red_block", LampBlock::new); + public static final RegistryObject LAMP_BLACK = BLOCKS.register("lamp_black_block", LampBlock::new); public static final RegistryObject LAMP_CONTROLLER = BLOCKS.register("lamp_controller_block", LampPowererBlock::new); diff --git a/src/main/java/de/ellpeck/actuallyadditions/common/blocks/functional/LampBlock.java b/src/main/java/de/ellpeck/actuallyadditions/common/blocks/functional/LampBlock.java index c13194941..f6452b61e 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/common/blocks/functional/LampBlock.java +++ b/src/main/java/de/ellpeck/actuallyadditions/common/blocks/functional/LampBlock.java @@ -5,6 +5,7 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.material.Material; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; import net.minecraft.state.BooleanProperty; import net.minecraft.state.StateContainer; import net.minecraft.state.properties.BlockStateProperties; @@ -15,10 +16,10 @@ import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; -public class ColoredLampBlock extends ActuallyBlock { +public class LampBlock extends ActuallyBlock { private static final BooleanProperty LIT = BlockStateProperties.LIT; - public ColoredLampBlock() { + public LampBlock() { super(Properties.create(Material.ROCK)); this.setDefaultState(this.stateContainer.getBaseState().with(LIT, false)); } @@ -29,11 +30,14 @@ public class ColoredLampBlock extends ActuallyBlock { } @Override - public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { - if (!state.get(LIT)) { - worldIn.setBlockState(pos, state.getBlock().getDefaultState().with(LIT, true)); + public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) { + ItemStack stack = player.getHeldItem(hand); + if (hand == Hand.MAIN_HAND && stack.isEmpty()) { + world.setBlockState(pos, state.getBlock().getDefaultState().with(LIT, !state.getBlockState().get(LIT)), 2); + return ActionResultType.SUCCESS; } - return super.onBlockActivated(state, worldIn, pos, player, handIn, hit); + + return super.onBlockActivated(state, world, pos, player, hand, hit); } @Override