diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLampPowerer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLampPowerer.java index 3f36b7f38..5b5631d5e 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLampPowerer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLampPowerer.java @@ -22,9 +22,13 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import java.util.ArrayList; +import java.util.List; + public class BlockLampPowerer extends BlockBase{ private static final PropertyInteger META = PropertyInteger.create("meta", 0, 5); @@ -59,20 +63,38 @@ public class BlockLampPowerer extends BlockBase{ if(!world.isRemote){ IBlockState state = world.getBlockState(pos); BlockPos coords = pos.offset(WorldUtil.getDirectionByPistonRotation(state.getBlock().getMetaFromState(state))); - IBlockState coordsState = world.getBlockState(coords); - if(coordsState.getBlock() instanceof BlockColoredLamp){ - int meta = coordsState.getBlock().getMetaFromState(coordsState); - if(world.isBlockIndirectlyGettingPowered(pos) > 0){ - if(!((BlockColoredLamp)coordsState.getBlock()).isOn){ - world.setBlockState(coords, InitBlocks.blockColoredLampOn.getStateFromMeta(meta), 2); - } + this.updateLampsAtPos(world, coords, world.isBlockIndirectlyGettingPowered(pos) > 0, new ArrayList()); + } + } + + private void updateLampsAtPos(World world, BlockPos pos, boolean powered, List updatedAlready){ + IBlockState state = world.getBlockState(pos); + Block block = state.getBlock(); + if(block instanceof BlockColoredLamp){ + boolean isOn = ((BlockColoredLamp)block).isOn; + int meta = block.getMetaFromState(state); + if(powered){ + if(!isOn){ + world.setBlockState(pos, InitBlocks.blockColoredLampOn.getStateFromMeta(meta), 2); } - else{ - if(((BlockColoredLamp)coordsState.getBlock()).isOn){ - world.setBlockState(coords, InitBlocks.blockColoredLamp.getStateFromMeta(meta), 2); - } + } + else{ + if(isOn){ + world.setBlockState(pos, InitBlocks.blockColoredLamp.getStateFromMeta(meta), 2); } } + + this.updateSurrounding(world, pos, powered, updatedAlready); + } + } + + private void updateSurrounding(World world, BlockPos pos, boolean powered, List updatedAlready){ + for(EnumFacing side : EnumFacing.values()){ + BlockPos offset = pos.offset(side); + if(!updatedAlready.contains(offset)){ + updatedAlready.add(pos); + this.updateLampsAtPos(world, offset, powered, updatedAlready); + } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/InitBooklet.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/InitBooklet.java index fd929be48..c865af7b3 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/InitBooklet.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/InitBooklet.java @@ -93,7 +93,8 @@ public final class InitBooklet{ new BookletChapter("coalStuff", ActuallyAdditionsAPI.entryMisc, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.TINY_COAL.ordinal()), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeTinyCoal).setNoText(), new PageCrafting(3, ItemCrafting.recipeTinyChar).setNoText(), new PageCrafting(4, BlockCrafting.recipeBlockChar).setNoText()); ArrayList lampPages = new ArrayList(); lampPages.add(new PageTextOnly(lampPages.size()+1)); - lampPages.add(new PageCrafting(lampPages.size()+1, BlockCrafting.recipePowerer).setNoText()); + lampPages.add(new PageTextOnly(lampPages.size()+1)); + lampPages.add(new PageCrafting(lampPages.size()+1, BlockCrafting.recipePowerer).setNoText().setPageStacksWildcard()); for(IRecipe recipe : BlockCrafting.RECIPES_LAMPS){ lampPages.add(new PageCrafting(lampPages.size()+1, recipe).setNoText()); } diff --git a/src/main/resources/assets/actuallyadditions/lang/en_US.lang b/src/main/resources/assets/actuallyadditions/lang/en_US.lang index 7134c261c..93a64aecc 100644 --- a/src/main/resources/assets/actuallyadditions/lang/en_US.lang +++ b/src/main/resources/assets/actuallyadditions/lang/en_US.lang @@ -752,7 +752,8 @@ booklet.actuallyadditions.chapter.coalStuff.name=Coal Stuff booklet.actuallyadditions.chapter.coalStuff.text.1=Sometimes your Coal just burns for too long or too short, you know what I mean? For that, you can now craft Tiny Coal, Tiny Charcoal and Blocks of Charcoal for using them in a furnace. While the Block of Charcoal burns for as long as a Block of Coal, the Tiny Coal and Tiny Charcoal will burn for one eighth of a piece of coal, meaning it will smelt one item in a normal furnace. booklet.actuallyadditions.chapter.lamps.name=Lamps -booklet.actuallyadditions.chapter.lamps.text.1=Lamps are a block providing lots of light, similar to the mystic Glowstone or Torches, but they can be dyed with all of the 16 different colors either by crafting them or by placing them on the ground and right-clicking them with a piece of dye. When right-clicking them with an empty hand, they will turn on and off. If you want them, however, to be toggled using Redstone Power, just place a Lamp Controller next to one. +booklet.actuallyadditions.chapter.lamps.text.1=Lamps are a block providing lots of light, similar to the mystic Glowstone or Torches, but they can be dyed with all of the 16 different colors either by crafting them or by placing them on the ground and right-clicking them with a piece of dye. When right-clicking them with an empty hand, they will turn on and off. +booklet.actuallyadditions.chapter.lamps.text.2=There is a way to toggle them with Redstone, however. If you place a Lamp Controller facing into one and give it a redstone signal, it will turn the lamp in front of it on and off. The thing that makes this very expandable, though, is that it also toggles every lamp adjacent to that lamp and every other lamp that gets touched. That means you can have a huge field of lamps and toggle them all with just one Lamp Controller. booklet.actuallyadditions.chapter.treasureChest.name=Treasure Chests booklet.actuallyadditions.chapter.treasureChest.text.1=A Treasure Chest found underwater.