2023-05-25 20:02:08 +02:00
|
|
|
package com.minelittlepony.unicopia.block;
|
|
|
|
|
|
|
|
import net.minecraft.block.AbstractBlock;
|
2023-06-02 21:20:30 +02:00
|
|
|
import net.minecraft.block.BlockSetType;
|
2023-05-25 20:02:08 +02:00
|
|
|
import net.minecraft.block.BlockState;
|
|
|
|
import net.minecraft.block.ButtonBlock;
|
|
|
|
import net.minecraft.block.LeavesBlock;
|
|
|
|
import net.minecraft.block.MapColor;
|
|
|
|
import net.minecraft.block.PillarBlock;
|
2023-06-03 13:40:54 +02:00
|
|
|
import net.minecraft.block.enums.Instrument;
|
|
|
|
import net.minecraft.block.piston.PistonBehavior;
|
2023-05-25 20:02:08 +02:00
|
|
|
import net.minecraft.entity.EntityType;
|
|
|
|
import net.minecraft.sound.BlockSoundGroup;
|
|
|
|
import net.minecraft.util.math.BlockPos;
|
|
|
|
import net.minecraft.util.math.Direction;
|
|
|
|
import net.minecraft.world.BlockView;
|
|
|
|
|
|
|
|
interface BlockConstructionUtils {
|
|
|
|
static ButtonBlock woodenButton() {
|
2023-06-02 21:20:30 +02:00
|
|
|
return woodenButton(BlockSoundGroup.WOOD, BlockSetType.OAK);
|
2023-05-25 20:02:08 +02:00
|
|
|
}
|
|
|
|
|
2023-06-02 21:20:30 +02:00
|
|
|
static ButtonBlock woodenButton(BlockSoundGroup soundGroup, BlockSetType setType) {
|
2023-06-03 13:40:54 +02:00
|
|
|
return new ButtonBlock(AbstractBlock.Settings.create().noCollision().strength(0.5f).pistonBehavior(PistonBehavior.DESTROY).sounds(soundGroup), setType, 30, true);
|
2023-05-25 20:02:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static boolean never(BlockState state, BlockView world, BlockPos pos, EntityType<?> type) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static boolean never(BlockState state, BlockView world, BlockPos pos) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PillarBlock createLogBlock(MapColor topMapColor, MapColor sideMapColor) {
|
2023-06-03 13:40:54 +02:00
|
|
|
return new PillarBlock(AbstractBlock.Settings.create().mapColor(state -> state.get(PillarBlock.AXIS) == Direction.Axis.Y ? topMapColor : sideMapColor).instrument(Instrument.BASS).strength(2.0f).sounds(BlockSoundGroup.WOOD).burnable());
|
2023-05-25 20:02:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static PillarBlock createWoodBlock(MapColor mapColor) {
|
2023-06-03 13:40:54 +02:00
|
|
|
return new PillarBlock(AbstractBlock.Settings.create().mapColor(mapColor).instrument(Instrument.BASS).strength(2.0f).sounds(BlockSoundGroup.WOOD).burnable());
|
2023-05-25 20:02:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static LeavesBlock createLeavesBlock(BlockSoundGroup soundGroup) {
|
2023-06-03 13:40:54 +02:00
|
|
|
return new LeavesBlock(AbstractBlock.Settings.create().mapColor(MapColor.DARK_GREEN).strength(0.2f).ticksRandomly().sounds(soundGroup).nonOpaque().allowsSpawning(BlockConstructionUtils::canSpawnOnLeaves).suffocates(BlockConstructionUtils::never).blockVision(BlockConstructionUtils::never).burnable().pistonBehavior(PistonBehavior.DESTROY).solidBlock(BlockConstructionUtils::never));
|
2023-05-25 20:02:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static Boolean canSpawnOnLeaves(BlockState state, BlockView world, BlockPos pos, EntityType<?> type) {
|
|
|
|
return type == EntityType.OCELOT || type == EntityType.PARROT;
|
|
|
|
}
|
|
|
|
}
|