Merge pull request #11 from Creators-of-Create/jay/mc1.20.1/remove-none-type

This commit is contained in:
IThundxr 2025-02-20 09:42:19 -05:00 committed by GitHub
commit 6b77eddbf1
Failed to generate hash of commit
6 changed files with 23 additions and 23 deletions

View file

@ -81,8 +81,10 @@ public class TransportedItemStack implements Comparable<TransportedItemStack> {
nbt.putInt("Angle", angle);
nbt.putInt("InDirection", insertedFrom.get3DDataValue());
if (processedBy != null && processedBy != AllFanProcessingTypes.NONE) {
if (processedBy != null) {
ResourceLocation key = CreateBuiltInRegistries.FAN_PROCESSING_TYPE.getKey(processedBy);
if (key == null)
throw new IllegalArgumentException("Could not get id for FanProcessingType " + processedBy + "!");
nbt.putString("FanProcessingType", key.toString());
nbt.putInt("FanProcessingTime", processingTime);

View file

@ -5,12 +5,12 @@ import java.util.Iterator;
import java.util.List;
import org.apache.commons.lang3.tuple.Pair;
import org.jetbrains.annotations.Nullable;
import com.simibubi.create.AllTags;
import com.simibubi.create.content.decoration.copycat.CopycatBlock;
import com.simibubi.create.content.kinetics.belt.behaviour.TransportedItemStackHandlerBehaviour;
import com.simibubi.create.content.kinetics.belt.behaviour.TransportedItemStackHandlerBehaviour.TransportedResult;
import com.simibubi.create.content.kinetics.fan.processing.AllFanProcessingTypes;
import com.simibubi.create.content.kinetics.fan.processing.FanProcessing;
import com.simibubi.create.content.kinetics.fan.processing.FanProcessingType;
import com.simibubi.create.foundation.advancement.AllAdvancements;
@ -108,7 +108,7 @@ public class AirCurrent {
FanProcessingType processingType = getTypeAt((float) entityDistance);
if (processingType == AllFanProcessingTypes.NONE)
if (processingType == null)
continue;
if (entity instanceof ItemEntity itemEntity) {
@ -140,7 +140,7 @@ public class AirCurrent {
TransportedItemStackHandlerBehaviour handler = pair.getKey();
Level world = handler.getWorld();
FanProcessingType processingType = pair.getRight();
if (processingType == AllFanProcessingTypes.NONE)
if (processingType == null)
continue;
handler.handleProcessingOnAllItems(transported -> {
@ -178,7 +178,7 @@ public class AirCurrent {
// Determine segments with transported fluids/gases
segments.clear();
AirCurrentSegment currentSegment = null;
FanProcessingType type = AllFanProcessingTypes.NONE;
FanProcessingType type = null;
int limit = getLimit();
int searchStart = pushing ? 1 : limit;
@ -189,7 +189,7 @@ public class AirCurrent {
for (int i = searchStart; i * searchStep <= searchEnd * searchStep; i += searchStep) {
BlockPos currentPos = start.relative(direction, i);
FanProcessingType newType = FanProcessingType.getAt(world, currentPos);
if (newType != AllFanProcessingTypes.NONE) {
if (newType != null) {
type = newType;
}
if (currentSegment == null) {
@ -322,7 +322,7 @@ public class AirCurrent {
BlockEntityBehaviour.get(world, pos, TransportedItemStackHandlerBehaviour.TYPE);
if (behaviour != null) {
FanProcessingType type = FanProcessingType.getAt(world, pos);
if (type == AllFanProcessingTypes.NONE)
if (type == null)
type = segmentType;
affectedItemHandlers.add(Pair.of(behaviour, type));
}
@ -339,6 +339,7 @@ public class AirCurrent {
.getEntities(null, bounds);
}
@Nullable
public FanProcessingType getTypeAt(float offset) {
if (offset >= 0 && offset <= maxDistance) {
if (pushing) {
@ -355,10 +356,11 @@ public class AirCurrent {
}
}
}
return AllFanProcessingTypes.NONE;
return null;
}
private static class AirCurrentSegment {
@Nullable
private FanProcessingType type;
private int startOffset;
private int endOffset;

View file

@ -1,8 +1,8 @@
package com.simibubi.create.content.kinetics.fan;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import com.simibubi.create.content.kinetics.fan.processing.AllFanProcessingTypes;
import com.simibubi.create.content.kinetics.fan.processing.FanProcessingType;
import net.createmod.catnip.math.VecHelper;
@ -78,7 +78,7 @@ public class AirFlowParticle extends SimpleAnimatedParticle {
motion = motion.scale(airCurrent.maxDistance - (distance - 1f)).scale(.5f);
FanProcessingType type = getType(distance);
if (type == AllFanProcessingTypes.NONE) {
if (type == null) {
setColor(0xEEEEEE);
setAlpha(.25f);
selectSprite((int) Mth.clamp((distance / airCurrent.maxDistance) * 8 + random.nextInt(4),
@ -100,9 +100,10 @@ public class AirFlowParticle extends SimpleAnimatedParticle {
}
}
@Nullable
private FanProcessingType getType(double distance) {
if (source.getAirCurrent() == null)
return AllFanProcessingTypes.NONE;
return null;
return source.getAirCurrent().getTypeAt((float) distance);
}

View file

@ -62,7 +62,6 @@ import net.minecraftforge.registries.DeferredRegister;
public class AllFanProcessingTypes {
private static final DeferredRegister<FanProcessingType> REGISTER = DeferredRegister.create(CreateRegistries.FAN_PROCESSING_TYPE, Create.ID);
public static final NoneType NONE = register("none", new NoneType());
public static final BlastingType BLASTING = register("blasting", new BlastingType());
public static final HauntingType HAUNTING = register("haunting", new HauntingType());
public static final SmokingType SMOKING = register("smoking", new SmokingType());
@ -72,7 +71,6 @@ public class AllFanProcessingTypes {
static {
Object2ReferenceOpenHashMap<String, FanProcessingType> map = new Object2ReferenceOpenHashMap<>();
map.put("NONE", NONE);
map.put("BLASTING", BLASTING);
map.put("HAUNTING", HAUNTING);
map.put("SMOKING", SMOKING);
@ -95,6 +93,7 @@ public class AllFanProcessingTypes {
return LEGACY_NAME_MAP.get(name);
}
@Nullable
public static FanProcessingType parseLegacy(String str) {
FanProcessingType type = ofLegacyName(str);
if (type != null) {

View file

@ -96,6 +96,8 @@ public class FanProcessing {
if (!processing.contains("Type") || AllFanProcessingTypes.parseLegacy(processing.getString("Type")) != type) {
ResourceLocation key = CreateBuiltInRegistries.FAN_PROCESSING_TYPE.getKey(type);
if (key == null)
throw new IllegalArgumentException("Could not get id for FanProcessingType " + type + "!");
processing.putString("Type", key.toString());
int timeModifierForStackSize = ((entity.getItem()

View file

@ -31,25 +31,19 @@ public interface FanProcessingType {
void affectEntity(Entity entity, Level level);
@Nullable
static FanProcessingType parse(String str) {
ResourceLocation id = ResourceLocation.tryParse(str);
if (id == null) {
return AllFanProcessingTypes.NONE;
}
FanProcessingType type = CreateBuiltInRegistries.FAN_PROCESSING_TYPE.get(id);
if (type == null) {
return AllFanProcessingTypes.NONE;
}
return type;
return CreateBuiltInRegistries.FAN_PROCESSING_TYPE.get(ResourceLocation.tryParse(str));
}
@Nullable
static FanProcessingType getAt(Level level, BlockPos pos) {
for (FanProcessingType type : FanProcessingTypeRegistry.getSortedTypesView()) {
if (type.isValidAt(level, pos)) {
return type;
}
}
return AllFanProcessingTypes.NONE;
return null;
}
interface AirFlowParticleAccess {