Skip to content

Commit 9e7182c

Browse files
committed
Added the Illuminant Rod.
1 parent 2dd4eb5 commit 9e7182c

File tree

8 files changed

+155
-1
lines changed

8 files changed

+155
-1
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
package com.flanks255.simplylight.blocks;
2+
3+
4+
import net.minecraft.block.Block;
5+
import net.minecraft.block.BlockState;
6+
import net.minecraft.block.IWaterLoggable;
7+
import net.minecraft.block.material.Material;
8+
import net.minecraft.block.material.MaterialColor;
9+
import net.minecraft.block.material.PushReaction;
10+
import net.minecraft.fluid.Fluid;
11+
import net.minecraft.fluid.Fluids;
12+
import net.minecraft.fluid.IFluidState;
13+
import net.minecraft.item.BlockItemUseContext;
14+
import net.minecraft.state.StateContainer;
15+
import net.minecraft.state.properties.BlockStateProperties;
16+
import net.minecraft.util.math.BlockPos;
17+
import net.minecraft.util.math.shapes.ISelectionContext;
18+
import net.minecraft.util.math.shapes.VoxelShape;
19+
import net.minecraft.util.math.shapes.VoxelShapes;
20+
import net.minecraft.world.IBlockReader;
21+
import net.minecraftforge.common.ToolType;
22+
23+
import javax.annotation.Nullable;
24+
25+
public class RodLamp extends LampBase implements IWaterLoggable {
26+
public RodLamp (String name) {
27+
super(name, Block.Properties.create(new Material(
28+
MaterialColor.WHITE_TERRACOTTA,
29+
false, //isLiquid
30+
false, //isSolid
31+
true, //Blocks Movement
32+
false, //isOpaque
33+
true, //requires no tool
34+
false, //isFlammable
35+
false, //isReplaceable
36+
PushReaction.NORMAL
37+
)).hardnessAndResistance(1.0f).harvestLevel(0).harvestTool(ToolType.PICKAXE));
38+
39+
40+
}
41+
42+
private VoxelShape UpDown = Block.makeCuboidShape(7,0,7, 9,16,9);
43+
private VoxelShape EastWest = Block.makeCuboidShape(0,7,7, 16,9,9);
44+
private VoxelShape NorthSouth = Block.makeCuboidShape(7,7,0, 9,9,16);
45+
46+
@Override
47+
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
48+
VoxelShape ret;
49+
switch (state.get(BlockStateProperties.AXIS)) {
50+
case X:
51+
ret = EastWest;
52+
break;
53+
case Y:
54+
ret = UpDown;
55+
break;
56+
default:
57+
ret = NorthSouth;
58+
break;
59+
}
60+
return ret;
61+
}
62+
63+
@Nullable
64+
@Override
65+
public BlockState getStateForPlacement(BlockItemUseContext p_196258_1_) {
66+
return getDefaultState().with(BlockStateProperties.AXIS, p_196258_1_.getFace().getAxis()).with(BlockStateProperties.WATERLOGGED, false);
67+
}
68+
69+
@Override
70+
public boolean canContainFluid(IBlockReader p_204510_1_, BlockPos p_204510_2_, BlockState p_204510_3_, Fluid p_204510_4_) {
71+
return true;
72+
}
73+
74+
@Override
75+
public IFluidState getFluidState(BlockState p_204507_1_) {
76+
return p_204507_1_.get(BlockStateProperties.WATERLOGGED)? Fluids.WATER.getStillFluidState(false) : super.getFluidState(p_204507_1_);
77+
}
78+
79+
@Override
80+
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> p_206840_1_) {
81+
p_206840_1_.add(BlockStateProperties.AXIS, BlockStateProperties.WATERLOGGED);
82+
}
83+
84+
@Override
85+
public int getLightValue(BlockState p_149750_1_) {
86+
return 15;
87+
}
88+
89+
}

src/main/java/com/flanks255/simplylight/simplylight.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public class simplylight
3232
public static final ThinLamp illuminantPanel = new ThinLamp("illuminant_panel",4);
3333
public static final WallLamp wallLamp = new WallLamp("wall_lamp");
3434
public static final LightBulb lightBulb = new LightBulb("lightbulb");
35+
public static final RodLamp rodLamp = new RodLamp("rodlamp");
3536

3637

3738
private static ItemGroup itemGroup = new ItemGroup(MODID) {
@@ -84,6 +85,7 @@ public static void onBlocksRegistry(final RegistryEvent.Register<Block> blockReg
8485
blockRegistry.register(simplylight.illuminantPanel);
8586
blockRegistry.register(simplylight.wallLamp);
8687
blockRegistry.register(simplylight.lightBulb);
88+
blockRegistry.register(simplylight.rodLamp);
8789
}
8890

8991
@SubscribeEvent
@@ -98,6 +100,7 @@ public static void onItemsRegistry(final RegistryEvent.Register<Item> itemRegist
98100
itemRegistry.register(new BaseBlockItem(simplylight.illuminantPanel, properties).setRegistryName("illuminant_panel"));
99101
itemRegistry.register(new BaseBlockItem(simplylight.wallLamp, properties).setRegistryName("wall_lamp"));
100102
itemRegistry.register(new BaseBlockItem(simplylight.lightBulb, properties).setRegistryName("lightbulb"));
103+
itemRegistry.register(new BaseBlockItem(simplylight.rodLamp, properties).setRegistryName("rodlamp"));
101104
}
102105
}
103106
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"variants": {
3+
"axis=y": { "model":"simplylight:block/rodlamp"},
4+
"axis=x": { "model":"simplylight:block/rodlamp", "x": 90, "y": 90 },
5+
"axis=z": { "model":"simplylight:block/rodlamp", "x": 90 }
6+
}
7+
}

src/main/resources/assets/simplylight/lang/en_us.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,10 @@
3232

3333
"block.simplylight.lightbulb": "Simple Light Bulb",
3434
"block.simplylight.lightbulb.info": "Just a simple light bulb,",
35-
"block.simplylight.lightbulb.info2": "place in any direction."
35+
"block.simplylight.lightbulb.info2": "place in any direction.",
36+
37+
"block.simplylight.rodlamp": "Illuminant Rod",
38+
"block.simplylight.rodlamp.info": "A simple rod of light.",
39+
"block.simplylight.rodlamp.info2": "Can be placed in any direction."
40+
3641
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"credit": "Made with Blockbench",
3+
"ambientocclusion": false,
4+
"textures": {
5+
"all": "simplylight:block/omni2",
6+
"particle": "simplylight:block/omni2"
7+
},
8+
"elements": [
9+
{
10+
"from": [7, 0, 7],
11+
"to": [9, 16, 9],
12+
"faces": {
13+
"north": {"uv": [0, 0, 2, 16], "texture": "#all"},
14+
"east": {"uv": [0, 0, 2, 16], "texture": "#all"},
15+
"south": {"uv": [0, 0, 2, 16], "texture": "#all"},
16+
"west": {"uv": [0, 0, 2, 16], "texture": "#all"},
17+
"up": {"uv": [2, 0, 4, 2], "texture": "#all"},
18+
"down": {"uv": [2, 0, 4, 2], "texture": "#all"}
19+
}
20+
}
21+
],
22+
"display": {
23+
"gui": {
24+
"rotation": [45, 45, 0]
25+
}
26+
}
27+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"parent": "simplylight:block/rodlamp"
3+
}
222 Bytes
Loading
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"type": "minecraft:crafting_shaped",
3+
"pattern":[
4+
"bab",
5+
"bab",
6+
"bab"
7+
],
8+
"key":{
9+
"a":{
10+
"tag":"forge:stone"
11+
},
12+
"b":{
13+
"tag":"forge:dusts/glowstone"
14+
}
15+
},
16+
"result":{
17+
"item":"simplylight:rodlamp",
18+
"count":8
19+
}
20+
}

0 commit comments

Comments
 (0)