Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Robotics!
  • Loading branch information
CalenXwX committed Apr 21, 2025
commit db7e646f680266aebdcd266d75347fe567d65269
27 changes: 19 additions & 8 deletions api/buildcraft/api/boards/RedstoneBoardNBT.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,40 @@

import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.Tag;
import net.minecraft.world.entity.player.Player;
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;

public abstract class RedstoneBoardNBT<T> {

private static Random rand = new Random();

public abstract String getID();
public abstract ResourceLocation getID();

public abstract void addInformation(ItemStack stack, Player player, List<String> list, boolean advanced);
// public abstract void addInformation(ItemStack stack, Player player, List<String> list, boolean advanced);
public abstract void addInformation(ItemStack stack, @Nullable Level world, List<Component> list, TooltipFlag flag);

public abstract String getDisplayName();
// public abstract String getDisplayName();
public final String getDisplayName() {
return getDisplayNameComponent().getString();
}

public abstract Component getDisplayNameComponent();

public abstract IRedstoneBoard<T> create(CompoundTag nbt, T object);

public abstract String getItemModelLocation();
// public abstract String getItemModelLocation();
public abstract String getBoardTexture();

public void createBoard(CompoundTag nbt) {
nbt.putString("id", getID());
}
// public void createBoard(CompoundTag nbt) {
// nbt.putString("id", getID().toString());
// }

public int getParameterNumber(CompoundTag nbt) {
if (!nbt.contains("parameters")) {
Expand Down
14 changes: 11 additions & 3 deletions api/buildcraft/api/boards/RedstoneBoardRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
package buildcraft.api.boards;

import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import net.minecraftforge.registries.RegistryObject;

import java.util.Collection;
import java.util.List;
import java.util.Map;

public abstract class RedstoneBoardRegistry {

Expand All @@ -24,9 +28,13 @@ public abstract class RedstoneBoardRegistry {

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<RedstoneBoardNBT<?>> getAllBoardNBTs();
// public abstract Collection<RedstoneBoardNBT<?>> getAllBoardNBTs();
public abstract List<RedstoneBoardNBT<?>> getAllBoardNBTs();

public abstract Map<RedstoneBoardNBT<?>, RegistryObject<? extends Item>> getBoardNBTItemMap();

public abstract long getPowerCost(RedstoneBoardNBT<?> board);
}
3 changes: 3 additions & 0 deletions api/buildcraft/api/boards/RedstoneBoardRobotNBT.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,8 @@ public RedstoneBoardRobot create(CompoundTag nbt, EntityRobotBase robot) {
public abstract RedstoneBoardRobot create(EntityRobotBase robot);

public abstract ResourceLocation getRobotTexture();
// Calen 1.18.2
public abstract ResourceLocation getRobotTextureFullLocation();

public abstract ResourceLocation getRobotId();
}
36 changes: 14 additions & 22 deletions api/buildcraft/api/core/BuildCraftAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,16 @@
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
package buildcraft.api.core;

import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraftforge.fml.ModContainer;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.ModLoadingContext;

import java.util.HashMap;
import java.util.Set;

public final class BuildCraftAPI {
public static IFakePlayerProvider fakePlayerProvider;

public static final Set<Block> softBlocks = Sets.newHashSet();
public static final HashMap<String, IWorldProperty> worldProperties = Maps.newHashMap();
// public static final Set<Block> softBlocks = Sets.newHashSet();
// public static final HashMap<String, IWorldProperty> worldProperties = Maps.newHashMap();

/** Deactivate constructor */
private BuildCraftAPI() {
Expand All @@ -35,20 +27,20 @@ public static String getVersion() {
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(Level 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);
Expand Down
13 changes: 13 additions & 0 deletions api/buildcraft/api/core/IBlockFilter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
* <p/>
* 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);
}
13 changes: 13 additions & 0 deletions api/buildcraft/api/core/IEntityFilter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
* <p/>
* 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);

}
6 changes: 5 additions & 1 deletion api/buildcraft/api/core/IInvSlot.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

import net.minecraft.world.item.ItemStack;

import javax.annotation.Nonnull;

public interface IInvSlot {
/** Returns the slot number of the underlying Inventory.
*
Expand All @@ -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);
}
14 changes: 11 additions & 3 deletions api/buildcraft/api/crops/CropManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
import java.util.List;

public final class CropManager {
public enum HarvestResult {
SUCCESS,
FAIL,
PROGRESS;
}

private static List<ICropHandler> handlers = new ArrayList<>();
private static ICropHandler defaultHandler;

Expand Down Expand Up @@ -73,13 +79,15 @@ public static boolean isMature(LevelAccessor blockAccess, BlockState state, Bloc
return defaultHandler.isMature(blockAccess, state, pos);
}

public static boolean harvestCrop(Level world, BlockPos pos, NonNullList<ItemStack> drops) {
// public static boolean harvestCrop(Level world, BlockPos pos, NonNullList<ItemStack> drops)
public static HarvestResult harvestCrop(Level world, BlockPos pos, ItemStack tool, NonNullList<ItemStack> 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;
}
}
6 changes: 5 additions & 1 deletion api/buildcraft/api/crops/ICropHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.state.BlockState;

import javax.annotation.Nonnull;

public interface ICropHandler {

/** Check if an item is a seed.
Expand Down Expand Up @@ -46,8 +48,10 @@ public interface ICropHandler {
*
* @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(Level world, BlockPos pos, NonNullList<ItemStack> drops);
// boolean harvestCrop(Level world, BlockPos pos, NonNullList<ItemStack> drops);
CropManager.HarvestResult harvestCrop(Level world, BlockPos pos, @Nonnull ItemStack tool, NonNullList<ItemStack> drops);

}
6 changes: 6 additions & 0 deletions api/buildcraft/api/gates/IGateProvider.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package buildcraft.api.gates;

// Calen 1.18.2
public interface IGateProvider {
IGate getGate();
}
13 changes: 13 additions & 0 deletions api/buildcraft/api/mj/IMjContainerItem.java
Original file line number Diff line number Diff line change
@@ -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);
}
6 changes: 4 additions & 2 deletions api/buildcraft/api/mj/MjBattery.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
/** 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<CompoundTag> {
public static final String NBT_STORED = "stored";

private final long capacity;
private long microJoules = 0;

Expand All @@ -20,13 +22,13 @@ public MjBattery(long capacity) {
@Override
public CompoundTag serializeNBT() {
CompoundTag nbt = new CompoundTag();
nbt.putLong("stored", microJoules);
nbt.putLong(NBT_STORED, microJoules);
return nbt;
}

@Override
public void deserializeNBT(CompoundTag nbt) {
microJoules = nbt.getLong("stored");
microJoules = nbt.getLong(NBT_STORED);
}

public void writeToBuffer(ByteBuf buffer) {
Expand Down
1 change: 1 addition & 0 deletions api/buildcraft/api/recipes/BuildcraftRecipeRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public final class BuildcraftRecipeRegistry {

public static IIntegrationRecipeRegistry integrationRecipes;
public static IRefineryRecipeManager refineryRecipes;
public static IProgrammingRecipeManager programmingRecipes;

private BuildcraftRecipeRegistry() {
}
Expand Down
7 changes: 5 additions & 2 deletions api/buildcraft/api/recipes/IIntegrationRecipeProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
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;
Expand All @@ -17,10 +18,12 @@ public interface IIntegrationRecipeProvider {
* @param toIntegrate A list of stacks to try to integrate to the
* @return */
@Nullable
IntegrationRecipe getRecipeFor(@Nonnull ItemStack target, @Nonnull NonNullList<ItemStack> toIntegrate);
// IntegrationRecipe getRecipeFor(@Nonnull ItemStack target, @Nonnull NonNullList<ItemStack> toIntegrate);
IntegrationRecipe getRecipeFor(@Nonnull ItemStack target, @Nonnull NonNullList<ItemStack> 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);
}
5 changes: 4 additions & 1 deletion api/buildcraft/api/recipes/IIntegrationRecipeRegistry.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package buildcraft.api.recipes;

import net.minecraft.world.level.Level;

import java.util.Iterator;

public interface IIntegrationRecipeRegistry extends IIntegrationRecipeProvider {
Expand All @@ -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<IntegrationRecipe> getAllRecipes();
// Iterable<IntegrationRecipe> getAllRecipes();
Iterable<IntegrationRecipe> getAllRecipes(Level world);

}
Loading