Skip to content

Commit

Permalink
Level 2 things
Browse files Browse the repository at this point in the history
  • Loading branch information
LudoCrypt committed Jul 18, 2020
1 parent f5121d7 commit b97fe9d
Show file tree
Hide file tree
Showing 230 changed files with 2,866 additions and 1,117 deletions.
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ dependencies {
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

modImplementation 'com.github.qouteall:ImmersivePortalsMod:v0.31-1.15'
modApi "me.sargunvohra.mcmods:autoconfig1u:2.1.0"
modImplementation "io.github.prospector:modmenu:1.10.2+build.35"
include(modImplementation('com.github.Chocohead:Fabric-ASM:v2.0.1'))
include "me.sargunvohra.mcmods:autoconfig1u:2.1.0"

modApi "me.sargunvohra.mcmods:autoconfig1u:2.2.0"
include "me.sargunvohra.mcmods:autoconfig1u:2.2.0"
modApi "me.shedaniel.cloth:config-2:2.14.2"
include "me.shedaniel.cloth:config-2:2.14.2"
}

processResources {
Expand Down
184 changes: 125 additions & 59 deletions src/main/java/net/ludocrypt/backrooms/Backrooms.java

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions src/main/java/net/ludocrypt/backrooms/BackroomsClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ public static RenderLayer getItemRenderLayer(Item item) {
@SuppressWarnings("unchecked")
private <E extends BlockEntity> void registerBlockEntityRenderer(String identifier,
Function<BlockEntityRenderDispatcher, BlockEntityRenderer<E>> blockEntityRenderer) {
BlockEntityRendererRegistry.INSTANCE.register(
(BlockEntityType<E>) Registry.BLOCK_ENTITY_TYPE.get(Backrooms.getId(identifier)),
blockEntityRenderer);
BlockEntityRendererRegistry.INSTANCE.register((BlockEntityType<E>) Registry.BLOCK_ENTITY_TYPE.get(Backrooms.getId(identifier)), blockEntityRenderer);
}

}
41 changes: 41 additions & 0 deletions src/main/java/net/ludocrypt/backrooms/biome/Level2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package net.ludocrypt.backrooms.biome;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.ludocrypt.backrooms.Backrooms;
import net.ludocrypt.backrooms.features.LevelsFeatureInit;
import net.ludocrypt.backrooms.features.decorators.Level2RoomDecorator;
import net.minecraft.block.BlockState;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.GenerationStep;
import net.minecraft.world.gen.decorator.Decorator;
import net.minecraft.world.gen.decorator.DecoratorConfig;
import net.minecraft.world.gen.decorator.NopeDecoratorConfig;
import net.minecraft.world.gen.feature.FeatureConfig;
import net.minecraft.world.gen.surfacebuilder.SurfaceBuilder;

public class Level2 extends Biome {
protected static final BlockState WALL = Backrooms.WALL.getDefaultState();
public static final Decorator<NopeDecoratorConfig> LEVEL2PLACER = new Level2RoomDecorator(NopeDecoratorConfig::deserialize);

public Level2() {

super(new Biome.Settings().configureSurfaceBuilder(SurfaceBuilder.NOPE, SurfaceBuilder.AIR_CONFIG)
.precipitation(Biome.Precipitation.NONE).category(Biome.Category.NONE).depth(0F).scale(0F)
.temperature(5.0F).downfall(0F).waterColor(69).waterFogColor(69).parent((String) null));

this.addFeature(GenerationStep.Feature.LOCAL_MODIFICATIONS,
LevelsFeatureInit.LEVEL2ROOM.configure(FeatureConfig.DEFAULT)
.createDecoratedFeature(LEVEL2PLACER.configure(DecoratorConfig.DEFAULT)));
}

@Environment(EnvType.CLIENT)
public int getGrassColorAt(double p_225528_1_, double p_225528_3_) {
return 226217111;
}

@Environment(EnvType.CLIENT)
public int getFoliageColor() {
return 226217111;
}
}
14 changes: 14 additions & 0 deletions src/main/java/net/ludocrypt/backrooms/blocks/Checkered_Block.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package net.ludocrypt.backrooms.blocks;

import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.block.Block;
import net.minecraft.block.Material;
import net.minecraft.sound.BlockSoundGroup;

public class Checkered_Block extends Block {
public Checkered_Block() {
super(FabricBlockSettings.of(Material.STONE).breakByTool(FabricToolTags.PICKAXES).sounds(BlockSoundGroup.STONE)
.hardness(6).resistance(6));
}
}
127 changes: 127 additions & 0 deletions src/main/java/net/ludocrypt/backrooms/blocks/Pipe.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
package net.ludocrypt.backrooms.blocks;

import java.util.Random;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.ludocrypt.backrooms.Backrooms;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.ConnectingBlock;
import net.minecraft.block.Material;
import net.minecraft.entity.EntityContext;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.Property;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.BlockView;
import net.minecraft.world.IWorld;
import net.minecraft.world.World;

public class Pipe extends Block {

public static final BooleanProperty UP = BooleanProperty.of("up");
public static final BooleanProperty DOWN = BooleanProperty.of("down");
public static final BooleanProperty EAST = BooleanProperty.of("east");
public static final BooleanProperty WEST = BooleanProperty.of("west");
public static final BooleanProperty NORTH = BooleanProperty.of("north");
public static final BooleanProperty SOUTH = BooleanProperty.of("south");
public static final VoxelShape MIDDLESHAPE = Block.createCuboidShape(4.0D, 4.0D, 4.0D, 12.0D, 12.0D, 12.0D);
public static final VoxelShape UPSHAPE = Block.createCuboidShape(4.0D, 12.0D, 4.0D, 12.0D, 16.0D, 12.0D);
public static final VoxelShape DOWNSHAPE = Block.createCuboidShape(4.0D, 0.0D, 4.0D, 12.0D, 4.0D, 12.0D);
public static final VoxelShape EASTSHAPE = Block.createCuboidShape(12.0D, 4.0D, 4.0D, 16.0D, 12.0D, 12.0D);
public static final VoxelShape WESTSHAPE = Block.createCuboidShape(0.0D, 4.0D, 4.0D, 4.0D, 12.0D, 12.0D);
public static final VoxelShape NORTHSHAPE = Block.createCuboidShape(4.0D, 4.0D, 0.0D, 12.0D, 12.0D, 4.0D);
public static final VoxelShape SOUTHSHAPE = Block.createCuboidShape(4.0D, 4.0D, 12.0D, 12.0D, 12.0D, 16.0D);

public Pipe() {
super(FabricBlockSettings.of(Material.STONE).breakByTool(FabricToolTags.PICKAXES).sounds(BlockSoundGroup.STONE)
.hardness(6).resistance(6).lightLevel(5));
setDefaultState(getStateManager().getDefaultState().with(UP, false).with(DOWN, false).with(EAST, false)
.with(WEST, false).with(NORTH, false).with(SOUTH, false));
}

@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) {
VoxelShape up = UPSHAPE;
VoxelShape down = DOWNSHAPE;
VoxelShape east = EASTSHAPE;
VoxelShape west = WESTSHAPE;
VoxelShape north = NORTHSHAPE;
VoxelShape south = SOUTHSHAPE;
if (!state.get(UP)) {
up = MIDDLESHAPE;
}
if (!state.get(DOWN)) {
down = MIDDLESHAPE;
}
if (!state.get(EAST)) {
east = MIDDLESHAPE;
}
if (!state.get(WEST)) {
west = MIDDLESHAPE;
}
if (!state.get(NORTH)) {
north = MIDDLESHAPE;
}
if (!state.get(SOUTH)) {
south = MIDDLESHAPE;
}
VoxelShape alltogether = VoxelShapes.union(up, down, east, west, north, south);
return alltogether;
}

@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
stateManager.add(UP, DOWN, EAST, WEST, NORTH, SOUTH);
}

@Override
@Environment(EnvType.CLIENT)
public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) {
super.randomDisplayTick(state, world, pos, random);
if (random.nextInt(2) == 0) {
world.addParticle(ParticleTypes.MYCELIUM, (double) pos.getX() + (double) random.nextFloat(),
(double) pos.getY() + (double) random.nextFloat(),
(double) pos.getZ() + (double) random.nextFloat(), 1.0D, -1.0D, 1.0D);
}
if (random.nextInt(10) == 0) {
world.addParticle(ParticleTypes.DRIPPING_WATER, (double) pos.getX() + (random.nextDouble() / 4) + 0.5,
(double) pos.getY() + 0.18, (double) pos.getZ() + (random.nextDouble() / 4) + 0.5, 0.0D, 0.0D, 0.0D);
}
}

public BlockState withConnectionProperties(BlockView view, BlockPos pos) {
Block block = view.getBlockState(pos.down()).getBlock();
Block block2 = view.getBlockState(pos.up()).getBlock();
Block block3 = view.getBlockState(pos.north()).getBlock();
Block block4 = view.getBlockState(pos.east()).getBlock();
Block block5 = view.getBlockState(pos.south()).getBlock();
Block block6 = view.getBlockState(pos.west()).getBlock();
return (BlockState) ((BlockState) ((BlockState) ((BlockState) ((BlockState) ((BlockState) this.getDefaultState()
.with(DOWN, block == Backrooms.PIPE)).with(UP, block2 == Backrooms.PIPE)).with(NORTH,
block3 == Backrooms.PIPE)).with(EAST, block4 == Backrooms.PIPE)).with(SOUTH,
block5 == Backrooms.PIPE)).with(WEST, block6 == Backrooms.PIPE);
}

@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
return this.withConnectionProperties(ctx.getWorld(), ctx.getBlockPos());
}

@Override
public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState,
IWorld world, BlockPos pos, BlockPos neighborPos) {
Block block = neighborState.getBlock();
boolean bl = block == Backrooms.PIPE;
return (BlockState) state.with((Property<Boolean>) ConnectingBlock.FACING_PROPERTIES.get(facing), bl);
}
}
80 changes: 0 additions & 80 deletions src/main/java/net/ludocrypt/backrooms/blocks/PortalDebug.java

This file was deleted.

19 changes: 0 additions & 19 deletions src/main/java/net/ludocrypt/backrooms/blocks/Tile.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,16 @@

import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.ludocrypt.backrooms.Backrooms;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.HorizontalFacingBlock;
import net.minecraft.block.Material;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.DirectionProperty;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;

public class Tile extends Block {
public static final DirectionProperty FACING = HorizontalFacingBlock.FACING;
Expand All @@ -35,18 +28,6 @@ protected void appendProperties(StateManager.Builder<Block, BlockState> stateMan
stateManager.add(FACING).add(SINGLE);
}

@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand,
BlockHitResult hit) {
if (player.isInSneakingPose()) {
world.setBlockState(pos,
Backrooms.TILE.getDefaultState().with(SINGLE, true).with(FACING, Direction.EAST));
return ActionResult.SUCCESS;
} else {
return ActionResult.PASS;
}
}

public BlockState getPlacementState(ItemPlacementContext ctx) {
if (ctx.getPlayerFacing() == Direction.EAST || ctx.getPlayerFacing() == Direction.WEST) {
return (BlockState) this.getDefaultState().with(FACING, Direction.EAST).with(SINGLE, true);
Expand Down
27 changes: 27 additions & 0 deletions src/main/java/net/ludocrypt/backrooms/blocks/TornWallpaper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package net.ludocrypt.backrooms.blocks;

import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Material;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.IntProperty;

public class TornWallpaper extends Block {

public static final IntProperty TORN_LEVEL = IntProperty.of("torn_level", 1, 4);

public TornWallpaper() {
super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).sounds(BlockSoundGroup.WOOD)
.hardness(2).resistance(2));
setDefaultState(getStateManager().getDefaultState().with(TORN_LEVEL, 1));
}

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

}
Loading

0 comments on commit b97fe9d

Please sign in to comment.