Start migration
This commit is contained in:
parent
6630ce0cab
commit
47ed597358
491 changed files with 12045 additions and 11953 deletions
|
@ -1,5 +1,5 @@
|
||||||
plugins {
|
plugins {
|
||||||
id 'fabric-loom' version '0.7-SNAPSHOT'
|
id 'fabric-loom' version '0.6-SNAPSHOT'
|
||||||
id 'maven-publish'
|
id 'maven-publish'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ apply plugin: 'maven'
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||||
mappings "net.fabricmc:yarn:${project.minecraft_version}+build.${project.yarn_mappings}:v2"
|
mappings minecraft.officialMojangMappings()
|
||||||
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
||||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,6 @@
|
||||||
# Dependencies
|
# Dependencies
|
||||||
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
|
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
|
||||||
patchouli_version = 50-FABRIC
|
patchouli_version = 50-FABRIC
|
||||||
fabric_version = 0.32.0+1.16
|
fabric_version = 0.32.5+1.16
|
||||||
canvas_version = 1.0.+
|
canvas_version = 1.0.+
|
||||||
rei_version = 5.8.10
|
rei_version = 5.8.10
|
|
@ -3,8 +3,8 @@ package ru.betterend;
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.ModInitializer;
|
import net.fabricmc.api.ModInitializer;
|
||||||
import net.fabricmc.loader.api.FabricLoader;
|
import net.fabricmc.loader.api.FabricLoader;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import ru.betterend.api.BetterEndPlugin;
|
import ru.betterend.api.BetterEndPlugin;
|
||||||
import ru.betterend.config.Configs;
|
import ru.betterend.config.Configs;
|
||||||
import ru.betterend.effects.EndEnchantments;
|
import ru.betterend.effects.EndEnchantments;
|
||||||
|
@ -39,6 +39,7 @@ import ru.betterend.world.surface.SurfaceBuilders;
|
||||||
public class BetterEnd implements ModInitializer {
|
public class BetterEnd implements ModInitializer {
|
||||||
public static final String MOD_ID = "betterend";
|
public static final String MOD_ID = "betterend";
|
||||||
public static final Logger LOGGER = Logger.get();
|
public static final Logger LOGGER = Logger.get();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInitialize() {
|
public void onInitialize() {
|
||||||
EndPortals.loadPortals();
|
EndPortals.loadPortals();
|
||||||
|
@ -71,12 +72,13 @@ public class BetterEnd implements ModInitializer {
|
||||||
GuideBookItem.register();
|
GuideBookItem.register();
|
||||||
}
|
}
|
||||||
|
|
||||||
FabricLoader.getInstance().getEntrypoints("betterend", BetterEndPlugin.class).forEach(BetterEndPlugin::register);
|
FabricLoader.getInstance().getEntrypoints("betterend", BetterEndPlugin.class)
|
||||||
|
.forEach(BetterEndPlugin::register);
|
||||||
Configs.saveConfigs();
|
Configs.saveConfigs();
|
||||||
|
|
||||||
if (hasGuideBook()) {
|
if (hasGuideBook()) {
|
||||||
PlayerAdvancementsEvents.PLAYER_ADVENCEMENT_COMPLETE.register((player, advancement, criterionName) -> {
|
PlayerAdvancementsEvents.PLAYER_ADVANCEMENT_COMPLETE.register((player, advancement, criterionName) -> {
|
||||||
Identifier advId = new Identifier("minecraft:end/enter_end_gateway");
|
ResourceLocation advId = new ResourceLocation("minecraft:end/enter_end_gateway");
|
||||||
if (advId.equals(advancement.getId())) {
|
if (advId.equals(advancement.getId())) {
|
||||||
player.giveItemStack(new ItemStack(GuideBookItem.GUIDE_BOOK));
|
player.giveItemStack(new ItemStack(GuideBookItem.GUIDE_BOOK));
|
||||||
}
|
}
|
||||||
|
@ -88,8 +90,8 @@ public class BetterEnd implements ModInitializer {
|
||||||
return FabricLoader.getInstance().isModLoaded("patchouli");
|
return FabricLoader.getInstance().isModLoaded("patchouli");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Identifier makeID(String path) {
|
public static ResourceLocation makeID(String path) {
|
||||||
return new Identifier(MOD_ID, path);
|
return new ResourceLocation(MOD_ID, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getStringId(String id) {
|
public static String getStringId(String id) {
|
||||||
|
|
|
@ -1,35 +1,35 @@
|
||||||
package ru.betterend.blocks;
|
package ru.betterend.blocks;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.state.StateManager;
|
import net.minecraft.world.level.block.state.StateDefinition;
|
||||||
import net.minecraft.state.property.IntProperty;
|
import net.minecraft.world.level.block.state.properties.IntegerProperty;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import ru.betterend.blocks.basis.EndAnvilBlock;
|
import ru.betterend.blocks.basis.EndAnvilBlock;
|
||||||
import ru.betterend.item.material.EndToolMaterial;
|
import ru.betterend.item.material.EndToolMaterial;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.patterns.Patterns;
|
||||||
import ru.betterend.registry.EndBlocks;
|
import ru.betterend.registry.EndBlocks;
|
||||||
|
|
||||||
public class AeterniumAnvil extends EndAnvilBlock {
|
public class AeterniumAnvil extends EndAnvilBlock {
|
||||||
private static final IntProperty DESTRUCTION = BlockProperties.DESTRUCTION_LONG;
|
private static final IntegerProperty DESTRUCTION = BlockProperties.DESTRUCTION_LONG;
|
||||||
|
|
||||||
public AeterniumAnvil() {
|
public AeterniumAnvil() {
|
||||||
super(EndBlocks.AETERNIUM_BLOCK.getDefaultMaterialColor(), EndToolMaterial.AETERNIUM.getMiningLevel());
|
super(EndBlocks.AETERNIUM_BLOCK.defaultMaterialColor(), EndToolMaterial.AETERNIUM.getLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
||||||
builder.add(DESTRUCTION);
|
builder.add(DESTRUCTION);
|
||||||
builder.add(FACING);
|
builder.add(FACING);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IntProperty getDestructionProperty() {
|
public IntegerProperty getDESTRUCTION() {
|
||||||
return DESTRUCTION;
|
return DESTRUCTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Identifier statePatternId() {
|
public ResourceLocation statePatternId() {
|
||||||
return Patterns.STATE_ANVIL_LONG;
|
return Patterns.STATE_ANVIL_LONG;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,26 +3,23 @@ package ru.betterend.blocks;
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.block.Material;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import net.minecraft.block.MaterialColor;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.sound.BlockSoundGroup;
|
import net.minecraft.world.level.material.Material;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.world.level.material.MaterialColor;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.level.block.SoundType;
|
||||||
import ru.betterend.blocks.basis.BlockBase;
|
import ru.betterend.blocks.basis.BlockBase;
|
||||||
|
|
||||||
public class AeterniumBlock extends BlockBase {
|
public class AeterniumBlock extends BlockBase {
|
||||||
|
|
||||||
public AeterniumBlock() {
|
public AeterniumBlock() {
|
||||||
super(FabricBlockSettings.of(Material.METAL, MaterialColor.GRAY)
|
super(FabricBlockSettings.of(Material.METAL, MaterialColor.COLOR_GRAY).hardness(65F).resistance(1200F)
|
||||||
.hardness(65F)
|
.requiresTool().sounds(SoundType.NETHERITE_BLOCK));
|
||||||
.resistance(1200F)
|
|
||||||
.requiresTool()
|
|
||||||
.sounds(BlockSoundGroup.NETHERITE));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public int getColor(BlockState state, BlockView world, BlockPos pos) {
|
public int getColor(BlockState state, BlockGetter world, BlockPos pos) {
|
||||||
return 0xFF657A7A;
|
return 0xFF657A7A;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,12 +2,12 @@ package ru.betterend.blocks;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||||
import net.minecraft.block.Material;
|
import net.minecraft.world.level.material.Material;
|
||||||
import net.minecraft.sound.BlockSoundGroup;
|
import net.minecraft.world.level.block.SoundType;
|
||||||
import ru.betterend.blocks.basis.BlockBase;
|
import ru.betterend.blocks.basis.BlockBase;
|
||||||
|
|
||||||
public class AmaranitaCapBlock extends BlockBase {
|
public class AmaranitaCapBlock extends BlockBase {
|
||||||
public AmaranitaCapBlock() {
|
public AmaranitaCapBlock() {
|
||||||
super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).sounds(BlockSoundGroup.WOOD));
|
super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).sounds(SoundType.WOOD));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,15 +2,15 @@ package ru.betterend.blocks;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||||
import net.minecraft.block.Material;
|
import net.minecraft.world.level.material.Material;
|
||||||
import net.minecraft.sound.BlockSoundGroup;
|
import net.minecraft.world.level.block.SoundType;
|
||||||
import ru.betterend.blocks.basis.BlockBase;
|
import ru.betterend.blocks.basis.BlockBase;
|
||||||
import ru.betterend.client.render.ERenderLayer;
|
import ru.betterend.client.render.ERenderLayer;
|
||||||
import ru.betterend.interfaces.IRenderTypeable;
|
import ru.betterend.interfaces.IRenderTypeable;
|
||||||
|
|
||||||
public class AmaranitaHymenophoreBlock extends BlockBase implements IRenderTypeable {
|
public class AmaranitaHymenophoreBlock extends BlockBase implements IRenderTypeable {
|
||||||
public AmaranitaHymenophoreBlock() {
|
public AmaranitaHymenophoreBlock() {
|
||||||
super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).sounds(BlockSoundGroup.WOOD));
|
super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).sounds(SoundType.WOOD));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package ru.betterend.blocks;
|
package ru.betterend.blocks;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.block.MaterialColor;
|
import net.minecraft.world.level.material.MaterialColor;
|
||||||
import ru.betterend.blocks.basis.EndPillarBlock;
|
import ru.betterend.blocks.basis.EndPillarBlock;
|
||||||
|
|
||||||
public class AmaranitaStemBlock extends EndPillarBlock {
|
public class AmaranitaStemBlock extends EndPillarBlock {
|
||||||
public AmaranitaStemBlock() {
|
public AmaranitaStemBlock() {
|
||||||
super(FabricBlockSettings.copyOf(Blocks.OAK_PLANKS).materialColor(MaterialColor.LIME));
|
super(FabricBlockSettings.copyOf(Blocks.OAK_PLANKS).materialColor(MaterialColor.COLOR_LIGHT_GREEN));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package ru.betterend.blocks;
|
package ru.betterend.blocks;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.block.MaterialColor;
|
import net.minecraft.world.level.material.MaterialColor;
|
||||||
import ru.betterend.blocks.basis.BlockBase;
|
import ru.betterend.blocks.basis.BlockBase;
|
||||||
|
|
||||||
public class AmberBlock extends BlockBase {
|
public class AmberBlock extends BlockBase {
|
||||||
public AmberBlock() {
|
public AmberBlock() {
|
||||||
super(FabricBlockSettings.copyOf(Blocks.DIAMOND_BLOCK).materialColor(MaterialColor.YELLOW));
|
super(FabricBlockSettings.copyOf(Blocks.DIAMOND_BLOCK).materialColor(MaterialColor.COLOR_YELLOW));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,11 +3,11 @@ package ru.betterend.blocks;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.server.world.ServerWorld;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import ru.betterend.blocks.basis.BlockBase;
|
import ru.betterend.blocks.basis.BlockBase;
|
||||||
import ru.betterend.registry.EndBlocks;
|
import ru.betterend.registry.EndBlocks;
|
||||||
import ru.betterend.registry.EndParticles;
|
import ru.betterend.registry.EndParticles;
|
||||||
|
@ -20,33 +20,33 @@ public class AncientEmeraldIceBlock extends BlockBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
|
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
|
||||||
Direction dir = BlocksHelper.randomDirection(random);
|
Direction dir = BlocksHelper.randomDirection(random);
|
||||||
|
|
||||||
if (random.nextBoolean()) {
|
if (random.nextBoolean()) {
|
||||||
int x = MHelper.randRange(-2, 2, random);
|
int x = MHelper.randRange(-2, 2, random);
|
||||||
int y = MHelper.randRange(-2, 2, random);
|
int y = MHelper.randRange(-2, 2, random);
|
||||||
int z = MHelper.randRange(-2, 2, random);
|
int z = MHelper.randRange(-2, 2, random);
|
||||||
BlockPos p = pos.add(x, y, z);
|
BlockPos p = pos.offset(x, y, z);
|
||||||
if (world.getBlockState(p).isOf(Blocks.WATER)) {
|
if (world.getBlockState(p).is(Blocks.WATER)) {
|
||||||
world.setBlockState(p, EndBlocks.EMERALD_ICE.getDefaultState());
|
world.setBlockAndUpdate(p, EndBlocks.EMERALD_ICE.defaultBlockState());
|
||||||
makeParticles(world, p, random);
|
makeParticles(world, p, random);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pos = pos.offset(dir);
|
pos = pos.relative(dir);
|
||||||
state = world.getBlockState(pos);
|
state = world.getBlockState(pos);
|
||||||
if (state.isOf(Blocks.WATER)) {
|
if (state.is(Blocks.WATER)) {
|
||||||
world.setBlockState(pos, EndBlocks.EMERALD_ICE.getDefaultState());
|
world.setBlockAndUpdate(pos, EndBlocks.EMERALD_ICE.defaultBlockState());
|
||||||
makeParticles(world, pos, random);
|
makeParticles(world, pos, random);
|
||||||
}
|
} else if (state.is(EndBlocks.EMERALD_ICE)) {
|
||||||
else if (state.isOf(EndBlocks.EMERALD_ICE)) {
|
world.setBlockAndUpdate(pos, EndBlocks.DENSE_EMERALD_ICE.defaultBlockState());
|
||||||
world.setBlockState(pos, EndBlocks.DENSE_EMERALD_ICE.getDefaultState());
|
|
||||||
makeParticles(world, pos, random);
|
makeParticles(world, pos, random);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void makeParticles(ServerWorld world, BlockPos pos, Random random) {
|
private void makeParticles(ServerLevel world, BlockPos pos, Random random) {
|
||||||
world.spawnParticles(EndParticles.SNOWFLAKE, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 20, 0.5, 0.5, 0.5, 0);
|
world.sendParticles(EndParticles.SNOWFLAKE, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 20, 0.5, 0.5,
|
||||||
|
0.5, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,19 +6,19 @@ import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||||
import net.minecraft.block.AbstractGlassBlock;
|
import net.minecraft.core.Vec3i;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.block.Material;
|
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||||
import net.minecraft.client.color.block.BlockColorProvider;
|
import net.minecraft.world.item.enchantment.Enchantments;
|
||||||
import net.minecraft.client.color.item.ItemColorProvider;
|
import net.minecraft.world.level.block.AbstractGlassBlock;
|
||||||
import net.minecraft.enchantment.EnchantmentHelper;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.enchantment.Enchantments;
|
import net.minecraft.world.level.material.Material;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.client.color.block.BlockColor;
|
||||||
import net.minecraft.loot.context.LootContext;
|
import net.minecraft.client.color.item.ItemColor;
|
||||||
import net.minecraft.loot.context.LootContextParameters;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.sound.BlockSoundGroup;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||||
import net.minecraft.util.math.Vec3i;
|
import net.minecraft.world.level.block.SoundType;
|
||||||
import ru.betterend.client.render.ERenderLayer;
|
import ru.betterend.client.render.ERenderLayer;
|
||||||
import ru.betterend.interfaces.IColorProvider;
|
import ru.betterend.interfaces.IColorProvider;
|
||||||
import ru.betterend.interfaces.IRenderTypeable;
|
import ru.betterend.interfaces.IRenderTypeable;
|
||||||
|
@ -31,18 +31,13 @@ public class AuroraCrystalBlock extends AbstractGlassBlock implements IRenderTyp
|
||||||
private static final int MAX_DROP = 4;
|
private static final int MAX_DROP = 4;
|
||||||
|
|
||||||
public AuroraCrystalBlock() {
|
public AuroraCrystalBlock() {
|
||||||
super(FabricBlockSettings.of(Material.GLASS)
|
super(FabricBlockSettings.of(Material.GLASS).breakByTool(FabricToolTags.PICKAXES)
|
||||||
.breakByTool(FabricToolTags.PICKAXES)
|
.suffocates((state, world, pos) -> false).hardness(1F).resistance(1F).sounds(SoundType.GLASS)
|
||||||
.suffocates((state, world, pos) -> { return false; })
|
.luminance(15).nonOpaque());
|
||||||
.hardness(1F)
|
|
||||||
.resistance(1F)
|
|
||||||
.sounds(BlockSoundGroup.GLASS)
|
|
||||||
.luminance(15)
|
|
||||||
.nonOpaque());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockColorProvider getProvider() {
|
public BlockColor getBlockProvider() {
|
||||||
return (state, world, pos, tintIndex) -> {
|
return (state, world, pos, tintIndex) -> {
|
||||||
long i = (long) pos.getX() + (long) pos.getY() + (long) pos.getZ();
|
long i = (long) pos.getX() + (long) pos.getY() + (long) pos.getZ();
|
||||||
double delta = i * 0.1;
|
double delta = i * 0.1;
|
||||||
|
@ -54,19 +49,17 @@ public class AuroraCrystalBlock extends AbstractGlassBlock implements IRenderTyp
|
||||||
Vec3i color1 = COLORS[index];
|
Vec3i color1 = COLORS[index];
|
||||||
Vec3i color2 = COLORS[index2];
|
Vec3i color2 = COLORS[index2];
|
||||||
|
|
||||||
int r = MHelper.floor(MathHelper.lerp(delta, color1.getX(), color2.getX()));
|
int r = MHelper.floor(Mth.lerp(delta, color1.getX(), color2.getX()));
|
||||||
int g = MHelper.floor(MathHelper.lerp(delta, color1.getY(), color2.getY()));
|
int g = MHelper.floor(Mth.lerp(delta, color1.getY(), color2.getY()));
|
||||||
int b = MHelper.floor(MathHelper.lerp(delta, color1.getZ(), color2.getZ()));
|
int b = MHelper.floor(Mth.lerp(delta, color1.getZ(), color2.getZ()));
|
||||||
|
|
||||||
return MHelper.color(r, g, b);
|
return MHelper.color(r, g, b);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemColorProvider getItemProvider() {
|
public ItemColor getItemProvider() {
|
||||||
return (stack, tintIndex) -> {
|
return (stack, tintIndex) -> MHelper.color(COLORS[3].getX(), COLORS[3].getY(), COLORS[3].getZ());
|
||||||
return MHelper.color(COLORS[3].getX(), COLORS[3].getY(), COLORS[3].getZ());
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -75,18 +68,18 @@ public class AuroraCrystalBlock extends AbstractGlassBlock implements IRenderTyp
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
ItemStack tool = builder.get(LootContextParameters.TOOL);
|
ItemStack tool = builder.getParameter(LootContextParams.TOOL);
|
||||||
if (tool != null && tool.isEffectiveOn(state)) {
|
if (tool != null && tool.isCorrectToolForDrops(state)) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
int enchant = EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, tool);
|
int enchant = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool);
|
||||||
if (enchant > 0) {
|
if (enchant > 0) {
|
||||||
return Lists.newArrayList(new ItemStack(this));
|
return Lists.newArrayList(new ItemStack(this));
|
||||||
}
|
}
|
||||||
enchant = EnchantmentHelper.getLevel(Enchantments.FORTUNE, tool);
|
enchant = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.BLOCK_FORTUNE, tool);
|
||||||
if (enchant > 0) {
|
if (enchant > 0) {
|
||||||
int min = MathHelper.clamp(MIN_DROP + enchant, MIN_DROP, MAX_DROP);
|
int min = Mth.clamp(MIN_DROP + enchant, MIN_DROP, MAX_DROP);
|
||||||
int max = MAX_DROP + (enchant / Enchantments.FORTUNE.getMaxLevel());
|
int max = MAX_DROP + (enchant / Enchantments.BLOCK_FORTUNE.getMaxLevel());
|
||||||
if (min == max) {
|
if (min == max) {
|
||||||
return Lists.newArrayList(new ItemStack(EndItems.CRYSTAL_SHARDS, max));
|
return Lists.newArrayList(new ItemStack(EndItems.CRYSTAL_SHARDS, max));
|
||||||
}
|
}
|
||||||
|
@ -100,11 +93,7 @@ public class AuroraCrystalBlock extends AbstractGlassBlock implements IRenderTyp
|
||||||
}
|
}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
COLORS = new Vec3i[] {
|
COLORS = new Vec3i[] { new Vec3i(247, 77, 161), new Vec3i(120, 184, 255), new Vec3i(120, 255, 168),
|
||||||
new Vec3i(247, 77, 161),
|
new Vec3i(243, 58, 255) };
|
||||||
new Vec3i(120, 184, 255),
|
|
||||||
new Vec3i(120, 255, 168),
|
|
||||||
new Vec3i(243, 58, 255)
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ package ru.betterend.blocks;
|
||||||
|
|
||||||
import net.minecraft.state.property.BooleanProperty;
|
import net.minecraft.state.property.BooleanProperty;
|
||||||
import net.minecraft.state.property.EnumProperty;
|
import net.minecraft.state.property.EnumProperty;
|
||||||
import net.minecraft.state.property.IntProperty;
|
import net.minecraft.world.level.block.state.properties.IntegerProperty;
|
||||||
import net.minecraft.util.StringIdentifiable;
|
import net.minecraft.util.StringIdentifiable;
|
||||||
import ru.betterend.registry.EndPortals;
|
import ru.betterend.registry.EndPortals;
|
||||||
|
|
||||||
|
@ -20,19 +20,17 @@ public class BlockProperties {
|
||||||
public static final BooleanProperty ACTIVE = BooleanProperty.of("active");
|
public static final BooleanProperty ACTIVE = BooleanProperty.of("active");
|
||||||
public static final BooleanProperty SMALL = BooleanProperty.of("small");
|
public static final BooleanProperty SMALL = BooleanProperty.of("small");
|
||||||
|
|
||||||
public static final IntProperty DESTRUCTION_LONG = IntProperty.of("destruction", 0, 8);
|
public static final IntegerProperty DESTRUCTION_LONG = IntegerProperty.of("destruction", 0, 8);
|
||||||
public static final IntProperty DESTRUCTION = IntProperty.of("destruction", 0, 2);
|
public static final IntegerProperty DESTRUCTION = IntegerProperty.of("destruction", 0, 2);
|
||||||
public static final IntProperty ROTATION = IntProperty.of("rotation", 0, 3);
|
public static final IntegerProperty ROTATION = IntegerProperty.of("rotation", 0, 3);
|
||||||
public static final IntProperty FULLNESS = IntProperty.of("fullness", 0, 3);
|
public static final IntegerProperty FULLNESS = IntegerProperty.of("fullness", 0, 3);
|
||||||
public static final IntProperty COLOR = IntProperty.of("color", 0, 7);
|
public static final IntegerProperty COLOR = IntegerProperty.of("color", 0, 7);
|
||||||
public static final IntProperty PORTAL = IntProperty.of("portal", 0, EndPortals.getCount());
|
public static final IntegerProperty PORTAL = IntegerProperty.of("portal", 0, EndPortals.getCount());
|
||||||
public static final IntProperty SIZE = IntProperty.of("size", 0, 7);
|
public static final IntegerProperty SIZE = IntegerProperty.of("size", 0, 7);
|
||||||
public static final IntProperty AGE = IntProperty.of("age", 0, 3);
|
public static final IntegerProperty AGE = IntegerProperty.of("age", 0, 3);
|
||||||
|
|
||||||
public static enum TripleShape implements StringIdentifiable {
|
public static enum TripleShape implements StringIdentifiable {
|
||||||
TOP("top"),
|
TOP("top"), MIDDLE("middle"), BOTTOM("bottom");
|
||||||
MIDDLE("middle"),
|
|
||||||
BOTTOM("bottom");
|
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
|
@ -52,11 +50,7 @@ public class BlockProperties {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static enum PedestalState implements StringIdentifiable {
|
public static enum PedestalState implements StringIdentifiable {
|
||||||
PEDESTAL_TOP("pedestal_top"),
|
PEDESTAL_TOP("pedestal_top"), COLUMN_TOP("column_top"), BOTTOM("bottom"), PILLAR("pillar"), COLUMN("column"),
|
||||||
COLUMN_TOP("column_top"),
|
|
||||||
BOTTOM("bottom"),
|
|
||||||
PILLAR("pillar"),
|
|
||||||
COLUMN("column"),
|
|
||||||
DEFAULT("default");
|
DEFAULT("default");
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
|
@ -77,12 +71,9 @@ public class BlockProperties {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static enum HydraluxShape implements StringIdentifiable {
|
public static enum HydraluxShape implements StringIdentifiable {
|
||||||
FLOWER_BIG_BOTTOM("flower_big_bottom", true),
|
FLOWER_BIG_BOTTOM("flower_big_bottom", true), FLOWER_BIG_TOP("flower_big_top", true),
|
||||||
FLOWER_BIG_TOP("flower_big_top", true),
|
FLOWER_SMALL_BOTTOM("flower_small_bottom", true), FLOWER_SMALL_TOP("flower_small_top", true),
|
||||||
FLOWER_SMALL_BOTTOM("flower_small_bottom", true),
|
VINE("vine", false), ROOTS("roots", false);
|
||||||
FLOWER_SMALL_TOP("flower_small_top", true),
|
|
||||||
VINE("vine", false),
|
|
||||||
ROOTS("roots", false);
|
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
private final boolean glow;
|
private final boolean glow;
|
||||||
|
@ -108,11 +99,7 @@ public class BlockProperties {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static enum PentaShape implements StringIdentifiable {
|
public static enum PentaShape implements StringIdentifiable {
|
||||||
BOTTOM("bottom"),
|
BOTTOM("bottom"), PRE_BOTTOM("pre_bottom"), MIDDLE("middle"), PRE_TOP("pre_top"), TOP("top");
|
||||||
PRE_BOTTOM("pre_bottom"),
|
|
||||||
MIDDLE("middle"),
|
|
||||||
PRE_TOP("pre_top"),
|
|
||||||
TOP("top");
|
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
|
@ -132,12 +119,8 @@ public class BlockProperties {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static enum LumecornShape implements StringIdentifiable {
|
public static enum LumecornShape implements StringIdentifiable {
|
||||||
LIGHT_TOP("light_top", 15),
|
LIGHT_TOP("light_top", 15), LIGHT_TOP_MIDDLE("light_top_middle", 15), LIGHT_MIDDLE("light_middle", 15),
|
||||||
LIGHT_TOP_MIDDLE("light_top_middle", 15),
|
LIGHT_BOTTOM("light_bottom", 15), MIDDLE("middle", 0), BOTTOM_BIG("bottom_big", 0),
|
||||||
LIGHT_MIDDLE("light_middle", 15),
|
|
||||||
LIGHT_BOTTOM("light_bottom", 15),
|
|
||||||
MIDDLE("middle", 0),
|
|
||||||
BOTTOM_BIG("bottom_big", 0),
|
|
||||||
BOTTOM_SMALL("bottom_small", 0);
|
BOTTOM_SMALL("bottom_small", 0);
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
|
@ -1,13 +1,10 @@
|
||||||
package ru.betterend.blocks;
|
package ru.betterend.blocks;
|
||||||
|
|
||||||
import net.minecraft.sound.BlockSoundGroup;
|
import net.minecraft.world.level.block.SoundType;
|
||||||
import net.minecraft.sound.SoundEvents;
|
import net.minecraft.sounds.SoundEvents;
|
||||||
|
|
||||||
public class BlockSounds {
|
public class BlockSounds {
|
||||||
public static final BlockSoundGroup TERRAIN_SOUND = new BlockSoundGroup(1.0F, 1.0F,
|
public static final SoundType TERRAIN_SOUND = new SoundType(1.0F, 1.0F, SoundEvents.BLOCK_STONE_BREAK,
|
||||||
SoundEvents.BLOCK_STONE_BREAK,
|
SoundEvents.BLOCK_WART_BLOCK_STEP, SoundEvents.BLOCK_STONE_PLACE, SoundEvents.BLOCK_STONE_HIT,
|
||||||
SoundEvents.BLOCK_WART_BLOCK_STEP,
|
|
||||||
SoundEvents.BLOCK_STONE_PLACE,
|
|
||||||
SoundEvents.BLOCK_STONE_HIT,
|
|
||||||
SoundEvents.BLOCK_STONE_FALL);
|
SoundEvents.BLOCK_STONE_FALL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package ru.betterend.blocks;
|
package ru.betterend.blocks;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.state.StateManager;
|
import net.minecraft.world.level.block.state.StateDefinition;
|
||||||
import net.minecraft.state.property.EnumProperty;
|
import net.minecraft.state.property.EnumProperty;
|
||||||
import ru.betterend.blocks.BlockProperties.TripleShape;
|
import ru.betterend.blocks.BlockProperties.TripleShape;
|
||||||
import ru.betterend.blocks.basis.UpDownPlantBlock;
|
import ru.betterend.blocks.basis.UpDownPlantBlock;
|
||||||
|
@ -12,7 +12,7 @@ public class BlueVineBlock extends UpDownPlantBlock {
|
||||||
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
|
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
|
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
|
||||||
stateManager.add(SHAPE);
|
stateManager.add(SHAPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,16 +2,16 @@ package ru.betterend.blocks;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.block.Material;
|
import net.minecraft.world.level.material.Material;
|
||||||
import net.minecraft.sound.BlockSoundGroup;
|
import net.minecraft.world.level.block.SoundType;
|
||||||
import net.minecraft.state.StateManager;
|
import net.minecraft.world.level.block.state.StateDefinition;
|
||||||
import net.minecraft.state.property.BooleanProperty;
|
import net.minecraft.state.property.BooleanProperty;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.world.WorldAccess;
|
import net.minecraft.world.level.LevelAccessor;
|
||||||
import net.minecraft.world.WorldView;
|
import net.minecraft.world.WorldView;
|
||||||
import ru.betterend.blocks.basis.BlockBase;
|
import ru.betterend.blocks.basis.BlockBase;
|
||||||
import ru.betterend.registry.EndBlocks;
|
import ru.betterend.registry.EndBlocks;
|
||||||
|
@ -20,27 +20,28 @@ public class BlueVineLanternBlock extends BlockBase {
|
||||||
public static final BooleanProperty NATURAL = BlockProperties.NATURAL;
|
public static final BooleanProperty NATURAL = BlockProperties.NATURAL;
|
||||||
|
|
||||||
public BlueVineLanternBlock() {
|
public BlueVineLanternBlock() {
|
||||||
super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).sounds(BlockSoundGroup.WART_BLOCK).luminance(15));
|
super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).sounds(SoundType.WART_BLOCK)
|
||||||
this.setDefaultState(this.stateManager.getDefaultState().with(NATURAL, false));
|
.luminance(15));
|
||||||
|
this.setDefaultState(this.stateManager.defaultBlockState().with(NATURAL, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
||||||
return state.get(NATURAL) ? world.getBlockState(pos.down()).getBlock() == EndBlocks.BLUE_VINE : true;
|
return state.getValue(NATURAL) ? world.getBlockState(pos.below()).getBlock() == EndBlocks.BLUE_VINE : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
|
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world,
|
||||||
|
BlockPos pos, BlockPos neighborPos) {
|
||||||
if (!canPlaceAt(state, world, pos)) {
|
if (!canPlaceAt(state, world, pos)) {
|
||||||
return Blocks.AIR.getDefaultState();
|
return Blocks.AIR.defaultBlockState();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
|
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
|
||||||
stateManager.add(NATURAL);
|
stateManager.add(NATURAL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,10 @@ package ru.betterend.blocks;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import net.minecraft.block.AbstractBlock;
|
import net.minecraft.world.level.block.AbstractBlock;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.world.StructureWorldAccess;
|
import net.minecraft.world.StructureWorldAccess;
|
||||||
import ru.betterend.blocks.BlockProperties.TripleShape;
|
import ru.betterend.blocks.BlockProperties.TripleShape;
|
||||||
import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
|
import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
|
||||||
|
@ -22,30 +22,36 @@ public class BlueVineSeedBlock extends EndPlantWithAgeBlock {
|
||||||
if (h < height + 1) {
|
if (h < height + 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.BLUE_VINE.getDefaultState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM));
|
BlocksHelper.setWithoutUpdate(world, pos,
|
||||||
|
EndBlocks.BLUE_VINE.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM));
|
||||||
for (int i = 1; i < height; i++) {
|
for (int i = 1; i < height; i++) {
|
||||||
BlocksHelper.setWithoutUpdate(world, pos.up(i), EndBlocks.BLUE_VINE.getDefaultState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE));
|
BlocksHelper.setWithoutUpdate(world, pos.up(i),
|
||||||
|
EndBlocks.BLUE_VINE.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE));
|
||||||
}
|
}
|
||||||
BlocksHelper.setWithoutUpdate(world, pos.up(height), EndBlocks.BLUE_VINE.getDefaultState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP));
|
BlocksHelper.setWithoutUpdate(world, pos.up(height),
|
||||||
|
EndBlocks.BLUE_VINE.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP));
|
||||||
placeLantern(world, pos.up(height + 1));
|
placeLantern(world, pos.up(height + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void placeLantern(StructureWorldAccess world, BlockPos pos) {
|
private void placeLantern(StructureWorldAccess world, BlockPos pos) {
|
||||||
BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.BLUE_VINE_LANTERN.getDefaultState().with(BlueVineLanternBlock.NATURAL, true));
|
BlocksHelper.setWithoutUpdate(world, pos,
|
||||||
for (Direction dir: BlocksHelper.HORIZONTAL) {
|
EndBlocks.BLUE_VINE_LANTERN.defaultBlockState().with(BlueVineLanternBlock.NATURAL, true));
|
||||||
BlockPos p = pos.offset(dir);
|
for (Direction dir : BlocksHelper.HORIZONTAL) {
|
||||||
|
BlockPos p = pos.relative(dir);
|
||||||
if (world.isAir(p)) {
|
if (world.isAir(p)) {
|
||||||
BlocksHelper.setWithoutUpdate(world, p, EndBlocks.BLUE_VINE_FUR.getDefaultState().with(FurBlock.FACING, dir));
|
BlocksHelper.setWithoutUpdate(world, p,
|
||||||
|
EndBlocks.BLUE_VINE_FUR.defaultBlockState().with(FurBlock.FACING, dir));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (world.isAir(pos.up())) {
|
if (world.isAir(pos.up())) {
|
||||||
BlocksHelper.setWithoutUpdate(world, pos.up(), EndBlocks.BLUE_VINE_FUR.getDefaultState().with(FurBlock.FACING, Direction.UP));
|
BlocksHelper.setWithoutUpdate(world, pos.up(),
|
||||||
|
EndBlocks.BLUE_VINE_FUR.defaultBlockState().with(FurBlock.FACING, Direction.UP));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isTerrain(BlockState state) {
|
protected boolean isTerrain(BlockState state) {
|
||||||
return state.isOf(EndBlocks.END_MOSS) || state.isOf(EndBlocks.END_MYCELIUM);
|
return state.is(EndBlocks.END_MOSS) || state.is(EndBlocks.END_MYCELIUM);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -5,16 +5,16 @@ import java.util.Random;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import net.minecraft.block.AbstractBlock;
|
import net.minecraft.world.level.block.AbstractBlock;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.block.ShapeContext;
|
import net.minecraft.world.level.block.ShapeContext;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.loot.context.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.shape.VoxelShape;
|
import net.minecraft.util.shape.VoxelShape;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.level.Level;
|
||||||
import ru.betterend.blocks.basis.EndPlantBlock;
|
import ru.betterend.blocks.basis.EndPlantBlock;
|
||||||
import ru.betterend.registry.EndBlocks;
|
import ru.betterend.registry.EndBlocks;
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ public class BoluxMushroomBlock extends EndPlantBlock {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isTerrain(BlockState state) {
|
protected boolean isTerrain(BlockState state) {
|
||||||
return state.isOf(EndBlocks.RUTISCUS);
|
return state.is(EndBlocks.RUTISCUS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -46,12 +46,12 @@ public class BoluxMushroomBlock extends EndPlantBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) {
|
public boolean canGrow(Level world, Random random, BlockPos pos, BlockState state) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
return Lists.newArrayList(new ItemStack(this));
|
return Lists.newArrayList(new ItemStack(this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,21 +5,21 @@ import java.util.Random;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.block.MaterialColor;
|
import net.minecraft.world.level.material.MaterialColor;
|
||||||
import net.minecraft.client.world.ClientWorld;
|
import net.minecraft.client.multiplayer.ClientLevel;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraft.fluid.Fluids;
|
import net.minecraft.fluid.Fluids;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.server.world.ServerWorld;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.state.StateManager;
|
import net.minecraft.world.level.block.state.StateDefinition;
|
||||||
import net.minecraft.state.property.BooleanProperty;
|
import net.minecraft.state.property.BooleanProperty;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.WorldAccess;
|
import net.minecraft.world.level.LevelAccessor;
|
||||||
import ru.betterend.blocks.basis.BlockBase;
|
import ru.betterend.blocks.basis.BlockBase;
|
||||||
import ru.betterend.registry.EndBlocks;
|
import ru.betterend.registry.EndBlocks;
|
||||||
import ru.betterend.util.BlocksHelper;
|
import ru.betterend.util.BlocksHelper;
|
||||||
|
@ -28,29 +28,30 @@ public class BrimstoneBlock extends BlockBase {
|
||||||
public static final BooleanProperty ACTIVATED = BlockProperties.ACTIVE;
|
public static final BooleanProperty ACTIVATED = BlockProperties.ACTIVE;
|
||||||
|
|
||||||
public BrimstoneBlock() {
|
public BrimstoneBlock() {
|
||||||
super(FabricBlockSettings.copyOf(Blocks.END_STONE).materialColor(MaterialColor.BROWN).ticksRandomly());
|
super(FabricBlockSettings.copyOf(Blocks.END_STONE).materialColor(MaterialColor.COLOR_BROWN).ticksRandomly());
|
||||||
setDefaultState(stateManager.getDefaultState().with(ACTIVATED, false));
|
setDefaultState(stateManager.defaultBlockState().with(ACTIVATED, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
|
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
|
||||||
stateManager.add(ACTIVATED);
|
stateManager.add(ACTIVATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlaced(World world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack itemStack) {
|
public void onPlaced(Level world, BlockPos pos, BlockState state, @Nullable LivingEntity placer,
|
||||||
if (world.isClient()) {
|
ItemStack itemStack) {
|
||||||
updateChunks((ClientWorld) world, pos);
|
if (world.isClientSide()) {
|
||||||
|
updateChunks((ClientLevel) world, pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onBroken(WorldAccess world, BlockPos pos, BlockState state) {
|
public void onBroken(LevelAccessor world, BlockPos pos, BlockState state) {
|
||||||
if (world.isClient()) {
|
if (world.isClientSide()) {
|
||||||
updateChunks((ClientWorld) world, pos);
|
updateChunks((ClientLevel) world, pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateChunks(ClientWorld world, BlockPos pos) {
|
private void updateChunks(ClientLevel world, BlockPos pos) {
|
||||||
int y = pos.getY() >> 4;
|
int y = pos.getY() >> 4;
|
||||||
int x1 = (pos.getX() - 2) >> 4;
|
int x1 = (pos.getX() - 2) >> 4;
|
||||||
int z1 = (pos.getZ() - 2) >> 4;
|
int z1 = (pos.getZ() - 2) >> 4;
|
||||||
|
@ -64,39 +65,35 @@ public class BrimstoneBlock extends BlockBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
|
public void scheduledTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
|
||||||
boolean deactivate = true;
|
boolean deactivate = true;
|
||||||
for (Direction dir: BlocksHelper.DIRECTIONS) {
|
for (Direction dir : BlocksHelper.DIRECTIONS) {
|
||||||
if (world.getFluidState(pos.offset(dir)).getFluid().equals(Fluids.WATER)) {
|
if (world.getFluidState(pos.relative(dir)).getFluid().equals(Fluids.WATER)) {
|
||||||
deactivate = false;
|
deactivate = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (state.get(ACTIVATED)) {
|
if (state.getValue(ACTIVATED)) {
|
||||||
if (deactivate) {
|
if (deactivate) {
|
||||||
world.setBlockState(pos, getDefaultState().with(ACTIVATED, false));
|
world.setBlockAndUpdate(pos, getDefaultState().with(ACTIVATED, false));
|
||||||
}
|
} else if (state.getValue(ACTIVATED) && random.nextInt(16) == 0) {
|
||||||
else if (state.get(ACTIVATED) && random.nextInt(16) == 0) {
|
|
||||||
Direction dir = BlocksHelper.randomDirection(random);
|
Direction dir = BlocksHelper.randomDirection(random);
|
||||||
BlockPos side = pos.offset(dir);
|
BlockPos side = pos.relative(dir);
|
||||||
BlockState sideState = world.getBlockState(side);
|
BlockState sideState = world.getBlockState(side);
|
||||||
if (sideState.getBlock() instanceof SulphurCrystalBlock) {
|
if (sideState.getBlock() instanceof SulphurCrystalBlock) {
|
||||||
if (sideState.get(SulphurCrystalBlock.AGE) < 2 && sideState.get(SulphurCrystalBlock.WATERLOGGED)) {
|
if (sideState.get(SulphurCrystalBlock.AGE) < 2 && sideState.get(SulphurCrystalBlock.WATERLOGGED)) {
|
||||||
int age = sideState.get(SulphurCrystalBlock.AGE) + 1;
|
int age = sideState.get(SulphurCrystalBlock.AGE) + 1;
|
||||||
world.setBlockState(side, sideState.with(SulphurCrystalBlock.AGE, age));
|
world.setBlockAndUpdate(side, sideState.with(SulphurCrystalBlock.AGE, age));
|
||||||
}
|
}
|
||||||
}
|
} else if (sideState.getFluidState().getFluid() == Fluids.WATER) {
|
||||||
else if (sideState.getFluidState().getFluid() == Fluids.WATER) {
|
BlockState crystal = EndBlocks.SULPHUR_CRYSTAL.defaultBlockState()
|
||||||
BlockState crystal = EndBlocks.SULPHUR_CRYSTAL.getDefaultState()
|
.with(SulphurCrystalBlock.FACING, dir).with(SulphurCrystalBlock.WATERLOGGED, true)
|
||||||
.with(SulphurCrystalBlock.FACING, dir)
|
|
||||||
.with(SulphurCrystalBlock.WATERLOGGED, true)
|
|
||||||
.with(SulphurCrystalBlock.AGE, 0);
|
.with(SulphurCrystalBlock.AGE, 0);
|
||||||
world.setBlockState(side, crystal);
|
world.setBlockAndUpdate(side, crystal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if (!deactivate && !state.getValue(ACTIVATED)) {
|
||||||
else if (!deactivate && !state.get(ACTIVATED)) {
|
world.setBlockAndUpdate(pos, getDefaultState().with(ACTIVATED, true));
|
||||||
world.setBlockState(pos, getDefaultState().with(ACTIVATED, true));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,28 +6,25 @@ import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||||
import net.minecraft.block.AbstractBlock;
|
import net.minecraft.world.level.block.AbstractBlock;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.block.Material;
|
import net.minecraft.world.level.material.Material;
|
||||||
import net.minecraft.block.ShapeContext;
|
import net.minecraft.world.level.block.ShapeContext;
|
||||||
import net.minecraft.particle.ParticleTypes;
|
import net.minecraft.core.particles.ParticleTypes;
|
||||||
import net.minecraft.sound.BlockSoundGroup;
|
import net.minecraft.world.level.block.SoundType;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.shape.VoxelShape;
|
import net.minecraft.util.shape.VoxelShape;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.level.Level;
|
||||||
import ru.betterend.blocks.basis.UnderwaterPlantBlock;
|
import ru.betterend.blocks.basis.UnderwaterPlantBlock;
|
||||||
|
|
||||||
public class BubbleCoralBlock extends UnderwaterPlantBlock {
|
public class BubbleCoralBlock extends UnderwaterPlantBlock {
|
||||||
private static final VoxelShape SHAPE = Block.createCuboidShape(0, 0, 0, 16, 14, 16);
|
private static final VoxelShape SHAPE = Block.createCuboidShape(0, 0, 0, 16, 14, 16);
|
||||||
|
|
||||||
public BubbleCoralBlock() {
|
public BubbleCoralBlock() {
|
||||||
super(FabricBlockSettings.of(Material.UNDERWATER_PLANT)
|
super(FabricBlockSettings.of(Material.UNDERWATER_PLANT).breakByTool(FabricToolTags.SHEARS)
|
||||||
.breakByTool(FabricToolTags.SHEARS)
|
.sounds(SoundType.CORAL).breakByHand(true).noCollision());
|
||||||
.sounds(BlockSoundGroup.CORAL)
|
|
||||||
.breakByHand(true)
|
|
||||||
.noCollision());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -36,7 +33,7 @@ public class BubbleCoralBlock extends UnderwaterPlantBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) {
|
public void animateTick(BlockState state, Level world, BlockPos pos, Random random) {
|
||||||
double x = pos.getX() + random.nextDouble();
|
double x = pos.getX() + random.nextDouble();
|
||||||
double y = pos.getY() + random.nextDouble() * 0.5F + 0.5F;
|
double y = pos.getY() + random.nextDouble() * 0.5F + 0.5F;
|
||||||
double z = pos.getZ() + random.nextDouble();
|
double z = pos.getZ() + random.nextDouble();
|
||||||
|
@ -54,7 +51,7 @@ public class BubbleCoralBlock extends UnderwaterPlantBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) {
|
public boolean canGrow(Level world, Random random, BlockPos pos, BlockState state) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,11 +4,11 @@ import java.util.List;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.loot.context.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import net.minecraft.world.WorldView;
|
import net.minecraft.world.WorldView;
|
||||||
import ru.betterend.blocks.BlockProperties.TripleShape;
|
import ru.betterend.blocks.BlockProperties.TripleShape;
|
||||||
import ru.betterend.blocks.basis.VineBlock;
|
import ru.betterend.blocks.basis.VineBlock;
|
||||||
|
@ -22,14 +22,12 @@ public class BulbVineBlock extends VineBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
if (state.get(SHAPE) == TripleShape.BOTTOM) {
|
if (state.getValue(SHAPE) == TripleShape.BOTTOM) {
|
||||||
return Lists.newArrayList(new ItemStack(EndItems.GLOWING_BULB));
|
return Lists.newArrayList(new ItemStack(EndItems.GLOWING_BULB));
|
||||||
}
|
} else if (MHelper.RANDOM.nextInt(8) == 0) {
|
||||||
else if (MHelper.RANDOM.nextInt(8) == 0) {
|
|
||||||
return Lists.newArrayList(new ItemStack(EndBlocks.BULB_VINE_SEED));
|
return Lists.newArrayList(new ItemStack(EndBlocks.BULB_VINE_SEED));
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return Lists.newArrayList();
|
return Lists.newArrayList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,6 +40,7 @@ public class BulbVineBlock extends VineBlock {
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
||||||
boolean canPlace = super.canPlaceAt(state, world, pos);
|
boolean canPlace = super.canPlaceAt(state, world, pos);
|
||||||
return (state.isOf(this) && state.get(SHAPE) == TripleShape.BOTTOM) ? canPlace : canPlace && world.getBlockState(pos.down()).isOf(this);
|
return (state.is(this) && state.getValue(SHAPE) == TripleShape.BOTTOM) ? canPlace
|
||||||
|
: canPlace && world.getBlockState(pos.below()).is(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,17 +7,17 @@ import com.google.common.collect.Maps;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.block.Material;
|
import net.minecraft.world.level.material.Material;
|
||||||
import net.minecraft.block.MaterialColor;
|
import net.minecraft.world.level.material.MaterialColor;
|
||||||
import net.minecraft.block.ShapeContext;
|
import net.minecraft.world.level.block.ShapeContext;
|
||||||
import net.minecraft.sound.BlockSoundGroup;
|
import net.minecraft.world.level.block.SoundType;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.util.shape.VoxelShape;
|
import net.minecraft.util.shape.VoxelShape;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import ru.betterend.blocks.basis.EndLanternBlock;
|
import ru.betterend.blocks.basis.EndLanternBlock;
|
||||||
import ru.betterend.client.render.ERenderLayer;
|
import ru.betterend.client.render.ERenderLayer;
|
||||||
import ru.betterend.interfaces.IRenderTypeable;
|
import ru.betterend.interfaces.IRenderTypeable;
|
||||||
|
@ -29,13 +29,8 @@ public class BulbVineLanternBlock extends EndLanternBlock implements IRenderType
|
||||||
private static final VoxelShape SHAPE_FLOOR = Block.createCuboidShape(4, 0, 4, 12, 12, 12);
|
private static final VoxelShape SHAPE_FLOOR = Block.createCuboidShape(4, 0, 4, 12, 12, 12);
|
||||||
|
|
||||||
public BulbVineLanternBlock() {
|
public BulbVineLanternBlock() {
|
||||||
this(FabricBlockSettings.of(Material.METAL)
|
this(FabricBlockSettings.of(Material.METAL).sounds(SoundType.LANTERN).hardness(1).resistance(1)
|
||||||
.sounds(BlockSoundGroup.LANTERN)
|
.breakByTool(FabricToolTags.PICKAXES).materialColor(MaterialColor.LIGHT_GRAY).requiresTool()
|
||||||
.hardness(1)
|
|
||||||
.resistance(1)
|
|
||||||
.breakByTool(FabricToolTags.PICKAXES)
|
|
||||||
.materialColor(MaterialColor.LIGHT_GRAY)
|
|
||||||
.requiresTool()
|
|
||||||
.luminance(15));
|
.luminance(15));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +40,7 @@ public class BulbVineLanternBlock extends EndLanternBlock implements IRenderType
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
|
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
|
||||||
return state.get(IS_FLOOR) ? SHAPE_FLOOR : SHAPE_CEIL;
|
return state.getValue(IS_FLOOR) ? SHAPE_FLOOR : SHAPE_CEIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -55,25 +50,24 @@ public class BulbVineLanternBlock extends EndLanternBlock implements IRenderType
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStatesPattern(Reader data) {
|
public String getStatesPattern(Reader data) {
|
||||||
Identifier blockId = Registry.BLOCK.getId(this);
|
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||||
return Patterns.createJson(data, blockId.getPath(), blockId.getPath());
|
return Patterns.createJson(data, blockId.getPath(), blockId.getPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String block) {
|
public String getModelPattern(String block) {
|
||||||
Identifier blockId = Registry.BLOCK.getId(this);
|
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||||
Map<String, String> map = Maps.newHashMap();
|
Map<String, String> map = Maps.newHashMap();
|
||||||
map.put("%glow%", getGlowTexture());
|
map.put("%glow%", getGlowTexture());
|
||||||
map.put("%metal%", getMetalTexture(blockId));
|
map.put("%metal%", getMetalTexture(blockId));
|
||||||
if (block.contains("item") || block.contains("ceil")) {
|
if (block.contains("item") || block.contains("ceil")) {
|
||||||
return Patterns.createJson(Patterns.BLOCK_BULB_LANTERN_CEIL, map);
|
return Patterns.createJson(Patterns.BLOCK_BULB_LANTERN_CEIL, map);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return Patterns.createJson(Patterns.BLOCK_BULB_LANTERN_FLOOR, map);
|
return Patterns.createJson(Patterns.BLOCK_BULB_LANTERN_FLOOR, map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getMetalTexture(Identifier blockId) {
|
protected String getMetalTexture(ResourceLocation blockId) {
|
||||||
String name = blockId.getPath();
|
String name = blockId.getPath();
|
||||||
name = name.substring(0, name.indexOf('_'));
|
name = name.substring(0, name.indexOf('_'));
|
||||||
return name + "_bulb_vine_lantern_metal";
|
return name + "_bulb_vine_lantern_metal";
|
||||||
|
@ -84,7 +78,7 @@ public class BulbVineLanternBlock extends EndLanternBlock implements IRenderType
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Identifier statePatternId() {
|
public ResourceLocation statePatternId() {
|
||||||
return Patterns.STATE_BULB_LANTERN;
|
return Patterns.STATE_BULB_LANTERN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package ru.betterend.blocks;
|
package ru.betterend.blocks;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.minecraft.client.color.block.BlockColorProvider;
|
import net.minecraft.client.color.block.BlockColor;
|
||||||
import net.minecraft.client.color.item.ItemColorProvider;
|
import net.minecraft.client.color.item.ItemColor;
|
||||||
import ru.betterend.interfaces.IColorProvider;
|
import ru.betterend.interfaces.IColorProvider;
|
||||||
import ru.betterend.util.BlocksHelper;
|
import ru.betterend.util.BlocksHelper;
|
||||||
import ru.betterend.util.MHelper;
|
import ru.betterend.util.MHelper;
|
||||||
|
@ -13,14 +13,14 @@ public class BulbVineLanternColoredBlock extends BulbVineLanternBlock implements
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockColorProvider getProvider() {
|
public BlockColor getBlockProvider() {
|
||||||
return (state, world, pos, tintIndex) -> {
|
return (state, world, pos, tintIndex) -> {
|
||||||
return getColor();
|
return getColor();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemColorProvider getItemProvider() {
|
public ItemColor getItemProvider() {
|
||||||
return (stack, tintIndex) -> {
|
return (stack, tintIndex) -> {
|
||||||
return getColor();
|
return getColor();
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,9 +2,9 @@ package ru.betterend.blocks;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.tag.BlockTags;
|
import net.minecraft.tags.BlockTags;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.StructureWorldAccess;
|
import net.minecraft.world.StructureWorldAccess;
|
||||||
import net.minecraft.world.WorldView;
|
import net.minecraft.world.WorldView;
|
||||||
import ru.betterend.blocks.BlockProperties.TripleShape;
|
import ru.betterend.blocks.BlockProperties.TripleShape;
|
||||||
|
@ -24,11 +24,14 @@ public class BulbVineSeedBlock extends EndPlantWithAgeBlock {
|
||||||
public void growAdult(StructureWorldAccess world, Random random, BlockPos pos) {
|
public void growAdult(StructureWorldAccess world, Random random, BlockPos pos) {
|
||||||
int h = BlocksHelper.downRay(world, pos, random.nextInt(24)) - 1;
|
int h = BlocksHelper.downRay(world, pos, random.nextInt(24)) - 1;
|
||||||
if (h > 2) {
|
if (h > 2) {
|
||||||
BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.BULB_VINE.getDefaultState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP));
|
BlocksHelper.setWithoutUpdate(world, pos,
|
||||||
|
EndBlocks.BULB_VINE.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP));
|
||||||
for (int i = 1; i < h; i++) {
|
for (int i = 1; i < h; i++) {
|
||||||
BlocksHelper.setWithoutUpdate(world, pos.down(i), EndBlocks.BULB_VINE.getDefaultState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE));
|
BlocksHelper.setWithoutUpdate(world, pos.down(i),
|
||||||
|
EndBlocks.BULB_VINE.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE));
|
||||||
}
|
}
|
||||||
BlocksHelper.setWithoutUpdate(world, pos.down(h), EndBlocks.BULB_VINE.getDefaultState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM));
|
BlocksHelper.setWithoutUpdate(world, pos.down(h),
|
||||||
|
EndBlocks.BULB_VINE.defaultBlockState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,18 +4,18 @@ import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.block.ShapeContext;
|
import net.minecraft.world.level.block.ShapeContext;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.loot.context.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import net.minecraft.state.StateManager;
|
import net.minecraft.world.level.block.state.StateDefinition;
|
||||||
import net.minecraft.state.property.BooleanProperty;
|
import net.minecraft.state.property.BooleanProperty;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.shape.VoxelShape;
|
import net.minecraft.util.shape.VoxelShape;
|
||||||
import net.minecraft.util.shape.VoxelShapes;
|
import net.minecraft.util.shape.VoxelShapes;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import ru.betterend.blocks.basis.BlockBaseNotFull;
|
import ru.betterend.blocks.basis.BlockBaseNotFull;
|
||||||
import ru.betterend.client.render.ERenderLayer;
|
import ru.betterend.client.render.ERenderLayer;
|
||||||
import ru.betterend.interfaces.IRenderTypeable;
|
import ru.betterend.interfaces.IRenderTypeable;
|
||||||
|
@ -27,12 +27,12 @@ public class CavePumpkinBlock extends BlockBaseNotFull implements IRenderTypeabl
|
||||||
private static final VoxelShape SHAPE_BIG;
|
private static final VoxelShape SHAPE_BIG;
|
||||||
|
|
||||||
public CavePumpkinBlock() {
|
public CavePumpkinBlock() {
|
||||||
super(FabricBlockSettings.copyOf(Blocks.PUMPKIN).luminance((state) -> state.get(SMALL) ? 10 : 15));
|
super(FabricBlockSettings.copyOf(Blocks.PUMPKIN).luminance((state) -> state.getValue(SMALL) ? 10 : 15));
|
||||||
setDefaultState(getDefaultState().with(SMALL, false));
|
setDefaultState(getDefaultState().with(SMALL, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
|
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
|
||||||
stateManager.add(SMALL);
|
stateManager.add(SMALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,12 +43,13 @@ public class CavePumpkinBlock extends BlockBaseNotFull implements IRenderTypeabl
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
||||||
return state.get(SMALL) ? SHAPE_SMALL : SHAPE_BIG;
|
return state.getValue(SMALL) ? SHAPE_SMALL : SHAPE_BIG;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
return state.get(SMALL) ? Collections.singletonList(new ItemStack(EndBlocks.CAVE_PUMPKIN_SEED)) : Collections.singletonList(new ItemStack(this));
|
return state.getValue(SMALL) ? Collections.singletonList(new ItemStack(EndBlocks.CAVE_PUMPKIN_SEED))
|
||||||
|
: Collections.singletonList(new ItemStack(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
|
|
@ -2,17 +2,17 @@ package ru.betterend.blocks;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import net.minecraft.block.AbstractBlock;
|
import net.minecraft.world.level.block.AbstractBlock;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.block.ShapeContext;
|
import net.minecraft.world.level.block.ShapeContext;
|
||||||
import net.minecraft.server.world.ServerWorld;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.util.shape.VoxelShape;
|
import net.minecraft.util.shape.VoxelShape;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import net.minecraft.world.StructureWorldAccess;
|
import net.minecraft.world.StructureWorldAccess;
|
||||||
import net.minecraft.world.WorldAccess;
|
import net.minecraft.world.level.LevelAccessor;
|
||||||
import net.minecraft.world.WorldView;
|
import net.minecraft.world.WorldView;
|
||||||
import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
|
import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
|
||||||
import ru.betterend.registry.EndBlocks;
|
import ru.betterend.registry.EndBlocks;
|
||||||
|
@ -27,31 +27,34 @@ public class CavePumpkinVineBlock extends EndPlantWithAgeBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) {
|
public void grow(ServerLevel world, Random random, BlockPos pos, BlockState state) {
|
||||||
int age = state.get(AGE);
|
int age = state.getValue(AGE);
|
||||||
BlockState down = world.getBlockState(pos.down());
|
BlockState down = world.getBlockState(pos.below());
|
||||||
if (down.getMaterial().isReplaceable() || (down.isOf(EndBlocks.CAVE_PUMPKIN) && down.get(BlockProperties.SMALL))) {
|
if (down.getMaterial().isReplaceable()
|
||||||
|
|| (down.is(EndBlocks.CAVE_PUMPKIN) && down.get(BlockProperties.SMALL))) {
|
||||||
if (age < 3) {
|
if (age < 3) {
|
||||||
world.setBlockState(pos, state.with(AGE, age + 1));
|
world.setBlockAndUpdate(pos, state.with(AGE, age + 1));
|
||||||
}
|
}
|
||||||
if (age == 2) {
|
if (age == 2) {
|
||||||
world.setBlockState(pos.down(), EndBlocks.CAVE_PUMPKIN.getDefaultState().with(BlockProperties.SMALL, true));
|
world.setBlockAndUpdate(pos.below(),
|
||||||
}
|
EndBlocks.CAVE_PUMPKIN.defaultBlockState().with(BlockProperties.SMALL, true));
|
||||||
else if (age == 3) {
|
} else if (age == 3) {
|
||||||
world.setBlockState(pos.down(), EndBlocks.CAVE_PUMPKIN.getDefaultState());
|
world.setBlockAndUpdate(pos.below(), EndBlocks.CAVE_PUMPKIN.defaultBlockState());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void growAdult(StructureWorldAccess world, Random random, BlockPos pos) {}
|
public void growAdult(StructureWorldAccess world, Random random, BlockPos pos) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
|
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world,
|
||||||
state = super.getStateForNeighborUpdate(state, facing, neighborState, world, pos, neighborPos);
|
BlockPos pos, BlockPos neighborPos) {
|
||||||
if (state.isOf(this) && state.get(BlockProperties.AGE) > 1) {
|
state = super.updateShape(state, facing, neighborState, world, pos, neighborPos);
|
||||||
BlockState down = world.getBlockState(pos.down());
|
if (state.is(this) && state.getValue(BlockProperties.AGE) > 1) {
|
||||||
if (!down.isOf(EndBlocks.CAVE_PUMPKIN)) {
|
BlockState down = world.getBlockState(pos.below());
|
||||||
|
if (!down.is(EndBlocks.CAVE_PUMPKIN)) {
|
||||||
state = state.with(BlockProperties.AGE, 1);
|
state = state.with(BlockProperties.AGE, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,16 +6,16 @@ import java.util.EnumMap;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.block.ShapeContext;
|
import net.minecraft.world.level.block.ShapeContext;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.util.shape.VoxelShape;
|
import net.minecraft.util.shape.VoxelShape;
|
||||||
import net.minecraft.util.shape.VoxelShapes;
|
import net.minecraft.util.shape.VoxelShapes;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import ru.betterend.blocks.basis.AttachedBlock;
|
import ru.betterend.blocks.basis.AttachedBlock;
|
||||||
import ru.betterend.client.render.ERenderLayer;
|
import ru.betterend.client.render.ERenderLayer;
|
||||||
import ru.betterend.interfaces.IRenderTypeable;
|
import ru.betterend.interfaces.IRenderTypeable;
|
||||||
|
@ -36,34 +36,31 @@ public class ChandelierBlock extends AttachedBlock implements IRenderTypeable, B
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
|
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
|
||||||
return BOUNDING_SHAPES.get(state.get(FACING));
|
return BOUNDING_SHAPES.get(state.getValue(FACING));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStatesPattern(Reader data) {
|
public String getStatesPattern(Reader data) {
|
||||||
Identifier blockId = Registry.BLOCK.getId(this);
|
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||||
return Patterns.createJson(data, blockId.getPath(), blockId.getPath());
|
return Patterns.createJson(data, blockId.getPath(), blockId.getPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String block) {
|
public String getModelPattern(String block) {
|
||||||
Identifier blockId = Registry.BLOCK.getId(this);
|
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||||
if (block.contains("item")) {
|
if (block.contains("item")) {
|
||||||
return Patterns.createJson(Patterns.ITEM_GENERATED, "item/" + blockId.getPath());
|
return Patterns.createJson(Patterns.ITEM_GENERATED, "item/" + blockId.getPath());
|
||||||
}
|
} else if (block.contains("ceil")) {
|
||||||
else if (block.contains("ceil")) {
|
|
||||||
return Patterns.createJson(Patterns.BLOCK_CHANDELIER_CEIL, blockId.getPath());
|
return Patterns.createJson(Patterns.BLOCK_CHANDELIER_CEIL, blockId.getPath());
|
||||||
}
|
} else if (block.contains("wall")) {
|
||||||
else if (block.contains("wall")) {
|
|
||||||
return Patterns.createJson(Patterns.BLOCK_CHANDELIER_WALL, blockId.getPath());
|
return Patterns.createJson(Patterns.BLOCK_CHANDELIER_WALL, blockId.getPath());
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return Patterns.createJson(Patterns.BLOCK_CHANDELIER_FLOOR, blockId.getPath());
|
return Patterns.createJson(Patterns.BLOCK_CHANDELIER_FLOOR, blockId.getPath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Identifier statePatternId() {
|
public ResourceLocation statePatternId() {
|
||||||
return Patterns.STATE_CHANDELIER;
|
return Patterns.STATE_CHANDELIER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ package ru.betterend.blocks;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.fabricmc.fabric.api.registry.FuelRegistry;
|
import net.fabricmc.fabric.api.registry.FuelRegistry;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import ru.betterend.blocks.basis.BlockBase;
|
import ru.betterend.blocks.basis.BlockBase;
|
||||||
|
|
||||||
public class CharcoalBlock extends BlockBase {
|
public class CharcoalBlock extends BlockBase {
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
package ru.betterend.blocks;
|
package ru.betterend.blocks;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.fluid.Fluids;
|
import net.minecraft.fluid.Fluids;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.world.WorldView;
|
import net.minecraft.world.WorldView;
|
||||||
import ru.betterend.blocks.basis.UnderwaterPlantBlock;
|
import ru.betterend.blocks.basis.UnderwaterPlantBlock;
|
||||||
|
|
||||||
public class CharniaBlock extends UnderwaterPlantBlock {
|
public class CharniaBlock extends UnderwaterPlantBlock {
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
||||||
return sideCoversSmallSquare(world, pos.down(), Direction.UP) && world.getFluidState(pos).getFluid() == Fluids.WATER;
|
return sideCoversSmallSquare(world, pos.below(), Direction.UP)
|
||||||
|
&& world.getFluidState(pos).getFluid() == Fluids.WATER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package ru.betterend.blocks;
|
package ru.betterend.blocks;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import ru.betterend.blocks.basis.EndPlantBlock;
|
import ru.betterend.blocks.basis.EndPlantBlock;
|
||||||
import ru.betterend.registry.EndBlocks;
|
import ru.betterend.registry.EndBlocks;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package ru.betterend.blocks;
|
package ru.betterend.blocks;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import ru.betterend.blocks.basis.BlockBase;
|
import ru.betterend.blocks.basis.BlockBase;
|
||||||
import ru.betterend.client.render.ERenderLayer;
|
import ru.betterend.client.render.ERenderLayer;
|
||||||
import ru.betterend.interfaces.IRenderTypeable;
|
import ru.betterend.interfaces.IRenderTypeable;
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package ru.betterend.blocks;
|
package ru.betterend.blocks;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.minecraft.block.Material;
|
import net.minecraft.world.level.material.Material;
|
||||||
import net.minecraft.sound.BlockSoundGroup;
|
import net.minecraft.world.level.block.SoundType;
|
||||||
import ru.betterend.blocks.basis.BlockBase;
|
import ru.betterend.blocks.basis.BlockBase;
|
||||||
|
|
||||||
public class DenseSnowBlock extends BlockBase {
|
public class DenseSnowBlock extends BlockBase {
|
||||||
public DenseSnowBlock() {
|
public DenseSnowBlock() {
|
||||||
super(FabricBlockSettings.of(Material.SNOW_BLOCK).strength(0.2F).sounds(BlockSoundGroup.SNOW));
|
super(FabricBlockSettings.of(Material.SNOW_BLOCK).strength(0.2F).sounds(SoundType.SNOW));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package ru.betterend.blocks;
|
package ru.betterend.blocks;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.WorldView;
|
import net.minecraft.world.WorldView;
|
||||||
import net.minecraft.world.gen.feature.Feature;
|
import net.minecraft.world.gen.feature.Feature;
|
||||||
import ru.betterend.blocks.basis.FeatureSaplingBlock;
|
import ru.betterend.blocks.basis.FeatureSaplingBlock;
|
||||||
|
@ -20,6 +20,6 @@ public class DragonTreeSaplingBlock extends FeatureSaplingBlock {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
||||||
return world.getBlockState(pos.down()).isOf(EndBlocks.SHADOW_GRASS);
|
return world.getBlockState(pos.below()).is(EndBlocks.SHADOW_GRASS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,22 +8,22 @@ import java.util.Random;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.block.Material;
|
import net.minecraft.world.level.material.Material;
|
||||||
import net.minecraft.block.TransparentBlock;
|
import net.minecraft.world.level.block.TransparentBlock;
|
||||||
import net.minecraft.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.enchantment.EnchantmentHelper;
|
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||||
import net.minecraft.enchantment.Enchantments;
|
import net.minecraft.world.item.enchantment.Enchantments;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.world.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.loot.context.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import net.minecraft.server.world.ServerWorld;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.world.LightType;
|
import net.minecraft.world.LightType;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.level.Level;
|
||||||
import ru.betterend.client.render.ERenderLayer;
|
import ru.betterend.client.render.ERenderLayer;
|
||||||
import ru.betterend.interfaces.IRenderTypeable;
|
import ru.betterend.interfaces.IRenderTypeable;
|
||||||
import ru.betterend.patterns.BlockPatterned;
|
import ru.betterend.patterns.BlockPatterned;
|
||||||
|
@ -40,59 +40,59 @@ public class EmeraldIceBlock extends TransparentBlock implements IRenderTypeable
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterBreak(World world, PlayerEntity player, BlockPos pos, BlockState state, @Nullable BlockEntity blockEntity, ItemStack stack) {
|
public void afterBreak(Level world, PlayerEntity player, BlockPos pos, BlockState state,
|
||||||
|
@Nullable BlockEntity blockEntity, ItemStack stack) {
|
||||||
super.afterBreak(world, player, pos, state, blockEntity, stack);
|
super.afterBreak(world, player, pos, state, blockEntity, stack);
|
||||||
if (EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, stack) == 0) {
|
if (EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, stack) == 0) {
|
||||||
if (world.getDimension().isUltrawarm()) {
|
if (world.getDimension().isUltrawarm()) {
|
||||||
world.removeBlock(pos, false);
|
world.removeBlock(pos, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Material material = world.getBlockState(pos.down()).getMaterial();
|
Material material = world.getBlockState(pos.below()).getMaterial();
|
||||||
if (material.blocksMovement() || material.isLiquid()) {
|
if (material.blocksMovement() || material.isLiquid()) {
|
||||||
world.setBlockState(pos, Blocks.WATER.getDefaultState());
|
world.setBlockAndUpdate(pos, Blocks.WATER.defaultBlockState());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
|
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
|
||||||
if (world.getLightLevel(LightType.BLOCK, pos) > 11 - state.getOpacity(world, pos)) {
|
if (world.getLightLevel(LightType.BLOCK, pos) > 11 - state.getOpacity(world, pos)) {
|
||||||
this.melt(state, world, pos);
|
this.melt(state, world, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void melt(BlockState state, World world, BlockPos pos) {
|
protected void melt(BlockState state, Level world, BlockPos pos) {
|
||||||
if (world.getDimension().isUltrawarm()) {
|
if (world.getDimension().isUltrawarm()) {
|
||||||
world.removeBlock(pos, false);
|
world.removeBlock(pos, false);
|
||||||
}
|
} else {
|
||||||
else {
|
world.setBlockAndUpdate(pos, Blocks.WATER.defaultBlockState());
|
||||||
world.setBlockState(pos, Blocks.WATER.getDefaultState());
|
|
||||||
world.updateNeighbor(pos, Blocks.WATER, pos);
|
world.updateNeighbor(pos, Blocks.WATER, pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
return Collections.singletonList(new ItemStack(this));
|
return Collections.singletonList(new ItemStack(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStatesPattern(Reader data) {
|
public String getStatesPattern(Reader data) {
|
||||||
String block = Registry.BLOCK.getId(this).getPath();
|
String block = Registry.BLOCK.getKey(this).getPath();
|
||||||
return Patterns.createJson(data, block, block);
|
return Patterns.createJson(data, block, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String block) {
|
public String getModelPattern(String block) {
|
||||||
Identifier blockId = Registry.BLOCK.getId(this);
|
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||||
return Patterns.createJson(Patterns.BLOCK_BASE, blockId.getPath(), block);
|
return Patterns.createJson(Patterns.BLOCK_BASE, blockId.getPath(), block);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Identifier statePatternId() {
|
public ResourceLocation statePatternId() {
|
||||||
return Patterns.STATE_SIMPLE;
|
return Patterns.STATE_SIMPLE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,25 +10,25 @@ import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.block.Material;
|
import net.minecraft.world.level.material.Material;
|
||||||
import net.minecraft.block.ShapeContext;
|
import net.minecraft.world.level.block.ShapeContext;
|
||||||
import net.minecraft.fluid.FluidState;
|
import net.minecraft.fluid.FluidState;
|
||||||
import net.minecraft.fluid.Fluids;
|
import net.minecraft.fluid.Fluids;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.loot.context.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import net.minecraft.sound.BlockSoundGroup;
|
import net.minecraft.world.level.block.SoundType;
|
||||||
import net.minecraft.state.StateManager;
|
import net.minecraft.world.level.block.state.StateDefinition;
|
||||||
import net.minecraft.state.property.EnumProperty;
|
import net.minecraft.state.property.EnumProperty;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.util.shape.VoxelShape;
|
import net.minecraft.util.shape.VoxelShape;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.WorldAccess;
|
import net.minecraft.world.level.LevelAccessor;
|
||||||
import net.minecraft.world.WorldView;
|
import net.minecraft.world.WorldView;
|
||||||
import ru.betterend.blocks.BlockProperties.TripleShape;
|
import ru.betterend.blocks.BlockProperties.TripleShape;
|
||||||
import ru.betterend.blocks.basis.UnderwaterPlantBlock;
|
import ru.betterend.blocks.basis.UnderwaterPlantBlock;
|
||||||
|
@ -42,20 +42,19 @@ public class EndLilyBlock extends UnderwaterPlantBlock {
|
||||||
private static final VoxelShape SHAPE_TOP = Block.createCuboidShape(2, 0, 2, 14, 6, 14);
|
private static final VoxelShape SHAPE_TOP = Block.createCuboidShape(2, 0, 2, 14, 6, 14);
|
||||||
|
|
||||||
public EndLilyBlock() {
|
public EndLilyBlock() {
|
||||||
super(FabricBlockSettings.of(Material.UNDERWATER_PLANT)
|
super(FabricBlockSettings.of(Material.UNDERWATER_PLANT).breakByTool(FabricToolTags.SHEARS)
|
||||||
.breakByTool(FabricToolTags.SHEARS)
|
.sounds(SoundType.WET_GRASS).breakByHand(true).luminance((state) -> {
|
||||||
.sounds(BlockSoundGroup.WET_GRASS)
|
return state.getValue(SHAPE) == TripleShape.TOP ? 13 : 0;
|
||||||
.breakByHand(true)
|
}).noCollision());
|
||||||
.luminance((state) -> { return state.get(SHAPE) == TripleShape.TOP ? 13 : 0; })
|
|
||||||
.noCollision());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
|
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world,
|
||||||
|
BlockPos pos, BlockPos neighborPos) {
|
||||||
if (!canPlaceAt(state, world, pos)) {
|
if (!canPlaceAt(state, world, pos)) {
|
||||||
return state.get(SHAPE) == TripleShape.TOP ? Blocks.AIR.getDefaultState() : Blocks.WATER.getDefaultState();
|
return state.getValue(SHAPE) == TripleShape.TOP ? Blocks.AIR.defaultBlockState()
|
||||||
}
|
: Blocks.WATER.defaultBlockState();
|
||||||
else {
|
} else {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,39 +62,39 @@ public class EndLilyBlock extends UnderwaterPlantBlock {
|
||||||
@Override
|
@Override
|
||||||
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
|
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
|
||||||
Vec3d vec3d = state.getModelOffset(view, pos);
|
Vec3d vec3d = state.getModelOffset(view, pos);
|
||||||
VoxelShape shape = state.get(SHAPE) == TripleShape.TOP ? SHAPE_TOP : SHAPE_BOTTOM;
|
VoxelShape shape = state.getValue(SHAPE) == TripleShape.TOP ? SHAPE_TOP : SHAPE_BOTTOM;
|
||||||
return shape.offset(vec3d.x, vec3d.y, vec3d.z);
|
return shape.offset(vec3d.x, vec3d.y, vec3d.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
|
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
|
||||||
stateManager.add(SHAPE);
|
stateManager.add(SHAPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FluidState getFluidState(BlockState state) {
|
public FluidState getFluidState(BlockState state) {
|
||||||
return state.get(SHAPE) == TripleShape.TOP ? Fluids.EMPTY.getDefaultState() : Fluids.WATER.getStill(false);
|
return state.getValue(SHAPE) == TripleShape.TOP ? Fluids.EMPTY.defaultBlockState()
|
||||||
|
: Fluids.WATER.getStill(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
||||||
if (state.get(SHAPE) == TripleShape.TOP) {
|
if (state.getValue(SHAPE) == TripleShape.TOP) {
|
||||||
return world.getBlockState(pos.down()).getBlock() == this;
|
return world.getBlockState(pos.below()).getBlock() == this;
|
||||||
}
|
} else if (state.getValue(SHAPE) == TripleShape.BOTTOM) {
|
||||||
else if (state.get(SHAPE) == TripleShape.BOTTOM) {
|
return isTerrain(world.getBlockState(pos.below()));
|
||||||
return isTerrain(world.getBlockState(pos.down()));
|
} else {
|
||||||
}
|
|
||||||
else {
|
|
||||||
BlockState up = world.getBlockState(pos.up());
|
BlockState up = world.getBlockState(pos.up());
|
||||||
BlockState down = world.getBlockState(pos.down());
|
BlockState down = world.getBlockState(pos.below());
|
||||||
return up.getBlock() == this && down.getBlock() == this;
|
return up.getBlock() == this && down.getBlock() == this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
if (state.get(SHAPE) == TripleShape.TOP) {
|
if (state.getValue(SHAPE) == TripleShape.TOP) {
|
||||||
return Lists.newArrayList(new ItemStack(EndItems.END_LILY_LEAF, MHelper.randRange(1, 2, MHelper.RANDOM)), new ItemStack(EndBlocks.END_LILY_SEED, MHelper.randRange(1, 2, MHelper.RANDOM)));
|
return Lists.newArrayList(new ItemStack(EndItems.END_LILY_LEAF, MHelper.randRange(1, 2, MHelper.RANDOM)),
|
||||||
|
new ItemStack(EndBlocks.END_LILY_SEED, MHelper.randRange(1, 2, MHelper.RANDOM)));
|
||||||
}
|
}
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
@ -112,7 +111,7 @@ public class EndLilyBlock extends UnderwaterPlantBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) {
|
public boolean canGrow(Level world, Random random, BlockPos pos, BlockState state) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ package ru.betterend.blocks;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import net.minecraft.fluid.Fluids;
|
import net.minecraft.fluid.Fluids;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.StructureWorldAccess;
|
import net.minecraft.world.StructureWorldAccess;
|
||||||
import ru.betterend.blocks.BlockProperties.TripleShape;
|
import ru.betterend.blocks.BlockProperties.TripleShape;
|
||||||
import ru.betterend.blocks.basis.UnderwaterPlantWithAgeBlock;
|
import ru.betterend.blocks.basis.UnderwaterPlantWithAgeBlock;
|
||||||
|
@ -14,13 +14,16 @@ public class EndLilySeedBlock extends UnderwaterPlantWithAgeBlock {
|
||||||
@Override
|
@Override
|
||||||
public void grow(StructureWorldAccess world, Random random, BlockPos pos) {
|
public void grow(StructureWorldAccess world, Random random, BlockPos pos) {
|
||||||
if (canGrow(world, pos)) {
|
if (canGrow(world, pos)) {
|
||||||
BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.END_LILY.getDefaultState().with(EndLilyBlock.SHAPE, TripleShape.BOTTOM));
|
BlocksHelper.setWithoutUpdate(world, pos,
|
||||||
|
EndBlocks.END_LILY.defaultBlockState().with(EndLilyBlock.SHAPE, TripleShape.BOTTOM));
|
||||||
BlockPos up = pos.up();
|
BlockPos up = pos.up();
|
||||||
while (world.getFluidState(up).isStill()) {
|
while (world.getFluidState(up).isStill()) {
|
||||||
BlocksHelper.setWithoutUpdate(world, up, EndBlocks.END_LILY.getDefaultState().with(EndLilyBlock.SHAPE, TripleShape.MIDDLE));
|
BlocksHelper.setWithoutUpdate(world, up,
|
||||||
|
EndBlocks.END_LILY.defaultBlockState().with(EndLilyBlock.SHAPE, TripleShape.MIDDLE));
|
||||||
up = up.up();
|
up = up.up();
|
||||||
}
|
}
|
||||||
BlocksHelper.setWithoutUpdate(world, up, EndBlocks.END_LILY.getDefaultState().with(EndLilyBlock.SHAPE, TripleShape.TOP));
|
BlocksHelper.setWithoutUpdate(world, up,
|
||||||
|
EndBlocks.END_LILY.defaultBlockState().with(EndLilyBlock.SHAPE, TripleShape.TOP));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,16 +7,16 @@ import com.google.common.collect.Lists;
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.minecraft.block.AbstractBlock;
|
import net.minecraft.world.level.block.AbstractBlock;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.block.Material;
|
import net.minecraft.world.level.material.Material;
|
||||||
import net.minecraft.block.ShapeContext;
|
import net.minecraft.world.level.block.ShapeContext;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.loot.context.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.shape.VoxelShape;
|
import net.minecraft.util.shape.VoxelShape;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import ru.betterend.blocks.basis.EndPlantBlock;
|
import ru.betterend.blocks.basis.EndPlantBlock;
|
||||||
import ru.betterend.registry.EndBlocks;
|
import ru.betterend.registry.EndBlocks;
|
||||||
import ru.betterend.util.MHelper;
|
import ru.betterend.util.MHelper;
|
||||||
|
@ -31,7 +31,7 @@ public class EndLotusFlowerBlock extends EndPlantBlock {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isTerrain(BlockState state) {
|
protected boolean isTerrain(BlockState state) {
|
||||||
return state.isOf(EndBlocks.END_LOTUS_STEM);
|
return state.is(EndBlocks.END_LOTUS_STEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -50,7 +50,7 @@ public class EndLotusFlowerBlock extends EndPlantBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
int count = MHelper.randRange(1, 2, MHelper.RANDOM);
|
int count = MHelper.randRange(1, 2, MHelper.RANDOM);
|
||||||
return Lists.newArrayList(new ItemStack(EndBlocks.END_LOTUS_SEED, count));
|
return Lists.newArrayList(new ItemStack(EndBlocks.END_LOTUS_SEED, count));
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,22 +3,22 @@ package ru.betterend.blocks;
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.block.Material;
|
import net.minecraft.world.level.material.Material;
|
||||||
import net.minecraft.block.ShapeContext;
|
import net.minecraft.world.level.block.ShapeContext;
|
||||||
import net.minecraft.fluid.WaterFluid;
|
import net.minecraft.fluid.WaterFluid;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.sound.BlockSoundGroup;
|
import net.minecraft.world.level.block.SoundType;
|
||||||
import net.minecraft.state.StateManager;
|
import net.minecraft.world.level.block.state.StateDefinition;
|
||||||
import net.minecraft.state.property.EnumProperty;
|
import net.minecraft.state.property.EnumProperty;
|
||||||
import net.minecraft.state.property.Properties;
|
import net.minecraft.state.property.Properties;
|
||||||
import net.minecraft.util.BlockMirror;
|
import net.minecraft.util.BlockMirror;
|
||||||
import net.minecraft.util.BlockRotation;
|
import net.minecraft.world.level.block.Rotation;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.util.shape.VoxelShape;
|
import net.minecraft.util.shape.VoxelShape;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import net.minecraft.world.WorldView;
|
import net.minecraft.world.WorldView;
|
||||||
import ru.betterend.blocks.BlockProperties.TripleShape;
|
import ru.betterend.blocks.BlockProperties.TripleShape;
|
||||||
import ru.betterend.blocks.basis.BlockBaseNotFull;
|
import ru.betterend.blocks.basis.BlockBaseNotFull;
|
||||||
|
@ -33,17 +33,17 @@ public class EndLotusLeafBlock extends BlockBaseNotFull implements IRenderTypeab
|
||||||
private static final VoxelShape VSHAPE = Block.createCuboidShape(0, 0, 0, 16, 1, 16);
|
private static final VoxelShape VSHAPE = Block.createCuboidShape(0, 0, 0, 16, 1, 16);
|
||||||
|
|
||||||
public EndLotusLeafBlock() {
|
public EndLotusLeafBlock() {
|
||||||
super(FabricBlockSettings.of(Material.PLANT).nonOpaque().sounds(BlockSoundGroup.WET_GRASS));
|
super(FabricBlockSettings.of(Material.PLANT).nonOpaque().sounds(SoundType.WET_GRASS));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
||||||
BlockState down = world.getBlockState(pos.down());
|
BlockState down = world.getBlockState(pos.below());
|
||||||
return !down.getFluidState().isEmpty() && down.getFluidState().getFluid() instanceof WaterFluid;
|
return !down.getFluidState().isEmpty() && down.getFluidState().getFluid() instanceof WaterFluid;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
||||||
builder.add(SHAPE, HORIZONTAL_FACING);
|
builder.add(SHAPE, HORIZONTAL_FACING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ public class EndLotusLeafBlock extends BlockBaseNotFull implements IRenderTypeab
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState rotate(BlockState state, BlockRotation rotation) {
|
public BlockState rotate(BlockState state, Rotation rotation) {
|
||||||
return BlocksHelper.rotateHorizontal(state, rotation, HORIZONTAL_FACING);
|
return BlocksHelper.rotateHorizontal(state, rotation, HORIZONTAL_FACING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,11 +2,11 @@ package ru.betterend.blocks;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.fluid.Fluids;
|
import net.minecraft.fluid.Fluids;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.math.BlockPos.Mutable;
|
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.world.StructureWorldAccess;
|
import net.minecraft.world.StructureWorldAccess;
|
||||||
import ru.betterend.blocks.BlockProperties.TripleShape;
|
import ru.betterend.blocks.BlockProperties.TripleShape;
|
||||||
import ru.betterend.blocks.basis.UnderwaterPlantWithAgeBlock;
|
import ru.betterend.blocks.basis.UnderwaterPlantWithAgeBlock;
|
||||||
|
@ -17,13 +17,14 @@ public class EndLotusSeedBlock extends UnderwaterPlantWithAgeBlock {
|
||||||
@Override
|
@Override
|
||||||
public void grow(StructureWorldAccess world, Random random, BlockPos pos) {
|
public void grow(StructureWorldAccess world, Random random, BlockPos pos) {
|
||||||
if (canGrow(world, pos)) {
|
if (canGrow(world, pos)) {
|
||||||
BlockState startLeaf = EndBlocks.END_LOTUS_STEM.getDefaultState().with(EndLotusStemBlock.LEAF, true);
|
BlockState startLeaf = EndBlocks.END_LOTUS_STEM.defaultBlockState().with(EndLotusStemBlock.LEAF, true);
|
||||||
BlockState roots = EndBlocks.END_LOTUS_STEM.getDefaultState().with(EndLotusStemBlock.SHAPE, TripleShape.BOTTOM).with(EndLotusStemBlock.WATERLOGGED, true);
|
BlockState roots = EndBlocks.END_LOTUS_STEM.defaultBlockState()
|
||||||
BlockState stem = EndBlocks.END_LOTUS_STEM.getDefaultState();
|
.with(EndLotusStemBlock.SHAPE, TripleShape.BOTTOM).with(EndLotusStemBlock.WATERLOGGED, true);
|
||||||
BlockState flower = EndBlocks.END_LOTUS_FLOWER.getDefaultState();
|
BlockState stem = EndBlocks.END_LOTUS_STEM.defaultBlockState();
|
||||||
|
BlockState flower = EndBlocks.END_LOTUS_FLOWER.defaultBlockState();
|
||||||
|
|
||||||
BlocksHelper.setWithoutUpdate(world, pos, roots);
|
BlocksHelper.setWithoutUpdate(world, pos, roots);
|
||||||
Mutable bpos = new Mutable().set(pos);
|
MutableBlockPos bpos = new MutableBlockPos().set(pos);
|
||||||
bpos.setY(bpos.getY() + 1);
|
bpos.setY(bpos.getY() + 1);
|
||||||
while (world.getFluidState(bpos).isStill()) {
|
while (world.getFluidState(bpos).isStill()) {
|
||||||
BlocksHelper.setWithoutUpdate(world, bpos, stem.with(EndLotusStemBlock.WATERLOGGED, true));
|
BlocksHelper.setWithoutUpdate(world, bpos, stem.with(EndLotusStemBlock.WATERLOGGED, true));
|
||||||
|
@ -36,9 +37,9 @@ public class EndLotusSeedBlock extends UnderwaterPlantWithAgeBlock {
|
||||||
BlockPos leafCenter = bpos.toImmutable().offset(dir);
|
BlockPos leafCenter = bpos.toImmutable().offset(dir);
|
||||||
if (hasLeaf(world, leafCenter)) {
|
if (hasLeaf(world, leafCenter)) {
|
||||||
generateLeaf(world, leafCenter);
|
generateLeaf(world, leafCenter);
|
||||||
BlocksHelper.setWithoutUpdate(world, bpos, startLeaf.with(EndLotusStemBlock.SHAPE, shape).with(EndLotusStemBlock.FACING, dir));
|
BlocksHelper.setWithoutUpdate(world, bpos,
|
||||||
}
|
startLeaf.with(EndLotusStemBlock.SHAPE, shape).with(EndLotusStemBlock.FACING, dir));
|
||||||
else {
|
} else {
|
||||||
BlocksHelper.setWithoutUpdate(world, bpos, stem.with(EndLotusStemBlock.SHAPE, shape));
|
BlocksHelper.setWithoutUpdate(world, bpos, stem.with(EndLotusStemBlock.SHAPE, shape));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,14 +64,14 @@ public class EndLotusSeedBlock extends UnderwaterPlantWithAgeBlock {
|
||||||
BlocksHelper.setWithoutUpdate(world, bpos, flower);
|
BlocksHelper.setWithoutUpdate(world, bpos, flower);
|
||||||
bpos.setY(bpos.getY() - 1);
|
bpos.setY(bpos.getY() - 1);
|
||||||
stem = world.getBlockState(bpos);
|
stem = world.getBlockState(bpos);
|
||||||
if (!stem.isOf(EndBlocks.END_LOTUS_STEM)) {
|
if (!stem.is(EndBlocks.END_LOTUS_STEM)) {
|
||||||
stem = EndBlocks.END_LOTUS_STEM.getDefaultState();
|
stem = EndBlocks.END_LOTUS_STEM.defaultBlockState();
|
||||||
if (!world.getBlockState(bpos.north()).getFluidState().isEmpty()) {
|
if (!world.getBlockState(bpos.north()).getFluidState().isEmpty()) {
|
||||||
stem = stem.with(EndLotusStemBlock.WATERLOGGED, true);
|
stem = stem.with(EndLotusStemBlock.WATERLOGGED, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (world.getBlockState(bpos.offset(dir)).isOf(EndBlocks.END_LOTUS_LEAF)) {
|
if (world.getBlockState(bpos.offset(dir)).is(EndBlocks.END_LOTUS_LEAF)) {
|
||||||
stem = stem.with(EndLotusStemBlock.LEAF, true).with(EndLotusStemBlock.FACING, dir);
|
stem = stem.with(EndLotusStemBlock.LEAF, true).with(EndLotusStemBlock.FACING, dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +80,7 @@ public class EndLotusSeedBlock extends UnderwaterPlantWithAgeBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean canGrow(StructureWorldAccess world, BlockPos pos) {
|
private boolean canGrow(StructureWorldAccess world, BlockPos pos) {
|
||||||
Mutable bpos = new Mutable();
|
MutableBlockPos bpos = new MutableBlockPos();
|
||||||
bpos.set(pos);
|
bpos.set(pos);
|
||||||
while (world.getBlockState(bpos).getFluidState().getFluid().equals(Fluids.WATER.getStill())) {
|
while (world.getBlockState(bpos).getFluidState().getFluid().equals(Fluids.WATER.getStill())) {
|
||||||
bpos.setY(bpos.getY() + 1);
|
bpos.setY(bpos.getY() + 1);
|
||||||
|
@ -88,29 +89,31 @@ public class EndLotusSeedBlock extends UnderwaterPlantWithAgeBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generateLeaf(StructureWorldAccess world, BlockPos pos) {
|
private void generateLeaf(StructureWorldAccess world, BlockPos pos) {
|
||||||
Mutable p = new Mutable();
|
MutableBlockPos p = new MutableBlockPos();
|
||||||
BlockState leaf = EndBlocks.END_LOTUS_LEAF.getDefaultState();
|
BlockState leaf = EndBlocks.END_LOTUS_LEAF.defaultBlockState();
|
||||||
BlocksHelper.setWithoutUpdate(world, pos, leaf.with(EndLotusLeafBlock.SHAPE, TripleShape.BOTTOM));
|
BlocksHelper.setWithoutUpdate(world, pos, leaf.with(EndLotusLeafBlock.SHAPE, TripleShape.BOTTOM));
|
||||||
for (Direction move: BlocksHelper.HORIZONTAL) {
|
for (Direction move : BlocksHelper.HORIZONTAL) {
|
||||||
BlocksHelper.setWithoutUpdate(world, p.set(pos).move(move), leaf.with(EndLotusLeafBlock.HORIZONTAL_FACING, move).with(EndLotusLeafBlock.SHAPE, TripleShape.MIDDLE));
|
BlocksHelper.setWithoutUpdate(world, p.set(pos).move(move), leaf
|
||||||
|
.with(EndLotusLeafBlock.HORIZONTAL_FACING, move).with(EndLotusLeafBlock.SHAPE, TripleShape.MIDDLE));
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 4; i ++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
Direction d1 = BlocksHelper.HORIZONTAL[i];
|
Direction d1 = BlocksHelper.HORIZONTAL[i];
|
||||||
Direction d2 = BlocksHelper.HORIZONTAL[(i + 1) & 3];
|
Direction d2 = BlocksHelper.HORIZONTAL[(i + 1) & 3];
|
||||||
BlocksHelper.setWithoutUpdate(world, p.set(pos).move(d1).move(d2), leaf.with(EndLotusLeafBlock.HORIZONTAL_FACING, d1).with(EndLotusLeafBlock.SHAPE, TripleShape.TOP));
|
BlocksHelper.setWithoutUpdate(world, p.set(pos).move(d1).move(d2),
|
||||||
|
leaf.with(EndLotusLeafBlock.HORIZONTAL_FACING, d1).with(EndLotusLeafBlock.SHAPE, TripleShape.TOP));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasLeaf(StructureWorldAccess world, BlockPos pos) {
|
private boolean hasLeaf(StructureWorldAccess world, BlockPos pos) {
|
||||||
Mutable p = new Mutable();
|
MutableBlockPos p = new MutableBlockPos();
|
||||||
p.setY(pos.getY());
|
p.setY(pos.getY());
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (int x = -1; x < 2; x ++) {
|
for (int x = -1; x < 2; x++) {
|
||||||
p.setX(pos.getX() + x);
|
p.setX(pos.getX() + x);
|
||||||
for (int z = -1; z < 2; z ++) {
|
for (int z = -1; z < 2; z++) {
|
||||||
p.setZ(pos.getZ() + z);
|
p.setZ(pos.getZ() + z);
|
||||||
if (world.isAir(p) && !world.getFluidState(p.down()).isEmpty())
|
if (world.isAir(p) && !world.getFluidState(p.below()).isEmpty())
|
||||||
count ++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return count == 9;
|
return count == 9;
|
||||||
|
|
|
@ -5,26 +5,26 @@ import java.util.Map;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.block.ShapeContext;
|
import net.minecraft.world.level.block.ShapeContext;
|
||||||
import net.minecraft.block.Waterloggable;
|
import net.minecraft.world.level.block.Waterloggable;
|
||||||
import net.minecraft.fluid.FluidState;
|
import net.minecraft.fluid.FluidState;
|
||||||
import net.minecraft.fluid.Fluids;
|
import net.minecraft.fluid.Fluids;
|
||||||
import net.minecraft.item.ItemPlacementContext;
|
import net.minecraft.world.item.ItemPlacementContext;
|
||||||
import net.minecraft.state.StateManager;
|
import net.minecraft.world.level.block.state.StateDefinition;
|
||||||
import net.minecraft.state.property.BooleanProperty;
|
import net.minecraft.state.property.BooleanProperty;
|
||||||
import net.minecraft.state.property.EnumProperty;
|
import net.minecraft.state.property.EnumProperty;
|
||||||
import net.minecraft.state.property.Properties;
|
import net.minecraft.state.property.Properties;
|
||||||
import net.minecraft.util.BlockMirror;
|
import net.minecraft.util.BlockMirror;
|
||||||
import net.minecraft.util.BlockRotation;
|
import net.minecraft.world.level.block.Rotation;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.util.math.Direction.Axis;
|
import net.minecraft.core.Direction.Axis;
|
||||||
import net.minecraft.util.shape.VoxelShape;
|
import net.minecraft.util.shape.VoxelShape;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import net.minecraft.world.WorldAccess;
|
import net.minecraft.world.level.LevelAccessor;
|
||||||
import ru.betterend.blocks.BlockProperties.TripleShape;
|
import ru.betterend.blocks.BlockProperties.TripleShape;
|
||||||
import ru.betterend.blocks.basis.BlockBase;
|
import ru.betterend.blocks.basis.BlockBase;
|
||||||
import ru.betterend.client.render.ERenderLayer;
|
import ru.betterend.client.render.ERenderLayer;
|
||||||
|
@ -40,33 +40,36 @@ public class EndLotusStemBlock extends BlockBase implements Waterloggable, IRend
|
||||||
|
|
||||||
public EndLotusStemBlock() {
|
public EndLotusStemBlock() {
|
||||||
super(FabricBlockSettings.copyOf(Blocks.OAK_PLANKS));
|
super(FabricBlockSettings.copyOf(Blocks.OAK_PLANKS));
|
||||||
this.setDefaultState(getDefaultState().with(WATERLOGGED, false).with(SHAPE, TripleShape.MIDDLE).with(LEAF, false).with(FACING, Direction.UP));
|
this.setDefaultState(getDefaultState().with(WATERLOGGED, false).with(SHAPE, TripleShape.MIDDLE)
|
||||||
|
.with(LEAF, false).with(FACING, Direction.UP));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
|
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
|
||||||
return state.get(LEAF) ? SHAPES.get(Axis.Y) : SHAPES.get(state.get(FACING).getAxis());
|
return state.getValue(LEAF) ? SHAPES.get(Axis.Y) : SHAPES.get(state.getValue(FACING).getAxis());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
||||||
builder.add(FACING, WATERLOGGED, SHAPE, LEAF);
|
builder.add(FACING, WATERLOGGED, SHAPE, LEAF);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FluidState getFluidState(BlockState state) {
|
public FluidState getFluidState(BlockState state) {
|
||||||
return (Boolean) state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(state);
|
return (Boolean) state.getValue(WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getPlacementState(ItemPlacementContext ctx) {
|
public BlockState getPlacementState(ItemPlacementContext ctx) {
|
||||||
WorldAccess worldAccess = ctx.getWorld();
|
LevelAccessor worldAccess = ctx.getLevel();
|
||||||
BlockPos blockPos = ctx.getBlockPos();
|
BlockPos blockPos = ctx.getBlockPos();
|
||||||
return this.getDefaultState().with(WATERLOGGED, worldAccess.getFluidState(blockPos).getFluid() == Fluids.WATER).with(FACING, ctx.getSide());
|
return this.defaultBlockState()
|
||||||
|
.with(WATERLOGGED, worldAccess.getFluidState(blockPos).getFluid() == Fluids.WATER)
|
||||||
|
.with(FACING, ctx.getSide());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState rotate(BlockState state, BlockRotation rotation) {
|
public BlockState rotate(BlockState state, Rotation rotation) {
|
||||||
return BlocksHelper.rotateHorizontal(state, rotation, FACING);
|
return BlocksHelper.rotateHorizontal(state, rotation, FACING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,8 +79,9 @@ public class EndLotusStemBlock extends BlockBase implements Waterloggable, IRend
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState newState, WorldAccess world, BlockPos pos, BlockPos posFrom) {
|
public BlockState updateShape(BlockState state, Direction direction, BlockState newState, LevelAccessor world,
|
||||||
if ((Boolean) state.get(WATERLOGGED)) {
|
BlockPos pos, BlockPos posFrom) {
|
||||||
|
if ((Boolean) state.getValue(WATERLOGGED)) {
|
||||||
world.getFluidTickScheduler().schedule(pos, Fluids.WATER, Fluids.WATER.getTickRate(world));
|
world.getFluidTickScheduler().schedule(pos, Fluids.WATER, Fluids.WATER.getTickRate(world));
|
||||||
}
|
}
|
||||||
return state;
|
return state;
|
||||||
|
|
|
@ -7,20 +7,20 @@ import java.util.Map;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.block.ShapeContext;
|
import net.minecraft.world.level.block.ShapeContext;
|
||||||
import net.minecraft.enchantment.EnchantmentHelper;
|
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||||
import net.minecraft.enchantment.Enchantments;
|
import net.minecraft.world.item.enchantment.Enchantments;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.loot.context.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import net.minecraft.loot.context.LootContextParameters;
|
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.util.shape.VoxelShape;
|
import net.minecraft.util.shape.VoxelShape;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import ru.betterend.blocks.basis.BlockBaseNotFull;
|
import ru.betterend.blocks.basis.BlockBaseNotFull;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.patterns.Patterns;
|
||||||
|
|
||||||
|
@ -28,7 +28,9 @@ public class EndPathBlock extends BlockBaseNotFull {
|
||||||
private static final VoxelShape SHAPE = Block.createCuboidShape(0, 0, 0, 16, 15, 16);
|
private static final VoxelShape SHAPE = Block.createCuboidShape(0, 0, 0, 16, 15, 16);
|
||||||
|
|
||||||
public EndPathBlock(Block source) {
|
public EndPathBlock(Block source) {
|
||||||
super(FabricBlockSettings.copyOf(source).allowsSpawning((state, world, pos, type) -> { return false; }));
|
super(FabricBlockSettings.copyOf(source).allowsSpawning((state, world, pos, type) -> {
|
||||||
|
return false;
|
||||||
|
}));
|
||||||
if (source instanceof EndTerrainBlock) {
|
if (source instanceof EndTerrainBlock) {
|
||||||
EndTerrainBlock terrain = (EndTerrainBlock) source;
|
EndTerrainBlock terrain = (EndTerrainBlock) source;
|
||||||
terrain.setPathBlock(this);
|
terrain.setPathBlock(this);
|
||||||
|
@ -36,9 +38,9 @@ public class EndPathBlock extends BlockBaseNotFull {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
ItemStack tool = builder.get(LootContextParameters.TOOL);
|
ItemStack tool = builder.getParameter(LootContextParams.TOOL);
|
||||||
if (tool != null && EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, tool) > 0) {
|
if (tool != null && EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) {
|
||||||
return Collections.singletonList(new ItemStack(this));
|
return Collections.singletonList(new ItemStack(this));
|
||||||
}
|
}
|
||||||
return Collections.singletonList(new ItemStack(Blocks.END_STONE));
|
return Collections.singletonList(new ItemStack(Blocks.END_STONE));
|
||||||
|
@ -56,7 +58,7 @@ public class EndPathBlock extends BlockBaseNotFull {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String block) {
|
public String getModelPattern(String block) {
|
||||||
String name = Registry.BLOCK.getId(this).getPath();
|
String name = Registry.BLOCK.getKey(this).getPath();
|
||||||
Map<String, String> map = Maps.newHashMap();
|
Map<String, String> map = Maps.newHashMap();
|
||||||
map.put("%top%", name + "_top");
|
map.put("%top%", name + "_top");
|
||||||
map.put("%side%", name.replace("_path", "") + "_side");
|
map.put("%side%", name.replace("_path", "") + "_side");
|
||||||
|
@ -64,7 +66,7 @@ public class EndPathBlock extends BlockBaseNotFull {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Identifier statePatternId() {
|
public ResourceLocation statePatternId() {
|
||||||
return Patterns.STATE_ROTATED_TOP;
|
return Patterns.STATE_ROTATED_TOP;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package ru.betterend.blocks;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import ru.betterend.BetterEnd;
|
import ru.betterend.BetterEnd;
|
||||||
import ru.betterend.blocks.basis.PedestalBlock;
|
import ru.betterend.blocks.basis.PedestalBlock;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.patterns.Patterns;
|
||||||
|
@ -18,12 +18,12 @@ public class EndPedestal extends PedestalBlock {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String block) {
|
public String getModelPattern(String block) {
|
||||||
Identifier blockId = Registry.BLOCK.getId(parent);
|
ResourceLocation blockId = Registry.BLOCK.getKey(parent);
|
||||||
String name = blockId.getPath();
|
String name = blockId.getPath();
|
||||||
Map<String, String> textures = new HashMap<String, String>() {
|
Map<String, String> textures = new HashMap<String, String>() {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
{
|
{
|
||||||
put("%mod%", BetterEnd.MOD_ID );
|
put("%mod%", BetterEnd.MOD_ID);
|
||||||
put("%top%", name + "_polished");
|
put("%top%", name + "_polished");
|
||||||
put("%base%", name + "_polished");
|
put("%base%", name + "_polished");
|
||||||
put("%pillar%", name + "_pillar_side");
|
put("%pillar%", name + "_pillar_side");
|
||||||
|
|
|
@ -6,30 +6,30 @@ import java.util.Random;
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.block.NetherPortalBlock;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.client.color.block.BlockColorProvider;
|
import net.minecraft.sounds.SoundEvents;
|
||||||
import net.minecraft.client.color.item.ItemColorProvider;
|
import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.world.level.Level;
|
||||||
|
import net.minecraft.world.level.LevelAccessor;
|
||||||
|
import net.minecraft.world.level.block.Block;
|
||||||
|
import net.minecraft.world.level.block.Rotation;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import net.minecraft.world.level.block.Blocks;
|
||||||
|
import net.minecraft.world.level.block.NetherPortalBlock;
|
||||||
|
import net.minecraft.client.color.block.BlockColor;
|
||||||
|
import net.minecraft.client.color.item.ItemColor;
|
||||||
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.world.level.block.state.StateDefinition;
|
||||||
import net.minecraft.server.world.ServerWorld;
|
import net.minecraft.world.level.block.state.properties.IntegerProperty;
|
||||||
import net.minecraft.sound.SoundCategory;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.sound.SoundEvents;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.state.StateManager;
|
import net.minecraft.core.Direction.Axis;
|
||||||
import net.minecraft.state.property.IntProperty;
|
import net.minecraft.core.Direction.AxisDirection;
|
||||||
import net.minecraft.util.BlockRotation;
|
import net.minecraft.world.level.dimension.DimensionType;
|
||||||
import net.minecraft.util.Identifier;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.util.math.Direction;
|
|
||||||
import net.minecraft.util.math.Direction.Axis;
|
|
||||||
import net.minecraft.util.math.Direction.AxisDirection;
|
|
||||||
import net.minecraft.util.registry.Registry;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraft.world.WorldAccess;
|
|
||||||
import net.minecraft.world.dimension.DimensionType;
|
|
||||||
import ru.betterend.client.render.ERenderLayer;
|
import ru.betterend.client.render.ERenderLayer;
|
||||||
import ru.betterend.interfaces.IColorProvider;
|
import ru.betterend.interfaces.IColorProvider;
|
||||||
import ru.betterend.interfaces.IRenderTypeable;
|
import ru.betterend.interfaces.IRenderTypeable;
|
||||||
|
@ -39,30 +39,32 @@ import ru.betterend.registry.EndPortals;
|
||||||
import ru.betterend.rituals.EternalRitual;
|
import ru.betterend.rituals.EternalRitual;
|
||||||
|
|
||||||
public class EndPortalBlock extends NetherPortalBlock implements IRenderTypeable, IColorProvider {
|
public class EndPortalBlock extends NetherPortalBlock implements IRenderTypeable, IColorProvider {
|
||||||
public static final IntProperty PORTAL = BlockProperties.PORTAL;
|
public static final IntegerProperty PORTAL = BlockProperties.PORTAL;
|
||||||
|
|
||||||
public EndPortalBlock() {
|
public EndPortalBlock() {
|
||||||
super(FabricBlockSettings.copyOf(Blocks.NETHER_PORTAL).resistance(Blocks.BEDROCK.getBlastResistance()).luminance(15));
|
super(FabricBlockSettings.copyOf(Blocks.NETHER_PORTAL).resistance(Blocks.BEDROCK.getExplosionResistance())
|
||||||
|
.luminance(15));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
||||||
super.appendProperties(builder);
|
super.createBlockStateDefinition(builder);
|
||||||
builder.add(PORTAL);
|
builder.add(PORTAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) {
|
public void animateTick(BlockState state, Level world, BlockPos pos, Random random) {
|
||||||
if (random.nextInt(100) == 0) {
|
if (random.nextInt(100) == 0) {
|
||||||
world.playSound(pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, SoundEvents.BLOCK_PORTAL_AMBIENT, SoundCategory.BLOCKS, 0.5F, random.nextFloat() * 0.4F + 0.8F, false);
|
world.playLocalSound(pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, SoundEvents.PORTAL_AMBIENT,
|
||||||
|
SoundSource.BLOCKS, 0.5F, random.nextFloat() * 0.4F + 0.8F, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
double x = pos.getX() + random.nextDouble();
|
double x = pos.getX() + random.nextDouble();
|
||||||
double y = pos.getY() + random.nextDouble();
|
double y = pos.getY() + random.nextDouble();
|
||||||
double z = pos.getZ() + random.nextDouble();
|
double z = pos.getZ() + random.nextDouble();
|
||||||
int k = random.nextInt(2) * 2 - 1;
|
int k = random.nextInt(2) * 2 - 1;
|
||||||
if (!world.getBlockState(pos.west()).isOf(this) && !world.getBlockState(pos.east()).isOf(this)) {
|
if (!world.getBlockState(pos.west()).is(this) && !world.getBlockState(pos.east()).is(this)) {
|
||||||
x = pos.getX() + 0.5D + 0.25D * k;
|
x = pos.getX() + 0.5D + 0.25D * k;
|
||||||
} else {
|
} else {
|
||||||
z = pos.getZ() + 0.5D + 0.25D * k;
|
z = pos.getZ() + 0.5D + 0.25D * k;
|
||||||
|
@ -72,49 +74,50 @@ public class EndPortalBlock extends NetherPortalBlock implements IRenderTypeable
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {}
|
public BlockState updateShape(BlockState state, Direction direction, BlockState newState, LevelAccessor world,
|
||||||
|
BlockPos pos, BlockPos posFrom) {
|
||||||
@Override
|
|
||||||
public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState newState, WorldAccess world, BlockPos pos, BlockPos posFrom) {
|
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) {
|
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
|
||||||
if (world.isClient || !validate(entity)) return;
|
if (world.isClientSide() || !validate(entity))
|
||||||
entity.resetNetherPortalCooldown();
|
return;
|
||||||
ServerWorld currentWorld = (ServerWorld) world;
|
entity.setPortalCooldown();
|
||||||
|
ServerLevel currentWorld = (ServerLevel) world;
|
||||||
MinecraftServer server = currentWorld.getServer();
|
MinecraftServer server = currentWorld.getServer();
|
||||||
ServerWorld targetWorld = EndPortals.getWorld(server, state.get(PORTAL));
|
ServerLevel targetWorld = EndPortals.getLevel(server, state.getValue(PORTAL));
|
||||||
boolean isInEnd = currentWorld.getRegistryKey().equals(World.END);
|
boolean isInEnd = currentWorld.dimension().equals(Level.END);
|
||||||
ServerWorld destination = isInEnd ? targetWorld : server.getWorld(World.END);
|
ServerLevel destination = isInEnd ? targetWorld : server.getLevel(Level.END);
|
||||||
BlockPos exitPos = findExitPos(currentWorld, destination, pos, entity);
|
BlockPos exitPos = findExitPos(currentWorld, destination, pos, entity);
|
||||||
if (exitPos == null) return;
|
if (exitPos == null)
|
||||||
if (entity instanceof ServerPlayerEntity) {
|
return;
|
||||||
ServerPlayerEntity player = (ServerPlayerEntity) entity;
|
if (entity instanceof ServerPlayer) {
|
||||||
|
ServerPlayer player = (ServerPlayer) entity;
|
||||||
teleportPlayer(player, destination, exitPos);
|
teleportPlayer(player, destination, exitPos);
|
||||||
} else {
|
} else {
|
||||||
TeleportingEntity teleEntity = (TeleportingEntity) entity;
|
TeleportingEntity teleEntity = (TeleportingEntity) entity;
|
||||||
teleEntity.beSetExitPos(exitPos);
|
teleEntity.beSetExitPos(exitPos);
|
||||||
Entity teleported = entity.moveToWorld(destination);
|
Entity teleported = entity.changeDimension(destination);
|
||||||
if (teleported != null) {
|
if (teleported != null) {
|
||||||
teleported.resetNetherPortalCooldown();
|
teleported.setPortalCooldown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean validate(Entity entity) {
|
private boolean validate(Entity entity) {
|
||||||
return !entity.hasVehicle() && !entity.hasPassengers() &&
|
return !entity.isPassenger() && !entity.isVehicle() && entity.canChangeDimensions()
|
||||||
entity.canUsePortals() && !entity.hasNetherPortalCooldown();
|
&& !entity.isOnPortalCooldown();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void teleportPlayer(ServerPlayerEntity player, ServerWorld destination, BlockPos exitPos) {
|
private void teleportPlayer(ServerPlayer player, ServerLevel destination, BlockPos exitPos) {
|
||||||
if (player.isCreative()) {
|
if (player.isCreative()) {
|
||||||
player.teleport(destination, exitPos.getX() + 0.5, exitPos.getY(), exitPos.getZ() + 0.5, player.yaw, player.pitch);
|
player.teleportTo(destination, exitPos.getX() + 0.5, exitPos.getY(), exitPos.getZ() + 0.5, player.yRot,
|
||||||
|
player.xRot);
|
||||||
} else {
|
} else {
|
||||||
TeleportingEntity teleEntity = (TeleportingEntity) player;
|
TeleportingEntity teleEntity = (TeleportingEntity) player;
|
||||||
teleEntity.beSetExitPos(exitPos);
|
teleEntity.beSetExitPos(exitPos);
|
||||||
player.moveToWorld(destination);
|
player.changeDimension(destination);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,70 +126,75 @@ public class EndPortalBlock extends NetherPortalBlock implements IRenderTypeable
|
||||||
return ERenderLayer.TRANSLUCENT;
|
return ERenderLayer.TRANSLUCENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
private BlockPos findExitPos(ServerWorld currentWorld, ServerWorld targetWorld, BlockPos currentPos, Entity entity) {
|
private BlockPos findExitPos(ServerLevel currentWorld, ServerLevel targetWorld, BlockPos currentPos,
|
||||||
if (targetWorld == null) return null;
|
Entity entity) {
|
||||||
Registry<DimensionType> registry = targetWorld.getRegistryManager().getDimensionTypes();
|
if (targetWorld == null)
|
||||||
Identifier targetWorldId = targetWorld.getRegistryKey().getValue();
|
return null;
|
||||||
Identifier currentWorldId = currentWorld.getRegistryKey().getValue();
|
Registry<DimensionType> registry = targetWorld.registryAccess().dimensionTypes();
|
||||||
double targetMultiplier = Objects.requireNonNull(registry.get(targetWorldId)).getCoordinateScale();
|
ResourceLocation targetWorldId = targetWorld.dimension().location();
|
||||||
double currentMultiplier = Objects.requireNonNull(registry.get(currentWorldId)).getCoordinateScale();
|
ResourceLocation currentWorldId = currentWorld.dimension().location();
|
||||||
|
double targetMultiplier = Objects.requireNonNull(registry.get(targetWorldId)).coordinateScale();
|
||||||
|
double currentMultiplier = Objects.requireNonNull(registry.get(currentWorldId)).coordinateScale();
|
||||||
double multiplier = targetMultiplier > currentMultiplier ? 1.0 / targetMultiplier : currentMultiplier;
|
double multiplier = targetMultiplier > currentMultiplier ? 1.0 / targetMultiplier : currentMultiplier;
|
||||||
BlockPos.Mutable basePos = currentPos.mutableCopy().set(currentPos.getX() * multiplier, currentPos.getY(), currentPos.getZ() * multiplier);
|
BlockPos.MutableBlockPos basePos = currentPos.mutable().set(currentPos.getX() * multiplier, currentPos.getY(),
|
||||||
BlockPos.Mutable checkPos = basePos.mutableCopy();
|
currentPos.getZ() * multiplier);
|
||||||
|
BlockPos.MutableBlockPos checkPos = basePos.mutable();
|
||||||
BlockState currentState = currentWorld.getBlockState(currentPos);
|
BlockState currentState = currentWorld.getBlockState(currentPos);
|
||||||
int radius = (EternalRitual.SEARCH_RADIUS >> 4) + 1;
|
int radius = (EternalRitual.SEARCH_RADIUS >> 4) + 1;
|
||||||
checkPos = EternalRitual.findBlockPos(targetWorld, checkPos, radius, this, state -> state.isOf(this) &&
|
checkPos = EternalRitual.findBlockPos(targetWorld, checkPos, radius, this,
|
||||||
state.get(PORTAL).equals(currentState.get(PORTAL)));
|
state -> state.is(this) && state.getValue(PORTAL).equals(currentState.getValue(PORTAL)));
|
||||||
if (checkPos != null) {
|
if (checkPos != null) {
|
||||||
BlockState checkState = targetWorld.getBlockState(checkPos);
|
BlockState checkState = targetWorld.getBlockState(checkPos);
|
||||||
Axis axis = checkState.get(AXIS);
|
Axis axis = checkState.getValue(AXIS);
|
||||||
checkPos = findCenter(targetWorld, checkPos, axis);
|
checkPos = findCenter(targetWorld, checkPos, axis);
|
||||||
Direction frontDir = Direction.from(axis, AxisDirection.POSITIVE).rotateYClockwise();
|
Direction frontDir = Direction.fromAxisAndDirection(axis, AxisDirection.POSITIVE).getClockWise();
|
||||||
Direction entityDir = entity.getMovementDirection();
|
Direction entityDir = entity.getMotionDirection();
|
||||||
if (entityDir.getAxis().isVertical()) {
|
if (entityDir.getAxis().isVertical()) {
|
||||||
entityDir = frontDir;
|
entityDir = frontDir;
|
||||||
}
|
}
|
||||||
if (frontDir != entityDir && frontDir.getOpposite() != entityDir) {
|
if (frontDir != entityDir && frontDir.getOpposite() != entityDir) {
|
||||||
entity.applyRotation(BlockRotation.CLOCKWISE_90);
|
entity.rotate(Rotation.CLOCKWISE_90);
|
||||||
entityDir = entityDir.rotateYClockwise();
|
entityDir = entityDir.getClockWise();
|
||||||
}
|
}
|
||||||
return checkPos.offset(entityDir);
|
return checkPos.move(entityDir);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private BlockPos.Mutable findCenter(World world, BlockPos.Mutable pos, Direction.Axis axis) {
|
private BlockPos.MutableBlockPos findCenter(Level world, BlockPos.MutableBlockPos pos, Direction.Axis axis) {
|
||||||
return findCenter(world, pos, axis, 1);
|
return findCenter(world, pos, axis, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private BlockPos.Mutable findCenter(World world, BlockPos.Mutable pos, Direction.Axis axis, int step) {
|
private BlockPos.MutableBlockPos findCenter(Level world, BlockPos.MutableBlockPos pos, Direction.Axis axis,
|
||||||
if (step > 8) return pos;
|
int step) {
|
||||||
|
if (step > 8)
|
||||||
|
return pos;
|
||||||
BlockState right, left;
|
BlockState right, left;
|
||||||
Direction rightDir, leftDir;
|
Direction rightDir, leftDir;
|
||||||
rightDir = Direction.from(axis, AxisDirection.POSITIVE);
|
rightDir = Direction.fromAxisAndDirection(axis, AxisDirection.POSITIVE);
|
||||||
leftDir = rightDir.getOpposite();
|
leftDir = rightDir.getOpposite();
|
||||||
right = world.getBlockState(pos.offset(rightDir));
|
right = world.getBlockState(pos.relative(rightDir));
|
||||||
left = world.getBlockState(pos.offset(leftDir));
|
left = world.getBlockState(pos.relative(leftDir));
|
||||||
BlockState down = world.getBlockState(pos.down());
|
BlockState down = world.getBlockState(pos.below());
|
||||||
if (down.isOf(this)) {
|
if (down.is(this)) {
|
||||||
return findCenter(world, pos.move(Direction.DOWN), axis, step);
|
return findCenter(world, pos.move(Direction.DOWN), axis, step);
|
||||||
} else if (right.isOf(this) && left.isOf(this)) {
|
} else if (right.is(this) && left.is(this)) {
|
||||||
return pos;
|
return pos;
|
||||||
} else if (right.isOf(this)) {
|
} else if (right.is(this)) {
|
||||||
return findCenter(world, pos.move(rightDir), axis, ++step);
|
return findCenter(world, pos.move(rightDir), axis, ++step);
|
||||||
} else if (left.isOf(this)) {
|
} else if (left.is(this)) {
|
||||||
return findCenter(world, pos.move(leftDir), axis, ++step);
|
return findCenter(world, pos.move(leftDir), axis, ++step);
|
||||||
}
|
}
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockColorProvider getProvider() {
|
public BlockColor getBlockProvider() {
|
||||||
return (state, world, pos, tintIndex) -> EndPortals.getColor(state.get(PORTAL));
|
return (state, world, pos, tintIndex) -> EndPortals.getColor(state.getValue(PORTAL));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemColorProvider getItemProvider() {
|
public ItemColor getItemProvider() {
|
||||||
return (stack, tintIndex) -> EndPortals.getColor(0);
|
return (stack, tintIndex) -> EndPortals.getColor(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package ru.betterend.blocks;
|
package ru.betterend.blocks;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.block.MaterialColor;
|
import net.minecraft.world.level.material.MaterialColor;
|
||||||
import net.minecraft.sound.BlockSoundGroup;
|
import net.minecraft.world.level.block.SoundType;
|
||||||
import ru.betterend.blocks.basis.BlockBase;
|
import ru.betterend.blocks.basis.BlockBase;
|
||||||
|
|
||||||
public class EndStoneBlock extends BlockBase {
|
public class EndStoneBlock extends BlockBase {
|
||||||
public EndStoneBlock(MaterialColor color) {
|
public EndStoneBlock(MaterialColor color) {
|
||||||
super(FabricBlockSettings.copyOf(Blocks.END_STONE).materialColor(color).sounds(BlockSoundGroup.STONE));
|
super(FabricBlockSettings.copyOf(Blocks.END_STONE).materialColor(color).sounds(SoundType.STONE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,36 +8,36 @@ import com.google.common.collect.Lists;
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.block.BlockRenderType;
|
import net.minecraft.world.level.block.BlockRenderType;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.block.HorizontalFacingBlock;
|
import net.minecraft.world.level.block.HorizontalFacingBlock;
|
||||||
import net.minecraft.block.Material;
|
import net.minecraft.world.level.material.Material;
|
||||||
import net.minecraft.block.MaterialColor;
|
import net.minecraft.world.level.material.MaterialColor;
|
||||||
import net.minecraft.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.world.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemPlacementContext;
|
import net.minecraft.world.item.ItemPlacementContext;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.loot.context.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import net.minecraft.loot.context.LootContextParameters;
|
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||||
import net.minecraft.particle.ParticleTypes;
|
import net.minecraft.core.particles.ParticleTypes;
|
||||||
import net.minecraft.screen.ScreenHandler;
|
import net.minecraft.screen.ScreenHandler;
|
||||||
import net.minecraft.sound.BlockSoundGroup;
|
import net.minecraft.world.level.block.SoundType;
|
||||||
import net.minecraft.sound.SoundCategory;
|
import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.sound.SoundEvents;
|
import net.minecraft.sounds.SoundEvents;
|
||||||
import net.minecraft.state.StateManager;
|
import net.minecraft.world.level.block.state.StateDefinition;
|
||||||
import net.minecraft.state.property.BooleanProperty;
|
import net.minecraft.state.property.BooleanProperty;
|
||||||
import net.minecraft.state.property.DirectionProperty;
|
import net.minecraft.state.property.DirectionProperty;
|
||||||
import net.minecraft.state.property.Properties;
|
import net.minecraft.state.property.Properties;
|
||||||
import net.minecraft.util.ActionResult;
|
import net.minecraft.util.ActionResult;
|
||||||
import net.minecraft.util.BlockMirror;
|
import net.minecraft.util.BlockMirror;
|
||||||
import net.minecraft.util.BlockRotation;
|
import net.minecraft.world.level.block.Rotation;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.hit.BlockHitResult;
|
import net.minecraft.util.hit.BlockHitResult;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.level.Level;
|
||||||
import ru.betterend.blocks.basis.BaseBlockWithEntity;
|
import ru.betterend.blocks.basis.BaseBlockWithEntity;
|
||||||
import ru.betterend.blocks.entities.EndStoneSmelterBlockEntity;
|
import ru.betterend.blocks.entities.EndStoneSmelterBlockEntity;
|
||||||
|
|
||||||
|
@ -47,18 +47,14 @@ public class EndStoneSmelter extends BaseBlockWithEntity {
|
||||||
public static final String ID = "end_stone_smelter";
|
public static final String ID = "end_stone_smelter";
|
||||||
|
|
||||||
public EndStoneSmelter() {
|
public EndStoneSmelter() {
|
||||||
super(FabricBlockSettings.of(Material.STONE, MaterialColor.GRAY)
|
super(FabricBlockSettings.of(Material.STONE, MaterialColor.COLOR_GRAY).hardness(4F).resistance(100F)
|
||||||
.hardness(4F)
|
.requiresTool().sounds(SoundType.STONE));
|
||||||
.resistance(100F)
|
this.setDefaultState(this.stateManager.defaultBlockState().with(FACING, Direction.NORTH).with(LIT, false));
|
||||||
.requiresTool()
|
|
||||||
.sounds(BlockSoundGroup.STONE));
|
|
||||||
this.setDefaultState(this.stateManager.getDefaultState()
|
|
||||||
.with(FACING, Direction.NORTH)
|
|
||||||
.with(LIT, false));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
|
public ActionResult onUse(BlockState state, Level world, BlockPos pos, PlayerEntity player, Hand hand,
|
||||||
if (world.isClient) {
|
BlockHitResult hit) {
|
||||||
|
if (world.isClientSide) {
|
||||||
return ActionResult.SUCCESS;
|
return ActionResult.SUCCESS;
|
||||||
} else {
|
} else {
|
||||||
this.openScreen(world, pos, player);
|
this.openScreen(world, pos, player);
|
||||||
|
@ -66,7 +62,7 @@ public class EndStoneSmelter extends BaseBlockWithEntity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openScreen(World world, BlockPos pos, PlayerEntity player) {
|
private void openScreen(Level world, BlockPos pos, PlayerEntity player) {
|
||||||
BlockEntity blockEntity = world.getBlockEntity(pos);
|
BlockEntity blockEntity = world.getBlockEntity(pos);
|
||||||
if (blockEntity instanceof EndStoneSmelterBlockEntity) {
|
if (blockEntity instanceof EndStoneSmelterBlockEntity) {
|
||||||
player.openHandledScreen((EndStoneSmelterBlockEntity) blockEntity);
|
player.openHandledScreen((EndStoneSmelterBlockEntity) blockEntity);
|
||||||
|
@ -75,7 +71,7 @@ public class EndStoneSmelter extends BaseBlockWithEntity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getPlacementState(ItemPlacementContext ctx) {
|
public BlockState getPlacementState(ItemPlacementContext ctx) {
|
||||||
return this.getDefaultState().with(FACING, ctx.getPlayerFacing().getOpposite());
|
return this.defaultBlockState().with(FACING, ctx.getPlayerFacing().getOpposite());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -84,9 +80,9 @@ public class EndStoneSmelter extends BaseBlockWithEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
List<ItemStack> drop = Lists.newArrayList(new ItemStack(this));
|
List<ItemStack> drop = Lists.newArrayList(new ItemStack(this));
|
||||||
BlockEntity blockEntity = builder.getNullable(LootContextParameters.BLOCK_ENTITY);
|
BlockEntity blockEntity = builder.getNullable(LootContextParams.BLOCK_ENTITY);
|
||||||
if (blockEntity instanceof EndStoneSmelterBlockEntity) {
|
if (blockEntity instanceof EndStoneSmelterBlockEntity) {
|
||||||
EndStoneSmelterBlockEntity smelterBlockEntity = (EndStoneSmelterBlockEntity) blockEntity;
|
EndStoneSmelterBlockEntity smelterBlockEntity = (EndStoneSmelterBlockEntity) blockEntity;
|
||||||
for (int i = 0; i < smelterBlockEntity.size(); i++) {
|
for (int i = 0; i < smelterBlockEntity.size(); i++) {
|
||||||
|
@ -105,8 +101,8 @@ public class EndStoneSmelter extends BaseBlockWithEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getComparatorOutput(BlockState state, World world, BlockPos pos) {
|
public int getComparatorOutput(BlockState state, Level world, BlockPos pos) {
|
||||||
//TODO
|
// TODO
|
||||||
return ScreenHandler.calculateComparatorOutput(world.getBlockEntity(pos));
|
return ScreenHandler.calculateComparatorOutput(world.getBlockEntity(pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,31 +112,32 @@ public class EndStoneSmelter extends BaseBlockWithEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState rotate(BlockState state, BlockRotation rotation) {
|
public BlockState rotate(BlockState state, Rotation rotation) {
|
||||||
return (BlockState)state.with(FACING, rotation.rotate((Direction)state.get(FACING)));
|
return (BlockState) state.with(FACING, rotation.rotate((Direction) state.getValue(FACING)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState mirror(BlockState state, BlockMirror mirror) {
|
public BlockState mirror(BlockState state, BlockMirror mirror) {
|
||||||
return state.rotate(mirror.getRotation((Direction)state.get(FACING)));
|
return state.rotate(mirror.getRotation((Direction) state.getValue(FACING)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
||||||
builder.add(FACING, LIT);
|
builder.add(FACING, LIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) {
|
public void animateTick(BlockState state, Level world, BlockPos pos, Random random) {
|
||||||
if (state.get(LIT)) {
|
if (state.getValue(LIT)) {
|
||||||
double x = pos.getX() + 0.5D;
|
double x = pos.getX() + 0.5D;
|
||||||
double y = pos.getY();
|
double y = pos.getY();
|
||||||
double z = pos.getZ() + 0.5D;
|
double z = pos.getZ() + 0.5D;
|
||||||
if (random.nextDouble() < 0.1D) {
|
if (random.nextDouble() < 0.1D) {
|
||||||
world.playSound(x, y, z, SoundEvents.BLOCK_BLASTFURNACE_FIRE_CRACKLE, SoundCategory.BLOCKS, 1.0F, 1.0F, false);
|
world.playLocalSound(x, y, z, SoundEvents.BLOCK_BLASTFURNACE_FIRE_CRACKLE, SoundSource.BLOCKS, 1.0F,
|
||||||
|
1.0F, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
Direction direction = (Direction)state.get(FACING);
|
Direction direction = (Direction) state.getValue(FACING);
|
||||||
Direction.Axis axis = direction.getAxis();
|
Direction.Axis axis = direction.getAxis();
|
||||||
double defOffset = random.nextDouble() * 0.6D - 0.3D;
|
double defOffset = random.nextDouble() * 0.6D - 0.3D;
|
||||||
double offX = axis == Direction.Axis.X ? direction.getOffsetX() * 0.52D : defOffset;
|
double offX = axis == Direction.Axis.X ? direction.getOffsetX() * 0.52D : defOffset;
|
||||||
|
|
|
@ -9,29 +9,29 @@ import com.google.common.collect.Maps;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.block.MaterialColor;
|
import net.minecraft.world.level.material.MaterialColor;
|
||||||
import net.minecraft.block.SnowBlock;
|
import net.minecraft.world.level.block.SnowBlock;
|
||||||
import net.minecraft.enchantment.EnchantmentHelper;
|
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||||
import net.minecraft.enchantment.Enchantments;
|
import net.minecraft.world.item.enchantment.Enchantments;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.world.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.loot.context.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import net.minecraft.loot.context.LootContextParameters;
|
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.server.world.ServerWorld;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.sound.SoundCategory;
|
import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.sound.SoundEvents;
|
import net.minecraft.sounds.SoundEvents;
|
||||||
import net.minecraft.util.ActionResult;
|
import net.minecraft.util.ActionResult;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.hit.BlockHitResult;
|
import net.minecraft.util.hit.BlockHitResult;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.WorldView;
|
import net.minecraft.world.WorldView;
|
||||||
import net.minecraft.world.chunk.light.ChunkLightProvider;
|
import net.minecraft.world.chunk.light.ChunkLightProvider;
|
||||||
import ru.betterend.blocks.basis.BlockBase;
|
import ru.betterend.blocks.basis.BlockBase;
|
||||||
|
@ -41,7 +41,8 @@ public class EndTerrainBlock extends BlockBase {
|
||||||
private Block pathBlock;
|
private Block pathBlock;
|
||||||
|
|
||||||
public EndTerrainBlock(MaterialColor color) {
|
public EndTerrainBlock(MaterialColor color) {
|
||||||
super(FabricBlockSettings.copyOf(Blocks.END_STONE).materialColor(color).sounds(BlockSounds.TERRAIN_SOUND).ticksRandomly());
|
super(FabricBlockSettings.copyOf(Blocks.END_STONE).materialColor(color).sounds(BlockSounds.TERRAIN_SOUND)
|
||||||
|
.ticksRandomly());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPathBlock(Block roadBlock) {
|
public void setPathBlock(Block roadBlock) {
|
||||||
|
@ -49,13 +50,14 @@ public class EndTerrainBlock extends BlockBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
|
public ActionResult onUse(BlockState state, Level world, BlockPos pos, PlayerEntity player, Hand hand,
|
||||||
|
BlockHitResult hit) {
|
||||||
if (pathBlock != null && player.getMainHandStack().getItem().isIn(FabricToolTags.SHOVELS)) {
|
if (pathBlock != null && player.getMainHandStack().getItem().isIn(FabricToolTags.SHOVELS)) {
|
||||||
world.playSound(player, pos, SoundEvents.ITEM_SHOVEL_FLATTEN, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
world.playLocalSound(player, pos, SoundEvents.ITEM_SHOVEL_FLATTEN, SoundSource.BLOCKS, 1.0F, 1.0F);
|
||||||
if (!world.isClient) {
|
if (!world.isClientSide) {
|
||||||
world.setBlockState(pos, pathBlock.getDefaultState());
|
world.setBlockAndUpdate(pos, pathBlock.defaultBlockState());
|
||||||
if (player != null && !player.isCreative()) {
|
if (player != null && !player.isCreative()) {
|
||||||
player.getMainHandStack().damage(1, world.random, (ServerPlayerEntity) player);
|
player.getMainHandStack().damage(1, world.random, (ServerPlayer) player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ActionResult.SUCCESS;
|
return ActionResult.SUCCESS;
|
||||||
|
@ -64,39 +66,38 @@ public class EndTerrainBlock extends BlockBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
ItemStack tool = builder.get(LootContextParameters.TOOL);
|
ItemStack tool = builder.getParameter(LootContextParams.TOOL);
|
||||||
if (tool != null && EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, tool) > 0) {
|
if (tool != null && EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) {
|
||||||
return Collections.singletonList(new ItemStack(this));
|
return Collections.singletonList(new ItemStack(this));
|
||||||
}
|
}
|
||||||
return Collections.singletonList(new ItemStack(Blocks.END_STONE));
|
return Collections.singletonList(new ItemStack(Blocks.END_STONE));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
|
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
|
||||||
if (random.nextInt(16) == 0 && !canSurvive(state, world, pos)) {
|
if (random.nextInt(16) == 0 && !canSurvive(state, world, pos)) {
|
||||||
world.setBlockState(pos, Blocks.END_STONE.getDefaultState());
|
world.setBlockAndUpdate(pos, Blocks.END_STONE.defaultBlockState());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean canSurvive(BlockState state, WorldView worldView, BlockPos pos) {
|
protected boolean canSurvive(BlockState state, WorldView worldView, BlockPos pos) {
|
||||||
BlockPos blockPos = pos.up();
|
BlockPos blockPos = pos.up();
|
||||||
BlockState blockState = worldView.getBlockState(blockPos);
|
BlockState blockState = worldView.getBlockState(blockPos);
|
||||||
if (blockState.isOf(Blocks.SNOW) && (Integer) blockState.get(SnowBlock.LAYERS) == 1) {
|
if (blockState.is(Blocks.SNOW) && (Integer) blockState.get(SnowBlock.LAYERS) == 1) {
|
||||||
return true;
|
return true;
|
||||||
}
|
} else if (blockState.getFluidState().getLevel() == 8) {
|
||||||
else if (blockState.getFluidState().getLevel() == 8) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
} else {
|
||||||
else {
|
int i = ChunkLightProvider.getRealisticOpacity(worldView, state, pos, blockState, blockPos, Direction.UP,
|
||||||
int i = ChunkLightProvider.getRealisticOpacity(worldView, state, pos, blockState, blockPos, Direction.UP, blockState.getOpacity(worldView, blockPos));
|
blockState.getOpacity(worldView, blockPos));
|
||||||
return i < 5;
|
return i < 5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String block) {
|
public String getModelPattern(String block) {
|
||||||
String name = Registry.BLOCK.getId(this).getPath();
|
String name = Registry.BLOCK.getKey(this).getPath();
|
||||||
Map<String, String> map = Maps.newHashMap();
|
Map<String, String> map = Maps.newHashMap();
|
||||||
map.put("%top%", "betterend:block/" + name + "_top");
|
map.put("%top%", "betterend:block/" + name + "_top");
|
||||||
map.put("%side%", "betterend:block/" + name + "_side");
|
map.put("%side%", "betterend:block/" + name + "_side");
|
||||||
|
@ -105,7 +106,7 @@ public class EndTerrainBlock extends BlockBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Identifier statePatternId() {
|
public ResourceLocation statePatternId() {
|
||||||
return Patterns.STATE_ROTATED_TOP;
|
return Patterns.STATE_ROTATED_TOP;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,22 +3,19 @@ package ru.betterend.blocks;
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.block.Material;
|
import net.minecraft.world.level.material.Material;
|
||||||
import net.minecraft.block.MaterialColor;
|
import net.minecraft.world.level.material.MaterialColor;
|
||||||
import net.minecraft.sound.BlockSoundGroup;
|
import net.minecraft.world.level.block.SoundType;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import ru.betterend.blocks.basis.BlockBase;
|
import ru.betterend.blocks.basis.BlockBase;
|
||||||
|
|
||||||
public class EnderBlock extends BlockBase {
|
public class EnderBlock extends BlockBase {
|
||||||
|
|
||||||
public EnderBlock() {
|
public EnderBlock() {
|
||||||
super(FabricBlockSettings.of(Material.STONE, MaterialColor.field_25708)
|
super(FabricBlockSettings.of(Material.STONE, MaterialColor.field_25708).hardness(5F).resistance(6F)
|
||||||
.hardness(5F)
|
.requiresTool().sounds(SoundType.STONE));
|
||||||
.resistance(6F)
|
|
||||||
.requiresTool()
|
|
||||||
.sounds(BlockSoundGroup.STONE));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
|
|
|
@ -7,13 +7,13 @@ import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.block.FallingBlock;
|
import net.minecraft.world.level.block.FallingBlock;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.loot.context.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import ru.betterend.util.MHelper;
|
import ru.betterend.util.MHelper;
|
||||||
|
|
||||||
public class EndstoneDustBlock extends FallingBlock {
|
public class EndstoneDustBlock extends FallingBlock {
|
||||||
|
@ -21,13 +21,12 @@ public class EndstoneDustBlock extends FallingBlock {
|
||||||
private static final int COLOR = MHelper.color(226, 239, 168);
|
private static final int COLOR = MHelper.color(226, 239, 168);
|
||||||
|
|
||||||
public EndstoneDustBlock() {
|
public EndstoneDustBlock() {
|
||||||
super(FabricBlockSettings.copyOf(Blocks.SAND)
|
super(FabricBlockSettings.copyOf(Blocks.SAND).breakByTool(FabricToolTags.SHOVELS)
|
||||||
.breakByTool(FabricToolTags.SHOVELS)
|
.materialColor(Blocks.END_STONE.defaultMaterialColor()));
|
||||||
.materialColor(Blocks.END_STONE.getDefaultMaterialColor()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
return Collections.singletonList(new ItemStack(this));
|
return Collections.singletonList(new ItemStack(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,23 +4,23 @@ import java.util.List;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.world.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.loot.context.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import net.minecraft.loot.context.LootContextParameters;
|
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||||
import net.minecraft.state.StateManager;
|
import net.minecraft.world.level.block.state.StateDefinition;
|
||||||
import net.minecraft.state.property.BooleanProperty;
|
import net.minecraft.state.property.BooleanProperty;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.WorldAccess;
|
import net.minecraft.world.level.LevelAccessor;
|
||||||
import net.minecraft.world.explosion.Explosion;
|
import net.minecraft.world.explosion.Explosion;
|
||||||
import ru.betterend.blocks.basis.PedestalBlock;
|
import ru.betterend.blocks.basis.PedestalBlock;
|
||||||
import ru.betterend.blocks.entities.EternalPedestalEntity;
|
import ru.betterend.blocks.entities.EternalPedestalEntity;
|
||||||
|
@ -37,7 +37,7 @@ public class EternalPedestal extends PedestalBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void checkRitual(World world, BlockPos pos) {
|
public void checkRitual(Level world, BlockPos pos) {
|
||||||
BlockEntity blockEntity = world.getBlockEntity(pos);
|
BlockEntity blockEntity = world.getBlockEntity(pos);
|
||||||
if (blockEntity instanceof EternalPedestalEntity) {
|
if (blockEntity instanceof EternalPedestalEntity) {
|
||||||
EternalPedestalEntity pedestal = (EternalPedestalEntity) blockEntity;
|
EternalPedestalEntity pedestal = (EternalPedestalEntity) blockEntity;
|
||||||
|
@ -46,7 +46,7 @@ public class EternalPedestal extends PedestalBlock {
|
||||||
if (pedestal.hasRitual()) {
|
if (pedestal.hasRitual()) {
|
||||||
EternalRitual ritual = pedestal.getRitual();
|
EternalRitual ritual = pedestal.getRitual();
|
||||||
if (ritual.isActive()) {
|
if (ritual.isActive()) {
|
||||||
Identifier targetWorld = ritual.getTargetWorldId();
|
ResourceLocation targetWorld = ritual.getTargetWorldId();
|
||||||
int portalId;
|
int portalId;
|
||||||
if (targetWorld != null) {
|
if (targetWorld != null) {
|
||||||
portalId = EndPortals.getPortalIdByWorld(targetWorld);
|
portalId = EndPortals.getPortalIdByWorld(targetWorld);
|
||||||
|
@ -56,12 +56,12 @@ public class EternalPedestal extends PedestalBlock {
|
||||||
ritual.disablePortal(portalId);
|
ritual.disablePortal(portalId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
world.setBlockState(pos, updatedState.with(ACTIVATED, false).with(HAS_LIGHT, false));
|
world.setBlockAndUpdate(pos, updatedState.with(ACTIVATED, false).with(HAS_LIGHT, false));
|
||||||
} else {
|
} else {
|
||||||
ItemStack itemStack = pedestal.getStack(0);
|
ItemStack itemStack = pedestal.getStack(0);
|
||||||
Identifier id = Registry.ITEM.getId(itemStack.getItem());
|
ResourceLocation id = Registry.ITEM.getId(itemStack.getItem());
|
||||||
if (EndPortals.isAvailableItem(id)) {
|
if (EndPortals.isAvailableItem(id)) {
|
||||||
world.setBlockState(pos, updatedState.with(ACTIVATED, true).with(HAS_LIGHT, true));
|
world.setBlockAndUpdate(pos, updatedState.with(ACTIVATED, true).with(HAS_LIGHT, true));
|
||||||
if (pedestal.hasRitual()) {
|
if (pedestal.hasRitual()) {
|
||||||
pedestal.getRitual().checkStructure();
|
pedestal.getRitual().checkStructure();
|
||||||
} else {
|
} else {
|
||||||
|
@ -74,9 +74,11 @@ public class EternalPedestal extends PedestalBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState newState, WorldAccess world, BlockPos pos, BlockPos posFrom) {
|
public BlockState updateShape(BlockState state, Direction direction, BlockState newState, LevelAccessor world,
|
||||||
BlockState updated = super.getStateForNeighborUpdate(state, direction, newState, world, pos, posFrom);
|
BlockPos pos, BlockPos posFrom) {
|
||||||
if (!updated.isOf(this)) return updated;
|
BlockState updated = super.updateShape(state, direction, newState, world, pos, posFrom);
|
||||||
|
if (!updated.is(this))
|
||||||
|
return updated;
|
||||||
if (!this.isPlaceable(updated)) {
|
if (!this.isPlaceable(updated)) {
|
||||||
return updated.with(ACTIVATED, false);
|
return updated.with(ACTIVATED, false);
|
||||||
}
|
}
|
||||||
|
@ -90,7 +92,7 @@ public class EternalPedestal extends PedestalBlock {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getBlastResistance() {
|
public float getBlastResistance() {
|
||||||
return Blocks.BEDROCK.getBlastResistance();
|
return Blocks.BEDROCK.getExplosionResistance();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -99,15 +101,16 @@ public class EternalPedestal extends PedestalBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
if (state.isOf(this)) {
|
if (state.is(this)) {
|
||||||
BlockProperties.PedestalState currentState = state.get(BlockProperties.PEDESTAL_STATE);
|
BlockProperties.PedestalState currentState = state.getValue(BlockProperties.PEDESTAL_STATE);
|
||||||
if (currentState.equals(BlockProperties.PedestalState.BOTTOM) || currentState.equals(BlockProperties.PedestalState.PILLAR)) {
|
if (currentState.equals(BlockProperties.PedestalState.BOTTOM)
|
||||||
|
|| currentState.equals(BlockProperties.PedestalState.PILLAR)) {
|
||||||
return Lists.newArrayList();
|
return Lists.newArrayList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<ItemStack> drop = Lists.newArrayList();
|
List<ItemStack> drop = Lists.newArrayList();
|
||||||
BlockEntity blockEntity = builder.getNullable(LootContextParameters.BLOCK_ENTITY);
|
BlockEntity blockEntity = builder.getNullable(LootContextParams.BLOCK_ENTITY);
|
||||||
if (blockEntity instanceof EternalPedestalEntity) {
|
if (blockEntity instanceof EternalPedestalEntity) {
|
||||||
EternalPedestalEntity pedestal = (EternalPedestalEntity) blockEntity;
|
EternalPedestalEntity pedestal = (EternalPedestalEntity) blockEntity;
|
||||||
if (!pedestal.isEmpty()) {
|
if (!pedestal.isEmpty()) {
|
||||||
|
@ -118,8 +121,8 @@ public class EternalPedestal extends PedestalBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
|
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
|
||||||
super.appendProperties(stateManager);
|
super.createBlockStateDefinition(stateManager);
|
||||||
stateManager.add(ACTIVATED);
|
stateManager.add(ACTIVATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,13 +4,13 @@ import java.util.List;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.world.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.loot.context.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import net.minecraft.world.explosion.Explosion;
|
import net.minecraft.world.explosion.Explosion;
|
||||||
|
|
||||||
public class EternalRunedFlavolite extends RunedFlavolite {
|
public class EternalRunedFlavolite extends RunedFlavolite {
|
||||||
|
@ -22,7 +22,7 @@ public class EternalRunedFlavolite extends RunedFlavolite {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getBlastResistance() {
|
public float getBlastResistance() {
|
||||||
return Blocks.BEDROCK.getBlastResistance();
|
return Blocks.BEDROCK.getExplosionResistance();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -31,7 +31,7 @@ public class EternalRunedFlavolite extends RunedFlavolite {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
return Lists.newArrayList();
|
return Lists.newArrayList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,12 +2,13 @@ package ru.betterend.blocks;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||||
import net.minecraft.block.Material;
|
import net.minecraft.world.level.material.Material;
|
||||||
import net.minecraft.sound.BlockSoundGroup;
|
import net.minecraft.world.level.block.SoundType;
|
||||||
import ru.betterend.blocks.basis.BlockBase;
|
import ru.betterend.blocks.basis.BlockBase;
|
||||||
|
|
||||||
public class FilaluxLanternBlock extends BlockBase {
|
public class FilaluxLanternBlock extends BlockBase {
|
||||||
public FilaluxLanternBlock() {
|
public FilaluxLanternBlock() {
|
||||||
super(FabricBlockSettings.of(Material.WOOD).luminance(15).sounds(BlockSoundGroup.WOOD).breakByTool(FabricToolTags.AXES));
|
super(FabricBlockSettings.of(Material.WOOD).luminance(15).sounds(SoundType.WOOD)
|
||||||
|
.breakByTool(FabricToolTags.AXES));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,18 +6,18 @@ import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||||
import net.minecraft.block.AbstractBlock;
|
import net.minecraft.world.level.block.AbstractBlock;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.block.Material;
|
import net.minecraft.world.level.material.Material;
|
||||||
import net.minecraft.block.ShapeContext;
|
import net.minecraft.world.level.block.ShapeContext;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.loot.context.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import net.minecraft.sound.BlockSoundGroup;
|
import net.minecraft.world.level.block.SoundType;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.shape.VoxelShape;
|
import net.minecraft.util.shape.VoxelShape;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import ru.betterend.blocks.basis.EndPlantBlock;
|
import ru.betterend.blocks.basis.EndPlantBlock;
|
||||||
import ru.betterend.interfaces.ISpetialItem;
|
import ru.betterend.interfaces.ISpetialItem;
|
||||||
|
|
||||||
|
@ -25,15 +25,13 @@ public class FlamaeaBlock extends EndPlantBlock implements ISpetialItem {
|
||||||
private static final VoxelShape SHAPE = Block.createCuboidShape(0, 0, 0, 16, 1, 16);
|
private static final VoxelShape SHAPE = Block.createCuboidShape(0, 0, 0, 16, 1, 16);
|
||||||
|
|
||||||
public FlamaeaBlock() {
|
public FlamaeaBlock() {
|
||||||
super(FabricBlockSettings.of(Material.PLANT)
|
super(FabricBlockSettings.of(Material.PLANT).breakByTool(FabricToolTags.SHEARS).sounds(SoundType.WET_GRASS)
|
||||||
.breakByTool(FabricToolTags.SHEARS)
|
|
||||||
.sounds(BlockSoundGroup.WET_GRASS)
|
|
||||||
.breakByHand(true));
|
.breakByHand(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isTerrain(BlockState state) {
|
protected boolean isTerrain(BlockState state) {
|
||||||
return state.isOf(Blocks.WATER);
|
return state.is(Blocks.WATER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -47,7 +45,7 @@ public class FlamaeaBlock extends EndPlantBlock implements ISpetialItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
return Lists.newArrayList(new ItemStack(this));
|
return Lists.newArrayList(new ItemStack(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,12 +2,13 @@ package ru.betterend.blocks;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||||
import net.minecraft.block.Material;
|
import net.minecraft.world.level.material.Material;
|
||||||
import net.minecraft.sound.BlockSoundGroup;
|
import net.minecraft.world.level.block.SoundType;
|
||||||
import ru.betterend.blocks.basis.BlockBase;
|
import ru.betterend.blocks.basis.BlockBase;
|
||||||
|
|
||||||
public class GlowingHymenophoreBlock extends BlockBase {
|
public class GlowingHymenophoreBlock extends BlockBase {
|
||||||
public GlowingHymenophoreBlock() {
|
public GlowingHymenophoreBlock() {
|
||||||
super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).sounds(BlockSoundGroup.WART_BLOCK).luminance(15));
|
super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).sounds(SoundType.WART_BLOCK)
|
||||||
|
.luminance(15));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,9 @@ package ru.betterend.blocks;
|
||||||
|
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import ru.betterend.blocks.basis.EndPlantBlock;
|
import ru.betterend.blocks.basis.EndPlantBlock;
|
||||||
import ru.betterend.registry.EndBlocks;
|
import ru.betterend.registry.EndBlocks;
|
||||||
|
|
||||||
|
|
|
@ -2,17 +2,17 @@ package ru.betterend.blocks;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.block.Material;
|
import net.minecraft.world.level.material.Material;
|
||||||
import net.minecraft.block.MaterialColor;
|
import net.minecraft.world.level.material.MaterialColor;
|
||||||
import net.minecraft.sound.BlockSoundGroup;
|
import net.minecraft.world.level.block.SoundType;
|
||||||
import net.minecraft.state.StateManager;
|
import net.minecraft.world.level.block.state.StateDefinition;
|
||||||
import net.minecraft.state.property.BooleanProperty;
|
import net.minecraft.state.property.BooleanProperty;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.world.WorldAccess;
|
import net.minecraft.world.level.LevelAccessor;
|
||||||
import net.minecraft.world.WorldView;
|
import net.minecraft.world.WorldView;
|
||||||
import ru.betterend.blocks.basis.BlockBase;
|
import ru.betterend.blocks.basis.BlockBase;
|
||||||
import ru.betterend.registry.EndBlocks;
|
import ru.betterend.registry.EndBlocks;
|
||||||
|
@ -21,32 +21,28 @@ public class GlowingPillarLuminophorBlock extends BlockBase {
|
||||||
public static final BooleanProperty NATURAL = BlockProperties.NATURAL;
|
public static final BooleanProperty NATURAL = BlockProperties.NATURAL;
|
||||||
|
|
||||||
public GlowingPillarLuminophorBlock() {
|
public GlowingPillarLuminophorBlock() {
|
||||||
super(FabricBlockSettings.of(Material.LEAVES)
|
super(FabricBlockSettings.of(Material.LEAVES).materialColor(MaterialColor.COLOR_ORANGE)
|
||||||
.materialColor(MaterialColor.ORANGE)
|
.breakByTool(FabricToolTags.SHEARS).sounds(SoundType.GRASS).strength(0.2F).luminance(15));
|
||||||
.breakByTool(FabricToolTags.SHEARS)
|
this.setDefaultState(this.stateManager.defaultBlockState().with(NATURAL, false));
|
||||||
.sounds(BlockSoundGroup.GRASS)
|
|
||||||
.strength(0.2F)
|
|
||||||
.luminance(15));
|
|
||||||
this.setDefaultState(this.stateManager.getDefaultState().with(NATURAL, false));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
||||||
return state.get(NATURAL) ? world.getBlockState(pos.down()).isOf(EndBlocks.GLOWING_PILLAR_ROOTS) : true;
|
return state.getValue(NATURAL) ? world.getBlockState(pos.below()).is(EndBlocks.GLOWING_PILLAR_ROOTS) : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
|
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world,
|
||||||
|
BlockPos pos, BlockPos neighborPos) {
|
||||||
if (!canPlaceAt(state, world, pos)) {
|
if (!canPlaceAt(state, world, pos)) {
|
||||||
return Blocks.AIR.getDefaultState();
|
return Blocks.AIR.defaultBlockState();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
|
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
|
||||||
stateManager.add(NATURAL);
|
stateManager.add(NATURAL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,13 +2,13 @@ package ru.betterend.blocks;
|
||||||
|
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.state.StateManager;
|
import net.minecraft.world.level.block.state.StateDefinition;
|
||||||
import net.minecraft.state.property.EnumProperty;
|
import net.minecraft.state.property.EnumProperty;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import ru.betterend.blocks.BlockProperties.TripleShape;
|
import ru.betterend.blocks.BlockProperties.TripleShape;
|
||||||
import ru.betterend.blocks.basis.UpDownPlantBlock;
|
import ru.betterend.blocks.basis.UpDownPlantBlock;
|
||||||
import ru.betterend.registry.EndBlocks;
|
import ru.betterend.registry.EndBlocks;
|
||||||
|
@ -17,13 +17,13 @@ public class GlowingPillarRootsBlock extends UpDownPlantBlock {
|
||||||
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
|
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
|
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
|
||||||
stateManager.add(SHAPE);
|
stateManager.add(SHAPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isTerrain(BlockState state) {
|
protected boolean isTerrain(BlockState state) {
|
||||||
return state.isOf(EndBlocks.AMBER_MOSS);
|
return state.is(EndBlocks.AMBER_MOSS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -4,14 +4,14 @@ import java.util.Random;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||||
import net.minecraft.block.AbstractBlock;
|
import net.minecraft.world.level.block.AbstractBlock;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.block.Material;
|
import net.minecraft.world.level.material.Material;
|
||||||
import net.minecraft.sound.BlockSoundGroup;
|
import net.minecraft.world.level.block.SoundType;
|
||||||
import net.minecraft.state.property.Properties;
|
import net.minecraft.state.property.Properties;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.math.BlockPos.Mutable;
|
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.world.StructureWorldAccess;
|
import net.minecraft.world.StructureWorldAccess;
|
||||||
import ru.betterend.blocks.BlockProperties.TripleShape;
|
import ru.betterend.blocks.BlockProperties.TripleShape;
|
||||||
import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
|
import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
|
||||||
|
@ -21,13 +21,9 @@ import ru.betterend.util.MHelper;
|
||||||
|
|
||||||
public class GlowingPillarSeedBlock extends EndPlantWithAgeBlock {
|
public class GlowingPillarSeedBlock extends EndPlantWithAgeBlock {
|
||||||
public GlowingPillarSeedBlock() {
|
public GlowingPillarSeedBlock() {
|
||||||
super(FabricBlockSettings.of(Material.PLANT)
|
super(FabricBlockSettings.of(Material.PLANT).luminance((state) -> {
|
||||||
.luminance((state) -> { return state.get(AGE) * 3 + 3; })
|
return state.getValue(AGE) * 3 + 3;
|
||||||
.breakByTool(FabricToolTags.SHEARS)
|
}).breakByTool(FabricToolTags.SHEARS).sounds(SoundType.GRASS).breakByHand(true).ticksRandomly().noCollision());
|
||||||
.sounds(BlockSoundGroup.GRASS)
|
|
||||||
.breakByHand(true)
|
|
||||||
.ticksRandomly()
|
|
||||||
.noCollision());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -38,34 +34,36 @@ public class GlowingPillarSeedBlock extends EndPlantWithAgeBlock {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Mutable mut = new Mutable().set(pos);
|
MutableBlockPos mut = new MutableBlockPos().set(pos);
|
||||||
BlockState roots = EndBlocks.GLOWING_PILLAR_ROOTS.getDefaultState();
|
BlockState roots = EndBlocks.GLOWING_PILLAR_ROOTS.defaultBlockState();
|
||||||
if (height < 2) {
|
if (height < 2) {
|
||||||
BlocksHelper.setWithUpdate(world, mut, roots.with(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE));
|
BlocksHelper.setWithUpdate(world, mut, roots.with(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE));
|
||||||
mut.move(Direction.UP);
|
mut.move(Direction.UP);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
BlocksHelper.setWithUpdate(world, mut, roots.with(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM));
|
BlocksHelper.setWithUpdate(world, mut, roots.with(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM));
|
||||||
mut.move(Direction.UP);
|
mut.move(Direction.UP);
|
||||||
BlocksHelper.setWithUpdate(world, mut, roots.with(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP));
|
BlocksHelper.setWithUpdate(world, mut, roots.with(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP));
|
||||||
mut.move(Direction.UP);
|
mut.move(Direction.UP);
|
||||||
}
|
}
|
||||||
BlocksHelper.setWithUpdate(world, mut, EndBlocks.GLOWING_PILLAR_LUMINOPHOR.getDefaultState().with(BlueVineLanternBlock.NATURAL, true));
|
BlocksHelper.setWithUpdate(world, mut,
|
||||||
for (Direction dir: BlocksHelper.DIRECTIONS) {
|
EndBlocks.GLOWING_PILLAR_LUMINOPHOR.defaultBlockState().with(BlueVineLanternBlock.NATURAL, true));
|
||||||
|
for (Direction dir : BlocksHelper.DIRECTIONS) {
|
||||||
pos = mut.offset(dir);
|
pos = mut.offset(dir);
|
||||||
if (world.isAir(pos)) {
|
if (world.isAir(pos)) {
|
||||||
BlocksHelper.setWithUpdate(world, pos, EndBlocks.GLOWING_PILLAR_LEAVES.getDefaultState().with(Properties.FACING, dir));
|
BlocksHelper.setWithUpdate(world, pos,
|
||||||
|
EndBlocks.GLOWING_PILLAR_LEAVES.defaultBlockState().with(Properties.FACING, dir));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mut.move(Direction.UP);
|
mut.move(Direction.UP);
|
||||||
if (world.isAir(mut)) {
|
if (world.isAir(mut)) {
|
||||||
BlocksHelper.setWithUpdate(world, mut, EndBlocks.GLOWING_PILLAR_LEAVES.getDefaultState().with(Properties.FACING, Direction.UP));
|
BlocksHelper.setWithUpdate(world, mut,
|
||||||
|
EndBlocks.GLOWING_PILLAR_LEAVES.defaultBlockState().with(Properties.FACING, Direction.UP));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isTerrain(BlockState state) {
|
protected boolean isTerrain(BlockState state) {
|
||||||
return state.isOf(EndBlocks.AMBER_MOSS);
|
return state.is(EndBlocks.AMBER_MOSS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -7,22 +7,22 @@ import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.block.Material;
|
import net.minecraft.world.level.material.Material;
|
||||||
import net.minecraft.block.MaterialColor;
|
import net.minecraft.world.level.material.MaterialColor;
|
||||||
import net.minecraft.client.color.block.BlockColorProvider;
|
import net.minecraft.client.color.block.BlockColor;
|
||||||
import net.minecraft.client.color.item.ItemColorProvider;
|
import net.minecraft.client.color.item.ItemColor;
|
||||||
import net.minecraft.enchantment.EnchantmentHelper;
|
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||||
import net.minecraft.enchantment.Enchantments;
|
import net.minecraft.world.item.enchantment.Enchantments;
|
||||||
import net.minecraft.item.ItemPlacementContext;
|
import net.minecraft.world.item.ItemPlacementContext;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.loot.context.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import net.minecraft.loot.context.LootContextParameters;
|
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||||
import net.minecraft.sound.BlockSoundGroup;
|
import net.minecraft.world.level.block.SoundType;
|
||||||
import net.minecraft.state.StateManager;
|
import net.minecraft.world.level.block.state.StateDefinition;
|
||||||
import net.minecraft.state.property.IntProperty;
|
import net.minecraft.world.level.block.state.properties.IntegerProperty;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.Mth;
|
||||||
import ru.betterend.blocks.basis.BlockBase;
|
import ru.betterend.blocks.basis.BlockBase;
|
||||||
import ru.betterend.interfaces.IColorProvider;
|
import ru.betterend.interfaces.IColorProvider;
|
||||||
import ru.betterend.noise.OpenSimplexNoise;
|
import ru.betterend.noise.OpenSimplexNoise;
|
||||||
|
@ -30,32 +30,29 @@ import ru.betterend.registry.EndBlocks;
|
||||||
import ru.betterend.util.MHelper;
|
import ru.betterend.util.MHelper;
|
||||||
|
|
||||||
public class HelixTreeLeavesBlock extends BlockBase implements IColorProvider {
|
public class HelixTreeLeavesBlock extends BlockBase implements IColorProvider {
|
||||||
public static final IntProperty COLOR = BlockProperties.COLOR;
|
public static final IntegerProperty COLOR = BlockProperties.COLOR;
|
||||||
private static final OpenSimplexNoise NOISE = new OpenSimplexNoise(0);
|
private static final OpenSimplexNoise NOISE = new OpenSimplexNoise(0);
|
||||||
|
|
||||||
public HelixTreeLeavesBlock() {
|
public HelixTreeLeavesBlock() {
|
||||||
super(FabricBlockSettings.of(Material.LEAVES)
|
super(FabricBlockSettings.of(Material.LEAVES).materialColor(MaterialColor.COLOR_ORANGE)
|
||||||
.materialColor(MaterialColor.ORANGE)
|
.breakByTool(FabricToolTags.SHEARS).sounds(SoundType.WART_BLOCK).sounds(SoundType.GRASS)
|
||||||
.breakByTool(FabricToolTags.SHEARS)
|
|
||||||
.sounds(BlockSoundGroup.WART_BLOCK)
|
|
||||||
.sounds(BlockSoundGroup.GRASS)
|
|
||||||
.strength(0.2F));
|
.strength(0.2F));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
|
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
|
||||||
stateManager.add(COLOR);
|
stateManager.add(COLOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockColorProvider getProvider() {
|
public BlockColor getBlockProvider() {
|
||||||
return (state, world, pos, tintIndex) -> {
|
return (state, world, pos, tintIndex) -> {
|
||||||
return MHelper.color(237, getGreen(state.get(COLOR)), 20);
|
return MHelper.color(237, getGreen(state.getValue(COLOR)), 20);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemColorProvider getItemProvider() {
|
public ItemColor getItemProvider() {
|
||||||
return (stack, tintIndex) -> {
|
return (stack, tintIndex) -> {
|
||||||
return MHelper.color(237, getGreen(4), 20);
|
return MHelper.color(237, getGreen(4), 20);
|
||||||
};
|
};
|
||||||
|
@ -66,27 +63,29 @@ public class HelixTreeLeavesBlock extends BlockBase implements IColorProvider {
|
||||||
double px = ctx.getBlockPos().getX() * 0.1;
|
double px = ctx.getBlockPos().getX() * 0.1;
|
||||||
double py = ctx.getBlockPos().getY() * 0.1;
|
double py = ctx.getBlockPos().getY() * 0.1;
|
||||||
double pz = ctx.getBlockPos().getZ() * 0.1;
|
double pz = ctx.getBlockPos().getZ() * 0.1;
|
||||||
return this.getDefaultState().with(COLOR, MHelper.floor(NOISE.eval(px, py, pz) * 3.5 + 4));
|
return this.defaultBlockState().with(COLOR, MHelper.floor(NOISE.eval(px, py, pz) * 3.5 + 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getGreen(int color) {
|
private int getGreen(int color) {
|
||||||
float delta = color / 7F;
|
float delta = color / 7F;
|
||||||
return (int) MathHelper.lerp(delta, 80, 158);
|
return (int) Mth.lerp(delta, 80, 158);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
ItemStack tool = builder.get(LootContextParameters.TOOL);
|
ItemStack tool = builder.getParameter(LootContextParams.TOOL);
|
||||||
if (tool != null) {
|
if (tool != null) {
|
||||||
if (tool.getItem().isIn(FabricToolTags.SHEARS) || tool.isEffectiveOn(state) || EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, tool) > 0) {
|
if (tool.getItem().isIn(FabricToolTags.SHEARS) || tool.isCorrectToolForDrops(state)
|
||||||
|
|| EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) {
|
||||||
return Collections.singletonList(new ItemStack(this));
|
return Collections.singletonList(new ItemStack(this));
|
||||||
}
|
}
|
||||||
int fortune = EnchantmentHelper.getLevel(Enchantments.FORTUNE, tool);
|
int fortune = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.BLOCK_FORTUNE, tool);
|
||||||
if (MHelper.RANDOM.nextInt(16) <= fortune) {
|
if (MHelper.RANDOM.nextInt(16) <= fortune) {
|
||||||
return Lists.newArrayList(new ItemStack(EndBlocks.HELIX_TREE_SAPLING));
|
return Lists.newArrayList(new ItemStack(EndBlocks.HELIX_TREE_SAPLING));
|
||||||
}
|
}
|
||||||
return Lists.newArrayList();
|
return Lists.newArrayList();
|
||||||
}
|
}
|
||||||
return MHelper.RANDOM.nextInt(32) == 0 ? Lists.newArrayList(new ItemStack(EndBlocks.HELIX_TREE_SAPLING)) : Lists.newArrayList();
|
return MHelper.RANDOM.nextInt(32) == 0 ? Lists.newArrayList(new ItemStack(EndBlocks.HELIX_TREE_SAPLING))
|
||||||
|
: Lists.newArrayList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,17 +10,17 @@ import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.block.Material;
|
import net.minecraft.world.level.material.Material;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.loot.context.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import net.minecraft.sound.BlockSoundGroup;
|
import net.minecraft.world.level.block.SoundType;
|
||||||
import net.minecraft.state.StateManager;
|
import net.minecraft.world.level.block.state.StateDefinition;
|
||||||
import net.minecraft.state.property.EnumProperty;
|
import net.minecraft.state.property.EnumProperty;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.WorldView;
|
import net.minecraft.world.WorldView;
|
||||||
import ru.betterend.blocks.BlockProperties.HydraluxShape;
|
import ru.betterend.blocks.BlockProperties.HydraluxShape;
|
||||||
import ru.betterend.blocks.basis.UnderwaterPlantBlock;
|
import ru.betterend.blocks.basis.UnderwaterPlantBlock;
|
||||||
|
@ -32,31 +32,27 @@ public class HydraluxBlock extends UnderwaterPlantBlock {
|
||||||
public static final EnumProperty<HydraluxShape> SHAPE = BlockProperties.HYDRALUX_SHAPE;
|
public static final EnumProperty<HydraluxShape> SHAPE = BlockProperties.HYDRALUX_SHAPE;
|
||||||
|
|
||||||
public HydraluxBlock() {
|
public HydraluxBlock() {
|
||||||
super(FabricBlockSettings.of(Material.UNDERWATER_PLANT)
|
super(FabricBlockSettings.of(Material.UNDERWATER_PLANT).breakByTool(FabricToolTags.SHEARS)
|
||||||
.breakByTool(FabricToolTags.SHEARS)
|
.sounds(SoundType.WET_GRASS).breakByHand(true).luminance((state) -> {
|
||||||
.sounds(BlockSoundGroup.WET_GRASS)
|
return state.getValue(SHAPE).hasGlow() ? 15 : 0;
|
||||||
.breakByHand(true)
|
}).noCollision());
|
||||||
.luminance((state) -> { return state.get(SHAPE).hasGlow() ? 15 : 0; })
|
|
||||||
.noCollision());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
|
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
|
||||||
stateManager.add(SHAPE);
|
stateManager.add(SHAPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
||||||
BlockState down = world.getBlockState(pos.down());
|
BlockState down = world.getBlockState(pos.below());
|
||||||
HydraluxShape shape = state.get(SHAPE);
|
HydraluxShape shape = state.getValue(SHAPE);
|
||||||
if (shape == HydraluxShape.FLOWER_BIG_TOP || shape == HydraluxShape.FLOWER_SMALL_TOP) {
|
if (shape == HydraluxShape.FLOWER_BIG_TOP || shape == HydraluxShape.FLOWER_SMALL_TOP) {
|
||||||
return down.isOf(this);
|
return down.is(this);
|
||||||
}
|
} else if (shape == HydraluxShape.ROOTS) {
|
||||||
else if (shape == HydraluxShape.ROOTS) {
|
return down.is(EndBlocks.SULPHURIC_ROCK.stone) && world.getBlockState(pos.up()).is(this);
|
||||||
return down.isOf(EndBlocks.SULPHURIC_ROCK.stone) && world.getBlockState(pos.up()).isOf(this);
|
} else {
|
||||||
}
|
return down.is(this) && world.getBlockState(pos.up()).is(this);
|
||||||
else {
|
|
||||||
return down.isOf(this) && world.getBlockState(pos.up()).isOf(this);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +62,7 @@ public class HydraluxBlock extends UnderwaterPlantBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) {
|
public boolean canGrow(Level world, Random random, BlockPos pos, BlockState state) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,13 +73,13 @@ public class HydraluxBlock extends UnderwaterPlantBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
HydraluxShape shape = state.get(SHAPE);
|
HydraluxShape shape = state.getValue(SHAPE);
|
||||||
if (shape == HydraluxShape.FLOWER_BIG_BOTTOM || shape == HydraluxShape.FLOWER_SMALL_BOTTOM) {
|
if (shape == HydraluxShape.FLOWER_BIG_BOTTOM || shape == HydraluxShape.FLOWER_SMALL_BOTTOM) {
|
||||||
return Lists.newArrayList(new ItemStack(EndItems.HYDRALUX_PETAL, MHelper.randRange(1, 4, MHelper.RANDOM)));
|
return Lists.newArrayList(new ItemStack(EndItems.HYDRALUX_PETAL, MHelper.randRange(1, 4, MHelper.RANDOM)));
|
||||||
}
|
} else if (shape == HydraluxShape.ROOTS) {
|
||||||
else if (shape == HydraluxShape.ROOTS) {
|
return Lists
|
||||||
return Lists.newArrayList(new ItemStack(EndBlocks.HYDRALUX_SAPLING, MHelper.randRange(1, 2, MHelper.RANDOM)));
|
.newArrayList(new ItemStack(EndBlocks.HYDRALUX_SAPLING, MHelper.randRange(1, 2, MHelper.RANDOM)));
|
||||||
}
|
}
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,23 +2,18 @@ package ru.betterend.blocks;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||||
import net.minecraft.block.Material;
|
import net.minecraft.world.level.material.Material;
|
||||||
import net.minecraft.block.MaterialColor;
|
import net.minecraft.world.level.material.MaterialColor;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.sound.BlockSoundGroup;
|
import net.minecraft.world.level.block.SoundType;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.level.Level;
|
||||||
import ru.betterend.blocks.basis.BlockBase;
|
import ru.betterend.blocks.basis.BlockBase;
|
||||||
|
|
||||||
public class HydraluxPetalBlock extends BlockBase {
|
public class HydraluxPetalBlock extends BlockBase {
|
||||||
public HydraluxPetalBlock() {
|
public HydraluxPetalBlock() {
|
||||||
this(FabricBlockSettings.of(Material.PLANT)
|
this(FabricBlockSettings.of(Material.PLANT).materialColor(MaterialColor.SPRUCE).sounds(SoundType.WART_BLOCK)
|
||||||
.materialColor(MaterialColor.SPRUCE)
|
.breakByTool(FabricToolTags.AXES).hardness(1).resistance(1).breakByHand(true));
|
||||||
.sounds(BlockSoundGroup.WART_BLOCK)
|
|
||||||
.breakByTool(FabricToolTags.AXES)
|
|
||||||
.hardness(1)
|
|
||||||
.resistance(1)
|
|
||||||
.breakByHand(true));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public HydraluxPetalBlock(FabricBlockSettings settings) {
|
public HydraluxPetalBlock(FabricBlockSettings settings) {
|
||||||
|
@ -26,5 +21,6 @@ public class HydraluxPetalBlock extends BlockBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLandedUpon(World world, BlockPos pos, Entity entity, float distance) {}
|
public void onLandedUpon(Level world, BlockPos pos, Entity entity, float distance) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package ru.betterend.blocks;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.minecraft.client.color.block.BlockColorProvider;
|
import net.minecraft.client.color.block.BlockColor;
|
||||||
import net.minecraft.client.color.item.ItemColorProvider;
|
import net.minecraft.client.color.item.ItemColor;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import ru.betterend.interfaces.IColorProvider;
|
import ru.betterend.interfaces.IColorProvider;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.patterns.Patterns;
|
||||||
import ru.betterend.util.BlocksHelper;
|
import ru.betterend.util.BlocksHelper;
|
||||||
|
@ -16,14 +16,14 @@ public class HydraluxPetalColoredBlock extends HydraluxPetalBlock implements ICo
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockColorProvider getProvider() {
|
public BlockColor getBlockProvider() {
|
||||||
return (state, world, pos, tintIndex) -> {
|
return (state, world, pos, tintIndex) -> {
|
||||||
return BlocksHelper.getBlockColor(this);
|
return BlocksHelper.getBlockColor(this);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemColorProvider getItemProvider() {
|
public ItemColor getItemProvider() {
|
||||||
return (stack, tintIndex) -> {
|
return (stack, tintIndex) -> {
|
||||||
return BlocksHelper.getBlockColor(this);
|
return BlocksHelper.getBlockColor(this);
|
||||||
};
|
};
|
||||||
|
@ -42,7 +42,7 @@ public class HydraluxPetalColoredBlock extends HydraluxPetalBlock implements ICo
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Identifier statePatternId() {
|
public ResourceLocation statePatternId() {
|
||||||
return Patterns.STATE_DIRECT;
|
return Patterns.STATE_DIRECT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,10 @@ package ru.betterend.blocks;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.math.BlockPos.Mutable;
|
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||||
import net.minecraft.world.StructureWorldAccess;
|
import net.minecraft.world.StructureWorldAccess;
|
||||||
import ru.betterend.blocks.BlockProperties.HydraluxShape;
|
import ru.betterend.blocks.BlockProperties.HydraluxShape;
|
||||||
import ru.betterend.blocks.basis.UnderwaterPlantWithAgeBlock;
|
import ru.betterend.blocks.basis.UnderwaterPlantWithAgeBlock;
|
||||||
|
@ -17,17 +17,17 @@ public class HydraluxSaplingBlock extends UnderwaterPlantWithAgeBlock {
|
||||||
@Override
|
@Override
|
||||||
public void grow(StructureWorldAccess world, Random random, BlockPos pos) {
|
public void grow(StructureWorldAccess world, Random random, BlockPos pos) {
|
||||||
int h = MHelper.randRange(4, 8, random);
|
int h = MHelper.randRange(4, 8, random);
|
||||||
Mutable mut = new Mutable().set(pos);
|
MutableBlockPos mut = new MutableBlockPos().set(pos);
|
||||||
|
|
||||||
for (int i = 1; i < h; i++) {
|
for (int i = 1; i < h; i++) {
|
||||||
mut.setY(pos.getY() + i);
|
mut.setY(pos.getY() + i);
|
||||||
if (!world.getBlockState(mut).isOf(Blocks.WATER)) {
|
if (!world.getBlockState(mut).is(Blocks.WATER)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mut.setY(pos.getY());
|
mut.setY(pos.getY());
|
||||||
BlockState state = EndBlocks.HYDRALUX.getDefaultState();
|
BlockState state = EndBlocks.HYDRALUX.defaultBlockState();
|
||||||
BlocksHelper.setWithoutUpdate(world, pos, state.with(BlockProperties.HYDRALUX_SHAPE, HydraluxShape.ROOTS));
|
BlocksHelper.setWithoutUpdate(world, pos, state.with(BlockProperties.HYDRALUX_SHAPE, HydraluxShape.ROOTS));
|
||||||
for (int i = 1; i < h - 2; i++) {
|
for (int i = 1; i < h - 2; i++) {
|
||||||
mut.setY(pos.getY() + i);
|
mut.setY(pos.getY() + i);
|
||||||
|
@ -36,14 +36,16 @@ public class HydraluxSaplingBlock extends UnderwaterPlantWithAgeBlock {
|
||||||
|
|
||||||
mut.setY(mut.getY() + 1);
|
mut.setY(mut.getY() + 1);
|
||||||
boolean big = random.nextBoolean();
|
boolean big = random.nextBoolean();
|
||||||
BlocksHelper.setWithoutUpdate(world, mut, state.with(BlockProperties.HYDRALUX_SHAPE, big ? HydraluxShape.FLOWER_BIG_BOTTOM : HydraluxShape.FLOWER_SMALL_BOTTOM));
|
BlocksHelper.setWithoutUpdate(world, mut, state.with(BlockProperties.HYDRALUX_SHAPE,
|
||||||
|
big ? HydraluxShape.FLOWER_BIG_BOTTOM : HydraluxShape.FLOWER_SMALL_BOTTOM));
|
||||||
|
|
||||||
mut.setY(mut.getY() + 1);
|
mut.setY(mut.getY() + 1);
|
||||||
BlocksHelper.setWithoutUpdate(world, mut, state.with(BlockProperties.HYDRALUX_SHAPE, big ? HydraluxShape.FLOWER_BIG_TOP : HydraluxShape.FLOWER_SMALL_TOP));
|
BlocksHelper.setWithoutUpdate(world, mut, state.with(BlockProperties.HYDRALUX_SHAPE,
|
||||||
|
big ? HydraluxShape.FLOWER_BIG_TOP : HydraluxShape.FLOWER_SMALL_TOP));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isTerrain(BlockState state) {
|
protected boolean isTerrain(BlockState state) {
|
||||||
return state.isOf(EndBlocks.SULPHURIC_ROCK.stone);
|
return state.is(EndBlocks.SULPHURIC_ROCK.stone);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,33 +8,33 @@ import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.block.BlockEntityProvider;
|
import net.minecraft.world.level.block.BlockEntityProvider;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.block.FluidFillable;
|
import net.minecraft.world.level.block.FluidFillable;
|
||||||
import net.minecraft.block.Material;
|
import net.minecraft.world.level.material.Material;
|
||||||
import net.minecraft.block.ShapeContext;
|
import net.minecraft.world.level.block.ShapeContext;
|
||||||
import net.minecraft.block.Waterloggable;
|
import net.minecraft.world.level.block.Waterloggable;
|
||||||
import net.minecraft.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraft.fluid.Fluid;
|
import net.minecraft.fluid.Fluid;
|
||||||
import net.minecraft.fluid.FluidState;
|
import net.minecraft.fluid.FluidState;
|
||||||
import net.minecraft.fluid.Fluids;
|
import net.minecraft.fluid.Fluids;
|
||||||
import net.minecraft.item.ItemPlacementContext;
|
import net.minecraft.world.item.ItemPlacementContext;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.particle.ParticleTypes;
|
import net.minecraft.core.particles.ParticleTypes;
|
||||||
import net.minecraft.server.world.ServerWorld;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.sound.BlockSoundGroup;
|
import net.minecraft.world.level.block.SoundType;
|
||||||
import net.minecraft.state.StateManager;
|
import net.minecraft.world.level.block.state.StateDefinition;
|
||||||
import net.minecraft.state.property.BooleanProperty;
|
import net.minecraft.state.property.BooleanProperty;
|
||||||
import net.minecraft.state.property.Properties;
|
import net.minecraft.state.property.Properties;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.util.shape.VoxelShape;
|
import net.minecraft.util.shape.VoxelShape;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.WorldAccess;
|
import net.minecraft.world.level.LevelAccessor;
|
||||||
import net.minecraft.world.WorldView;
|
import net.minecraft.world.WorldView;
|
||||||
import ru.betterend.blocks.basis.BlockBaseNotFull;
|
import ru.betterend.blocks.basis.BlockBaseNotFull;
|
||||||
import ru.betterend.blocks.entities.BlockEntityHydrothermalVent;
|
import ru.betterend.blocks.entities.BlockEntityHydrothermalVent;
|
||||||
|
@ -42,22 +42,20 @@ import ru.betterend.registry.EndBlocks;
|
||||||
import ru.betterend.registry.EndParticles;
|
import ru.betterend.registry.EndParticles;
|
||||||
import ru.betterend.util.BlocksHelper;
|
import ru.betterend.util.BlocksHelper;
|
||||||
|
|
||||||
public class HydrothermalVentBlock extends BlockBaseNotFull implements BlockEntityProvider, FluidFillable, Waterloggable {
|
public class HydrothermalVentBlock extends BlockBaseNotFull
|
||||||
|
implements BlockEntityProvider, FluidFillable, Waterloggable {
|
||||||
public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED;
|
public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED;
|
||||||
public static final BooleanProperty ACTIVATED = BlockProperties.ACTIVE;
|
public static final BooleanProperty ACTIVATED = BlockProperties.ACTIVE;
|
||||||
private static final VoxelShape SHAPE = Block.createCuboidShape(1, 1, 1, 15, 16, 15);
|
private static final VoxelShape SHAPE = Block.createCuboidShape(1, 1, 1, 15, 16, 15);
|
||||||
|
|
||||||
public HydrothermalVentBlock() {
|
public HydrothermalVentBlock() {
|
||||||
super(FabricBlockSettings.of(Material.STONE)
|
super(FabricBlockSettings.of(Material.STONE).breakByTool(FabricToolTags.PICKAXES).sounds(SoundType.STONE)
|
||||||
.breakByTool(FabricToolTags.PICKAXES)
|
.noCollision().requiresTool());
|
||||||
.sounds(BlockSoundGroup.STONE)
|
|
||||||
.noCollision()
|
|
||||||
.requiresTool());
|
|
||||||
this.setDefaultState(getDefaultState().with(WATERLOGGED, true).with(ACTIVATED, false));
|
this.setDefaultState(getDefaultState().with(WATERLOGGED, true).with(ACTIVATED, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
||||||
builder.add(WATERLOGGED, ACTIVATED);
|
builder.add(WATERLOGGED, ACTIVATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,22 +70,22 @@ public class HydrothermalVentBlock extends BlockBaseNotFull implements BlockEnti
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean tryFillWithFluid(WorldAccess world, BlockPos pos, BlockState state, FluidState fluidState) {
|
public boolean tryFillWithFluid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluidState) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
||||||
state = world.getBlockState(pos.down());
|
state = world.getBlockState(pos.below());
|
||||||
return state.isOf(EndBlocks.SULPHURIC_ROCK.stone);
|
return state.is(EndBlocks.SULPHURIC_ROCK.stone);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
|
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world,
|
||||||
|
BlockPos pos, BlockPos neighborPos) {
|
||||||
if (!canPlaceAt(state, world, pos)) {
|
if (!canPlaceAt(state, world, pos)) {
|
||||||
return Blocks.WATER.getDefaultState();
|
return Blocks.WATER.defaultBlockState();
|
||||||
}
|
} else if (state.getValue(WATERLOGGED) && facing == Direction.UP && neighborState.is(Blocks.WATER)) {
|
||||||
else if (state.get(WATERLOGGED) && facing == Direction.UP && neighborState.isOf(Blocks.WATER)) {
|
|
||||||
world.getBlockTickScheduler().schedule(pos, this, 20);
|
world.getBlockTickScheduler().schedule(pos, this, 20);
|
||||||
}
|
}
|
||||||
return state;
|
return state;
|
||||||
|
@ -95,14 +93,15 @@ public class HydrothermalVentBlock extends BlockBaseNotFull implements BlockEnti
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getPlacementState(ItemPlacementContext ctx) {
|
public BlockState getPlacementState(ItemPlacementContext ctx) {
|
||||||
WorldAccess worldAccess = ctx.getWorld();
|
LevelAccessor worldAccess = ctx.getLevel();
|
||||||
BlockPos blockPos = ctx.getBlockPos();
|
BlockPos blockPos = ctx.getBlockPos();
|
||||||
return this.getDefaultState().with(WATERLOGGED, worldAccess.getFluidState(blockPos).getFluid() == Fluids.WATER);
|
return this.defaultBlockState().with(WATERLOGGED,
|
||||||
|
worldAccess.getFluidState(blockPos).getFluid() == Fluids.WATER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FluidState getFluidState(BlockState state) {
|
public FluidState getFluidState(BlockState state) {
|
||||||
return (Boolean) state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(state);
|
return (Boolean) state.getValue(WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -111,32 +110,33 @@ public class HydrothermalVentBlock extends BlockBaseNotFull implements BlockEnti
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
|
public void scheduledTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
|
||||||
BlockPos up = pos.up();
|
BlockPos up = pos.up();
|
||||||
if (world.getBlockState(up).isOf(Blocks.WATER)) {
|
if (world.getBlockState(up).is(Blocks.WATER)) {
|
||||||
BlocksHelper.setWithoutUpdate(world, up, EndBlocks.VENT_BUBBLE_COLUMN);
|
BlocksHelper.setWithoutUpdate(world, up, EndBlocks.VENT_BUBBLE_COLUMN);
|
||||||
world.getBlockTickScheduler().schedule(up, EndBlocks.VENT_BUBBLE_COLUMN, 5);
|
world.getBlockTickScheduler().schedule(up, EndBlocks.VENT_BUBBLE_COLUMN, 5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlaced(World world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack itemStack) {
|
public void onPlaced(Level world, BlockPos pos, BlockState state, @Nullable LivingEntity placer,
|
||||||
if (world instanceof ServerWorld && state.get(WATERLOGGED) && world.getBlockState(pos.up()).isOf(Blocks.WATER)) {
|
ItemStack itemStack) {
|
||||||
scheduledTick(state,(ServerWorld) world, pos, world.random);
|
if (world instanceof ServerLevel && state.getValue(WATERLOGGED)
|
||||||
|
&& world.getBlockState(pos.up()).is(Blocks.WATER)) {
|
||||||
|
scheduledTick(state, (ServerLevel) world, pos, world.random);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) {
|
public void animateTick(BlockState state, Level world, BlockPos pos, Random random) {
|
||||||
if (!state.get(ACTIVATED) && random.nextBoolean()) {
|
if (!state.getValue(ACTIVATED) && random.nextBoolean()) {
|
||||||
super.randomDisplayTick(state, world, pos, random);
|
super.animateTick(state, world, pos, random);
|
||||||
double x = pos.getX() + random.nextDouble();
|
double x = pos.getX() + random.nextDouble();
|
||||||
double y = pos.getY() + 0.9 + random.nextDouble() * 0.3;
|
double y = pos.getY() + 0.9 + random.nextDouble() * 0.3;
|
||||||
double z = pos.getZ() + random.nextDouble();
|
double z = pos.getZ() + random.nextDouble();
|
||||||
if (state.get(WATERLOGGED)) {
|
if (state.getValue(WATERLOGGED)) {
|
||||||
world.addParticle(EndParticles.GEYSER_PARTICLE, x, y, z, 0, 0, 0);
|
world.addParticle(EndParticles.GEYSER_PARTICLE, x, y, z, 0, 0, 0);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
world.addParticle(ParticleTypes.SMOKE, x, y, z, 0, 0, 0);
|
world.addParticle(ParticleTypes.SMOKE, x, y, z, 0, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
package ru.betterend.blocks;
|
package ru.betterend.blocks;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.block.ShapeContext;
|
import net.minecraft.world.level.block.ShapeContext;
|
||||||
import net.minecraft.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.shape.VoxelShape;
|
import net.minecraft.util.shape.VoxelShape;
|
||||||
import net.minecraft.util.shape.VoxelShapes;
|
import net.minecraft.util.shape.VoxelShapes;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.level.Level;
|
||||||
import ru.betterend.blocks.basis.PedestalBlock;
|
import ru.betterend.blocks.basis.PedestalBlock;
|
||||||
import ru.betterend.blocks.entities.InfusionPedestalEntity;
|
import ru.betterend.blocks.entities.InfusionPedestalEntity;
|
||||||
import ru.betterend.rituals.InfusionRitual;
|
import ru.betterend.rituals.InfusionRitual;
|
||||||
|
@ -24,7 +24,7 @@ public class InfusionPedestal extends PedestalBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void checkRitual(World world, BlockPos pos) {
|
public void checkRitual(Level world, BlockPos pos) {
|
||||||
BlockEntity blockEntity = world.getBlockEntity(pos);
|
BlockEntity blockEntity = world.getBlockEntity(pos);
|
||||||
if (blockEntity instanceof InfusionPedestalEntity) {
|
if (blockEntity instanceof InfusionPedestalEntity) {
|
||||||
InfusionPedestalEntity pedestal = (InfusionPedestalEntity) blockEntity;
|
InfusionPedestalEntity pedestal = (InfusionPedestalEntity) blockEntity;
|
||||||
|
@ -45,8 +45,8 @@ public class InfusionPedestal extends PedestalBlock {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
||||||
if (state.isOf(this)) {
|
if (state.is(this)) {
|
||||||
switch(state.get(STATE)) {
|
switch (state.getValue(STATE)) {
|
||||||
case PEDESTAL_TOP: {
|
case PEDESTAL_TOP: {
|
||||||
return SHAPE_PEDESTAL_TOP;
|
return SHAPE_PEDESTAL_TOP;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,21 +6,21 @@ import java.util.List;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.block.SlimeBlock;
|
import net.minecraft.world.level.block.SlimeBlock;
|
||||||
import net.minecraft.client.color.block.BlockColorProvider;
|
import net.minecraft.client.color.block.BlockColor;
|
||||||
import net.minecraft.client.color.item.ItemColorProvider;
|
import net.minecraft.client.color.item.ItemColor;
|
||||||
import net.minecraft.item.ItemPlacementContext;
|
import net.minecraft.world.item.ItemPlacementContext;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.loot.context.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import net.minecraft.state.StateManager;
|
import net.minecraft.world.level.block.state.StateDefinition;
|
||||||
import net.minecraft.state.property.IntProperty;
|
import net.minecraft.world.level.block.state.properties.IntegerProperty;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.util.math.Vec3i;
|
import net.minecraft.core.Vec3i;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import ru.betterend.client.render.ERenderLayer;
|
import ru.betterend.client.render.ERenderLayer;
|
||||||
import ru.betterend.interfaces.IColorProvider;
|
import ru.betterend.interfaces.IColorProvider;
|
||||||
import ru.betterend.interfaces.IRenderTypeable;
|
import ru.betterend.interfaces.IRenderTypeable;
|
||||||
|
@ -30,7 +30,7 @@ import ru.betterend.patterns.Patterns;
|
||||||
import ru.betterend.util.MHelper;
|
import ru.betterend.util.MHelper;
|
||||||
|
|
||||||
public class JellyshroomCapBlock extends SlimeBlock implements IRenderTypeable, BlockPatterned, IColorProvider {
|
public class JellyshroomCapBlock extends SlimeBlock implements IRenderTypeable, BlockPatterned, IColorProvider {
|
||||||
public static final IntProperty COLOR = BlockProperties.COLOR;
|
public static final IntegerProperty COLOR = BlockProperties.COLOR;
|
||||||
private static final OpenSimplexNoise NOISE = new OpenSimplexNoise(0);
|
private static final OpenSimplexNoise NOISE = new OpenSimplexNoise(0);
|
||||||
private final Vec3i colorStart;
|
private final Vec3i colorStart;
|
||||||
private final Vec3i colorEnd;
|
private final Vec3i colorEnd;
|
||||||
|
@ -48,11 +48,11 @@ public class JellyshroomCapBlock extends SlimeBlock implements IRenderTypeable,
|
||||||
double px = ctx.getBlockPos().getX() * 0.1;
|
double px = ctx.getBlockPos().getX() * 0.1;
|
||||||
double py = ctx.getBlockPos().getY() * 0.1;
|
double py = ctx.getBlockPos().getY() * 0.1;
|
||||||
double pz = ctx.getBlockPos().getZ() * 0.1;
|
double pz = ctx.getBlockPos().getZ() * 0.1;
|
||||||
return this.getDefaultState().with(COLOR, MHelper.floor(NOISE.eval(px, py, pz) * 3.5 + 4));
|
return this.defaultBlockState().with(COLOR, MHelper.floor(NOISE.eval(px, py, pz) * 3.5 + 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
|
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
|
||||||
stateManager.add(COLOR);
|
stateManager.add(COLOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,13 +62,13 @@ public class JellyshroomCapBlock extends SlimeBlock implements IRenderTypeable,
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
return Lists.newArrayList(new ItemStack(this));
|
return Lists.newArrayList(new ItemStack(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStatesPattern(Reader data) {
|
public String getStatesPattern(Reader data) {
|
||||||
String block = Registry.BLOCK.getId(this).getPath();
|
String block = Registry.BLOCK.getKey(this).getPath();
|
||||||
return Patterns.createJson(data, block, block);
|
return Patterns.createJson(data, block, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,23 +78,23 @@ public class JellyshroomCapBlock extends SlimeBlock implements IRenderTypeable,
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Identifier statePatternId() {
|
public ResourceLocation statePatternId() {
|
||||||
return Patterns.STATE_SIMPLE;
|
return Patterns.STATE_SIMPLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockColorProvider getProvider() {
|
public BlockColor getBlockProvider() {
|
||||||
return (state, world, pos, tintIndex) -> {
|
return (state, world, pos, tintIndex) -> {
|
||||||
float delta = (float) state.get(COLOR) / 7F;
|
float delta = (float) state.getValue(COLOR) / 7F;
|
||||||
int r = MathHelper.floor(MathHelper.lerp(delta, colorStart.getX() / 255F, colorEnd.getX() / 255F) * 255F);
|
int r = Mth.floor(Mth.lerp(delta, colorStart.getX() / 255F, colorEnd.getX() / 255F) * 255F);
|
||||||
int g = MathHelper.floor(MathHelper.lerp(delta, colorStart.getY() / 255F, colorEnd.getY() / 255F) * 255F);
|
int g = Mth.floor(Mth.lerp(delta, colorStart.getY() / 255F, colorEnd.getY() / 255F) * 255F);
|
||||||
int b = MathHelper.floor(MathHelper.lerp(delta, colorStart.getZ() / 255F, colorEnd.getZ() / 255F) * 255F);
|
int b = Mth.floor(Mth.lerp(delta, colorStart.getZ() / 255F, colorEnd.getZ() / 255F) * 255F);
|
||||||
return MHelper.color(r, g, b);
|
return MHelper.color(r, g, b);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemColorProvider getItemProvider() {
|
public ItemColor getItemProvider() {
|
||||||
return (stack, tintIndex) -> {
|
return (stack, tintIndex) -> {
|
||||||
return coloritem;
|
return coloritem;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package ru.betterend.blocks;
|
package ru.betterend.blocks;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.WorldView;
|
import net.minecraft.world.WorldView;
|
||||||
import net.minecraft.world.gen.feature.Feature;
|
import net.minecraft.world.gen.feature.Feature;
|
||||||
import ru.betterend.blocks.basis.FeatureSaplingBlock;
|
import ru.betterend.blocks.basis.FeatureSaplingBlock;
|
||||||
|
@ -20,6 +20,7 @@ public class LacugroveSaplingBlock extends FeatureSaplingBlock {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
||||||
return world.getBlockState(pos.down()).isOf(EndBlocks.END_MOSS) || world.getBlockState(pos.down()).isOf(EndBlocks.ENDSTONE_DUST);
|
return world.getBlockState(pos.below()).is(EndBlocks.END_MOSS)
|
||||||
|
|| world.getBlockState(pos.below()).is(EndBlocks.ENDSTONE_DUST);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,17 +3,17 @@ package ru.betterend.blocks;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.loot.context.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import net.minecraft.state.StateManager;
|
import net.minecraft.world.level.block.state.StateDefinition;
|
||||||
import net.minecraft.state.property.EnumProperty;
|
import net.minecraft.state.property.EnumProperty;
|
||||||
import net.minecraft.state.property.IntProperty;
|
import net.minecraft.world.level.block.state.properties.IntegerProperty;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.world.WorldAccess;
|
import net.minecraft.world.level.LevelAccessor;
|
||||||
import net.minecraft.world.WorldView;
|
import net.minecraft.world.WorldView;
|
||||||
import ru.betterend.blocks.BlockProperties.PentaShape;
|
import ru.betterend.blocks.BlockProperties.PentaShape;
|
||||||
import ru.betterend.blocks.basis.EndPlantBlock;
|
import ru.betterend.blocks.basis.EndPlantBlock;
|
||||||
|
@ -22,46 +22,45 @@ import ru.betterend.util.MHelper;
|
||||||
|
|
||||||
public class LanceleafBlock extends EndPlantBlock {
|
public class LanceleafBlock extends EndPlantBlock {
|
||||||
public static final EnumProperty<PentaShape> SHAPE = BlockProperties.PENTA_SHAPE;
|
public static final EnumProperty<PentaShape> SHAPE = BlockProperties.PENTA_SHAPE;
|
||||||
public static final IntProperty ROTATION = BlockProperties.ROTATION;
|
public static final IntegerProperty ROTATION = BlockProperties.ROTATION;
|
||||||
|
|
||||||
public LanceleafBlock() {
|
public LanceleafBlock() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
|
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
|
||||||
stateManager.add(SHAPE, ROTATION);
|
stateManager.add(SHAPE, ROTATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
||||||
PentaShape shape = state.get(SHAPE);
|
PentaShape shape = state.getValue(SHAPE);
|
||||||
if (shape == PentaShape.TOP) {
|
if (shape == PentaShape.TOP) {
|
||||||
return world.getBlockState(pos.down()).isOf(this);
|
return world.getBlockState(pos.below()).is(this);
|
||||||
}
|
} else if (shape == PentaShape.BOTTOM) {
|
||||||
else if (shape == PentaShape.BOTTOM) {
|
return world.getBlockState(pos.below()).is(EndBlocks.AMBER_MOSS) && world.getBlockState(pos.up()).is(this);
|
||||||
return world.getBlockState(pos.down()).isOf(EndBlocks.AMBER_MOSS) && world.getBlockState(pos.up()).isOf(this);
|
} else {
|
||||||
}
|
return world.getBlockState(pos.below()).is(this) && world.getBlockState(pos.up()).is(this);
|
||||||
else {
|
|
||||||
return world.getBlockState(pos.down()).isOf(this) && world.getBlockState(pos.up()).isOf(this);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
|
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world,
|
||||||
|
BlockPos pos, BlockPos neighborPos) {
|
||||||
if (!canPlaceAt(state, world, pos)) {
|
if (!canPlaceAt(state, world, pos)) {
|
||||||
return Blocks.AIR.getDefaultState();
|
return Blocks.AIR.defaultBlockState();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
if (state.get(SHAPE) == PentaShape.BOTTOM) {
|
if (state.getValue(SHAPE) == PentaShape.BOTTOM) {
|
||||||
return Collections.singletonList(new ItemStack(EndBlocks.LANCELEAF_SEED));
|
return Collections.singletonList(new ItemStack(EndBlocks.LANCELEAF_SEED));
|
||||||
}
|
}
|
||||||
return MHelper.RANDOM.nextBoolean() ? Collections.emptyList() : Collections.singletonList(new ItemStack(EndBlocks.LANCELEAF_SEED));
|
return MHelper.RANDOM.nextBoolean() ? Collections.emptyList()
|
||||||
|
: Collections.singletonList(new ItemStack(EndBlocks.LANCELEAF_SEED));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,11 +2,11 @@ package ru.betterend.blocks;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import net.minecraft.block.AbstractBlock;
|
import net.minecraft.world.level.block.AbstractBlock;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.math.BlockPos.Mutable;
|
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.world.StructureWorldAccess;
|
import net.minecraft.world.StructureWorldAccess;
|
||||||
import ru.betterend.blocks.BlockProperties.PentaShape;
|
import ru.betterend.blocks.BlockProperties.PentaShape;
|
||||||
import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
|
import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
|
||||||
|
@ -23,20 +23,24 @@ public class LanceleafSeedBlock extends EndPlantWithAgeBlock {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int rotation = random.nextInt(4);
|
int rotation = random.nextInt(4);
|
||||||
Mutable mut = new Mutable().set(pos);
|
MutableBlockPos mut = new MutableBlockPos().set(pos);
|
||||||
BlockState plant = EndBlocks.LANCELEAF.getDefaultState().with(BlockProperties.ROTATION, rotation);
|
BlockState plant = EndBlocks.LANCELEAF.defaultBlockState().with(BlockProperties.ROTATION, rotation);
|
||||||
BlocksHelper.setWithoutUpdate(world, mut, plant.with(BlockProperties.PENTA_SHAPE, PentaShape.BOTTOM));
|
BlocksHelper.setWithoutUpdate(world, mut, plant.with(BlockProperties.PENTA_SHAPE, PentaShape.BOTTOM));
|
||||||
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), plant.with(BlockProperties.PENTA_SHAPE, PentaShape.PRE_BOTTOM));
|
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP),
|
||||||
|
plant.with(BlockProperties.PENTA_SHAPE, PentaShape.PRE_BOTTOM));
|
||||||
for (int i = 2; i < height - 2; i++) {
|
for (int i = 2; i < height - 2; i++) {
|
||||||
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), plant.with(BlockProperties.PENTA_SHAPE, PentaShape.MIDDLE));
|
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP),
|
||||||
|
plant.with(BlockProperties.PENTA_SHAPE, PentaShape.MIDDLE));
|
||||||
}
|
}
|
||||||
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), plant.with(BlockProperties.PENTA_SHAPE, PentaShape.PRE_TOP));
|
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP),
|
||||||
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), plant.with(BlockProperties.PENTA_SHAPE, PentaShape.TOP));
|
plant.with(BlockProperties.PENTA_SHAPE, PentaShape.PRE_TOP));
|
||||||
|
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP),
|
||||||
|
plant.with(BlockProperties.PENTA_SHAPE, PentaShape.TOP));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isTerrain(BlockState state) {
|
protected boolean isTerrain(BlockState state) {
|
||||||
return state.isOf(EndBlocks.AMBER_MOSS);
|
return state.is(EndBlocks.AMBER_MOSS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -4,18 +4,18 @@ import java.util.Random;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.block.Material;
|
import net.minecraft.world.level.material.Material;
|
||||||
import net.minecraft.block.ShapeContext;
|
import net.minecraft.world.level.block.ShapeContext;
|
||||||
import net.minecraft.sound.BlockSoundGroup;
|
import net.minecraft.world.level.block.SoundType;
|
||||||
import net.minecraft.state.StateManager;
|
import net.minecraft.world.level.block.state.StateDefinition;
|
||||||
import net.minecraft.state.property.EnumProperty;
|
import net.minecraft.state.property.EnumProperty;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.shape.VoxelShape;
|
import net.minecraft.util.shape.VoxelShape;
|
||||||
import net.minecraft.util.shape.VoxelShapes;
|
import net.minecraft.util.shape.VoxelShapes;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.WorldView;
|
import net.minecraft.world.WorldView;
|
||||||
import ru.betterend.blocks.BlockProperties.TripleShape;
|
import ru.betterend.blocks.BlockProperties.TripleShape;
|
||||||
import ru.betterend.blocks.basis.EndPlantBlock;
|
import ru.betterend.blocks.basis.EndPlantBlock;
|
||||||
|
@ -24,42 +24,40 @@ import ru.betterend.registry.EndBlocks;
|
||||||
public class LargeAmaranitaBlock extends EndPlantBlock {
|
public class LargeAmaranitaBlock extends EndPlantBlock {
|
||||||
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
|
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
|
||||||
private static final VoxelShape SHAPE_BOTTOM = Block.createCuboidShape(4, 0, 4, 12, 14, 12);
|
private static final VoxelShape SHAPE_BOTTOM = Block.createCuboidShape(4, 0, 4, 12, 14, 12);
|
||||||
private static final VoxelShape SHAPE_TOP = VoxelShapes.union(Block.createCuboidShape(1, 3, 1, 15, 16, 15), SHAPE_BOTTOM);
|
private static final VoxelShape SHAPE_TOP = VoxelShapes.union(Block.createCuboidShape(1, 3, 1, 15, 16, 15),
|
||||||
|
SHAPE_BOTTOM);
|
||||||
|
|
||||||
public LargeAmaranitaBlock() {
|
public LargeAmaranitaBlock() {
|
||||||
super(FabricBlockSettings.of(Material.PLANT)
|
super(FabricBlockSettings.of(Material.PLANT)
|
||||||
.luminance((state) -> (state.get(SHAPE) == TripleShape.TOP) ? 15 : 0)
|
.luminance((state) -> (state.getValue(SHAPE) == TripleShape.TOP) ? 15 : 0)
|
||||||
.breakByTool(FabricToolTags.SHEARS)
|
.breakByTool(FabricToolTags.SHEARS).sounds(SoundType.GRASS).breakByHand(true));
|
||||||
.sounds(BlockSoundGroup.GRASS)
|
|
||||||
.breakByHand(true));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
|
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
|
||||||
return state.get(SHAPE) == TripleShape.TOP ? SHAPE_TOP : SHAPE_BOTTOM;
|
return state.getValue(SHAPE) == TripleShape.TOP ? SHAPE_TOP : SHAPE_BOTTOM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isTerrain(BlockState state) {
|
protected boolean isTerrain(BlockState state) {
|
||||||
return state.isOf(EndBlocks.SANGNUM) || state.isOf(EndBlocks.MOSSY_OBSIDIAN) || state.isOf(EndBlocks.MOSSY_DRAGON_BONE);
|
return state.is(EndBlocks.SANGNUM) || state.is(EndBlocks.MOSSY_OBSIDIAN)
|
||||||
|
|| state.is(EndBlocks.MOSSY_DRAGON_BONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
|
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
|
||||||
stateManager.add(SHAPE);
|
stateManager.add(SHAPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
||||||
TripleShape shape = state.get(SHAPE);
|
TripleShape shape = state.getValue(SHAPE);
|
||||||
if (shape == TripleShape.BOTTOM) {
|
if (shape == TripleShape.BOTTOM) {
|
||||||
return isTerrain(world.getBlockState(pos.down())) && world.getBlockState(pos.up()).isOf(this);
|
return isTerrain(world.getBlockState(pos.below())) && world.getBlockState(pos.up()).is(this);
|
||||||
}
|
} else if (shape == TripleShape.TOP) {
|
||||||
else if (shape == TripleShape.TOP) {
|
return world.getBlockState(pos.below()).is(this);
|
||||||
return world.getBlockState(pos.down()).isOf(this);
|
} else {
|
||||||
}
|
return world.getBlockState(pos.below()).is(this) && world.getBlockState(pos.up()).is(this);
|
||||||
else {
|
|
||||||
return world.getBlockState(pos.down()).isOf(this) && world.getBlockState(pos.up()).isOf(this);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +72,7 @@ public class LargeAmaranitaBlock extends EndPlantBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) {
|
public boolean canGrow(Level world, Random random, BlockPos pos, BlockState state) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,20 +7,20 @@ import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.block.Material;
|
import net.minecraft.world.level.material.Material;
|
||||||
import net.minecraft.block.ShapeContext;
|
import net.minecraft.world.level.block.ShapeContext;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.loot.context.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import net.minecraft.state.StateManager;
|
import net.minecraft.world.level.block.state.StateDefinition;
|
||||||
import net.minecraft.state.property.EnumProperty;
|
import net.minecraft.state.property.EnumProperty;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.util.shape.VoxelShape;
|
import net.minecraft.util.shape.VoxelShape;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import net.minecraft.world.WorldAccess;
|
import net.minecraft.world.level.LevelAccessor;
|
||||||
import net.minecraft.world.WorldView;
|
import net.minecraft.world.WorldView;
|
||||||
import ru.betterend.blocks.BlockProperties.LumecornShape;
|
import ru.betterend.blocks.BlockProperties.LumecornShape;
|
||||||
import ru.betterend.blocks.basis.BlockBaseNotFull;
|
import ru.betterend.blocks.basis.BlockBaseNotFull;
|
||||||
|
@ -37,16 +37,14 @@ public class LumecornBlock extends BlockBaseNotFull implements IRenderTypeable {
|
||||||
private static final VoxelShape SHAPE_TOP = Block.createCuboidShape(6, 0, 6, 10, 8, 10);
|
private static final VoxelShape SHAPE_TOP = Block.createCuboidShape(6, 0, 6, 10, 8, 10);
|
||||||
|
|
||||||
public LumecornBlock() {
|
public LumecornBlock() {
|
||||||
super(FabricBlockSettings.of(Material.WOOD)
|
super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).hardness(0.5F)
|
||||||
.breakByTool(FabricToolTags.AXES)
|
|
||||||
.hardness(0.5F)
|
|
||||||
.luminance((state) -> {
|
.luminance((state) -> {
|
||||||
return state.get(SHAPE).getLight();
|
return state.getValue(SHAPE).getLight();
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
|
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
|
||||||
stateManager.add(SHAPE);
|
stateManager.add(SHAPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,46 +55,46 @@ public class LumecornBlock extends BlockBaseNotFull implements IRenderTypeable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
|
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
|
||||||
return state.get(SHAPE) == LumecornShape.LIGHT_TOP ? SHAPE_TOP : SHAPE_BOTTOM;
|
return state.getValue(SHAPE) == LumecornShape.LIGHT_TOP ? SHAPE_TOP : SHAPE_BOTTOM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
||||||
LumecornShape shape = state.get(SHAPE);
|
LumecornShape shape = state.getValue(SHAPE);
|
||||||
if (shape == LumecornShape.BOTTOM_BIG || shape == LumecornShape.BOTTOM_SMALL) {
|
if (shape == LumecornShape.BOTTOM_BIG || shape == LumecornShape.BOTTOM_SMALL) {
|
||||||
return world.getBlockState(pos.down()).isIn(EndTags.END_GROUND);
|
return world.getBlockState(pos.below()).isIn(EndTags.END_GROUND);
|
||||||
}
|
} else if (shape == LumecornShape.LIGHT_TOP) {
|
||||||
else if (shape == LumecornShape.LIGHT_TOP) {
|
return world.getBlockState(pos.below()).is(this);
|
||||||
return world.getBlockState(pos.down()).isOf(this);
|
} else {
|
||||||
}
|
return world.getBlockState(pos.below()).is(this) && world.getBlockState(pos.up()).is(this);
|
||||||
else {
|
|
||||||
return world.getBlockState(pos.down()).isOf(this) && world.getBlockState(pos.up()).isOf(this);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
|
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world,
|
||||||
|
BlockPos pos, BlockPos neighborPos) {
|
||||||
if (!canPlaceAt(state, world, pos)) {
|
if (!canPlaceAt(state, world, pos)) {
|
||||||
return Blocks.AIR.getDefaultState();
|
return Blocks.AIR.defaultBlockState();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
LumecornShape shape = state.get(SHAPE);
|
LumecornShape shape = state.getValue(SHAPE);
|
||||||
if (shape == LumecornShape.BOTTOM_BIG || shape == LumecornShape.BOTTOM_SMALL || shape == LumecornShape.MIDDLE) {
|
if (shape == LumecornShape.BOTTOM_BIG || shape == LumecornShape.BOTTOM_SMALL || shape == LumecornShape.MIDDLE) {
|
||||||
return Collections.singletonList(new ItemStack(EndBlocks.LUMECORN_SEED, MHelper.randRange(1, 2, MHelper.RANDOM)));
|
return Collections
|
||||||
|
.singletonList(new ItemStack(EndBlocks.LUMECORN_SEED, MHelper.randRange(1, 2, MHelper.RANDOM)));
|
||||||
}
|
}
|
||||||
return MHelper.RANDOM.nextBoolean() ? Collections.singletonList(new ItemStack(EndItems.LUMECORN_ROD)) : Collections.emptyList();
|
return MHelper.RANDOM.nextBoolean() ? Collections.singletonList(new ItemStack(EndItems.LUMECORN_ROD))
|
||||||
|
: Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public ItemStack getPickStack(BlockView world, BlockPos pos, BlockState state) {
|
public ItemStack getPickStack(BlockView world, BlockPos pos, BlockState state) {
|
||||||
LumecornShape shape = state.get(SHAPE);
|
LumecornShape shape = state.getValue(SHAPE);
|
||||||
if (shape == LumecornShape.BOTTOM_BIG || shape == LumecornShape.BOTTOM_SMALL || shape == LumecornShape.MIDDLE) {
|
if (shape == LumecornShape.BOTTOM_BIG || shape == LumecornShape.BOTTOM_SMALL || shape == LumecornShape.MIDDLE) {
|
||||||
return new ItemStack(EndBlocks.LUMECORN_SEED);
|
return new ItemStack(EndBlocks.LUMECORN_SEED);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,9 @@ package ru.betterend.blocks;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import net.minecraft.block.AbstractBlock;
|
import net.minecraft.world.level.block.AbstractBlock;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.StructureWorldAccess;
|
import net.minecraft.world.StructureWorldAccess;
|
||||||
import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
|
import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
|
||||||
import ru.betterend.registry.EndBlocks;
|
import ru.betterend.registry.EndBlocks;
|
||||||
|
@ -18,7 +18,7 @@ public class LumecornSeedBlock extends EndPlantWithAgeBlock {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isTerrain(BlockState state) {
|
protected boolean isTerrain(BlockState state) {
|
||||||
return state.isOf(EndBlocks.END_MOSS);
|
return state.is(EndBlocks.END_MOSS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -5,20 +5,20 @@ import java.util.Queue;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.block.FluidBlock;
|
import net.minecraft.world.level.block.FluidBlock;
|
||||||
import net.minecraft.block.FluidDrainable;
|
import net.minecraft.world.level.block.FluidDrainable;
|
||||||
import net.minecraft.block.Material;
|
import net.minecraft.world.level.material.Material;
|
||||||
import net.minecraft.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.fluid.FluidState;
|
import net.minecraft.fluid.FluidState;
|
||||||
import net.minecraft.fluid.Fluids;
|
import net.minecraft.fluid.Fluids;
|
||||||
import net.minecraft.tag.FluidTags;
|
import net.minecraft.tags.FluidTags;
|
||||||
import net.minecraft.util.Pair;
|
import net.minecraft.util.Pair;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.WorldAccess;
|
import net.minecraft.world.level.LevelAccessor;
|
||||||
import ru.betterend.blocks.basis.BlockBaseNotFull;
|
import ru.betterend.blocks.basis.BlockBaseNotFull;
|
||||||
import ru.betterend.client.render.ERenderLayer;
|
import ru.betterend.client.render.ERenderLayer;
|
||||||
import ru.betterend.interfaces.IRenderTypeable;
|
import ru.betterend.interfaces.IRenderTypeable;
|
||||||
|
@ -30,21 +30,22 @@ public class MengerSpongeBlock extends BlockBaseNotFull implements IRenderTypeab
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBlockAdded(BlockState state, World world, BlockPos pos, BlockState oldState, boolean notify) {
|
public void onBlockAdded(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) {
|
||||||
if (absorbWater(world, pos)) {
|
if (absorbWater(world, pos)) {
|
||||||
world.setBlockState(pos, EndBlocks.MENGER_SPONGE_WET.getDefaultState());
|
world.setBlockAndUpdate(pos, EndBlocks.MENGER_SPONGE_WET.defaultBlockState());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
|
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world,
|
||||||
|
BlockPos pos, BlockPos neighborPos) {
|
||||||
if (absorbWater(world, pos)) {
|
if (absorbWater(world, pos)) {
|
||||||
return EndBlocks.MENGER_SPONGE_WET.getDefaultState();
|
return EndBlocks.MENGER_SPONGE_WET.defaultBlockState();
|
||||||
}
|
}
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean absorbWater(WorldAccess world, BlockPos pos) {
|
private boolean absorbWater(LevelAccessor world, BlockPos pos) {
|
||||||
Queue<Pair<BlockPos, Integer>> queue = Lists.newLinkedList();
|
Queue<Pair<BlockPos, Integer>> queue = Lists.newLinkedList();
|
||||||
queue.add(new Pair<BlockPos, Integer>(pos, 0));
|
queue.add(new Pair<BlockPos, Integer>(pos, 0));
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -63,23 +64,25 @@ public class MengerSpongeBlock extends BlockBaseNotFull implements IRenderTypeab
|
||||||
FluidState fluidState = world.getFluidState(blockPos2);
|
FluidState fluidState = world.getFluidState(blockPos2);
|
||||||
Material material = blockState.getMaterial();
|
Material material = blockState.getMaterial();
|
||||||
if (fluidState.isIn(FluidTags.WATER)) {
|
if (fluidState.isIn(FluidTags.WATER)) {
|
||||||
if (blockState.getBlock() instanceof FluidDrainable && ((FluidDrainable) blockState.getBlock()).tryDrainFluid(world, blockPos2, blockState) != Fluids.EMPTY) {
|
if (blockState.getBlock() instanceof FluidDrainable && ((FluidDrainable) blockState.getBlock())
|
||||||
|
.tryDrainFluid(world, blockPos2, blockState) != Fluids.EMPTY) {
|
||||||
++i;
|
++i;
|
||||||
if (j < 6) {
|
if (j < 6) {
|
||||||
queue.add(new Pair<BlockPos, Integer>(blockPos2, j + 1));
|
queue.add(new Pair<BlockPos, Integer>(blockPos2, j + 1));
|
||||||
}
|
}
|
||||||
}
|
} else if (blockState.getBlock() instanceof FluidBlock) {
|
||||||
else if (blockState.getBlock() instanceof FluidBlock) {
|
world.setBlockAndUpdate(blockPos2, Blocks.AIR.defaultBlockState(), 3);
|
||||||
world.setBlockState(blockPos2, Blocks.AIR.getDefaultState(), 3);
|
|
||||||
++i;
|
++i;
|
||||||
if (j < 6) {
|
if (j < 6) {
|
||||||
queue.add(new Pair<BlockPos, Integer>(blockPos2, j + 1));
|
queue.add(new Pair<BlockPos, Integer>(blockPos2, j + 1));
|
||||||
}
|
}
|
||||||
}
|
} else if (material == Material.UNDERWATER_PLANT
|
||||||
else if (material == Material.UNDERWATER_PLANT || material == Material.REPLACEABLE_UNDERWATER_PLANT) {
|
|| material == Material.REPLACEABLE_UNDERWATER_PLANT) {
|
||||||
BlockEntity blockEntity = blockState.getBlock().hasBlockEntity() ? world.getBlockEntity(blockPos2) : null;
|
BlockEntity blockEntity = blockState.getBlock().hasBlockEntity()
|
||||||
|
? world.getBlockEntity(blockPos2)
|
||||||
|
: null;
|
||||||
dropStacks(blockState, world, blockPos2, blockEntity);
|
dropStacks(blockState, world, blockPos2, blockEntity);
|
||||||
world.setBlockState(blockPos2, Blocks.AIR.getDefaultState(), 3);
|
world.setBlockAndUpdate(blockPos2, Blocks.AIR.defaultBlockState(), 3);
|
||||||
++i;
|
++i;
|
||||||
if (j < 6) {
|
if (j < 6) {
|
||||||
queue.add(new Pair<BlockPos, Integer>(blockPos2, j + 1));
|
queue.add(new Pair<BlockPos, Integer>(blockPos2, j + 1));
|
||||||
|
|
|
@ -5,20 +5,20 @@ import java.util.Random;
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.entity.ItemEntity;
|
import net.minecraft.world.entity.ItemEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.world.entity.player.PlayerEntity;
|
||||||
import net.minecraft.fluid.FluidState;
|
import net.minecraft.fluid.FluidState;
|
||||||
import net.minecraft.fluid.Fluids;
|
import net.minecraft.fluid.Fluids;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.particle.ParticleTypes;
|
import net.minecraft.core.particles.ParticleTypes;
|
||||||
import net.minecraft.sound.SoundCategory;
|
import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.sound.SoundEvents;
|
import net.minecraft.sounds.SoundEvents;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.world.GameRules;
|
import net.minecraft.world.GameRules;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.level.Level;
|
||||||
import ru.betterend.blocks.basis.BlockBaseNotFull;
|
import ru.betterend.blocks.basis.BlockBaseNotFull;
|
||||||
import ru.betterend.client.render.ERenderLayer;
|
import ru.betterend.client.render.ERenderLayer;
|
||||||
import ru.betterend.interfaces.IRenderTypeable;
|
import ru.betterend.interfaces.IRenderTypeable;
|
||||||
|
@ -31,20 +31,21 @@ public class MengerSpongeWetBlock extends BlockBaseNotFull implements IRenderTyp
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBlockAdded(BlockState state, World world, BlockPos pos, BlockState oldState, boolean notify) {
|
public void onBlockAdded(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) {
|
||||||
if (world.getDimension().isUltrawarm()) {
|
if (world.getDimension().isUltrawarm()) {
|
||||||
world.setBlockState(pos, EndBlocks.MENGER_SPONGE.getDefaultState(), 3);
|
world.setBlockAndUpdate(pos, EndBlocks.MENGER_SPONGE.defaultBlockState(), 3);
|
||||||
world.syncWorldEvent(2009, pos, 0);
|
world.syncWorldEvent(2009, pos, 0);
|
||||||
world.playSound((PlayerEntity) null, pos, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 1.0F, (1.0F + world.getRandom().nextFloat() * 0.2F) * 0.7F);
|
world.playLocalSound((PlayerEntity) null, pos, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundSource.BLOCKS, 1.0F,
|
||||||
|
(1.0F + world.getRandom().nextFloat() * 0.2F) * 0.7F);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) {
|
public void animateTick(BlockState state, Level world, BlockPos pos, Random random) {
|
||||||
Direction direction = Direction.random(random);
|
Direction direction = Direction.random(random);
|
||||||
if (direction != Direction.UP) {
|
if (direction != Direction.UP) {
|
||||||
BlockPos blockPos = pos.offset(direction);
|
BlockPos blockPos = pos.relative(direction);
|
||||||
BlockState blockState = world.getBlockState(blockPos);
|
BlockState blockState = world.getBlockState(blockPos);
|
||||||
if (!state.isOpaque() || !blockState.isSideSolidFullSquare(world, blockPos, direction.getOpposite())) {
|
if (!state.isOpaque() || !blockState.isSideSolidFullSquare(world, blockPos, direction.getOpposite())) {
|
||||||
double x = (double) pos.getX();
|
double x = (double) pos.getX();
|
||||||
|
@ -54,24 +55,20 @@ public class MengerSpongeWetBlock extends BlockBaseNotFull implements IRenderTyp
|
||||||
y -= 0.05;
|
y -= 0.05;
|
||||||
x += random.nextDouble();
|
x += random.nextDouble();
|
||||||
z += random.nextDouble();
|
z += random.nextDouble();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
y += random.nextDouble() * 0.8;
|
y += random.nextDouble() * 0.8;
|
||||||
if (direction.getAxis() == Direction.Axis.X) {
|
if (direction.getAxis() == Direction.Axis.X) {
|
||||||
z += random.nextDouble();
|
z += random.nextDouble();
|
||||||
if (direction == Direction.EAST) {
|
if (direction == Direction.EAST) {
|
||||||
++x;
|
++x;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
x += 0.05;
|
x += 0.05;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
x += random.nextDouble();
|
x += random.nextDouble();
|
||||||
if (direction == Direction.SOUTH) {
|
if (direction == Direction.SOUTH) {
|
||||||
++z;
|
++z;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
z += 0.05;
|
z += 0.05;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,13 +80,14 @@ public class MengerSpongeWetBlock extends BlockBaseNotFull implements IRenderTyp
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBreak(World world, BlockPos pos, BlockState state, PlayerEntity player) {
|
public void onBreak(Level world, BlockPos pos, BlockState state, PlayerEntity player) {
|
||||||
BlocksHelper.setWithUpdate(world, pos, Blocks.AIR);
|
BlocksHelper.setWithUpdate(world, pos, Blocks.AIR);
|
||||||
if (!world.isClient()) {
|
if (!world.isClientSide()) {
|
||||||
world.syncWorldEvent(2001, pos, getRawIdFromState(state));
|
world.syncWorldEvent(2001, pos, getRawIdFromState(state));
|
||||||
}
|
}
|
||||||
if (world.getGameRules().getBoolean(GameRules.DO_TILE_DROPS) && (player == null || !player.isCreative())) {
|
if (world.getGameRules().getBoolean(GameRules.DO_TILE_DROPS) && (player == null || !player.isCreative())) {
|
||||||
ItemEntity drop = new ItemEntity(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, new ItemStack(this));
|
ItemEntity drop = new ItemEntity(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5,
|
||||||
|
new ItemStack(this));
|
||||||
world.spawnEntity(drop);
|
world.spawnEntity(drop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package ru.betterend.blocks;
|
package ru.betterend.blocks;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import ru.betterend.blocks.basis.BlockBase;
|
import ru.betterend.blocks.basis.BlockBase;
|
||||||
|
|
||||||
public class MissingTileBlock extends BlockBase {
|
public class MissingTileBlock extends BlockBase {
|
||||||
|
|
|
@ -5,17 +5,17 @@ import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.block.SnowBlock;
|
import net.minecraft.world.level.block.SnowBlock;
|
||||||
import net.minecraft.enchantment.EnchantmentHelper;
|
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||||
import net.minecraft.enchantment.Enchantments;
|
import net.minecraft.world.item.enchantment.Enchantments;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.loot.context.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import net.minecraft.loot.context.LootContextParameters;
|
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||||
import net.minecraft.server.world.ServerWorld;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.world.WorldView;
|
import net.minecraft.world.WorldView;
|
||||||
import net.minecraft.world.chunk.light.ChunkLightProvider;
|
import net.minecraft.world.chunk.light.ChunkLightProvider;
|
||||||
import ru.betterend.blocks.basis.EndPillarBlock;
|
import ru.betterend.blocks.basis.EndPillarBlock;
|
||||||
|
@ -27,30 +27,31 @@ public class MossyDragonBoneBlock extends EndPillarBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
ItemStack tool = builder.get(LootContextParameters.TOOL);
|
ItemStack tool = builder.getParameter(LootContextParams.TOOL);
|
||||||
if (tool != null && EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, tool) > 0) {
|
if (tool != null && EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) {
|
||||||
return Collections.singletonList(new ItemStack(this));
|
return Collections.singletonList(new ItemStack(this));
|
||||||
}
|
}
|
||||||
return Collections.singletonList(new ItemStack(EndBlocks.DRAGON_BONE_BLOCK));
|
return Collections.singletonList(new ItemStack(EndBlocks.DRAGON_BONE_BLOCK));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
|
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
|
||||||
if (random.nextInt(16) == 0 && !canSurvive(state, world, pos)) {
|
if (random.nextInt(16) == 0 && !canSurvive(state, world, pos)) {
|
||||||
world.setBlockState(pos, Blocks.BONE_BLOCK.getDefaultState().with(AXIS, state.get(AXIS)));
|
world.setBlockAndUpdate(pos, Blocks.BONE_BLOCK.defaultBlockState().with(AXIS, state.getValue(AXIS)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean canSurvive(BlockState state, WorldView worldView, BlockPos pos) {
|
public static boolean canSurvive(BlockState state, WorldView worldView, BlockPos pos) {
|
||||||
BlockPos blockPos = pos.up();
|
BlockPos blockPos = pos.up();
|
||||||
BlockState blockState = worldView.getBlockState(blockPos);
|
BlockState blockState = worldView.getBlockState(blockPos);
|
||||||
if (blockState.isOf(Blocks.SNOW) && (Integer)blockState.get(SnowBlock.LAYERS) == 1) {
|
if (blockState.is(Blocks.SNOW) && (Integer) blockState.get(SnowBlock.LAYERS) == 1) {
|
||||||
return true;
|
return true;
|
||||||
} else if (blockState.getFluidState().getLevel() == 8) {
|
} else if (blockState.getFluidState().getLevel() == 8) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
int i = ChunkLightProvider.getRealisticOpacity(worldView, state, pos, blockState, blockPos, Direction.UP, blockState.getOpacity(worldView, blockPos));
|
int i = ChunkLightProvider.getRealisticOpacity(worldView, state, pos, blockState, blockPos, Direction.UP,
|
||||||
|
blockState.getOpacity(worldView, blockPos));
|
||||||
return i < 5;
|
return i < 5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,12 +2,12 @@ package ru.betterend.blocks;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.block.Material;
|
import net.minecraft.world.level.material.Material;
|
||||||
import net.minecraft.item.ItemPlacementContext;
|
import net.minecraft.world.item.ItemPlacementContext;
|
||||||
import net.minecraft.sound.BlockSoundGroup;
|
import net.minecraft.world.level.block.SoundType;
|
||||||
import net.minecraft.state.StateManager;
|
import net.minecraft.world.level.block.state.StateDefinition;
|
||||||
import net.minecraft.state.property.BooleanProperty;
|
import net.minecraft.state.property.BooleanProperty;
|
||||||
import ru.betterend.blocks.basis.BlockBase;
|
import ru.betterend.blocks.basis.BlockBase;
|
||||||
import ru.betterend.registry.EndBlocks;
|
import ru.betterend.registry.EndBlocks;
|
||||||
|
@ -16,15 +16,16 @@ public class MossyGlowshroomCapBlock extends BlockBase {
|
||||||
public static final BooleanProperty TRANSITION = BlockProperties.TRANSITION;
|
public static final BooleanProperty TRANSITION = BlockProperties.TRANSITION;
|
||||||
|
|
||||||
public MossyGlowshroomCapBlock() {
|
public MossyGlowshroomCapBlock() {
|
||||||
super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).sounds(BlockSoundGroup.WOOD));
|
super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).sounds(SoundType.WOOD));
|
||||||
this.setDefaultState(this.stateManager.getDefaultState().with(TRANSITION, false));
|
this.setDefaultState(this.stateManager.defaultBlockState().with(TRANSITION, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockState getPlacementState(ItemPlacementContext ctx) {
|
public BlockState getPlacementState(ItemPlacementContext ctx) {
|
||||||
return this.getDefaultState().with(TRANSITION, EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(ctx.getWorld().getBlockState(ctx.getBlockPos().down())));
|
return this.defaultBlockState().with(TRANSITION,
|
||||||
|
EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(ctx.getLevel().getBlockState(ctx.getBlockPos().below())));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
||||||
builder.add(TRANSITION);
|
builder.add(TRANSITION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package ru.betterend.blocks;
|
package ru.betterend.blocks;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.WorldView;
|
import net.minecraft.world.WorldView;
|
||||||
import net.minecraft.world.gen.feature.Feature;
|
import net.minecraft.world.gen.feature.Feature;
|
||||||
import ru.betterend.blocks.basis.FeatureSaplingBlock;
|
import ru.betterend.blocks.basis.FeatureSaplingBlock;
|
||||||
|
@ -20,6 +20,7 @@ public class MossyGlowshroomSaplingBlock extends FeatureSaplingBlock {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
||||||
return world.getBlockState(pos.down()).isOf(EndBlocks.END_MOSS) || world.getBlockState(pos.down()).isOf(EndBlocks.END_MYCELIUM);
|
return world.getBlockState(pos.below()).is(EndBlocks.END_MOSS)
|
||||||
|
|| world.getBlockState(pos.below()).is(EndBlocks.END_MYCELIUM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,17 +5,17 @@ import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.block.SnowBlock;
|
import net.minecraft.world.level.block.SnowBlock;
|
||||||
import net.minecraft.enchantment.EnchantmentHelper;
|
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||||
import net.minecraft.enchantment.Enchantments;
|
import net.minecraft.world.item.enchantment.Enchantments;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.loot.context.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import net.minecraft.loot.context.LootContextParameters;
|
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||||
import net.minecraft.server.world.ServerWorld;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.world.WorldView;
|
import net.minecraft.world.WorldView;
|
||||||
import net.minecraft.world.chunk.light.ChunkLightProvider;
|
import net.minecraft.world.chunk.light.ChunkLightProvider;
|
||||||
import ru.betterend.blocks.basis.BlockBase;
|
import ru.betterend.blocks.basis.BlockBase;
|
||||||
|
@ -26,30 +26,31 @@ public class MossyObsidian extends BlockBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
ItemStack tool = builder.get(LootContextParameters.TOOL);
|
ItemStack tool = builder.getParameter(LootContextParams.TOOL);
|
||||||
if (tool != null && EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, tool) > 0) {
|
if (tool != null && EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) {
|
||||||
return Collections.singletonList(new ItemStack(this));
|
return Collections.singletonList(new ItemStack(this));
|
||||||
}
|
}
|
||||||
return Collections.singletonList(new ItemStack(Blocks.OBSIDIAN));
|
return Collections.singletonList(new ItemStack(Blocks.OBSIDIAN));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
|
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
|
||||||
if (random.nextInt(16) == 0 && !canSurvive(state, world, pos)) {
|
if (random.nextInt(16) == 0 && !canSurvive(state, world, pos)) {
|
||||||
world.setBlockState(pos, Blocks.OBSIDIAN.getDefaultState());
|
world.setBlockAndUpdate(pos, Blocks.OBSIDIAN.defaultBlockState());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean canSurvive(BlockState state, WorldView worldView, BlockPos pos) {
|
public static boolean canSurvive(BlockState state, WorldView worldView, BlockPos pos) {
|
||||||
BlockPos blockPos = pos.up();
|
BlockPos blockPos = pos.up();
|
||||||
BlockState blockState = worldView.getBlockState(blockPos);
|
BlockState blockState = worldView.getBlockState(blockPos);
|
||||||
if (blockState.isOf(Blocks.SNOW) && (Integer)blockState.get(SnowBlock.LAYERS) == 1) {
|
if (blockState.is(Blocks.SNOW) && (Integer) blockState.get(SnowBlock.LAYERS) == 1) {
|
||||||
return true;
|
return true;
|
||||||
} else if (blockState.getFluidState().getLevel() == 8) {
|
} else if (blockState.getFluidState().getLevel() == 8) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
int i = ChunkLightProvider.getRealisticOpacity(worldView, state, pos, blockState, blockPos, Direction.UP, blockState.getOpacity(worldView, blockPos));
|
int i = ChunkLightProvider.getRealisticOpacity(worldView, state, pos, blockState, blockPos, Direction.UP,
|
||||||
|
blockState.getOpacity(worldView, blockPos));
|
||||||
return i < 5;
|
return i < 5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,23 +4,23 @@ import java.util.Random;
|
||||||
|
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraft.entity.ai.pathing.NavigationType;
|
import net.minecraft.world.entity.ai.pathing.NavigationType;
|
||||||
import net.minecraft.entity.effect.StatusEffectInstance;
|
import net.minecraft.world.entity.effect.StatusEffectInstance;
|
||||||
import net.minecraft.entity.effect.StatusEffects;
|
import net.minecraft.world.entity.effect.StatusEffects;
|
||||||
import net.minecraft.particle.ParticleTypes;
|
import net.minecraft.core.particles.ParticleTypes;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.level.Level;
|
||||||
import ru.betterend.blocks.basis.EndPlantBlock;
|
import ru.betterend.blocks.basis.EndPlantBlock;
|
||||||
import ru.betterend.registry.EndBlocks;
|
import ru.betterend.registry.EndBlocks;
|
||||||
|
|
||||||
public class MurkweedBlock extends EndPlantBlock {
|
public class MurkweedBlock extends EndPlantBlock {
|
||||||
@Override
|
@Override
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) {
|
public void animateTick(BlockState state, Level world, BlockPos pos, Random random) {
|
||||||
double x = pos.getX() + random.nextDouble();
|
double x = pos.getX() + random.nextDouble();
|
||||||
double y = pos.getY() + random.nextDouble() * 0.5 + 0.5;
|
double y = pos.getY() + random.nextDouble() * 0.5 + 0.5;
|
||||||
double z = pos.getZ() + random.nextDouble();
|
double z = pos.getZ() + random.nextDouble();
|
||||||
|
@ -29,7 +29,7 @@ public class MurkweedBlock extends EndPlantBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) {
|
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
|
||||||
if (entity instanceof LivingEntity && !((LivingEntity) entity).hasStatusEffect(StatusEffects.BLINDNESS)) {
|
if (entity instanceof LivingEntity && !((LivingEntity) entity).hasStatusEffect(StatusEffects.BLINDNESS)) {
|
||||||
((LivingEntity) entity).addStatusEffect(new StatusEffectInstance(StatusEffects.BLINDNESS, 50));
|
((LivingEntity) entity).addStatusEffect(new StatusEffectInstance(StatusEffects.BLINDNESS, 50));
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ public class MurkweedBlock extends EndPlantBlock {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isTerrain(BlockState state) {
|
protected boolean isTerrain(BlockState state) {
|
||||||
return state.isOf(EndBlocks.SHADOW_GRASS);
|
return state.is(EndBlocks.SHADOW_GRASS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -5,46 +5,46 @@ import java.util.List;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.enchantment.EnchantmentHelper;
|
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||||
import net.minecraft.enchantment.Enchantments;
|
import net.minecraft.world.item.enchantment.Enchantments;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraft.entity.ai.pathing.NavigationType;
|
import net.minecraft.world.entity.ai.pathing.NavigationType;
|
||||||
import net.minecraft.entity.damage.DamageSource;
|
import net.minecraft.world.entity.damage.DamageSource;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.item.Items;
|
import net.minecraft.world.item.Items;
|
||||||
import net.minecraft.loot.context.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import net.minecraft.loot.context.LootContextParameters;
|
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.level.Level;
|
||||||
import ru.betterend.blocks.basis.EndPlantBlock;
|
import ru.betterend.blocks.basis.EndPlantBlock;
|
||||||
import ru.betterend.registry.EndBlocks;
|
import ru.betterend.registry.EndBlocks;
|
||||||
import ru.betterend.util.MHelper;
|
import ru.betterend.util.MHelper;
|
||||||
|
|
||||||
public class NeedlegrassBlock extends EndPlantBlock {
|
public class NeedlegrassBlock extends EndPlantBlock {
|
||||||
@Override
|
@Override
|
||||||
public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) {
|
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
|
||||||
if (entity instanceof LivingEntity) {
|
if (entity instanceof LivingEntity) {
|
||||||
entity.damage(DamageSource.CACTUS, 0.1F);
|
entity.damage(DamageSource.CACTUS, 0.1F);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
ItemStack tool = builder.get(LootContextParameters.TOOL);
|
ItemStack tool = builder.getParameter(LootContextParams.TOOL);
|
||||||
if (tool != null && tool.getItem().isIn(FabricToolTags.SHEARS) || EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, tool) > 0) {
|
if (tool != null && tool.getItem().isIn(FabricToolTags.SHEARS)
|
||||||
|
|| EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) {
|
||||||
return Lists.newArrayList(new ItemStack(this));
|
return Lists.newArrayList(new ItemStack(this));
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return Lists.newArrayList(new ItemStack(Items.STICK, MHelper.randRange(0, 2, MHelper.RANDOM)));
|
return Lists.newArrayList(new ItemStack(Items.STICK, MHelper.randRange(0, 2, MHelper.RANDOM)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isTerrain(BlockState state) {
|
protected boolean isTerrain(BlockState state) {
|
||||||
return state.isOf(EndBlocks.SHADOW_GRASS);
|
return state.is(EndBlocks.SHADOW_GRASS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -5,28 +5,28 @@ import java.util.EnumMap;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.block.ShapeContext;
|
import net.minecraft.world.level.block.ShapeContext;
|
||||||
import net.minecraft.block.Waterloggable;
|
import net.minecraft.world.level.block.Waterloggable;
|
||||||
import net.minecraft.fluid.FluidState;
|
import net.minecraft.fluid.FluidState;
|
||||||
import net.minecraft.fluid.Fluids;
|
import net.minecraft.fluid.Fluids;
|
||||||
import net.minecraft.item.ItemPlacementContext;
|
import net.minecraft.world.item.ItemPlacementContext;
|
||||||
import net.minecraft.state.StateManager;
|
import net.minecraft.world.level.block.state.StateDefinition;
|
||||||
import net.minecraft.state.property.BooleanProperty;
|
import net.minecraft.state.property.BooleanProperty;
|
||||||
import net.minecraft.state.property.DirectionProperty;
|
import net.minecraft.state.property.DirectionProperty;
|
||||||
import net.minecraft.state.property.EnumProperty;
|
import net.minecraft.state.property.EnumProperty;
|
||||||
import net.minecraft.state.property.Properties;
|
import net.minecraft.state.property.Properties;
|
||||||
import net.minecraft.util.BlockMirror;
|
import net.minecraft.util.BlockMirror;
|
||||||
import net.minecraft.util.BlockRotation;
|
import net.minecraft.world.level.block.Rotation;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.util.math.Direction.Axis;
|
import net.minecraft.core.Direction.Axis;
|
||||||
import net.minecraft.util.shape.VoxelShape;
|
import net.minecraft.util.shape.VoxelShape;
|
||||||
import net.minecraft.util.shape.VoxelShapes;
|
import net.minecraft.util.shape.VoxelShapes;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import net.minecraft.world.WorldAccess;
|
import net.minecraft.world.level.LevelAccessor;
|
||||||
import ru.betterend.blocks.BlockProperties.TripleShape;
|
import ru.betterend.blocks.BlockProperties.TripleShape;
|
||||||
import ru.betterend.blocks.basis.BlockBaseNotFull;
|
import ru.betterend.blocks.basis.BlockBaseNotFull;
|
||||||
import ru.betterend.client.render.ERenderLayer;
|
import ru.betterend.client.render.ERenderLayer;
|
||||||
|
@ -45,29 +45,32 @@ public class NeonCactusBlock extends BlockBaseNotFull implements Waterloggable,
|
||||||
|
|
||||||
public NeonCactusBlock() {
|
public NeonCactusBlock() {
|
||||||
super(FabricBlockSettings.copyOf(Blocks.CACTUS).luminance(state -> {
|
super(FabricBlockSettings.copyOf(Blocks.CACTUS).luminance(state -> {
|
||||||
TripleShape shape = state.get(SHAPE);
|
TripleShape shape = state.getValue(SHAPE);
|
||||||
if (shape == TripleShape.TOP) {
|
if (shape == TripleShape.TOP) {
|
||||||
return 15;
|
return 15;
|
||||||
}
|
}
|
||||||
return shape == TripleShape.MIDDLE ? 13 : 10;
|
return shape == TripleShape.MIDDLE ? 13 : 10;
|
||||||
}));
|
}));
|
||||||
setDefaultState(getDefaultState().with(WATERLOGGED, false).with(FACING, Direction.UP).with(SHAPE, TripleShape.TOP));
|
setDefaultState(
|
||||||
|
getDefaultState().with(WATERLOGGED, false).with(FACING, Direction.UP).with(SHAPE, TripleShape.TOP));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
|
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
|
||||||
stateManager.add(SHAPE, WATERLOGGED, FACING);
|
stateManager.add(SHAPE, WATERLOGGED, FACING);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getPlacementState(ItemPlacementContext ctx) {
|
public BlockState getPlacementState(ItemPlacementContext ctx) {
|
||||||
WorldAccess worldAccess = ctx.getWorld();
|
LevelAccessor worldAccess = ctx.getLevel();
|
||||||
BlockPos blockPos = ctx.getBlockPos();
|
BlockPos blockPos = ctx.getBlockPos();
|
||||||
return this.getDefaultState().with(WATERLOGGED, worldAccess.getFluidState(blockPos).getFluid() == Fluids.WATER).with(FACING, ctx.getSide());
|
return this.defaultBlockState()
|
||||||
|
.with(WATERLOGGED, worldAccess.getFluidState(blockPos).getFluid() == Fluids.WATER)
|
||||||
|
.with(FACING, ctx.getSide());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState rotate(BlockState state, BlockRotation rotation) {
|
public BlockState rotate(BlockState state, Rotation rotation) {
|
||||||
return BlocksHelper.rotateHorizontal(state, rotation, FACING);
|
return BlocksHelper.rotateHorizontal(state, rotation, FACING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,12 +81,13 @@ public class NeonCactusBlock extends BlockBaseNotFull implements Waterloggable,
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FluidState getFluidState(BlockState state) {
|
public FluidState getFluidState(BlockState state) {
|
||||||
return (Boolean) state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(state);
|
return (Boolean) state.getValue(WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState newState, WorldAccess world, BlockPos pos, BlockPos posFrom) {
|
public BlockState updateShape(BlockState state, Direction direction, BlockState newState, LevelAccessor world,
|
||||||
if ((Boolean) state.get(WATERLOGGED)) {
|
BlockPos pos, BlockPos posFrom) {
|
||||||
|
if ((Boolean) state.getValue(WATERLOGGED)) {
|
||||||
world.getFluidTickScheduler().schedule(pos, Fluids.WATER, Fluids.WATER.getTickRate(world));
|
world.getFluidTickScheduler().schedule(pos, Fluids.WATER, Fluids.WATER.getTickRate(world));
|
||||||
}
|
}
|
||||||
return state;
|
return state;
|
||||||
|
@ -96,18 +100,17 @@ public class NeonCactusBlock extends BlockBaseNotFull implements Waterloggable,
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
|
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
|
||||||
TripleShape shape = state.get(SHAPE);
|
TripleShape shape = state.getValue(SHAPE);
|
||||||
|
|
||||||
if (shape == TripleShape.BOTTOM) {
|
if (shape == TripleShape.BOTTOM) {
|
||||||
return VoxelShapes.fullCube();
|
return VoxelShapes.fullCube();
|
||||||
}
|
}
|
||||||
Direction dir = state.get(FACING);
|
Direction dir = state.getValue(FACING);
|
||||||
BlockState next = view.getBlockState(pos.offset(dir));
|
BlockState next = view.getBlockState(pos.relative(dir));
|
||||||
if (next.isOf(this)) {
|
if (next.is(this)) {
|
||||||
Axis axis = dir.getAxis();
|
Axis axis = dir.getAxis();
|
||||||
return shape == TripleShape.MIDDLE ? MEDIUM_SHAPES.get(axis) : SMALL_SHAPES.get(axis);
|
return shape == TripleShape.MIDDLE ? MEDIUM_SHAPES.get(axis) : SMALL_SHAPES.get(axis);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return shape == TripleShape.MIDDLE ? MEDIUM_SHAPES_OPEN.get(dir) : SMALL_SHAPES_OPEN.get(dir);
|
return shape == TripleShape.MIDDLE ? MEDIUM_SHAPES_OPEN.get(dir) : SMALL_SHAPES_OPEN.get(dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package ru.betterend.blocks;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import ru.betterend.blocks.basis.PedestalBlock;
|
import ru.betterend.blocks.basis.PedestalBlock;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.patterns.Patterns;
|
||||||
|
|
||||||
|
@ -17,12 +17,12 @@ public class PedestalVanilla extends PedestalBlock {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String block) {
|
public String getModelPattern(String block) {
|
||||||
Identifier blockId = Registry.BLOCK.getId(parent);
|
ResourceLocation blockId = Registry.BLOCK.getKey(parent);
|
||||||
String name = blockId.getPath().replace("_block", "");
|
String name = blockId.getPath().replace("_block", "");
|
||||||
Map<String, String> textures = new HashMap<String, String>() {
|
Map<String, String> textures = new HashMap<String, String>() {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
{
|
{
|
||||||
put("%mod%", blockId.getNamespace() );
|
put("%mod%", blockId.getNamespace());
|
||||||
put("%top%", "polished_" + name);
|
put("%top%", "polished_" + name);
|
||||||
put("%base%", "polished_" + name);
|
put("%base%", "polished_" + name);
|
||||||
put("%pillar%", name + "_pillar");
|
put("%pillar%", name + "_pillar");
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package ru.betterend.blocks;
|
package ru.betterend.blocks;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.WorldView;
|
import net.minecraft.world.WorldView;
|
||||||
import net.minecraft.world.gen.feature.Feature;
|
import net.minecraft.world.gen.feature.Feature;
|
||||||
import ru.betterend.blocks.basis.FeatureSaplingBlock;
|
import ru.betterend.blocks.basis.FeatureSaplingBlock;
|
||||||
|
@ -20,6 +20,6 @@ public class PythadendronSaplingBlock extends FeatureSaplingBlock {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
||||||
return world.getBlockState(pos.down()).isOf(EndBlocks.CHORUS_NYLIUM);
|
return world.getBlockState(pos.below()).is(EndBlocks.CHORUS_NYLIUM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,33 +7,33 @@ import org.jetbrains.annotations.Nullable;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.block.ShapeContext;
|
import net.minecraft.world.level.block.ShapeContext;
|
||||||
import net.minecraft.client.color.block.BlockColorProvider;
|
import net.minecraft.client.color.block.BlockColor;
|
||||||
import net.minecraft.client.color.item.ItemColorProvider;
|
import net.minecraft.client.color.item.ItemColor;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.world.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.BlockItem;
|
import net.minecraft.world.item.BlockItem;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.loot.context.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.server.world.ServerWorld;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.sound.SoundCategory;
|
import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.sound.SoundEvents;
|
import net.minecraft.sounds.SoundEvents;
|
||||||
import net.minecraft.state.StateManager;
|
import net.minecraft.world.level.block.state.StateDefinition;
|
||||||
import net.minecraft.state.property.EnumProperty;
|
import net.minecraft.state.property.EnumProperty;
|
||||||
import net.minecraft.text.TranslatableText;
|
import net.minecraft.text.TranslatableText;
|
||||||
import net.minecraft.util.ActionResult;
|
import net.minecraft.util.ActionResult;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.hit.BlockHitResult;
|
import net.minecraft.util.hit.BlockHitResult;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.util.shape.VoxelShape;
|
import net.minecraft.util.shape.VoxelShape;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.WorldAccess;
|
import net.minecraft.world.level.LevelAccessor;
|
||||||
import net.minecraft.world.WorldView;
|
import net.minecraft.world.WorldView;
|
||||||
import ru.betterend.blocks.BlockProperties.TripleShape;
|
import ru.betterend.blocks.BlockProperties.TripleShape;
|
||||||
import ru.betterend.blocks.basis.BlockBase;
|
import ru.betterend.blocks.basis.BlockBase;
|
||||||
|
@ -54,17 +54,17 @@ public class RespawnObeliskBlock extends BlockBase implements IColorProvider, IR
|
||||||
|
|
||||||
public RespawnObeliskBlock() {
|
public RespawnObeliskBlock() {
|
||||||
super(FabricBlockSettings.copyOf(Blocks.END_STONE).luminance((state) -> {
|
super(FabricBlockSettings.copyOf(Blocks.END_STONE).luminance((state) -> {
|
||||||
return (state.get(SHAPE) == TripleShape.BOTTOM) ? 0 : 15;
|
return (state.getValue(SHAPE) == TripleShape.BOTTOM) ? 0 : 15;
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
|
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
|
||||||
return (state.get(SHAPE) == TripleShape.BOTTOM) ? VOXEL_SHAPE_BOTTOM : VOXEL_SHAPE_MIDDLE_TOP;
|
return (state.getValue(SHAPE) == TripleShape.BOTTOM) ? VOXEL_SHAPE_BOTTOM : VOXEL_SHAPE_MIDDLE_TOP;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
|
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
|
||||||
stateManager.add(SHAPE);
|
stateManager.add(SHAPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,50 +79,46 @@ public class RespawnObeliskBlock extends BlockBase implements IColorProvider, IR
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlaced(World world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack itemStack) {
|
public void onPlaced(Level world, BlockPos pos, BlockState state, @Nullable LivingEntity placer,
|
||||||
state = this.getDefaultState();
|
ItemStack itemStack) {
|
||||||
|
state = this.defaultBlockState();
|
||||||
BlocksHelper.setWithUpdate(world, pos, state.with(SHAPE, TripleShape.BOTTOM));
|
BlocksHelper.setWithUpdate(world, pos, state.with(SHAPE, TripleShape.BOTTOM));
|
||||||
BlocksHelper.setWithUpdate(world, pos.up(), state.with(SHAPE, TripleShape.MIDDLE));
|
BlocksHelper.setWithUpdate(world, pos.up(), state.with(SHAPE, TripleShape.MIDDLE));
|
||||||
BlocksHelper.setWithUpdate(world, pos.up(2), state.with(SHAPE, TripleShape.TOP));
|
BlocksHelper.setWithUpdate(world, pos.up(2), state.with(SHAPE, TripleShape.TOP));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
|
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world,
|
||||||
TripleShape shape = state.get(SHAPE);
|
BlockPos pos, BlockPos neighborPos) {
|
||||||
|
TripleShape shape = state.getValue(SHAPE);
|
||||||
if (shape == TripleShape.BOTTOM) {
|
if (shape == TripleShape.BOTTOM) {
|
||||||
if (world.getBlockState(pos.up()).isOf(this)) {
|
if (world.getBlockState(pos.up()).is(this)) {
|
||||||
return state;
|
return state;
|
||||||
|
} else {
|
||||||
|
return Blocks.AIR.defaultBlockState();
|
||||||
}
|
}
|
||||||
else {
|
} else if (shape == TripleShape.MIDDLE) {
|
||||||
return Blocks.AIR.getDefaultState();
|
if (world.getBlockState(pos.up()).is(this) && world.getBlockState(pos.below()).is(this)) {
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (shape == TripleShape.MIDDLE) {
|
|
||||||
if (world.getBlockState(pos.up()).isOf(this) && world.getBlockState(pos.down()).isOf(this)) {
|
|
||||||
return state;
|
return state;
|
||||||
|
} else {
|
||||||
|
return Blocks.AIR.defaultBlockState();
|
||||||
}
|
}
|
||||||
else {
|
} else {
|
||||||
return Blocks.AIR.getDefaultState();
|
if (world.getBlockState(pos.below()).is(this)) {
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (world.getBlockState(pos.down()).isOf(this)) {
|
|
||||||
return state;
|
return state;
|
||||||
}
|
} else {
|
||||||
else {
|
return Blocks.AIR.defaultBlockState();
|
||||||
return Blocks.AIR.getDefaultState();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBreak(World world, BlockPos pos, BlockState state, PlayerEntity player) {
|
public void onBreak(Level world, BlockPos pos, BlockState state, PlayerEntity player) {
|
||||||
if (player.isCreative()) {
|
if (player.isCreative()) {
|
||||||
TripleShape shape = state.get(SHAPE);
|
TripleShape shape = state.getValue(SHAPE);
|
||||||
if (shape == TripleShape.MIDDLE) {
|
if (shape == TripleShape.MIDDLE) {
|
||||||
BlocksHelper.setWithUpdate(world, pos.down(), Blocks.AIR);
|
BlocksHelper.setWithUpdate(world, pos.below(), Blocks.AIR);
|
||||||
}
|
} else if (shape == TripleShape.TOP) {
|
||||||
else if (shape == TripleShape.TOP) {
|
|
||||||
BlocksHelper.setWithUpdate(world, pos.down(2), Blocks.AIR);
|
BlocksHelper.setWithUpdate(world, pos.down(2), Blocks.AIR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -130,11 +126,10 @@ public class RespawnObeliskBlock extends BlockBase implements IColorProvider, IR
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
if (state.get(SHAPE) == TripleShape.BOTTOM) {
|
if (state.getValue(SHAPE) == TripleShape.BOTTOM) {
|
||||||
return Lists.newArrayList(new ItemStack(this));
|
return Lists.newArrayList(new ItemStack(this));
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return Lists.newArrayList();
|
return Lists.newArrayList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -145,58 +140,57 @@ public class RespawnObeliskBlock extends BlockBase implements IColorProvider, IR
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockColorProvider getProvider() {
|
public BlockColor getBlockProvider() {
|
||||||
return ((IColorProvider) EndBlocks.AURORA_CRYSTAL).getProvider();
|
return ((IColorProvider) EndBlocks.AURORA_CRYSTAL).getBlockProvider();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemColorProvider getItemProvider() {
|
public ItemColor getItemProvider() {
|
||||||
return (stack, tintIndex) -> {
|
return (stack, tintIndex) -> {
|
||||||
return MHelper.color(255, 255, 255);
|
return MHelper.color(255, 255, 255);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
|
public ActionResult onUse(BlockState state, Level world, BlockPos pos, PlayerEntity player, Hand hand,
|
||||||
|
BlockHitResult hit) {
|
||||||
ItemStack itemStack = player.getStackInHand(hand);
|
ItemStack itemStack = player.getStackInHand(hand);
|
||||||
boolean canActivate = itemStack.getItem() == EndItems.AMBER_GEM && itemStack.getCount() > 5;
|
boolean canActivate = itemStack.getItem() == EndItems.AMBER_GEM && itemStack.getCount() > 5;
|
||||||
if (hand != Hand.MAIN_HAND || !canActivate) {
|
if (hand != Hand.MAIN_HAND || !canActivate) {
|
||||||
if (!world.isClient && !(itemStack.getItem() instanceof BlockItem) && !player.isCreative()) {
|
if (!world.isClientSide && !(itemStack.getItem() instanceof BlockItem) && !player.isCreative()) {
|
||||||
ServerPlayerEntity serverPlayerEntity = (ServerPlayerEntity) player;
|
ServerPlayer serverPlayerEntity = (ServerPlayer) player;
|
||||||
serverPlayerEntity.sendMessage(new TranslatableText("message.betterend.fail_spawn"), true);
|
serverPlayerEntity.sendMessage(new TranslatableText("message.betterend.fail_spawn"), true);
|
||||||
}
|
}
|
||||||
return ActionResult.FAIL;
|
return ActionResult.FAIL;
|
||||||
}
|
} else if (!world.isClientSide) {
|
||||||
else if (!world.isClient) {
|
ServerPlayer serverPlayerEntity = (ServerPlayer) player;
|
||||||
ServerPlayerEntity serverPlayerEntity = (ServerPlayerEntity) player;
|
serverPlayerEntity.setSpawnPoint(world.dimension(), pos, 0.0F, false, false);
|
||||||
serverPlayerEntity.setSpawnPoint(world.getRegistryKey(), pos, 0.0F, false, false);
|
|
||||||
serverPlayerEntity.sendMessage(new TranslatableText("message.betterend.set_spawn"), true);
|
serverPlayerEntity.sendMessage(new TranslatableText("message.betterend.set_spawn"), true);
|
||||||
double px = pos.getX() + 0.5;
|
double px = pos.getX() + 0.5;
|
||||||
double py = pos.getY() + 0.5;
|
double py = pos.getY() + 0.5;
|
||||||
double pz = pos.getZ() + 0.5;
|
double pz = pos.getZ() + 0.5;
|
||||||
InfusionParticleType particle = new InfusionParticleType(new ItemStack(EndItems.AMBER_GEM));
|
InfusionParticleType particle = new InfusionParticleType(new ItemStack(EndItems.AMBER_GEM));
|
||||||
if (world instanceof ServerWorld) {
|
if (world instanceof ServerLevel) {
|
||||||
double py1 = py;
|
double py1 = py;
|
||||||
double py2 = py - 0.2;
|
double py2 = py - 0.2;
|
||||||
if (state.get(SHAPE) == TripleShape.BOTTOM) {
|
if (state.getValue(SHAPE) == TripleShape.BOTTOM) {
|
||||||
py1 += 1;
|
py1 += 1;
|
||||||
py2 += 2;
|
py2 += 2;
|
||||||
}
|
} else if (state.getValue(SHAPE) == TripleShape.MIDDLE) {
|
||||||
else if (state.get(SHAPE) == TripleShape.MIDDLE) {
|
|
||||||
py1 += 0;
|
py1 += 0;
|
||||||
py2 += 1;
|
py2 += 1;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
py1 -= 2;
|
py1 -= 2;
|
||||||
}
|
}
|
||||||
((ServerWorld) world).spawnParticles(particle, px, py1, pz, 20, 0.14, 0.5, 0.14, 0.1);
|
((ServerLevel) world).sendParticles(particle, px, py1, pz, 20, 0.14, 0.5, 0.14, 0.1);
|
||||||
((ServerWorld) world).spawnParticles(particle, px, py2, pz, 20, 0.14, 0.3, 0.14, 0.1);
|
((ServerLevel) world).sendParticles(particle, px, py2, pz, 20, 0.14, 0.3, 0.14, 0.1);
|
||||||
}
|
}
|
||||||
world.playSound(null, px, py, py, SoundEvents.BLOCK_RESPAWN_ANCHOR_SET_SPAWN, SoundCategory.BLOCKS, 1F, 1F);
|
world.playLocalSound(null, px, py, py, SoundEvents.BLOCK_RESPAWN_ANCHOR_SET_SPAWN, SoundSource.BLOCKS, 1F,
|
||||||
|
1F);
|
||||||
if (!player.isCreative()) {
|
if (!player.isCreative()) {
|
||||||
itemStack.decrement(6);
|
itemStack.decrement(6);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return player.isCreative() ? ActionResult.PASS : ActionResult.success(world.isClient);
|
return player.isCreative() ? ActionResult.PASS : ActionResult.success(world.isClientSide);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package ru.betterend.blocks;
|
package ru.betterend.blocks;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.state.StateManager;
|
import net.minecraft.world.level.block.state.StateDefinition;
|
||||||
import net.minecraft.state.property.BooleanProperty;
|
import net.minecraft.state.property.BooleanProperty;
|
||||||
import ru.betterend.blocks.basis.BlockBase;
|
import ru.betterend.blocks.basis.BlockBase;
|
||||||
import ru.betterend.registry.EndBlocks;
|
import ru.betterend.registry.EndBlocks;
|
||||||
|
@ -13,14 +13,15 @@ public class RunedFlavolite extends BlockBase {
|
||||||
public static final BooleanProperty ACTIVATED = BlockProperties.ACTIVE;
|
public static final BooleanProperty ACTIVATED = BlockProperties.ACTIVE;
|
||||||
|
|
||||||
public RunedFlavolite() {
|
public RunedFlavolite() {
|
||||||
super(FabricBlockSettings.copyOf(EndBlocks.FLAVOLITE.polished).resistance(Blocks.OBSIDIAN.getBlastResistance()).luminance(state -> {
|
super(FabricBlockSettings.copyOf(EndBlocks.FLAVOLITE.polished)
|
||||||
return state.get(ACTIVATED) ? 8 : 0;
|
.resistance(Blocks.OBSIDIAN.getExplosionResistance()).luminance(state -> {
|
||||||
|
return state.getValue(ACTIVATED) ? 8 : 0;
|
||||||
}));
|
}));
|
||||||
this.setDefaultState(stateManager.getDefaultState().with(ACTIVATED, false));
|
this.setDefaultState(stateManager.defaultBlockState().with(ACTIVATED, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
|
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
|
||||||
stateManager.add(ACTIVATED);
|
stateManager.add(ACTIVATED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package ru.betterend.blocks;
|
package ru.betterend.blocks;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.block.ShapeContext;
|
import net.minecraft.world.level.block.ShapeContext;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.shape.VoxelShape;
|
import net.minecraft.util.shape.VoxelShape;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import ru.betterend.blocks.basis.EndCropBlock;
|
import ru.betterend.blocks.basis.EndCropBlock;
|
||||||
import ru.betterend.registry.EndBlocks;
|
import ru.betterend.registry.EndBlocks;
|
||||||
import ru.betterend.registry.EndItems;
|
import ru.betterend.registry.EndItems;
|
||||||
|
|
|
@ -4,22 +4,23 @@ import java.util.Random;
|
||||||
|
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.block.MaterialColor;
|
import net.minecraft.world.level.material.MaterialColor;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.level.Level;
|
||||||
import ru.betterend.registry.EndParticles;
|
import ru.betterend.registry.EndParticles;
|
||||||
|
|
||||||
public class ShadowGrassBlock extends EndTerrainBlock {
|
public class ShadowGrassBlock extends EndTerrainBlock {
|
||||||
public ShadowGrassBlock() {
|
public ShadowGrassBlock() {
|
||||||
super(MaterialColor.BLACK);
|
super(MaterialColor.COLOR_BLACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) {
|
public void animateTick(BlockState state, Level world, BlockPos pos, Random random) {
|
||||||
super.randomDisplayTick(state, world, pos, random);
|
super.animateTick(state, world, pos, random);
|
||||||
if (random.nextInt(32) == 0) {
|
if (random.nextInt(32) == 0) {
|
||||||
world.addParticle(EndParticles.BLACK_SPORE, (double) pos.getX() + random.nextDouble(), (double) pos.getY() + 1.1D, (double) pos.getZ() + random.nextDouble(), 0.0D, 0.0D, 0.0D);
|
world.addParticle(EndParticles.BLACK_SPORE, (double) pos.getX() + random.nextDouble(),
|
||||||
|
(double) pos.getY() + 1.1D, (double) pos.getZ() + random.nextDouble(), 0.0D, 0.0D, 0.0D);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,31 +4,31 @@ import java.util.Random;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.block.Material;
|
import net.minecraft.world.level.material.Material;
|
||||||
import net.minecraft.entity.ItemEntity;
|
import net.minecraft.world.entity.ItemEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.world.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemPlacementContext;
|
import net.minecraft.world.item.ItemPlacementContext;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.server.world.ServerWorld;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.sound.BlockSoundGroup;
|
import net.minecraft.world.level.block.SoundType;
|
||||||
import net.minecraft.sound.SoundCategory;
|
import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.sound.SoundEvents;
|
import net.minecraft.sounds.SoundEvents;
|
||||||
import net.minecraft.state.StateManager;
|
import net.minecraft.world.level.block.state.StateDefinition;
|
||||||
import net.minecraft.state.property.DirectionProperty;
|
import net.minecraft.state.property.DirectionProperty;
|
||||||
import net.minecraft.state.property.IntProperty;
|
import net.minecraft.world.level.block.state.properties.IntegerProperty;
|
||||||
import net.minecraft.state.property.Properties;
|
import net.minecraft.state.property.Properties;
|
||||||
import net.minecraft.util.ActionResult;
|
import net.minecraft.util.ActionResult;
|
||||||
import net.minecraft.util.BlockMirror;
|
import net.minecraft.util.BlockMirror;
|
||||||
import net.minecraft.util.BlockRotation;
|
import net.minecraft.world.level.block.Rotation;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.hit.BlockHitResult;
|
import net.minecraft.util.hit.BlockHitResult;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.math.Box;
|
import net.minecraft.util.math.Box;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.level.Level;
|
||||||
import ru.betterend.blocks.basis.BlockBase;
|
import ru.betterend.blocks.basis.BlockBase;
|
||||||
import ru.betterend.entity.SilkMothEntity;
|
import ru.betterend.entity.SilkMothEntity;
|
||||||
import ru.betterend.registry.EndEntities;
|
import ru.betterend.registry.EndEntities;
|
||||||
|
@ -38,26 +38,27 @@ import ru.betterend.util.MHelper;
|
||||||
|
|
||||||
public class SilkMothHiveBlock extends BlockBase {
|
public class SilkMothHiveBlock extends BlockBase {
|
||||||
public static final DirectionProperty FACING = Properties.HORIZONTAL_FACING;
|
public static final DirectionProperty FACING = Properties.HORIZONTAL_FACING;
|
||||||
public static final IntProperty FULLNESS = BlockProperties.FULLNESS;
|
public static final IntegerProperty FULLNESS = BlockProperties.FULLNESS;
|
||||||
|
|
||||||
public SilkMothHiveBlock() {
|
public SilkMothHiveBlock() {
|
||||||
super(FabricBlockSettings.of(Material.WOOD).hardness(0.5F).resistance(0.1F).sounds(BlockSoundGroup.WOOL).nonOpaque().ticksRandomly().breakByHand(true));
|
super(FabricBlockSettings.of(Material.WOOD).hardness(0.5F).resistance(0.1F).sounds(SoundType.WOOL).nonOpaque()
|
||||||
|
.ticksRandomly().breakByHand(true));
|
||||||
this.setDefaultState(getDefaultState().with(FULLNESS, 0));
|
this.setDefaultState(getDefaultState().with(FULLNESS, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
|
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
|
||||||
stateManager.add(FACING, FULLNESS);
|
stateManager.add(FACING, FULLNESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getPlacementState(ItemPlacementContext ctx) {
|
public BlockState getPlacementState(ItemPlacementContext ctx) {
|
||||||
Direction dir = ctx.getPlayerFacing().getOpposite();
|
Direction dir = ctx.getPlayerFacing().getOpposite();
|
||||||
return this.getDefaultState().with(FACING, dir);
|
return this.defaultBlockState().with(FACING, dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState rotate(BlockState state, BlockRotation rotation) {
|
public BlockState rotate(BlockState state, Rotation rotation) {
|
||||||
return BlocksHelper.rotateHorizontal(state, rotation, FACING);
|
return BlocksHelper.rotateHorizontal(state, rotation, FACING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,13 +68,15 @@ public class SilkMothHiveBlock extends BlockBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
|
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
|
||||||
Direction dir = state.get(FACING);
|
Direction dir = state.getValue(FACING);
|
||||||
BlockPos spawn = pos.offset(dir);
|
BlockPos spawn = pos.relative(dir);
|
||||||
if (!world.getBlockState(spawn).isAir()) {
|
if (!world.getBlockState(spawn).isAir()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int count = world.getEntitiesByType(EndEntities.SILK_MOTH, new Box(pos).expand(16), (entity) -> { return true; }).size();
|
int count = world.getEntitiesByType(EndEntities.SILK_MOTH, new Box(pos).expand(16), (entity) -> {
|
||||||
|
return true;
|
||||||
|
}).size();
|
||||||
if (count > 6) {
|
if (count > 6) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -82,16 +85,17 @@ public class SilkMothHiveBlock extends BlockBase {
|
||||||
moth.setVelocity(new Vec3d(dir.getOffsetX() * 0.4, 0, dir.getOffsetZ() * 0.4));
|
moth.setVelocity(new Vec3d(dir.getOffsetX() * 0.4, 0, dir.getOffsetZ() * 0.4));
|
||||||
moth.setHive(world, pos);
|
moth.setHive(world, pos);
|
||||||
world.spawnEntity(moth);
|
world.spawnEntity(moth);
|
||||||
world.playSound(null, pos, SoundEvents.BLOCK_BEEHIVE_EXIT, SoundCategory.BLOCKS, 1, 1);
|
world.playLocalSound(null, pos, SoundEvents.BLOCK_BEEHIVE_EXIT, SoundSource.BLOCKS, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
|
public ActionResult onUse(BlockState state, Level world, BlockPos pos, PlayerEntity player, Hand hand,
|
||||||
|
BlockHitResult hit) {
|
||||||
if (hand == Hand.MAIN_HAND) {
|
if (hand == Hand.MAIN_HAND) {
|
||||||
ItemStack stack = player.getMainHandStack();
|
ItemStack stack = player.getMainHandStack();
|
||||||
if (stack.getItem().isIn(FabricToolTags.SHEARS) && state.get(FULLNESS) == 3) {
|
if (stack.getItem().isIn(FabricToolTags.SHEARS) && state.getValue(FULLNESS) == 3) {
|
||||||
BlocksHelper.setWithUpdate(world, pos, state.with(FULLNESS, 0));
|
BlocksHelper.setWithUpdate(world, pos, state.with(FULLNESS, 0));
|
||||||
Direction dir = state.get(FACING);
|
Direction dir = state.getValue(FACING);
|
||||||
double px = pos.getX() + dir.getOffsetX() + 0.5;
|
double px = pos.getX() + dir.getOffsetX() + 0.5;
|
||||||
double py = pos.getY() + dir.getOffsetY() + 0.5;
|
double py = pos.getY() + dir.getOffsetY() + 0.5;
|
||||||
double pz = pos.getZ() + dir.getOffsetZ() + 0.5;
|
double pz = pos.getZ() + dir.getOffsetZ() + 0.5;
|
||||||
|
|
|
@ -6,39 +6,39 @@ import java.util.Random;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.block.Material;
|
import net.minecraft.world.level.material.Material;
|
||||||
import net.minecraft.block.ShapeContext;
|
import net.minecraft.world.level.block.ShapeContext;
|
||||||
import net.minecraft.entity.ItemEntity;
|
import net.minecraft.world.entity.ItemEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.world.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemPlacementContext;
|
import net.minecraft.world.item.ItemPlacementContext;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.loot.context.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import net.minecraft.server.world.ServerWorld;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.sound.BlockSoundGroup;
|
import net.minecraft.world.level.block.SoundType;
|
||||||
import net.minecraft.sound.SoundCategory;
|
import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.sound.SoundEvents;
|
import net.minecraft.sounds.SoundEvents;
|
||||||
import net.minecraft.state.StateManager;
|
import net.minecraft.world.level.block.state.StateDefinition;
|
||||||
import net.minecraft.state.property.BooleanProperty;
|
import net.minecraft.state.property.BooleanProperty;
|
||||||
import net.minecraft.state.property.DirectionProperty;
|
import net.minecraft.state.property.DirectionProperty;
|
||||||
import net.minecraft.state.property.IntProperty;
|
import net.minecraft.world.level.block.state.properties.IntegerProperty;
|
||||||
import net.minecraft.state.property.Properties;
|
import net.minecraft.state.property.Properties;
|
||||||
import net.minecraft.tag.BlockTags;
|
import net.minecraft.tags.BlockTags;
|
||||||
import net.minecraft.util.ActionResult;
|
import net.minecraft.util.ActionResult;
|
||||||
import net.minecraft.util.BlockMirror;
|
import net.minecraft.util.BlockMirror;
|
||||||
import net.minecraft.util.BlockRotation;
|
import net.minecraft.world.level.block.Rotation;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.hit.BlockHitResult;
|
import net.minecraft.util.hit.BlockHitResult;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.math.Box;
|
import net.minecraft.util.math.Box;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.util.shape.VoxelShape;
|
import net.minecraft.util.shape.VoxelShape;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.WorldAccess;
|
import net.minecraft.world.level.LevelAccessor;
|
||||||
import ru.betterend.blocks.basis.BlockBase;
|
import ru.betterend.blocks.basis.BlockBase;
|
||||||
import ru.betterend.client.render.ERenderLayer;
|
import ru.betterend.client.render.ERenderLayer;
|
||||||
import ru.betterend.entity.SilkMothEntity;
|
import ru.betterend.entity.SilkMothEntity;
|
||||||
|
@ -51,23 +51,24 @@ import ru.betterend.util.MHelper;
|
||||||
public class SilkMothNestBlock extends BlockBase implements IRenderTypeable {
|
public class SilkMothNestBlock extends BlockBase implements IRenderTypeable {
|
||||||
public static final BooleanProperty ACTIVE = BlockProperties.ACTIVE;
|
public static final BooleanProperty ACTIVE = BlockProperties.ACTIVE;
|
||||||
public static final DirectionProperty FACING = Properties.HORIZONTAL_FACING;
|
public static final DirectionProperty FACING = Properties.HORIZONTAL_FACING;
|
||||||
public static final IntProperty FULLNESS = BlockProperties.FULLNESS;
|
public static final IntegerProperty FULLNESS = BlockProperties.FULLNESS;
|
||||||
private static final VoxelShape TOP = createCuboidShape(6, 0, 6, 10, 16, 10);
|
private static final VoxelShape TOP = createCuboidShape(6, 0, 6, 10, 16, 10);
|
||||||
private static final VoxelShape BOTTOM = createCuboidShape(0, 0, 0, 16, 16, 16);
|
private static final VoxelShape BOTTOM = createCuboidShape(0, 0, 0, 16, 16, 16);
|
||||||
|
|
||||||
public SilkMothNestBlock() {
|
public SilkMothNestBlock() {
|
||||||
super(FabricBlockSettings.of(Material.WOOL).hardness(0.5F).resistance(0.1F).sounds(BlockSoundGroup.WOOL).nonOpaque().ticksRandomly());
|
super(FabricBlockSettings.of(Material.WOOL).hardness(0.5F).resistance(0.1F).sounds(SoundType.WOOL).nonOpaque()
|
||||||
|
.ticksRandomly());
|
||||||
this.setDefaultState(getDefaultState().with(ACTIVE, true).with(FULLNESS, 0));
|
this.setDefaultState(getDefaultState().with(ACTIVE, true).with(FULLNESS, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
|
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
|
||||||
stateManager.add(ACTIVE, FACING, FULLNESS);
|
stateManager.add(ACTIVE, FACING, FULLNESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
|
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
|
||||||
return state.get(ACTIVE) ? BOTTOM : TOP;
|
return state.getValue(ACTIVE) ? BOTTOM : TOP;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -78,24 +79,25 @@ public class SilkMothNestBlock extends BlockBase implements IRenderTypeable {
|
||||||
@Override
|
@Override
|
||||||
public BlockState getPlacementState(ItemPlacementContext ctx) {
|
public BlockState getPlacementState(ItemPlacementContext ctx) {
|
||||||
Direction dir = ctx.getPlayerFacing().getOpposite();
|
Direction dir = ctx.getPlayerFacing().getOpposite();
|
||||||
return this.getDefaultState().with(FACING, dir);
|
return this.defaultBlockState().with(FACING, dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
|
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world,
|
||||||
if (!state.get(ACTIVE)) {
|
BlockPos pos, BlockPos neighborPos) {
|
||||||
if (sideCoversSmallSquare(world, pos.up(), Direction.DOWN) || world.getBlockState(pos.up()).isIn(BlockTags.LEAVES)) {
|
if (!state.getValue(ACTIVE)) {
|
||||||
|
if (sideCoversSmallSquare(world, pos.up(), Direction.DOWN)
|
||||||
|
|| world.getBlockState(pos.up()).isIn(BlockTags.LEAVES)) {
|
||||||
return state;
|
return state;
|
||||||
}
|
} else {
|
||||||
else {
|
return Blocks.AIR.defaultBlockState();
|
||||||
return Blocks.AIR.getDefaultState();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState rotate(BlockState state, BlockRotation rotation) {
|
public BlockState rotate(BlockState state, Rotation rotation) {
|
||||||
return BlocksHelper.rotateHorizontal(state, rotation, FACING);
|
return BlocksHelper.rotateHorizontal(state, rotation, FACING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,36 +107,38 @@ public class SilkMothNestBlock extends BlockBase implements IRenderTypeable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
return state.get(ACTIVE) ? Collections.singletonList(new ItemStack(this)) : Collections.emptyList();
|
return state.getValue(ACTIVE) ? Collections.singletonList(new ItemStack(this)) : Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBreak(World world, BlockPos pos, BlockState state, PlayerEntity player) {
|
public void onBreak(Level world, BlockPos pos, BlockState state, PlayerEntity player) {
|
||||||
if (!state.get(ACTIVE) && player.isCreative()) {
|
if (!state.getValue(ACTIVE) && player.isCreative()) {
|
||||||
BlocksHelper.setWithUpdate(world, pos.down(), Blocks.AIR);
|
BlocksHelper.setWithUpdate(world, pos.below(), Blocks.AIR);
|
||||||
}
|
}
|
||||||
BlockState up = world.getBlockState(pos.up());
|
BlockState up = world.getBlockState(pos.up());
|
||||||
if (up.isOf(this) && !up.get(ACTIVE)) {
|
if (up.is(this) && !up.get(ACTIVE)) {
|
||||||
BlocksHelper.setWithUpdate(world, pos.up(), Blocks.AIR);
|
BlocksHelper.setWithUpdate(world, pos.up(), Blocks.AIR);
|
||||||
}
|
}
|
||||||
super.onBreak(world, pos, state, player);
|
super.onBreak(world, pos, state, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
|
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
|
||||||
if (!state.get(ACTIVE)) {
|
if (!state.getValue(ACTIVE)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (random.nextBoolean()) {
|
if (random.nextBoolean()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Direction dir = state.get(FACING);
|
Direction dir = state.getValue(FACING);
|
||||||
BlockPos spawn = pos.offset(dir);
|
BlockPos spawn = pos.relative(dir);
|
||||||
if (!world.getBlockState(spawn).isAir()) {
|
if (!world.getBlockState(spawn).isAir()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int count = world.getEntitiesByType(EndEntities.SILK_MOTH, new Box(pos).expand(16), (entity) -> { return true; }).size();
|
int count = world.getEntitiesByType(EndEntities.SILK_MOTH, new Box(pos).expand(16), (entity) -> {
|
||||||
|
return true;
|
||||||
|
}).size();
|
||||||
if (count > 6) {
|
if (count > 6) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -143,16 +147,18 @@ public class SilkMothNestBlock extends BlockBase implements IRenderTypeable {
|
||||||
moth.setVelocity(new Vec3d(dir.getOffsetX() * 0.4, 0, dir.getOffsetZ() * 0.4));
|
moth.setVelocity(new Vec3d(dir.getOffsetX() * 0.4, 0, dir.getOffsetZ() * 0.4));
|
||||||
moth.setHive(world, pos);
|
moth.setHive(world, pos);
|
||||||
world.spawnEntity(moth);
|
world.spawnEntity(moth);
|
||||||
world.playSound(null, pos, SoundEvents.BLOCK_BEEHIVE_EXIT, SoundCategory.BLOCKS, 1, 1);
|
world.playLocalSound(null, pos, SoundEvents.BLOCK_BEEHIVE_EXIT, SoundSource.BLOCKS, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
|
public ActionResult onUse(BlockState state, Level world, BlockPos pos, PlayerEntity player, Hand hand,
|
||||||
|
BlockHitResult hit) {
|
||||||
if (hand == Hand.MAIN_HAND) {
|
if (hand == Hand.MAIN_HAND) {
|
||||||
ItemStack stack = player.getMainHandStack();
|
ItemStack stack = player.getMainHandStack();
|
||||||
if (stack.getItem().isIn(FabricToolTags.SHEARS) && state.get(ACTIVE) && state.get(FULLNESS) == 3) {
|
if (stack.getItem().isIn(FabricToolTags.SHEARS) && state.getValue(ACTIVE)
|
||||||
|
&& state.getValue(FULLNESS) == 3) {
|
||||||
BlocksHelper.setWithUpdate(world, pos, state.with(FULLNESS, 0));
|
BlocksHelper.setWithUpdate(world, pos, state.with(FULLNESS, 0));
|
||||||
Direction dir = state.get(FACING);
|
Direction dir = state.getValue(FACING);
|
||||||
double px = pos.getX() + dir.getOffsetX() + 0.5;
|
double px = pos.getX() + dir.getOffsetX() + 0.5;
|
||||||
double py = pos.getY() + dir.getOffsetY() + 0.5;
|
double py = pos.getY() + dir.getOffsetY() + 0.5;
|
||||||
double pz = pos.getZ() + dir.getOffsetZ() + 0.5;
|
double pz = pos.getZ() + dir.getOffsetZ() + 0.5;
|
||||||
|
|
|
@ -2,16 +2,16 @@ package ru.betterend.blocks;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.block.ShapeContext;
|
import net.minecraft.world.level.block.ShapeContext;
|
||||||
import net.minecraft.server.world.ServerWorld;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.util.shape.VoxelShape;
|
import net.minecraft.util.shape.VoxelShape;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.level.Level;
|
||||||
import ru.betterend.blocks.basis.EndPlantBlock;
|
import ru.betterend.blocks.basis.EndPlantBlock;
|
||||||
import ru.betterend.registry.EndBlocks;
|
import ru.betterend.registry.EndBlocks;
|
||||||
import ru.betterend.registry.EndFeatures;
|
import ru.betterend.registry.EndFeatures;
|
||||||
|
@ -22,11 +22,12 @@ public class SmallAmaranitaBlock extends EndPlantBlock {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isTerrain(BlockState state) {
|
protected boolean isTerrain(BlockState state) {
|
||||||
return state.isOf(EndBlocks.SANGNUM) || state.isOf(EndBlocks.MOSSY_OBSIDIAN) || state.isOf(EndBlocks.MOSSY_DRAGON_BONE);
|
return state.is(EndBlocks.SANGNUM) || state.is(EndBlocks.MOSSY_OBSIDIAN)
|
||||||
|
|| state.is(EndBlocks.MOSSY_DRAGON_BONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) {
|
public void grow(ServerLevel world, Random random, BlockPos pos, BlockState state) {
|
||||||
BlockPos bigPos = growBig(world, pos);
|
BlockPos bigPos = growBig(world, pos);
|
||||||
if (bigPos != null) {
|
if (bigPos != null) {
|
||||||
if (EndFeatures.GIGANTIC_AMARANITA.getFeature().generate(world, null, random, bigPos, null)) {
|
if (EndFeatures.GIGANTIC_AMARANITA.getFeature().generate(world, null, random, bigPos, null)) {
|
||||||
|
@ -46,10 +47,10 @@ public class SmallAmaranitaBlock extends EndPlantBlock {
|
||||||
return SHAPE.offset(vec3d.x, vec3d.y, vec3d.z);
|
return SHAPE.offset(vec3d.x, vec3d.y, vec3d.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
private BlockPos growBig(ServerWorld world, BlockPos pos) {
|
private BlockPos growBig(ServerLevel world, BlockPos pos) {
|
||||||
for (int x = -1; x < 2; x++) {
|
for (int x = -1; x < 2; x++) {
|
||||||
for (int z = -1; z < 2; z++) {
|
for (int z = -1; z < 2; z++) {
|
||||||
BlockPos p = pos.add(x, 0, z);
|
BlockPos p = pos.offset(x, 0, z);
|
||||||
if (checkFrame(world, p)) {
|
if (checkFrame(world, p)) {
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
@ -58,21 +59,19 @@ public class SmallAmaranitaBlock extends EndPlantBlock {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkFrame(ServerWorld world, BlockPos pos) {
|
private boolean checkFrame(ServerLevel world, BlockPos pos) {
|
||||||
return world.getBlockState(pos).isOf(this) &&
|
return world.getBlockState(pos).is(this) && world.getBlockState(pos.south()).is(this)
|
||||||
world.getBlockState(pos.south()).isOf(this) &&
|
&& world.getBlockState(pos.east()).is(this) && world.getBlockState(pos.south().east()).is(this);
|
||||||
world.getBlockState(pos.east()).isOf(this) &&
|
|
||||||
world.getBlockState(pos.south().east()).isOf(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void replaceMushroom(ServerWorld world, BlockPos pos) {
|
private void replaceMushroom(ServerLevel world, BlockPos pos) {
|
||||||
if (world.getBlockState(pos).isOf(this)) {
|
if (world.getBlockState(pos).is(this)) {
|
||||||
BlocksHelper.setWithUpdate(world, pos, Blocks.AIR);
|
BlocksHelper.setWithUpdate(world, pos, Blocks.AIR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) {
|
public boolean canGrow(Level world, Random random, BlockPos pos, BlockState state) {
|
||||||
return random.nextInt(8) == 0;
|
return random.nextInt(8) == 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,25 +9,25 @@ import com.google.common.collect.Maps;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.block.Fertilizable;
|
import net.minecraft.world.level.block.Fertilizable;
|
||||||
import net.minecraft.block.Material;
|
import net.minecraft.world.level.material.Material;
|
||||||
import net.minecraft.block.ShapeContext;
|
import net.minecraft.world.level.block.ShapeContext;
|
||||||
import net.minecraft.enchantment.EnchantmentHelper;
|
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||||
import net.minecraft.enchantment.Enchantments;
|
import net.minecraft.world.item.enchantment.Enchantments;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.loot.context.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import net.minecraft.loot.context.LootContextParameters;
|
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||||
import net.minecraft.server.world.ServerWorld;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.sound.BlockSoundGroup;
|
import net.minecraft.world.level.block.SoundType;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.util.shape.VoxelShape;
|
import net.minecraft.util.shape.VoxelShape;
|
||||||
import net.minecraft.util.shape.VoxelShapes;
|
import net.minecraft.util.shape.VoxelShapes;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.WorldView;
|
import net.minecraft.world.WorldView;
|
||||||
import ru.betterend.blocks.basis.AttachedBlock;
|
import ru.betterend.blocks.basis.AttachedBlock;
|
||||||
import ru.betterend.client.render.ERenderLayer;
|
import ru.betterend.client.render.ERenderLayer;
|
||||||
|
@ -40,33 +40,30 @@ public class SmallJellyshroomBlock extends AttachedBlock implements IRenderTypea
|
||||||
private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class);
|
private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class);
|
||||||
|
|
||||||
public SmallJellyshroomBlock() {
|
public SmallJellyshroomBlock() {
|
||||||
super(FabricBlockSettings.of(Material.PLANT)
|
super(FabricBlockSettings.of(Material.PLANT).breakByTool(FabricToolTags.SHEARS).sounds(SoundType.NETHER_WART)
|
||||||
.breakByTool(FabricToolTags.SHEARS)
|
.breakByHand(true).noCollision());
|
||||||
.sounds(BlockSoundGroup.NETHER_WART)
|
|
||||||
.breakByHand(true)
|
|
||||||
.noCollision());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
|
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
|
||||||
return BOUNDING_SHAPES.get(state.get(FACING));
|
return BOUNDING_SHAPES.get(state.getValue(FACING));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
ItemStack tool = builder.get(LootContextParameters.TOOL);
|
ItemStack tool = builder.getParameter(LootContextParams.TOOL);
|
||||||
if (tool != null && tool.getItem().isIn(FabricToolTags.SHEARS) || EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, tool) > 0) {
|
if (tool != null && tool.getItem().isIn(FabricToolTags.SHEARS)
|
||||||
|
|| EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) {
|
||||||
return Lists.newArrayList(new ItemStack(this));
|
return Lists.newArrayList(new ItemStack(this));
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return Lists.newArrayList();
|
return Lists.newArrayList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
||||||
Direction direction = state.get(FACING);
|
Direction direction = state.getValue(FACING);
|
||||||
BlockPos blockPos = pos.offset(direction.getOpposite());
|
BlockPos blockPos = pos.relative(direction.getOpposite());
|
||||||
BlockState support = world.getBlockState(blockPos);
|
BlockState support = world.getBlockState(blockPos);
|
||||||
return sideCoversSmallSquare(world, blockPos, direction) && support.isOpaque() && support.getLuminance() == 0;
|
return sideCoversSmallSquare(world, blockPos, direction) && support.isOpaque() && support.getLuminance() == 0;
|
||||||
}
|
}
|
||||||
|
@ -87,16 +84,16 @@ public class SmallJellyshroomBlock extends AttachedBlock implements IRenderTypea
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isFertilizable(BlockView world, BlockPos pos, BlockState state, boolean isClient) {
|
public boolean isFertilizable(BlockView world, BlockPos pos, BlockState state, boolean isClient) {
|
||||||
return state.get(FACING) == Direction.UP && world.getBlockState(pos.down()).isIn(EndTags.END_GROUND);
|
return state.getValue(FACING) == Direction.UP && world.getBlockState(pos.below()).isIn(EndTags.END_GROUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) {
|
public boolean canGrow(Level world, Random random, BlockPos pos, BlockState state) {
|
||||||
return random.nextInt(16) == 0;
|
return random.nextInt(16) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) {
|
public void grow(ServerLevel world, Random random, BlockPos pos, BlockState state) {
|
||||||
BlocksHelper.setWithUpdate(world, pos, Blocks.AIR);
|
BlocksHelper.setWithUpdate(world, pos, Blocks.AIR);
|
||||||
EndFeatures.JELLYSHROOM.getFeature().generate(world, null, random, pos, null);
|
EndFeatures.JELLYSHROOM.getFeature().generate(world, null, random, pos, null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,18 +2,13 @@ package ru.betterend.blocks;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||||
import net.minecraft.block.Material;
|
import net.minecraft.world.level.material.Material;
|
||||||
import net.minecraft.sound.BlockSoundGroup;
|
import net.minecraft.world.level.block.SoundType;
|
||||||
import ru.betterend.blocks.basis.EndPillarBlock;
|
import ru.betterend.blocks.basis.EndPillarBlock;
|
||||||
|
|
||||||
public class SmaragdantCrystalBlock extends EndPillarBlock {
|
public class SmaragdantCrystalBlock extends EndPillarBlock {
|
||||||
public SmaragdantCrystalBlock() {
|
public SmaragdantCrystalBlock() {
|
||||||
super(FabricBlockSettings.of(Material.GLASS)
|
super(FabricBlockSettings.of(Material.GLASS).breakByTool(FabricToolTags.PICKAXES).sounds(SoundType.GLASS)
|
||||||
.breakByTool(FabricToolTags.PICKAXES)
|
.luminance(15).hardness(1F).resistance(1F).nonOpaque());
|
||||||
.sounds(BlockSoundGroup.GLASS)
|
|
||||||
.luminance(15)
|
|
||||||
.hardness(1F)
|
|
||||||
.resistance(1F)
|
|
||||||
.nonOpaque());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,49 +6,46 @@ import com.google.common.collect.Maps;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.block.FluidFillable;
|
import net.minecraft.world.level.block.FluidFillable;
|
||||||
import net.minecraft.block.Material;
|
import net.minecraft.world.level.material.Material;
|
||||||
import net.minecraft.block.MaterialColor;
|
import net.minecraft.world.level.material.MaterialColor;
|
||||||
import net.minecraft.block.ShapeContext;
|
import net.minecraft.world.level.block.ShapeContext;
|
||||||
import net.minecraft.block.Waterloggable;
|
import net.minecraft.world.level.block.Waterloggable;
|
||||||
import net.minecraft.fluid.Fluid;
|
import net.minecraft.fluid.Fluid;
|
||||||
import net.minecraft.fluid.FluidState;
|
import net.minecraft.fluid.FluidState;
|
||||||
import net.minecraft.fluid.Fluids;
|
import net.minecraft.fluid.Fluids;
|
||||||
import net.minecraft.item.ItemPlacementContext;
|
import net.minecraft.world.item.ItemPlacementContext;
|
||||||
import net.minecraft.sound.BlockSoundGroup;
|
import net.minecraft.world.level.block.SoundType;
|
||||||
import net.minecraft.state.StateManager;
|
import net.minecraft.world.level.block.state.StateDefinition;
|
||||||
import net.minecraft.state.property.BooleanProperty;
|
import net.minecraft.state.property.BooleanProperty;
|
||||||
import net.minecraft.state.property.Properties;
|
import net.minecraft.state.property.Properties;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.util.shape.VoxelShape;
|
import net.minecraft.util.shape.VoxelShape;
|
||||||
import net.minecraft.util.shape.VoxelShapes;
|
import net.minecraft.util.shape.VoxelShapes;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import net.minecraft.world.WorldAccess;
|
import net.minecraft.world.level.LevelAccessor;
|
||||||
import net.minecraft.world.WorldView;
|
import net.minecraft.world.WorldView;
|
||||||
import ru.betterend.blocks.basis.AttachedBlock;
|
import ru.betterend.blocks.basis.AttachedBlock;
|
||||||
import ru.betterend.client.render.ERenderLayer;
|
import ru.betterend.client.render.ERenderLayer;
|
||||||
import ru.betterend.interfaces.IRenderTypeable;
|
import ru.betterend.interfaces.IRenderTypeable;
|
||||||
|
|
||||||
public class SmaragdantCrystalShardBlock extends AttachedBlock implements IRenderTypeable, Waterloggable, FluidFillable {
|
public class SmaragdantCrystalShardBlock extends AttachedBlock
|
||||||
|
implements IRenderTypeable, Waterloggable, FluidFillable {
|
||||||
private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class);
|
private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class);
|
||||||
public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED;
|
public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED;
|
||||||
|
|
||||||
public SmaragdantCrystalShardBlock() {
|
public SmaragdantCrystalShardBlock() {
|
||||||
super(FabricBlockSettings.of(Material.STONE)
|
super(FabricBlockSettings.of(Material.STONE).materialColor(MaterialColor.COLOR_GREEN)
|
||||||
.materialColor(MaterialColor.GREEN)
|
.breakByTool(FabricToolTags.PICKAXES).sounds(SoundType.GLASS).luminance(15).requiresTool()
|
||||||
.breakByTool(FabricToolTags.PICKAXES)
|
|
||||||
.sounds(BlockSoundGroup.GLASS)
|
|
||||||
.luminance(15)
|
|
||||||
.requiresTool()
|
|
||||||
.noCollision());
|
.noCollision());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
|
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
|
||||||
super.appendProperties(stateManager);
|
super.createBlockStateDefinition(stateManager);
|
||||||
stateManager.add(WATERLOGGED);
|
stateManager.add(WATERLOGGED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,19 +56,19 @@ public class SmaragdantCrystalShardBlock extends AttachedBlock implements IRende
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canFillWithFluid(BlockView world, BlockPos pos, BlockState state, Fluid fluid) {
|
public boolean canFillWithFluid(BlockView world, BlockPos pos, BlockState state, Fluid fluid) {
|
||||||
return !state.get(WATERLOGGED);
|
return !state.getValue(WATERLOGGED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean tryFillWithFluid(WorldAccess world, BlockPos pos, BlockState state, FluidState fluidState) {
|
public boolean tryFillWithFluid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluidState) {
|
||||||
return !state.get(WATERLOGGED);
|
return !state.getValue(WATERLOGGED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getPlacementState(ItemPlacementContext ctx) {
|
public BlockState getPlacementState(ItemPlacementContext ctx) {
|
||||||
BlockState state = super.getPlacementState(ctx);
|
BlockState state = super.getPlacementState(ctx);
|
||||||
if (state != null) {
|
if (state != null) {
|
||||||
WorldView worldView = ctx.getWorld();
|
WorldView worldView = ctx.getLevel();
|
||||||
BlockPos blockPos = ctx.getBlockPos();
|
BlockPos blockPos = ctx.getBlockPos();
|
||||||
boolean water = worldView.getFluidState(blockPos).getFluid() == Fluids.WATER;
|
boolean water = worldView.getFluidState(blockPos).getFluid() == Fluids.WATER;
|
||||||
return state.with(WATERLOGGED, water);
|
return state.with(WATERLOGGED, water);
|
||||||
|
@ -81,18 +78,18 @@ public class SmaragdantCrystalShardBlock extends AttachedBlock implements IRende
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FluidState getFluidState(BlockState state) {
|
public FluidState getFluidState(BlockState state) {
|
||||||
return state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : Fluids.EMPTY.getDefaultState();
|
return state.getValue(WATERLOGGED) ? Fluids.WATER.getStill(false) : Fluids.EMPTY.defaultBlockState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
|
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
|
||||||
return BOUNDING_SHAPES.get(state.get(FACING));
|
return BOUNDING_SHAPES.get(state.getValue(FACING));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
||||||
Direction direction = (Direction) state.get(FACING);
|
Direction direction = (Direction) state.getValue(FACING);
|
||||||
BlockPos blockPos = pos.offset(direction.getOpposite());
|
BlockPos blockPos = pos.relative(direction.getOpposite());
|
||||||
return world.getBlockState(blockPos).isSideSolidFullSquare(world, blockPos, direction);
|
return world.getBlockState(blockPos).isSideSolidFullSquare(world, blockPos, direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,30 +9,30 @@ import com.google.common.collect.Maps;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.block.FluidFillable;
|
import net.minecraft.world.level.block.FluidFillable;
|
||||||
import net.minecraft.block.Material;
|
import net.minecraft.world.level.material.Material;
|
||||||
import net.minecraft.block.MaterialColor;
|
import net.minecraft.world.level.material.MaterialColor;
|
||||||
import net.minecraft.block.ShapeContext;
|
import net.minecraft.world.level.block.ShapeContext;
|
||||||
import net.minecraft.block.Waterloggable;
|
import net.minecraft.world.level.block.Waterloggable;
|
||||||
import net.minecraft.fluid.Fluid;
|
import net.minecraft.fluid.Fluid;
|
||||||
import net.minecraft.fluid.FluidState;
|
import net.minecraft.fluid.FluidState;
|
||||||
import net.minecraft.fluid.Fluids;
|
import net.minecraft.fluid.Fluids;
|
||||||
import net.minecraft.item.ItemPlacementContext;
|
import net.minecraft.world.item.ItemPlacementContext;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.loot.context.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import net.minecraft.sound.BlockSoundGroup;
|
import net.minecraft.world.level.block.SoundType;
|
||||||
import net.minecraft.state.StateManager;
|
import net.minecraft.world.level.block.state.StateDefinition;
|
||||||
import net.minecraft.state.property.BooleanProperty;
|
import net.minecraft.state.property.BooleanProperty;
|
||||||
import net.minecraft.state.property.IntProperty;
|
import net.minecraft.world.level.block.state.properties.IntegerProperty;
|
||||||
import net.minecraft.state.property.Properties;
|
import net.minecraft.state.property.Properties;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.util.shape.VoxelShape;
|
import net.minecraft.util.shape.VoxelShape;
|
||||||
import net.minecraft.util.shape.VoxelShapes;
|
import net.minecraft.util.shape.VoxelShapes;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import net.minecraft.world.WorldAccess;
|
import net.minecraft.world.level.LevelAccessor;
|
||||||
import net.minecraft.world.WorldView;
|
import net.minecraft.world.WorldView;
|
||||||
import ru.betterend.blocks.basis.AttachedBlock;
|
import ru.betterend.blocks.basis.AttachedBlock;
|
||||||
import ru.betterend.client.render.ERenderLayer;
|
import ru.betterend.client.render.ERenderLayer;
|
||||||
|
@ -43,21 +43,17 @@ import ru.betterend.util.MHelper;
|
||||||
|
|
||||||
public class SulphurCrystalBlock extends AttachedBlock implements IRenderTypeable, Waterloggable, FluidFillable {
|
public class SulphurCrystalBlock extends AttachedBlock implements IRenderTypeable, Waterloggable, FluidFillable {
|
||||||
private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class);
|
private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class);
|
||||||
public static final IntProperty AGE = IntProperty.of("age", 0, 2);
|
public static final IntegerProperty AGE = IntegerProperty.of("age", 0, 2);
|
||||||
public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED;
|
public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED;
|
||||||
|
|
||||||
public SulphurCrystalBlock() {
|
public SulphurCrystalBlock() {
|
||||||
super(FabricBlockSettings.of(Material.STONE)
|
super(FabricBlockSettings.of(Material.STONE).materialColor(MaterialColor.COLOR_YELLOW)
|
||||||
.materialColor(MaterialColor.YELLOW)
|
.breakByTool(FabricToolTags.PICKAXES).sounds(SoundType.GLASS).requiresTool().noCollision());
|
||||||
.breakByTool(FabricToolTags.PICKAXES)
|
|
||||||
.sounds(BlockSoundGroup.GLASS)
|
|
||||||
.requiresTool()
|
|
||||||
.noCollision());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
|
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
|
||||||
super.appendProperties(stateManager);
|
super.createBlockStateDefinition(stateManager);
|
||||||
stateManager.add(AGE, WATERLOGGED);
|
stateManager.add(AGE, WATERLOGGED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,25 +63,27 @@ public class SulphurCrystalBlock extends AttachedBlock implements IRenderTypeabl
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
return state.get(AGE) < 2 ? Collections.emptyList() : Lists.newArrayList(new ItemStack(EndItems.CRYSTALLINE_SULPHUR, MHelper.randRange(1, 3, MHelper.RANDOM)));
|
return state.getValue(AGE) < 2 ? Collections.emptyList()
|
||||||
|
: Lists.newArrayList(
|
||||||
|
new ItemStack(EndItems.CRYSTALLINE_SULPHUR, MHelper.randRange(1, 3, MHelper.RANDOM)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canFillWithFluid(BlockView world, BlockPos pos, BlockState state, Fluid fluid) {
|
public boolean canFillWithFluid(BlockView world, BlockPos pos, BlockState state, Fluid fluid) {
|
||||||
return !state.get(WATERLOGGED);
|
return !state.getValue(WATERLOGGED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean tryFillWithFluid(WorldAccess world, BlockPos pos, BlockState state, FluidState fluidState) {
|
public boolean tryFillWithFluid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluidState) {
|
||||||
return !state.get(WATERLOGGED);
|
return !state.getValue(WATERLOGGED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getPlacementState(ItemPlacementContext ctx) {
|
public BlockState getPlacementState(ItemPlacementContext ctx) {
|
||||||
BlockState state = super.getPlacementState(ctx);
|
BlockState state = super.getPlacementState(ctx);
|
||||||
if (state != null) {
|
if (state != null) {
|
||||||
WorldView worldView = ctx.getWorld();
|
WorldView worldView = ctx.getLevel();
|
||||||
BlockPos blockPos = ctx.getBlockPos();
|
BlockPos blockPos = ctx.getBlockPos();
|
||||||
boolean water = worldView.getFluidState(blockPos).getFluid() == Fluids.WATER;
|
boolean water = worldView.getFluidState(blockPos).getFluid() == Fluids.WATER;
|
||||||
return state.with(WATERLOGGED, water);
|
return state.with(WATERLOGGED, water);
|
||||||
|
@ -95,19 +93,19 @@ public class SulphurCrystalBlock extends AttachedBlock implements IRenderTypeabl
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FluidState getFluidState(BlockState state) {
|
public FluidState getFluidState(BlockState state) {
|
||||||
return state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : Fluids.EMPTY.getDefaultState();
|
return state.getValue(WATERLOGGED) ? Fluids.WATER.getStill(false) : Fluids.EMPTY.defaultBlockState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
|
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
|
||||||
return BOUNDING_SHAPES.get(state.get(FACING));
|
return BOUNDING_SHAPES.get(state.getValue(FACING));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
||||||
Direction direction = (Direction) state.get(FACING);
|
Direction direction = (Direction) state.getValue(FACING);
|
||||||
BlockPos blockPos = pos.offset(direction.getOpposite());
|
BlockPos blockPos = pos.relative(direction.getOpposite());
|
||||||
return world.getBlockState(blockPos).isOf(EndBlocks.BRIMSTONE);
|
return world.getBlockState(blockPos).is(EndBlocks.BRIMSTONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
|
|
@ -4,14 +4,14 @@ import java.util.Random;
|
||||||
|
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.client.color.block.BlockColorProvider;
|
import net.minecraft.client.color.block.BlockColor;
|
||||||
import net.minecraft.client.color.item.ItemColorProvider;
|
import net.minecraft.client.color.item.ItemColor;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.util.math.Vec3i;
|
import net.minecraft.core.Vec3i;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.level.Level;
|
||||||
import ru.betterend.blocks.basis.VineBlock;
|
import ru.betterend.blocks.basis.VineBlock;
|
||||||
import ru.betterend.interfaces.IColorProvider;
|
import ru.betterend.interfaces.IColorProvider;
|
||||||
import ru.betterend.registry.EndParticles;
|
import ru.betterend.registry.EndParticles;
|
||||||
|
@ -25,7 +25,7 @@ public class TenaneaFlowersBlock extends VineBlock implements IColorProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockColorProvider getProvider() {
|
public BlockColor getBlockProvider() {
|
||||||
return (state, world, pos, tintIndex) -> {
|
return (state, world, pos, tintIndex) -> {
|
||||||
long i = (MHelper.getRandom(pos.getX(), pos.getZ()) & 63) + pos.getY();
|
long i = (MHelper.getRandom(pos.getX(), pos.getZ()) & 63) + pos.getY();
|
||||||
double delta = i * 0.1;
|
double delta = i * 0.1;
|
||||||
|
@ -37,9 +37,9 @@ public class TenaneaFlowersBlock extends VineBlock implements IColorProvider {
|
||||||
Vec3i color1 = COLORS[index];
|
Vec3i color1 = COLORS[index];
|
||||||
Vec3i color2 = COLORS[index2];
|
Vec3i color2 = COLORS[index2];
|
||||||
|
|
||||||
int r = MHelper.floor(MathHelper.lerp(delta, color1.getX(), color2.getX()));
|
int r = MHelper.floor(Mth.lerp(delta, color1.getX(), color2.getX()));
|
||||||
int g = MHelper.floor(MathHelper.lerp(delta, color1.getY(), color2.getY()));
|
int g = MHelper.floor(Mth.lerp(delta, color1.getY(), color2.getY()));
|
||||||
int b = MHelper.floor(MathHelper.lerp(delta, color1.getZ(), color2.getZ()));
|
int b = MHelper.floor(Mth.lerp(delta, color1.getZ(), color2.getZ()));
|
||||||
float[] hsb = MHelper.fromRGBtoHSB(r, g, b);
|
float[] hsb = MHelper.fromRGBtoHSB(r, g, b);
|
||||||
|
|
||||||
return MHelper.fromHSBtoRGB(hsb[0], MHelper.max(0.5F, hsb[1]), hsb[2]);
|
return MHelper.fromHSBtoRGB(hsb[0], MHelper.max(0.5F, hsb[1]), hsb[2]);
|
||||||
|
@ -47,7 +47,7 @@ public class TenaneaFlowersBlock extends VineBlock implements IColorProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemColorProvider getItemProvider() {
|
public ItemColor getItemProvider() {
|
||||||
return (stack, tintIndex) -> {
|
return (stack, tintIndex) -> {
|
||||||
return MHelper.color(255, 255, 255);
|
return MHelper.color(255, 255, 255);
|
||||||
};
|
};
|
||||||
|
@ -59,8 +59,8 @@ public class TenaneaFlowersBlock extends VineBlock implements IColorProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) {
|
public void animateTick(BlockState state, Level world, BlockPos pos, Random random) {
|
||||||
super.randomDisplayTick(state, world, pos, random);
|
super.animateTick(state, world, pos, random);
|
||||||
if (random.nextInt(32) == 0) {
|
if (random.nextInt(32) == 0) {
|
||||||
double x = (double) pos.getX() + random.nextGaussian() + 0.5;
|
double x = (double) pos.getX() + random.nextGaussian() + 0.5;
|
||||||
double z = (double) pos.getZ() + random.nextGaussian() + 0.5;
|
double z = (double) pos.getZ() + random.nextGaussian() + 0.5;
|
||||||
|
@ -70,11 +70,7 @@ public class TenaneaFlowersBlock extends VineBlock implements IColorProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
COLORS = new Vec3i[] {
|
COLORS = new Vec3i[] { new Vec3i(250, 111, 222), new Vec3i(167, 89, 255), new Vec3i(120, 207, 239),
|
||||||
new Vec3i(250, 111, 222),
|
new Vec3i(255, 87, 182) };
|
||||||
new Vec3i(167, 89, 255),
|
|
||||||
new Vec3i(120, 207, 239),
|
|
||||||
new Vec3i(255, 87, 182)
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package ru.betterend.blocks;
|
package ru.betterend.blocks;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.WorldView;
|
import net.minecraft.world.WorldView;
|
||||||
import net.minecraft.world.gen.feature.Feature;
|
import net.minecraft.world.gen.feature.Feature;
|
||||||
import ru.betterend.blocks.basis.FeatureSaplingBlock;
|
import ru.betterend.blocks.basis.FeatureSaplingBlock;
|
||||||
|
@ -20,6 +20,6 @@ public class TenaneaSaplingBlock extends FeatureSaplingBlock {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
||||||
return world.getBlockState(pos.down()).isOf(EndBlocks.RUTISCUS);
|
return world.getBlockState(pos.below()).is(EndBlocks.RUTISCUS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,14 @@
|
||||||
package ru.betterend.blocks;
|
package ru.betterend.blocks;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.minecraft.block.Material;
|
import net.minecraft.world.level.material.Material;
|
||||||
import net.minecraft.block.MaterialColor;
|
import net.minecraft.world.level.material.MaterialColor;
|
||||||
import net.minecraft.sound.BlockSoundGroup;
|
import net.minecraft.world.level.block.SoundType;
|
||||||
import ru.betterend.blocks.basis.BlockBase;
|
import ru.betterend.blocks.basis.BlockBase;
|
||||||
|
|
||||||
public class TerminiteBlock extends BlockBase {
|
public class TerminiteBlock extends BlockBase {
|
||||||
public TerminiteBlock() {
|
public TerminiteBlock() {
|
||||||
super(FabricBlockSettings.of(Material.METAL, MaterialColor.field_25708)
|
super(FabricBlockSettings.of(Material.METAL, MaterialColor.field_25708).hardness(7F).resistance(9F)
|
||||||
.hardness(7F)
|
.requiresTool().sounds(SoundType.METAL));
|
||||||
.resistance(9F)
|
|
||||||
.requiresTool()
|
|
||||||
.sounds(BlockSoundGroup.METAL));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package ru.betterend.blocks;
|
package ru.betterend.blocks;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import ru.betterend.blocks.basis.EndPlantBlock;
|
import ru.betterend.blocks.basis.EndPlantBlock;
|
||||||
|
|
||||||
public class TerrainPlantBlock extends EndPlantBlock {
|
public class TerrainPlantBlock extends EndPlantBlock {
|
||||||
|
@ -14,8 +14,8 @@ public class TerrainPlantBlock extends EndPlantBlock {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isTerrain(BlockState state) {
|
protected boolean isTerrain(BlockState state) {
|
||||||
for (Block block: ground) {
|
for (Block block : ground) {
|
||||||
if (state.isOf(block)) {
|
if (state.is(block)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,11 +4,11 @@ import java.util.Random;
|
||||||
|
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.server.world.ServerWorld;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.level.Level;
|
||||||
import ru.betterend.blocks.basis.DoublePlantBlock;
|
import ru.betterend.blocks.basis.DoublePlantBlock;
|
||||||
import ru.betterend.blocks.basis.EndPlantBlock;
|
import ru.betterend.blocks.basis.EndPlantBlock;
|
||||||
import ru.betterend.registry.EndBlocks;
|
import ru.betterend.registry.EndBlocks;
|
||||||
|
@ -21,7 +21,7 @@ public class TwistedUmbrellaMossBlock extends EndPlantBlock {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isTerrain(BlockState state) {
|
protected boolean isTerrain(BlockState state) {
|
||||||
return state.isOf(EndBlocks.END_MOSS) || state.isOf(EndBlocks.END_MYCELIUM) || state.isOf(EndBlocks.JUNGLE_MOSS);
|
return state.is(EndBlocks.END_MOSS) || state.is(EndBlocks.END_MYCELIUM) || state.is(EndBlocks.JUNGLE_MOSS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
|
@ -35,14 +35,14 @@ public class TwistedUmbrellaMossBlock extends EndPlantBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) {
|
public boolean canGrow(Level world, Random random, BlockPos pos, BlockState state) {
|
||||||
return world.isAir(pos.up());
|
return world.isAir(pos.up());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) {
|
public void grow(ServerLevel world, Random random, BlockPos pos, BlockState state) {
|
||||||
int rot = world.random.nextInt(4);
|
int rot = world.random.nextInt(4);
|
||||||
BlockState bs = EndBlocks.TWISTED_UMBRELLA_MOSS_TALL.getDefaultState().with(DoublePlantBlock.ROTATION, rot);
|
BlockState bs = EndBlocks.TWISTED_UMBRELLA_MOSS_TALL.defaultBlockState().with(DoublePlantBlock.ROTATION, rot);
|
||||||
BlocksHelper.setWithoutUpdate(world, pos, bs);
|
BlocksHelper.setWithoutUpdate(world, pos, bs);
|
||||||
BlocksHelper.setWithoutUpdate(world, pos.up(), bs.with(DoublePlantBlock.TOP, true));
|
BlocksHelper.setWithoutUpdate(world, pos.up(), bs.with(DoublePlantBlock.TOP, true));
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,11 +2,11 @@ package ru.betterend.blocks;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.entity.ItemEntity;
|
import net.minecraft.world.entity.ItemEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.server.world.ServerWorld;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import ru.betterend.blocks.basis.DoublePlantBlock;
|
import ru.betterend.blocks.basis.DoublePlantBlock;
|
||||||
import ru.betterend.registry.EndBlocks;
|
import ru.betterend.registry.EndBlocks;
|
||||||
|
|
||||||
|
@ -16,13 +16,14 @@ public class TwistedUmbrellaMossTallBlock extends DoublePlantBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) {
|
public void grow(ServerLevel world, Random random, BlockPos pos, BlockState state) {
|
||||||
ItemEntity item = new ItemEntity(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, new ItemStack(EndBlocks.TWISTED_UMBRELLA_MOSS));
|
ItemEntity item = new ItemEntity(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5,
|
||||||
|
new ItemStack(EndBlocks.TWISTED_UMBRELLA_MOSS));
|
||||||
world.spawnEntity(item);
|
world.spawnEntity(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isTerrain(BlockState state) {
|
protected boolean isTerrain(BlockState state) {
|
||||||
return state.isOf(EndBlocks.END_MOSS) || state.isOf(EndBlocks.END_MYCELIUM) || state.isOf(EndBlocks.JUNGLE_MOSS);
|
return state.is(EndBlocks.END_MOSS) || state.is(EndBlocks.END_MYCELIUM) || state.is(EndBlocks.JUNGLE_MOSS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,11 +4,11 @@ import java.util.Random;
|
||||||
|
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.server.world.ServerWorld;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.level.Level;
|
||||||
import ru.betterend.blocks.basis.DoublePlantBlock;
|
import ru.betterend.blocks.basis.DoublePlantBlock;
|
||||||
import ru.betterend.blocks.basis.EndPlantBlock;
|
import ru.betterend.blocks.basis.EndPlantBlock;
|
||||||
import ru.betterend.registry.EndBlocks;
|
import ru.betterend.registry.EndBlocks;
|
||||||
|
@ -21,7 +21,7 @@ public class UmbrellaMossBlock extends EndPlantBlock {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isTerrain(BlockState state) {
|
protected boolean isTerrain(BlockState state) {
|
||||||
return state.isOf(EndBlocks.END_MOSS) || state.isOf(EndBlocks.END_MYCELIUM) || state.isOf(EndBlocks.JUNGLE_MOSS);
|
return state.is(EndBlocks.END_MOSS) || state.is(EndBlocks.END_MYCELIUM) || state.is(EndBlocks.JUNGLE_MOSS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
|
@ -35,14 +35,14 @@ public class UmbrellaMossBlock extends EndPlantBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) {
|
public boolean canGrow(Level world, Random random, BlockPos pos, BlockState state) {
|
||||||
return world.isAir(pos.up());
|
return world.isAir(pos.up());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) {
|
public void grow(ServerLevel world, Random random, BlockPos pos, BlockState state) {
|
||||||
int rot = world.random.nextInt(4);
|
int rot = world.random.nextInt(4);
|
||||||
BlockState bs = EndBlocks.UMBRELLA_MOSS_TALL.getDefaultState().with(DoublePlantBlock.ROTATION, rot);
|
BlockState bs = EndBlocks.UMBRELLA_MOSS_TALL.defaultBlockState().with(DoublePlantBlock.ROTATION, rot);
|
||||||
BlocksHelper.setWithoutUpdate(world, pos, bs);
|
BlocksHelper.setWithoutUpdate(world, pos, bs);
|
||||||
BlocksHelper.setWithoutUpdate(world, pos.up(), bs.with(DoublePlantBlock.TOP, true));
|
BlocksHelper.setWithoutUpdate(world, pos.up(), bs.with(DoublePlantBlock.TOP, true));
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue