Reorganized Imports/Packages
This commit is contained in:
parent
cb9459f176
commit
3ee10482ab
721 changed files with 34873 additions and 33558 deletions
|
@ -0,0 +1,36 @@
|
|||
package org.betterx.bclib.interfaces;
|
||||
|
||||
|
||||
import org.betterx.bclib.recipes.AnvilRecipe;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface AnvilScreenHandlerExtended {
|
||||
void be_updateCurrentRecipe(AnvilRecipe recipe);
|
||||
|
||||
AnvilRecipe be_getCurrentRecipe();
|
||||
|
||||
List<AnvilRecipe> be_getRecipes();
|
||||
|
||||
default void be_nextRecipe() {
|
||||
List<AnvilRecipe> recipes = be_getRecipes();
|
||||
if (recipes.size() < 2) return;
|
||||
AnvilRecipe current = be_getCurrentRecipe();
|
||||
int i = recipes.indexOf(current) + 1;
|
||||
if (i >= recipes.size()) {
|
||||
i = 0;
|
||||
}
|
||||
be_updateCurrentRecipe(recipes.get(i));
|
||||
}
|
||||
|
||||
default void be_previousRecipe() {
|
||||
List<AnvilRecipe> recipes = be_getRecipes();
|
||||
if (recipes.size() < 2) return;
|
||||
AnvilRecipe current = be_getCurrentRecipe();
|
||||
int i = recipes.indexOf(current) - 1;
|
||||
if (i <= 0) {
|
||||
i = recipes.size() - 1;
|
||||
}
|
||||
be_updateCurrentRecipe(recipes.get(i));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package org.betterx.bclib.interfaces;
|
||||
|
||||
import org.betterx.bclib.world.generator.BiomePicker;
|
||||
|
||||
public interface BiomeChunk {
|
||||
void setBiome(int x, int z, BiomePicker.ActualBiome biome);
|
||||
BiomePicker.ActualBiome getBiome(int x, int z);
|
||||
int getSide();
|
||||
}
|
10
src/main/java/org/betterx/bclib/interfaces/BiomeMap.java
Normal file
10
src/main/java/org/betterx/bclib/interfaces/BiomeMap.java
Normal file
|
@ -0,0 +1,10 @@
|
|||
package org.betterx.bclib.interfaces;
|
||||
|
||||
import org.betterx.bclib.world.generator.BiomePicker;
|
||||
|
||||
public interface BiomeMap {
|
||||
void setChunkProcessor(TriConsumer<Integer, Integer, Integer> processor);
|
||||
BiomeChunk getChunk(int cx, int cz, boolean update);
|
||||
BiomePicker.ActualBiome getBiome(double x, double y, double z);
|
||||
void clearCache();
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package org.betterx.bclib.interfaces;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
|
||||
public interface BiomeSetter {
|
||||
void bclib_setBiome(Biome biome, BlockPos pos);
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package org.betterx.bclib.interfaces;
|
||||
|
||||
public interface BiomeSourceAccessor {
|
||||
void bclRebuildFeatures();
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package org.betterx.bclib.interfaces;
|
||||
|
||||
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 net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
||||
import org.betterx.bclib.BCLib;
|
||||
import org.betterx.bclib.client.models.ModelsHelper;
|
||||
import org.betterx.bclib.client.models.PatternsHelper;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface BlockModelProvider extends ItemModelProvider {
|
||||
@Environment(EnvType.CLIENT)
|
||||
default @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
||||
Optional<String> pattern = PatternsHelper.createBlockSimple(resourceLocation);
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
default UnbakedModel getModelVariant(ResourceLocation stateId,
|
||||
BlockState blockState,
|
||||
Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath());
|
||||
registerBlockModel(stateId, modelId, blockState, modelCache);
|
||||
return ModelsHelper.createBlockSimple(modelId);
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
default void registerBlockModel(ResourceLocation stateId,
|
||||
ResourceLocation modelId,
|
||||
BlockState blockState,
|
||||
Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
if (!modelCache.containsKey(modelId)) {
|
||||
BlockModel model = getBlockModel(stateId, blockState);
|
||||
if (model != null) {
|
||||
model.name = modelId.toString();
|
||||
modelCache.put(modelId, model);
|
||||
} else {
|
||||
BCLib.LOGGER.warning("Error loading model: {}", modelId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package org.betterx.bclib.interfaces;
|
||||
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureSet;
|
||||
|
||||
public interface ChunkGeneratorAccessor {
|
||||
Registry<StructureSet> bclib_getStructureSetsRegistry();
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package org.betterx.bclib.interfaces;
|
||||
|
||||
import net.minecraft.client.color.block.BlockColor;
|
||||
import net.minecraft.client.color.item.ItemColor;
|
||||
|
||||
public interface CustomColorProvider {
|
||||
BlockColor getProvider();
|
||||
|
||||
ItemColor getItemProvider();
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package org.betterx.bclib.interfaces;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
|
||||
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
|
||||
|
||||
public interface CustomItemProvider {
|
||||
/**
|
||||
* Used to replace default Block Item when block is registered.
|
||||
*
|
||||
* @return {@link BlockItem}
|
||||
*/
|
||||
BlockItem getCustomItem(ResourceLocation blockID, FabricItemSettings settings);
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package org.betterx.bclib.interfaces;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
||||
import org.betterx.bclib.client.models.ModelsHelper;
|
||||
|
||||
public interface ItemModelProvider {
|
||||
@Environment(EnvType.CLIENT)
|
||||
default BlockModel getItemModel(ResourceLocation resourceLocation) {
|
||||
return ModelsHelper.createItemModel(resourceLocation);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package org.betterx.bclib.interfaces;
|
||||
|
||||
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
|
||||
|
||||
public interface NoiseGeneratorSettingsProvider {
|
||||
NoiseGeneratorSettings bclib_getNoiseGeneratorSettings();
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package org.betterx.bclib.interfaces;
|
||||
|
||||
import net.minecraft.core.MappedRegistry;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.Lifecycle;
|
||||
import org.betterx.bclib.BCLib;
|
||||
import org.betterx.bclib.mixin.common.SurfaceRulesContextAccessor;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
public interface NumericProvider {
|
||||
ResourceKey<Registry<Codec<? extends NumericProvider>>> NUMERIC_PROVIDER_REGISTRY = ResourceKey.createRegistryKey(
|
||||
BCLib.makeID("worldgen/numeric_provider"));
|
||||
Registry<Codec<? extends NumericProvider>> NUMERIC_PROVIDER = new MappedRegistry<>(NUMERIC_PROVIDER_REGISTRY,
|
||||
Lifecycle.experimental(),
|
||||
null);
|
||||
Codec<NumericProvider> CODEC = NUMERIC_PROVIDER.byNameCodec()
|
||||
.dispatch(NumericProvider::pcodec, Function.identity());
|
||||
int getNumber(SurfaceRulesContextAccessor context);
|
||||
|
||||
Codec<? extends NumericProvider> pcodec();
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package org.betterx.bclib.interfaces;
|
||||
|
||||
import org.betterx.bclib.api.datafixer.MigrationProfile;
|
||||
import org.betterx.bclib.api.datafixer.PatchDidiFailException;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface PatchBiFunction<U, V, R> {
|
||||
R apply(U t, V v, MigrationProfile profile) throws PatchDidiFailException;
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package org.betterx.bclib.interfaces;
|
||||
|
||||
import org.betterx.bclib.api.datafixer.MigrationProfile;
|
||||
import org.betterx.bclib.api.datafixer.PatchDidiFailException;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface PatchFunction<T, R> {
|
||||
R apply(T t, MigrationProfile profile) throws PatchDidiFailException;
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package org.betterx.bclib.interfaces;
|
||||
|
||||
public interface PostInitable {
|
||||
void postInit();
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package org.betterx.bclib.interfaces;
|
||||
|
||||
import org.betterx.bclib.client.render.BCLRenderLayer;
|
||||
|
||||
public interface RenderLayerProvider {
|
||||
BCLRenderLayer getRenderLayer();
|
||||
}
|
17
src/main/java/org/betterx/bclib/interfaces/SpawnRule.java
Normal file
17
src/main/java/org/betterx/bclib/interfaces/SpawnRule.java
Normal file
|
@ -0,0 +1,17 @@
|
|||
package org.betterx.bclib.interfaces;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.entity.MobSpawnType;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface SpawnRule<M extends Mob> {
|
||||
boolean canSpawn(EntityType<M> type,
|
||||
LevelAccessor world,
|
||||
MobSpawnType spawnReason,
|
||||
BlockPos pos,
|
||||
RandomSource random);
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package org.betterx.bclib.interfaces;
|
||||
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
import org.betterx.bclib.api.surface.SurfaceRuleBuilder;
|
||||
|
||||
public interface SurfaceMaterialProvider {
|
||||
BlockState getTopMaterial();
|
||||
BlockState getUnderMaterial();
|
||||
BlockState getAltTopMaterial();
|
||||
|
||||
boolean generateFloorRule();
|
||||
SurfaceRuleBuilder surface();
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package org.betterx.bclib.interfaces;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public interface SurfaceProvider {
|
||||
BlockState bclib_getSurface(BlockPos pos, Holder<Biome> biome, ServerLevel level);
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package org.betterx.bclib.interfaces;
|
||||
|
||||
import net.minecraft.world.level.biome.BiomeSource;
|
||||
|
||||
public interface SurfaceRuleProvider {
|
||||
void bclib_addBiomeSource(BiomeSource source);
|
||||
void bclib_clearBiomeSources();
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package org.betterx.bclib.interfaces;
|
||||
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public interface SurvivesOnBlocks extends SurvivesOnSpecialGround {
|
||||
List<Block> getSurvivableBlocks();
|
||||
|
||||
@Override
|
||||
default String getSurvivableBlocksString() {
|
||||
return getSurvivableBlocks()
|
||||
.stream()
|
||||
.filter(block -> block != Blocks.AIR && block != null)
|
||||
.map(block -> {
|
||||
ItemStack stack = new ItemStack(block);
|
||||
if (stack.hasCustomHoverName()) return stack.getHoverName().getString();
|
||||
else return block.getName().getString();
|
||||
})
|
||||
.sorted(Comparator.naturalOrder())
|
||||
.collect(Collectors.joining(", "));
|
||||
}
|
||||
|
||||
@Override
|
||||
default boolean isSurvivable(BlockState state) {
|
||||
return getSurvivableBlocks().contains(state.getBlock());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package org.betterx.bclib.interfaces;
|
||||
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SurvivesOnSpecialGround {
|
||||
String getSurvivableBlocksString();
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
static List<String> splitLines(String input) {
|
||||
final int MAX_LEN = 45;
|
||||
List<String> lines = Lists.newArrayList();
|
||||
|
||||
while (input.length() > MAX_LEN) {
|
||||
int idx = input.lastIndexOf(",", MAX_LEN);
|
||||
if (idx >= 0) {
|
||||
lines.add(input.substring(0, idx + 1).trim());
|
||||
input = input.substring(idx + 1).trim();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
lines.add(input.trim());
|
||||
|
||||
return lines;
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
static void appendHoverText(List<Component> list, String description) {
|
||||
final int MAX_LINES = 7;
|
||||
List<String> lines = splitLines(description);
|
||||
if (lines.size() == 1) {
|
||||
list.add(Component.translatable("tooltip.bclib.place_on", lines.get(0)).withStyle(ChatFormatting.GREEN));
|
||||
} else if (lines.size() > 1) {
|
||||
list.add(Component.translatable("tooltip.bclib.place_on", "").withStyle(ChatFormatting.GREEN));
|
||||
for (int i = 0; i < Math.min(lines.size(), MAX_LINES); i++) {
|
||||
String line = lines.get(i);
|
||||
if (i == MAX_LINES - 1 && i < lines.size() - 1) line += " ...";
|
||||
list.add(Component.literal(" " + line).withStyle(ChatFormatting.GREEN));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean isSurvivable(BlockState state);
|
||||
|
||||
default boolean canSurviveOnTop(BlockState state, LevelReader world, BlockPos pos) {
|
||||
return isSurvivable(world.getBlockState(pos.below()));
|
||||
}
|
||||
|
||||
default boolean canSurviveOnBottom(BlockState state, LevelReader world, BlockPos pos) {
|
||||
return isSurvivable(world.getBlockState(pos.above()));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package org.betterx.bclib.interfaces;
|
||||
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public interface SurvivesOnTags extends SurvivesOnSpecialGround {
|
||||
List<TagKey<Block>> getSurvivableTags();
|
||||
|
||||
@Override
|
||||
default String getSurvivableBlocksString() {
|
||||
return getSurvivableTags()
|
||||
.stream()
|
||||
.map(tag -> Registry.BLOCK.getTag(tag))
|
||||
.filter(named -> named.isPresent())
|
||||
.map(named -> named.get())
|
||||
.flatMap(named -> named.stream())
|
||||
.filter(block -> block != Blocks.AIR && block != null)
|
||||
.map(block -> {
|
||||
ItemStack stack = new ItemStack(block.value());
|
||||
if (stack.hasCustomHoverName()) return stack.getHoverName().getString();
|
||||
else return block.value().getName().getString();
|
||||
})
|
||||
.sorted(Comparator.naturalOrder())
|
||||
.collect(Collectors.joining(", "));
|
||||
}
|
||||
|
||||
@Override
|
||||
default boolean isSurvivable(BlockState state) {
|
||||
return getSurvivableTags().stream().anyMatch(tag -> state.is(tag));
|
||||
}
|
||||
}
|
11
src/main/java/org/betterx/bclib/interfaces/TagProvider.java
Normal file
11
src/main/java/org/betterx/bclib/interfaces/TagProvider.java
Normal file
|
@ -0,0 +1,11 @@
|
|||
package org.betterx.bclib.interfaces;
|
||||
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface TagProvider {
|
||||
void addTags(List<TagKey<Block>> blockTags, List<TagKey<Item>> itemTags);
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package org.betterx.bclib.interfaces;
|
||||
|
||||
public interface TileEntityRenderProvider {
|
||||
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
package org.betterx.bclib.interfaces;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface TriConsumer<A, B, C> {
|
||||
void accept(A a, B b, C c);
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
package org.betterx.bclib.interfaces;
|
||||
|
||||
public interface UnknownReceipBookCategory {
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
package org.betterx.bclib.interfaces.tools;
|
||||
|
||||
public interface AddMineableAxe {
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
package org.betterx.bclib.interfaces.tools;
|
||||
|
||||
public interface AddMineableHammer {
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
package org.betterx.bclib.interfaces.tools;
|
||||
|
||||
public interface AddMineableHoe {
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
package org.betterx.bclib.interfaces.tools;
|
||||
|
||||
public interface AddMineablePickaxe {
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
package org.betterx.bclib.interfaces.tools;
|
||||
|
||||
public interface AddMineableShears {
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
package org.betterx.bclib.interfaces.tools;
|
||||
|
||||
public interface AddMineableShovel {
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
package org.betterx.bclib.interfaces.tools;
|
||||
|
||||
public interface AddMineableSword {
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
package org.betterx.bclib.interfaces.tools;
|
||||
|
||||
public interface PreventMineableAdd {
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue