Fixed structure features and code style
This commit is contained in:
parent
d431f2555c
commit
5a9365e2bb
153 changed files with 2304 additions and 2459 deletions
|
@ -8,7 +8,7 @@ yarn_mappings= 6
|
|||
loader_version= 0.11.6
|
||||
|
||||
# Mod Properties
|
||||
mod_version = 0.2.0
|
||||
mod_version = 0.2.1
|
||||
maven_group = ru.bclib
|
||||
archives_base_name = bclib
|
||||
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
package ru.bclib.api;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Random;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.impl.biome.InternalBiomeData;
|
||||
|
@ -20,6 +16,9 @@ import net.minecraft.world.level.biome.Biomes;
|
|||
import ru.bclib.util.MHelper;
|
||||
import ru.bclib.world.biomes.BCLBiome;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Random;
|
||||
|
||||
public class BiomeAPI {
|
||||
/**
|
||||
* Empty biome used as default value if requested biome doesn't exist or linked. Shouldn't be registered anywhere to prevent bugs.
|
||||
|
@ -33,6 +32,7 @@ public class BiomeAPI {
|
|||
|
||||
/**
|
||||
* Initialize registry for current server.
|
||||
*
|
||||
* @param server - {@link MinecraftServer}
|
||||
*/
|
||||
public static void initRegistry(MinecraftServer server) {
|
||||
|
@ -49,23 +49,19 @@ public class BiomeAPI {
|
|||
|
||||
/**
|
||||
* Adds {@link BCLBiome} to FabricAPI biomes as the Nether biome (with random {@link ClimateParameters}).
|
||||
*
|
||||
* @param biome - {@link BCLBiome}.
|
||||
*/
|
||||
public static void addNetherBiomeToFabricApi(BCLBiome biome) {
|
||||
ResourceKey<Biome> key = BuiltinRegistries.BIOME.getResourceKey(biome.getBiome()).get();
|
||||
Random random = new Random(biome.getID().toString().hashCode());
|
||||
ClimateParameters parameters = new ClimateParameters(
|
||||
MHelper.randRange(-2F, 2F, random),
|
||||
MHelper.randRange(-2F, 2F, random),
|
||||
MHelper.randRange(-2F, 2F, random),
|
||||
MHelper.randRange(-2F, 2F, random),
|
||||
MHelper.randRange(-2F, 2F, random)
|
||||
);
|
||||
ClimateParameters parameters = new ClimateParameters(MHelper.randRange(-2F, 2F, random), MHelper.randRange(-2F, 2F, random), MHelper.randRange(-2F, 2F, random), MHelper.randRange(-2F, 2F, random), MHelper.randRange(-2F, 2F, random));
|
||||
InternalBiomeData.addNetherBiome(key, parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds {@link BCLBiome} to FabricAPI biomes as an End land biome (generating on islands).
|
||||
*
|
||||
* @param biome - {@link BCLBiome}.
|
||||
*/
|
||||
public static void addEndLandBiomeToFabricApi(BCLBiome biome) {
|
||||
|
@ -77,6 +73,7 @@ public class BiomeAPI {
|
|||
|
||||
/**
|
||||
* Adds {@link BCLBiome} to FabricAPI biomes as an End void biome (generating between islands in the void).
|
||||
*
|
||||
* @param biome - {@link BCLBiome}.
|
||||
*/
|
||||
public static void addEndVoidBiomeToFabricApi(BCLBiome biome) {
|
||||
|
@ -87,6 +84,7 @@ public class BiomeAPI {
|
|||
|
||||
/**
|
||||
* Get {@link BCLBiome} from {@link Biome} instance on server. Used to convert world biomes to BCLBiomes.
|
||||
*
|
||||
* @param biome - {@link Biome} from world.
|
||||
* @return {@link BCLBiome} or {@code BiomeAPI.EMPTY_BIOME}.
|
||||
*/
|
||||
|
@ -99,6 +97,7 @@ public class BiomeAPI {
|
|||
|
||||
/**
|
||||
* Get {@link BCLBiome} from biome on client. Used in fog rendering.
|
||||
*
|
||||
* @param biome - {@link Biome} from client world.
|
||||
* @return {@link BCLBiome} or {@code BiomeAPI.EMPTY_BIOME}.
|
||||
*/
|
||||
|
@ -116,6 +115,7 @@ public class BiomeAPI {
|
|||
|
||||
/**
|
||||
* Get biome {@link ResourceLocation} from given {@link Biome}.
|
||||
*
|
||||
* @param biome - {@link Biome} from server world.
|
||||
* @return biome {@link ResourceLocation}.
|
||||
*/
|
||||
|
@ -126,6 +126,7 @@ public class BiomeAPI {
|
|||
|
||||
/**
|
||||
* Get {@link BCLBiome} from given {@link ResourceLocation}.
|
||||
*
|
||||
* @param biomeID - biome {@link ResourceLocation}.
|
||||
* @return {@link BCLBiome} or {@code BiomeAPI.EMPTY_BIOME}.
|
||||
*/
|
||||
|
@ -135,6 +136,7 @@ public class BiomeAPI {
|
|||
|
||||
/**
|
||||
* Get actual {@link Biome} from given {@link BCLBiome}. If it is null it will request it from current {@link Registry}.
|
||||
*
|
||||
* @param biome - {@link BCLBiome}.
|
||||
* @return {@link Biome}.
|
||||
*/
|
||||
|
@ -149,6 +151,7 @@ public class BiomeAPI {
|
|||
|
||||
/**
|
||||
* Check if biome with {@link ResourceLocation} exists in API registry.
|
||||
*
|
||||
* @param biomeID - biome {@link ResourceLocation}.
|
||||
* @return {@code true} if biome exists in API registry and {@code false} if not.
|
||||
*/
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
package ru.bclib.api;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import ru.bclib.util.WeightedList;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import ru.bclib.util.WeightedList;
|
||||
|
||||
public class BonemealAPI {
|
||||
private static final Map<ResourceLocation, Map<Block, WeightedList<Block>>> WATER_GRASS_BIOMES = Maps.newHashMap();
|
||||
private static final Map<ResourceLocation, Map<Block, WeightedList<Block>>> LAND_GRASS_BIOMES = Maps.newHashMap();
|
||||
|
@ -27,13 +26,13 @@ public class BonemealAPI {
|
|||
}
|
||||
|
||||
public static void addLandGrass(Block plant, Block... terrain) {
|
||||
for (Block block: terrain) {
|
||||
for (Block block : terrain) {
|
||||
addLandGrass(block, plant, 1F);
|
||||
}
|
||||
}
|
||||
|
||||
public static void addLandGrass(ResourceLocation biome, Block plant, Block... terrain) {
|
||||
for (Block block: terrain) {
|
||||
for (Block block : terrain) {
|
||||
addLandGrass(biome, block, plant, 1F);
|
||||
}
|
||||
}
|
||||
|
@ -62,13 +61,13 @@ public class BonemealAPI {
|
|||
}
|
||||
|
||||
public static void addWaterGrass(Block plant, Block... terrain) {
|
||||
for (Block block: terrain) {
|
||||
for (Block block : terrain) {
|
||||
addWaterGrass(block, plant, 1F);
|
||||
}
|
||||
}
|
||||
|
||||
public static void addWaterGrass(ResourceLocation biome, Block plant, Block... terrain) {
|
||||
for (Block block: terrain) {
|
||||
for (Block block : terrain) {
|
||||
addWaterGrass(biome, block, plant, 1F);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,15 @@
|
|||
package ru.bclib.api;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.fabricmc.loader.api.ModContainer;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.NbtIo;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.chunk.storage.RegionFile;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
|
@ -8,17 +18,6 @@ import java.util.List;
|
|||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.fabricmc.loader.api.ModContainer;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.NbtIo;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.chunk.storage.RegionFile;
|
||||
|
||||
public class DataFixerAPI {
|
||||
private static final Map<String, String> REPLACEMENT = Maps.newHashMap();
|
||||
private static final Map<String, Integer> FIX_VERSIONS = Maps.newHashMap();
|
||||
|
@ -31,7 +30,7 @@ public class DataFixerAPI {
|
|||
|
||||
boolean shoudFix = false;
|
||||
Collection<ModContainer> mods = FabricLoader.getInstance().getAllMods();
|
||||
for (ModContainer mod: mods) {
|
||||
for (ModContainer mod : mods) {
|
||||
String name = mod.getMetadata().getId();
|
||||
int preVersion = WorldDataAPI.getIntModVersion(name);
|
||||
int version = getModVersion(mod.getMetadata().getVersion().toString());
|
||||
|
@ -39,7 +38,8 @@ public class DataFixerAPI {
|
|||
int fixVersion = FIX_VERSIONS.getOrDefault(name, version);
|
||||
shoudFix |= fixVersion < version && fixVersion >= preVersion;
|
||||
}
|
||||
};
|
||||
}
|
||||
;
|
||||
if (!shoudFix) {
|
||||
return;
|
||||
}
|
||||
|
@ -90,14 +90,15 @@ public class DataFixerAPI {
|
|||
|
||||
/**
|
||||
* Register block data fix. Fix will be applied on world load if current mod version will be newer than specified one.
|
||||
* @param modID - {@link String} mod id;
|
||||
*
|
||||
* @param modID - {@link String} mod id;
|
||||
* @param modVersion - {@link String} mod version, should be in format: %d.%d.%d
|
||||
* @param result - {@link String} new block name;
|
||||
* @param names - array of {@link String}, old block names to convert.
|
||||
* @param result - {@link String} new block name;
|
||||
* @param names - array of {@link String}, old block names to convert.
|
||||
*/
|
||||
protected static void addFix(String modID, String modVersion, String result, String... names) {
|
||||
FIX_VERSIONS.put(modID, getModVersion(modVersion));
|
||||
for (String name: names) {
|
||||
for (String name : names) {
|
||||
REPLACEMENT.put(name, result);
|
||||
}
|
||||
}
|
||||
|
@ -106,7 +107,7 @@ public class DataFixerAPI {
|
|||
if (list == null) {
|
||||
list = Lists.newArrayList();
|
||||
}
|
||||
for (File file: dir.listFiles()) {
|
||||
for (File file : dir.listFiles()) {
|
||||
if (file.isDirectory()) {
|
||||
getAllRegions(file, list);
|
||||
}
|
||||
|
@ -119,6 +120,7 @@ public class DataFixerAPI {
|
|||
|
||||
/**
|
||||
* Get mod version from string. String should be in format: %d.%d.%d
|
||||
*
|
||||
* @param version - {@link String} mod version.
|
||||
* @return int mod version.
|
||||
*/
|
||||
|
@ -137,6 +139,7 @@ public class DataFixerAPI {
|
|||
|
||||
/**
|
||||
* Get mod version from integer. String will be in format %d.%d.%d
|
||||
*
|
||||
* @param version - mod version in integer form.
|
||||
* @return {@link String} mod version.
|
||||
*/
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
package ru.bclib.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import ru.bclib.integration.ModIntegration;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ModIntegrationAPI {
|
||||
private static final List<ModIntegration> INTEGRATIONS = Lists.newArrayList();
|
||||
|
||||
/**
|
||||
* Registers mod integration
|
||||
*
|
||||
* @param integration
|
||||
* @return
|
||||
*/
|
||||
|
@ -21,6 +21,7 @@ public class ModIntegrationAPI {
|
|||
|
||||
/**
|
||||
* Get all registered mod integrations.
|
||||
*
|
||||
* @return {@link List} of {@link ModIntegration}.
|
||||
*/
|
||||
public static List<ModIntegration> getIntegrations() {
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package ru.bclib.api;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import net.fabricmc.fabric.api.tag.TagRegistry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
|
@ -16,6 +14,8 @@ import net.minecraft.world.level.block.Blocks;
|
|||
import ru.bclib.BCLib;
|
||||
import ru.bclib.util.TagHelper;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class TagAPI {
|
||||
// Block Tags
|
||||
public static final Tag.Named<Block> BOOKSHELVES = makeCommonBlockTag("bookshelves");
|
||||
|
@ -37,8 +37,9 @@ public class TagAPI {
|
|||
|
||||
/**
|
||||
* Get or create {@link Tag.Named}.
|
||||
*
|
||||
* @param containerSupplier - {@link TagCollection} {@link Supplier} tag collection;
|
||||
* @param id - {@link ResourceLocation} tag id.
|
||||
* @param id - {@link ResourceLocation} tag id.
|
||||
* @return {@link Tag.Named}.
|
||||
*/
|
||||
public static <T> Tag.Named<T> makeTag(Supplier<TagCollection<T>> containerSupplier, ResourceLocation id) {
|
||||
|
@ -48,8 +49,9 @@ public class TagAPI {
|
|||
|
||||
/**
|
||||
* Get or create {@link Block} {@link Tag.Named} with mod namespace.
|
||||
*
|
||||
* @param modID - {@link String} mod namespace (mod id);
|
||||
* @param name - {@link String} tag name.
|
||||
* @param name - {@link String} tag name.
|
||||
* @return {@link Block} {@link Tag.Named}.
|
||||
*/
|
||||
public static Tag.Named<Block> makeBlockTag(String modID, String name) {
|
||||
|
@ -58,8 +60,9 @@ public class TagAPI {
|
|||
|
||||
/**
|
||||
* Get or create {@link Item} {@link Tag.Named} with mod namespace.
|
||||
*
|
||||
* @param modID - {@link String} mod namespace (mod id);
|
||||
* @param name - {@link String} tag name.
|
||||
* @param name - {@link String} tag name.
|
||||
* @return {@link Item} {@link Tag.Named}.
|
||||
*/
|
||||
public static Tag.Named<Item> makeItemTag(String modID, String name) {
|
||||
|
@ -68,9 +71,10 @@ public class TagAPI {
|
|||
|
||||
/**
|
||||
* Get or create {@link Block} {@link Tag.Named}.
|
||||
* @see <a href="https://fabricmc.net/wiki/tutorial:tags">Fabric Wiki (Tags)</a>
|
||||
*
|
||||
* @param name - {@link String} tag name.
|
||||
* @return {@link Block} {@link Tag.Named}.
|
||||
* @see <a href="https://fabricmc.net/wiki/tutorial:tags">Fabric Wiki (Tags)</a>
|
||||
*/
|
||||
public static Tag.Named<Block> makeCommonBlockTag(String name) {
|
||||
return makeTag(BlockTags::getAllTags, new ResourceLocation("c", name));
|
||||
|
@ -78,9 +82,10 @@ public class TagAPI {
|
|||
|
||||
/**
|
||||
* Get or create {@link Item} {@link Tag.Named}.
|
||||
* @see <a href="https://fabricmc.net/wiki/tutorial:tags">Fabric Wiki (Tags)</a>
|
||||
*
|
||||
* @param name - {@link String} tag name.
|
||||
* @return {@link Item} {@link Tag.Named}.
|
||||
* @see <a href="https://fabricmc.net/wiki/tutorial:tags">Fabric Wiki (Tags)</a>
|
||||
*/
|
||||
public static Tag.Named<Item> makeCommonItemTag(String name) {
|
||||
return makeTag(ItemTags::getAllTags, new ResourceLocation("c", name));
|
||||
|
@ -88,6 +93,7 @@ public class TagAPI {
|
|||
|
||||
/**
|
||||
* Get or create Minecraft {@link Block} {@link Tag.Named}.
|
||||
*
|
||||
* @param name - {@link String} tag name.
|
||||
* @return {@link Block} {@link Tag.Named}.
|
||||
*/
|
||||
|
@ -99,6 +105,7 @@ public class TagAPI {
|
|||
|
||||
/**
|
||||
* Adds {@link Block} to NETHER_GROUND and GEN_TERRAIN tags to process it properly in terrain generators and block logic.
|
||||
*
|
||||
* @param block - {@link Block}.
|
||||
*/
|
||||
public static void addNetherGround(Block block) {
|
||||
|
@ -108,6 +115,7 @@ public class TagAPI {
|
|||
|
||||
/**
|
||||
* Adds {@link Block} to END_GROUND and GEN_TERRAIN tags to process it properly in terrain generators and block logic.
|
||||
*
|
||||
* @param block - {@link Block}.
|
||||
*/
|
||||
public static void addEndGround(Block block) {
|
||||
|
|
|
@ -1,20 +1,19 @@
|
|||
package ru.bclib.api;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.fabricmc.loader.api.ModContainer;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtIo;
|
||||
import ru.bclib.BCLib;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.fabricmc.loader.api.ModContainer;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtIo;
|
||||
import ru.bclib.BCLib;
|
||||
|
||||
public class WorldDataAPI {
|
||||
private static final Map<String, CompoundTag> TAGS = Maps.newHashMap();
|
||||
private static final List<String> MODS = Lists.newArrayList();
|
||||
|
@ -52,6 +51,7 @@ public class WorldDataAPI {
|
|||
|
||||
/**
|
||||
* Register mod cache, world cache is located in world data folder.
|
||||
*
|
||||
* @param modID - {@link String} modID.
|
||||
*/
|
||||
public static void registerModCache(String modID) {
|
||||
|
@ -60,6 +60,7 @@ public class WorldDataAPI {
|
|||
|
||||
/**
|
||||
* Get root {@link CompoundTag} for mod cache in world data folder.
|
||||
*
|
||||
* @param modID - {@link String} modID.
|
||||
* @return {@link CompoundTag}
|
||||
*/
|
||||
|
@ -74,13 +75,14 @@ public class WorldDataAPI {
|
|||
|
||||
/**
|
||||
* Get {@link CompoundTag} with specified path from mod cache in world data folder.
|
||||
*
|
||||
* @param modID - {@link String} path to tag, dot-separated.
|
||||
* @return {@link CompoundTag}
|
||||
*/
|
||||
public static CompoundTag getCompoundTag(String modID, String path) {
|
||||
String[] parts = path.split("\\.");
|
||||
CompoundTag tag = getRootTag(modID);
|
||||
for (String part: parts) {
|
||||
for (String part : parts) {
|
||||
if (tag.contains(part)) {
|
||||
tag = tag.getCompound(part);
|
||||
}
|
||||
|
@ -95,6 +97,7 @@ public class WorldDataAPI {
|
|||
|
||||
/**
|
||||
* Forces mod cache file to be saved.
|
||||
*
|
||||
* @param modID {@link String} mod ID.
|
||||
*/
|
||||
public static void saveFile(String modID) {
|
||||
|
@ -108,6 +111,7 @@ public class WorldDataAPI {
|
|||
|
||||
/**
|
||||
* Get stored mod version (only for mods with registered cache).
|
||||
*
|
||||
* @return {@link String} mod version.
|
||||
*/
|
||||
public static String getModVersion(String modID) {
|
||||
|
@ -116,6 +120,7 @@ public class WorldDataAPI {
|
|||
|
||||
/**
|
||||
* Get stored mod version as integer (only for mods with registered cache).
|
||||
*
|
||||
* @return {@code int} mod version.
|
||||
*/
|
||||
public static int getIntModVersion(String modID) {
|
||||
|
|
|
@ -101,7 +101,8 @@ public class BaseBarrelBlockEntity extends RandomizableContainerBlockEntity {
|
|||
viewerCount = ChestBlockEntity.getOpenCount(level, worldPosition);
|
||||
if (viewerCount > 0) {
|
||||
scheduleUpdate();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
BlockState blockState = getBlockState();
|
||||
if (!(blockState.getBlock() instanceof BaseBarrelBlock)) {
|
||||
setRemoved();
|
||||
|
@ -133,8 +134,7 @@ public class BaseBarrelBlockEntity extends RandomizableContainerBlockEntity {
|
|||
double d = (double) this.worldPosition.getX() + 0.5D + (double) vec3i.getX() / 2.0D;
|
||||
double e = (double) this.worldPosition.getY() + 0.5D + (double) vec3i.getY() / 2.0D;
|
||||
double f = (double) this.worldPosition.getZ() + 0.5D + (double) vec3i.getZ() / 2.0D;
|
||||
level.playSound(null, d, e, f, soundEvent, SoundSource.BLOCKS, 0.5F,
|
||||
this.level.random.nextFloat() * 0.1F + 0.9F);
|
||||
level.playSound(null, d, e, f, soundEvent, SoundSource.BLOCKS, 0.5F, this.level.random.nextFloat() * 0.1F + 0.9F);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +1,6 @@
|
|||
package ru.bclib.blockentities;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
|
@ -13,6 +8,9 @@ import net.minecraft.world.level.block.entity.BlockEntityType;
|
|||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
public class DynamicBlockEntityType<T extends BlockEntity> extends BlockEntityType<T> {
|
||||
|
||||
private final Set<Block> validBlocks = Sets.newHashSet();
|
||||
|
@ -24,7 +22,8 @@ public class DynamicBlockEntityType<T extends BlockEntity> extends BlockEntityTy
|
|||
}
|
||||
|
||||
@Override
|
||||
@Nullable public T create(BlockPos blockPos, BlockState blockState) {
|
||||
@Nullable
|
||||
public T create(BlockPos blockPos, BlockState blockState) {
|
||||
return factory.create(blockPos, blockState);
|
||||
}
|
||||
|
||||
|
@ -38,8 +37,7 @@ public class DynamicBlockEntityType<T extends BlockEntity> extends BlockEntityTy
|
|||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public
|
||||
interface BlockEntitySupplier<T extends BlockEntity> {
|
||||
public interface BlockEntitySupplier<T extends BlockEntity> {
|
||||
T create(BlockPos blockPos, BlockState blockState);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,7 @@
|
|||
package ru.bclib.blocks;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
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;
|
||||
|
@ -25,12 +18,17 @@ import net.minecraft.world.level.block.state.StateDefinition;
|
|||
import net.minecraft.world.level.block.state.properties.IntegerProperty;
|
||||
import net.minecraft.world.level.material.MaterialColor;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.bclib.client.models.BasePatterns;
|
||||
import ru.bclib.client.models.BlockModelProvider;
|
||||
import ru.bclib.client.models.ModelsHelper;
|
||||
import ru.bclib.client.models.PatternsHelper;
|
||||
import ru.bclib.items.BaseAnvilItem;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public abstract class BaseAnvilBlock extends AnvilBlock implements BlockModelProvider {
|
||||
public static final IntegerProperty DESTRUCTION = BlockProperties.DESTRUCTION;
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package ru.bclib.blocks;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import ru.bclib.client.models.BasePatterns;
|
||||
import ru.bclib.client.models.PatternsHelper;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class BaseBarkBlock extends BaseRotatedPillarBlock {
|
||||
public BaseBarkBlock(Properties settings) {
|
||||
super(settings);
|
||||
|
|
|
@ -1,12 +1,5 @@
|
|||
package ru.bclib.blocks;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
|
@ -24,7 +17,6 @@ import net.minecraft.world.entity.LivingEntity;
|
|||
import net.minecraft.world.entity.monster.piglin.PiglinAi;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.BarrelBlock;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
@ -33,6 +25,7 @@ import net.minecraft.world.level.block.entity.BlockEntity;
|
|||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.bclib.blockentities.BaseBarrelBlockEntity;
|
||||
import ru.bclib.client.models.BasePatterns;
|
||||
import ru.bclib.client.models.BlockModelProvider;
|
||||
|
@ -40,6 +33,11 @@ import ru.bclib.client.models.ModelsHelper;
|
|||
import ru.bclib.client.models.PatternsHelper;
|
||||
import ru.bclib.registry.BaseBlockEntities;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
|
||||
public class BaseBarrelBlock extends BarrelBlock implements BlockModelProvider {
|
||||
public BaseBarrelBlock(Block source) {
|
||||
super(FabricBlockSettings.copyOf(source).noOcclusion());
|
||||
|
@ -59,11 +57,11 @@ public class BaseBarrelBlock extends BarrelBlock implements BlockModelProvider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand,
|
||||
BlockHitResult hit) {
|
||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
if (world.isClientSide) {
|
||||
return InteractionResult.SUCCESS;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
BlockEntity blockEntity = world.getBlockEntity(pos);
|
||||
if (blockEntity instanceof BaseBarrelBlockEntity) {
|
||||
player.openMenu((BaseBarrelBlockEntity) blockEntity);
|
||||
|
@ -89,8 +87,7 @@ public class BaseBarrelBlock extends BarrelBlock implements BlockModelProvider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setPlacedBy(Level world, BlockPos pos, BlockState state, LivingEntity placer,
|
||||
ItemStack itemStack) {
|
||||
public void setPlacedBy(Level world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack itemStack) {
|
||||
if (itemStack.hasCustomHoverName()) {
|
||||
BlockEntity blockEntity = world.getBlockEntity(pos);
|
||||
if (blockEntity instanceof BaseBarrelBlockEntity) {
|
||||
|
@ -111,7 +108,8 @@ public class BaseBarrelBlock extends BarrelBlock implements BlockModelProvider {
|
|||
Optional<String> pattern;
|
||||
if (blockState.getValue(OPEN)) {
|
||||
pattern = PatternsHelper.createJson(BasePatterns.BLOCK_BARREL_OPEN, blockId);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
pattern = PatternsHelper.createJson(BasePatterns.BLOCK_BOTTOM_TOP, blockId);
|
||||
}
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
|
@ -121,18 +119,28 @@ public class BaseBarrelBlock extends BarrelBlock implements BlockModelProvider {
|
|||
@Environment(EnvType.CLIENT)
|
||||
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
String open = blockState.getValue(OPEN) ? "_open" : "";
|
||||
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(),
|
||||
"block/" + stateId.getPath() + open);
|
||||
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath() + open);
|
||||
registerBlockModel(stateId, modelId, blockState, modelCache);
|
||||
Direction facing = blockState.getValue(FACING);
|
||||
BlockModelRotation rotation = BlockModelRotation.X0_Y0;
|
||||
switch (facing) {
|
||||
case NORTH: rotation = BlockModelRotation.X90_Y0; break;
|
||||
case EAST: rotation = BlockModelRotation.X90_Y90; break;
|
||||
case SOUTH: rotation = BlockModelRotation.X90_Y180; break;
|
||||
case WEST: rotation = BlockModelRotation.X90_Y270; break;
|
||||
case DOWN: rotation = BlockModelRotation.X180_Y0; break;
|
||||
default: break;
|
||||
case NORTH:
|
||||
rotation = BlockModelRotation.X90_Y0;
|
||||
break;
|
||||
case EAST:
|
||||
rotation = BlockModelRotation.X90_Y90;
|
||||
break;
|
||||
case SOUTH:
|
||||
rotation = BlockModelRotation.X90_Y180;
|
||||
break;
|
||||
case WEST:
|
||||
rotation = BlockModelRotation.X90_Y270;
|
||||
break;
|
||||
case DOWN:
|
||||
rotation = BlockModelRotation.X180_Y0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return ModelsHelper.createMultiVariant(modelId, rotation.getRotation(), false);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
package ru.bclib.blocks;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
@ -11,6 +8,9 @@ import net.minecraft.world.level.block.state.BlockState;
|
|||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import ru.bclib.client.models.BlockModelProvider;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class BaseBlock extends Block implements BlockModelProvider {
|
||||
public BaseBlock(Properties settings) {
|
||||
super(settings);
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
package ru.bclib.blocks;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.block.BaseEntityBlock;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class BaseBlockWithEntity extends BaseEntityBlock {
|
||||
public BaseBlockWithEntity(Properties settings) {
|
||||
super(settings);
|
||||
|
|
|
@ -1,11 +1,5 @@
|
|||
package ru.bclib.blocks;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
|
@ -19,10 +13,15 @@ import net.minecraft.world.level.block.Block;
|
|||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.bclib.client.models.BasePatterns;
|
||||
import ru.bclib.client.models.ModelsHelper;
|
||||
import ru.bclib.client.models.PatternsHelper;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class BaseBookshelfBlock extends BaseBlock {
|
||||
public BaseBookshelfBlock(Block source) {
|
||||
super(FabricBlockSettings.copyOf(source));
|
||||
|
|
|
@ -1,12 +1,5 @@
|
|||
package ru.bclib.blocks;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
|
@ -20,11 +13,17 @@ import net.minecraft.world.level.block.ButtonBlock;
|
|||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.AttachFace;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.bclib.client.models.BasePatterns;
|
||||
import ru.bclib.client.models.BlockModelProvider;
|
||||
import ru.bclib.client.models.ModelsHelper;
|
||||
import ru.bclib.client.models.PatternsHelper;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public abstract class BaseButtonBlock extends ButtonBlock implements BlockModelProvider {
|
||||
|
||||
private final Block parent;
|
||||
|
@ -52,9 +51,7 @@ public abstract class BaseButtonBlock extends ButtonBlock implements BlockModelP
|
|||
@Environment(EnvType.CLIENT)
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
Optional<String> pattern = blockState.getValue(POWERED) ?
|
||||
PatternsHelper.createJson(BasePatterns.BLOCK_BUTTON_PRESSED, parentId) :
|
||||
PatternsHelper.createJson(BasePatterns.BLOCK_BUTTON, parentId);
|
||||
Optional<String> pattern = blockState.getValue(POWERED) ? PatternsHelper.createJson(BasePatterns.BLOCK_BUTTON_PRESSED, parentId) : PatternsHelper.createJson(BasePatterns.BLOCK_BUTTON, parentId);
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
|
||||
|
@ -62,23 +59,40 @@ public abstract class BaseButtonBlock extends ButtonBlock implements BlockModelP
|
|||
@Environment(EnvType.CLIENT)
|
||||
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
String powered = blockState.getValue(POWERED) ? "_powered" : "";
|
||||
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(),
|
||||
"block/" + stateId.getPath() + powered);
|
||||
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath() + powered);
|
||||
registerBlockModel(stateId, modelId, blockState, modelCache);
|
||||
AttachFace face = blockState.getValue(FACE);
|
||||
boolean isCeiling = face == AttachFace.CEILING;
|
||||
int x = 0, y = 0;
|
||||
switch (face) {
|
||||
case CEILING: x = 180; break;
|
||||
case WALL: x = 90; break;
|
||||
default: break;
|
||||
case CEILING:
|
||||
x = 180;
|
||||
break;
|
||||
case WALL:
|
||||
x = 90;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
switch (blockState.getValue(FACING)) {
|
||||
case NORTH: if (isCeiling) { y = 180; } break;
|
||||
case EAST: y = isCeiling ? 270 : 90; break;
|
||||
case SOUTH: if(!isCeiling) { y = 180; } break;
|
||||
case WEST: y = isCeiling ? 90 : 270; break;
|
||||
default: break;
|
||||
case NORTH:
|
||||
if (isCeiling) {
|
||||
y = 180;
|
||||
}
|
||||
break;
|
||||
case EAST:
|
||||
y = isCeiling ? 270 : 90;
|
||||
break;
|
||||
case SOUTH:
|
||||
if (!isCeiling) {
|
||||
y = 180;
|
||||
}
|
||||
break;
|
||||
case WEST:
|
||||
y = isCeiling ? 90 : 270;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
BlockModelRotation rotation = BlockModelRotation.by(x, y);
|
||||
return ModelsHelper.createMultiVariant(modelId, rotation.getRotation(), face == AttachFace.WALL);
|
||||
|
|
|
@ -1,12 +1,5 @@
|
|||
package ru.bclib.blocks;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
|
@ -20,6 +13,7 @@ import net.minecraft.world.level.block.ChainBlock;
|
|||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.MaterialColor;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.bclib.client.models.BasePatterns;
|
||||
import ru.bclib.client.models.BlockModelProvider;
|
||||
import ru.bclib.client.models.ModelsHelper;
|
||||
|
@ -27,6 +21,11 @@ import ru.bclib.client.models.PatternsHelper;
|
|||
import ru.bclib.client.render.BCLRenderLayer;
|
||||
import ru.bclib.interfaces.IRenderTyped;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public class BaseChainBlock extends ChainBlock implements BlockModelProvider, IRenderTyped {
|
||||
public BaseChainBlock(MaterialColor color) {
|
||||
super(FabricBlockSettings.copyOf(Blocks.CHAIN).mapColor(color));
|
||||
|
@ -55,8 +54,7 @@ public class BaseChainBlock extends ChainBlock implements BlockModelProvider, IR
|
|||
@Environment(EnvType.CLIENT)
|
||||
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
Direction.Axis axis = blockState.getValue(AXIS);
|
||||
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(),
|
||||
"block/" + stateId.getPath());
|
||||
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath());
|
||||
registerBlockModel(stateId, modelId, blockState, modelCache);
|
||||
return ModelsHelper.createRotatedModel(modelId, axis);
|
||||
}
|
||||
|
|
|
@ -1,30 +1,28 @@
|
|||
package ru.bclib.blocks;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.ChestBlock;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.bclib.client.models.BasePatterns;
|
||||
import ru.bclib.client.models.BlockModelProvider;
|
||||
import ru.bclib.client.models.ModelsHelper;
|
||||
import ru.bclib.client.models.PatternsHelper;
|
||||
import ru.bclib.registry.BaseBlockEntities;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class BaseChestBlock extends ChestBlock implements BlockModelProvider {
|
||||
private final Block parent;
|
||||
|
||||
|
@ -40,8 +38,7 @@ public class BaseChestBlock extends ChestBlock implements BlockModelProvider {
|
|||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder)
|
||||
{
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
List<ItemStack> drop = super.getDrops(state, builder);
|
||||
drop.add(new ItemStack(this.asItem()));
|
||||
return drop;
|
||||
|
|
|
@ -1,12 +1,5 @@
|
|||
package ru.bclib.blocks;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
|
@ -18,12 +11,18 @@ import net.minecraft.world.level.block.Block;
|
|||
import net.minecraft.world.level.block.ComposterBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.bclib.client.models.BasePatterns;
|
||||
import ru.bclib.client.models.BlockModelProvider;
|
||||
import ru.bclib.client.models.ModelsHelper;
|
||||
import ru.bclib.client.models.ModelsHelper.MultiPartBuilder;
|
||||
import ru.bclib.client.models.PatternsHelper;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public class BaseComposterBlock extends ComposterBlock implements BlockModelProvider {
|
||||
public BaseComposterBlock(Block source) {
|
||||
super(FabricBlockSettings.copyOf(source));
|
||||
|
@ -60,7 +59,8 @@ public class BaseComposterBlock extends ComposterBlock implements BlockModelProv
|
|||
ResourceLocation contentId;
|
||||
if (level > 7) {
|
||||
contentId = new ResourceLocation("block/composter_contents_ready");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
contentId = new ResourceLocation("block/composter_contents" + level);
|
||||
}
|
||||
builder.part(contentId).setCondition(state -> state.getValue(LEVEL).equals(level)).add();
|
||||
|
|
|
@ -1,12 +1,5 @@
|
|||
package ru.bclib.blocks;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
|
@ -17,11 +10,17 @@ import net.minecraft.world.level.block.Block;
|
|||
import net.minecraft.world.level.block.CraftingTableBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.bclib.client.models.BasePatterns;
|
||||
import ru.bclib.client.models.BlockModelProvider;
|
||||
import ru.bclib.client.models.ModelsHelper;
|
||||
import ru.bclib.client.models.PatternsHelper;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class BaseCraftingTableBlock extends CraftingTableBlock implements BlockModelProvider {
|
||||
public BaseCraftingTableBlock(Block source) {
|
||||
super(FabricBlockSettings.copyOf(source));
|
||||
|
@ -45,6 +44,7 @@ public class BaseCraftingTableBlock extends CraftingTableBlock implements BlockM
|
|||
String blockName = blockId.getPath();
|
||||
Optional<String> pattern = PatternsHelper.createJson(BasePatterns.BLOCK_SIDED, new HashMap<String, String>() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
{
|
||||
put("%modid%", blockId.getNamespace());
|
||||
put("%particle%", blockName + "_front");
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
package ru.bclib.blocks;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
@ -31,6 +26,10 @@ import net.minecraft.world.phys.shapes.VoxelShape;
|
|||
import ru.bclib.util.BlocksHelper;
|
||||
import ru.bclib.util.MHelper;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class BaseCropBlock extends BasePlantBlock {
|
||||
private static final VoxelShape SHAPE = Block.box(2, 0, 2, 14, 14, 14);
|
||||
public static final IntegerProperty AGE = IntegerProperty.create("age", 0, 3);
|
||||
|
@ -39,12 +38,7 @@ public class BaseCropBlock extends BasePlantBlock {
|
|||
private final Item drop;
|
||||
|
||||
public BaseCropBlock(Item drop, Block... terrain) {
|
||||
super(FabricBlockSettings.of(Material.PLANT)
|
||||
.breakByTool(FabricToolTags.HOES)
|
||||
.breakByHand(true)
|
||||
.sound(SoundType.GRASS)
|
||||
.randomTicks()
|
||||
.noCollission());
|
||||
super(FabricBlockSettings.of(Material.PLANT).breakByTool(FabricToolTags.HOES).breakByHand(true).sound(SoundType.GRASS).randomTicks().noCollission());
|
||||
this.drop = drop;
|
||||
this.terrain = terrain;
|
||||
this.registerDefaultState(defaultBlockState().setValue(AGE, 0));
|
||||
|
@ -57,7 +51,7 @@ public class BaseCropBlock extends BasePlantBlock {
|
|||
|
||||
@Override
|
||||
protected boolean isTerrain(BlockState state) {
|
||||
for (Block block: terrain) {
|
||||
for (Block block : terrain) {
|
||||
if (state.is(block)) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,12 +1,5 @@
|
|||
package ru.bclib.blocks;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
|
@ -23,6 +16,7 @@ import net.minecraft.world.level.block.state.BlockState;
|
|||
import net.minecraft.world.level.block.state.properties.DoorHingeSide;
|
||||
import net.minecraft.world.level.block.state.properties.DoubleBlockHalf;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.bclib.client.models.BasePatterns;
|
||||
import ru.bclib.client.models.BlockModelProvider;
|
||||
import ru.bclib.client.models.ModelsHelper;
|
||||
|
@ -30,6 +24,11 @@ import ru.bclib.client.models.PatternsHelper;
|
|||
import ru.bclib.client.render.BCLRenderLayer;
|
||||
import ru.bclib.interfaces.IRenderTyped;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public class BaseDoorBlock extends DoorBlock implements IRenderTyped, BlockModelProvider {
|
||||
public BaseDoorBlock(Block source) {
|
||||
super(FabricBlockSettings.copyOf(source).strength(3F, 3F).noOcclusion());
|
||||
|
@ -40,8 +39,7 @@ public class BaseDoorBlock extends DoorBlock implements IRenderTyped, BlockModel
|
|||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
if (state.getValue(HALF) == DoubleBlockHalf.LOWER)
|
||||
return Collections.singletonList(new ItemStack(this.asItem()));
|
||||
else
|
||||
return Collections.emptyList();
|
||||
else return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -64,7 +62,8 @@ public class BaseDoorBlock extends DoorBlock implements IRenderTyped, BlockModel
|
|||
case TOP:
|
||||
pattern = PatternsHelper.createJson(BasePatterns.BLOCK_DOOR_TOP, resourceLocation);
|
||||
break;
|
||||
default: break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
|
@ -81,23 +80,27 @@ public class BaseDoorBlock extends DoorBlock implements IRenderTyped, BlockModel
|
|||
case EAST:
|
||||
if (hinge && open) {
|
||||
rotation = BlockModelRotation.X0_Y90;
|
||||
} else if (open) {
|
||||
}
|
||||
else if (open) {
|
||||
rotation = BlockModelRotation.X0_Y270;
|
||||
}
|
||||
break;
|
||||
case SOUTH:
|
||||
if (!hinge && !open || hinge && !open) {
|
||||
rotation = BlockModelRotation.X0_Y90;
|
||||
} else if (hinge) {
|
||||
}
|
||||
else if (hinge) {
|
||||
rotation = BlockModelRotation.X0_Y180;
|
||||
}
|
||||
break;
|
||||
case WEST:
|
||||
if (!hinge && !open || hinge && !open) {
|
||||
rotation = BlockModelRotation.X0_Y180;
|
||||
} else if (hinge) {
|
||||
}
|
||||
else if (hinge) {
|
||||
rotation = BlockModelRotation.X0_Y270;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
rotation = BlockModelRotation.X0_Y90;
|
||||
}
|
||||
break;
|
||||
|
@ -105,13 +108,13 @@ public class BaseDoorBlock extends DoorBlock implements IRenderTyped, BlockModel
|
|||
default:
|
||||
if (!hinge && !open || hinge && !open) {
|
||||
rotation = BlockModelRotation.X0_Y270;
|
||||
} else if (!hinge) {
|
||||
}
|
||||
else if (!hinge) {
|
||||
rotation = BlockModelRotation.X0_Y180;
|
||||
}
|
||||
break;
|
||||
}
|
||||
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(),
|
||||
"block/" + stateId.getPath() + "_" + doorType);
|
||||
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath() + "_" + doorType);
|
||||
registerBlockModel(stateId, modelId, blockState, modelCache);
|
||||
return ModelsHelper.createMultiVariant(modelId, rotation.getRotation(), false);
|
||||
}
|
||||
|
@ -135,10 +138,7 @@ public class BaseDoorBlock extends DoorBlock implements IRenderTyped, BlockModel
|
|||
}
|
||||
|
||||
protected enum DoorType implements StringRepresentable {
|
||||
BOTTOM_HINGE("bottom_hinge"),
|
||||
TOP_HINGE("top_hinge"),
|
||||
BOTTOM("bottom"),
|
||||
TOP("top");
|
||||
BOTTOM_HINGE("bottom_hinge"), TOP_HINGE("top_hinge"), BOTTOM("bottom"), TOP("top");
|
||||
|
||||
private final String name;
|
||||
|
||||
|
@ -147,8 +147,7 @@ public class BaseDoorBlock extends DoorBlock implements IRenderTyped, BlockModel
|
|||
}
|
||||
|
||||
public boolean isHinge() {
|
||||
return this == BOTTOM_HINGE ||
|
||||
this == TOP_HINGE;
|
||||
return this == BOTTOM_HINGE || this == TOP_HINGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
package ru.bclib.blocks;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
@ -38,6 +34,9 @@ import ru.bclib.client.render.BCLRenderLayer;
|
|||
import ru.bclib.interfaces.IRenderTyped;
|
||||
import ru.bclib.util.BlocksHelper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public abstract class BaseDoublePlantBlock extends BaseBlockNotFull implements IRenderTyped, BonemealableBlock {
|
||||
private static final VoxelShape SHAPE = Block.box(4, 2, 4, 12, 16, 12);
|
||||
|
@ -45,21 +44,12 @@ public abstract class BaseDoublePlantBlock extends BaseBlockNotFull implements I
|
|||
public static final BooleanProperty TOP = BooleanProperty.create("top");
|
||||
|
||||
public BaseDoublePlantBlock() {
|
||||
super(FabricBlockSettings.of(Material.PLANT)
|
||||
.breakByTool(FabricToolTags.SHEARS)
|
||||
.breakByHand(true)
|
||||
.sound(SoundType.WET_GRASS)
|
||||
.noCollission());
|
||||
super(FabricBlockSettings.of(Material.PLANT).breakByTool(FabricToolTags.SHEARS).breakByHand(true).sound(SoundType.WET_GRASS).noCollission());
|
||||
this.registerDefaultState(this.stateDefinition.any().setValue(TOP, false));
|
||||
}
|
||||
|
||||
public BaseDoublePlantBlock(int light) {
|
||||
super(FabricBlockSettings.of(Material.PLANT)
|
||||
.breakByTool(FabricToolTags.SHEARS)
|
||||
.breakByHand(true)
|
||||
.sound(SoundType.WET_GRASS)
|
||||
.lightLevel((state) -> state.getValue(TOP) ? light : 0)
|
||||
.noCollission());
|
||||
super(FabricBlockSettings.of(Material.PLANT).breakByTool(FabricToolTags.SHEARS).breakByHand(true).sound(SoundType.WET_GRASS).lightLevel((state) -> state.getValue(TOP) ? light : 0).noCollission());
|
||||
this.registerDefaultState(this.stateDefinition.any().setValue(TOP, false));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,5 @@
|
|||
package ru.bclib.blocks;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
|
@ -20,12 +13,18 @@ import net.minecraft.world.level.block.Block;
|
|||
import net.minecraft.world.level.block.FenceBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.bclib.client.models.BasePatterns;
|
||||
import ru.bclib.client.models.BlockModelProvider;
|
||||
import ru.bclib.client.models.ModelsHelper;
|
||||
import ru.bclib.client.models.ModelsHelper.MultiPartBuilder;
|
||||
import ru.bclib.client.models.PatternsHelper;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public class BaseFenceBlock extends FenceBlock implements BlockModelProvider {
|
||||
private final Block parent;
|
||||
|
||||
|
@ -66,21 +65,16 @@ public class BaseFenceBlock extends FenceBlock implements BlockModelProvider {
|
|||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
ResourceLocation postId = new ResourceLocation(stateId.getNamespace(),
|
||||
"block/" + stateId.getPath() + "_post");
|
||||
ResourceLocation sideId = new ResourceLocation(stateId.getNamespace(),
|
||||
"block/" + stateId.getPath() + "_side");
|
||||
ResourceLocation postId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath() + "_post");
|
||||
ResourceLocation sideId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath() + "_side");
|
||||
registerBlockModel(postId, postId, blockState, modelCache);
|
||||
registerBlockModel(sideId, sideId, blockState, modelCache);
|
||||
|
||||
MultiPartBuilder builder = MultiPartBuilder.create(stateDefinition);
|
||||
builder.part(sideId).setCondition(state -> state.getValue(NORTH)).setUVLock(true).add();
|
||||
builder.part(sideId).setCondition(state -> state.getValue(EAST))
|
||||
.setTransformation(BlockModelRotation.X0_Y90.getRotation()).setUVLock(true).add();
|
||||
builder.part(sideId).setCondition(state -> state.getValue(SOUTH))
|
||||
.setTransformation(BlockModelRotation.X0_Y180.getRotation()).setUVLock(true).add();
|
||||
builder.part(sideId).setCondition(state -> state.getValue(WEST))
|
||||
.setTransformation(BlockModelRotation.X0_Y270.getRotation()).setUVLock(true).add();
|
||||
builder.part(sideId).setCondition(state -> state.getValue(EAST)).setTransformation(BlockModelRotation.X0_Y90.getRotation()).setUVLock(true).add();
|
||||
builder.part(sideId).setCondition(state -> state.getValue(SOUTH)).setTransformation(BlockModelRotation.X0_Y180.getRotation()).setUVLock(true).add();
|
||||
builder.part(sideId).setCondition(state -> state.getValue(WEST)).setTransformation(BlockModelRotation.X0_Y270.getRotation()).setUVLock(true).add();
|
||||
builder.part(postId).add();
|
||||
|
||||
return builder.build();
|
||||
|
|
|
@ -69,7 +69,8 @@ public class BaseFurnaceBlock extends FurnaceBlock implements BlockModelProvider
|
|||
textures.put("%front%", blockName + "_front_on");
|
||||
textures.put("%glow%", blockName + "_glow");
|
||||
pattern = PatternsHelper.createJson(BasePatterns.BLOCK_FURNACE_LIT, textures);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
textures.put("%front%", blockName + "_front");
|
||||
pattern = PatternsHelper.createJson(BasePatterns.BLOCK_FURNACE, textures);
|
||||
}
|
||||
|
@ -86,8 +87,7 @@ public class BaseFurnaceBlock extends FurnaceBlock implements BlockModelProvider
|
|||
@Environment(EnvType.CLIENT)
|
||||
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
String lit = blockState.getValue(LIT) ? "_lit" : "";
|
||||
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(),
|
||||
"block/" + stateId.getPath() + lit);
|
||||
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath() + lit);
|
||||
registerBlockModel(stateId, modelId, blockState, modelCache);
|
||||
return ModelsHelper.createFacingModel(modelId, blockState.getValue(FACING), false, true);
|
||||
}
|
||||
|
|
|
@ -1,12 +1,5 @@
|
|||
package ru.bclib.blocks;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
|
@ -19,11 +12,17 @@ import net.minecraft.world.level.block.Block;
|
|||
import net.minecraft.world.level.block.FenceGateBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.bclib.client.models.BasePatterns;
|
||||
import ru.bclib.client.models.BlockModelProvider;
|
||||
import ru.bclib.client.models.ModelsHelper;
|
||||
import ru.bclib.client.models.PatternsHelper;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public class BaseGateBlock extends FenceGateBlock implements BlockModelProvider {
|
||||
private final Block parent;
|
||||
|
||||
|
@ -52,11 +51,10 @@ public class BaseGateBlock extends FenceGateBlock implements BlockModelProvider
|
|||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
Optional<String> pattern;
|
||||
if (inWall) {
|
||||
pattern = isOpen ? PatternsHelper.createJson(BasePatterns.BLOCK_GATE_OPEN_WALL, parentId) :
|
||||
PatternsHelper.createJson(BasePatterns.BLOCK_GATE_CLOSED_WALL, parentId);
|
||||
} else {
|
||||
pattern = isOpen ? PatternsHelper.createJson(BasePatterns.BLOCK_GATE_OPEN, parentId) :
|
||||
PatternsHelper.createJson(BasePatterns.BLOCK_GATE_CLOSED, parentId);
|
||||
pattern = isOpen ? PatternsHelper.createJson(BasePatterns.BLOCK_GATE_OPEN_WALL, parentId) : PatternsHelper.createJson(BasePatterns.BLOCK_GATE_CLOSED_WALL, parentId);
|
||||
}
|
||||
else {
|
||||
pattern = isOpen ? PatternsHelper.createJson(BasePatterns.BLOCK_GATE_OPEN, parentId) : PatternsHelper.createJson(BasePatterns.BLOCK_GATE_CLOSED, parentId);
|
||||
}
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
|
@ -67,8 +65,7 @@ public class BaseGateBlock extends FenceGateBlock implements BlockModelProvider
|
|||
boolean inWall = blockState.getValue(IN_WALL);
|
||||
boolean isOpen = blockState.getValue(OPEN);
|
||||
String state = "" + (inWall ? "_wall" : "") + (isOpen ? "_open" : "_closed");
|
||||
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(),
|
||||
"block/" + stateId.getPath() + state);
|
||||
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath() + state);
|
||||
registerBlockModel(stateId, modelId, blockState, modelCache);
|
||||
return ModelsHelper.createFacingModel(modelId, blockState.getValue(FACING), true, false);
|
||||
}
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
package ru.bclib.blocks;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
|
@ -31,6 +26,7 @@ import net.minecraft.world.level.material.FluidState;
|
|||
import net.minecraft.world.level.material.Fluids;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.bclib.client.models.BasePatterns;
|
||||
import ru.bclib.client.models.BlockModelProvider;
|
||||
import ru.bclib.client.models.ModelsHelper;
|
||||
|
@ -39,6 +35,9 @@ import ru.bclib.client.render.BCLRenderLayer;
|
|||
import ru.bclib.interfaces.IRenderTyped;
|
||||
import ru.bclib.util.BlocksHelper;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class BaseLadderBlock extends BaseBlockNotFull implements IRenderTyped, BlockModelProvider {
|
||||
public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING;
|
||||
|
@ -80,11 +79,11 @@ public class BaseLadderBlock extends BaseBlockNotFull implements IRenderTyped, B
|
|||
}
|
||||
|
||||
@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 (facing.getOpposite() == state.getValue(FACING) && !state.canSurvive(world, pos)) {
|
||||
return Blocks.AIR.defaultBlockState();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (state.getValue(WATERLOGGED)) {
|
||||
world.getLiquidTicks().scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world));
|
||||
}
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
package ru.bclib.blocks;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
|
@ -24,30 +20,19 @@ import ru.bclib.client.render.BCLRenderLayer;
|
|||
import ru.bclib.interfaces.IRenderTyped;
|
||||
import ru.bclib.util.MHelper;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class BaseLeavesBlock extends LeavesBlock implements BlockModelProvider, IRenderTyped {
|
||||
private final Block sapling;
|
||||
|
||||
public BaseLeavesBlock(Block sapling, MaterialColor color) {
|
||||
super(FabricBlockSettings.copyOf(Blocks.OAK_LEAVES)
|
||||
.mapColor(color)
|
||||
.breakByTool(FabricToolTags.HOES)
|
||||
.breakByTool(FabricToolTags.SHEARS)
|
||||
.breakByHand(true)
|
||||
.isValidSpawn((state, world, pos, type) -> false)
|
||||
.isSuffocating((state, world, pos) -> false)
|
||||
.isViewBlocking((state, world, pos) -> false));
|
||||
super(FabricBlockSettings.copyOf(Blocks.OAK_LEAVES).mapColor(color).breakByTool(FabricToolTags.HOES).breakByTool(FabricToolTags.SHEARS).breakByHand(true).isValidSpawn((state, world, pos, type) -> false).isSuffocating((state, world, pos) -> false).isViewBlocking((state, world, pos) -> false));
|
||||
this.sapling = sapling;
|
||||
}
|
||||
|
||||
public BaseLeavesBlock(Block sapling, MaterialColor color, int light) {
|
||||
super(FabricBlockSettings.copyOf(Blocks.OAK_LEAVES)
|
||||
.mapColor(color)
|
||||
.luminance(light)
|
||||
.breakByTool(FabricToolTags.HOES)
|
||||
.breakByTool(FabricToolTags.SHEARS)
|
||||
.isValidSpawn((state, world, pos, type) -> false)
|
||||
.isSuffocating((state, world, pos) -> false)
|
||||
.isViewBlocking((state, world, pos) -> false));
|
||||
super(FabricBlockSettings.copyOf(Blocks.OAK_LEAVES).mapColor(color).luminance(light).breakByTool(FabricToolTags.HOES).breakByTool(FabricToolTags.SHEARS).isValidSpawn((state, world, pos, type) -> false).isSuffocating((state, world, pos) -> false).isViewBlocking((state, world, pos) -> false));
|
||||
this.sapling = sapling;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,5 @@
|
|||
package ru.bclib.blocks;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
|
@ -21,6 +14,7 @@ import net.minecraft.world.level.block.Block;
|
|||
import net.minecraft.world.level.block.IronBarsBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.bclib.client.models.BasePatterns;
|
||||
import ru.bclib.client.models.BlockModelProvider;
|
||||
import ru.bclib.client.models.ModelsHelper;
|
||||
|
@ -28,6 +22,11 @@ import ru.bclib.client.models.PatternsHelper;
|
|||
import ru.bclib.client.render.BCLRenderLayer;
|
||||
import ru.bclib.interfaces.IRenderTyped;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public class BaseMetalBarsBlock extends IronBarsBlock implements BlockModelProvider, IRenderTyped {
|
||||
public BaseMetalBarsBlock(Block source) {
|
||||
super(FabricBlockSettings.copyOf(source).strength(5.0F, 6.0F).noOcclusion());
|
||||
|
@ -76,24 +75,17 @@ public class BaseMetalBarsBlock extends IronBarsBlock implements BlockModelProvi
|
|||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
ResourceLocation postId = new ResourceLocation(stateId.getNamespace(),
|
||||
"block/" + stateId.getPath() + "_post");
|
||||
ResourceLocation sideId = new ResourceLocation(stateId.getNamespace(),
|
||||
"block/" + stateId.getPath() + "_side");
|
||||
ResourceLocation postId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath() + "_post");
|
||||
ResourceLocation sideId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath() + "_side");
|
||||
registerBlockModel(postId, postId, blockState, modelCache);
|
||||
registerBlockModel(sideId, sideId, blockState, modelCache);
|
||||
|
||||
ModelsHelper.MultiPartBuilder builder = ModelsHelper.MultiPartBuilder.create(stateDefinition);
|
||||
builder.part(postId).setCondition(state ->
|
||||
!state.getValue(NORTH) && !state.getValue(EAST) &&
|
||||
!state.getValue(SOUTH) && !state.getValue(WEST)).add();
|
||||
builder.part(postId).setCondition(state -> !state.getValue(NORTH) && !state.getValue(EAST) && !state.getValue(SOUTH) && !state.getValue(WEST)).add();
|
||||
builder.part(sideId).setCondition(state -> state.getValue(NORTH)).setUVLock(true).add();
|
||||
builder.part(sideId).setCondition(state -> state.getValue(EAST))
|
||||
.setTransformation(BlockModelRotation.X0_Y90.getRotation()).setUVLock(true).add();
|
||||
builder.part(sideId).setCondition(state -> state.getValue(SOUTH))
|
||||
.setTransformation(BlockModelRotation.X0_Y180.getRotation()).setUVLock(true).add();
|
||||
builder.part(sideId).setCondition(state -> state.getValue(WEST))
|
||||
.setTransformation(BlockModelRotation.X0_Y270.getRotation()).setUVLock(true).add();
|
||||
builder.part(sideId).setCondition(state -> state.getValue(EAST)).setTransformation(BlockModelRotation.X0_Y90.getRotation()).setUVLock(true).add();
|
||||
builder.part(sideId).setCondition(state -> state.getValue(SOUTH)).setTransformation(BlockModelRotation.X0_Y180.getRotation()).setUVLock(true).add();
|
||||
builder.part(sideId).setCondition(state -> state.getValue(WEST)).setTransformation(BlockModelRotation.X0_Y270.getRotation()).setUVLock(true).add();
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
package ru.bclib.blocks;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -23,17 +19,16 @@ import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
|||
import ru.bclib.client.models.BlockModelProvider;
|
||||
import ru.bclib.util.MHelper;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class BaseOreBlock extends OreBlock implements BlockModelProvider {
|
||||
private final Item dropItem;
|
||||
private final int minCount;
|
||||
private final int maxCount;
|
||||
|
||||
public BaseOreBlock(Item drop, int minCount, int maxCount, int experience) {
|
||||
super(FabricBlockSettings.of(Material.STONE, MaterialColor.SAND)
|
||||
.hardness(3F)
|
||||
.resistance(9F)
|
||||
.requiresCorrectToolForDrops()
|
||||
.sound(SoundType.STONE), UniformInt.of(1, experience));
|
||||
super(FabricBlockSettings.of(Material.STONE, MaterialColor.SAND).hardness(3F).resistance(9F).requiresCorrectToolForDrops().sound(SoundType.STONE), UniformInt.of(1, experience));
|
||||
this.dropItem = drop;
|
||||
this.minCount = minCount;
|
||||
this.maxCount = maxCount;
|
||||
|
@ -56,7 +51,8 @@ public class BaseOreBlock extends OreBlock implements BlockModelProvider {
|
|||
return Collections.singletonList(new ItemStack(dropItem, max));
|
||||
}
|
||||
count = MHelper.randRange(min, max, MHelper.RANDOM);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
count = MHelper.randRange(minCount, maxCount, MHelper.RANDOM);
|
||||
}
|
||||
return Collections.singletonList(new ItemStack(dropItem, count));
|
||||
|
|
|
@ -1,14 +1,6 @@
|
|||
package ru.bclib.blocks;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
|
@ -28,10 +20,16 @@ import net.minecraft.world.level.storage.loot.LootContext;
|
|||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.bclib.client.models.BasePatterns;
|
||||
import ru.bclib.client.models.ModelsHelper;
|
||||
import ru.bclib.client.models.PatternsHelper;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class BasePathBlock extends BaseBlockNotFull {
|
||||
private static final VoxelShape SHAPE = Block.box(0, 0, 0, 16, 15, 16);
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
package ru.bclib.blocks;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
@ -33,6 +29,9 @@ import net.minecraft.world.phys.shapes.VoxelShape;
|
|||
import ru.bclib.client.render.BCLRenderLayer;
|
||||
import ru.bclib.interfaces.IRenderTyped;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public abstract class BasePlantBlock extends BaseBlockNotFull implements IRenderTyped, BonemealableBlock {
|
||||
private static final VoxelShape SHAPE = Block.box(4, 0, 4, 12, 14, 12);
|
||||
|
@ -46,20 +45,11 @@ public abstract class BasePlantBlock extends BaseBlockNotFull implements IRender
|
|||
}
|
||||
|
||||
public BasePlantBlock(boolean replaceable) {
|
||||
super(FabricBlockSettings.of(replaceable ? Material.REPLACEABLE_PLANT : Material.PLANT)
|
||||
.breakByTool(FabricToolTags.SHEARS)
|
||||
.breakByHand(true)
|
||||
.sound(SoundType.GRASS)
|
||||
.noCollission());
|
||||
super(FabricBlockSettings.of(replaceable ? Material.REPLACEABLE_PLANT : Material.PLANT).breakByTool(FabricToolTags.SHEARS).breakByHand(true).sound(SoundType.GRASS).noCollission());
|
||||
}
|
||||
|
||||
public BasePlantBlock(boolean replaceable, int light) {
|
||||
super(FabricBlockSettings.of(replaceable ? Material.REPLACEABLE_PLANT : Material.PLANT)
|
||||
.breakByTool(FabricToolTags.SHEARS)
|
||||
.breakByHand(true)
|
||||
.luminance(light)
|
||||
.sound(SoundType.GRASS)
|
||||
.noCollission());
|
||||
super(FabricBlockSettings.of(replaceable ? Material.REPLACEABLE_PLANT : Material.PLANT).breakByTool(FabricToolTags.SHEARS).breakByHand(true).luminance(light).sound(SoundType.GRASS).noCollission());
|
||||
}
|
||||
|
||||
public BasePlantBlock(Properties settings) {
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package ru.bclib.blocks;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
@ -15,16 +13,13 @@ import net.minecraft.world.level.block.state.StateDefinition;
|
|||
import net.minecraft.world.level.block.state.properties.IntegerProperty;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public abstract class BasePlantWithAgeBlock extends BasePlantBlock {
|
||||
public static final IntegerProperty AGE = BlockProperties.AGE;
|
||||
|
||||
public BasePlantWithAgeBlock() {
|
||||
this(FabricBlockSettings.of(Material.PLANT)
|
||||
.breakByTool(FabricToolTags.SHEARS)
|
||||
.breakByHand(true)
|
||||
.sound(SoundType.GRASS)
|
||||
.randomTicks()
|
||||
.noCollission());
|
||||
this(FabricBlockSettings.of(Material.PLANT).breakByTool(FabricToolTags.SHEARS).breakByHand(true).sound(SoundType.GRASS).randomTicks().noCollission());
|
||||
}
|
||||
|
||||
public BasePlantWithAgeBlock(Properties settings) {
|
||||
|
|
|
@ -1,12 +1,5 @@
|
|||
package ru.bclib.blocks;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
|
@ -19,11 +12,17 @@ import net.minecraft.world.level.block.Block;
|
|||
import net.minecraft.world.level.block.PressurePlateBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.bclib.client.models.BasePatterns;
|
||||
import ru.bclib.client.models.BlockModelProvider;
|
||||
import ru.bclib.client.models.ModelsHelper;
|
||||
import ru.bclib.client.models.PatternsHelper;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public class BasePressurePlateBlock extends PressurePlateBlock implements BlockModelProvider {
|
||||
private final Block parent;
|
||||
|
||||
|
@ -51,7 +50,8 @@ public class BasePressurePlateBlock extends PressurePlateBlock implements BlockM
|
|||
Optional<String> pattern;
|
||||
if (blockState.getValue(POWERED)) {
|
||||
pattern = PatternsHelper.createJson(BasePatterns.BLOCK_PLATE_DOWN, parentId);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
pattern = PatternsHelper.createJson(BasePatterns.BLOCK_PLATE_UP, parentId);
|
||||
}
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
|
@ -61,8 +61,7 @@ public class BasePressurePlateBlock extends PressurePlateBlock implements BlockM
|
|||
@Environment(EnvType.CLIENT)
|
||||
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
String state = blockState.getValue(POWERED) ? "_down" : "_up";
|
||||
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(),
|
||||
"block/" + stateId.getPath() + state);
|
||||
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath() + state);
|
||||
registerBlockModel(stateId, modelId, blockState, modelCache);
|
||||
return ModelsHelper.createBlockSimple(modelId);
|
||||
}
|
||||
|
|
|
@ -1,12 +1,5 @@
|
|||
package ru.bclib.blocks;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
|
@ -18,10 +11,16 @@ import net.minecraft.world.level.block.Block;
|
|||
import net.minecraft.world.level.block.RotatedPillarBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
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.PatternsHelper;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public class BaseRotatedPillarBlock extends RotatedPillarBlock implements BlockModelProvider {
|
||||
public BaseRotatedPillarBlock(Properties settings) {
|
||||
super(settings);
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
package ru.bclib.blocks;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
|
@ -42,22 +37,21 @@ import net.minecraft.world.level.material.Fluids;
|
|||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.bclib.blockentities.BaseSignBlockEntity;
|
||||
import ru.bclib.client.models.BlockModelProvider;
|
||||
import ru.bclib.client.models.ModelsHelper;
|
||||
import ru.bclib.interfaces.ISpetialItem;
|
||||
import ru.bclib.util.BlocksHelper;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class BaseSignBlock extends SignBlock implements BlockModelProvider, ISpetialItem {
|
||||
public static final IntegerProperty ROTATION = BlockStateProperties.ROTATION_16;
|
||||
public static final BooleanProperty FLOOR = BooleanProperty.create("floor");
|
||||
private static final VoxelShape[] WALL_SHAPES = new VoxelShape[] {
|
||||
Block.box(0.0D, 4.5D, 14.0D, 16.0D, 12.5D, 16.0D),
|
||||
Block.box(0.0D, 4.5D, 0.0D, 2.0D, 12.5D, 16.0D),
|
||||
Block.box(0.0D, 4.5D, 0.0D, 16.0D, 12.5D, 2.0D),
|
||||
Block.box(14.0D, 4.5D, 0.0D, 16.0D, 12.5D, 16.0D)
|
||||
};
|
||||
private static final VoxelShape[] WALL_SHAPES = new VoxelShape[] {Block.box(0.0D, 4.5D, 14.0D, 16.0D, 12.5D, 16.0D), Block.box(0.0D, 4.5D, 0.0D, 2.0D, 12.5D, 16.0D), Block.box(0.0D, 4.5D, 0.0D, 16.0D, 12.5D, 2.0D), Block.box(14.0D, 4.5D, 0.0D, 16.0D, 12.5D, 16.0D)};
|
||||
|
||||
private final Block parent;
|
||||
|
||||
|
@ -90,7 +84,8 @@ public class BaseSignBlock extends SignBlock implements BlockModelProvider, ISpe
|
|||
if (!world.isClientSide) {
|
||||
sign.setAllowedPlayerEditor(placer.getUUID());
|
||||
((ServerPlayer) placer).connection.send(new ClientboundOpenSignEditorPacket(pos));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
sign.setEditable(true);
|
||||
}
|
||||
}
|
||||
|
@ -123,10 +118,9 @@ public class BaseSignBlock extends SignBlock implements BlockModelProvider, ISpe
|
|||
public BlockState getStateForPlacement(BlockPlaceContext ctx) {
|
||||
if (ctx.getClickedFace() == Direction.UP) {
|
||||
FluidState fluidState = ctx.getLevel().getFluidState(ctx.getClickedPos());
|
||||
return this.defaultBlockState().setValue(FLOOR, true)
|
||||
.setValue(ROTATION, Mth.floor((180.0 + ctx.getRotation() * 16.0 / 360.0) + 0.5 - 12) & 15)
|
||||
.setValue(WATERLOGGED, fluidState.getType() == Fluids.WATER);
|
||||
} else if (ctx.getClickedFace() != Direction.DOWN) {
|
||||
return this.defaultBlockState().setValue(FLOOR, true).setValue(ROTATION, Mth.floor((180.0 + ctx.getRotation() * 16.0 / 360.0) + 0.5 - 12) & 15).setValue(WATERLOGGED, fluidState.getType() == Fluids.WATER);
|
||||
}
|
||||
else if (ctx.getClickedFace() != Direction.DOWN) {
|
||||
BlockState blockState = this.defaultBlockState();
|
||||
FluidState fluidState = ctx.getLevel().getFluidState(ctx.getClickedPos());
|
||||
LevelReader worldView = ctx.getLevel();
|
||||
|
|
|
@ -1,12 +1,5 @@
|
|||
package ru.bclib.blocks;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
|
@ -21,11 +14,17 @@ import net.minecraft.world.level.block.SlabBlock;
|
|||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.SlabType;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.bclib.client.models.BasePatterns;
|
||||
import ru.bclib.client.models.BlockModelProvider;
|
||||
import ru.bclib.client.models.ModelsHelper;
|
||||
import ru.bclib.client.models.PatternsHelper;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public class BaseSlabBlock extends SlabBlock implements BlockModelProvider {
|
||||
private final Block parent;
|
||||
|
||||
|
@ -53,7 +52,8 @@ public class BaseSlabBlock extends SlabBlock implements BlockModelProvider {
|
|||
Optional<String> pattern;
|
||||
if (blockState.getValue(TYPE) == SlabType.DOUBLE) {
|
||||
pattern = PatternsHelper.createBlockSimple(parentId);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
pattern = PatternsHelper.createJson(BasePatterns.BLOCK_SLAB, parentId);
|
||||
}
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
|
@ -63,8 +63,7 @@ public class BaseSlabBlock extends SlabBlock implements BlockModelProvider {
|
|||
@Environment(EnvType.CLIENT)
|
||||
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
SlabType type = blockState.getValue(TYPE);
|
||||
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(),
|
||||
"block/" + stateId.getPath() + "_" + type);
|
||||
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath() + "_" + type);
|
||||
registerBlockModel(stateId, modelId, blockState, modelCache);
|
||||
if (type == SlabType.TOP) {
|
||||
return ModelsHelper.createMultiVariant(modelId, BlockModelRotation.X180_Y0.getRotation(), true);
|
||||
|
|
|
@ -1,12 +1,5 @@
|
|||
package ru.bclib.blocks;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
|
@ -22,11 +15,17 @@ import net.minecraft.world.level.block.state.BlockState;
|
|||
import net.minecraft.world.level.block.state.properties.Half;
|
||||
import net.minecraft.world.level.block.state.properties.StairsShape;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.bclib.client.models.BasePatterns;
|
||||
import ru.bclib.client.models.BlockModelProvider;
|
||||
import ru.bclib.client.models.ModelsHelper;
|
||||
import ru.bclib.client.models.PatternsHelper;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public class BaseStairsBlock extends StairBlock implements BlockModelProvider {
|
||||
|
||||
private final Block parent;
|
||||
|
@ -77,10 +76,12 @@ public class BaseStairsBlock extends StairBlock implements BlockModelProvider {
|
|||
switch (shape) {
|
||||
case INNER_LEFT:
|
||||
case INNER_RIGHT:
|
||||
state = "_inner"; break;
|
||||
state = "_inner";
|
||||
break;
|
||||
case OUTER_LEFT:
|
||||
case OUTER_RIGHT:
|
||||
state = "_outer"; break;
|
||||
state = "_outer";
|
||||
break;
|
||||
default:
|
||||
state = "";
|
||||
}
|
||||
|
@ -88,10 +89,8 @@ public class BaseStairsBlock extends StairBlock implements BlockModelProvider {
|
|||
registerBlockModel(stateId, modelId, blockState, modelCache);
|
||||
|
||||
boolean isTop = blockState.getValue(HALF) == Half.TOP;
|
||||
boolean isLeft = shape == StairsShape.INNER_LEFT ||
|
||||
shape == StairsShape.OUTER_LEFT;
|
||||
boolean isRight = shape == StairsShape.INNER_RIGHT ||
|
||||
shape == StairsShape.OUTER_RIGHT;
|
||||
boolean isLeft = shape == StairsShape.INNER_LEFT || shape == StairsShape.OUTER_LEFT;
|
||||
boolean isRight = shape == StairsShape.INNER_RIGHT || shape == StairsShape.OUTER_RIGHT;
|
||||
int y = 0;
|
||||
int x = isTop ? 180 : 0;
|
||||
switch (blockState.getValue(FACING)) {
|
||||
|
|
|
@ -1,15 +1,6 @@
|
|||
package ru.bclib.blocks;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
|
@ -41,11 +32,18 @@ import net.minecraft.world.level.material.MaterialColor;
|
|||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.bclib.client.models.BasePatterns;
|
||||
import ru.bclib.client.models.ModelsHelper;
|
||||
import ru.bclib.client.models.PatternsHelper;
|
||||
import ru.bclib.client.sound.BlockSounds;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class BaseTerrainBlock extends BaseBlock {
|
||||
|
||||
|
|
|
@ -1,13 +1,5 @@
|
|||
package ru.bclib.blocks;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
|
@ -21,6 +13,7 @@ import net.minecraft.world.level.block.TrapDoorBlock;
|
|||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.Half;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.bclib.client.models.BasePatterns;
|
||||
import ru.bclib.client.models.BlockModelProvider;
|
||||
import ru.bclib.client.models.ModelsHelper;
|
||||
|
@ -28,6 +21,12 @@ import ru.bclib.client.models.PatternsHelper;
|
|||
import ru.bclib.client.render.BCLRenderLayer;
|
||||
import ru.bclib.interfaces.IRenderTyped;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public class BaseTrapdoorBlock extends TrapDoorBlock implements IRenderTyped, BlockModelProvider {
|
||||
public BaseTrapdoorBlock(Block source) {
|
||||
super(FabricBlockSettings.copyOf(source).strength(3.0F, 3.0F).noOcclusion());
|
||||
|
@ -56,6 +55,7 @@ public class BaseTrapdoorBlock extends TrapDoorBlock implements IRenderTyped, Bl
|
|||
String name = resourceLocation.getPath();
|
||||
Optional<String> pattern = PatternsHelper.createJson(BasePatterns.BLOCK_TRAPDOOR, new HashMap<String, String>() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
{
|
||||
put("%modid%", resourceLocation.getNamespace());
|
||||
put("%texture%", name);
|
||||
|
@ -87,7 +87,8 @@ public class BaseTrapdoorBlock extends TrapDoorBlock implements IRenderTyped, Bl
|
|||
case WEST:
|
||||
y = (isTop && isOpen) ? 90 : 270;
|
||||
break;
|
||||
default: break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
BlockModelRotation rotation = BlockModelRotation.by(x, y);
|
||||
return ModelsHelper.createMultiVariant(modelId, rotation.getRotation(), false);
|
||||
|
|
|
@ -17,20 +17,11 @@ import net.minecraft.world.level.material.Material;
|
|||
public abstract class BaseUnderwaterWallPlantBlock extends BaseWallPlantBlock implements LiquidBlockContainer {
|
||||
|
||||
public BaseUnderwaterWallPlantBlock() {
|
||||
super(FabricBlockSettings.of(Material.WATER_PLANT)
|
||||
.breakByTool(FabricToolTags.SHEARS)
|
||||
.breakByHand(true)
|
||||
.sound(SoundType.WET_GRASS)
|
||||
.noCollission());
|
||||
super(FabricBlockSettings.of(Material.WATER_PLANT).breakByTool(FabricToolTags.SHEARS).breakByHand(true).sound(SoundType.WET_GRASS).noCollission());
|
||||
}
|
||||
|
||||
public BaseUnderwaterWallPlantBlock(int light) {
|
||||
super(FabricBlockSettings.of(Material.WATER_PLANT)
|
||||
.breakByTool(FabricToolTags.SHEARS)
|
||||
.breakByHand(true)
|
||||
.luminance(light)
|
||||
.sound(SoundType.WET_GRASS)
|
||||
.noCollission());
|
||||
super(FabricBlockSettings.of(Material.WATER_PLANT).breakByTool(FabricToolTags.SHEARS).breakByHand(true).luminance(light).sound(SoundType.WET_GRASS).noCollission());
|
||||
}
|
||||
|
||||
public BaseUnderwaterWallPlantBlock(Properties settings) {
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
package ru.bclib.blocks;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
@ -37,6 +33,9 @@ import ru.bclib.client.render.BCLRenderLayer;
|
|||
import ru.bclib.interfaces.IRenderTyped;
|
||||
import ru.bclib.util.BlocksHelper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class BaseVineBlock extends BaseBlockNotFull implements IRenderTyped, BonemealableBlock {
|
||||
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
|
||||
|
@ -51,12 +50,7 @@ public class BaseVineBlock extends BaseBlockNotFull implements IRenderTyped, Bon
|
|||
}
|
||||
|
||||
public BaseVineBlock(int light, boolean bottomOnly) {
|
||||
super(FabricBlockSettings.of(Material.PLANT)
|
||||
.breakByTool(FabricToolTags.SHEARS)
|
||||
.breakByHand(true)
|
||||
.sound(SoundType.GRASS)
|
||||
.lightLevel((state) -> bottomOnly ? state.getValue(SHAPE) == TripleShape.BOTTOM ? light : 0 : light)
|
||||
.noCollission());
|
||||
super(FabricBlockSettings.of(Material.PLANT).breakByTool(FabricToolTags.SHEARS).breakByHand(true).sound(SoundType.GRASS).lightLevel((state) -> bottomOnly ? state.getValue(SHAPE) == TripleShape.BOTTOM ? light : 0 : light).noCollission());
|
||||
this.registerDefaultState(this.stateDefinition.any().setValue(SHAPE, TripleShape.BOTTOM));
|
||||
}
|
||||
|
||||
|
@ -96,10 +90,8 @@ public class BaseVineBlock extends BaseBlockNotFull implements IRenderTyped, Bon
|
|||
return Blocks.AIR.defaultBlockState();
|
||||
}
|
||||
else {
|
||||
if (world.getBlockState(pos.below()).getBlock() != this)
|
||||
return state.setValue(SHAPE, TripleShape.BOTTOM);
|
||||
else if (world.getBlockState(pos.above()).getBlock() != this)
|
||||
return state.setValue(SHAPE, TripleShape.TOP);
|
||||
if (world.getBlockState(pos.below()).getBlock() != this) return state.setValue(SHAPE, TripleShape.BOTTOM);
|
||||
else if (world.getBlockState(pos.above()).getBlock() != this) return state.setValue(SHAPE, TripleShape.TOP);
|
||||
return state.setValue(SHAPE, TripleShape.MIDDLE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,5 @@
|
|||
package ru.bclib.blocks;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
|
@ -21,11 +14,17 @@ import net.minecraft.world.level.block.WallBlock;
|
|||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.WallSide;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.bclib.client.models.BasePatterns;
|
||||
import ru.bclib.client.models.BlockModelProvider;
|
||||
import ru.bclib.client.models.ModelsHelper;
|
||||
import ru.bclib.client.models.PatternsHelper;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public class BaseWallBlock extends WallBlock implements BlockModelProvider {
|
||||
|
||||
private final Block parent;
|
||||
|
@ -70,31 +69,22 @@ public class BaseWallBlock extends WallBlock implements BlockModelProvider {
|
|||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
ResourceLocation postId = new ResourceLocation(stateId.getNamespace(),
|
||||
"block/" + stateId.getPath() + "_post");
|
||||
ResourceLocation sideId = new ResourceLocation(stateId.getNamespace(),
|
||||
"block/" + stateId.getPath() + "_side");
|
||||
ResourceLocation sideTallId = new ResourceLocation(stateId.getNamespace(),
|
||||
"block/" + stateId.getPath() + "_side_tall");
|
||||
ResourceLocation postId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath() + "_post");
|
||||
ResourceLocation sideId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath() + "_side");
|
||||
ResourceLocation sideTallId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath() + "_side_tall");
|
||||
registerBlockModel(postId, postId, blockState, modelCache);
|
||||
registerBlockModel(sideId, sideId, blockState, modelCache);
|
||||
registerBlockModel(sideTallId, sideTallId, blockState, modelCache);
|
||||
|
||||
ModelsHelper.MultiPartBuilder builder = ModelsHelper.MultiPartBuilder.create(stateDefinition);
|
||||
builder.part(sideId).setCondition(state -> state.getValue(NORTH_WALL) == WallSide.LOW).setUVLock(true).add();
|
||||
builder.part(sideId).setCondition(state -> state.getValue(EAST_WALL) == WallSide.LOW)
|
||||
.setTransformation(BlockModelRotation.X0_Y90.getRotation()).setUVLock(true).add();
|
||||
builder.part(sideId).setCondition(state -> state.getValue(SOUTH_WALL) == WallSide.LOW)
|
||||
.setTransformation(BlockModelRotation.X0_Y180.getRotation()).setUVLock(true).add();
|
||||
builder.part(sideId).setCondition(state -> state.getValue(WEST_WALL) == WallSide.LOW)
|
||||
.setTransformation(BlockModelRotation.X0_Y270.getRotation()).setUVLock(true).add();
|
||||
builder.part(sideId).setCondition(state -> state.getValue(EAST_WALL) == WallSide.LOW).setTransformation(BlockModelRotation.X0_Y90.getRotation()).setUVLock(true).add();
|
||||
builder.part(sideId).setCondition(state -> state.getValue(SOUTH_WALL) == WallSide.LOW).setTransformation(BlockModelRotation.X0_Y180.getRotation()).setUVLock(true).add();
|
||||
builder.part(sideId).setCondition(state -> state.getValue(WEST_WALL) == WallSide.LOW).setTransformation(BlockModelRotation.X0_Y270.getRotation()).setUVLock(true).add();
|
||||
builder.part(sideTallId).setCondition(state -> state.getValue(NORTH_WALL) == WallSide.TALL).setUVLock(true).add();
|
||||
builder.part(sideTallId).setCondition(state -> state.getValue(EAST_WALL) == WallSide.TALL)
|
||||
.setTransformation(BlockModelRotation.X0_Y90.getRotation()).setUVLock(true).add();
|
||||
builder.part(sideTallId).setCondition(state -> state.getValue(SOUTH_WALL) == WallSide.TALL)
|
||||
.setTransformation(BlockModelRotation.X0_Y180.getRotation()).setUVLock(true).add();
|
||||
builder.part(sideTallId).setCondition(state -> state.getValue(WEST_WALL) == WallSide.TALL)
|
||||
.setTransformation(BlockModelRotation.X0_Y270.getRotation()).setUVLock(true).add();
|
||||
builder.part(sideTallId).setCondition(state -> state.getValue(EAST_WALL) == WallSide.TALL).setTransformation(BlockModelRotation.X0_Y90.getRotation()).setUVLock(true).add();
|
||||
builder.part(sideTallId).setCondition(state -> state.getValue(SOUTH_WALL) == WallSide.TALL).setTransformation(BlockModelRotation.X0_Y180.getRotation()).setUVLock(true).add();
|
||||
builder.part(sideTallId).setCondition(state -> state.getValue(WEST_WALL) == WallSide.TALL).setTransformation(BlockModelRotation.X0_Y270.getRotation()).setUVLock(true).add();
|
||||
builder.part(postId).setCondition(state -> state.getValue(UP)).add();
|
||||
|
||||
return builder.build();
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
package ru.bclib.blocks;
|
||||
|
||||
import java.util.EnumMap;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
@ -28,29 +25,18 @@ import net.minecraft.world.phys.shapes.CollisionContext;
|
|||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import ru.bclib.util.BlocksHelper;
|
||||
|
||||
import java.util.EnumMap;
|
||||
|
||||
public abstract class BaseWallPlantBlock extends BasePlantBlock {
|
||||
private static final EnumMap<Direction, VoxelShape> SHAPES = Maps.newEnumMap(ImmutableMap.of(
|
||||
Direction.NORTH, Block.box(1, 1, 8, 15, 15, 16),
|
||||
Direction.SOUTH, Block.box(1, 1, 0, 15, 15, 8),
|
||||
Direction.WEST, Block.box(8, 1, 1, 16, 15, 15),
|
||||
Direction.EAST, Block.box(0, 1, 1, 8, 15, 15)));
|
||||
private static final EnumMap<Direction, VoxelShape> SHAPES = Maps.newEnumMap(ImmutableMap.of(Direction.NORTH, Block.box(1, 1, 8, 15, 15, 16), Direction.SOUTH, Block.box(1, 1, 0, 15, 15, 8), Direction.WEST, Block.box(8, 1, 1, 16, 15, 15), Direction.EAST, Block.box(0, 1, 1, 8, 15, 15)));
|
||||
public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING;
|
||||
|
||||
public BaseWallPlantBlock() {
|
||||
this(FabricBlockSettings.of(Material.PLANT)
|
||||
.breakByTool(FabricToolTags.SHEARS)
|
||||
.breakByHand(true)
|
||||
.sound(SoundType.GRASS)
|
||||
.noCollission());
|
||||
this(FabricBlockSettings.of(Material.PLANT).breakByTool(FabricToolTags.SHEARS).breakByHand(true).sound(SoundType.GRASS).noCollission());
|
||||
}
|
||||
|
||||
public BaseWallPlantBlock(int light) {
|
||||
this(FabricBlockSettings.of(Material.PLANT)
|
||||
.breakByTool(FabricToolTags.SHEARS)
|
||||
.breakByHand(true)
|
||||
.luminance(light)
|
||||
.sound(SoundType.GRASS)
|
||||
.noCollission());
|
||||
this(FabricBlockSettings.of(Material.PLANT).breakByTool(FabricToolTags.SHEARS).breakByHand(true).luminance(light).sound(SoundType.GRASS).noCollission());
|
||||
}
|
||||
|
||||
public BaseWallPlantBlock(Properties settings) {
|
||||
|
|
|
@ -1,12 +1,5 @@
|
|||
package ru.bclib.blocks;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
|
@ -19,11 +12,17 @@ import net.minecraft.world.level.block.Block;
|
|||
import net.minecraft.world.level.block.WeightedPressurePlateBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.bclib.client.models.BasePatterns;
|
||||
import ru.bclib.client.models.BlockModelProvider;
|
||||
import ru.bclib.client.models.ModelsHelper;
|
||||
import ru.bclib.client.models.PatternsHelper;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public class BaseWeightedPlateBlock extends WeightedPressurePlateBlock implements BlockModelProvider {
|
||||
private final Block parent;
|
||||
|
||||
|
@ -51,7 +50,8 @@ public class BaseWeightedPlateBlock extends WeightedPressurePlateBlock implement
|
|||
Optional<String> pattern;
|
||||
if (blockState.getValue(POWER) > 0) {
|
||||
pattern = PatternsHelper.createJson(BasePatterns.BLOCK_PLATE_DOWN, parentId);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
pattern = PatternsHelper.createJson(BasePatterns.BLOCK_PLATE_UP, parentId);
|
||||
}
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
|
@ -61,8 +61,7 @@ public class BaseWeightedPlateBlock extends WeightedPressurePlateBlock implement
|
|||
@Environment(EnvType.CLIENT)
|
||||
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
String state = blockState.getValue(POWER) > 0 ? "_down" : "_up";
|
||||
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(),
|
||||
"block/" + stateId.getPath() + state);
|
||||
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath() + state);
|
||||
registerBlockModel(stateId, modelId, blockState, modelCache);
|
||||
return ModelsHelper.createBlockSimple(modelId);
|
||||
}
|
||||
|
|
|
@ -24,9 +24,7 @@ public class BlockProperties {
|
|||
public static final IntegerProperty AGE = IntegerProperty.create("age", 0, 3);
|
||||
|
||||
public enum TripleShape implements StringRepresentable {
|
||||
TOP("top", 0),
|
||||
MIDDLE("middle", 1),
|
||||
BOTTOM("bottom", 2);
|
||||
TOP("top", 0), MIDDLE("middle", 1), BOTTOM("bottom", 2);
|
||||
|
||||
private final String name;
|
||||
private final int index;
|
||||
|
@ -56,11 +54,7 @@ public class BlockProperties {
|
|||
}
|
||||
|
||||
public enum PentaShape implements StringRepresentable {
|
||||
BOTTOM("bottom"),
|
||||
PRE_BOTTOM("pre_bottom"),
|
||||
MIDDLE("middle"),
|
||||
PRE_TOP("pre_top"),
|
||||
TOP("top");
|
||||
BOTTOM("bottom"), PRE_BOTTOM("pre_bottom"), MIDDLE("middle"), PRE_TOP("pre_top"), TOP("top");
|
||||
|
||||
private final String name;
|
||||
|
||||
|
|
|
@ -1,13 +1,5 @@
|
|||
package ru.bclib.blocks;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
|
@ -26,10 +18,12 @@ import net.minecraft.world.level.block.SaplingBlock;
|
|||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.levelgen.feature.Feature;
|
||||
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.bclib.client.models.BasePatterns;
|
||||
import ru.bclib.client.models.BlockModelProvider;
|
||||
import ru.bclib.client.models.ModelsHelper;
|
||||
|
@ -37,27 +31,21 @@ import ru.bclib.client.models.PatternsHelper;
|
|||
import ru.bclib.client.render.BCLRenderLayer;
|
||||
import ru.bclib.interfaces.IRenderTyped;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public abstract class FeatureSaplingBlock extends SaplingBlock implements IRenderTyped, BlockModelProvider {
|
||||
private static final VoxelShape SHAPE = Block.box(4, 0, 4, 12, 14, 12);
|
||||
|
||||
public FeatureSaplingBlock() {
|
||||
super(null, FabricBlockSettings.of(Material.PLANT)
|
||||
.breakByHand(true)
|
||||
.collidable(false)
|
||||
.instabreak()
|
||||
.sound(SoundType.GRASS)
|
||||
.randomTicks());
|
||||
super(null, FabricBlockSettings.of(Material.PLANT).breakByHand(true).collidable(false).instabreak().sound(SoundType.GRASS).randomTicks());
|
||||
}
|
||||
|
||||
public FeatureSaplingBlock(int light) {
|
||||
super(null, FabricBlockSettings.of(Material.PLANT)
|
||||
.breakByHand(true)
|
||||
.collidable(false)
|
||||
.luminance(light)
|
||||
.instabreak()
|
||||
.sound(SoundType.GRASS)
|
||||
.randomTicks());
|
||||
super(null, FabricBlockSettings.of(Material.PLANT).breakByHand(true).collidable(false).luminance(light).instabreak().sound(SoundType.GRASS).randomTicks());
|
||||
}
|
||||
|
||||
protected abstract Feature<?> getFeature();
|
||||
|
@ -74,10 +62,8 @@ public abstract class FeatureSaplingBlock extends SaplingBlock implements IRende
|
|||
|
||||
@Override
|
||||
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
|
||||
if (!canSurvive(state, world, pos))
|
||||
return Blocks.AIR.defaultBlockState();
|
||||
else
|
||||
return state;
|
||||
if (!canSurvive(state, world, pos)) return Blocks.AIR.defaultBlockState();
|
||||
else return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -9,26 +9,11 @@ import ru.bclib.interfaces.IRenderTyped;
|
|||
|
||||
public class SimpleLeavesBlock extends BaseBlockNotFull implements IRenderTyped {
|
||||
public SimpleLeavesBlock(MaterialColor color) {
|
||||
super(FabricBlockSettings.of(Material.LEAVES)
|
||||
.strength(0.2F)
|
||||
.mapColor(color)
|
||||
.sound(SoundType.GRASS)
|
||||
.noOcclusion()
|
||||
.isValidSpawn((state, world, pos, type) -> false)
|
||||
.isSuffocating((state, world, pos) -> false)
|
||||
.isViewBlocking((state, world, pos) -> false));
|
||||
super(FabricBlockSettings.of(Material.LEAVES).strength(0.2F).mapColor(color).sound(SoundType.GRASS).noOcclusion().isValidSpawn((state, world, pos, type) -> false).isSuffocating((state, world, pos) -> false).isViewBlocking((state, world, pos) -> false));
|
||||
}
|
||||
|
||||
public SimpleLeavesBlock(MaterialColor color, int light) {
|
||||
super(FabricBlockSettings.of(Material.LEAVES)
|
||||
.luminance(light)
|
||||
.mapColor(color)
|
||||
.strength(0.2F)
|
||||
.sound(SoundType.GRASS)
|
||||
.noOcclusion()
|
||||
.isValidSpawn((state, world, pos, type) -> false)
|
||||
.isSuffocating((state, world, pos) -> false)
|
||||
.isViewBlocking((state, world, pos) -> false));
|
||||
super(FabricBlockSettings.of(Material.LEAVES).luminance(light).mapColor(color).strength(0.2F).sound(SoundType.GRASS).noOcclusion().isValidSpawn((state, world, pos, type) -> false).isSuffocating((state, world, pos) -> false).isViewBlocking((state, world, pos) -> false));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
package ru.bclib.blocks;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
|
@ -37,12 +32,16 @@ import net.minecraft.world.level.material.FluidState;
|
|||
import net.minecraft.world.level.material.Fluids;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.bclib.client.models.BasePatterns;
|
||||
import ru.bclib.client.models.ModelsHelper;
|
||||
import ru.bclib.client.models.PatternsHelper;
|
||||
import ru.bclib.client.render.BCLRenderLayer;
|
||||
import ru.bclib.interfaces.IRenderTyped;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class StalactiteBlock extends BaseBlockNotFull implements SimpleWaterloggedBlock, LiquidBlockContainer, IRenderTyped {
|
||||
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
|
||||
|
@ -213,8 +212,7 @@ public class StalactiteBlock extends BaseBlockNotFull implements SimpleWaterlogg
|
|||
@Environment(EnvType.CLIENT)
|
||||
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
BlockModelRotation rotation = blockState.getValue(IS_FLOOR) ? BlockModelRotation.X0_Y0 : BlockModelRotation.X180_Y0;
|
||||
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(),
|
||||
stateId.getPath() + "_" + blockState.getValue(SIZE));
|
||||
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), stateId.getPath() + "_" + blockState.getValue(SIZE));
|
||||
registerBlockModel(modelId, modelId, blockState, modelCache);
|
||||
return ModelsHelper.createMultiVariant(modelId, rotation.getRotation(), false);
|
||||
}
|
||||
|
|
|
@ -1,15 +1,7 @@
|
|||
package ru.bclib.blocks;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
|
@ -34,11 +26,17 @@ import net.minecraft.world.level.block.state.StateDefinition;
|
|||
import net.minecraft.world.level.block.state.properties.EnumProperty;
|
||||
import net.minecraft.world.level.material.MaterialColor;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.bclib.blocks.BlockProperties.TripleShape;
|
||||
import ru.bclib.client.models.BasePatterns;
|
||||
import ru.bclib.client.models.ModelsHelper;
|
||||
import ru.bclib.client.models.PatternsHelper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
|
||||
public class TripleTerrainBlock extends BaseTerrainBlock {
|
||||
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
|
||||
|
||||
|
@ -78,7 +76,8 @@ public class TripleTerrainBlock extends BaseTerrainBlock {
|
|||
TripleShape shape = state.getValue(SHAPE);
|
||||
if (shape == TripleShape.BOTTOM) {
|
||||
super.randomTick(state, world, pos, random);
|
||||
} else if (random.nextInt(16) == 0) {
|
||||
}
|
||||
else if (random.nextInt(16) == 0) {
|
||||
boolean bottom = canStayBottom(world, pos);
|
||||
if (shape == TripleShape.TOP) {
|
||||
if (!bottom) {
|
||||
|
@ -89,9 +88,11 @@ public class TripleTerrainBlock extends BaseTerrainBlock {
|
|||
boolean top = canStay(state, world, pos) || isMiddle(world.getBlockState(pos.above()));
|
||||
if (!top && !bottom) {
|
||||
world.setBlockAndUpdate(pos, Blocks.END_STONE.defaultBlockState());
|
||||
} else if (top && !bottom) {
|
||||
}
|
||||
else if (top && !bottom) {
|
||||
world.setBlockAndUpdate(pos, state.setValue(SHAPE, TripleShape.BOTTOM));
|
||||
} else if (!top) {
|
||||
}
|
||||
else if (!top) {
|
||||
world.setBlockAndUpdate(pos, state.setValue(SHAPE, TripleShape.TOP));
|
||||
}
|
||||
}
|
||||
|
@ -103,9 +104,11 @@ public class TripleTerrainBlock extends BaseTerrainBlock {
|
|||
BlockState blockState = world.getBlockState(blockPos);
|
||||
if (isMiddle(blockState)) {
|
||||
return true;
|
||||
} else if (blockState.getFluidState().getAmount() == 8) {
|
||||
}
|
||||
else if (blockState.getFluidState().getAmount() == 8) {
|
||||
return false;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return !blockState.isFaceSturdy(world, blockPos, Direction.UP);
|
||||
}
|
||||
}
|
||||
|
@ -124,7 +127,8 @@ public class TripleTerrainBlock extends BaseTerrainBlock {
|
|||
if (isMiddle(blockState)) {
|
||||
ResourceLocation topId = new ResourceLocation(blockId.getNamespace(), path + "_top");
|
||||
pattern = PatternsHelper.createBlockSimple(topId);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
Map<String, String> textures = Maps.newHashMap();
|
||||
textures.put("%top%", "betterend:block/" + path + "_top");
|
||||
textures.put("%side%", "betterend:block/" + path + "_side");
|
||||
|
@ -139,8 +143,7 @@ public class TripleTerrainBlock extends BaseTerrainBlock {
|
|||
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
boolean isMiddle = isMiddle(blockState);
|
||||
String middle = isMiddle ? "_middle" : "";
|
||||
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(),
|
||||
"block/" + stateId.getPath() + middle);
|
||||
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath() + middle);
|
||||
registerBlockModel(stateId, modelId, blockState, modelCache);
|
||||
if (isMiddle) {
|
||||
List<Variant> variants = Lists.newArrayList();
|
||||
|
@ -148,13 +151,9 @@ public class TripleTerrainBlock extends BaseTerrainBlock {
|
|||
variants.add(new Variant(modelId, rotation.getRotation(), false, 1));
|
||||
}
|
||||
return new MultiVariant(variants);
|
||||
} else if (blockState.getValue(SHAPE) == TripleShape.TOP) {
|
||||
return new MultiVariant(Lists.newArrayList(
|
||||
new Variant(modelId, BlockModelRotation.X180_Y0.getRotation(), false, 1),
|
||||
new Variant(modelId, BlockModelRotation.X180_Y90.getRotation(), false, 1),
|
||||
new Variant(modelId, BlockModelRotation.X180_Y180.getRotation(), false, 1),
|
||||
new Variant(modelId, BlockModelRotation.X180_Y270.getRotation(), false, 1)
|
||||
));
|
||||
}
|
||||
else if (blockState.getValue(SHAPE) == TripleShape.TOP) {
|
||||
return new MultiVariant(Lists.newArrayList(new Variant(modelId, BlockModelRotation.X180_Y0.getRotation(), false, 1), new Variant(modelId, BlockModelRotation.X180_Y90.getRotation(), false, 1), new Variant(modelId, BlockModelRotation.X180_Y180.getRotation(), false, 1), new Variant(modelId, BlockModelRotation.X180_Y270.getRotation(), false, 1)));
|
||||
}
|
||||
return ModelsHelper.createRandomTopModel(modelId);
|
||||
}
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
package ru.bclib.blocks;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
@ -37,25 +33,19 @@ import net.minecraft.world.phys.shapes.VoxelShape;
|
|||
import ru.bclib.client.render.BCLRenderLayer;
|
||||
import ru.bclib.interfaces.IRenderTyped;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public abstract class UnderwaterPlantBlock extends BaseBlockNotFull implements IRenderTyped, BonemealableBlock, LiquidBlockContainer {
|
||||
private static final VoxelShape SHAPE = Block.box(4, 0, 4, 12, 14, 12);
|
||||
|
||||
public UnderwaterPlantBlock() {
|
||||
super(FabricBlockSettings.of(Material.WATER_PLANT)
|
||||
.breakByTool(FabricToolTags.SHEARS)
|
||||
.breakByHand(true)
|
||||
.sound(SoundType.WET_GRASS)
|
||||
.noCollission());
|
||||
super(FabricBlockSettings.of(Material.WATER_PLANT).breakByTool(FabricToolTags.SHEARS).breakByHand(true).sound(SoundType.WET_GRASS).noCollission());
|
||||
}
|
||||
|
||||
public UnderwaterPlantBlock(int light) {
|
||||
super(FabricBlockSettings.of(Material.WATER_PLANT)
|
||||
.breakByTool(FabricToolTags.SHEARS)
|
||||
.breakByHand(true)
|
||||
.luminance(light)
|
||||
.sound(SoundType.WET_GRASS)
|
||||
.noCollission());
|
||||
super(FabricBlockSettings.of(Material.WATER_PLANT).breakByTool(FabricToolTags.SHEARS).breakByHand(true).luminance(light).sound(SoundType.WET_GRASS).noCollission());
|
||||
}
|
||||
|
||||
public UnderwaterPlantBlock(Properties settings) {
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package ru.bclib.blocks;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
@ -14,16 +12,13 @@ import net.minecraft.world.level.block.state.StateDefinition;
|
|||
import net.minecraft.world.level.block.state.properties.IntegerProperty;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public abstract class UnderwaterPlantWithAgeBlock extends UnderwaterPlantBlock {
|
||||
public static final IntegerProperty AGE = BlockProperties.AGE;
|
||||
|
||||
public UnderwaterPlantWithAgeBlock() {
|
||||
super(FabricBlockSettings.of(Material.WATER_PLANT)
|
||||
.breakByTool(FabricToolTags.SHEARS)
|
||||
.breakByHand(true)
|
||||
.sound(SoundType.WET_GRASS)
|
||||
.randomTicks()
|
||||
.noCollission());
|
||||
super(FabricBlockSettings.of(Material.WATER_PLANT).breakByTool(FabricToolTags.SHEARS).breakByHand(true).sound(SoundType.WET_GRASS).randomTicks().noCollission());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
package ru.bclib.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
@ -29,16 +26,14 @@ import net.minecraft.world.phys.shapes.VoxelShape;
|
|||
import ru.bclib.client.render.BCLRenderLayer;
|
||||
import ru.bclib.interfaces.IRenderTyped;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public abstract class UpDownPlantBlock extends BaseBlockNotFull implements IRenderTyped {
|
||||
private static final VoxelShape SHAPE = Block.box(4, 0, 4, 12, 16, 12);
|
||||
|
||||
public UpDownPlantBlock() {
|
||||
super(FabricBlockSettings.of(Material.PLANT)
|
||||
.breakByTool(FabricToolTags.SHEARS)
|
||||
.breakByHand(true)
|
||||
.sound(SoundType.GRASS)
|
||||
.noCollission());
|
||||
super(FabricBlockSettings.of(Material.PLANT).breakByTool(FabricToolTags.SHEARS).breakByHand(true).sound(SoundType.GRASS).noCollission());
|
||||
}
|
||||
|
||||
protected abstract boolean isTerrain(BlockState state);
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
package ru.bclib.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
@ -15,16 +12,11 @@ import net.minecraft.world.level.block.state.BlockState;
|
|||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class WallMushroomBlock extends BaseWallPlantBlock {
|
||||
public WallMushroomBlock(int light) {
|
||||
super(FabricBlockSettings.of(Material.PLANT)
|
||||
.breakByTool(FabricToolTags.AXES)
|
||||
.breakByHand(true)
|
||||
.luminance(light)
|
||||
.hardness(0.2F)
|
||||
.sound(SoundType.GRASS)
|
||||
.sound(SoundType.WOOD)
|
||||
.noCollission());
|
||||
super(FabricBlockSettings.of(Material.PLANT).breakByTool(FabricToolTags.AXES).breakByHand(true).luminance(light).hardness(0.2F).sound(SoundType.GRASS).sound(SoundType.WOOD).noCollission());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -23,10 +23,8 @@ public class BCLibClient implements ClientModInitializer {
|
|||
Registry.BLOCK.forEach(block -> {
|
||||
if (block instanceof IRenderTyped) {
|
||||
BCLRenderLayer layer = ((IRenderTyped) block).getRenderLayer();
|
||||
if (layer == BCLRenderLayer.CUTOUT)
|
||||
BlockRenderLayerMap.INSTANCE.putBlock(block, cutout);
|
||||
else if (layer == BCLRenderLayer.TRANSLUCENT)
|
||||
BlockRenderLayerMap.INSTANCE.putBlock(block, translucent);
|
||||
if (layer == BCLRenderLayer.CUTOUT) BlockRenderLayerMap.INSTANCE.putBlock(block, cutout);
|
||||
else if (layer == BCLRenderLayer.TRANSLUCENT) BlockRenderLayerMap.INSTANCE.putBlock(block, translucent);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -56,28 +56,25 @@ public class BlockSignEditScreen extends Screen {
|
|||
model = new SignRenderer.SignModel(this.minecraft.getEntityModels().bakeLayer(ModelLayers.createSignModelName(WoodType.OAK)));
|
||||
|
||||
minecraft.keyboardHandler.setSendRepeatsToGui(true);
|
||||
this.addRenderableWidget(new Button(this.width / 2 - 100, this.height / 4 + 120, 200, 20, CommonComponents.GUI_DONE,
|
||||
(buttonWidget) -> {
|
||||
this.finishEditing();
|
||||
}));
|
||||
this.addRenderableWidget(new Button(this.width / 2 - 100, this.height / 4 + 120, 200, 20, CommonComponents.GUI_DONE, (buttonWidget) -> {
|
||||
this.finishEditing();
|
||||
}));
|
||||
this.sign.setEditable(false);
|
||||
this.selectionManager = new TextFieldHelper(() -> {
|
||||
return this.text[this.currentRow];
|
||||
}, (string) -> {
|
||||
this.text[this.currentRow] = string;
|
||||
this.sign.setMessage(this.currentRow, new TextComponent(string));
|
||||
}, TextFieldHelper.createClipboardGetter(this.minecraft), TextFieldHelper.createClipboardSetter(this.minecraft),
|
||||
(string) -> {
|
||||
return this.minecraft.font.width(string) <= 90;
|
||||
});
|
||||
}, TextFieldHelper.createClipboardGetter(this.minecraft), TextFieldHelper.createClipboardSetter(this.minecraft), (string) -> {
|
||||
return this.minecraft.font.width(string) <= 90;
|
||||
});
|
||||
}
|
||||
|
||||
public void removed() {
|
||||
minecraft.keyboardHandler.setSendRepeatsToGui(false);
|
||||
ClientPacketListener clientPlayNetworkHandler = this.minecraft.getConnection();
|
||||
if (clientPlayNetworkHandler != null) {
|
||||
clientPlayNetworkHandler.send(new ServerboundSignUpdatePacket(this.sign.getBlockPos(), this.text[0], this.text[1],
|
||||
this.text[2], this.text[3]));
|
||||
clientPlayNetworkHandler.send(new ServerboundSignUpdatePacket(this.sign.getBlockPos(), this.text[0], this.text[1], this.text[2], this.text[3]));
|
||||
}
|
||||
|
||||
this.sign.setEditable(true);
|
||||
|
@ -109,9 +106,11 @@ public class BlockSignEditScreen extends Screen {
|
|||
this.currentRow = this.currentRow - 1 & 3;
|
||||
this.selectionManager.setCursorToEnd();
|
||||
return true;
|
||||
} else if (keyCode != 264 && keyCode != 257 && keyCode != 335) {
|
||||
}
|
||||
else if (keyCode != 264 && keyCode != 257 && keyCode != 335) {
|
||||
return selectionManager.keyPressed(keyCode) || super.keyPressed(keyCode, scanCode, modifiers);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.currentRow = this.currentRow + 1 & 3;
|
||||
this.selectionManager.setCursorToEnd();
|
||||
return true;
|
||||
|
@ -168,15 +167,12 @@ public class BlockSignEditScreen extends Screen {
|
|||
}
|
||||
|
||||
float n = (float) (-this.minecraft.font.width(string2) / 2);
|
||||
this.minecraft.font.drawInBatch(string2, n, (float) (m * 10 - this.text.length * 5), i, false, matrix4f,
|
||||
immediate, false, 0, 15728880, false);
|
||||
this.minecraft.font.drawInBatch(string2, n, (float) (m * 10 - this.text.length * 5), i, false, matrix4f, immediate, false, 0, 15728880, false);
|
||||
if (m == this.currentRow && j >= 0 && bl2) {
|
||||
s = this.minecraft.font
|
||||
.width(string2.substring(0, Math.max(Math.min(j, string2.length()), 0)));
|
||||
s = this.minecraft.font.width(string2.substring(0, Math.max(Math.min(j, string2.length()), 0)));
|
||||
t = s - this.minecraft.font.width(string2) / 2;
|
||||
if (j >= string2.length()) {
|
||||
this.minecraft.font.drawInBatch("_", (float) t, (float) l, i, false, matrix4f, immediate, false,
|
||||
0, 15728880, false);
|
||||
this.minecraft.font.drawInBatch("_", (float) t, (float) l, i, false, matrix4f, immediate, false, 0, 15728880, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -187,8 +183,7 @@ public class BlockSignEditScreen extends Screen {
|
|||
for (m = 0; m < this.text.length; ++m) {
|
||||
string2 = this.text[m];
|
||||
if (string2 != null && m == this.currentRow && j >= 0) {
|
||||
int r = this.minecraft.font
|
||||
.width(string2.substring(0, Math.max(Math.min(j, string2.length()), 0)));
|
||||
int r = this.minecraft.font.width(string2.substring(0, Math.max(Math.min(j, string2.length()), 0)));
|
||||
s = r - this.minecraft.font.width(string2) / 2;
|
||||
if (bl2 && j < string2.length()) {
|
||||
int var31 = l - 1;
|
||||
|
@ -200,10 +195,8 @@ public class BlockSignEditScreen extends Screen {
|
|||
if (k != j) {
|
||||
t = Math.min(j, k);
|
||||
int u = Math.max(j, k);
|
||||
int v = this.minecraft.font.width(string2.substring(0, t))
|
||||
- this.minecraft.font.width(string2) / 2;
|
||||
int w = this.minecraft.font.width(string2.substring(0, u))
|
||||
- this.minecraft.font.width(string2) / 2;
|
||||
int v = this.minecraft.font.width(string2.substring(0, t)) - this.minecraft.font.width(string2) / 2;
|
||||
int w = this.minecraft.font.width(string2.substring(0, u)) - this.minecraft.font.width(string2) / 2;
|
||||
int x = Math.min(v, w);
|
||||
int y = Math.max(v, w);
|
||||
Tesselator tessellator = Tesselator.getInstance();
|
||||
|
|
|
@ -2,90 +2,67 @@ package ru.bclib.client.models;
|
|||
|
||||
import net.minecraft.client.model.geom.ModelPart;
|
||||
import net.minecraft.client.model.geom.PartPose;
|
||||
import net.minecraft.client.model.geom.builders.*;
|
||||
import net.minecraft.client.model.geom.builders.CubeDeformation;
|
||||
import net.minecraft.client.model.geom.builders.CubeListBuilder;
|
||||
import net.minecraft.client.model.geom.builders.LayerDefinition;
|
||||
import net.minecraft.client.model.geom.builders.MeshDefinition;
|
||||
import net.minecraft.client.model.geom.builders.PartDefinition;
|
||||
|
||||
public class BaseChestBlockModel {
|
||||
public final ModelPart partA;
|
||||
public final ModelPart partC;
|
||||
public final ModelPart partB;
|
||||
public final ModelPart partRightA;
|
||||
public final ModelPart partRightC;
|
||||
public final ModelPart partRightB;
|
||||
public final ModelPart partLeftA;
|
||||
public final ModelPart partLeftC;
|
||||
public final ModelPart partLeftB;
|
||||
public final ModelPart partA;
|
||||
public final ModelPart partC;
|
||||
public final ModelPart partB;
|
||||
public final ModelPart partRightA;
|
||||
public final ModelPart partRightC;
|
||||
public final ModelPart partRightB;
|
||||
public final ModelPart partLeftA;
|
||||
public final ModelPart partLeftC;
|
||||
public final ModelPart partLeftB;
|
||||
|
||||
public static LayerDefinition getTexturedModelData() {
|
||||
MeshDefinition modelData = new MeshDefinition();
|
||||
PartDefinition modelPartData = modelData.getRoot();
|
||||
CubeDeformation deformation_partC = new CubeDeformation(0.0f);
|
||||
modelPartData.addOrReplaceChild("partC", CubeListBuilder.create()
|
||||
.texOffs(0, 19)
|
||||
.addBox(1.0f, 0.0f, 1.0f, 14.0f, 9.0f, 14.0f, deformation_partC),
|
||||
PartPose.ZERO);
|
||||
public static LayerDefinition getTexturedModelData() {
|
||||
MeshDefinition modelData = new MeshDefinition();
|
||||
PartDefinition modelPartData = modelData.getRoot();
|
||||
CubeDeformation deformation_partC = new CubeDeformation(0.0f);
|
||||
modelPartData.addOrReplaceChild("partC", CubeListBuilder.create().texOffs(0, 19).addBox(1.0f, 0.0f, 1.0f, 14.0f, 9.0f, 14.0f, deformation_partC), PartPose.ZERO);
|
||||
|
||||
CubeDeformation deformation_partA = new CubeDeformation(0.0f);
|
||||
modelPartData.addOrReplaceChild("partA", CubeListBuilder.create()
|
||||
.texOffs(0, 0)
|
||||
.addBox(1.0f, 0.0f, 0.0f, 14.0f, 5.0f, 14.0f, deformation_partA),
|
||||
PartPose.offset(0.0f, 9.0f, 1.0f));
|
||||
CubeDeformation deformation_partA = new CubeDeformation(0.0f);
|
||||
modelPartData.addOrReplaceChild("partA", CubeListBuilder.create().texOffs(0, 0).addBox(1.0f, 0.0f, 0.0f, 14.0f, 5.0f, 14.0f, deformation_partA), PartPose.offset(0.0f, 9.0f, 1.0f));
|
||||
|
||||
CubeDeformation deformation_partB = new CubeDeformation(0.0f);
|
||||
modelPartData.addOrReplaceChild("partB", CubeListBuilder.create()
|
||||
.texOffs(0, 0)
|
||||
.addBox(7.0f, -1.0f, 15.0f, 2.0f, 4.0f, 1.0f, deformation_partB),
|
||||
PartPose.offset(0.0f, 8.0f, 0.0f));
|
||||
CubeDeformation deformation_partB = new CubeDeformation(0.0f);
|
||||
modelPartData.addOrReplaceChild("partB", CubeListBuilder.create().texOffs(0, 0).addBox(7.0f, -1.0f, 15.0f, 2.0f, 4.0f, 1.0f, deformation_partB), PartPose.offset(0.0f, 8.0f, 0.0f));
|
||||
|
||||
CubeDeformation deformation_partRightC = new CubeDeformation(0.0f);
|
||||
modelPartData.addOrReplaceChild("partRightC", CubeListBuilder.create()
|
||||
.texOffs(0, 19)
|
||||
.addBox(1.0f, 0.0f, 1.0f, 15.0f, 9.0f, 14.0f, deformation_partRightC),
|
||||
PartPose.ZERO);
|
||||
CubeDeformation deformation_partRightC = new CubeDeformation(0.0f);
|
||||
modelPartData.addOrReplaceChild("partRightC", CubeListBuilder.create().texOffs(0, 19).addBox(1.0f, 0.0f, 1.0f, 15.0f, 9.0f, 14.0f, deformation_partRightC), PartPose.ZERO);
|
||||
|
||||
CubeDeformation deformation_partRightA = new CubeDeformation(0.0f);
|
||||
modelPartData.addOrReplaceChild("partRightA", CubeListBuilder.create()
|
||||
.texOffs(0, 0)
|
||||
.addBox(1.0f, 0.0f, 0.0f, 15.0f, 5.0f, 14.0f, deformation_partRightA),
|
||||
PartPose.offset(0.0f, 9.0f, 1.0f));
|
||||
CubeDeformation deformation_partRightA = new CubeDeformation(0.0f);
|
||||
modelPartData.addOrReplaceChild("partRightA", CubeListBuilder.create().texOffs(0, 0).addBox(1.0f, 0.0f, 0.0f, 15.0f, 5.0f, 14.0f, deformation_partRightA), PartPose.offset(0.0f, 9.0f, 1.0f));
|
||||
|
||||
CubeDeformation deformation_partRightB = new CubeDeformation(0.0f);
|
||||
PartDefinition partRightB = modelPartData.addOrReplaceChild("partRightB", CubeListBuilder.create()
|
||||
.texOffs(0, 0)
|
||||
.addBox(15.0f, -1.0f, 15.0f, 1.0f, 4.0f, 1.0f, deformation_partRightB),
|
||||
PartPose.offset(0.0f, 8.0f, 0.0f));
|
||||
CubeDeformation deformation_partRightB = new CubeDeformation(0.0f);
|
||||
PartDefinition partRightB = modelPartData.addOrReplaceChild("partRightB", CubeListBuilder.create().texOffs(0, 0).addBox(15.0f, -1.0f, 15.0f, 1.0f, 4.0f, 1.0f, deformation_partRightB), PartPose.offset(0.0f, 8.0f, 0.0f));
|
||||
|
||||
CubeDeformation deformation_partLeftC = new CubeDeformation(0.0f);
|
||||
modelPartData.addOrReplaceChild("partLeftC", CubeListBuilder.create()
|
||||
.texOffs(0, 19)
|
||||
.addBox(0.0f, 0.0f, 1.0f, 15.0f, 9.0f, 14.0f, deformation_partLeftC),
|
||||
PartPose.ZERO);
|
||||
CubeDeformation deformation_partLeftC = new CubeDeformation(0.0f);
|
||||
modelPartData.addOrReplaceChild("partLeftC", CubeListBuilder.create().texOffs(0, 19).addBox(0.0f, 0.0f, 1.0f, 15.0f, 9.0f, 14.0f, deformation_partLeftC), PartPose.ZERO);
|
||||
|
||||
CubeDeformation deformation_partLeftA = new CubeDeformation(0.0f);
|
||||
modelPartData.addOrReplaceChild("partLeftA", CubeListBuilder.create()
|
||||
.texOffs(0, 0)
|
||||
.addBox(0.0f, 0.0f, 0.0f, 15.0f, 5.0f, 14.0f, deformation_partLeftA),
|
||||
PartPose.offset(0.0f, 9.0f, 1.0f));
|
||||
CubeDeformation deformation_partLeftA = new CubeDeformation(0.0f);
|
||||
modelPartData.addOrReplaceChild("partLeftA", CubeListBuilder.create().texOffs(0, 0).addBox(0.0f, 0.0f, 0.0f, 15.0f, 5.0f, 14.0f, deformation_partLeftA), PartPose.offset(0.0f, 9.0f, 1.0f));
|
||||
|
||||
CubeDeformation deformation_partLeftB = new CubeDeformation(0.0f);
|
||||
modelPartData.addOrReplaceChild("partLeftB", CubeListBuilder.create()
|
||||
.texOffs(0, 0)
|
||||
.addBox(0.0f, -1.0f, 15.0f, 1.0f, 4.0f, 1.0f, deformation_partLeftB),
|
||||
PartPose.offset(0.0f, 8.0f, 0.0f));
|
||||
CubeDeformation deformation_partLeftB = new CubeDeformation(0.0f);
|
||||
modelPartData.addOrReplaceChild("partLeftB", CubeListBuilder.create().texOffs(0, 0).addBox(0.0f, -1.0f, 15.0f, 1.0f, 4.0f, 1.0f, deformation_partLeftB), PartPose.offset(0.0f, 8.0f, 0.0f));
|
||||
|
||||
return LayerDefinition.create(modelData, 64, 64);
|
||||
}
|
||||
return LayerDefinition.create(modelData, 64, 64);
|
||||
}
|
||||
|
||||
public BaseChestBlockModel(ModelPart modelPart) {
|
||||
super();
|
||||
public BaseChestBlockModel(ModelPart modelPart) {
|
||||
super();
|
||||
|
||||
partC = modelPart.getChild("partC");
|
||||
partA = modelPart.getChild("partA");
|
||||
partB = modelPart.getChild("partB");
|
||||
partRightC = modelPart.getChild("partRightC");
|
||||
partRightA = modelPart.getChild("partRightA");
|
||||
partRightB = modelPart.getChild("partRightB");
|
||||
partLeftC = modelPart.getChild("partLeftC");
|
||||
partLeftA = modelPart.getChild("partLeftA");
|
||||
partLeftB = modelPart.getChild("partLeftB");
|
||||
}
|
||||
partC = modelPart.getChild("partC");
|
||||
partA = modelPart.getChild("partA");
|
||||
partB = modelPart.getChild("partB");
|
||||
partRightC = modelPart.getChild("partRightC");
|
||||
partRightA = modelPart.getChild("partRightA");
|
||||
partRightB = modelPart.getChild("partRightB");
|
||||
partLeftC = modelPart.getChild("partLeftC");
|
||||
partLeftA = modelPart.getChild("partLeftA");
|
||||
partLeftB = modelPart.getChild("partLeftB");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,20 +1,19 @@
|
|||
package ru.bclib.client.models;
|
||||
|
||||
import static net.minecraft.client.resources.model.ModelBakery.MISSING_MODEL_LOCATION;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.bclib.BCLib;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import static net.minecraft.client.resources.model.ModelBakery.MISSING_MODEL_LOCATION;
|
||||
|
||||
public interface BlockModelProvider extends ItemModelProvider {
|
||||
@Environment(EnvType.CLIENT)
|
||||
default @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
||||
|
@ -36,7 +35,8 @@ public interface BlockModelProvider extends ItemModelProvider {
|
|||
if (model != null) {
|
||||
model.name = modelId.toString();
|
||||
modelCache.put(modelId, model);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
BCLib.LOGGER.warning("Error loading model: {}", modelId);
|
||||
modelCache.put(modelId, modelCache.get(MISSING_MODEL_LOCATION));
|
||||
}
|
||||
|
|
|
@ -1,12 +1,7 @@
|
|||
package ru.bclib.client.models;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.mojang.math.Transformation;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
|
@ -22,6 +17,10 @@ import net.minecraft.world.level.block.Block;
|
|||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class ModelsHelper {
|
||||
public static BlockModel fromPattern(Optional<String> pattern) {
|
||||
|
@ -66,20 +65,20 @@ public class ModelsHelper {
|
|||
public static MultiVariant createRotatedModel(ResourceLocation resourceLocation, Direction.Axis axis) {
|
||||
BlockModelRotation rotation = BlockModelRotation.X0_Y0;
|
||||
switch (axis) {
|
||||
case X: rotation = BlockModelRotation.X90_Y90; break;
|
||||
case Z: rotation = BlockModelRotation.X90_Y0; break;
|
||||
default: break;
|
||||
case X:
|
||||
rotation = BlockModelRotation.X90_Y90;
|
||||
break;
|
||||
case Z:
|
||||
rotation = BlockModelRotation.X90_Y0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return createMultiVariant(resourceLocation, rotation.getRotation(), false);
|
||||
}
|
||||
|
||||
public static MultiVariant createRandomTopModel(ResourceLocation resourceLocation) {
|
||||
return new MultiVariant(Lists.newArrayList(
|
||||
new Variant(resourceLocation, Transformation.identity(), false, 1),
|
||||
new Variant(resourceLocation, BlockModelRotation.X0_Y90.getRotation(), false, 1),
|
||||
new Variant(resourceLocation, BlockModelRotation.X0_Y180.getRotation(), false, 1),
|
||||
new Variant(resourceLocation, BlockModelRotation.X0_Y270.getRotation(), false, 1)
|
||||
));
|
||||
return new MultiVariant(Lists.newArrayList(new Variant(resourceLocation, Transformation.identity(), false, 1), new Variant(resourceLocation, BlockModelRotation.X0_Y90.getRotation(), false, 1), new Variant(resourceLocation, BlockModelRotation.X0_Y180.getRotation(), false, 1), new Variant(resourceLocation, BlockModelRotation.X0_Y270.getRotation(), false, 1)));
|
||||
}
|
||||
|
||||
public static class MultiPartBuilder {
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
package ru.bclib.client.models;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
|
@ -8,12 +13,6 @@ import java.util.Map;
|
|||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
|
||||
public class PatternsHelper {
|
||||
public static Optional<String> createItemGenerated(ResourceLocation itemId) {
|
||||
return createJson(BasePatterns.ITEM_GENERATED, itemId);
|
||||
|
@ -53,13 +52,13 @@ public class PatternsHelper {
|
|||
public static Optional<String> createJson(ResourceLocation patternId, Map<String, String> textures) {
|
||||
ResourceManager resourceManager = Minecraft.getInstance().getResourceManager();
|
||||
try (InputStream input = resourceManager.getResource(patternId).getInputStream()) {
|
||||
String json = new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8))
|
||||
.lines().collect(Collectors.joining());
|
||||
String json = new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8)).lines().collect(Collectors.joining());
|
||||
for (Map.Entry<String, String> texture : textures.entrySet()) {
|
||||
json = json.replace(texture.getKey(), texture.getValue());
|
||||
}
|
||||
return Optional.of(json);
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
catch (Exception ex) {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package ru.bclib.client.render;
|
||||
|
||||
public enum BCLRenderLayer {
|
||||
CUTOUT,
|
||||
TRANSLUCENT;
|
||||
CUTOUT, TRANSLUCENT;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,11 @@ import net.minecraft.core.Direction;
|
|||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.*;
|
||||
import net.minecraft.world.level.block.AbstractChestBlock;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.ChestBlock;
|
||||
import net.minecraft.world.level.block.DoubleBlockCombiner;
|
||||
import net.minecraft.world.level.block.DoubleBlockCombiner.NeighborCombineResult;
|
||||
import net.minecraft.world.level.block.entity.ChestBlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
@ -38,6 +42,7 @@ public class BaseChestBlockEntityRenderer implements BlockEntityRenderer<BaseChe
|
|||
private static final int ID_RIGHT = 2;
|
||||
|
||||
private final BaseChestBlockModel chestModel;
|
||||
|
||||
public BaseChestBlockEntityRenderer(BlockEntityRendererProvider.Context ctx) {
|
||||
super();
|
||||
chestModel = new BaseChestBlockModel(BaseChestBlockModel.getTexturedModelData().bakeRoot());
|
||||
|
@ -62,25 +67,27 @@ public class BaseChestBlockEntityRenderer implements BlockEntityRenderer<BaseChe
|
|||
|
||||
if (worldExists) {
|
||||
propertySource = abstractChestBlock.combine(blockState, world, entity.getBlockPos(), true);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
propertySource = DoubleBlockCombiner.Combiner::acceptNone;
|
||||
}
|
||||
|
||||
float pitch = ((Float2FloatFunction) propertySource.apply(ChestBlock.opennessCombiner(entity))).get(tickDelta);
|
||||
pitch = 1.0F - pitch;
|
||||
pitch = 1.0F - pitch * pitch * pitch;
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
int blockLight = ((Int2IntFunction) propertySource.apply(new BrightnessCombiner())).applyAsInt(light);
|
||||
@SuppressWarnings({"unchecked", "rawtypes"}) int blockLight = ((Int2IntFunction) propertySource.apply(new BrightnessCombiner())).applyAsInt(light);
|
||||
|
||||
VertexConsumer vertexConsumer = getConsumer(vertexConsumers, block, chestType);
|
||||
|
||||
if (isDouble) {
|
||||
if (chestType == ChestType.LEFT) {
|
||||
renderParts(matrices, vertexConsumer, chestModel.partLeftA, chestModel.partLeftB, chestModel.partLeftC, pitch, blockLight, overlay);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
renderParts(matrices, vertexConsumer, chestModel.partRightA, chestModel.partRightB, chestModel.partRightC, pitch, blockLight, overlay);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
renderParts(matrices, vertexConsumer, chestModel.partA, chestModel.partB, chestModel.partC, pitch, blockLight, overlay);
|
||||
}
|
||||
|
||||
|
@ -113,18 +120,10 @@ public class BaseChestBlockEntityRenderer implements BlockEntityRenderer<BaseChe
|
|||
ResourceLocation blockId = Registry.BLOCK.getKey(block);
|
||||
String modId = blockId.getNamespace();
|
||||
String path = blockId.getPath();
|
||||
LAYERS.put(block, new RenderType[] {
|
||||
RenderType.entityCutout(new ResourceLocation(modId, "textures/entity/chest/" + path + ".png")),
|
||||
RenderType.entityCutout(new ResourceLocation(modId, "textures/entity/chest/" + path + "_left.png")),
|
||||
RenderType.entityCutout(new ResourceLocation(modId, "textures/entity/chest/" + path + "_right.png"))
|
||||
});
|
||||
LAYERS.put(block, new RenderType[] {RenderType.entityCutout(new ResourceLocation(modId, "textures/entity/chest/" + path + ".png")), RenderType.entityCutout(new ResourceLocation(modId, "textures/entity/chest/" + path + "_left.png")), RenderType.entityCutout(new ResourceLocation(modId, "textures/entity/chest/" + path + "_right.png"))});
|
||||
}
|
||||
|
||||
static {
|
||||
defaultLayer = new RenderType[] {
|
||||
RenderType.entityCutout(new ResourceLocation("textures/entity/chest/normal.png")),
|
||||
RenderType.entityCutout(new ResourceLocation("textures/entity/chest/normal_left.png")),
|
||||
RenderType.entityCutout(new ResourceLocation("textures/entity/chest/normal_right.png"))
|
||||
};
|
||||
defaultLayer = new RenderType[] {RenderType.entityCutout(new ResourceLocation("textures/entity/chest/normal.png")), RenderType.entityCutout(new ResourceLocation("textures/entity/chest/normal_left.png")), RenderType.entityCutout(new ResourceLocation("textures/entity/chest/normal_right.png"))};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,8 +51,7 @@ public class BaseSignBlockEntityRenderer implements BlockEntityRenderer<BaseSign
|
|||
model = new SignRenderer.SignModel(ctx.bakeLayer(ModelLayers.createSignModelName(WoodType.OAK)));
|
||||
}
|
||||
|
||||
public void render(BaseSignBlockEntity signBlockEntity, float tickDelta, PoseStack matrixStack,
|
||||
MultiBufferSource provider, int light, int overlay) {
|
||||
public void render(BaseSignBlockEntity signBlockEntity, float tickDelta, PoseStack matrixStack, MultiBufferSource provider, int light, int overlay) {
|
||||
BlockState state = signBlockEntity.getBlockState();
|
||||
|
||||
matrixStack.pushPose();
|
||||
|
@ -65,7 +64,8 @@ public class BaseSignBlockEntityRenderer implements BlockEntityRenderer<BaseSign
|
|||
if (blockState.getValue(BaseSignBlock.FLOOR)) {
|
||||
matrixStack.mulPose(Vector3f.YP.rotationDegrees(angle));
|
||||
model.stick.visible = true;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
matrixStack.mulPose(Vector3f.YP.rotationDegrees(angle + 180));
|
||||
matrixStack.translate(0.0D, -0.3125D, -0.4375D);
|
||||
model.stick.visible = false;
|
||||
|
@ -87,11 +87,10 @@ public class BaseSignBlockEntityRenderer implements BlockEntityRenderer<BaseSign
|
|||
int p = (int) (NativeImage.getB(m) * 0.4D);
|
||||
int q = NativeImage.combine(0, p, o, n);
|
||||
|
||||
FormattedCharSequence[] formattedCharSequences = signBlockEntity
|
||||
.getRenderMessages(Minecraft.getInstance().isTextFilteringEnabled(), (component) -> {
|
||||
List<FormattedCharSequence> list = this.font.split(component, 90);
|
||||
return list.isEmpty() ? FormattedCharSequence.EMPTY : (FormattedCharSequence) list.get(0);
|
||||
});
|
||||
FormattedCharSequence[] formattedCharSequences = signBlockEntity.getRenderMessages(Minecraft.getInstance().isTextFilteringEnabled(), (component) -> {
|
||||
List<FormattedCharSequence> list = this.font.split(component, 90);
|
||||
return list.isEmpty() ? FormattedCharSequence.EMPTY : (FormattedCharSequence) list.get(0);
|
||||
});
|
||||
int drawColor;
|
||||
boolean drawOutlined;
|
||||
int drawLight;
|
||||
|
@ -99,7 +98,8 @@ public class BaseSignBlockEntityRenderer implements BlockEntityRenderer<BaseSign
|
|||
drawColor = signBlockEntity.getColor().getTextColor();
|
||||
drawOutlined = isOutlineVisible(signBlockEntity, drawColor);
|
||||
drawLight = 15728880;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
drawColor = m;
|
||||
drawOutlined = false;
|
||||
drawLight = light;
|
||||
|
@ -109,11 +109,10 @@ public class BaseSignBlockEntityRenderer implements BlockEntityRenderer<BaseSign
|
|||
FormattedCharSequence formattedCharSequence = formattedCharSequences[s];
|
||||
float t = (float) (-this.font.width(formattedCharSequence) / 2);
|
||||
if (drawOutlined) {
|
||||
this.font.drawInBatch8xOutline(formattedCharSequence, t, (float) (s * 10 - 20), drawColor, m,
|
||||
matrixStack.last().pose(), provider, drawLight);
|
||||
} else {
|
||||
this.font.drawInBatch((FormattedCharSequence) formattedCharSequence, t, (float) (s * 10 - 20), drawColor, false,
|
||||
matrixStack.last().pose(), provider, false, 0, drawLight);
|
||||
this.font.drawInBatch8xOutline(formattedCharSequence, t, (float) (s * 10 - 20), drawColor, m, matrixStack.last().pose(), provider, drawLight);
|
||||
}
|
||||
else {
|
||||
this.font.drawInBatch((FormattedCharSequence) formattedCharSequence, t, (float) (s * 10 - 20), drawColor, false, matrixStack.last().pose(), provider, false, 0, drawLight);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -122,19 +121,19 @@ public class BaseSignBlockEntityRenderer implements BlockEntityRenderer<BaseSign
|
|||
}
|
||||
|
||||
|
||||
|
||||
private static boolean isOutlineVisible(BaseSignBlockEntity signBlockEntity, int i) {
|
||||
if (i == DyeColor.BLACK.getTextColor()) {
|
||||
return true;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
Minecraft minecraft = Minecraft.getInstance();
|
||||
LocalPlayer localPlayer = minecraft.player;
|
||||
if (localPlayer != null && minecraft.options.getCameraType().isFirstPerson() && localPlayer.isScoping()) {
|
||||
return true;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
Entity entity = minecraft.getCameraEntity();
|
||||
return entity != null && entity.distanceToSqr(
|
||||
Vec3.atCenterOf(signBlockEntity.getBlockPos())) < (double) OUTLINE_RENDER_DISTANCE;
|
||||
return entity != null && entity.distanceToSqr(Vec3.atCenterOf(signBlockEntity.getBlockPos())) < (double) OUTLINE_RENDER_DISTANCE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -143,7 +142,8 @@ public class BaseSignBlockEntityRenderer implements BlockEntityRenderer<BaseSign
|
|||
WoodType signType2;
|
||||
if (block instanceof SignBlock) {
|
||||
signType2 = ((SignBlock) block).type();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
signType2 = WoodType.OAK;
|
||||
}
|
||||
|
||||
|
@ -160,8 +160,7 @@ public class BaseSignBlockEntityRenderer implements BlockEntityRenderer<BaseSign
|
|||
|
||||
public static void registerRenderLayer(Block block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(block);
|
||||
RenderType layer = RenderType.entitySolid(new ResourceLocation(blockId.getNamespace(),
|
||||
"textures/entity/sign/" + blockId.getPath() + ".png"));
|
||||
RenderType layer = RenderType.entitySolid(new ResourceLocation(blockId.getNamespace(), "textures/entity/sign/" + blockId.getPath() + ".png"));
|
||||
LAYERS.put(block, layer);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,10 +4,5 @@ import net.minecraft.sounds.SoundEvents;
|
|||
import net.minecraft.world.level.block.SoundType;
|
||||
|
||||
public class BlockSounds {
|
||||
public static final SoundType TERRAIN_SOUND = new SoundType(1.0F, 1.0F,
|
||||
SoundEvents.STONE_BREAK,
|
||||
SoundEvents.WART_BLOCK_STEP,
|
||||
SoundEvents.STONE_PLACE,
|
||||
SoundEvents.STONE_HIT,
|
||||
SoundEvents.STONE_FALL);
|
||||
public static final SoundType TERRAIN_SOUND = new SoundType(1.0F, 1.0F, SoundEvents.STONE_BREAK, SoundEvents.WART_BLOCK_STEP, SoundEvents.STONE_PLACE, SoundEvents.STONE_HIT, SoundEvents.STONE_FALL);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package ru.bclib.config;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import ru.bclib.BCLib;
|
||||
import ru.bclib.config.ConfigKeeper.BooleanEntry;
|
||||
import ru.bclib.config.ConfigKeeper.Entry;
|
||||
|
@ -55,7 +54,8 @@ public abstract class Config {
|
|||
if (entry == null) return false;
|
||||
entry.setValue(value);
|
||||
return true;
|
||||
} catch (NullPointerException ex) {
|
||||
}
|
||||
catch (NullPointerException ex) {
|
||||
BCLib.LOGGER.catching(ex);
|
||||
}
|
||||
return false;
|
||||
|
@ -81,7 +81,8 @@ public abstract class Config {
|
|||
if (entry == null) return false;
|
||||
entry.setValue(value);
|
||||
return true;
|
||||
} catch (NullPointerException ex) {
|
||||
}
|
||||
catch (NullPointerException ex) {
|
||||
BCLib.LOGGER.catching(ex);
|
||||
}
|
||||
return false;
|
||||
|
@ -93,7 +94,8 @@ public abstract class Config {
|
|||
if (entry == null) return false;
|
||||
entry.setValue(value);
|
||||
return true;
|
||||
} catch (NullPointerException | ClassCastException ex) {
|
||||
}
|
||||
catch (NullPointerException | ClassCastException ex) {
|
||||
BCLib.LOGGER.catching(ex);
|
||||
}
|
||||
return false;
|
||||
|
@ -119,7 +121,8 @@ public abstract class Config {
|
|||
if (entry == null) return false;
|
||||
entry.setValue(value);
|
||||
return true;
|
||||
} catch (NullPointerException ex) {
|
||||
}
|
||||
catch (NullPointerException ex) {
|
||||
BCLib.LOGGER.catching(ex);
|
||||
}
|
||||
return false;
|
||||
|
@ -145,7 +148,8 @@ public abstract class Config {
|
|||
if (entry == null) return false;
|
||||
entry.setValue(value);
|
||||
return true;
|
||||
} catch (NullPointerException ex) {
|
||||
}
|
||||
catch (NullPointerException ex) {
|
||||
BCLib.LOGGER.catching(ex);
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -1,20 +1,18 @@
|
|||
package ru.bclib.config;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import net.minecraft.util.GsonHelper;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.bclib.util.JsonFactory;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public final class ConfigKeeper {
|
||||
private final Map<ConfigKey, Entry<?>> configEntries = Maps.newHashMap();
|
||||
private final JsonObject configObject;
|
||||
|
@ -297,8 +295,7 @@ public final class ConfigKeeper {
|
|||
}
|
||||
|
||||
protected boolean hasLocation() {
|
||||
return this.location != null &&
|
||||
this.key != null;
|
||||
return this.location != null && this.key != null;
|
||||
}
|
||||
|
||||
public T getValue() {
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
package ru.bclib.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import ru.bclib.util.JsonFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class ConfigWriter {
|
||||
private final static Path GAME_CONFIG_DIR = FabricLoader.getInstance().getConfigDir();
|
||||
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
package ru.bclib.config;
|
||||
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.bclib.config.ConfigKeeper.Entry;
|
||||
import ru.bclib.config.ConfigKeeper.FloatRange;
|
||||
import ru.bclib.config.ConfigKeeper.IntegerRange;
|
||||
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
public class IdConfig extends Config {
|
||||
protected final BiFunction<ResourceLocation, String, ConfigKey> keyFactory;
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package ru.bclib.config;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import ru.bclib.config.ConfigKeeper.Entry;
|
||||
import ru.bclib.config.ConfigKeeper.FloatRange;
|
||||
import ru.bclib.config.ConfigKeeper.IntegerRange;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
package ru.bclib.integration;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import net.fabricmc.fabric.api.tag.TagRegistry;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.core.Registry;
|
||||
|
@ -25,6 +20,11 @@ import net.minecraft.world.level.levelgen.feature.Feature;
|
|||
import ru.bclib.BCLib;
|
||||
import ru.bclib.world.features.BCLFeature;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public abstract class ModIntegration {
|
||||
private final String modID;
|
||||
|
||||
|
@ -178,7 +178,7 @@ public abstract class ModIntegration {
|
|||
|
||||
public Object newInstance(Class<?> cl, Object... args) {
|
||||
if (cl != null) {
|
||||
for (Constructor<?> constructor: cl.getConstructors()) {
|
||||
for (Constructor<?> constructor : cl.getConstructors()) {
|
||||
if (constructor.getParameterCount() == args.length) {
|
||||
try {
|
||||
return constructor.newInstance(args);
|
||||
|
|
|
@ -2,5 +2,6 @@ package ru.bclib.interfaces;
|
|||
|
||||
public interface ISpetialItem {
|
||||
boolean canPlaceOnWater();
|
||||
|
||||
int getStackSize();
|
||||
}
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
package ru.bclib.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
|
@ -18,9 +14,12 @@ import net.minecraft.world.item.context.BlockPlaceContext;
|
|||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.bclib.blocks.BaseAnvilBlock;
|
||||
import ru.bclib.client.models.ItemModelProvider;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BaseAnvilItem extends BlockItem implements ItemModelProvider {
|
||||
|
||||
public final static String DESTRUCTION = "destruction";
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
package ru.bclib.items;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.entity.ai.attributes.Attribute;
|
||||
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
|
||||
|
@ -13,14 +10,11 @@ import net.minecraft.world.item.ArmorItem;
|
|||
import net.minecraft.world.item.ArmorMaterial;
|
||||
import ru.bclib.client.models.ItemModelProvider;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class BaseArmorItem extends ArmorItem implements ItemModelProvider {
|
||||
|
||||
protected static final UUID[] ARMOR_MODIFIER_UUID_PER_SLOT = new UUID[] {
|
||||
UUID.fromString("845DB27C-C624-495F-8C9F-6020A9A58B6B"),
|
||||
UUID.fromString("D8499B04-0E66-4726-AB29-64469D734E0D"),
|
||||
UUID.fromString("9F3D476D-C118-4544-8365-64846904B48E"),
|
||||
UUID.fromString("2AD3F246-FEE1-4E67-B886-69FD380BB150")
|
||||
};
|
||||
protected static final UUID[] ARMOR_MODIFIER_UUID_PER_SLOT = new UUID[] {UUID.fromString("845DB27C-C624-495F-8C9F-6020A9A58B6B"), UUID.fromString("D8499B04-0E66-4726-AB29-64469D734E0D"), UUID.fromString("9F3D476D-C118-4544-8365-64846904B48E"), UUID.fromString("2AD3F246-FEE1-4E67-B886-69FD380BB150")};
|
||||
|
||||
protected final Multimap<Attribute, AttributeModifier> defaultModifiers;
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package ru.bclib.items;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
|
@ -14,6 +12,8 @@ import ru.bclib.client.models.ItemModelProvider;
|
|||
import ru.bclib.client.models.ModelsHelper;
|
||||
import ru.bclib.client.models.PatternsHelper;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class BaseSpawnEggItem extends SpawnEggItem implements ItemModelProvider {
|
||||
public BaseSpawnEggItem(EntityType<? extends Mob> type, int primaryColor, int secondaryColor, Properties settings) {
|
||||
super(type, primaryColor, secondaryColor, settings);
|
||||
|
|
|
@ -1,15 +1,6 @@
|
|||
package ru.bclib.mixin.client;
|
||||
|
||||
import net.minecraft.world.level.material.FogType;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.client.renderer.FogRenderer;
|
||||
|
@ -21,7 +12,12 @@ import net.minecraft.world.entity.Entity;
|
|||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.level.material.FogType;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import ru.bclib.api.BiomeAPI;
|
||||
import ru.bclib.util.BackgroundInfo;
|
||||
import ru.bclib.util.MHelper;
|
||||
|
|
|
@ -1,20 +1,19 @@
|
|||
package ru.bclib.mixin.client;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.EnchantmentTableBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import ru.bclib.api.TagAPI;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@Mixin(EnchantmentTableBlock.class)
|
||||
public abstract class EnchantingTableBlockMixin extends Block {
|
||||
public EnchantingTableBlockMixin(Properties settings) {
|
||||
|
|
|
@ -1,16 +1,5 @@
|
|||
package ru.bclib.mixin.client;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import net.minecraft.client.renderer.block.BlockModelShaper;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.renderer.block.model.multipart.MultiPart;
|
||||
|
@ -24,10 +13,20 @@ import net.minecraft.world.item.BlockItem;
|
|||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import ru.bclib.BCLib;
|
||||
import ru.bclib.client.models.BlockModelProvider;
|
||||
import ru.bclib.client.models.ItemModelProvider;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
@Mixin(ModelBakery.class)
|
||||
public abstract class ModelBakeryMixin {
|
||||
@Final
|
||||
|
@ -55,7 +54,8 @@ public abstract class ModelBakeryMixin {
|
|||
ItemModelProvider modelProvider = null;
|
||||
if (item instanceof ItemModelProvider) {
|
||||
modelProvider = (ItemModelProvider) item;
|
||||
} else if (item instanceof BlockItem) {
|
||||
}
|
||||
else if (item instanceof BlockItem) {
|
||||
Block block = Registry.BLOCK.get(clearLoc);
|
||||
if (block instanceof ItemModelProvider) {
|
||||
modelProvider = (ItemModelProvider) block;
|
||||
|
@ -67,21 +67,21 @@ public abstract class ModelBakeryMixin {
|
|||
model.name = itemLoc.toString();
|
||||
cacheAndQueueDependencies(modelId, model);
|
||||
unbakedCache.put(itemLoc, model);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
BCLib.LOGGER.warning("Error loading model: {}", itemLoc);
|
||||
}
|
||||
info.cancel();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
ResourceLocation stateLoc = new ResourceLocation(modId, "blockstates/" + path + ".json");
|
||||
if (!resourceManager.hasResource(stateLoc)) {
|
||||
Block block = Registry.BLOCK.get(clearLoc);
|
||||
if (block instanceof BlockModelProvider) {
|
||||
List<BlockState> possibleStates = block.getStateDefinition().getPossibleStates();
|
||||
Optional<BlockState> possibleState = possibleStates.stream()
|
||||
.filter(state -> modelId.equals(BlockModelShaper.stateToModelLocation(clearLoc, state)))
|
||||
.findFirst();
|
||||
Optional<BlockState> possibleState = possibleStates.stream().filter(state -> modelId.equals(BlockModelShaper.stateToModelLocation(clearLoc, state))).findFirst();
|
||||
if (possibleState.isPresent()) {
|
||||
UnbakedModel modelVariant = ((BlockModelProvider) block).getModelVariant(modelId, possibleState.get(), unbakedCache);
|
||||
if (modelVariant != null) {
|
||||
|
@ -90,10 +90,12 @@ public abstract class ModelBakeryMixin {
|
|||
ResourceLocation stateId = BlockModelShaper.stateToModelLocation(clearLoc, state);
|
||||
cacheAndQueueDependencies(stateId, modelVariant);
|
||||
});
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
cacheAndQueueDependencies(modelId, modelVariant);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
BCLib.LOGGER.warning("Error loading variant: {}", modelId);
|
||||
}
|
||||
info.cancel();
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
package ru.bclib.mixin.common;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.core.Vec3i;
|
||||
|
@ -16,6 +11,10 @@ import net.minecraft.world.level.biome.Biome.BiomeCategory;
|
|||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import ru.bclib.api.BiomeAPI;
|
||||
import ru.bclib.api.BonemealAPI;
|
||||
import ru.bclib.api.TagAPI;
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
package ru.bclib.mixin.common;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
import net.minecraft.world.level.ItemLike;
|
||||
import net.minecraft.world.level.block.ComposterBlock;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
@Mixin(ComposterBlock.class)
|
||||
public interface ComposterBlockAccessor {
|
||||
|
|
|
@ -1,15 +1,5 @@
|
|||
package ru.bclib.mixin.common;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.world.Container;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
|
@ -20,8 +10,17 @@ import net.minecraft.world.inventory.MenuType;
|
|||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentInstance;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import ru.bclib.api.TagAPI;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
@Mixin(EnchantmentMenu.class)
|
||||
public abstract class EnchantmentMenuMixin extends AbstractContainerMenu {
|
||||
@Final
|
||||
|
|
|
@ -1,16 +1,9 @@
|
|||
package ru.bclib.mixin.common;
|
||||
|
||||
import net.minecraft.data.worldgen.Features;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.crafting.Recipe;
|
||||
import net.minecraft.world.item.crafting.RecipeType;
|
||||
import net.minecraft.world.level.block.ComposterBlock;
|
||||
import net.minecraft.world.level.levelgen.placement.ConfiguredDecorator;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Mixin(targets = "net.minecraft.data.worldgen.Features$Decorators")
|
||||
public interface FeatureDecoratorsAccessor {
|
||||
@Accessor("HEIGHTMAP_SQUARE")
|
||||
|
|
|
@ -1,17 +1,5 @@
|
|||
package ru.bclib.mixin.common;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
@ -19,9 +7,20 @@ import net.minecraft.server.ServerResources;
|
|||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.storage.WorldData;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import ru.bclib.api.BiomeAPI;
|
||||
import ru.bclib.recipes.BCLRecipeManager;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Mixin(MinecraftServer.class)
|
||||
public class MinecraftServerMixin {
|
||||
@Shadow
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
package ru.bclib.mixin.common;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.alchemy.Potion;
|
||||
import net.minecraft.world.item.alchemy.PotionBrewing;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
@Mixin(PotionBrewing.class)
|
||||
public interface PotionBrewingAccessor {
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
package ru.bclib.mixin.common;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.crafting.Recipe;
|
||||
import net.minecraft.world.item.crafting.RecipeManager;
|
||||
import net.minecraft.world.item.crafting.RecipeType;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Mixin(RecipeManager.class)
|
||||
public interface RecipeManagerAccessor {
|
||||
|
|
|
@ -1,20 +1,6 @@
|
|||
package ru.bclib.mixin.common;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
|
@ -24,8 +10,20 @@ import net.minecraft.world.item.crafting.Recipe;
|
|||
import net.minecraft.world.item.crafting.RecipeManager;
|
||||
import net.minecraft.world.item.crafting.RecipeType;
|
||||
import net.minecraft.world.level.Level;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import ru.bclib.recipes.BCLRecipeManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
@Mixin(RecipeManager.class)
|
||||
public abstract class RecipeManagerMixin {
|
||||
@Shadow
|
||||
|
|
|
@ -1,15 +1,5 @@
|
|||
package ru.bclib.mixin.common;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
|
@ -22,10 +12,19 @@ import net.minecraft.world.level.dimension.DimensionType;
|
|||
import net.minecraft.world.level.storage.LevelStorageSource;
|
||||
import net.minecraft.world.level.storage.ServerLevelData;
|
||||
import net.minecraft.world.level.storage.WritableLevelData;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import ru.bclib.api.BiomeAPI;
|
||||
import ru.bclib.api.DataFixerAPI;
|
||||
import ru.bclib.api.WorldDataAPI;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@Mixin(ServerLevel.class)
|
||||
public abstract class ServerLevelMixin extends Level {
|
||||
private static String bcl_lastWorld = null;
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package ru.bclib.mixin.common;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.Tag;
|
||||
import net.minecraft.tags.TagLoader;
|
||||
|
@ -11,6 +9,8 @@ import org.spongepowered.asm.mixin.injection.At;
|
|||
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||
import ru.bclib.util.TagHelper;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Mixin(TagLoader.class)
|
||||
public class TagLoaderMixin {
|
||||
@Shadow
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,10 +1,10 @@
|
|||
package ru.bclib.noise;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import ru.bclib.util.MHelper;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class VoronoiNoise {
|
||||
private static final Random RANDOM = new Random();
|
||||
final int seed;
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
package ru.bclib.recipes;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.crafting.Recipe;
|
||||
|
@ -13,6 +9,9 @@ import net.minecraft.world.item.crafting.RecipeType;
|
|||
import net.minecraft.world.level.ItemLike;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class BCLRecipeManager {
|
||||
private static final Map<RecipeType<?>, Map<ResourceLocation, Recipe<?>>> RECIPES = Maps.newHashMap();
|
||||
|
||||
|
@ -52,8 +51,7 @@ public class BCLRecipeManager {
|
|||
}
|
||||
for (Entry<ResourceLocation, Recipe<?>> entry : list.entrySet()) {
|
||||
ResourceLocation id = entry.getKey();
|
||||
if (!typeList.containsKey(id))
|
||||
typeList.put(id, entry.getValue());
|
||||
if (!typeList.containsKey(id)) typeList.put(id, entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -71,13 +69,14 @@ public class BCLRecipeManager {
|
|||
public String toString() {
|
||||
return type;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public static boolean exists(ItemLike item) {
|
||||
if (item instanceof Block) {
|
||||
return Registry.BLOCK.getKey((Block) item) != Registry.BLOCK.getDefaultKey();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return Registry.ITEM.getKey(item.asItem()) != Registry.ITEM.getDefaultKey();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,18 +20,8 @@ public class CraftingRecipes {
|
|||
GridRecipe.make(BCLib.MOD_ID, "tag_minecart", Items.MINECART).setShape("I I", "III").addMaterial('I', TagAPI.IRON_INGOTS).checkConfig(Configs.RECIPE_CONFIG).build();
|
||||
GridRecipe.make(BCLib.MOD_ID, "tag_shield", Items.SHIELD).setShape("WIW", "WWW", " W ").addMaterial('I', TagAPI.IRON_INGOTS).addMaterial('W', ItemTags.PLANKS).checkConfig(Configs.RECIPE_CONFIG).build();
|
||||
|
||||
GridRecipe.make(BCLib.MOD_ID, "tag_hopper", Blocks.HOPPER)
|
||||
.setShape("I I", "ICI", " I ")
|
||||
.addMaterial('I', TagAPI.IRON_INGOTS)
|
||||
.addMaterial('C', TagAPI.ITEM_CHEST)
|
||||
.checkConfig(Configs.RECIPE_CONFIG)
|
||||
.build();
|
||||
GridRecipe.make(BCLib.MOD_ID, "tag_hopper", Blocks.HOPPER).setShape("I I", "ICI", " I ").addMaterial('I', TagAPI.IRON_INGOTS).addMaterial('C', TagAPI.ITEM_CHEST).checkConfig(Configs.RECIPE_CONFIG).build();
|
||||
|
||||
GridRecipe.make(BCLib.MOD_ID, "tag_shulker_box", Blocks.SHULKER_BOX)
|
||||
.setShape("S", "C", "S")
|
||||
.addMaterial('S', Items.SHULKER_SHELL)
|
||||
.addMaterial('C', TagAPI.ITEM_CHEST)
|
||||
.checkConfig(Configs.RECIPE_CONFIG)
|
||||
.build();
|
||||
GridRecipe.make(BCLib.MOD_ID, "tag_shulker_box", Blocks.SHULKER_BOX).setShape("S", "C", "S").addMaterial('S', Items.SHULKER_SHELL).addMaterial('C', TagAPI.ITEM_CHEST).checkConfig(Configs.RECIPE_CONFIG).build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
package ru.bclib.recipes;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.Tag;
|
||||
|
@ -19,6 +15,9 @@ import net.minecraft.world.level.ItemLike;
|
|||
import ru.bclib.BCLib;
|
||||
import ru.bclib.config.PathConfig;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
public class GridRecipe {
|
||||
private static final GridRecipe INSTANCE = new GridRecipe();
|
||||
|
||||
|
@ -67,7 +66,7 @@ public class GridRecipe {
|
|||
}
|
||||
|
||||
public GridRecipe setList(String shape) {
|
||||
this.shape = new String[] { shape };
|
||||
this.shape = new String[] {shape};
|
||||
this.shaped = false;
|
||||
return this;
|
||||
}
|
||||
|
@ -81,7 +80,7 @@ public class GridRecipe {
|
|||
}
|
||||
|
||||
public GridRecipe addMaterial(char key, ItemLike... values) {
|
||||
for (ItemLike item: values) {
|
||||
for (ItemLike item : values) {
|
||||
exist &= BCLRecipeManager.exists(item);
|
||||
}
|
||||
return addMaterial(key, Ingredient.of(values));
|
||||
|
@ -100,11 +99,11 @@ public class GridRecipe {
|
|||
private NonNullList<Ingredient> getMaterials(int width, int height) {
|
||||
NonNullList<Ingredient> materials = NonNullList.withSize(width * height, Ingredient.EMPTY);
|
||||
int pos = 0;
|
||||
for (String line: shape) {
|
||||
for (String line : shape) {
|
||||
for (int i = 0; i < width; i++) {
|
||||
char c = line.charAt(i);
|
||||
Ingredient material = materialKeys.get(c);
|
||||
materials.set(pos ++, material == null ? Ingredient.EMPTY : material);
|
||||
materials.set(pos++, material == null ? Ingredient.EMPTY : material);
|
||||
}
|
||||
}
|
||||
return materials;
|
||||
|
@ -119,7 +118,8 @@ public class GridRecipe {
|
|||
|
||||
CraftingRecipe recipe = shaped ? new ShapedRecipe(id, group, width, height, materials, result) : new ShapelessRecipe(id, group, result, materials);
|
||||
BCLRecipeManager.addRecipe(type, recipe);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
BCLib.LOGGER.debug("Recipe {} couldn't be added", id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ public class SmithingTableRecipe {
|
|||
BCLib.LOGGER.warning("Addition input for Smithing recipe can't be 'null', recipe {} will be ignored!", id);
|
||||
return;
|
||||
}
|
||||
if(result == null) {
|
||||
if (result == null) {
|
||||
BCLib.LOGGER.warning("Result for Smithing recipe can't be 'null', recipe {} will be ignored!", id);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package ru.bclib.registry;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
|
@ -32,26 +30,18 @@ public class BaseBlockEntities {
|
|||
public static void register() {}
|
||||
|
||||
public static Block[] getChests() {
|
||||
return BaseRegistry.getRegisteredBlocks().values().stream()
|
||||
.filter(item -> item instanceof BlockItem && ((BlockItem) item).getBlock() instanceof BaseChestBlock)
|
||||
.map(item -> ((BlockItem) item).getBlock()).toArray(Block[]::new);
|
||||
return BaseRegistry.getRegisteredBlocks().values().stream().filter(item -> item instanceof BlockItem && ((BlockItem) item).getBlock() instanceof BaseChestBlock).map(item -> ((BlockItem) item).getBlock()).toArray(Block[]::new);
|
||||
}
|
||||
|
||||
public static Block[] getBarrels() {
|
||||
return BaseRegistry.getRegisteredBlocks().values().stream()
|
||||
.filter(item -> item instanceof BlockItem && ((BlockItem) item).getBlock() instanceof BaseBarrelBlock)
|
||||
.map(item -> ((BlockItem) item).getBlock()).toArray(Block[]::new);
|
||||
return BaseRegistry.getRegisteredBlocks().values().stream().filter(item -> item instanceof BlockItem && ((BlockItem) item).getBlock() instanceof BaseBarrelBlock).map(item -> ((BlockItem) item).getBlock()).toArray(Block[]::new);
|
||||
}
|
||||
|
||||
public static Block[] getSigns() {
|
||||
return BaseRegistry.getRegisteredBlocks().values().stream()
|
||||
.filter(item -> item instanceof BlockItem && ((BlockItem) item).getBlock() instanceof BaseSignBlock)
|
||||
.map(item -> ((BlockItem) item).getBlock()).toArray(Block[]::new);
|
||||
return BaseRegistry.getRegisteredBlocks().values().stream().filter(item -> item instanceof BlockItem && ((BlockItem) item).getBlock() instanceof BaseSignBlock).map(item -> ((BlockItem) item).getBlock()).toArray(Block[]::new);
|
||||
}
|
||||
|
||||
public static Block[] getFurnaces() {
|
||||
return BaseRegistry.getRegisteredBlocks().values().stream()
|
||||
.filter(item -> item instanceof BlockItem && ((BlockItem) item).getBlock() instanceof BaseFurnaceBlock)
|
||||
.map(item -> ((BlockItem) item).getBlock()).toArray(Block[]::new);
|
||||
return BaseRegistry.getRegisteredBlocks().values().stream().filter(item -> item instanceof BlockItem && ((BlockItem) item).getBlock() instanceof BaseFurnaceBlock).map(item -> ((BlockItem) item).getBlock()).toArray(Block[]::new);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
package ru.bclib.registry;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -14,6 +10,9 @@ import net.minecraft.world.item.Item;
|
|||
import net.minecraft.world.item.Items;
|
||||
import ru.bclib.BCLib;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class BaseRegistry<T> {
|
||||
|
||||
private static final List<BaseRegistry<?>> REGISTRIES = Lists.newArrayList();
|
||||
|
|
|
@ -29,7 +29,8 @@ public abstract class BlocksRegistry extends BaseRegistry<Block> {
|
|||
Properties item = makeItemSettings().stacksTo(maxCount);
|
||||
if (placeOnWater) {
|
||||
registerBlockItem(id, new WaterLilyBlockItem(block, item));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
registerBlockItem(id, new BlockItem(block, item));
|
||||
}
|
||||
if (block.defaultBlockState().getMaterial().isFlammable() && FlammableBlockRegistry.getDefaultInstance().get(block).getBurnChance() == 0) {
|
||||
|
|
|
@ -55,13 +55,17 @@ public abstract class ItemsRegistry extends BaseRegistry<Item> {
|
|||
|
||||
if (item instanceof ShovelItem) {
|
||||
TagHelper.addTag((Tag.Named<Item>) FabricToolTags.SHOVELS, item);
|
||||
} else if (item instanceof SwordItem) {
|
||||
}
|
||||
else if (item instanceof SwordItem) {
|
||||
TagHelper.addTag((Tag.Named<Item>) FabricToolTags.SWORDS, item);
|
||||
} else if (item instanceof BasePickaxeItem) {
|
||||
}
|
||||
else if (item instanceof BasePickaxeItem) {
|
||||
TagHelper.addTag((Tag.Named<Item>) FabricToolTags.PICKAXES, item);
|
||||
} else if (item instanceof BaseAxeItem) {
|
||||
}
|
||||
else if (item instanceof BaseAxeItem) {
|
||||
TagHelper.addTag((Tag.Named<Item>) FabricToolTags.AXES, item);
|
||||
} else if (item instanceof BaseHoeItem) {
|
||||
}
|
||||
else if (item instanceof BaseHoeItem) {
|
||||
TagHelper.addTag((Tag.Named<Item>) FabricToolTags.HOES, item);
|
||||
}
|
||||
|
||||
|
@ -85,7 +89,7 @@ public abstract class ItemsRegistry extends BaseRegistry<Item> {
|
|||
|
||||
public Item registerFood(String name, int hunger, float saturation, MobEffectInstance... effects) {
|
||||
FoodProperties.Builder builder = new FoodProperties.Builder().nutrition(hunger).saturationMod(saturation);
|
||||
for (MobEffectInstance effect: effects) {
|
||||
for (MobEffectInstance effect : effects) {
|
||||
builder.effect(effect, 1F);
|
||||
}
|
||||
return registerFood(name, builder.build());
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package ru.bclib.sdf;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class PosInfo implements Comparable<PosInfo> {
|
||||
private static final BlockState AIR = Blocks.AIR.defaultBlockState();
|
||||
private final Map<BlockPos, PosInfo> blocks;
|
||||
|
|
|
@ -1,16 +1,8 @@
|
|||
package ru.bclib.sdf;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
|
@ -20,6 +12,13 @@ import net.minecraft.world.phys.AABB;
|
|||
import ru.bclib.util.BlocksHelper;
|
||||
import ru.bclib.world.structures.StructureWorld;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
|
||||
public abstract class SDF {
|
||||
private List<Function<PosInfo, BlockState>> postProcesses = Lists.newArrayList();
|
||||
private Function<BlockState, Boolean> canReplace = (state) -> {
|
||||
|
@ -52,8 +51,8 @@ public abstract class SDF {
|
|||
MutableBlockPos bPos = new MutableBlockPos();
|
||||
|
||||
while (run) {
|
||||
for (BlockPos center: ends) {
|
||||
for (Direction dir: Direction.values()) {
|
||||
for (BlockPos center : ends) {
|
||||
for (Direction dir : Direction.values()) {
|
||||
bPos.set(center).move(dir);
|
||||
BlockPos wpos = bPos.offset(start);
|
||||
|
||||
|
@ -164,8 +163,8 @@ public abstract class SDF {
|
|||
MutableBlockPos bPos = new MutableBlockPos();
|
||||
|
||||
while (run) {
|
||||
for (BlockPos center: ends) {
|
||||
for (Direction dir: Direction.values()) {
|
||||
for (BlockPos center : ends) {
|
||||
for (Direction dir : Direction.values()) {
|
||||
bPos.set(center).move(dir);
|
||||
BlockPos wpos = bPos.offset(start);
|
||||
BlockState state = world.getBlockState(wpos);
|
||||
|
@ -227,8 +226,8 @@ public abstract class SDF {
|
|||
MutableBlockPos bPos = new MutableBlockPos();
|
||||
|
||||
while (run) {
|
||||
for (BlockPos center: ends) {
|
||||
for (Direction dir: Direction.values()) {
|
||||
for (BlockPos center : ends) {
|
||||
for (Direction dir : Direction.values()) {
|
||||
bPos.set(center).move(dir);
|
||||
BlockPos wpos = bPos.offset(start);
|
||||
|
||||
|
@ -284,8 +283,8 @@ public abstract class SDF {
|
|||
MutableBlockPos bPos = new MutableBlockPos();
|
||||
|
||||
while (run) {
|
||||
for (BlockPos center: ends) {
|
||||
for (Direction dir: Direction.values()) {
|
||||
for (BlockPos center : ends) {
|
||||
for (Direction dir : Direction.values()) {
|
||||
bPos.set(center).move(dir);
|
||||
BlockPos wpos = bPos.offset(start);
|
||||
BlockState state = world.getBlockState(wpos);
|
||||
|
|
|
@ -27,7 +27,8 @@ public abstract class SDFBinary extends SDF {
|
|||
public BlockState getBlockState(BlockPos pos) {
|
||||
if (firstValue) {
|
||||
return sourceA.getBlockState(pos);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return sourceB.getBlockState(pos);
|
||||
}
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue