Code style fix & version update
This commit is contained in:
parent
6266b30088
commit
179ada3296
20 changed files with 392 additions and 427 deletions
|
@ -8,7 +8,7 @@ yarn_mappings= 6
|
|||
loader_version= 0.11.6
|
||||
|
||||
# Mod Properties
|
||||
mod_version = 0.2.4
|
||||
mod_version = 0.2.5
|
||||
maven_group = ru.bclib
|
||||
archives_base_name = bclib
|
||||
|
||||
|
|
|
@ -1,5 +1,17 @@
|
|||
package ru.bclib.api;
|
||||
|
||||
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 org.jetbrains.annotations.NotNull;
|
||||
import ru.bclib.BCLib;
|
||||
import ru.bclib.config.Configs;
|
||||
import ru.bclib.config.PathConfig;
|
||||
import ru.bclib.config.SessionConfig;
|
||||
import ru.bclib.util.Logger;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
|
@ -12,24 +24,11 @@ import java.util.Set;
|
|||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
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 ru.bclib.BCLib;
|
||||
import ru.bclib.config.Configs;
|
||||
import ru.bclib.config.PathConfig;
|
||||
import ru.bclib.config.SessionConfig;
|
||||
import ru.bclib.util.Logger;
|
||||
|
||||
public class DataFixerAPI2 {
|
||||
private static final Logger LOGGER = new Logger("DataFixerAPI");
|
||||
|
||||
public static void fixData(SessionConfig config) {
|
||||
if (true || !Configs.MAIN_CONFIG.getBoolean(Configs.MAIN_PATCH_CATEGORY, "applyPatches", true)){
|
||||
if (true || !Configs.MAIN_CONFIG.getBoolean(Configs.MAIN_PATCH_CATEGORY, "applyPatches", true)) {
|
||||
LOGGER.info("World Patches are disabled");
|
||||
return;
|
||||
}
|
||||
|
@ -89,13 +88,13 @@ public class DataFixerAPI2 {
|
|||
data.markApplied();
|
||||
}
|
||||
|
||||
private static boolean fixItemArrayWithID(ListTag items, boolean[] changed, Patch.MigrationData data, boolean recursive){
|
||||
private static boolean fixItemArrayWithID(ListTag items, boolean[] changed, Patch.MigrationData data, boolean recursive) {
|
||||
items.forEach(inTag -> {
|
||||
final CompoundTag tag = (CompoundTag) inTag;
|
||||
|
||||
changed[0] |= data.replaceStringFromIDs(tag, "id");
|
||||
|
||||
if (recursive && tag.contains("Items")){
|
||||
if (recursive && tag.contains("Items")) {
|
||||
changed[0] |= fixItemArrayWithID(tag.getList("Items", 10), changed, data, true);
|
||||
}
|
||||
});
|
||||
|
@ -130,29 +129,27 @@ public class DataFixerAPI2 {
|
|||
|
||||
/**
|
||||
* register a new Patch
|
||||
*
|
||||
* @param patch A #Supplier that will instantiate the new Patch Object
|
||||
*/
|
||||
public static void registerPatch(Supplier<Patch> patch){
|
||||
public static void registerPatch(Supplier<Patch> patch) {
|
||||
ALL.add(patch.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the highest patch-level that is available for the given mod. If no patches were
|
||||
* registerd for the mod, this will return 0
|
||||
*
|
||||
* @param modID The ID of the mod you want to query
|
||||
* @return The highest Patch-Level that was found
|
||||
*/
|
||||
public static int maxPatchLevel(@NotNull String modID){
|
||||
return ALL.stream()
|
||||
.filter(p-> p.getModID().equals(modID))
|
||||
.mapToInt(p->p.level)
|
||||
.max()
|
||||
.orElse(0);
|
||||
public static int maxPatchLevel(@NotNull String modID) {
|
||||
return ALL.stream().filter(p -> p.getModID().equals(modID)).mapToInt(p -> p.level).max().orElse(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by inheriting classes.
|
||||
*
|
||||
* <p>
|
||||
* Performs some sanity checks on the values and might throw a #RuntimeException if any
|
||||
* inconsistencies are found.
|
||||
*
|
||||
|
@ -166,10 +163,10 @@ public class DataFixerAPI2 {
|
|||
*/
|
||||
protected Patch(@NotNull String modID, int level) {
|
||||
//Patchlevels need to be unique and registered in ascending order
|
||||
if (modID==null || "".equals(modID)){
|
||||
if (modID == null || "".equals(modID)) {
|
||||
throw new RuntimeException("[INTERNAL ERROR] Patches need a valid modID!");
|
||||
}
|
||||
if (!ALL.stream().filter(p-> p.getModID().equals(modID)).noneMatch(p -> p.getLevel() >= level) || level <= 0){
|
||||
if (!ALL.stream().filter(p -> p.getModID().equals(modID)).noneMatch(p -> p.getLevel() >= level) || level <= 0) {
|
||||
throw new RuntimeException("[INTERNAL ERROR] Patch-levels need to be created in ascending order beginning with 1.");
|
||||
}
|
||||
|
||||
|
@ -181,9 +178,7 @@ public class DataFixerAPI2 {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Patch{" +
|
||||
"level=" + getModID() + ":" + getLevel() +
|
||||
'}';
|
||||
return "Patch{" + "level=" + getModID() + ":" + getLevel() + '}';
|
||||
}
|
||||
|
||||
final public int getLevel() {
|
||||
|
@ -192,6 +187,7 @@ public class DataFixerAPI2 {
|
|||
|
||||
/**
|
||||
* The Mod-ID that registered this Patch
|
||||
*
|
||||
* @return The ID
|
||||
*/
|
||||
final public String getModID() {
|
||||
|
@ -202,45 +198,47 @@ public class DataFixerAPI2 {
|
|||
/**
|
||||
* Return block data fixes. Fixes will be applied on world load if current patch-level for
|
||||
* the linked mod is lower than the {@link #level}.
|
||||
*
|
||||
* <p>
|
||||
* The default implementation of this method returns an empty map.
|
||||
*
|
||||
* @return The returned Map should contain the replacements. All occurences of the
|
||||
* {@code KeySet} are replaced with the associated value.
|
||||
*/
|
||||
public Map<String, String> getIDReplacements(){
|
||||
public Map<String, String> getIDReplacements() {
|
||||
return new HashMap<String, String>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates ready to use data for all currently registered patches. The list of
|
||||
* patches is selected by the current patch-level of the world.
|
||||
*
|
||||
* <p>
|
||||
* A {@link #Patch} with a given {@link #level} is only included if the patch-level of the
|
||||
* world is less
|
||||
*
|
||||
* @return a new {@link MigrationData} Object.
|
||||
*/
|
||||
static MigrationData createMigrationData(PathConfig config){
|
||||
static MigrationData createMigrationData(PathConfig config) {
|
||||
return new MigrationData(config);
|
||||
}
|
||||
|
||||
static class MigrationData{
|
||||
static class MigrationData {
|
||||
final Set<String> mods;
|
||||
final Map<String, String> idReplacements;
|
||||
private final PathConfig config;
|
||||
|
||||
private MigrationData(PathConfig config){
|
||||
private MigrationData(PathConfig config) {
|
||||
this.config = config;
|
||||
|
||||
this.mods = Collections.unmodifiableSet(Patch.getALL().stream().map(p -> p.modID).collect(Collectors.toSet()));
|
||||
|
||||
HashMap<String, String> replacements = new HashMap<String, String>();
|
||||
for(String modID : mods){
|
||||
for (String modID : mods) {
|
||||
Patch.getALL().stream().filter(p -> p.modID.equals(modID)).forEach(patch -> {
|
||||
if (currentPatchLevel(modID) < patch.level) {
|
||||
replacements.putAll(patch.getIDReplacements());
|
||||
LOGGER.info("Applying " + patch);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
LOGGER.info("Ignoring " + patch);
|
||||
}
|
||||
});
|
||||
|
@ -249,34 +247,29 @@ public class DataFixerAPI2 {
|
|||
this.idReplacements = Collections.unmodifiableMap(replacements);
|
||||
}
|
||||
|
||||
final public void markApplied(){
|
||||
for(String modID : mods){
|
||||
LOGGER.info("Updating Patch-Level for '{}' from {} to {} -> {}",
|
||||
modID,
|
||||
currentPatchLevel(modID),
|
||||
Patch.maxPatchLevel(modID),
|
||||
config.setInt(Configs.MAIN_PATCH_CATEGORY, modID, Patch.maxPatchLevel(modID))
|
||||
);
|
||||
final public void markApplied() {
|
||||
for (String modID : mods) {
|
||||
LOGGER.info("Updating Patch-Level for '{}' from {} to {} -> {}", modID, currentPatchLevel(modID), Patch.maxPatchLevel(modID), config.setInt(Configs.MAIN_PATCH_CATEGORY, modID, Patch.maxPatchLevel(modID)));
|
||||
}
|
||||
|
||||
config.saveChanges();
|
||||
}
|
||||
|
||||
public int currentPatchLevel(@NotNull String modID){
|
||||
public int currentPatchLevel(@NotNull String modID) {
|
||||
return config.getInt(Configs.MAIN_PATCH_CATEGORY, modID, 0);
|
||||
}
|
||||
|
||||
public boolean hasAnyFixes(){
|
||||
return idReplacements.size()>0;
|
||||
public boolean hasAnyFixes() {
|
||||
return idReplacements.size() > 0;
|
||||
}
|
||||
|
||||
public boolean replaceStringFromIDs(@NotNull CompoundTag tag, @NotNull String key){
|
||||
public boolean replaceStringFromIDs(@NotNull CompoundTag tag, @NotNull String key) {
|
||||
if (!tag.contains(key)) return false;
|
||||
|
||||
final String val = tag.getString(key);
|
||||
final String replace = idReplacements.get(val);
|
||||
|
||||
if (replace != null){
|
||||
if (replace != null) {
|
||||
LOGGER.warning("Replacing ID '{}' with '{}'.", val, replace);
|
||||
tag.putString(key, replace);
|
||||
return true;
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
package ru.bclib.blocks;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -14,9 +10,13 @@ import net.minecraft.world.level.material.MaterialColor;
|
|||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import ru.bclib.client.models.BlockModelProvider;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* Base class for a default Block.
|
||||
*
|
||||
* <p>
|
||||
* This Block-Type will:
|
||||
* <ul>
|
||||
* <li>Drop itself</li>
|
||||
|
@ -26,6 +26,7 @@ import ru.bclib.client.models.BlockModelProvider;
|
|||
public class BaseBlock extends Block implements BlockModelProvider {
|
||||
/**
|
||||
* Creates a new Block with the passed properties
|
||||
*
|
||||
* @param settings The properties of the Block.
|
||||
*/
|
||||
public BaseBlock(Properties settings) {
|
||||
|
@ -34,7 +35,7 @@ public class BaseBlock extends Block implements BlockModelProvider {
|
|||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>
|
||||
* This implementation will drop the Block itself
|
||||
*/
|
||||
@Override
|
||||
|
@ -45,7 +46,7 @@ public class BaseBlock extends Block implements BlockModelProvider {
|
|||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>
|
||||
* This implementation will load the Block-Model and return it as the Item-Model
|
||||
*/
|
||||
@Override
|
||||
|
@ -55,16 +56,17 @@ public class BaseBlock extends Block implements BlockModelProvider {
|
|||
|
||||
/**
|
||||
* This method is used internally.
|
||||
*
|
||||
* <p>
|
||||
* It is called from Block-Contructors, to allow the augmentation of the blocks
|
||||
* preset properties.
|
||||
*
|
||||
* <p>
|
||||
* For example in {@link BaseLeavesBlock#BaseLeavesBlock(Block, MaterialColor, Consumer)}
|
||||
*
|
||||
* @param customizeProperties A {@link Consumer} to call with the preset properties
|
||||
* @param settings The properties as created by the Block
|
||||
* @return The reconfigured {@code settings}
|
||||
*/
|
||||
static FabricBlockSettings acceptAndReturn(Consumer<FabricBlockSettings> customizeProperties, FabricBlockSettings settings){
|
||||
static FabricBlockSettings acceptAndReturn(Consumer<FabricBlockSettings> customizeProperties, FabricBlockSettings settings) {
|
||||
customizeProperties.accept(settings);
|
||||
return settings;
|
||||
}
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
package ru.bclib.blocks;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
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;
|
||||
|
@ -25,19 +20,15 @@ import ru.bclib.client.render.BCLRenderLayer;
|
|||
import ru.bclib.interfaces.IRenderTyped;
|
||||
import ru.bclib.util.MHelper;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class BaseLeavesBlock extends LeavesBlock implements BlockModelProvider, IRenderTyped {
|
||||
private final Block sapling;
|
||||
|
||||
private static FabricBlockSettings makeLeaves(MaterialColor color){
|
||||
return FabricBlockSettings
|
||||
.copyOf(Blocks.OAK_LEAVES)
|
||||
.mapColor(color)
|
||||
.breakByTool(FabricToolTags.HOES)
|
||||
.breakByTool(FabricToolTags.SHEARS)
|
||||
.breakByHand(true)
|
||||
.allowsSpawning((state, world, pos, type) -> false)
|
||||
.suffocates((state, world, pos) -> false)
|
||||
.blockVision((state, world, pos) -> false);
|
||||
private static FabricBlockSettings makeLeaves(MaterialColor color) {
|
||||
return FabricBlockSettings.copyOf(Blocks.OAK_LEAVES).mapColor(color).breakByTool(FabricToolTags.HOES).breakByTool(FabricToolTags.SHEARS).breakByHand(true).allowsSpawning((state, world, pos, type) -> false).suffocates((state, world, pos) -> false).blockVision((state, world, pos) -> false);
|
||||
}
|
||||
|
||||
public BaseLeavesBlock(Block sapling, MaterialColor color, Consumer<FabricBlockSettings> customizeProperties) {
|
||||
|
|
|
@ -3,7 +3,11 @@ package ru.bclib.blocks.properties;
|
|||
import com.google.common.collect.Sets;
|
||||
import net.minecraft.world.level.block.state.properties.Property;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
@Deprecated
|
||||
public class StringProperty extends Property<String> {
|
||||
|
@ -36,7 +40,8 @@ public class StringProperty extends Property<String> {
|
|||
public Optional<String> getValue(String string) {
|
||||
if (values.contains(string)) {
|
||||
return Optional.of(string);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package ru.bclib.config;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.bclib.BCLib;
|
||||
import ru.bclib.config.ConfigKeeper.BooleanEntry;
|
||||
|
@ -11,12 +9,14 @@ import ru.bclib.config.ConfigKeeper.IntegerEntry;
|
|||
import ru.bclib.config.ConfigKeeper.RangeEntry;
|
||||
import ru.bclib.config.ConfigKeeper.StringEntry;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public abstract class Config {
|
||||
protected final ConfigKeeper keeper;
|
||||
|
||||
protected abstract void registerEntries();
|
||||
|
||||
public Config(String modID, String group){
|
||||
public Config(String modID, String group) {
|
||||
this(modID, group, null);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,21 +1,19 @@
|
|||
package ru.bclib.config;
|
||||
|
||||
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.io.File;
|
||||
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 ru.bclib.util.JsonFactory;
|
||||
|
||||
public final class ConfigKeeper {
|
||||
private final Map<ConfigKey, Entry<?>> configEntries = Maps.newHashMap();
|
||||
private final JsonObject configObject;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package ru.bclib.config;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class ConfigKey {
|
||||
private final String path[];
|
||||
private final String entry;
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
@ -20,12 +19,7 @@ public class ConfigWriter {
|
|||
}
|
||||
|
||||
public ConfigWriter(String modID, String configFile, File configFolder) {
|
||||
this.configFile = new File(
|
||||
(configFolder==null
|
||||
? GAME_CONFIG_DIR.resolve(modID).toFile()
|
||||
: new File(configFolder, modID)),
|
||||
configFile + ".json"
|
||||
);
|
||||
this.configFile = new File((configFolder == null ? GAME_CONFIG_DIR.resolve(modID).toFile() : new File(configFolder, modID)), configFile + ".json");
|
||||
File parent = this.configFile.getParentFile();
|
||||
if (!parent.exists()) {
|
||||
parent.mkdirs();
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package ru.bclib.config;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
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.io.File;
|
||||
|
||||
public class PathConfig extends Config {
|
||||
|
||||
public PathConfig(String modID, String group) {
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package ru.bclib.config;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.storage.LevelStorageSource;
|
||||
import ru.bclib.BCLib;
|
||||
|
||||
public class SessionConfig extends PathConfig{
|
||||
private static File getWorldFolder(LevelStorageSource.LevelStorageAccess session, ServerLevel world){
|
||||
import java.io.File;
|
||||
|
||||
public class SessionConfig extends PathConfig {
|
||||
private static File getWorldFolder(LevelStorageSource.LevelStorageAccess session, ServerLevel world) {
|
||||
File dir = session.getDimensionPath(world.dimension());
|
||||
if (!new File(dir, "level.dat").exists()) {
|
||||
dir = dir.getParentFile();
|
||||
|
|
|
@ -3,25 +3,15 @@ package ru.bclib.mixin.client;
|
|||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.color.block.BlockColors;
|
||||
import net.minecraft.client.color.item.ItemColors;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.gui.screens.WinScreen;
|
||||
import net.minecraft.client.main.GameConfig;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.sounds.Music;
|
||||
import net.minecraft.sounds.Musics;
|
||||
import net.minecraft.world.level.Level;
|
||||
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.interfaces.IColorProvider;
|
||||
import ru.bclib.util.MHelper;
|
||||
|
||||
@Mixin(Minecraft.class)
|
||||
public class MinecraftMixin {
|
||||
|
|
|
@ -25,11 +25,7 @@ public class TextureAtlasMixin {
|
|||
bclib_modifyAtlas = resourceLocation.toString().equals("minecraft:textures/atlas/blocks.png");
|
||||
}
|
||||
|
||||
@Inject(
|
||||
method = "load(Lnet/minecraft/server/packs/resources/ResourceManager;Lnet/minecraft/client/renderer/texture/TextureAtlasSprite$Info;IIIII)Lnet/minecraft/client/renderer/texture/TextureAtlasSprite;",
|
||||
at = @At("HEAD"),
|
||||
cancellable = true
|
||||
)
|
||||
@Inject(method = "load(Lnet/minecraft/server/packs/resources/ResourceManager;Lnet/minecraft/client/renderer/texture/TextureAtlasSprite$Info;IIIII)Lnet/minecraft/client/renderer/texture/TextureAtlasSprite;", at = @At("HEAD"), cancellable = true)
|
||||
private void bclib_loadSprite(ResourceManager resourceManager, TextureAtlasSprite.Info spriteInfo, int atlasWidth, int atlasHeight, int maxLevel, int posX, int posY, CallbackInfoReturnable<TextureAtlasSprite> info) {
|
||||
ResourceLocation location = spriteInfo.name();
|
||||
if (bclib_modifyAtlas && location.getPath().startsWith("block")) {
|
||||
|
|
|
@ -7,7 +7,6 @@ import net.minecraft.world.InteractionResult;
|
|||
import net.minecraft.world.item.BoneMealItem;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import net.minecraft.world.level.Level;
|
||||
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;
|
||||
|
@ -18,12 +17,9 @@ 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;
|
||||
import ru.bclib.util.BlocksHelper;
|
||||
import ru.bclib.util.MHelper;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@Mixin(BoneMealItem.class)
|
||||
public class BoneMealItemMixin {
|
||||
private static final MutableBlockPos bclib_BLOCK_POS = new MutableBlockPos();
|
||||
|
@ -139,7 +135,7 @@ public class BoneMealItemMixin {
|
|||
Block terrain = BonemealAPI.getSpreadable(state.getBlock());
|
||||
if (center.is(terrain)) {
|
||||
if (haveSameProperties(state, center)) {
|
||||
for (Property property: center.getProperties()) {
|
||||
for (Property property : center.getProperties()) {
|
||||
state = state.setValue(property, center.getValue(property));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +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 net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
|
@ -27,6 +22,11 @@ import ru.bclib.api.DataFixerAPI2;
|
|||
import ru.bclib.api.WorldDataAPI;
|
||||
import ru.bclib.config.SessionConfig;
|
||||
|
||||
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 bclib_lastWorld = null;
|
||||
|
|
|
@ -52,6 +52,7 @@ public class JsonFactory {
|
|||
|
||||
/**
|
||||
* Loads {@link JsonObject} from resource location using Minecraft resource manager. Can be used to load JSON from resourcepacks and resources.
|
||||
*
|
||||
* @param location {@link ResourceLocation} to JSON file
|
||||
* @return {@link JsonObject}
|
||||
*/
|
||||
|
@ -70,7 +71,8 @@ public class JsonFactory {
|
|||
stream.close();
|
||||
}
|
||||
}
|
||||
catch (IOException ex) {}
|
||||
catch (IOException ex) {
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
package ru.bclib.util;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
|
@ -14,6 +10,9 @@ import net.minecraft.world.item.Item;
|
|||
import net.minecraft.world.level.ItemLike;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Utility functions to manage Minecraft Tags
|
||||
*/
|
||||
|
@ -23,11 +22,11 @@ public class TagHelper {
|
|||
|
||||
/**
|
||||
* Adds one Tag to multiple Blocks.
|
||||
*
|
||||
* <p>
|
||||
* Example:
|
||||
* <pre>{@code Tag.Named<Block> DIMENSION_STONE = makeBlockTag("mymod", "dim_stone");
|
||||
* TagHelper.addTag(DIMENSION_STONE, Blocks.END_STONE, Blocks.NETHERRACK);}</pre>
|
||||
*
|
||||
* <p>
|
||||
* The call will reserve the Tag. The Tag is added to the blocks once
|
||||
* {@link #apply(String, Map)} was executed.
|
||||
*
|
||||
|
@ -47,11 +46,11 @@ public class TagHelper {
|
|||
|
||||
/**
|
||||
* Adds one Tag to multiple Items.
|
||||
*
|
||||
* <p>
|
||||
* Example:
|
||||
* <pre>{@code Tag.Named<Item> METALS = makeBlockTag("mymod", "metals");
|
||||
* TagHelper.addTag(METALS, Items.IRON_INGOT, Items.GOLD_INGOT, Items.COPPER_INGOT);}</pre>
|
||||
*
|
||||
* <p>
|
||||
* The call will reserve the Tag. The Tag is added to the items once
|
||||
* {@link #apply(String, Map)} was executed.
|
||||
*
|
||||
|
@ -71,7 +70,7 @@ public class TagHelper {
|
|||
|
||||
/**
|
||||
* Adds multiple Tags to one Item.
|
||||
*
|
||||
* <p>
|
||||
* The call will reserve the Tags. The Tags are added to the Item once
|
||||
* * {@link #apply(String, Map)} was executed.
|
||||
*
|
||||
|
@ -87,7 +86,7 @@ public class TagHelper {
|
|||
|
||||
/**
|
||||
* Adds multiple Tags to one Block.
|
||||
*
|
||||
* <p>
|
||||
* The call will reserve the Tags. The Tags are added to the Block once
|
||||
* * {@link #apply(String, Map)} was executed.
|
||||
*
|
||||
|
@ -103,9 +102,9 @@ public class TagHelper {
|
|||
|
||||
/**
|
||||
* Adds all {@code ids} to the {@code builder}.
|
||||
*
|
||||
* @param builder
|
||||
* @param ids
|
||||
*
|
||||
* @return The Builder passed as {@code builder}.
|
||||
*/
|
||||
public static Tag.Builder apply(Tag.Builder builder, Set<ResourceLocation> ids) {
|
||||
|
@ -115,13 +114,12 @@ public class TagHelper {
|
|||
|
||||
/**
|
||||
* Automatically called in {@link net.minecraft.tags.TagLoader#loadAndBuild(ResourceManager)}.
|
||||
*
|
||||
* <p>
|
||||
* In most cases there is no need to call this Method manually.
|
||||
*
|
||||
* @param directory The name of the Tag-directory. Should be either <i>"tags/blocks"</i> or
|
||||
* <i>"tags/items"</i>.
|
||||
* @param tagsMap The map that will hold the registered Tags
|
||||
*
|
||||
* @return The {@code tagsMap} Parameter.
|
||||
*/
|
||||
public static Map<ResourceLocation, Tag.Builder> apply(String directory, Map<ResourceLocation, Tag.Builder> tagsMap) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue