Add colored lamps (#1297)

This commit is contained in:
Firestar311 2019-11-16 01:26:17 -06:00 committed by Brennan Ward
parent ca53ffb287
commit 7160236d45
71 changed files with 364 additions and 7 deletions

8
.gitignore vendored
View file

@ -20,3 +20,11 @@
.settings/org.eclipse.jdt.core.prefs .settings/org.eclipse.jdt.core.prefs
*.prefs *.prefs
/run/ /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

View file

@ -24,8 +24,9 @@ public class AABlocks {
public static final Block CHISELED_BLACK_QUARTZ_BLOCK = null; public static final Block CHISELED_BLACK_QUARTZ_BLOCK = null;
public static final Block BLACK_QUARTZ_PILLAR = null; public static final Block BLACK_QUARTZ_PILLAR = null;
public static final Block BLACK_QUARTZ_SLAB = 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) { public static void register(Register<Block> e) {
//Formatter::off //Formatter::off
e.getRegistry().registerAll( 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("black_quartz_block"),
new Block(Properties.create(Material.ROCK, MaterialColor.BLACK).hardnessAndResistance(0.8F)).setRegistryName("chiseled_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 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 //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(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(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_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 //Formatter::on
} }
} }

View file

@ -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);
}
}

View file

@ -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;
}
}

View file

@ -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" }
}
}

View file

@ -5,5 +5,6 @@
"block.actuallyadditions.chiseled_black_quartz_block": "Chiseled Black Quartz Block", "block.actuallyadditions.chiseled_black_quartz_block": "Chiseled Black Quartz Block",
"block.actuallyadditions.black_quartz_pillar": "Black Quartz Pillar", "block.actuallyadditions.black_quartz_pillar": "Black Quartz Pillar",
"block.actuallyadditions.black_quartz_slab": "Black Quartz Slab", "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"
} }

View file

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "actuallyadditions:block/colored_lamp_block_black"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "actuallyadditions:block/colored_lamp_block_blue"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "actuallyadditions:block/colored_lamp_block_brown"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "actuallyadditions:block/colored_lamp_block_cyan"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "actuallyadditions:block/colored_lamp_block_on_gray"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "actuallyadditions:block/colored_lamp_block_green"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "actuallyadditions:block/colored_lamp_block_light_blue"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "actuallyadditions:block/colored_lamp_block_light_gray"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "actuallyadditions:block/colored_lamp_block_lime"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "actuallyadditions:block/colored_lamp_block_magenta"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "actuallyadditions:block/colored_lamp_block_on_black"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "actuallyadditions:block/colored_lamp_block_on_blue"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "actuallyadditions:block/colored_lamp_block_on_brown"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "actuallyadditions:block/colored_lamp_block_on_cyan"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "actuallyadditions:block/colored_lamp_block_on_gray"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "actuallyadditions:block/colored_lamp_block_on_green"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "actuallyadditions:block/colored_lamp_block_on_light_blue"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "actuallyadditions:block/colored_lamp_block_on_light_gray"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "actuallyadditions:block/colored_lamp_block_on_lime"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "actuallyadditions:block/colored_lamp_block_on_magenta"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "actuallyadditions:block/colored_lamp_block_on_orange"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "actuallyadditions:block/colored_lamp_block_on_pink"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "actuallyadditions:block/colored_lamp_block_on_purple"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "actuallyadditions:block/colored_lamp_block_on_red"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "actuallyadditions:block/colored_lamp_block_on_white"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "actuallyadditions:block/colored_lamp_block_on_yellow"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "actuallyadditions:block/colored_lamp_block_orange"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "actuallyadditions:block/colored_lamp_block_pink"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "actuallyadditions:block/colored_lamp_block_purple"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "actuallyadditions:block/colored_lamp_block_red"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "actuallyadditions:block/colored_lamp_block_white"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "actuallyadditions:block/colored_lamp_block_yellow"
}
}

View file

@ -0,0 +1,3 @@
{
"parent": "actuallyadditions:block/colored_lamp_block_white"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 306 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 533 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 445 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 378 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 372 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 422 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 436 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 404 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 558 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 518 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 361 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 623 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 481 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 493 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 459 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 464 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 492 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 507 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 635 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 606 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 514 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 521 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 600 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 453 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 569 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 595 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 470 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 471 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 489 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 439 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 527 B