diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 0b89a53..0000000 --- a/.travis.yml +++ /dev/null @@ -1,16 +0,0 @@ -language: java -jdk: - - openjdk8 - -jobs: - include: - - stage: build - install: ./gradlew setupCiWorkspace -S - script: ./gradlew build - - stage: checkstyle - install: echo "skipping default ./gradlew assemble" - script: ./gradlew checkstyle - -env: - global: - TERM=dumb diff --git a/api/buildcraft/api/BCBlocks.java b/api/buildcraft/api/BCBlocks.java index 693aa4e..8b96b33 100644 --- a/api/buildcraft/api/BCBlocks.java +++ b/api/buildcraft/api/BCBlocks.java @@ -1,68 +1,109 @@ package buildcraft.api; -import net.minecraft.block.Block; - -import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder; +import net.minecraft.world.level.block.Block; +import net.minecraftforge.registries.ObjectHolder; public class BCBlocks { - @ObjectHolder("buildcraftcore") public static class Core { - public static final Block SPRING = null; - public static final Block DECORATED = null; - public static final Block ENGINE = null; + @ObjectHolder(registryName = "block", value = "buildcraftcore:spring_water") + public static final Block SPRING_WATER = null; + @ObjectHolder(registryName = "block", value = "buildcraftcore:spring_oil") + public static final Block SPRING_OIL = null; + @ObjectHolder(registryName = "block", value = "buildcraftcore:decorated_destroy") + public static final Block DECORATED_DESTROY = null; + @ObjectHolder(registryName = "block", value = "buildcraftcore:decorated_blueprint") + public static final Block DECORATED_BLUEPRINT = null; + @ObjectHolder(registryName = "block", value = "buildcraftcore:decorated_template") + public static final Block DECORATED_TEMPLATE = null; + @ObjectHolder(registryName = "block", value = "buildcraftcore:decorated_paper") + public static final Block DECORATED_PAPER = null; + @ObjectHolder(registryName = "block", value = "buildcraftcore:decorated_leather") + public static final Block DECORATED_LEATHER = null; + @ObjectHolder(registryName = "block", value = "buildcraftcore:decorated_laser_back") + public static final Block DECORATED_LASER_BACK = null; + @ObjectHolder(registryName = "block", value = "buildcraftcore:engine_wood") + public static final Block ENGINE_WOOD = null; + @ObjectHolder(registryName = "block", value = "buildcraftcore:engine_stone") + public static final Block ENGINE_STONE = null; + @ObjectHolder(registryName = "block", value = "buildcraftcore:engine_iron") + public static final Block ENGINE_IRON = null; + @ObjectHolder(registryName = "block", value = "buildcraftcore:engine_creative") + public static final Block ENGINE_CREATIVE = null; + @ObjectHolder(registryName = "block", value = "buildcraftcore:marker_volume") public static final Block MARKER_VOLUME = null; + @ObjectHolder(registryName = "block", value = "buildcraftcore:marker_path") public static final Block MARKER_PATH = null; } - @ObjectHolder("buildcraftbuilders") public static class Builders { + @ObjectHolder(registryName = "block", value = "buildcraftbuilders:architect") public static final Block ARCHITECT = null; + @ObjectHolder(registryName = "block", value = "buildcraftbuilders:builder") public static final Block BUILDER = null; + @ObjectHolder(registryName = "block", value = "buildcraftbuilders:filler") public static final Block FILLER = null; + @ObjectHolder(registryName = "block", value = "buildcraftbuilders:library") public static final Block LIBRARY = null; + @ObjectHolder(registryName = "block", value = "buildcraftbuilders:replacer") public static final Block REPLACER = null; + @ObjectHolder(registryName = "block", value = "buildcraftbuilders:quarry") public static final Block QUARRY = null; + @ObjectHolder(registryName = "block", value = "buildcraftbuilders:frame") public static final Block FRAME = null; } - @ObjectHolder("buildcraftenergy") public static class Energy { // Fluid blocks can be accessed ~somewhere else~ +// @ObjectHolder(registryName = "block", value = "buildcraftenergy:") } - @ObjectHolder("buildcraftfactory") public static class Factory { + @ObjectHolder(registryName = "block", value = "buildcraftfactory:autoworkbench_item") public static final Block AUTOWORKBENCH_ITEM = null; + @ObjectHolder(registryName = "block", value = "buildcraftfactory:mining_well") public static final Block MINING_WELL = null; + @ObjectHolder(registryName = "block", value = "buildcraftfactory:pump") public static final Block PUMP = null; + @ObjectHolder(registryName = "block", value = "buildcraftfactory:tube") public static final Block TUBE = null; + @ObjectHolder(registryName = "block", value = "buildcraftfactory:flood_gate") public static final Block FLOOD_GATE = null; + @ObjectHolder(registryName = "block", value = "buildcraftfactory:tank") public static final Block TANK = null; + @ObjectHolder(registryName = "block", value = "buildcraftfactory:chute") public static final Block CHUTE = null; + @ObjectHolder(registryName = "block", value = "buildcraftfactory:water_gel") public static final Block WATER_GEL = null; + @ObjectHolder(registryName = "block", value = "buildcraftfactory:distiller") public static final Block DISTILLER = null; + @ObjectHolder(registryName = "block", value = "buildcraftfactory:heat_exchange") public static final Block HEAT_EXCHANGE = null; } - @ObjectHolder("buildcrafttransport") public static class Transport { + @ObjectHolder(registryName = "block", value = "buildcrafttransport:filtered_buffer") public static final Block FILTERED_BUFFER = null; + @ObjectHolder(registryName = "block", value = "buildcrafttransport:pipe_holder") public static final Block PIPE_HOLDER = null; } - @ObjectHolder("buildcraftsilicon") public static class Silicon { + @ObjectHolder(registryName = "block", value = "buildcraftsilicon:laser") public static final Block LASER = null; + @ObjectHolder(registryName = "block", value = "buildcraftsilicon:assembly_table") public static final Block ASSEMBLY_TABLE = null; + @ObjectHolder(registryName = "block", value = "buildcraftsilicon:advanced_crafting_table") public static final Block ADVANCED_CRAFTING_TABLE = null; + @ObjectHolder(registryName = "block", value = "buildcraftsilicon:integration_table") public static final Block INTEGRATION_TABLE = null; + @ObjectHolder(registryName = "block", value = "buildcraftsilicon:charging_table") public static final Block CHARGING_TABLE = null; + @ObjectHolder(registryName = "block", value = "buildcraftsilicon:programming_table") public static final Block PROGRAMMING_TABLE = null; } - @ObjectHolder("buildcraftrobotics") public static class Robotics { - +// @ObjectHolder(registryName = "block", value = "buildcraftrobotics:") } } diff --git a/api/buildcraft/api/BCItems.java b/api/buildcraft/api/BCItems.java index 01f5446..970c2cd 100644 --- a/api/buildcraft/api/BCItems.java +++ b/api/buildcraft/api/BCItems.java @@ -1,79 +1,111 @@ package buildcraft.api; -import net.minecraft.item.Item; - -import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder; - import buildcraft.api.items.FluidItemDrops; +import net.minecraft.world.item.Item; +import net.minecraftforge.registries.ObjectHolder; public class BCItems { - @ObjectHolder("buildcraftlib") public static class Lib { + @ObjectHolder(registryName = "item", value = "buildcraftlib:guide") public static final Item GUIDE = null; + @ObjectHolder(registryName = "item", value = "buildcraftlib:guide_note") public static final Item GUIDE_NOTE = null; + @ObjectHolder(registryName = "item", value = "buildcraftlib:debugger") public static final Item DEBUGGER = null; } - @ObjectHolder("buildcraftcore") public static class Core { + @ObjectHolder(registryName = "item", value = "buildcraftcore:gear_wood") public static final Item GEAR_WOOD = null; + @ObjectHolder(registryName = "item", value = "buildcraftcore:gear_stone") public static final Item GEAR_STONE = null; + @ObjectHolder(registryName = "item", value = "buildcraftcore:gear_iron") public static final Item GEAR_IRON = null; + @ObjectHolder(registryName = "item", value = "buildcraftcore:gear_gold") public static final Item GEAR_GOLD = null; + @ObjectHolder(registryName = "item", value = "buildcraftcore:gear_diamond") public static final Item GEAR_DIAMOND = null; + @ObjectHolder(registryName = "item", value = "buildcraftcore:wrench") public static final Item WRENCH = null; - public static final Item PAINTBRUSH = null; + @ObjectHolder(registryName = "item", value = "buildcraftcore:paintbrush_clean") + public static final Item PAINTBRUSH_CLEAN = null; + @ObjectHolder(registryName = "item", value = "buildcraftcore:list") public static final Item LIST = null; + @ObjectHolder(registryName = "item", value = "buildcraftcore:map_location") public static final Item MAP_LOCATION = null; + @ObjectHolder(registryName = "item", value = "buildcraftcore:marker_connector") public static final Item MARKER_CONNECTOR = null; + @ObjectHolder(registryName = "item", value = "buildcraftcore:volume_box") public static final Item VOLUME_BOX = null; + @ObjectHolder(registryName = "item", value = "buildcraftcore:goggles") public static final Item GOGGLES = null; - /** It is recommended that you refer to {@link FluidItemDrops#item} when creating fluid drops rather than - * this. */ + /** + * It is recommended that you refer to {@link FluidItemDrops#item} when creating fluid drops rather than + * this. + */ + @ObjectHolder(registryName = "item", value = "buildcraftcore:fragile_fluid_shard") public static final Item FRAGILE_FLUID_SHARD = null; } - @ObjectHolder("buildcraftbuilders") public static class Builders { - +// @ObjectHolder(registryName = "item", value = "buildcraftbuilders:") } - @ObjectHolder("buildcraftenergy") public static class Energy { - public static final Item GLOB_OF_OIL = null; + @ObjectHolder(registryName = "item", value = "buildcraftenergy:glob_oil") + public static final Item GLOB_OIL = null; } - @ObjectHolder("buildcraftfactory") public static class Factory { + @ObjectHolder(registryName = "item", value = "buildcraftfactory:plastic_sheet") public static final Item PLASTIC_SHEET = null; - public static final Item WATER_GEL = null; - public static final Item GELLED_WATER = null; + @ObjectHolder(registryName = "item", value = "buildcraftfactory:water_gel_spawn") + public static final Item WATER_GEL_SPAWN = null; + @ObjectHolder(registryName = "item", value = "buildcraftfactory:gel") + public static final Item GEL = null; } - @ObjectHolder("buildcrafttransport") public static class Transport { + @ObjectHolder(registryName = "item", value = "buildcrafttransport:plug_blocker") public static final Item PLUG_BLOCKER = null; + @ObjectHolder(registryName = "item", value = "buildcrafttransport:plug_power_adaptor") public static final Item PLUG_POWER_ADAPTOR = null; - public static final Item PIPE_STRUCTURE = null; - public static final Item PIPE_WOOD_ITEM = null; - public static final Item PIPE_EMZULI_ITEM = null; - public static final Item PIPE_DIAMOND_WOOD_ITEM = null; - public static final Item PIPE_WOOD_FLUID = null; - public static final Item PIPE_DIAMOND_WOOD_FLUID = null; + @ObjectHolder(registryName = "item", value = "buildcrafttransport:pipe_structure_cobblestone_colorless") + public static final Item PIPE_STRUCTURE_COBBLESTONE_COLORLESS = null; + @ObjectHolder(registryName = "item", value = "buildcrafttransport:pipe_items_wood_colorless") + public static final Item PIPE_ITEMS_WOOD_COLORLESS = null; + @ObjectHolder(registryName = "item", value = "buildcrafttransport:pipe_items_emzuli_colorless") + public static final Item PIPE_ITEMS_EMZULI_COLORLESS = null; + @ObjectHolder(registryName = "item", value = "buildcrafttransport:pipe_items_diamond_wood_colorless") + public static final Item PIPE_ITEMS_DIAMOND_WOOD_COLORLESS = null; + @ObjectHolder(registryName = "item", value = "buildcrafttransport:pipe_fluids_wood_colorless") + public static final Item PIPE_FLUIDS_WOOD_COLORLESS = null; + @ObjectHolder(registryName = "item", value = "buildcrafttransport:pipe_fluids_diamond_wood_colorless") + public static final Item PIPE_FLUIDS_DIAMOND_WOOD_COLORLESS = null; } - @ObjectHolder("buildcraftsilicon") public static class Silicon { - public static final Item REDSTONE_CHIPSET = null; - + @ObjectHolder(registryName = "item", value = "buildcraftsilicon:chipset_redstone") + public static final Item CHIPSET_REDSTONE = null; + @ObjectHolder(registryName = "item", value = "buildcraftsilicon:chipset_iron") + public static final Item CHIPSET_IRON = null; + @ObjectHolder(registryName = "item", value = "buildcraftsilicon:chipset_gold") + public static final Item CHIPSET_GOLD = null; + @ObjectHolder(registryName = "item", value = "buildcraftsilicon:chipset_quartz") + public static final Item CHIPSET_QUARTZ = null; + @ObjectHolder(registryName = "item", value = "buildcraftsilicon:chipset_diamond") + public static final Item CHIPSET_DIAMOND = null; + + @ObjectHolder(registryName = "item", value = "buildcraftsilicon:plug_pulsar") public static final Item PLUG_PULSAR = null; + @ObjectHolder(registryName = "item", value = "buildcraftsilicon:plug_facade") + public static final Item PLUG_FACADE = null; } - @ObjectHolder("buildcraftrobotics") public static class Robotics { - +// @ObjectHolder(registryName = "item", value = "buildcraftrobotics:") } } diff --git a/api/buildcraft/api/BCModules.java b/api/buildcraft/api/BCModules.java index bb9cf30..2a67c7b 100644 --- a/api/buildcraft/api/BCModules.java +++ b/api/buildcraft/api/BCModules.java @@ -1,17 +1,16 @@ package buildcraft.api; +import net.minecraft.client.resources.model.ModelResourceLocation; +import net.minecraft.resources.ResourceLocation; +import net.minecraftforge.fml.ModList; +import net.minecraftforge.fml.ModLoadingContext; +import net.minecraftforge.fml.ModLoadingStage; + +import javax.annotation.Nullable; import java.util.ArrayList; import java.util.List; import java.util.Locale; -import javax.annotation.Nullable; - -import net.minecraft.client.renderer.block.model.ModelResourceLocation; -import net.minecraft.util.ResourceLocation; - -import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.fml.common.LoaderState; - public enum BCModules implements IBuildCraftMod { LIB, // Base module for all BC. @@ -30,10 +29,14 @@ public enum BCModules implements IBuildCraftMod { private static boolean hasChecked = false; private static BCModules[] loadedModules, missingModules; + // Calen + public static final String BUILDCRAFT = "buildcraft"; + public final String lowerCaseName = name().toLowerCase(Locale.ROOT); // Bit hacky, but it works as this is all english public final String camelCaseName = name().charAt(0) + lowerCaseName.substring(1); - private final String modId = "buildcraft" + lowerCaseName; + // private final String modId = "buildcraft" + lowerCaseName; + private final String modId = BUILDCRAFT + lowerCaseName; private boolean loaded; private static void checkLoadStatus() { @@ -48,12 +51,14 @@ private static synchronized void load0() { if (hasChecked) { return; } - if (!Loader.instance().hasReachedState(LoaderState.PREINITIALIZATION)) { +// if (!Loader.instance().hasReachedState(LoaderState.PREINITIALIZATION)) + if (ModLoadingContext.get().getActiveContainer().getCurrentState().ordinal() < ModLoadingStage.CONSTRUCT.ordinal()) { throw new RuntimeException("You can only use BCModules.isLoaded from pre-init onwards!"); } List found = new ArrayList<>(), missing = new ArrayList<>(); for (BCModules module : VALUES) { - module.loaded = Loader.isModLoaded(module.modId); + module.loaded = ModList.get().isLoaded(module.modId); + if (module.loaded) { found.add(module); } else { @@ -104,10 +109,11 @@ public ResourceLocation createLocation(String path) { } public ModelResourceLocation createModelLocation(String path, String variant) { - return new ModelResourceLocation(getModId() + ":" + path + "#" + variant); + return new ModelResourceLocation(getModId(), path, variant); } public ModelResourceLocation createModelLocation(String pathAndVariant) { - return new ModelResourceLocation(getModId() + ":" + pathAndVariant); + String[] pathAndVariantArray = pathAndVariant.split("#"); + return new ModelResourceLocation(getModId(), pathAndVariantArray[0], pathAndVariantArray[1]); } } diff --git a/api/buildcraft/api/blocks/CustomPaintHelper.java b/api/buildcraft/api/blocks/CustomPaintHelper.java index 2517af2..a3dd769 100644 --- a/api/buildcraft/api/blocks/CustomPaintHelper.java +++ b/api/buildcraft/api/blocks/CustomPaintHelper.java @@ -1,24 +1,23 @@ package buildcraft.api.blocks; -import java.util.List; -import java.util.Map; - -import javax.annotation.Nullable; - +import buildcraft.api.core.BCDebugging; +import buildcraft.api.core.BCLog; import com.google.common.collect.Lists; import com.google.common.collect.Maps; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.item.DyeColor; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.Property; +import net.minecraft.world.phys.Vec3; +import net.minecraftforge.registries.ForgeRegistries; -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.item.EnumDyeColor; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; -import net.minecraft.world.World; - -import buildcraft.api.core.BCDebugging; -import buildcraft.api.core.BCLog; +import javax.annotation.Nullable; +import java.util.List; +import java.util.Map; /** Provides a simple way to paint a single block, iterating through all {@link ICustomPaintHandler}'s that are * registered for the block. */ @@ -43,11 +42,12 @@ public void registerHandlerForAll(ICustomPaintHandler handler) { /** Register's a paint handler for every class of a given block. */ public void registerHandlerForAll(Class blockClass, ICustomPaintHandler handler) { - for (Block block : Block.REGISTRY) { +// for (Block block : Block.REGISTRY) + for (Block block : ForgeRegistries.BLOCKS.getValues()) { Class foundClass = block.getClass(); if (blockClass.isAssignableFrom(foundClass)) { if (DEBUG) { - BCLog.logger.info("[api.painting] Found an assignable block " + block.getRegistryName() + " (" + foundClass + ") for " + blockClass); + BCLog.logger.info("[api.painting] Found an assignable block " + block.builtInRegistryHolder().key().location() + " (" + foundClass + ") for " + blockClass); } registerHandlerInternal(block, handler); } @@ -57,10 +57,10 @@ public void registerHandlerForAll(Class blockClass, ICustomPain public void registerHandler(Block block, ICustomPaintHandler handler) { if (registerHandlerInternal(block, handler)) { if (DEBUG) { - BCLog.logger.info("[api.painting] Setting a paint handler for block " + block.getRegistryName() + "(" + handler.getClass() + ")"); + BCLog.logger.info("[api.painting] Setting a paint handler for block " + block.builtInRegistryHolder().key().location() + "(" + handler.getClass() + ")"); } } else if (DEBUG) { - BCLog.logger.info("[api.painting] Adding another paint handler for block " + block.getRegistryName() + "(" + handler.getClass() + ")"); + BCLog.logger.info("[api.painting] Adding another paint handler for block " + block.builtInRegistryHolder().key().location() + "(" + handler.getClass() + ")"); } } @@ -77,7 +77,7 @@ private boolean registerHandlerInternal(Block block, ICustomPaintHandler handler } /** Attempts to paint a block at the given position. Basically iterates through all registered paint handlers. */ - public EnumActionResult attemptPaintBlock(World world, BlockPos pos, IBlockState state, Vec3d hitPos, @Nullable EnumFacing hitSide, @Nullable EnumDyeColor paint) { + public InteractionResult attemptPaintBlock(Level world, BlockPos pos, BlockState state, Vec3 hitPos, @Nullable Direction hitSide, @Nullable DyeColor paint) { Block block = state.getBlock(); if (block instanceof ICustomPaintHandler) { return ((ICustomPaintHandler) block).attemptPaint(world, pos, state, hitPos, hitSide, paint); @@ -87,29 +87,55 @@ public EnumActionResult attemptPaintBlock(World world, BlockPos pos, IBlockState return defaultAttemptPaint(world, pos, state, hitPos, hitSide, paint); } for (ICustomPaintHandler handler : custom) { - EnumActionResult result = handler.attemptPaint(world, pos, state, hitPos, hitSide, paint); - if (result != EnumActionResult.PASS) { + InteractionResult result = handler.attemptPaint(world, pos, state, hitPos, hitSide, paint); + if (result != InteractionResult.PASS) { return result; } } return defaultAttemptPaint(world, pos, state, hitPos, hitSide, paint); } - private EnumActionResult defaultAttemptPaint(World world, BlockPos pos, IBlockState state, Vec3d hitPos, EnumFacing hitSide, @Nullable EnumDyeColor paint) { + private InteractionResult defaultAttemptPaint(Level world, BlockPos pos, BlockState state, Vec3 hitPos, Direction hitSide, @Nullable DyeColor paint) { for (ICustomPaintHandler handler : allHandlers) { - EnumActionResult result = handler.attemptPaint(world, pos, state, hitPos, hitSide, paint); - if (result != EnumActionResult.PASS) { + InteractionResult result = handler.attemptPaint(world, pos, state, hitPos, hitSide, paint); + if (result != InteractionResult.PASS) { return result; } } if (paint == null) { - return EnumActionResult.FAIL; + return InteractionResult.FAIL; } - Block b = state.getBlock(); - if (b.recolorBlock(world, pos, hitSide, paint)) { - return EnumActionResult.SUCCESS; +// Block b = state.getBlock(); +// if (b.recolorBlock(world, pos, hitSide, paint)) + if (recolorBlock(world, pos, hitSide, paint)) { + return InteractionResult.SUCCESS; } else { - return EnumActionResult.FAIL; + return InteractionResult.FAIL; + } + } + + /** + * From 1.12.2 Block + * Common way to recolor a block with an external tool + * + * @param world The world + * @param pos Block position in world + * @param side The side hit with the coloring tool + * @param color The color to change to + * @return If the recoloring was successful + */ + @SuppressWarnings({ "unchecked", "rawtypes" }) + public static boolean recolorBlock(Level world, BlockPos pos, Direction side, DyeColor color) { + BlockState state = world.getBlockState(pos); + for (Property prop : state.getProperties()) { + if (prop.getName().equals("color") && prop.getValueClass() == DyeColor.class) { + DyeColor current = (DyeColor) state.getValue(prop); + if (current != color && prop.getPossibleValues().contains(color)) { + world.setBlock(pos, state.setValue(prop, color), Block.UPDATE_ALL); + return true; + } + } } + return false; } } diff --git a/api/buildcraft/api/blocks/CustomRotationHelper.java b/api/buildcraft/api/blocks/CustomRotationHelper.java index 235c0de..c11e063 100644 --- a/api/buildcraft/api/blocks/CustomRotationHelper.java +++ b/api/buildcraft/api/blocks/CustomRotationHelper.java @@ -1,20 +1,19 @@ package buildcraft.api.blocks; -import java.util.List; -import java.util.Map; - +import buildcraft.api.core.BCDebugging; +import buildcraft.api.core.BCLog; import com.google.common.collect.Lists; import com.google.common.collect.Maps; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraftforge.registries.ForgeRegistries; -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -import buildcraft.api.core.BCDebugging; -import buildcraft.api.core.BCLog; +import java.util.List; +import java.util.Map; public enum CustomRotationHelper { INSTANCE; @@ -26,11 +25,11 @@ public enum CustomRotationHelper { private final Map> handlers = Maps.newIdentityHashMap(); public void registerHandlerForAll(Class blockClass, ICustomRotationHandler handler) { - for (Block block : Block.REGISTRY) { + for (Block block : ForgeRegistries.BLOCKS) { Class foundClass = block.getClass(); if (blockClass.isAssignableFrom(foundClass)) { if (DEBUG) { - BCLog.logger.info("[api.rotation] Found an assignable block " + block.getRegistryName() + " (" + foundClass + ") for " + blockClass); + BCLog.logger.info("[api.rotation] Found an assignable block " + block.builtInRegistryHolder().key().location() + " (" + foundClass + ") for " + blockClass); } registerHandlerInternal(block, handler); } @@ -40,10 +39,10 @@ public void registerHandlerForAll(Class blockClass, ICustomRota public void registerHandler(Block block, ICustomRotationHandler handler) { if (registerHandlerInternal(block, handler)) { if (DEBUG) { - BCLog.logger.info("[api.rotation] Setting a rotation handler for block " + block.getRegistryName()); + BCLog.logger.info("[api.rotation] Setting a rotation handler for block " + block.builtInRegistryHolder().key().location()); } } else if (DEBUG) { - BCLog.logger.info("[api.rotation] Adding another rotation handler for block " + block.getRegistryName()); + BCLog.logger.info("[api.rotation] Adding another rotation handler for block " + block.builtInRegistryHolder().key().location()); } } @@ -59,18 +58,18 @@ private boolean registerHandlerInternal(Block block, ICustomRotationHandler hand } } - public EnumActionResult attemptRotateBlock(World world, BlockPos pos, IBlockState state, EnumFacing sideWrenched) { + public InteractionResult attemptRotateBlock(Level world, BlockPos pos, BlockState state, Direction sideWrenched) { Block block = state.getBlock(); if (block instanceof ICustomRotationHandler) { return ((ICustomRotationHandler) block).attemptRotation(world, pos, state, sideWrenched); } - if (!handlers.containsKey(block)) return EnumActionResult.PASS; + if (!handlers.containsKey(block)) return InteractionResult.PASS; for (ICustomRotationHandler handler : handlers.get(block)) { - EnumActionResult result = handler.attemptRotation(world, pos, state, sideWrenched); - if (result != EnumActionResult.PASS) { + InteractionResult result = handler.attemptRotation(world, pos, state, sideWrenched); + if (result != InteractionResult.PASS) { return result; } } - return EnumActionResult.PASS; + return InteractionResult.PASS; } } diff --git a/api/buildcraft/api/blocks/ICustomPaintHandler.java b/api/buildcraft/api/blocks/ICustomPaintHandler.java index fd79c91..e717ccc 100644 --- a/api/buildcraft/api/blocks/ICustomPaintHandler.java +++ b/api/buildcraft/api/blocks/ICustomPaintHandler.java @@ -1,21 +1,21 @@ package buildcraft.api.blocks; -import javax.annotation.Nullable; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.item.DyeColor; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.Vec3; -import net.minecraft.block.state.IBlockState; -import net.minecraft.item.EnumDyeColor; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; -import net.minecraft.world.World; +import javax.annotation.Nullable; /** Provides a way to paint blocks from any position. You can either implement this on a block, or register an instance * for a block with {@link CustomPaintHelper} */ public interface ICustomPaintHandler { /** Attempts to paint the given block. This can also only paint a specific part of the block (as the hit position is * given). - * + * * @param world The world that the block is contained within. * @param pos The position of the block. * @param state The current state of the block. @@ -27,5 +27,5 @@ public interface ICustomPaintHandler { * @return The result of attempting to paint. SUCCESS means that you changed the block from before to a new value, * FAIL means you COULD have handled the block, but it was already painted to that colour, or PASS if you * have no idea how to handle the block in question. */ - EnumActionResult attemptPaint(World world, BlockPos pos, IBlockState state, Vec3d hitPos, @Nullable EnumFacing hitSide, @Nullable EnumDyeColor paintColour); + InteractionResult attemptPaint(Level world, BlockPos pos, BlockState state, Vec3 hitPos, @Nullable Direction hitSide, @Nullable DyeColor paintColour); } diff --git a/api/buildcraft/api/blocks/ICustomRotationHandler.java b/api/buildcraft/api/blocks/ICustomRotationHandler.java index 9076f8f..8e04d3a 100644 --- a/api/buildcraft/api/blocks/ICustomRotationHandler.java +++ b/api/buildcraft/api/blocks/ICustomRotationHandler.java @@ -1,11 +1,11 @@ package buildcraft.api.blocks; -import net.minecraft.block.state.IBlockState; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.BlockState; public interface ICustomRotationHandler { - EnumActionResult attemptRotation(World world, BlockPos pos, IBlockState state, EnumFacing sideWrenched); + InteractionResult attemptRotation(Level world, BlockPos pos, BlockState state, Direction sideWrenched); } diff --git a/api/buildcraft/api/blocks/ISpring.java b/api/buildcraft/api/blocks/ISpring.java new file mode 100644 index 0000000..27903b6 --- /dev/null +++ b/api/buildcraft/api/blocks/ISpring.java @@ -0,0 +1,7 @@ +package buildcraft.api.blocks; + +import buildcraft.api.enums.EnumSpring; + +public interface ISpring { + EnumSpring getType(); +} diff --git a/api/buildcraft/api/blocks/package-info.java b/api/buildcraft/api/blocks/package-info.java index 47ae1d2..a820019 100644 --- a/api/buildcraft/api/blocks/package-info.java +++ b/api/buildcraft/api/blocks/package-info.java @@ -2,7 +2,5 @@ * * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -@API(apiVersion = "1.0", owner = "buildcraftapi_core", provides = "buildcraftapi_blocks") +//@API(apiVersion = "1.0", owner = "buildcraftapi_core", provides = "buildcraftapi_blocks") package buildcraft.api.blocks; - -import net.minecraftforge.fml.common.API; diff --git a/api/buildcraft/api/boards/RedstoneBoardNBT.java b/api/buildcraft/api/boards/RedstoneBoardNBT.java index 0ced64a..f8e7739 100755 --- a/api/buildcraft/api/boards/RedstoneBoardNBT.java +++ b/api/buildcraft/api/boards/RedstoneBoardNBT.java @@ -4,38 +4,48 @@ * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.boards; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.Tag; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.TooltipFlag; +import net.minecraft.world.level.Level; + +import javax.annotation.Nullable; import java.util.List; import java.util.Random; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - -import net.minecraftforge.common.util.Constants; - public abstract class RedstoneBoardNBT { private static Random rand = new Random(); - public abstract String getID(); + public abstract ResourceLocation getID(); - public abstract void addInformation(ItemStack stack, EntityPlayer player, List list, boolean advanced); + // public abstract void addInformation(ItemStack stack, Player player, List list, boolean advanced); + public abstract void addInformation(ItemStack stack, @Nullable Level world, List list, TooltipFlag flag); - public abstract String getDisplayName(); + // public abstract String getDisplayName(); + public final String getDisplayName() { + return getDisplayNameComponent().getString(); + } - public abstract IRedstoneBoard create(NBTTagCompound nbt, T object); + public abstract Component getDisplayNameComponent(); - public abstract String getItemModelLocation(); + public abstract IRedstoneBoard create(CompoundTag nbt, T object); - public void createBoard(NBTTagCompound nbt) { - nbt.setString("id", getID()); - } + // public abstract String getItemModelLocation(); + public abstract String getBoardTexture(); + +// public void createBoard(CompoundTag nbt) { +// nbt.putString("id", getID().toString()); +// } - public int getParameterNumber(NBTTagCompound nbt) { - if (!nbt.hasKey("parameters")) { + public int getParameterNumber(CompoundTag nbt) { + if (!nbt.contains("parameters")) { return 0; } else { - return nbt.getTagList("parameters", Constants.NBT.TAG_COMPOUND).tagCount(); + return nbt.getList("parameters", Tag.TAG_COMPOUND).size(); } } diff --git a/api/buildcraft/api/boards/RedstoneBoardRegistry.java b/api/buildcraft/api/boards/RedstoneBoardRegistry.java index edfe79c..d923ff6 100755 --- a/api/buildcraft/api/boards/RedstoneBoardRegistry.java +++ b/api/buildcraft/api/boards/RedstoneBoardRegistry.java @@ -4,16 +4,20 @@ * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.boards; -import java.util.Collection; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.Item; +import net.minecraftforge.registries.RegistryObject; -import net.minecraft.nbt.NBTTagCompound; +import java.util.List; +import java.util.Map; public abstract class RedstoneBoardRegistry { public static RedstoneBoardRegistry instance; /** Register a redstone board type. - * + * * @param redstoneBoardNBT The RedstoneBoardNBT instance containing the board information. * @param microJoules MJ price of the board, in micro MJ. */ public abstract void registerBoardType(RedstoneBoardNBT redstoneBoardNBT, long microJoules); @@ -22,11 +26,15 @@ public abstract class RedstoneBoardRegistry { public abstract RedstoneBoardRobotNBT getEmptyRobotBoard(); - public abstract RedstoneBoardNBT getRedstoneBoard(NBTTagCompound nbt); + public abstract RedstoneBoardNBT getRedstoneBoard(CompoundTag nbt); - public abstract RedstoneBoardNBT getRedstoneBoard(String id); + // public abstract RedstoneBoardNBT getRedstoneBoard(String id); + public abstract RedstoneBoardNBT getRedstoneBoard(ResourceLocation id); - public abstract Collection> getAllBoardNBTs(); + // public abstract Collection> getAllBoardNBTs(); + public abstract List> getAllBoardNBTs(); + + public abstract Map, RegistryObject> getBoardNBTItemMap(); public abstract long getPowerCost(RedstoneBoardNBT board); } diff --git a/api/buildcraft/api/boards/RedstoneBoardRobotNBT.java b/api/buildcraft/api/boards/RedstoneBoardRobotNBT.java index 4a4161b..acaa94c 100755 --- a/api/buildcraft/api/boards/RedstoneBoardRobotNBT.java +++ b/api/buildcraft/api/boards/RedstoneBoardRobotNBT.java @@ -4,15 +4,14 @@ * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.boards; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ResourceLocation; - import buildcraft.api.robots.EntityRobotBase; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.resources.ResourceLocation; public abstract class RedstoneBoardRobotNBT extends RedstoneBoardNBT { @Override - public RedstoneBoardRobot create(NBTTagCompound nbt, EntityRobotBase robot) { + public RedstoneBoardRobot create(CompoundTag nbt, EntityRobotBase robot) { return create(robot); } @@ -20,4 +19,10 @@ public RedstoneBoardRobot create(NBTTagCompound nbt, EntityRobotBase robot) { public abstract ResourceLocation getRobotTexture(); + // Calen 1.18.2 + public abstract ResourceLocation getRobotItemTexture(); + + public abstract ResourceLocation getRobotTextureFullLocation(); + + public abstract ResourceLocation getRobotId(); } diff --git a/api/buildcraft/api/boards/package-info.java b/api/buildcraft/api/boards/package-info.java index 69405e4..8ee0580 100644 --- a/api/buildcraft/api/boards/package-info.java +++ b/api/buildcraft/api/boards/package-info.java @@ -2,7 +2,5 @@ * * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -@API(apiVersion = "2.0", owner = "buildcraftapi_core", provides = "buildcraftapi_boards") +//@API(apiVersion = "2.0", owner = "buildcraftapi_core", provides = "buildcraftapi_boards") package buildcraft.api.boards; - -import net.minecraftforge.fml.common.API; diff --git a/api/buildcraft/api/core/AreaProviders.java b/api/buildcraft/api/core/AreaProviders.java index 0ebe02f..e802c4e 100644 --- a/api/buildcraft/api/core/AreaProviders.java +++ b/api/buildcraft/api/core/AreaProviders.java @@ -1,20 +1,20 @@ package buildcraft.api.core; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; + import java.util.ArrayList; import java.util.List; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - public class AreaProviders { public static final List providers = new ArrayList<>(); public interface IAreaProviderGetter { /** @return All of the {@link IAreaProvider}'s that contain the specified block psoition. */ - List getAreaProviders(World world, BlockPos at); + List getAreaProviders(Level world, BlockPos at); } - public static List getAreaProviders(World world, BlockPos at) { + public static List getAreaProviders(Level world, BlockPos at) { List list = new ArrayList<>(); for (IAreaProviderGetter getter : providers) { list.addAll(getter.getAreaProviders(world, at)); diff --git a/api/buildcraft/api/core/BCDebugging.java b/api/buildcraft/api/core/BCDebugging.java index 14e5917..e89af50 100644 --- a/api/buildcraft/api/core/BCDebugging.java +++ b/api/buildcraft/api/core/BCDebugging.java @@ -4,18 +4,12 @@ * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.core; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; + import java.lang.reflect.Method; import java.util.Locale; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.fml.common.LoaderState; -import net.minecraftforge.fml.common.ModContainer; - -import buildcraft.api.BCModules; - /** Provides a way to quickly enable or disable certain debug conditions via VM arguments or whether the client/server * is in a dev environment */ public class BCDebugging { @@ -48,8 +42,8 @@ enum DebugLevel { boolean isDev; try { - Method getTileEntity = World.class.getDeclaredMethod("getTileEntity", BlockPos.class); - BCLog.logger.info("[debugger] Method found: World.getTileEntity = " + getTileEntity); + Method getBlockEntity = Level.class.getDeclaredMethod("getBlockEntity", BlockPos.class); + BCLog.logger.info("[debugger] Method found: Level.getBlockEntity = " + getBlockEntity); isDev = true; } catch (Throwable ignored) { // If it didn't find it then we aren't in a dev environment diff --git a/api/buildcraft/api/core/BCLog.java b/api/buildcraft/api/core/BCLog.java index f745091..7b892f7 100644 --- a/api/buildcraft/api/core/BCLog.java +++ b/api/buildcraft/api/core/BCLog.java @@ -12,7 +12,8 @@ public final class BCLog { public static final Logger logger = LogManager.getLogger("BuildCraft"); /** Deactivate constructor */ - private BCLog() {} + private BCLog() { + } @Deprecated public static void logErrorAPI(String mod, Throwable error, Class classFile) { diff --git a/api/buildcraft/api/core/BuildCraftAPI.java b/api/buildcraft/api/core/BuildCraftAPI.java index f7f24c0..81b7d60 100644 --- a/api/buildcraft/api/core/BuildCraftAPI.java +++ b/api/buildcraft/api/core/BuildCraftAPI.java @@ -1,58 +1,51 @@ /** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ + * BuildCraft is distributed under the terms of the Minecraft Mod Public License 1.0, or MMPL. Please check the contents + * of the license located in http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.api.core; -import java.util.HashMap; -import java.util.Set; - -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; - -import net.minecraft.block.Block; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.fml.common.ModContainer; +import net.minecraft.resources.ResourceLocation; +import net.minecraftforge.fml.ModContainer; +import net.minecraftforge.fml.ModList; +import net.minecraftforge.fml.ModLoadingContext; public final class BuildCraftAPI { public static IFakePlayerProvider fakePlayerProvider; - public static final Set softBlocks = Sets.newHashSet(); - public static final HashMap worldProperties = Maps.newHashMap(); + // public static final Set softBlocks = Sets.newHashSet(); + // public static final HashMap worldProperties = Maps.newHashMap(); /** Deactivate constructor */ - private BuildCraftAPI() {} + private BuildCraftAPI() { + } public static String getVersion() { - ModContainer container = Loader.instance().getIndexedModList().get("buildcraftlib"); + ModContainer container = ModList.get().getModContainerById("buildcraftlib").get(); if (container != null) { - return container.getDisplayVersion(); + return container.getModInfo().getVersion().getQualifier(); } return "UNKNOWN VERSION"; } - public static IWorldProperty getWorldProperty(String name) { - return worldProperties.get(name); - } +// public static IWorldProperty getWorldProperty(String name) { +// return worldProperties.get(name); +// } - public static void registerWorldProperty(String name, IWorldProperty property) { - if (worldProperties.containsKey(name)) { - BCLog.logger.warn("The WorldProperty key '" + name + "' is being overridden with " + property.getClass().getSimpleName() + "!"); - } - worldProperties.put(name, property); - } +// public static void registerWorldProperty(String name, IWorldProperty property) { +// if (worldProperties.containsKey(name)) { +// BCLog.logger.warn("The WorldProperty key '" + name + "' is being overridden with " + property.getClass().getSimpleName() + "!"); +// } +// worldProperties.put(name, property); +// } - public static boolean isSoftBlock(World world, BlockPos pos) { - return worldProperties.get("soft").get(world, pos); - } +// public static boolean isSoftBlock(Level world, BlockPos pos) { +// return worldProperties.get("soft").get(world, pos); +// } public static ResourceLocation nameToResourceLocation(String name) { if (name.indexOf(':') > 0) return new ResourceLocation(name); - ModContainer modContainer = Loader.instance().activeModContainer(); +// ModContainer modContainer = Loader.instance().activeModContainer(); + ModContainer modContainer = ModLoadingContext.get().getActiveContainer(); if (modContainer == null) { throw new IllegalStateException("Illegal recipe name " + name + ". Provide domain id to register it correctly."); } diff --git a/api/buildcraft/api/core/CapabilitiesHelper.java b/api/buildcraft/api/core/CapabilitiesHelper.java index e39a8c4..e947e6f 100644 --- a/api/buildcraft/api/core/CapabilitiesHelper.java +++ b/api/buildcraft/api/core/CapabilitiesHelper.java @@ -1,19 +1,10 @@ package buildcraft.api.core; -import java.lang.reflect.Field; -import java.util.IdentityHashMap; -import java.util.concurrent.Callable; - -import javax.annotation.Nonnull; - -import net.minecraft.nbt.NBTBase; -import net.minecraft.util.EnumFacing; - import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.common.capabilities.Capability.IStorage; -import net.minecraftforge.common.capabilities.CapabilityInject; import net.minecraftforge.common.capabilities.CapabilityManager; +import java.util.concurrent.Callable; + /** Forge has a wonderful system for capabilities, which provides a better way of managing mod compat even if the target * mod isn't loaded. Said system uses ASM data to inject capabilities into every mod, which makes it a matter of * checking a (generic) field at runtime. @@ -38,59 +29,59 @@ public class CapabilitiesHelper { /** Registers a given type with {@link #registerCapability(CheckedStorage, Callable)}, but with a * {@link ThrowingStorage} and a factory that throws an {@link UnsupportedOperationException} instead of creating a * new capability instance. - * + * * @param clazz The type that all instances must derive from. * @return The registered {@link Capability} */ - @Nonnull - public static Capability registerCapability(Class clazz) { - return registerCapability(new ThrowingStorage<>(clazz), () -> { - throw new UnsupportedOperationException("You must create your own instances!"); - }); - } +// @Nonnull +// public static Capability registerCapability(Class clazz) { +// return registerCapability(new ThrowingStorage<>(clazz), () -> { +// throw new UnsupportedOperationException("You must create your own instances!"); +// }); +// } /** Registers a given type with the {@link CapabilityManager}, but also returns the capability instance. - * + * * @param storage The storage for the capability. This must extend {@link CheckedStorage} in order to allow the - * internal mechanisms to ensure that nothing went wrong during our meddling into forge. + * internal mechanisms to ensure that nothing went wrong during our meddling into forge. * @param factory The factory for the capability. * @return The registered {@link Capability} */ - @Nonnull - public static Capability registerCapability(CheckedStorage storage, Callable factory) { - return registerCapInternal(storage, factory); - } +// @Nonnull +// public static Capability registerCapability(CheckedStorage storage, Callable factory) { +// return registerCapInternal(storage, factory); +// } /** A type of {@link IStorage} that contains the class that it would store. Used by the internal mechanisms of * {@link CapabilitiesHelper} to ensure that everything registers properly. A default always-throwing implementation * is {@link ThrowingStorage}. - * + * * @param The type of this storage */ - public static abstract class CheckedStorage implements IStorage { - - public final Class clazz; - - public CheckedStorage(Class clazz) { - this.clazz = clazz; - } - } +// public static abstract class CheckedStorage implements IStorage { +// +// public final Class clazz; +// +// public CheckedStorage(Class clazz) { +// this.clazz = clazz; +// } +// } /** A type of {@link CheckedStorage} that throws an {@link UnsupportedOperationException} from both the read and * write methods. It is designed for {@link Capability Capability's} that must be written and read separately. */ - public static final class ThrowingStorage extends CheckedStorage { - - public ThrowingStorage(Class clazz) { - super(clazz); - } - - @Override - public NBTBase writeNBT(Capability capability, T instance, EnumFacing side) { - throw new UnsupportedOperationException("You must create your own instances!"); - } - - @Override - public void readNBT(Capability capability, T instance, EnumFacing side, NBTBase nbt) { - throw new UnsupportedOperationException("You must create your own instances!"); - } - } +// public static final class ThrowingStorage extends CheckedStorage { +// +// public ThrowingStorage(Class clazz) { +// super(clazz); +// } +// +// @Override +// public NBTBase writeNBT(Capability capability, T instance, EnumFacing side) { +// throw new UnsupportedOperationException("You must create your own instances!"); +// } +// +// @Override +// public void readNBT(Capability capability, T instance, EnumFacing side, NBTBase nbt) { +// throw new UnsupportedOperationException("You must create your own instances!"); +// } +// } // ################ // @@ -98,74 +89,74 @@ public void readNBT(Capability capability, T instance, EnumFacing side, NBTBa // // ################ - private static final IdentityHashMap __FIELD_CAP_MANAGER_PROVIDERS; - - static { - try { - Field fld = CapabilityManager.class.getDeclaredField("providers"); - fld.setAccessible(true); - Object obj = fld.get(CapabilityManager.INSTANCE); - __FIELD_CAP_MANAGER_PROVIDERS = (IdentityHashMap) obj; - if (__FIELD_CAP_MANAGER_PROVIDERS == null) { - throw new Error("Couldn't find providers!"); - } - } catch (ReflectiveOperationException | ClassCastException e) { - throw new Error(e); - } - } - - @Nonnull - private static Capability registerCapInternal(CheckedStorage storage, Callable factory) { - Class clazz = storage.clazz; - - CapabilityManager.INSTANCE.register(clazz, storage, factory); - - String fullName = clazz.getName().intern(); - Object obj = __FIELD_CAP_MANAGER_PROVIDERS.get(fullName); - if (obj == null) { - throw new IllegalStateException("Apparently we didn't register the capability? How?"); - } - if (!(obj instanceof Capability)) { - throw new Error("We must have the wrong map! providers.get(key) returned " + obj.getClass() - + " rather than " + Capability.class); - } - Capability cap = (Capability) obj; - // Ensure that the given cap is actually *our* capability - // compare the given class with the VoidStorage class, as - // Capability doesn't have a way of doing that directly. - IStorage cStorage = cap.getStorage(); - if (!(cStorage instanceof CheckedStorage)) { - throw new IllegalStateException( - "Returned capability storage has a different storage class than expected! " + cStorage.getClass()); - } - CheckedStorage vStorage = (CheckedStorage) cStorage; - if (vStorage.clazz != clazz) { - throw new IllegalStateException( - "Returned capability storage has a different class than expected! " + vStorage.clazz + " vs " + clazz); - } - return (Capability) cap; - } +// private static final IdentityHashMap __FIELD_CAP_MANAGER_PROVIDERS; + +// static { +// try { +// Field fld = CapabilityManager.class.getDeclaredField("providers"); +// fld.setAccessible(true); +// Object obj = fld.get(CapabilityManager.INSTANCE); +// __FIELD_CAP_MANAGER_PROVIDERS = (IdentityHashMap) obj; +// if (__FIELD_CAP_MANAGER_PROVIDERS == null) { +// throw new Error("Couldn't find providers!"); +// } +// } catch (ReflectiveOperationException | ClassCastException e) { +// throw new Error(e); +// } +// } + +// @Nonnull +// private static Capability registerCapInternal(CheckedStorage storage, Callable factory) { +// Class clazz = storage.clazz; +// +// CapabilityManager.INSTANCE.register(clazz, storage, factory); +// +// String fullName = clazz.getName().intern(); +// Object obj = __FIELD_CAP_MANAGER_PROVIDERS.get(fullName); +// if (obj == null) { +// throw new IllegalStateException("Apparently we didn't register the capability? How?"); +// } +// if (!(obj instanceof Capability)) { +// throw new Error("We must have the wrong map! providers.get(key) returned " + obj.getClass() +// + " rather than " + Capability.class); +// } +// Capability cap = (Capability) obj; +// // Ensure that the given cap is actually *our* capability +// // compare the given class with the VoidStorage class, as +// // Capability doesn't have a way of doing that directly. +// IStorage cStorage = cap.getStorage(); +// if (!(cStorage instanceof CheckedStorage)) { +// throw new IllegalStateException( +// "Returned capability storage has a different storage class than expected! " + cStorage.getClass()); +// } +// CheckedStorage vStorage = (CheckedStorage) cStorage; +// if (vStorage.clazz != clazz) { +// throw new IllegalStateException( +// "Returned capability storage has a different class than expected! " + vStorage.clazz + " vs " + clazz); +// } +// return (Capability) cap; +// } /** Prefer {@link #registerCapability(Class)} or other methods over this one: this will be removed at some point in * the future. Most likely before beta. */ - @Nonnull - @Deprecated - public static Capability ensureRegistration(Capability cap, Class clazz) { - if (cap == null) { - throw new Error("Capability registration failed for " + clazz); - } - return cap; - } - - public static class VoidStorage implements Capability.IStorage { - @Override - public NBTBase writeNBT(Capability capability, T instance, EnumFacing side) { - throw new IllegalStateException("You must create your own instances!"); - } - - @Override - public void readNBT(Capability capability, T instance, EnumFacing side, NBTBase nbt) { - throw new IllegalStateException("You must create your own instances!"); - } - } +// @Nonnull +// @Deprecated +// public static Capability ensureRegistration(Capability cap, Class clazz) { +// if (cap == null) { +// throw new Error("Capability registration failed for " + clazz); +// } +// return cap; +// } + +// public static class VoidStorage implements Capability.IStorage { +// @Override +// public NBTBase writeNBT(Capability capability, T instance, EnumFacing side) { +// throw new IllegalStateException("You must create your own instances!"); +// } +// +// @Override +// public void readNBT(Capability capability, T instance, EnumFacing side, NBTBase nbt) { +// throw new IllegalStateException("You must create your own instances!"); +// } +// } } diff --git a/api/buildcraft/api/core/EnumColor.java b/api/buildcraft/api/core/EnumColor.java deleted file mode 100644 index 0288438..0000000 --- a/api/buildcraft/api/core/EnumColor.java +++ /dev/null @@ -1,147 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.core; - -import java.util.Locale; -import java.util.Random; - -import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.util.IStringSerializable; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.text.translation.I18n; - -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -/** Use minecraft's EnumDyeColor in as many places as possible. */ -@Deprecated -public enum EnumColor implements IStringSerializable { - - BLACK, - RED, - GREEN, - BROWN, - BLUE, - PURPLE, - CYAN, - LIGHT_GRAY, - GRAY, - PINK, - LIME, - YELLOW, - LIGHT_BLUE, - MAGENTA, - ORANGE, - WHITE; - - public static final EnumColor[] VALUES = values(); - public static final String[] DYES = { "dyeBlack", "dyeRed", "dyeGreen", "dyeBrown", "dyeBlue", "dyePurple", "dyeCyan", "dyeLightGray", "dyeGray", - "dyePink", "dyeLime", "dyeYellow", "dyeLightBlue", "dyeMagenta", "dyeOrange", "dyeWhite" }; - public static final String[] NAMES = { "Black", "Red", "Green", "Brown", "Blue", "Purple", "Cyan", "LightGray", "Gray", "Pink", "Lime", "Yellow", - "LightBlue", "Magenta", "Orange", "White" }; - public static final int[] DARK_HEX = { 0x2D2D2D, 0xA33835, 0x394C1E, 0x5C3A24, 0x3441A2, 0x843FBF, 0x36809E, 0x888888, 0x444444, 0xE585A0, - 0x3FAA36, 0xCFC231, 0x7F9AD1, 0xFF64FF, 0xFF6A00, 0xFFFFFF }; - public static final int[] LIGHT_HEX = { 0x181414, 0xBE2B27, 0x007F0E, 0x89502D, 0x253193, 0x7e34bf, 0x299799, 0xa0a7a7, 0x7A7A7A, 0xD97199, - 0x39D52E, 0xFFD91C, 0x66AAFF, 0xD943C6, 0xEA7835, 0xe4e4e4 }; - - @SideOnly(Side.CLIENT) - private static ResourceLocation iconSheet; - - @SideOnly(Side.CLIENT) - private static TextureAtlasSprite[] brushSprites; - - public int getDarkHex() { - return DARK_HEX[ordinal()]; - } - - public int getLightHex() { - return LIGHT_HEX[ordinal()]; - } - - public static EnumColor fromId(int id) { - if (id < 0 || id >= VALUES.length) { - return WHITE; - } - return VALUES[id]; - } - - public static EnumColor fromDye(String dyeTag) { - for (int id = 0; id < DYES.length; id++) { - if (DYES[id].equals(dyeTag)) { - return VALUES[id]; - } - } - return null; - } - - public static EnumColor fromName(String name) { - for (int id = 0; id < NAMES.length; id++) { - if (NAMES[id].equals(name)) { - return VALUES[id]; - } - } - return null; - } - - public static EnumColor getRand() { - return VALUES[new Random().nextInt(VALUES.length)]; - } - - public EnumColor getNext() { - EnumColor next = VALUES[(ordinal() + 1) % VALUES.length]; - return next; - } - - public EnumColor getPrevious() { - EnumColor previous = VALUES[(ordinal() + VALUES.length - 1) % VALUES.length]; - return previous; - } - - public EnumColor inverse() { - return EnumColor.VALUES[15 - ordinal()]; - } - - public String getTag() { - return "color." + name().replace("_", ".").toLowerCase(Locale.ENGLISH); - } - - public String getBasicTag() { - return name().replace("_", ".").toLowerCase(Locale.ENGLISH); - } - - @Override - public String getName() { - return NAMES[ordinal()]; - } - - public String getLocalizedName() { - return I18n.translateToLocal(getTag()); - } - - public String getDye() { - return DYES[ordinal()]; - } - - @Override - public String toString() { - String s = name().replace("_", " "); - String[] words = s.split(" "); - StringBuilder b = new StringBuilder(); - for (String word : words) { - b.append(word.charAt(0)).append(word.substring(1).toLowerCase(Locale.ENGLISH)).append(" "); - } - return b.toString().trim(); - } - - @SideOnly(Side.CLIENT) - public static void registerSprites(TextureAtlasSprite[] sprites) { - brushSprites = sprites; - } - - @SideOnly(Side.CLIENT) - public TextureAtlasSprite getSprite() { - return brushSprites[ordinal()]; - } -} diff --git a/api/buildcraft/api/core/EnumPipePart.java b/api/buildcraft/api/core/EnumPipePart.java index 3eb3731..b6e6f6f 100644 --- a/api/buildcraft/api/core/EnumPipePart.java +++ b/api/buildcraft/api/core/EnumPipePart.java @@ -1,23 +1,22 @@ package buildcraft.api.core; +import com.google.common.collect.Maps; +import net.minecraft.core.Direction; +import net.minecraft.nbt.NumericTag; +import net.minecraft.nbt.StringTag; +import net.minecraft.nbt.Tag; +import net.minecraft.util.StringRepresentable; + import java.util.Locale; import java.util.Map; -import com.google.common.collect.Maps; - -import net.minecraft.nbt.NBTBase; -import net.minecraft.nbt.NBTPrimitive; -import net.minecraft.nbt.NBTTagString; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.IStringSerializable; - -public enum EnumPipePart implements IStringSerializable { - DOWN(EnumFacing.DOWN), - UP(EnumFacing.UP), - NORTH(EnumFacing.NORTH), - SOUTH(EnumFacing.SOUTH), - WEST(EnumFacing.WEST), - EAST(EnumFacing.EAST), +public enum EnumPipePart implements StringRepresentable { + DOWN(Direction.DOWN), + UP(Direction.UP), + NORTH(Direction.NORTH), + SOUTH(Direction.SOUTH), + WEST(Direction.WEST), + EAST(Direction.EAST), /** CENTER, UNKNOWN and ALL are all valid uses of this. */ CENTER(null); @@ -25,22 +24,23 @@ public enum EnumPipePart implements IStringSerializable { public static final EnumPipePart[] FACES; public static final EnumPipePart[] HORIZONTALS; - private static final Map facingMap = Maps.newEnumMap(EnumFacing.class); + private static final Map facingMap = Maps.newEnumMap(Direction.class); private static final Map nameMap = Maps.newHashMap(); private static final int MAX_VALUES = values().length; - public final EnumFacing face; + public final Direction face; static { for (EnumPipePart part : values()) { nameMap.put(part.name(), part); if (part.face != null) facingMap.put(part.face, part); } - FACES = fromFacingArray(EnumFacing.VALUES); - HORIZONTALS = fromFacingArray(EnumFacing.HORIZONTALS); + FACES = fromFacingArray(Direction.VALUES); +// HORIZONTALS = fromFacingArray(Direction.HORIZONTALS); + HORIZONTALS = fromFacingArray(Direction.BY_2D_DATA); } - private static EnumPipePart[] fromFacingArray(EnumFacing... faces) { + private static EnumPipePart[] fromFacingArray(Direction... faces) { EnumPipePart[] arr = new EnumPipePart[faces.length]; for (int i = 0; i < faces.length; i++) { arr[i] = fromFacing(faces[i]); @@ -48,11 +48,11 @@ private static EnumPipePart[] fromFacingArray(EnumFacing... faces) { return arr; } - public static int ordinal(EnumFacing face) { + public static int ordinal(Direction face) { return face == null ? 6 : face.ordinal(); } - public static EnumPipePart fromFacing(EnumFacing face) { + public static EnumPipePart fromFacing(Direction face) { if (face == null) { return EnumPipePart.CENTER; } @@ -70,17 +70,17 @@ public static EnumPipePart fromMeta(int meta) { return VALUES[meta]; } - EnumPipePart(EnumFacing face) { + EnumPipePart(Direction face) { this.face = face; } public int getIndex() { if (face == null) return 6; - return face.getIndex(); + return face.get3DDataValue(); } @Override - public String getName() { + public String getSerializedName() { return name().toLowerCase(Locale.ROOT); } @@ -110,16 +110,16 @@ public EnumPipePart opposite() { return fromFacing(face.getOpposite()); } - public static EnumPipePart readFromNBT(NBTBase base) { + public static EnumPipePart readFromNBT(Tag base) { if (base == null) { return CENTER; } - if (base instanceof NBTTagString) { - NBTTagString nbtString = (NBTTagString) base; - String string = nbtString.getString(); + if (base instanceof StringTag) { + StringTag nbtString = (StringTag) base; + String string = nbtString.getAsString(); return nameMap.getOrDefault(string, CENTER); } else { - byte ord = ((NBTPrimitive) base).getByte(); + byte ord = ((NumericTag) base).getAsByte(); if (ord < 0 || ord > 6) { return CENTER; } @@ -127,7 +127,7 @@ public static EnumPipePart readFromNBT(NBTBase base) { } } - public NBTBase writeToNBT() { - return new NBTTagString(name()); + public Tag writeToNBT() { + return StringTag.valueOf(name()); } } diff --git a/api/buildcraft/api/core/EnumWireColour.java b/api/buildcraft/api/core/EnumWireColour.java index b6e1e3d..95249b9 100644 --- a/api/buildcraft/api/core/EnumWireColour.java +++ b/api/buildcraft/api/core/EnumWireColour.java @@ -1,41 +1,42 @@ package buildcraft.api.core; +import net.minecraft.world.item.DyeColor; + import java.util.EnumMap; import java.util.EnumSet; import java.util.Set; -import net.minecraft.item.EnumDyeColor; - -/** A subset of colours from {@link EnumDyeColor} that are suitable for use in LED's or wires (or equivalent). In other +/** A subset of colours from {@link DyeColor} that are suitable for use in LED's or wires (or equivalent). In other * words they must all be uniquely identifiable from both their lit and dark colours, and not look similar to other * colours. */ +@Deprecated(forRemoval = true) public enum EnumWireColour { // We disallow all variants of grey and black, as they don't make much sense relative to LED's. // In theory we could keep black OR dark gey LED's (as they are very distant) but it's simpler not to. - WHITE(EnumDyeColor.WHITE, EnumDyeColor.SILVER, EnumDyeColor.GRAY, EnumDyeColor.BLACK), - ORANGE(EnumDyeColor.ORANGE), + WHITE(DyeColor.WHITE, DyeColor.LIGHT_GRAY, DyeColor.GRAY, DyeColor.BLACK), + ORANGE(DyeColor.ORANGE), // MAGENTA -> PINK - LIGHT_BLUE(EnumDyeColor.LIGHT_BLUE, EnumDyeColor.CYAN), - YELLOW(EnumDyeColor.YELLOW), - LIME(EnumDyeColor.LIME), - PINK(EnumDyeColor.PINK, EnumDyeColor.MAGENTA), + LIGHT_BLUE(DyeColor.LIGHT_BLUE, DyeColor.CYAN), + YELLOW(DyeColor.YELLOW), + LIME(DyeColor.LIME), + PINK(DyeColor.PINK, DyeColor.MAGENTA), // GRAY -> WHITE // SILVER (LIGHT_GRAY) -> WHITE // CYAN -> LIGHT_BLUE - PURPLE(EnumDyeColor.PURPLE), - BLUE(EnumDyeColor.BLUE), - BROWN(EnumDyeColor.BROWN), - GREEN(EnumDyeColor.GREEN), - RED(EnumDyeColor.RED), + PURPLE(DyeColor.PURPLE), + BLUE(DyeColor.BLUE), + BROWN(DyeColor.BROWN), + GREEN(DyeColor.GREEN), + RED(DyeColor.RED), // BLACK -> WHITE ; - private static final EnumMap DYE_TO_WIRE; + private static final EnumMap DYE_TO_WIRE; static { - DYE_TO_WIRE = new EnumMap<>(EnumDyeColor.class); + DYE_TO_WIRE = new EnumMap<>(DyeColor.class); for (EnumWireColour wire : values()) { - for (EnumDyeColor dye : wire.similarBasedColours) { + for (DyeColor dye : wire.similarBasedColours) { EnumWireColour prev = DYE_TO_WIRE.put(dye, wire); if (prev != null) { throw new Error(wire + " attempted to override " + prev + " for the dye " + dye + "!"); @@ -43,7 +44,7 @@ public enum EnumWireColour { } } - for (EnumDyeColor dye : EnumDyeColor.values()) { + for (DyeColor dye : DyeColor.values()) { EnumWireColour wire = DYE_TO_WIRE.get(dye); if (wire == null) { throw new Error(dye + " isn't mapped to a wire colour!"); @@ -52,18 +53,18 @@ public enum EnumWireColour { } /** The primary minecraft colour that this is based on. */ - public final EnumDyeColor primaryIdenticalColour; + public final DyeColor primaryIdenticalColour; /** A set of similar minecraft colours that this single colour is based on. Always includes * {@link #primaryIdenticalColour}. */ - public final Set similarBasedColours; + public final Set similarBasedColours; - private EnumWireColour(EnumDyeColor primary, EnumDyeColor... secondary) { + private EnumWireColour(DyeColor primary, DyeColor... secondary) { this.primaryIdenticalColour = primary; this.similarBasedColours = EnumSet.of(primary, secondary); } - public static EnumWireColour convertToWire(EnumDyeColor dye) { + public static EnumWireColour convertToWire(DyeColor dye) { return DYE_TO_WIRE.get(dye); } } diff --git a/api/buildcraft/api/core/IAreaProvider.java b/api/buildcraft/api/core/IAreaProvider.java index 02bcf0c..d048e79 100644 --- a/api/buildcraft/api/core/IAreaProvider.java +++ b/api/buildcraft/api/core/IAreaProvider.java @@ -4,7 +4,7 @@ * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.core; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; /** To be implemented by TileEntities able to provide a square area on the world, typically BuildCraft markers. */ public interface IAreaProvider { diff --git a/api/buildcraft/api/core/IBlockFilter.java b/api/buildcraft/api/core/IBlockFilter.java new file mode 100644 index 0000000..f7b3e82 --- /dev/null +++ b/api/buildcraft/api/core/IBlockFilter.java @@ -0,0 +1,13 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + *

+ * BuildCraft is distributed under the terms of the Minecraft Mod Public License 1.0, or MMPL. Please check the contents + * of the license located in http://www.mod-buildcraft.com/MMPL-1.0.txt */ +package buildcraft.api.core; + +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; + +// Calen 1.18.2 from 1.8.9 +public interface IBlockFilter { + boolean matches(Level world, BlockPos pos); +} diff --git a/api/buildcraft/api/core/IBox.java b/api/buildcraft/api/core/IBox.java index 6449077..39f1c36 100644 --- a/api/buildcraft/api/core/IBox.java +++ b/api/buildcraft/api/core/IBox.java @@ -4,7 +4,7 @@ * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.core; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; /** A cuboid volume. BuildCraft's default implementation is mutable, so you should not cache instances that you do not * own as-is, without making an immutable copy first. */ @@ -18,6 +18,6 @@ public interface IBox extends IZone { BlockPos max(); default BlockPos size() { - return max().subtract(min()).add(1, 1, 1); + return max().subtract(min()).offset(1, 1, 1); } } diff --git a/api/buildcraft/api/core/IEngineType.java b/api/buildcraft/api/core/IEngineType.java index b871096..ee1ae91 100644 --- a/api/buildcraft/api/core/IEngineType.java +++ b/api/buildcraft/api/core/IEngineType.java @@ -1,5 +1,8 @@ package buildcraft.api.core; +import net.minecraft.resources.ResourceLocation; + public interface IEngineType { - String getItemModelLocation(); + // String getItemModelLocation(); + ResourceLocation getItemModelLocation(); } diff --git a/api/buildcraft/api/core/IEntityFilter.java b/api/buildcraft/api/core/IEntityFilter.java new file mode 100644 index 0000000..0c836de --- /dev/null +++ b/api/buildcraft/api/core/IEntityFilter.java @@ -0,0 +1,13 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + *

+ * BuildCraft is distributed under the terms of the Minecraft Mod Public License 1.0, or MMPL. Please check the contents + * of the license located in http://www.mod-buildcraft.com/MMPL-1.0.txt */ +package buildcraft.api.core; + +import net.minecraft.world.entity.Entity; + +public interface IEntityFilter { + + boolean matches(Entity entity); + +} diff --git a/api/buildcraft/api/core/IFakePlayerProvider.java b/api/buildcraft/api/core/IFakePlayerProvider.java index c8bed73..8defda3 100755 --- a/api/buildcraft/api/core/IFakePlayerProvider.java +++ b/api/buildcraft/api/core/IFakePlayerProvider.java @@ -1,16 +1,12 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - *

- * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. - */ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public License 1.0, or MMPL. Please check the contents + * of the license located in http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.api.core; import com.mojang.authlib.GameProfile; - -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.WorldServer; - +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerLevel; import net.minecraftforge.common.util.FakePlayer; public interface IFakePlayerProvider { @@ -19,7 +15,7 @@ public interface IFakePlayerProvider { * UUID of the real player who created the block or entity that calls this. */ @Deprecated - FakePlayer getBuildCraftPlayer(WorldServer world); + FakePlayer getBuildCraftPlayer(ServerLevel world); /** * @param world @@ -27,7 +23,7 @@ public interface IFakePlayerProvider { * @return A fake player that can be used IN THE CURRENT METHOD CONTEXT ONLY! This will cause problems if this * player is left around as it holds a reference to the world object. */ - FakePlayer getFakePlayer(WorldServer world, GameProfile profile); + FakePlayer getFakePlayer(ServerLevel world, GameProfile profile); /** * @param world @@ -36,5 +32,5 @@ public interface IFakePlayerProvider { * @return A fake player that can be used IN THE CURRENT METHOD CONTEXT ONLY! This will cause problems if this * player is left around as it holds a reference to the world object. */ - FakePlayer getFakePlayer(WorldServer world, GameProfile profile, BlockPos pos); + FakePlayer getFakePlayer(ServerLevel world, GameProfile profile, BlockPos pos); } diff --git a/api/buildcraft/api/core/IFakeWorld.java b/api/buildcraft/api/core/IFakeWorld.java new file mode 100644 index 0000000..4d9c42d --- /dev/null +++ b/api/buildcraft/api/core/IFakeWorld.java @@ -0,0 +1,17 @@ +package buildcraft.api.core; + +import net.minecraft.core.Holder; +import net.minecraft.core.RegistryAccess; +import net.minecraft.resources.ResourceKey; +import net.minecraft.util.profiling.ProfilerFiller; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.dimension.DimensionType; +import net.minecraft.world.level.storage.WritableLevelData; + +import java.util.function.Supplier; + +public abstract class IFakeWorld extends Level { + protected IFakeWorld(WritableLevelData data, ResourceKey dim, RegistryAccess registryAccess, Holder dimensionType, Supplier profiler, boolean pIsClientSide, boolean isDebug, long biomeZoomSeed, int maxChainedNeighborUpdates) { + super(data, dim, registryAccess, dimensionType, profiler, pIsClientSide, isDebug, biomeZoomSeed, maxChainedNeighborUpdates); + } +} diff --git a/api/buildcraft/api/core/IFluidFilter.java b/api/buildcraft/api/core/IFluidFilter.java index 0cd10d6..7774892 100755 --- a/api/buildcraft/api/core/IFluidFilter.java +++ b/api/buildcraft/api/core/IFluidFilter.java @@ -7,6 +7,5 @@ import net.minecraftforge.fluids.FluidStack; public interface IFluidFilter { - boolean matches(FluidStack fluid); } diff --git a/api/buildcraft/api/core/IFluidHandlerAdv.java b/api/buildcraft/api/core/IFluidHandlerAdv.java index aba2d8a..aa8fdd9 100644 --- a/api/buildcraft/api/core/IFluidHandlerAdv.java +++ b/api/buildcraft/api/core/IFluidHandlerAdv.java @@ -1,10 +1,10 @@ package buildcraft.api.core; -import javax.annotation.Nullable; - import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.IFluidHandler; +import javax.annotation.Nullable; + /** A version of {@link IFluidHandler} that can drain a fluid that a fluid filter accepts. */ public interface IFluidHandlerAdv extends IFluidHandler { /** Drains fluid out of internal tanks, distribution is left entirely to the IFluidHandler. @@ -14,5 +14,5 @@ public interface IFluidHandlerAdv extends IFluidHandler { * @param doDrain If false, drain will only be simulated. * @return FluidStack representing the Fluid and amount that was (or would have been, if simulated) drained. */ @Nullable - FluidStack drain(IFluidFilter filter, int maxDrain, boolean doDrain); + FluidStack drain(IFluidFilter filter, int maxDrain, FluidAction doDrain); } diff --git a/api/buildcraft/api/core/IInvSlot.java b/api/buildcraft/api/core/IInvSlot.java index a047a2f..191fd9f 100644 --- a/api/buildcraft/api/core/IInvSlot.java +++ b/api/buildcraft/api/core/IInvSlot.java @@ -4,7 +4,9 @@ * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.core; -import net.minecraft.item.ItemStack; +import net.minecraft.world.item.ItemStack; + +import javax.annotation.Nonnull; public interface IInvSlot { /** Returns the slot number of the underlying Inventory. @@ -18,9 +20,11 @@ public interface IInvSlot { boolean isItemValidForSlot(ItemStack stack); + @Nonnull ItemStack decreaseStackInSlot(int amount); + @Nonnull ItemStack getStackInSlot(); - void setStackInSlot(ItemStack stack); + void setStackInSlot(@Nonnull ItemStack stack); } diff --git a/api/buildcraft/api/core/IPathProvider.java b/api/buildcraft/api/core/IPathProvider.java index f21ef36..bf855a9 100644 --- a/api/buildcraft/api/core/IPathProvider.java +++ b/api/buildcraft/api/core/IPathProvider.java @@ -1,10 +1,9 @@ package buildcraft.api.core; -import java.util.List; - -import net.minecraft.util.math.BlockPos; - import buildcraft.api.items.IMapLocation.MapLocationType; +import net.minecraft.core.BlockPos; + +import java.util.List; /** To be implemented by TileEntities able to provide a path on the world, typically BuildCraft path markers. */ public interface IPathProvider { diff --git a/api/buildcraft/api/core/IStackFilter.java b/api/buildcraft/api/core/IStackFilter.java index 4f450c6..963606b 100644 --- a/api/buildcraft/api/core/IStackFilter.java +++ b/api/buildcraft/api/core/IStackFilter.java @@ -4,17 +4,17 @@ * of the license located in http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.api.core; -import javax.annotation.Nonnull; +import net.minecraft.core.NonNullList; +import net.minecraft.world.item.ItemStack; -import net.minecraft.item.ItemStack; -import net.minecraft.util.NonNullList; +import javax.annotation.Nonnull; /** This interface provides a convenient means of dealing with entire classes of items without having to specify each * item individually. */ public interface IStackFilter { /** Check to see if a given stack matches this filter. - * + * * @param stack The stack to test. stack.isEmpty will always return false. * @return True if it does match, false otherwise. */ boolean matches(@Nonnull ItemStack stack); @@ -24,9 +24,7 @@ default IStackFilter and(IStackFilter filter) { return (stack) -> before.matches(stack) && filter.matches(stack); } - /** - * Returns example stack to match this filter - */ + /** Returns example stack to match this filter */ default NonNullList getExamples() { return NonNullList.withSize(0, ItemStack.EMPTY); } diff --git a/api/buildcraft/api/core/IWorldProperty.java b/api/buildcraft/api/core/IWorldProperty.java index 415dc12..52ee68c 100755 --- a/api/buildcraft/api/core/IWorldProperty.java +++ b/api/buildcraft/api/core/IWorldProperty.java @@ -4,11 +4,11 @@ * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.core; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; public interface IWorldProperty { - boolean get(World world, BlockPos pos); + boolean get(Level world, BlockPos pos); void clear(); } diff --git a/api/buildcraft/api/core/IZone.java b/api/buildcraft/api/core/IZone.java index efc9b16..1214c77 100755 --- a/api/buildcraft/api/core/IZone.java +++ b/api/buildcraft/api/core/IZone.java @@ -4,15 +4,16 @@ * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.core; -import java.util.Random; +import net.minecraft.core.BlockPos; +import net.minecraft.util.RandomSource; +import net.minecraft.world.phys.Vec3; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; +import java.util.Random; /** Defines some volume in the world. This is not guaranteed to be fully connected to itself. */ public interface IZone { /** Returns the smallest possible distance that the pos would have to be changed by in order for - * {@link #contains(Vec3d)} to return true. If the position is already inside then this will return 0 */ + * {@link #contains(Vec3)} to return true. If the position is already inside then this will return 0 */ double distanceTo(BlockPos pos); /** Returns {@link #distanceTo(BlockPos)} but squared. Usually this will be quicker to calculate. */ @@ -20,8 +21,9 @@ public interface IZone { /** Returns true if the point is enclosed by this zone, such that none of the coordinates lie outside the range * specified by this zone. */ - boolean contains(Vec3d point); + boolean contains(Vec3 point); - /** Gets a random position that {@link #contains(Vec3d)} will return true. */ - BlockPos getRandomBlockPos(Random rand); + /** Gets a random position that {@link #contains(Vec3)} will return true. */ + // BlockPos getRandomBlockPos(Random rand); + BlockPos getRandomBlockPos(RandomSource rand); } diff --git a/api/buildcraft/api/core/InvalidInputDataException.java b/api/buildcraft/api/core/InvalidInputDataException.java index 866c36c..6e90933 100644 --- a/api/buildcraft/api/core/InvalidInputDataException.java +++ b/api/buildcraft/api/core/InvalidInputDataException.java @@ -8,9 +8,7 @@ import java.io.IOException; -/** - * Indicates that we failed to load from NBT or some other file. - */ +/** Indicates that we failed to load from NBT or some other file. */ public class InvalidInputDataException extends IOException { public InvalidInputDataException() { } diff --git a/api/buildcraft/api/core/SafeTimeTracker.java b/api/buildcraft/api/core/SafeTimeTracker.java index 30593be..d9596a7 100644 --- a/api/buildcraft/api/core/SafeTimeTracker.java +++ b/api/buildcraft/api/core/SafeTimeTracker.java @@ -4,7 +4,7 @@ * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.core; -import net.minecraft.world.World; +import net.minecraft.world.level.Level; /** Provides a way of tracking time in the world, without requiring manual ticking. */ public class SafeTimeTracker { @@ -34,17 +34,17 @@ public SafeTimeTracker(long delay, long random) { } /** Return true if the internal delay has passed since last time marked was called successfully. */ - public boolean markTimeIfDelay(World world) { + public boolean markTimeIfDelay(Level world) { return markTimeIfDelay(world, internalDelay); } /** Return true if a given delay has passed since last time marked was called successfully. */ - public boolean markTimeIfDelay(World world, long delay) { + public boolean markTimeIfDelay(Level world, long delay) { if (world == null) { return false; } - long currentTime = world.getTotalWorldTime(); + long currentTime = world.getGameTime(); if (currentTime < lastMark) { lastMark = currentTime; @@ -64,7 +64,7 @@ public long durationOfLastDelay() { return duration > 0 ? duration : 0; } - public void markTime(World world) { - lastMark = world.getTotalWorldTime(); + public void markTime(Level world) { + lastMark = world.getGameTime(); } } diff --git a/api/buildcraft/api/core/StackKey.java b/api/buildcraft/api/core/StackKey.java index d8c2c44..03ffd49 100644 --- a/api/buildcraft/api/core/StackKey.java +++ b/api/buildcraft/api/core/StackKey.java @@ -4,11 +4,10 @@ * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.core; -import net.minecraft.block.Block; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - -import net.minecraftforge.fluids.Fluid; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.material.Fluid; import net.minecraftforge.fluids.FluidStack; /** This class is used whenever stacks needs to be stored as keys. */ @@ -29,20 +28,26 @@ public StackKey(ItemStack stack, FluidStack fluidStack) { this.fluidStack = fluidStack; } - public static StackKey stack(Item item, int amount, int damage) { - return new StackKey(new ItemStack(item, amount, damage)); + // public static StackKey stack(Item item, int amount, int damage) + public static StackKey stack(Item item, int amount) { +// return new StackKey(new ItemStack(item, amount, damage)); + return new StackKey(new ItemStack(item, amount)); } - public static StackKey stack(Block block, int amount, int damage) { - return new StackKey(new ItemStack(block, amount, damage)); + // public static StackKey stack(Block block, int amount, int damage) + public static StackKey stack(Block block, int amount) { +// return new StackKey(new ItemStack(block, amount, damage)); + return new StackKey(new ItemStack(block, amount)); } public static StackKey stack(Item item) { - return new StackKey(new ItemStack(item, 1, 0)); +// return new StackKey(new ItemStack(item, 1, 0)); + return new StackKey(new ItemStack(item, 1)); } public static StackKey stack(Block block) { - return new StackKey(new ItemStack(block, 1, 0)); +// return new StackKey(new ItemStack(block, 1, 0)); + return new StackKey(new ItemStack(block, 1)); } public static StackKey stack(ItemStack itemStack) { @@ -74,13 +79,17 @@ public boolean equals(Object o) { return false; } if (stack != null) { - if (stack.getItem() != k.stack.getItem() || stack.getHasSubtypes() && stack.getItemDamage() != k.stack.getItemDamage() || !objectsEqual( - stack.getTagCompound(), k.stack.getTagCompound())) { + if ( + stack.getItem() != k.stack.getItem() +// || stack.getHasSubtypes() + && stack.getDamageValue() != k.stack.getDamageValue() + || !objectsEqual(stack.getTag(), k.stack.getTag()) + ) { return false; } } if (fluidStack != null) { - if (!fluidStack.isFluidEqual(k.fluidStack) || fluidStack.amount != k.fluidStack.amount) { + if (!fluidStack.isFluidEqual(k.fluidStack) || fluidStack.getAmount() != k.fluidStack.getAmount()) { return false; } } @@ -92,14 +101,15 @@ public int hashCode() { int result = 7; if (stack != null) { result = 31 * result + stack.getItem().hashCode(); - result = 31 * result + stack.getItemDamage(); - result = 31 * result + objectHashCode(stack.getTagCompound()); + result = 31 * result + stack.getDamageValue(); + result = 31 * result + objectHashCode(stack.getTag()); } result = 31 * result + 7; if (fluidStack != null) { - result = 31 * result + fluidStack.getFluid().getName().hashCode(); - result = 31 * result + fluidStack.amount; - result = 31 * result + objectHashCode(fluidStack.tag); +// result = 31 * result + fluidStack.getFluid().getName().hashCode(); + result = 31 * result + fluidStack.getFluid().builtInRegistryHolder().key().location().hashCode(); + result = 31 * result + fluidStack.getAmount(); + result = 31 * result + objectHashCode(fluidStack.getTag()); } return result; } diff --git a/api/buildcraft/api/core/package-info.java b/api/buildcraft/api/core/package-info.java index 223c751..1f2a297 100644 --- a/api/buildcraft/api/core/package-info.java +++ b/api/buildcraft/api/core/package-info.java @@ -2,7 +2,5 @@ * * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -@API(apiVersion = "2.2", owner = "buildcraftlib", provides = "buildcraftapi_core") +//@API(apiVersion = "2.2", owner = "buildcraftlib", provides = "buildcraftapi_core") package buildcraft.api.core; - -import net.minecraftforge.fml.common.API; diff --git a/api/buildcraft/api/crops/CropManager.java b/api/buildcraft/api/crops/CropManager.java index 68a4302..8429dbe 100644 --- a/api/buildcraft/api/crops/CropManager.java +++ b/api/buildcraft/api/crops/CropManager.java @@ -1,17 +1,23 @@ package buildcraft.api.crops; +import net.minecraft.core.BlockPos; +import net.minecraft.core.NonNullList; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.block.state.BlockState; + import java.util.ArrayList; import java.util.List; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.NonNullList; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; - public final class CropManager { + public enum HarvestResult { + SUCCESS, + FAIL, + PROGRESS; + } + private static List handlers = new ArrayList<>(); private static ICropHandler defaultHandler; @@ -40,7 +46,7 @@ public static boolean isSeed(ItemStack stack) { return defaultHandler.isSeed(stack); } - public static boolean canSustainPlant(World world, ItemStack seed, BlockPos pos) { + public static boolean canSustainPlant(Level world, ItemStack seed, BlockPos pos) { for (ICropHandler cropHandler : handlers) { if (cropHandler.isSeed(seed) && cropHandler.canSustainPlant(world, seed, pos)) { return true; @@ -51,8 +57,8 @@ public static boolean canSustainPlant(World world, ItemStack seed, BlockPos pos) /** Attempts to plant the crop given by the seed into the world. Also checks to make sure that * {@link ICropHandler#isSeed(ItemStack)} is true, and - * {@link ICropHandler#canSustainPlant(World, ItemStack, BlockPos)} is true for the position. */ - public static boolean plantCrop(World world, EntityPlayer player, ItemStack seed, BlockPos pos) { + * {@link ICropHandler#canSustainPlant(Level, ItemStack, BlockPos)} is true for the position. */ + public static boolean plantCrop(Level world, Player player, ItemStack seed, BlockPos pos) { for (ICropHandler cropHandler : handlers) { if (cropHandler.isSeed(seed) && cropHandler.canSustainPlant(world, seed, pos) && cropHandler.plantCrop(world, player, seed, pos)) { return true; @@ -64,7 +70,7 @@ public static boolean plantCrop(World world, EntityPlayer player, ItemStack seed return false; } - public static boolean isMature(IBlockAccess blockAccess, IBlockState state, BlockPos pos) { + public static boolean isMature(LevelAccessor blockAccess, BlockState state, BlockPos pos) { for (ICropHandler cropHandler : handlers) { if (cropHandler.isMature(blockAccess, state, pos)) { return true; @@ -73,14 +79,15 @@ public static boolean isMature(IBlockAccess blockAccess, IBlockState state, Bloc return defaultHandler.isMature(blockAccess, state, pos); } - public static boolean harvestCrop(World world, BlockPos pos, NonNullList drops) { - IBlockState state = world.getBlockState(pos); + // public static boolean harvestCrop(Level world, BlockPos pos, NonNullList drops) + public static HarvestResult harvestCrop(Level world, BlockPos pos, ItemStack tool, NonNullList drops) { + BlockState state = world.getBlockState(pos); for (ICropHandler cropHandler : handlers) { if (cropHandler.isMature(world, state, pos)) { - return cropHandler.harvestCrop(world, pos, drops); + return cropHandler.harvestCrop(world, pos, tool, drops); } } - return defaultHandler.isMature(world, state, pos) && defaultHandler.harvestCrop(world, pos, drops); + // return defaultHandler.isMature(world, state, pos) && defaultHandler.harvestCrop(world, pos, drops); + return defaultHandler.isMature(world, state, pos) ? defaultHandler.harvestCrop(world, pos, tool, drops) : HarvestResult.FAIL; } - } diff --git a/api/buildcraft/api/crops/ICropHandler.java b/api/buildcraft/api/crops/ICropHandler.java index 845108f..701abf8 100644 --- a/api/buildcraft/api/crops/ICropHandler.java +++ b/api/buildcraft/api/crops/ICropHandler.java @@ -1,12 +1,14 @@ package buildcraft.api.crops; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.NonNullList; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; +import net.minecraft.core.BlockPos; +import net.minecraft.core.NonNullList; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.block.state.BlockState; + +import javax.annotation.Nonnull; public interface ICropHandler { @@ -23,7 +25,7 @@ public interface ICropHandler { * @param seed * @param pos * @return true if the item can be planted at pos. */ - boolean canSustainPlant(World world, ItemStack seed, BlockPos pos); + boolean canSustainPlant(Level world, ItemStack seed, BlockPos pos); /** Plant the item in the block. You can assume plantCrop() will only be called if canSustainPlant() returned true. * @@ -32,7 +34,7 @@ public interface ICropHandler { * @param seed * @param pos * @return true if the item was planted at pos. */ - boolean plantCrop(World world, EntityPlayer player, ItemStack seed, BlockPos pos); + boolean plantCrop(Level world, Player player, ItemStack seed, BlockPos pos); /** Check if a crop is mature and can be harvested. * @@ -40,14 +42,16 @@ public interface ICropHandler { * @param state * @param pos * @return true if the block at pos is mature and can be harvested. */ - boolean isMature(IBlockAccess blockAccess, IBlockState state, BlockPos pos); + boolean isMature(LevelAccessor blockAccess, BlockState state, BlockPos pos); /** Harvest the crop. You can assume harvestCrop() will only be called if isMature() returned true. * * @param world * @param pos + * @param tool * @param drops a list to return the harvest's drops. * @return true if the block was successfully harvested. */ - boolean harvestCrop(World world, BlockPos pos, NonNullList drops); + // boolean harvestCrop(Level world, BlockPos pos, NonNullList drops); + CropManager.HarvestResult harvestCrop(Level world, BlockPos pos, @Nonnull ItemStack tool, NonNullList drops); } diff --git a/api/buildcraft/api/crops/package-info.java b/api/buildcraft/api/crops/package-info.java index fcf92d8..b91544f 100644 --- a/api/buildcraft/api/crops/package-info.java +++ b/api/buildcraft/api/crops/package-info.java @@ -2,7 +2,5 @@ * * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -@API(apiVersion = "1.1", owner = "buildcraftapi_core", provides = "buildcraftapi_crops") +//@API(apiVersion = "1.1", owner = "buildcraftapi_core", provides = "buildcraftapi_crops") package buildcraft.api.crops; - -import net.minecraftforge.fml.common.API; diff --git a/api/buildcraft/api/data/NbtSquishConstants.java b/api/buildcraft/api/data/NbtSquishConstants.java index 6622ace..2715501 100644 --- a/api/buildcraft/api/data/NbtSquishConstants.java +++ b/api/buildcraft/api/data/NbtSquishConstants.java @@ -1,15 +1,18 @@ package buildcraft.api.data; -import java.util.zip.GZIPInputStream; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtAccounter; +import net.minecraft.nbt.NbtIo; -import net.minecraft.nbt.CompressedStreamTools; -import net.minecraft.nbt.NBTTagCompound; +import java.io.DataInput; +import java.io.DataOutput; +import java.util.zip.GZIPInputStream; public class NbtSquishConstants { /** Default written NBT Tag type- this is provided by - * {@link CompressedStreamTools#write(NBTTagCompound, java.io.DataOutput)} and - * {@link CompressedStreamTools#read(java.io.DataInput, net.minecraft.nbt.NBTSizeTracker)}. - * + * {@link NbtIo#write(CompoundTag, DataOutput)} and + * {@link NbtIo#read(DataInput, NbtAccounter)}. + * * Generally more suited to smaller NBT tags, and it writes fairly quickly. Can quickly use up a lot of space for * larger/more complex tags so it is recommended that you also pass it through a GZIP compressor to take up a much * smaller space. */ diff --git a/api/buildcraft/api/enums/EnumDecoratedBlock.java b/api/buildcraft/api/enums/EnumDecoratedBlock.java index 0a6b53f..5762d7c 100644 --- a/api/buildcraft/api/enums/EnumDecoratedBlock.java +++ b/api/buildcraft/api/enums/EnumDecoratedBlock.java @@ -1,10 +1,10 @@ package buildcraft.api.enums; -import java.util.Locale; +import net.minecraft.util.StringRepresentable; -import net.minecraft.util.IStringSerializable; +import java.util.Locale; -public enum EnumDecoratedBlock implements IStringSerializable { +public enum EnumDecoratedBlock implements StringRepresentable { DESTROY(0), BLUEPRINT(10), TEMPLATE(10), @@ -21,7 +21,7 @@ public enum EnumDecoratedBlock implements IStringSerializable { } @Override - public String getName() { + public String getSerializedName() { return name().toLowerCase(Locale.ROOT); } diff --git a/api/buildcraft/api/enums/EnumEngineType.java b/api/buildcraft/api/enums/EnumEngineType.java index 38cdc62..b3aa418 100644 --- a/api/buildcraft/api/enums/EnumEngineType.java +++ b/api/buildcraft/api/enums/EnumEngineType.java @@ -1,39 +1,45 @@ package buildcraft.api.enums; -import net.minecraft.util.IStringSerializable; - import buildcraft.api.core.IEngineType; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.StringRepresentable; -public enum EnumEngineType implements IStringSerializable, IEngineType { +public enum EnumEngineType implements StringRepresentable, IEngineType { WOOD("core", "wood"), - STONE("energy", "stone"), - IRON("energy", "iron"), - CREATIVE("energy", "creative"); + STONE("core", "stone"), + IRON("core", "iron"), + CREATIVE("core", "creative"), + RF("core", "rf"), + ; - public final String unlocalizedTag; - public final String resourceLocation; + // public final String unlocalizedTag; + private final String unlocalizedTag; + // public final String resourceLocation; + public final ResourceLocation resourceLocation; public static final EnumEngineType[] VALUES = values(); EnumEngineType(String mod, String loc) { unlocalizedTag = loc; - resourceLocation = "buildcraft" + mod + ":blocks/engine/inv/" + loc; + // resourceLocation = "buildcraft" + mod + ":blocks/engine/inv/" + loc; + resourceLocation = new ResourceLocation("buildcraft" + mod, "engine_" + loc); } @Override - public String getItemModelLocation() { + // public String getItemModelLocation() + public ResourceLocation getItemModelLocation() { return resourceLocation; } @Override - public String getName() { + public String getSerializedName() { return unlocalizedTag; } - public static EnumEngineType fromMeta(int meta) { - if (meta < 0 || meta >= VALUES.length) { - meta = 0; - } - return VALUES[meta]; - } +// public static EnumEngineType fromMeta(int meta) { +// if (meta < 0 || meta >= VALUES.length) { +// meta = 0; +// } +// return VALUES[meta]; +// } } diff --git a/api/buildcraft/api/enums/EnumLaserTableType.java b/api/buildcraft/api/enums/EnumLaserTableType.java index dbf99a5..7645a34 100644 --- a/api/buildcraft/api/enums/EnumLaserTableType.java +++ b/api/buildcraft/api/enums/EnumLaserTableType.java @@ -1,8 +1,8 @@ package buildcraft.api.enums; -import net.minecraft.util.IStringSerializable; +import net.minecraft.util.StringRepresentable; -public enum EnumLaserTableType implements IStringSerializable { +public enum EnumLaserTableType implements StringRepresentable { ASSEMBLY_TABLE, ADVANCED_CRAFTING_TABLE, INTEGRATION_TABLE, @@ -10,7 +10,7 @@ public enum EnumLaserTableType implements IStringSerializable { PROGRAMMING_TABLE; @Override - public String getName() { + public String getSerializedName() { return name(); } } diff --git a/api/buildcraft/api/enums/EnumMachineState.java b/api/buildcraft/api/enums/EnumMachineState.java index 7b7caf7..a10dd85 100644 --- a/api/buildcraft/api/enums/EnumMachineState.java +++ b/api/buildcraft/api/enums/EnumMachineState.java @@ -1,21 +1,20 @@ package buildcraft.api.enums; -import net.minecraft.block.state.IBlockState; -import net.minecraft.util.IStringSerializable; - import buildcraft.api.properties.BuildCraftProperties; +import net.minecraft.util.StringRepresentable; +import net.minecraft.world.level.block.state.BlockState; -public enum EnumMachineState implements IStringSerializable { +public enum EnumMachineState implements StringRepresentable { OFF, ON, DONE; - public static EnumMachineState getType(IBlockState state) { + public static EnumMachineState getType(BlockState state) { return state.getValue(BuildCraftProperties.MACHINE_STATE); } @Override - public String getName() { + public String getSerializedName() { return name(); } } diff --git a/api/buildcraft/api/enums/EnumOptionalSnapshotType.java b/api/buildcraft/api/enums/EnumOptionalSnapshotType.java index cfd413d..1cd0dc4 100644 --- a/api/buildcraft/api/enums/EnumOptionalSnapshotType.java +++ b/api/buildcraft/api/enums/EnumOptionalSnapshotType.java @@ -1,14 +1,14 @@ package buildcraft.api.enums; -import java.util.Locale; +import net.minecraft.util.StringRepresentable; -import net.minecraft.util.IStringSerializable; +import java.util.Locale; /** * Version of {@link EnumSnapshotType} with {@link EnumOptionalSnapshotType#NONE} value. * Shouldn't be used where it's possible to use {@link EnumSnapshotType}. */ -public enum EnumOptionalSnapshotType implements IStringSerializable { +public enum EnumOptionalSnapshotType implements StringRepresentable { NONE(null), TEMPLATE(EnumSnapshotType.TEMPLATE), BLUEPRINT(EnumSnapshotType.BLUEPRINT); @@ -34,7 +34,7 @@ public static EnumOptionalSnapshotType fromNullable(EnumSnapshotType type) { } @Override - public String getName() { + public String getSerializedName() { return name().toLowerCase(Locale.ROOT); } } diff --git a/api/buildcraft/api/enums/EnumPowerStage.java b/api/buildcraft/api/enums/EnumPowerStage.java index 0a88bae..75f914c 100644 --- a/api/buildcraft/api/enums/EnumPowerStage.java +++ b/api/buildcraft/api/enums/EnumPowerStage.java @@ -1,10 +1,10 @@ package buildcraft.api.enums; -import java.util.Locale; +import net.minecraft.util.StringRepresentable; -import net.minecraft.util.IStringSerializable; +import java.util.Locale; -public enum EnumPowerStage implements IStringSerializable { +public enum EnumPowerStage implements StringRepresentable { BLUE, GREEN, YELLOW, @@ -21,7 +21,7 @@ public String getModelName() { } @Override - public String getName() { + public String getSerializedName() { return getModelName(); } } diff --git a/api/buildcraft/api/enums/EnumRedstoneChipset.java b/api/buildcraft/api/enums/EnumRedstoneChipset.java index 90d7cc4..1cebdfa 100644 --- a/api/buildcraft/api/enums/EnumRedstoneChipset.java +++ b/api/buildcraft/api/enums/EnumRedstoneChipset.java @@ -1,14 +1,15 @@ package buildcraft.api.enums; -import java.util.Locale; - -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IStringSerializable; - import buildcraft.api.BCItems; +import buildcraft.api.items.IChipset; +import net.minecraft.util.StringRepresentable; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; -public enum EnumRedstoneChipset implements IStringSerializable { +import java.util.Locale; + +// public enum EnumRedstoneChipset implements IStringSerializable +public enum EnumRedstoneChipset implements StringRepresentable { RED, IRON, GOLD, @@ -18,12 +19,18 @@ public enum EnumRedstoneChipset implements IStringSerializable { private final String name = name().toLowerCase(Locale.ROOT); public ItemStack getStack(int stackSize) { - Item chipset = BCItems.Silicon.REDSTONE_CHIPSET; + Item chipset = switch (this) { + case RED -> BCItems.Silicon.CHIPSET_REDSTONE; + case IRON -> BCItems.Silicon.CHIPSET_IRON; + case GOLD -> BCItems.Silicon.CHIPSET_GOLD; + case QUARTZ -> BCItems.Silicon.CHIPSET_QUARTZ; + case DIAMOND -> BCItems.Silicon.CHIPSET_DIAMOND; + }; if (chipset == null) { return ItemStack.EMPTY; + } else { + return new ItemStack(chipset, stackSize); } - - return new ItemStack(chipset, stackSize, ordinal()); } public ItemStack getStack() { @@ -31,10 +38,12 @@ public ItemStack getStack() { } public static EnumRedstoneChipset fromStack(ItemStack stack) { - if (stack == null) { +// if (stack == null) + if (stack == null || !(stack.getItem() instanceof IChipset)) { return RED; } - return fromOrdinal(stack.getMetadata()); +// return fromOrdinal(stack.getMetadata()); + return ((IChipset) stack.getItem()).getType(); } public static EnumRedstoneChipset fromOrdinal(int ordinal) { @@ -45,7 +54,8 @@ public static EnumRedstoneChipset fromOrdinal(int ordinal) { } @Override - public String getName() { +// public String getName() + public String getSerializedName() { return name; } } diff --git a/api/buildcraft/api/enums/EnumSpring.java b/api/buildcraft/api/enums/EnumSpring.java index 21e4cf2..7c6bcaa 100644 --- a/api/buildcraft/api/enums/EnumSpring.java +++ b/api/buildcraft/api/enums/EnumSpring.java @@ -1,40 +1,46 @@ package buildcraft.api.enums; -import java.util.Locale; -import java.util.function.Supplier; - -import net.minecraft.block.state.IBlockState; -import net.minecraft.init.Blocks; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.IStringSerializable; +import buildcraft.api.blocks.ISpring; +import net.minecraft.core.BlockPos; +import net.minecraft.util.StringRepresentable; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.state.BlockState; -import buildcraft.api.properties.BuildCraftProperties; +import java.util.Locale; +import java.util.function.BiFunction; -public enum EnumSpring implements IStringSerializable { - WATER(5, -1, Blocks.WATER.getDefaultState()), +public enum EnumSpring implements StringRepresentable { + WATER(5, -1, Blocks.WATER.defaultBlockState()), OIL(6000, 8, null); // Set in BuildCraftEnergy public static final EnumSpring[] VALUES = values(); public final int tickRate, chance; - public IBlockState liquidBlock; + public BlockState liquidBlock; public boolean canGen = true; - public Supplier tileConstructor; + // public Supplier tileConstructor; + public BiFunction tileConstructor; private final String lowerCaseName = name().toLowerCase(Locale.ROOT); - EnumSpring(int tickRate, int chance, IBlockState liquidBlock) { + EnumSpring(int tickRate, int chance, BlockState liquidBlock) { this.tickRate = tickRate; this.chance = chance; this.liquidBlock = liquidBlock; } - public static EnumSpring fromState(IBlockState state) { - return state.getValue(BuildCraftProperties.SPRING_TYPE); + public static EnumSpring fromState(BlockState state) { +// return state.getValue(BuildCraftProperties.SPRING_TYPE); + if (state.getBlock() instanceof ISpring spring) { + return spring.getType(); + } else { + return null; + } } @Override - public String getName() { + public String getSerializedName() { return lowerCaseName; } } diff --git a/api/buildcraft/api/enums/package-info.java b/api/buildcraft/api/enums/package-info.java index ab21992..49f7dd0 100644 --- a/api/buildcraft/api/enums/package-info.java +++ b/api/buildcraft/api/enums/package-info.java @@ -2,7 +2,5 @@ * * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -@API(apiVersion = "1.0", owner = "buildcraftapi_core", provides = "buildcraftapi_enums") +//@API(apiVersion = "1.0", owner = "buildcraftapi_core", provides = "buildcraftapi_enums") package buildcraft.api.enums; - -import net.minecraftforge.fml.common.API; diff --git a/api/buildcraft/api/events/BlockInteractionEvent.java b/api/buildcraft/api/events/BlockInteractionEvent.java index 4a4d8b7..8a1bb8a 100644 --- a/api/buildcraft/api/events/BlockInteractionEvent.java +++ b/api/buildcraft/api/events/BlockInteractionEvent.java @@ -4,18 +4,17 @@ * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.events; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.player.EntityPlayer; - -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; @Cancelable public class BlockInteractionEvent extends Event { - public final EntityPlayer player; - public final IBlockState state; + public final Player player; + public final BlockState state; - public BlockInteractionEvent(EntityPlayer player, IBlockState state) { + public BlockInteractionEvent(Player player, BlockState state) { this.player = player; this.state = state; } diff --git a/api/buildcraft/api/events/BlockPlacedDownEvent.java b/api/buildcraft/api/events/BlockPlacedDownEvent.java index 22a8a74..71302e5 100644 --- a/api/buildcraft/api/events/BlockPlacedDownEvent.java +++ b/api/buildcraft/api/events/BlockPlacedDownEvent.java @@ -4,20 +4,19 @@ * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.events; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.math.BlockPos; - -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; @Cancelable public class BlockPlacedDownEvent extends Event { - public final EntityPlayer player; - public final IBlockState state; + public final Player player; + public final BlockState state; public final BlockPos pos; - public BlockPlacedDownEvent(EntityPlayer player, BlockPos pos, IBlockState state) { + public BlockPlacedDownEvent(Player player, BlockPos pos, BlockState state) { this.player = player; this.state = state; this.pos = pos; diff --git a/api/buildcraft/api/events/PipePlacedEvent.java b/api/buildcraft/api/events/PipePlacedEvent.java index 3664a57..40163ec 100644 --- a/api/buildcraft/api/events/PipePlacedEvent.java +++ b/api/buildcraft/api/events/PipePlacedEvent.java @@ -4,18 +4,17 @@ * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.events; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.util.math.BlockPos; - -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.Item; +import net.minecraftforge.eventbus.api.Event; public class PipePlacedEvent extends Event { - public EntityPlayer player; + public Player player; public Item pipeType; public BlockPos pos; - public PipePlacedEvent(EntityPlayer player, Item pipeType, BlockPos pos) { + public PipePlacedEvent(Player player, Item pipeType, BlockPos pos) { this.player = player; this.pipeType = pipeType; this.pos = pos; diff --git a/api/buildcraft/api/events/RobotEvent.java b/api/buildcraft/api/events/RobotEvent.java index 9b12b64..7c01008 100644 --- a/api/buildcraft/api/events/RobotEvent.java +++ b/api/buildcraft/api/events/RobotEvent.java @@ -4,13 +4,11 @@ * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.events; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; - -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; - import buildcraft.api.robots.EntityRobotBase; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; public abstract class RobotEvent extends Event { public final EntityRobotBase robot; @@ -21,9 +19,9 @@ public RobotEvent(EntityRobotBase robot) { @Cancelable public static class Place extends RobotEvent { - public final EntityPlayer player; + public final Player player; - public Place(EntityRobotBase robot, EntityPlayer player) { + public Place(EntityRobotBase robot, Player player) { super(robot); this.player = player; } @@ -31,10 +29,10 @@ public Place(EntityRobotBase robot, EntityPlayer player) { @Cancelable public static class Interact extends RobotEvent { - public final EntityPlayer player; + public final Player player; public final ItemStack item; - public Interact(EntityRobotBase robot, EntityPlayer player, ItemStack item) { + public Interact(EntityRobotBase robot, Player player, ItemStack item) { super(robot); this.player = player; this.item = item; @@ -43,9 +41,9 @@ public Interact(EntityRobotBase robot, EntityPlayer player, ItemStack item) { @Cancelable public static class Dismantle extends RobotEvent { - public final EntityPlayer player; + public final Player player; - public Dismantle(EntityRobotBase robot, EntityPlayer player) { + public Dismantle(EntityRobotBase robot, Player player) { super(robot); this.player = player; } diff --git a/api/buildcraft/api/events/RobotPlacementEvent.java b/api/buildcraft/api/events/RobotPlacementEvent.java index b0abc44..6c057f4 100644 --- a/api/buildcraft/api/events/RobotPlacementEvent.java +++ b/api/buildcraft/api/events/RobotPlacementEvent.java @@ -4,19 +4,17 @@ * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.events; -import net.minecraft.entity.player.EntityPlayer; - -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraft.world.entity.player.Player; +import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; @Cancelable public class RobotPlacementEvent extends Event { - public EntityPlayer player; + public Player player; public String robotProgram; - public RobotPlacementEvent(EntityPlayer player, String robotProgram) { + public RobotPlacementEvent(Player player, String robotProgram) { this.player = player; this.robotProgram = robotProgram; } - } diff --git a/api/buildcraft/api/events/package-info.java b/api/buildcraft/api/events/package-info.java index 46ac77c..dbbc4cc 100644 --- a/api/buildcraft/api/events/package-info.java +++ b/api/buildcraft/api/events/package-info.java @@ -2,7 +2,5 @@ * * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -@API(apiVersion = "2.0", owner = "buildcraftapi_core", provides = "buildcraftapi_events") +//@API(apiVersion = "2.0", owner = "buildcraftapi_core", provides = "buildcraftapi_events") package buildcraft.api.events; - -import net.minecraftforge.fml.common.API; diff --git a/api/buildcraft/api/facades/FacadeAPI.java b/api/buildcraft/api/facades/FacadeAPI.java index 1f3e2b9..68b9c63 100644 --- a/api/buildcraft/api/facades/FacadeAPI.java +++ b/api/buildcraft/api/facades/FacadeAPI.java @@ -1,11 +1,13 @@ package buildcraft.api.facades; -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - -import net.minecraftforge.fml.common.event.FMLInterModComms; +import buildcraft.api.imc.BcImcMessage; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraftforge.fml.InterModComms; +import net.minecraftforge.registries.RegistryObject; public final class FacadeAPI { public static final String IMC_MOD_TARGET = "buildcraftsilicon"; @@ -15,7 +17,8 @@ public final class FacadeAPI { public static final String NBT_CUSTOM_BLOCK_META = "block_meta"; public static final String NBT_CUSTOM_ITEM_STACK = "item_stack"; - public static IFacadeItem facadeItem; + // public static IFacadeItem facadeItem; + public static RegistryObject facadeItem; public static IFacadeRegistry registry; private FacadeAPI() { @@ -23,19 +26,22 @@ private FacadeAPI() { } public static void disableBlock(Block block) { - FMLInterModComms.sendMessage(IMC_MOD_TARGET, IMC_FACADE_DISABLE, block.getRegistryName()); +// FMLInterModComms.sendMessage(IMC_MOD_TARGET, IMC_FACADE_DISABLE, block.getRegistryName()); + InterModComms.sendTo(IMC_MOD_TARGET, IMC_FACADE_DISABLE, () -> new BcImcMessage(block.builtInRegistryHolder().key().location())); } - public static void mapStateToStack(IBlockState state, ItemStack stack) { - NBTTagCompound nbt = new NBTTagCompound(); - nbt.setString(NBT_CUSTOM_BLOCK_REG_KEY, state.getBlock().getRegistryName().toString()); - nbt.setInteger(NBT_CUSTOM_BLOCK_META, state.getBlock().getMetaFromState(state)); - nbt.setTag(NBT_CUSTOM_ITEM_STACK, stack.serializeNBT()); - FMLInterModComms.sendMessage(IMC_MOD_TARGET, IMC_FACADE_CUSTOM, nbt); + public static void mapStateToStack(BlockState state, ItemStack stack) { + CompoundTag nbt = new CompoundTag(); + nbt.putString(NBT_CUSTOM_BLOCK_REG_KEY, state.getBlock().builtInRegistryHolder().key().location().toString()); +// nbt.putInt(NBT_CUSTOM_BLOCK_META, state.getBlock().getMetaFromState(state)); + nbt.put(NBT_CUSTOM_BLOCK_META, NbtUtils.writeBlockState(state)); + nbt.put(NBT_CUSTOM_ITEM_STACK, stack.serializeNBT()); +// FMLInterModComms.sendMessage(IMC_MOD_TARGET, IMC_FACADE_CUSTOM, nbt); + InterModComms.sendTo(IMC_MOD_TARGET, IMC_FACADE_CUSTOM, () -> new BcImcMessage(nbt)); } public static boolean isFacadeMessageId(String id) { return IMC_FACADE_CUSTOM.equals(id) // - || IMC_FACADE_DISABLE.equals(id); + || IMC_FACADE_DISABLE.equals(id); } } diff --git a/api/buildcraft/api/facades/IFacade.java b/api/buildcraft/api/facades/IFacade.java index 1142a73..f511f3d 100644 --- a/api/buildcraft/api/facades/IFacade.java +++ b/api/buildcraft/api/facades/IFacade.java @@ -1,9 +1,13 @@ package buildcraft.api.facades; +import net.minecraft.nbt.CompoundTag; + public interface IFacade { FacadeType getType(); boolean isHollow(); IFacadePhasedState[] getPhasedStates(); + + CompoundTag writeToNbt(); } diff --git a/api/buildcraft/api/facades/IFacadeItem.java b/api/buildcraft/api/facades/IFacadeItem.java index 65c312a..bc0583c 100644 --- a/api/buildcraft/api/facades/IFacadeItem.java +++ b/api/buildcraft/api/facades/IFacadeItem.java @@ -4,12 +4,12 @@ * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.facades; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.state.BlockState; + import javax.annotation.Nonnull; import javax.annotation.Nullable; -import net.minecraft.block.state.IBlockState; -import net.minecraft.item.ItemStack; - public interface IFacadeItem { @Nullable @@ -22,7 +22,7 @@ default FacadeType getFacadeType(@Nonnull ItemStack stack) { } @Nonnull - ItemStack getFacadeForBlock(IBlockState state); + ItemStack getFacadeForBlock(BlockState state); /** @param facade The {@link IFacade} instance. NOTE: This MUST be an object returned from * {@link IFacadeRegistry#createBasicFacade(IFacadeState, boolean)} or @@ -32,4 +32,6 @@ default FacadeType getFacadeType(@Nonnull ItemStack stack) { @Nullable IFacade getFacade(@Nonnull ItemStack facade); + + ItemStack createItemStack(IFacade state); } diff --git a/api/buildcraft/api/facades/IFacadePhasedState.java b/api/buildcraft/api/facades/IFacadePhasedState.java index e576e09..5cbf728 100644 --- a/api/buildcraft/api/facades/IFacadePhasedState.java +++ b/api/buildcraft/api/facades/IFacadePhasedState.java @@ -1,12 +1,12 @@ package buildcraft.api.facades; -import javax.annotation.Nullable; +import net.minecraft.world.item.DyeColor; -import net.minecraft.item.EnumDyeColor; +import javax.annotation.Nullable; public interface IFacadePhasedState { IFacadeState getState(); @Nullable - EnumDyeColor getActiveColor(); + DyeColor getActiveColor(); } diff --git a/api/buildcraft/api/facades/IFacadeRegistry.java b/api/buildcraft/api/facades/IFacadeRegistry.java index c0e53f3..c9cb903 100644 --- a/api/buildcraft/api/facades/IFacadeRegistry.java +++ b/api/buildcraft/api/facades/IFacadeRegistry.java @@ -1,16 +1,15 @@ package buildcraft.api.facades; -import java.util.Collection; +import net.minecraft.world.item.DyeColor; import javax.annotation.Nullable; - -import net.minecraft.item.EnumDyeColor; +import java.util.Collection; public interface IFacadeRegistry { Collection getValidFacades(); - IFacadePhasedState createPhasedState(IFacadeState state, @Nullable EnumDyeColor activeColor); + IFacadePhasedState createPhasedState(IFacadeState state, @Nullable DyeColor activeColor); IFacade createPhasedFacade(IFacadePhasedState[] states, boolean isHollow); diff --git a/api/buildcraft/api/facades/IFacadeState.java b/api/buildcraft/api/facades/IFacadeState.java index cf7ad7f..7c8eaae 100644 --- a/api/buildcraft/api/facades/IFacadeState.java +++ b/api/buildcraft/api/facades/IFacadeState.java @@ -1,12 +1,12 @@ package buildcraft.api.facades; -import net.minecraft.block.state.IBlockState; -import net.minecraft.item.ItemStack; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.state.BlockState; public interface IFacadeState { boolean isTransparent(); - IBlockState getBlockState(); + BlockState getBlockState(); ItemStack getRequiredStack(); } diff --git a/api/buildcraft/api/facades/package-info.java b/api/buildcraft/api/facades/package-info.java index ee3094d..7679c3a 100644 --- a/api/buildcraft/api/facades/package-info.java +++ b/api/buildcraft/api/facades/package-info.java @@ -2,7 +2,5 @@ * * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -@API(apiVersion = "1.1", owner = "buildcraftapi_core", provides = "buildcraftapi_facades") +//@API(apiVersion = "1.1", owner = "buildcraftapi_core", provides = "buildcraftapi_facades") package buildcraft.api.facades; - -import net.minecraftforge.fml.common.API; diff --git a/api/buildcraft/api/filler/IFilledTemplate.java b/api/buildcraft/api/filler/IFilledTemplate.java index d0b59d4..05af925 100644 --- a/api/buildcraft/api/filler/IFilledTemplate.java +++ b/api/buildcraft/api/filler/IFilledTemplate.java @@ -1,10 +1,8 @@ package buildcraft.api.filler; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; -/** - * Use methods of the interface as much as possible, implementation can do optimizations - */ +/** Use methods of the interface as much as possible, implementation can do optimizations */ public interface IFilledTemplate { BlockPos getSize(); diff --git a/api/buildcraft/api/filler/IFillerPattern.java b/api/buildcraft/api/filler/IFillerPattern.java index cd23730..db7eb1c 100644 --- a/api/buildcraft/api/filler/IFillerPattern.java +++ b/api/buildcraft/api/filler/IFillerPattern.java @@ -4,14 +4,13 @@ * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.filler; -import javax.annotation.Nullable; - -import net.minecraft.util.math.BlockPos; - import buildcraft.api.core.render.ISprite; import buildcraft.api.statements.IStatement; import buildcraft.api.statements.IStatementParameter; import buildcraft.api.statements.containers.IFillerStatementContainer; +import net.minecraft.core.BlockPos; + +import javax.annotation.Nullable; /** A type of statement that is used for filler patterns. */ public interface IFillerPattern extends IStatement { diff --git a/api/buildcraft/api/filler/IFillerPatternShape.java b/api/buildcraft/api/filler/IFillerPatternShape.java index b51e253..95d26ae 100644 --- a/api/buildcraft/api/filler/IFillerPatternShape.java +++ b/api/buildcraft/api/filler/IFillerPatternShape.java @@ -4,14 +4,13 @@ * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.filler; -import javax.annotation.Nullable; - -import net.minecraft.world.World; - import buildcraft.api.statements.IStatementParameter; import buildcraft.api.statements.containers.IFillerStatementContainer; +import net.minecraft.world.level.Level; + +import javax.annotation.Nullable; -/** {@code IFillerPattern} independent from {@link World} */ +/** {@code IFillerPattern} independent from {@link Level} */ public interface IFillerPatternShape extends IFillerPattern { /** * @param filledTemplate empty template @@ -23,8 +22,8 @@ public interface IFillerPatternShape extends IFillerPattern { @Override default IFilledTemplate createTemplate(IFillerStatementContainer filler, IStatementParameter[] params) { IFilledTemplate template = FillerManager.registry.createFilledTemplate( - filler.getBox().min(), - filler.getBox().size() + filler.getBox().min(), + filler.getBox().size() ); if (!fillTemplate(template, params)) { return null; diff --git a/api/buildcraft/api/filler/IFillerRegistry.java b/api/buildcraft/api/filler/IFillerRegistry.java index fa49cb1..1268db8 100644 --- a/api/buildcraft/api/filler/IFillerRegistry.java +++ b/api/buildcraft/api/filler/IFillerRegistry.java @@ -1,12 +1,10 @@ package buildcraft.api.filler; -import java.util.Collection; +import buildcraft.api.statements.IStatement; +import net.minecraft.core.BlockPos; import javax.annotation.Nullable; - -import net.minecraft.util.math.BlockPos; - -import buildcraft.api.statements.IStatement; +import java.util.Collection; public interface IFillerRegistry { void addPattern(IFillerPattern pattern); diff --git a/api/buildcraft/api/filler/package-info.java b/api/buildcraft/api/filler/package-info.java index d5b3f2a..e76db5e 100644 --- a/api/buildcraft/api/filler/package-info.java +++ b/api/buildcraft/api/filler/package-info.java @@ -1,8 +1,6 @@ -/* Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com * * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -@API(apiVersion = "5.0", owner = "buildcraftapi_core", provides = "buildcraftapi_filler") +//@API(apiVersion = "5.0", owner = "buildcraftapi_core", provides = "buildcraftapi_filler") package buildcraft.api.filler; - -import net.minecraftforge.fml.common.API; diff --git a/api/buildcraft/api/fuels/BuildcraftFuelRegistry.java b/api/buildcraft/api/fuels/BuildcraftFuelRegistry.java index 545ac3d..107b26a 100644 --- a/api/buildcraft/api/fuels/BuildcraftFuelRegistry.java +++ b/api/buildcraft/api/fuels/BuildcraftFuelRegistry.java @@ -8,5 +8,6 @@ public final class BuildcraftFuelRegistry { public static IFuelManager fuel; public static ICoolantManager coolant; - private BuildcraftFuelRegistry() {} + private BuildcraftFuelRegistry() { + } } diff --git a/api/buildcraft/api/fuels/EnumCoolantType.java b/api/buildcraft/api/fuels/EnumCoolantType.java new file mode 100644 index 0000000..a5008d6 --- /dev/null +++ b/api/buildcraft/api/fuels/EnumCoolantType.java @@ -0,0 +1,17 @@ +package buildcraft.api.fuels; + +import java.util.Locale; + +public enum EnumCoolantType { + FLUID, + SOLID, + ; + + public String getLowerName() { + return this.name().toLowerCase(Locale.ROOT); + } + + public static EnumCoolantType byName(String name) { + return valueOf(name.toUpperCase(Locale.ROOT)); + } +} diff --git a/api/buildcraft/api/fuels/ICoolant.java b/api/buildcraft/api/fuels/ICoolant.java index f81a863..8ef0b61 100644 --- a/api/buildcraft/api/fuels/ICoolant.java +++ b/api/buildcraft/api/fuels/ICoolant.java @@ -1,16 +1,51 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.fuels; +import buildcraft.api.BCModules; +import net.minecraft.core.RegistryAccess; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.Container; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.world.level.Level; import net.minecraftforge.fluids.FluidStack; -public interface ICoolant { - boolean matchesFluid(FluidStack fluid); +public interface ICoolant extends Recipe { + public static final ResourceLocation TYPE_ID = new ResourceLocation(BCModules.ENERGY.getModId(), "coolant"); - /** @param fluid - * @param heat - * @return 0 if the input fluid provides no cooling, or a value greater than 0 if it does. */ - float getDegreesCoolingPerMB(FluidStack fluid, float heat); + public static final RecipeType TYPE = RecipeType.simple(TYPE_ID); + + EnumCoolantType getCoolantType(); + + FluidStack getFluid(); + + @Override + default boolean matches(Container inv, Level world) { + return false; + } + + @Override + default ItemStack assemble(Container inv, RegistryAccess registryAccess) { + return ItemStack.EMPTY; + } + + @Override + default boolean canCraftInDimensions(int width, int height) { + return true; + } + + @Override + default ItemStack getResultItem(RegistryAccess registryAccess) { + return ItemStack.EMPTY; + } + + @Override + default boolean isSpecial() { + return true; + } + + @Override + default RecipeType getType() { + return TYPE; + } } diff --git a/api/buildcraft/api/fuels/ICoolantManager.java b/api/buildcraft/api/fuels/ICoolantManager.java index dfcf78b..629c002 100644 --- a/api/buildcraft/api/fuels/ICoolantManager.java +++ b/api/buildcraft/api/fuels/ICoolantManager.java @@ -1,36 +1,48 @@ /** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ + * BuildCraft is distributed under the terms of the Minecraft Mod Public License 1.0, or MMPL. Please check the contents + * of the license located in http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.api.fuels; -import java.util.Collection; - -import net.minecraft.item.ItemStack; - -import net.minecraftforge.fluids.Fluid; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.material.Fluid; import net.minecraftforge.fluids.FluidStack; +import java.util.Collection; + public interface ICoolantManager { - ICoolant addCoolant(ICoolant coolant); + // IFluidCoolant addCoolant(IFluidCoolant coolant); + IFluidCoolant addUnregisteredFluidCoolant(IFluidCoolant coolant); - ICoolant addCoolant(FluidStack fluid, float degreesCoolingPerMb); + // IFluidCoolant addCoolant(FluidStack fluid, float degreesCoolingPerMb); + IFluidCoolant addCoolant(ResourceLocation id, FluidStack fluid, float degreesCoolingPerMb); - default ICoolant addCoolant(Fluid fluid, float degreesCoolingPerMb) { - return addCoolant(new FluidStack(fluid, 1), degreesCoolingPerMb); + // default IFluidCoolant addCoolant(Fluid fluid, float degreesCoolingPerMb) + default IFluidCoolant addCoolant(ResourceLocation id, Fluid fluid, float degreesCoolingPerMb) { +// return addCoolant(new FluidStack(fluid, 1), degreesCoolingPerMb); + return addCoolant(id, new FluidStack(fluid, 1), degreesCoolingPerMb); } - ISolidCoolant addSolidCoolant(ISolidCoolant solidCoolant); + // ISolidCoolant addSolidCoolant(ISolidCoolant solidCoolant); + ISolidCoolant addUnregisteredSolidCoolant(ISolidCoolant solidCoolant); - ISolidCoolant addSolidCoolant(ItemStack solid, FluidStack fluid, float multiplier); + // ISolidCoolant addSolidCoolant(ItemStack solid, FluidStack fluid, float multiplier); + ISolidCoolant addSolidCoolant(ResourceLocation id, ItemStack solid, FluidStack fluid, float multiplier); - Collection getCoolants(); + // Collection getCoolants(); + Collection getCoolants(Level world); - Collection getSolidCoolants(); + // Collection getSolidCoolants(); + Collection getSolidCoolants(Level world); - ICoolant getCoolant(FluidStack fluid); + // IFluidCoolant getCoolant(FluidStack fluid); + IFluidCoolant getCoolant(Level world, FluidStack fluid); - float getDegreesPerMb(FluidStack fluid, float heat); + // float getDegreesPerMb(FluidStack fluid, float heat); + float getDegreesPerMb(Level world, FluidStack fluid, float heat); - ISolidCoolant getSolidCoolant(ItemStack solid); + // ISolidCoolant getSolidCoolant(ItemStack solid); + ISolidCoolant getSolidCoolant(Level world, ItemStack solid); } diff --git a/api/buildcraft/api/fuels/IFluidCoolant.java b/api/buildcraft/api/fuels/IFluidCoolant.java new file mode 100644 index 0000000..b0fee8d --- /dev/null +++ b/api/buildcraft/api/fuels/IFluidCoolant.java @@ -0,0 +1,24 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public License 1.0, or MMPL. Please check the contents + * of the license located in http://www.mod-buildcraft.com/MMPL-1.0.txt */ +package buildcraft.api.fuels; + +import net.minecraftforge.fluids.FluidStack; + +/** + * This was named ICoolant in 1.12.2. + * In 1.18.2, we differ coolants as {@link EnumCoolantType#FLUID} AND {@link EnumCoolantType#SOLID}., + * {@link IFluidCoolant} and {@link ISolidCoolant} both extends {@link ICoolant}. + */ +public interface IFluidCoolant extends ICoolant { + boolean matchesFluid(FluidStack fluid); + + /** @param fluid + * @param heat + * @return 0 if the input fluid provides no cooling, or a value greater than 0 if it does. */ + float getDegreesCoolingPerMB(FluidStack fluid, float heat); + + /** @return The degrees-of-cooling-per-mb value of the recipe, ignoring whether a correct input is present. */ + float getDegreesCoolingPerMB(); +} diff --git a/api/buildcraft/api/fuels/IFuel.java b/api/buildcraft/api/fuels/IFuel.java index 382eb2a..87edd34 100644 --- a/api/buildcraft/api/fuels/IFuel.java +++ b/api/buildcraft/api/fuels/IFuel.java @@ -1,13 +1,26 @@ /** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ + * BuildCraft is distributed under the terms of the Minecraft Mod Public License 1.0, or MMPL. Please check the contents + * of the license located in http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.api.fuels; +import buildcraft.api.BCModules; +import net.minecraft.core.RegistryAccess; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.Container; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.world.level.Level; import net.minecraftforge.fluids.FluidStack; -public interface IFuel { - /** @return The input fluid. The {@link FluidStack#amount} is ignored. */ +//public interface IFuel +public interface IFuel extends Recipe { + public static final ResourceLocation TYPE_ID = new ResourceLocation(BCModules.ENERGY.getModId(), "fuel"); + + public static final RecipeType TYPE = RecipeType.simple(TYPE_ID); + + /** @return The input fluid. The {@link FluidStack#getAmount()} is ignored. */ FluidStack getFluid(); /** @return The number of ticks that a single bucket (1000mb) of this fuel will burn for. */ @@ -15,4 +28,34 @@ public interface IFuel { /** @return The amount (in micro mj) of power that this fuel will give off in 1 tick. */ long getPowerPerCycle(); + + @Override + default boolean matches(Container inv, Level world) { + return false; + } + + @Override + default ItemStack assemble(Container inv, RegistryAccess registryAccess) { + return ItemStack.EMPTY; + } + + @Override + default boolean canCraftInDimensions(int width, int height) { + return true; + } + + @Override + default ItemStack getResultItem(RegistryAccess registryAccess) { + return ItemStack.EMPTY; + } + + @Override + default boolean isSpecial() { + return true; + } + + @Override + default RecipeType getType() { + return TYPE; + } } diff --git a/api/buildcraft/api/fuels/IFuelManager.java b/api/buildcraft/api/fuels/IFuelManager.java index cb02063..2666843 100644 --- a/api/buildcraft/api/fuels/IFuelManager.java +++ b/api/buildcraft/api/fuels/IFuelManager.java @@ -1,34 +1,45 @@ /** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ + * BuildCraft is distributed under the terms of the Minecraft Mod Public License 1.0, or MMPL. Please check the contents + * of the license located in http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.api.fuels; -import java.util.Collection; - -import net.minecraftforge.fluids.Fluid; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.material.Fluid; import net.minecraftforge.fluids.FluidStack; +import java.util.Collection; + public interface IFuelManager { - F addFuel(F fuel); + // F addFuel(F fuel); + F addUnregisteredFuel(F fuel); - IFuel addFuel(FluidStack fluid, long powerPerCycle, int totalBurningTime); + // IFuel addFuel(FluidStack fluid, long powerPerCycle, int totalBurningTime); + IFuel addUnregisteredFuel(ResourceLocation id, FluidStack fluid, long powerPerCycle, int totalBurningTime); - default IFuel addFuel(Fluid fluid, long powerPerCycle, int totalBurningTime) { - return addFuel(new FluidStack(fluid, 1), powerPerCycle, totalBurningTime); + // default IFuel addFuel(Fluid fluid, long powerPerCycle, int totalBurningTime) + default IFuel addUnregisteredFuel(ResourceLocation id, Fluid fluid, long powerPerCycle, int totalBurningTime) { +// return addFuel(new FluidStack(fluid, 1), powerPerCycle, totalBurningTime); + return addUnregisteredFuel(id, new FluidStack(fluid, 1), powerPerCycle, totalBurningTime); } /** @param residue The residue fluidstack, per bucket of the original fuel. */ - IDirtyFuel addDirtyFuel(FluidStack fuel, long powerPerCycle, int totalBurningTime, FluidStack residue); +// IDirtyFuel addDirtyFuel(FluidStack fuel, long powerPerCycle, int totalBurningTime, FluidStack residue); + IDirtyFuel addUnregisteredDirtyFuel(ResourceLocation id, FluidStack fuel, long powerPerCycle, int totalBurningTime, FluidStack residue); /** @param residue The residue fluidstack, per bucket of the original fuel. */ - default IDirtyFuel addDirtyFuel(Fluid fuel, long powerPerCycle, int totalBurningTime, FluidStack residue) { - return addDirtyFuel(new FluidStack(fuel, 1), powerPerCycle, totalBurningTime, residue); +// default IDirtyFuel addDirtyFuel(Fluid fuel, long powerPerCycle, int totalBurningTime, FluidStack residue) + default IDirtyFuel addUnregisteredDirtyFuel(ResourceLocation id, Fluid fuel, long powerPerCycle, int totalBurningTime, FluidStack residue) { +// return addDirtyFuel(new FluidStack(fuel, 1), powerPerCycle, totalBurningTime, residue); + return addUnregisteredDirtyFuel(id, new FluidStack(fuel, 1), powerPerCycle, totalBurningTime, residue); } - Collection getFuels(); + // Collection getFuels(); + Collection getFuels(Level world); - IFuel getFuel(FluidStack fluid); + // IFuel getFuel(FluidStack fluid); + IFuel getFuel(Level world, FluidStack fluid); interface IDirtyFuel extends IFuel { /** @return The residue fluidstack, per bucket of original fuel. */ diff --git a/api/buildcraft/api/fuels/ISolidCoolant.java b/api/buildcraft/api/fuels/ISolidCoolant.java index 2b466ef..6de111b 100644 --- a/api/buildcraft/api/fuels/ISolidCoolant.java +++ b/api/buildcraft/api/fuels/ISolidCoolant.java @@ -1,13 +1,16 @@ /** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ + * BuildCraft is distributed under the terms of the Minecraft Mod Public License 1.0, or MMPL. Please check the contents + * of the license located in http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.api.fuels; -import net.minecraft.item.ItemStack; - +import net.minecraft.world.item.ItemStack; import net.minecraftforge.fluids.FluidStack; -public interface ISolidCoolant { +public interface ISolidCoolant extends ICoolant { FluidStack getFluidFromSolidCoolant(ItemStack stack); + + float getMultiplier(); + + ItemStack getSolid(); } diff --git a/api/buildcraft/api/fuels/package-info.java b/api/buildcraft/api/fuels/package-info.java index b108eae..1515996 100644 --- a/api/buildcraft/api/fuels/package-info.java +++ b/api/buildcraft/api/fuels/package-info.java @@ -2,7 +2,5 @@ * * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -@API(apiVersion = "2.0", owner = "buildcraftapi_core", provides = "buildcraftapi_fuels") +//@API(apiVersion = "2.0", owner = "buildcraftapi_core", provides = "buildcraftapi_fuels") package buildcraft.api.fuels; - -import net.minecraftforge.fml.common.API; diff --git a/api/buildcraft/api/gates/IGate.java b/api/buildcraft/api/gates/IGate.java index 2d9302c..0350649 100644 --- a/api/buildcraft/api/gates/IGate.java +++ b/api/buildcraft/api/gates/IGate.java @@ -4,14 +4,14 @@ * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.gates; -import java.util.List; - import buildcraft.api.statements.IStatement; import buildcraft.api.statements.IStatementParameter; import buildcraft.api.statements.StatementSlot; import buildcraft.api.statements.containers.ISidedStatementContainer; import buildcraft.api.transport.pipe.IPipeHolder; +import java.util.List; + public interface IGate extends ISidedStatementContainer { IPipeHolder getPipeHolder(); diff --git a/api/buildcraft/api/gates/IGateProvider.java b/api/buildcraft/api/gates/IGateProvider.java new file mode 100644 index 0000000..6e8f3bd --- /dev/null +++ b/api/buildcraft/api/gates/IGateProvider.java @@ -0,0 +1,6 @@ +package buildcraft.api.gates; + +// Calen 1.18.2 +public interface IGateProvider { + IGate getGate(); +} diff --git a/api/buildcraft/api/gates/package-info.java b/api/buildcraft/api/gates/package-info.java index 63d9988..5b5928c 100644 --- a/api/buildcraft/api/gates/package-info.java +++ b/api/buildcraft/api/gates/package-info.java @@ -2,7 +2,5 @@ * * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -@API(apiVersion = "4.1", owner = "buildcraftapi_core", provides = "buildcraftapi_gates") +//@API(apiVersion = "4.1", owner = "buildcraftapi_core", provides = "buildcraftapi_gates") package buildcraft.api.gates; - -import net.minecraftforge.fml.common.API; diff --git a/api/buildcraft/api/imc/BcImcMessage.java b/api/buildcraft/api/imc/BcImcMessage.java new file mode 100644 index 0000000..ef80d70 --- /dev/null +++ b/api/buildcraft/api/imc/BcImcMessage.java @@ -0,0 +1,32 @@ +package buildcraft.api.imc; + +import net.minecraft.nbt.CompoundTag; +import net.minecraft.resources.ResourceLocation; + +import javax.annotation.Nonnull; + +/** Used in {@link buildcraft.api.facades.FacadeAPI} */ +public class BcImcMessage { + @Nonnull + private final Object value; + + public BcImcMessage(@Nonnull Object value) { + this.value = value; + } + + public ResourceLocation getResourceLocationValue() { + return (ResourceLocation) value; + } + + public CompoundTag getNBTValue() { + return (CompoundTag) value; + } + + public boolean isNBTMessage() { + return CompoundTag.class.isAssignableFrom(getMessageType()); + } + + public Class getMessageType() { + return value.getClass(); + } +} diff --git a/api/buildcraft/api/inventory/IItemHandlerFiltered.java b/api/buildcraft/api/inventory/IItemHandlerFiltered.java index 8672d1d..919d212 100644 --- a/api/buildcraft/api/inventory/IItemHandlerFiltered.java +++ b/api/buildcraft/api/inventory/IItemHandlerFiltered.java @@ -1,7 +1,6 @@ package buildcraft.api.inventory; -import net.minecraft.item.ItemStack; - +import net.minecraft.world.item.ItemStack; import net.minecraftforge.items.IItemHandler; /** A type of {@link IItemHandler} that has a single valid stack per slot, as specified by {@link #getFilter(int)}. Note diff --git a/api/buildcraft/api/inventory/IItemTransactor.java b/api/buildcraft/api/inventory/IItemTransactor.java index 212d2e3..7265568 100644 --- a/api/buildcraft/api/inventory/IItemTransactor.java +++ b/api/buildcraft/api/inventory/IItemTransactor.java @@ -1,13 +1,12 @@ package buildcraft.api.inventory; +import buildcraft.api.core.IStackFilter; +import net.minecraft.core.NonNullList; +import net.minecraft.world.item.ItemStack; + import javax.annotation.Nonnull; import javax.annotation.Nullable; -import net.minecraft.item.ItemStack; -import net.minecraft.util.NonNullList; - -import buildcraft.api.core.IStackFilter; - /** A simple way to define something that deals with item insertion and extraction, without caring about slots. */ public interface IItemTransactor { /** @param stack The stack to insert. Must not be null! @@ -19,7 +18,7 @@ public interface IItemTransactor { /** Similar to {@link #insert(ItemStack, boolean, boolean)} but probably be more efficient at inserting lots of * items. - * + * * @param stacks The stacks to insert. Must not be null! * @param simulate If true then the in-world state of this will not be changed. * @return The overflow stacks. Will be an empty list if all of it was accepted. */ @@ -35,7 +34,7 @@ default NonNullList insert(NonNullList stacks, boolean sim } /** Extracts a number of items that match the given filter - * + * * @param filter The filter that MUST be met by the extracted stack. Null means no filter - it can be any item. * @param min The minimum number of items to extract, or 0 if not enough items can be extracted * @param max The maximum number of items to extract. diff --git a/api/buildcraft/api/items/FluidItemDrops.java b/api/buildcraft/api/items/FluidItemDrops.java index de82f18..45c219e 100644 --- a/api/buildcraft/api/items/FluidItemDrops.java +++ b/api/buildcraft/api/items/FluidItemDrops.java @@ -1,19 +1,18 @@ package buildcraft.api.items; -import net.minecraft.item.ItemStack; -import net.minecraft.util.NonNullList; - +import net.minecraft.core.NonNullList; +import net.minecraft.world.item.ItemStack; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidTank; +import net.minecraftforge.registries.RegistryObject; public class FluidItemDrops { - - public static IItemFluidShard item; + public static RegistryObject item; public static void addFluidDrops(NonNullList toDrop, FluidStack... fluids) { if (item != null) { for (FluidStack fluid : fluids) { - item.addFluidDrops(toDrop, fluid); + item.get().addFluidDrops(toDrop, fluid); } } } @@ -21,7 +20,7 @@ public static void addFluidDrops(NonNullList toDrop, FluidStack... fl public static void addFluidDrops(NonNullList toDrop, IFluidTank... tanks) { if (item != null) { for (IFluidTank tank : tanks) { - item.addFluidDrops(toDrop, tank.getFluid()); + item.get().addFluidDrops(toDrop, tank.getFluid()); } } } diff --git a/api/buildcraft/api/items/IChipset.java b/api/buildcraft/api/items/IChipset.java new file mode 100644 index 0000000..8914f84 --- /dev/null +++ b/api/buildcraft/api/items/IChipset.java @@ -0,0 +1,7 @@ +package buildcraft.api.items; + +import buildcraft.api.enums.EnumRedstoneChipset; + +public interface IChipset { + EnumRedstoneChipset getType(); +} diff --git a/api/buildcraft/api/items/IItemCustomPipeRender.java b/api/buildcraft/api/items/IItemCustomPipeRender.java index 697b875..581aa3f 100644 --- a/api/buildcraft/api/items/IItemCustomPipeRender.java +++ b/api/buildcraft/api/items/IItemCustomPipeRender.java @@ -1,14 +1,13 @@ package buildcraft.api.items; -import net.minecraft.item.ItemStack; - -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +import net.minecraft.world.item.ItemStack; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; public interface IItemCustomPipeRender { float getPipeRenderScale(ItemStack stack); /** @return False to use the default renderer, true otherwise. */ - @SideOnly(Side.CLIENT) + @OnlyIn(Dist.CLIENT) boolean renderItemInPipe(ItemStack stack, double x, double y, double z); } diff --git a/api/buildcraft/api/items/IItemFluidShard.java b/api/buildcraft/api/items/IItemFluidShard.java index 0557f6b..a21a68e 100644 --- a/api/buildcraft/api/items/IItemFluidShard.java +++ b/api/buildcraft/api/items/IItemFluidShard.java @@ -1,12 +1,11 @@ package buildcraft.api.items; -import javax.annotation.Nullable; - -import net.minecraft.item.ItemStack; -import net.minecraft.util.NonNullList; - +import net.minecraft.core.NonNullList; +import net.minecraft.world.item.ItemStack; import net.minecraftforge.fluids.FluidStack; +import javax.annotation.Nullable; + public interface IItemFluidShard { void addFluidDrops(NonNullList toDrop, @Nullable FluidStack fluid); } diff --git a/api/buildcraft/api/items/IList.java b/api/buildcraft/api/items/IList.java index 1456d24..edcf1b0 100644 --- a/api/buildcraft/api/items/IList.java +++ b/api/buildcraft/api/items/IList.java @@ -1,8 +1,8 @@ package buildcraft.api.items; -import javax.annotation.Nonnull; +import net.minecraft.world.item.ItemStack; -import net.minecraft.item.ItemStack; +import javax.annotation.Nonnull; public interface IList extends INamedItem { boolean matches(@Nonnull ItemStack stackList, @Nonnull ItemStack item); diff --git a/api/buildcraft/api/items/IMapLocation.java b/api/buildcraft/api/items/IMapLocation.java index cb5dba5..1185706 100644 --- a/api/buildcraft/api/items/IMapLocation.java +++ b/api/buildcraft/api/items/IMapLocation.java @@ -1,15 +1,13 @@ package buildcraft.api.items; -import java.util.List; - -import javax.annotation.Nonnull; - -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; - import buildcraft.api.core.IBox; import buildcraft.api.core.IZone; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.item.ItemStack; + +import javax.annotation.Nonnull; +import java.util.List; /** Created by asie on 2/28/15. */ public interface IMapLocation extends INamedItem { @@ -25,7 +23,7 @@ enum MapLocationType { public final int meta = ordinal(); public static MapLocationType getFromStack(@Nonnull ItemStack stack) { - int dam = stack.getItemDamage(); + int dam = stack.getDamageValue(); if (dam < 0 || dam >= values().length) { return MapLocationType.CLEAN; } @@ -33,37 +31,37 @@ public static MapLocationType getFromStack(@Nonnull ItemStack stack) { } public void setToStack(@Nonnull ItemStack stack) { - stack.setItemDamage(meta); + stack.setDamageValue(meta); } } /** This function can be used for SPOT types. - * + * * @param stack * @return The point representing the map location. */ BlockPos getPoint(@Nonnull ItemStack stack); /** This function can be used for SPOT and AREA types. - * + * * @param stack * @return The box representing the map location. */ IBox getBox(@Nonnull ItemStack stack); /** This function can be used for SPOT, AREA and ZONE types. The PATH type needs to be handled separately. - * + * * @param stack * @return An IZone representing the map location - also an instance of IBox for SPOT and AREA types. */ IZone getZone(@Nonnull ItemStack stack); /** This function can be used for SPOT and PATH types. - * + * * @param stack * @return A list of BlockPoses representing the path the Map Location stores. */ List getPath(@Nonnull ItemStack stack); /** This function can be used for SPOT types only. - * + * * @param stack * @return The side of the spot. */ - EnumFacing getPointSide(@Nonnull ItemStack stack); + Direction getPointSide(@Nonnull ItemStack stack); } diff --git a/api/buildcraft/api/items/INamedItem.java b/api/buildcraft/api/items/INamedItem.java index 87c3420..225fc8d 100644 --- a/api/buildcraft/api/items/INamedItem.java +++ b/api/buildcraft/api/items/INamedItem.java @@ -1,11 +1,12 @@ package buildcraft.api.items; -import javax.annotation.Nonnull; +import net.minecraft.world.item.ItemStack; -import net.minecraft.item.ItemStack; +import javax.annotation.Nonnull; public interface INamedItem { - String getName(@Nonnull ItemStack stack); + // Component getName(@Nonnull ItemStack stack); + String getName_INamedItem(@Nonnull ItemStack stack); boolean setName(@Nonnull ItemStack stack, String name); } diff --git a/api/buildcraft/api/items/package-info.java b/api/buildcraft/api/items/package-info.java index 883db47..8747597 100644 --- a/api/buildcraft/api/items/package-info.java +++ b/api/buildcraft/api/items/package-info.java @@ -2,7 +2,5 @@ * * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -@API(apiVersion = "1.1", owner = "buildcraftapi_core", provides = "buildcraftapi_items") +//@API(apiVersion = "1.1", owner = "buildcraftapi_core", provides = "buildcraftapi_items") package buildcraft.api.items; - -import net.minecraftforge.fml.common.API; diff --git a/api/buildcraft/api/library/ILibraryTypeHandler.java b/api/buildcraft/api/library/ILibraryTypeHandler.java deleted file mode 100644 index 8616d10..0000000 --- a/api/buildcraft/api/library/ILibraryTypeHandler.java +++ /dev/null @@ -1,18 +0,0 @@ -package buildcraft.api.library; - -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - -public interface ILibraryTypeHandler { - boolean isHandler(ItemStack stack, boolean store); - - String getFileExtension(); - - int getTextColor(); - - String getName(ItemStack stack); - - ItemStack load(ItemStack stack, NBTTagCompound compound); - - boolean store(ItemStack stack, NBTTagCompound compound); -} diff --git a/api/buildcraft/api/library/LibraryAPI.java b/api/buildcraft/api/library/LibraryAPI.java deleted file mode 100644 index b899793..0000000 --- a/api/buildcraft/api/library/LibraryAPI.java +++ /dev/null @@ -1,30 +0,0 @@ -package buildcraft.api.library; - -import java.util.HashSet; -import java.util.Set; - -@Deprecated -public final class LibraryAPI { - private static final Set handlers = new HashSet<>(); - - private LibraryAPI() { - - } - - public static Set getHandlerSet() { - return handlers; - } - - public static void registerHandler(LibraryTypeHandler handler) { - handlers.add(handler); - } - - public static LibraryTypeHandler getHandlerFor(String extension) { - for (LibraryTypeHandler h : handlers) { - if (h.isInputExtension(extension)) { - return h; - } - } - return null; - } -} diff --git a/api/buildcraft/api/library/LibraryTypeHandler.java b/api/buildcraft/api/library/LibraryTypeHandler.java deleted file mode 100644 index 08db4f6..0000000 --- a/api/buildcraft/api/library/LibraryTypeHandler.java +++ /dev/null @@ -1,31 +0,0 @@ -package buildcraft.api.library; - -import net.minecraft.item.ItemStack; - -@Deprecated -public abstract class LibraryTypeHandler { - public enum HandlerType { - LOAD, - STORE - } - - private final String extension; - - public LibraryTypeHandler(String extension) { - this.extension = extension; - } - - public abstract boolean isHandler(ItemStack stack, HandlerType type); - - public boolean isInputExtension(String ext) { - return extension.equals(ext); - } - - public String getOutputExtension() { - return extension; - } - - public abstract int getTextColor(); - - public abstract String getName(ItemStack stack); -} diff --git a/api/buildcraft/api/library/LibraryTypeHandlerByteArray.java b/api/buildcraft/api/library/LibraryTypeHandlerByteArray.java deleted file mode 100644 index c7c5e23..0000000 --- a/api/buildcraft/api/library/LibraryTypeHandlerByteArray.java +++ /dev/null @@ -1,13 +0,0 @@ -package buildcraft.api.library; - -import net.minecraft.item.ItemStack; - -public abstract class LibraryTypeHandlerByteArray extends LibraryTypeHandler { - public LibraryTypeHandlerByteArray(String extension) { - super(extension); - } - - public abstract ItemStack load(ItemStack stack, byte[] data); - - public abstract byte[] store(ItemStack stack); -} diff --git a/api/buildcraft/api/library/LibraryTypeHandlerNBT.java b/api/buildcraft/api/library/LibraryTypeHandlerNBT.java deleted file mode 100644 index a656ff7..0000000 --- a/api/buildcraft/api/library/LibraryTypeHandlerNBT.java +++ /dev/null @@ -1,14 +0,0 @@ -package buildcraft.api.library; - -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - -public abstract class LibraryTypeHandlerNBT extends LibraryTypeHandler { - public LibraryTypeHandlerNBT(String extension) { - super(extension); - } - - public abstract ItemStack load(ItemStack stack, NBTTagCompound nbt); - - public abstract boolean store(ItemStack stack, NBTTagCompound nbt); -} diff --git a/api/buildcraft/api/lists/ListMatchHandler.java b/api/buildcraft/api/lists/ListMatchHandler.java index e35a680..86e5a03 100644 --- a/api/buildcraft/api/lists/ListMatchHandler.java +++ b/api/buildcraft/api/lists/ListMatchHandler.java @@ -1,11 +1,11 @@ package buildcraft.api.lists; +import net.minecraft.core.NonNullList; +import net.minecraft.world.item.ItemStack; + import javax.annotation.Nonnull; import javax.annotation.Nullable; -import net.minecraft.item.ItemStack; -import net.minecraft.util.NonNullList; - public abstract class ListMatchHandler { public enum Type { TYPE, @@ -18,7 +18,7 @@ public enum Type { public abstract boolean isValidSource(Type type, @Nonnull ItemStack stack); /** Get custom client examples. - * + * * @param type * @param stack * @return A List (even empty!) if the examples satisfy this handler, null if iteration and .matches should be used diff --git a/api/buildcraft/api/lists/ListRegistry.java b/api/buildcraft/api/lists/ListRegistry.java index 38a9166..08e62ae 100644 --- a/api/buildcraft/api/lists/ListRegistry.java +++ b/api/buildcraft/api/lists/ListRegistry.java @@ -1,11 +1,11 @@ package buildcraft.api.lists; +import net.minecraft.world.item.Item; + import java.util.ArrayList; import java.util.Collections; import java.util.List; -import net.minecraft.item.Item; - public final class ListRegistry { public static final List> itemClassAsType = new ArrayList<>(); private static final List handlers = new ArrayList<>(); diff --git a/api/buildcraft/api/lists/package-info.java b/api/buildcraft/api/lists/package-info.java index b953535..a4456d8 100644 --- a/api/buildcraft/api/lists/package-info.java +++ b/api/buildcraft/api/lists/package-info.java @@ -2,7 +2,5 @@ * * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -@API(apiVersion = "1.0", owner = "buildcraftapi_core", provides = "buildcraftapi_lists") +//@API(apiVersion = "1.0", owner = "buildcraftapi_core", provides = "buildcraftapi_lists") package buildcraft.api.lists; - -import net.minecraftforge.fml.common.API; diff --git a/api/buildcraft/api/mj/ILaserTarget.java b/api/buildcraft/api/mj/ILaserTarget.java index e1fbfb4..981c1db 100644 --- a/api/buildcraft/api/mj/ILaserTarget.java +++ b/api/buildcraft/api/mj/ILaserTarget.java @@ -7,6 +7,7 @@ /** This interface should be defined by any Tile which wants to receive power from BuildCraft lasers. * * The respective Block MUST implement ILaserTargetBlock! */ +//@ILaserTargetAnnotation // Calen public interface ILaserTarget { /** Returns The amount of power this target currently needs. diff --git a/api/buildcraft/api/mj/IMjConnector.java b/api/buildcraft/api/mj/IMjConnector.java index 3c5f997..713599d 100644 --- a/api/buildcraft/api/mj/IMjConnector.java +++ b/api/buildcraft/api/mj/IMjConnector.java @@ -3,12 +3,12 @@ import javax.annotation.Nonnull; /** Signifies that this should visibly connect to other Mj handling entities/tiles. This should NEVER be the tile - * entity, but an encapsulated class that refers back to it. Use {@link buildcraft.api.mj.MjAPI#CAP_CONNECTOR} to access + * entity, but an encapsulated class that refers back to it. Use {@link MjAPI#CAP_CONNECTOR} to access * this. */ public interface IMjConnector { /** Checks to see if this connector can connect to the other connector. By default this should check that the other * connector is the same power system. - * + * * @param other * @return */ boolean canConnect(@Nonnull IMjConnector other); diff --git a/api/buildcraft/api/mj/IMjContainerItem.java b/api/buildcraft/api/mj/IMjContainerItem.java new file mode 100644 index 0000000..aa537a5 --- /dev/null +++ b/api/buildcraft/api/mj/IMjContainerItem.java @@ -0,0 +1,13 @@ +package buildcraft.api.mj; + +import net.minecraft.world.item.ItemStack; + +public interface IMjContainerItem { + long receivePower(ItemStack container, long maxReceive, boolean simulate); + + long extractPower(ItemStack container, long maxExtract, boolean simulate); + + long getPowerStored(ItemStack container); + + long getMaxPowerStored(ItemStack container); +} diff --git a/api/buildcraft/api/mj/IMjEffectManager.java b/api/buildcraft/api/mj/IMjEffectManager.java index c7fb899..a2b009e 100644 --- a/api/buildcraft/api/mj/IMjEffectManager.java +++ b/api/buildcraft/api/mj/IMjEffectManager.java @@ -1,15 +1,15 @@ package buildcraft.api.mj; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.Vec3d; -import net.minecraft.world.World; +import net.minecraft.core.Direction; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.Vec3; /** Various effects for showing power loss visibly, and for large amounts of power, causes some damage to nearby * entities. */ public interface IMjEffectManager { - void createPowerLossEffect(World world, Vec3d center, long microJoulesLost); + void createPowerLossEffect(Level world, Vec3 center, long microJoulesLost); - void createPowerLossEffect(World world, Vec3d center, EnumFacing direction, long microJoulesLost); + void createPowerLossEffect(Level world, Vec3 center, Direction direction, long microJoulesLost); - void createPowerLossEffect(World world, Vec3d center, Vec3d direction, long microJoulesLost); + void createPowerLossEffect(Level world, Vec3 center, Vec3 direction, long microJoulesLost); } diff --git a/api/buildcraft/api/mj/IMjPassiveProvider.java b/api/buildcraft/api/mj/IMjPassiveProvider.java index 55b33c6..e6df834 100644 --- a/api/buildcraft/api/mj/IMjPassiveProvider.java +++ b/api/buildcraft/api/mj/IMjPassiveProvider.java @@ -4,7 +4,7 @@ * engine). Power can be extracted from this by powered wooden kinesis pipes, for example. */ public interface IMjPassiveProvider extends IMjConnector { /** Attempts to extract power from this provider - * + * * @param simulate * @return Either 0, min, max, or a value between min and max. */ long extractPower(long min, long max, boolean simulate); diff --git a/api/buildcraft/api/mj/IMjReceiver.java b/api/buildcraft/api/mj/IMjReceiver.java index a8cecd7..750640e 100644 --- a/api/buildcraft/api/mj/IMjReceiver.java +++ b/api/buildcraft/api/mj/IMjReceiver.java @@ -11,10 +11,10 @@ public interface IMjReceiver extends IMjConnector { *

  • Store all power in something like an {@link MjBattery} for later usage. *
  • Refuse all power (if you have no more work to do or your {@link MjBattery} is full). * - * + * * Note that callers are NOT expected to call {@link #canReceive()} before calling this - implementors should check * all of the conditions in {@link #canReceive()} before accepting power. - * + * * @param microJoules The number of micro joules to add. * @param simulate If true then just pretend you received power- don't actually change any of your internal state. * @return The excess power. */ @@ -22,7 +22,7 @@ public interface IMjReceiver extends IMjConnector { /** Checks to see if {@link #receivePower(long, boolean)} *might* accept any power right now, ignoring the amount of * power contained right now (if any). - * + * * @return True if this {@link IMjReceiver} can receive power right now. */ default boolean canReceive() { return true; diff --git a/api/buildcraft/api/mj/IMjRedstoneReceiver.java b/api/buildcraft/api/mj/IMjRedstoneReceiver.java index 11eb5de..f0e892e 100644 --- a/api/buildcraft/api/mj/IMjRedstoneReceiver.java +++ b/api/buildcraft/api/mj/IMjRedstoneReceiver.java @@ -1,4 +1,5 @@ package buildcraft.api.mj; /** Designates that a receiver can receive redstone power (cheap, free, small amounts) */ -public interface IMjRedstoneReceiver extends IMjReceiver {} +public interface IMjRedstoneReceiver extends IMjReceiver { +} diff --git a/api/buildcraft/api/mj/IMjToRfStatus.java b/api/buildcraft/api/mj/IMjToRfStatus.java new file mode 100644 index 0000000..525bf2c --- /dev/null +++ b/api/buildcraft/api/mj/IMjToRfStatus.java @@ -0,0 +1,43 @@ +package buildcraft.api.mj; + +import buildcraft.api.BCModules; + +public interface IMjToRfStatus { + + public static IMjToRfStatus get() { + return MjToRfStatusHolder.STATUS; + } + + MjRfConversion getConversion(); + + boolean isAutoconvertEnabled(); +} + +final class MjToRfStatusHolder implements IMjToRfStatus { + + static final IMjToRfStatus STATUS = get0(); + + private static IMjToRfStatus get0() { + if (BCModules.LIB.isLoaded()) { + try { + return (IMjToRfStatus) Class.forName("buildcraft.lib.BCLibConfig$MjToRfStatus").newInstance(); + } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) { + throw new Error(e); + } + } else { + return new MjToRfStatusHolder(); + } + } + + private final MjRfConversion defaultConversion = MjRfConversion.createDefault(); + + @Override + public MjRfConversion getConversion() { + return defaultConversion; + } + + @Override + public boolean isAutoconvertEnabled() { + return false; + } +} diff --git a/api/buildcraft/api/mj/MjAPI.java b/api/buildcraft/api/mj/MjAPI.java index 1ed476e..b0438f1 100644 --- a/api/buildcraft/api/mj/MjAPI.java +++ b/api/buildcraft/api/mj/MjAPI.java @@ -1,16 +1,16 @@ package buildcraft.api.mj; -import java.text.DecimalFormat; - -import javax.annotation.Nonnull; - -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.Vec3d; -import net.minecraft.world.World; - +import net.minecraft.core.Direction; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.Vec3; import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.capabilities.CapabilityManager; +import net.minecraftforge.common.capabilities.CapabilityToken; +import net.minecraftforge.common.capabilities.RegisterCapabilitiesEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; -import buildcraft.api.core.CapabilitiesHelper; +import javax.annotation.Nonnull; +import java.text.DecimalFormat; public class MjAPI { @@ -45,6 +45,14 @@ private static String formatMjInternal(double val) { return MJ_DISPLAY_FORMAT.format(val); } + public static MjRfConversion getRfConversion() { + return IMjToRfStatus.get().getConversion(); + } + + public static boolean isRfAutoConversionEnabled() { + return IMjToRfStatus.get().isAutoconvertEnabled(); + } + // ######################################## // // Null based classes @@ -53,14 +61,18 @@ private static String formatMjInternal(double val) { public enum NullaryEffectManager implements IMjEffectManager { INSTANCE; + @Override - public void createPowerLossEffect(World world, Vec3d center, long microJoulesLost) {} + public void createPowerLossEffect(Level world, Vec3 center, long microJoulesLost) { + } @Override - public void createPowerLossEffect(World world, Vec3d center, EnumFacing direction, long microJoulesLost) {} + public void createPowerLossEffect(Level world, Vec3 center, Direction direction, long microJoulesLost) { + } @Override - public void createPowerLossEffect(World world, Vec3d center, Vec3d direction, long microJoulesLost) {} + public void createPowerLossEffect(Level world, Vec3 center, Vec3 direction, long microJoulesLost) { + } } // @formatter:on @@ -71,26 +83,30 @@ public void createPowerLossEffect(World world, Vec3d center, Vec3d direction, lo // ############### @Nonnull - public static final Capability CAP_CONNECTOR; - + public static final Capability CAP_CONNECTOR = CapabilityManager.get(new CapabilityToken<>() { + }); @Nonnull - public static final Capability CAP_RECEIVER; - + public static final Capability CAP_RECEIVER = CapabilityManager.get(new CapabilityToken<>() { + }); @Nonnull - public static final Capability CAP_REDSTONE_RECEIVER; + public static final Capability CAP_REDSTONE_RECEIVER = CapabilityManager.get(new CapabilityToken<>() { + }); @Nonnull - public static final Capability CAP_READABLE; + public static final Capability CAP_READABLE = CapabilityManager.get(new CapabilityToken<>() { + }); @Nonnull - public static final Capability CAP_PASSIVE_PROVIDER; - - static { - CAP_CONNECTOR = CapabilitiesHelper.registerCapability(IMjConnector.class); - CAP_RECEIVER = CapabilitiesHelper.registerCapability(IMjReceiver.class); - CAP_REDSTONE_RECEIVER = CapabilitiesHelper.registerCapability(IMjRedstoneReceiver.class); - CAP_READABLE = CapabilitiesHelper.registerCapability(IMjReadable.class); - CAP_PASSIVE_PROVIDER = CapabilitiesHelper.registerCapability(IMjPassiveProvider.class); + public static final Capability CAP_PASSIVE_PROVIDER = CapabilityManager.get(new CapabilityToken<>() { + }); + + @SubscribeEvent + public static void registerCapability(RegisterCapabilitiesEvent event) { + event.register(IMjConnector.class); + event.register(IMjReceiver.class); + event.register(IMjRedstoneReceiver.class); + event.register(IMjReadable.class); + event.register(IMjPassiveProvider.class); } private static long getMjValue() { diff --git a/api/buildcraft/api/mj/MjBattery.java b/api/buildcraft/api/mj/MjBattery.java index 68c2ea1..dbe682b 100644 --- a/api/buildcraft/api/mj/MjBattery.java +++ b/api/buildcraft/api/mj/MjBattery.java @@ -1,17 +1,17 @@ package buildcraft.api.mj; import io.netty.buffer.ByteBuf; - -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; -import net.minecraft.world.World; - +import net.minecraft.core.BlockPos; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.Vec3; import net.minecraftforge.common.util.INBTSerializable; -/** Provides a basic implementation of a simple battery. Note that you should call {@link #tick(World, BlockPos)} or - * {@link #tick(World, Vec3d)} every tick to allow for losing excess power. */ -public class MjBattery implements INBTSerializable { +/** Provides a basic implementation of a simple battery. Note that you should call {@link #tick(Level, BlockPos)} or + * {@link #tick(Level, Vec3)} every tick to allow for losing excess power. */ +public class MjBattery implements INBTSerializable { + public static final String NBT_STORED = "stored"; + private final long capacity; private long microJoules = 0; @@ -20,15 +20,15 @@ public MjBattery(long capacity) { } @Override - public NBTTagCompound serializeNBT() { - NBTTagCompound nbt = new NBTTagCompound(); - nbt.setLong("stored", microJoules); + public CompoundTag serializeNBT() { + CompoundTag nbt = new CompoundTag(); + nbt.putLong(NBT_STORED, microJoules); return nbt; } @Override - public void deserializeNBT(NBTTagCompound nbt) { - microJoules = nbt.getLong("stored"); + public void deserializeNBT(CompoundTag nbt) { + microJoules = nbt.getLong(NBT_STORED); } public void writeToBuffer(ByteBuf buffer) { @@ -40,14 +40,26 @@ public void readFromBuffer(ByteBuf buffer) { } public long addPower(long microJoulesToAdd, boolean simulate) { +// if (!simulate) { +// this.microJoules += microJoulesToAdd; +// } +// return 0; + + // Calen FIX: now the battery will not receive energy more than this.capability + long excess = 0; + long toAdd = microJoulesToAdd; + if (this.microJoules + microJoulesToAdd > this.capacity) { + excess = this.microJoules + microJoulesToAdd - this.capacity; + toAdd = this.capacity - this.microJoules; + } if (!simulate) { - this.microJoules += microJoulesToAdd; + this.microJoules += toAdd; } - return 0; + return excess; } /** Attempts to add power, but only if this is not already full. - * + * * @param microJoulesToAdd The power to add. * @return The excess power. */ public long addPowerChecking(long microJoulesToAdd, boolean simulate) { @@ -63,7 +75,7 @@ public long extractAll() { } /** Attempts to extract exactly the given amount of power. - * + * * @param power The amount of power to extract. * @return True if the power was removed, false if not. */ public boolean extractPower(long power) { @@ -89,17 +101,17 @@ public long getCapacity() { return capacity; } - public void tick(World world, BlockPos position) { - tick(world, new Vec3d(position.getX() + 0.5, position.getY() + 0.5, position.getZ() + 0.5)); + public void tick(Level world, BlockPos position) { + tick(world, new Vec3(position.getX() + 0.5, position.getY() + 0.5, position.getZ() + 0.5)); } - public void tick(World world, Vec3d position) { + public void tick(Level world, Vec3 position) { if (microJoules > capacity * 2) { losePower(world, position); } } - protected void losePower(World world, Vec3d position) { + protected void losePower(Level world, Vec3 position) { long diff = microJoules - capacity * 2; long lost = ceilDivide(diff, 32); microJoules -= lost; diff --git a/api/buildcraft/api/mj/MjCapabilityHelper.java b/api/buildcraft/api/mj/MjCapabilityHelper.java index c70c74c..24a9a47 100644 --- a/api/buildcraft/api/mj/MjCapabilityHelper.java +++ b/api/buildcraft/api/mj/MjCapabilityHelper.java @@ -1,12 +1,14 @@ package buildcraft.api.mj; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import net.minecraft.util.EnumFacing; - +import net.minecraft.core.Direction; import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.capabilities.ForgeCapabilities; import net.minecraftforge.common.capabilities.ICapabilityProvider; +import net.minecraftforge.common.util.LazyOptional; +import net.minecraftforge.energy.IEnergyStorage; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; /** Provides a quick way to return all types of a single {@link IMjConnector} for all the different capabilities. */ public class MjCapabilityHelper implements ICapabilityProvider { @@ -26,36 +28,160 @@ public class MjCapabilityHelper implements ICapabilityProvider { @Nullable private final IMjPassiveProvider provider; + @Nullable + private final IEnergyStorage rfAutoConvert; + public MjCapabilityHelper(@Nonnull IMjConnector mj) { this.connector = mj; this.receiver = mj instanceof IMjReceiver ? (IMjReceiver) mj : null; this.rsReceiver = mj instanceof IMjRedstoneReceiver ? (IMjRedstoneReceiver) mj : null; this.readable = mj instanceof IMjReadable ? (IMjReadable) mj : null; this.provider = mj instanceof IMjPassiveProvider ? (IMjPassiveProvider) mj : null; - } - @Override - public boolean hasCapability(@Nonnull Capability capability, EnumFacing facing) { - return getCapability(capability, facing) != null; + if (MjAPI.isRfAutoConversionEnabled()) { + rfAutoConvert = new IEnergyStorage() { + + @Override + public int getEnergyStored() { + IMjReadable read = readable; + if (read != null) { + long mjPerRf = MjAPI.getRfConversion().mjPerRf; + return (int) (read.getStored() / mjPerRf); + } else { + return 0; + } + } + + @Override + public int getMaxEnergyStored() { + IMjReadable read = readable; + if (read != null) { + long mjPerRf = MjAPI.getRfConversion().mjPerRf; + return (int) (read.getCapacity() / mjPerRf); + } else { + return 0; + } + } + + @Override + public boolean canReceive() { + return receiver != null && receiver.canReceive(); + } + + /** @return Amount of energy that was (or would have been, if simulated) accepted by the storage. */ + @Override + public int receiveEnergy(int maxReceive, boolean simulate) { + + if (maxReceive <= 0) { + return 0; + } + + IMjReceiver recv = receiver; + if (recv == null || !recv.canReceive()) { + return 0; + } + + long mjPerRf = MjAPI.getRfConversion().mjPerRf; + long maxReceiveMj = maxReceive * mjPerRf; + long excess = recv.receivePower(maxReceiveMj, true); + + // Actual MJ that was accepted + long acceptedMj = maxReceiveMj - excess; + + if (acceptedMj < mjPerRf) { + return 0; + } + + // MJ that was accepted but cannot be converted back to RF + // (We need to actual accepted MJ to be some integer multiple of mjPerRf) + long excessMj = acceptedMj % mjPerRf; + // An MJ value that is an integer multiple of mjPerRf + // Calen FIX: acceptedMj, not maxReceiveMj + // long exactAcceptableMj = maxReceiveMj - excessMj; + long exactAcceptableMj = acceptedMj - excessMj; + + if (exactAcceptableMj <= 0) { + return 0; + } + + int rf = (int) (exactAcceptableMj / mjPerRf); + if (rf * mjPerRf != exactAcceptableMj) { + // Sanity check + throw new IllegalStateException( + "Programmer made a mistake?? mjPerRf=" + mjPerRf + ", rf=" + rf + ", exactAcceptableMJ=" + + exactAcceptableMj + ); + } + + long excess2 = recv.receivePower(exactAcceptableMj, true); + + if (excess2 != 0) { + // Odd. This means we can't actually accept the exact amount + // not actually a crash + return 0; + } + + if (!simulate) { + long excess3 = recv.receivePower(exactAcceptableMj, simulate); + + if (excess3 != excess2) { + throw new IllegalStateException("Bad impl: " + recv.getClass() + " of receivePower"); + } + } + + return rf; + } + + @Override + public boolean canExtract() { + return provider != null; + } + + /** @return Amount of energy that was (or would have been, if simulated) extracted from the storage. */ + @Override + public int extractEnergy(int maxExtract, boolean simulate) { + long mjPerRf = MjAPI.getRfConversion().mjPerRf; + // TODO! + // (Nothing in buildcraft supports this at the moment) + return 0; + } + + }; + } else { + rfAutoConvert = null; + } } +// @Override +// public boolean hasCapability(@Nonnull Capability capability, EnumFacing facing) { +// return getCapability(capability, facing) != null; +// } + @Override - public T getCapability(@Nonnull Capability capability, EnumFacing facing) { + public LazyOptional getCapability(@Nonnull Capability capability, Direction facing) { if (capability == MjAPI.CAP_CONNECTOR) { - return MjAPI.CAP_CONNECTOR.cast(connector); +// return MjAPI.CAP_CONNECTOR.cast(connector); + return connector == null ? LazyOptional.empty() : LazyOptional.of(() -> connector).cast(); } if (capability == MjAPI.CAP_RECEIVER) { - return MjAPI.CAP_RECEIVER.cast(receiver); +// return MjAPI.CAP_RECEIVER.cast(receiver); + return receiver == null ? LazyOptional.empty() : LazyOptional.of(() -> receiver).cast(); } if (capability == MjAPI.CAP_REDSTONE_RECEIVER) { - return MjAPI.CAP_REDSTONE_RECEIVER.cast(rsReceiver); +// return MjAPI.CAP_REDSTONE_RECEIVER.cast(rsReceiver); + return rsReceiver == null ? LazyOptional.empty() : LazyOptional.of(() -> rsReceiver).cast(); } if (capability == MjAPI.CAP_READABLE) { - return MjAPI.CAP_READABLE.cast(readable); +// return MjAPI.CAP_READABLE.cast(readable); + return readable == null ? LazyOptional.empty() : LazyOptional.of(() -> readable).cast(); } if (capability == MjAPI.CAP_PASSIVE_PROVIDER) { - return MjAPI.CAP_PASSIVE_PROVIDER.cast(provider); +// return MjAPI.CAP_PASSIVE_PROVIDER.cast(provider); + return provider == null ? LazyOptional.empty() : LazyOptional.of(() -> provider).cast(); + } + if (capability == ForgeCapabilities.ENERGY) { + return rfAutoConvert == null ? LazyOptional.empty() : LazyOptional.of(() -> rfAutoConvert).cast(); } - return null; + return LazyOptional.empty(); } } diff --git a/api/buildcraft/api/mj/MjRfConversion.java b/api/buildcraft/api/mj/MjRfConversion.java new file mode 100644 index 0000000..8f922b9 --- /dev/null +++ b/api/buildcraft/api/mj/MjRfConversion.java @@ -0,0 +1,46 @@ +package buildcraft.api.mj; + +public class MjRfConversion { + + /** Maximum MJ per RF, or minimum of 5 RF to make 1 MJ. */ + public static final long MAX_MJ_PER_RF = MjAPI.MJ / 5; + + /** Minimum MJ per RF, or maximum of 10,000 RF to make 1 MJ */ + public static final long MIN_MJ_PER_RF = MjAPI.MJ / 10_000; + + /** Default MJ per RF. */ + public static final long DEFAULT_MJ_PER_RF = MjAPI.MJ / 10; + + /** micro MJ per 1 int rf. */ + public final long mjPerRf; + + /** Set to true if {@link #mjPerRf} has been set to the {@link #DEFAULT_MJ_PER_RF} because the passed in value was + * out-of-bounds. (This is used to differentiate between it being explicitly set to the default value). */ + public final boolean usingDefaultValue; + + private MjRfConversion(long mjPerRf) { + if (MIN_MJ_PER_RF <= mjPerRf && mjPerRf <= MAX_MJ_PER_RF) { + usingDefaultValue = false; + this.mjPerRf = mjPerRf; + } else { + usingDefaultValue = true; + this.mjPerRf = DEFAULT_MJ_PER_RF; + } + } + + /** @param mjPerRf Micro Minecraft Joules per 1 RF */ + public static MjRfConversion createRaw(long mjPerRf) { + return new MjRfConversion(mjPerRf); + } + + /** @param configMjPerRf {@link MjAPI#MJ} per RF. This is rounded to the nearest 100 micro MJ */ + public static MjRfConversion createParsed(double configMjPerRf) { + long value = Math.round(configMjPerRf * 10_000); + return new MjRfConversion(value * MjAPI.MJ / 10_000); + } + + public static MjRfConversion createDefault() { + // -10 is always out of range + return new MjRfConversion(-10); + } +} diff --git a/api/buildcraft/api/mj/MjToRfAutoConvertor.java b/api/buildcraft/api/mj/MjToRfAutoConvertor.java new file mode 100644 index 0000000..4507c6b --- /dev/null +++ b/api/buildcraft/api/mj/MjToRfAutoConvertor.java @@ -0,0 +1,192 @@ +package buildcraft.api.mj; + +import net.minecraftforge.energy.IEnergyStorage; + +/** Automatic conversion utility class for treating an RF {@link IEnergyStorage} in the MJ API. */ +public class MjToRfAutoConvertor implements IMjReadable { + + final IEnergyStorage rf; + + /** @return An {@link MjToRfAutoConvertor} that may implement {@link IMjPassiveProvider} and/or {@link IMjReceiver} + * if the given storage can provide/receive energy, or null if the given storage is null, or if + * RF<->MJ autoconversion is not enabled ( {@link MjAPI#isRfAutoConversionEnabled()} ) */ + public static MjToRfAutoConvertor create(IEnergyStorage rf) { + + if (rf == null) { + return null; + } + + if (!MjAPI.isRfAutoConversionEnabled()) { + return null; + } + + if (rf.canReceive()) { + if (rf.canExtract()) { + return new OfBoth(rf); + } else { + return new OfReceiver(rf); + } + } else { + if (rf.canExtract()) { + return new OfProvider(rf); + } else { + return new MjToRfAutoConvertor(rf); + } + } + } + + /** @return An {@link MjToRfAutoConvertor} that may implements {@link IMjReceiver} if the given storage can receive + * energy, or null if the given storage is null, or if RF<->MJ autoconversion is not enabled ( + * {@link MjAPI#isRfAutoConversionEnabled()} ) */ + public static IMjReceiver createReceiver(IEnergyStorage rf) { + MjToRfAutoConvertor convertor = create(rf); + if (convertor instanceof IMjReceiver) { + return (IMjReceiver) convertor; + } else { + return null; + } + } + + /** @return An {@link MjToRfAutoConvertor} that may implements {@link IMjPassiveProvider} if the given storage can + * provide energy, or null if the given storage is null, or if RF<->MJ autoconversion is not enabled ( + * {@link MjAPI#isRfAutoConversionEnabled()} ) */ + public static IMjPassiveProvider createProvider(IEnergyStorage rf) { + MjToRfAutoConvertor convertor = create(rf); + if (convertor instanceof IMjPassiveProvider) { + return (IMjPassiveProvider) convertor; + } else { + return null; + } + } + + MjToRfAutoConvertor(IEnergyStorage storage) { + this.rf = storage; + } + + /** @return true. (Redstone-like engines are expected to not connect due to this class never implementing + * {@link IMjRedstoneReceiver}) */ + @Override + public boolean canConnect(IMjConnector other) { + return true; + } + + @Override + public long getStored() { + return rf.getEnergyStored() * MjAPI.getRfConversion().mjPerRf; + } + + @Override + public long getCapacity() { + return rf.getMaxEnergyStored() * MjAPI.getRfConversion().mjPerRf; + } + + long implGetPowerRequested() { + return (rf.getMaxEnergyStored() - rf.getEnergyStored()) * MjAPI.getRfConversion().mjPerRf; + } + + /** @return excess */ + long implReceivePower(long microJoules, boolean simulate) { + if (!rf.canReceive()) { + return microJoules; + } + + long mjPerRf = MjAPI.getRfConversion().mjPerRf; + + int maxRf = (int) (microJoules / mjPerRf); + + if (maxRf <= 0) { + return microJoules; + } + + int received = rf.receiveEnergy(maxRf, simulate); + + return microJoules - received * mjPerRf; + } + + long implExtractPower(long min, long max, boolean simulate) { + + if (!rf.canExtract()) { + return 0; + } + + long mjPerRf = MjAPI.getRfConversion().mjPerRf; + + int maxRf = (int) (max / mjPerRf); + + if (maxRf <= 0) { + return 0; + } + + int extractedRF = rf.extractEnergy(maxRf, true); + long extractedMJ = extractedRF * mjPerRf; + if (extractedMJ < min) { + return 0; + } + + if (!simulate) { + rf.extractEnergy(maxRf, simulate); + } + + return extractedMJ; + } +} + +final class OfReceiver extends MjToRfAutoConvertor implements IMjReceiver { + + OfReceiver(IEnergyStorage storage) { + super(storage); + } + + @Override + public boolean canReceive() { + return rf.canReceive(); + } + + @Override + public long getPowerRequested() { + return implGetPowerRequested(); + } + + @Override + public long receivePower(long microJoules, boolean simulate) { + return implReceivePower(microJoules, simulate); + } +} + +final class OfProvider extends MjToRfAutoConvertor implements IMjPassiveProvider { + OfProvider(IEnergyStorage storage) { + super(storage); + } + + @Override + public long extractPower(long min, long max, boolean simulate) { + return implExtractPower(min, max, simulate); + } +} + +final class OfBoth extends MjToRfAutoConvertor implements IMjReceiver, IMjPassiveProvider { + + OfBoth(IEnergyStorage storage) { + super(storage); + } + + @Override + public boolean canReceive() { + return rf.canReceive(); + } + + @Override + public long getPowerRequested() { + return implGetPowerRequested(); + } + + @Override + public long receivePower(long microJoules, boolean simulate) { + return implReceivePower(microJoules, simulate); + } + + @Override + public long extractPower(long min, long max, boolean simulate) { + return implExtractPower(min, max, simulate); + } +} diff --git a/api/buildcraft/api/net/IMessage.java b/api/buildcraft/api/net/IMessage.java new file mode 100644 index 0000000..4e16d57 --- /dev/null +++ b/api/buildcraft/api/net/IMessage.java @@ -0,0 +1,21 @@ +package buildcraft.api.net; + +import buildcraft.api.core.BCLog; +import net.minecraft.network.FriendlyByteBuf; + +public interface IMessage { + void fromBytes(FriendlyByteBuf buf); + + void toBytes(FriendlyByteBuf buf); + + public static MSG staticFromBytes(Class clazz, FriendlyByteBuf buf) { + try { + MSG message = clazz.newInstance(); + message.fromBytes(buf); + return message; + } catch (Exception e) { + BCLog.logger.error(e); + return null; + } + } +} diff --git a/api/buildcraft/api/net/IMessageHandler.java b/api/buildcraft/api/net/IMessageHandler.java new file mode 100644 index 0000000..6a82a0e --- /dev/null +++ b/api/buildcraft/api/net/IMessageHandler.java @@ -0,0 +1,7 @@ +package buildcraft.api.net; + +import net.minecraftforge.network.NetworkEvent; + +public interface IMessageHandler { + REPLY onMessage(REQ message, NetworkEvent.Context ctx); +} diff --git a/api/buildcraft/api/power/IEngine.java b/api/buildcraft/api/power/IEngine.java index c25037c..bc71333 100644 --- a/api/buildcraft/api/power/IEngine.java +++ b/api/buildcraft/api/power/IEngine.java @@ -4,23 +4,23 @@ * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.power; -import net.minecraft.util.EnumFacing; +import net.minecraft.core.Direction; /** Engines should implement this interface if they want to support BuildCraft's behaviour of passing power between * engines without using receivePower() (which has other issues). */ public interface IEngine { /** Returns true if the engine wants to receive power from another engine on this side. - * + * * @param side * @return */ - boolean canReceiveFromEngine(EnumFacing side); + boolean canReceiveFromEngine(Direction side); /** Receives power from an engine. * * @param microJoules The number of micro joules to add. * @param simulate If true then just pretend you received power- don't actually change any of your internal state. * @return True if all the power was accepted, false if not. - * + * * @see buildcraft.api.mj.IMjReceiver#receivePower(long, boolean) */ boolean receivePower(long microJoules, boolean simulate); } diff --git a/api/buildcraft/api/power/IRedstoneEngine.java b/api/buildcraft/api/power/IRedstoneEngine.java index 3fc534d..e942d61 100644 --- a/api/buildcraft/api/power/IRedstoneEngine.java +++ b/api/buildcraft/api/power/IRedstoneEngine.java @@ -4,4 +4,5 @@ * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.power; -public interface IRedstoneEngine {} +public interface IRedstoneEngine { +} diff --git a/api/buildcraft/api/power/package-info.java b/api/buildcraft/api/power/package-info.java index 66e7868..6f368b4 100644 --- a/api/buildcraft/api/power/package-info.java +++ b/api/buildcraft/api/power/package-info.java @@ -2,7 +2,5 @@ * * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -@API(apiVersion = "1.3", owner = "buildcraftapi_core", provides = "buildcraftapi_power") +//@API(apiVersion = "1.3", owner = "buildcraftapi_core", provides = "buildcraftapi_power") package buildcraft.api.power; - -import net.minecraftforge.fml.common.API; diff --git a/api/buildcraft/api/properties/BuildCraftProperties.java b/api/buildcraft/api/properties/BuildCraftProperties.java index a04b44e..d7c186a 100644 --- a/api/buildcraft/api/properties/BuildCraftProperties.java +++ b/api/buildcraft/api/properties/BuildCraftProperties.java @@ -1,56 +1,48 @@ package buildcraft.api.properties; -import java.util.Map; - +import buildcraft.api.enums.*; import com.google.common.collect.Maps; +import net.minecraft.core.Direction; +import net.minecraft.world.item.DyeColor; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import net.minecraft.world.level.block.state.properties.Property; -import net.minecraft.block.properties.IProperty; -import net.minecraft.block.properties.PropertyBool; -import net.minecraft.block.properties.PropertyEnum; -import net.minecraft.block.properties.PropertyInteger; -import net.minecraft.item.EnumDyeColor; -import net.minecraft.util.EnumFacing; - -import buildcraft.api.enums.EnumDecoratedBlock; -import buildcraft.api.enums.EnumEngineType; -import buildcraft.api.enums.EnumLaserTableType; -import buildcraft.api.enums.EnumMachineState; -import buildcraft.api.enums.EnumOptionalSnapshotType; -import buildcraft.api.enums.EnumPowerStage; -import buildcraft.api.enums.EnumSpring; +import java.util.Map; public final class BuildCraftProperties { - public static final IProperty BLOCK_FACING = PropertyEnum.create("facing", EnumFacing.class, EnumFacing.Plane.HORIZONTAL.facings()); - public static final IProperty BLOCK_FACING_6 = PropertyEnum.create("facing", EnumFacing.class); + public static final Property BLOCK_FACING = EnumProperty.create("facing", Direction.class, new Direction[] { Direction.NORTH, Direction.EAST, Direction.SOUTH, Direction.WEST }); + public static final Property BLOCK_FACING_6 = EnumProperty.create("facing", Direction.class); - public static final IProperty BLOCK_COLOR = PropertyEnum.create("color", EnumDyeColor.class); - public static final IProperty SPRING_TYPE = PropertyEnum.create("type", EnumSpring.class); - public static final IProperty ENGINE_TYPE = PropertyEnum.create("type", EnumEngineType.class); - public static final IProperty LASER_TABLE_TYPE = PropertyEnum.create("type", EnumLaserTableType.class); - public static final IProperty MACHINE_STATE = PropertyEnum.create("state", EnumMachineState.class); - public static final IProperty ENERGY_STAGE = PropertyEnum.create("stage", EnumPowerStage.class); - public static final IProperty SNAPSHOT_TYPE = PropertyEnum.create("snapshot_type", EnumOptionalSnapshotType.class); - public static final IProperty DECORATED_BLOCK = PropertyEnum.create("decoration_type", EnumDecoratedBlock.class); + public static final Property BLOCK_COLOR = EnumProperty.create("color", DyeColor.class); + // public static final EnumProperty SPRING_TYPE = EnumProperty.create("type", EnumSpring.class); +// public static final Property ENGINE_TYPE = EnumProperty.create("type", EnumEngineType.class); + public static final Property LASER_TABLE_TYPE = EnumProperty.create("type", EnumLaserTableType.class); + public static final Property MACHINE_STATE = EnumProperty.create("state", EnumMachineState.class); + public static final Property ENERGY_STAGE = EnumProperty.create("stage", EnumPowerStage.class); + public static final Property SNAPSHOT_TYPE = EnumProperty.create("snapshot_type", EnumOptionalSnapshotType.class); + public static final Property DECORATED_BLOCK = EnumProperty.create("decoration_type", EnumDecoratedBlock.class); - public static final IProperty GENERIC_PIPE_DATA = PropertyInteger.create("pipe_data", 0, 15); - public static final IProperty LED_POWER = PropertyInteger.create("led_power", 0, 3); + public static final Property GENERIC_PIPE_DATA = IntegerProperty.create("pipe_data", 0, 15); + public static final Property LED_POWER = IntegerProperty.create("led_power", 0, 3); - public static final IProperty JOINED_BELOW = PropertyBool.create("joined_below"); - public static final IProperty MOVING = PropertyBool.create("moving"); - public static final IProperty LED_DONE = PropertyBool.create("led_done"); - public static final IProperty ACTIVE = PropertyBool.create("active"); - public static final IProperty VALID = PropertyBool.create("valid"); + public static final Property JOINED_BELOW = BooleanProperty.create("joined_below"); // 这里的注册名就是model文件里的条件 + public static final Property MOVING = BooleanProperty.create("moving"); + public static final Property LED_DONE = BooleanProperty.create("led_done"); + // public static final Property ACTIVE = BooleanProperty.create("active"); // set but never used + public static final Property VALID = BooleanProperty.create("valid"); - public static final IProperty CONNECTED_UP = PropertyBool.create("connected_up"); - public static final IProperty CONNECTED_DOWN = PropertyBool.create("connected_down"); - public static final IProperty CONNECTED_EAST = PropertyBool.create("connected_east"); - public static final IProperty CONNECTED_WEST = PropertyBool.create("connected_west"); - public static final IProperty CONNECTED_NORTH = PropertyBool.create("connected_north"); - public static final IProperty CONNECTED_SOUTH = PropertyBool.create("connected_south"); + public static final Property CONNECTED_UP = BooleanProperty.create("connected_up"); + public static final Property CONNECTED_DOWN = BooleanProperty.create("connected_down"); + public static final Property CONNECTED_EAST = BooleanProperty.create("connected_east"); + public static final Property CONNECTED_WEST = BooleanProperty.create("connected_west"); + public static final Property CONNECTED_NORTH = BooleanProperty.create("connected_north"); + public static final Property CONNECTED_SOUTH = BooleanProperty.create("connected_south"); - public static final Map> CONNECTED_MAP; + public static final Map> CONNECTED_MAP; - // Block state setting flags -these are used by World.markAndNotifyBlock and World.setBlockState. These flags can be + // Block state setting flags -these are used by Level.markAndNotifyBlock and Level.setBlockState. These flags can be // added together to pass the additions public static final int UPDATE_NONE = 0; /** This updates the neighbouring blocks that the new block is set. It also updates the comparator output of this @@ -63,23 +55,24 @@ public final class BuildCraftProperties { * world.isRemote returns false. */ public static final int UPDATE_EVEN_CLIENT = 4 + MARK_BLOCK_FOR_UPDATE; // 6 - // Pre-added flags- pass these as-is to the World.markAndNotifyBlock and World.setBlockState methods. + // Pre-added flags- pass these as-is to the Level.markAndNotifyBlock and Level.setBlockState methods. /** This will do what both {@link #UPDATE_NEIGHBOURS} and {@link #MARK_BLOCK_FOR_UPDATE} do. */ public static final int MARK_THIS_AND_NEIGHBOURS = UPDATE_NEIGHBOURS + MARK_BLOCK_FOR_UPDATE; /** This will update everything about this block. */ public static final int UPDATE_ALL = UPDATE_NEIGHBOURS + MARK_BLOCK_FOR_UPDATE + UPDATE_EVEN_CLIENT; static { - Map> map = Maps.newEnumMap(EnumFacing.class); - map.put(EnumFacing.DOWN, CONNECTED_DOWN); - map.put(EnumFacing.UP, CONNECTED_UP); - map.put(EnumFacing.EAST, CONNECTED_EAST); - map.put(EnumFacing.WEST, CONNECTED_WEST); - map.put(EnumFacing.NORTH, CONNECTED_NORTH); - map.put(EnumFacing.SOUTH, CONNECTED_SOUTH); + Map> map = Maps.newEnumMap(Direction.class); + map.put(Direction.DOWN, CONNECTED_DOWN); + map.put(Direction.UP, CONNECTED_UP); + map.put(Direction.EAST, CONNECTED_EAST); + map.put(Direction.WEST, CONNECTED_WEST); + map.put(Direction.NORTH, CONNECTED_NORTH); + map.put(Direction.SOUTH, CONNECTED_SOUTH); CONNECTED_MAP = Maps.immutableEnumMap(map); } /** Deactivate constructor */ - private BuildCraftProperties() {} + private BuildCraftProperties() { + } } diff --git a/api/buildcraft/api/recipes/AssemblyRecipe.java b/api/buildcraft/api/recipes/AssemblyRecipe.java deleted file mode 100644 index cbd8eb5..0000000 --- a/api/buildcraft/api/recipes/AssemblyRecipe.java +++ /dev/null @@ -1,85 +0,0 @@ -package buildcraft.api.recipes; - -import java.util.Set; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import net.minecraft.item.ItemStack; -import net.minecraft.util.NonNullList; -import net.minecraft.util.ResourceLocation; - -import net.minecraftforge.registries.IForgeRegistryEntry; - -/** - * @deprecated TEMPORARY CLASS DO NOT USE! - */ -@Deprecated -public abstract class AssemblyRecipe implements Comparable, IForgeRegistryEntry { - private ResourceLocation name; - - /** - * The outputs this recipe can generate with any of the given inputs - * @param inputs Current ingredients in the assembly table - * @return A Set containing all possible outputs given the given inputs or an empty one if nothing can be assembled from the given inputs - */ - public abstract Set getOutputs(NonNullList inputs); - - /** - * Used to determine all outputs from this recipe for recipe previews (guide book and/or JEI) - */ - public abstract Set getOutputPreviews(); - - /** - * Used to determine what items to use up for the given output - * @param output The output we want to know the inputs for, only ever called using stacks obtained from getOutputs or getOutputPreviews - */ - public abstract Set getInputsFor(@Nonnull ItemStack output); - - /** - * Used to determine how much MJ is required to asemble the given output item - * @param output The output we want to know the MJ cost for, only ever called using stacks obtained from getOutputs or getOutputPreviews - */ - public abstract long getRequiredMicroJoulesFor(@Nonnull ItemStack output); - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - - AssemblyRecipe that = (AssemblyRecipe) o; - - return name.equals(that.name); - } - - @Override - public int hashCode() { - return name.hashCode(); - } - - @Override - public int compareTo(AssemblyRecipe o) { - return name.toString().compareTo(o.name.toString()); - } - - @Override - public AssemblyRecipe setRegistryName(ResourceLocation name) { - this.name = name; - return this; - } - - @Nullable - @Override - public ResourceLocation getRegistryName() { - return name; - } - - @Override - public Class getRegistryType() { - return AssemblyRecipe.class; - } -} diff --git a/api/buildcraft/api/recipes/AssemblyRecipeBasic.java b/api/buildcraft/api/recipes/AssemblyRecipeBasic.java deleted file mode 100644 index 094d3c9..0000000 --- a/api/buildcraft/api/recipes/AssemblyRecipeBasic.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2017 SpaceToad and the BuildCraft team - * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not - * distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/ - */ - -package buildcraft.api.recipes; - -import java.util.Collections; -import java.util.Set; - -import javax.annotation.Nonnull; - -import com.google.common.collect.ImmutableSet; - -import net.minecraft.item.ItemStack; -import net.minecraft.util.NonNullList; -import net.minecraft.util.ResourceLocation; - -import buildcraft.api.core.BuildCraftAPI; - -/** - * @deprecated TEMPORARY CLASS DO NOT USE! - */ -@Deprecated -public class AssemblyRecipeBasic extends AssemblyRecipe { - private final long requiredMicroJoules; - private final ImmutableSet requiredStacks; - private final ImmutableSet output; - - public AssemblyRecipeBasic(ResourceLocation name, long requiredMicroJoules, ImmutableSet requiredStacks, @Nonnull ItemStack output) { - this.requiredMicroJoules = requiredMicroJoules; - this.requiredStacks = ImmutableSet.copyOf(requiredStacks); - this.output = ImmutableSet.of(output); - setRegistryName(name); - } - - public AssemblyRecipeBasic(String name, long requiredMicroJoules, ImmutableSet requiredStacks, @Nonnull ItemStack output) { - this(BuildCraftAPI.nameToResourceLocation(name), requiredMicroJoules, requiredStacks, output); - } - - public AssemblyRecipeBasic(String name, long requiredMicroJoules, Set requiredStacks, @Nonnull ItemStack output) { - this(name, requiredMicroJoules, ImmutableSet.copyOf(requiredStacks), output); - } - - @Override - public Set getOutputs(NonNullList inputs) { - if (requiredStacks.stream().allMatch((definition) -> inputs.stream().anyMatch((stack) -> !stack.isEmpty() && definition.ingredient.apply(stack) && stack.getCount() >= definition.count))) - return output; - return Collections.emptySet(); - } - - @Override - public Set getOutputPreviews() { - return output; - } - - @Override - public Set getInputsFor(@Nonnull ItemStack output) { - return requiredStacks; - } - - @Override - public long getRequiredMicroJoulesFor(@Nonnull ItemStack output) { - return requiredMicroJoules; - } -} diff --git a/api/buildcraft/api/recipes/BuildcraftRecipeRegistry.java b/api/buildcraft/api/recipes/BuildcraftRecipeRegistry.java index 22ee171..6e6218f 100644 --- a/api/buildcraft/api/recipes/BuildcraftRecipeRegistry.java +++ b/api/buildcraft/api/recipes/BuildcraftRecipeRegistry.java @@ -8,6 +8,8 @@ public final class BuildcraftRecipeRegistry { public static IIntegrationRecipeRegistry integrationRecipes; public static IRefineryRecipeManager refineryRecipes; + public static IProgrammingRecipeManager programmingRecipes; - private BuildcraftRecipeRegistry() {} + private BuildcraftRecipeRegistry() { + } } diff --git a/api/buildcraft/api/recipes/EnumAssemblyRecipeType.java b/api/buildcraft/api/recipes/EnumAssemblyRecipeType.java new file mode 100644 index 0000000..3b8f726 --- /dev/null +++ b/api/buildcraft/api/recipes/EnumAssemblyRecipeType.java @@ -0,0 +1,6 @@ +package buildcraft.api.recipes; + +public enum EnumAssemblyRecipeType { + BASIC, + FACADE, +} diff --git a/api/buildcraft/api/recipes/IAssemblyRecipe.java b/api/buildcraft/api/recipes/IAssemblyRecipe.java new file mode 100644 index 0000000..fc02e2d --- /dev/null +++ b/api/buildcraft/api/recipes/IAssemblyRecipe.java @@ -0,0 +1,77 @@ +package buildcraft.api.recipes; + +import buildcraft.api.BCModules; +import net.minecraft.core.NonNullList; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.Container; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.world.level.Level; + +import javax.annotation.Nonnull; +import java.util.Set; + +public interface IAssemblyRecipe extends Comparable, Recipe { + public static final ResourceLocation TYPE_ID = new ResourceLocation(BCModules.SILICON.getModId(), "assembly"); + + public static final RecipeType TYPE = RecipeType.simple(TYPE_ID); + + /** + * The outputs this recipe can generate with any of the given inputs + * + * @param inputs Current ingredients in the assembly table + * @return A Set containing all possible outputs given the given inputs or an empty one if nothing can be assembled from the given inputs + */ + public abstract Set getOutputs(NonNullList inputs); + + /** Used to determine all outputs from this recipe for recipe previews (guide book and/or JEI) */ + public abstract Set getOutputPreviews(); + + /** + * Used to determine what items to use up for the given output + * + * @param output The output we want to know the inputs for, only ever called using stacks obtained from getOutputs or getOutputPreviews + */ + public abstract Set getInputsFor(@Nonnull ItemStack output); + + /** + * Used to determine how much MJ is required to asemble the given output item + * + * @param output The output we want to know the MJ cost for, only ever called using stacks obtained from getOutputs or getOutputPreviews + */ + public abstract long getRequiredMicroJoulesFor(@Nonnull ItemStack output); + + @Override + public default int compareTo(IAssemblyRecipe o) { + return getId().toString().compareTo(o.getId().toString()); + } + + public abstract long getRequiredMicroJoules(); + + public abstract Set getRequiredIngredientStacks(); + + public abstract Set getOutput(); + + // Recipe + + @Override + public default boolean matches(Container inv, Level world) { + return false; + } + + @Override + public default boolean canCraftInDimensions(int width, int height) { + return true; + } + + @Override + public default boolean isSpecial() { + return true; + } + + @Override + public default RecipeType getType() { + return TYPE; + } +} diff --git a/api/buildcraft/api/recipes/IIntegrationRecipeProvider.java b/api/buildcraft/api/recipes/IIntegrationRecipeProvider.java index a6ebeaa..2f4aa08 100644 --- a/api/buildcraft/api/recipes/IIntegrationRecipeProvider.java +++ b/api/buildcraft/api/recipes/IIntegrationRecipeProvider.java @@ -1,26 +1,29 @@ package buildcraft.api.recipes; +import net.minecraft.core.NonNullList; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; + import javax.annotation.Nonnull; import javax.annotation.Nullable; -import net.minecraft.item.ItemStack; -import net.minecraft.util.NonNullList; -import net.minecraft.util.ResourceLocation; - /** Provides a way of registering complex recipes without needing to register every possible variant. If you want the * recipes to be viewable in JEI and the guide book then you will *also* need to implement the bc lib class * IIntegrationRecipeViewable. */ public interface IIntegrationRecipeProvider { /** Gets an integration recipe for the given ingredients. - * + * * @param target The center itemstack. * @param toIntegrate A list of stacks to try to integrate to the * @return */ @Nullable - IntegrationRecipe getRecipeFor(@Nonnull ItemStack target, @Nonnull NonNullList toIntegrate); + // IntegrationRecipe getRecipeFor(@Nonnull ItemStack target, @Nonnull NonNullList toIntegrate); + IntegrationRecipe getRecipeFor(@Nonnull ItemStack target, @Nonnull NonNullList toIntegrate, Level world); /** * Returns recipe by it's name */ - IntegrationRecipe getRecipe(@Nonnull ResourceLocation name); + // IntegrationRecipe getRecipe(@Nonnull ResourceLocation name); + IntegrationRecipe getRecipe(@Nonnull ResourceLocation name, Level world); } diff --git a/api/buildcraft/api/recipes/IIntegrationRecipeRegistry.java b/api/buildcraft/api/recipes/IIntegrationRecipeRegistry.java index d4bd8ee..8f94814 100644 --- a/api/buildcraft/api/recipes/IIntegrationRecipeRegistry.java +++ b/api/buildcraft/api/recipes/IIntegrationRecipeRegistry.java @@ -1,5 +1,7 @@ package buildcraft.api.recipes; +import net.minecraft.world.level.Level; + import java.util.Iterator; public interface IIntegrationRecipeRegistry extends IIntegrationRecipeProvider { @@ -9,6 +11,7 @@ public interface IIntegrationRecipeRegistry extends IIntegrationRecipeProvider { * Gets all of the simple recipes that are registered. Note that you *can* use the returned iterator's * {@link Iterator#remove()} method to remove recipes from this registry. */ - Iterable getAllRecipes(); + // Iterable getAllRecipes(); + Iterable getAllRecipes(Level world); } diff --git a/api/buildcraft/api/recipes/IProgrammingRecipe.java b/api/buildcraft/api/recipes/IProgrammingRecipe.java new file mode 100644 index 0000000..316295d --- /dev/null +++ b/api/buildcraft/api/recipes/IProgrammingRecipe.java @@ -0,0 +1,79 @@ +package buildcraft.api.recipes; + +import buildcraft.api.BCModules; +import net.minecraft.core.RegistryAccess; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.Container; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.world.level.Level; + +// public interface IProgrammingRecipe +public interface IProgrammingRecipe extends Recipe { + public static final ResourceLocation TYPE_ID = new ResourceLocation(BCModules.SILICON.getModId(), "programming"); + + public static final RecipeType TYPE = RecipeType.simple(TYPE_ID); + + @Override + default RecipeType getType() { + return TYPE; + } + + ResourceLocation getId(); + +// /** Get a list (size at least width*height) of ItemStacks representing options. +// * +// * @param width The width of the Programming Table panel. +// * @param height The height of the Programming Table panel. +// * @return */ +// List getOptions(int width, int height); + + /** Get the energy cost of a given option ItemStack. + * + * @return */ + // int getEnergyCost(ItemStack option); + long getEnergyCost(); + + /** @param input The input stack. + * @return Whether this recipe applies to the given input stack. */ + boolean canCraft(ItemStack input); + + /** Craft the input ItemStack with the given option into an output ItemStack. + * + * @param input + * @return The output ItemStack. */ + // ItemStack craft(ItemStack input, ItemStack option); + ItemStack craft(ItemStack input); + + IngredientStack getInput(); + + ItemStack getOutput(); + + // Recipe + + @Override + public default boolean matches(Container inv, Level world) { + return false; + } + + @Override + default ItemStack assemble(Container inv, RegistryAccess registryAccess) { + return ItemStack.EMPTY; + } + + @Override + public default boolean canCraftInDimensions(int width, int height) { + return true; + } + + @Override + default ItemStack getResultItem(RegistryAccess registryAccess) { + return ItemStack.EMPTY; + } + + @Override + public default boolean isSpecial() { + return true; + } +} diff --git a/api/buildcraft/api/recipes/IProgrammingRecipeManager.java b/api/buildcraft/api/recipes/IProgrammingRecipeManager.java new file mode 100644 index 0000000..360b695 --- /dev/null +++ b/api/buildcraft/api/recipes/IProgrammingRecipeManager.java @@ -0,0 +1,29 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.recipes; + +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.Level; + +import java.util.Collection; +import java.util.List; + +public interface IProgrammingRecipeManager { + void addRecipe(IProgrammingRecipe recipe); + + // void removeRecipe(String id); + void removeRecipe(ResourceLocation id); + + void removeRecipe(IProgrammingRecipe recipe); + + // IProgrammingRecipe getRecipe(String id); + IProgrammingRecipe getRecipe(Level world, ResourceLocation id); + + // Collection getRecipes(); + Collection getRecipes(Level world); + + // Calen 1.18.2 + List getOptions(List recipes, int width, int height); +} diff --git a/api/buildcraft/api/recipes/IRefineryRecipeManager.java b/api/buildcraft/api/recipes/IRefineryRecipeManager.java index 65b523b..4e8c78d 100644 --- a/api/buildcraft/api/recipes/IRefineryRecipeManager.java +++ b/api/buildcraft/api/recipes/IRefineryRecipeManager.java @@ -1,30 +1,44 @@ package buildcraft.api.recipes; +import buildcraft.api.BCModules; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.Container; +import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.world.level.Level; +import net.minecraftforge.fluids.FluidStack; + +import javax.annotation.Nullable; import java.util.Collection; import java.util.function.Predicate; import java.util.stream.Stream; -import javax.annotation.Nullable; - -import net.minecraftforge.fluids.FluidStack; - public interface IRefineryRecipeManager { - IHeatableRecipe createHeatingRecipe(FluidStack in, FluidStack out, int heatFrom, int heatTo); + // IHeatableRecipe createHeatingRecipe(FluidStack in, FluidStack out, int heatFrom, int heatTo); + IHeatableRecipe createHeatingRecipe(ResourceLocation id, FluidStack in, FluidStack out, int heatFrom, int heatTo); - default IHeatableRecipe addHeatableRecipe(FluidStack in, FluidStack out, int heatFrom, int heatTo) { - return getHeatableRegistry().addRecipe(createHeatingRecipe(in, out, heatFrom, heatTo)); + // default IHeatableRecipe addHeatableRecipe(FluidStack in, FluidStack out, int heatFrom, int heatTo) + default IHeatableRecipe addUnregisteredHeatableRecipe(ResourceLocation id, FluidStack in, FluidStack out, int heatFrom, int heatTo) { +// return getHeatableRegistry().addRecipe(createHeatingRecipe(in, out, heatFrom, heatTo)); + return getHeatableRegistry().addUnregisteredRecipe(createHeatingRecipe(id, in, out, heatFrom, heatTo)); } - ICoolableRecipe createCoolableRecipe(FluidStack in, FluidStack out, int heatFrom, int heatTo); + // ICoolableRecipe createCoolableRecipe(FluidStack in, FluidStack out, int heatFrom, int heatTo); + ICoolableRecipe createCoolableRecipe(ResourceLocation id, FluidStack in, FluidStack out, int heatFrom, int heatTo); - default ICoolableRecipe addCoolableRecipe(FluidStack in, FluidStack out, int heatFrom, int heatTo) { - return getCoolableRegistry().addRecipe(createCoolableRecipe(in, out, heatFrom, heatTo)); + // default ICoolableRecipe addCoolableRecipe(FluidStack in, FluidStack out, int heatFrom, int heatTo) + default ICoolableRecipe addUnregisteredCoolableRecipe(ResourceLocation id, FluidStack in, FluidStack out, int heatFrom, int heatTo) { +// return getCoolableRegistry().addRecipe(createCoolableRecipe(in, out, heatFrom, heatTo)); + return getCoolableRegistry().addUnregisteredRecipe(createCoolableRecipe(id, in, out, heatFrom, heatTo)); } - IDistillationRecipe createDistillationRecipe(FluidStack in, FluidStack outGas, FluidStack outLiquid, long powerRequired); + // IDistillationRecipe createDistillationRecipe(FluidStack in, FluidStack outGas, FluidStack outLiquid, long powerRequired); + IDistillationRecipe createDistillationRecipe(ResourceLocation id, FluidStack in, FluidStack outGas, FluidStack outLiquid, long powerRequired); - default IDistillationRecipe addDistillationRecipe(FluidStack in, FluidStack outGas, FluidStack outLiquid, long powerRequired) { - return getDistillationRegistry().addRecipe(createDistillationRecipe(in, outGas, outLiquid, powerRequired)); + // default IDistillationRecipe addDistillationRecipe(FluidStack in, FluidStack outGas, FluidStack outLiquid, long powerRequired) + default IDistillationRecipe addUnregisteredDistillationRecipe(ResourceLocation id, FluidStack in, FluidStack outGas, FluidStack outLiquid, long powerRequired) { +// return getDistillationRegistry().addRecipe(createDistillationRecipe(in, outGas, outLiquid, powerRequired)); + return getDistillationRegistry().addUnregisteredRecipe(createDistillationRecipe(id, in, outGas, outLiquid, powerRequired)); } IRefineryRegistry getHeatableRegistry(); @@ -36,30 +50,39 @@ default IDistillationRecipe addDistillationRecipe(FluidStack in, FluidStack outG interface IRefineryRegistry { /** @return an unmodifiable collection containing all of the distillation recipes that satisfy the given * predicate. All of the recipe objects are guaranteed to never be null. */ - Stream getRecipes(Predicate toReturn); +// Stream getRecipes(Predicate toReturn); + Stream getRecipes(Level world, Predicate toReturn); /** @return an unmodifiable set containing all of the distillation recipes. */ - Collection getAllRecipes(); +// Collection getAllRecipes(); + Collection getAllRecipes(Level world); @Nullable - R getRecipeForInput(@Nullable FluidStack fluid); +// R getRecipeForInput(@Nullable FluidStack fluid); + R getRecipeForInput(Level world, @Nullable FluidStack fluid); - Collection removeRecipes(Predicate toRemove); + // Collection removeRecipes(Predicate toRemove); + Collection removeUnregisteredRecipes(Predicate toRemove); /** Adds the given recipe to the registry. Note that this will remove any existing recipes for the passed * recipe's {@link IRefineryRecipe#in()} - * + * * @param recipe The recipe to add. * @return The input recipe. */ - R addRecipe(R recipe); +// R addRecipe(R recipe); + R addUnregisteredRecipe(R recipe); + +// // Calen +// RecipeType getRecipeType; } - interface IRefineryRecipe { + // interface IRefineryRecipe + interface IRefineryRecipe extends Recipe { FluidStack in(); } interface IHeatExchangerRecipe extends IRefineryRecipe { - @Nullable + // @Nullable FluidStack out(); int heatFrom(); @@ -67,15 +90,43 @@ interface IHeatExchangerRecipe extends IRefineryRecipe { int heatTo(); } - interface IHeatableRecipe extends IHeatExchangerRecipe {} + interface IHeatableRecipe extends IHeatExchangerRecipe { + public static final ResourceLocation TYPE_ID = new ResourceLocation(BCModules.FACTORY.getModId(), "heat_exchange/heatable"); + + public static final RecipeType TYPE = RecipeType.simple(TYPE_ID); - interface ICoolableRecipe extends IHeatExchangerRecipe {} + + @Override + default RecipeType getType() { + return TYPE; + } + } + + interface ICoolableRecipe extends IHeatExchangerRecipe { + public static final ResourceLocation TYPE_ID = new ResourceLocation(BCModules.FACTORY.getModId(), "heat_exchange/coolable"); + + public static final RecipeType TYPE = RecipeType.simple(TYPE_ID); + + @Override + default RecipeType getType() { + return TYPE; + } + } interface IDistillationRecipe extends IRefineryRecipe { + public static final ResourceLocation TYPE_ID = new ResourceLocation(BCModules.FACTORY.getModId(), "distillation"); + + public static final RecipeType TYPE = RecipeType.simple(TYPE_ID); + long powerRequired(); FluidStack outGas(); FluidStack outLiquid(); + + @Override + default RecipeType getType() { + return TYPE; + } } } diff --git a/api/buildcraft/api/recipes/IngredientStack.java b/api/buildcraft/api/recipes/IngredientStack.java index adbcdea..2dc1c9c 100644 --- a/api/buildcraft/api/recipes/IngredientStack.java +++ b/api/buildcraft/api/recipes/IngredientStack.java @@ -6,8 +6,12 @@ package buildcraft.api.recipes; -import net.minecraft.item.crafting.Ingredient; - +import com.google.gson.JsonElement; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.tags.TagKey; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.world.level.ItemLike; import net.minecraftforge.common.crafting.CraftingHelper; public final class IngredientStack { @@ -23,7 +27,31 @@ public IngredientStack(Ingredient ingredient) { this(ingredient, 1); } - public static IngredientStack of(Object o) { - return new IngredientStack(CraftingHelper.getIngredient(o)); + // public static IngredientStack of(Object o) + public static IngredientStack of(JsonElement o) { + return new IngredientStack(CraftingHelper.getIngredient(o, true)); + } + + public static IngredientStack of(ItemStack o) { + return new IngredientStack(Ingredient.of(o)); + } + + public static IngredientStack of(ItemLike o) { + return new IngredientStack(Ingredient.of(o)); + } + + public static IngredientStack of(TagKey tag) { + return new IngredientStack(Ingredient.of(tag)); + } + + public void toNetwork(FriendlyByteBuf buffer) { + buffer.writeInt(this.count); + this.ingredient.toNetwork(buffer); + } + + public static IngredientStack fromNetwork(FriendlyByteBuf buffer) { + int countIn = buffer.readInt(); + Ingredient ingredientIn = Ingredient.fromNetwork(buffer); + return new IngredientStack(ingredientIn, countIn); } } diff --git a/api/buildcraft/api/recipes/IntegrationRecipe.java b/api/buildcraft/api/recipes/IntegrationRecipe.java index 984404b..29da7f3 100644 --- a/api/buildcraft/api/recipes/IntegrationRecipe.java +++ b/api/buildcraft/api/recipes/IntegrationRecipe.java @@ -1,18 +1,32 @@ package buildcraft.api.recipes; +import buildcraft.api.BCModules; +import com.google.common.collect.ImmutableList; +import net.minecraft.core.NonNullList; +import net.minecraft.core.RegistryAccess; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.Container; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.world.level.Level; + import javax.annotation.Nonnull; -import com.google.common.collect.ImmutableList; +public abstract class IntegrationRecipe implements Recipe { + public static final ResourceLocation TYPE_ID = new ResourceLocation(BCModules.SILICON.getModId(), "integration"); -import net.minecraft.item.ItemStack; -import net.minecraft.util.NonNullList; -import net.minecraft.util.ResourceLocation; + public static final RecipeType TYPE = RecipeType.simple(TYPE_ID); -public abstract class IntegrationRecipe { public final ResourceLocation name; - public IntegrationRecipe(ResourceLocation name) { + private final long energyCost; + private final int maxExpansionCount; + + public IntegrationRecipe(ResourceLocation name, long energyCost, int maxExpansionCount) { this.name = name; + this.energyCost = energyCost; + this.maxExpansionCount = maxExpansionCount; } /** @@ -23,22 +37,31 @@ public IntegrationRecipe(ResourceLocation name) { */ public abstract ItemStack getOutput(@Nonnull ItemStack target, NonNullList toIntegrate); + // Calen 1.18.2 + public abstract ItemStack getExampleOutput(); + /** * Determines the components to use when crafting finishes - * @param output The generated outputted, determined by getOutput * @return The components to use up */ - public abstract ImmutableList getRequirements(@Nonnull ItemStack output); + // public abstract ImmutableList getRequirements(@Nonnull ItemStack output); + public abstract ImmutableList getRequirements(); /** * Determines the amount of MJ required to integrate - * @param output The output that would be generated * @return The powercost in microjoules */ - public abstract long getRequiredMicroJoules(ItemStack output); + // public abstract long getRequiredMicroJoules(ItemStack output); + public final long getRequiredMicroJoules() { + return energyCost; + } public abstract IngredientStack getCenterStack(); + public int getMaxExpansionCount() { + return maxExpansionCount; + } + @Override public boolean equals(Object o) { if (this == o) { @@ -57,4 +80,36 @@ public boolean equals(Object o) { public int hashCode() { return name.hashCode(); } + + // Recipe + + @Override + public boolean matches(Container inv, Level world) { + return false; + } + + @Override + public ItemStack assemble(Container inv, RegistryAccess registryAccess) { + return ItemStack.EMPTY; + } + + @Override + public boolean canCraftInDimensions(int width, int height) { + return true; + } + + @Override + public ItemStack getResultItem(RegistryAccess registryAccess) { + return ItemStack.EMPTY; + } + + @Override + public boolean isSpecial() { + return true; + } + + @Override + public RecipeType getType() { + return TYPE; + } } diff --git a/api/buildcraft/api/recipes/package-info.java b/api/buildcraft/api/recipes/package-info.java index 596d90d..0d35939 100644 --- a/api/buildcraft/api/recipes/package-info.java +++ b/api/buildcraft/api/recipes/package-info.java @@ -2,7 +2,5 @@ * * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -@API(apiVersion = "3.0", owner = "buildcraftapi_core", provides = "buildcraftapi_recipes") +//@API(apiVersion = "3.0", owner = "buildcraftapi_core", provides = "buildcraftapi_recipes") package buildcraft.api.recipes; - -import net.minecraftforge.fml.common.API; diff --git a/api/buildcraft/api/registry/EventBuildCraftReload.java b/api/buildcraft/api/registry/EventBuildCraftReload.java index 903a9c3..d51d051 100644 --- a/api/buildcraft/api/registry/EventBuildCraftReload.java +++ b/api/buildcraft/api/registry/EventBuildCraftReload.java @@ -1,18 +1,17 @@ package buildcraft.api.registry; -import java.util.Set; - -import javax.annotation.Nullable; - import com.google.gson.GsonBuilder; - -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.Ingredient; - +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.fml.event.IModBusEvent; + +import javax.annotation.Nullable; +import java.util.Set; -public abstract class EventBuildCraftReload extends Event { +// public abstract class EventBuildCraftReload extends Event +public abstract class EventBuildCraftReload extends Event implements IModBusEvent { /** The manager that is being reloaded. */ public final IReloadableRegistryManager manager; @@ -29,7 +28,7 @@ public EventBuildCraftReload(IReloadableRegistryManager manager, Set> reloadingRegistries) { + @Nullable Set> reloadingRegistries) { super(manager, reloadingRegistries); } } @@ -50,7 +49,7 @@ public static class PopulateGson extends EventBuildCraftReload { public final GsonBuilder gsonBuilder; public PopulateGson(IReloadableRegistryManager manager, - @Nullable Set> reloadingRegistries, GsonBuilder gsonBuilder) { + @Nullable Set> reloadingRegistries, GsonBuilder gsonBuilder) { super(manager, reloadingRegistries); this.gsonBuilder = gsonBuilder; } @@ -68,7 +67,7 @@ public PostLoad(IReloadableRegistryManager manager, @Nullable Set> reloadingRegistries) { + @Nullable Set> reloadingRegistries) { super(manager, reloadingRegistries); } } diff --git a/api/buildcraft/api/registry/IReloadableRegistry.java b/api/buildcraft/api/registry/IReloadableRegistry.java index e973dad..61e0b1a 100644 --- a/api/buildcraft/api/registry/IReloadableRegistry.java +++ b/api/buildcraft/api/registry/IReloadableRegistry.java @@ -1,10 +1,10 @@ package buildcraft.api.registry; +import net.minecraft.resources.ResourceLocation; + import java.util.Collection; import java.util.Map; -import net.minecraft.util.ResourceLocation; - /** A registry of any Java object. This does not perform serialisation of any kind to the entries. */ public interface IReloadableRegistry { diff --git a/api/buildcraft/api/registry/IReloadableRegistryManager.java b/api/buildcraft/api/registry/IReloadableRegistryManager.java index 9c71ba1..f1a88bb 100644 --- a/api/buildcraft/api/registry/IReloadableRegistryManager.java +++ b/api/buildcraft/api/registry/IReloadableRegistryManager.java @@ -1,10 +1,10 @@ package buildcraft.api.registry; +import buildcraft.api.registry.IReloadableRegistry.PackType; + import java.util.Map; import java.util.Set; -import buildcraft.api.registry.IReloadableRegistry.PackType; - public interface IReloadableRegistryManager { PackType getType(); @@ -33,7 +33,7 @@ public interface IReloadableRegistryManager { Map> getAllRegistries(); /** Creates and registers a basic {@link IReloadableRegistry}. - * + * * @param name The name for the given registry. This should be unique, and the best way of doing that is to prefix * it with the modid, followed by a slash, and then the mod-unique name. * @throws IllegalArgumentException if name contains a colon. */ @@ -41,7 +41,7 @@ public interface IReloadableRegistryManager { /** Scripts will be loaded from "[pack_type.prefix]/[pack_name]/compat/[entry_path]/". The entryPath parameter * should start with the modid. - * + * * @param entryPath */ IScriptableRegistry createScriptableRegistry(String entryPath); diff --git a/api/buildcraft/api/registry/IScriptableRegistry.java b/api/buildcraft/api/registry/IScriptableRegistry.java index b6bae4d..048296e 100644 --- a/api/buildcraft/api/registry/IScriptableRegistry.java +++ b/api/buildcraft/api/registry/IScriptableRegistry.java @@ -1,16 +1,14 @@ package buildcraft.api.registry; -import java.util.Map; -import java.util.Set; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonObject; import com.google.gson.JsonSyntaxException; +import net.minecraft.resources.ResourceLocation; -import net.minecraft.util.ResourceLocation; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import java.util.Map; +import java.util.Set; /** A type of {@link IReloadableRegistry} that can be configured with buildcraft style simple scripts. A full * description can be found [...] */ @@ -37,7 +35,7 @@ default void addCustomType(String name, IEntryDeserializer deserial } /** @return A {@link Set} (likely unmodifiable) that contains all of the - * {@link ResourceLocation#getResourceDomain()}'s that had added entries to this registry through + * {@link ResourceLocation#getNamespace()}'s that had added entries to this registry through * scripts. */ Set getSourceDomains(); @@ -56,7 +54,7 @@ public interface IEntryDeserializer { * @throws JsonSyntaxException if the input {@link JsonObject} was either missing required fields or had the * wrong type or data for those fields. */ OptionallyDisabled deserialize(ResourceLocation name, JsonObject obj, JsonDeserializationContext ctx) - throws JsonSyntaxException; + throws JsonSyntaxException; } /** Similar to {@link IEntryDeserializer} except that this guarantees that @@ -71,7 +69,7 @@ public interface ISimpleEntryDeserializer extends IEntryDeserializer { * {@link #deserializeConst(ResourceLocation, JsonObject, JsonDeserializationContext)} directly. */ @Override default OptionallyDisabled deserialize(ResourceLocation name, JsonObject obj, JsonDeserializationContext ctx) - throws JsonSyntaxException { + throws JsonSyntaxException { return new OptionallyDisabled<>(deserializeConst(name, obj, ctx)); } @@ -82,7 +80,7 @@ default OptionallyDisabled deserialize(ResourceLocation name, JsonObject obj, * @throws JsonSyntaxException if the input {@link JsonObject} was either missing required fields or had the * wrong type or data for those fields. */ E deserializeConst(ResourceLocation name, JsonObject obj, JsonDeserializationContext ctx) - throws JsonSyntaxException; + throws JsonSyntaxException; } /** A simple wrapper which either contains the object, or a string with a reason why it is allowed to be null. */ diff --git a/api/buildcraft/api/robots/AIRobot.java b/api/buildcraft/api/robots/AIRobot.java index 0fad582..1d23f7e 100755 --- a/api/buildcraft/api/robots/AIRobot.java +++ b/api/buildcraft/api/robots/AIRobot.java @@ -4,10 +4,9 @@ * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.robots; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - import buildcraft.api.mj.MjAPI; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.item.ItemStack; public class AIRobot { public EntityRobotBase robot; @@ -42,24 +41,24 @@ public void end() { } /** This gets called when a delegate AI ends work naturally. - * + * * @param ai The delegate AI which ended work. */ public void delegateAIEnded(AIRobot ai) { } /** This gets called when a delegate AI is forcibly aborted. - * + * * @param ai The delegate AI which was aborted. */ public void delegateAIAborted(AIRobot ai) { } - public void writeSelfToNBT(NBTTagCompound nbt) { + public void writeSelfToNBT(CompoundTag nbt) { } - public void loadSelfFromNBT(NBTTagCompound nbt) { + public void loadSelfFromNBT(CompoundTag nbt) { } @@ -155,30 +154,30 @@ public final AIRobot getDelegateAI() { return delegateAI; } - public final void writeToNBT(NBTTagCompound nbt) { - nbt.setString("aiName", RobotManager.getAIRobotName(getClass())); + public final void writeToNBT(CompoundTag nbt) { + nbt.putString("aiName", RobotManager.getAIRobotName(getClass())); - NBTTagCompound data = new NBTTagCompound(); + CompoundTag data = new CompoundTag(); writeSelfToNBT(data); - nbt.setTag("data", data); + nbt.put("data", data); if (delegateAI != null && delegateAI.canLoadFromNBT()) { - NBTTagCompound sub = new NBTTagCompound(); + CompoundTag sub = new CompoundTag(); delegateAI.writeToNBT(sub); - nbt.setTag("delegateAI", sub); + nbt.put("delegateAI", sub); } } - public final void loadFromNBT(NBTTagCompound nbt) { - loadSelfFromNBT(nbt.getCompoundTag("data")); + public final void loadFromNBT(CompoundTag nbt) { + loadSelfFromNBT(nbt.getCompound("data")); - if (nbt.hasKey("delegateAI")) { - NBTTagCompound sub = nbt.getCompoundTag("delegateAI"); + if (nbt.contains("delegateAI")) { + CompoundTag sub = nbt.getCompound("delegateAI"); try { Class aiRobotClass; - if (sub.hasKey("class")) { + if (sub.contains("class")) { // Migration support for 6.4.x aiRobotClass = RobotManager.getAIRobotByLegacyClassName(sub.getString("class")); } else { @@ -198,12 +197,12 @@ public final void loadFromNBT(NBTTagCompound nbt) { } } - public static AIRobot loadAI(NBTTagCompound nbt, EntityRobotBase robot) { + public static AIRobot loadAI(CompoundTag nbt, EntityRobotBase robot) { AIRobot ai = null; try { Class aiRobotClass; - if (nbt.hasKey("class")) { + if (nbt.contains("class")) { // Migration support for 6.4.x aiRobotClass = RobotManager.getAIRobotByLegacyClassName(nbt.getString("class")); } else { diff --git a/api/buildcraft/api/robots/DockingStation.java b/api/buildcraft/api/robots/DockingStation.java index d3237a0..6d4a8a8 100755 --- a/api/buildcraft/api/robots/DockingStation.java +++ b/api/buildcraft/api/robots/DockingStation.java @@ -4,24 +4,22 @@ * of the license located in http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.api.robots; -import java.util.Arrays; - -import net.minecraft.inventory.IInventory; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -import net.minecraftforge.fluids.capability.IFluidHandler; - import buildcraft.api.core.BCLog; import buildcraft.api.core.EnumPipePart; import buildcraft.api.statements.StatementSlot; import buildcraft.api.transport.IInjectable; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.Container; +import net.minecraft.world.level.Level; +import net.minecraftforge.fluids.capability.IFluidHandler; + +import java.util.Arrays; public abstract class DockingStation { - public EnumFacing side; - public World world; + public Direction side; + public Level world; private long robotTakingId = EntityRobotBase.NULL_ROBOT_ID; private EntityRobotBase robotTaking; @@ -30,12 +28,13 @@ public abstract class DockingStation { private BlockPos pos; - public DockingStation(BlockPos iIndex, EnumFacing iSide) { + public DockingStation(BlockPos iIndex, Direction iSide) { pos = iIndex; side = iSide; } - public DockingStation() {} + public DockingStation() { + } public boolean isMainStation() { return linkIsMain; @@ -45,7 +44,7 @@ public BlockPos getPos() { return pos; } - public EnumFacing side() { + public Direction side() { return side; } @@ -116,20 +115,20 @@ public void unsafeRelease(EntityRobotBase robot) { } } - public void writeToNBT(NBTTagCompound nbt) { - nbt.setIntArray("pos", new int[] { getPos().getX(), getPos().getY(), getPos().getZ() }); - nbt.setByte("side", (byte) side.ordinal()); - nbt.setBoolean("isMain", linkIsMain); - nbt.setLong("robotId", robotTakingId); + public void writeToNBT(CompoundTag nbt) { + nbt.putIntArray("pos", new int[] { getPos().getX(), getPos().getY(), getPos().getZ() }); + nbt.putByte("side", (byte) side.ordinal()); + nbt.putBoolean("isMain", linkIsMain); + nbt.putLong("robotId", robotTakingId); } - public void readFromNBT(NBTTagCompound nbt) { - if (nbt.hasKey("index")) { + public void readFromNBT(CompoundTag nbt) { + if (nbt.contains("index")) { // For compatibility with older versions of minecraft and buildcraft - NBTTagCompound indexNBT = nbt.getCompoundTag("index"); - int x = indexNBT.getInteger("i"); - int y = indexNBT.getInteger("j"); - int z = indexNBT.getInteger("k"); + CompoundTag indexNBT = nbt.getCompound("index"); + int x = indexNBT.getInt("i"); + int y = indexNBT.getInt("j"); + int z = indexNBT.getInt("k"); pos = new BlockPos(x, y, z); } else { int[] array = nbt.getIntArray("pos"); @@ -141,7 +140,7 @@ public void readFromNBT(NBTTagCompound nbt) { BCLog.logger.warn("Did not find any integer positions! This is a bug!"); } } - side = EnumFacing.values()[nbt.getByte("side")]; + side = Direction.VALUES[nbt.getByte("side")]; linkIsMain = nbt.getBoolean("isMain"); robotTakingId = nbt.getLong("robotId"); } @@ -189,7 +188,7 @@ public EnumPipePart getItemOutputSide() { return EnumPipePart.CENTER; } - public IInventory getItemInput() { + public Container getItemInput() { return null; } diff --git a/api/buildcraft/api/robots/EntityRobotBase.java b/api/buildcraft/api/robots/EntityRobotBase.java index 0e6439d..65403aa 100755 --- a/api/buildcraft/api/robots/EntityRobotBase.java +++ b/api/buildcraft/api/robots/EntityRobotBase.java @@ -4,33 +4,32 @@ * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.robots; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLiving; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -import net.minecraftforge.items.IItemHandler; - import buildcraft.api.boards.RedstoneBoardRobot; -import buildcraft.api.core.IFluidHandlerAdv; import buildcraft.api.core.IZone; import buildcraft.api.mj.MjAPI; import buildcraft.api.mj.MjBattery; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.BlockEntity; + +import javax.annotation.Nonnull; -public abstract class EntityRobotBase extends EntityLiving implements IItemHandler, IFluidHandlerAdv { +public abstract class EntityRobotBase extends LivingEntity { - public static final long MAX_POWER = 5000 * MjAPI.MJ; + public static final long MAX_POWER = 5000 * MjAPI.MJ; public static final long SAFETY_POWER = MAX_POWER / 5; public static final long SHUTDOWN_POWER = 0; public static final long NULL_ROBOT_ID = Long.MAX_VALUE; - public EntityRobotBase(World par1World) { - super(par1World); + public EntityRobotBase(EntityType entityType, Level world) { + super(entityType, world); } - public abstract void setItemInUse(ItemStack stack); + public abstract void setItemInUse(@Nonnull ItemStack stack); public abstract void setItemActive(boolean b); @@ -80,7 +79,7 @@ public long getPower() { public abstract void onChunkUnload(); - public abstract ItemStack receiveItem(TileEntity tile, ItemStack stack); + public abstract ItemStack receiveItem(BlockEntity tile, ItemStack stack); public abstract void setMainStation(DockingStation station); } diff --git a/api/buildcraft/api/robots/IRequestProvider.java b/api/buildcraft/api/robots/IRequestProvider.java index 2e56148..1e7bde5 100755 --- a/api/buildcraft/api/robots/IRequestProvider.java +++ b/api/buildcraft/api/robots/IRequestProvider.java @@ -4,7 +4,9 @@ * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.robots; -import net.minecraft.item.ItemStack; +import net.minecraft.world.item.ItemStack; + +import javax.annotation.Nonnull; /** Provide requests of items that need to be fulfilled. * @@ -21,6 +23,7 @@ public interface IRequestProvider { * * @param slot * @return the request in the slot, or null if there's no request. */ + @Nonnull ItemStack getRequest(int slot); /** Fulfill the request in slot with the stack given and return any excess. @@ -28,5 +31,6 @@ public interface IRequestProvider { * @param slot * @param stack * @return any excess that was not used to fulfill the request. */ + @Nonnull ItemStack offerItem(int slot, ItemStack stack); } diff --git a/api/buildcraft/api/robots/IRobotOverlayItem.java b/api/buildcraft/api/robots/IRobotOverlayItem.java index fa39ee1..d3e6a5f 100644 --- a/api/buildcraft/api/robots/IRobotOverlayItem.java +++ b/api/buildcraft/api/robots/IRobotOverlayItem.java @@ -1,14 +1,13 @@ package buildcraft.api.robots; -import net.minecraft.client.renderer.texture.TextureManager; -import net.minecraft.item.ItemStack; - -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +import net.minecraft.world.item.ItemStack; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; public interface IRobotOverlayItem { boolean isValidRobotOverlay(ItemStack stack); - @SideOnly(Side.CLIENT) - void renderRobotOverlay(ItemStack stack, TextureManager textureManager); + @OnlyIn(Dist.CLIENT) + // void renderRobotOverlay(ItemStack stack, TextureManager textureManager); + void renderRobotOverlay(ItemStack stack); } diff --git a/api/buildcraft/api/robots/IRobotRegistry.java b/api/buildcraft/api/robots/IRobotRegistry.java index 96360f5..e313b5b 100755 --- a/api/buildcraft/api/robots/IRobotRegistry.java +++ b/api/buildcraft/api/robots/IRobotRegistry.java @@ -4,11 +4,11 @@ * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.robots; -import java.util.Collection; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; +import java.util.Collection; public interface IRobotRegistry { @@ -36,7 +36,7 @@ public interface IRobotRegistry { void releaseResources(EntityRobotBase robot); - DockingStation getStation(BlockPos pos, EnumFacing side); + DockingStation getStation(BlockPos pos, Direction side); Collection getStations(); @@ -48,9 +48,9 @@ public interface IRobotRegistry { void release(DockingStation station, long robotId); - void writeToNBT(NBTTagCompound nbt); + void writeToNBT(CompoundTag nbt); - void readFromNBT(NBTTagCompound nbt); + void readFromNBT(CompoundTag nbt); void registryMarkDirty(); } diff --git a/api/buildcraft/api/robots/IRobotRegistryProvider.java b/api/buildcraft/api/robots/IRobotRegistryProvider.java index 0012494..e3eef09 100644 --- a/api/buildcraft/api/robots/IRobotRegistryProvider.java +++ b/api/buildcraft/api/robots/IRobotRegistryProvider.java @@ -1,7 +1,7 @@ package buildcraft.api.robots; -import net.minecraft.world.World; +import net.minecraft.world.level.Level; public interface IRobotRegistryProvider { - IRobotRegistry getRegistry(World world); + IRobotRegistry getRegistry(Level world); } diff --git a/api/buildcraft/api/robots/IStationFilter.java b/api/buildcraft/api/robots/IStationFilter.java new file mode 100644 index 0000000..809c08d --- /dev/null +++ b/api/buildcraft/api/robots/IStationFilter.java @@ -0,0 +1,10 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + *

    + * BuildCraft is distributed under the terms of the Minecraft Mod Public License 1.0, or MMPL. Please check the contents + * of the license located in http://www.mod-buildcraft.com/MMPL-1.0.txt */ +package buildcraft.api.robots; + +public interface IStationFilter { + + boolean matches(DockingStation station); +} diff --git a/api/buildcraft/api/robots/ResourceId.java b/api/buildcraft/api/robots/ResourceId.java index 539503a..b7f17ac 100755 --- a/api/buildcraft/api/robots/ResourceId.java +++ b/api/buildcraft/api/robots/ResourceId.java @@ -4,22 +4,24 @@ * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.robots; -import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.CompoundTag; public abstract class ResourceId { - protected ResourceId() {} + protected ResourceId() { + } - public void writeToNBT(NBTTagCompound nbt) { - nbt.setString("resourceName", RobotManager.getResourceIdName(getClass())); + public void writeToNBT(CompoundTag nbt) { + nbt.putString("resourceName", RobotManager.getResourceIdName(getClass())); } - protected void readFromNBT(NBTTagCompound nbt) {} + protected void readFromNBT(CompoundTag nbt) { + } - public static ResourceId load(NBTTagCompound nbt) { + public static ResourceId load(CompoundTag nbt) { try { Class cls; - if (nbt.hasKey("class")) { + if (nbt.contains("class")) { // Migration support for 6.4.x cls = RobotManager.getResourceIdByLegacyClassName(nbt.getString("class")); } else { diff --git a/api/buildcraft/api/robots/ResourceIdBlock.java b/api/buildcraft/api/robots/ResourceIdBlock.java index 4e89a58..ad235db 100755 --- a/api/buildcraft/api/robots/ResourceIdBlock.java +++ b/api/buildcraft/api/robots/ResourceIdBlock.java @@ -4,13 +4,11 @@ * of the license located in http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.api.robots; -import org.apache.commons.lang3.builder.HashCodeBuilder; - -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; - import buildcraft.api.core.EnumPipePart; +import net.minecraft.core.BlockPos; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.level.block.entity.BlockEntity; +import org.apache.commons.lang3.builder.HashCodeBuilder; public class ResourceIdBlock extends ResourceId { @@ -29,8 +27,8 @@ public ResourceIdBlock(BlockPos iIndex) { pos = iIndex; } - public ResourceIdBlock(TileEntity tile) { - pos = tile.getPos(); + public ResourceIdBlock(BlockEntity tile) { + pos = tile.getBlockPos(); } @Override @@ -51,21 +49,21 @@ public int hashCode() { } @Override - public void writeToNBT(NBTTagCompound nbt) { + public void writeToNBT(CompoundTag nbt) { super.writeToNBT(nbt); int[] arr = new int[] { pos.getX(), pos.getY(), pos.getZ() }; - nbt.setIntArray("pos", arr); + nbt.putIntArray("pos", arr); - nbt.setTag("side", side.writeToNBT()); + nbt.put("side", side.writeToNBT()); } @Override - protected void readFromNBT(NBTTagCompound nbt) { + protected void readFromNBT(CompoundTag nbt) { super.readFromNBT(nbt); int[] arr = nbt.getIntArray("pos"); pos = new BlockPos(arr[0], arr[1], arr[2]); - side = EnumPipePart.readFromNBT(nbt.getTag("side")); + side = EnumPipePart.readFromNBT(nbt.get("side")); } } diff --git a/api/buildcraft/api/robots/ResourceIdRequest.java b/api/buildcraft/api/robots/ResourceIdRequest.java index d224b8e..405728b 100755 --- a/api/buildcraft/api/robots/ResourceIdRequest.java +++ b/api/buildcraft/api/robots/ResourceIdRequest.java @@ -4,11 +4,9 @@ * of the license located in http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.api.robots; -import org.apache.commons.lang3.builder.HashCodeBuilder; - -import net.minecraft.nbt.NBTTagCompound; - import buildcraft.api.core.EnumPipePart; +import net.minecraft.nbt.CompoundTag; +import org.apache.commons.lang3.builder.HashCodeBuilder; public class ResourceIdRequest extends ResourceIdBlock { @@ -39,16 +37,16 @@ public int hashCode() { } @Override - public void writeToNBT(NBTTagCompound nbt) { + public void writeToNBT(CompoundTag nbt) { super.writeToNBT(nbt); - nbt.setInteger("localId", slot); + nbt.putInt("localId", slot); } @Override - protected void readFromNBT(NBTTagCompound nbt) { + protected void readFromNBT(CompoundTag nbt) { super.readFromNBT(nbt); - slot = nbt.getInteger("localId"); + slot = nbt.getInt("localId"); } } diff --git a/api/buildcraft/api/robots/RobotManager.java b/api/buildcraft/api/robots/RobotManager.java index 7c712c9..98dd22b 100644 --- a/api/buildcraft/api/robots/RobotManager.java +++ b/api/buildcraft/api/robots/RobotManager.java @@ -4,12 +4,12 @@ * of the license located in http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.api.robots; +import buildcraft.api.core.BCLog; + import java.util.ArrayList; import java.util.HashMap; import java.util.Map; -import buildcraft.api.core.BCLog; - public abstract class RobotManager { public static IRobotRegistryProvider registryProvider; public static ArrayList> aiRobots = new ArrayList<>(); diff --git a/api/buildcraft/api/robots/package-info.java b/api/buildcraft/api/robots/package-info.java index 6196069..591fd15 100644 --- a/api/buildcraft/api/robots/package-info.java +++ b/api/buildcraft/api/robots/package-info.java @@ -2,7 +2,5 @@ * * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -@API(apiVersion = "3.0", owner = "buildcraftapi_core", provides = "buildcraftapi_robotics") +//@API(apiVersion = "3.0", owner = "buildcraftapi_core", provides = "buildcraftapi_robotics") package buildcraft.api.robots; - -import net.minecraftforge.fml.common.API; diff --git a/api/buildcraft/api/schematics/ISchematicBlock.java b/api/buildcraft/api/schematics/ISchematicBlock.java index 3ae62ed..d250f32 100644 --- a/api/buildcraft/api/schematics/ISchematicBlock.java +++ b/api/buildcraft/api/schematics/ISchematicBlock.java @@ -1,21 +1,19 @@ package buildcraft.api.schematics; +import buildcraft.api.core.IFakeWorld; +import buildcraft.api.core.InvalidInputDataException; +import net.minecraft.core.BlockPos; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Rotation; +import net.minecraftforge.fluids.FluidStack; + +import javax.annotation.Nonnull; import java.util.Collections; import java.util.List; import java.util.Set; -import javax.annotation.Nonnull; - -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.Rotation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -import net.minecraftforge.fluids.FluidStack; - -import buildcraft.api.core.InvalidInputDataException; - public interface ISchematicBlock { void init(SchematicBlockContext context); @@ -40,20 +38,21 @@ default List computeRequiredFluids() { ISchematicBlock getRotated(Rotation rotation); - boolean canBuild(World world, BlockPos blockPos); + boolean canBuild(Level world, BlockPos blockPos); - default boolean isReadyToBuild(World world, BlockPos blockPos) { + default boolean isReadyToBuild(Level world, BlockPos blockPos) { return true; } - boolean build(World world, BlockPos blockPos); + boolean build(Level world, BlockPos blockPos); - boolean buildWithoutChecks(World world, BlockPos blockPos); + // boolean buildWithoutChecks(Level world, BlockPos blockPos); + boolean buildWithoutChecks(IFakeWorld world, BlockPos blockPos); - boolean isBuilt(World world, BlockPos blockPos); + boolean isBuilt(Level world, BlockPos blockPos); - NBTTagCompound serializeNBT(); + CompoundTag serializeNBT(); /** @throws InvalidInputDataException If the input data wasn't correct or didn't make sense. */ - void deserializeNBT(NBTTagCompound nbt) throws InvalidInputDataException; + void deserializeNBT(CompoundTag nbt) throws InvalidInputDataException; } diff --git a/api/buildcraft/api/schematics/ISchematicEntity.java b/api/buildcraft/api/schematics/ISchematicEntity.java index b026f3b..4b9805e 100644 --- a/api/buildcraft/api/schematics/ISchematicEntity.java +++ b/api/buildcraft/api/schematics/ISchematicEntity.java @@ -1,26 +1,23 @@ package buildcraft.api.schematics; -import java.util.Collections; -import java.util.List; - -import javax.annotation.Nonnull; - -import net.minecraft.entity.Entity; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.Rotation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; -import net.minecraft.world.World; - +import buildcraft.api.core.InvalidInputDataException; +import net.minecraft.core.BlockPos; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Rotation; +import net.minecraft.world.phys.Vec3; import net.minecraftforge.fluids.FluidStack; -import buildcraft.api.core.InvalidInputDataException; +import javax.annotation.Nonnull; +import java.util.Collections; +import java.util.List; public interface ISchematicEntity { void init(SchematicEntityContext context); - Vec3d getPos(); + Vec3 getPos(); @Nonnull default List computeRequiredItems() { @@ -34,12 +31,12 @@ default List computeRequiredFluids() { ISchematicEntity getRotated(Rotation rotation); - Entity build(World world, BlockPos basePos); + Entity build(Level world, BlockPos basePos); - Entity buildWithoutChecks(World world, BlockPos basePos); + Entity buildWithoutChecks(Level world, BlockPos basePos); - NBTTagCompound serializeNBT(); + CompoundTag serializeNBT(); /** @throws InvalidInputDataException If the input data wasn't correct or didn't make sense. */ - void deserializeNBT(NBTTagCompound nbt) throws InvalidInputDataException; + void deserializeNBT(CompoundTag nbt) throws InvalidInputDataException; } diff --git a/api/buildcraft/api/schematics/SchematicBlockContext.java b/api/buildcraft/api/schematics/SchematicBlockContext.java index 0ca9853..09126c0 100644 --- a/api/buildcraft/api/schematics/SchematicBlockContext.java +++ b/api/buildcraft/api/schematics/SchematicBlockContext.java @@ -1,28 +1,28 @@ package buildcraft.api.schematics; -import javax.annotation.Nonnull; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import javax.annotation.Nonnull; public class SchematicBlockContext { @Nonnull - public final World world; + public final Level world; @Nonnull public final BlockPos basePos; @Nonnull public final BlockPos pos; @Nonnull - public final IBlockState blockState; + public final BlockState blockState; @Nonnull public final Block block; - public SchematicBlockContext(@Nonnull World world, + public SchematicBlockContext(@Nonnull Level world, @Nonnull BlockPos basePos, @Nonnull BlockPos pos, - @Nonnull IBlockState blockState, + @Nonnull BlockState blockState, @Nonnull Block block) { this.world = world; this.basePos = basePos; diff --git a/api/buildcraft/api/schematics/SchematicBlockFactory.java b/api/buildcraft/api/schematics/SchematicBlockFactory.java index bf57fb1..b107284 100644 --- a/api/buildcraft/api/schematics/SchematicBlockFactory.java +++ b/api/buildcraft/api/schematics/SchematicBlockFactory.java @@ -1,11 +1,10 @@ package buildcraft.api.schematics; -import java.util.function.Predicate; -import java.util.function.Supplier; +import net.minecraft.resources.ResourceLocation; import javax.annotation.Nonnull; - -import net.minecraft.util.ResourceLocation; +import java.util.function.Predicate; +import java.util.function.Supplier; public class SchematicBlockFactory implements Comparable> { @Nonnull diff --git a/api/buildcraft/api/schematics/SchematicBlockFactoryRegistry.java b/api/buildcraft/api/schematics/SchematicBlockFactoryRegistry.java index d88de20..fee0270 100644 --- a/api/buildcraft/api/schematics/SchematicBlockFactoryRegistry.java +++ b/api/buildcraft/api/schematics/SchematicBlockFactoryRegistry.java @@ -1,33 +1,37 @@ package buildcraft.api.schematics; +import buildcraft.api.core.BuildCraftAPI; +import com.google.common.collect.ImmutableList; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.block.Block; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; import java.util.List; import java.util.Set; -import java.util.TreeSet; +import java.util.concurrent.ConcurrentSkipListSet; import java.util.function.Predicate; import java.util.function.Supplier; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import com.google.common.collect.ImmutableList; - -import net.minecraft.block.Block; -import net.minecraft.util.ResourceLocation; - -import buildcraft.api.core.BuildCraftAPI; - public class SchematicBlockFactoryRegistry { - private static final Set> FACTORIES = new TreeSet<>(); + // private static final Set> FACTORIES = new TreeSet<>(); + private static final Set> FACTORIES = new ConcurrentSkipListSet<>(); - public static void registerFactory(String name, - int priority, - Predicate predicate, - Supplier supplier) { - FACTORIES.add(new SchematicBlockFactory<>( - BuildCraftAPI.nameToResourceLocation(name), - priority, - predicate, - supplier + // Calen thread safety: sometimes "air" not registered just after BCBuildersSchematics#preInit:registerSchematicFactory("air", 0, SchematicBlockAir::predicate, SchematicBlockAir::new) + public synchronized static Set> getFactoriesSynchronized() { + return FACTORIES; + } + + public static synchronized void registerFactory(String name, + int priority, + Predicate predicate, + Supplier supplier) { +// FACTORIES.add(new SchematicBlockFactory<>( + getFactoriesSynchronized().add(new SchematicBlockFactory<>( + BuildCraftAPI.nameToResourceLocation(name), + priority, + predicate, + supplier )); } @@ -36,31 +40,34 @@ public static void registerFactory(String name, List blocks, Supplier supplier) { registerFactory( - name, - priority, - context -> blocks.contains(context.block), - supplier + name, + priority, + context -> blocks.contains(context.block), + supplier ); } public static List> getFactories() { - return ImmutableList.copyOf(FACTORIES); +// return ImmutableList.copyOf(FACTORIES); + return ImmutableList.copyOf(getFactoriesSynchronized()); } @Nonnull public static SchematicBlockFactory getFactoryByInstance(S instance) { // noinspection unchecked - return (SchematicBlockFactory) FACTORIES.stream() - .filter(schematicBlockFactory -> schematicBlockFactory.clazz == instance.getClass()) - .findFirst() - .orElseThrow(() -> new IllegalStateException("Didn't find a factory for " + instance.getClass())); +// return (SchematicBlockFactory) FACTORIES.stream() + return (SchematicBlockFactory) getFactoriesSynchronized().stream() + .filter(schematicBlockFactory -> schematicBlockFactory.clazz == instance.getClass()) + .findFirst() + .orElseThrow(() -> new IllegalStateException("Didn't find a factory for " + instance.getClass())); } @Nullable public static SchematicBlockFactory getFactoryByName(ResourceLocation name) { - return FACTORIES.stream() - .filter(schematicBlockFactory -> schematicBlockFactory.name.equals(name)) - .findFirst() - .orElse(null); +// return FACTORIES.stream() + return getFactoriesSynchronized().stream() + .filter(schematicBlockFactory -> schematicBlockFactory.name.equals(name)) + .findFirst() + .orElse(null); } } diff --git a/api/buildcraft/api/schematics/SchematicEntityContext.java b/api/buildcraft/api/schematics/SchematicEntityContext.java index b812556..11c63ac 100644 --- a/api/buildcraft/api/schematics/SchematicEntityContext.java +++ b/api/buildcraft/api/schematics/SchematicEntityContext.java @@ -1,20 +1,20 @@ package buildcraft.api.schematics; -import javax.annotation.Nonnull; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.Level; -import net.minecraft.entity.Entity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import javax.annotation.Nonnull; public class SchematicEntityContext { @Nonnull - public final World world; + public final Level world; @Nonnull public final BlockPos basePos; @Nonnull public final Entity entity; - public SchematicEntityContext(@Nonnull World world, + public SchematicEntityContext(@Nonnull Level world, @Nonnull BlockPos basePos, @Nonnull Entity entity) { this.world = world; diff --git a/api/buildcraft/api/schematics/SchematicEntityFactory.java b/api/buildcraft/api/schematics/SchematicEntityFactory.java index a81a52a..9c64672 100644 --- a/api/buildcraft/api/schematics/SchematicEntityFactory.java +++ b/api/buildcraft/api/schematics/SchematicEntityFactory.java @@ -1,11 +1,10 @@ package buildcraft.api.schematics; -import java.util.function.Predicate; -import java.util.function.Supplier; +import net.minecraft.resources.ResourceLocation; import javax.annotation.Nonnull; - -import net.minecraft.util.ResourceLocation; +import java.util.function.Predicate; +import java.util.function.Supplier; public class SchematicEntityFactory implements Comparable> { @Nonnull diff --git a/api/buildcraft/api/schematics/SchematicEntityFactoryRegistry.java b/api/buildcraft/api/schematics/SchematicEntityFactoryRegistry.java index a5525b1..37b11ec 100644 --- a/api/buildcraft/api/schematics/SchematicEntityFactoryRegistry.java +++ b/api/buildcraft/api/schematics/SchematicEntityFactoryRegistry.java @@ -1,21 +1,17 @@ package buildcraft.api.schematics; +import buildcraft.api.core.BuildCraftAPI; +import com.google.common.collect.ImmutableList; +import net.minecraft.resources.ResourceLocation; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; import java.util.List; import java.util.Set; import java.util.TreeSet; import java.util.function.Predicate; import java.util.function.Supplier; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import com.google.common.collect.ImmutableList; - -import net.minecraft.entity.EntityList; -import net.minecraft.util.ResourceLocation; - -import buildcraft.api.core.BuildCraftAPI; - public class SchematicEntityFactoryRegistry { private static final Set> FACTORIES = new TreeSet<>(); @@ -24,22 +20,27 @@ public static void registerFactory(String name, Predicate predicate, Supplier supplier) { FACTORIES.add(new SchematicEntityFactory<>( - BuildCraftAPI.nameToResourceLocation(name), - priority, - predicate, - supplier + BuildCraftAPI.nameToResourceLocation(name), + priority, + predicate, + supplier )); } - public static void registerFactory(String name, - int priority, - List entities, - Supplier supplier) { + // Calen no usage in 1.12.2 + // EntityList.class not present in 1.18.2 + public static void registerFactory( + String name, + int priority, + List entities, + Supplier supplier + ) { registerFactory( - name, - priority, - context -> entities.contains(EntityList.getKey(context.entity)), - supplier + name, + priority, +// context -> entities.contains(EntityList.getKey(context.entity)), + context -> entities.contains(context.entity.getType().builtInRegistryHolder().key().location()), + supplier ); } @@ -51,16 +52,16 @@ public static List> getFactories() { public static SchematicEntityFactory getFactoryByInstance(S instance) { // noinspection unchecked return (SchematicEntityFactory) FACTORIES.stream() - .filter(schematicEntityFactory -> schematicEntityFactory.clazz == instance.getClass()) - .findFirst() - .orElseThrow(() -> new IllegalStateException("Didn't find a factory for " + instance.getClass())); + .filter(schematicEntityFactory -> schematicEntityFactory.clazz == instance.getClass()) + .findFirst() + .orElseThrow(() -> new IllegalStateException("Didn't find a factory for " + instance.getClass())); } @Nullable public static SchematicEntityFactory getFactoryByName(ResourceLocation name) { return FACTORIES.stream() - .filter(schematicEntityFactory -> schematicEntityFactory.name.equals(name)) - .findFirst() - .orElse(null); + .filter(schematicEntityFactory -> schematicEntityFactory.name.equals(name)) + .findFirst() + .orElse(null); } } diff --git a/api/buildcraft/api/library/package-info.java b/api/buildcraft/api/statements/ActionState.java similarity index 64% rename from api/buildcraft/api/library/package-info.java rename to api/buildcraft/api/statements/ActionState.java index ecf627f..b4c364c 100644 --- a/api/buildcraft/api/library/package-info.java +++ b/api/buildcraft/api/statements/ActionState.java @@ -2,7 +2,9 @@ * * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -@API(apiVersion = "2.0", owner = "buildcraftapi_core", provides = "buildcraftapi_library") -package buildcraft.api.library; +package buildcraft.api.statements; -import net.minecraftforge.fml.common.API; +// Calen 1.18.2: from 1.8.9 +public class ActionState { + +} diff --git a/api/buildcraft/api/statements/IAction.java b/api/buildcraft/api/statements/IAction.java index 2cd0c35..1af6d00 100644 --- a/api/buildcraft/api/statements/IAction.java +++ b/api/buildcraft/api/statements/IAction.java @@ -3,4 +3,5 @@ /** Marker interface that designates a class as being an action. Note that you *must* implement ONE of the following * interfaces to be recognised as an action: {@link IActionInternal}, {@link IActionInternalSided}, or * {@link IActionExternal} */ -public interface IAction extends IStatement {} +public interface IAction extends IStatement { +} diff --git a/api/buildcraft/api/statements/IActionExternal.java b/api/buildcraft/api/statements/IActionExternal.java index 9086612..0795ddb 100644 --- a/api/buildcraft/api/statements/IActionExternal.java +++ b/api/buildcraft/api/statements/IActionExternal.java @@ -4,9 +4,9 @@ * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.statements; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.entity.BlockEntity; public interface IActionExternal extends IAction { - void actionActivate(TileEntity target, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters); + void actionActivate(BlockEntity target, Direction side, IStatementContainer source, IStatementParameter[] parameters); } diff --git a/api/buildcraft/api/statements/IActionInternalSided.java b/api/buildcraft/api/statements/IActionInternalSided.java index 0ae3d70..571cabb 100644 --- a/api/buildcraft/api/statements/IActionInternalSided.java +++ b/api/buildcraft/api/statements/IActionInternalSided.java @@ -1,7 +1,7 @@ package buildcraft.api.statements; -import net.minecraft.util.EnumFacing; +import net.minecraft.core.Direction; public interface IActionInternalSided extends IAction { - void actionActivate(EnumFacing side, IStatementContainer source, IStatementParameter[] parameters); + void actionActivate(Direction side, IStatementContainer source, IStatementParameter[] parameters); } diff --git a/api/buildcraft/api/statements/IActionProvider.java b/api/buildcraft/api/statements/IActionProvider.java index fa550ff..80c4141 100644 --- a/api/buildcraft/api/statements/IActionProvider.java +++ b/api/buildcraft/api/statements/IActionProvider.java @@ -4,17 +4,16 @@ * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.statements; -import java.util.Collection; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.entity.BlockEntity; import javax.annotation.Nonnull; - -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; +import java.util.Collection; public interface IActionProvider { void addInternalActions(Collection actions, IStatementContainer container); - void addInternalSidedActions(Collection actions, IStatementContainer container, @Nonnull EnumFacing side); + void addInternalSidedActions(Collection actions, IStatementContainer container, @Nonnull Direction side); - void addExternalActions(Collection actions, @Nonnull EnumFacing side, TileEntity tile); + void addExternalActions(Collection actions, @Nonnull Direction side, BlockEntity tile); } diff --git a/api/buildcraft/api/statements/IGuiSlot.java b/api/buildcraft/api/statements/IGuiSlot.java index f5cb3b2..528d052 100644 --- a/api/buildcraft/api/statements/IGuiSlot.java +++ b/api/buildcraft/api/statements/IGuiSlot.java @@ -1,16 +1,14 @@ package buildcraft.api.statements; -import java.util.List; - -import javax.annotation.Nullable; - -import com.google.common.collect.ImmutableList; - -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - import buildcraft.api.core.IConvertable; import buildcraft.api.core.render.ISprite; +import com.google.common.collect.ImmutableList; +import net.minecraft.network.chat.Component; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; + +import javax.annotation.Nullable; +import java.util.List; public interface IGuiSlot extends IConvertable { /** Every statement needs a unique tag, it should be in the format of "<modid>:<name>". @@ -20,21 +18,39 @@ public interface IGuiSlot extends IConvertable { /** Return the description in the UI. Note that this should NEVER be called directly, instead this acts as a bridge * for {@link #getTooltip()}. (As such this might return null or throw an exception) */ - @SideOnly(Side.CLIENT) - String getDescription(); + @OnlyIn(Dist.CLIENT) +// String getDescription(); + Component getDescription(); + + // Calen + @OnlyIn(Dist.CLIENT) + String getDescriptionKey(); /** @return The full tooltip for the UI. */ - @SideOnly(Side.CLIENT) - default List getTooltip() { - String desc = getDescription(); + @OnlyIn(Dist.CLIENT) + default List getTooltip() { +// String desc = getDescription(); + Component desc = getDescription(); + if (desc == null) { + return ImmutableList.of(); + } +// return ImmutableList.of(Component.literal(desc)); + return ImmutableList.of(desc); + } + + // Calen + @OnlyIn(Dist.CLIENT) + default List getTooltipKey() { + String desc = getDescriptionKey(); if (desc == null) { return ImmutableList.of(); } +// return ImmutableList.of(Component.literal(desc)); return ImmutableList.of(desc); } /** @return A sprite to show in a GUI, or null if this should not render a sprite. */ - @SideOnly(Side.CLIENT) + @OnlyIn(Dist.CLIENT) @Nullable ISprite getSprite(); } diff --git a/api/buildcraft/api/statements/IStatement.java b/api/buildcraft/api/statements/IStatement.java index b8d61a9..361157a 100644 --- a/api/buildcraft/api/statements/IStatement.java +++ b/api/buildcraft/api/statements/IStatement.java @@ -21,7 +21,7 @@ public interface IStatement extends IGuiSlot { * this checks the classes of the old and new parameters, however it is sensible to override this check in case the * parameters given no longer match. For example if you return {@link StatementParameterItemStack} from * {@link #createParameter(int)} and require the stack to match a filter, but the incoming stack might not. - * + * * @param old * @param index * @return */ diff --git a/api/buildcraft/api/statements/IStatementContainer.java b/api/buildcraft/api/statements/IStatementContainer.java index e08a7e8..0ce1941 100644 --- a/api/buildcraft/api/statements/IStatementContainer.java +++ b/api/buildcraft/api/statements/IStatementContainer.java @@ -4,15 +4,15 @@ * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.statements; -import javax.annotation.Nullable; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; +import javax.annotation.Nullable; /** This is implemented by objects containing Statements, such as Gates and TileEntities. */ public interface IStatementContainer { - TileEntity getTile(); + BlockEntity getTile(); @Nullable - TileEntity getNeighbourTile(EnumFacing side); + BlockEntity getNeighbourTile(Direction side); } diff --git a/api/buildcraft/api/statements/IStatementParameter.java b/api/buildcraft/api/statements/IStatementParameter.java index d90b380..45a4d52 100755 --- a/api/buildcraft/api/statements/IStatementParameter.java +++ b/api/buildcraft/api/statements/IStatementParameter.java @@ -4,14 +4,13 @@ * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.statements; -import javax.annotation.Nonnull; - -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.PacketBuffer; - import buildcraft.api.statements.StatementManager.IParamReaderBuf; import buildcraft.api.statements.StatementManager.IParameterReader; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.world.item.ItemStack; + +import javax.annotation.Nonnull; public interface IStatementParameter extends IGuiSlot { @@ -26,25 +25,27 @@ default DrawType getDrawType() { /** Return a non-null value to be set as the statement parameter if you handled the mouse click and do not want all * possible values to be shown, or null if you did nothing and wish to show all possible values. - * + * * @see #getPossible(IStatementContainer) */ - IStatementParameter onClick(IStatementContainer source, IStatement stmt, ItemStack stack, - StatementMouseClick mouse); + IStatementParameter onClick(IStatementContainer source, IStatement stmt, @Nonnull ItemStack stack, StatementMouseClick mouse); + + // Calen 1.18.2 + default IStatementParameter onScroll(IStatementContainer source, IStatement stmt, @Nonnull ItemStack stack, double delta) {return this;} - void writeToNbt(NBTTagCompound nbt); + void writeToNbt(CompoundTag nbt); - /** Writes this parameter to the given {@link PacketBuffer}. The default implementation writes out the value of - * {@link #writeToNbt(NBTTagCompound)}, and that will be passed back into - * {@link IParameterReader#readFromNbt(NBTTagCompound)}. + /** Writes this parameter to the given {@link FriendlyByteBuf}. The default implementation writes out the value of + * {@link #writeToNbt(CompoundTag)}, and that will be passed back into + * {@link IParameterReader#readFromNbt(CompoundTag)}. *

    * It is likely that implementors can write a more compact form of themselves, so they are encouraged to override * this and also register an {@link IParamReaderBuf} in * {@link StatementManager#registerParameter(String, IParamReaderBuf)} or * {@link StatementManager#registerParameter(IParameterReader, IParamReaderBuf)} */ - default void writeToBuf(PacketBuffer buffer) { - NBTTagCompound nbt = new NBTTagCompound(); + default void writeToBuf(FriendlyByteBuf buffer) { + CompoundTag nbt = new CompoundTag(); writeToNbt(nbt); - buffer.writeCompoundTag(nbt); + buffer.writeNbt(nbt); } /** This returns the parameter after a left rotation. Used in particular in blueprints orientation. */ diff --git a/api/buildcraft/api/statements/ITrigger.java b/api/buildcraft/api/statements/ITrigger.java index cdb65c9..46e31e7 100644 --- a/api/buildcraft/api/statements/ITrigger.java +++ b/api/buildcraft/api/statements/ITrigger.java @@ -3,4 +3,5 @@ /** Marker interface that designates a class as being a trigger. Note that you *must* implement ONE of the following * interfaces to be recognised as a trigger: {@link ITriggerInternal}, {@link ITriggerInternalSided}, or * {@link ITriggerExternal} */ -public interface ITrigger extends IStatement {} +public interface ITrigger extends IStatement { +} diff --git a/api/buildcraft/api/statements/ITriggerExternal.java b/api/buildcraft/api/statements/ITriggerExternal.java index 87a848f..453371a 100644 --- a/api/buildcraft/api/statements/ITriggerExternal.java +++ b/api/buildcraft/api/statements/ITriggerExternal.java @@ -4,11 +4,11 @@ * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.statements; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.entity.BlockEntity; public interface ITriggerExternal extends ITrigger { - boolean isTriggerActive(TileEntity target, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters); + boolean isTriggerActive(BlockEntity target, Direction side, IStatementContainer source, IStatementParameter[] parameters); } diff --git a/api/buildcraft/api/statements/ITriggerExternalOverride.java b/api/buildcraft/api/statements/ITriggerExternalOverride.java index 9b1fd1e..5e7db16 100644 --- a/api/buildcraft/api/statements/ITriggerExternalOverride.java +++ b/api/buildcraft/api/statements/ITriggerExternalOverride.java @@ -1,6 +1,6 @@ package buildcraft.api.statements; -import net.minecraft.util.EnumFacing; +import net.minecraft.core.Direction; /** This interface can be used by tiles to override external trigger behaviour. * @@ -12,5 +12,5 @@ enum Result { IGNORE } - Result override(EnumFacing side, IStatementContainer source, ITriggerExternal trigger, IStatementParameter[] parameters); + Result override(Direction side, IStatementContainer source, ITriggerExternal trigger, IStatementParameter[] parameters); } diff --git a/api/buildcraft/api/statements/ITriggerInternalSided.java b/api/buildcraft/api/statements/ITriggerInternalSided.java index 73459f0..7298c30 100644 --- a/api/buildcraft/api/statements/ITriggerInternalSided.java +++ b/api/buildcraft/api/statements/ITriggerInternalSided.java @@ -1,7 +1,7 @@ package buildcraft.api.statements; -import net.minecraft.util.EnumFacing; +import net.minecraft.core.Direction; public interface ITriggerInternalSided extends ITrigger { - boolean isTriggerActive(EnumFacing side, IStatementContainer source, IStatementParameter[] parameters); + boolean isTriggerActive(Direction side, IStatementContainer source, IStatementParameter[] parameters); } diff --git a/api/buildcraft/api/statements/ITriggerProvider.java b/api/buildcraft/api/statements/ITriggerProvider.java index 8f3bf03..a78de97 100644 --- a/api/buildcraft/api/statements/ITriggerProvider.java +++ b/api/buildcraft/api/statements/ITriggerProvider.java @@ -4,18 +4,17 @@ * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.statements; -import java.util.Collection; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.entity.BlockEntity; import javax.annotation.Nonnull; - -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; +import java.util.Collection; public interface ITriggerProvider { void addInternalTriggers(Collection triggers, IStatementContainer container); - void addInternalSidedTriggers(Collection triggers, IStatementContainer container, @Nonnull EnumFacing side); + void addInternalSidedTriggers(Collection triggers, IStatementContainer container, @Nonnull Direction side); /** Returns the list of triggers available to a gate next to the given block. */ - void addExternalTriggers(Collection triggers, @Nonnull EnumFacing side, TileEntity tile); + void addExternalTriggers(Collection triggers, @Nonnull Direction side, BlockEntity tile); } diff --git a/api/buildcraft/api/statements/StatementManager.java b/api/buildcraft/api/statements/StatementManager.java index 49f0915..f854f5e 100644 --- a/api/buildcraft/api/statements/StatementManager.java +++ b/api/buildcraft/api/statements/StatementManager.java @@ -4,21 +4,15 @@ * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.statements; +import net.minecraft.core.Direction; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.world.level.block.entity.BlockEntity; + import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.PacketBuffer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; +import java.util.*; public final class StatementManager { - public static Map statements = new HashMap<>(); public static Map parameters = new HashMap<>(); public static Map paramsBuf = new HashMap<>(); @@ -31,16 +25,17 @@ public final class StatementManager { @FunctionalInterface public interface IParameterReader { - IStatementParameter readFromNbt(NBTTagCompound nbt); + IStatementParameter readFromNbt(CompoundTag nbt); } @FunctionalInterface public interface IParamReaderBuf { - IStatementParameter readFromBuf(PacketBuffer buffer) throws IOException; + IStatementParameter readFromBuf(FriendlyByteBuf buffer) throws IOException; } /** Deactivate constructor */ - private StatementManager() {} + private StatementManager() { + } public static void registerTriggerProvider(ITriggerProvider provider) { if (provider != null && !triggerProviders.contains(provider)) { @@ -59,11 +54,11 @@ public static void registerStatement(IStatement statement) { } public static void registerParameter(IParameterReader reader) { - registerParameter(reader, buf -> reader.readFromNbt(buf.readCompoundTag())); + registerParameter(reader, buf -> reader.readFromNbt(buf.readNbt())); } public static void registerParameter(IParameterReader reader, IParamReaderBuf bufReader) { - String name = reader.readFromNbt(new NBTTagCompound()).getUniqueTag(); + String name = reader.readFromNbt(new CompoundTag()).getUniqueTag(); registerParameter(name, reader); registerParameter(name, bufReader); } @@ -76,7 +71,7 @@ public static void registerParameter(String name, IParamReaderBuf reader) { paramsBuf.put(name, reader); } - public static List getExternalTriggers(EnumFacing side, TileEntity entity) { + public static List getExternalTriggers(Direction side, BlockEntity entity) { if (entity instanceof IOverrideDefaultStatements) { List result = ((IOverrideDefaultStatements) entity).overrideTriggers(); if (result != null) { @@ -93,7 +88,7 @@ public static List getExternalTriggers(EnumFacing side, TileEn return new ArrayList<>(triggers); } - public static List getExternalActions(EnumFacing side, TileEntity entity) { + public static List getExternalActions(Direction side, BlockEntity entity) { if (entity instanceof IOverrideDefaultStatements) { List result = ((IOverrideDefaultStatements) entity).overrideActions(); if (result != null) { @@ -130,7 +125,7 @@ public static List getInternalActions(IStatementContainer conta return new ArrayList<>(actions); } - public static List getInternalSidedTriggers(IStatementContainer container, EnumFacing side) { + public static List getInternalSidedTriggers(IStatementContainer container, Direction side) { LinkedHashSet triggers = new LinkedHashSet<>(); for (ITriggerProvider provider : triggerProviders) { @@ -140,7 +135,7 @@ public static List getInternalSidedTriggers(IStatementCon return new ArrayList<>(triggers); } - public static List getInternalSidedActions(IStatementContainer container, EnumFacing side) { + public static List getInternalSidedActions(IStatementContainer container, Direction side) { LinkedHashSet actions = new LinkedHashSet<>(); for (IActionProvider provider : actionProviders) { diff --git a/api/buildcraft/api/statements/StatementParameterItemStack.java b/api/buildcraft/api/statements/StatementParameterItemStack.java index 253bd46..9577946 100755 --- a/api/buildcraft/api/statements/StatementParameterItemStack.java +++ b/api/buildcraft/api/statements/StatementParameterItemStack.java @@ -1,25 +1,23 @@ /** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ + * BuildCraft is distributed under the terms of the Minecraft Mod Public License 1.0, or MMPL. Please check the contents + * of the license located in http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.api.statements; -import java.util.List; -import java.util.Objects; - -import javax.annotation.Nonnull; - +import buildcraft.api.core.render.ISprite; import com.google.common.collect.ImmutableList; +import net.minecraft.ChatFormatting; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.chat.Component; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.TooltipFlag; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.text.TextFormatting; - -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -import buildcraft.api.core.render.ISprite; +import javax.annotation.Nonnull; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; public class StatementParameterItemStack implements IStatementParameter { // needed because ItemStack.EMPTY doesn't have @Nonnull applied to it :/ @@ -47,8 +45,8 @@ public StatementParameterItemStack(@Nonnull ItemStack stack) { this.stack = stack; } - public StatementParameterItemStack(NBTTagCompound nbt) { - ItemStack read = new ItemStack(nbt.getCompoundTag("stack")); + public StatementParameterItemStack(CompoundTag nbt) { + ItemStack read = ItemStack.of(nbt.getCompound("stack")); if (read.isEmpty()) { stack = EMPTY_STACK; } else { @@ -57,11 +55,11 @@ public StatementParameterItemStack(NBTTagCompound nbt) { } @Override - public void writeToNbt(NBTTagCompound compound) { + public void writeToNbt(CompoundTag compound) { if (!stack.isEmpty()) { - NBTTagCompound tagCompound = new NBTTagCompound(); - stack.writeToNBT(tagCompound); - compound.setTag("stack", tagCompound); + CompoundTag tagCompound = new CompoundTag(); + stack.save(tagCompound); + compound.put("stack", tagCompound); } } @@ -78,7 +76,7 @@ public ItemStack getItemStack() { @Override public StatementParameterItemStack onClick( - IStatementContainer source, IStatement stmt, ItemStack stack, StatementMouseClick mouse + IStatementContainer source, IStatement stmt, ItemStack stack, StatementMouseClick mouse ) { if (stack.isEmpty()) { return EMPTY; @@ -94,8 +92,9 @@ public boolean equals(Object object) { if (object instanceof StatementParameterItemStack) { StatementParameterItemStack param = (StatementParameterItemStack) object; - return ItemStack.areItemStacksEqual(stack, param.stack) - && ItemStack.areItemStackTagsEqual(stack, param.stack); +// return ItemStack.areItemStacksEqual(stack, param.stack) +// && ItemStack.areItemStackTagsEqual(stack, param.stack); + return ItemStack.matches(stack, param.stack); } else { return false; } @@ -107,27 +106,50 @@ public int hashCode() { } @Override - @SideOnly(Side.CLIENT) - public String getDescription() { + @OnlyIn(Dist.CLIENT) + public Component getDescription() { + throw new UnsupportedOperationException("Don't call getDescription directly!"); + } + + @Override + @OnlyIn(Dist.CLIENT) + public String getDescriptionKey() { throw new UnsupportedOperationException("Don't call getDescription directly!"); } @Override - @SideOnly(Side.CLIENT) - public List getTooltip() { + @OnlyIn(Dist.CLIENT) + public List getTooltip() { if (stack.isEmpty()) { return ImmutableList.of(); } - List tooltip = stack.getTooltip(null, ITooltipFlag.TooltipFlags.NORMAL); + List tooltip = stack.getTooltipLines(null, TooltipFlag.Default.NORMAL); if (!tooltip.isEmpty()) { - tooltip.set(0, stack.getRarity().rarityColor + tooltip.get(0)); + tooltip.set(0, Component.literal(stack.getRarity().color.toString()).append(tooltip.get(0))); for (int i = 1; i < tooltip.size(); i++) { - tooltip.set(i, TextFormatting.GRAY + tooltip.get(i)); + tooltip.set(i, Component.literal(ChatFormatting.GRAY.toString()).append(tooltip.get(i))); } } return tooltip; } + @Override + @OnlyIn(Dist.CLIENT) + public List getTooltipKey() { + if (stack.isEmpty()) { + return ImmutableList.of(); + } + List tooltip = stack.getTooltipLines(null, TooltipFlag.Default.NORMAL); + List toolTipRet = new ArrayList<>(tooltip.size()); + if (!tooltip.isEmpty()) { + toolTipRet.set(0, Component.literal(stack.getRarity().color.toString()).append(tooltip.get(0)).getString()); + for (int i = 1; i < tooltip.size(); i++) { + toolTipRet.set(i, Component.literal(ChatFormatting.GRAY.toString()).append(tooltip.get(i)).getString()); + } + } + return toolTipRet; + } + @Override public String getUniqueTag() { return "buildcraft:stack"; diff --git a/api/buildcraft/api/statements/StatementSlot.java b/api/buildcraft/api/statements/StatementSlot.java index b3306b4..55d117f 100755 --- a/api/buildcraft/api/statements/StatementSlot.java +++ b/api/buildcraft/api/statements/StatementSlot.java @@ -4,11 +4,11 @@ * of the license located in http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.api.statements; +import buildcraft.api.core.EnumPipePart; + import java.util.Arrays; import java.util.Objects; -import buildcraft.api.core.EnumPipePart; - public class StatementSlot { public IStatement statement; public IStatementParameter[] parameters; diff --git a/api/buildcraft/api/statements/containers/IFillerStatementContainer.java b/api/buildcraft/api/statements/containers/IFillerStatementContainer.java index 475a01d..05255ed 100644 --- a/api/buildcraft/api/statements/containers/IFillerStatementContainer.java +++ b/api/buildcraft/api/statements/containers/IFillerStatementContainer.java @@ -1,23 +1,22 @@ package buildcraft.api.statements.containers; -import javax.annotation.Nullable; - -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; - import buildcraft.api.core.IBox; import buildcraft.api.filler.IFillerPattern; import buildcraft.api.statements.IStatementContainer; import buildcraft.api.statements.IStatementParameter; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.BlockEntity; + +import javax.annotation.Nullable; public interface IFillerStatementContainer extends IStatementContainer { /** Unlike in {@link IStatementContainer} some containers might not be tile based (for example the volume box). */ @Override @Nullable - TileEntity getTile(); + BlockEntity getTile(); - World getFillerWorld(); + Level getFillerWorld(); /** @return True if this filler has a non-zero sized box. */ boolean hasBox(); diff --git a/api/buildcraft/api/statements/containers/IRedstoneStatementContainer.java b/api/buildcraft/api/statements/containers/IRedstoneStatementContainer.java index 1d7989a..bab96bb 100644 --- a/api/buildcraft/api/statements/containers/IRedstoneStatementContainer.java +++ b/api/buildcraft/api/statements/containers/IRedstoneStatementContainer.java @@ -1,17 +1,17 @@ package buildcraft.api.statements.containers; -import net.minecraft.util.EnumFacing; +import net.minecraft.core.Direction; public interface IRedstoneStatementContainer { /** Get the redstone input from a given side. - * + * * @param side The side - use "null" for maximum input. * @return The redstone input, from 0 to 15. */ - int getRedstoneInput(EnumFacing side); + int getRedstoneInput(Direction side); /** Set the redstone input for a given side. - * + * * @param side The side - use "null" for all sides. * @return Whether the set was successful. */ - boolean setRedstoneOutput(EnumFacing side, int value); + boolean setRedstoneOutput(Direction side, int value); } diff --git a/api/buildcraft/api/statements/containers/ISidedStatementContainer.java b/api/buildcraft/api/statements/containers/ISidedStatementContainer.java index b65ace4..ffa23af 100644 --- a/api/buildcraft/api/statements/containers/ISidedStatementContainer.java +++ b/api/buildcraft/api/statements/containers/ISidedStatementContainer.java @@ -1,10 +1,9 @@ package buildcraft.api.statements.containers; -import net.minecraft.util.EnumFacing; - import buildcraft.api.statements.IStatementContainer; +import net.minecraft.core.Direction; /** Created by asie on 3/14/15. */ public interface ISidedStatementContainer extends IStatementContainer { - EnumFacing getSide(); + Direction getSide(); } diff --git a/api/buildcraft/api/statements/package-info.java b/api/buildcraft/api/statements/package-info.java index 64642d7..1cf5f34 100644 --- a/api/buildcraft/api/statements/package-info.java +++ b/api/buildcraft/api/statements/package-info.java @@ -2,7 +2,5 @@ * * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -@API(apiVersion = "1.1", owner = "buildcraftapi_core", provides = "buildcraftapi_statements") +//@API(apiVersion = "1.1", owner = "buildcraftapi_core", provides = "buildcraftapi_statements") package buildcraft.api.statements; - -import net.minecraftforge.fml.common.API; diff --git a/api/buildcraft/api/template/ITemplateHandler.java b/api/buildcraft/api/template/ITemplateHandler.java index e0dac1b..3674b45 100644 --- a/api/buildcraft/api/template/ITemplateHandler.java +++ b/api/buildcraft/api/template/ITemplateHandler.java @@ -6,11 +6,11 @@ package buildcraft.api.template; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; public interface ITemplateHandler { - boolean handle(World world, BlockPos pos, EntityPlayer player, ItemStack stack); + boolean handle(Level world, BlockPos pos, Player player, ItemStack stack); } diff --git a/api/buildcraft/api/template/ITemplateRegistry.java b/api/buildcraft/api/template/ITemplateRegistry.java index ec6d250..0e62d99 100644 --- a/api/buildcraft/api/template/ITemplateRegistry.java +++ b/api/buildcraft/api/template/ITemplateRegistry.java @@ -6,12 +6,11 @@ package buildcraft.api.template; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - import buildcraft.api.core.EnumHandlerPriority; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; public interface ITemplateRegistry { /** Adds a handler with a {@link EnumHandlerPriority} of {@linkplain EnumHandlerPriority#NORMAL} */ @@ -21,5 +20,5 @@ default void addHandler(ITemplateHandler handler) { void addHandler(ITemplateHandler handler, EnumHandlerPriority priority); - boolean handle(World world, BlockPos pos, EntityPlayer player, ItemStack stack); + boolean handle(Level world, BlockPos pos, Player player, ItemStack stack); } diff --git a/api/buildcraft/api/tiles/IBCTileMenuProvider.java b/api/buildcraft/api/tiles/IBCTileMenuProvider.java new file mode 100644 index 0000000..cda74c1 --- /dev/null +++ b/api/buildcraft/api/tiles/IBCTileMenuProvider.java @@ -0,0 +1,9 @@ +package buildcraft.api.tiles; + +import buildcraft.api.net.IMessage; +import net.minecraft.world.MenuProvider; +import net.minecraft.world.entity.player.Player; + +public interface IBCTileMenuProvider extends MenuProvider { + public abstract IMessage onServerPlayerOpenNoSend(Player player); +} diff --git a/api/buildcraft/api/tiles/IDebuggable.java b/api/buildcraft/api/tiles/IDebuggable.java index 8a9f2dc..3802795 100644 --- a/api/buildcraft/api/tiles/IDebuggable.java +++ b/api/buildcraft/api/tiles/IDebuggable.java @@ -1,23 +1,26 @@ package buildcraft.api.tiles; -import java.util.List; - -import net.minecraft.util.EnumFacing; +import net.minecraft.client.resources.language.I18n; +import net.minecraft.core.Direction; +import net.minecraft.network.chat.Component; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +import java.util.List; public interface IDebuggable { /** Get the debug information from a tile entity as a list of strings, used for the F3 debug menu. The left and * right parameters correspond to the sides of the F3 screen. - * + * + * @param left {@link I18n} doesn't exist in Server Side, so we should use {@link Component}. * @param side The side the block was clicked on, may be null if we don't know, or is the "centre" side */ - void getDebugInfo(List left, List right, EnumFacing side); +// void getDebugInfo(List left, List right, Direction side); + void getDebugInfo(List left, List right, Direction side); - /** Same as {@link #getDebugInfo(List, List, EnumFacing)}, but only for client + /** Same as {@link #getDebugInfo(List, List, Direction)}, but only for client * - * @param side same as for {@link #getDebugInfo(List, List, EnumFacing)} */ - @SideOnly(Side.CLIENT) - default void getClientDebugInfo(List left, List right, EnumFacing side) { + * @param side same as for {@link #getDebugInfo(List, List, Direction)} */ + @OnlyIn(Dist.CLIENT) + default void getClientDebugInfo(List left, List right, Direction side) { } } diff --git a/api/buildcraft/api/tiles/IHasWork.java b/api/buildcraft/api/tiles/IHasWork.java index fa87196..5e3b57f 100644 --- a/api/buildcraft/api/tiles/IHasWork.java +++ b/api/buildcraft/api/tiles/IHasWork.java @@ -8,7 +8,7 @@ * cetera). */ public interface IHasWork { /** Check if the Tile Entity is currently doing any work. - * + * * @return True if the Tile Entity is doing work. */ boolean hasWork(); } diff --git a/api/buildcraft/api/tiles/IHeatable.java b/api/buildcraft/api/tiles/IHeatable.java index d789ab5..a9eb43c 100644 --- a/api/buildcraft/api/tiles/IHeatable.java +++ b/api/buildcraft/api/tiles/IHeatable.java @@ -19,7 +19,7 @@ public interface IHeatable { double getCurrentHeatValue(); /** Set the heat of the tile. - * + * * @param value Heat value, in degrees. * @return The heat the tile has after the set. */ double setHeatValue(double value); diff --git a/api/buildcraft/api/tiles/ITickable.java b/api/buildcraft/api/tiles/ITickable.java new file mode 100644 index 0000000..9f21277 --- /dev/null +++ b/api/buildcraft/api/tiles/ITickable.java @@ -0,0 +1,42 @@ +package buildcraft.api.tiles; + +import net.minecraft.world.level.block.entity.BlockEntity; +import org.jetbrains.annotations.MustBeInvokedByOverriders; + +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +// From 1.12.2 MC +public interface ITickable { + /** Like the old updateEntity(), except more generic. */ + @MustBeInvokedByOverriders + default void update() { + LinkedList taskOfCurrentTile = tasks.get(this); + if (taskOfCurrentTile != null && !taskOfCurrentTile.isEmpty()) { + taskOfCurrentTile.forEach(Runnable::run); + taskOfCurrentTile.clear(); + } + } + + static final Map> tasks = new ConcurrentHashMap<>(); + + // Calen + + /** + * When world loading, BlockEntity#level may be null, or Level#getBlockState may cause dead lock + * + * @param task + * @param forceDelay If true, the task will be delayed to next update() even if the world is not null. + */ + default void runWhenWorldNotNull(Runnable task, boolean forceDelay) { + // Calen: don't create abstract method getLevel() in ITickable, because it will not be renamed when reobf, ant will become a different method from BlockEntity#getLevel. + if (forceDelay || ((BlockEntity) this).getLevel() == null) { + List tasksOfCurrentTile = tasks.computeIfAbsent(this, k -> new LinkedList<>()); + tasksOfCurrentTile.add(task); + } else { + task.run(); + } + } +} diff --git a/api/buildcraft/api/tiles/ITileAreaProvider.java b/api/buildcraft/api/tiles/ITileAreaProvider.java index 89a7c14..1ace48f 100644 --- a/api/buildcraft/api/tiles/ITileAreaProvider.java +++ b/api/buildcraft/api/tiles/ITileAreaProvider.java @@ -1,8 +1,7 @@ package buildcraft.api.tiles; -import net.minecraft.util.math.BlockPos; - import buildcraft.api.core.IAreaProvider; +import net.minecraft.core.BlockPos; /** Used for more fine-grained control of whether or not a machine connects to the provider here. */ public interface ITileAreaProvider extends IAreaProvider { diff --git a/api/buildcraft/api/tiles/TilesAPI.java b/api/buildcraft/api/tiles/TilesAPI.java index abacf92..9c09125 100644 --- a/api/buildcraft/api/tiles/TilesAPI.java +++ b/api/buildcraft/api/tiles/TilesAPI.java @@ -1,28 +1,35 @@ package buildcraft.api.tiles; -import javax.annotation.Nonnull; - import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.capabilities.CapabilityManager; +import net.minecraftforge.common.capabilities.CapabilityToken; +import net.minecraftforge.common.capabilities.RegisterCapabilitiesEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; -import buildcraft.api.core.CapabilitiesHelper; +import javax.annotation.Nonnull; public class TilesAPI { @Nonnull - public static final Capability CAP_CONTROLLABLE; + public static final Capability CAP_CONTROLLABLE = CapabilityManager.get(new CapabilityToken<>() { + }); @Nonnull - public static final Capability CAP_HAS_WORK; + public static final Capability CAP_HAS_WORK = CapabilityManager.get(new CapabilityToken<>() { + }); @Nonnull - public static final Capability CAP_HEATABLE; + public static final Capability CAP_HEATABLE = CapabilityManager.get(new CapabilityToken<>() { + }); @Nonnull - public static final Capability CAP_TILE_AREA_PROVIDER; - - static { - CAP_CONTROLLABLE = CapabilitiesHelper.registerCapability(IControllable.class); - CAP_HAS_WORK = CapabilitiesHelper.registerCapability(IHasWork.class); - CAP_HEATABLE = CapabilitiesHelper.registerCapability(IHeatable.class); - CAP_TILE_AREA_PROVIDER = CapabilitiesHelper.registerCapability(ITileAreaProvider.class); + public static final Capability CAP_TILE_AREA_PROVIDER = CapabilityManager.get(new CapabilityToken<>() { + }); + + @SubscribeEvent + public static void registerCapability(RegisterCapabilitiesEvent event) { + event.register(IControllable.class); + event.register(IHasWork.class); + event.register(IHeatable.class); + event.register(ITileAreaProvider.class); } } diff --git a/api/buildcraft/api/tiles/package-info.java b/api/buildcraft/api/tiles/package-info.java index ad60078..53b1774 100644 --- a/api/buildcraft/api/tiles/package-info.java +++ b/api/buildcraft/api/tiles/package-info.java @@ -2,7 +2,5 @@ * * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -@API(apiVersion = "1.2", owner = "buildcraftapi_core", provides = "buildcraftapi_tiles") +//@API(apiVersion = "1.2", owner = "buildcraftapi_core", provides = "buildcraftapi_tiles") package buildcraft.api.tiles; - -import net.minecraftforge.fml.common.API; diff --git a/api/buildcraft/api/tools/IToolWrench.java b/api/buildcraft/api/tools/IToolWrench.java index 9201b55..34b7e21 100644 --- a/api/buildcraft/api/tools/IToolWrench.java +++ b/api/buildcraft/api/tools/IToolWrench.java @@ -4,10 +4,10 @@ * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.tools; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumHand; -import net.minecraft.util.math.RayTraceResult; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.phys.HitResult; /*** Implement this interface on subclasses of Item to have that item work as a wrench for buildcraft */ public interface IToolWrench { @@ -20,7 +20,7 @@ public interface IToolWrench { * @param rayTrace - The object that is being wrenched * * @return true if wrenching is allowed, false if not */ - boolean canWrench(EntityPlayer player, EnumHand hand, ItemStack wrench, RayTraceResult rayTrace); + boolean canWrench(Player player, InteractionHand hand, ItemStack wrench, HitResult rayTrace); /*** Callback after the wrench has been used. This can be used to decrease durability or for other purposes. * @@ -28,5 +28,5 @@ public interface IToolWrench { * @param hand - Which hand was holding the wrench * @param wrench - The item stack that holds the wrench * @param rayTrace - The object that is being wrenched */ - void wrenchUsed(EntityPlayer player, EnumHand hand, ItemStack wrench, RayTraceResult rayTrace); + void wrenchUsed(Player player, InteractionHand hand, ItemStack wrench, HitResult rayTrace); } diff --git a/api/buildcraft/api/tools/package-info.java b/api/buildcraft/api/tools/package-info.java index f089abf..8b081c3 100644 --- a/api/buildcraft/api/tools/package-info.java +++ b/api/buildcraft/api/tools/package-info.java @@ -2,7 +2,5 @@ * * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -@API(apiVersion = "1.0", owner = "buildcraftapi_core", provides = "buildcraftapi_tools") +//@API(apiVersion = "1.0", owner = "buildcraftapi_core", provides = "buildcraftapi_tools") package buildcraft.api.tools; - -import net.minecraftforge.fml.common.API; diff --git a/api/buildcraft/api/transport/EnumWirePart.java b/api/buildcraft/api/transport/EnumWirePart.java index 687ba67..311fa48 100644 --- a/api/buildcraft/api/transport/EnumWirePart.java +++ b/api/buildcraft/api/transport/EnumWirePart.java @@ -1,9 +1,10 @@ package buildcraft.api.transport; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumFacing.AxisDirection; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.Vec3d; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.AxisDirection; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.phys.shapes.Shapes; +import net.minecraft.world.phys.shapes.VoxelShape; public enum EnumWirePart { EAST_UP_SOUTH(true, true, true), @@ -20,30 +21,36 @@ public enum EnumWirePart { public final AxisDirection x, y, z; /** The bounding box for rendering a wire or selecting an already-placed wire. */ - public final AxisAlignedBB boundingBox; + public final VoxelShape boundingBox; /** The bounding box that is used when adding pipe wire to a pipe */ - public final AxisAlignedBB boundingBoxPossible; + public final VoxelShape boundingBoxPossible; EnumWirePart(boolean x, boolean y, boolean z) { this.x = x ? AxisDirection.POSITIVE : AxisDirection.NEGATIVE; this.y = y ? AxisDirection.POSITIVE : AxisDirection.NEGATIVE; this.z = z ? AxisDirection.POSITIVE : AxisDirection.NEGATIVE; - double x1 = this.x.getOffset() * (5 / 16.0) + 0.5; - double y1 = this.y.getOffset() * (5 / 16.0) + 0.5; - double z1 = this.z.getOffset() * (5 / 16.0) + 0.5; - double x2 = this.x.getOffset() * (4 / 16.0) + 0.5; - double y2 = this.y.getOffset() * (4 / 16.0) + 0.5; - double z2 = this.z.getOffset() * (4 / 16.0) + 0.5; - this.boundingBox = new AxisAlignedBB(x1, y1, z1, x2, y2, z2); + double x1 = this.x.getStep() * (5 / 16.0) + 0.5; + double y1 = this.y.getStep() * (5 / 16.0) + 0.5; + double z1 = this.z.getStep() * (5 / 16.0) + 0.5; + double x2 = this.x.getStep() * (4 / 16.0) + 0.5; + double y2 = this.y.getStep() * (4 / 16.0) + 0.5; + double z2 = this.z.getStep() * (4 / 16.0) + 0.5; + this.boundingBox = Shapes.box(Math.min(x1, x2), Math.min(y1, y2), Math.min(z1, z2), Math.max(x1, x2), Math.max(y1, y2), Math.max(z1, z2)); - Vec3d center = new Vec3d(0.5, 0.5, 0.5); - Vec3d edge = new Vec3d(x ? 0.75 : 0.25, y ? 0.75 : 0.25, z ? 0.75 : 0.25); - this.boundingBoxPossible = new AxisAlignedBB(center.x, center.y, center.z, edge.x, - edge.y, edge.z); + Vec3 center = new Vec3(0.5, 0.5, 0.5); + Vec3 edge = new Vec3(x ? 0.75 : 0.25, y ? 0.75 : 0.25, z ? 0.75 : 0.25); + this.boundingBoxPossible = Shapes.box( + Math.min(center.x, edge.x), + Math.min(center.y, edge.y), + Math.min(center.z, edge.z), + Math.max(center.x, edge.x), + Math.max(center.y, edge.y), + Math.max(center.z, edge.z) + ); } - public AxisDirection getDirection(EnumFacing.Axis axis) { + public AxisDirection getDirection(Direction.Axis axis) { switch (axis) { case X: return x; diff --git a/api/buildcraft/api/transport/IInjectable.java b/api/buildcraft/api/transport/IInjectable.java index 2aeebd6..58da923 100644 --- a/api/buildcraft/api/transport/IInjectable.java +++ b/api/buildcraft/api/transport/IInjectable.java @@ -1,16 +1,17 @@ package buildcraft.api.transport; +import net.minecraft.core.Direction; +import net.minecraft.world.item.DyeColor; +import net.minecraft.world.item.ItemStack; + import javax.annotation.Nonnull; -import net.minecraft.item.EnumDyeColor; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; /** Interface for pipes to implement if they can accept items in a similar fashion to BC pipes. */ public interface IInjectable { /** Tests to see if this pipe can accept items from the given direction. Useless to call this if you are going to - * call {@link #injectItem(ItemStack, boolean, EnumFacing, EnumDyeColor, double)} straight after. */ - boolean canInjectItems(EnumFacing from); + * call {@link #injectItem(ItemStack, boolean, Direction, DyeColor, double)} straight after. */ + boolean canInjectItems(Direction from); /** Offers an ItemStack for addition to the pipe. Will be rejected if the pipe doesn't accept items from that side. * This should never be called on the client side! Implementors are free to throw an exception if be called on the @@ -23,5 +24,5 @@ public interface IInjectable { * @param speed The speed of the item to be added (in blocks per tick) or {@code <=0} if a default should be used. * @return The left over stack that was not accepted. */ @Nonnull - ItemStack injectItem(@Nonnull ItemStack stack, boolean doAdd, EnumFacing from, EnumDyeColor color, double speed); + ItemStack injectItem(@Nonnull ItemStack stack, boolean doAdd, Direction from, DyeColor color, double speed); } diff --git a/api/buildcraft/api/transport/IItemPluggable.java b/api/buildcraft/api/transport/IItemPluggable.java index a55a0c4..d752ca7 100644 --- a/api/buildcraft/api/transport/IItemPluggable.java +++ b/api/buildcraft/api/transport/IItemPluggable.java @@ -1,27 +1,25 @@ package buildcraft.api.transport; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; - import buildcraft.api.transport.pipe.IPipeHolder; import buildcraft.api.transport.pluggable.PipePluggable; +import net.minecraft.core.Direction; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; /** Designates an item that can be placed onto a pipe as a {@link PipePluggable}. */ public interface IItemPluggable { /** Called when this item is placed onto a pipe holder. This can return null if this item does not make a valid * pluggable. Note that if you return a non-null pluggable then it will *definitely* be added to the pipe, and you * are responsible for making all the effects yourself (like the sound effect). - * + * * @param stack The stack that holds this item * @param holder The pipe holder * @param side The side that the pluggable should be placed on * @return A pluggable to place onto the pipe */ @Nullable - PipePluggable onPlace(@Nonnull ItemStack stack, IPipeHolder holder, EnumFacing side, EntityPlayer player, - EnumHand hand); + PipePluggable onPlace(@Nonnull ItemStack stack, IPipeHolder holder, Direction side, Player player, InteractionHand hand); } diff --git a/api/buildcraft/api/transport/IStripesActivator.java b/api/buildcraft/api/transport/IStripesActivator.java index a0dd7c8..a39d034 100644 --- a/api/buildcraft/api/transport/IStripesActivator.java +++ b/api/buildcraft/api/transport/IStripesActivator.java @@ -4,13 +4,13 @@ * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.transport; -import javax.annotation.Nonnull; +import net.minecraft.core.Direction; +import net.minecraft.world.item.ItemStack; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; +import javax.annotation.Nonnull; public interface IStripesActivator { - boolean sendItem(@Nonnull ItemStack itemStack, EnumFacing from); + boolean sendItem(@Nonnull ItemStack itemStack, Direction from); - void dropItem(@Nonnull ItemStack itemStack, EnumFacing from); + void dropItem(@Nonnull ItemStack itemStack, Direction from); } diff --git a/api/buildcraft/api/transport/IStripesHandlerBlock.java b/api/buildcraft/api/transport/IStripesHandlerBlock.java index 888cac4..e94c8da 100644 --- a/api/buildcraft/api/transport/IStripesHandlerBlock.java +++ b/api/buildcraft/api/transport/IStripesHandlerBlock.java @@ -1,9 +1,9 @@ package buildcraft.api.transport; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.Level; public interface IStripesHandlerBlock { @@ -14,5 +14,5 @@ public interface IStripesHandlerBlock { * @param activator * @return True if this broke a block, false otherwise (note that this handler MUST NOT return false if it has * changed the world in any way) */ - boolean handle(World world, BlockPos pos, EnumFacing direction, EntityPlayer player, IStripesActivator activator); + boolean handle(Level world, BlockPos pos, Direction direction, Player player, IStripesActivator activator); } diff --git a/api/buildcraft/api/transport/IStripesHandlerItem.java b/api/buildcraft/api/transport/IStripesHandlerItem.java index 6512be8..e361baa 100644 --- a/api/buildcraft/api/transport/IStripesHandlerItem.java +++ b/api/buildcraft/api/transport/IStripesHandlerItem.java @@ -4,20 +4,20 @@ * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.transport; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; public interface IStripesHandlerItem { /** Called to handle the given {@link ItemStack} within the world. Note that the player's inventory will be empty, - * except that the target stack will be set into its {@link EnumHand#MAIN_HAND}. Any items left in the players + * except that the target stack will be set into its {@link InteractionHand#MAIN_HAND}. Any items left in the players * inventory will be returned back through the activator with - * {@link IStripesActivator#sendItem(ItemStack, EnumFacing)} - * + * {@link IStripesActivator#sendItem(ItemStack, Direction)} + * * @param world * @param pos * @param direction @@ -26,5 +26,5 @@ public interface IStripesHandlerItem { * @param activator * @return True if this used the item, false otherwise (note that this handler MUST NOT return false if it has * changed the world in any way) */ - boolean handle(World world, BlockPos pos, EnumFacing direction, ItemStack stack, EntityPlayer player, IStripesActivator activator); + boolean handle(Level world, BlockPos pos, Direction direction, ItemStack stack, Player player, IStripesActivator activator); } diff --git a/api/buildcraft/api/transport/IStripesRegistry.java b/api/buildcraft/api/transport/IStripesRegistry.java index ae69806..f71bb26 100644 --- a/api/buildcraft/api/transport/IStripesRegistry.java +++ b/api/buildcraft/api/transport/IStripesRegistry.java @@ -1,12 +1,14 @@ package buildcraft.api.transport; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - import buildcraft.api.core.EnumHandlerPriority; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; + +import java.util.EnumMap; +import java.util.List; public interface IStripesRegistry { /** Adds a handler with a {@link EnumHandlerPriority} of {@linkplain EnumHandlerPriority#NORMAL} */ @@ -25,17 +27,22 @@ default void addHandler(IStripesHandlerBlock handler) { /** @param pos The position of the stripes pipe. * @return True if a handler handled the itemstack, false otherwise (and so nothing has been done) */ - boolean handleItem(World world, + boolean handleItem(Level world, BlockPos pos, - EnumFacing direction, + Direction direction, ItemStack stack, - EntityPlayer player, + Player player, IStripesActivator activator); /** @return True if a handler broke a block, false otherwise (and so nothing has been done) */ - boolean handleBlock(World world, + boolean handleBlock(Level world, BlockPos pos, - EnumFacing direction, - EntityPlayer player, + Direction direction, + Player player, IStripesActivator activator); + + // Calen 1.18.2 + public EnumMap> getItemHandlers(); + + public EnumMap> getBlockHandlers(); } diff --git a/api/buildcraft/api/transport/IWireEmitter.java b/api/buildcraft/api/transport/IWireEmitter.java index 4b480e2..bf7a844 100644 --- a/api/buildcraft/api/transport/IWireEmitter.java +++ b/api/buildcraft/api/transport/IWireEmitter.java @@ -6,13 +6,13 @@ package buildcraft.api.transport; -import net.minecraft.item.EnumDyeColor; +import net.minecraft.world.item.DyeColor; public interface IWireEmitter { /** Checks to see if this wire emitter is currently emitting the given colour. Only used to check if a given emitter * is still active. */ - boolean isEmitting(EnumDyeColor colour); + boolean isEmitting(DyeColor colour); /** Emits the given wire colour this tick. */ - void emitWire(EnumDyeColor colour); + void emitWire(DyeColor colour); } diff --git a/api/buildcraft/api/transport/IWireManager.java b/api/buildcraft/api/transport/IWireManager.java index 942c3ab..c55514f 100644 --- a/api/buildcraft/api/transport/IWireManager.java +++ b/api/buildcraft/api/transport/IWireManager.java @@ -1,8 +1,7 @@ package buildcraft.api.transport; -import net.minecraft.item.EnumDyeColor; - import buildcraft.api.transport.pipe.IPipeHolder; +import net.minecraft.world.item.DyeColor; public interface IWireManager { @@ -10,15 +9,15 @@ public interface IWireManager { void updateBetweens(boolean recursive); - EnumDyeColor getColorOfPart(EnumWirePart part); + DyeColor getColorOfPart(EnumWirePart part); - EnumDyeColor removePart(EnumWirePart part); + DyeColor removePart(EnumWirePart part); - boolean addPart(EnumWirePart part, EnumDyeColor colour); + boolean addPart(EnumWirePart part, DyeColor colour); - boolean hasPartOfColor(EnumDyeColor color); + boolean hasPartOfColor(DyeColor color); boolean isPowered(EnumWirePart part); - boolean isAnyPowered(EnumDyeColor color); + boolean isAnyPowered(DyeColor color); } diff --git a/api/buildcraft/api/transport/WireNode.java b/api/buildcraft/api/transport/WireNode.java index 5430b64..1f23bfd 100644 --- a/api/buildcraft/api/transport/WireNode.java +++ b/api/buildcraft/api/transport/WireNode.java @@ -1,12 +1,12 @@ package buildcraft.api.transport; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.Direction.AxisDirection; + import java.util.EnumMap; import java.util.Map; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumFacing.AxisDirection; -import net.minecraft.util.math.BlockPos; - public class WireNode { public final BlockPos pos; public final EnumWirePart part; @@ -30,7 +30,7 @@ public boolean equals(Object obj) { if (getClass() != obj.getClass()) return false; WireNode other = (WireNode) obj; return part == other.part // - && pos.equals(other.pos); + && pos.equals(other.pos); } @Override @@ -38,22 +38,22 @@ public String toString() { return "(" + pos.getX() + ", " + pos.getY() + ", " + pos.getZ() + ", " + part + ")"; } - public WireNode offset(EnumFacing face) { - int nx = (part.x == AxisDirection.POSITIVE ? 1 : 0) + face.getFrontOffsetX(); - int ny = (part.y == AxisDirection.POSITIVE ? 1 : 0) + face.getFrontOffsetY(); - int nz = (part.z == AxisDirection.POSITIVE ? 1 : 0) + face.getFrontOffsetZ(); + public WireNode offset(Direction face) { + int nx = (part.x == AxisDirection.POSITIVE ? 1 : 0) + face.getStepX(); + int ny = (part.y == AxisDirection.POSITIVE ? 1 : 0) + face.getStepY(); + int nz = (part.z == AxisDirection.POSITIVE ? 1 : 0) + face.getStepZ(); EnumWirePart nPart = EnumWirePart.get(nx, ny, nz); if (nx < 0 || ny < 0 || nz < 0 || nx > 1 || ny > 1 || nz > 1) { - return new WireNode(pos.offset(face), nPart); + return new WireNode(pos.relative(face), nPart); } else { return new WireNode(pos, nPart); } } - public Map getAllPossibleConnections() { - Map map = new EnumMap<>(EnumFacing.class); + public Map getAllPossibleConnections() { + Map map = new EnumMap<>(Direction.class); - for (EnumFacing face : EnumFacing.VALUES) { + for (Direction face : Direction.VALUES) { map.put(face, offset(face)); } return map; diff --git a/api/buildcraft/api/transport/package-info.java b/api/buildcraft/api/transport/package-info.java index b9cd4de..ea4e143 100644 --- a/api/buildcraft/api/transport/package-info.java +++ b/api/buildcraft/api/transport/package-info.java @@ -2,7 +2,5 @@ * * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -@API(apiVersion = "5.0", owner = "buildcraftapi_core", provides = "buildcraftapi_transport") +//@API(apiVersion = "5.0", owner = "buildcraftapi_core", provides = "buildcraftapi_transport") package buildcraft.api.transport; - -import net.minecraftforge.fml.common.API; diff --git a/api/buildcraft/api/transport/pipe/ICustomPipeConnection.java b/api/buildcraft/api/transport/pipe/ICustomPipeConnection.java index d4ca9ab..41b317b 100644 --- a/api/buildcraft/api/transport/pipe/ICustomPipeConnection.java +++ b/api/buildcraft/api/transport/pipe/ICustomPipeConnection.java @@ -1,13 +1,13 @@ package buildcraft.api.transport.pipe; -import net.minecraft.block.state.IBlockState; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.BlockState; public interface ICustomPipeConnection { /** @return How long the connecting pipe should extend for, in addition to its normal 4/16f connection. Values less * than or equal to -4 / 16.0f indicate that the pipe will not connect at all, and will render - * as it it was not connected. */ - float getExtension(World world, BlockPos pos, EnumFacing face, IBlockState state); + * as it was not connected. */ + float getExtension(Level world, BlockPos pos, Direction face, BlockState state); } diff --git a/api/buildcraft/api/transport/pipe/IFlowFluid.java b/api/buildcraft/api/transport/pipe/IFlowFluid.java index 259736a..0c5b595 100644 --- a/api/buildcraft/api/transport/pipe/IFlowFluid.java +++ b/api/buildcraft/api/transport/pipe/IFlowFluid.java @@ -1,24 +1,24 @@ package buildcraft.api.transport.pipe; -import javax.annotation.Nullable; - -import net.minecraft.util.ActionResult; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumFacing; - -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.capability.IFluidHandler; - import buildcraft.api.core.IFluidFilter; import buildcraft.api.core.IFluidHandlerAdv; import buildcraft.api.transport.pluggable.PipePluggable; +import net.minecraft.core.Direction; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.InteractionResultHolder; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.capability.IFluidHandler; +import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction; + +import javax.annotation.Nullable; public interface IFlowFluid { /** @deprecated use the version below with a simulate paramater. */ @Nullable @Deprecated - default FluidStack tryExtractFluid(int millibuckets, EnumFacing from, FluidStack filter) { - return tryExtractFluid(millibuckets, from, filter, false); + default FluidStack tryExtractFluid(int millibuckets, Direction from, FluidStack filter) { +// return tryExtractFluid(millibuckets, from, filter, false); + return tryExtractFluid(millibuckets, from, filter, FluidAction.EXECUTE); } /** @param millibuckets @@ -26,41 +26,46 @@ default FluidStack tryExtractFluid(int millibuckets, EnumFacing from, FluidStack * @param filter The fluidstack that the extracted fluid must match, or null for any fluid. * @return The fluidstack extracted and inserted into the pipe. */ @Nullable - FluidStack tryExtractFluid(int millibuckets, EnumFacing from, FluidStack filter, boolean simulate); +// FluidStack tryExtractFluid(int millibuckets, Direction from, FluidStack filter, boolean simulate); + FluidStack tryExtractFluid(int millibuckets, Direction from, FluidStack filter, FluidAction action); /** @deprecated use the version below with a simulate paramater. */ @Deprecated - default ActionResult tryExtractFluidAdv(int millibuckets, EnumFacing from, IFluidFilter filter) { - return tryExtractFluidAdv(millibuckets, from, filter, false); + default InteractionResultHolder tryExtractFluidAdv(int millibuckets, Direction from, IFluidFilter filter) { +// return tryExtractFluidAdv(millibuckets, from, filter, false); + return tryExtractFluidAdv(millibuckets, from, filter, FluidAction.EXECUTE); } - /** Advanced version of {@link #tryExtractFluid(int, EnumFacing, FluidStack, boolean)}. Note that this only works for + /** Advanced version of {@link #tryExtractFluid(int, Direction, FluidStack, FluidAction)}. Note that this only works for * instances of {@link IFluidHandler} that ALSO extends {@link IFluidHandlerAdv} - * + * * @param millibuckets * @param from - * @param filter A filter to try and match fluids. - * @return The fluidstack extracted and inserted into the pipe. If {@link ActionResult#getType()} equals - * {@link EnumActionResult#PASS} then it means that the {@link IFluidHandler} didn't implement - * {@link IFluidHandlerAdv} and you should call the basic version, if you can. */ - ActionResult tryExtractFluidAdv(int millibuckets, EnumFacing from, IFluidFilter filter, boolean simulate); + * @param filter A filter to try and match fluids. + * @return The fluidstack extracted and inserted into the pipe. If {@link InteractionResultHolder#getResult()} equals + * {@link InteractionResult#PASS} then it means that the {@link IFluidHandler} didn't implement + * {@link IFluidHandlerAdv} and you should call the basic version, if you can. */ +// InteractionResultHolder tryExtractFluidAdv(int millibuckets, Direction from, IFluidFilter filter, boolean simulate); + InteractionResultHolder tryExtractFluidAdv(int millibuckets, Direction from, IFluidFilter filter, FluidAction action); /** Attempts to insert a fluid directly into the pipe. Note that this will fail if the pipe currently contains a * different fluid type. - * + * * @param from The side that the fluid should *not* go in, or null if the fluid may flow in any direction. * @return The amount of fluid that was accepted, or 0 if no fluid was accepted. */ - int insertFluidsForce(FluidStack fluid, @Nullable EnumFacing from, boolean simulate); +// int insertFluidsForce(FluidStack fluid, @Nullable EnumFacing from, boolean simulate); + int insertFluidsForce(FluidStack fluid, @Nullable Direction from, FluidAction action); /** Tries to extract fluids directly from the pipe. NOTE: This is intended for {@link PipeBehaviour} and * {@link PipePluggable} implementors ONLY! This will result in very buggy behaviour if external tiles try to use * this! - * + * * @param min The minimum amount of fluid to extract. If less than this amount is in the given center then nothing * will be extracted. * @param section The section to extract from. Null means the center. - * @param simulate + * @param action * @return */ @Nullable - FluidStack extractFluidsForce(int min, int max, @Nullable EnumFacing section, boolean simulate); +// FluidStack extractFluidsForce(int min, int max, @Nullable EnumFacing section, boolean simulate); + FluidStack extractFluidsForce(int min, int max, @Nullable Direction section, FluidAction action); } diff --git a/api/buildcraft/api/transport/pipe/IFlowItems.java b/api/buildcraft/api/transport/pipe/IFlowItems.java index bdedd38..ec032f0 100644 --- a/api/buildcraft/api/transport/pipe/IFlowItems.java +++ b/api/buildcraft/api/transport/pipe/IFlowItems.java @@ -1,45 +1,44 @@ package buildcraft.api.transport.pipe; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import net.minecraft.item.EnumDyeColor; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; - import buildcraft.api.core.IStackFilter; import buildcraft.api.transport.IInjectable; +import net.minecraft.core.Direction; +import net.minecraft.world.item.DyeColor; +import net.minecraft.world.item.ItemStack; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; public interface IFlowItems extends IInjectable { /** @deprecated Use the version below with a simulate paramater. */ @Deprecated - default int tryExtractItems(int count, EnumFacing from, @Nullable EnumDyeColor colour, IStackFilter filter) { + default int tryExtractItems(int count, Direction from, @Nullable DyeColor colour, IStackFilter filter) { return tryExtractItems(count, from, colour, filter, false); } /** Attempts to extract items from the inventory connected to this pipe on the given side. - * + * * @param count The maximum number of items to extract * @param from The direction to extract from. * @param colour The colour that extracted items should be painted. * @param filter The filter to determine what can be extracted. * @param simulate If true then only simulate the extraction. * @return The number of items extracted. */ - int tryExtractItems(int count, EnumFacing from, @Nullable EnumDyeColor colour, IStackFilter filter, boolean simulate); + int tryExtractItems(int count, Direction from, @Nullable DyeColor colour, IStackFilter filter, boolean simulate); /** Inserts an item directly into the centre of this pipe, going in the given direction. This should ONLY be called * from an instance of {@link PipeBehaviour}, as otherwise it can lead to problems. (For example crashing if a pipe * contains an item that the pipe behaviour doesn't expect). - * + * * @param stack ItemStack offered for addition. Do not manipulate this! * @param from Orientation the ItemStack should pretend to be coming from. * @param colour The colour of the item to be added to the pipe, or null for no colour. * @param speed The speed of the item to be added (in blocks per tick) or {@code <=0} if a default should be * used. */ - void insertItemsForce(@Nonnull ItemStack stack, EnumFacing from, @Nullable EnumDyeColor colour, double speed); + void insertItemsForce(@Nonnull ItemStack stack, Direction from, @Nullable DyeColor colour, double speed); /** Sends a phantom (fake) item from the given facing, to the other facing. If from is null then it will start at * the center, or if to is null then it will end at the center. */ - void sendPhantomItem(@Nonnull ItemStack stack, @Nullable EnumFacing from, @Nullable EnumFacing to, @Nullable EnumDyeColor colour); + void sendPhantomItem(@Nonnull ItemStack stack, @Nullable Direction from, @Nullable Direction to, @Nullable DyeColor colour); } diff --git a/api/buildcraft/api/transport/pipe/IFlowPower.java b/api/buildcraft/api/transport/pipe/IFlowPower.java index 051d0ad..a240e31 100644 --- a/api/buildcraft/api/transport/pipe/IFlowPower.java +++ b/api/buildcraft/api/transport/pipe/IFlowPower.java @@ -1,17 +1,17 @@ package buildcraft.api.transport.pipe; -import net.minecraft.util.EnumFacing; - import buildcraft.api.mj.IMjPassiveProvider; +import net.minecraft.core.Direction; -public interface IFlowPower { +public interface IFlowPower extends IFlowPowerLike { /** Makes this pipe reconfigure itself, possibly due to the addition of new modules. */ + @Override void reconfigure(); /** Attempts to extract power from the {@link IMjPassiveProvider} connected to this pipe on the given side. - * + * * @param maxPower The Maximum amount of power that can be extracted. * @param from The side (of this pipe) to take power from. * @return The amount of power extracted. */ - long tryExtractPower(long maxPower, EnumFacing from); + long tryExtractPower(long maxPower, Direction from); } diff --git a/api/buildcraft/api/transport/pipe/IFlowPowerLike.java b/api/buildcraft/api/transport/pipe/IFlowPowerLike.java new file mode 100644 index 0000000..c56b085 --- /dev/null +++ b/api/buildcraft/api/transport/pipe/IFlowPowerLike.java @@ -0,0 +1,6 @@ +package buildcraft.api.transport.pipe; + +public interface IFlowPowerLike { + /** Makes this pipe reconfigure itself, possibly due to the addition of new modules. */ + void reconfigure(); +} diff --git a/api/buildcraft/api/transport/pipe/IFlowRedstoneFlux.java b/api/buildcraft/api/transport/pipe/IFlowRedstoneFlux.java new file mode 100644 index 0000000..d87b98c --- /dev/null +++ b/api/buildcraft/api/transport/pipe/IFlowRedstoneFlux.java @@ -0,0 +1,18 @@ +package buildcraft.api.transport.pipe; + +import net.minecraft.core.Direction; +import net.minecraftforge.energy.IEnergyStorage; + +public interface IFlowRedstoneFlux extends IFlowPowerLike { + /** Makes this pipe reconfigure itself, possibly due to the addition of new modules. */ + @Override + void reconfigure(); + + /** Attempts to extract power from the {@link IEnergyStorage} connected to this pipe on the given side. + * + * @param maxPower The Maximum amount of power that can be extracted. + * @param from The side (of this pipe) to take power from. + * @return The amount of power extracted. */ + // int tryExtractPower(int maxPower, EnumFacing from); + int tryExtractPower(int maxPower, Direction from); +} diff --git a/api/buildcraft/api/transport/pipe/IItemPipe.java b/api/buildcraft/api/transport/pipe/IItemPipe.java index 1d2d377..a1472b5 100644 --- a/api/buildcraft/api/transport/pipe/IItemPipe.java +++ b/api/buildcraft/api/transport/pipe/IItemPipe.java @@ -1,7 +1,14 @@ package buildcraft.api.transport.pipe; +import net.minecraft.world.item.DyeColor; + +import javax.annotation.Nullable; + /** To be implemented by the real item pipe in Transport mod, but leaves knowledge for classes that do not have direct * dependency on transport. */ public interface IItemPipe { PipeDefinition getDefinition(); + + @Nullable + DyeColor getColour(); } diff --git a/api/buildcraft/api/transport/pipe/IPipe.java b/api/buildcraft/api/transport/pipe/IPipe.java index 8f3d51e..a6ebdf4 100644 --- a/api/buildcraft/api/transport/pipe/IPipe.java +++ b/api/buildcraft/api/transport/pipe/IPipe.java @@ -1,9 +1,8 @@ package buildcraft.api.transport.pipe; -import net.minecraft.item.EnumDyeColor; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; - +import net.minecraft.core.Direction; +import net.minecraft.world.item.DyeColor; +import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraftforge.common.capabilities.ICapabilityProvider; public interface IPipe extends ICapabilityProvider { @@ -15,19 +14,19 @@ public interface IPipe extends ICapabilityProvider { PipeFlow getFlow(); - EnumDyeColor getColour(); + DyeColor getColour(); - void setColour(EnumDyeColor colour); + void setColour(DyeColor colour); void markForUpdate(); - TileEntity getConnectedTile(EnumFacing side); + BlockEntity getConnectedTile(Direction side); - IPipe getConnectedPipe(EnumFacing side); + IPipe getConnectedPipe(Direction side); - boolean isConnected(EnumFacing side); + boolean isConnected(Direction side); - ConnectedType getConnectedType(EnumFacing side); + ConnectedType getConnectedType(Direction side); enum ConnectedType { TILE, diff --git a/api/buildcraft/api/transport/pipe/IPipeBehaviourBaker.java b/api/buildcraft/api/transport/pipe/IPipeBehaviourBaker.java index f5c50cb..c4a4a46 100644 --- a/api/buildcraft/api/transport/pipe/IPipeBehaviourBaker.java +++ b/api/buildcraft/api/transport/pipe/IPipeBehaviourBaker.java @@ -1,9 +1,9 @@ package buildcraft.api.transport.pipe; -import java.util.List; - import net.minecraft.client.renderer.block.model.BakedQuad; +import java.util.List; + public interface IPipeBehaviourBaker { List bake(B behaviour); } diff --git a/api/buildcraft/api/transport/pipe/IPipeBehaviourRenderer.java b/api/buildcraft/api/transport/pipe/IPipeBehaviourRenderer.java index 5b00179..f420c9b 100644 --- a/api/buildcraft/api/transport/pipe/IPipeBehaviourRenderer.java +++ b/api/buildcraft/api/transport/pipe/IPipeBehaviourRenderer.java @@ -1,12 +1,12 @@ package buildcraft.api.transport.pipe; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraft.client.renderer.BufferBuilder; - -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) +@OnlyIn(Dist.CLIENT) public interface IPipeBehaviourRenderer { - void render(B behaviour, double x, double y, double z, float partialTicks, BufferBuilder bb); + // void render(B behaviour, double x, double y, double z, float partialTicks, BufferBuilder bb); + public void render(B gate, float partialTicks, PoseStack poseStack, VertexConsumer vertexConsumer, int combinedLight, int combinedOverlay); } diff --git a/api/buildcraft/api/transport/pipe/IPipeConnection.java b/api/buildcraft/api/transport/pipe/IPipeConnection.java index 55a5142..2031feb 100644 --- a/api/buildcraft/api/transport/pipe/IPipeConnection.java +++ b/api/buildcraft/api/transport/pipe/IPipeConnection.java @@ -4,7 +4,7 @@ * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.transport.pipe; -import net.minecraft.util.EnumFacing; +import net.minecraft.core.Direction; @Deprecated // TODO: Test to see if this is necessary! (Or perhaps make it a capability) @@ -22,5 +22,5 @@ enum ConnectOverride { * @param type * @param with * @return CONNECT to force a connection, DISCONNECT to force no connection, and DEFAULT to let the pipe decide. */ - ConnectOverride overridePipeConnection(Object/*IPipeTile.PipeType*/ type, EnumFacing with); + ConnectOverride overridePipeConnection(Object/*IPipeTile.PipeType*/ type, Direction with); } diff --git a/api/buildcraft/api/transport/pipe/IPipeExtensionManager.java b/api/buildcraft/api/transport/pipe/IPipeExtensionManager.java index eaf6628..5a85944 100644 --- a/api/buildcraft/api/transport/pipe/IPipeExtensionManager.java +++ b/api/buildcraft/api/transport/pipe/IPipeExtensionManager.java @@ -4,12 +4,11 @@ * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.transport.pipe; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - import buildcraft.api.transport.IStripesActivator; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; public interface IPipeExtensionManager { @@ -26,7 +25,7 @@ public interface IPipeExtensionManager { * @param stack the pipe stack to use (Note: only uses one item and sends the rest back) * @return true on success, false otherwise */ - boolean requestPipeExtension(World world, BlockPos pos, EnumFacing dir, IStripesActivator stripes, ItemStack stack); + boolean requestPipeExtension(Level world, BlockPos pos, Direction dir, IStripesActivator stripes, ItemStack stack); /** * Registers a pipe as a retraction trigger for pipe extension requests diff --git a/api/buildcraft/api/transport/pipe/IPipeFlowBaker.java b/api/buildcraft/api/transport/pipe/IPipeFlowBaker.java index 97bcf98..c23afc2 100644 --- a/api/buildcraft/api/transport/pipe/IPipeFlowBaker.java +++ b/api/buildcraft/api/transport/pipe/IPipeFlowBaker.java @@ -1,9 +1,9 @@ package buildcraft.api.transport.pipe; -import java.util.List; - import net.minecraft.client.renderer.block.model.BakedQuad; +import java.util.List; + public interface IPipeFlowBaker { List bake(F flow); } diff --git a/api/buildcraft/api/transport/pipe/IPipeFlowRenderer.java b/api/buildcraft/api/transport/pipe/IPipeFlowRenderer.java index 7ce7636..d5021a3 100644 --- a/api/buildcraft/api/transport/pipe/IPipeFlowRenderer.java +++ b/api/buildcraft/api/transport/pipe/IPipeFlowRenderer.java @@ -1,12 +1,11 @@ package buildcraft.api.transport.pipe; -import net.minecraft.client.renderer.BufferBuilder; +import com.mojang.blaze3d.vertex.PoseStack; +import net.minecraft.client.renderer.MultiBufferSource; public interface IPipeFlowRenderer { /** @param flow The flow to render - * @param x - * @param y - * @param z - * @param bufferBuilder The (optional) vertex buffer that you can render into. Note that you can still do GL stuff. */ - void render(F flow, double x, double y, double z, float partialTicks, BufferBuilder bufferBuilder); + * @param bufferSource The buffer source of (optional) vertex buffer that you can render into. Note that you can still do GL stuff. */ +// void render(F flow, double x, double y, double z, float partialTicks, BufferBuilder bufferBuilder); + void render(F flow, float partialTicks, PoseStack poseStack, MultiBufferSource bufferSource, int combinedLight, int combinedOverlay); } diff --git a/api/buildcraft/api/transport/pipe/IPipeHolder.java b/api/buildcraft/api/transport/pipe/IPipeHolder.java index ef00690..e1bfb46 100644 --- a/api/buildcraft/api/transport/pipe/IPipeHolder.java +++ b/api/buildcraft/api/transport/pipe/IPipeHolder.java @@ -1,50 +1,49 @@ package buildcraft.api.transport.pipe; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import com.mojang.authlib.GameProfile; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.network.PacketBuffer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -import net.minecraftforge.common.capabilities.Capability; - import buildcraft.api.statements.containers.IRedstoneStatementContainer; +import buildcraft.api.tiles.IBCTileMenuProvider; +import buildcraft.api.tiles.ITickable; import buildcraft.api.transport.IWireManager; import buildcraft.api.transport.pluggable.PipePluggable; +import com.mojang.authlib.GameProfile; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraftforge.common.capabilities.Capability; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; /** Designates a tile that can contain a pipe, up to 6 sided pluggables. */ -public interface IPipeHolder extends IRedstoneStatementContainer { - World getPipeWorld(); +public interface IPipeHolder extends IRedstoneStatementContainer, IBCTileMenuProvider, ITickable { + Level getPipeWorld(); BlockPos getPipePos(); - TileEntity getPipeTile(); + BlockEntity getPipeTile(); IPipe getPipe(); /** @return true if the player should be able to interact with the pipe holder in GUI form. Implementors should * generally check to ensure they are still present in-world. */ - boolean canPlayerInteract(EntityPlayer player); + boolean canPlayerInteract(Player player); @Nullable - PipePluggable getPluggable(EnumFacing side); + PipePluggable getPluggable(Direction side); @Nullable - TileEntity getNeighbourTile(EnumFacing side); + BlockEntity getNeighbourTile(Direction side); @Nullable - IPipe getNeighbourPipe(EnumFacing side); + IPipe getNeighbourPipe(Direction side); /** Gets the given capability going outwards from the pipe. This will test the * {@link PipePluggable#getInternalCapability(Capability)} first, and the look at the neighbouring tile. */ @Nullable - T getCapabilityFromPipe(EnumFacing side, @Nonnull Capability capability); + T getCapabilityFromPipe(Direction side, @Nonnull Capability capability); IWireManager getWireManager(); @@ -60,7 +59,7 @@ public interface IPipeHolder extends IRedstoneStatementContainer { /** Schedules a GUI network update, that is only the players who currently have a pipe element open in a GUI will be * updated. - * + * * @param parts The parts that want to send a network update. */ void scheduleNetworkGuiUpdate(PipeMessageReceiver... parts); @@ -71,20 +70,25 @@ public interface IPipeHolder extends IRedstoneStatementContainer { void sendGuiMessage(PipeMessageReceiver to, IWriter writer); /** Called on the server whenever a gui container object is opened. */ - void onPlayerOpen(EntityPlayer player); + void onPlayerOpen(Player player); + + @Override + default void update() { + ITickable.super.update(); + } /** Called on the server whenever a gui container object is closed. */ - void onPlayerClose(EntityPlayer player); + void onPlayerClose(Player player); enum PipeMessageReceiver { BEHAVIOUR(null), FLOW(null), - PLUGGABLE_DOWN(EnumFacing.DOWN), - PLUGGABLE_UP(EnumFacing.UP), - PLUGGABLE_NORTH(EnumFacing.NORTH), - PLUGGABLE_SOUTH(EnumFacing.SOUTH), - PLUGGABLE_WEST(EnumFacing.WEST), - PLUGGABLE_EAST(EnumFacing.EAST), + PLUGGABLE_DOWN(Direction.DOWN), + PLUGGABLE_UP(Direction.UP), + PLUGGABLE_NORTH(Direction.NORTH), + PLUGGABLE_SOUTH(Direction.SOUTH), + PLUGGABLE_WEST(Direction.WEST), + PLUGGABLE_EAST(Direction.EAST), WIRES(null); // Wires are updated differently (they never use this API) @@ -99,14 +103,14 @@ enum PipeMessageReceiver { } } - public final EnumFacing face; + public final Direction face; - PipeMessageReceiver(EnumFacing face) { + PipeMessageReceiver(Direction face) { this.face = face; } } interface IWriter { - void write(PacketBuffer buffer); + void write(FriendlyByteBuf buffer); } } diff --git a/api/buildcraft/api/transport/pipe/IPipeRegistry.java b/api/buildcraft/api/transport/pipe/IPipeRegistry.java index e4ead26..84df580 100644 --- a/api/buildcraft/api/transport/pipe/IPipeRegistry.java +++ b/api/buildcraft/api/transport/pipe/IPipeRegistry.java @@ -1,36 +1,42 @@ package buildcraft.api.transport.pipe; -import java.util.Map; -import java.util.function.Consumer; - -import javax.annotation.Nullable; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.DyeColor; +import net.minecraftforge.registries.RegistryObject; -import net.minecraft.item.Item; -import net.minecraft.util.ResourceLocation; +import java.util.Map; public interface IPipeRegistry { PipeDefinition getDefinition(ResourceLocation identifier); void registerPipe(PipeDefinition definition); - /** Maps the given {@link PipeDefinition} to an {@link IItemPipe}. This acts exactly akin to - * {@link Map#put(Object, Object)}. */ - void setItemForPipe(PipeDefinition definition, @Nullable IItemPipe item); + /** + * Maps the given {@link PipeDefinition} to an {@link IItemPipe}. This acts exactly akin to + * {@link Map#put(Object, Object)}. + */ +// void setItemForPipe(PipeDefinition definition, @Nullable IItemPipe item); + void setItemForPipe(PipeDefinition definition, Map> item); - IItemPipe getItemForPipe(PipeDefinition definition); + /** Creates a pipe item with a single colour */ + // IItemPipe getItemForPipe(PipeDefinition definition); + IItemPipe getItemForPipe(PipeDefinition definition, DyeColor colour); - /** Creates an {@link IItemPipe} for the given {@link PipeDefinition}. If the {@link PipeDefinition} has been + /** + * Creates an {@link IItemPipe} for the given {@link PipeDefinition}. If the {@link PipeDefinition} has been * registered with {@link #registerPipe(PipeDefinition)} then it will also be registered with - * {@link #setItemForPipe(PipeDefinition, IItemPipe)}. The returned item will be automatically registered with - * forge. */ - IItemPipe createItemForPipe(PipeDefinition definition); - - /** Identical to {@link #createItemForPipe(PipeDefinition)}, but doesn't require registering tags with buildcraft - * lib in order to register. - * - * @param postCreate A function to call in order to setup the {@link Item#setRegistryName(ResourceLocation)} and - * {@link Item#setUnlocalizedName(String)}. */ - IItemPipe createUnnamedItemForPipe(PipeDefinition definition, Consumer postCreate); + * {@link #setItemForPipe(PipeDefinition, Map)}. The returned item will be automatically registered with + * forge. + */ +// IItemPipe createItemForPipe(PipeDefinition definition); + Map> createItemForPipe(PipeDefinition definition); + +// /** Identical to {@link #createItemForPipe(PipeDefinition)}, but doesn't require registering tags with buildcraftcore +// * lib in order to register. +// * +// * @param postCreate A function to call in order to setup the {@link Item#setRegistryName(ResourceLocation)} and +// * {@link Item#setUnlocalizedName(String)}. */ +// IItemPipe createUnnamedItemForPipe(PipeDefinition definition, Consumer postCreate); Iterable getAllRegisteredPipes(); } diff --git a/api/buildcraft/api/transport/pipe/PipeApi.java b/api/buildcraft/api/transport/pipe/PipeApi.java index cc9997c..1eace25 100644 --- a/api/buildcraft/api/transport/pipe/PipeApi.java +++ b/api/buildcraft/api/transport/pipe/PipeApi.java @@ -1,18 +1,19 @@ package buildcraft.api.transport.pipe; -import java.util.IdentityHashMap; -import java.util.Map; - -import javax.annotation.Nonnull; - -import net.minecraftforge.common.capabilities.Capability; - -import buildcraft.api.core.CapabilitiesHelper; import buildcraft.api.mj.MjAPI; import buildcraft.api.transport.IInjectable; import buildcraft.api.transport.IStripesRegistry; import buildcraft.api.transport.pluggable.IPluggableRegistry; import buildcraft.api.transport.pluggable.PipePluggable; +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.capabilities.CapabilityManager; +import net.minecraftforge.common.capabilities.CapabilityToken; +import net.minecraftforge.common.capabilities.RegisterCapabilitiesEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; + +import javax.annotation.Nonnull; +import java.util.IdentityHashMap; +import java.util.Map; /** The central holding class for all pipe related registers and methods. */ public final class PipeApi { @@ -24,6 +25,7 @@ public final class PipeApi { public static PipeFlowType flowItems; public static PipeFlowType flowFluids; public static PipeFlowType flowPower; + public static PipeFlowType flowRf; /** The default transfer information used if a pipe definition has not been registered. Note that this is replaced * by BuildCraft Transport to config-defined values. */ @@ -33,20 +35,29 @@ public final class PipeApi { * by BuildCraft Transport to config-defined values. */ public static PowerTransferInfo powerInfoDefault = PowerTransferInfo.createFromResistance(8 * MjAPI.MJ, MjAPI.MJ / 32, false); + /** The default transfer information used if a pipe definition has not been registered. Note that this is replaced + * by BuildCraft Transport to config-defined values. */ + public static RedstoneFluxTransferInfo rfInfoDefault = new RedstoneFluxTransferInfo(80, false); + public static final Map fluidTransferData = new IdentityHashMap<>(); public static final Map powerTransferData = new IdentityHashMap<>(); + public static final Map rfTransferData = new IdentityHashMap<>(); @Nonnull - public static final Capability CAP_PIPE_HOLDER; + public static final Capability CAP_PIPE_HOLDER = CapabilityManager.get(new CapabilityToken<>() { + }); @Nonnull - public static final Capability CAP_PIPE; + public static final Capability CAP_PIPE = CapabilityManager.get(new CapabilityToken<>() { + }); @Nonnull - public static final Capability CAP_PLUG; + public static final Capability CAP_PLUG = CapabilityManager.get(new CapabilityToken<>() { + }); @Nonnull - public static final Capability CAP_INJECTABLE; + public static final Capability CAP_INJECTABLE = CapabilityManager.get(new CapabilityToken<>() { + }); public static FluidTransferInfo getFluidTransferInfo(PipeDefinition def) { FluidTransferInfo info = fluidTransferData.get(def); @@ -66,6 +77,15 @@ public static PowerTransferInfo getPowerTransferInfo(PipeDefinition def) { } } + public static RedstoneFluxTransferInfo getRfTransferInfo(PipeDefinition def) { + RedstoneFluxTransferInfo info = rfTransferData.get(def); + if (info == null) { + return rfInfoDefault; + } else { + return info; + } + } + public static class FluidTransferInfo { /** Controls the maximum amount of fluid that can be transferred around and out of a pipe per tick. Note that * this does not affect the flow rate coming into the pipe. */ @@ -93,7 +113,7 @@ public static class PowerTransferInfo { public final boolean isReceiver; /** Sets resistancePerTick to be equal to lossPerTick when full power is being transferred, scaling down to 0. - * + * * @param transferPerTick * @param lossPerTick * @param isReceiver */ @@ -102,7 +122,7 @@ public static PowerTransferInfo createFromLoss(long transferPerTick, long lossPe } /** Sets lossPerTick to be equal to resistancePerTick when full power is being transferred. - * + * * @param transferPerTick * @param resistancePerTick * @param isReceiver */ @@ -121,12 +141,23 @@ public PowerTransferInfo(long transferPerTick, long lossPerTick, long resistance } } + public static class RedstoneFluxTransferInfo { + public final int transferPerTick; + public final boolean isReceiver; + + public RedstoneFluxTransferInfo(int transferPerTick, boolean isReceiver) { + this.transferPerTick = transferPerTick; + this.isReceiver = isReceiver; + } + } + // Internals - static { - CAP_PIPE = CapabilitiesHelper.registerCapability(IPipe.class); - CAP_PLUG = CapabilitiesHelper.registerCapability(PipePluggable.class); - CAP_PIPE_HOLDER = CapabilitiesHelper.registerCapability(IPipeHolder.class); - CAP_INJECTABLE = CapabilitiesHelper.registerCapability(IInjectable.class); + @SubscribeEvent + public static void registerCapability(RegisterCapabilitiesEvent event) { + event.register(IPipe.class); + event.register(PipePluggable.class); + event.register(IPipeHolder.class); + event.register(IInjectable.class); } } diff --git a/api/buildcraft/api/transport/pipe/PipeApiClient.java b/api/buildcraft/api/transport/pipe/PipeApiClient.java index ebcd9e6..461c2da 100644 --- a/api/buildcraft/api/transport/pipe/PipeApiClient.java +++ b/api/buildcraft/api/transport/pipe/PipeApiClient.java @@ -1,14 +1,13 @@ package buildcraft.api.transport.pipe; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - import buildcraft.api.transport.pluggable.IPlugDynamicRenderer; import buildcraft.api.transport.pluggable.IPluggableStaticBaker; import buildcraft.api.transport.pluggable.PipePluggable; import buildcraft.api.transport.pluggable.PluggableModelKey; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; -@SideOnly(Side.CLIENT) +@OnlyIn(Dist.CLIENT) public enum PipeApiClient { INSTANCE; @@ -22,12 +21,10 @@ public interface IClientRegistry { /** Registers a dynamic renderer for the given pipe behaviour. Most {@link PipeBehaviour} types will have no use * for this. */ - void registerRenderer(Class behaviourClass, - IPipeBehaviourRenderer renderer); + void registerRenderer(Class behaviourClass, IPipeBehaviourRenderer renderer);

    void registerRenderer(Class plugClass, IPlugDynamicRenderer

    renderer); -

    void registerBaker(Class keyClass, - IPluggableStaticBaker

    renderer); +

    void registerBaker(Class keyClass, IPluggableStaticBaker

    renderer); } } diff --git a/api/buildcraft/api/transport/pipe/PipeBehaviour.java b/api/buildcraft/api/transport/pipe/PipeBehaviour.java index e4622bc..bba3609 100644 --- a/api/buildcraft/api/transport/pipe/PipeBehaviour.java +++ b/api/buildcraft/api/transport/pipe/PipeBehaviour.java @@ -1,25 +1,24 @@ package buildcraft.api.transport.pipe; -import java.io.IOException; - -import javax.annotation.Nonnull; - -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.PacketBuffer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.NonNullList; -import net.minecraft.util.math.RayTraceResult; - +import buildcraft.api.core.EnumPipePart; +import net.minecraft.core.Direction; +import net.minecraft.core.NonNullList; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.phys.HitResult; +import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.ICapabilityProvider; -import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; -import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.common.util.LazyOptional; +import net.minecraftforge.network.NetworkDirection; +import net.minecraftforge.network.NetworkEvent; -import buildcraft.api.core.EnumPipePart; +import javax.annotation.Nonnull; +import java.io.IOException; public abstract class PipeBehaviour implements ICapabilityProvider { public final IPipe pipe; @@ -28,63 +27,70 @@ public PipeBehaviour(IPipe pipe) { this.pipe = pipe; } - public PipeBehaviour(IPipe pipe, NBTTagCompound nbt) { + public PipeBehaviour(IPipe pipe, CompoundTag nbt) { this.pipe = pipe; } - public NBTTagCompound writeToNbt() { - NBTTagCompound nbt = new NBTTagCompound(); + public CompoundTag writeToNbt() { + CompoundTag nbt = new CompoundTag(); return nbt; } - public void writePayload(PacketBuffer buffer, Side side) {} + public void writePayload(FriendlyByteBuf buffer, Dist side) { + } - public void readPayload(PacketBuffer buffer, Side side, MessageContext ctx) throws IOException {} + // public void readPayload(FriendlyByteBuf buffer, Dist side, MessageContext ctx) throws IOException {} + public void readPayload(FriendlyByteBuf buffer, NetworkDirection side, NetworkEvent.Context ctx) throws IOException { + } - /** @deprecated Replaced by {@link #getTextureData(EnumFacing)}. */ + /** @deprecated Replaced by {@link #getTextureData(Direction)}. */ @Deprecated - public int getTextureIndex(EnumFacing face) { + public int getTextureIndex(Direction face) { return 0; } - public PipeFaceTex getTextureData(EnumFacing face) { + public PipeFaceTex getTextureData(Direction face) { return PipeFaceTex.get(getTextureIndex(face)); } // Event handling - public boolean canConnect(EnumFacing face, PipeBehaviour other) { + public boolean canConnect(Direction face, PipeBehaviour other) { return true; } - public boolean canConnect(EnumFacing face, TileEntity oTile) { + public boolean canConnect(Direction face, BlockEntity oTile) { return true; } /** Used to force a connection to a given tile, even if the {@link PipeFlow} wouldn't normally connect to it. */ - public boolean shouldForceConnection(EnumFacing face, TileEntity oTile) { + public boolean shouldForceConnection(Direction face, BlockEntity oTile) { return false; } - public boolean onPipeActivate(EntityPlayer player, RayTraceResult trace, float hitX, float hitY, float hitZ, - EnumPipePart part) { + public boolean onPipeActivate(Player player, HitResult trace, float hitX, float hitY, float hitZ, EnumPipePart part) { return false; } - public void onEntityCollide(Entity entity) {} - - public void onTick() {} + public void onEntityCollide(Entity entity) { + } - @Override - public boolean hasCapability(@Nonnull Capability capability, EnumFacing facing) { - return getCapability(capability, facing) != null; + public void onTick() { } + // 1.18.2: getCapability().isPresent() +// @Override +// public boolean hasCapability(@Nonnull Capability capability, EnumFacing facing) { +// return getCapability(capability, facing) != null; +// } + + @Nonnull @Override - public T getCapability(@Nonnull Capability capability, EnumFacing facing) { - return null; + public LazyOptional getCapability(@Nonnull Capability capability, Direction facing) { + return LazyOptional.empty(); } - public void addDrops(NonNullList toDrop, int fortune) {} + public void addDrops(NonNullList toDrop, int fortune) { + } } diff --git a/api/buildcraft/api/transport/pipe/PipeConnectionAPI.java b/api/buildcraft/api/transport/pipe/PipeConnectionAPI.java index 9872034..b038090 100644 --- a/api/buildcraft/api/transport/pipe/PipeConnectionAPI.java +++ b/api/buildcraft/api/transport/pipe/PipeConnectionAPI.java @@ -1,10 +1,9 @@ package buildcraft.api.transport.pipe; -import java.util.Map; - import com.google.common.collect.Maps; +import net.minecraft.world.level.block.Block; -import net.minecraft.block.Block; +import java.util.Map; /** Use this class to register blocks with custom block sizes so that pipes can connect to them properly. Note that you * do not need to register a custom pipe connection if your block implements ICustomPipeConnection. The registered @@ -15,7 +14,7 @@ public final class PipeConnectionAPI { /** Register a block with a custom connection. Useful if you don't own the block class or are adding it for some-one * else. - * + * * @param block The block instance * @param connection The connection instance */ public static void registerConnection(Block block, ICustomPipeConnection connection) { diff --git a/api/buildcraft/api/transport/pipe/PipeDefinition.java b/api/buildcraft/api/transport/pipe/PipeDefinition.java index cfd3e68..f991d1e 100644 --- a/api/buildcraft/api/transport/pipe/PipeDefinition.java +++ b/api/buildcraft/api/transport/pipe/PipeDefinition.java @@ -1,15 +1,17 @@ package buildcraft.api.transport.pipe; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.Rarity; +import net.minecraftforge.fml.ModContainer; +import net.minecraftforge.fml.ModLoadingContext; + import javax.annotation.Nonnull; import javax.annotation.Nullable; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ResourceLocation; - -import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.fml.common.ModContainer; - public final class PipeDefinition { + public final Item.Properties properties; public final ResourceLocation identifier; public final IPipeCreator logicConstructor; public final IPipeLoader logicLoader; @@ -23,6 +25,7 @@ public final class PipeDefinition { private EnumPipeColourType colourType; public PipeDefinition(PipeDefinitionBuilder builder) { + this.properties = builder.properties; this.identifier = builder.identifier; this.textures = new String[builder.textureSuffixes.length]; for (int i = 0; i < textures.length; i++) { @@ -63,10 +66,14 @@ public interface IPipeCreator { @FunctionalInterface public interface IPipeLoader { - PipeBehaviour loadBehaviour(IPipe t, NBTTagCompound u); + PipeBehaviour loadBehaviour(IPipe t, CompoundTag u); } public static class PipeDefinitionBuilder { + public Item.Properties properties = new Item.Properties() + .rarity(Rarity.COMMON) + .durability(0) + .stacksTo(64); public ResourceLocation identifier; public String texturePrefix; public String[] textureSuffixes = { "" }; @@ -81,10 +88,11 @@ public static class PipeDefinitionBuilder { public boolean canBeColoured; public EnumPipeColourType colourType; - public PipeDefinitionBuilder() {} + public PipeDefinitionBuilder() { + } public PipeDefinitionBuilder(ResourceLocation identifier, IPipeCreator logicConstructor, - IPipeLoader logicLoader, PipeFlowType flowType) { + IPipeLoader logicLoader, PipeFlowType flowType) { this.identifier = identifier; this.logicConstructor = logicConstructor; this.logicLoader = logicLoader; @@ -100,10 +108,10 @@ public PipeDefinitionBuilder idTex(String both) { } private static String getActiveModId() { - ModContainer mod = Loader.instance().activeModContainer(); + ModContainer mod = ModLoadingContext.get().getActiveContainer(); if (mod == null) { throw new IllegalStateException( - "Cannot interact with PipeDefinition outside of an actively scoped mod!"); + "Cannot interact with PipeDefinition outside of an actively scoped mod!"); } return mod.getModId(); } @@ -119,7 +127,7 @@ public PipeDefinitionBuilder tex(String prefix, String... suffixes) { /** Sets the texture prefix to be: [current_mod_id]:pipes/[prefix] where [current_mod_id] is the * modid of the currently loaded mod, and [prefix] is the string parameter given. - * + * * @return this */ public PipeDefinitionBuilder texPrefix(String prefix) { return texPrefixDirect(getActiveModId() + ":pipes/" + prefix); @@ -127,7 +135,7 @@ public PipeDefinitionBuilder texPrefix(String prefix) { /** Sets the {@link #texturePrefix} to the input string, without any additions or changes (unlike * {@link #texPrefix(String)}) - * + * * @return this */ public PipeDefinitionBuilder texPrefixDirect(String prefix) { texturePrefix = prefix; @@ -136,7 +144,7 @@ public PipeDefinitionBuilder texPrefixDirect(String prefix) { /** Sets {@link #textureSuffixes} to the given array, or to {""} if the argument list is empty or * null. - * + * * @return this. */ public PipeDefinitionBuilder texSuffixes(String... suffixes) { if (suffixes == null || suffixes.length == 0) { diff --git a/api/buildcraft/api/transport/pipe/PipeEventConnectionChange.java b/api/buildcraft/api/transport/pipe/PipeEventConnectionChange.java index fe529dd..01487ed 100644 --- a/api/buildcraft/api/transport/pipe/PipeEventConnectionChange.java +++ b/api/buildcraft/api/transport/pipe/PipeEventConnectionChange.java @@ -1,14 +1,14 @@ package buildcraft.api.transport.pipe; -import net.minecraft.util.EnumFacing; +import net.minecraft.core.Direction; /** Fired whenever a connection change is picked up by an {@link IPipe}. This even doesn't include the new value - * (boolean isConnected) as it can be accessed via {@link IPipe#isConnected(EnumFacing)}. */ + * (boolean isConnected) as it can be accessed via {@link IPipe#isConnected(Direction)}. */ public class PipeEventConnectionChange extends PipeEvent { - public final EnumFacing direction; + public final Direction direction; - public PipeEventConnectionChange(IPipeHolder holder, EnumFacing direction) { + public PipeEventConnectionChange(IPipeHolder holder, Direction direction) { super(holder); this.direction = direction; } diff --git a/api/buildcraft/api/transport/pipe/PipeEventFluid.java b/api/buildcraft/api/transport/pipe/PipeEventFluid.java index e057122..cf3c4e9 100644 --- a/api/buildcraft/api/transport/pipe/PipeEventFluid.java +++ b/api/buildcraft/api/transport/pipe/PipeEventFluid.java @@ -1,15 +1,13 @@ package buildcraft.api.transport.pipe; +import net.minecraft.core.Direction; +import net.minecraftforge.fluids.FluidStack; + +import javax.annotation.Nonnull; import java.util.Arrays; import java.util.Collection; import java.util.EnumSet; -import javax.annotation.Nonnull; - -import net.minecraft.util.EnumFacing; - -import net.minecraftforge.fluids.FluidStack; - public abstract class PipeEventFluid extends PipeEvent { public final IFlowFluid flow; @@ -27,12 +25,12 @@ protected PipeEventFluid(boolean canBeCancelled, IPipeHolder holder, IFlowFluid } public static class TryInsert extends PipeEventFluid { - public final EnumFacing from; + public final Direction from; /** The incoming fluidstack. Currently changing this does nothing. */ @Nonnull public final FluidStack fluid; - public TryInsert(IPipeHolder holder, IFlowFluid flow, EnumFacing from, @Nonnull FluidStack fluid) { + public TryInsert(IPipeHolder holder, IFlowFluid flow, Direction from, @Nonnull FluidStack fluid) { super(true, holder, flow); this.from = from; this.fluid = fluid; @@ -48,19 +46,19 @@ public static class PreMoveToCentre extends PipeEventFluid { /** The maximum amount of fluid that the centre pipe could accept. */ public final int totalAcceptable; - /** Array of {@link EnumFacing#getIndex()} to the maximum amount of fluid that a given side can offer. DO NOT + /** Array of {@link Direction#get3DDataValue()} to the maximum amount of fluid that a given side can offer. DO NOT * CHANGE THIS! */ public final int[] totalOffered; // Used for checking the state private final int[] totalOfferedCheck; - /** Array of {@link EnumFacing#getIndex()} to the amount of fluid that the given side will actually offer to the + /** Array of {@link Direction#get3DDataValue()} to the amount of fluid that the given side will actually offer to the * centre. This should *never* be larger than */ public final int[] actuallyOffered; public PreMoveToCentre(IPipeHolder holder, IFlowFluid flow, FluidStack fluid, int totalAcceptable, - int[] totalOffered, int[] actuallyOffered) { + int[] totalOffered, int[] actuallyOffered) { super(holder, flow); this.fluid = fluid; this.totalAcceptable = totalAcceptable; @@ -77,7 +75,7 @@ public String checkStateForErrors() { } if (actuallyOffered[i] > totalOffered[i]) { return "actuallyOffered[" + i + "](=" + actuallyOffered[i] - + ") shouldn't be greater than totalOffered[" + i + "](=" + totalOffered[i] + ")"; + + ") shouldn't be greater than totalOffered[" + i + "](=" + totalOffered[i] + ")"; } } return super.checkStateForErrors(); @@ -97,7 +95,7 @@ public static class OnMoveToCentre extends PipeEventFluid { private final int[] fluidLeaveCheck, fluidEnterCheck; public OnMoveToCentre(IPipeHolder holder, IFlowFluid flow, FluidStack fluid, int[] fluidLeavingSide, - int[] fluidEnteringCentre) { + int[] fluidEnteringCentre) { super(holder, flow); this.fluid = fluid; this.fluidLeavingSide = fluidLeavingSide; @@ -111,15 +109,15 @@ public String checkStateForErrors() { for (int i = 0; i < fluidLeavingSide.length; i++) { if (fluidLeavingSide[i] > fluidLeaveCheck[i]) { return "fluidLeavingSide[" + i + "](=" + fluidLeavingSide[i] - + ") shouldn't be bigger than its original value!(=" + fluidLeaveCheck[i] + ")"; + + ") shouldn't be bigger than its original value!(=" + fluidLeaveCheck[i] + ")"; } if (fluidEnteringCentre[i] > fluidEnterCheck[i]) { return "fluidEnteringCentre[" + i + "](=" + fluidEnteringCentre[i] - + ") shouldn't be bigger than its original value!(=" + fluidEnterCheck[i] + ")"; + + ") shouldn't be bigger than its original value!(=" + fluidEnterCheck[i] + ")"; } if (fluidEnteringCentre[i] > fluidLeavingSide[i]) { return "fluidEnteringCentre[" + i + "](=" + fluidEnteringCentre[i] - + ") shouldn't be bigger than fluidLeavingSide[" + i + "](=" + fluidLeavingSide[i] + ")"; + + ") shouldn't be bigger than fluidLeavingSide[" + i + "](=" + fluidLeavingSide[i] + ")"; } } return super.checkStateForErrors(); @@ -132,7 +130,7 @@ public static class SideCheck extends PipeEventFluid { /** The priorities of each side. Stored inversely to the values given, so a higher priority will have a lower * value than a lower priority. */ private final int[] priority = new int[6]; - private final EnumSet allowed = EnumSet.allOf(EnumFacing.class); + private final EnumSet allowed = EnumSet.allOf(Direction.class); public SideCheck(IPipeHolder holder, IFlowFluid flow, FluidStack fluid) { super(holder, flow); @@ -142,23 +140,23 @@ public SideCheck(IPipeHolder holder, IFlowFluid flow, FluidStack fluid) { /** Checks to see if a side if allowed. Note that this may return true even though a later handler might * disallow a side, so you should only use this to skip checking a side (for example a diamond pipe might not * check the filters for a specific side if its already been disallowed) */ - public boolean isAllowed(EnumFacing side) { + public boolean isAllowed(Direction side) { return allowed.contains(side); } /** Disallows the specific side(s) from being a destination for the item. If no sides are allowed, then the * fluid will stay in the current pipe section. */ - public void disallow(EnumFacing... sides) { - for (EnumFacing side : sides) { + public void disallow(Direction... sides) { + for (Direction side : sides) { allowed.remove(side); } } - public void disallowAll(Collection sides) { + public void disallowAll(Collection sides) { allowed.removeAll(sides); } - public void disallowAllExcept(EnumFacing side) { + public void disallowAllExcept(Direction side) { if (allowed.contains(side)) { allowed.clear(); allowed.add(side); @@ -167,7 +165,7 @@ public void disallowAllExcept(EnumFacing side) { } } - public void disallowAllExcept(EnumFacing... sides) { + public void disallowAllExcept(Direction... sides) { switch (sides.length) { case 0: { allowed.clear(); @@ -190,8 +188,8 @@ public void disallowAllExcept(EnumFacing... sides) { return; } default: { - EnumSet except = EnumSet.noneOf(EnumFacing.class); - for (EnumFacing face : sides) { + EnumSet except = EnumSet.noneOf(Direction.class); + for (Direction face : sides) { except.add(face); } this.allowed.retainAll(except); @@ -200,7 +198,7 @@ public void disallowAllExcept(EnumFacing... sides) { } } - public void disallowAllExcept(Collection sides) { + public void disallowAllExcept(Collection sides) { allowed.retainAll(sides); } @@ -208,30 +206,31 @@ public void disallowAll() { allowed.clear(); } - public void increasePriority(EnumFacing side) { + public void increasePriority(Direction side) { increasePriority(side, 1); } - public void increasePriority(EnumFacing side, int by) { + public void increasePriority(Direction side, int by) { priority[side.ordinal()] -= by; } - public void decreasePriority(EnumFacing side) { + public void decreasePriority(Direction side) { decreasePriority(side, 1); } - public void decreasePriority(EnumFacing side, int by) { + public void decreasePriority(Direction side, int by) { increasePriority(side, -by); } - public EnumSet getOrder() { + public EnumSet getOrder() { if (allowed.isEmpty()) { - return EnumSet.noneOf(EnumFacing.class); + return EnumSet.noneOf(Direction.class); } if (allowed.size() == 1) { return allowed; } - priority_search: { + priority_search: + { int val = priority[0]; for (int i = 1; i < priority.length; i++) { if (priority[i] != val) { @@ -251,8 +250,8 @@ public EnumSet getOrder() { continue; } last = current; - EnumSet set = EnumSet.noneOf(EnumFacing.class); - for (EnumFacing face : EnumFacing.VALUES) { + EnumSet set = EnumSet.noneOf(Direction.class); + for (Direction face : Direction.VALUES) { if (allowed.contains(face)) { if (priority[face.ordinal()] == current) { set.add(face); @@ -263,7 +262,7 @@ public EnumSet getOrder() { return set; } } - return EnumSet.noneOf(EnumFacing.class); + return EnumSet.noneOf(Direction.class); } } } diff --git a/api/buildcraft/api/transport/pipe/PipeEventHandler.java b/api/buildcraft/api/transport/pipe/PipeEventHandler.java index 15eaeca..44d9424 100644 --- a/api/buildcraft/api/transport/pipe/PipeEventHandler.java +++ b/api/buildcraft/api/transport/pipe/PipeEventHandler.java @@ -9,11 +9,11 @@ * extends {@link PipeEvent}.
    * An example is:
    * - @PipeEventHandler
    - public void sideCheck(PipeEventItem.SideCheck sideCheck) {
    - // Logic omitted
    - } - * + @PipeEventHandler
    + public void sideCheck(PipeEventItem.SideCheck sideCheck) {
    + // Logic omitted
    + } + * *
    */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) diff --git a/api/buildcraft/api/transport/pipe/PipeEventItem.java b/api/buildcraft/api/transport/pipe/PipeEventItem.java index e049029..3940ca8 100644 --- a/api/buildcraft/api/transport/pipe/PipeEventItem.java +++ b/api/buildcraft/api/transport/pipe/PipeEventItem.java @@ -1,23 +1,16 @@ package buildcraft.api.transport.pipe; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.EnumSet; -import java.util.List; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; +import net.minecraft.core.Direction; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.item.DyeColor; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.item.EnumDyeColor; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import java.util.*; public abstract class PipeEventItem extends PipeEvent { @@ -44,8 +37,8 @@ protected PipeEventItem(boolean canBeCancelled, IPipeHolder holder, IFlowItems f /** Fires whenever item insertion is attempted. The item might have been extracted by the pipe behaviour, inserted * by another pipe or even a different kind of tile. Note that you have no way of telling what caused this event. */ public static class TryInsert extends PipeEventItem { - public final EnumDyeColor colour; - public final EnumFacing from; + public final DyeColor colour; + public final Direction from; /** The itemstack that is attempting to be inserted. NEVER CHANGE THIS! */ @Nonnull public final ItemStack attempting; @@ -53,8 +46,8 @@ public static class TryInsert extends PipeEventItem { * {@link #attempting} */ public int accepted; - public TryInsert(IPipeHolder holder, IFlowItems flow, EnumDyeColor colour, EnumFacing from, - @Nonnull ItemStack attempting) { + public TryInsert(IPipeHolder holder, IFlowItems flow, DyeColor colour, Direction from, + @Nonnull ItemStack attempting) { super(true, holder, flow); this.colour = colour; this.from = from; @@ -70,11 +63,11 @@ public void cancel() { } public static abstract class ReachDest extends PipeEventItem { - public EnumDyeColor colour; + public DyeColor colour; @Nonnull private ItemStack stack; - public ReachDest(IPipeHolder holder, IFlowItems flow, EnumDyeColor colour, @Nonnull ItemStack stack) { + public ReachDest(IPipeHolder holder, IFlowItems flow, DyeColor colour, @Nonnull ItemStack stack) { super(holder, flow); this.colour = colour; this.stack = stack; @@ -96,10 +89,10 @@ public void setStack(ItemStack stack) { /** Fired after {@link TryInsert} (if some items were allowed in) to modify the incoming itemstack or its colour. */ public static class OnInsert extends ReachDest { - public final EnumFacing from; + public final Direction from; - public OnInsert(IPipeHolder holder, IFlowItems flow, EnumDyeColor colour, @Nonnull ItemStack stack, - EnumFacing from) { + public OnInsert(IPipeHolder holder, IFlowItems flow, DyeColor colour, @Nonnull ItemStack stack, + Direction from) { super(holder, flow, colour, stack); this.from = from; } @@ -107,10 +100,10 @@ public OnInsert(IPipeHolder holder, IFlowItems flow, EnumDyeColor colour, @Nonnu /** Fired whenever an item reaches the centre of a pipe. Note that you *can* change the itemstack or the colour. */ public static class ReachCenter extends ReachDest { - public final EnumFacing from; + public final Direction from; - public ReachCenter(IPipeHolder holder, IFlowItems flow, EnumDyeColor colour, @Nonnull ItemStack stack, - EnumFacing from) { + public ReachCenter(IPipeHolder holder, IFlowItems flow, DyeColor colour, @Nonnull ItemStack stack, + Direction from) { super(holder, flow, colour, stack); this.from = from; } @@ -118,10 +111,10 @@ public ReachCenter(IPipeHolder holder, IFlowItems flow, EnumDyeColor colour, @No /** Fired whenever an item reaches the end of a pipe. Note that you *can* change the itemstack or the colour. */ public static class ReachEnd extends ReachDest { - public final EnumFacing to; + public final Direction to; - public ReachEnd(IPipeHolder holder, IFlowItems flow, EnumDyeColor colour, @Nonnull ItemStack stack, - EnumFacing to) { + public ReachEnd(IPipeHolder holder, IFlowItems flow, DyeColor colour, @Nonnull ItemStack stack, + Direction to) { super(holder, flow, colour, stack); this.to = to; } @@ -139,9 +132,9 @@ public static abstract class Ejected extends PipeEventItem { private ItemStack excess; /** The side that the item has been ejected to. */ - public final EnumFacing to; + public final Direction to; - protected Ejected(IPipeHolder holder, IFlowItems flow, ItemStack inserted, ItemStack excess, EnumFacing to) { + protected Ejected(IPipeHolder holder, IFlowItems flow, ItemStack inserted, ItemStack excess, Direction to) { super(holder, flow); this.inserted = inserted; this.excess = excess; @@ -165,8 +158,8 @@ public void setExcess(ItemStack stack) { public static class IntoPipe extends Ejected { public final IFlowItems otherPipe; - public IntoPipe(IPipeHolder holder, IFlowItems flow, ItemStack inserted, ItemStack excess, EnumFacing to, - IFlowItems otherPipe) { + public IntoPipe(IPipeHolder holder, IFlowItems flow, ItemStack inserted, ItemStack excess, Direction to, + IFlowItems otherPipe) { super(holder, flow, inserted, excess, to); this.otherPipe = otherPipe; } @@ -174,10 +167,10 @@ public IntoPipe(IPipeHolder holder, IFlowItems flow, ItemStack inserted, ItemSta /** Fired when an item is injected into a tile entity. (Refer to {@link Ejected} for more details) */ public static class IntoTile extends Ejected { - public final TileEntity tile; + public final BlockEntity tile; - public IntoTile(IPipeHolder holder, IFlowItems flow, ItemStack inserted, ItemStack excess, EnumFacing to, - TileEntity tile) { + public IntoTile(IPipeHolder holder, IFlowItems flow, ItemStack inserted, ItemStack excess, Direction to, + BlockEntity tile) { super(holder, flow, inserted, excess, to); this.tile = tile; } @@ -193,18 +186,18 @@ public IntoTile(IPipeHolder holder, IFlowItems flow, ItemStack inserted, ItemSta /** Fired after {@link ReachCenter} to determine what sides are the items NOT allowed to go to, and the order of * priority for the allowed sides. */ public static class SideCheck extends PipeEventItem { - public final EnumDyeColor colour; - public final EnumFacing from; + public final DyeColor colour; + public final Direction from; @Nonnull public final ItemStack stack; /** The priorities of each side. Stored inversely to the values given, so a higher priority will have a lower * value than a lower priority. */ private final int[] priority = new int[6]; - private final EnumSet allowed = EnumSet.allOf(EnumFacing.class); + private final EnumSet allowed = EnumSet.allOf(Direction.class); - public SideCheck(IPipeHolder holder, IFlowItems flow, EnumDyeColor colour, EnumFacing from, - @Nonnull ItemStack stack) { + public SideCheck(IPipeHolder holder, IFlowItems flow, DyeColor colour, Direction from, + @Nonnull ItemStack stack) { super(holder, flow); this.colour = colour; this.from = from; @@ -214,23 +207,23 @@ public SideCheck(IPipeHolder holder, IFlowItems flow, EnumDyeColor colour, EnumF /** Checks to see if a side if allowed. Note that this may return true even though a later handler might * disallow a side, so you should only use this to skip checking a side (for example a diamond pipe might not * check the filters for a specific side if its already been disallowed) */ - public boolean isAllowed(EnumFacing side) { + public boolean isAllowed(Direction side) { return allowed.contains(side); } /** Disallows the specific side(s) from being a destination for the item. If no sides are allowed, then * {@link TryBounce} will be fired to test if the item can bounce back. */ - public void disallow(EnumFacing... sides) { - for (EnumFacing side : sides) { + public void disallow(Direction... sides) { + for (Direction side : sides) { allowed.remove(side); } } - public void disallowAll(Collection sides) { + public void disallowAll(Collection sides) { allowed.removeAll(sides); } - public void disallowAllExcept(EnumFacing... sides) { + public void disallowAllExcept(Direction... sides) { allowed.retainAll(Lists.newArrayList(sides)); } @@ -238,23 +231,23 @@ public void disallowAll() { allowed.clear(); } - public void increasePriority(EnumFacing side) { + public void increasePriority(Direction side) { increasePriority(side, 1); } - public void increasePriority(EnumFacing side, int by) { + public void increasePriority(Direction side, int by) { priority[side.ordinal()] -= by; } - public void decreasePriority(EnumFacing side) { + public void decreasePriority(Direction side) { decreasePriority(side, 1); } - public void decreasePriority(EnumFacing side, int by) { + public void decreasePriority(Direction side, int by) { increasePriority(side, -by); } - public List> getOrder() { + public List> getOrder() { // Skip the calculations if the size is simple switch (allowed.size()) { case 0: @@ -263,7 +256,8 @@ public List> getOrder() { return ImmutableList.of(allowed); default: } - priority_search: { + priority_search: + { int val = priority[0]; for (int i = 1; i < priority.length; i++) { if (priority[i] != val) { @@ -277,15 +271,15 @@ public List> getOrder() { int[] ordered = Arrays.copyOf(priority, 6); Arrays.sort(ordered); int last = 0; - List> list = Lists.newArrayList(); + List> list = Lists.newArrayList(); for (int i = 0; i < 6; i++) { int current = ordered[i]; if (i != 0 && current == last) { continue; } last = current; - EnumSet set = EnumSet.noneOf(EnumFacing.class); - for (EnumFacing face : EnumFacing.VALUES) { + EnumSet set = EnumSet.noneOf(Direction.class); + for (Direction face : Direction.VALUES) { if (allowed.contains(face)) { if (priority[face.ordinal()] == current) { set.add(face); @@ -303,14 +297,14 @@ public List> getOrder() { /** Fired after {@link SideCheck} (if all sides were disallowed) to see if the item is allowed to bounce back to * where it was inserted. */ public static class TryBounce extends PipeEventItem { - public final EnumDyeColor colour; - public final EnumFacing from; + public final DyeColor colour; + public final Direction from; @Nonnull public final ItemStack stack; public boolean canBounce = false; - public TryBounce(IPipeHolder holder, IFlowItems flow, EnumDyeColor colour, EnumFacing from, - @Nonnull ItemStack stack) { + public TryBounce(IPipeHolder holder, IFlowItems flow, DyeColor colour, Direction from, + @Nonnull ItemStack stack) { super(holder, flow); this.colour = colour; this.from = from; @@ -319,9 +313,9 @@ public TryBounce(IPipeHolder holder, IFlowItems flow, EnumDyeColor colour, EnumF } public static class Drop extends PipeEventItem { - private final EntityItem entity; + private final ItemEntity entity; - public Drop(IPipeHolder holder, IFlowItems flow, EntityItem entity) { + public Drop(IPipeHolder holder, IFlowItems flow, ItemEntity entity) { super(holder, flow); this.entity = entity; } @@ -342,32 +336,32 @@ public void setStack(ItemStack stack) { } } - public EntityItem getEntity() { + public ItemEntity getEntity() { return this.entity; } } /** Base class for {@link Split} and {@link FindDest}. Do not listen to this directly! */ public static abstract class OrderedEvent extends PipeEventItem { - public final List> orderedDestinations; + public final List> orderedDestinations; - public OrderedEvent(IPipeHolder holder, IFlowItems flow, List> orderedDestinations) { + public OrderedEvent(IPipeHolder holder, IFlowItems flow, List> orderedDestinations) { super(holder, flow); this.orderedDestinations = orderedDestinations; } - public EnumSet getAllPossibleDestinations() { - EnumSet set = EnumSet.noneOf(EnumFacing.class); - for (EnumSet e : orderedDestinations) { + public EnumSet getAllPossibleDestinations() { + EnumSet set = EnumSet.noneOf(Direction.class); + for (EnumSet e : orderedDestinations) { set.addAll(e); } return set; } - public ImmutableList generateRandomOrder() { - ImmutableList.Builder builder = ImmutableList.builder(); - for (EnumSet set : orderedDestinations) { - List faces = new ArrayList<>(set); + public ImmutableList generateRandomOrder() { + ImmutableList.Builder builder = ImmutableList.builder(); + for (EnumSet set : orderedDestinations) { + List faces = new ArrayList<>(set); Collections.shuffle(faces); builder.addAll(faces); } @@ -382,7 +376,7 @@ public ImmutableList generateRandomOrder() { public static class Split extends OrderedEvent { public final List items = new ArrayList<>(); - public Split(IPipeHolder holder, IFlowItems flow, List> order, ItemEntry toSplit) { + public Split(IPipeHolder holder, IFlowItems flow, List> order, ItemEntry toSplit) { super(holder, flow, order); items.add(toSplit); } @@ -394,8 +388,8 @@ public Split(IPipeHolder holder, IFlowItems flow, List> orde public static class FindDest extends OrderedEvent { public final ImmutableList items; - public FindDest(IPipeHolder holder, IFlowItems flow, List> orderedDestinations, - ImmutableList items) { + public FindDest(IPipeHolder holder, IFlowItems flow, List> orderedDestinations, + ImmutableList items) { super(holder, flow, orderedDestinations); this.items = items; } @@ -422,15 +416,15 @@ public void modifyTo(double target, double maxDelta) { /** Mostly immutable holding class for item stacks. */ public static class ItemEntry { - public final EnumDyeColor colour; + public final DyeColor colour; @Nonnull public final ItemStack stack; - public final EnumFacing from; + public final Direction from; /** The list of the destinations to try, in order. */ @Nullable - public List to; + public List to; - public ItemEntry(EnumDyeColor colour, @Nonnull ItemStack stack, EnumFacing from) { + public ItemEntry(DyeColor colour, @Nonnull ItemStack stack, Direction from) { this.colour = colour; this.stack = stack; this.from = from; diff --git a/api/buildcraft/api/transport/pipe/PipeEventPower.java b/api/buildcraft/api/transport/pipe/PipeEventPower.java index 4e356eb..4c23d2a 100644 --- a/api/buildcraft/api/transport/pipe/PipeEventPower.java +++ b/api/buildcraft/api/transport/pipe/PipeEventPower.java @@ -1,8 +1,7 @@ package buildcraft.api.transport.pipe; -import net.minecraft.util.EnumFacing; - import buildcraft.api.mj.MjAPI; +import net.minecraft.core.Direction; public abstract class PipeEventPower extends PipeEvent { public final IFlowPower flow; @@ -26,6 +25,7 @@ public static class Configure extends PipeEventPower { * or by {@link #powerResistance} if it is set. This is capped at the value given in {@link #getMaxPower()} */ private long powerLoss = -1; private boolean receiver = false; + private boolean disabled = false; public Configure(IPipeHolder holder, IFlowPower flow) { super(holder, flow); @@ -71,21 +71,29 @@ public boolean isReceiver() { public void setReceiver(boolean receiver) { this.receiver = receiver; } + + public void disableTransfer() { + disabled = true; + } + + public boolean isTransferDisabled() { + return disabled; + } } public static class PrimaryDirection extends PipeEventPower { - private EnumFacing facing; + private Direction facing; - public PrimaryDirection(IPipeHolder holder, IFlowPower flow, EnumFacing facing) { + public PrimaryDirection(IPipeHolder holder, IFlowPower flow, Direction facing) { super(holder, flow); this.facing = facing; } - public EnumFacing getFacing() { + public Direction getFacing() { return facing; } - public void setFacing(EnumFacing facing) { + public void setFacing(Direction facing) { this.facing = facing; } } diff --git a/api/buildcraft/api/transport/pipe/PipeEventRedstoneFlux.java b/api/buildcraft/api/transport/pipe/PipeEventRedstoneFlux.java new file mode 100644 index 0000000..bf66008 --- /dev/null +++ b/api/buildcraft/api/transport/pipe/PipeEventRedstoneFlux.java @@ -0,0 +1,69 @@ +package buildcraft.api.transport.pipe; + +import net.minecraft.core.Direction; + +public abstract class PipeEventRedstoneFlux extends PipeEvent { + public final IFlowRedstoneFlux flow; + + protected PipeEventRedstoneFlux(IPipeHolder holder, IFlowRedstoneFlux flow) { + super(holder); + this.flow = flow; + } + + protected PipeEventRedstoneFlux(boolean canBeCancelled, IPipeHolder holder, IFlowRedstoneFlux flow) { + super(canBeCancelled, holder); + this.flow = flow; + } + + public static class Configure extends PipeEventRedstoneFlux { + private int maxPower = 100; + private boolean receiver = false; + private boolean disabled = false; + + public Configure(IPipeHolder holder, IFlowRedstoneFlux flow) { + super(holder, flow); + } + + public int getMaxPower() { + return this.maxPower; + } + + public void setMaxPower(int maxPower) { + this.maxPower = maxPower; + } + + public boolean isReceiver() { + return this.receiver; + } + + /** Sets this pipe to be one that receives power from external sources. */ + public void setReceiver(boolean receiver) { + this.receiver = receiver; + } + + public void disableTransfer() { + disabled = true; + } + + public boolean isTransferDisabled() { + return disabled; + } + } + + public static class PrimaryDirection extends PipeEventRedstoneFlux { + private Direction facing; + + public PrimaryDirection(IPipeHolder holder, IFlowRedstoneFlux flow, Direction facing) { + super(holder, flow); + this.facing = facing; + } + + public Direction getFacing() { + return facing; + } + + public void setFacing(Direction facing) { + this.facing = facing; + } + } +} diff --git a/api/buildcraft/api/transport/pipe/PipeEventStatement.java b/api/buildcraft/api/transport/pipe/PipeEventStatement.java index 5d96caf..7a236f0 100644 --- a/api/buildcraft/api/transport/pipe/PipeEventStatement.java +++ b/api/buildcraft/api/transport/pipe/PipeEventStatement.java @@ -1,15 +1,13 @@ package buildcraft.api.transport.pipe; -import java.util.Collection; - -import javax.annotation.Nonnull; - -import net.minecraft.util.EnumFacing; - import buildcraft.api.statements.IActionInternal; import buildcraft.api.statements.IActionInternalSided; import buildcraft.api.statements.ITriggerInternal; import buildcraft.api.statements.ITriggerInternalSided; +import net.minecraft.core.Direction; + +import javax.annotation.Nonnull; +import java.util.Collection; public abstract class PipeEventStatement extends PipeEvent { public PipeEventStatement(IPipeHolder holder) { @@ -31,9 +29,9 @@ public static class AddTriggerInternalSided extends PipeEventStatement { public final Collection triggers; @Nonnull - public final EnumFacing side; + public final Direction side; - public AddTriggerInternalSided(IPipeHolder holder, Collection triggers, @Nonnull EnumFacing side) { + public AddTriggerInternalSided(IPipeHolder holder, Collection triggers, @Nonnull Direction side) { super(holder); this.triggers = triggers; this.side = side; @@ -55,9 +53,9 @@ public static class AddActionInternalSided extends PipeEventStatement { public final Collection actions; @Nonnull - public final EnumFacing side; + public final Direction side; - public AddActionInternalSided(IPipeHolder holder, Collection actions, @Nonnull EnumFacing side) { + public AddActionInternalSided(IPipeHolder holder, Collection actions, @Nonnull Direction side) { super(holder); this.actions = actions; this.side = side; diff --git a/api/buildcraft/api/transport/pipe/PipeEventTileState.java b/api/buildcraft/api/transport/pipe/PipeEventTileState.java index 1847561..885c941 100644 --- a/api/buildcraft/api/transport/pipe/PipeEventTileState.java +++ b/api/buildcraft/api/transport/pipe/PipeEventTileState.java @@ -1,6 +1,6 @@ package buildcraft.api.transport.pipe; -import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.level.block.entity.BlockEntity; /** Fired when the state of a pipe's tile entity changes. Listen for subclasses, not this one! */ public abstract class PipeEventTileState extends PipeEvent { @@ -8,21 +8,21 @@ public abstract class PipeEventTileState extends PipeEvent { super(holder); } - /** Fired in {@link TileEntity#invalidate()} */ + /** Fired in {@link BlockEntity#setRemoved()} */ public static class Invalidate extends PipeEventTileState { public Invalidate(IPipeHolder holder) { super(holder); } } - /** Fired in {@link TileEntity#validate()} */ + /** Fired in {@link BlockEntity#clearRemoved()} */ public static class Validate extends PipeEventTileState { public Validate(IPipeHolder holder) { super(holder); } } - /** Fired in {@link TileEntity#onChunkUnload()} */ + /** Fired in {@link BlockEntity#onChunkUnloaded()} */ public static class ChunkUnload extends PipeEventTileState { public ChunkUnload(IPipeHolder holder) { super(holder); diff --git a/api/buildcraft/api/transport/pipe/PipeFaceTex.java b/api/buildcraft/api/transport/pipe/PipeFaceTex.java index 2c90354..af557ae 100644 --- a/api/buildcraft/api/transport/pipe/PipeFaceTex.java +++ b/api/buildcraft/api/transport/pipe/PipeFaceTex.java @@ -120,7 +120,7 @@ public boolean equals(Object obj) { if (!Arrays.equals(textures, other.textures)) { return false; } - for (int i = textures.length; i > 0;) { + for (int i = textures.length; i > 0; ) { i--; if (getColour(i) != other.getColour(i)) { return false; diff --git a/api/buildcraft/api/transport/pipe/PipeFlow.java b/api/buildcraft/api/transport/pipe/PipeFlow.java index 3ec2117..4608edb 100644 --- a/api/buildcraft/api/transport/pipe/PipeFlow.java +++ b/api/buildcraft/api/transport/pipe/PipeFlow.java @@ -1,25 +1,24 @@ package buildcraft.api.transport.pipe; -import java.io.IOException; - -import javax.annotation.Nonnull; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.PacketBuffer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.NonNullList; -import net.minecraft.util.math.RayTraceResult; - -import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.common.capabilities.ICapabilityProvider; -import net.minecraftforge.fml.relauncher.Side; - import buildcraft.api.core.EnumPipePart; import buildcraft.api.transport.pipe.IPipeHolder.IWriter; import buildcraft.api.transport.pipe.IPipeHolder.PipeMessageReceiver; +import net.minecraft.core.Direction; +import net.minecraft.core.NonNullList; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.phys.HitResult; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.capabilities.ICapabilityProvider; +import net.minecraftforge.common.util.LazyOptional; +import net.minecraftforge.network.NetworkDirection; + +import javax.annotation.Nonnull; +import java.io.IOException; public abstract class PipeFlow implements ICapabilityProvider { /** The ID for completely refreshing the state of this flow. */ @@ -34,59 +33,64 @@ public PipeFlow(IPipe pipe) { this.pipe = pipe; } - public PipeFlow(IPipe pipe, NBTTagCompound nbt) { + public PipeFlow(IPipe pipe, CompoundTag nbt) { this.pipe = pipe; } - public NBTTagCompound writeToNbt() { - return new NBTTagCompound(); + public CompoundTag writeToNbt() { + return new CompoundTag(); } /** Writes a payload with the specified id. Standard ID's are NET_ID_FULL_STATE and NET_ID_UPDATE. */ - public void writePayload(int id, PacketBuffer buffer, Side side) {} + public void writePayload(int id, FriendlyByteBuf buffer, Dist side) { + } /** Reads a payload with the specified id. Standard ID's are NET_ID_FULL_STATE and NET_ID_UPDATE. */ - public void readPayload(int id, PacketBuffer buffer, Side side) throws IOException {} + public void readPayload(int id, FriendlyByteBuf buffer, NetworkDirection side) throws IOException { + } public void sendPayload(int id) { - final Side side = pipe.getHolder().getPipeWorld().isRemote ? Side.CLIENT : Side.SERVER; + final Dist side = pipe.getHolder().getPipeWorld().isClientSide ? Dist.CLIENT : Dist.DEDICATED_SERVER; sendCustomPayload(id, (buf) -> writePayload(id, buf, side)); } public final void sendCustomPayload(int id, IWriter writer) { - pipe.getHolder().sendMessage(PipeMessageReceiver.FLOW, buffer -> { + pipe.getHolder().sendMessage(PipeMessageReceiver.FLOW, buffer -> + { buffer.writeBoolean(true); buffer.writeShort(id); writer.write(buffer); }); } - public abstract boolean canConnect(EnumFacing face, PipeFlow other); + public abstract boolean canConnect(Direction face, PipeFlow other); - public abstract boolean canConnect(EnumFacing face, TileEntity oTile); + public abstract boolean canConnect(Direction face, BlockEntity oTile); /** Used to force a connection to a given tile, even if the {@link PipeBehaviour} wouldn't normally connect to * it. */ - public boolean shouldForceConnection(EnumFacing face, TileEntity oTile) { + public boolean shouldForceConnection(Direction face, BlockEntity oTile) { return false; } public void onTick() {} + public void postPluggableTick() {} + public void addDrops(NonNullList toDrop, int fortune) {} - public boolean onFlowActivate(EntityPlayer player, RayTraceResult trace, float hitX, float hitY, float hitZ, - EnumPipePart part) { + public boolean onFlowActivate(Player player, HitResult trace, float hitX, float hitY, float hitZ, + EnumPipePart part) { return false; } - @Override - public final boolean hasCapability(@Nonnull Capability capability, EnumFacing facing) { - return getCapability(capability, facing) != null; - } +// @Override +// public final boolean hasCapability(@Nonnull Capability capability, EnumFacing facing) { +// return getCapability(capability, facing) != null; +// } @Override - public T getCapability(@Nonnull Capability capability, EnumFacing facing) { - return null; + public LazyOptional getCapability(@Nonnull Capability capability, Direction facing) { + return LazyOptional.empty(); } } diff --git a/api/buildcraft/api/transport/pipe/PipeFlowType.java b/api/buildcraft/api/transport/pipe/PipeFlowType.java index fb79d40..2cb320f 100644 --- a/api/buildcraft/api/transport/pipe/PipeFlowType.java +++ b/api/buildcraft/api/transport/pipe/PipeFlowType.java @@ -1,6 +1,6 @@ package buildcraft.api.transport.pipe; -import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.CompoundTag; public final class PipeFlowType { public final IFlowCreator creator; @@ -27,6 +27,6 @@ public interface IFlowCreator { @FunctionalInterface public interface IFlowLoader { - PipeFlow loadFlow(IPipe t, NBTTagCompound u); + PipeFlow loadFlow(IPipe t, CompoundTag u); } } diff --git a/api/buildcraft/api/transport/pluggable/ActionIterator.java b/api/buildcraft/api/transport/pluggable/ActionIterator.java new file mode 100644 index 0000000..ecb9d5a --- /dev/null +++ b/api/buildcraft/api/transport/pluggable/ActionIterator.java @@ -0,0 +1,69 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + *

    + * BuildCraft is distributed under the terms of the Minecraft Mod Public License 1.0, or MMPL. Please check the contents + * of the license located in http://www.mod-buildcraft.com/MMPL-1.0.txt */ +package buildcraft.api.transport.pluggable; + +import buildcraft.api.gates.IGateProvider; +import buildcraft.api.statements.StatementSlot; +import buildcraft.api.transport.pipe.IPipe; +import net.minecraft.core.Direction; + +import java.util.Iterator; +import java.util.List; + +public class ActionIterator implements Iterable { + private final IPipe pipe; + + public ActionIterator(IPipe iPipe) { + pipe = iPipe; + } + + @Override + public Iterator iterator() { + return new It(); + } + + private class It implements Iterator { + + private Direction curDir = Direction.values()[0]; + private int index = 0; + + @Override + public boolean hasNext() { + return getNext(false) != null; + } + + @Override + public StatementSlot next() { + return getNext(true); + } + + private StatementSlot getNext(boolean advance) { + Direction curDir = this.curDir; + int index = this.index; + while (true) { + // List lst = pipe.hasGate(curDir) ? pipe.getGate(curDir).getActiveActions() : null; + List lst = pipe.getHolder().getPluggable(curDir) instanceof IGateProvider ? ((IGateProvider) pipe.getHolder().getPluggable(curDir)).getGate().getActiveActions() : null; + if (lst == null || index >= lst.size()) { + if (curDir.ordinal() == 5) { + return null; + } + curDir = Direction.values()[curDir.ordinal() + 1]; + } else { + index++; + if (advance) { + this.curDir = curDir; + this.index = index; + } + return lst.get(index - 1); + } + } + } + + @Override + public void remove() { + throw new UnsupportedOperationException("Remove not supported."); + } + } +} diff --git a/api/buildcraft/api/transport/pluggable/IPlugDynamicRenderer.java b/api/buildcraft/api/transport/pluggable/IPlugDynamicRenderer.java index 1a71aa3..5ae33c5 100644 --- a/api/buildcraft/api/transport/pluggable/IPlugDynamicRenderer.java +++ b/api/buildcraft/api/transport/pluggable/IPlugDynamicRenderer.java @@ -1,8 +1,9 @@ package buildcraft.api.transport.pluggable; - -import net.minecraft.client.renderer.BufferBuilder; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; public interface IPlugDynamicRenderer

    { - void render(P plug, double x, double y, double z, float partialTicks, BufferBuilder bb); + // void render(P plug, double x, double y, double z, float partialTicks, BufferBuilder bb); + void render(P gate, float partialTicks, PoseStack poseStack, VertexConsumer vertexConsumer, int combinedLight, int combinedOverlay); } diff --git a/api/buildcraft/api/transport/pluggable/IPluggableRegistry.java b/api/buildcraft/api/transport/pluggable/IPluggableRegistry.java index 243731c..5fa459a 100644 --- a/api/buildcraft/api/transport/pluggable/IPluggableRegistry.java +++ b/api/buildcraft/api/transport/pluggable/IPluggableRegistry.java @@ -1,6 +1,6 @@ package buildcraft.api.transport.pluggable; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; public interface IPluggableRegistry { default void register(PluggableDefinition definition) { diff --git a/api/buildcraft/api/transport/pluggable/IPluggableStaticBaker.java b/api/buildcraft/api/transport/pluggable/IPluggableStaticBaker.java index a3f0012..f33eb34 100644 --- a/api/buildcraft/api/transport/pluggable/IPluggableStaticBaker.java +++ b/api/buildcraft/api/transport/pluggable/IPluggableStaticBaker.java @@ -1,13 +1,12 @@ package buildcraft.api.transport.pluggable; -import java.util.List; - import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +import java.util.List; -@SideOnly(Side.CLIENT) +@OnlyIn(Dist.CLIENT) public interface IPluggableStaticBaker { List bake(K key); } diff --git a/api/buildcraft/api/transport/pluggable/PipePluggable.java b/api/buildcraft/api/transport/pluggable/PipePluggable.java index 73d22b6..62e3e1e 100644 --- a/api/buildcraft/api/transport/pluggable/PipePluggable.java +++ b/api/buildcraft/api/transport/pluggable/PipePluggable.java @@ -1,75 +1,73 @@ package buildcraft.api.transport.pluggable; -import java.io.IOException; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import net.minecraft.block.Block; -import net.minecraft.block.state.BlockFaceShape; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.BlockRenderLayer; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.NonNullList; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.world.Explosion; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; - +import buildcraft.api.transport.pipe.IPipeHolder; +import net.minecraft.client.renderer.RenderType; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.NonNullList; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Explosion; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.HitResult; +import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.ICapabilityProvider; -import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +import net.minecraftforge.common.util.LazyOptional; +import net.minecraftforge.network.NetworkDirection; +import net.minecraftforge.network.NetworkEvent; -import buildcraft.api.transport.pipe.IPipeHolder; -import buildcraft.api.transport.pipe.IPipeHolder.PipeMessageReceiver; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import java.io.IOException; public abstract class PipePluggable { public final PluggableDefinition definition; public final IPipeHolder holder; - public final EnumFacing side; + public final Direction side; - public PipePluggable(PluggableDefinition definition, IPipeHolder holder, EnumFacing side) { + public PipePluggable(PluggableDefinition definition, IPipeHolder holder, Direction side) { this.definition = definition; this.holder = holder; this.side = side; } - public NBTTagCompound writeToNbt() { - NBTTagCompound nbt = new NBTTagCompound(); + public CompoundTag writeToNbt() { + CompoundTag nbt = new CompoundTag(); return nbt; } /** Writes the payload that will be passed into - * {@link PluggableDefinition#loadFromBuffer(IPipeHolder, EnumFacing, PacketBuffer)} on the client. (This is called + * {@link PluggableDefinition#loadFromBuffer(IPipeHolder, Direction, FriendlyByteBuf)} on the client. (This is called * on the server and sent to the client). Note that this will be called *instead* of write and read payload. */ - public void writeCreationPayload(PacketBuffer buffer) { + public void writeCreationPayload(FriendlyByteBuf buffer) { } - public void writePayload(PacketBuffer buffer, Side side) { + public void writePayload(FriendlyByteBuf buffer, Dist side) { } - public void readPayload(PacketBuffer buffer, Side side, MessageContext ctx) throws IOException { + public void readPayload(FriendlyByteBuf buffer, NetworkDirection side, NetworkEvent.Context ctx) throws IOException { } public final void scheduleNetworkUpdate() { - holder.scheduleNetworkUpdate(PipeMessageReceiver.PLUGGABLES[side.ordinal()]); + holder.scheduleNetworkUpdate(IPipeHolder.PipeMessageReceiver.PLUGGABLES[side.ordinal()]); } - public void onTick() {} + public void onTick() { + } /** @return A bounding box that will be used for collisions and raytracing. */ - public abstract AxisAlignedBB getBoundingBox(); + public abstract VoxelShape getBoundingBox(); /** @return True if the pipe cannot connect outwards (it is blocked), or False if this does not block the pipe. */ public boolean isBlocking() { @@ -78,14 +76,14 @@ public boolean isBlocking() { /** Gets the value of a specified capability key, or null if the given capability is not supported at the call time. * This is effectively {@link ICapabilityProvider}, but where - * {@link ICapabilityProvider#hasCapability(Capability, EnumFacing)} will return true when this returns a non-null + * {@link ICapabilityProvider#getCapability(Capability, Direction)#isPresent()} will return true when this returns a non-null * value. */ - public T getCapability(@Nonnull Capability cap) { - return null; + public LazyOptional getCapability(@Nonnull Capability cap) { + return LazyOptional.empty(); } /** Gets the {@link Capability} that is accessible from the pipe that this is attached to. - * + * * @param cap * @return */ public T getInternalCapability(@Nonnull Capability cap) { @@ -93,7 +91,8 @@ public T getInternalCapability(@Nonnull Capability cap) { } /** Called whenever this pluggable is removed from the pipe. */ - public void onRemove() {} + public void onRemove() { + } /** @param toDrop A list containing all the items to drop (so you should add your items to this list) */ public void addDrops(NonNullList toDrop, int fortune) { @@ -104,58 +103,61 @@ public void addDrops(NonNullList toDrop, int fortune) { } /** Called whenever this pluggable is picked by the player (similar to Block.getPickBlock) - * + * * @return The stack that should be picked, or ItemStack.EMPTY if no stack can be picked from this pluggable. */ public ItemStack getPickStack() { return ItemStack.EMPTY; } - public boolean onPluggableActivate(EntityPlayer player, RayTraceResult trace, float hitX, float hitY, float hitZ) { + public boolean onPluggableActivate(Player player, HitResult trace, float hitX, float hitY, float hitZ) { return false; } + @OnlyIn(Dist.CLIENT) @Nullable - public PluggableModelKey getModelRenderKey(BlockRenderLayer layer) { + public PluggableModelKey getModelRenderKey(RenderType layer) { return null; } /** Called if the {@link IPluggableStaticBaker} returns quads with tint indexes set to * data * 6 + key.side.ordinal(). "data" is passed in here as "tintIndex". - * + * * @return The tint index to render the quad with, or -1 for default. */ - @SideOnly(Side.CLIENT) + @OnlyIn(Dist.CLIENT) public int getBlockColor(int tintIndex) { return -1; } /** PipePluggable version of - * {@link Block#canBeConnectedTo(net.minecraft.world.IBlockAccess, net.minecraft.util.math.BlockPos, EnumFacing)}. */ + * {@link Block#canBeConnectedTo(net.minecraft.world.level.LevelAccessor, BlockPos, Direction)}. */ public boolean canBeConnected() { return false; } /** PipePluggable version of - * {@link net.minecraft.block.state.IBlockState#isSideSolid(IBlockAccess, BlockPos, EnumFacing)} */ + * {@link BlockState#isSideSolid(IBlockAccess, BlockPos, Direction)} */ public boolean isSideSolid() { return false; } - /** PipePluggable version of {@link Block#getExplosionResistance(World, BlockPos, Entity, Explosion)} */ - public float getExplosionResistance(@Nullable Entity exploder, Explosion explosion) { + /** PipePluggable version of {@link Block#getExplosionResistance(BlockState, BlockGetter, BlockPos, Explosion)} */ +// public float getExplosionResistance(@Nullable Entity exploder, Explosion explosion) + public float getExplosionResistance(@Nonnull Entity exploder, Explosion explosion) { return 0; } - public boolean canConnectToRedstone(@Nullable EnumFacing to) { + public boolean canConnectToRedstone(@Nullable Direction to) { return false; } - /** PipePluggable version of - * {@link net.minecraft.block.state.IBlockState#getBlockFaceShape(IBlockAccess, BlockPos, EnumFacing)} */ - public BlockFaceShape getBlockFaceShape() { - return BlockFaceShape.UNDEFINED; - } + // Calen: seems use block Shape in 1.18.2 +// /** PipePluggable version of +// * {@link net.minecraft.block.state.IBlockState#getBlockFaceShape(IBlockAccess, BlockPos, EnumFacing)} */ +// public BlockFaceShape getBlockFaceShape() { +// return BlockFaceShape.UNDEFINED; +// } - public void onPlacedBy(EntityPlayer player) { + public void onPlacedBy(Player player) { } } diff --git a/api/buildcraft/api/transport/pluggable/PluggableDefinition.java b/api/buildcraft/api/transport/pluggable/PluggableDefinition.java index 4d7fdaa..bed9289 100644 --- a/api/buildcraft/api/transport/pluggable/PluggableDefinition.java +++ b/api/buildcraft/api/transport/pluggable/PluggableDefinition.java @@ -1,14 +1,13 @@ package buildcraft.api.transport.pluggable; -import javax.annotation.Nullable; - -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.ResourceLocation; - import buildcraft.api.core.InvalidInputDataException; import buildcraft.api.transport.pipe.IPipeHolder; +import net.minecraft.core.Direction; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.resources.ResourceLocation; + +import javax.annotation.Nullable; public final class PluggableDefinition { public final ResourceLocation identifier; @@ -33,12 +32,12 @@ public PluggableDefinition(ResourceLocation identifier, @Nullable IPluggableCrea this.creator = creator; } - public PipePluggable readFromNbt(IPipeHolder holder, EnumFacing side, NBTTagCompound nbt) { + public PipePluggable readFromNbt(IPipeHolder holder, Direction side, CompoundTag nbt) { return reader.readFromNbt(this, holder, side, nbt); } - public PipePluggable loadFromBuffer(IPipeHolder holder, EnumFacing side, PacketBuffer buffer) - throws InvalidInputDataException { + public PipePluggable loadFromBuffer(IPipeHolder holder, Direction side, FriendlyByteBuf buffer) + throws InvalidInputDataException { return loader.loadFromBuffer(this, holder, side, buffer); } @@ -47,30 +46,26 @@ public interface IPluggableNbtReader { /** Reads the pipe pluggable from NBT. Unlike {@link IPluggableNetLoader} (which is allowed to fail and throw an * exception if the wrong data is given) this should make a best effort to read the pluggable from nbt, or fall * back to sensible defaults. */ - PipePluggable readFromNbt(PluggableDefinition definition, IPipeHolder holder, EnumFacing side, - NBTTagCompound nbt); + PipePluggable readFromNbt(PluggableDefinition definition, IPipeHolder holder, Direction side, CompoundTag nbt); } @FunctionalInterface public interface IPluggableNetLoader { - PipePluggable loadFromBuffer(PluggableDefinition definition, IPipeHolder holder, EnumFacing side, - PacketBuffer buffer) throws InvalidInputDataException; + PipePluggable loadFromBuffer(PluggableDefinition definition, IPipeHolder holder, Direction side, FriendlyByteBuf buffer) throws InvalidInputDataException; } @FunctionalInterface public interface IPluggableCreator extends IPluggableNbtReader, IPluggableNetLoader { @Override - default PipePluggable loadFromBuffer(PluggableDefinition definition, IPipeHolder holder, EnumFacing side, - PacketBuffer buffer) { + default PipePluggable loadFromBuffer(PluggableDefinition definition, IPipeHolder holder, Direction side, FriendlyByteBuf buffer) { return createSimplePluggable(definition, holder, side); } @Override - default PipePluggable readFromNbt(PluggableDefinition definition, IPipeHolder holder, EnumFacing side, - NBTTagCompound nbt) { + default PipePluggable readFromNbt(PluggableDefinition definition, IPipeHolder holder, Direction side, CompoundTag nbt) { return createSimplePluggable(definition, holder, side); } - PipePluggable createSimplePluggable(PluggableDefinition definition, IPipeHolder holder, EnumFacing side); + PipePluggable createSimplePluggable(PluggableDefinition definition, IPipeHolder holder, Direction side); } } diff --git a/api/buildcraft/api/transport/pluggable/PluggableModelKey.java b/api/buildcraft/api/transport/pluggable/PluggableModelKey.java index 7c832c1..83525c0 100644 --- a/api/buildcraft/api/transport/pluggable/PluggableModelKey.java +++ b/api/buildcraft/api/transport/pluggable/PluggableModelKey.java @@ -1,17 +1,17 @@ package buildcraft.api.transport.pluggable; -import java.util.Objects; +import net.minecraft.client.renderer.RenderType; +import net.minecraft.core.Direction; -import net.minecraft.util.BlockRenderLayer; -import net.minecraft.util.EnumFacing; +import java.util.Objects; public abstract class PluggableModelKey { - public final BlockRenderLayer layer; - public final EnumFacing side; + public final RenderType layer; + public final Direction side; private final int hash; - public PluggableModelKey(BlockRenderLayer layer, EnumFacing side) { - if (layer != BlockRenderLayer.CUTOUT && layer != BlockRenderLayer.TRANSLUCENT) { + public PluggableModelKey(RenderType layer, Direction side) { + if (layer != RenderType.cutout() && layer != RenderType.translucent()) { throw new IllegalArgumentException("Can only use CUTOUT or TRANSLUCENT at the moment (was " + layer + ")"); } if (side == null) throw new NullPointerException("side"); diff --git a/build.gradle b/build.gradle index 0efb16f..730359a 100644 --- a/build.gradle +++ b/build.gradle @@ -1,22 +1,23 @@ - -// For those who want the bleeding edge buildscript { repositories { - jcenter() - maven { - name = "forge" - url = "http://files.minecraftforge.net/maven" - } + // These repositories are only for Gradle plugins, put any other repositories in the repository core further below + maven { url = 'https://maven.minecraftforge.net' } + mavenCentral() } dependencies { - classpath "net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT" + classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true + // Mixin + classpath 'org.spongepowered:mixingradle:0.7.+' } } -apply plugin: "net.minecraftforge.gradle.forge" - -if (gradle.startParameter.taskNames.contains("checkstyle")) { - apply plugin: "checkstyle" +// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup. +plugins { + id 'eclipse' + id 'idea' + id 'maven-publish' + id 'net.minecraftforge.gradle' version '[6.0,6.2)' } +apply plugin: 'net.minecraftforge.gradle' ext.configFile = file "build.properties" configFile.withReader { @@ -27,85 +28,190 @@ configFile.withReader { } version = config.mod_version -group= "com.mod-buildcraft.api" // http://maven.apache.org/guides/mini/guide-naming-conventions.html +group = "com.mod-buildcraft.api" archivesBaseName = "buildcraft-api" // the name that all artifacts will use as a base. artifacts names follow this pattern: [baseName]-[appendix]-[version]-[classifier].[extension] -sourceCompatibility = JavaVersion.VERSION_1_8 -targetCompatibility = JavaVersion.VERSION_1_8 +// Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17. +java.toolchain.languageVersion = JavaLanguageVersion.of(17) +println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}" minecraft { - version = config.mc_version + "-" + config.forge_version - runDir = "run" + // The mappings can be changed at any time and must be in the following format. + // Channel: Version: + // official MCVersion Official field/method names from Mojang mapping files + // parchment YYYY.MM.DD-MCVersion Open community-sourced parameter names and javadocs layered on top of official + // + // You must be aware of the Mojang license when using the 'official' or 'parchment' mappings. + // See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md + // + // Parchment is an unofficial project maintained by ParchmentMC, separate from MinecraftForge + // Additional setup is needed to use their mappings: https://github.com/ParchmentMC/Parchment/wiki/Getting-Started + // + // Use non-default mappings at your own risk. They may not always work. + // Simply re-run your setup task after changing the mappings to update your workspace. + mappings channel: config.mappings_channel, version: config.mappings_version + + copyIdeResources = true + + accessTransformer = file('resources/accesstransformer.cfg') +} + +compileJava { + options.compilerArgs << "-Xmaxerrs" << "2000" + options.compilerArgs << "-Xmaxwarns" << "2" + options.compilerArgs << "-Xlint:all" + options.compilerArgs << "-Xdiags:verbose" + options.compilerArgs << "-encoding" << "UTF-8" +} + +javadoc { + options.setUse(true) + options.addStringsOption("Xmaxerrs").setValue(["2000"]) + options.addStringsOption("Xmaxwarns").setValue(["2"]) +} - // the mappings can be changed at any time, and must be in the following format. - // snapshot_YYYYMMDD snapshot are built nightly. - // stable_# stables are built at the discretion of the MCP team. - // Use non-default mappings at your own risk. they may not always work. - // simply re-run your setup task after changing the mappings to update your workspace. - mappings = config.mappings_version - // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable. +task javadocJar(type: Jar, dependsOn: javadoc) { +// classifier = 'javadoc' + from javadoc.destinationDir } +// Include resources generated by data generators. sourceSets { main { java { srcDir "api" } + resources { + } } } -if (gradle.startParameter.taskNames.contains("checkstyle")) { - checkstyle { - configFile = file("guidelines/buildcraft.checkstyle") - } +repositories { + // Put repositories for dependencies here + // ForgeGradle automatically adds the Forge maven and Maven Central for you - task checkstyle {} - tasks["checkstyle"].dependsOn checkstyleApi - tasks["checkstyle"].dependsOn checkstyleMain + // If you have mod jar dependencies in ./libs, you can declare them as a repository like so: + // flatDir { + // dir 'libs' + // } - tasks["checkstyleApi"].enabled = gradle.startParameter.taskNames.contains("checkstyle") - tasks["checkstyleMain"].enabled = gradle.startParameter.taskNames.contains("checkstyle") + maven { + name 'CurseMaven' + url 'https://www.cursemaven.com' + content { + includeGroup 'curse.maven' + } + } } -processResources -{ - // this will ensure that this task is redone when the versions change. - inputs.property "version", project.version - inputs.property "mcversion", project.minecraft.version +dependencies { + // Specify the version of Minecraft to use. If this is any group other than 'net.minecraft', it is assumed + // that the dep is a ForgeGradle 'patcher' dependency, and its patches will be applied. + // The userdev artifact is a special name and will get all sorts of transformations applied to it. - // replace stuff in mcmod.info, nothing else - from(sourceSets.main.resources.srcDirs) { - include 'mcmod.info' + minecraft "net.minecraftforge:forge:${config.mc_version}-${config.forge_version}" - // replace version and mcversion - expand 'version':project.version, 'mcversion':project.minecraft.version - } + // Examples using mod jars from ./libs - // copy everything else, thats not the mcmod.info - from(sourceSets.main.resources.srcDirs) { - exclude 'mcmod.info' - } -} + // For more info... + // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html + // http://www.gradle.org/docs/current/userguide/dependency_management.html -compileJava { - options.compilerArgs << "-Xmaxerrs" << "2000" - options.compilerArgs << "-Xmaxwarns" << "2" - options.compilerArgs << "-Xlint:all" - options.compilerArgs << "-Xdiags:verbose" - options.compilerArgs << "-encoding" << "UTF-8" + annotationProcessor 'org.spongepowered:mixin:0.8.5:processor' } -javadoc { - options.setUse(true) - options.addStringsOption("Xmaxerrs").setValue(["2000"]) - options.addStringsOption("Xmaxwarns").setValue(["2"]) +if (gradle.startParameter.taskNames.contains("checkstyle")) { + checkstyle { + configFile = file("guidelines/buildcraft.checkstyle") + } + + task checkstyle {} + tasks["checkstyle"].dependsOn checkstyleApi + tasks["checkstyle"].dependsOn checkstyleMain + + tasks["checkstyleApi"].enabled = gradle.startParameter.taskNames.contains("checkstyle") + tasks["checkstyleMain"].enabled = gradle.startParameter.taskNames.contains("checkstyle") } -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir +tasks.named('processResources', ProcessResources).configure { +// var replaceProperties = [ +// minecraft_version : config.mc_version, +// minecraft_version_range: minecraft_version_range, +// forge_version : config.forge_version, +// forge_version_range : forge_version_range, +// loader_version_range : loader_version_range, +// mod_id : mod_id, +// mod_name : mod_name, +// mod_license : mod_license, +// mod_version : mod_version, +// mod_authors : mod_authors, +// mod_description : mod_description, +// ] +// inputs.properties replaceProperties + +// filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) { +// expand replaceProperties + [project: project] +// } +// // this will ensure that this task is redone when the versions change. +// inputs.property "version", project.version +// inputs.property "mcversion", config.mc_version + "-" + config.forge_version +// +// // replace stuff in mcmod.info, nothing else +// from(sourceSets.main.resources.srcDirs) { +// include 'mcmod.info' +// +// // replace version and mcversion +// expand 'version':project.version, 'mcversion':config.mc_version + "-" + config.forge_version +// } +// +// // copy everything else, thats not the mcmod.info +// from(sourceSets.main.resources.srcDirs) { +// exclude 'mcmod.info' +// } } artifacts { archives javadocJar } + +// Example for how to get properties into the manifest for reading at runtime. +tasks.named('jar', Jar).configure { + manifest { + attributes([ + "Specification-Title" : "BuildCraft", + "Specification-Vendor" : "BuildCraft Team", + "Specification-Version" : project.version, + "Implementation-Title" : project.name, + "Implementation-Version" : project.jar.archiveVersion, + "Implementation-Vendor" : "BuildCraft Team", + "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") + ]) + } + include '**/**/**/libs/*' +} + +// Example configuration to allow publishing using the maven-publish plugin +// This is the preferred method to reobfuscate your jar file +jar.finalizedBy('reobfJar') +// However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing +// publish.dependsOn('reobfJar') + +publishing { + publications { + register('mavenJava', MavenPublication) { + artifact jar + } + } + repositories { + maven { +// url "file://${project.projectDir}/mcmodsrepo" + url System.getenv("MAVEN_DIR") ?: "$projectDir/build/maven" + } + } +} + +tasks.withType(JavaCompile).configureEach { + options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation +} + +jar.enabled = true diff --git a/build.properties b/build.properties index d21cfb0..becf4ef 100644 --- a/build.properties +++ b/build.properties @@ -1,4 +1,5 @@ -mc_version=1.12.2 -forge_version=14.23.0.2532 -mappings_version=snapshot_20170629 -mod_version=7.99 +mc_version=1.20.1 +forge_version=47.3.12 +mappings_channel=official +mappings_version=1.20.1 +mod_version=7.99.24.9 diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..29b2ac4 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,2 @@ +org.gradle.jvmargs=-Xmx3G +org.gradle.daemon=false diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 30d399d..41d9927 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 9397848..0d18421 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Mon Sep 14 12:28:28 PDT 2015 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.7-bin.zip diff --git a/gradlew b/gradlew index 91a7e26..1b6c787 100755 --- a/gradlew +++ b/gradlew @@ -1,79 +1,129 @@ -#!/usr/bin/env bash +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum -warn ( ) { +warn () { echo "$*" -} +} >&2 -die ( ) { +die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac -# For Cygwin, ensure paths are in UNIX format before anything is touched. -if $cygwin ; then - [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` -fi - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >&- -APP_HOME="`pwd -P`" -cd "$SAVED" >&- - CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -82,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" + JAVACMD=java which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the @@ -90,75 +140,95 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=$((i+1)) + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules -function splitJvmOpts() { - JVM_OPTS=("$@") -} -eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS -JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" - -exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index aec9973..ac1b06f 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,3 +1,19 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @@ -8,20 +24,23 @@ @rem Set local scope for the variables with windows NT shell if "%OS%"=="Windows_NT" setlocal -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - set DIRNAME=%~dp0 if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if "%ERRORLEVEL%" == "0" goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -35,7 +54,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -45,34 +64,14 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windowz variants - -if not "%OS%" == "Windows_NT" goto win9xME_args -if "%@eval[2+2]" == "4" goto 4NT_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* -goto execute - -:4NT_args -@rem Get arguments from the 4NT Shell from JP Software -set CMD_LINE_ARGS=%$ - :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell diff --git a/resources/accesstransformer.cfg b/resources/accesstransformer.cfg new file mode 100644 index 0000000..4580094 --- /dev/null +++ b/resources/accesstransformer.cfg @@ -0,0 +1,2 @@ +public net.minecraft.core.Direction f_122349_ # BY_2D_DATA +public net.minecraft.core.Direction f_122346_ # VALUES diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..93f1b80 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,13 @@ +pluginManagement { + repositories { + gradlePluginPortal() + maven { + name = 'MinecraftForge' + url = 'https://maven.minecraftforge.net/' + } + } +} + +plugins { + id 'org.gradle.toolchains.foojay-resolver-convention' version '0.7.0' +} \ No newline at end of file