Merge pull request #229 from paulevsGitch/1.17

Update to 1.17.1
This commit is contained in:
paulevsGitch 2021-07-09 11:56:41 +03:00 committed by GitHub
commit a2aacd79b7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
420 changed files with 8792 additions and 5910 deletions

2
.gitignore vendored
View file

@ -29,3 +29,5 @@ bin/
run/
output/
*.log
Convert.class
ModelPart.class

180
Convert.java Normal file
View file

@ -0,0 +1,180 @@
class ModelPart {
static java.util.ArrayList<ModelPart> parts = new java.util.ArrayList<>(20);
final String name;
ModelPart parent = null;
boolean mirror = false;
float x=0, y=0, z=0, rx=0, ry=0, rz=0;
int u=0, v=0;
float bx=0,by=0,bz=0,ba=0,bb=0,bc=0;
float scale = 1;
static int wd = 64;
static int hg = 32;
boolean hadBox = false;
ModelPart(Convert c, String name){
this(c, 0, 0, name);
}
ModelPart(Convert c, int u, int v, String name){
this.name = name;
this.u = u;
this.v = v;
parts.add(this);
}
ModelPart(int wd, int hg, int u, int v, String name){
this.name = name;
this.u = u;
this.v = v;
ModelPart.wd = wd;
ModelPart.hg = hg;
parts.add(this);
}
ModelPart setPos(float x, float y, float z){
this.x=x;
this.y=y;
this.z=z;
return this;
}
ModelPart setRotationAngle(float x, float y, float z){
this.rx=x;
this.ry=y;
this.rz=z;
return this;
}
ModelPart addChild(ModelPart p){
p.parent = this;
return this;
}
ModelPart texOffs(int u, int v){
this.u=u;
this.v=v;
return this;
}
ModelPart addBox(float x, float y, float z, float a, float b, float c){
return addBox(x, y, z, a, b, c, 1);
}
ModelPart addBox(float x, float y, float z, float a, float b, float c, float _d){
bx=x;
by=y;
bz=z;
ba=a;
bb=b;
bc=c;
scale = _d;
hadBox = true;
return this;
}
ModelPart addBox(float x, float y, float z, float a, float b, float c, float _d, boolean mirror){
this.mirror = mirror;
bx=x;
by=y;
bz=z;
ba=a;
bb=b;
bc=c;
hadBox = true;
return this;
}
public String toString(){
String s = "";
String pName = parent==null?"modelPartData":parent.name;
if (scale!=1){
s += "CubeDeformation deformation_"+name+" = new CubeDeformation("+scale+"f);\n";
}
s += "PartDefinition " + name + " = ";
s += pName+".addOrReplaceChild(\""+name+"\", CubeListBuilder.create()\n";
if (this.mirror) s+= ".mirror()\n";
s+= ".texOffs("+u+", "+v+")";
if (this.hadBox) {
s+= "\n";
if (scale!=1)
s+= ".addBox("+bx+"f, "+by+"f, "+bz+"f, "+ba+"f, "+bb+"f, "+bc+"f, deformation_"+name+"),\n";
else
s+= ".addBox("+bx+"f, "+by+"f, "+bz+"f, "+ba+"f, "+bb+"f, "+bc+"f),\n";
} else {
s+= ",\n";
}
if (x==0 && y==0 && z==0 && rx==0 && ry==0 && rz==0){
s+= "PartPose.ZERO";
} else if (rx==0 && ry==0 && rz==0){
s+= "PartPose.offset("+x+"f, "+y+"f, "+z+"f)";
} else {
s+= "PartPose.offsetAndRotation("+x+"f, "+y+"f, "+z+"f, \n"+rx+"f, "+ry+"f, "+rz+"f)";
}
s +=");";
return s;
}
public static void print(){
System.out.println("public static LayerDefinition getTexturedModelData() {");
System.out.println(" MeshDefinition modelData = new MeshDefinition();");
System.out.println(" PartDefinition modelPartData = modelData.getRoot();");
for(ModelPart p : parts){
System.out.println(p);
System.out.println();
}
System.out.println("return LayerDefinition.create(modelData, "+wd+", "+hg+");");
System.out.println("}");
System.out.println();
System.out.println();
for(ModelPart p : parts){
String pName = p.parent==null?"modelPart":p.parent.name;
System.out.println(p.name +" = "+pName+".getChild(\""+p.name+"\");");
}
}
}
public class Convert {
public static void main(String[] args){
new Convert().c();
ModelPart.print();
}
void setRotationAngle(ModelPart p, float x, float y, float z){
p.setRotationAngle(x, y, z);
}
public void c (){
float scale = 1;
ModelPart partC = new ModelPart(64, 64, 0, 19, "partC");
partC.addBox(1.0F, 0.0F, 1.0F, 14.0F, 9.0F, 14.0F, 0.0F);
ModelPart partA = new ModelPart(64, 64, 0, 0,"partA");
partA.addBox(1.0F, 0.0F, 0.0F, 14.0F, 5.0F, 14.0F, 0.0F);
partA.y = 9.0F;
partA.z = 1.0F;
ModelPart partB = new ModelPart(64, 64, 0, 0, "partB");
partB.addBox(7.0F, -1.0F, 15.0F, 2.0F, 4.0F, 1.0F, 0.0F);
partB.y = 8.0F;
ModelPart partRightC = new ModelPart(64, 64, 0, 19, "partRightC");
partRightC.addBox(1.0F, 0.0F, 1.0F, 15.0F, 9.0F, 14.0F, 0.0F);
ModelPart partRightA = new ModelPart(64, 64, 0, 0, "partRightA");
partRightA.addBox(1.0F, 0.0F, 0.0F, 15.0F, 5.0F, 14.0F, 0.0F);
partRightA.y = 9.0F;
partRightA.z = 1.0F;
ModelPart partRightB = new ModelPart(64, 64, 0, 0, "partRightB");
partRightB.addBox(15.0F, -1.0F, 15.0F, 1.0F, 4.0F, 1.0F, 0.0F);
partRightB.y = 8.0F;
ModelPart partLeftC = new ModelPart(64, 64, 0, 19, "partLeftC");
partLeftC.addBox(0.0F, 0.0F, 1.0F, 15.0F, 9.0F, 14.0F, 0.0F);
ModelPart partLeftA = new ModelPart(64, 64, 0, 0, "partLeftA");
partLeftA.addBox(0.0F, 0.0F, 0.0F, 15.0F, 5.0F, 14.0F, 0.0F);
partLeftA.y = 9.0F;
partLeftA.z = 1.0F;
ModelPart partLeftB = new ModelPart(64, 64, 0, 0, "partLeftB");
partLeftB.addBox(0.0F, -1.0F, 15.0F, 1.0F, 4.0F, 1.0F, 0.0F);
partLeftB.y = 8.0F;
}
}

View file

@ -1,6 +1,6 @@
[![](https://jitpack.io/v/paulevsGitch/BetterEnd.svg)](https://jitpack.io/#paulevsGitch/BetterEnd)
# Better End
Better End Mod for Fabric, MC 1.16.4
Better End Mod for Fabric, MC 1.17.1
Importing:
* Clone repo

View file

@ -7,20 +7,19 @@ buildscript {
plugins {
id 'idea'
id 'eclipse'
id 'fabric-loom' version '0.7-SNAPSHOT'
id 'fabric-loom' version '0.8-SNAPSHOT'
id 'maven-publish'
}
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_16
targetCompatibility = JavaVersion.VERSION_16
archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group
repositories {
maven { url "https://maven.dblsaiko.net/" }
maven { url "https://server.bbkr.space:8081/artifactory/libs-release/" }
maven { url "https://maven.dblsaiko.net/" }
maven { url "https://maven.fabricmc.net/" }
maven { url 'https://maven.blamejared.com' }
maven { url "https://maven.shedaniel.me/" }
@ -33,11 +32,11 @@ dependencies {
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
useApi "vazkii.patchouli:Patchouli:1.16.4-${project.patchouli_version}"
useApi "vazkii.patchouli:Patchouli:1.17-${project.patchouli_version}"
useApi "com.github.paulevsGitch:BCLib:${project.bclib_version}"
useOptional "me.shedaniel:RoughlyEnoughItems:${project.rei_version}"
useOptional "me.shedaniel:RoughlyEnoughItems-api:${project.rei_version}"
useOptional "me.shedaniel:RoughlyEnoughItems-fabric:${project.rei_version}"
useOptional "me.shedaniel:RoughlyEnoughItems-api-fabric:${project.rei_version}"
//useOptional "grondag:canvas-mc116:${project.canvas_version}"
}
@ -73,7 +72,7 @@ def useApi(String dep) {
processResources {
inputs.property "version", project.version
duplicatesStrategy = 'EXCLUDE'
duplicatesStrategy = 'WARN'
from(sourceSets.main.resources.srcDirs) {
include "fabric.mod.json"

View file

@ -3,19 +3,19 @@ org.gradle.jvmargs=-Xmx2G
# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.16.5
yarn_mappings=6
loader_version=0.11.3
minecraft_version= 1.17.1
yarn_mappings= 6
loader_version= 0.11.6
# Mod Properties
mod_version = 0.9.8.5-pre
mod_version = 0.10.1-pre
maven_group = ru.betterend
archives_base_name = better-end
# Dependencies
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
patchouli_version = 53-FABRIC
fabric_version = 0.36.0+1.16
bclib_version = 0.1.44
rei_version = 5.12.248
canvas_version = 1.0.+
patchouli_version = 55-FABRIC-SNAPSHOT
fabric_version = 0.36.1+1.17
bclib_version = 0.2.0
rei_version = 6.0.262-alpha
canvas_version = 1.0.+

View file

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View file

@ -33,7 +33,7 @@ import ru.betterend.world.surface.SurfaceBuilders;
public class BetterEnd implements ModInitializer {
public static final String MOD_ID = "betterend";
public static final Logger LOGGER = new Logger(MOD_ID);
@Override
public void onInitialize() {
WorldDataAPI.registerModCache(MOD_ID);
@ -62,11 +62,11 @@ public class BetterEnd implements ModInitializer {
Integrations.init();
Configs.saveConfigs();
}
public static ResourceLocation makeID(String path) {
return new ResourceLocation(MOD_ID, path);
}
public static String getStringId(String id) {
return String.format("%s:%s", MOD_ID, id);
}

View file

@ -2,29 +2,33 @@ package ru.betterend.api;
public interface BetterEndPlugin {
/**
* Alloying recipes registration.
* See AlloyingRecipe.Builder for details.
* Alloying recipes registration.
* See AlloyingRecipe.Builder for details.
*/
default void registerAlloyingRecipes() {}
default void registerAlloyingRecipes() {
}
/**
* Smithing recipes registration.
* See AnvilSmithingRecipe.Builder for details.
* Smithing recipes registration.
* See AnvilSmithingRecipe.Builder for details.
*/
default void registerSmithingRecipes() {}
default void registerSmithingRecipes() {
}
/**
* Additional biomes registration.
* See BiomeRegistry.registerBiome for details.
* Additional biomes registration.
* See BiomeRegistry.registerBiome for details.
*/
default void registerEndBiomes() {}
default void registerEndBiomes() {
}
/**
* Register other mod stuff, for example, EndHammers.
* Register other mod stuff, for example, EndHammers.
*/
default void registerOthers() {}
default void registerOthers() {
}
public static void register(BetterEndPlugin plugin) {
plugin.registerAlloyingRecipes();
plugin.registerSmithingRecipes();

View file

@ -1,9 +1,5 @@
package ru.betterend.blocks;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
@ -21,15 +17,19 @@ import ru.bclib.util.MHelper;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndParticles;
import java.util.Collections;
import java.util.List;
import java.util.Random;
public class AncientEmeraldIceBlock extends BaseBlock {
public AncientEmeraldIceBlock() {
super(FabricBlockSettings.copyOf(Blocks.BLUE_ICE).randomTicks());
}
@Override
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
Direction dir = BlocksHelper.randomDirection(random);
if (random.nextBoolean()) {
int x = MHelper.randRange(-2, 2, random);
int y = MHelper.randRange(-2, 2, random);
@ -40,7 +40,7 @@ public class AncientEmeraldIceBlock extends BaseBlock {
makeParticles(world, p, random);
}
}
pos = pos.relative(dir);
state = world.getBlockState(pos);
if (state.is(Blocks.WATER)) {
@ -52,11 +52,11 @@ public class AncientEmeraldIceBlock extends BaseBlock {
makeParticles(world, pos, random);
}
}
private void makeParticles(ServerLevel world, BlockPos pos, Random random) {
world.sendParticles(EndParticles.SNOWFLAKE, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 20, 0.5, 0.5, 0.5, 0);
}
@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
ItemStack tool = builder.getOptionalParameter(LootContextParams.TOOL);

View file

@ -1,9 +1,6 @@
package ru.betterend.blocks;
import java.util.List;
import com.google.common.collect.Lists;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.client.color.block.BlockColor;
@ -20,23 +17,25 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import ru.bclib.api.TagAPI;
import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.IColorProvider;
import ru.bclib.interfaces.IRenderTyped;
import ru.bclib.util.ColorUtil;
import ru.bclib.util.MHelper;
import ru.betterend.registry.EndItems;
import ru.betterend.registry.EndTags;
import java.util.List;
public class AuroraCrystalBlock extends AbstractGlassBlock implements IRenderTyped, IColorProvider {
public static final Vec3i[] COLORS;
private static final int MIN_DROP = 1;
private static final int MAX_DROP = 4;
public AuroraCrystalBlock() {
super(FabricBlockSettings.of(Material.GLASS)
.breakByTool(FabricToolTags.PICKAXES)
.breakByTool(EndTags.HAMMERS)
.breakByTool(TagAPI.HAMMERS)
.hardness(1F)
.resistance(1F)
.luminance(15)
@ -50,22 +49,23 @@ public class AuroraCrystalBlock extends AbstractGlassBlock implements IRenderTyp
return (state, world, pos, tintIndex) -> {
if (pos == null) {
pos = BlockPos.ZERO;
};
}
;
long i = (long) pos.getX() + (long) pos.getY() + (long) pos.getZ();
double delta = i * 0.1;
int index = MHelper.floor(delta);
int index2 = (index + 1) & 3;
delta -= index;
index &= 3;
Vec3i color1 = COLORS[index];
Vec3i color2 = COLORS[index2];
int r = MHelper.floor(Mth.lerp(delta, color1.getX(), color2.getX()));
int g = MHelper.floor(Mth.lerp(delta, color1.getY(), color2.getY()));
int b = MHelper.floor(Mth.lerp(delta, color1.getZ(), color2.getZ()));
return ColorUtil.color(r, g, b);
};
}
@ -81,7 +81,7 @@ public class AuroraCrystalBlock extends AbstractGlassBlock implements IRenderTyp
public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.TRANSLUCENT;
}
@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
ItemStack tool = builder.getParameter(LootContextParams.TOOL);
@ -99,20 +99,21 @@ public class AuroraCrystalBlock extends AbstractGlassBlock implements IRenderTyp
return Lists.newArrayList(new ItemStack(EndItems.CRYSTAL_SHARDS, max));
}
count = MHelper.randRange(min, max, MHelper.RANDOM);
} else {
}
else {
count = MHelper.randRange(MIN_DROP, MAX_DROP, MHelper.RANDOM);
}
return Lists.newArrayList(new ItemStack(EndItems.CRYSTAL_SHARDS, count));
}
return Lists.newArrayList();
}
static {
COLORS = new Vec3i[] {
new Vec3i(247, 77, 161),
new Vec3i(120, 184, 255),
new Vec3i(120, 255, 168),
new Vec3i(243, 58, 255)
COLORS = new Vec3i[]{
new Vec3i(247, 77, 161),
new Vec3i(120, 184, 255),
new Vec3i(120, 255, 168),
new Vec3i(243, 58, 255)
};
}
}

View file

@ -10,12 +10,12 @@ import ru.betterend.registry.EndBlocks;
public class BlueVineBlock extends UpDownPlantBlock {
public static final EnumProperty<BlockProperties.TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(SHAPE);
}
@Override
protected boolean isTerrain(BlockState state) {
return state.getBlock() == EndBlocks.END_MOSS || state.getBlock() == EndBlocks.END_MYCELIUM;

View file

@ -19,17 +19,17 @@ import ru.betterend.registry.EndBlocks;
public class BlueVineLanternBlock extends BaseBlock {
public static final BooleanProperty NATURAL = BlockProperties.NATURAL;
public BlueVineLanternBlock() {
super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).luminance(15).sound(SoundType.WART_BLOCK));
this.registerDefaultState(this.stateDefinition.any().setValue(NATURAL, false));
}
@Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
return !state.getValue(NATURAL) || world.getBlockState(pos.below()).getBlock() == EndBlocks.BLUE_VINE;
}
@Override
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
if (!canSurvive(state, world, pos)) {
@ -39,7 +39,7 @@ public class BlueVineLanternBlock extends BaseBlock {
return state;
}
}
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(NATURAL);

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
@ -14,6 +12,8 @@ import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
import ru.betterend.blocks.basis.FurBlock;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class BlueVineSeedBlock extends EndPlantWithAgeBlock {
@Override
public void growAdult(WorldGenLevel world, Random random, BlockPos pos) {
@ -29,10 +29,10 @@ public class BlueVineSeedBlock extends EndPlantWithAgeBlock {
BlocksHelper.setWithoutUpdate(world, pos.above(height), EndBlocks.BLUE_VINE.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE, BlockProperties.TripleShape.TOP));
placeLantern(world, pos.above(height + 1));
}
private void placeLantern(WorldGenLevel world, BlockPos pos) {
BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.BLUE_VINE_LANTERN.defaultBlockState().setValue(BlueVineLanternBlock.NATURAL, true));
for (Direction dir: BlocksHelper.HORIZONTAL) {
for (Direction dir : BlocksHelper.HORIZONTAL) {
BlockPos p = pos.relative(dir);
if (world.isEmptyBlock(p)) {
BlocksHelper.setWithoutUpdate(world, p, EndBlocks.BLUE_VINE_FUR.defaultBlockState().setValue(FurBlock.FACING, dir));
@ -42,12 +42,12 @@ public class BlueVineSeedBlock extends EndPlantWithAgeBlock {
BlocksHelper.setWithoutUpdate(world, pos.above(), EndBlocks.BLUE_VINE_FUR.defaultBlockState().setValue(FurBlock.FACING, Direction.UP));
}
}
@Override
protected boolean isTerrain(BlockState state) {
return state.is(EndBlocks.END_MOSS) || state.is(EndBlocks.END_MYCELIUM);
}
@Override
public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.NONE;

View file

@ -1,10 +1,6 @@
package ru.betterend.blocks;
import java.util.List;
import java.util.Random;
import com.google.common.collect.Lists;
import net.minecraft.core.BlockPos;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.BlockGetter;
@ -18,18 +14,21 @@ import net.minecraft.world.phys.shapes.VoxelShape;
import ru.betterend.blocks.basis.EndPlantBlock;
import ru.betterend.registry.EndBlocks;
import java.util.List;
import java.util.Random;
public class BoluxMushroomBlock extends EndPlantBlock {
private static final VoxelShape SHAPE = Block.box(1, 0, 1, 15, 9, 15);
public BoluxMushroomBlock() {
super(10);
}
@Override
protected boolean isTerrain(BlockState state) {
return state.is(EndBlocks.RUTISCUS);
}
@Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return SHAPE;
@ -39,7 +38,7 @@ public class BoluxMushroomBlock extends EndPlantBlock {
public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.NONE;
}
@Override
public boolean isValidBonemealTarget(BlockGetter world, BlockPos pos, BlockState state, boolean isClient) {
return false;
@ -49,7 +48,7 @@ public class BoluxMushroomBlock extends EndPlantBlock {
public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) {
return false;
}
@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return Lists.newArrayList(new ItemStack(this));

View file

@ -1,9 +1,5 @@
package ru.betterend.blocks;
import java.util.Random;
import org.jetbrains.annotations.Nullable;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.core.BlockPos;
@ -20,19 +16,22 @@ import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.level.material.MaterialColor;
import org.jetbrains.annotations.Nullable;
import ru.bclib.blocks.BaseBlock;
import ru.bclib.blocks.BlockProperties;
import ru.bclib.util.BlocksHelper;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class BrimstoneBlock extends BaseBlock {
public static final BooleanProperty ACTIVATED = BlockProperties.ACTIVE;
public BrimstoneBlock() {
super(FabricBlockSettings.copyOf(Blocks.END_STONE).materialColor(MaterialColor.COLOR_BROWN).randomTicks());
registerDefaultState(stateDefinition.any().setValue(ACTIVATED, false));
}
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(ACTIVATED);
@ -44,13 +43,13 @@ public class BrimstoneBlock extends BaseBlock {
updateChunks((ClientLevel) world, pos);
}
}
public void destroy(LevelAccessor world, BlockPos pos, BlockState state) {
if (world.isClientSide()) {
updateChunks((ClientLevel) world, pos);
}
}
private void updateChunks(ClientLevel world, BlockPos pos) {
int y = pos.getY() >> 4;
int x1 = (pos.getX() - 2) >> 4;
@ -63,11 +62,11 @@ public class BrimstoneBlock extends BaseBlock {
}
}
}
@Override
public void tick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
boolean deactivate = true;
for (Direction dir: BlocksHelper.DIRECTIONS) {
for (Direction dir : BlocksHelper.DIRECTIONS) {
if (world.getFluidState(pos.relative(dir)).getType().equals(Fluids.WATER)) {
deactivate = false;
break;

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks;
import java.util.Random;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
@ -19,10 +17,12 @@ import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import ru.betterend.blocks.basis.EndUnderwaterPlantBlock;
import java.util.Random;
public class BubbleCoralBlock extends EndUnderwaterPlantBlock {
private static final VoxelShape SHAPE = Block.box(0, 0, 0, 16, 14, 16);
public BubbleCoralBlock() {
super(FabricBlockSettings.of(Material.WATER_PLANT)
.breakByTool(FabricToolTags.SHEARS)
@ -30,7 +30,7 @@ public class BubbleCoralBlock extends EndUnderwaterPlantBlock {
.sound(SoundType.CORAL_BLOCK)
.noCollission());
}
@Override
public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.NONE;
@ -43,12 +43,12 @@ public class BubbleCoralBlock extends EndUnderwaterPlantBlock {
double z = pos.getZ() + random.nextDouble();
world.addParticle(ParticleTypes.BUBBLE, x, y, z, 0.0D, 0.0D, 0.0D);
}
@Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return SHAPE;
}
@Override
public boolean isValidBonemealTarget(BlockGetter world, BlockPos pos, BlockState state, boolean isClient) {
return false;

View file

@ -1,9 +1,6 @@
package ru.betterend.blocks;
import java.util.List;
import com.google.common.collect.Lists;
import net.minecraft.core.BlockPos;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.BlockGetter;
@ -16,11 +13,13 @@ import ru.bclib.util.MHelper;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndItems;
import java.util.List;
public class BulbVineBlock extends BaseVineBlock {
public BulbVineBlock() {
super(15, true);
}
@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
if (state.getValue(SHAPE) == TripleShape.BOTTOM) {
@ -33,12 +32,12 @@ public class BulbVineBlock extends BaseVineBlock {
return Lists.newArrayList();
}
}
@Override
public boolean isValidBonemealTarget(BlockGetter world, BlockPos pos, BlockState state, boolean isClient) {
return false;
}
@Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
boolean canPlace = super.canSurvive(state, world, pos);

View file

@ -1,12 +1,6 @@
package ru.betterend.blocks;
import java.util.Map;
import java.util.Optional;
import org.jetbrains.annotations.Nullable;
import com.google.common.collect.Maps;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
@ -22,6 +16,7 @@ import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.material.MaterialColor;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.jetbrains.annotations.Nullable;
import ru.bclib.client.models.BlockModelProvider;
import ru.bclib.client.models.ModelsHelper;
import ru.bclib.client.render.BCLRenderLayer;
@ -29,10 +24,13 @@ import ru.bclib.interfaces.IRenderTyped;
import ru.betterend.blocks.basis.EndLanternBlock;
import ru.betterend.client.models.Patterns;
import java.util.Map;
import java.util.Optional;
public class BulbVineLanternBlock extends EndLanternBlock implements IRenderTyped, BlockModelProvider {
private static final VoxelShape SHAPE_CEIL = Block.box(4, 4, 4, 12, 16, 12);
private static final VoxelShape SHAPE_FLOOR = Block.box(4, 0, 4, 12, 12, 12);
public BulbVineLanternBlock() {
this(FabricBlockSettings.of(Material.METAL)
.hardness(1)
@ -43,11 +41,11 @@ public class BulbVineLanternBlock extends EndLanternBlock implements IRenderType
.requiresCorrectToolForDrops()
.sound(SoundType.LANTERN));
}
public BulbVineLanternBlock(Properties settings) {
super(settings);
}
@Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return state.getValue(IS_FLOOR) ? SHAPE_FLOOR : SHAPE_CEIL;
@ -69,13 +67,13 @@ public class BulbVineLanternBlock extends EndLanternBlock implements IRenderType
Patterns.createJson(Patterns.BLOCK_BULB_LANTERN_CEIL, textures);
return ModelsHelper.fromPattern(pattern);
}
protected String getMetalTexture(ResourceLocation blockId) {
String name = blockId.getPath();
name = name.substring(0, name.indexOf('_'));
return name + "_bulb_vine_lantern_metal";
}
protected String getGlowTexture() {
return "bulb_vine_lantern_bulb";
}

View file

@ -21,7 +21,7 @@ public class BulbVineLanternColoredBlock extends BulbVineLanternBlock implements
public ItemColor getItemProvider() {
return (stack, tintIndex) -> getColor();
}
private int getColor() {
int color = BlocksHelper.getBlockColor(this);
int b = (color & 255);
@ -30,7 +30,7 @@ public class BulbVineLanternColoredBlock extends BulbVineLanternBlock implements
float[] hsv = ColorUtil.RGBtoHSB(r, g, b, new float[3]);
return ColorUtil.HSBtoRGB(hsv[0], hsv[1], hsv[1] > 0.2 ? 1 : hsv[2]);
}
@Override
protected String getGlowTexture() {
return "bulb_vine_lantern_overlay";

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.tags.BlockTags;
import net.minecraft.world.level.LevelReader;
@ -14,6 +12,8 @@ import ru.bclib.util.BlocksHelper;
import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class BulbVineSeedBlock extends EndPlantWithAgeBlock {
@Override

View file

@ -1,8 +1,5 @@
package ru.betterend.blocks;
import java.util.Collections;
import java.util.List;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.core.BlockPos;
import net.minecraft.world.item.ItemStack;
@ -22,21 +19,24 @@ import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.IRenderTyped;
import ru.betterend.registry.EndBlocks;
import java.util.Collections;
import java.util.List;
public class CavePumpkinBlock extends BaseBlockNotFull implements IRenderTyped {
public static final BooleanProperty SMALL = BlockProperties.SMALL;
private static final VoxelShape SHAPE_SMALL;
private static final VoxelShape SHAPE_BIG;
public CavePumpkinBlock() {
super(FabricBlockSettings.copyOf(Blocks.PUMPKIN).luminance((state) -> state.getValue(SMALL) ? 10 : 15));
registerDefaultState(defaultBlockState().setValue(SMALL, false));
}
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(SMALL);
}
@Override
public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.CUTOUT;
@ -46,19 +46,19 @@ public class CavePumpkinBlock extends BaseBlockNotFull implements IRenderTyped {
public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) {
return state.getValue(SMALL) ? SHAPE_SMALL : SHAPE_BIG;
}
@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return state.getValue(SMALL) ? Collections.singletonList(new ItemStack(EndBlocks.CAVE_PUMPKIN_SEED)) : Collections.singletonList(new ItemStack(this));
}
static {
VoxelShape lantern = Block.box(1, 0, 1, 15, 13, 15);
VoxelShape cap = Block.box(0, 12, 0, 16, 15, 16);
VoxelShape top = Block.box(5, 15, 5, 11, 16, 11);
SHAPE_BIG = Shapes.or(lantern, cap, top);
lantern = Block.box(1, 7, 1, 15, 13, 15);
lantern = Block.box(5, 7, 5, 11, 13, 11);
cap = Block.box(4, 12, 4, 12, 15, 12);
top = Block.box(6, 15, 6, 10, 16, 10);
SHAPE_SMALL = Shapes.or(lantern, cap, top);

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerLevel;
@ -18,15 +16,17 @@ import ru.bclib.blocks.BlockProperties;
import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class CavePumpkinVineBlock extends EndPlantWithAgeBlock {
private static final VoxelShape SHAPE = Block.box(4, 0, 4, 12, 16, 12);
@Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
BlockState down = world.getBlockState(pos.above());
return isTerrain(down);
}
@Override
public void performBonemeal(ServerLevel world, Random random, BlockPos pos, BlockState state) {
int age = state.getValue(AGE);
@ -45,8 +45,9 @@ public class CavePumpkinVineBlock extends EndPlantWithAgeBlock {
}
@Override
public void growAdult(WorldGenLevel world, Random random, BlockPos pos) {}
public void growAdult(WorldGenLevel world, Random random, BlockPos pos) {
}
@Override
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
state = super.updateShape(state, facing, neighborState, world, pos, neighborPos);
@ -63,7 +64,7 @@ public class CavePumpkinVineBlock extends EndPlantWithAgeBlock {
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return SHAPE;
}
@Override
public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.NONE;

View file

@ -1,13 +1,6 @@
package ru.betterend.blocks;
import java.util.EnumMap;
import java.util.Map;
import java.util.Optional;
import org.jetbrains.annotations.Nullable;
import com.google.common.collect.Maps;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
@ -23,6 +16,7 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.jetbrains.annotations.Nullable;
import ru.bclib.blocks.BaseAttachedBlock;
import ru.bclib.client.models.BlockModelProvider;
import ru.bclib.client.models.ModelsHelper;
@ -30,18 +24,22 @@ import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.IRenderTyped;
import ru.betterend.client.models.Patterns;
import java.util.EnumMap;
import java.util.Map;
import java.util.Optional;
public class ChandelierBlock extends BaseAttachedBlock implements IRenderTyped, BlockModelProvider {
private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class);
public ChandelierBlock(Block source) {
super(FabricBlockSettings.copyOf(source).luminance(15).noCollission().noOcclusion().requiresCorrectToolForDrops());
}
@Override
public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.CUTOUT;
}
@Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return BOUNDING_SHAPES.get(state.getValue(FACING));

View file

@ -8,7 +8,7 @@ public class ChorusGrassBlock extends EndPlantBlock {
public ChorusGrassBlock() {
super(true);
}
@Override
protected boolean isTerrain(BlockState state) {
return state.getBlock() == EndBlocks.CHORUS_NYLIUM;

View file

@ -1,8 +1,5 @@
package ru.betterend.blocks;
import java.util.Collections;
import java.util.List;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
@ -15,6 +12,9 @@ import ru.bclib.blocks.BaseBlock;
import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.IRenderTyped;
import java.util.Collections;
import java.util.List;
public class DenseEmeraldIceBlock extends BaseBlock implements IRenderTyped {
public DenseEmeraldIceBlock() {
super(FabricBlockSettings.copyOf(Blocks.PACKED_ICE));
@ -24,7 +24,7 @@ public class DenseEmeraldIceBlock extends BaseBlock implements IRenderTyped {
public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.TRANSLUCENT;
}
@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
ItemStack tool = builder.getOptionalParameter(LootContextParams.TOOL);

View file

@ -17,7 +17,7 @@ public class DragonTreeSaplingBlock extends FeatureSaplingBlock {
protected Feature<?> getFeature() {
return EndFeatures.DRAGON_TREE.getFeature();
}
@Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
return world.getBlockState(pos.below()).is(EndBlocks.SHADOW_GRASS);

View file

@ -1,11 +1,5 @@
package ru.betterend.blocks;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import org.jetbrains.annotations.Nullable;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
@ -26,10 +20,15 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import org.jetbrains.annotations.Nullable;
import ru.bclib.client.models.BlockModelProvider;
import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.IRenderTyped;
import java.util.Collections;
import java.util.List;
import java.util.Random;
public class EmeraldIceBlock extends HalfTransparentBlock implements IRenderTyped, BlockModelProvider {
public EmeraldIceBlock() {
super(FabricBlockSettings.copyOf(Blocks.ICE));
@ -74,7 +73,7 @@ public class EmeraldIceBlock extends HalfTransparentBlock implements IRenderType
world.neighborChanged(pos, Blocks.WATER, pos);
}
}
@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
ItemStack tool = builder.getOptionalParameter(LootContextParams.TOOL);

View file

@ -11,10 +11,10 @@ public class EndBlockProperties extends BlockProperties {
public static final EnumProperty<HydraluxShape> HYDRALUX_SHAPE = EnumProperty.create("shape", HydraluxShape.class);
public static final EnumProperty<PedestalState> PEDESTAL_STATE = EnumProperty.create("state", PedestalState.class);
public static final EnumProperty<CactusBottom> CACTUS_BOTTOM = EnumProperty.create("bottom", CactusBottom.class);
public static final BooleanProperty HAS_ITEM = BooleanProperty.create("has_item");
public static final IntegerProperty PORTAL = IntegerProperty.create("portal", 0, EndPortals.getCount());
public enum PedestalState implements StringRepresentable {
PEDESTAL_TOP("pedestal_top"),
COLUMN_TOP("column_top"),
@ -22,24 +22,24 @@ public class EndBlockProperties extends BlockProperties {
PILLAR("pillar"),
COLUMN("column"),
DEFAULT("default");
private final String name;
PedestalState(String name) {
this.name = name;
}
@Override
public String getSerializedName() {
return this.name;
}
@Override
public String toString() {
return this.name;
}
}
public enum HydraluxShape implements StringRepresentable {
FLOWER_BIG_BOTTOM("flower_big_bottom", true),
FLOWER_BIG_TOP("flower_big_top", true),
@ -47,10 +47,10 @@ public class EndBlockProperties extends BlockProperties {
FLOWER_SMALL_TOP("flower_small_top", true),
VINE("vine", false),
ROOTS("roots", false);
private final String name;
private final boolean glow;
HydraluxShape(String name, boolean glow) {
this.name = name;
this.glow = glow;
@ -60,17 +60,17 @@ public class EndBlockProperties extends BlockProperties {
public String getSerializedName() {
return name;
}
@Override
public String toString() {
return name;
}
public boolean hasGlow() {
return glow;
}
}
public enum LumecornShape implements StringRepresentable {
LIGHT_TOP("light_top", 15),
LIGHT_TOP_MIDDLE("light_top_middle", 15),
@ -79,10 +79,10 @@ public class EndBlockProperties extends BlockProperties {
MIDDLE("middle", 0),
BOTTOM_BIG("bottom_big", 0),
BOTTOM_SMALL("bottom_small", 0);
private final String name;
private final int light;
LumecornShape(String name, int light) {
this.name = name;
this.light = light;
@ -92,24 +92,24 @@ public class EndBlockProperties extends BlockProperties {
public String getSerializedName() {
return name;
}
@Override
public String toString() {
return name;
}
public int getLight() {
return light;
}
}
public enum CactusBottom implements StringRepresentable {
EMPTY("empty"),
SAND("sand"),
MOSS("moss");
private final String name;
CactusBottom(String name) {
this.name = name;
}
@ -118,7 +118,7 @@ public class EndBlockProperties extends BlockProperties {
public String getSerializedName() {
return name;
}
@Override
public String toString() {
return name;

View file

@ -1,11 +1,6 @@
package ru.betterend.blocks;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import com.google.common.collect.Lists;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
@ -37,11 +32,15 @@ import ru.betterend.blocks.basis.EndUnderwaterPlantBlock;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndItems;
import java.util.Collections;
import java.util.List;
import java.util.Random;
public class EndLilyBlock extends EndUnderwaterPlantBlock {
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
private static final VoxelShape SHAPE_BOTTOM = Block.box(4, 0, 4, 12, 16, 12);
private static final VoxelShape SHAPE_TOP = Block.box(2, 0, 2, 14, 6, 14);
public EndLilyBlock() {
super(FabricBlockSettings.of(Material.WATER_PLANT)
.breakByTool(FabricToolTags.SHEARS)
@ -50,7 +49,7 @@ public class EndLilyBlock extends EndUnderwaterPlantBlock {
.lightLevel((state) -> state.getValue(SHAPE) == TripleShape.TOP ? 13 : 0)
.noCollission());
}
@Override
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
if (!canSurvive(state, world, pos)) {
@ -60,24 +59,24 @@ public class EndLilyBlock extends EndUnderwaterPlantBlock {
return state;
}
}
@Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
Vec3 vec3d = state.getOffset(view, pos);
VoxelShape shape = state.getValue(SHAPE) == TripleShape.TOP ? SHAPE_TOP : SHAPE_BOTTOM;
return shape.move(vec3d.x, vec3d.y, vec3d.z);
}
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(SHAPE);
}
@Override
public FluidState getFluidState(BlockState state) {
return state.getValue(SHAPE) == TripleShape.TOP ? Fluids.EMPTY.defaultFluidState() : Fluids.WATER.getSource(false);
}
@Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
if (state.getValue(SHAPE) == TripleShape.TOP) {
@ -92,7 +91,7 @@ public class EndLilyBlock extends EndUnderwaterPlantBlock {
return up.getBlock() == this && down.getBlock() == this;
}
}
@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
if (state.getValue(SHAPE) == TripleShape.TOP) {
@ -100,13 +99,13 @@ public class EndLilyBlock extends EndUnderwaterPlantBlock {
}
return Collections.emptyList();
}
@Override
@Environment(EnvType.CLIENT)
public ItemStack getCloneItemStack(BlockGetter world, BlockPos pos, BlockState state) {
return new ItemStack(EndBlocks.END_LILY_SEED);
}
@Override
public boolean isValidBonemealTarget(BlockGetter world, BlockPos pos, BlockState state, boolean isClient) {
return false;

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
@ -12,6 +10,8 @@ import ru.bclib.blocks.UnderwaterPlantWithAgeBlock;
import ru.bclib.util.BlocksHelper;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class EndLilySeedBlock extends UnderwaterPlantWithAgeBlock {
@Override
public void grow(WorldGenLevel world, Random random, BlockPos pos) {
@ -25,7 +25,7 @@ public class EndLilySeedBlock extends UnderwaterPlantWithAgeBlock {
BlocksHelper.setWithoutUpdate(world, up, EndBlocks.END_LILY.defaultBlockState().setValue(EndLilyBlock.SHAPE, TripleShape.TOP));
}
}
private boolean canGrow(WorldGenLevel world, BlockPos pos) {
BlockPos up = pos.above();
while (world.getBlockState(up).getFluidState().getType().equals(Fluids.WATER.getSource())) {

View file

@ -1,9 +1,6 @@
package ru.betterend.blocks;
import java.util.List;
import com.google.common.collect.Lists;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
@ -21,40 +18,42 @@ import ru.bclib.util.MHelper;
import ru.betterend.blocks.basis.EndPlantBlock;
import ru.betterend.registry.EndBlocks;
import java.util.List;
public class EndLotusFlowerBlock extends EndPlantBlock {
private static final VoxelShape SHAPE_OUTLINE = Block.box(2, 0, 2, 14, 14, 14);
private static final VoxelShape SHAPE_COLLISION = Block.box(0, 0, 0, 16, 2, 16);
public EndLotusFlowerBlock() {
super(FabricBlockSettings.of(Material.PLANT).luminance(15).noOcclusion());
}
@Override
protected boolean isTerrain(BlockState state) {
return state.is(EndBlocks.END_LOTUS_STEM);
}
@Override
public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.NONE;
}
@Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return SHAPE_OUTLINE;
}
@Override
public VoxelShape getCollisionShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return SHAPE_COLLISION;
}
@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
int count = MHelper.randRange(1, 2, MHelper.RANDOM);
return Lists.newArrayList(new ItemStack(EndBlocks.END_LOTUS_SEED, count));
}
@Override
@Environment(EnvType.CLIENT)
public ItemStack getCloneItemStack(BlockGetter world, BlockPos pos, BlockState state) {

View file

@ -32,27 +32,27 @@ public class EndLotusLeafBlock extends BaseBlockNotFull implements IRenderTyped
public static final EnumProperty<Direction> HORIZONTAL_FACING = BlockStateProperties.HORIZONTAL_FACING;
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
private static final VoxelShape VSHAPE = Block.box(0, 0, 0, 16, 1, 16);
public EndLotusLeafBlock() {
super(FabricBlockSettings.of(Material.PLANT).noOcclusion().sound(SoundType.WET_GRASS));
}
@Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
BlockState down = world.getBlockState(pos.below());
return !down.getFluidState().isEmpty() && down.getFluidState().getType() instanceof WaterFluid;
}
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
builder.add(SHAPE, HORIZONTAL_FACING);
}
@Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return VSHAPE;
}
@Override
public BlockState rotate(BlockState state, Rotation rotation) {
return BlocksHelper.rotateHorizontal(state, rotation, HORIZONTAL_FACING);
@ -62,12 +62,12 @@ public class EndLotusLeafBlock extends BaseBlockNotFull implements IRenderTyped
public BlockState mirror(BlockState state, Mirror mirror) {
return BlocksHelper.mirrorHorizontal(state, mirror, HORIZONTAL_FACING);
}
@Override
public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.CUTOUT;
}
@Override
@Environment(EnvType.CLIENT)
public ItemStack getCloneItemStack(BlockGetter world, BlockPos pos, BlockState state) {

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
@ -14,6 +12,8 @@ import ru.bclib.blocks.UnderwaterPlantWithAgeBlock;
import ru.bclib.util.BlocksHelper;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class EndLotusSeedBlock extends UnderwaterPlantWithAgeBlock {
@Override
public void grow(WorldGenLevel world, Random random, BlockPos pos) {
@ -22,7 +22,7 @@ public class EndLotusSeedBlock extends UnderwaterPlantWithAgeBlock {
BlockState roots = EndBlocks.END_LOTUS_STEM.defaultBlockState().setValue(EndLotusStemBlock.SHAPE, TripleShape.BOTTOM).setValue(EndLotusStemBlock.WATERLOGGED, true);
BlockState stem = EndBlocks.END_LOTUS_STEM.defaultBlockState();
BlockState flower = EndBlocks.END_LOTUS_FLOWER.defaultBlockState();
BlocksHelper.setWithoutUpdate(world, pos, roots);
MutableBlockPos bpos = new MutableBlockPos().set(pos);
bpos.setY(bpos.getY() + 1);
@ -30,7 +30,7 @@ public class EndLotusSeedBlock extends UnderwaterPlantWithAgeBlock {
BlocksHelper.setWithoutUpdate(world, bpos, stem.setValue(EndLotusStemBlock.WATERLOGGED, true));
bpos.setY(bpos.getY() + 1);
}
int height = random.nextBoolean() ? 0 : random.nextBoolean() ? 1 : random.nextBoolean() ? 1 : -1;
TripleShape shape = (height == 0) ? TripleShape.TOP : TripleShape.MIDDLE;
Direction dir = BlocksHelper.randomHorizontal(random);
@ -42,7 +42,7 @@ public class EndLotusSeedBlock extends UnderwaterPlantWithAgeBlock {
else {
BlocksHelper.setWithoutUpdate(world, bpos, stem.setValue(EndLotusStemBlock.SHAPE, shape));
}
bpos.setY(bpos.getY() + 1);
for (int i = 1; i <= height; i++) {
if (!world.isEmptyBlock(bpos)) {
@ -56,11 +56,11 @@ public class EndLotusSeedBlock extends UnderwaterPlantWithAgeBlock {
BlocksHelper.setWithoutUpdate(world, bpos, stem);
bpos.setY(bpos.getY() + 1);
}
if (!world.isEmptyBlock(bpos) || height < 0) {
bpos.setY(bpos.getY() - 1);
}
BlocksHelper.setWithoutUpdate(world, bpos, flower);
bpos.setY(bpos.getY() - 1);
stem = world.getBlockState(bpos);
@ -70,15 +70,15 @@ public class EndLotusSeedBlock extends UnderwaterPlantWithAgeBlock {
stem = stem.setValue(EndLotusStemBlock.WATERLOGGED, true);
}
}
if (world.getBlockState(bpos.relative(dir)).is(EndBlocks.END_LOTUS_LEAF)) {
stem = stem.setValue(EndLotusStemBlock.LEAF, true).setValue(EndLotusStemBlock.FACING, dir);
}
BlocksHelper.setWithoutUpdate(world, bpos, stem.setValue(EndLotusStemBlock.SHAPE, TripleShape.TOP));
}
}
private boolean canGrow(WorldGenLevel world, BlockPos pos) {
MutableBlockPos bpos = new MutableBlockPos();
bpos.set(pos);
@ -87,31 +87,31 @@ public class EndLotusSeedBlock extends UnderwaterPlantWithAgeBlock {
}
return world.isEmptyBlock(bpos) && world.isEmptyBlock(bpos.above());
}
private void generateLeaf(WorldGenLevel world, BlockPos pos) {
MutableBlockPos p = new MutableBlockPos();
BlockState leaf = EndBlocks.END_LOTUS_LEAF.defaultBlockState();
BlocksHelper.setWithoutUpdate(world, pos, leaf.setValue(EndLotusLeafBlock.SHAPE, TripleShape.BOTTOM));
for (Direction move: BlocksHelper.HORIZONTAL) {
for (Direction move : BlocksHelper.HORIZONTAL) {
BlocksHelper.setWithoutUpdate(world, p.set(pos).move(move), leaf.setValue(EndLotusLeafBlock.HORIZONTAL_FACING, move).setValue(EndLotusLeafBlock.SHAPE, TripleShape.MIDDLE));
}
for (int i = 0; i < 4; i ++) {
for (int i = 0; i < 4; i++) {
Direction d1 = BlocksHelper.HORIZONTAL[i];
Direction d2 = BlocksHelper.HORIZONTAL[(i + 1) & 3];
BlocksHelper.setWithoutUpdate(world, p.set(pos).move(d1).move(d2), leaf.setValue(EndLotusLeafBlock.HORIZONTAL_FACING, d1).setValue(EndLotusLeafBlock.SHAPE, TripleShape.TOP));
}
}
private boolean hasLeaf(WorldGenLevel world, BlockPos pos) {
MutableBlockPos p = new MutableBlockPos();
p.setY(pos.getY());
int count = 0;
for (int x = -1; x < 2; x ++) {
for (int x = -1; x < 2; 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);
if (world.isEmptyBlock(p) && !world.getFluidState(p.below()).isEmpty())
count ++;
count++;
}
}
return count == 9;

View file

@ -1,9 +1,6 @@
package ru.betterend.blocks;
import java.util.Map;
import com.google.common.collect.Maps;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
@ -32,28 +29,30 @@ import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.IRenderTyped;
import ru.bclib.util.BlocksHelper;
import java.util.Map;
public class EndLotusStemBlock extends BaseBlock implements SimpleWaterloggedBlock, IRenderTyped {
public static final EnumProperty<Direction> FACING = BlockStateProperties.FACING;
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
public static final BooleanProperty LEAF = BooleanProperty.create("leaf");
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
private static final Map<Axis, VoxelShape> SHAPES = Maps.newEnumMap(Axis.class);
public EndLotusStemBlock() {
super(FabricBlockSettings.copyOf(Blocks.OAK_PLANKS));
this.registerDefaultState(defaultBlockState().setValue(WATERLOGGED, false).setValue(SHAPE, TripleShape.MIDDLE).setValue(LEAF, false).setValue(FACING, Direction.UP));
}
@Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return state.getValue(LEAF) ? SHAPES.get(Axis.Y) : SHAPES.get(state.getValue(FACING).getAxis());
}
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
builder.add(FACING, WATERLOGGED, SHAPE, LEAF);
}
@Override
public FluidState getFluidState(BlockState state) {
return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state);
@ -65,7 +64,7 @@ public class EndLotusStemBlock extends BaseBlock implements SimpleWaterloggedBlo
BlockPos blockPos = ctx.getClickedPos();
return this.defaultBlockState().setValue(WATERLOGGED, worldAccess.getFluidState(blockPos).getType() == Fluids.WATER).setValue(FACING, ctx.getClickedFace());
}
@Override
public BlockState rotate(BlockState state, Rotation rotation) {
return BlocksHelper.rotateHorizontal(state, rotation, FACING);
@ -83,12 +82,12 @@ public class EndLotusStemBlock extends BaseBlock implements SimpleWaterloggedBlo
}
return state;
}
@Override
public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.CUTOUT;
}
static {
SHAPES.put(Axis.X, Block.box(0, 6, 6, 16, 10, 10));
SHAPES.put(Axis.Y, Block.box(6, 0, 6, 10, 16, 10));

View file

@ -1,14 +1,14 @@
package ru.betterend.blocks;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block;
import ru.betterend.BetterEnd;
import ru.betterend.blocks.basis.PedestalBlock;
import java.util.HashMap;
import java.util.Map;
public class EndPedestal extends PedestalBlock {
public EndPedestal(Block parent) {
@ -21,8 +21,9 @@ public class EndPedestal extends PedestalBlock {
String name = blockId.getPath();
return new HashMap<String, String>() {
private static final long serialVersionUID = 1L;
{
put("%mod%", BetterEnd.MOD_ID );
put("%mod%", BetterEnd.MOD_ID);
put("%top%", name + "_polished");
put("%base%", name + "_polished");
put("%pillar%", name + "_pillar_side");

View file

@ -1,9 +1,5 @@
package ru.betterend.blocks;
import java.util.Objects;
import java.util.Optional;
import java.util.Random;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
@ -40,6 +36,10 @@ import ru.betterend.registry.EndParticles;
import ru.betterend.registry.EndPortals;
import ru.betterend.rituals.EternalRitual;
import java.util.Objects;
import java.util.Optional;
import java.util.Random;
public class EndPortalBlock extends NetherPortalBlock implements IRenderTyped, IColorProvider {
public static final IntegerProperty PORTAL = EndBlockProperties.PORTAL;
@ -52,7 +52,7 @@ public class EndPortalBlock extends NetherPortalBlock implements IRenderTyped, I
super.createBlockStateDefinition(builder);
builder.add(PORTAL);
}
@Override
@Environment(EnvType.CLIENT)
public void animateTick(BlockState state, Level world, BlockPos pos, Random random) {
@ -66,7 +66,8 @@ public class EndPortalBlock extends NetherPortalBlock implements IRenderTyped, I
int k = random.nextInt(2) * 2 - 1;
if (!world.getBlockState(pos.west()).is(this) && !world.getBlockState(pos.east()).is(this)) {
x = pos.getX() + 0.5D + 0.25D * k;
} else {
}
else {
z = pos.getZ() + 0.5D + 0.25D * k;
}
@ -74,13 +75,14 @@ public class EndPortalBlock extends NetherPortalBlock implements IRenderTyped, I
}
@Override
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {}
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
}
@Override
public BlockState updateShape(BlockState state, Direction direction, BlockState newState, LevelAccessor world, BlockPos pos, BlockPos posFrom) {
return state;
}
@Override
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
if (world.isClientSide || !validate(entity)) return;
@ -94,8 +96,9 @@ public class EndPortalBlock extends NetherPortalBlock implements IRenderTyped, I
if (exitPos == null) return;
if (entity instanceof ServerPlayer && ((ServerPlayer) entity).isCreative()) {
((ServerPlayer) entity).teleportTo(destination, exitPos.getX() + 0.5, exitPos.getY(),
exitPos.getZ() + 0.5, entity.yRot, entity.xRot);
} else {
exitPos.getZ() + 0.5, entity.getYRot(), entity.getXRot());
}
else {
((TeleportingEntity) entity).be_setExitPos(exitPos);
Optional<Entity> teleported = Optional.ofNullable(entity.changeDimension(destination));
teleported.ifPresent(Entity::setPortalCooldown);
@ -106,15 +109,15 @@ public class EndPortalBlock extends NetherPortalBlock implements IRenderTyped, I
return !entity.isPassenger() && !entity.isVehicle() &&
entity.canChangeDimensions() && !entity.isOnPortalCooldown();
}
@Override
public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.TRANSLUCENT;
}
private BlockPos findExitPos(ServerLevel currentWorld, ServerLevel targetWorld, BlockPos currentPos, Entity entity) {
if (targetWorld == null) return null;
Registry<DimensionType> registry = targetWorld.registryAccess().dimensionTypes();
Registry<DimensionType> registry = targetWorld.registryAccess().registryOrThrow(Registry.DIMENSION_TYPE_REGISTRY);
ResourceLocation targetWorldId = targetWorld.dimension().location();
ResourceLocation currentWorldId = currentWorld.dimension().location();
double targetMultiplier = Objects.requireNonNull(registry.get(targetWorldId)).coordinateScale();
@ -143,11 +146,11 @@ public class EndPortalBlock extends NetherPortalBlock implements IRenderTyped, I
}
return null;
}
private MutableBlockPos findCenter(Level world, MutableBlockPos pos, Direction.Axis axis) {
return findCenter(world, pos, axis, 1);
}
private MutableBlockPos findCenter(Level world, MutableBlockPos pos, Direction.Axis axis, int step) {
if (step > 8) return pos;
BlockState right, left;
@ -159,11 +162,14 @@ public class EndPortalBlock extends NetherPortalBlock implements IRenderTyped, I
BlockState down = world.getBlockState(pos.below());
if (down.is(this)) {
return findCenter(world, pos.move(Direction.DOWN), axis, step);
} else if (right.is(this) && left.is(this)) {
}
else if (right.is(this) && left.is(this)) {
return pos;
} else if (right.is(this)) {
}
else if (right.is(this)) {
return findCenter(world, pos.move(rightDir), axis, ++step);
} else if (left.is(this)) {
}
else if (left.is(this)) {
return findCenter(world, pos.move(leftDir), axis, ++step);
}
return pos;

View file

@ -1,10 +1,6 @@
package ru.betterend.blocks;
import java.util.List;
import java.util.Random;
import com.google.common.collect.Lists;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
@ -19,7 +15,6 @@ import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.HorizontalDirectionalBlock;
@ -28,6 +23,8 @@ import net.minecraft.world.level.block.RenderShape;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityTicker;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
@ -38,8 +35,13 @@ import net.minecraft.world.level.material.MaterialColor;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import net.minecraft.world.phys.BlockHitResult;
import org.jetbrains.annotations.Nullable;
import ru.bclib.blocks.BaseBlockWithEntity;
import ru.betterend.blocks.entities.EndStoneSmelterBlockEntity;
import ru.betterend.registry.EndBlockEntities;
import java.util.List;
import java.util.Random;
public class EndStoneSmelter extends BaseBlockWithEntity {
public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING;
@ -48,19 +50,19 @@ public class EndStoneSmelter extends BaseBlockWithEntity {
public EndStoneSmelter() {
super(FabricBlockSettings.of(Material.STONE, MaterialColor.COLOR_GRAY)
.luminance(state -> state.getValue(LIT) ? 15 : 0)
.hardness(4F)
.resistance(100F)
.requiresCorrectToolForDrops()
.sound(SoundType.STONE));
registerDefaultState(this.stateDefinition.any()
.setValue(FACING, Direction.NORTH)
.setValue(LIT, false));
registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH).setValue(LIT, false));
}
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
if (world.isClientSide) {
return InteractionResult.SUCCESS;
} else {
}
else {
this.openScreen(world, pos, player);
return InteractionResult.CONSUME;
}
@ -72,17 +74,17 @@ public class EndStoneSmelter extends BaseBlockWithEntity {
player.openMenu((EndStoneSmelterBlockEntity) blockEntity);
}
}
@Override
public BlockState getStateForPlacement(BlockPlaceContext ctx) {
return defaultBlockState().setValue(FACING, ctx.getHorizontalDirection().getOpposite());
}
@Override
public BlockEntity newBlockEntity(BlockGetter world) {
return new EndStoneSmelterBlockEntity();
public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) {
return new EndStoneSmelterBlockEntity(blockPos, blockState);
}
@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
List<ItemStack> drop = Lists.newArrayList(new ItemStack(this));
@ -129,7 +131,7 @@ public class EndStoneSmelter extends BaseBlockWithEntity {
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
builder.add(FACING, LIT);
}
@Environment(EnvType.CLIENT)
public void animateTick(BlockState state, Level world, BlockPos pos, Random random) {
if (state.getValue(LIT)) {
@ -137,7 +139,7 @@ public class EndStoneSmelter extends BaseBlockWithEntity {
double y = pos.getY();
double z = pos.getZ() + 0.5D;
if (random.nextDouble() < 0.1D) {
world.playLocalSound(x, y, z, SoundEvents.BLASTFURNACE_FIRE_CRACKLE, SoundSource.BLOCKS, 1.0F, 1.0F, false);
world.playLocalSound(x, y, z, SoundEvents.BLASTFURNACE_FIRE_CRACKLE, SoundSource.BLOCKS, 1.0F, 1.0F, false);
}
Direction direction = state.getValue(FACING);
@ -149,4 +151,11 @@ public class EndStoneSmelter extends BaseBlockWithEntity {
world.addParticle(ParticleTypes.SMOKE, x + offX, y + offY, z + offZ, 0.0D, 0.0D, 0.0D);
}
}
@Override
@Nullable
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState blockState, BlockEntityType<T> blockEntityType) {
return level.isClientSide() ? null : createTickerHelper(blockEntityType, EndBlockEntities.END_STONE_SMELTER, EndStoneSmelterBlockEntity::tick);
}
}

View file

@ -1,8 +1,5 @@
package ru.betterend.blocks;
import java.util.Collections;
import java.util.List;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
@ -16,16 +13,19 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.storage.loot.LootContext;
import ru.bclib.util.ColorUtil;
import java.util.Collections;
import java.util.List;
public class EndstoneDustBlock extends FallingBlock {
@Environment(EnvType.CLIENT)
private static final int COLOR = ColorUtil.color(226, 239, 168);
public EndstoneDustBlock() {
super(FabricBlockSettings.copyOf(Blocks.SAND)
.breakByTool(FabricToolTags.SHOVELS)
.materialColor(Blocks.END_STONE.defaultMaterialColor()));
}
@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return Collections.singletonList(new ItemStack(this));

View file

@ -1,9 +1,6 @@
package ru.betterend.blocks;
import java.util.List;
import com.google.common.collect.Lists;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.Registry;
@ -28,14 +25,16 @@ import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndPortals;
import ru.betterend.rituals.EternalRitual;
import java.util.List;
public class EternalPedestal extends PedestalBlock {
public static final BooleanProperty ACTIVATED = EndBlockProperties.ACTIVE;
public EternalPedestal() {
super(EndBlocks.FLAVOLITE_RUNED_ETERNAL);
this.registerDefaultState(defaultBlockState().setValue(ACTIVATED, false));
}
@Override
public void checkRitual(Level world, BlockPos pos) {
BlockEntity blockEntity = world.getBlockEntity(pos);
@ -50,21 +49,24 @@ public class EternalPedestal extends PedestalBlock {
int portalId;
if (targetWorld != null) {
portalId = EndPortals.getPortalIdByWorld(targetWorld);
} else {
}
else {
portalId = EndPortals.getPortalIdByWorld(EndPortals.OVERWORLD_ID);
}
ritual.disablePortal(portalId);
}
}
world.setBlockAndUpdate(pos, updatedState.setValue(ACTIVATED, false).setValue(HAS_LIGHT, false));
} else {
}
else {
ItemStack itemStack = pedestal.getItem(0);
ResourceLocation id = Registry.ITEM.getKey(itemStack.getItem());
if (EndPortals.isAvailableItem(id)) {
world.setBlockAndUpdate(pos, updatedState.setValue(ACTIVATED, true).setValue(HAS_LIGHT, true));
if (pedestal.hasRitual()) {
pedestal.getRitual().checkStructure();
} else {
}
else {
EternalRitual ritual = new EternalRitual(world, pos);
ritual.checkStructure();
}
@ -72,7 +74,7 @@ public class EternalPedestal extends PedestalBlock {
}
}
}
@Override
@Deprecated
public BlockState updateShape(BlockState state, Direction direction, BlockState newState, LevelAccessor world, BlockPos pos, BlockPos posFrom) {
@ -83,23 +85,23 @@ public class EternalPedestal extends PedestalBlock {
}
return updated;
}
@Override
@Deprecated
public float getDestroyProgress(BlockState state, Player player, BlockGetter world, BlockPos pos) {
return 0.0F;
}
@Override
public float getExplosionResistance() {
return Blocks.BEDROCK.getExplosionResistance();
}
@Override
public boolean dropFromExplosion(Explosion explosion) {
return false;
}
@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
if (state.is(this)) {
@ -118,7 +120,7 @@ public class EternalPedestal extends PedestalBlock {
}
return drop;
}
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
super.createBlockStateDefinition(stateManager);
@ -126,8 +128,8 @@ public class EternalPedestal extends PedestalBlock {
}
@Override
public BlockEntity newBlockEntity(BlockGetter world) {
return new EternalPedestalEntity();
public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) {
return new EternalPedestalEntity(blockPos, blockState);
}
@Override

View file

@ -7,7 +7,7 @@ public class FilaluxBlock extends BaseVineBlock {
public FilaluxBlock() {
super(15, true);
}
@Override
public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.NONE;

View file

@ -1,9 +1,6 @@
package ru.betterend.blocks;
import java.util.EnumMap;
import com.google.common.collect.Maps;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.core.BlockPos;
@ -19,9 +16,11 @@ import ru.bclib.blocks.BaseAttachedBlock;
import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.IRenderTyped;
import java.util.EnumMap;
public class FilaluxWingsBlock extends BaseAttachedBlock implements IRenderTyped {
private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class);
public FilaluxWingsBlock() {
super(FabricBlockSettings.of(Material.PLANT).breakByTool(FabricToolTags.SHEARS).sound(SoundType.WET_GRASS).noCollission());
}
@ -30,12 +29,12 @@ public class FilaluxWingsBlock extends BaseAttachedBlock implements IRenderTyped
public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.CUTOUT;
}
@Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return BOUNDING_SHAPES.get(state.getValue(FACING));
}
static {
BOUNDING_SHAPES.put(Direction.UP, Shapes.box(0.0, 0.0, 0.0, 1.0, 0.5, 1.0));
BOUNDING_SHAPES.put(Direction.DOWN, Shapes.box(0.0, 0.5, 0.0, 1.0, 1.0, 1.0));

View file

@ -1,9 +1,6 @@
package ru.betterend.blocks;
import java.util.List;
import com.google.common.collect.Lists;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.core.BlockPos;
@ -21,21 +18,23 @@ import net.minecraft.world.phys.shapes.VoxelShape;
import ru.bclib.interfaces.ISpetialItem;
import ru.betterend.blocks.basis.EndPlantBlock;
import java.util.List;
public class FlamaeaBlock extends EndPlantBlock implements ISpetialItem {
private static final VoxelShape SHAPE = Block.box(0, 0, 0, 16, 1, 16);
public FlamaeaBlock() {
super(FabricBlockSettings.of(Material.PLANT)
.breakByTool(FabricToolTags.SHEARS)
.breakByHand(true)
.sound(SoundType.WET_GRASS));
}
@Override
protected boolean isTerrain(BlockState state) {
return state.is(Blocks.WATER);
}
@Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return SHAPE;
@ -45,7 +44,7 @@ public class FlamaeaBlock extends EndPlantBlock implements ISpetialItem {
public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.NONE;
}
@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return Lists.newArrayList(new ItemStack(this));

View file

@ -12,19 +12,19 @@ public class GlowingMossBlock extends EndPlantBlock {
public GlowingMossBlock(int light) {
super(light);
}
@Override
protected boolean isTerrain(BlockState state) {
return state.getBlock() == EndBlocks.END_MOSS || state.getBlock() == EndBlocks.END_MYCELIUM;
}
@Environment(EnvType.CLIENT)
public boolean hasEmissiveLighting(BlockGetter world, BlockPos pos) {
return true;
}
@Environment(EnvType.CLIENT)
public float getAmbientOcclusionLightLevel(BlockGetter world, BlockPos pos) {
return 1F;
}
@Environment(EnvType.CLIENT)
public boolean hasEmissiveLighting(BlockGetter world, BlockPos pos) {
return true;
}
@Environment(EnvType.CLIENT)
public float getAmbientOcclusionLightLevel(BlockGetter world, BlockPos pos) {
return 1F;
}
}

View file

@ -19,7 +19,7 @@ import ru.betterend.registry.EndBlocks;
public class GlowingPillarLuminophorBlock extends BaseBlock {
public static final BooleanProperty NATURAL = EndBlockProperties.NATURAL;
public GlowingPillarLuminophorBlock() {
super(FabricBlockSettings.of(Material.LEAVES)
.materialColor(MaterialColor.COLOR_ORANGE)
@ -29,12 +29,12 @@ public class GlowingPillarLuminophorBlock extends BaseBlock {
.sound(SoundType.GRASS));
this.registerDefaultState(this.stateDefinition.any().setValue(NATURAL, false));
}
@Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
return !state.getValue(NATURAL) || world.getBlockState(pos.below()).is(EndBlocks.GLOWING_PILLAR_ROOTS);
}
@Override
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
if (!canSurvive(state, world, pos)) {
@ -44,7 +44,7 @@ public class GlowingPillarLuminophorBlock extends BaseBlock {
return state;
}
}
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(NATURAL);

View file

@ -16,17 +16,17 @@ import ru.betterend.registry.EndBlocks;
public class GlowingPillarRootsBlock extends UpDownPlantBlock {
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(SHAPE);
}
@Override
protected boolean isTerrain(BlockState state) {
return state.is(EndBlocks.AMBER_MOSS);
}
@Override
@Environment(EnvType.CLIENT)
public ItemStack getCloneItemStack(BlockGetter world, BlockPos pos, BlockState state) {

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks;
import java.util.Random;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.core.BlockPos;
@ -20,6 +18,8 @@ import ru.bclib.util.MHelper;
import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class GlowingPillarSeedBlock extends EndPlantWithAgeBlock {
public GlowingPillarSeedBlock() {
@ -31,7 +31,7 @@ public class GlowingPillarSeedBlock extends EndPlantWithAgeBlock {
.randomTicks()
.noCollission());
}
@Override
public void growAdult(WorldGenLevel world, Random random, BlockPos pos) {
int height = MHelper.randRange(1, 2, random);
@ -39,19 +39,20 @@ public class GlowingPillarSeedBlock extends EndPlantWithAgeBlock {
if (h < height) {
return;
}
MutableBlockPos mut = new MutableBlockPos().set(pos);
BlockState roots = EndBlocks.GLOWING_PILLAR_ROOTS.defaultBlockState();
if (height < 2) {
BlocksHelper.setWithUpdate(world, mut, roots.setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE));
} else {
}
else {
BlocksHelper.setWithUpdate(world, mut, roots.setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM));
mut.move(Direction.UP);
BlocksHelper.setWithUpdate(world, mut, roots.setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP));
}
mut.move(Direction.UP);
BlocksHelper.setWithUpdate(world, mut, EndBlocks.GLOWING_PILLAR_LUMINOPHOR.defaultBlockState().setValue(BlueVineLanternBlock.NATURAL, true));
for (Direction dir: BlocksHelper.DIRECTIONS) {
for (Direction dir : BlocksHelper.DIRECTIONS) {
pos = mut.relative(dir);
if (world.isEmptyBlock(pos)) {
BlocksHelper.setWithUpdate(world, pos, EndBlocks.GLOWING_PILLAR_LEAVES.defaultBlockState().setValue(BlockStateProperties.FACING, dir));
@ -62,12 +63,12 @@ public class GlowingPillarSeedBlock extends EndPlantWithAgeBlock {
BlocksHelper.setWithUpdate(world, mut, EndBlocks.GLOWING_PILLAR_LEAVES.defaultBlockState().setValue(BlockStateProperties.FACING, Direction.UP));
}
}
@Override
protected boolean isTerrain(BlockState state) {
return state.is(EndBlocks.AMBER_MOSS);
}
@Override
public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.NONE;

View file

@ -1,10 +1,6 @@
package ru.betterend.blocks;
import java.util.Collections;
import java.util.List;
import com.google.common.collect.Lists;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.client.color.block.BlockColor;
@ -30,10 +26,13 @@ import ru.bclib.util.MHelper;
import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndBlocks;
import java.util.Collections;
import java.util.List;
public class HelixTreeLeavesBlock extends BaseBlock implements IColorProvider {
public static final IntegerProperty COLOR = EndBlockProperties.COLOR;
private static final OpenSimplexNoise NOISE = new OpenSimplexNoise(0);
public HelixTreeLeavesBlock() {
super(FabricBlockSettings.of(Material.LEAVES)
.materialColor(MaterialColor.COLOR_ORANGE)
@ -42,7 +41,7 @@ public class HelixTreeLeavesBlock extends BaseBlock implements IColorProvider {
.sound(SoundType.GRASS)
.strength(0.2F));
}
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(COLOR);
@ -61,7 +60,7 @@ public class HelixTreeLeavesBlock extends BaseBlock implements IColorProvider {
return ColorUtil.color(237, getGreen(4), 20);
};
}
@Override
public BlockState getStateForPlacement(BlockPlaceContext ctx) {
double px = ctx.getClickedPos().getX() * 0.1;
@ -69,17 +68,17 @@ public class HelixTreeLeavesBlock extends BaseBlock implements IColorProvider {
double pz = ctx.getClickedPos().getZ() * 0.1;
return this.defaultBlockState().setValue(COLOR, MHelper.floor(NOISE.eval(px, py, pz) * 3.5 + 4));
}
private int getGreen(int color) {
float delta = color / 7F;
return (int) Mth.lerp(delta, 80, 158);
}
@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
ItemStack tool = builder.getParameter(LootContextParams.TOOL);
if (tool != null) {
if (tool.getItem().is(FabricToolTags.SHEARS) || tool.isCorrectToolForDrops(state) || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) {
if (tool.is(FabricToolTags.SHEARS) || tool.isCorrectToolForDrops(state) || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) {
return Collections.singletonList(new ItemStack(this));
}
int fortune = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.BLOCK_FORTUNE, tool);

View file

@ -1,11 +1,6 @@
package ru.betterend.blocks;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import com.google.common.collect.Lists;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
@ -29,10 +24,14 @@ import ru.betterend.blocks.EndBlockProperties.HydraluxShape;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndItems;
import java.util.Collections;
import java.util.List;
import java.util.Random;
public class HydraluxBlock extends UnderwaterPlantBlock {
public static final EnumProperty<HydraluxShape> SHAPE = EndBlockProperties.HYDRALUX_SHAPE;
public HydraluxBlock() {
super(FabricBlockSettings.of(Material.WATER_PLANT)
.breakByTool(FabricToolTags.SHEARS)
@ -41,12 +40,12 @@ public class HydraluxBlock extends UnderwaterPlantBlock {
.lightLevel((state) -> state.getValue(SHAPE).hasGlow() ? 15 : 0)
.noCollission());
}
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(SHAPE);
}
@Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
BlockState down = world.getBlockState(pos.below());
@ -76,13 +75,13 @@ public class HydraluxBlock extends UnderwaterPlantBlock {
public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) {
return false;
}
@Override
@Environment(EnvType.CLIENT)
public ItemStack getCloneItemStack(BlockGetter world, BlockPos pos, BlockState state) {
return new ItemStack(EndBlocks.HYDRALUX_SAPLING);
}
@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
HydraluxShape shape = state.getValue(SHAPE);

View file

@ -6,6 +6,7 @@ import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.material.MaterialColor;
import ru.bclib.blocks.BaseBlock;
@ -20,11 +21,12 @@ public class HydraluxPetalBlock extends BaseBlock {
.materialColor(MaterialColor.PODZOL)
.sound(SoundType.WART_BLOCK));
}
public HydraluxPetalBlock(Properties settings) {
super(settings);
}
@Override
public void fallOn(Level world, BlockPos pos, Entity entity, float distance) {}
public void fallOn(Level level, BlockState blockState, BlockPos blockPos, Entity entity, float f) {
}
}

View file

@ -1,9 +1,5 @@
package ru.betterend.blocks;
import java.util.Optional;
import org.jetbrains.annotations.Nullable;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
@ -12,16 +8,19 @@ import net.minecraft.client.color.item.ItemColor;
import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.state.BlockState;
import org.jetbrains.annotations.Nullable;
import ru.bclib.client.models.ModelsHelper;
import ru.bclib.interfaces.IColorProvider;
import ru.bclib.util.BlocksHelper;
import ru.betterend.client.models.Patterns;
import java.util.Optional;
public class HydraluxPetalColoredBlock extends HydraluxPetalBlock implements IColorProvider {
public HydraluxPetalColoredBlock(FabricBlockSettings settings) {
super(settings);
}
@Override
public BlockColor getProvider() {
return (state, world, pos, tintIndex) -> BlocksHelper.getBlockColor(this);

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.world.level.WorldGenLevel;
@ -13,20 +11,22 @@ import ru.bclib.util.MHelper;
import ru.betterend.blocks.EndBlockProperties.HydraluxShape;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class HydraluxSaplingBlock extends UnderwaterPlantWithAgeBlock {
@Override
public void grow(WorldGenLevel world, Random random, BlockPos pos) {
int h = MHelper.randRange(4, 8, random);
MutableBlockPos mut = new MutableBlockPos().set(pos);
for (int i = 1; i < h; i++) {
mut.setY(pos.getY() + i);
if (!world.getBlockState(mut).is(Blocks.WATER)) {
return;
}
}
mut.setY(pos.getY());
BlockState state = EndBlocks.HYDRALUX.defaultBlockState();
BlocksHelper.setWithoutUpdate(world, pos, state.setValue(EndBlockProperties.HYDRALUX_SHAPE, HydraluxShape.ROOTS));
@ -34,15 +34,15 @@ public class HydraluxSaplingBlock extends UnderwaterPlantWithAgeBlock {
mut.setY(pos.getY() + i);
BlocksHelper.setWithoutUpdate(world, mut, state.setValue(EndBlockProperties.HYDRALUX_SHAPE, HydraluxShape.VINE));
}
mut.setY(mut.getY() + 1);
boolean big = random.nextBoolean();
BlocksHelper.setWithoutUpdate(world, mut, state.setValue(EndBlockProperties.HYDRALUX_SHAPE, big ? HydraluxShape.FLOWER_BIG_BOTTOM : HydraluxShape.FLOWER_SMALL_BOTTOM));
mut.setY(mut.getY() + 1);
BlocksHelper.setWithoutUpdate(world, mut, state.setValue(EndBlockProperties.HYDRALUX_SHAPE, big ? HydraluxShape.FLOWER_BIG_TOP : HydraluxShape.FLOWER_SMALL_TOP));
}
@Override
protected boolean isTerrain(BlockState state) {
return state.is(EndBlocks.SULPHURIC_ROCK.stone);

View file

@ -1,9 +1,5 @@
package ru.betterend.blocks;
import java.util.Random;
import org.jetbrains.annotations.Nullable;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
@ -26,6 +22,8 @@ import net.minecraft.world.level.block.LiquidBlockContainer;
import net.minecraft.world.level.block.SimpleWaterloggedBlock;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityTicker;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
@ -36,6 +34,7 @@ import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.jetbrains.annotations.Nullable;
import ru.bclib.blocks.BaseBlockNotFull;
import ru.bclib.blocks.BlockProperties;
import ru.bclib.util.BlocksHelper;
@ -43,12 +42,14 @@ import ru.betterend.blocks.entities.BlockEntityHydrothermalVent;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndParticles;
import java.util.Random;
@SuppressWarnings("deprecation")
public class HydrothermalVentBlock extends BaseBlockNotFull implements EntityBlock, LiquidBlockContainer, SimpleWaterloggedBlock {
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
public static final BooleanProperty ACTIVATED = BlockProperties.ACTIVE;
private static final VoxelShape SHAPE = Block.box(1, 1, 1, 15, 16, 15);
public HydrothermalVentBlock() {
super(FabricBlockSettings.of(Material.STONE)
.breakByTool(FabricToolTags.PICKAXES)
@ -57,17 +58,17 @@ public class HydrothermalVentBlock extends BaseBlockNotFull implements EntityBlo
.requiresCorrectToolForDrops());
this.registerDefaultState(defaultBlockState().setValue(WATERLOGGED, true).setValue(ACTIVATED, false));
}
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
builder.add(WATERLOGGED, ACTIVATED);
}
@Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return SHAPE;
}
@Override
public boolean canPlaceLiquid(BlockGetter world, BlockPos pos, BlockState state, Fluid fluid) {
return false;
@ -77,13 +78,13 @@ public class HydrothermalVentBlock extends BaseBlockNotFull implements EntityBlo
public boolean placeLiquid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluidState) {
return false;
}
@Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
state = world.getBlockState(pos.below());
return state.is(EndBlocks.SULPHURIC_ROCK.stone);
}
@Override
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
if (!canSurvive(state, world, pos)) {
@ -94,22 +95,22 @@ public class HydrothermalVentBlock extends BaseBlockNotFull implements EntityBlo
}
return state;
}
@Override
public BlockState getStateForPlacement(BlockPlaceContext ctx) {
LevelAccessor worldAccess = ctx.getLevel();
BlockPos blockPos = ctx.getClickedPos();
return this.defaultBlockState().setValue(WATERLOGGED, worldAccess.getFluidState(blockPos).getType() == Fluids.WATER);
}
@Override
public FluidState getFluidState(BlockState state) {
return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state);
}
@Override
public BlockEntity newBlockEntity(BlockGetter world) {
return new BlockEntityHydrothermalVent();
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
return new BlockEntityHydrothermalVent(pos, state);
}
@Override
@ -120,27 +121,28 @@ public class HydrothermalVentBlock extends BaseBlockNotFull implements EntityBlo
world.getBlockTicks().scheduleTick(up, EndBlocks.VENT_BUBBLE_COLUMN, 5);
}
}
@Override
public void setPlacedBy(Level world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack itemStack) {
if (world instanceof ServerLevel && state.getValue(WATERLOGGED) && world.getBlockState(pos.above()).is(Blocks.WATER)) {
tick(state,(ServerLevel) world, pos, world.random);
tick(state, (ServerLevel) world, pos, world.random);
}
}
@Environment(EnvType.CLIENT)
public void animateTick(BlockState state, Level world, BlockPos pos, Random random) {
super.animateTick(state, world, pos, random);
if (!state.getValue(ACTIVATED) && random.nextBoolean()) {
super.animateTick(state, world, pos, random);
double x = pos.getX() + random.nextDouble();
double y = pos.getY() + 0.9 + random.nextDouble() * 0.3;
double z = pos.getZ() + random.nextDouble();
if (state.getValue(WATERLOGGED)) {
world.addParticle(EndParticles.GEYSER_PARTICLE, x, y, z, 0, 0, 0);
}
else {
world.addParticle(ParticleTypes.SMOKE, x, y, z, 0, 0, 0);
}
world.addParticle(ParticleTypes.LARGE_SMOKE, x, y, z, 0, 0, 0);
}
}
@Nullable
@Override
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState blockState, BlockEntityType<T> blockEntityType) {
return BlockEntityHydrothermalVent::tick;
}
}

View file

@ -6,12 +6,16 @@ import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityTicker;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.jetbrains.annotations.Nullable;
import ru.betterend.blocks.basis.PedestalBlock;
import ru.betterend.blocks.entities.InfusionPedestalEntity;
import ru.betterend.blocks.entities.PedestalBlockEntity;
import ru.betterend.rituals.InfusionRitual;
@SuppressWarnings("deprecation")
@ -23,7 +27,7 @@ public class InfusionPedestal extends PedestalBlock {
super(Blocks.OBSIDIAN);
this.height = 1.08F;
}
@Override
public void checkRitual(Level world, BlockPos pos) {
BlockEntity blockEntity = world.getBlockEntity(pos);
@ -35,17 +39,18 @@ public class InfusionPedestal extends PedestalBlock {
ritual.configure();
}
pedestal.getRitual().checkRecipe();
} else {
}
else {
InfusionRitual ritual = new InfusionRitual(pedestal, world, pos);
pedestal.linkRitual(ritual);
ritual.checkRecipe();
}
}
}
@Override
public BlockEntity newBlockEntity(BlockGetter world) {
return new InfusionPedestalEntity();
public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) {
return new InfusionPedestalEntity(blockPos, blockState);
}
@Override
@ -57,7 +62,7 @@ public class InfusionPedestal extends PedestalBlock {
@Deprecated
public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) {
if (state.is(this)) {
switch(state.getValue(STATE)) {
switch (state.getValue(STATE)) {
case PEDESTAL_TOP: {
return SHAPE_PEDESTAL_TOP;
}
@ -72,6 +77,12 @@ public class InfusionPedestal extends PedestalBlock {
return super.getShape(state, world, pos, context);
}
@Override
@Nullable
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState blockState, BlockEntityType<T> blockEntityType) {
return InfusionPedestalEntity::tickEnity;
}
static {
VoxelShape basinUp = Block.box(2, 3, 2, 14, 4, 14);
VoxelShape basinDown = Block.box(0, 0, 0, 16, 3, 16);

View file

@ -1,12 +1,6 @@
package ru.betterend.blocks;
import java.util.List;
import java.util.Optional;
import org.jetbrains.annotations.Nullable;
import com.google.common.collect.Lists;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
@ -25,6 +19,7 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import net.minecraft.world.level.storage.loot.LootContext;
import org.jetbrains.annotations.Nullable;
import ru.bclib.client.models.BlockModelProvider;
import ru.bclib.client.models.ModelsHelper;
import ru.bclib.client.render.BCLRenderLayer;
@ -35,20 +30,23 @@ import ru.bclib.util.MHelper;
import ru.betterend.client.models.Patterns;
import ru.betterend.noise.OpenSimplexNoise;
import java.util.List;
import java.util.Optional;
public class JellyshroomCapBlock extends SlimeBlock implements IRenderTyped, BlockModelProvider, IColorProvider {
public static final IntegerProperty COLOR = EndBlockProperties.COLOR;
private static final OpenSimplexNoise NOISE = new OpenSimplexNoise(0);
private final Vec3i colorStart;
private final Vec3i colorEnd;
private final int coloritem;
public JellyshroomCapBlock(int r1, int g1, int b1, int r2, int g2, int b2) {
super(FabricBlockSettings.copyOf(Blocks.SLIME_BLOCK));
colorStart = new Vec3i(r1, g1, b1);
colorEnd = new Vec3i(r2, g2, b2);
coloritem = ColorUtil.color((r1 + r2) >> 1, (g1 + g2) >> 1, (b1 + b2) >> 1);
}
@Override
public BlockState getStateForPlacement(BlockPlaceContext ctx) {
double px = ctx.getClickedPos().getX() * 0.1;
@ -56,17 +54,17 @@ public class JellyshroomCapBlock extends SlimeBlock implements IRenderTyped, Blo
double pz = ctx.getClickedPos().getZ() * 0.1;
return this.defaultBlockState().setValue(COLOR, MHelper.floor(NOISE.eval(px, py, pz) * 3.5 + 4));
}
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(COLOR);
}
@Override
public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.TRANSLUCENT;
}
@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return Lists.newArrayList(new ItemStack(this));

View file

@ -17,7 +17,7 @@ public class LacugroveSaplingBlock extends FeatureSaplingBlock {
protected Feature<?> getFeature() {
return EndFeatures.LACUGROVE.getFeature();
}
@Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
return world.getBlockState(pos.below()).is(EndBlocks.END_MOSS) || world.getBlockState(pos.below()).is(EndBlocks.ENDSTONE_DUST);

View file

@ -1,8 +1,5 @@
package ru.betterend.blocks;
import java.util.Collections;
import java.util.List;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.item.ItemStack;
@ -21,11 +18,14 @@ import ru.bclib.util.MHelper;
import ru.betterend.blocks.basis.EndPlantBlock;
import ru.betterend.registry.EndBlocks;
import java.util.Collections;
import java.util.List;
public class LanceleafBlock extends EndPlantBlock {
public static final EnumProperty<PentaShape> SHAPE = BlockProperties.PENTA_SHAPE;
public static final IntegerProperty ROTATION = BlockProperties.ROTATION;
public LanceleafBlock() {
super();
}
@ -34,7 +34,7 @@ public class LanceleafBlock extends EndPlantBlock {
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(SHAPE, ROTATION);
}
@Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
PentaShape shape = state.getValue(SHAPE);
@ -48,7 +48,7 @@ public class LanceleafBlock extends EndPlantBlock {
return world.getBlockState(pos.below()).is(this) && world.getBlockState(pos.above()).is(this);
}
}
@Override
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
if (!canSurvive(state, world, pos)) {
@ -58,7 +58,7 @@ public class LanceleafBlock extends EndPlantBlock {
return state;
}
}
@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
if (state.getValue(SHAPE) == PentaShape.BOTTOM) {

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
@ -15,6 +13,8 @@ import ru.bclib.util.MHelper;
import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class LanceleafSeedBlock extends EndPlantWithAgeBlock {
@Override
public void growAdult(WorldGenLevel world, Random random, BlockPos pos) {
@ -34,12 +34,12 @@ public class LanceleafSeedBlock extends EndPlantWithAgeBlock {
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), plant.setValue(BlockProperties.PENTA_SHAPE, PentaShape.PRE_TOP));
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), plant.setValue(BlockProperties.PENTA_SHAPE, PentaShape.TOP));
}
@Override
protected boolean isTerrain(BlockState state) {
return state.is(EndBlocks.AMBER_MOSS);
}
@Override
public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.NONE;

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks;
import java.util.Random;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.core.BlockPos;
@ -22,11 +20,13 @@ import ru.bclib.blocks.BlockProperties.TripleShape;
import ru.betterend.blocks.basis.EndPlantBlock;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class LargeAmaranitaBlock extends EndPlantBlock {
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
private static final VoxelShape SHAPE_BOTTOM = Block.box(4, 0, 4, 12, 14, 12);
private static final VoxelShape SHAPE_TOP = Shapes.or(Block.box(1, 3, 1, 15, 16, 15), SHAPE_BOTTOM);
public LargeAmaranitaBlock() {
super(FabricBlockSettings.of(Material.PLANT)
.breakByTool(FabricToolTags.SHEARS)
@ -34,22 +34,22 @@ public class LargeAmaranitaBlock extends EndPlantBlock {
.sound(SoundType.GRASS)
.lightLevel((state) -> (state.getValue(SHAPE) == TripleShape.TOP) ? 15 : 0));
}
@Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return state.getValue(SHAPE) == TripleShape.TOP ? SHAPE_TOP : SHAPE_BOTTOM;
}
@Override
protected boolean isTerrain(BlockState state) {
return state.is(EndBlocks.SANGNUM) || state.is(EndBlocks.MOSSY_OBSIDIAN) || state.is(EndBlocks.MOSSY_DRAGON_BONE);
}
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(SHAPE);
}
@Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
TripleShape shape = state.getValue(SHAPE);
@ -63,12 +63,12 @@ public class LargeAmaranitaBlock extends EndPlantBlock {
return world.getBlockState(pos.below()).is(this) && world.getBlockState(pos.above()).is(this);
}
}
@Override
public OffsetType getOffsetType() {
return OffsetType.NONE;
}
@Override
public boolean isValidBonemealTarget(BlockGetter world, BlockPos pos, BlockState state, boolean isClient) {
return false;

View file

@ -17,7 +17,7 @@ public class LucerniaSaplingBlock extends FeatureSaplingBlock {
protected Feature<?> getFeature() {
return EndFeatures.LUCERNIA.getFeature();
}
@Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
return world.getBlockState(pos.below()).is(EndBlocks.RUTISCUS);

View file

@ -1,8 +1,5 @@
package ru.betterend.blocks;
import java.util.Collections;
import java.util.List;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
@ -31,19 +28,22 @@ import ru.betterend.blocks.EndBlockProperties.LumecornShape;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndItems;
import java.util.Collections;
import java.util.List;
@SuppressWarnings("deprecation")
public class LumecornBlock extends BaseBlockNotFull implements IRenderTyped {
public static final EnumProperty<LumecornShape> SHAPE = EnumProperty.create("shape", LumecornShape.class);
private static final VoxelShape SHAPE_BOTTOM = Block.box(6, 0, 6, 10, 16, 10);
private static final VoxelShape SHAPE_TOP = Block.box(6, 0, 6, 10, 8, 10);
public LumecornBlock() {
super(FabricBlockSettings.of(Material.WOOD)
.breakByTool(FabricToolTags.AXES)
.hardness(0.5F)
.luminance(state -> state.getValue(SHAPE).getLight()));
}
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(SHAPE);
@ -53,12 +53,12 @@ public class LumecornBlock extends BaseBlockNotFull implements IRenderTyped {
public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.CUTOUT;
}
@Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return state.getValue(SHAPE) == LumecornShape.LIGHT_TOP ? SHAPE_TOP : SHAPE_BOTTOM;
}
@Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
LumecornShape shape = state.getValue(SHAPE);
@ -72,7 +72,7 @@ public class LumecornBlock extends BaseBlockNotFull implements IRenderTyped {
return world.getBlockState(pos.below()).is(this) && world.getBlockState(pos.above()).is(this);
}
}
@Override
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
if (!canSurvive(state, world, pos)) {
@ -82,7 +82,7 @@ public class LumecornBlock extends BaseBlockNotFull implements IRenderTyped {
return state;
}
}
@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
LumecornShape shape = state.getValue(SHAPE);
@ -91,7 +91,7 @@ public class LumecornBlock extends BaseBlockNotFull implements IRenderTyped {
}
return MHelper.RANDOM.nextBoolean() ? Collections.singletonList(new ItemStack(EndItems.LUMECORN_ROD)) : Collections.emptyList();
}
@Override
@Environment(EnvType.CLIENT)
public ItemStack getCloneItemStack(BlockGetter world, BlockPos pos, BlockState state) {

View file

@ -1,27 +1,28 @@
package ru.betterend.blocks;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndFeatures;
import java.util.Random;
public class LumecornSeedBlock extends EndPlantWithAgeBlock {
@Override
public void growAdult(WorldGenLevel world, Random random, BlockPos pos) {
EndFeatures.LUMECORN.getFeature().place(world, null, random, pos, null);
EndFeatures.LUMECORN.getFeature().place(new FeaturePlaceContext<>(world, null, random, pos, null));
}
@Override
protected boolean isTerrain(BlockState state) {
return state.is(EndBlocks.END_MOSS);
}
@Override
public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.NONE;

View file

@ -1,9 +1,6 @@
package ru.betterend.blocks;
import java.util.Queue;
import com.google.common.collect.Lists;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
@ -17,26 +14,27 @@ import net.minecraft.world.level.block.LiquidBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.level.material.Material;
import ru.bclib.blocks.BaseBlockNotFull;
import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.IRenderTyped;
import ru.betterend.registry.EndBlocks;
import java.util.Queue;
@SuppressWarnings("deprecation")
public class MengerSpongeBlock extends BaseBlockNotFull implements IRenderTyped {
public MengerSpongeBlock() {
super(FabricBlockSettings.copyOf(Blocks.SPONGE).noOcclusion());
}
@Override
public void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) {
if (absorbWater(world, pos)) {
world.setBlockAndUpdate(pos, EndBlocks.MENGER_SPONGE_WET.defaultBlockState());
}
}
@Override
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
if (absorbWater(world, pos)) {
@ -61,19 +59,21 @@ public class MengerSpongeBlock extends BaseBlockNotFull implements IRenderTyped
FluidState fluidState = world.getFluidState(blockPos2);
Material material = blockState.getMaterial();
if (fluidState.is(FluidTags.WATER)) {
if (blockState.getBlock() instanceof BucketPickup && ((BucketPickup) blockState.getBlock()).takeLiquid(world, blockPos2, blockState) != Fluids.EMPTY) {
if (blockState.getBlock() instanceof BucketPickup && !((BucketPickup) blockState.getBlock()).pickupBlock(world, blockPos2, blockState).isEmpty()) {
++i;
if (j < 6) {
queue.add(new Tuple<>(blockPos2, j + 1));
}
} else if (blockState.getBlock() instanceof LiquidBlock) {
}
else if (blockState.getBlock() instanceof LiquidBlock) {
world.setBlock(blockPos2, Blocks.AIR.defaultBlockState(), 3);
++i;
if (j < 6) {
queue.add(new Tuple<>(blockPos2, j + 1));
}
} else if (material == Material.WATER_PLANT || material == Material.REPLACEABLE_WATER_PLANT) {
BlockEntity blockEntity = blockState.getBlock().isEntityBlock() ? world.getBlockEntity(blockPos2) : null;
}
else if (material == Material.WATER_PLANT || material == Material.REPLACEABLE_WATER_PLANT) {
BlockEntity blockEntity = blockState.hasBlockEntity() ? world.getBlockEntity(blockPos2) : null;
dropResources(blockState, world, blockPos2, blockEntity);
world.setBlock(blockPos2, Blocks.AIR.defaultBlockState(), 3);
++i;
@ -91,7 +91,7 @@ public class MengerSpongeBlock extends BaseBlockNotFull implements IRenderTyped
return i > 0;
}
@Override
public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.CUTOUT;

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks;
import java.util.Random;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
@ -25,6 +23,8 @@ import ru.bclib.interfaces.IRenderTyped;
import ru.bclib.util.BlocksHelper;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
@SuppressWarnings("deprecation")
public class MengerSpongeWetBlock extends BaseBlockNotFull implements IRenderTyped {
public MengerSpongeWetBlock() {
@ -94,12 +94,12 @@ public class MengerSpongeWetBlock extends BaseBlockNotFull implements IRenderTyp
world.addFreshEntity(drop);
}
}
@Override
public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.CUTOUT;
}
@Override
public FluidState getFluidState(BlockState state) {
return Fluids.WATER.getSource(false);

View file

@ -1,9 +1,5 @@
package ru.betterend.blocks;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
@ -21,12 +17,16 @@ import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import ru.bclib.blocks.BaseRotatedPillarBlock;
import ru.betterend.registry.EndBlocks;
import java.util.Collections;
import java.util.List;
import java.util.Random;
@SuppressWarnings("deprecation")
public class MossyDragonBoneBlock extends BaseRotatedPillarBlock {
public MossyDragonBoneBlock() {
super(FabricBlockSettings.copyOf(Blocks.BONE_BLOCK).hardness(0.5F).randomTicks());
}
@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
ItemStack tool = builder.getParameter(LootContextParams.TOOL);
@ -35,7 +35,7 @@ public class MossyDragonBoneBlock extends BaseRotatedPillarBlock {
}
return Collections.singletonList(new ItemStack(EndBlocks.DRAGON_BONE_BLOCK));
}
@Override
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
if (random.nextInt(16) == 0 && !canSurvive(state, world, pos)) {
@ -45,15 +45,17 @@ public class MossyDragonBoneBlock extends BaseRotatedPillarBlock {
@Override
public boolean canSurvive(BlockState state, LevelReader worldView, BlockPos pos) {
BlockPos blockPos = pos.above();
BlockState blockState = worldView.getBlockState(blockPos);
if (blockState.is(Blocks.SNOW) && blockState.getValue(SnowLayerBlock.LAYERS) == 1) {
return true;
} else if (blockState.getFluidState().getAmount() == 8) {
return false;
} else {
int i = LayerLightEngine.getLightBlockInto(worldView, state, pos, blockState, blockPos, Direction.UP, blockState.getLightBlock(worldView, blockPos));
return i < 5;
}
}
BlockPos blockPos = pos.above();
BlockState blockState = worldView.getBlockState(blockPos);
if (blockState.is(Blocks.SNOW) && blockState.getValue(SnowLayerBlock.LAYERS) == 1) {
return true;
}
else if (blockState.getFluidState().getAmount() == 8) {
return false;
}
else {
int i = LayerLightEngine.getLightBlockInto(worldView, state, pos, blockState, blockPos, Direction.UP, blockState.getLightBlock(worldView, blockPos));
return i < 5;
}
}
}

View file

@ -14,12 +14,12 @@ import ru.betterend.registry.EndBlocks;
public class MossyGlowshroomCapBlock extends BaseBlock {
public static final BooleanProperty TRANSITION = EndBlockProperties.TRANSITION;
public MossyGlowshroomCapBlock() {
super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).sound(SoundType.WOOD));
this.registerDefaultState(this.stateDefinition.any().setValue(TRANSITION, false));
}
public BlockState getStateForPlacement(BlockPlaceContext ctx) {
return this.defaultBlockState().setValue(TRANSITION, EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(ctx.getLevel().getBlockState(ctx.getClickedPos().below())));
}

View file

@ -18,7 +18,7 @@ public class MossyGlowshroomSaplingBlock extends FeatureSaplingBlock {
protected Feature<?> getFeature() {
return EndFeatures.MOSSY_GLOWSHROOM.getFeature();
}
@Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
return world.getBlockState(pos.below()).is(EndBlocks.END_MOSS) || world.getBlockState(pos.below()).is(EndBlocks.END_MYCELIUM);

View file

@ -1,9 +1,5 @@
package ru.betterend.blocks;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
@ -20,11 +16,15 @@ import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import ru.bclib.blocks.BaseBlock;
import java.util.Collections;
import java.util.List;
import java.util.Random;
public class MossyObsidian extends BaseBlock {
public MossyObsidian() {
super(FabricBlockSettings.copyOf(Blocks.OBSIDIAN).hardness(3).randomTicks());
}
@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
ItemStack tool = builder.getParameter(LootContextParams.TOOL);
@ -33,24 +33,26 @@ public class MossyObsidian extends BaseBlock {
}
return Collections.singletonList(new ItemStack(Blocks.OBSIDIAN));
}
@Override
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
if (random.nextInt(16) == 0 && !canSurvive(state, world, pos)) {
world.setBlockAndUpdate(pos, Blocks.OBSIDIAN.defaultBlockState());
}
}
public boolean canSurvive(BlockState state, LevelReader worldView, BlockPos pos) {
BlockPos blockPos = pos.above();
BlockState blockState = worldView.getBlockState(blockPos);
if (blockState.is(Blocks.SNOW) && (Integer)blockState.getValue(SnowLayerBlock.LAYERS) == 1) {
return true;
} else if (blockState.getFluidState().getAmount() == 8) {
return false;
} else {
int i = LayerLightEngine.getLightBlockInto(worldView, state, pos, blockState, blockPos, Direction.UP, blockState.getLightBlock(worldView, blockPos));
return i < 5;
}
}
BlockPos blockPos = pos.above();
BlockState blockState = worldView.getBlockState(blockPos);
if (blockState.is(Blocks.SNOW) && (Integer) blockState.getValue(SnowLayerBlock.LAYERS) == 1) {
return true;
}
else if (blockState.getFluidState().getAmount() == 8) {
return false;
}
else {
int i = LayerLightEngine.getLightBlockInto(worldView, state, pos, blockState, blockPos, Direction.UP, blockState.getLightBlock(worldView, blockPos));
return i < 5;
}
}
}

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks;
import java.util.Random;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.core.BlockPos;
@ -17,6 +15,8 @@ import net.minecraft.world.level.pathfinder.PathComputationType;
import ru.betterend.blocks.basis.EndPlantBlock;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class MurkweedBlock extends EndPlantBlock {
@Override
@Environment(EnvType.CLIENT)
@ -27,19 +27,19 @@ public class MurkweedBlock extends EndPlantBlock {
double v = random.nextDouble() * 0.1;
world.addParticle(ParticleTypes.ENTITY_EFFECT, x, y, z, v, v, v);
}
@Override
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
if (entity instanceof LivingEntity && !((LivingEntity) entity).hasEffect(MobEffects.BLINDNESS)) {
((LivingEntity) entity).addEffect(new MobEffectInstance(MobEffects.BLINDNESS, 50));
}
}
@Override
protected boolean isTerrain(BlockState state) {
return state.is(EndBlocks.SHADOW_GRASS);
}
@Override
public boolean isPathfindable(BlockState state, BlockGetter world, BlockPos pos, PathComputationType type) {
return false;

View file

@ -1,9 +1,6 @@
package ru.betterend.blocks;
import java.util.List;
import com.google.common.collect.Lists;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.core.BlockPos;
import net.minecraft.world.damagesource.DamageSource;
@ -23,6 +20,8 @@ import ru.bclib.util.MHelper;
import ru.betterend.blocks.basis.EndPlantBlock;
import ru.betterend.registry.EndBlocks;
import java.util.List;
public class NeedlegrassBlock extends EndPlantBlock {
@Override
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
@ -30,18 +29,18 @@ public class NeedlegrassBlock extends EndPlantBlock {
entity.hurt(DamageSource.CACTUS, 0.1F);
}
}
@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
ItemStack tool = builder.getParameter(LootContextParams.TOOL);
if (tool != null && tool.getItem().is(FabricToolTags.SHEARS) || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) {
if (tool != null && tool.is(FabricToolTags.SHEARS) || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) {
return Lists.newArrayList(new ItemStack(this));
}
else {
return Lists.newArrayList(new ItemStack(Items.STICK, MHelper.randRange(0, 2, MHelper.RANDOM)));
}
}
@Override
protected boolean isTerrain(BlockState state) {
return state.is(EndBlocks.SHADOW_GRASS);

View file

@ -1,12 +1,7 @@
package ru.betterend.blocks;
import java.util.EnumMap;
import java.util.List;
import java.util.Random;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
@ -48,13 +43,17 @@ import ru.bclib.util.MHelper;
import ru.betterend.blocks.EndBlockProperties.CactusBottom;
import ru.betterend.registry.EndBlocks;
import java.util.EnumMap;
import java.util.List;
import java.util.Random;
@SuppressWarnings("deprecation")
public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWaterloggedBlock, IRenderTyped {
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
public static final EnumProperty<CactusBottom> CACTUS_BOTTOM = EndBlockProperties.CACTUS_BOTTOM;
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
public static final DirectionProperty FACING = BlockStateProperties.FACING;
private static final EnumMap<Direction, VoxelShape> BIG_SHAPES_OPEN = Maps.newEnumMap(Direction.class);
private static final EnumMap<Direction, VoxelShape> MEDIUM_SHAPES_OPEN = Maps.newEnumMap(Direction.class);
private static final EnumMap<Direction, VoxelShape> SMALL_SHAPES_OPEN = Maps.newEnumMap(Direction.class);
@ -62,17 +61,17 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
private static final EnumMap<Axis, VoxelShape> MEDIUM_SHAPES = Maps.newEnumMap(Axis.class);
private static final EnumMap<Axis, VoxelShape> SMALL_SHAPES = Maps.newEnumMap(Axis.class);
private static final int MAX_LENGTH = 12;
public NeonCactusPlantBlock() {
super(FabricBlockSettings.copyOf(Blocks.CACTUS).luminance(15).randomTicks());
registerDefaultState(defaultBlockState().setValue(WATERLOGGED, false).setValue(FACING, Direction.UP).setValue(SHAPE, TripleShape.TOP));
}
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(SHAPE, CACTUS_BOTTOM, WATERLOGGED, FACING);
}
@Override
public BlockState getStateForPlacement(BlockPlaceContext ctx) {
LevelAccessor world = ctx.getLevel();
@ -91,7 +90,7 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
}
return state;
}
@Override
public BlockState rotate(BlockState state, Rotation rotation) {
return BlocksHelper.rotateHorizontal(state, rotation, FACING);
@ -101,12 +100,12 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
public BlockState mirror(BlockState state, Mirror mirror) {
return BlocksHelper.mirrorHorizontal(state, mirror, FACING);
}
@Override
public FluidState getFluidState(BlockState state) {
return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state);
}
@Override
public BlockState updateShape(BlockState state, Direction direction, BlockState newState, LevelAccessor world, BlockPos pos, BlockPos posFrom) {
world.getBlockTicks().scheduleTick(pos, this, 2);
@ -126,19 +125,19 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
}
return state;
}
@Override
public void tick(BlockState blockState, ServerLevel serverLevel, BlockPos blockPos, Random random) {
if (!blockState.canSurvive(serverLevel, blockPos)) {
serverLevel.destroyBlock(blockPos, true, null, 1);
}
}
@Override
public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.CUTOUT;
}
@Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
TripleShape shape = state.getValue(SHAPE);
@ -158,7 +157,7 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
return shape == TripleShape.MIDDLE ? MEDIUM_SHAPES_OPEN.get(dir) : SMALL_SHAPES_OPEN.get(dir);
}
}
@Override
public boolean canSurvive(BlockState state, LevelReader level, BlockPos pos) {
Direction dir = state.getValue(FACING);
@ -166,12 +165,12 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
BlockState support = level.getBlockState(supportPos);
return support.is(this) || support.isFaceSturdy(level, supportPos, dir);
}
@Override
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
if (!this.canSurvive(state, world, pos) || random.nextInt(8) > 0) {
return;
}
}
Direction dir = state.getValue(FACING);
if (!world.isEmptyBlock(pos.relative(dir))) {
return;
@ -201,11 +200,11 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
BlocksHelper.setWithoutUpdate(world, pos.relative(dir), placement);
mutateStem(placement, world, pos, MAX_LENGTH);
}
public void growPlant(WorldGenLevel world, BlockPos pos, Random random) {
growPlant(world, pos, random, MHelper.randRange(MAX_LENGTH >> 1, MAX_LENGTH, random));
}
public void growPlant(WorldGenLevel world, BlockPos pos, Random random, int iterations) {
BlockState state = defaultBlockState();
BlockState downState = world.getBlockState(pos.below());
@ -231,7 +230,7 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
}
}
}
private boolean growIteration(WorldGenLevel world, MutableBlockPos pos, Random random, List<MutableBlockPos> ends, int length) {
BlockState state = world.getBlockState(pos);
if (!state.is(this)) {
@ -265,7 +264,7 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
pos.move(dir);
return true;
}
private Direction getSideDirection(WorldGenLevel world, BlockPos pos, BlockState iterState, Direction dir, Random random) {
MutableBlockPos iterPos = pos.mutable();
Direction startDir = dir;
@ -273,7 +272,7 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
while (iterState.is(this) && startDir.getAxis().isVertical()) {
startDir = iterState.getValue(FACING);
if (lastDir == null) {
for (Direction side: BlocksHelper.HORIZONTAL) {
for (Direction side : BlocksHelper.HORIZONTAL) {
BlockState sideState = world.getBlockState(iterPos.relative(side));
if (sideState.is(this)) {
Direction sideDir = sideState.getValue(FACING);
@ -287,7 +286,7 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
iterPos.move(dir);
iterState = world.getBlockState(iterPos);
}
Direction side = lastDir == null ? BlocksHelper.randomHorizontal(random) : lastDir.getClockWise();
if (side.getOpposite() == startDir) {
side = side.getOpposite();
@ -299,12 +298,12 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
public boolean isPathfindable(BlockState blockState, BlockGetter blockGetter, BlockPos blockPos, PathComputationType pathComputationType) {
return false;
}
@Override
public void entityInside(BlockState blockState, Level level, BlockPos blockPos, Entity entity) {
entity.hurt(DamageSource.CACTUS, 1.0F);
}
private int getLength(BlockState state, ServerLevel world, BlockPos pos, int max) {
int length = 0;
Direction dir = state.getValue(FACING).getOpposite();
@ -319,11 +318,11 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
break;
}
dir = state.getValue(FACING).getOpposite();
length ++;
length++;
}
return length;
}
private int getHorizontal(BlockState state, WorldGenLevel world, BlockPos pos, int max) {
int count = 0;
Direction dir = state.getValue(FACING).getOpposite();
@ -338,11 +337,11 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
if (dir.getStepY() != 0) {
break;
}
count ++;
count++;
}
return count;
}
private void mutateStem(BlockState state, WorldGenLevel world, BlockPos pos, int max) {
Direction dir = state.getValue(FACING).getOpposite();
MutableBlockPos mut = new MutableBlockPos().set(pos);
@ -361,39 +360,39 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
}
}
}
static {
BIG_SHAPES.put(Axis.X, Block.box(0, 2, 2, 16, 14, 14));
BIG_SHAPES.put(Axis.Y, Block.box(2, 0, 2, 14, 16, 14));
BIG_SHAPES.put(Axis.Z, Block.box(2, 2, 0, 14, 14, 16));
MEDIUM_SHAPES.put(Axis.X, Block.box(0, 3, 3, 16, 13, 13));
MEDIUM_SHAPES.put(Axis.Y, Block.box(3, 0, 3, 13, 16, 13));
MEDIUM_SHAPES.put(Axis.Z, Block.box(3, 3, 0, 13, 13, 16));
SMALL_SHAPES.put(Axis.X, Block.box(0, 4, 4, 16, 12, 12));
SMALL_SHAPES.put(Axis.Y, Block.box(4, 0, 4, 12, 16, 12));
SMALL_SHAPES.put(Axis.Z, Block.box(4, 4, 0, 12, 12, 16));
BIG_SHAPES_OPEN.put(Direction.UP, Block.box(2, 0, 2, 14, 14, 14));
BIG_SHAPES_OPEN.put(Direction.DOWN, Block.box(2, 2, 2, 14, 16, 14));
BIG_SHAPES_OPEN.put(Direction.UP, Block.box(2, 0, 2, 14, 14, 14));
BIG_SHAPES_OPEN.put(Direction.DOWN, Block.box(2, 2, 2, 14, 16, 14));
BIG_SHAPES_OPEN.put(Direction.NORTH, Block.box(2, 2, 2, 14, 14, 16));
BIG_SHAPES_OPEN.put(Direction.SOUTH, Block.box(2, 2, 0, 14, 14, 14));
BIG_SHAPES_OPEN.put(Direction.WEST, Block.box(2, 2, 2, 16, 14, 14));
BIG_SHAPES_OPEN.put(Direction.EAST, Block.box(0, 2, 2, 14, 14, 14));
MEDIUM_SHAPES_OPEN.put(Direction.UP, Block.box(3, 0, 3, 13, 13, 13));
MEDIUM_SHAPES_OPEN.put(Direction.DOWN, Block.box(3, 3, 3, 13, 16, 13));
BIG_SHAPES_OPEN.put(Direction.WEST, Block.box(2, 2, 2, 16, 14, 14));
BIG_SHAPES_OPEN.put(Direction.EAST, Block.box(0, 2, 2, 14, 14, 14));
MEDIUM_SHAPES_OPEN.put(Direction.UP, Block.box(3, 0, 3, 13, 13, 13));
MEDIUM_SHAPES_OPEN.put(Direction.DOWN, Block.box(3, 3, 3, 13, 16, 13));
MEDIUM_SHAPES_OPEN.put(Direction.NORTH, Block.box(3, 3, 3, 13, 13, 16));
MEDIUM_SHAPES_OPEN.put(Direction.SOUTH, Block.box(3, 3, 0, 13, 13, 13));
MEDIUM_SHAPES_OPEN.put(Direction.WEST, Block.box(3, 3, 3, 16, 13, 13));
MEDIUM_SHAPES_OPEN.put(Direction.EAST, Block.box(0, 3, 3, 13, 13, 13));
SMALL_SHAPES_OPEN.put(Direction.UP, Block.box(4, 0, 4, 12, 12, 12));
SMALL_SHAPES_OPEN.put(Direction.DOWN, Block.box(4, 4, 4, 12, 16, 12));
MEDIUM_SHAPES_OPEN.put(Direction.WEST, Block.box(3, 3, 3, 16, 13, 13));
MEDIUM_SHAPES_OPEN.put(Direction.EAST, Block.box(0, 3, 3, 13, 13, 13));
SMALL_SHAPES_OPEN.put(Direction.UP, Block.box(4, 0, 4, 12, 12, 12));
SMALL_SHAPES_OPEN.put(Direction.DOWN, Block.box(4, 4, 4, 12, 16, 12));
SMALL_SHAPES_OPEN.put(Direction.NORTH, Block.box(4, 4, 4, 12, 12, 16));
SMALL_SHAPES_OPEN.put(Direction.SOUTH, Block.box(4, 4, 0, 12, 12, 12));
SMALL_SHAPES_OPEN.put(Direction.WEST, Block.box(4, 4, 4, 16, 12, 12));
SMALL_SHAPES_OPEN.put(Direction.EAST, Block.box(0, 4, 4, 12, 12, 12));
SMALL_SHAPES_OPEN.put(Direction.WEST, Block.box(4, 4, 4, 16, 12, 12));
SMALL_SHAPES_OPEN.put(Direction.EAST, Block.box(0, 4, 4, 12, 12, 12));
}
}

View file

@ -1,13 +1,13 @@
package ru.betterend.blocks;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block;
import ru.betterend.blocks.basis.PedestalBlock;
import java.util.HashMap;
import java.util.Map;
public class PedestalVanilla extends PedestalBlock {
public PedestalVanilla(Block parent) {
@ -20,8 +20,9 @@ public class PedestalVanilla extends PedestalBlock {
String name = blockId.getPath().replace("_block", "");
return new HashMap<String, String>() {
private static final long serialVersionUID = 1L;
{
put("%mod%", blockId.getNamespace() );
put("%mod%", blockId.getNamespace());
put("%top%", "polished_" + name);
put("%base%", "polished_" + name);
put("%pillar%", name + "_pillar");

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks;
import java.util.Random;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
@ -19,9 +17,11 @@ import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import ru.betterend.blocks.basis.EndUnderwaterPlantBlock;
import java.util.Random;
public class PondAnemoneBlock extends EndUnderwaterPlantBlock {
private static final VoxelShape SHAPE = Block.box(2, 0, 2, 14, 14, 14);
public PondAnemoneBlock() {
super(FabricBlockSettings.of(Material.WATER_PLANT)
.breakByTool(FabricToolTags.SHEARS)
@ -30,7 +30,7 @@ public class PondAnemoneBlock extends EndUnderwaterPlantBlock {
.sound(SoundType.CORAL_BLOCK)
.noCollission());
}
@Override
public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.NONE;
@ -43,12 +43,12 @@ public class PondAnemoneBlock extends EndUnderwaterPlantBlock {
double z = pos.getZ() + random.nextDouble();
world.addParticle(ParticleTypes.BUBBLE, x, y, z, 0.0D, 0.0D, 0.0D);
}
@Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return SHAPE;
}
@Override
public boolean isValidBonemealTarget(BlockGetter world, BlockPos pos, BlockState state, boolean isClient) {
return false;

View file

@ -17,7 +17,7 @@ public class PythadendronSaplingBlock extends FeatureSaplingBlock {
protected Feature<?> getFeature() {
return EndFeatures.PYTHADENDRON_TREE.getFeature();
}
@Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
return world.getBlockState(pos.below()).is(EndBlocks.CHORUS_NYLIUM);

View file

@ -1,11 +1,6 @@
package ru.betterend.blocks;
import java.util.List;
import org.jetbrains.annotations.Nullable;
import com.google.common.collect.Lists;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.client.color.block.BlockColor;
import net.minecraft.client.color.item.ItemColor;
@ -35,6 +30,7 @@ import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.jetbrains.annotations.Nullable;
import ru.bclib.blocks.BaseBlock;
import ru.bclib.blocks.BlockProperties;
import ru.bclib.blocks.BlockProperties.TripleShape;
@ -47,28 +43,30 @@ import ru.betterend.particle.InfusionParticleType;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndItems;
import java.util.List;
public class RespawnObeliskBlock extends BaseBlock implements IColorProvider, IRenderTyped {
private static final VoxelShape VOXEL_SHAPE_BOTTOM = Block.box(1, 0, 1, 15, 16, 15);
private static final VoxelShape VOXEL_SHAPE_MIDDLE_TOP = Block.box(2, 0, 2, 14, 16, 14);
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
public RespawnObeliskBlock() {
super(FabricBlockSettings.copyOf(Blocks.END_STONE).luminance((state) -> {
return (state.getValue(SHAPE) == TripleShape.BOTTOM) ? 0 : 15;
}));
}
@Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return (state.getValue(SHAPE) == TripleShape.BOTTOM) ? VOXEL_SHAPE_BOTTOM : VOXEL_SHAPE_MIDDLE_TOP;
}
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(SHAPE);
}
@Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
for (int i = 0; i < 3; i++) {
@ -78,7 +76,7 @@ public class RespawnObeliskBlock extends BaseBlock implements IColorProvider, IR
}
return true;
}
@Override
public void setPlacedBy(Level world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack itemStack) {
state = this.defaultBlockState();
@ -86,7 +84,7 @@ public class RespawnObeliskBlock extends BaseBlock implements IColorProvider, IR
BlocksHelper.setWithUpdate(world, pos.above(), state.setValue(SHAPE, TripleShape.MIDDLE));
BlocksHelper.setWithUpdate(world, pos.above(2), state.setValue(SHAPE, TripleShape.TOP));
}
@Override
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
TripleShape shape = state.getValue(SHAPE);
@ -115,7 +113,7 @@ public class RespawnObeliskBlock extends BaseBlock implements IColorProvider, IR
}
}
}
@Override
public void playerWillDestroy(Level world, BlockPos pos, BlockState state, Player player) {
if (player.isCreative()) {
@ -129,7 +127,7 @@ public class RespawnObeliskBlock extends BaseBlock implements IColorProvider, IR
}
super.playerWillDestroy(world, pos, state, player);
}
@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
if (state.getValue(SHAPE) == TripleShape.BOTTOM) {
@ -144,12 +142,12 @@ public class RespawnObeliskBlock extends BaseBlock implements IColorProvider, IR
public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.TRANSLUCENT;
}
@Override
public BlockColor getProvider() {
return ((IColorProvider) EndBlocks.AURORA_CRYSTAL).getProvider();
}
@Override
public ItemColor getItemProvider() {
return (stack, tintIndex) -> {
@ -193,10 +191,10 @@ public class RespawnObeliskBlock extends BaseBlock implements IColorProvider, IR
((ServerLevel) world).sendParticles(particle, px, py1, pz, 20, 0.14, 0.5, 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.RESPAWN_ANCHOR_SET_SPAWN, SoundSource.BLOCKS, 1F, 1F);
if (!player.isCreative()) {
itemStack.shrink(6);
}
world.playSound(null, px, py, py, SoundEvents.RESPAWN_ANCHOR_SET_SPAWN, SoundSource.BLOCKS, 1F, 1F);
if (!player.isCreative()) {
itemStack.shrink(6);
}
}
return player.isCreative() ? InteractionResult.PASS : InteractionResult.sidedSuccess(world.isClientSide);
}

View file

@ -1,9 +1,6 @@
package ru.betterend.blocks;
import java.util.List;
import com.google.common.collect.Lists;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Explosion;
@ -18,30 +15,32 @@ import ru.bclib.blocks.BlockProperties;
import ru.bclib.util.BlocksHelper;
import ru.betterend.registry.EndBlocks;
import java.util.List;
public class RunedFlavolite extends BaseBlock {
public static final BooleanProperty ACTIVATED = BlockProperties.ACTIVE;
public RunedFlavolite(boolean unbreakable) {
super(FabricBlockSettings.copyOf(EndBlocks.FLAVOLITE.polished)
.strength(
unbreakable ? -1 : 1,
unbreakable ? Blocks.BEDROCK.getExplosionResistance() : Blocks.OBSIDIAN.getExplosionResistance()
).luminance(state -> {
return state.getValue(ACTIVATED) ? 8 : 0;
}));
.strength(
unbreakable ? -1 : 1,
unbreakable ? Blocks.BEDROCK.getExplosionResistance() : Blocks.OBSIDIAN.getExplosionResistance()
).luminance(state -> {
return state.getValue(ACTIVATED) ? 8 : 0;
}));
this.registerDefaultState(stateDefinition.any().setValue(ACTIVATED, false));
}
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(ACTIVATED);
}
@Override
public boolean dropFromExplosion(Explosion explosion) {
return !BlocksHelper.isInvulnerableUnsafe(this.defaultBlockState());
}
@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
if (BlocksHelper.isInvulnerableUnsafe(this.defaultBlockState())) {

View file

@ -12,11 +12,11 @@ import ru.betterend.registry.EndItems;
public class ShadowBerryBlock extends BaseCropBlock {
private static final VoxelShape SHAPE = Block.box(1, 0, 1, 15, 8, 15);
public ShadowBerryBlock() {
super(EndItems.SHADOW_BERRY_RAW, EndBlocks.SHADOW_GRASS);
}
@Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return SHAPE;

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks;
import java.util.Random;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.core.BlockPos;
@ -11,6 +9,8 @@ import net.minecraft.world.level.material.MaterialColor;
import ru.betterend.blocks.basis.EndTerrainBlock;
import ru.betterend.registry.EndParticles;
import java.util.Random;
public class ShadowGrassBlock extends EndTerrainBlock {
public ShadowGrassBlock() {
super(MaterialColor.COLOR_BLACK);

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks;
import java.util.Random;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.core.BlockPos;
@ -36,26 +34,28 @@ import ru.betterend.entity.SilkMothEntity;
import ru.betterend.registry.EndEntities;
import ru.betterend.registry.EndItems;
import java.util.Random;
public class SilkMothHiveBlock extends BaseBlock {
public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING;
public static final IntegerProperty FULLNESS = EndBlockProperties.FULLNESS;
public SilkMothHiveBlock() {
super(FabricBlockSettings.of(Material.WOOD).breakByHand(true).hardness(0.5F).resistance(0.1F).sound(SoundType.WOOL).noOcclusion().randomTicks());
this.registerDefaultState(defaultBlockState().setValue(FULLNESS, 0));
}
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(FACING, FULLNESS);
}
@Override
public BlockState getStateForPlacement(BlockPlaceContext ctx) {
Direction dir = ctx.getHorizontalDirection().getOpposite();
return this.defaultBlockState().setValue(FACING, dir);
}
@Override
public BlockState rotate(BlockState state, Rotation rotation) {
return BlocksHelper.rotateHorizontal(state, rotation, FACING);
@ -65,7 +65,7 @@ public class SilkMothHiveBlock extends BaseBlock {
public BlockState mirror(BlockState state, Mirror mirror) {
return BlocksHelper.mirrorHorizontal(state, mirror, FACING);
}
@Override
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
Direction dir = state.getValue(FACING);
@ -73,7 +73,9 @@ public class SilkMothHiveBlock extends BaseBlock {
if (!world.getBlockState(spawn).isAir()) {
return;
}
int count = world.getEntities(EndEntities.SILK_MOTH, new AABB(pos).inflate(16), (entity) -> { return true; }).size();
int count = world.getEntities(EndEntities.SILK_MOTH, new AABB(pos).inflate(16), (entity) -> {
return true;
}).size();
if (count > 6) {
return;
}
@ -84,12 +86,12 @@ public class SilkMothHiveBlock extends BaseBlock {
world.addFreshEntity(moth);
world.playSound(null, pos, SoundEvents.BEEHIVE_EXIT, SoundSource.BLOCKS, 1, 1);
}
@Override
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
if (hand == InteractionHand.MAIN_HAND) {
ItemStack stack = player.getMainHandItem();
if (stack.getItem().is(FabricToolTags.SHEARS) && state.getValue(FULLNESS) == 3) {
if (stack.is(FabricToolTags.SHEARS) && state.getValue(FULLNESS) == 3) {
BlocksHelper.setWithUpdate(world, pos, state.setValue(FULLNESS, 0));
Direction dir = state.getValue(FACING);
double px = pos.getX() + dir.getStepX() + 0.5;

View file

@ -1,9 +1,5 @@
package ru.betterend.blocks;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.core.BlockPos;
@ -48,23 +44,27 @@ import ru.betterend.entity.SilkMothEntity;
import ru.betterend.registry.EndEntities;
import ru.betterend.registry.EndItems;
import java.util.Collections;
import java.util.List;
import java.util.Random;
public class SilkMothNestBlock extends BaseBlock implements IRenderTyped {
public static final BooleanProperty ACTIVE = EndBlockProperties.ACTIVE;
public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING;
public static final IntegerProperty FULLNESS = EndBlockProperties.FULLNESS;
private static final VoxelShape TOP = box(6, 0, 6, 10, 16, 10);
private static final VoxelShape BOTTOM = box(0, 0, 0, 16, 16, 16);
public SilkMothNestBlock() {
super(FabricBlockSettings.of(Material.WOOL).hardness(0.5F).resistance(0.1F).sound(SoundType.WOOL).noOcclusion().randomTicks());
this.registerDefaultState(defaultBlockState().setValue(ACTIVE, true).setValue(FULLNESS, 0));
}
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(ACTIVE, FACING, FULLNESS);
}
@Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return state.getValue(ACTIVE) ? BOTTOM : TOP;
@ -74,13 +74,13 @@ public class SilkMothNestBlock extends BaseBlock implements IRenderTyped {
public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.CUTOUT;
}
@Override
public BlockState getStateForPlacement(BlockPlaceContext ctx) {
Direction dir = ctx.getHorizontalDirection().getOpposite();
return this.defaultBlockState().setValue(FACING, dir);
}
@Override
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
if (!state.getValue(ACTIVE)) {
@ -93,7 +93,7 @@ public class SilkMothNestBlock extends BaseBlock implements IRenderTyped {
}
return state;
}
@Override
public BlockState rotate(BlockState state, Rotation rotation) {
return BlocksHelper.rotateHorizontal(state, rotation, FACING);
@ -103,12 +103,12 @@ public class SilkMothNestBlock extends BaseBlock implements IRenderTyped {
public BlockState mirror(BlockState state, Mirror mirror) {
return BlocksHelper.mirrorHorizontal(state, mirror, FACING);
}
@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return state.getValue(ACTIVE) ? Collections.singletonList(new ItemStack(this)) : Collections.emptyList();
}
@Override
public void playerWillDestroy(Level world, BlockPos pos, BlockState state, Player player) {
if (!state.getValue(ACTIVE) && player.isCreative()) {
@ -120,7 +120,7 @@ public class SilkMothNestBlock extends BaseBlock implements IRenderTyped {
}
super.playerWillDestroy(world, pos, state, player);
}
@Override
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
if (!state.getValue(ACTIVE)) {
@ -134,7 +134,9 @@ public class SilkMothNestBlock extends BaseBlock implements IRenderTyped {
if (!world.getBlockState(spawn).isAir()) {
return;
}
int count = world.getEntities(EndEntities.SILK_MOTH, new AABB(pos).inflate(16), (entity) -> { return true; }).size();
int count = world.getEntities(EndEntities.SILK_MOTH, new AABB(pos).inflate(16), (entity) -> {
return true;
}).size();
if (count > 6) {
return;
}
@ -145,12 +147,12 @@ public class SilkMothNestBlock extends BaseBlock implements IRenderTyped {
world.addFreshEntity(moth);
world.playSound(null, pos, SoundEvents.BEEHIVE_EXIT, SoundSource.BLOCKS, 1, 1);
}
@Override
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
if (hand == InteractionHand.MAIN_HAND) {
ItemStack stack = player.getMainHandItem();
if (stack.getItem().is(FabricToolTags.SHEARS) && state.getValue(ACTIVE) && state.getValue(FULLNESS) == 3) {
if (stack.is(FabricToolTags.SHEARS) && state.getValue(ACTIVE) && state.getValue(FULLNESS) == 3) {
BlocksHelper.setWithUpdate(world, pos, state.setValue(FULLNESS, 0));
Direction dir = state.getValue(FACING);
double px = pos.getX() + dir.getStepX() + 0.5;

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.BlockGetter;
@ -9,6 +7,7 @@ import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
@ -17,19 +16,21 @@ import ru.betterend.blocks.basis.EndPlantBlock;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndFeatures;
import java.util.Random;
public class SmallAmaranitaBlock extends EndPlantBlock {
private static final VoxelShape SHAPE = Block.box(4, 0, 4, 12, 10, 12);
@Override
protected boolean isTerrain(BlockState state) {
return state.is(EndBlocks.SANGNUM) || state.is(EndBlocks.MOSSY_OBSIDIAN) || state.is(EndBlocks.MOSSY_DRAGON_BONE);
}
@Override
public void performBonemeal(ServerLevel world, Random random, BlockPos pos, BlockState state) {
BlockPos bigPos = growBig(world, pos);
if (bigPos != null) {
if (EndFeatures.GIGANTIC_AMARANITA.getFeature().place(world, null, random, bigPos, null)) {
if (EndFeatures.GIGANTIC_AMARANITA.getFeature().place(new FeaturePlaceContext<>(world, null, random, bigPos, null))) {
replaceMushroom(world, bigPos);
replaceMushroom(world, bigPos.south());
replaceMushroom(world, bigPos.east());
@ -37,15 +38,15 @@ public class SmallAmaranitaBlock extends EndPlantBlock {
}
return;
}
EndFeatures.LARGE_AMARANITA.getFeature().place(world, null, random, pos, null);
EndFeatures.LARGE_AMARANITA.getFeature().place(new FeaturePlaceContext<>(world, null, random, pos, null));
}
@Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
Vec3 vec3d = state.getOffset(view, pos);
return SHAPE.move(vec3d.x, vec3d.y, vec3d.z);
}
private BlockPos growBig(ServerLevel world, BlockPos pos) {
for (int x = -1; x < 2; x++) {
for (int z = -1; z < 2; z++) {
@ -57,20 +58,20 @@ public class SmallAmaranitaBlock extends EndPlantBlock {
}
return null;
}
private boolean checkFrame(ServerLevel world, BlockPos pos) {
return world.getBlockState(pos).is(this) &&
world.getBlockState(pos.south()).is(this) &&
world.getBlockState(pos.east()).is(this) &&
world.getBlockState(pos.south().east()).is(this);
}
private void replaceMushroom(ServerLevel world, BlockPos pos) {
if (world.getBlockState(pos).is(this)) {
BlocksHelper.setWithUpdate(world, pos, Blocks.AIR);
}
}
@Override
public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) {
return random.nextInt(8) == 0;

View file

@ -1,12 +1,7 @@
package ru.betterend.blocks;
import java.util.EnumMap;
import java.util.List;
import java.util.Random;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.core.BlockPos;
@ -23,6 +18,7 @@ import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.BonemealableBlock;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
@ -36,9 +32,13 @@ import ru.bclib.interfaces.IRenderTyped;
import ru.bclib.util.BlocksHelper;
import ru.betterend.registry.EndFeatures;
import java.util.EnumMap;
import java.util.List;
import java.util.Random;
public class SmallJellyshroomBlock extends BaseAttachedBlock implements IRenderTyped, BonemealableBlock {
private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class);
public SmallJellyshroomBlock() {
super(FabricBlockSettings.of(Material.PLANT)
.breakByTool(FabricToolTags.SHEARS)
@ -52,18 +52,18 @@ public class SmallJellyshroomBlock extends BaseAttachedBlock implements IRenderT
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return BOUNDING_SHAPES.get(state.getValue(FACING));
}
@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
ItemStack tool = builder.getParameter(LootContextParams.TOOL);
if (tool != null && tool.getItem().is(FabricToolTags.SHEARS) || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) {
if (tool != null && tool.is(FabricToolTags.SHEARS) || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) {
return Lists.newArrayList(new ItemStack(this));
}
else {
return Lists.newArrayList();
}
}
@Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
Direction direction = state.getValue(FACING);
@ -71,12 +71,12 @@ public class SmallJellyshroomBlock extends BaseAttachedBlock implements IRenderT
BlockState support = world.getBlockState(blockPos);
return canSupportCenter(world, blockPos, direction) && support.canOcclude() && support.getLightEmission() == 0;
}
@Override
public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.CUTOUT;
}
static {
BOUNDING_SHAPES.put(Direction.UP, Block.box(3, 0, 3, 13, 16, 13));
BOUNDING_SHAPES.put(Direction.DOWN, Block.box(3, 0, 3, 13, 16, 13));
@ -99,6 +99,6 @@ public class SmallJellyshroomBlock extends BaseAttachedBlock implements IRenderT
@Override
public void performBonemeal(ServerLevel world, Random random, BlockPos pos, BlockState state) {
BlocksHelper.setWithUpdate(world, pos, Blocks.AIR);
EndFeatures.JELLYSHROOM.getFeature().place(world, null, random, pos, null);
EndFeatures.JELLYSHROOM.getFeature().place(new FeaturePlaceContext<>(world, null, random, pos, null));
}
}

View file

@ -1,9 +1,6 @@
package ru.betterend.blocks;
import java.util.EnumMap;
import com.google.common.collect.Maps;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.core.BlockPos;
@ -32,11 +29,13 @@ import ru.bclib.blocks.BaseAttachedBlock;
import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.IRenderTyped;
import java.util.EnumMap;
@SuppressWarnings("deprecation")
public class SmaragdantCrystalShardBlock extends BaseAttachedBlock implements IRenderTyped, SimpleWaterloggedBlock, LiquidBlockContainer {
private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class);
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
public SmaragdantCrystalShardBlock() {
super(FabricBlockSettings.of(Material.STONE)
.materialColor(MaterialColor.COLOR_GREEN)
@ -46,18 +45,18 @@ public class SmaragdantCrystalShardBlock extends BaseAttachedBlock implements IR
.requiresCorrectToolForDrops()
.noCollission());
}
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
super.createBlockStateDefinition(stateManager);
stateManager.add(WATERLOGGED);
}
@Override
public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.CUTOUT;
}
@Override
public boolean canPlaceLiquid(BlockGetter world, BlockPos pos, BlockState state, Fluid fluid) {
return !state.getValue(WATERLOGGED);
@ -67,7 +66,7 @@ public class SmaragdantCrystalShardBlock extends BaseAttachedBlock implements IR
public boolean placeLiquid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluidState) {
return !state.getValue(WATERLOGGED);
}
@Override
public BlockState getStateForPlacement(BlockPlaceContext ctx) {
BlockState state = super.getStateForPlacement(ctx);
@ -79,24 +78,24 @@ public class SmaragdantCrystalShardBlock extends BaseAttachedBlock implements IR
}
return null;
}
@Override
public FluidState getFluidState(BlockState state) {
return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : Fluids.EMPTY.defaultFluidState();
}
@Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return BOUNDING_SHAPES.get(state.getValue(FACING));
}
@Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
Direction direction = state.getValue(FACING);
BlockPos blockPos = pos.relative(direction.getOpposite());
return world.getBlockState(blockPos).isFaceSturdy(world, blockPos, direction);
}
static {
BOUNDING_SHAPES.put(Direction.UP, Shapes.box(0.125, 0.0, 0.125, 0.875F, 0.875F, 0.875F));
BOUNDING_SHAPES.put(Direction.DOWN, Shapes.box(0.125, 0.125, 0.125, 0.875F, 1.0, 0.875F));

View file

@ -1,12 +1,7 @@
package ru.betterend.blocks;
import java.util.Collections;
import java.util.EnumMap;
import java.util.List;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.core.BlockPos;
@ -41,12 +36,16 @@ import ru.bclib.util.MHelper;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndItems;
import java.util.Collections;
import java.util.EnumMap;
import java.util.List;
@SuppressWarnings("deprecation")
public class SulphurCrystalBlock extends BaseAttachedBlock implements IRenderTyped, SimpleWaterloggedBlock, LiquidBlockContainer {
private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class);
public static final IntegerProperty AGE = IntegerProperty.create("age", 0, 2);
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
public SulphurCrystalBlock() {
super(FabricBlockSettings.of(Material.STONE)
.materialColor(MaterialColor.COLOR_YELLOW)
@ -55,23 +54,23 @@ public class SulphurCrystalBlock extends BaseAttachedBlock implements IRenderTyp
.requiresCorrectToolForDrops()
.noCollission());
}
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
super.createBlockStateDefinition(stateManager);
stateManager.add(AGE, WATERLOGGED);
}
@Override
public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.CUTOUT;
}
@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return state.getValue(AGE) < 2 ? Collections.emptyList() : Lists.newArrayList(new ItemStack(EndItems.CRYSTALLINE_SULPHUR, MHelper.randRange(1, 3, MHelper.RANDOM)));
}
@Override
public boolean canPlaceLiquid(BlockGetter world, BlockPos pos, BlockState state, Fluid fluid) {
return !state.getValue(WATERLOGGED);
@ -81,7 +80,7 @@ public class SulphurCrystalBlock extends BaseAttachedBlock implements IRenderTyp
public boolean placeLiquid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluidState) {
return !state.getValue(WATERLOGGED);
}
@Override
public BlockState getStateForPlacement(BlockPlaceContext ctx) {
BlockState state = super.getStateForPlacement(ctx);
@ -93,24 +92,24 @@ public class SulphurCrystalBlock extends BaseAttachedBlock implements IRenderTyp
}
return null;
}
@Override
public FluidState getFluidState(BlockState state) {
return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : Fluids.EMPTY.defaultFluidState();
}
@Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return BOUNDING_SHAPES.get(state.getValue(FACING));
}
@Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
Direction direction = state.getValue(FACING);
BlockPos blockPos = pos.relative(direction.getOpposite());
return world.getBlockState(blockPos).is(EndBlocks.BRIMSTONE);
}
static {
BOUNDING_SHAPES.put(Direction.UP, Shapes.box(0.125, 0.0, 0.125, 0.875F, 0.5, 0.875F));
BOUNDING_SHAPES.put(Direction.DOWN, Shapes.box(0.125, 0.5, 0.125, 0.875F, 1.0, 0.875F));

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks;
import java.util.Random;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.color.block.BlockColor;
@ -18,9 +16,11 @@ import ru.bclib.util.ColorUtil;
import ru.bclib.util.MHelper;
import ru.betterend.registry.EndParticles;
import java.util.Random;
public class TenaneaFlowersBlock extends BaseVineBlock implements IColorProvider {
public static final Vec3i[] COLORS;
public TenaneaFlowersBlock() {
super(15);
}
@ -30,22 +30,23 @@ public class TenaneaFlowersBlock extends BaseVineBlock implements IColorProvider
return (state, world, pos, tintIndex) -> {
if (pos == null) {
pos = BlockPos.ZERO;
};
}
;
long i = (MHelper.getRandom(pos.getX(), pos.getZ()) & 63) + pos.getY();
double delta = i * 0.1;
int index = MHelper.floor(delta);
int index2 = (index + 1) & 3;
delta -= index;
index &= 3;
Vec3i color1 = COLORS[index];
Vec3i color2 = COLORS[index2];
int r = MHelper.floor(Mth.lerp(delta, color1.getX(), color2.getX()));
int g = MHelper.floor(Mth.lerp(delta, color1.getY(), color2.getY()));
int b = MHelper.floor(Mth.lerp(delta, color1.getZ(), color2.getZ()));
float[] hsb = ColorUtil.RGBtoHSB(r, g, b, new float[3]);
return ColorUtil.HSBtoRGB(hsb[0], MHelper.max(0.5F, hsb[1]), hsb[2]);
};
}
@ -54,12 +55,12 @@ public class TenaneaFlowersBlock extends BaseVineBlock implements IColorProvider
public ItemColor getItemProvider() {
return (stack, tintIndex) -> ColorUtil.color(255, 255, 255);
}
@Override
public boolean isValidBonemealTarget(BlockGetter world, BlockPos pos, BlockState state, boolean isClient) {
return false;
}
@Environment(EnvType.CLIENT)
public void animateTick(BlockState state, Level world, BlockPos pos, Random random) {
super.animateTick(state, world, pos, random);
@ -70,13 +71,13 @@ public class TenaneaFlowersBlock extends BaseVineBlock implements IColorProvider
world.addParticle(EndParticles.TENANEA_PETAL, x, y, z, 0, 0, 0);
}
}
static {
COLORS = new Vec3i[] {
new Vec3i(250, 111, 222),
new Vec3i(167, 89, 255),
new Vec3i(120, 207, 239),
new Vec3i(255, 87, 182)
COLORS = new Vec3i[]{
new Vec3i(250, 111, 222),
new Vec3i(167, 89, 255),
new Vec3i(120, 207, 239),
new Vec3i(255, 87, 182)
};
}
}

View file

@ -17,7 +17,7 @@ public class TenaneaSaplingBlock extends FeatureSaplingBlock {
protected Feature<?> getFeature() {
return EndFeatures.TENANEA.getFeature();
}
@Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
return world.getBlockState(pos.below()).is(EndBlocks.PINK_MOSS);

View file

@ -6,15 +6,15 @@ import ru.betterend.blocks.basis.EndPlantBlock;
public class TerrainPlantBlock extends EndPlantBlock {
private final Block[] ground;
public TerrainPlantBlock(Block... ground) {
super(true);
this.ground = ground;
}
@Override
protected boolean isTerrain(BlockState state) {
for (Block block: ground) {
for (Block block : ground) {
if (state.is(block)) {
return true;
}

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks;
import java.util.Random;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.core.BlockPos;
@ -14,34 +12,36 @@ import ru.bclib.util.BlocksHelper;
import ru.betterend.blocks.basis.EndPlantBlock;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class TwistedUmbrellaMossBlock extends EndPlantBlock {
public TwistedUmbrellaMossBlock() {
super(11);
}
@Override
protected boolean isTerrain(BlockState state) {
return state.is(EndBlocks.END_MOSS) || state.is(EndBlocks.END_MYCELIUM) || state.is(EndBlocks.JUNGLE_MOSS);
}
@Environment(EnvType.CLIENT)
public boolean hasEmissiveLighting(BlockGetter world, BlockPos pos) {
return true;
}
@Environment(EnvType.CLIENT)
public float getAmbientOcclusionLightLevel(BlockGetter world, BlockPos pos) {
return 1F;
}
@Override
@Environment(EnvType.CLIENT)
public boolean hasEmissiveLighting(BlockGetter world, BlockPos pos) {
return true;
}
@Environment(EnvType.CLIENT)
public float getAmbientOcclusionLightLevel(BlockGetter world, BlockPos pos) {
return 1F;
}
@Override
public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) {
return world.isEmptyBlock(pos.above());
}
@Override
@Override
public void performBonemeal(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.defaultBlockState().setValue(BaseDoublePlantBlock.ROTATION, rot);
BlocksHelper.setWithoutUpdate(world, pos, bs);
BlocksHelper.setWithoutUpdate(world, pos.above(), bs.setValue(BaseDoublePlantBlock.TOP, true));

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.item.ItemEntity;
@ -10,17 +8,19 @@ import net.minecraft.world.level.block.state.BlockState;
import ru.bclib.blocks.BaseDoublePlantBlock;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class TwistedUmbrellaMossTallBlock extends BaseDoublePlantBlock {
public TwistedUmbrellaMossTallBlock() {
super(12);
}
@Override
public void performBonemeal(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));
world.addFreshEntity(item);
}
@Override
protected boolean isTerrain(BlockState state) {
return state.is(EndBlocks.END_MOSS) || state.is(EndBlocks.END_MYCELIUM) || state.is(EndBlocks.JUNGLE_MOSS);

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks;
import java.util.Random;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.core.BlockPos;
@ -14,34 +12,36 @@ import ru.bclib.util.BlocksHelper;
import ru.betterend.blocks.basis.EndPlantBlock;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class UmbrellaMossBlock extends EndPlantBlock {
public UmbrellaMossBlock() {
super(11);
}
@Override
protected boolean isTerrain(BlockState state) {
return state.is(EndBlocks.END_MOSS) || state.is(EndBlocks.END_MYCELIUM) || state.is(EndBlocks.JUNGLE_MOSS);
}
@Environment(EnvType.CLIENT)
public boolean hasEmissiveLighting(BlockGetter world, BlockPos pos) {
return true;
}
@Environment(EnvType.CLIENT)
public float getAmbientOcclusionLightLevel(BlockGetter world, BlockPos pos) {
return 1F;
}
@Override
@Environment(EnvType.CLIENT)
public boolean hasEmissiveLighting(BlockGetter world, BlockPos pos) {
return true;
}
@Environment(EnvType.CLIENT)
public float getAmbientOcclusionLightLevel(BlockGetter world, BlockPos pos) {
return 1F;
}
@Override
public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) {
return world.isEmptyBlock(pos.above());
}
@Override
@Override
public void performBonemeal(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.defaultBlockState().setValue(BaseDoublePlantBlock.ROTATION, rot);
BlocksHelper.setWithoutUpdate(world, pos, bs);
BlocksHelper.setWithoutUpdate(world, pos.above(), bs.setValue(BaseDoublePlantBlock.TOP, true));

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.item.ItemEntity;
@ -10,17 +8,19 @@ import net.minecraft.world.level.block.state.BlockState;
import ru.bclib.blocks.BaseDoublePlantBlock;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class UmbrellaMossTallBlock extends BaseDoublePlantBlock {
public UmbrellaMossTallBlock() {
super(12);
}
@Override
public void performBonemeal(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.UMBRELLA_MOSS));
world.addFreshEntity(item);
}
@Override
protected boolean isTerrain(BlockState state) {
return state.is(EndBlocks.END_MOSS) || state.is(EndBlocks.END_MYCELIUM) || state.is(EndBlocks.JUNGLE_MOSS);

View file

@ -25,19 +25,19 @@ import ru.betterend.registry.EndItems;
public class UmbrellaTreeClusterBlock extends BaseBlock {
public static final BooleanProperty NATURAL = BlockProperties.NATURAL;
public UmbrellaTreeClusterBlock() {
super(FabricBlockSettings.copyOf(Blocks.NETHER_WART_BLOCK)
.materialColor(MaterialColor.COLOR_PURPLE)
.luminance(15));
registerDefaultState(stateDefinition.any().setValue(NATURAL, false));
}
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(NATURAL);
}
@Override
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
ItemStack stack = player.getMainHandItem();

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks;
import java.util.Random;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
@ -15,21 +13,23 @@ import ru.bclib.blocks.BaseBlock;
import ru.bclib.util.BlocksHelper;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class UmbrellaTreeClusterEmptyBlock extends BaseBlock {
public static final BooleanProperty NATURAL = EndBlockProperties.NATURAL;
public UmbrellaTreeClusterEmptyBlock() {
super(FabricBlockSettings.copyOf(Blocks.NETHER_WART_BLOCK)
.materialColor(MaterialColor.COLOR_PURPLE)
.randomTicks());
registerDefaultState(stateDefinition.any().setValue(NATURAL, false));
}
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(NATURAL);
}
@Override
public void tick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
if (state.getValue(NATURAL) && random.nextInt(16) == 0) {

View file

@ -1,10 +1,6 @@
package ru.betterend.blocks;
import java.util.Collections;
import java.util.List;
import com.google.common.collect.Lists;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
@ -29,14 +25,17 @@ import ru.bclib.util.MHelper;
import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndBlocks;
import java.util.Collections;
import java.util.List;
public class UmbrellaTreeMembraneBlock extends SlimeBlock implements IRenderTyped, BlockModelProvider {
public static final IntegerProperty COLOR = EndBlockProperties.COLOR;
private static final OpenSimplexNoise NOISE = new OpenSimplexNoise(0);
public UmbrellaTreeMembraneBlock() {
super(FabricBlockSettings.copyOf(Blocks.SLIME_BLOCK));
}
@Override
public BlockState getStateForPlacement(BlockPlaceContext ctx) {
double px = ctx.getClickedPos().getX() * 0.1;
@ -44,17 +43,17 @@ public class UmbrellaTreeMembraneBlock extends SlimeBlock implements IRenderType
double pz = ctx.getClickedPos().getZ() * 0.1;
return this.defaultBlockState().setValue(COLOR, MHelper.floor(NOISE.eval(px, py, pz) * 3.5 + 4));
}
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(COLOR);
}
@Override
public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.TRANSLUCENT;
}
@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
if (state.getValue(COLOR) > 0) {
@ -69,7 +68,7 @@ public class UmbrellaTreeMembraneBlock extends SlimeBlock implements IRenderType
public boolean propagatesSkylightDown(BlockState state, BlockGetter world, BlockPos pos) {
return state.getValue(COLOR) > 0;
}
@Environment(EnvType.CLIENT)
public boolean skipRendering(BlockState state, BlockState stateFrom, Direction direction) {
if (state.getValue(COLOR) > 0) {

View file

@ -18,12 +18,12 @@ public class UmbrellaTreeSaplingBlock extends FeatureSaplingBlock {
protected Feature<?> getFeature() {
return EndFeatures.UMBRELLA_TREE.getFeature();
}
@Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
return world.getBlockState(pos.below()).is(EndBlocks.JUNGLE_MOSS);
}
@Override
public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.TRANSLUCENT;

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks;
import java.util.Random;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
@ -9,9 +7,12 @@ import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
@ -32,17 +33,20 @@ import net.minecraft.world.phys.shapes.VoxelShape;
import ru.bclib.util.BlocksHelper;
import ru.betterend.registry.EndBlocks;
import java.util.Optional;
import java.util.Random;
public class VentBubbleColumnBlock extends Block implements BucketPickup, LiquidBlockContainer {
public VentBubbleColumnBlock() {
super(FabricBlockSettings.of(Material.BUBBLE_COLUMN).noOcclusion().noCollission().noDrops());
}
@Override
public Fluid takeLiquid(LevelAccessor world, BlockPos pos, BlockState state) {
public ItemStack pickupBlock(LevelAccessor world, BlockPos pos, BlockState state) {
world.setBlock(pos, Blocks.AIR.defaultBlockState(), 11);
return Fluids.WATER;
return new ItemStack(Items.WATER_BUCKET);
}
@Override
public RenderShape getRenderShape(BlockState state) {
return RenderShape.INVISIBLE;
@ -105,7 +109,7 @@ public class VentBubbleColumnBlock extends Block implements BucketPickup, Liquid
entity.onInsideBubbleColumn(false);
}
}
@Override
public boolean canPlaceLiquid(BlockGetter world, BlockPos pos, BlockState state, Fluid fluid) {
return false;
@ -115,9 +119,15 @@ public class VentBubbleColumnBlock extends Block implements BucketPickup, Liquid
public boolean placeLiquid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluidState) {
return false;
}
@Override
public FluidState getFluidState(BlockState state) {
return Fluids.WATER.getSource(false);
}
@Override
public Optional<SoundEvent> getPickupSound() {
return Fluids.WATER.getPickupSound();
}
}

View file

@ -1,8 +1,5 @@
package ru.betterend.blocks.basis;
import java.util.List;
import java.util.Objects;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.context.BlockPlaceContext;
@ -17,13 +14,16 @@ import ru.bclib.blocks.BaseAnvilBlock;
import ru.betterend.blocks.complex.MetalMaterial;
import ru.betterend.item.EndAnvilItem;
import java.util.List;
import java.util.Objects;
public class EndAnvilBlock extends BaseAnvilBlock {
protected final int level;
protected IntegerProperty durability;
protected MetalMaterial metalMaterial;
protected int maxDurability;
public EndAnvilBlock(MaterialColor color, int level) {
super(color);
this.level = level;
@ -81,7 +81,7 @@ public class EndAnvilBlock extends BaseAnvilBlock {
super.createBlockStateDefinition(builder);
builder.add(getDurability());
}
public int getCraftingLevel() {
return level;
}
@ -109,7 +109,8 @@ public class EndAnvilBlock extends BaseAnvilBlock {
if (destructionProperty.getPossibleValues().contains(destruction)) {
try {
return fallingState.setValue(destructionProperty, destruction);
} catch (Exception ex) {
}
catch (Exception ex) {
return null;
}
}

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks.basis;
import java.util.Map;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
@ -28,24 +26,26 @@ import ru.bclib.blocks.BaseBlockNotFull;
import ru.bclib.blocks.BlockProperties;
import ru.bclib.client.models.ModelsHelper;
import java.util.Map;
@SuppressWarnings("deprecation")
public class EndLanternBlock extends BaseBlockNotFull implements SimpleWaterloggedBlock, LiquidBlockContainer {
public static final BooleanProperty IS_FLOOR = BlockProperties.IS_FLOOR;
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
public EndLanternBlock(Block source) {
this(FabricBlockSettings.copyOf(source).luminance(15).noOcclusion());
}
public EndLanternBlock(Properties settings) {
super(settings.noOcclusion());
}
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(IS_FLOOR, WATERLOGGED);
}
@Override
public BlockState getStateForPlacement(BlockPlaceContext ctx) {
LevelReader worldView = ctx.getLevel();
@ -86,7 +86,7 @@ public class EndLanternBlock extends BaseBlockNotFull implements SimpleWaterlogg
}
}
}
@Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
if (state.getValue(IS_FLOOR)) {
@ -96,7 +96,7 @@ public class EndLanternBlock extends BaseBlockNotFull implements SimpleWaterlogg
return canSupportCenter(world, pos.above(), Direction.DOWN);
}
}
@Override
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
Boolean water = state.getValue(WATERLOGGED);
@ -110,7 +110,7 @@ public class EndLanternBlock extends BaseBlockNotFull implements SimpleWaterlogg
return state;
}
}
@Override
public boolean canPlaceLiquid(BlockGetter world, BlockPos pos, BlockState state, Fluid fluid) {
return false;
@ -120,7 +120,7 @@ public class EndLanternBlock extends BaseBlockNotFull implements SimpleWaterlogg
public boolean placeLiquid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluidState) {
return false;
}
@Override
public FluidState getFluidState(BlockState state) {
return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : Fluids.EMPTY.defaultFluidState();

View file

@ -6,7 +6,8 @@ import ru.bclib.blocks.BasePlantWithAgeBlock;
public abstract class EndPlantWithAgeBlock extends BasePlantWithAgeBlock {
public EndPlantWithAgeBlock() {}
public EndPlantWithAgeBlock() {
}
public EndPlantWithAgeBlock(Properties settings) {
super(settings);

View file

@ -6,7 +6,8 @@ import ru.bclib.blocks.UnderwaterPlantBlock;
public class EndUnderwaterPlantBlock extends UnderwaterPlantBlock {
public EndUnderwaterPlantBlock() {}
public EndUnderwaterPlantBlock() {
}
public EndUnderwaterPlantBlock(int light) {
super(light);

View file

@ -6,7 +6,8 @@ import ru.bclib.blocks.BaseUnderwaterWallPlantBlock;
public class EndUnderwaterWallPlantBlock extends BaseUnderwaterWallPlantBlock {
public EndUnderwaterWallPlantBlock() {}
public EndUnderwaterWallPlantBlock() {
}
public EndUnderwaterWallPlantBlock(int light) {
super(light);

Some files were not shown because too many files have changed in this diff Show more