Skip to content

Commit

Permalink
luminous fungus working
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyof429 committed Aug 19, 2024
1 parent 4ad035e commit cd94e57
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 10 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.minecraft.data.client.Models;
import net.minecraft.registry.tag.BlockTags;
import org.infernalstudios.infernalexp.InfernalExpansion;
import org.infernalstudios.infernalexp.block.custom.LuminousFungusBlock;
import org.infernalstudios.infernalexp.setup.ModRegistry;

public class ModBlocks {
Expand Down Expand Up @@ -68,6 +69,6 @@ public static void register() {


public static final Block LUMINOUS_FUNGUS = ModRegistry.ofBlock("luminous_fungus",
new PlantBlock(FabricBlockSettings.copyOf(Blocks.WARPED_FUNGUS).luminance(10)))
.drop().model(ModRegistry.Models.CROSS).cutout().build();
new LuminousFungusBlock(FabricBlockSettings.copyOf(Blocks.WARPED_FUNGUS).luminance(10).ticksRandomly()))
.drop().cutout().build();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package org.infernalstudios.infernalexp.block.custom;

import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.PlantBlock;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.random.Random;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;

public class LuminousFungusBlock extends PlantBlock {
public static final BooleanProperty IS_LIT = BooleanProperty.of("is_lit");

public LuminousFungusBlock(Settings settings) {
super(settings);
this.setDefaultState(this.getDefaultState().with(IS_LIT, false));
}

@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
builder.add(IS_LIT);
}

@Override
protected boolean canPlantOnTop(BlockState floor, BlockView world, BlockPos pos) {
return floor.isSideSolidFullSquare(world, pos, Direction.UP);
}

@Override
public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) {
super.onEntityCollision(state, world, pos, entity);
if (!state.get(IS_LIT) && entity instanceof LivingEntity living) {
living.addStatusEffect(new StatusEffectInstance(StatusEffects.GLOWING, 200, 0));
world.setBlockState(pos, state.with(IS_LIT, true));
}
}

@Override
public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
super.randomTick(state, world, pos, random);
if (state.get(IS_LIT)) world.setBlockState(pos, state.with(IS_LIT, false));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"variants": {
"is_lit=true": {
"model": "infernalexp:block/luminous_fungus_lit"
},
"is_lit=false": {
"model": "infernalexp:block/luminous_fungus"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:block/cross",
"textures": {
"cross": "infernalexp:block/luminous_fungus_lit"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "infernalexp:block/luminous_fungus"
"layer0": "infernalexp:block/luminous_fungus_lit"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.

0 comments on commit cd94e57

Please sign in to comment.