Compare commits

..

No commits in common. "0.12.1-pre" and "1.16.5" have entirely different histories.

1747 changed files with 11842 additions and 20808 deletions

5
.gitignore vendored
View file

@ -27,8 +27,5 @@ bin/
# fabric # fabric
run/ run/
run-client/
output/ output/
*.getBlock("log") *.log
Convert.class
ModelPart.class

View file

@ -1,161 +0,0 @@
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 + "\");");
}
}
}
ModelPart.print();
}
void setRotationAngle(ModelPart p, float x, float y, float z){
p.setRotationAngle(x, y, z);
}
public void c (){
float scale = 1;
ModelPart[] SHARDS = new ModelPart[4];
SHARDS[0] = new ModelPart(16, 16, 2, 4, "SHARDS[0]").addBox(-5.0F, 1.0F, -3.0F, 2.0F, 8.0F, 2.0F);
SHARDS[1] = new ModelPart(16, 16, 2, 4, "SHARDS[1]").addBox(3.0F, -1.0F, -1.0F, 2.0F, 8.0F, 2.0F);
SHARDS[2] = new ModelPart(16, 16, 2, 4, "SHARDS[2]").addBox(-1.0F, 0.0F, -5.0F, 2.0F, 4.0F, 2.0F);
SHARDS[3] = new ModelPart(16, 16, 2, 4, "SHARDS[3]").addBox(0.0F, 3.0F, 4.0F, 2.0F, 6.0F, 2.0F);
ModelPart CORE = new ModelPart(16, 16, 0, 0, "CORE");
CORE.addBox(-2.0F, -2.0F, -2.0F, 4.0F, 12.0F, 4.0F);
}
}

View file

@ -1,19 +1,17 @@
[![](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
* Edit gradle.properties if necessary * Edit gradle.properties if necessary
* Run command line in folder: gradlew genSources eclipse (or Another-IDE-Name) * Run command line in folder: gradlew genSources eclipse (or Another-IDE-Name)
* Import project to IDE * Import project to IDE
Building: Building:
* Clone repo * Clone repo
* Run command line in folder: gradlew build * Run command line in folder: gradlew build
* Mod .jar will be in ./build/libs * Mod .jar will be in ./build/libs
Mappings:
* https://modmuss50.me/fabric.html?&version=1.16.4

View file

@ -7,20 +7,20 @@ buildscript {
plugins { plugins {
id 'idea' id 'idea'
id 'eclipse' id 'eclipse'
id 'fabric-loom' version '0.8-SNAPSHOT' id 'fabric-loom' version '0.7-SNAPSHOT'
id 'maven-publish' id 'maven-publish'
} }
sourceCompatibility = JavaVersion.VERSION_16 sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_16 targetCompatibility = JavaVersion.VERSION_1_8
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
def local_bclib = findProject(':BCLib') != null
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,46 +33,37 @@ 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.17-${project.patchouli_version}" useApi "vazkii.patchouli:Patchouli:1.16.4-${project.patchouli_version}"
println "Using local BCLib: ${local_bclib}" useApi "com.github.paulevsGitch:BCLib:${project.bclib_version}"
if (local_bclib){
implementation( project(path:":BCLib", configuration: 'dev') )
} else {
modImplementation "com.github.paulevsGitch:BCLib:${project.bclib_version}"
}
useOptional "me.shedaniel:RoughlyEnoughItems-fabric:${project.rei_version}" useOptional "me.shedaniel:RoughlyEnoughItems:${project.rei_version}"
useOptional "me.shedaniel:RoughlyEnoughItems-api-fabric:${project.rei_version}" useOptional "me.shedaniel:RoughlyEnoughItems-api:${project.rei_version}"
//useOptional "grondag:canvas-mc116:${project.canvas_version}" //useOptional "grondag:canvas-mc116:${project.canvas_version}"
} }
def useOptional(String dep) { def useOptional(String dep) {
dependencies.modRuntime(dep) { dependencies.modRuntime (dep) {
exclude group: 'net.fabricmc.fabric-api' exclude group: "net.fabricmc.fabric-api"
exclude group: 'net.fabricmc' exclude group: "net.fabricmc"
if (!dep.contains("me.shedaniel")) { if (!dep.contains("me.shedaniel")) {
exclude group: 'me.shedaniel.cloth' exclude group: "me.shedaniel"
exclude group: 'me.shedaniel'
} }
} }
dependencies.modCompileOnly(dep) { dependencies.modCompileOnly (dep) {
exclude group: 'net.fabricmc.fabric-api' exclude group: "net.fabricmc.fabric-api"
exclude group: 'net.fabricmc' exclude group: "net.fabricmc"
if (!dep.contains("me.shedaniel")) { if (!dep.contains("me.shedaniel")) {
exclude group: 'me.shedaniel.cloth' exclude group: "me.shedaniel"
exclude group: 'me.shedaniel'
} }
} }
} }
def useApi(String dep) { def useApi(String dep) {
dependencies.modApi(dep) { dependencies.modApi (dep) {
exclude group: 'net.fabricmc.fabric-api' exclude group: "net.fabricmc.fabric-api"
exclude group: 'net.fabricmc' exclude group: "net.fabricmc"
exclude group: 'com.terraformersmc'
if (!dep.contains("me.shedaniel")) { if (!dep.contains("me.shedaniel")) {
exclude group: 'me.shedaniel.cloth' exclude group: "me.shedaniel"
exclude group: 'me.shedaniel'
} }
} }
} }
@ -85,10 +76,6 @@ processResources {
include "fabric.mod.json" include "fabric.mod.json"
expand "version": project.version expand "version": project.version
} }
from(sourceSets.main.resources.srcDirs) {
exclude "fabric.mod.json"
}
} }
// ensure that the encoding is set to UTF-8, no matter what the system default is // ensure that the encoding is set to UTF-8, no matter what the system default is

View file

@ -1,20 +1,21 @@
# Done to increase the memory available to gradle. # Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx2G 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.17.1 minecraft_version=1.16.5
yarn_mappings=6 yarn_mappings=6
loader_version=0.11.6 loader_version=0.11.3
# Mod Properties # Mod Properties
mod_version=0.12.1-pre mod_version = 0.9.8-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 = 50-FABRIC
patchouli_version = 55-FABRIC-SNAPSHOT fabric_version = 0.32.9+1.16
fabric_version = 0.36.1+1.17
bclib_version = 0.4.2
rei_version = 6.0.264-alpha
canvas_version = 1.0.+ canvas_version = 1.0.+
bclib_version = 0.1.38
rei_version = 5.8.10

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.1-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

View file

@ -1,6 +0,0 @@
# From https://github.com/jitpack/jitpack.io/issues/4506#issuecomment-864562270
before_install:
- source "$HOME/.sdkman/bin/sdkman-init.sh"
- sdk update
- sdk install java 16.0.1.hs-adpt
- sdk use java 16.0.1.hs-adpt

View file

@ -1,16 +1,7 @@
{ {
"variants": { "variants": {
"axis=x": { "axis=x": { "model": "betterend:block/%name%_pillar", "x": 90, "y": 90 },
"model": "betterend:block/%name%_pillar", "axis=y": { "model": "betterend:block/%name%_pillar" },
"x": 90, "axis=z": { "model": "betterend:block/%name%_pillar", "x": 90 }
"y": 90
},
"axis=y": {
"model": "betterend:block/%name%_pillar"
},
"axis=z": {
"model": "betterend:block/%name%_pillar",
"x": 90
}
} }
} }

View file

@ -1,6 +1,5 @@
pluginManagement { pluginManagement {
repositories { repositories {
jcenter()
maven { maven {
name = 'Fabric' name = 'Fabric'
url = 'https://maven.fabricmc.net/' url = 'https://maven.fabricmc.net/'
@ -8,39 +7,3 @@ pluginManagement {
gradlePluginPortal() gradlePluginPortal()
} }
} }
// #### Custom Settings ####
//Change the next line to disable local BCLib loading
def allowLocalLibUse = false
//When true, the local BCLib is also used in commandline builds
def allowLocalLibInConsoleMode = false
//The path were to look for the local BCLib
def BCLibPath = '../BCLib'
// #### Logic ####
def isIDE = properties.containsKey('android.injected.invoked.from.ide')
|| (System.getenv("XPC_SERVICE_NAME") ?: "").contains("intellij")
|| (System.getenv("XPC_SERVICE_NAME") ?: "").contains(".idea")
|| System.getenv("IDEA_INITIAL_DIRECTORY") != null
println "IntelliJ: ${isIDE}"
def BCLibFolder = new File( BCLibPath )
if( allowLocalLibUse && (isIDE || allowLocalLibInConsoleMode) && BCLibFolder.exists() ) {
println "Using local BCLib from '${BCLibFolder}' in IntelliJ"
println "If you do not want to load the local version of BClib"
println "either rename the Folder containing BCLib to something"
println "else, or set 'allowLocalLibUse' in settings.gradle"
println "to false."
println ""
println "If you receive version-errors when launching minecraft"
println "in IntelliJ, make sure you have set up gradle instead"
println "of IntelliJ to compile and run."
include ':BCLib'
project(":BCLib").projectDir = BCLibFolder
project(':BCLib').buildFileName = './bclib-composit.gradle'
}

View file

@ -7,6 +7,7 @@ import ru.bclib.api.WorldDataAPI;
import ru.bclib.util.Logger; import ru.bclib.util.Logger;
import ru.betterend.api.BetterEndPlugin; import ru.betterend.api.BetterEndPlugin;
import ru.betterend.config.Configs; import ru.betterend.config.Configs;
import ru.betterend.effects.EndEnchantments;
import ru.betterend.effects.EndPotions; import ru.betterend.effects.EndPotions;
import ru.betterend.integration.Integrations; import ru.betterend.integration.Integrations;
import ru.betterend.recipe.AlloyingRecipes; import ru.betterend.recipe.AlloyingRecipes;
@ -17,7 +18,6 @@ import ru.betterend.recipe.InfusionRecipes;
import ru.betterend.recipe.SmithingRecipes; import ru.betterend.recipe.SmithingRecipes;
import ru.betterend.registry.EndBiomes; import ru.betterend.registry.EndBiomes;
import ru.betterend.registry.EndBlockEntities; import ru.betterend.registry.EndBlockEntities;
import ru.betterend.registry.EndEnchantments;
import ru.betterend.registry.EndEntities; import ru.betterend.registry.EndEntities;
import ru.betterend.registry.EndFeatures; import ru.betterend.registry.EndFeatures;
import ru.betterend.registry.EndPortals; import ru.betterend.registry.EndPortals;
@ -26,8 +26,8 @@ import ru.betterend.registry.EndStructures;
import ru.betterend.registry.EndTags; import ru.betterend.registry.EndTags;
import ru.betterend.util.BonemealPlants; import ru.betterend.util.BonemealPlants;
import ru.betterend.util.LootTableUtil; import ru.betterend.util.LootTableUtil;
import ru.betterend.world.generator.BetterEndBiomeSource;
import ru.betterend.world.generator.GeneratorOptions; import ru.betterend.world.generator.GeneratorOptions;
import ru.betterend.world.generator.TerrainGenerator;
import ru.betterend.world.surface.SurfaceBuilders; import ru.betterend.world.surface.SurfaceBuilders;
public class BetterEnd implements ModInitializer { public class BetterEnd implements ModInitializer {
@ -44,6 +44,7 @@ public class BetterEnd implements ModInitializer {
EndEntities.register(); EndEntities.register();
SurfaceBuilders.register(); SurfaceBuilders.register();
EndBiomes.register(); EndBiomes.register();
BetterEndBiomeSource.register();
EndTags.register(); EndTags.register();
EndEnchantments.register(); EndEnchantments.register();
EndPotions.register(); EndPotions.register();
@ -59,13 +60,7 @@ public class BetterEnd implements ModInitializer {
LootTableUtil.init(); LootTableUtil.init();
FabricLoader.getInstance().getEntrypoints("betterend", BetterEndPlugin.class).forEach(BetterEndPlugin::register); FabricLoader.getInstance().getEntrypoints("betterend", BetterEndPlugin.class).forEach(BetterEndPlugin::register);
Integrations.init(); Integrations.init();
DataFixer.register();
Configs.saveConfigs(); Configs.saveConfigs();
if (GeneratorOptions.useNewGenerator()) {
ru.bclib.world.generator.GeneratorOptions.setFarEndBiomes(GeneratorOptions.getIslandDistBlock() > 250000L);
ru.bclib.world.generator.GeneratorOptions.setEndLandFunction((pos) -> TerrainGenerator.isLand(pos.x, pos.y));
}
} }
public static ResourceLocation makeID(String path) { public static ResourceLocation makeID(String path) {

View file

@ -1,33 +0,0 @@
package ru.betterend;
import ru.bclib.api.datafixer.DataFixerAPI;
import ru.bclib.api.datafixer.Patch;
public class DataFixer {
public static void register() {
DataFixerAPI.registerPatch(() -> {
return new BetterEndPatch();
});
}
private static final class BetterEndPatch extends Patch {
protected BetterEndPatch() {
super(BetterEnd.MOD_ID, "0.11.0");
}
/*public PatchFunction<CompoundTag, Boolean> getLevelDatPatcher() {
return (root, profile) -> {
CompoundTag dimensions = root.getCompound("Data").getCompound("WorldGenSettings").getCompound("dimensions");
if (dimensions.contains("minecraft:the_end")) {
CompoundTag biomeSource = dimensions.getCompound("minecraft:the_end").getCompound("generator").getCompound("biome_source");
if (!biomeSource.getString("type").equals("betterend:better_end_biome_source")) {
BetterEnd.LOGGER.info("Applying biome source patch");
biomeSource.putString("type", "betterend:better_end_biome_source");
return true;
}
}
return false;
};
}*/
}
}

View file

@ -5,28 +5,24 @@ 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, EndITEM_HAMMERS. * 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) {

View file

@ -1,16 +1,33 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import ru.betterend.blocks.basis.EndAnvilBlock; import ru.betterend.blocks.basis.EndAnvilBlock;
import ru.betterend.item.EndAnvilItem;
import ru.betterend.item.material.EndToolMaterial; import ru.betterend.item.material.EndToolMaterial;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndItems;
public class AeterniumAnvil extends EndAnvilBlock { public class AeterniumAnvil extends EndAnvilBlock {
protected final Item anvilItem;
public AeterniumAnvil() { public AeterniumAnvil() {
super(EndBlocks.AETERNIUM_BLOCK.defaultMaterialColor(), EndToolMaterial.AETERNIUM.getLevel()); super(EndBlocks.AETERNIUM_BLOCK.defaultMaterialColor(), EndToolMaterial.AETERNIUM.getLevel());
this.anvilItem = EndItems.registerEndItem("aeternuim_anvil_item", new EndAnvilItem(this));
} }
@Override @Override
public int getMaxDurability() { public IntegerProperty getDurability() {
return 8; if (durability == null) {
this.maxDurability = 8;
this.durability = IntegerProperty.create("durability", 0, maxDurability);
}
return durability;
}
@Override
public Item asItem() {
return anvilItem;
} }
} }

View file

@ -6,9 +6,9 @@ import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.material.Material; import net.minecraft.world.level.material.Material;
import ru.bclib.blocks.BaseBlock; import ru.bclib.blocks.BaseBlock;
import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.RenderLayerProvider; import ru.bclib.interfaces.IRenderTyped;
public class AmaranitaHymenophoreBlock extends BaseBlock implements RenderLayerProvider { public class AmaranitaHymenophoreBlock extends BaseBlock implements IRenderTyped {
public AmaranitaHymenophoreBlock() { public AmaranitaHymenophoreBlock() {
super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).sound(SoundType.WOOD)); super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).sound(SoundType.WOOD));
} }

View file

@ -1,14 +1,16 @@
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;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity;
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;
import net.minecraft.world.item.enchantment.Enchantments; import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.level.Level;
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.storage.loot.LootContext; import net.minecraft.world.level.storage.loot.LootContext;
@ -19,10 +21,6 @@ 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());
@ -56,17 +54,7 @@ public class AncientEmeraldIceBlock extends BaseBlock {
} }
private void makeParticles(ServerLevel world, BlockPos pos, Random random) { private void makeParticles(ServerLevel world, BlockPos pos, Random random) {
world.sendParticles( world.sendParticles(EndParticles.SNOWFLAKE, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 20, 0.5, 0.5, 0.5, 0);
EndParticles.SNOWFLAKE,
pos.getX() + 0.5,
pos.getY() + 0.5,
pos.getZ() + 0.5,
20,
0.5,
0.5,
0.5,
0
);
} }
@Override @Override
@ -79,10 +67,4 @@ public class AncientEmeraldIceBlock extends BaseBlock {
return Collections.emptyList(); return Collections.emptyList();
} }
} }
@Override
public void stepOn(Level level, BlockPos blockPos, BlockState blockState, Entity entity) {
super.stepOn(level, blockPos, blockState, entity);
entity.setIsInPowderSnow(true);
}
} }

View file

@ -1,6 +1,9 @@
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;
@ -11,35 +14,29 @@ import net.minecraft.util.Mth;
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;
import net.minecraft.world.item.enchantment.Enchantments; import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.AbstractGlassBlock; import net.minecraft.world.level.block.AbstractGlassBlock;
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.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 net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import ru.bclib.api.TagAPI;
import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.CustomColorProvider; import ru.bclib.interfaces.IColorProvider;
import ru.bclib.interfaces.RenderLayerProvider; 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 RenderLayerProvider, CustomColorProvider {
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 super(FabricBlockSettings.of(Material.GLASS)
.of(Material.GLASS)
.breakByTool(FabricToolTags.PICKAXES) .breakByTool(FabricToolTags.PICKAXES)
.breakByTool(TagAPI.ITEM_HAMMERS) .breakByTool(EndTags.HAMMERS)
.hardness(1F) .hardness(1F)
.resistance(1F) .resistance(1F)
.luminance(15) .luminance(15)
@ -48,19 +45,12 @@ public class AuroraCrystalBlock extends AbstractGlassBlock implements RenderLaye
.sound(SoundType.GLASS)); .sound(SoundType.GLASS));
} }
@Override
@Deprecated
public VoxelShape getVisualShape(BlockState blockState, BlockGetter blockGetter, BlockPos blockPos, CollisionContext collisionContext) {
return this.getCollisionShape(blockState, blockGetter, blockPos, collisionContext);
}
@Override @Override
public BlockColor getProvider() { public BlockColor getProvider() {
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;
@ -109,8 +99,7 @@ public class AuroraCrystalBlock extends AbstractGlassBlock implements RenderLaye
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));

View file

@ -21,10 +21,7 @@ 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) super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).luminance(15).sound(SoundType.WART_BLOCK));
.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));
} }

View file

@ -1,5 +1,7 @@
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;
@ -12,8 +14,6 @@ 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) {
@ -22,51 +22,24 @@ public class BlueVineSeedBlock extends EndPlantWithAgeBlock {
if (h < height + 1) { if (h < height + 1) {
return; return;
} }
BlocksHelper.setWithoutUpdate( BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.BLUE_VINE.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE, BlockProperties.TripleShape.BOTTOM));
world,
pos,
EndBlocks.BLUE_VINE.defaultBlockState()
.setValue(BlockProperties.TRIPLE_SHAPE, BlockProperties.TripleShape.BOTTOM)
);
for (int i = 1; i < height; i++) { for (int i = 1; i < height; i++) {
BlocksHelper.setWithoutUpdate( BlocksHelper.setWithoutUpdate(world, pos.above(i), EndBlocks.BLUE_VINE.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE, BlockProperties.TripleShape.MIDDLE));
world,
pos.above(i),
EndBlocks.BLUE_VINE.defaultBlockState()
.setValue(BlockProperties.TRIPLE_SHAPE, BlockProperties.TripleShape.MIDDLE)
);
} }
BlocksHelper.setWithoutUpdate( BlocksHelper.setWithoutUpdate(world, pos.above(height), EndBlocks.BLUE_VINE.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE, BlockProperties.TripleShape.TOP));
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( BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.BLUE_VINE_LANTERN.defaultBlockState().setValue(BlueVineLanternBlock.NATURAL, true));
world, for (Direction dir: BlocksHelper.HORIZONTAL) {
pos,
EndBlocks.BLUE_VINE_LANTERN.defaultBlockState().setValue(BlueVineLanternBlock.NATURAL, true)
);
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( BlocksHelper.setWithoutUpdate(world, p, EndBlocks.BLUE_VINE_FUR.defaultBlockState().setValue(FurBlock.FACING, dir));
world,
p,
EndBlocks.BLUE_VINE_FUR.defaultBlockState().setValue(FurBlock.FACING, dir)
);
} }
} }
if (world.isEmptyBlock(pos.above())) { if (world.isEmptyBlock(pos.above())) {
BlocksHelper.setWithoutUpdate( BlocksHelper.setWithoutUpdate(world, pos.above(), EndBlocks.BLUE_VINE_FUR.defaultBlockState().setValue(FurBlock.FACING, Direction.UP));
world,
pos.above(),
EndBlocks.BLUE_VINE_FUR.defaultBlockState().setValue(FurBlock.FACING, Direction.UP)
);
} }
} }

View file

@ -1,6 +1,10 @@
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;
@ -14,9 +18,6 @@ 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);

View file

@ -1,5 +1,9 @@
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;
@ -16,14 +20,11 @@ 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;
@ -66,7 +67,7 @@ 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,5 +1,7 @@
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;
@ -17,8 +19,6 @@ 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);

View file

@ -1,6 +1,9 @@
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;
@ -13,8 +16,6 @@ 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);
@ -41,7 +42,6 @@ public class BulbVineBlock extends BaseVineBlock {
@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);
return (state.is(this) && state.getValue(SHAPE) == TripleShape.BOTTOM) ? canPlace : canPlace && world.getBlockState( return (state.is(this) && state.getValue(SHAPE) == TripleShape.BOTTOM) ? canPlace : canPlace && world.getBlockState(pos.below()).is(this);
pos.below()).is(this);
} }
} }

View file

@ -1,8 +1,12 @@
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.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.renderer.block.model.BlockModel;
@ -16,18 +20,14 @@ 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.ModelsHelper; import ru.bclib.client.models.ModelsHelper;
import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.BlockModelProvider; import ru.bclib.interfaces.IRenderTyped;
import ru.bclib.interfaces.RenderLayerProvider;
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; public class BulbVineLanternBlock extends EndLanternBlock implements IRenderTyped, BlockModelProvider {
import java.util.Optional;
public class BulbVineLanternBlock extends EndLanternBlock implements RenderLayerProvider, 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);
@ -57,15 +57,13 @@ public class BulbVineLanternBlock extends EndLanternBlock implements RenderLayer
} }
@Override @Override
@Environment(EnvType.CLIENT)
public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) { public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
Map<String, String> textures = Maps.newHashMap(); Map<String, String> textures = Maps.newHashMap();
textures.put("%glow%", getGlowTexture()); textures.put("%glow%", getGlowTexture());
textures.put("%metal%", getMetalTexture(resourceLocation)); textures.put("%metal%", getMetalTexture(resourceLocation));
Optional<String> pattern = blockState.getValue(IS_FLOOR) ? Patterns.createJson( Optional<String> pattern = blockState.getValue(IS_FLOOR) ?
Patterns.BLOCK_BULB_LANTERN_FLOOR, Patterns.createJson(Patterns.BLOCK_BULB_LANTERN_FLOOR, textures) :
textures Patterns.createJson(Patterns.BLOCK_BULB_LANTERN_CEIL, textures);
) : Patterns.createJson(Patterns.BLOCK_BULB_LANTERN_CEIL, textures);
return ModelsHelper.fromPattern(pattern); return ModelsHelper.fromPattern(pattern);
} }

View file

@ -3,11 +3,11 @@ package ru.betterend.blocks;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.client.color.block.BlockColor; import net.minecraft.client.color.block.BlockColor;
import net.minecraft.client.color.item.ItemColor; import net.minecraft.client.color.item.ItemColor;
import ru.bclib.interfaces.CustomColorProvider; import ru.bclib.interfaces.IColorProvider;
import ru.bclib.util.BlocksHelper; import ru.bclib.util.BlocksHelper;
import ru.bclib.util.ColorUtil; import ru.bclib.util.ColorUtil;
public class BulbVineLanternColoredBlock extends BulbVineLanternBlock implements CustomColorProvider { public class BulbVineLanternColoredBlock extends BulbVineLanternBlock implements IColorProvider {
public BulbVineLanternColoredBlock(FabricBlockSettings settings) { public BulbVineLanternColoredBlock(FabricBlockSettings settings) {
super(settings); super(settings);
} }

View file

@ -1,5 +1,7 @@
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;
@ -12,37 +14,23 @@ 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
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
BlockState up = world.getBlockState(pos.above()); BlockState up = world.getBlockState(pos.above());
return up.is(TagAPI.BLOCK_GEN_TERRAIN) || up.is(BlockTags.LOGS) || up.is(BlockTags.LEAVES); return up.is(TagAPI.GEN_TERRAIN) || up.is(BlockTags.LOGS) || up.is(BlockTags.LEAVES);
} }
@Override @Override
public void growAdult(WorldGenLevel world, Random random, BlockPos pos) { public void growAdult(WorldGenLevel world, Random random, BlockPos pos) {
int h = BlocksHelper.downRay(world, pos, random.nextInt(24)) - 1; int h = BlocksHelper.downRay(world, pos, random.nextInt(24)) - 1;
if (h > 2) { if (h > 2) {
BlocksHelper.setWithoutUpdate( BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.BULB_VINE.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP));
world,
pos,
EndBlocks.BULB_VINE.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP)
);
for (int i = 1; i < h; i++) { for (int i = 1; i < h; i++) {
BlocksHelper.setWithoutUpdate( BlocksHelper.setWithoutUpdate(world, pos.below(i), EndBlocks.BULB_VINE.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE));
world,
pos.below(i),
EndBlocks.BULB_VINE.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE)
);
} }
BlocksHelper.setWithoutUpdate( BlocksHelper.setWithoutUpdate(world, pos.below(h), EndBlocks.BULB_VINE.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM));
world,
pos.below(h),
EndBlocks.BULB_VINE.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM)
);
} }
} }
} }

View file

@ -1,5 +1,8 @@
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;
@ -16,13 +19,10 @@ import net.minecraft.world.phys.shapes.VoxelShape;
import ru.bclib.blocks.BaseBlockNotFull; import ru.bclib.blocks.BaseBlockNotFull;
import ru.bclib.blocks.BlockProperties; import ru.bclib.blocks.BlockProperties;
import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.RenderLayerProvider; import ru.bclib.interfaces.IRenderTyped;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import java.util.Collections; public class CavePumpkinBlock extends BaseBlockNotFull implements IRenderTyped {
import java.util.List;
public class CavePumpkinBlock extends BaseBlockNotFull implements RenderLayerProvider {
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;
@ -49,8 +49,7 @@ public class CavePumpkinBlock extends BaseBlockNotFull implements RenderLayerPro
@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 return state.getValue(SMALL) ? Collections.singletonList(new ItemStack(EndBlocks.CAVE_PUMPKIN_SEED)) : Collections.singletonList(new ItemStack(this));
.singletonList(new ItemStack(this));
} }
static { static {
@ -59,7 +58,7 @@ public class CavePumpkinBlock extends BaseBlockNotFull implements RenderLayerPro
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(5, 7, 5, 11, 13, 11); lantern = Block.box(1, 7, 1, 15, 13, 15);
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,5 +1,7 @@
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;
@ -16,8 +18,6 @@ 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);
@ -31,16 +31,12 @@ public class CavePumpkinVineBlock extends EndPlantWithAgeBlock {
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);
BlockState down = world.getBlockState(pos.below()); BlockState down = world.getBlockState(pos.below());
if (down.getMaterial() if (down.getMaterial().isReplaceable() || (down.is(EndBlocks.CAVE_PUMPKIN) && down.getValue(BlockProperties.SMALL))) {
.isReplaceable() || (down.is(EndBlocks.CAVE_PUMPKIN) && down.getValue(BlockProperties.SMALL))) {
if (age < 3) { if (age < 3) {
world.setBlockAndUpdate(pos, state.setValue(AGE, age + 1)); world.setBlockAndUpdate(pos, state.setValue(AGE, age + 1));
} }
if (age == 2) { if (age == 2) {
world.setBlockAndUpdate( world.setBlockAndUpdate(pos.below(), EndBlocks.CAVE_PUMPKIN.defaultBlockState().setValue(BlockProperties.SMALL, true));
pos.below(),
EndBlocks.CAVE_PUMPKIN.defaultBlockState().setValue(BlockProperties.SMALL, true)
);
} }
else if (age == 3) { else if (age == 3) {
world.setBlockAndUpdate(pos.below(), EndBlocks.CAVE_PUMPKIN.defaultBlockState()); world.setBlockAndUpdate(pos.below(), EndBlocks.CAVE_PUMPKIN.defaultBlockState());
@ -49,8 +45,7 @@ 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) {

View file

@ -1,8 +1,13 @@
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.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.resources.model.BlockModelRotation; import net.minecraft.client.resources.model.BlockModelRotation;
@ -16,27 +21,18 @@ 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.ModelsHelper; import ru.bclib.client.models.ModelsHelper;
import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.BlockModelProvider; import ru.bclib.interfaces.IRenderTyped;
import ru.bclib.interfaces.RenderLayerProvider;
import ru.betterend.client.models.Patterns; import ru.betterend.client.models.Patterns;
import java.util.EnumMap; public class ChandelierBlock extends BaseAttachedBlock implements IRenderTyped, BlockModelProvider {
import java.util.Map;
import java.util.Optional;
public class ChandelierBlock extends BaseAttachedBlock implements RenderLayerProvider, 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) super(FabricBlockSettings.copyOf(source).luminance(15).noCollission().noOcclusion().requiresCorrectToolForDrops());
.luminance(15)
.noCollission()
.noOcclusion()
.requiresCorrectToolForDrops());
} }
@Override @Override
@ -50,13 +46,11 @@ public class ChandelierBlock extends BaseAttachedBlock implements RenderLayerPro
} }
@Override @Override
@Environment(EnvType.CLIENT)
public BlockModel getItemModel(ResourceLocation blockId) { public BlockModel getItemModel(ResourceLocation blockId) {
return ModelsHelper.createItemModel(blockId); return ModelsHelper.createItemModel(blockId);
} }
@Override @Override
@Environment(EnvType.CLIENT)
public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) { public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
Optional<String> pattern; Optional<String> pattern;
switch (blockState.getValue(FACING)) { switch (blockState.getValue(FACING)) {
@ -73,7 +67,6 @@ public class ChandelierBlock extends BaseAttachedBlock implements RenderLayerPro
} }
@Override @Override
@Environment(EnvType.CLIENT)
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) { public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
String state = "_wall"; String state = "_wall";
BlockModelRotation rotation = BlockModelRotation.X0_Y0; BlockModelRotation rotation = BlockModelRotation.X0_Y0;

View file

@ -1,5 +1,8 @@
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;
@ -10,12 +13,9 @@ 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 ru.bclib.client.render.BCLRenderLayer; import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.RenderLayerProvider; import ru.bclib.interfaces.IRenderTyped;
import java.util.Collections; public class DenseEmeraldIceBlock extends BaseBlock implements IRenderTyped {
import java.util.List;
public class DenseEmeraldIceBlock extends BaseBlock implements RenderLayerProvider {
public DenseEmeraldIceBlock() { public DenseEmeraldIceBlock() {
super(FabricBlockSettings.copyOf(Blocks.PACKED_ICE)); super(FabricBlockSettings.copyOf(Blocks.PACKED_ICE));
} }

View file

@ -2,14 +2,13 @@ package ru.betterend.blocks;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.feature.Feature; import net.minecraft.world.level.levelgen.feature.Feature;
import ru.betterend.blocks.basis.PottableFeatureSapling; import ru.bclib.blocks.FeatureSaplingBlock;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndFeatures; import ru.betterend.registry.EndFeatures;
public class DragonTreeSaplingBlock extends PottableFeatureSapling { public class DragonTreeSaplingBlock extends FeatureSaplingBlock {
public DragonTreeSaplingBlock() { public DragonTreeSaplingBlock() {
super(); super();
} }
@ -23,9 +22,4 @@ public class DragonTreeSaplingBlock extends PottableFeatureSapling {
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);
} }
@Override
public boolean canPlantOn(Block block) {
return block == EndBlocks.SHADOW_GRASS;
}
} }

View file

@ -1,7 +1,11 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import net.fabricmc.api.EnvType; import java.util.Collections;
import net.fabricmc.api.Environment; import java.util.List;
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.renderer.block.model.BlockModel; import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
@ -20,16 +24,11 @@ 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.render.BCLRenderLayer; import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.BlockModelProvider; import ru.bclib.interfaces.IRenderTyped;
import ru.bclib.interfaces.RenderLayerProvider;
import java.util.Collections; public class EmeraldIceBlock extends HalfTransparentBlock implements IRenderTyped, BlockModelProvider {
import java.util.List;
import java.util.Random;
public class EmeraldIceBlock extends HalfTransparentBlock implements RenderLayerProvider, BlockModelProvider {
public EmeraldIceBlock() { public EmeraldIceBlock() {
super(FabricBlockSettings.copyOf(Blocks.ICE)); super(FabricBlockSettings.copyOf(Blocks.ICE));
} }
@ -86,7 +85,6 @@ public class EmeraldIceBlock extends HalfTransparentBlock implements RenderLayer
} }
@Override @Override
@Environment(EnvType.CLIENT)
public BlockModel getItemModel(ResourceLocation resourceLocation) { public BlockModel getItemModel(ResourceLocation resourceLocation) {
return getBlockModel(resourceLocation, defaultBlockState()); return getBlockModel(resourceLocation, defaultBlockState());
} }

View file

@ -12,11 +12,8 @@ public class EndBlockProperties extends BlockProperties {
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 IntegerProperty PORTAL = IntegerProperty.create("portal", 0, EndPortals.getCount());
public static final IntegerProperty PLANT_ID = IntegerProperty.create("plant_id", 0, 63);
public static final IntegerProperty SOIL_ID = IntegerProperty.create("soil_id", 0, 16);
public static final IntegerProperty POT_LIGHT = IntegerProperty.create("pot_light", 0, 3);
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 enum PedestalState implements StringRepresentable { public enum PedestalState implements StringRepresentable {
PEDESTAL_TOP("pedestal_top"), PEDESTAL_TOP("pedestal_top"),

View file

@ -1,6 +1,11 @@
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;
@ -32,10 +37,6 @@ 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);
@ -74,8 +75,7 @@ public class EndLilyBlock extends EndUnderwaterPlantBlock {
@Override @Override
public FluidState getFluidState(BlockState state) { public FluidState getFluidState(BlockState state) {
return state.getValue(SHAPE) == TripleShape.TOP ? Fluids.EMPTY.defaultFluidState() : Fluids.WATER.getSource( return state.getValue(SHAPE) == TripleShape.TOP ? Fluids.EMPTY.defaultFluidState() : Fluids.WATER.getSource(false);
false);
} }
@Override @Override
@ -96,10 +96,7 @@ public class EndLilyBlock extends EndUnderwaterPlantBlock {
@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) {
return Lists.newArrayList( return Lists.newArrayList(new ItemStack(EndItems.END_LILY_LEAF, MHelper.randRange(1, 2, MHelper.RANDOM)), new ItemStack(EndBlocks.END_LILY_SEED, MHelper.randRange(1, 2, MHelper.RANDOM)));
new ItemStack(EndItems.END_LILY_LEAF, MHelper.randRange(1, 2, MHelper.RANDOM)),
new ItemStack(EndBlocks.END_LILY_SEED, MHelper.randRange(1, 2, MHelper.RANDOM))
);
} }
return Collections.emptyList(); return Collections.emptyList();
} }

View file

@ -1,5 +1,7 @@
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;
@ -10,31 +12,17 @@ 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) {
if (canGrow(world, pos)) { if (canGrow(world, pos)) {
BlocksHelper.setWithoutUpdate( BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.END_LILY.defaultBlockState().setValue(EndLilyBlock.SHAPE, TripleShape.BOTTOM));
world,
pos,
EndBlocks.END_LILY.defaultBlockState().setValue(EndLilyBlock.SHAPE, TripleShape.BOTTOM)
);
BlockPos up = pos.above(); BlockPos up = pos.above();
while (world.getFluidState(up).isSource()) { while (world.getFluidState(up).isSource()) {
BlocksHelper.setWithoutUpdate( BlocksHelper.setWithoutUpdate(world, up, EndBlocks.END_LILY.defaultBlockState().setValue(EndLilyBlock.SHAPE, TripleShape.MIDDLE));
world,
up,
EndBlocks.END_LILY.defaultBlockState().setValue(EndLilyBlock.SHAPE, TripleShape.MIDDLE)
);
up = up.above(); up = up.above();
} }
BlocksHelper.setWithoutUpdate( BlocksHelper.setWithoutUpdate(world, up, EndBlocks.END_LILY.defaultBlockState().setValue(EndLilyBlock.SHAPE, TripleShape.TOP));
world,
up,
EndBlocks.END_LILY.defaultBlockState().setValue(EndLilyBlock.SHAPE, TripleShape.TOP)
);
} }
} }
@ -48,6 +36,6 @@ public class EndLilySeedBlock extends UnderwaterPlantWithAgeBlock {
@Override @Override
protected boolean isTerrain(BlockState state) { protected boolean isTerrain(BlockState state) {
return state.is(TagAPI.BLOCK_END_GROUND); return state.is(TagAPI.END_GROUND);
} }
} }

View file

@ -1,6 +1,9 @@
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;
@ -18,8 +21,6 @@ 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);

View file

@ -24,11 +24,11 @@ import ru.bclib.blocks.BaseBlockNotFull;
import ru.bclib.blocks.BlockProperties; import ru.bclib.blocks.BlockProperties;
import ru.bclib.blocks.BlockProperties.TripleShape; import ru.bclib.blocks.BlockProperties.TripleShape;
import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.RenderLayerProvider; 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;
public class EndLotusLeafBlock extends BaseBlockNotFull implements RenderLayerProvider { 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);

View file

@ -1,5 +1,7 @@
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;
@ -12,16 +14,12 @@ 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) {
if (canGrow(world, pos)) { if (canGrow(world, pos)) {
BlockState startLeaf = EndBlocks.END_LOTUS_STEM.defaultBlockState().setValue(EndLotusStemBlock.LEAF, true); BlockState startLeaf = EndBlocks.END_LOTUS_STEM.defaultBlockState().setValue(EndLotusStemBlock.LEAF, true);
BlockState roots = EndBlocks.END_LOTUS_STEM.defaultBlockState() BlockState roots = EndBlocks.END_LOTUS_STEM.defaultBlockState().setValue(EndLotusStemBlock.SHAPE, TripleShape.BOTTOM).setValue(EndLotusStemBlock.WATERLOGGED, true);
.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();
@ -39,11 +37,7 @@ public class EndLotusSeedBlock extends UnderwaterPlantWithAgeBlock {
BlockPos leafCenter = bpos.immutable().relative(dir); BlockPos leafCenter = bpos.immutable().relative(dir);
if (hasLeaf(world, leafCenter)) { if (hasLeaf(world, leafCenter)) {
generateLeaf(world, leafCenter); generateLeaf(world, leafCenter);
BlocksHelper.setWithoutUpdate( BlocksHelper.setWithoutUpdate(world, bpos, startLeaf.setValue(EndLotusStemBlock.SHAPE, shape).setValue(EndLotusStemBlock.FACING, dir));
world,
bpos,
startLeaf.setValue(EndLotusStemBlock.SHAPE, shape).setValue(EndLotusStemBlock.FACING, dir)
);
} }
else { else {
BlocksHelper.setWithoutUpdate(world, bpos, stem.setValue(EndLotusStemBlock.SHAPE, shape)); BlocksHelper.setWithoutUpdate(world, bpos, stem.setValue(EndLotusStemBlock.SHAPE, shape));
@ -98,23 +92,13 @@ public class EndLotusSeedBlock extends UnderwaterPlantWithAgeBlock {
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( BlocksHelper.setWithoutUpdate(world, p.set(pos).move(move), leaf.setValue(EndLotusLeafBlock.HORIZONTAL_FACING, move).setValue(EndLotusLeafBlock.SHAPE, TripleShape.MIDDLE));
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( BlocksHelper.setWithoutUpdate(world, p.set(pos).move(d1).move(d2), leaf.setValue(EndLotusLeafBlock.HORIZONTAL_FACING, d1).setValue(EndLotusLeafBlock.SHAPE, TripleShape.TOP));
world,
p.set(pos).move(d1).move(d2),
leaf.setValue(EndLotusLeafBlock.HORIZONTAL_FACING, d1)
.setValue(EndLotusLeafBlock.SHAPE, TripleShape.TOP)
);
} }
} }
@ -122,11 +106,12 @@ public class EndLotusSeedBlock extends UnderwaterPlantWithAgeBlock {
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()) count++; if (world.isEmptyBlock(p) && !world.getFluidState(p.below()).isEmpty())
count ++;
} }
} }
return count == 9; return count == 9;
@ -134,6 +119,6 @@ public class EndLotusSeedBlock extends UnderwaterPlantWithAgeBlock {
@Override @Override
protected boolean isTerrain(BlockState state) { protected boolean isTerrain(BlockState state) {
return state.is(TagAPI.BLOCK_END_GROUND); return state.is(TagAPI.END_GROUND);
} }
} }

View file

@ -1,6 +1,9 @@
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;
@ -26,12 +29,10 @@ 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;
import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.RenderLayerProvider; 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, RenderLayerProvider {
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");
@ -40,10 +41,7 @@ public class EndLotusStemBlock extends BaseBlock implements SimpleWaterloggedBlo
public EndLotusStemBlock() { public EndLotusStemBlock() {
super(FabricBlockSettings.copyOf(Blocks.OAK_PLANKS)); super(FabricBlockSettings.copyOf(Blocks.OAK_PLANKS));
this.registerDefaultState(defaultBlockState().setValue(WATERLOGGED, false) this.registerDefaultState(defaultBlockState().setValue(WATERLOGGED, false).setValue(SHAPE, TripleShape.MIDDLE).setValue(LEAF, false).setValue(FACING, Direction.UP));
.setValue(SHAPE, TripleShape.MIDDLE)
.setValue(LEAF, false)
.setValue(FACING, Direction.UP));
} }
@Override @Override
@ -65,9 +63,7 @@ public class EndLotusStemBlock extends BaseBlock implements SimpleWaterloggedBlo
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() return this.defaultBlockState().setValue(WATERLOGGED, worldAccess.getFluidState(blockPos).getType() == Fluids.WATER).setValue(FACING, ctx.getClickedFace());
.setValue(WATERLOGGED, worldAccess.getFluidState(blockPos).getType() == Fluids.WATER)
.setValue(FACING, ctx.getClickedFace());
} }
@Override @Override

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,9 +21,8 @@ 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,5 +1,9 @@
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;
@ -29,24 +33,18 @@ 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.dimension.DimensionType; import net.minecraft.world.level.dimension.DimensionType;
import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.CustomColorProvider; import ru.bclib.interfaces.IColorProvider;
import ru.bclib.interfaces.RenderLayerProvider; import ru.bclib.interfaces.IRenderTyped;
import ru.betterend.interfaces.TeleportingEntity; import ru.betterend.interfaces.TeleportingEntity;
import ru.betterend.registry.EndParticles; 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; public class EndPortalBlock extends NetherPortalBlock implements IRenderTyped, IColorProvider {
import java.util.Optional;
import java.util.Random;
public class EndPortalBlock extends NetherPortalBlock implements RenderLayerProvider, CustomColorProvider {
public static final IntegerProperty PORTAL = EndBlockProperties.PORTAL; public static final IntegerProperty PORTAL = EndBlockProperties.PORTAL;
public EndPortalBlock() { public EndPortalBlock() {
super(FabricBlockSettings.copyOf(Blocks.NETHER_PORTAL) super(FabricBlockSettings.copyOf(Blocks.NETHER_PORTAL).resistance(Blocks.BEDROCK.getExplosionResistance()).luminance(15));
.resistance(Blocks.BEDROCK.getExplosionResistance())
.luminance(15));
} }
@Override @Override
@ -59,16 +57,7 @@ public class EndPortalBlock extends NetherPortalBlock implements RenderLayerProv
@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 (random.nextInt(100) == 0) { if (random.nextInt(100) == 0) {
world.playLocalSound( world.playLocalSound(pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, SoundEvents.PORTAL_AMBIENT, SoundSource.BLOCKS, 0.5F, random.nextFloat() * 0.4F + 0.8F, false);
pos.getX() + 0.5D,
pos.getY() + 0.5D,
pos.getZ() + 0.5D,
SoundEvents.PORTAL_AMBIENT,
SoundSource.BLOCKS,
0.5F,
random.nextFloat() * 0.4F + 0.8F,
false
);
} }
double x = pos.getX() + random.nextDouble(); double x = pos.getX() + random.nextDouble();
@ -77,8 +66,7 @@ public class EndPortalBlock extends NetherPortalBlock implements RenderLayerProv
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;
} }
@ -86,8 +74,7 @@ public class EndPortalBlock extends NetherPortalBlock implements RenderLayerProv
} }
@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) {
@ -106,16 +93,9 @@ public class EndPortalBlock extends NetherPortalBlock implements RenderLayerProv
BlockPos exitPos = findExitPos(currentWorld, destination, pos, entity); BlockPos exitPos = findExitPos(currentWorld, destination, pos, entity);
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( ((ServerPlayer) entity).teleportTo(destination, exitPos.getX() + 0.5, exitPos.getY(),
destination, exitPos.getZ() + 0.5, entity.yRot, entity.xRot);
exitPos.getX() + 0.5, } else {
exitPos.getY(),
exitPos.getZ() + 0.5,
entity.getYRot(),
entity.getXRot()
);
}
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);
@ -123,7 +103,8 @@ public class EndPortalBlock extends NetherPortalBlock implements RenderLayerProv
} }
private boolean validate(Entity entity) { private boolean validate(Entity entity) {
return !entity.isPassenger() && !entity.isVehicle() && entity.canChangeDimensions() && !entity.isOnPortalCooldown(); return !entity.isPassenger() && !entity.isVehicle() &&
entity.canChangeDimensions() && !entity.isOnPortalCooldown();
} }
@Override @Override
@ -133,28 +114,18 @@ public class EndPortalBlock extends NetherPortalBlock implements RenderLayerProv
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() Registry<DimensionType> registry = targetWorld.registryAccess().dimensionTypes();
.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();
double currentMultiplier = Objects.requireNonNull(registry.get(currentWorldId)).coordinateScale(); double currentMultiplier = Objects.requireNonNull(registry.get(currentWorldId)).coordinateScale();
double multiplier = targetMultiplier > currentMultiplier ? 1.0 / targetMultiplier : currentMultiplier; double multiplier = targetMultiplier > currentMultiplier ? 1.0 / targetMultiplier : currentMultiplier;
MutableBlockPos basePos = currentPos.mutable() MutableBlockPos basePos = currentPos.mutable().set(currentPos.getX() * multiplier, currentPos.getY(), currentPos.getZ() * multiplier);
.set(currentPos.getX() * multiplier,
currentPos.getY(),
currentPos.getZ() * multiplier
);
MutableBlockPos checkPos = basePos.mutable(); MutableBlockPos checkPos = basePos.mutable();
BlockState currentState = currentWorld.getBlockState(currentPos); BlockState currentState = currentWorld.getBlockState(currentPos);
int radius = (EternalRitual.SEARCH_RADIUS >> 4) + 1; int radius = (EternalRitual.SEARCH_RADIUS >> 4) + 1;
checkPos = EternalRitual.findBlockPos( checkPos = EternalRitual.findBlockPos(targetWorld, checkPos, radius, this, state -> state.is(this) &&
targetWorld, state.getValue(PORTAL).equals(currentState.getValue(PORTAL)));
checkPos,
radius,
this,
state -> state.is(this) && state.getValue(PORTAL).equals(currentState.getValue(PORTAL))
);
if (checkPos != null) { if (checkPos != null) {
BlockState checkState = targetWorld.getBlockState(checkPos); BlockState checkState = targetWorld.getBlockState(checkPos);
Axis axis = checkState.getValue(AXIS); Axis axis = checkState.getValue(AXIS);
@ -188,14 +159,11 @@ public class EndPortalBlock extends NetherPortalBlock implements RenderLayerProv
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,6 +1,10 @@
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;
@ -15,6 +19,7 @@ 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;
@ -23,8 +28,6 @@ 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;
@ -35,13 +38,8 @@ 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;
@ -50,19 +48,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().setValue(FACING, Direction.NORTH).setValue(LIT, false)); this.registerDefaultState(this.stateDefinition.any()
.setValue(FACING, Direction.NORTH)
.setValue(LIT, false));
} }
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { 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;
} }
@ -77,12 +75,12 @@ public class EndStoneSmelter extends BaseBlockWithEntity {
@Override @Override
public BlockState getStateForPlacement(BlockPlaceContext ctx) { public BlockState getStateForPlacement(BlockPlaceContext ctx) {
return defaultBlockState().setValue(FACING, ctx.getHorizontalDirection().getOpposite()); return this.defaultBlockState().setValue(FACING, ctx.getHorizontalDirection().getOpposite());
} }
@Override @Override
public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) { public BlockEntity newBlockEntity(BlockGetter world) {
return new EndStoneSmelterBlockEntity(blockPos, blockState); return new EndStoneSmelterBlockEntity();
} }
@Override @Override
@ -139,16 +137,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( world.playLocalSound(x, y, z, SoundEvents.BLASTFURNACE_FIRE_CRACKLE, SoundSource.BLOCKS, 1.0F, 1.0F, false);
x,
y,
z,
SoundEvents.BLASTFURNACE_FIRE_CRACKLE,
SoundSource.BLOCKS,
1.0F,
1.0F,
false
);
} }
Direction direction = state.getValue(FACING); Direction direction = state.getValue(FACING);
@ -160,15 +149,4 @@ 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,5 +1,8 @@
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;
@ -13,9 +16,6 @@ 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);

View file

@ -1,6 +1,9 @@
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;
@ -25,8 +28,6 @@ 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;
@ -49,24 +50,21 @@ 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();
} }
@ -128,8 +126,8 @@ public class EternalPedestal extends PedestalBlock {
} }
@Override @Override
public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) { public BlockEntity newBlockEntity(BlockGetter world) {
return new EternalPedestalEntity(blockPos, blockState); return new EternalPedestalEntity();
} }
@Override @Override

View file

@ -8,9 +8,6 @@ import ru.bclib.blocks.BaseBlock;
public class FilaluxLanternBlock extends BaseBlock { public class FilaluxLanternBlock extends BaseBlock {
public FilaluxLanternBlock() { public FilaluxLanternBlock() {
super(FabricBlockSettings.of(Material.WOOD) super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).luminance(15).sound(SoundType.WOOD));
.breakByTool(FabricToolTags.AXES)
.luminance(15)
.sound(SoundType.WOOD));
} }
} }

View file

@ -1,6 +1,9 @@
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;
@ -14,18 +17,13 @@ import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShape;
import ru.bclib.blocks.BaseAttachedBlock; import ru.bclib.blocks.BaseAttachedBlock;
import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.RenderLayerProvider; import ru.bclib.interfaces.IRenderTyped;
import java.util.EnumMap; public class FilaluxWingsBlock extends BaseAttachedBlock implements IRenderTyped {
public class FilaluxWingsBlock extends BaseAttachedBlock implements RenderLayerProvider {
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) super(FabricBlockSettings.of(Material.PLANT).breakByTool(FabricToolTags.SHEARS).sound(SoundType.WET_GRASS).noCollission());
.breakByTool(FabricToolTags.SHEARS)
.sound(SoundType.WET_GRASS)
.noCollission());
} }
@Override @Override

View file

@ -1,14 +1,13 @@
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.item.v1.FabricItemSettings;
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;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.WaterLilyBlockItem;
import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.BlockGetter;
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;
@ -19,12 +18,10 @@ 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.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 ru.bclib.interfaces.CustomItemProvider;
import ru.betterend.blocks.basis.EndPlantBlock; import ru.betterend.blocks.basis.EndPlantBlock;
import ru.betterend.interfaces.ISpetialItem;
import java.util.List; public class FlamaeaBlock extends EndPlantBlock implements ISpetialItem {
public class FlamaeaBlock extends EndPlantBlock implements CustomItemProvider {
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() {
@ -55,12 +52,12 @@ public class FlamaeaBlock extends EndPlantBlock implements CustomItemProvider {
} }
@Override @Override
public boolean canBePotted() { public int getStackSize() {
return false; return 64;
} }
@Override @Override
public BlockItem getCustomItem(ResourceLocation resourceLocation, FabricItemSettings fabricItemSettings) { public boolean canPlaceOnWater() {
return new WaterLilyBlockItem(this, fabricItemSettings); return true;
} }
} }

View file

@ -1,47 +0,0 @@
package ru.betterend.blocks;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import ru.bclib.client.models.ModelsHelper;
import ru.betterend.blocks.basis.EndPlantBlock;
import ru.betterend.registry.EndBlocks;
public class FlammalixBlock extends EndPlantBlock {
private static final VoxelShape SHAPE = Block.box(2, 0, 2, 14, 14, 14);
public FlammalixBlock() {
super(false, 12);
}
@Override
protected boolean isTerrain(BlockState state) {
return state.is(EndBlocks.PALLIDIUM_FULL) ||
state.is(EndBlocks.PALLIDIUM_HEAVY) ||
state.is(EndBlocks.PALLIDIUM_THIN) ||
state.is(EndBlocks.PALLIDIUM_TINY);
}
@Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return SHAPE;
}
@Override
public OffsetType getOffsetType() {
return OffsetType.NONE;
}
@Override
@Environment(EnvType.CLIENT)
public BlockModel getItemModel(ResourceLocation resourceLocation) {
return ModelsHelper.createItemModel(resourceLocation);
}
}

View file

@ -1,443 +0,0 @@
package ru.betterend.blocks;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.mojang.math.Transformation;
import com.mojang.math.Vector3f;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.client.resources.model.UnbakedModel;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.SaplingBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import net.minecraft.world.level.storage.loot.LootContext.Builder;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import ru.bclib.blocks.BaseBlockNotFull;
import ru.bclib.client.models.BasePatterns;
import ru.bclib.client.models.ModelsHelper;
import ru.bclib.client.models.ModelsHelper.MultiPartBuilder;
import ru.bclib.client.models.PatternsHelper;
import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.PostInitable;
import ru.bclib.interfaces.RenderLayerProvider;
import ru.bclib.util.BlocksHelper;
import ru.bclib.util.JsonFactory;
import ru.betterend.BetterEnd;
import ru.betterend.blocks.basis.PottableLeavesBlock;
import ru.betterend.client.models.Patterns;
import ru.betterend.config.Configs;
import ru.betterend.interfaces.PottablePlant;
import ru.betterend.interfaces.PottableTerrain;
import ru.betterend.registry.EndBlocks;
import java.io.File;
import java.util.List;
import java.util.Map;
import java.util.Optional;
public class FlowerPotBlock extends BaseBlockNotFull implements RenderLayerProvider, PostInitable {
private static final IntegerProperty PLANT_ID = EndBlockProperties.PLANT_ID;
private static final IntegerProperty SOIL_ID = EndBlockProperties.SOIL_ID;
private static final IntegerProperty POT_LIGHT = EndBlockProperties.POT_LIGHT;
private static final VoxelShape SHAPE_EMPTY;
private static final VoxelShape SHAPE_FULL;
private static Block[] plants;
private static Block[] soils;
public FlowerPotBlock(Block source) {
super(FabricBlockSettings.copyOf(source).luminance(state -> state.getValue(POT_LIGHT) * 5));
this.registerDefaultState(
this.defaultBlockState()
.setValue(PLANT_ID, 0)
.setValue(SOIL_ID, 0)
.setValue(POT_LIGHT, 0)
);
}
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
super.createBlockStateDefinition(builder);
builder.add(PLANT_ID, SOIL_ID, POT_LIGHT);
}
@Override
public List<ItemStack> getDrops(BlockState state, Builder builder) {
List<ItemStack> drop = Lists.newArrayList(new ItemStack(this));
int id = state.getValue(SOIL_ID) - 1;
if (id >= 0 && id < soils.length && soils[id] != null) {
drop.add(new ItemStack(soils[id]));
}
id = state.getValue(PLANT_ID) - 1;
if (id >= 0 && id < plants.length && plants[id] != null) {
drop.add(new ItemStack(plants[id]));
}
return drop;
}
@Override
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
int plantID = state.getValue(PLANT_ID);
if (plantID < 1 || plantID > plants.length || plants[plantID - 1] == null) {
return state.getValue(POT_LIGHT) > 0 ? state.setValue(POT_LIGHT, 0) : state;
}
int light = plants[plantID - 1].defaultBlockState().getLightEmission() / 5;
if (state.getValue(POT_LIGHT) != light) {
state = state.setValue(POT_LIGHT, light);
}
return state;
}
@Override
public void postInit() {
if (FlowerPotBlock.plants != null) {
return;
}
Block[] plants = new Block[128];
Block[] soils = new Block[16];
Map<String, Integer> reservedPlantsIDs = Maps.newHashMap();
Map<String, Integer> reservedSoilIDs = Maps.newHashMap();
JsonObject obj = JsonFactory.getJsonObject(new File(
FabricLoader.getInstance().getConfigDir().toFile(),
BetterEnd.MOD_ID + "/blocks.json"
));
if (obj.get("flower_pots") != null) {
JsonElement plantsObj = obj.get("flower_pots").getAsJsonObject().get("plants");
JsonElement soilsObj = obj.get("flower_pots").getAsJsonObject().get("soils");
if (plantsObj != null) {
plantsObj.getAsJsonObject().entrySet().forEach(entry -> {
String name = entry.getKey().substring(0, entry.getKey().indexOf(' '));
reservedPlantsIDs.put(name, entry.getValue().getAsInt());
});
}
if (soilsObj != null) {
soilsObj.getAsJsonObject().entrySet().forEach(entry -> {
String name = entry.getKey().substring(0, entry.getKey().indexOf(' '));
reservedSoilIDs.put(name, entry.getValue().getAsInt());
});
}
}
EndBlocks.getModBlocks().forEach(block -> {
if (block instanceof PottablePlant && ((PottablePlant) block).canBePotted()) {
processBlock(plants, block, "flower_pots.plants", reservedPlantsIDs);
}
else if (block instanceof PottableTerrain && ((PottableTerrain) block).canBePotted()) {
processBlock(soils, block, "flower_pots.soils", reservedSoilIDs);
}
});
Configs.BLOCK_CONFIG.saveChanges();
FlowerPotBlock.plants = new Block[maxNotNull(plants) + 1];
System.arraycopy(plants, 0, FlowerPotBlock.plants, 0, FlowerPotBlock.plants.length);
FlowerPotBlock.soils = new Block[maxNotNull(soils) + 1];
System.arraycopy(soils, 0, FlowerPotBlock.soils, 0, FlowerPotBlock.soils.length);
if (PLANT_ID.getValue(Integer.toString(FlowerPotBlock.plants.length)).isEmpty()) {
throw new RuntimeException("There are too much plant ID values!");
}
if (SOIL_ID.getValue(Integer.toString(FlowerPotBlock.soils.length)).isEmpty()) {
throw new RuntimeException("There are too much soil ID values!");
}
}
private int maxNotNull(Block[] array) {
int max = 0;
for (int i = 0; i < array.length; i++) {
if (array[i] != null) {
max = i;
}
}
return max;
}
private void processBlock(Block[] target, Block block, String path, Map<String, Integer> idMap) {
ResourceLocation location = Registry.BLOCK.getKey(block);
if (idMap.containsKey(location.getPath())) {
target[idMap.get(location.getPath())] = block;
}
else {
for (int i = 0; i < target.length; i++) {
if (!idMap.values().contains(i)) {
target[i] = block;
idMap.put(location.getPath(), i);
Configs.BLOCK_CONFIG.getInt(path, location.getPath(), i);
break;
}
}
}
}
@Override
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
if (level.isClientSide) {
return InteractionResult.CONSUME;
}
ItemStack itemStack = player.getItemInHand(hand);
int soilID = state.getValue(SOIL_ID);
if (soilID == 0 || soilID > soils.length || soils[soilID - 1] == null) {
if (!(itemStack.getItem() instanceof BlockItem)) {
return InteractionResult.PASS;
}
Block block = ((BlockItem) itemStack.getItem()).getBlock();
for (int i = 0; i < soils.length; i++) {
if (block == soils[i]) {
BlocksHelper.setWithUpdate(level, pos, state.setValue(SOIL_ID, i + 1));
if (!player.isCreative()) {
itemStack.shrink(1);
}
level.playSound(
player,
pos.getX() + 0.5,
pos.getY() + 0.5,
pos.getZ() + 0.5,
SoundEvents.SOUL_SOIL_PLACE,
SoundSource.BLOCKS,
1,
1
);
return InteractionResult.SUCCESS;
}
}
return InteractionResult.PASS;
}
int plantID = state.getValue(PLANT_ID);
if (itemStack.isEmpty()) {
if (plantID > 0 && plantID <= plants.length && plants[plantID - 1] != null) {
BlocksHelper.setWithUpdate(level, pos, state.setValue(PLANT_ID, 0).setValue(POT_LIGHT, 0));
player.addItem(new ItemStack(plants[plantID - 1]));
return InteractionResult.SUCCESS;
}
if (soilID > 0 && soilID <= soils.length && soils[soilID - 1] != null) {
BlocksHelper.setWithUpdate(level, pos, state.setValue(SOIL_ID, 0));
player.addItem(new ItemStack(soils[soilID - 1]));
}
return InteractionResult.PASS;
}
if (!(itemStack.getItem() instanceof BlockItem)) {
return InteractionResult.PASS;
}
BlockItem item = (BlockItem) itemStack.getItem();
for (int i = 0; i < plants.length; i++) {
if (item.getBlock() == plants[i]) {
if (!((PottablePlant) plants[i]).canPlantOn(soils[soilID - 1])) {
return InteractionResult.PASS;
}
int light = plants[i].defaultBlockState().getLightEmission() / 5;
BlocksHelper.setWithUpdate(level, pos, state.setValue(PLANT_ID, i + 1).setValue(POT_LIGHT, light));
level.playSound(
player,
pos.getX() + 0.5,
pos.getY() + 0.5,
pos.getZ() + 0.5,
SoundEvents.HOE_TILL,
SoundSource.BLOCKS,
1,
1
);
if (!player.isCreative()) {
itemStack.shrink(1);
}
return InteractionResult.SUCCESS;
}
}
return InteractionResult.PASS;
}
@Override
@Environment(EnvType.CLIENT)
public BlockModel getItemModel(ResourceLocation blockId) {
Optional<String> pattern = PatternsHelper.createJson(Patterns.BLOCK_FLOWER_POT, blockId);
return ModelsHelper.fromPattern(pattern);
}
@Override
@Environment(EnvType.CLIENT)
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
MultiPartBuilder model = MultiPartBuilder.create(stateDefinition);
model.part(new ModelResourceLocation(stateId.getNamespace(), stateId.getPath(), "inventory")).add();
Transformation offset = new Transformation(new Vector3f(0, 7.5F / 16F, 0), null, null, null);
for (int i = 0; i < plants.length; i++) {
if (plants[i] == null) {
continue;
}
final int compareID = i + 1;
ResourceLocation modelPath = Registry.BLOCK.getKey(plants[i]);
ResourceLocation objSource = new ResourceLocation(
modelPath.getNamespace(),
"models/block/" + modelPath.getPath() + "_potted.json"
);
if (Minecraft.getInstance().getResourceManager().hasResource(objSource)) {
objSource = new ResourceLocation(modelPath.getNamespace(), "block/" + modelPath.getPath() + "_potted");
model.part(objSource)
.setTransformation(offset)
.setCondition(state -> state.getValue(PLANT_ID) == compareID)
.add();
continue;
}
else if (plants[i] instanceof SaplingBlock) {
ResourceLocation loc = Registry.BLOCK.getKey(plants[i]);
modelPath = new ResourceLocation(loc.getNamespace(), "block/" + loc.getPath() + "_potted");
Map<String, String> textures = Maps.newHashMap();
textures.put("%modid%", loc.getNamespace());
textures.put("%texture%", loc.getPath());
Optional<String> pattern = Patterns.createJson(BasePatterns.BLOCK_CROSS, textures);
UnbakedModel unbakedModel = ModelsHelper.fromPattern(pattern);
modelCache.put(modelPath, unbakedModel);
model.part(modelPath)
.setTransformation(offset)
.setCondition(state -> state.getValue(PLANT_ID) == compareID)
.add();
continue;
}
else if (plants[i] instanceof PottableLeavesBlock) {
ResourceLocation loc = Registry.BLOCK.getKey(plants[i]);
modelPath = new ResourceLocation(loc.getNamespace(), "block/" + loc.getPath() + "_potted");
Map<String, String> textures = Maps.newHashMap();
textures.put("%leaves%", loc.getPath().contains("lucernia") ? loc.getPath() + "_1" : loc.getPath());
textures.put("%stem%", loc.getPath().replace("_leaves", "_log_side"));
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_POTTED_LEAVES, textures);
UnbakedModel unbakedModel = ModelsHelper.fromPattern(pattern);
modelCache.put(modelPath, unbakedModel);
model.part(modelPath)
.setTransformation(offset)
.setCondition(state -> state.getValue(PLANT_ID) == compareID)
.add();
continue;
}
objSource = new ResourceLocation(modelPath.getNamespace(), "blockstates/" + modelPath.getPath() + ".json");
JsonObject obj = JsonFactory.getJsonObject(objSource);
if (obj != null) {
JsonElement variants = obj.get("variants");
JsonElement list = null;
String path = null;
if (variants == null) {
continue;
}
if (variants.isJsonArray()) {
list = variants.getAsJsonArray().get(0);
}
else if (variants.isJsonObject()) {
list = variants.getAsJsonObject().get(((PottablePlant) plants[i]).getPottedState());
}
if (list == null) {
BetterEnd.LOGGER.warning("Incorrect json for pot plant " + objSource + ", no matching variants");
continue;
}
if (list.isJsonArray()) {
path = list.getAsJsonArray().get(0).getAsJsonObject().get("model").getAsString();
}
else {
path = list.getAsJsonObject().get("model").getAsString();
}
if (path == null) {
BetterEnd.LOGGER.warning("Incorrect json for pot plant " + objSource + ", no matching variants");
continue;
}
model.part(new ResourceLocation(path))
.setTransformation(offset)
.setCondition(state -> state.getValue(PLANT_ID) == compareID)
.add();
}
else {
ResourceLocation loc = Registry.BLOCK.getKey(plants[i]);
modelPath = new ResourceLocation(loc.getNamespace(), "block/" + loc.getPath() + "_potted");
Map<String, String> textures = Maps.newHashMap();
textures.put("%modid%", loc.getNamespace());
textures.put("%texture%", loc.getPath());
Optional<String> pattern = Patterns.createJson(BasePatterns.BLOCK_CROSS, textures);
UnbakedModel unbakedModel = ModelsHelper.fromPattern(pattern);
modelCache.put(modelPath, unbakedModel);
model.part(modelPath)
.setTransformation(offset)
.setCondition(state -> state.getValue(PLANT_ID) == compareID)
.add();
}
}
for (int i = 0; i < soils.length; i++) {
if (soils[i] == null) {
continue;
}
ResourceLocation soilLoc = BetterEnd.makeID("flower_pot_soil_" + i);
if (!modelCache.containsKey(soilLoc)) {
String texture = Registry.BLOCK.getKey(soils[i]).getPath() + "_top";
if (texture.contains("rutiscus")) {
texture += "_1";
}
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_FLOWER_POT_SOIL, texture);
UnbakedModel soil = ModelsHelper.fromPattern(pattern);
modelCache.put(soilLoc, soil);
}
final int compareID = i + 1;
model.part(soilLoc).setCondition(state -> state.getValue(SOIL_ID) == compareID).add();
}
UnbakedModel result = model.build();
modelCache.put(stateId, result);
return result;
}
@Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
int id = state.getValue(PLANT_ID);
return id > 0 && id <= plants.length ? SHAPE_FULL : SHAPE_EMPTY;
}
@Override
public VoxelShape getCollisionShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return SHAPE_EMPTY;
}
@Override
public BCLRenderLayer getRenderLayer() {
return BCLRenderLayer.CUTOUT;
}
static {
SHAPE_EMPTY = Shapes.or(Block.box(4, 1, 4, 12, 8, 12), Block.box(5, 0, 5, 11, 1, 11));
SHAPE_FULL = Shapes.or(SHAPE_EMPTY, Block.box(3, 8, 3, 13, 16, 13));
}
}

View file

@ -8,9 +8,6 @@ import ru.bclib.blocks.BaseBlock;
public class GlowingHymenophoreBlock extends BaseBlock { public class GlowingHymenophoreBlock extends BaseBlock {
public GlowingHymenophoreBlock() { public GlowingHymenophoreBlock() {
super(FabricBlockSettings.of(Material.WOOD) super(FabricBlockSettings.of(Material.WOOD).breakByTool(FabricToolTags.AXES).luminance(15).sound(SoundType.WART_BLOCK));
.breakByTool(FabricToolTags.AXES)
.luminance(15)
.sound(SoundType.WART_BLOCK));
} }
} }

View file

@ -1,5 +1,7 @@
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;
@ -18,8 +20,6 @@ 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() {
@ -44,35 +44,22 @@ public class GlowingPillarSeedBlock extends EndPlantWithAgeBlock {
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( BlocksHelper.setWithUpdate(world, mut, EndBlocks.GLOWING_PILLAR_LUMINOPHOR.defaultBlockState().setValue(BlueVineLanternBlock.NATURAL, true));
world, for (Direction dir: BlocksHelper.DIRECTIONS) {
mut,
EndBlocks.GLOWING_PILLAR_LUMINOPHOR.defaultBlockState().setValue(BlueVineLanternBlock.NATURAL, true)
);
for (Direction dir : BlocksHelper.DIRECTIONS) {
pos = mut.relative(dir); pos = mut.relative(dir);
if (world.isEmptyBlock(pos)) { if (world.isEmptyBlock(pos)) {
BlocksHelper.setWithUpdate( BlocksHelper.setWithUpdate(world, pos, EndBlocks.GLOWING_PILLAR_LEAVES.defaultBlockState().setValue(BlockStateProperties.FACING, dir));
world,
pos,
EndBlocks.GLOWING_PILLAR_LEAVES.defaultBlockState().setValue(BlockStateProperties.FACING, dir)
);
} }
} }
mut.move(Direction.UP); mut.move(Direction.UP);
if (world.isEmptyBlock(mut)) { if (world.isEmptyBlock(mut)) {
BlocksHelper.setWithUpdate( BlocksHelper.setWithUpdate(world, mut, EndBlocks.GLOWING_PILLAR_LEAVES.defaultBlockState().setValue(BlockStateProperties.FACING, Direction.UP));
world,
mut,
EndBlocks.GLOWING_PILLAR_LEAVES.defaultBlockState().setValue(BlockStateProperties.FACING, Direction.UP)
);
} }
} }

View file

@ -23,15 +23,14 @@ 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.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.blocks.BaseBlock; import ru.bclib.blocks.BaseBlock;
import ru.bclib.interfaces.CustomColorProvider; import ru.bclib.interfaces.IColorProvider;
import ru.bclib.util.ColorUtil; import ru.bclib.util.ColorUtil;
import ru.bclib.util.MHelper; 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;
public class HelixTreeLeavesBlock extends BaseBlock implements CustomColorProvider { 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);
@ -42,8 +41,6 @@ public class HelixTreeLeavesBlock extends BaseBlock implements CustomColorProvid
.sound(SoundType.WART_BLOCK) .sound(SoundType.WART_BLOCK)
.sound(SoundType.GRASS) .sound(SoundType.GRASS)
.strength(0.2F)); .strength(0.2F));
TagAPI.addTags(this, TagAPI.BLOCK_LEAVES);
} }
@Override @Override
@ -82,10 +79,7 @@ public class HelixTreeLeavesBlock extends BaseBlock implements CustomColorProvid
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.is(FabricToolTags.SHEARS) || tool.isCorrectToolForDrops(state) || EnchantmentHelper.getItemEnchantmentLevel( if (tool.getItem().is(FabricToolTags.SHEARS) || tool.isCorrectToolForDrops(state) || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) {
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);
@ -94,7 +88,6 @@ public class HelixTreeLeavesBlock extends BaseBlock implements CustomColorProvid
} }
return Lists.newArrayList(); return Lists.newArrayList();
} }
return MHelper.RANDOM.nextInt(32) == 0 ? Lists.newArrayList(new ItemStack(EndBlocks.HELIX_TREE_SAPLING)) : Lists return MHelper.RANDOM.nextInt(32) == 0 ? Lists.newArrayList(new ItemStack(EndBlocks.HELIX_TREE_SAPLING)) : Lists.newArrayList();
.newArrayList();
} }
} }

View file

@ -1,27 +1,12 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.feature.Feature; import net.minecraft.world.level.levelgen.feature.Feature;
import ru.betterend.blocks.basis.PottableFeatureSapling; import ru.bclib.blocks.FeatureSaplingBlock;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndFeatures; import ru.betterend.registry.EndFeatures;
public class HelixTreeSaplingBlock extends PottableFeatureSapling { public class HelixTreeSaplingBlock extends FeatureSaplingBlock {
@Override @Override
protected Feature<?> getFeature() { protected Feature<?> getFeature() {
return EndFeatures.HELIX_TREE.getFeature(); return EndFeatures.HELIX_TREE.getFeature();
} }
@Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
return world.getBlockState(pos.below()).is(EndBlocks.AMBER_MOSS);
}
@Override
public boolean canPlantOn(Block block) {
return block == EndBlocks.AMBER_MOSS;
}
} }

View file

@ -1,6 +1,11 @@
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;
@ -24,10 +29,6 @@ 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;
@ -63,7 +64,7 @@ public class HydraluxBlock extends UnderwaterPlantBlock {
@Override @Override
protected boolean isTerrain(BlockState state) { protected boolean isTerrain(BlockState state) {
return state.is(TagAPI.BLOCK_END_GROUND); return state.is(TagAPI.END_GROUND);
} }
@Override @Override
@ -89,10 +90,7 @@ public class HydraluxBlock extends UnderwaterPlantBlock {
return Lists.newArrayList(new ItemStack(EndItems.HYDRALUX_PETAL, MHelper.randRange(1, 4, MHelper.RANDOM))); return Lists.newArrayList(new ItemStack(EndItems.HYDRALUX_PETAL, MHelper.randRange(1, 4, MHelper.RANDOM)));
} }
else if (shape == HydraluxShape.ROOTS) { else if (shape == HydraluxShape.ROOTS) {
return Lists.newArrayList(new ItemStack( return Lists.newArrayList(new ItemStack(EndBlocks.HYDRALUX_SAPLING, MHelper.randRange(1, 2, MHelper.RANDOM)));
EndBlocks.HYDRALUX_SAPLING,
MHelper.randRange(1, 2, MHelper.RANDOM)
));
} }
return Collections.emptyList(); return Collections.emptyList();
} }

View file

@ -6,7 +6,6 @@ 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;
@ -27,6 +26,5 @@ public class HydraluxPetalBlock extends BaseBlock {
} }
@Override @Override
public void fallOn(Level level, BlockState blockState, BlockPos blockPos, Entity entity, float f) { public void fallOn(Level world, BlockPos pos, Entity entity, float distance) {}
}
} }

View file

@ -1,22 +1,21 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import net.fabricmc.api.EnvType; import java.util.Optional;
import net.fabricmc.api.Environment;
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.color.block.BlockColor; import net.minecraft.client.color.block.BlockColor;
import net.minecraft.client.color.item.ItemColor; 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.CustomColorProvider; 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 CustomColorProvider {
public HydraluxPetalColoredBlock(FabricBlockSettings settings) { public HydraluxPetalColoredBlock(FabricBlockSettings settings) {
super(settings); super(settings);
} }
@ -32,7 +31,6 @@ public class HydraluxPetalColoredBlock extends HydraluxPetalBlock implements Cus
} }
@Override @Override
@Environment(EnvType.CLIENT)
public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) { public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
String path = "betterend:block/block_petal_colored"; String path = "betterend:block/block_petal_colored";
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_PETAL_COLORED, path, path); Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_PETAL_COLORED, path, path);

View file

@ -1,5 +1,7 @@
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;
@ -11,8 +13,6 @@ 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
@ -29,40 +29,18 @@ public class HydraluxSaplingBlock extends UnderwaterPlantWithAgeBlock {
mut.setY(pos.getY()); mut.setY(pos.getY());
BlockState state = EndBlocks.HYDRALUX.defaultBlockState(); BlockState state = EndBlocks.HYDRALUX.defaultBlockState();
BlocksHelper.setWithoutUpdate( BlocksHelper.setWithoutUpdate(world, pos, state.setValue(EndBlockProperties.HYDRALUX_SHAPE, HydraluxShape.ROOTS));
world,
pos,
state.setValue(EndBlockProperties.HYDRALUX_SHAPE, HydraluxShape.ROOTS)
);
for (int i = 1; i < h - 2; i++) { for (int i = 1; i < h - 2; i++) {
mut.setY(pos.getY() + i); mut.setY(pos.getY() + i);
BlocksHelper.setWithoutUpdate( BlocksHelper.setWithoutUpdate(world, mut, state.setValue(EndBlockProperties.HYDRALUX_SHAPE, HydraluxShape.VINE));
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( BlocksHelper.setWithoutUpdate(world, mut, state.setValue(EndBlockProperties.HYDRALUX_SHAPE, big ? HydraluxShape.FLOWER_BIG_BOTTOM : HydraluxShape.FLOWER_SMALL_BOTTOM));
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( BlocksHelper.setWithoutUpdate(world, mut, state.setValue(EndBlockProperties.HYDRALUX_SHAPE, big ? HydraluxShape.FLOWER_BIG_TOP : HydraluxShape.FLOWER_SMALL_TOP));
world,
mut,
state.setValue(
EndBlockProperties.HYDRALUX_SHAPE,
big ? HydraluxShape.FLOWER_BIG_TOP : HydraluxShape.FLOWER_SMALL_TOP
)
);
} }
@Override @Override

View file

@ -1,5 +1,9 @@
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;
@ -22,8 +26,6 @@ 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;
@ -34,14 +36,12 @@ 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;
import ru.betterend.blocks.entities.BlockEntityHydrothermalVent; import ru.betterend.blocks.entities.BlockEntityHydrothermalVent;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
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 {
@ -99,8 +99,7 @@ public class HydrothermalVentBlock extends BaseBlockNotFull implements EntityBlo
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() return this.defaultBlockState().setValue(WATERLOGGED, worldAccess.getFluidState(blockPos).getType() == Fluids.WATER);
.setValue(WATERLOGGED, worldAccess.getFluidState(blockPos).getType() == Fluids.WATER);
} }
@Override @Override
@ -109,8 +108,8 @@ public class HydrothermalVentBlock extends BaseBlockNotFull implements EntityBlo
} }
@Override @Override
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) { public BlockEntity newBlockEntity(BlockGetter world) {
return new BlockEntityHydrothermalVent(pos, state); return new BlockEntityHydrothermalVent();
} }
@Override @Override
@ -124,26 +123,24 @@ public class HydrothermalVentBlock extends BaseBlockNotFull implements EntityBlo
@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()) if (world instanceof ServerLevel && state.getValue(WATERLOGGED) && world.getBlockState(pos.above()).is(Blocks.WATER)) {
.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();
world.addParticle(ParticleTypes.LARGE_SMOKE, x, y, z, 0, 0, 0); if (state.getValue(WATERLOGGED)) {
world.addParticle(EndParticles.GEYSER_PARTICLE, x, y, z, 0, 0, 0);
}
else {
world.addParticle(ParticleTypes.SMOKE, x, y, z, 0, 0, 0);
} }
} }
@Nullable
@Override
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState blockState, BlockEntityType<T> blockEntityType) {
return BlockEntityHydrothermalVent::tick;
} }
} }

View file

@ -6,13 +6,10 @@ 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.rituals.InfusionRitual; import ru.betterend.rituals.InfusionRitual;
@ -38,8 +35,7 @@ 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();
@ -48,8 +44,8 @@ public class InfusionPedestal extends PedestalBlock {
} }
@Override @Override
public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) { public BlockEntity newBlockEntity(BlockGetter world) {
return new InfusionPedestalEntity(blockPos, blockState); return new InfusionPedestalEntity();
} }
@Override @Override
@ -61,7 +57,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;
} }
@ -76,12 +72,6 @@ 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,8 +1,12 @@
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.Environment;
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;
@ -19,21 +23,17 @@ 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.ModelsHelper; import ru.bclib.client.models.ModelsHelper;
import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.BlockModelProvider; import ru.bclib.interfaces.IColorProvider;
import ru.bclib.interfaces.CustomColorProvider; import ru.bclib.interfaces.IRenderTyped;
import ru.bclib.interfaces.RenderLayerProvider;
import ru.bclib.util.ColorUtil; import ru.bclib.util.ColorUtil;
import ru.bclib.util.MHelper; 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; public class JellyshroomCapBlock extends SlimeBlock implements IRenderTyped, BlockModelProvider, IColorProvider {
import java.util.Optional;
public class JellyshroomCapBlock extends SlimeBlock implements RenderLayerProvider, BlockModelProvider, CustomColorProvider {
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;
@ -71,13 +71,11 @@ public class JellyshroomCapBlock extends SlimeBlock implements RenderLayerProvid
} }
@Override @Override
@Environment(EnvType.CLIENT)
public BlockModel getItemModel(ResourceLocation resourceLocation) { public BlockModel getItemModel(ResourceLocation resourceLocation) {
return getBlockModel(resourceLocation, defaultBlockState()); return getBlockModel(resourceLocation, defaultBlockState());
} }
@Override @Override
@Environment(EnvType.CLIENT)
public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) { public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_COLORED, "jellyshroom_cap"); Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_COLORED, "jellyshroom_cap");
return ModelsHelper.fromPattern(pattern); return ModelsHelper.fromPattern(pattern);

View file

@ -2,14 +2,13 @@ package ru.betterend.blocks;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.feature.Feature; import net.minecraft.world.level.levelgen.feature.Feature;
import ru.betterend.blocks.basis.PottableFeatureSapling; import ru.bclib.blocks.FeatureSaplingBlock;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndFeatures; import ru.betterend.registry.EndFeatures;
public class LacugroveSaplingBlock extends PottableFeatureSapling { public class LacugroveSaplingBlock extends FeatureSaplingBlock {
public LacugroveSaplingBlock() { public LacugroveSaplingBlock() {
super(); super();
} }
@ -21,12 +20,6 @@ public class LacugroveSaplingBlock extends PottableFeatureSapling {
@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()) return world.getBlockState(pos.below()).is(EndBlocks.END_MOSS) || world.getBlockState(pos.below()).is(EndBlocks.ENDSTONE_DUST);
.is(EndBlocks.ENDSTONE_DUST);
}
@Override
public boolean canPlantOn(Block block) {
return block == EndBlocks.END_MOSS;
} }
} }

View file

@ -1,5 +1,8 @@
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;
@ -18,9 +21,6 @@ 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;
@ -42,8 +42,7 @@ public class LanceleafBlock extends EndPlantBlock {
return world.getBlockState(pos.below()).is(this); return world.getBlockState(pos.below()).is(this);
} }
else if (shape == PentaShape.BOTTOM) { else if (shape == PentaShape.BOTTOM) {
return world.getBlockState(pos.below()).is(EndBlocks.AMBER_MOSS) && world.getBlockState(pos.above()) return world.getBlockState(pos.below()).is(EndBlocks.AMBER_MOSS) && world.getBlockState(pos.above()).is(this);
.is(this);
} }
else { else {
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);
@ -65,7 +64,6 @@ public class LanceleafBlock extends EndPlantBlock {
if (state.getValue(SHAPE) == PentaShape.BOTTOM) { if (state.getValue(SHAPE) == PentaShape.BOTTOM) {
return Collections.singletonList(new ItemStack(EndBlocks.LANCELEAF_SEED)); return Collections.singletonList(new ItemStack(EndBlocks.LANCELEAF_SEED));
} }
return MHelper.RANDOM.nextBoolean() ? Collections.emptyList() : Collections.singletonList(new ItemStack( return MHelper.RANDOM.nextBoolean() ? Collections.emptyList() : Collections.singletonList(new ItemStack(EndBlocks.LANCELEAF_SEED));
EndBlocks.LANCELEAF_SEED));
} }
} }

View file

@ -1,5 +1,7 @@
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;
@ -13,8 +15,6 @@ 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) {
@ -27,28 +27,12 @@ public class LanceleafSeedBlock extends EndPlantWithAgeBlock {
MutableBlockPos mut = new MutableBlockPos().set(pos); MutableBlockPos mut = new MutableBlockPos().set(pos);
BlockState plant = EndBlocks.LANCELEAF.defaultBlockState().setValue(BlockProperties.ROTATION, rotation); BlockState plant = EndBlocks.LANCELEAF.defaultBlockState().setValue(BlockProperties.ROTATION, rotation);
BlocksHelper.setWithoutUpdate(world, mut, plant.setValue(BlockProperties.PENTA_SHAPE, PentaShape.BOTTOM)); BlocksHelper.setWithoutUpdate(world, mut, plant.setValue(BlockProperties.PENTA_SHAPE, PentaShape.BOTTOM));
BlocksHelper.setWithoutUpdate( BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), plant.setValue(BlockProperties.PENTA_SHAPE, PentaShape.PRE_BOTTOM));
world,
mut.move(Direction.UP),
plant.setValue(BlockProperties.PENTA_SHAPE, PentaShape.PRE_BOTTOM)
);
for (int i = 2; i < height - 2; i++) { for (int i = 2; i < height - 2; i++) {
BlocksHelper.setWithoutUpdate( BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), plant.setValue(BlockProperties.PENTA_SHAPE, PentaShape.MIDDLE));
world,
mut.move(Direction.UP),
plant.setValue(BlockProperties.PENTA_SHAPE, PentaShape.MIDDLE)
);
} }
BlocksHelper.setWithoutUpdate( BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), plant.setValue(BlockProperties.PENTA_SHAPE, PentaShape.PRE_TOP));
world, BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), plant.setValue(BlockProperties.PENTA_SHAPE, PentaShape.TOP));
mut.move(Direction.UP),
plant.setValue(BlockProperties.PENTA_SHAPE, PentaShape.PRE_TOP)
);
BlocksHelper.setWithoutUpdate(
world,
mut.move(Direction.UP),
plant.setValue(BlockProperties.PENTA_SHAPE, PentaShape.TOP)
);
} }
@Override @Override

View file

@ -1,5 +1,7 @@
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,8 +22,6 @@ 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);

View file

@ -2,14 +2,13 @@ package ru.betterend.blocks;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.feature.Feature; import net.minecraft.world.level.levelgen.feature.Feature;
import ru.betterend.blocks.basis.PottableFeatureSapling; import ru.bclib.blocks.FeatureSaplingBlock;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndFeatures; import ru.betterend.registry.EndFeatures;
public class LucerniaSaplingBlock extends PottableFeatureSapling { public class LucerniaSaplingBlock extends FeatureSaplingBlock {
public LucerniaSaplingBlock() { public LucerniaSaplingBlock() {
super(); super();
} }
@ -23,9 +22,4 @@ public class LucerniaSaplingBlock extends PottableFeatureSapling {
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);
} }
@Override
public boolean canPlantOn(Block block) {
return block == EndBlocks.RUTISCUS;
}
} }

View file

@ -1,5 +1,8 @@
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;
@ -22,17 +25,14 @@ import net.minecraft.world.phys.shapes.VoxelShape;
import ru.bclib.api.TagAPI; import ru.bclib.api.TagAPI;
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.RenderLayerProvider; import ru.bclib.interfaces.IRenderTyped;
import ru.bclib.util.MHelper; import ru.bclib.util.MHelper;
import ru.betterend.blocks.EndBlockProperties.LumecornShape; 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 RenderLayerProvider { 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);
@ -63,7 +63,7 @@ public class LumecornBlock extends BaseBlockNotFull implements RenderLayerProvid
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);
if (shape == LumecornShape.BOTTOM_BIG || shape == LumecornShape.BOTTOM_SMALL) { if (shape == LumecornShape.BOTTOM_BIG || shape == LumecornShape.BOTTOM_SMALL) {
return world.getBlockState(pos.below()).is(TagAPI.BLOCK_END_GROUND); return world.getBlockState(pos.below()).is(TagAPI.END_GROUND);
} }
else if (shape == LumecornShape.LIGHT_TOP) { else if (shape == LumecornShape.LIGHT_TOP) {
return world.getBlockState(pos.below()).is(this); return world.getBlockState(pos.below()).is(this);
@ -87,13 +87,9 @@ public class LumecornBlock extends BaseBlockNotFull implements RenderLayerProvid
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);
if (shape == LumecornShape.BOTTOM_BIG || shape == LumecornShape.BOTTOM_SMALL || shape == LumecornShape.MIDDLE) { if (shape == LumecornShape.BOTTOM_BIG || shape == LumecornShape.BOTTOM_SMALL || shape == LumecornShape.MIDDLE) {
return Collections.singletonList(new ItemStack( return Collections.singletonList(new ItemStack(EndBlocks.LUMECORN_SEED, MHelper.randRange(1, 2, MHelper.RANDOM)));
EndBlocks.LUMECORN_SEED,
MHelper.randRange(1, 2, MHelper.RANDOM)
));
} }
return MHelper.RANDOM.nextBoolean() ? Collections.singletonList(new ItemStack(EndItems.LUMECORN_ROD)) : Collections return MHelper.RANDOM.nextBoolean() ? Collections.singletonList(new ItemStack(EndItems.LUMECORN_ROD)) : Collections.emptyList();
.emptyList();
} }
@Override @Override

View file

@ -1,21 +1,20 @@
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(new FeaturePlaceContext<>(world, null, random, pos, null)); EndFeatures.LUMECORN.getFeature().place(world, null, random, pos, null);
} }
@Override @Override

View file

@ -1,6 +1,9 @@
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;
@ -14,16 +17,15 @@ 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.RenderLayerProvider; 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 RenderLayerProvider { public class MengerSpongeBlock extends BaseBlockNotFull implements IRenderTyped {
public MengerSpongeBlock() { public MengerSpongeBlock() {
super(FabricBlockSettings.copyOf(Blocks.SPONGE).noOcclusion()); super(FabricBlockSettings.copyOf(Blocks.SPONGE).noOcclusion());
} }
@ -59,25 +61,19 @@ public class MengerSpongeBlock extends BaseBlockNotFull implements RenderLayerPr
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()).pickupBlock( if (blockState.getBlock() instanceof BucketPickup && ((BucketPickup) blockState.getBlock()).takeLiquid(world, blockPos2, blockState) != Fluids.EMPTY) {
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) {
else if (material == Material.WATER_PLANT || material == Material.REPLACEABLE_WATER_PLANT) { BlockEntity blockEntity = blockState.getBlock().isEntityBlock() ? world.getBlockEntity(blockPos2) : null;
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;

View file

@ -1,5 +1,7 @@
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,14 +21,12 @@ import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.Fluids; import net.minecraft.world.level.material.Fluids;
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.RenderLayerProvider; 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 RenderLayerProvider { public class MengerSpongeWetBlock extends BaseBlockNotFull implements IRenderTyped {
public MengerSpongeWetBlock() { public MengerSpongeWetBlock() {
super(FabricBlockSettings.copyOf(Blocks.WET_SPONGE).noOcclusion()); super(FabricBlockSettings.copyOf(Blocks.WET_SPONGE).noOcclusion());
} }
@ -36,14 +36,7 @@ public class MengerSpongeWetBlock extends BaseBlockNotFull implements RenderLaye
if (world.dimensionType().ultraWarm()) { if (world.dimensionType().ultraWarm()) {
world.setBlock(pos, EndBlocks.MENGER_SPONGE.defaultBlockState(), 3); world.setBlock(pos, EndBlocks.MENGER_SPONGE.defaultBlockState(), 3);
world.levelEvent(2009, pos, 0); world.levelEvent(2009, pos, 0);
world.playSound( world.playSound(null, pos, SoundEvents.FIRE_EXTINGUISH, SoundSource.BLOCKS, 1.0F, (1.0F + world.getRandom().nextFloat() * 0.2F) * 0.7F);
null,
pos,
SoundEvents.FIRE_EXTINGUISH,
SoundSource.BLOCKS,
1.0F,
(1.0F + world.getRandom().nextFloat() * 0.2F) * 0.7F
);
} }
} }
@ -97,13 +90,7 @@ public class MengerSpongeWetBlock extends BaseBlockNotFull implements RenderLaye
world.levelEvent(2001, pos, getId(state)); world.levelEvent(2001, pos, getId(state));
} }
if (world.getGameRules().getBoolean(GameRules.RULE_DOBLOCKDROPS) && (player == null || !player.isCreative())) { if (world.getGameRules().getBoolean(GameRules.RULE_DOBLOCKDROPS) && (player == null || !player.isCreative())) {
ItemEntity drop = new ItemEntity( ItemEntity drop = new ItemEntity(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, new ItemStack(this));
world,
pos.getX() + 0.5,
pos.getY() + 0.5,
pos.getZ() + 0.5,
new ItemStack(this)
);
world.addFreshEntity(drop); world.addFreshEntity(drop);
} }
} }

View file

@ -1,5 +1,9 @@
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;
@ -17,10 +21,6 @@ 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() {
@ -49,20 +49,10 @@ public class MossyDragonBoneBlock extends BaseRotatedPillarBlock {
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) {
else if (blockState.getFluidState().getAmount() == 8) {
return false; return false;
} } else {
else { int i = LayerLightEngine.getLightBlockInto(worldView, state, pos, blockState, blockPos, Direction.UP, blockState.getLightBlock(worldView, blockPos));
int i = LayerLightEngine.getLightBlockInto(
worldView,
state,
pos,
blockState,
blockPos,
Direction.UP,
blockState.getLightBlock(worldView, blockPos)
);
return i < 5; return i < 5;
} }
} }

View file

@ -21,11 +21,7 @@ public class MossyGlowshroomCapBlock extends BaseBlock {
} }
public BlockState getStateForPlacement(BlockPlaceContext ctx) { public BlockState getStateForPlacement(BlockPlaceContext ctx) {
return this.defaultBlockState() return this.defaultBlockState().setValue(TRANSITION, EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(ctx.getLevel().getBlockState(ctx.getClickedPos().below())));
.setValue(
TRANSITION,
EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(ctx.getLevel().getBlockState(ctx.getClickedPos().below()))
);
} }
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) { protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {

View file

@ -2,14 +2,14 @@ package ru.betterend.blocks;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.feature.Feature; import net.minecraft.world.level.levelgen.feature.Feature;
import ru.betterend.blocks.basis.PottableFeatureSapling; import ru.bclib.blocks.FeatureSaplingBlock;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndFeatures; import ru.betterend.registry.EndFeatures;
public class MossyGlowshroomSaplingBlock extends PottableFeatureSapling { public class MossyGlowshroomSaplingBlock extends FeatureSaplingBlock {
public MossyGlowshroomSaplingBlock() { public MossyGlowshroomSaplingBlock() {
super(7); super(7);
} }
@ -21,12 +21,6 @@ public class MossyGlowshroomSaplingBlock extends PottableFeatureSapling {
@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()) return world.getBlockState(pos.below()).is(EndBlocks.END_MOSS) || world.getBlockState(pos.below()).is(EndBlocks.END_MYCELIUM);
.is(EndBlocks.END_MYCELIUM);
}
@Override
public boolean canPlantOn(Block block) {
return block == EndBlocks.END_MOSS || block == EndBlocks.END_MYCELIUM;
} }
} }

View file

@ -1,5 +1,9 @@
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;
@ -16,10 +20,6 @@ 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());
@ -44,22 +44,12 @@ public class MossyObsidian extends BaseBlock {
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) {
else if (blockState.getFluidState().getAmount() == 8) {
return false; return false;
} } else {
else { int i = LayerLightEngine.getLightBlockInto(worldView, state, pos, blockState, blockPos, Direction.UP, blockState.getLightBlock(worldView, blockPos));
int i = LayerLightEngine.getLightBlockInto(
worldView,
state,
pos,
blockState,
blockPos,
Direction.UP,
blockState.getLightBlock(worldView, blockPos)
);
return i < 5; return i < 5;
} }
} }

View file

@ -1,5 +1,7 @@
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;
@ -15,8 +17,6 @@ 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)

View file

@ -1,6 +1,9 @@
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;
@ -20,8 +23,6 @@ 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) {
@ -33,10 +34,7 @@ public class NeedlegrassBlock extends EndPlantBlock {
@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.is(FabricToolTags.SHEARS) || EnchantmentHelper.getItemEnchantmentLevel( if (tool != null && tool.getItem().is(FabricToolTags.SHEARS) || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) {
Enchantments.SILK_TOUCH,
tool
) > 0) {
return Lists.newArrayList(new ItemStack(this)); return Lists.newArrayList(new ItemStack(this));
} }
else { else {

View file

@ -2,9 +2,9 @@ package ru.betterend.blocks;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import ru.betterend.blocks.basis.LitPillarBlock; import ru.bclib.blocks.BaseRotatedPillarBlock;
public class NeonCactusBlock extends LitPillarBlock { public class NeonCactusBlock extends BaseRotatedPillarBlock {
public NeonCactusBlock() { public NeonCactusBlock() {
super(FabricBlockSettings.copyOf(Blocks.CACTUS).luminance(15)); super(FabricBlockSettings.copyOf(Blocks.CACTUS).luminance(15));
} }

View file

@ -1,9 +1,12 @@
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.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos; import net.minecraft.core.BlockPos.MutableBlockPos;
@ -39,19 +42,14 @@ import ru.bclib.blocks.BaseBlockNotFull;
import ru.bclib.blocks.BlockProperties; import ru.bclib.blocks.BlockProperties;
import ru.bclib.blocks.BlockProperties.TripleShape; import ru.bclib.blocks.BlockProperties.TripleShape;
import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.RenderLayerProvider; import ru.bclib.interfaces.IRenderTyped;
import ru.bclib.util.BlocksHelper; import ru.bclib.util.BlocksHelper;
import ru.bclib.util.MHelper; import ru.bclib.util.MHelper;
import ru.betterend.blocks.EndBlockProperties.CactusBottom; import ru.betterend.blocks.EndBlockProperties.CactusBottom;
import ru.betterend.interfaces.PottablePlant;
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, RenderLayerProvider, PottablePlant { 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;
@ -67,9 +65,7 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
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) registerDefaultState(defaultBlockState().setValue(WATERLOGGED, false).setValue(FACING, Direction.UP).setValue(SHAPE, TripleShape.TOP));
.setValue(FACING, Direction.UP)
.setValue(SHAPE, TripleShape.TOP));
} }
@Override @Override
@ -83,9 +79,7 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
BlockPos pos = ctx.getClickedPos(); BlockPos pos = ctx.getClickedPos();
Direction dir = ctx.getClickedFace(); Direction dir = ctx.getClickedFace();
BlockState down = world.getBlockState(pos.relative(dir.getOpposite())); BlockState down = world.getBlockState(pos.relative(dir.getOpposite()));
BlockState state = this.defaultBlockState() BlockState state = this.defaultBlockState().setValue(WATERLOGGED, world.getFluidState(pos).getType() == Fluids.WATER).setValue(FACING, ctx.getClickedFace());
.setValue(WATERLOGGED, world.getFluidState(pos).getType() == Fluids.WATER)
.setValue(FACING, ctx.getClickedFace());
if (down.is(Blocks.END_STONE) || down.is(EndBlocks.ENDSTONE_DUST)) { if (down.is(Blocks.END_STONE) || down.is(EndBlocks.ENDSTONE_DUST)) {
state = state.setValue(CACTUS_BOTTOM, CactusBottom.SAND); state = state.setValue(CACTUS_BOTTOM, CactusBottom.SAND);
} }
@ -199,17 +193,11 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
Direction side = getSideDirection(world, pos, state, dir, random); Direction side = getSideDirection(world, pos, state, dir, random);
BlockPos sidePos = pos.relative(side); BlockPos sidePos = pos.relative(side);
if (world.isEmptyBlock(sidePos)) { if (world.isEmptyBlock(sidePos)) {
BlockState placement = state.setValue(SHAPE, TripleShape.TOP) BlockState placement = state.setValue(SHAPE, TripleShape.TOP).setValue(CACTUS_BOTTOM, CactusBottom.EMPTY).setValue(WATERLOGGED, false).setValue(FACING, side);
.setValue(CACTUS_BOTTOM, CactusBottom.EMPTY)
.setValue(WATERLOGGED, false)
.setValue(FACING, side);
BlocksHelper.setWithoutUpdate(world, sidePos, placement); BlocksHelper.setWithoutUpdate(world, sidePos, placement);
} }
} }
BlockState placement = state.setValue(SHAPE, TripleShape.TOP) BlockState placement = state.setValue(SHAPE, TripleShape.TOP).setValue(CACTUS_BOTTOM, CactusBottom.EMPTY).setValue(WATERLOGGED, false).setValue(FACING, dir);
.setValue(CACTUS_BOTTOM, CactusBottom.EMPTY)
.setValue(WATERLOGGED, false)
.setValue(FACING, dir);
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);
} }
@ -266,18 +254,12 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
Direction side = getSideDirection(world, pos, state, dir, random); Direction side = getSideDirection(world, pos, state, dir, random);
BlockPos sidePos = pos.relative(side); BlockPos sidePos = pos.relative(side);
if (world.isEmptyBlock(sidePos)) { if (world.isEmptyBlock(sidePos)) {
BlockState placement = state.setValue(SHAPE, TripleShape.TOP) BlockState placement = state.setValue(SHAPE, TripleShape.TOP).setValue(CACTUS_BOTTOM, CactusBottom.EMPTY).setValue(WATERLOGGED, false).setValue(FACING, side);
.setValue(CACTUS_BOTTOM, CactusBottom.EMPTY)
.setValue(WATERLOGGED, false)
.setValue(FACING, side);
BlocksHelper.setWithoutUpdate(world, sidePos, placement); BlocksHelper.setWithoutUpdate(world, sidePos, placement);
ends.add(sidePos.mutable()); ends.add(sidePos.mutable());
} }
} }
BlockState placement = state.setValue(SHAPE, TripleShape.TOP) BlockState placement = state.setValue(SHAPE, TripleShape.TOP).setValue(CACTUS_BOTTOM, CactusBottom.EMPTY).setValue(WATERLOGGED, false).setValue(FACING, dir);
.setValue(CACTUS_BOTTOM, CactusBottom.EMPTY)
.setValue(WATERLOGGED, false)
.setValue(FACING, dir);
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);
pos.move(dir); pos.move(dir);
@ -291,7 +273,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);
@ -331,13 +313,13 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
mut.move(dir); mut.move(dir);
state = world.getBlockState(mut); state = world.getBlockState(mut);
if (!state.is(this)) { if (!state.is(this)) {
if (!state.is(TagAPI.BLOCK_END_GROUND)) { if (!state.is(TagAPI.END_GROUND)) {
length = -1; length = -1;
} }
break; break;
} }
dir = state.getValue(FACING).getOpposite(); dir = state.getValue(FACING).getOpposite();
length++; length ++;
} }
return length; return length;
} }
@ -356,7 +338,7 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
if (dir.getStepY() != 0) { if (dir.getStepY() != 0) {
break; break;
} }
count++; count ++;
} }
return count; return count;
} }
@ -414,15 +396,4 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
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));
} }
@Override
public boolean canPlantOn(Block block) {
return true;
}
@Override
@Environment(EnvType.CLIENT)
public String getPottedState() {
return "bottom=moss,shape=top,facing=up";
}
} }

View file

@ -1,66 +0,0 @@
package ru.betterend.blocks;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.resources.model.UnbakedModel;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.MaterialColor;
import net.minecraft.world.phys.BlockHitResult;
import ru.bclib.util.BlocksHelper;
import ru.betterend.blocks.basis.EndTerrainBlock;
import ru.betterend.registry.EndBlocks;
import java.util.Map;
public class PallidiumBlock extends EndTerrainBlock {
private final Block nextLevel;
public PallidiumBlock(String thickness, Block nextLevel) {
super(MaterialColor.COLOR_LIGHT_GRAY);
this.nextLevel = nextLevel;
}
public boolean canBePotted() {
return this == EndBlocks.PALLIDIUM_FULL;
}
@Override
public Block getBaseBlock() {
return EndBlocks.UMBRALITH.stone;
}
@Override
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
if (nextLevel == null) {
return InteractionResult.PASS;
}
else if (level.isClientSide) {
return InteractionResult.PASS;
}
ItemStack itemStack = player.getItemInHand(hand);
if (itemStack.is(Items.BONE_MEAL)) {
BlocksHelper.setWithUpdate(level, pos, nextLevel);
if (!player.isCreative()) {
itemStack.shrink(1);
}
return InteractionResult.SUCCESS;
}
return InteractionResult.PASS;
}
@Override
@Environment(EnvType.CLIENT)
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
return this.getBlockModel(stateId, blockState);
}
}

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,9 +20,8 @@ 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,5 +1,7 @@
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;
@ -17,8 +19,6 @@ 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);

View file

@ -2,14 +2,13 @@ package ru.betterend.blocks;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.feature.Feature; import net.minecraft.world.level.levelgen.feature.Feature;
import ru.betterend.blocks.basis.PottableFeatureSapling; import ru.bclib.blocks.FeatureSaplingBlock;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndFeatures; import ru.betterend.registry.EndFeatures;
public class PythadendronSaplingBlock extends PottableFeatureSapling { public class PythadendronSaplingBlock extends FeatureSaplingBlock {
public PythadendronSaplingBlock() { public PythadendronSaplingBlock() {
super(); super();
} }
@ -23,9 +22,4 @@ public class PythadendronSaplingBlock extends PottableFeatureSapling {
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);
} }
@Override
public boolean canPlantOn(Block block) {
return block == EndBlocks.CHORUS_NYLIUM;
}
} }

View file

@ -1,6 +1,11 @@
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;
@ -30,22 +35,19 @@ 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;
import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.CustomColorProvider; import ru.bclib.interfaces.IColorProvider;
import ru.bclib.interfaces.RenderLayerProvider; import ru.bclib.interfaces.IRenderTyped;
import ru.bclib.util.BlocksHelper; import ru.bclib.util.BlocksHelper;
import ru.bclib.util.ColorUtil; import ru.bclib.util.ColorUtil;
import ru.betterend.particle.InfusionParticleType; 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 CustomColorProvider, RenderLayerProvider {
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);
@ -145,7 +147,7 @@ public class RespawnObeliskBlock extends BaseBlock implements CustomColorProvide
@Override @Override
public BlockColor getProvider() { public BlockColor getProvider() {
return ((CustomColorProvider) EndBlocks.AURORA_CRYSTAL).getProvider(); return ((IColorProvider) EndBlocks.AURORA_CRYSTAL).getProvider();
} }
@Override @Override
@ -162,10 +164,7 @@ public class RespawnObeliskBlock extends BaseBlock implements CustomColorProvide
if (hand != InteractionHand.MAIN_HAND || !canActivate) { if (hand != InteractionHand.MAIN_HAND || !canActivate) {
if (!world.isClientSide && !(itemStack.getItem() instanceof BlockItem) && !player.isCreative()) { if (!world.isClientSide && !(itemStack.getItem() instanceof BlockItem) && !player.isCreative()) {
ServerPlayer serverPlayerEntity = (ServerPlayer) player; ServerPlayer serverPlayerEntity = (ServerPlayer) player;
serverPlayerEntity.displayClientMessage( serverPlayerEntity.displayClientMessage(new TranslatableComponent("message.betterend.fail_spawn"), true);
new TranslatableComponent("message.betterend.fail_spawn"),
true
);
} }
return InteractionResult.FAIL; return InteractionResult.FAIL;
} }

View file

@ -1,6 +1,9 @@
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;
@ -15,8 +18,6 @@ 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;
@ -25,8 +26,7 @@ public class RunedFlavolite extends BaseBlock {
.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));

View file

@ -6,11 +6,11 @@ import net.minecraft.world.level.block.Block;
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.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShape;
import ru.betterend.blocks.basis.PottableCropBlock; import ru.bclib.blocks.BaseCropBlock;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndItems; import ru.betterend.registry.EndItems;
public class ShadowBerryBlock extends PottableCropBlock { 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() {

View file

@ -1,5 +1,7 @@
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;
@ -9,8 +11,6 @@ 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);
@ -20,15 +20,7 @@ public class ShadowGrassBlock extends EndTerrainBlock {
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);
if (random.nextInt(32) == 0) { if (random.nextInt(32) == 0) {
world.addParticle( world.addParticle(EndParticles.BLACK_SPORE, (double) pos.getX() + random.nextDouble(), (double) pos.getY() + 1.1D, (double) pos.getZ() + random.nextDouble(), 0.0D, 0.0D, 0.0D);
EndParticles.BLACK_SPORE,
(double) pos.getX() + random.nextDouble(),
(double) pos.getY() + 1.1D,
(double) pos.getZ() + random.nextDouble(),
0.0D,
0.0D,
0.0D
);
} }
} }
} }

View file

@ -1,5 +1,7 @@
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;
@ -34,20 +36,12 @@ 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) super(FabricBlockSettings.of(Material.WOOD).breakByHand(true).hardness(0.5F).resistance(0.1F).sound(SoundType.WOOL).noOcclusion().randomTicks());
.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));
} }
@ -79,9 +73,7 @@ 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) -> { int count = world.getEntities(EndEntities.SILK_MOTH, new AABB(pos).inflate(16), (entity) -> { return true; }).size();
return true;
}).size();
if (count > 6) { if (count > 6) {
return; return;
} }
@ -97,7 +89,7 @@ public class SilkMothHiveBlock extends BaseBlock {
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.is(FabricToolTags.SHEARS) && state.getValue(FULLNESS) == 3) { if (stack.getItem().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,5 +1,9 @@
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;
@ -37,18 +41,14 @@ import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShape;
import ru.bclib.blocks.BaseBlock; import ru.bclib.blocks.BaseBlock;
import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.RenderLayerProvider; import ru.bclib.interfaces.IRenderTyped;
import ru.bclib.util.BlocksHelper; import ru.bclib.util.BlocksHelper;
import ru.bclib.util.MHelper; import ru.bclib.util.MHelper;
import ru.betterend.entity.SilkMothEntity; 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; public class SilkMothNestBlock extends BaseBlock implements IRenderTyped {
import java.util.List;
import java.util.Random;
public class SilkMothNestBlock extends BaseBlock implements RenderLayerProvider {
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;
@ -56,12 +56,7 @@ public class SilkMothNestBlock extends BaseBlock implements RenderLayerProvider
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) super(FabricBlockSettings.of(Material.WOOL).hardness(0.5F).resistance(0.1F).sound(SoundType.WOOL).noOcclusion().randomTicks());
.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));
} }
@ -89,8 +84,7 @@ public class SilkMothNestBlock extends BaseBlock implements RenderLayerProvider
@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)) {
if (canSupportCenter(world, pos.above(), Direction.DOWN) || world.getBlockState(pos.above()) if (canSupportCenter(world, pos.above(), Direction.DOWN) || world.getBlockState(pos.above()).is(BlockTags.LEAVES)) {
.is(BlockTags.LEAVES)) {
return state; return state;
} }
else { else {
@ -140,9 +134,7 @@ public class SilkMothNestBlock extends BaseBlock implements RenderLayerProvider
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) -> { int count = world.getEntities(EndEntities.SILK_MOTH, new AABB(pos).inflate(16), (entity) -> { return true; }).size();
return true;
}).size();
if (count > 6) { if (count > 6) {
return; return;
} }
@ -158,7 +150,7 @@ public class SilkMothNestBlock extends BaseBlock implements RenderLayerProvider
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.is(FabricToolTags.SHEARS) && state.getValue(ACTIVE) && state.getValue(FULLNESS) == 3) { if (stack.getItem().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,5 +1,7 @@
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;
@ -7,7 +9,6 @@ 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;
@ -16,8 +17,6 @@ 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);
@ -30,8 +29,7 @@ public class SmallAmaranitaBlock extends EndPlantBlock {
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() if (EndFeatures.GIGANTIC_AMARANITA.getFeature().place(world, null, random, bigPos, null)) {
.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());
@ -39,7 +37,7 @@ public class SmallAmaranitaBlock extends EndPlantBlock {
} }
return; return;
} }
EndFeatures.LARGE_AMARANITA.getFeature().place(new FeaturePlaceContext<>(world, null, random, pos, null)); EndFeatures.LARGE_AMARANITA.getFeature().place(world, null, random, pos, null);
} }
@Override @Override
@ -61,8 +59,10 @@ public class SmallAmaranitaBlock extends EndPlantBlock {
} }
private boolean checkFrame(ServerLevel world, BlockPos pos) { private boolean checkFrame(ServerLevel world, BlockPos pos) {
return world.getBlockState(pos).is(this) && world.getBlockState(pos.south()).is(this) && world.getBlockState(pos return world.getBlockState(pos).is(this) &&
.east()).is(this) && world.getBlockState(pos.south().east()).is(this); world.getBlockState(pos.south()).is(this) &&
world.getBlockState(pos.east()).is(this) &&
world.getBlockState(pos.south().east()).is(this);
} }
private void replaceMushroom(ServerLevel world, BlockPos pos) { private void replaceMushroom(ServerLevel world, BlockPos pos) {

View file

@ -1,9 +1,12 @@
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.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
@ -20,7 +23,6 @@ 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;
@ -30,16 +32,11 @@ import net.minecraft.world.phys.shapes.VoxelShape;
import ru.bclib.api.TagAPI; import ru.bclib.api.TagAPI;
import ru.bclib.blocks.BaseAttachedBlock; import ru.bclib.blocks.BaseAttachedBlock;
import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.RenderLayerProvider; import ru.bclib.interfaces.IRenderTyped;
import ru.bclib.util.BlocksHelper; import ru.bclib.util.BlocksHelper;
import ru.betterend.interfaces.PottablePlant;
import ru.betterend.registry.EndFeatures; import ru.betterend.registry.EndFeatures;
import java.util.EnumMap; public class SmallJellyshroomBlock extends BaseAttachedBlock implements IRenderTyped, BonemealableBlock {
import java.util.List;
import java.util.Random;
public class SmallJellyshroomBlock extends BaseAttachedBlock implements RenderLayerProvider, BonemealableBlock, PottablePlant {
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() {
@ -59,10 +56,7 @@ public class SmallJellyshroomBlock extends BaseAttachedBlock implements RenderLa
@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.is(FabricToolTags.SHEARS) || EnchantmentHelper.getItemEnchantmentLevel( if (tool != null && tool.getItem().is(FabricToolTags.SHEARS) || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) {
Enchantments.SILK_TOUCH,
tool
) > 0) {
return Lists.newArrayList(new ItemStack(this)); return Lists.newArrayList(new ItemStack(this));
} }
else { else {
@ -94,7 +88,7 @@ public class SmallJellyshroomBlock extends BaseAttachedBlock implements RenderLa
@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 state.getValue(FACING) == Direction.UP && world.getBlockState(pos.below()).is(TagAPI.BLOCK_END_GROUND); return state.getValue(FACING) == Direction.UP && world.getBlockState(pos.below()).is(TagAPI.END_GROUND);
} }
@Override @Override
@ -105,17 +99,6 @@ public class SmallJellyshroomBlock extends BaseAttachedBlock implements RenderLa
@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(new FeaturePlaceContext<>(world, null, random, pos, null)); EndFeatures.JELLYSHROOM.getFeature().place(world, null, random, pos, null);
}
@Override
public boolean canPlantOn(Block block) {
return true;
}
@Override
@Environment(EnvType.CLIENT)
public String getPottedState() {
return "facing=up";
} }
} }

View file

@ -4,9 +4,9 @@ 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.world.level.block.SoundType; import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.material.Material; import net.minecraft.world.level.material.Material;
import ru.betterend.blocks.basis.LitPillarBlock; import ru.bclib.blocks.BaseRotatedPillarBlock;
public class SmaragdantCrystalBlock extends LitPillarBlock { public class SmaragdantCrystalBlock extends BaseRotatedPillarBlock {
public SmaragdantCrystalBlock() { public SmaragdantCrystalBlock() {
super(FabricBlockSettings.of(Material.GLASS) super(FabricBlockSettings.of(Material.GLASS)
.breakByTool(FabricToolTags.PICKAXES) .breakByTool(FabricToolTags.PICKAXES)
@ -14,6 +14,6 @@ public class SmaragdantCrystalBlock extends LitPillarBlock {
.hardness(1F) .hardness(1F)
.resistance(1F) .resistance(1F)
.noOcclusion() .noOcclusion()
.sound(SoundType.AMETHYST)); .sound(SoundType.GLASS));
} }
} }

View file

@ -1,6 +1,9 @@
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;
@ -27,12 +30,10 @@ import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShape;
import ru.bclib.blocks.BaseAttachedBlock; import ru.bclib.blocks.BaseAttachedBlock;
import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.RenderLayerProvider; import ru.bclib.interfaces.IRenderTyped;
import java.util.EnumMap;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class SmaragdantCrystalShardBlock extends BaseAttachedBlock implements RenderLayerProvider, 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;
@ -41,7 +42,7 @@ public class SmaragdantCrystalShardBlock extends BaseAttachedBlock implements Re
.materialColor(MaterialColor.COLOR_GREEN) .materialColor(MaterialColor.COLOR_GREEN)
.breakByTool(FabricToolTags.PICKAXES) .breakByTool(FabricToolTags.PICKAXES)
.luminance(15) .luminance(15)
.sound(SoundType.AMETHYST_CLUSTER) .sound(SoundType.GLASS)
.requiresCorrectToolForDrops() .requiresCorrectToolForDrops()
.noCollission()); .noCollission());
} }

View file

@ -1,7 +1,12 @@
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;
@ -31,17 +36,13 @@ import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShape;
import ru.bclib.blocks.BaseAttachedBlock; import ru.bclib.blocks.BaseAttachedBlock;
import ru.bclib.client.render.BCLRenderLayer; import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.RenderLayerProvider; import ru.bclib.interfaces.IRenderTyped;
import ru.bclib.util.MHelper; 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 RenderLayerProvider, 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;
@ -68,10 +69,7 @@ public class SulphurCrystalBlock extends BaseAttachedBlock implements RenderLaye
@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( return state.getValue(AGE) < 2 ? Collections.emptyList() : Lists.newArrayList(new ItemStack(EndItems.CRYSTALLINE_SULPHUR, MHelper.randRange(1, 3, MHelper.RANDOM)));
EndItems.CRYSTALLINE_SULPHUR,
MHelper.randRange(1, 3, MHelper.RANDOM)
));
} }
@Override @Override

View file

@ -1,5 +1,7 @@
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;
@ -11,14 +13,12 @@ import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import ru.bclib.blocks.BaseVineBlock; import ru.bclib.blocks.BaseVineBlock;
import ru.bclib.interfaces.CustomColorProvider; import ru.bclib.interfaces.IColorProvider;
import ru.bclib.util.ColorUtil; 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 CustomColorProvider {
public static final Vec3i[] COLORS; public static final Vec3i[] COLORS;
public TenaneaFlowersBlock() { public TenaneaFlowersBlock() {
@ -30,8 +30,7 @@ public class TenaneaFlowersBlock extends BaseVineBlock implements CustomColorPro
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);

View file

@ -2,14 +2,13 @@ package ru.betterend.blocks;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.feature.Feature; import net.minecraft.world.level.levelgen.feature.Feature;
import ru.betterend.blocks.basis.PottableFeatureSapling; import ru.bclib.blocks.FeatureSaplingBlock;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndFeatures; import ru.betterend.registry.EndFeatures;
public class TenaneaSaplingBlock extends PottableFeatureSapling { public class TenaneaSaplingBlock extends FeatureSaplingBlock {
public TenaneaSaplingBlock() { public TenaneaSaplingBlock() {
super(); super();
} }
@ -23,9 +22,4 @@ public class TenaneaSaplingBlock extends PottableFeatureSapling {
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);
} }
@Override
public boolean canPlantOn(Block block) {
return block == EndBlocks.PINK_MOSS;
}
} }

View file

@ -14,7 +14,7 @@ public class TerrainPlantBlock extends EndPlantBlock {
@Override @Override
protected boolean isTerrain(BlockState state) { protected boolean isTerrain(BlockState state) {
for (Block block : ground) { for (Block block: ground) {
if (state.is(block)) { if (state.is(block)) {
return true; return true;
} }

View file

@ -1,5 +1,7 @@
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;
@ -12,8 +14,6 @@ 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);
@ -42,8 +42,7 @@ public class TwistedUmbrellaMossBlock extends EndPlantBlock {
@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() BlockState bs = EndBlocks.TWISTED_UMBRELLA_MOSS_TALL.defaultBlockState().setValue(BaseDoublePlantBlock.ROTATION, rot);
.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,5 +1,7 @@
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;
@ -8,8 +10,6 @@ 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);
@ -17,13 +17,7 @@ public class TwistedUmbrellaMossTallBlock extends BaseDoublePlantBlock {
@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( ItemEntity item = new ItemEntity(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, new ItemStack(EndBlocks.TWISTED_UMBRELLA_MOSS));
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);
} }

View file

@ -1,5 +1,7 @@
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;
@ -12,8 +14,6 @@ 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);

View file

@ -1,5 +1,7 @@
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;
@ -8,8 +10,6 @@ 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);
@ -17,13 +17,7 @@ public class UmbrellaMossTallBlock extends BaseDoublePlantBlock {
@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( ItemEntity item = new ItemEntity(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, new ItemStack(EndBlocks.UMBRELLA_MOSS));
world,
pos.getX() + 0.5,
pos.getY() + 0.5,
pos.getZ() + 0.5,
new ItemStack(EndBlocks.UMBRELLA_MOSS)
);
world.addFreshEntity(item); world.addFreshEntity(item);
} }

View file

@ -47,21 +47,8 @@ public class UmbrellaTreeClusterBlock extends BaseBlock {
} }
stack = new ItemStack(EndItems.UMBRELLA_CLUSTER_JUICE); stack = new ItemStack(EndItems.UMBRELLA_CLUSTER_JUICE);
player.addItem(stack); player.addItem(stack);
world.playLocalSound( world.playLocalSound(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, SoundEvents.BOTTLE_FILL, SoundSource.BLOCKS, 1, 1, false);
pos.getX() + 0.5, BlocksHelper.setWithUpdate(world, pos, EndBlocks.UMBRELLA_TREE_CLUSTER_EMPTY.defaultBlockState().setValue(NATURAL, state.getValue(NATURAL)));
pos.getY() + 0.5,
pos.getZ() + 0.5,
SoundEvents.BOTTLE_FILL,
SoundSource.BLOCKS,
1,
1,
false
);
BlocksHelper.setWithUpdate(
world,
pos,
EndBlocks.UMBRELLA_TREE_CLUSTER_EMPTY.defaultBlockState().setValue(NATURAL, state.getValue(NATURAL))
);
return InteractionResult.SUCCESS; return InteractionResult.SUCCESS;
} }
return InteractionResult.FAIL; return InteractionResult.FAIL;

View file

@ -1,5 +1,7 @@
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;
@ -13,8 +15,6 @@ 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;
@ -33,11 +33,7 @@ public class UmbrellaTreeClusterEmptyBlock 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) {
if (state.getValue(NATURAL) && random.nextInt(16) == 0) { if (state.getValue(NATURAL) && random.nextInt(16) == 0) {
BlocksHelper.setWithUpdate( BlocksHelper.setWithUpdate(world, pos, EndBlocks.UMBRELLA_TREE_CLUSTER.defaultBlockState().setValue(UmbrellaTreeClusterBlock.NATURAL, true));
world,
pos,
EndBlocks.UMBRELLA_TREE_CLUSTER.defaultBlockState().setValue(UmbrellaTreeClusterBlock.NATURAL, true)
);
} }
} }
} }

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