mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-03-04 06:44:40 +01:00
Misleading documents
- Fix bad javadoc caused by cherry-picking conflicts - Format files in api/ and impl/
This commit is contained in:
parent
5359d7591e
commit
5183d1029a
11 changed files with 65 additions and 61 deletions
|
@ -1,7 +1,21 @@
|
|||
package com.simibubi.create.api.connectivity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.PriorityQueue;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import com.simibubi.create.content.fluids.tank.CreativeFluidTankBlockEntity;
|
||||
import com.simibubi.create.foundation.blockEntity.IMultiBlockEntityContainer;
|
||||
|
||||
import net.createmod.catnip.utility.Iterate;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
|
@ -13,17 +27,6 @@ import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
|||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.PriorityQueue;
|
||||
import java.util.Set;
|
||||
|
||||
public class ConnectivityHandler {
|
||||
|
||||
|
@ -35,7 +38,7 @@ public class ConnectivityHandler {
|
|||
}
|
||||
|
||||
private static <T extends BlockEntity & IMultiBlockEntityContainer> void formMulti(BlockEntityType<?> type,
|
||||
BlockGetter level, SearchCache<T> cache, List<T> frontier) {
|
||||
BlockGetter level, SearchCache<T> cache, List<T> frontier) {
|
||||
PriorityQueue<Pair<Integer, T>> creationQueue = makeCreationQueue();
|
||||
Set<BlockPos> visited = new HashSet<>();
|
||||
Direction.Axis mainAxis = frontier.get(0)
|
||||
|
@ -107,7 +110,7 @@ public class ConnectivityHandler {
|
|||
}
|
||||
|
||||
private static <T extends BlockEntity & IMultiBlockEntityContainer> int tryToFormNewMulti(T be, SearchCache<T> cache,
|
||||
boolean simulate) {
|
||||
boolean simulate) {
|
||||
int bestWidth = 1;
|
||||
int bestAmount = -1;
|
||||
if (!be.isController())
|
||||
|
@ -142,7 +145,7 @@ public class ConnectivityHandler {
|
|||
}
|
||||
|
||||
private static <T extends BlockEntity & IMultiBlockEntityContainer> int tryToFormNewMultiOfWidth(T be, int width,
|
||||
SearchCache<T> cache, boolean simulate) {
|
||||
SearchCache<T> cache, boolean simulate) {
|
||||
int amount = 0;
|
||||
int height = 0;
|
||||
BlockEntityType<?> type = be.getType();
|
||||
|
@ -160,13 +163,14 @@ public class ConnectivityHandler {
|
|||
}
|
||||
Direction.Axis axis = be.getMainConnectionAxis();
|
||||
|
||||
Search: for (int yOffset = 0; yOffset < be.getMaxLength(axis, width); yOffset++) {
|
||||
Search:
|
||||
for (int yOffset = 0; yOffset < be.getMaxLength(axis, width); yOffset++) {
|
||||
for (int xOffset = 0; xOffset < width; xOffset++) {
|
||||
for (int zOffset = 0; zOffset < width; zOffset++) {
|
||||
BlockPos pos = switch (axis) {
|
||||
case X -> origin.offset(yOffset, xOffset, zOffset);
|
||||
case Y -> origin.offset(xOffset, yOffset, zOffset);
|
||||
case Z -> origin.offset(xOffset, zOffset, yOffset);
|
||||
case X -> origin.offset(yOffset, xOffset, zOffset);
|
||||
case Y -> origin.offset(xOffset, yOffset, zOffset);
|
||||
case Z -> origin.offset(xOffset, zOffset, yOffset);
|
||||
};
|
||||
Optional<T> part = cache.getOrCache(type, level, pos);
|
||||
if (part.isEmpty())
|
||||
|
@ -229,9 +233,9 @@ public class ConnectivityHandler {
|
|||
for (int xOffset = 0; xOffset < width; xOffset++) {
|
||||
for (int zOffset = 0; zOffset < width; zOffset++) {
|
||||
BlockPos pos = switch (axis) {
|
||||
case X -> origin.offset(yOffset, xOffset, zOffset);
|
||||
case Y -> origin.offset(xOffset, yOffset, zOffset);
|
||||
case Z -> origin.offset(xOffset, zOffset, yOffset);
|
||||
case X -> origin.offset(yOffset, xOffset, zOffset);
|
||||
case Y -> origin.offset(xOffset, yOffset, zOffset);
|
||||
case Z -> origin.offset(xOffset, zOffset, yOffset);
|
||||
};
|
||||
T part = partAt(type, level, pos);
|
||||
if (part == null)
|
||||
|
@ -280,7 +284,7 @@ public class ConnectivityHandler {
|
|||
|
||||
// tryReconnect helps whenever only a few tanks have been removed
|
||||
private static <T extends BlockEntity & IMultiBlockEntityContainer> void splitMultiAndInvalidate(T be,
|
||||
@Nullable SearchCache<T> cache, boolean tryReconnect) {
|
||||
@Nullable SearchCache<T> cache, boolean tryReconnect) {
|
||||
Level level = be.getLevel();
|
||||
if (level == null)
|
||||
return;
|
||||
|
@ -314,9 +318,9 @@ public class ConnectivityHandler {
|
|||
for (int zOffset = 0; zOffset < width; zOffset++) {
|
||||
|
||||
BlockPos pos = switch (axis) {
|
||||
case X -> origin.offset(yOffset, xOffset, zOffset);
|
||||
case Y -> origin.offset(xOffset, yOffset, zOffset);
|
||||
case Z -> origin.offset(xOffset, zOffset, yOffset);
|
||||
case X -> origin.offset(yOffset, xOffset, zOffset);
|
||||
case Y -> origin.offset(xOffset, yOffset, zOffset);
|
||||
case Z -> origin.offset(xOffset, zOffset, yOffset);
|
||||
};
|
||||
|
||||
T partAt = partAt(be.getType(), level, pos);
|
||||
|
@ -373,7 +377,7 @@ public class ConnectivityHandler {
|
|||
|
||||
@Nullable
|
||||
public static <T extends BlockEntity & IMultiBlockEntityContainer> T partAt(BlockEntityType<?> type, BlockGetter level,
|
||||
BlockPos pos) {
|
||||
BlockPos pos) {
|
||||
BlockEntity be = level.getBlockEntity(pos);
|
||||
if (be != null && be.getType() == type && !be.isRemoved())
|
||||
return checked(be);
|
||||
|
@ -381,7 +385,7 @@ public class ConnectivityHandler {
|
|||
}
|
||||
|
||||
public static <T extends BlockEntity & IMultiBlockEntityContainer> boolean isConnected(BlockGetter level, BlockPos pos,
|
||||
BlockPos other) {
|
||||
BlockPos other) {
|
||||
T one = checked(level.getBlockEntity(pos));
|
||||
T two = checked(level.getBlockEntity(other));
|
||||
if (one == null || two == null)
|
||||
|
|
|
@ -18,8 +18,8 @@ import net.minecraft.world.phys.Vec3;
|
|||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
public abstract class TrainHatInfoProvider implements DataProvider {
|
||||
private final PackOutput.PathProvider path;
|
||||
protected final Map<ResourceLocation, TrainHatInfo> trainHatOffsets = new HashMap<>();
|
||||
private final PackOutput.PathProvider path;
|
||||
|
||||
public TrainHatInfoProvider(PackOutput output) {
|
||||
this.path = output.createPathProvider(PackOutput.Target.RESOURCE_PACK, TrainHatInfoReloadListener.HAT_INFO_DIRECTORY);
|
||||
|
@ -52,11 +52,11 @@ public abstract class TrainHatInfoProvider implements DataProvider {
|
|||
this.trainHatOffsets.clear();
|
||||
this.createOffsets();
|
||||
return CompletableFuture.allOf(
|
||||
this.trainHatOffsets.entrySet().stream().map(entry ->
|
||||
DataProvider.saveStable(output,
|
||||
TrainHatInfo.CODEC.encodeStart(JsonOps.INSTANCE, entry.getValue()).resultOrPartial(Create.LOGGER::error).orElseThrow(),
|
||||
this.path.json(entry.getKey()))
|
||||
).toArray(CompletableFuture[]::new));
|
||||
this.trainHatOffsets.entrySet().stream().map(entry ->
|
||||
DataProvider.saveStable(output,
|
||||
TrainHatInfo.CODEC.encodeStart(JsonOps.INSTANCE, entry.getValue()).resultOrPartial(Create.LOGGER::error).orElseThrow(),
|
||||
this.path.json(entry.getKey()))
|
||||
).toArray(CompletableFuture[]::new));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -26,8 +26,8 @@ import net.minecraftforge.eventbus.api.GenericEvent;
|
|||
*/
|
||||
public class BlockEntityBehaviourEvent<T extends SmartBlockEntity> extends GenericEvent<T> {
|
||||
|
||||
private T smartBlockEntity;
|
||||
private Map<BehaviourType<?>, BlockEntityBehaviour> behaviours;
|
||||
private final T smartBlockEntity;
|
||||
private final Map<BehaviourType<?>, BlockEntityBehaviour> behaviours;
|
||||
|
||||
public BlockEntityBehaviourEvent(T blockEntity, Map<BehaviourType<?>, BlockEntityBehaviour> behaviours) {
|
||||
smartBlockEntity = blockEntity;
|
||||
|
|
|
@ -18,15 +18,14 @@ import net.minecraftforge.eventbus.api.Event;
|
|||
*/
|
||||
public class PipeCollisionEvent extends Event {
|
||||
|
||||
protected final Fluid firstFluid, secondFluid;
|
||||
private final Level level;
|
||||
private final BlockPos pos;
|
||||
protected final Fluid firstFluid, secondFluid;
|
||||
|
||||
@Nullable
|
||||
private BlockState state;
|
||||
|
||||
protected PipeCollisionEvent(Level level, BlockPos pos, Fluid firstFluid, Fluid secondFluid,
|
||||
@Nullable BlockState defaultState) {
|
||||
@Nullable BlockState defaultState) {
|
||||
this.level = level;
|
||||
this.pos = pos;
|
||||
this.firstFluid = firstFluid;
|
||||
|
|
|
@ -4,18 +4,19 @@ import com.simibubi.create.content.trains.graph.TrackGraph;
|
|||
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
public class TrackGraphMergeEvent extends Event{
|
||||
private TrackGraph mergedInto, mergedFrom;
|
||||
|
||||
public class TrackGraphMergeEvent extends Event {
|
||||
private final TrackGraph mergedInto;
|
||||
private final TrackGraph mergedFrom;
|
||||
|
||||
public TrackGraphMergeEvent(TrackGraph from, TrackGraph into) {
|
||||
mergedInto = into;
|
||||
mergedFrom = from;
|
||||
}
|
||||
|
||||
|
||||
public TrackGraph getGraphMergedInto() {
|
||||
return mergedInto;
|
||||
}
|
||||
|
||||
|
||||
public TrackGraph getGraphMergedFrom() {
|
||||
return mergedFrom;
|
||||
}
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
package com.simibubi.create.api.schematic.nbt;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
public interface IPartialSafeNBT {
|
||||
/** This will always be called from the logical server */
|
||||
/**
|
||||
* This will always be called from the logical server
|
||||
*/
|
||||
void writeSafe(CompoundTag compound);
|
||||
}
|
||||
|
|
|
@ -16,10 +16,10 @@ public class SchematicSafeNBTRegistry {
|
|||
* Register a new partial safe nbt provider for a specific blockEntityType
|
||||
*
|
||||
* @param blockEntityType The block entity type you would like to register this for
|
||||
* @param safeNBT The custom PartialSafeNBT provider you would like to register for this blockEntityType,
|
||||
* your {@link ContextProvidingPartialSafeNBT#writeSafe(BlockEntity, CompoundTag)} method will be
|
||||
* called on the passed {@link ContextProvidingPartialSafeNBT}
|
||||
* when the block entities data is being prepared for placement.
|
||||
* @param safeNBT The custom PartialSafeNBT provider you would like to register for this blockEntityType,
|
||||
* your {@link ContextProvidingPartialSafeNBT#writeSafe(BlockEntity, CompoundTag)} method will be
|
||||
* called on the passed {@link ContextProvidingPartialSafeNBT}
|
||||
* when the block entities data is being prepared for placement.
|
||||
*/
|
||||
public static void register(BlockEntityType<? extends BlockEntity> blockEntityType, ContextProvidingPartialSafeNBT safeNBT) {
|
||||
SchematicSafeNBTRegistryImpl.register(blockEntityType, safeNBT);
|
||||
|
@ -29,7 +29,9 @@ public class SchematicSafeNBTRegistry {
|
|||
|
||||
@FunctionalInterface
|
||||
public interface ContextProvidingPartialSafeNBT {
|
||||
/** This will always be called from the logical server */
|
||||
/**
|
||||
* This will always be called from the logical server
|
||||
*/
|
||||
void writeSafe(BlockEntity blockEntity, CompoundTag tag);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.simibubi.create.api.schematic.requirement;
|
||||
|
||||
import com.simibubi.create.content.schematics.requirement.ItemRequirement;
|
||||
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.simibubi.create.api.schematic.requirement;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.simibubi.create.content.schematics.requirement.ItemRequirement;
|
||||
import com.simibubi.create.impl.schematic.requirement.SchematicRequirementsRegistryImpl;
|
||||
|
||||
|
@ -11,8 +13,6 @@ import net.minecraft.world.level.block.entity.BlockEntity;
|
|||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Registry for schematic requirements for blocks, block entities, and entities.
|
||||
*/
|
||||
|
@ -22,7 +22,7 @@ public class SchematicRequirementsRegistry {
|
|||
*
|
||||
* @param block The block you want to register a {@link BlockRequirement} for
|
||||
* @param requirement The requirement you would like to add to this block,
|
||||
* the {@link BlockRequirement#getRequiredItems(BlockState, BlockEntity)}
|
||||
* the {@link BlockRequirement#getRequiredItems(Block, BlockState, BlockEntity)}
|
||||
* method will be called on the {@link BlockRequirement} you have provided,
|
||||
* and you will be able to insert requirements based off the context that is given
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.simibubi.create.impl.schematic.nbt;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import com.simibubi.create.api.schematic.nbt.SchematicSafeNBTRegistry;
|
||||
import com.simibubi.create.foundation.utility.AttachedRegistry;
|
||||
|
||||
|
@ -7,8 +9,6 @@ import net.minecraft.world.level.block.entity.BlockEntity;
|
|||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public class SchematicSafeNBTRegistryImpl {
|
||||
private static final AttachedRegistry<BlockEntityType<?>, SchematicSafeNBTRegistry.ContextProvidingPartialSafeNBT> BLOCK_ENTITY_PARTIAL_SAFE_NBT = new AttachedRegistry<>(ForgeRegistries.BLOCK_ENTITY_TYPES);
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
package com.simibubi.create.impl.schematic.requirement;
|
||||
|
||||
import com.simibubi.create.api.schematic.requirement.SchematicRequirementsRegistry;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import com.simibubi.create.api.schematic.requirement.SchematicRequirementsRegistry;
|
||||
import com.simibubi.create.foundation.utility.AttachedRegistry;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -10,11 +11,8 @@ import net.minecraft.world.entity.EntityType;
|
|||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public class SchematicRequirementsRegistryImpl {
|
||||
private static final AttachedRegistry<Block, SchematicRequirementsRegistry.BlockRequirement> BLOCK_REQUIREMENTS = new AttachedRegistry<>(ForgeRegistries.BLOCKS);
|
||||
|
|
Loading…
Add table
Reference in a new issue