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/ run/
output/ output/
*.log *.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) [![](https://jitpack.io/v/paulevsGitch/BetterEnd.svg)](https://jitpack.io/#paulevsGitch/BetterEnd)
# Better End # Better End
Better End Mod for Fabric, MC 1.16.4 Better End Mod for Fabric, MC 1.17.1
Importing: Importing:
* Clone repo * Clone repo

View file

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

View file

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

View file

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists 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 zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

View file

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

View file

@ -2,29 +2,33 @@ package ru.betterend.api;
public interface BetterEndPlugin { public interface BetterEndPlugin {
/** /**
* Alloying recipes registration. * Alloying recipes registration.
* See AlloyingRecipe.Builder for details. * See AlloyingRecipe.Builder for details.
*/ */
default void registerAlloyingRecipes() {} default void registerAlloyingRecipes() {
}
/** /**
* Smithing recipes registration. * Smithing recipes registration.
* See AnvilSmithingRecipe.Builder for details. * See AnvilSmithingRecipe.Builder for details.
*/ */
default void registerSmithingRecipes() {} default void registerSmithingRecipes() {
}
/** /**
* Additional biomes registration. * Additional biomes registration.
* See BiomeRegistry.registerBiome for details. * 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) { public static void register(BetterEndPlugin plugin) {
plugin.registerAlloyingRecipes(); plugin.registerAlloyingRecipes();
plugin.registerSmithingRecipes(); plugin.registerSmithingRecipes();

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,11 +1,5 @@
package ru.betterend.blocks; 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.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
@ -26,10 +20,15 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material; import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.storage.loot.LootContext; import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.parameters.LootContextParams; import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import org.jetbrains.annotations.Nullable;
import ru.bclib.client.models.BlockModelProvider; import ru.bclib.client.models.BlockModelProvider;
import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.IRenderTyped; 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 class EmeraldIceBlock extends HalfTransparentBlock implements IRenderTyped, BlockModelProvider {
public EmeraldIceBlock() { public EmeraldIceBlock() {
super(FabricBlockSettings.copyOf(Blocks.ICE)); super(FabricBlockSettings.copyOf(Blocks.ICE));
@ -74,7 +73,7 @@ public class EmeraldIceBlock extends HalfTransparentBlock implements IRenderType
world.neighborChanged(pos, Blocks.WATER, pos); world.neighborChanged(pos, Blocks.WATER, pos);
} }
} }
@Override @Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
ItemStack tool = builder.getOptionalParameter(LootContextParams.TOOL); 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<HydraluxShape> HYDRALUX_SHAPE = EnumProperty.create("shape", HydraluxShape.class);
public static final EnumProperty<PedestalState> PEDESTAL_STATE = EnumProperty.create("state", PedestalState.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 EnumProperty<CactusBottom> CACTUS_BOTTOM = EnumProperty.create("bottom", CactusBottom.class);
public static final BooleanProperty HAS_ITEM = BooleanProperty.create("has_item"); public static final BooleanProperty HAS_ITEM = BooleanProperty.create("has_item");
public static final IntegerProperty PORTAL = IntegerProperty.create("portal", 0, EndPortals.getCount()); public static final IntegerProperty PORTAL = IntegerProperty.create("portal", 0, EndPortals.getCount());
public enum PedestalState implements StringRepresentable { public enum PedestalState implements StringRepresentable {
PEDESTAL_TOP("pedestal_top"), PEDESTAL_TOP("pedestal_top"),
COLUMN_TOP("column_top"), COLUMN_TOP("column_top"),
@ -22,24 +22,24 @@ public class EndBlockProperties extends BlockProperties {
PILLAR("pillar"), PILLAR("pillar"),
COLUMN("column"), COLUMN("column"),
DEFAULT("default"); DEFAULT("default");
private final String name; private final String name;
PedestalState(String name) { PedestalState(String name) {
this.name = name; this.name = name;
} }
@Override @Override
public String getSerializedName() { public String getSerializedName() {
return this.name; return this.name;
} }
@Override @Override
public String toString() { public String toString() {
return this.name; return this.name;
} }
} }
public enum HydraluxShape implements StringRepresentable { public enum HydraluxShape implements StringRepresentable {
FLOWER_BIG_BOTTOM("flower_big_bottom", true), FLOWER_BIG_BOTTOM("flower_big_bottom", true),
FLOWER_BIG_TOP("flower_big_top", true), FLOWER_BIG_TOP("flower_big_top", true),
@ -47,10 +47,10 @@ public class EndBlockProperties extends BlockProperties {
FLOWER_SMALL_TOP("flower_small_top", true), FLOWER_SMALL_TOP("flower_small_top", true),
VINE("vine", false), VINE("vine", false),
ROOTS("roots", false); ROOTS("roots", false);
private final String name; private final String name;
private final boolean glow; private final boolean glow;
HydraluxShape(String name, boolean glow) { HydraluxShape(String name, boolean glow) {
this.name = name; this.name = name;
this.glow = glow; this.glow = glow;
@ -60,17 +60,17 @@ public class EndBlockProperties extends BlockProperties {
public String getSerializedName() { public String getSerializedName() {
return name; return name;
} }
@Override @Override
public String toString() { public String toString() {
return name; return name;
} }
public boolean hasGlow() { public boolean hasGlow() {
return glow; return glow;
} }
} }
public enum LumecornShape implements StringRepresentable { public enum LumecornShape implements StringRepresentable {
LIGHT_TOP("light_top", 15), LIGHT_TOP("light_top", 15),
LIGHT_TOP_MIDDLE("light_top_middle", 15), LIGHT_TOP_MIDDLE("light_top_middle", 15),
@ -79,10 +79,10 @@ public class EndBlockProperties extends BlockProperties {
MIDDLE("middle", 0), MIDDLE("middle", 0),
BOTTOM_BIG("bottom_big", 0), BOTTOM_BIG("bottom_big", 0),
BOTTOM_SMALL("bottom_small", 0); BOTTOM_SMALL("bottom_small", 0);
private final String name; private final String name;
private final int light; private final int light;
LumecornShape(String name, int light) { LumecornShape(String name, int light) {
this.name = name; this.name = name;
this.light = light; this.light = light;
@ -92,24 +92,24 @@ public class EndBlockProperties extends BlockProperties {
public String getSerializedName() { public String getSerializedName() {
return name; return name;
} }
@Override @Override
public String toString() { public String toString() {
return name; return name;
} }
public int getLight() { public int getLight() {
return light; return light;
} }
} }
public enum CactusBottom implements StringRepresentable { public enum CactusBottom implements StringRepresentable {
EMPTY("empty"), EMPTY("empty"),
SAND("sand"), SAND("sand"),
MOSS("moss"); MOSS("moss");
private final String name; private final String name;
CactusBottom(String name) { CactusBottom(String name) {
this.name = name; this.name = name;
} }
@ -118,7 +118,7 @@ public class EndBlockProperties extends BlockProperties {
public String getSerializedName() { public String getSerializedName() {
return name; return name;
} }
@Override @Override
public String toString() { public String toString() {
return name; return name;

View file

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

View file

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

View file

@ -1,9 +1,6 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.List;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
@ -21,40 +18,42 @@ import ru.bclib.util.MHelper;
import ru.betterend.blocks.basis.EndPlantBlock; import ru.betterend.blocks.basis.EndPlantBlock;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import java.util.List;
public class EndLotusFlowerBlock extends EndPlantBlock { public class EndLotusFlowerBlock extends EndPlantBlock {
private static final VoxelShape SHAPE_OUTLINE = Block.box(2, 0, 2, 14, 14, 14); 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); private static final VoxelShape SHAPE_COLLISION = Block.box(0, 0, 0, 16, 2, 16);
public EndLotusFlowerBlock() { public EndLotusFlowerBlock() {
super(FabricBlockSettings.of(Material.PLANT).luminance(15).noOcclusion()); super(FabricBlockSettings.of(Material.PLANT).luminance(15).noOcclusion());
} }
@Override @Override
protected boolean isTerrain(BlockState state) { protected boolean isTerrain(BlockState state) {
return state.is(EndBlocks.END_LOTUS_STEM); return state.is(EndBlocks.END_LOTUS_STEM);
} }
@Override @Override
public BlockBehaviour.OffsetType getOffsetType() { public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.NONE; return BlockBehaviour.OffsetType.NONE;
} }
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) { public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return SHAPE_OUTLINE; return SHAPE_OUTLINE;
} }
@Override @Override
public VoxelShape getCollisionShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) { public VoxelShape getCollisionShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return SHAPE_COLLISION; return SHAPE_COLLISION;
} }
@Override @Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
int count = MHelper.randRange(1, 2, MHelper.RANDOM); int count = MHelper.randRange(1, 2, MHelper.RANDOM);
return Lists.newArrayList(new ItemStack(EndBlocks.END_LOTUS_SEED, count)); return Lists.newArrayList(new ItemStack(EndBlocks.END_LOTUS_SEED, count));
} }
@Override @Override
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public ItemStack getCloneItemStack(BlockGetter world, BlockPos pos, BlockState state) { 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<Direction> HORIZONTAL_FACING = BlockStateProperties.HORIZONTAL_FACING;
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE; public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
private static final VoxelShape VSHAPE = Block.box(0, 0, 0, 16, 1, 16); private static final VoxelShape VSHAPE = Block.box(0, 0, 0, 16, 1, 16);
public EndLotusLeafBlock() { public EndLotusLeafBlock() {
super(FabricBlockSettings.of(Material.PLANT).noOcclusion().sound(SoundType.WET_GRASS)); super(FabricBlockSettings.of(Material.PLANT).noOcclusion().sound(SoundType.WET_GRASS));
} }
@Override @Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
BlockState down = world.getBlockState(pos.below()); BlockState down = world.getBlockState(pos.below());
return !down.getFluidState().isEmpty() && down.getFluidState().getType() instanceof WaterFluid; return !down.getFluidState().isEmpty() && down.getFluidState().getType() instanceof WaterFluid;
} }
@Override @Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) { protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
builder.add(SHAPE, HORIZONTAL_FACING); builder.add(SHAPE, HORIZONTAL_FACING);
} }
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) { public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return VSHAPE; return VSHAPE;
} }
@Override @Override
public BlockState rotate(BlockState state, Rotation rotation) { public BlockState rotate(BlockState state, Rotation rotation) {
return BlocksHelper.rotateHorizontal(state, rotation, HORIZONTAL_FACING); 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) { public BlockState mirror(BlockState state, Mirror mirror) {
return BlocksHelper.mirrorHorizontal(state, mirror, HORIZONTAL_FACING); return BlocksHelper.mirrorHorizontal(state, mirror, HORIZONTAL_FACING);
} }
@Override @Override
public BCLRenderLayer getRenderLayer() { public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.CUTOUT; return BCLRenderLayer.CUTOUT;
} }
@Override @Override
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public ItemStack getCloneItemStack(BlockGetter world, BlockPos pos, BlockState state) { public ItemStack getCloneItemStack(BlockGetter world, BlockPos pos, BlockState state) {

View file

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

View file

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

View file

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

View file

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

View file

@ -1,10 +1,6 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.List;
import java.util.Random;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
@ -19,7 +15,6 @@ import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.context.BlockPlaceContext; import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.HorizontalDirectionalBlock; 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.Rotation;
import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.entity.BlockEntity; 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.BlockState;
import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BlockStateProperties; 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.LootContext;
import net.minecraft.world.level.storage.loot.parameters.LootContextParams; import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.BlockHitResult;
import org.jetbrains.annotations.Nullable;
import ru.bclib.blocks.BaseBlockWithEntity; import ru.bclib.blocks.BaseBlockWithEntity;
import ru.betterend.blocks.entities.EndStoneSmelterBlockEntity; 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 class EndStoneSmelter extends BaseBlockWithEntity {
public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING; public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING;
@ -48,19 +50,19 @@ public class EndStoneSmelter extends BaseBlockWithEntity {
public EndStoneSmelter() { public EndStoneSmelter() {
super(FabricBlockSettings.of(Material.STONE, MaterialColor.COLOR_GRAY) super(FabricBlockSettings.of(Material.STONE, MaterialColor.COLOR_GRAY)
.luminance(state -> state.getValue(LIT) ? 15 : 0)
.hardness(4F) .hardness(4F)
.resistance(100F) .resistance(100F)
.requiresCorrectToolForDrops() .requiresCorrectToolForDrops()
.sound(SoundType.STONE)); .sound(SoundType.STONE));
registerDefaultState(this.stateDefinition.any() registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH).setValue(LIT, false));
.setValue(FACING, Direction.NORTH)
.setValue(LIT, false));
} }
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
if (world.isClientSide) { if (world.isClientSide) {
return InteractionResult.SUCCESS; return InteractionResult.SUCCESS;
} else { }
else {
this.openScreen(world, pos, player); this.openScreen(world, pos, player);
return InteractionResult.CONSUME; return InteractionResult.CONSUME;
} }
@ -72,17 +74,17 @@ public class EndStoneSmelter extends BaseBlockWithEntity {
player.openMenu((EndStoneSmelterBlockEntity) blockEntity); player.openMenu((EndStoneSmelterBlockEntity) blockEntity);
} }
} }
@Override @Override
public BlockState getStateForPlacement(BlockPlaceContext ctx) { public BlockState getStateForPlacement(BlockPlaceContext ctx) {
return defaultBlockState().setValue(FACING, ctx.getHorizontalDirection().getOpposite()); return defaultBlockState().setValue(FACING, ctx.getHorizontalDirection().getOpposite());
} }
@Override @Override
public BlockEntity newBlockEntity(BlockGetter world) { public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) {
return new EndStoneSmelterBlockEntity(); return new EndStoneSmelterBlockEntity(blockPos, blockState);
} }
@Override @Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
List<ItemStack> drop = Lists.newArrayList(new ItemStack(this)); List<ItemStack> drop = Lists.newArrayList(new ItemStack(this));
@ -129,7 +131,7 @@ public class EndStoneSmelter extends BaseBlockWithEntity {
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) { protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
builder.add(FACING, LIT); builder.add(FACING, LIT);
} }
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public void animateTick(BlockState state, Level world, BlockPos pos, Random random) { public void animateTick(BlockState state, Level world, BlockPos pos, Random random) {
if (state.getValue(LIT)) { if (state.getValue(LIT)) {
@ -137,7 +139,7 @@ public class EndStoneSmelter extends BaseBlockWithEntity {
double y = pos.getY(); double y = pos.getY();
double z = pos.getZ() + 0.5D; double z = pos.getZ() + 0.5D;
if (random.nextDouble() < 0.1D) { if (random.nextDouble() < 0.1D) {
world.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); 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); 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; package ru.betterend.blocks;
import java.util.Collections;
import java.util.List;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
@ -16,16 +13,19 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.storage.loot.LootContext; import net.minecraft.world.level.storage.loot.LootContext;
import ru.bclib.util.ColorUtil; import ru.bclib.util.ColorUtil;
import java.util.Collections;
import java.util.List;
public class EndstoneDustBlock extends FallingBlock { public class EndstoneDustBlock extends FallingBlock {
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
private static final int COLOR = ColorUtil.color(226, 239, 168); private static final int COLOR = ColorUtil.color(226, 239, 168);
public EndstoneDustBlock() { public EndstoneDustBlock() {
super(FabricBlockSettings.copyOf(Blocks.SAND) super(FabricBlockSettings.copyOf(Blocks.SAND)
.breakByTool(FabricToolTags.SHOVELS) .breakByTool(FabricToolTags.SHOVELS)
.materialColor(Blocks.END_STONE.defaultMaterialColor())); .materialColor(Blocks.END_STONE.defaultMaterialColor()));
} }
@Override @Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return Collections.singletonList(new ItemStack(this)); return Collections.singletonList(new ItemStack(this));

View file

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

View file

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

View file

@ -1,9 +1,6 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.EnumMap;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
@ -19,9 +16,11 @@ import ru.bclib.blocks.BaseAttachedBlock;
import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.IRenderTyped; import ru.bclib.interfaces.IRenderTyped;
import java.util.EnumMap;
public class FilaluxWingsBlock extends BaseAttachedBlock implements IRenderTyped { public class FilaluxWingsBlock extends BaseAttachedBlock implements IRenderTyped {
private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class); private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class);
public FilaluxWingsBlock() { public FilaluxWingsBlock() {
super(FabricBlockSettings.of(Material.PLANT).breakByTool(FabricToolTags.SHEARS).sound(SoundType.WET_GRASS).noCollission()); 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() { public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.CUTOUT; return BCLRenderLayer.CUTOUT;
} }
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) { public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return BOUNDING_SHAPES.get(state.getValue(FACING)); return BOUNDING_SHAPES.get(state.getValue(FACING));
} }
static { static {
BOUNDING_SHAPES.put(Direction.UP, Shapes.box(0.0, 0.0, 0.0, 1.0, 0.5, 1.0)); 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)); 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; package ru.betterend.blocks;
import java.util.List;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
@ -21,21 +18,23 @@ import net.minecraft.world.phys.shapes.VoxelShape;
import ru.bclib.interfaces.ISpetialItem; import ru.bclib.interfaces.ISpetialItem;
import ru.betterend.blocks.basis.EndPlantBlock; import ru.betterend.blocks.basis.EndPlantBlock;
import java.util.List;
public class FlamaeaBlock extends EndPlantBlock implements ISpetialItem { public class FlamaeaBlock extends EndPlantBlock implements ISpetialItem {
private static final VoxelShape SHAPE = Block.box(0, 0, 0, 16, 1, 16); private static final VoxelShape SHAPE = Block.box(0, 0, 0, 16, 1, 16);
public FlamaeaBlock() { public FlamaeaBlock() {
super(FabricBlockSettings.of(Material.PLANT) super(FabricBlockSettings.of(Material.PLANT)
.breakByTool(FabricToolTags.SHEARS) .breakByTool(FabricToolTags.SHEARS)
.breakByHand(true) .breakByHand(true)
.sound(SoundType.WET_GRASS)); .sound(SoundType.WET_GRASS));
} }
@Override @Override
protected boolean isTerrain(BlockState state) { protected boolean isTerrain(BlockState state) {
return state.is(Blocks.WATER); return state.is(Blocks.WATER);
} }
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) { public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return SHAPE; return SHAPE;
@ -45,7 +44,7 @@ public class FlamaeaBlock extends EndPlantBlock implements ISpetialItem {
public BlockBehaviour.OffsetType getOffsetType() { public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.NONE; return BlockBehaviour.OffsetType.NONE;
} }
@Override @Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return Lists.newArrayList(new ItemStack(this)); return Lists.newArrayList(new ItemStack(this));

View file

@ -12,19 +12,19 @@ public class GlowingMossBlock extends EndPlantBlock {
public GlowingMossBlock(int light) { public GlowingMossBlock(int light) {
super(light); super(light);
} }
@Override @Override
protected boolean isTerrain(BlockState state) { protected boolean isTerrain(BlockState state) {
return state.getBlock() == EndBlocks.END_MOSS || state.getBlock() == EndBlocks.END_MYCELIUM; 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) @Environment(EnvType.CLIENT)
public float getAmbientOcclusionLightLevel(BlockGetter world, BlockPos pos) { public boolean hasEmissiveLighting(BlockGetter world, BlockPos pos) {
return 1F; 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 class GlowingPillarLuminophorBlock extends BaseBlock {
public static final BooleanProperty NATURAL = EndBlockProperties.NATURAL; public static final BooleanProperty NATURAL = EndBlockProperties.NATURAL;
public GlowingPillarLuminophorBlock() { public GlowingPillarLuminophorBlock() {
super(FabricBlockSettings.of(Material.LEAVES) super(FabricBlockSettings.of(Material.LEAVES)
.materialColor(MaterialColor.COLOR_ORANGE) .materialColor(MaterialColor.COLOR_ORANGE)
@ -29,12 +29,12 @@ public class GlowingPillarLuminophorBlock extends BaseBlock {
.sound(SoundType.GRASS)); .sound(SoundType.GRASS));
this.registerDefaultState(this.stateDefinition.any().setValue(NATURAL, false)); this.registerDefaultState(this.stateDefinition.any().setValue(NATURAL, false));
} }
@Override @Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
return !state.getValue(NATURAL) || world.getBlockState(pos.below()).is(EndBlocks.GLOWING_PILLAR_ROOTS); return !state.getValue(NATURAL) || world.getBlockState(pos.below()).is(EndBlocks.GLOWING_PILLAR_ROOTS);
} }
@Override @Override
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) { public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
if (!canSurvive(state, world, pos)) { if (!canSurvive(state, world, pos)) {
@ -44,7 +44,7 @@ public class GlowingPillarLuminophorBlock extends BaseBlock {
return state; return state;
} }
} }
@Override @Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) { protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(NATURAL); stateManager.add(NATURAL);

View file

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

View file

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

View file

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

View file

@ -1,11 +1,6 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
@ -29,10 +24,14 @@ import ru.betterend.blocks.EndBlockProperties.HydraluxShape;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndItems; import ru.betterend.registry.EndItems;
import java.util.Collections;
import java.util.List;
import java.util.Random;
public class HydraluxBlock extends UnderwaterPlantBlock { public class HydraluxBlock extends UnderwaterPlantBlock {
public static final EnumProperty<HydraluxShape> SHAPE = EndBlockProperties.HYDRALUX_SHAPE; public static final EnumProperty<HydraluxShape> SHAPE = EndBlockProperties.HYDRALUX_SHAPE;
public HydraluxBlock() { public HydraluxBlock() {
super(FabricBlockSettings.of(Material.WATER_PLANT) super(FabricBlockSettings.of(Material.WATER_PLANT)
.breakByTool(FabricToolTags.SHEARS) .breakByTool(FabricToolTags.SHEARS)
@ -41,12 +40,12 @@ public class HydraluxBlock extends UnderwaterPlantBlock {
.lightLevel((state) -> state.getValue(SHAPE).hasGlow() ? 15 : 0) .lightLevel((state) -> state.getValue(SHAPE).hasGlow() ? 15 : 0)
.noCollission()); .noCollission());
} }
@Override @Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) { protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(SHAPE); stateManager.add(SHAPE);
} }
@Override @Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
BlockState down = world.getBlockState(pos.below()); 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) { public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) {
return false; return false;
} }
@Override @Override
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public ItemStack getCloneItemStack(BlockGetter world, BlockPos pos, BlockState state) { public ItemStack getCloneItemStack(BlockGetter world, BlockPos pos, BlockState state) {
return new ItemStack(EndBlocks.HYDRALUX_SAPLING); return new ItemStack(EndBlocks.HYDRALUX_SAPLING);
} }
@Override @Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
HydraluxShape shape = state.getValue(SHAPE); 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.entity.Entity;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.SoundType; 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.Material;
import net.minecraft.world.level.material.MaterialColor; import net.minecraft.world.level.material.MaterialColor;
import ru.bclib.blocks.BaseBlock; import ru.bclib.blocks.BaseBlock;
@ -20,11 +21,12 @@ public class HydraluxPetalBlock extends BaseBlock {
.materialColor(MaterialColor.PODZOL) .materialColor(MaterialColor.PODZOL)
.sound(SoundType.WART_BLOCK)); .sound(SoundType.WART_BLOCK));
} }
public HydraluxPetalBlock(Properties settings) { public HydraluxPetalBlock(Properties settings) {
super(settings); super(settings);
} }
@Override @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; package ru.betterend.blocks;
import java.util.Optional;
import org.jetbrains.annotations.Nullable;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
@ -12,16 +8,19 @@ import net.minecraft.client.color.item.ItemColor;
import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import org.jetbrains.annotations.Nullable;
import ru.bclib.client.models.ModelsHelper; import ru.bclib.client.models.ModelsHelper;
import ru.bclib.interfaces.IColorProvider; import ru.bclib.interfaces.IColorProvider;
import ru.bclib.util.BlocksHelper; import ru.bclib.util.BlocksHelper;
import ru.betterend.client.models.Patterns; import ru.betterend.client.models.Patterns;
import java.util.Optional;
public class HydraluxPetalColoredBlock extends HydraluxPetalBlock implements IColorProvider { public class HydraluxPetalColoredBlock extends HydraluxPetalBlock implements IColorProvider {
public HydraluxPetalColoredBlock(FabricBlockSettings settings) { public HydraluxPetalColoredBlock(FabricBlockSettings settings) {
super(settings); super(settings);
} }
@Override @Override
public BlockColor getProvider() { public BlockColor getProvider() {
return (state, world, pos, tintIndex) -> BlocksHelper.getBlockColor(this); return (state, world, pos, tintIndex) -> BlocksHelper.getBlockColor(this);

View file

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

View file

@ -1,9 +1,5 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.Random;
import org.jetbrains.annotations.Nullable;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
@ -26,6 +22,8 @@ import net.minecraft.world.level.block.LiquidBlockContainer;
import net.minecraft.world.level.block.SimpleWaterloggedBlock; import net.minecraft.world.level.block.SimpleWaterloggedBlock;
import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.entity.BlockEntity; 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.BlockState;
import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BlockStateProperties; 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.level.material.Material;
import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShape;
import org.jetbrains.annotations.Nullable;
import ru.bclib.blocks.BaseBlockNotFull; import ru.bclib.blocks.BaseBlockNotFull;
import ru.bclib.blocks.BlockProperties; import ru.bclib.blocks.BlockProperties;
import ru.bclib.util.BlocksHelper; import ru.bclib.util.BlocksHelper;
@ -43,12 +42,14 @@ import ru.betterend.blocks.entities.BlockEntityHydrothermalVent;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndParticles; import ru.betterend.registry.EndParticles;
import java.util.Random;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class HydrothermalVentBlock extends BaseBlockNotFull implements EntityBlock, LiquidBlockContainer, SimpleWaterloggedBlock { public class HydrothermalVentBlock extends BaseBlockNotFull implements EntityBlock, LiquidBlockContainer, SimpleWaterloggedBlock {
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
public static final BooleanProperty ACTIVATED = BlockProperties.ACTIVE; public static final BooleanProperty ACTIVATED = BlockProperties.ACTIVE;
private static final VoxelShape SHAPE = Block.box(1, 1, 1, 15, 16, 15); private static final VoxelShape SHAPE = Block.box(1, 1, 1, 15, 16, 15);
public HydrothermalVentBlock() { public HydrothermalVentBlock() {
super(FabricBlockSettings.of(Material.STONE) super(FabricBlockSettings.of(Material.STONE)
.breakByTool(FabricToolTags.PICKAXES) .breakByTool(FabricToolTags.PICKAXES)
@ -57,17 +58,17 @@ public class HydrothermalVentBlock extends BaseBlockNotFull implements EntityBlo
.requiresCorrectToolForDrops()); .requiresCorrectToolForDrops());
this.registerDefaultState(defaultBlockState().setValue(WATERLOGGED, true).setValue(ACTIVATED, false)); this.registerDefaultState(defaultBlockState().setValue(WATERLOGGED, true).setValue(ACTIVATED, false));
} }
@Override @Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) { protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
builder.add(WATERLOGGED, ACTIVATED); builder.add(WATERLOGGED, ACTIVATED);
} }
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) { public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return SHAPE; return SHAPE;
} }
@Override @Override
public boolean canPlaceLiquid(BlockGetter world, BlockPos pos, BlockState state, Fluid fluid) { public boolean canPlaceLiquid(BlockGetter world, BlockPos pos, BlockState state, Fluid fluid) {
return false; return false;
@ -77,13 +78,13 @@ public class HydrothermalVentBlock extends BaseBlockNotFull implements EntityBlo
public boolean placeLiquid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluidState) { public boolean placeLiquid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluidState) {
return false; return false;
} }
@Override @Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
state = world.getBlockState(pos.below()); state = world.getBlockState(pos.below());
return state.is(EndBlocks.SULPHURIC_ROCK.stone); return state.is(EndBlocks.SULPHURIC_ROCK.stone);
} }
@Override @Override
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) { public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
if (!canSurvive(state, world, pos)) { if (!canSurvive(state, world, pos)) {
@ -94,22 +95,22 @@ public class HydrothermalVentBlock extends BaseBlockNotFull implements EntityBlo
} }
return state; return state;
} }
@Override @Override
public BlockState getStateForPlacement(BlockPlaceContext ctx) { public BlockState getStateForPlacement(BlockPlaceContext ctx) {
LevelAccessor worldAccess = ctx.getLevel(); LevelAccessor worldAccess = ctx.getLevel();
BlockPos blockPos = ctx.getClickedPos(); BlockPos blockPos = ctx.getClickedPos();
return this.defaultBlockState().setValue(WATERLOGGED, worldAccess.getFluidState(blockPos).getType() == Fluids.WATER); return this.defaultBlockState().setValue(WATERLOGGED, worldAccess.getFluidState(blockPos).getType() == Fluids.WATER);
} }
@Override @Override
public FluidState getFluidState(BlockState state) { public FluidState getFluidState(BlockState state) {
return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state); return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state);
} }
@Override @Override
public BlockEntity newBlockEntity(BlockGetter world) { public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
return new BlockEntityHydrothermalVent(); return new BlockEntityHydrothermalVent(pos, state);
} }
@Override @Override
@ -120,27 +121,28 @@ public class HydrothermalVentBlock extends BaseBlockNotFull implements EntityBlo
world.getBlockTicks().scheduleTick(up, EndBlocks.VENT_BUBBLE_COLUMN, 5); world.getBlockTicks().scheduleTick(up, EndBlocks.VENT_BUBBLE_COLUMN, 5);
} }
} }
@Override @Override
public void setPlacedBy(Level world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack itemStack) { 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)) { 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) @Environment(EnvType.CLIENT)
public void animateTick(BlockState state, Level world, BlockPos pos, Random random) { public void animateTick(BlockState state, Level world, BlockPos pos, Random random) {
super.animateTick(state, world, pos, random);
if (!state.getValue(ACTIVATED) && random.nextBoolean()) { if (!state.getValue(ACTIVATED) && random.nextBoolean()) {
super.animateTick(state, world, pos, random);
double x = pos.getX() + random.nextDouble(); double x = pos.getX() + random.nextDouble();
double y = pos.getY() + 0.9 + random.nextDouble() * 0.3; double y = pos.getY() + 0.9 + random.nextDouble() * 0.3;
double z = pos.getZ() + random.nextDouble(); double z = pos.getZ() + random.nextDouble();
if (state.getValue(WATERLOGGED)) { world.addParticle(ParticleTypes.LARGE_SMOKE, x, y, z, 0, 0, 0);
world.addParticle(EndParticles.GEYSER_PARTICLE, x, y, z, 0, 0, 0);
}
else {
world.addParticle(ParticleTypes.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.Block;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.BlockEntity; 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.BlockState;
import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShape;
import org.jetbrains.annotations.Nullable;
import ru.betterend.blocks.basis.PedestalBlock; import ru.betterend.blocks.basis.PedestalBlock;
import ru.betterend.blocks.entities.InfusionPedestalEntity; import ru.betterend.blocks.entities.InfusionPedestalEntity;
import ru.betterend.blocks.entities.PedestalBlockEntity;
import ru.betterend.rituals.InfusionRitual; import ru.betterend.rituals.InfusionRitual;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@ -23,7 +27,7 @@ public class InfusionPedestal extends PedestalBlock {
super(Blocks.OBSIDIAN); super(Blocks.OBSIDIAN);
this.height = 1.08F; this.height = 1.08F;
} }
@Override @Override
public void checkRitual(Level world, BlockPos pos) { public void checkRitual(Level world, BlockPos pos) {
BlockEntity blockEntity = world.getBlockEntity(pos); BlockEntity blockEntity = world.getBlockEntity(pos);
@ -35,17 +39,18 @@ public class InfusionPedestal extends PedestalBlock {
ritual.configure(); ritual.configure();
} }
pedestal.getRitual().checkRecipe(); pedestal.getRitual().checkRecipe();
} else { }
else {
InfusionRitual ritual = new InfusionRitual(pedestal, world, pos); InfusionRitual ritual = new InfusionRitual(pedestal, world, pos);
pedestal.linkRitual(ritual); pedestal.linkRitual(ritual);
ritual.checkRecipe(); ritual.checkRecipe();
} }
} }
} }
@Override @Override
public BlockEntity newBlockEntity(BlockGetter world) { public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) {
return new InfusionPedestalEntity(); return new InfusionPedestalEntity(blockPos, blockState);
} }
@Override @Override
@ -57,7 +62,7 @@ public class InfusionPedestal extends PedestalBlock {
@Deprecated @Deprecated
public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) { public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) {
if (state.is(this)) { if (state.is(this)) {
switch(state.getValue(STATE)) { switch (state.getValue(STATE)) {
case PEDESTAL_TOP: { case PEDESTAL_TOP: {
return SHAPE_PEDESTAL_TOP; return SHAPE_PEDESTAL_TOP;
} }
@ -72,6 +77,12 @@ public class InfusionPedestal extends PedestalBlock {
return super.getShape(state, world, pos, context); 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 { static {
VoxelShape basinUp = Block.box(2, 3, 2, 14, 4, 14); VoxelShape basinUp = Block.box(2, 3, 2, 14, 4, 14);
VoxelShape basinDown = Block.box(0, 0, 0, 16, 3, 16); VoxelShape basinDown = Block.box(0, 0, 0, 16, 3, 16);

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,9 +1,5 @@
package ru.betterend.blocks; 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.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; 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.bclib.blocks.BaseRotatedPillarBlock;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import java.util.Collections;
import java.util.List;
import java.util.Random;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class MossyDragonBoneBlock extends BaseRotatedPillarBlock { public class MossyDragonBoneBlock extends BaseRotatedPillarBlock {
public MossyDragonBoneBlock() { public MossyDragonBoneBlock() {
super(FabricBlockSettings.copyOf(Blocks.BONE_BLOCK).hardness(0.5F).randomTicks()); super(FabricBlockSettings.copyOf(Blocks.BONE_BLOCK).hardness(0.5F).randomTicks());
} }
@Override @Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
ItemStack tool = builder.getParameter(LootContextParams.TOOL); ItemStack tool = builder.getParameter(LootContextParams.TOOL);
@ -35,7 +35,7 @@ public class MossyDragonBoneBlock extends BaseRotatedPillarBlock {
} }
return Collections.singletonList(new ItemStack(EndBlocks.DRAGON_BONE_BLOCK)); return Collections.singletonList(new ItemStack(EndBlocks.DRAGON_BONE_BLOCK));
} }
@Override @Override
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) { public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
if (random.nextInt(16) == 0 && !canSurvive(state, world, pos)) { if (random.nextInt(16) == 0 && !canSurvive(state, world, pos)) {
@ -45,15 +45,17 @@ public class MossyDragonBoneBlock extends BaseRotatedPillarBlock {
@Override @Override
public boolean canSurvive(BlockState state, LevelReader worldView, BlockPos pos) { public boolean canSurvive(BlockState state, LevelReader worldView, BlockPos pos) {
BlockPos blockPos = pos.above(); BlockPos blockPos = pos.above();
BlockState blockState = worldView.getBlockState(blockPos); BlockState blockState = worldView.getBlockState(blockPos);
if (blockState.is(Blocks.SNOW) && blockState.getValue(SnowLayerBlock.LAYERS) == 1) { if (blockState.is(Blocks.SNOW) && blockState.getValue(SnowLayerBlock.LAYERS) == 1) {
return true; return true;
} else if (blockState.getFluidState().getAmount() == 8) { }
return false; else if (blockState.getFluidState().getAmount() == 8) {
} else { return false;
int i = LayerLightEngine.getLightBlockInto(worldView, state, pos, blockState, blockPos, Direction.UP, blockState.getLightBlock(worldView, blockPos)); }
return i < 5; 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 class MossyGlowshroomCapBlock extends BaseBlock {
public static final BooleanProperty TRANSITION = EndBlockProperties.TRANSITION; public static final BooleanProperty TRANSITION = EndBlockProperties.TRANSITION;
public MossyGlowshroomCapBlock() { public MossyGlowshroomCapBlock() {
super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).sound(SoundType.WOOD)); super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).sound(SoundType.WOOD));
this.registerDefaultState(this.stateDefinition.any().setValue(TRANSITION, false)); this.registerDefaultState(this.stateDefinition.any().setValue(TRANSITION, false));
} }
public BlockState getStateForPlacement(BlockPlaceContext ctx) { public BlockState getStateForPlacement(BlockPlaceContext ctx) {
return this.defaultBlockState().setValue(TRANSITION, EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(ctx.getLevel().getBlockState(ctx.getClickedPos().below()))); 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() { protected Feature<?> getFeature() {
return EndFeatures.MOSSY_GLOWSHROOM.getFeature(); return EndFeatures.MOSSY_GLOWSHROOM.getFeature();
} }
@Override @Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { 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); 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; 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.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; 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 net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import ru.bclib.blocks.BaseBlock; import ru.bclib.blocks.BaseBlock;
import java.util.Collections;
import java.util.List;
import java.util.Random;
public class MossyObsidian extends BaseBlock { public class MossyObsidian extends BaseBlock {
public MossyObsidian() { public MossyObsidian() {
super(FabricBlockSettings.copyOf(Blocks.OBSIDIAN).hardness(3).randomTicks()); super(FabricBlockSettings.copyOf(Blocks.OBSIDIAN).hardness(3).randomTicks());
} }
@Override @Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
ItemStack tool = builder.getParameter(LootContextParams.TOOL); ItemStack tool = builder.getParameter(LootContextParams.TOOL);
@ -33,24 +33,26 @@ public class MossyObsidian extends BaseBlock {
} }
return Collections.singletonList(new ItemStack(Blocks.OBSIDIAN)); return Collections.singletonList(new ItemStack(Blocks.OBSIDIAN));
} }
@Override @Override
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) { public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
if (random.nextInt(16) == 0 && !canSurvive(state, world, pos)) { if (random.nextInt(16) == 0 && !canSurvive(state, world, pos)) {
world.setBlockAndUpdate(pos, Blocks.OBSIDIAN.defaultBlockState()); world.setBlockAndUpdate(pos, Blocks.OBSIDIAN.defaultBlockState());
} }
} }
public boolean canSurvive(BlockState state, LevelReader worldView, BlockPos pos) { public boolean canSurvive(BlockState state, LevelReader worldView, BlockPos pos) {
BlockPos blockPos = pos.above(); BlockPos blockPos = pos.above();
BlockState blockState = worldView.getBlockState(blockPos); BlockState blockState = worldView.getBlockState(blockPos);
if (blockState.is(Blocks.SNOW) && (Integer)blockState.getValue(SnowLayerBlock.LAYERS) == 1) { if (blockState.is(Blocks.SNOW) && (Integer) blockState.getValue(SnowLayerBlock.LAYERS) == 1) {
return true; return true;
} else if (blockState.getFluidState().getAmount() == 8) { }
return false; else if (blockState.getFluidState().getAmount() == 8) {
} else { return false;
int i = LayerLightEngine.getLightBlockInto(worldView, state, pos, blockState, blockPos, Direction.UP, blockState.getLightBlock(worldView, blockPos)); }
return i < 5; 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; package ru.betterend.blocks;
import java.util.Random;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.minecraft.core.BlockPos; 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.blocks.basis.EndPlantBlock;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class MurkweedBlock extends EndPlantBlock { public class MurkweedBlock extends EndPlantBlock {
@Override @Override
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
@ -27,19 +27,19 @@ public class MurkweedBlock extends EndPlantBlock {
double v = random.nextDouble() * 0.1; double v = random.nextDouble() * 0.1;
world.addParticle(ParticleTypes.ENTITY_EFFECT, x, y, z, v, v, v); world.addParticle(ParticleTypes.ENTITY_EFFECT, x, y, z, v, v, v);
} }
@Override @Override
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) { public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
if (entity instanceof LivingEntity && !((LivingEntity) entity).hasEffect(MobEffects.BLINDNESS)) { if (entity instanceof LivingEntity && !((LivingEntity) entity).hasEffect(MobEffects.BLINDNESS)) {
((LivingEntity) entity).addEffect(new MobEffectInstance(MobEffects.BLINDNESS, 50)); ((LivingEntity) entity).addEffect(new MobEffectInstance(MobEffects.BLINDNESS, 50));
} }
} }
@Override @Override
protected boolean isTerrain(BlockState state) { protected boolean isTerrain(BlockState state) {
return state.is(EndBlocks.SHADOW_GRASS); return state.is(EndBlocks.SHADOW_GRASS);
} }
@Override @Override
public boolean isPathfindable(BlockState state, BlockGetter world, BlockPos pos, PathComputationType type) { public boolean isPathfindable(BlockState state, BlockGetter world, BlockPos pos, PathComputationType type) {
return false; return false;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.Random;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.minecraft.core.BlockPos; 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.blocks.basis.EndTerrainBlock;
import ru.betterend.registry.EndParticles; import ru.betterend.registry.EndParticles;
import java.util.Random;
public class ShadowGrassBlock extends EndTerrainBlock { public class ShadowGrassBlock extends EndTerrainBlock {
public ShadowGrassBlock() { public ShadowGrassBlock() {
super(MaterialColor.COLOR_BLACK); super(MaterialColor.COLOR_BLACK);

View file

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

View file

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

View file

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

View file

@ -1,12 +1,7 @@
package ru.betterend.blocks; 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.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.core.BlockPos; 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.BonemealableBlock;
import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockState; 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.material.Material;
import net.minecraft.world.level.storage.loot.LootContext; import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.parameters.LootContextParams; 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.bclib.util.BlocksHelper;
import ru.betterend.registry.EndFeatures; 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 { public class SmallJellyshroomBlock extends BaseAttachedBlock implements IRenderTyped, BonemealableBlock {
private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class); private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class);
public SmallJellyshroomBlock() { public SmallJellyshroomBlock() {
super(FabricBlockSettings.of(Material.PLANT) super(FabricBlockSettings.of(Material.PLANT)
.breakByTool(FabricToolTags.SHEARS) .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) { public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return BOUNDING_SHAPES.get(state.getValue(FACING)); return BOUNDING_SHAPES.get(state.getValue(FACING));
} }
@Override @Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
ItemStack tool = builder.getParameter(LootContextParams.TOOL); 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)); return Lists.newArrayList(new ItemStack(this));
} }
else { else {
return Lists.newArrayList(); return Lists.newArrayList();
} }
} }
@Override @Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
Direction direction = state.getValue(FACING); Direction direction = state.getValue(FACING);
@ -71,12 +71,12 @@ public class SmallJellyshroomBlock extends BaseAttachedBlock implements IRenderT
BlockState support = world.getBlockState(blockPos); BlockState support = world.getBlockState(blockPos);
return canSupportCenter(world, blockPos, direction) && support.canOcclude() && support.getLightEmission() == 0; return canSupportCenter(world, blockPos, direction) && support.canOcclude() && support.getLightEmission() == 0;
} }
@Override @Override
public BCLRenderLayer getRenderLayer() { public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.CUTOUT; return BCLRenderLayer.CUTOUT;
} }
static { static {
BOUNDING_SHAPES.put(Direction.UP, Block.box(3, 0, 3, 13, 16, 13)); 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)); 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 @Override
public void performBonemeal(ServerLevel world, Random random, BlockPos pos, BlockState state) { public void performBonemeal(ServerLevel world, Random random, BlockPos pos, BlockState state) {
BlocksHelper.setWithUpdate(world, pos, Blocks.AIR); 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; package ru.betterend.blocks;
import java.util.EnumMap;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
@ -32,11 +29,13 @@ import ru.bclib.blocks.BaseAttachedBlock;
import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.IRenderTyped; import ru.bclib.interfaces.IRenderTyped;
import java.util.EnumMap;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class SmaragdantCrystalShardBlock extends BaseAttachedBlock implements IRenderTyped, SimpleWaterloggedBlock, LiquidBlockContainer { public class SmaragdantCrystalShardBlock extends BaseAttachedBlock implements IRenderTyped, SimpleWaterloggedBlock, LiquidBlockContainer {
private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class); private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class);
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
public SmaragdantCrystalShardBlock() { public SmaragdantCrystalShardBlock() {
super(FabricBlockSettings.of(Material.STONE) super(FabricBlockSettings.of(Material.STONE)
.materialColor(MaterialColor.COLOR_GREEN) .materialColor(MaterialColor.COLOR_GREEN)
@ -46,18 +45,18 @@ public class SmaragdantCrystalShardBlock extends BaseAttachedBlock implements IR
.requiresCorrectToolForDrops() .requiresCorrectToolForDrops()
.noCollission()); .noCollission());
} }
@Override @Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) { protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
super.createBlockStateDefinition(stateManager); super.createBlockStateDefinition(stateManager);
stateManager.add(WATERLOGGED); stateManager.add(WATERLOGGED);
} }
@Override @Override
public BCLRenderLayer getRenderLayer() { public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.CUTOUT; return BCLRenderLayer.CUTOUT;
} }
@Override @Override
public boolean canPlaceLiquid(BlockGetter world, BlockPos pos, BlockState state, Fluid fluid) { public boolean canPlaceLiquid(BlockGetter world, BlockPos pos, BlockState state, Fluid fluid) {
return !state.getValue(WATERLOGGED); 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) { public boolean placeLiquid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluidState) {
return !state.getValue(WATERLOGGED); return !state.getValue(WATERLOGGED);
} }
@Override @Override
public BlockState getStateForPlacement(BlockPlaceContext ctx) { public BlockState getStateForPlacement(BlockPlaceContext ctx) {
BlockState state = super.getStateForPlacement(ctx); BlockState state = super.getStateForPlacement(ctx);
@ -79,24 +78,24 @@ public class SmaragdantCrystalShardBlock extends BaseAttachedBlock implements IR
} }
return null; return null;
} }
@Override @Override
public FluidState getFluidState(BlockState state) { public FluidState getFluidState(BlockState state) {
return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : Fluids.EMPTY.defaultFluidState(); return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : Fluids.EMPTY.defaultFluidState();
} }
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) { public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return BOUNDING_SHAPES.get(state.getValue(FACING)); return BOUNDING_SHAPES.get(state.getValue(FACING));
} }
@Override @Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
Direction direction = state.getValue(FACING); Direction direction = state.getValue(FACING);
BlockPos blockPos = pos.relative(direction.getOpposite()); BlockPos blockPos = pos.relative(direction.getOpposite());
return world.getBlockState(blockPos).isFaceSturdy(world, blockPos, direction); return world.getBlockState(blockPos).isFaceSturdy(world, blockPos, direction);
} }
static { static {
BOUNDING_SHAPES.put(Direction.UP, Shapes.box(0.125, 0.0, 0.125, 0.875F, 0.875F, 0.875F)); 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)); 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; 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.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
@ -41,12 +36,16 @@ import ru.bclib.util.MHelper;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndItems; import ru.betterend.registry.EndItems;
import java.util.Collections;
import java.util.EnumMap;
import java.util.List;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class SulphurCrystalBlock extends BaseAttachedBlock implements IRenderTyped, SimpleWaterloggedBlock, LiquidBlockContainer { public class SulphurCrystalBlock extends BaseAttachedBlock implements IRenderTyped, SimpleWaterloggedBlock, LiquidBlockContainer {
private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class); private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class);
public static final IntegerProperty AGE = IntegerProperty.create("age", 0, 2); public static final IntegerProperty AGE = IntegerProperty.create("age", 0, 2);
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
public SulphurCrystalBlock() { public SulphurCrystalBlock() {
super(FabricBlockSettings.of(Material.STONE) super(FabricBlockSettings.of(Material.STONE)
.materialColor(MaterialColor.COLOR_YELLOW) .materialColor(MaterialColor.COLOR_YELLOW)
@ -55,23 +54,23 @@ public class SulphurCrystalBlock extends BaseAttachedBlock implements IRenderTyp
.requiresCorrectToolForDrops() .requiresCorrectToolForDrops()
.noCollission()); .noCollission());
} }
@Override @Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) { protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
super.createBlockStateDefinition(stateManager); super.createBlockStateDefinition(stateManager);
stateManager.add(AGE, WATERLOGGED); stateManager.add(AGE, WATERLOGGED);
} }
@Override @Override
public BCLRenderLayer getRenderLayer() { public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.CUTOUT; return BCLRenderLayer.CUTOUT;
} }
@Override @Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { 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))); return state.getValue(AGE) < 2 ? Collections.emptyList() : Lists.newArrayList(new ItemStack(EndItems.CRYSTALLINE_SULPHUR, MHelper.randRange(1, 3, MHelper.RANDOM)));
} }
@Override @Override
public boolean canPlaceLiquid(BlockGetter world, BlockPos pos, BlockState state, Fluid fluid) { public boolean canPlaceLiquid(BlockGetter world, BlockPos pos, BlockState state, Fluid fluid) {
return !state.getValue(WATERLOGGED); 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) { public boolean placeLiquid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluidState) {
return !state.getValue(WATERLOGGED); return !state.getValue(WATERLOGGED);
} }
@Override @Override
public BlockState getStateForPlacement(BlockPlaceContext ctx) { public BlockState getStateForPlacement(BlockPlaceContext ctx) {
BlockState state = super.getStateForPlacement(ctx); BlockState state = super.getStateForPlacement(ctx);
@ -93,24 +92,24 @@ public class SulphurCrystalBlock extends BaseAttachedBlock implements IRenderTyp
} }
return null; return null;
} }
@Override @Override
public FluidState getFluidState(BlockState state) { public FluidState getFluidState(BlockState state) {
return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : Fluids.EMPTY.defaultFluidState(); return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : Fluids.EMPTY.defaultFluidState();
} }
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) { public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return BOUNDING_SHAPES.get(state.getValue(FACING)); return BOUNDING_SHAPES.get(state.getValue(FACING));
} }
@Override @Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
Direction direction = state.getValue(FACING); Direction direction = state.getValue(FACING);
BlockPos blockPos = pos.relative(direction.getOpposite()); BlockPos blockPos = pos.relative(direction.getOpposite());
return world.getBlockState(blockPos).is(EndBlocks.BRIMSTONE); return world.getBlockState(blockPos).is(EndBlocks.BRIMSTONE);
} }
static { static {
BOUNDING_SHAPES.put(Direction.UP, Shapes.box(0.125, 0.0, 0.125, 0.875F, 0.5, 0.875F)); 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)); 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; package ru.betterend.blocks;
import java.util.Random;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.minecraft.client.color.block.BlockColor; import net.minecraft.client.color.block.BlockColor;
@ -18,9 +16,11 @@ import ru.bclib.util.ColorUtil;
import ru.bclib.util.MHelper; import ru.bclib.util.MHelper;
import ru.betterend.registry.EndParticles; import ru.betterend.registry.EndParticles;
import java.util.Random;
public class TenaneaFlowersBlock extends BaseVineBlock implements IColorProvider { public class TenaneaFlowersBlock extends BaseVineBlock implements IColorProvider {
public static final Vec3i[] COLORS; public static final Vec3i[] COLORS;
public TenaneaFlowersBlock() { public TenaneaFlowersBlock() {
super(15); super(15);
} }
@ -30,22 +30,23 @@ public class TenaneaFlowersBlock extends BaseVineBlock implements IColorProvider
return (state, world, pos, tintIndex) -> { return (state, world, pos, tintIndex) -> {
if (pos == null) { if (pos == null) {
pos = BlockPos.ZERO; pos = BlockPos.ZERO;
}; }
;
long i = (MHelper.getRandom(pos.getX(), pos.getZ()) & 63) + pos.getY(); long i = (MHelper.getRandom(pos.getX(), pos.getZ()) & 63) + pos.getY();
double delta = i * 0.1; double delta = i * 0.1;
int index = MHelper.floor(delta); int index = MHelper.floor(delta);
int index2 = (index + 1) & 3; int index2 = (index + 1) & 3;
delta -= index; delta -= index;
index &= 3; index &= 3;
Vec3i color1 = COLORS[index]; Vec3i color1 = COLORS[index];
Vec3i color2 = COLORS[index2]; Vec3i color2 = COLORS[index2];
int r = MHelper.floor(Mth.lerp(delta, color1.getX(), color2.getX())); int r = MHelper.floor(Mth.lerp(delta, color1.getX(), color2.getX()));
int g = MHelper.floor(Mth.lerp(delta, color1.getY(), color2.getY())); int g = MHelper.floor(Mth.lerp(delta, color1.getY(), color2.getY()));
int b = MHelper.floor(Mth.lerp(delta, color1.getZ(), color2.getZ())); int b = MHelper.floor(Mth.lerp(delta, color1.getZ(), color2.getZ()));
float[] hsb = ColorUtil.RGBtoHSB(r, g, b, new float[3]); float[] hsb = ColorUtil.RGBtoHSB(r, g, b, new float[3]);
return ColorUtil.HSBtoRGB(hsb[0], MHelper.max(0.5F, hsb[1]), hsb[2]); 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() { public ItemColor getItemProvider() {
return (stack, tintIndex) -> ColorUtil.color(255, 255, 255); return (stack, tintIndex) -> ColorUtil.color(255, 255, 255);
} }
@Override @Override
public boolean isValidBonemealTarget(BlockGetter world, BlockPos pos, BlockState state, boolean isClient) { public boolean isValidBonemealTarget(BlockGetter world, BlockPos pos, BlockState state, boolean isClient) {
return false; return false;
} }
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public void animateTick(BlockState state, Level world, BlockPos pos, Random random) { public void animateTick(BlockState state, Level world, BlockPos pos, Random random) {
super.animateTick(state, world, pos, 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); world.addParticle(EndParticles.TENANEA_PETAL, x, y, z, 0, 0, 0);
} }
} }
static { static {
COLORS = new Vec3i[] { COLORS = new Vec3i[]{
new Vec3i(250, 111, 222), new Vec3i(250, 111, 222),
new Vec3i(167, 89, 255), new Vec3i(167, 89, 255),
new Vec3i(120, 207, 239), new Vec3i(120, 207, 239),
new Vec3i(255, 87, 182) new Vec3i(255, 87, 182)
}; };
} }
} }

View file

@ -17,7 +17,7 @@ public class TenaneaSaplingBlock extends FeatureSaplingBlock {
protected Feature<?> getFeature() { protected Feature<?> getFeature() {
return EndFeatures.TENANEA.getFeature(); return EndFeatures.TENANEA.getFeature();
} }
@Override @Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
return world.getBlockState(pos.below()).is(EndBlocks.PINK_MOSS); 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 { public class TerrainPlantBlock extends EndPlantBlock {
private final Block[] ground; private final Block[] ground;
public TerrainPlantBlock(Block... ground) { public TerrainPlantBlock(Block... ground) {
super(true); super(true);
this.ground = ground; this.ground = ground;
} }
@Override @Override
protected boolean isTerrain(BlockState state) { protected boolean isTerrain(BlockState state) {
for (Block block: ground) { for (Block block : ground) {
if (state.is(block)) { if (state.is(block)) {
return true; return true;
} }

View file

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

View file

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

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.Random;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.item.ItemEntity; 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.bclib.blocks.BaseDoublePlantBlock;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class UmbrellaMossTallBlock extends BaseDoublePlantBlock { public class UmbrellaMossTallBlock extends BaseDoublePlantBlock {
public UmbrellaMossTallBlock() { public UmbrellaMossTallBlock() {
super(12); super(12);
} }
@Override @Override
public void performBonemeal(ServerLevel world, Random random, BlockPos pos, BlockState state) { 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)); 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); world.addFreshEntity(item);
} }
@Override @Override
protected boolean isTerrain(BlockState state) { protected boolean isTerrain(BlockState state) {
return state.is(EndBlocks.END_MOSS) || state.is(EndBlocks.END_MYCELIUM) || state.is(EndBlocks.JUNGLE_MOSS); 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 class UmbrellaTreeClusterBlock extends BaseBlock {
public static final BooleanProperty NATURAL = BlockProperties.NATURAL; public static final BooleanProperty NATURAL = BlockProperties.NATURAL;
public UmbrellaTreeClusterBlock() { public UmbrellaTreeClusterBlock() {
super(FabricBlockSettings.copyOf(Blocks.NETHER_WART_BLOCK) super(FabricBlockSettings.copyOf(Blocks.NETHER_WART_BLOCK)
.materialColor(MaterialColor.COLOR_PURPLE) .materialColor(MaterialColor.COLOR_PURPLE)
.luminance(15)); .luminance(15));
registerDefaultState(stateDefinition.any().setValue(NATURAL, false)); registerDefaultState(stateDefinition.any().setValue(NATURAL, false));
} }
@Override @Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) { protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
stateManager.add(NATURAL); stateManager.add(NATURAL);
} }
@Override @Override
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
ItemStack stack = player.getMainHandItem(); ItemStack stack = player.getMainHandItem();

View file

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

View file

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

View file

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

View file

@ -1,7 +1,5 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import java.util.Random;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
@ -9,9 +7,12 @@ import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.core.particles.ParticleTypes; import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource; import net.minecraft.sounds.SoundSource;
import net.minecraft.world.entity.Entity; 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.BlockGetter;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.LevelAccessor;
@ -32,17 +33,20 @@ import net.minecraft.world.phys.shapes.VoxelShape;
import ru.bclib.util.BlocksHelper; import ru.bclib.util.BlocksHelper;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import java.util.Optional;
import java.util.Random;
public class VentBubbleColumnBlock extends Block implements BucketPickup, LiquidBlockContainer { public class VentBubbleColumnBlock extends Block implements BucketPickup, LiquidBlockContainer {
public VentBubbleColumnBlock() { public VentBubbleColumnBlock() {
super(FabricBlockSettings.of(Material.BUBBLE_COLUMN).noOcclusion().noCollission().noDrops()); super(FabricBlockSettings.of(Material.BUBBLE_COLUMN).noOcclusion().noCollission().noDrops());
} }
@Override @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); world.setBlock(pos, Blocks.AIR.defaultBlockState(), 11);
return Fluids.WATER; return new ItemStack(Items.WATER_BUCKET);
} }
@Override @Override
public RenderShape getRenderShape(BlockState state) { public RenderShape getRenderShape(BlockState state) {
return RenderShape.INVISIBLE; return RenderShape.INVISIBLE;
@ -105,7 +109,7 @@ public class VentBubbleColumnBlock extends Block implements BucketPickup, Liquid
entity.onInsideBubbleColumn(false); entity.onInsideBubbleColumn(false);
} }
} }
@Override @Override
public boolean canPlaceLiquid(BlockGetter world, BlockPos pos, BlockState state, Fluid fluid) { public boolean canPlaceLiquid(BlockGetter world, BlockPos pos, BlockState state, Fluid fluid) {
return false; 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) { public boolean placeLiquid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluidState) {
return false; return false;
} }
@Override @Override
public FluidState getFluidState(BlockState state) { public FluidState getFluidState(BlockState state) {
return Fluids.WATER.getSource(false); 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; package ru.betterend.blocks.basis;
import java.util.List;
import java.util.Objects;
import net.minecraft.world.item.Item; import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.context.BlockPlaceContext; 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.blocks.complex.MetalMaterial;
import ru.betterend.item.EndAnvilItem; import ru.betterend.item.EndAnvilItem;
import java.util.List;
import java.util.Objects;
public class EndAnvilBlock extends BaseAnvilBlock { public class EndAnvilBlock extends BaseAnvilBlock {
protected final int level; protected final int level;
protected IntegerProperty durability; protected IntegerProperty durability;
protected MetalMaterial metalMaterial; protected MetalMaterial metalMaterial;
protected int maxDurability; protected int maxDurability;
public EndAnvilBlock(MaterialColor color, int level) { public EndAnvilBlock(MaterialColor color, int level) {
super(color); super(color);
this.level = level; this.level = level;
@ -81,7 +81,7 @@ public class EndAnvilBlock extends BaseAnvilBlock {
super.createBlockStateDefinition(builder); super.createBlockStateDefinition(builder);
builder.add(getDurability()); builder.add(getDurability());
} }
public int getCraftingLevel() { public int getCraftingLevel() {
return level; return level;
} }
@ -109,7 +109,8 @@ public class EndAnvilBlock extends BaseAnvilBlock {
if (destructionProperty.getPossibleValues().contains(destruction)) { if (destructionProperty.getPossibleValues().contains(destruction)) {
try { try {
return fallingState.setValue(destructionProperty, destruction); return fallingState.setValue(destructionProperty, destruction);
} catch (Exception ex) { }
catch (Exception ex) {
return null; return null;
} }
} }

View file

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

View file

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

View file

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

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