mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-26 00:38:35 +01:00
Removed debugging, renamed LampBlock and fixed lamp functionality
This commit is contained in:
parent
61a490cf24
commit
fcdfe07c65
3 changed files with 27 additions and 24 deletions
|
@ -3,7 +3,6 @@ package de.ellpeck.actuallyadditions.common;
|
||||||
import de.ellpeck.actuallyadditions.common.blocks.ActuallyBlocks;
|
import de.ellpeck.actuallyadditions.common.blocks.ActuallyBlocks;
|
||||||
import de.ellpeck.actuallyadditions.common.config.Config;
|
import de.ellpeck.actuallyadditions.common.config.Config;
|
||||||
import de.ellpeck.actuallyadditions.common.items.ActuallyItems;
|
import de.ellpeck.actuallyadditions.common.items.ActuallyItems;
|
||||||
import net.minecraft.client.resources.I18n;
|
|
||||||
import net.minecraft.item.ItemGroup;
|
import net.minecraft.item.ItemGroup;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
@ -50,6 +49,6 @@ public class ActuallyAdditions {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clientSetup(FMLClientSetupEvent event) {
|
private void clientSetup(FMLClientSetupEvent event) {
|
||||||
ActuallyBlocks.BLOCKS.getEntries().forEach(e -> LOGGER.debug(I18n.format(e.get().getTranslatedName().getString())));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,22 +135,22 @@ public class ActuallyBlocks {
|
||||||
public static final RegistryObject<Block> BLACK_PILLAR_QUARTZ_SLAB = BLOCKS.register("black_pillar_quartz_slab_block", () -> new SlabBlock(Block.Properties.create(Material.ROCK)));
|
public static final RegistryObject<Block> BLACK_PILLAR_QUARTZ_SLAB = BLOCKS.register("black_pillar_quartz_slab_block", () -> new SlabBlock(Block.Properties.create(Material.ROCK)));
|
||||||
|
|
||||||
// LAMPS! SO MANY LAMPS
|
// LAMPS! SO MANY LAMPS
|
||||||
public static final RegistryObject<Block> LAMP_WHITE = BLOCKS.register("lamp_white_block", ColoredLampBlock::new);
|
public static final RegistryObject<Block> LAMP_WHITE = BLOCKS.register("lamp_white_block", LampBlock::new);
|
||||||
public static final RegistryObject<Block> LAMP_ORANGE = BLOCKS.register("lamp_orange_block", ColoredLampBlock::new);
|
public static final RegistryObject<Block> LAMP_ORANGE = BLOCKS.register("lamp_orange_block", LampBlock::new);
|
||||||
public static final RegistryObject<Block> LAMP_MAGENTA = BLOCKS.register("lamp_magenta_block", ColoredLampBlock::new);
|
public static final RegistryObject<Block> LAMP_MAGENTA = BLOCKS.register("lamp_magenta_block", LampBlock::new);
|
||||||
public static final RegistryObject<Block> LAMP_LIGHT_BLUE = BLOCKS.register("lamp_light_blue_block", ColoredLampBlock::new);
|
public static final RegistryObject<Block> LAMP_LIGHT_BLUE = BLOCKS.register("lamp_light_blue_block", LampBlock::new);
|
||||||
public static final RegistryObject<Block> LAMP_YELLOW = BLOCKS.register("lamp_yellow_block", ColoredLampBlock::new);
|
public static final RegistryObject<Block> LAMP_YELLOW = BLOCKS.register("lamp_yellow_block", LampBlock::new);
|
||||||
public static final RegistryObject<Block> LAMP_LIME = BLOCKS.register("lamp_lime_block", ColoredLampBlock::new);
|
public static final RegistryObject<Block> LAMP_LIME = BLOCKS.register("lamp_lime_block", LampBlock::new);
|
||||||
public static final RegistryObject<Block> LAMP_PINK = BLOCKS.register("lamp_pink_block", ColoredLampBlock::new);
|
public static final RegistryObject<Block> LAMP_PINK = BLOCKS.register("lamp_pink_block", LampBlock::new);
|
||||||
public static final RegistryObject<Block> LAMP_GRAY = BLOCKS.register("lamp_gray_block", ColoredLampBlock::new);
|
public static final RegistryObject<Block> LAMP_GRAY = BLOCKS.register("lamp_gray_block", LampBlock::new);
|
||||||
public static final RegistryObject<Block> LAMP_LIGHT_GRAY = BLOCKS.register("lamp_light_gray_block", ColoredLampBlock::new);
|
public static final RegistryObject<Block> LAMP_LIGHT_GRAY = BLOCKS.register("lamp_light_gray_block", LampBlock::new);
|
||||||
public static final RegistryObject<Block> LAMP_CYAN = BLOCKS.register("lamp_cyan_block", ColoredLampBlock::new);
|
public static final RegistryObject<Block> LAMP_CYAN = BLOCKS.register("lamp_cyan_block", LampBlock::new);
|
||||||
public static final RegistryObject<Block> LAMP_PURPLE = BLOCKS.register("lamp_purple_block", ColoredLampBlock::new);
|
public static final RegistryObject<Block> LAMP_PURPLE = BLOCKS.register("lamp_purple_block", LampBlock::new);
|
||||||
public static final RegistryObject<Block> LAMP_BLUE = BLOCKS.register("lamp_blue_block", ColoredLampBlock::new);
|
public static final RegistryObject<Block> LAMP_BLUE = BLOCKS.register("lamp_blue_block", LampBlock::new);
|
||||||
public static final RegistryObject<Block> LAMP_BROWN = BLOCKS.register("lamp_brown_block", ColoredLampBlock::new);
|
public static final RegistryObject<Block> LAMP_BROWN = BLOCKS.register("lamp_brown_block", LampBlock::new);
|
||||||
public static final RegistryObject<Block> LAMP_GREEN = BLOCKS.register("lamp_green_block", ColoredLampBlock::new);
|
public static final RegistryObject<Block> LAMP_GREEN = BLOCKS.register("lamp_green_block", LampBlock::new);
|
||||||
public static final RegistryObject<Block> LAMP_RED = BLOCKS.register("lamp_red_block", ColoredLampBlock::new);
|
public static final RegistryObject<Block> LAMP_RED = BLOCKS.register("lamp_red_block", LampBlock::new);
|
||||||
public static final RegistryObject<Block> LAMP_BLACK = BLOCKS.register("lamp_black_block", ColoredLampBlock::new);
|
public static final RegistryObject<Block> LAMP_BLACK = BLOCKS.register("lamp_black_block", LampBlock::new);
|
||||||
|
|
||||||
public static final RegistryObject<Block> LAMP_CONTROLLER = BLOCKS.register("lamp_controller_block", LampPowererBlock::new);
|
public static final RegistryObject<Block> LAMP_CONTROLLER = BLOCKS.register("lamp_controller_block", LampPowererBlock::new);
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.state.BooleanProperty;
|
import net.minecraft.state.BooleanProperty;
|
||||||
import net.minecraft.state.StateContainer;
|
import net.minecraft.state.StateContainer;
|
||||||
import net.minecraft.state.properties.BlockStateProperties;
|
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.IBlockReader;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public class ColoredLampBlock extends ActuallyBlock {
|
public class LampBlock extends ActuallyBlock {
|
||||||
private static final BooleanProperty LIT = BlockStateProperties.LIT;
|
private static final BooleanProperty LIT = BlockStateProperties.LIT;
|
||||||
|
|
||||||
public ColoredLampBlock() {
|
public LampBlock() {
|
||||||
super(Properties.create(Material.ROCK));
|
super(Properties.create(Material.ROCK));
|
||||||
this.setDefaultState(this.stateContainer.getBaseState().with(LIT, false));
|
this.setDefaultState(this.stateContainer.getBaseState().with(LIT, false));
|
||||||
}
|
}
|
||||||
|
@ -29,11 +30,14 @@ public class ColoredLampBlock extends ActuallyBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
|
public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
||||||
if (!state.get(LIT)) {
|
ItemStack stack = player.getHeldItem(hand);
|
||||||
worldIn.setBlockState(pos, state.getBlock().getDefaultState().with(LIT, true));
|
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
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue