Skip to content

Commit cd94e57

Browse files
committed
luminous fungus working
1 parent 4ad035e commit cd94e57

File tree

10 files changed

+71
-10
lines changed

10 files changed

+71
-10
lines changed

src/main/generated/assets/infernalexp/blockstates/luminous_fungus.json

-7
This file was deleted.

src/main/java/org/infernalstudios/infernalexp/block/ModBlocks.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import net.minecraft.data.client.Models;
77
import net.minecraft.registry.tag.BlockTags;
88
import org.infernalstudios.infernalexp.InfernalExpansion;
9+
import org.infernalstudios.infernalexp.block.custom.LuminousFungusBlock;
910
import org.infernalstudios.infernalexp.setup.ModRegistry;
1011

1112
public class ModBlocks {
@@ -68,6 +69,6 @@ public static void register() {
6869

6970

7071
public static final Block LUMINOUS_FUNGUS = ModRegistry.ofBlock("luminous_fungus",
71-
new PlantBlock(FabricBlockSettings.copyOf(Blocks.WARPED_FUNGUS).luminance(10)))
72-
.drop().model(ModRegistry.Models.CROSS).cutout().build();
72+
new LuminousFungusBlock(FabricBlockSettings.copyOf(Blocks.WARPED_FUNGUS).luminance(10).ticksRandomly()))
73+
.drop().cutout().build();
7374
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package org.infernalstudios.infernalexp.block.custom;
2+
3+
import net.minecraft.block.Block;
4+
import net.minecraft.block.BlockState;
5+
import net.minecraft.block.PlantBlock;
6+
import net.minecraft.entity.Entity;
7+
import net.minecraft.entity.LivingEntity;
8+
import net.minecraft.entity.effect.StatusEffectInstance;
9+
import net.minecraft.entity.effect.StatusEffects;
10+
import net.minecraft.server.world.ServerWorld;
11+
import net.minecraft.state.StateManager;
12+
import net.minecraft.state.property.BooleanProperty;
13+
import net.minecraft.util.math.BlockPos;
14+
import net.minecraft.util.math.Direction;
15+
import net.minecraft.util.math.random.Random;
16+
import net.minecraft.world.BlockView;
17+
import net.minecraft.world.World;
18+
19+
public class LuminousFungusBlock extends PlantBlock {
20+
public static final BooleanProperty IS_LIT = BooleanProperty.of("is_lit");
21+
22+
public LuminousFungusBlock(Settings settings) {
23+
super(settings);
24+
this.setDefaultState(this.getDefaultState().with(IS_LIT, false));
25+
}
26+
27+
@Override
28+
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
29+
builder.add(IS_LIT);
30+
}
31+
32+
@Override
33+
protected boolean canPlantOnTop(BlockState floor, BlockView world, BlockPos pos) {
34+
return floor.isSideSolidFullSquare(world, pos, Direction.UP);
35+
}
36+
37+
@Override
38+
public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) {
39+
super.onEntityCollision(state, world, pos, entity);
40+
if (!state.get(IS_LIT) && entity instanceof LivingEntity living) {
41+
living.addStatusEffect(new StatusEffectInstance(StatusEffects.GLOWING, 200, 0));
42+
world.setBlockState(pos, state.with(IS_LIT, true));
43+
}
44+
}
45+
46+
@Override
47+
public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
48+
super.randomTick(state, world, pos, random);
49+
if (state.get(IS_LIT)) world.setBlockState(pos, state.with(IS_LIT, false));
50+
}
51+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"variants": {
3+
"is_lit=true": {
4+
"model": "infernalexp:block/luminous_fungus_lit"
5+
},
6+
"is_lit=false": {
7+
"model": "infernalexp:block/luminous_fungus"
8+
}
9+
}
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"parent": "minecraft:block/cross",
3+
"textures": {
4+
"cross": "infernalexp:block/luminous_fungus_lit"
5+
}
6+
}
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"parent": "minecraft:item/generated",
33
"textures": {
4-
"layer0": "infernalexp:block/luminous_fungus"
4+
"layer0": "infernalexp:block/luminous_fungus_lit"
55
}
66
}
Loading
Binary file not shown.

0 commit comments

Comments
 (0)