Add colored lamps (#1297)
8
.gitignore
vendored
|
@ -20,3 +20,11 @@
|
|||
.settings/org.eclipse.jdt.core.prefs
|
||||
*.prefs
|
||||
/run/
|
||||
.DS_Store
|
||||
src/.DS_Store
|
||||
src/main/.DS_Store
|
||||
src/main/java/.DS_Store
|
||||
src/main/java/de/.DS_Store
|
||||
src/main/java/de/ellpeck/.DS_Store
|
||||
src/main/java/de/ellpeck/actuallyadditions/.DS_Store
|
||||
src/main/java/de/ellpeck/actuallyadditions/mod/.DS_Store
|
||||
|
|
|
@ -24,8 +24,9 @@ public class AABlocks {
|
|||
public static final Block CHISELED_BLACK_QUARTZ_BLOCK = null;
|
||||
public static final Block BLACK_QUARTZ_PILLAR = null;
|
||||
public static final Block BLACK_QUARTZ_SLAB = null;
|
||||
public static final Block COLORED_LAMP_BLOCK = null;
|
||||
|
||||
@SubscribeEvent
|
||||
@SubscribeEvent
|
||||
public static void register(Register<Block> e) {
|
||||
//Formatter::off
|
||||
e.getRegistry().registerAll(
|
||||
|
@ -33,8 +34,9 @@ public class AABlocks {
|
|||
new Block(Properties.create(Material.ROCK, MaterialColor.BLACK).hardnessAndResistance(0.8F)).setRegistryName("black_quartz_block"),
|
||||
new Block(Properties.create(Material.ROCK, MaterialColor.BLACK).hardnessAndResistance(0.8F)).setRegistryName("chiseled_black_quartz_block"),
|
||||
new RotatedPillarBlock(Block.Properties.create(Material.ROCK, MaterialColor.BLACK).hardnessAndResistance(0.8F)).setRegistryName("black_quartz_pillar"),
|
||||
new SlabBlock(Block.Properties.create(Material.ROCK, MaterialColor.BLACK).hardnessAndResistance(0.8F)).setRegistryName("black_quartz_slab")
|
||||
);
|
||||
new SlabBlock(Block.Properties.create(Material.ROCK, MaterialColor.BLACK).hardnessAndResistance(0.8F)).setRegistryName("black_quartz_slab"),
|
||||
new ColoredLampBlock().setRegistryName("colored_lamp_block")
|
||||
);
|
||||
//Formatter::on
|
||||
}
|
||||
|
||||
|
@ -46,8 +48,9 @@ public class AABlocks {
|
|||
new BlockItem(BLACK_QUARTZ_BLOCK, new Item.Properties().group(ActuallyAdditions.GROUP)).setRegistryName(BLACK_QUARTZ_BLOCK.getRegistryName()),
|
||||
new BlockItem(CHISELED_BLACK_QUARTZ_BLOCK, new Item.Properties().group(ActuallyAdditions.GROUP)).setRegistryName(CHISELED_BLACK_QUARTZ_BLOCK.getRegistryName()),
|
||||
new BlockItem(BLACK_QUARTZ_PILLAR, new Item.Properties().group(ActuallyAdditions.GROUP)).setRegistryName(BLACK_QUARTZ_PILLAR.getRegistryName()),
|
||||
new BlockItem(BLACK_QUARTZ_SLAB, new Item.Properties().group(ActuallyAdditions.GROUP)).setRegistryName(BLACK_QUARTZ_SLAB.getRegistryName())
|
||||
);
|
||||
new BlockItem(BLACK_QUARTZ_SLAB, new Item.Properties().group(ActuallyAdditions.GROUP)).setRegistryName(BLACK_QUARTZ_SLAB.getRegistryName()),
|
||||
new BlockItem(COLORED_LAMP_BLOCK, new Item.Properties().group(ActuallyAdditions.GROUP)).setRegistryName(COLORED_LAMP_BLOCK.getRegistryName())
|
||||
);
|
||||
//Formatter::on
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package de.ellpeck.actuallyadditions.mod.block;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.state.BooleanProperty;
|
||||
import net.minecraft.state.EnumProperty;
|
||||
import net.minecraft.state.StateContainer.Builder;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.world.IEnviromentBlockReader;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ColoredLampBlock extends Block {
|
||||
|
||||
public static final EnumProperty<LampColors> COLOR = EnumProperty.create("color", LampColors.class);
|
||||
public static final BooleanProperty ACTIVE = BooleanProperty.create("active");
|
||||
|
||||
public ColoredLampBlock() {
|
||||
super(Properties.create(Material.REDSTONE_LIGHT).harvestTool(ToolType.PICKAXE).harvestLevel(0).hardnessAndResistance(0.5F, 3.0F));
|
||||
}
|
||||
|
||||
public void onBlockPlacedBy(World worldIn, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) {
|
||||
super.onBlockPlacedBy(worldIn, pos, state.with(ACTIVE, false).with(COLOR, LampColors.WHITE), placer, stack);
|
||||
}
|
||||
|
||||
public boolean onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
||||
ItemStack stack = player.getHeldItemMainhand();
|
||||
if (hand == Hand.MAIN_HAND && (stack == null || stack.isEmpty())) {
|
||||
world.setBlockState(pos, state.with(ACTIVE, !state.get(ACTIVE)), 3);
|
||||
return true;
|
||||
}
|
||||
|
||||
LampColors color = LampColors.getColorFromStack(stack);
|
||||
if (color != null) {
|
||||
world.setBlockState(pos, state.with(COLOR, color), 3);
|
||||
world.markAndNotifyBlock(pos, world.getChunkAt(pos), state, world.getBlockState(pos), 3);
|
||||
if (!player.abilities.isCreativeMode) {
|
||||
player.inventory.decrStackSize(player.inventory.currentItem, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return super.onBlockActivated(state, world, pos, player, hand, hit);
|
||||
}
|
||||
|
||||
public int getLightValue(BlockState state, IEnviromentBlockReader world, BlockPos pos) {
|
||||
return state.get(ACTIVE) ? 15 : 0;
|
||||
}
|
||||
|
||||
protected void fillStateContainer(Builder<Block, BlockState> builder) {
|
||||
builder.add(COLOR, ACTIVE);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* This file ("TheColoredLampColors.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2017 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.block;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tags.ItemTags;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public enum LampColors implements IStringSerializable {
|
||||
|
||||
WHITE("White", "white"), ORANGE("Orange", "orange"), MAGENTA("Magenta", "magenta"), LIGHT_BLUE("LightBlue", "light_blue"), YELLOW("Yellow", "yellow"), LIME("Lime", "lime"), PINK("Pink", "pink"), GRAY("Gray", "gray"), LIGHT_GRAY("LightGray", "light_gray"), CYAN("Cyan", "cyan"), PURPLE("Purple", "purple"), BLUE("Blue", "blue"), BROWN("Brown", "brown"), GREEN("Green", "green"), RED("Red", "red"), BLACK("Black", "black");
|
||||
|
||||
public final String regName;
|
||||
public final String oreName;
|
||||
|
||||
LampColors(String oreName, String regName) {
|
||||
this.oreName = oreName;
|
||||
this.regName = regName;
|
||||
}
|
||||
|
||||
public static LampColors getColorFromStack(ItemStack stack) {
|
||||
Collection<ResourceLocation> owningTags = ItemTags.getCollection().getOwningTags(stack.getItem());
|
||||
String dyeColor = "";
|
||||
for (ResourceLocation rl : owningTags) {
|
||||
String path = rl.getPath();
|
||||
if (path.contains("dyes/")) {
|
||||
dyeColor = path.substring(5);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (StringUtils.isEmpty(dyeColor)) {
|
||||
return null;
|
||||
}
|
||||
return valueOf(dyeColor.toUpperCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.regName;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
"variants": {
|
||||
"active=true,color=white": { "model": "actuallyadditions:block/colored_lamp_block_on_white" },
|
||||
"active=false,color=white": { "model": "actuallyadditions:block/colored_lamp_block_white" },
|
||||
"active=true,color=black": { "model": "actuallyadditions:block/colored_lamp_block_on_black" },
|
||||
"active=false,color=black": { "model": "actuallyadditions:block/colored_lamp_block_black" },
|
||||
"active=true,color=blue": { "model": "actuallyadditions:block/colored_lamp_block_on_blue" },
|
||||
"active=false,color=blue": { "model": "actuallyadditions:block/colored_lamp_block_blue" },
|
||||
"active=true,color=brown": { "model": "actuallyadditions:block/colored_lamp_block_on_brown" },
|
||||
"active=false,color=brown": { "model": "actuallyadditions:block/colored_lamp_block_brown" },
|
||||
"active=true,color=cyan": { "model": "actuallyadditions:block/colored_lamp_block_on_cyan" },
|
||||
"active=false,color=cyan": { "model": "actuallyadditions:block/colored_lamp_block_cyan" },
|
||||
"active=true,color=gray": { "model": "actuallyadditions:block/colored_lamp_block_on_gray" },
|
||||
"active=false,color=gray": { "model": "actuallyadditions:block/colored_lamp_block_gray" },
|
||||
"active=true,color=green": { "model": "actuallyadditions:block/colored_lamp_block_on_green" },
|
||||
"active=false,color=green": { "model": "actuallyadditions:block/colored_lamp_block_green" },
|
||||
"active=true,color=light_blue": { "model": "actuallyadditions:block/colored_lamp_block_on_light_blue" },
|
||||
"active=false,color=light_blue": { "model": "actuallyadditions:block/colored_lamp_block_light_blue" },
|
||||
"active=true,color=light_gray": { "model": "actuallyadditions:block/colored_lamp_block_on_light_gray" },
|
||||
"active=false,color=light_gray": { "model": "actuallyadditions:block/colored_lamp_block_light_gray" },
|
||||
"active=true,color=lime": { "model": "actuallyadditions:block/colored_lamp_block_on_lime" },
|
||||
"active=false,color=lime": { "model": "actuallyadditions:block/colored_lamp_block_lime" },
|
||||
"active=true,color=magenta": { "model": "actuallyadditions:block/colored_lamp_block_on_magenta" },
|
||||
"active=false,color=magenta": { "model": "actuallyadditions:block/colored_lamp_block_magenta" },
|
||||
"active=true,color=orange": { "model": "actuallyadditions:block/colored_lamp_block_on_orange" },
|
||||
"active=false,color=orange": { "model": "actuallyadditions:block/colored_lamp_block_orange" },
|
||||
"active=true,color=pink": { "model": "actuallyadditions:block/colored_lamp_block_on_pink" },
|
||||
"active=false,color=pink": { "model": "actuallyadditions:block/colored_lamp_block_pink" },
|
||||
"active=true,color=purple": { "model": "actuallyadditions:block/colored_lamp_block_on_purple" },
|
||||
"active=false,color=purple": { "model": "actuallyadditions:block/colored_lamp_block_purple" },
|
||||
"active=true,color=red": { "model": "actuallyadditions:block/colored_lamp_block_on_red" },
|
||||
"active=false,color=red": { "model": "actuallyadditions:block/colored_lamp_block_red" },
|
||||
"active=true,color=yellow": { "model": "actuallyadditions:block/colored_lamp_block_on_yellow" },
|
||||
"active=false,color=yellow": { "model": "actuallyadditions:block/colored_lamp_block_yellow" }
|
||||
}
|
||||
}
|
|
@ -5,5 +5,6 @@
|
|||
"block.actuallyadditions.chiseled_black_quartz_block": "Chiseled Black Quartz Block",
|
||||
"block.actuallyadditions.black_quartz_pillar": "Black Quartz Pillar",
|
||||
"block.actuallyadditions.black_quartz_slab": "Black Quartz Slab",
|
||||
"block.actuallyadditions.black_quartz_ore": "Black Quartz Ore"
|
||||
"block.actuallyadditions.black_quartz_ore": "Black Quartz Ore",
|
||||
"block.actuallyadditions.colored_lamp_block": "Colored Lamp"
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "block/cube_all",
|
||||
"textures": {
|
||||
"all": "actuallyadditions:block/colored_lamp_block_black"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "block/cube_all",
|
||||
"textures": {
|
||||
"all": "actuallyadditions:block/colored_lamp_block_blue"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "block/cube_all",
|
||||
"textures": {
|
||||
"all": "actuallyadditions:block/colored_lamp_block_brown"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "block/cube_all",
|
||||
"textures": {
|
||||
"all": "actuallyadditions:block/colored_lamp_block_cyan"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "block/cube_all",
|
||||
"textures": {
|
||||
"all": "actuallyadditions:block/colored_lamp_block_on_gray"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "block/cube_all",
|
||||
"textures": {
|
||||
"all": "actuallyadditions:block/colored_lamp_block_green"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "block/cube_all",
|
||||
"textures": {
|
||||
"all": "actuallyadditions:block/colored_lamp_block_light_blue"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "block/cube_all",
|
||||
"textures": {
|
||||
"all": "actuallyadditions:block/colored_lamp_block_light_gray"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "block/cube_all",
|
||||
"textures": {
|
||||
"all": "actuallyadditions:block/colored_lamp_block_lime"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "block/cube_all",
|
||||
"textures": {
|
||||
"all": "actuallyadditions:block/colored_lamp_block_magenta"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "block/cube_all",
|
||||
"textures": {
|
||||
"all": "actuallyadditions:block/colored_lamp_block_on_black"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "block/cube_all",
|
||||
"textures": {
|
||||
"all": "actuallyadditions:block/colored_lamp_block_on_blue"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "block/cube_all",
|
||||
"textures": {
|
||||
"all": "actuallyadditions:block/colored_lamp_block_on_brown"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "block/cube_all",
|
||||
"textures": {
|
||||
"all": "actuallyadditions:block/colored_lamp_block_on_cyan"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "block/cube_all",
|
||||
"textures": {
|
||||
"all": "actuallyadditions:block/colored_lamp_block_on_gray"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "block/cube_all",
|
||||
"textures": {
|
||||
"all": "actuallyadditions:block/colored_lamp_block_on_green"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "block/cube_all",
|
||||
"textures": {
|
||||
"all": "actuallyadditions:block/colored_lamp_block_on_light_blue"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "block/cube_all",
|
||||
"textures": {
|
||||
"all": "actuallyadditions:block/colored_lamp_block_on_light_gray"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "block/cube_all",
|
||||
"textures": {
|
||||
"all": "actuallyadditions:block/colored_lamp_block_on_lime"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "block/cube_all",
|
||||
"textures": {
|
||||
"all": "actuallyadditions:block/colored_lamp_block_on_magenta"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "block/cube_all",
|
||||
"textures": {
|
||||
"all": "actuallyadditions:block/colored_lamp_block_on_orange"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "block/cube_all",
|
||||
"textures": {
|
||||
"all": "actuallyadditions:block/colored_lamp_block_on_pink"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "block/cube_all",
|
||||
"textures": {
|
||||
"all": "actuallyadditions:block/colored_lamp_block_on_purple"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "block/cube_all",
|
||||
"textures": {
|
||||
"all": "actuallyadditions:block/colored_lamp_block_on_red"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "block/cube_all",
|
||||
"textures": {
|
||||
"all": "actuallyadditions:block/colored_lamp_block_on_white"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "block/cube_all",
|
||||
"textures": {
|
||||
"all": "actuallyadditions:block/colored_lamp_block_on_yellow"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "block/cube_all",
|
||||
"textures": {
|
||||
"all": "actuallyadditions:block/colored_lamp_block_orange"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "block/cube_all",
|
||||
"textures": {
|
||||
"all": "actuallyadditions:block/colored_lamp_block_pink"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "block/cube_all",
|
||||
"textures": {
|
||||
"all": "actuallyadditions:block/colored_lamp_block_purple"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "block/cube_all",
|
||||
"textures": {
|
||||
"all": "actuallyadditions:block/colored_lamp_block_red"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "block/cube_all",
|
||||
"textures": {
|
||||
"all": "actuallyadditions:block/colored_lamp_block_white"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "block/cube_all",
|
||||
"textures": {
|
||||
"all": "actuallyadditions:block/colored_lamp_block_yellow"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"parent": "actuallyadditions:block/colored_lamp_block_white"
|
||||
}
|
After Width: | Height: | Size: 306 B |
After Width: | Height: | Size: 533 B |
After Width: | Height: | Size: 445 B |
After Width: | Height: | Size: 378 B |
After Width: | Height: | Size: 372 B |
After Width: | Height: | Size: 422 B |
After Width: | Height: | Size: 436 B |
After Width: | Height: | Size: 404 B |
After Width: | Height: | Size: 558 B |
After Width: | Height: | Size: 518 B |
After Width: | Height: | Size: 361 B |
After Width: | Height: | Size: 623 B |
After Width: | Height: | Size: 481 B |
After Width: | Height: | Size: 493 B |
After Width: | Height: | Size: 459 B |
After Width: | Height: | Size: 464 B |
After Width: | Height: | Size: 492 B |
After Width: | Height: | Size: 507 B |
After Width: | Height: | Size: 635 B |
After Width: | Height: | Size: 606 B |
After Width: | Height: | Size: 514 B |
After Width: | Height: | Size: 521 B |
After Width: | Height: | Size: 600 B |
After Width: | Height: | Size: 453 B |
After Width: | Height: | Size: 569 B |
After Width: | Height: | Size: 595 B |
After Width: | Height: | Size: 470 B |
After Width: | Height: | Size: 471 B |
After Width: | Height: | Size: 489 B |
After Width: | Height: | Size: 380 B |
After Width: | Height: | Size: 439 B |
After Width: | Height: | Size: 527 B |