mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-03-04 06:44:40 +01:00
Merge pull request #11 from Creators-of-Create/jay/mc1.20.1/remove-none-type
This commit is contained in:
commit
6b77eddbf1
6 changed files with 23 additions and 23 deletions
|
@ -81,8 +81,10 @@ public class TransportedItemStack implements Comparable<TransportedItemStack> {
|
||||||
nbt.putInt("Angle", angle);
|
nbt.putInt("Angle", angle);
|
||||||
nbt.putInt("InDirection", insertedFrom.get3DDataValue());
|
nbt.putInt("InDirection", insertedFrom.get3DDataValue());
|
||||||
|
|
||||||
if (processedBy != null && processedBy != AllFanProcessingTypes.NONE) {
|
if (processedBy != null) {
|
||||||
ResourceLocation key = CreateBuiltInRegistries.FAN_PROCESSING_TYPE.getKey(processedBy);
|
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.putString("FanProcessingType", key.toString());
|
||||||
nbt.putInt("FanProcessingTime", processingTime);
|
nbt.putInt("FanProcessingTime", processingTime);
|
||||||
|
|
|
@ -5,12 +5,12 @@ import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.simibubi.create.AllTags;
|
import com.simibubi.create.AllTags;
|
||||||
import com.simibubi.create.content.decoration.copycat.CopycatBlock;
|
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;
|
||||||
import com.simibubi.create.content.kinetics.belt.behaviour.TransportedItemStackHandlerBehaviour.TransportedResult;
|
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.FanProcessing;
|
||||||
import com.simibubi.create.content.kinetics.fan.processing.FanProcessingType;
|
import com.simibubi.create.content.kinetics.fan.processing.FanProcessingType;
|
||||||
import com.simibubi.create.foundation.advancement.AllAdvancements;
|
import com.simibubi.create.foundation.advancement.AllAdvancements;
|
||||||
|
@ -108,7 +108,7 @@ public class AirCurrent {
|
||||||
|
|
||||||
FanProcessingType processingType = getTypeAt((float) entityDistance);
|
FanProcessingType processingType = getTypeAt((float) entityDistance);
|
||||||
|
|
||||||
if (processingType == AllFanProcessingTypes.NONE)
|
if (processingType == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (entity instanceof ItemEntity itemEntity) {
|
if (entity instanceof ItemEntity itemEntity) {
|
||||||
|
@ -140,7 +140,7 @@ public class AirCurrent {
|
||||||
TransportedItemStackHandlerBehaviour handler = pair.getKey();
|
TransportedItemStackHandlerBehaviour handler = pair.getKey();
|
||||||
Level world = handler.getWorld();
|
Level world = handler.getWorld();
|
||||||
FanProcessingType processingType = pair.getRight();
|
FanProcessingType processingType = pair.getRight();
|
||||||
if (processingType == AllFanProcessingTypes.NONE)
|
if (processingType == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
handler.handleProcessingOnAllItems(transported -> {
|
handler.handleProcessingOnAllItems(transported -> {
|
||||||
|
@ -178,7 +178,7 @@ public class AirCurrent {
|
||||||
// Determine segments with transported fluids/gases
|
// Determine segments with transported fluids/gases
|
||||||
segments.clear();
|
segments.clear();
|
||||||
AirCurrentSegment currentSegment = null;
|
AirCurrentSegment currentSegment = null;
|
||||||
FanProcessingType type = AllFanProcessingTypes.NONE;
|
FanProcessingType type = null;
|
||||||
|
|
||||||
int limit = getLimit();
|
int limit = getLimit();
|
||||||
int searchStart = pushing ? 1 : limit;
|
int searchStart = pushing ? 1 : limit;
|
||||||
|
@ -189,7 +189,7 @@ public class AirCurrent {
|
||||||
for (int i = searchStart; i * searchStep <= searchEnd * searchStep; i += searchStep) {
|
for (int i = searchStart; i * searchStep <= searchEnd * searchStep; i += searchStep) {
|
||||||
BlockPos currentPos = start.relative(direction, i);
|
BlockPos currentPos = start.relative(direction, i);
|
||||||
FanProcessingType newType = FanProcessingType.getAt(world, currentPos);
|
FanProcessingType newType = FanProcessingType.getAt(world, currentPos);
|
||||||
if (newType != AllFanProcessingTypes.NONE) {
|
if (newType != null) {
|
||||||
type = newType;
|
type = newType;
|
||||||
}
|
}
|
||||||
if (currentSegment == null) {
|
if (currentSegment == null) {
|
||||||
|
@ -322,7 +322,7 @@ public class AirCurrent {
|
||||||
BlockEntityBehaviour.get(world, pos, TransportedItemStackHandlerBehaviour.TYPE);
|
BlockEntityBehaviour.get(world, pos, TransportedItemStackHandlerBehaviour.TYPE);
|
||||||
if (behaviour != null) {
|
if (behaviour != null) {
|
||||||
FanProcessingType type = FanProcessingType.getAt(world, pos);
|
FanProcessingType type = FanProcessingType.getAt(world, pos);
|
||||||
if (type == AllFanProcessingTypes.NONE)
|
if (type == null)
|
||||||
type = segmentType;
|
type = segmentType;
|
||||||
affectedItemHandlers.add(Pair.of(behaviour, type));
|
affectedItemHandlers.add(Pair.of(behaviour, type));
|
||||||
}
|
}
|
||||||
|
@ -339,6 +339,7 @@ public class AirCurrent {
|
||||||
.getEntities(null, bounds);
|
.getEntities(null, bounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public FanProcessingType getTypeAt(float offset) {
|
public FanProcessingType getTypeAt(float offset) {
|
||||||
if (offset >= 0 && offset <= maxDistance) {
|
if (offset >= 0 && offset <= maxDistance) {
|
||||||
if (pushing) {
|
if (pushing) {
|
||||||
|
@ -355,10 +356,11 @@ public class AirCurrent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return AllFanProcessingTypes.NONE;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class AirCurrentSegment {
|
private static class AirCurrentSegment {
|
||||||
|
@Nullable
|
||||||
private FanProcessingType type;
|
private FanProcessingType type;
|
||||||
private int startOffset;
|
private int startOffset;
|
||||||
private int endOffset;
|
private int endOffset;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package com.simibubi.create.content.kinetics.fan;
|
package com.simibubi.create.content.kinetics.fan;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
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 com.simibubi.create.content.kinetics.fan.processing.FanProcessingType;
|
||||||
|
|
||||||
import net.createmod.catnip.math.VecHelper;
|
import net.createmod.catnip.math.VecHelper;
|
||||||
|
@ -78,7 +78,7 @@ public class AirFlowParticle extends SimpleAnimatedParticle {
|
||||||
motion = motion.scale(airCurrent.maxDistance - (distance - 1f)).scale(.5f);
|
motion = motion.scale(airCurrent.maxDistance - (distance - 1f)).scale(.5f);
|
||||||
|
|
||||||
FanProcessingType type = getType(distance);
|
FanProcessingType type = getType(distance);
|
||||||
if (type == AllFanProcessingTypes.NONE) {
|
if (type == null) {
|
||||||
setColor(0xEEEEEE);
|
setColor(0xEEEEEE);
|
||||||
setAlpha(.25f);
|
setAlpha(.25f);
|
||||||
selectSprite((int) Mth.clamp((distance / airCurrent.maxDistance) * 8 + random.nextInt(4),
|
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) {
|
private FanProcessingType getType(double distance) {
|
||||||
if (source.getAirCurrent() == null)
|
if (source.getAirCurrent() == null)
|
||||||
return AllFanProcessingTypes.NONE;
|
return null;
|
||||||
return source.getAirCurrent().getTypeAt((float) distance);
|
return source.getAirCurrent().getTypeAt((float) distance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,6 @@ import net.minecraftforge.registries.DeferredRegister;
|
||||||
public class AllFanProcessingTypes {
|
public class AllFanProcessingTypes {
|
||||||
private static final DeferredRegister<FanProcessingType> REGISTER = DeferredRegister.create(CreateRegistries.FAN_PROCESSING_TYPE, Create.ID);
|
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 BlastingType BLASTING = register("blasting", new BlastingType());
|
||||||
public static final HauntingType HAUNTING = register("haunting", new HauntingType());
|
public static final HauntingType HAUNTING = register("haunting", new HauntingType());
|
||||||
public static final SmokingType SMOKING = register("smoking", new SmokingType());
|
public static final SmokingType SMOKING = register("smoking", new SmokingType());
|
||||||
|
@ -72,7 +71,6 @@ public class AllFanProcessingTypes {
|
||||||
|
|
||||||
static {
|
static {
|
||||||
Object2ReferenceOpenHashMap<String, FanProcessingType> map = new Object2ReferenceOpenHashMap<>();
|
Object2ReferenceOpenHashMap<String, FanProcessingType> map = new Object2ReferenceOpenHashMap<>();
|
||||||
map.put("NONE", NONE);
|
|
||||||
map.put("BLASTING", BLASTING);
|
map.put("BLASTING", BLASTING);
|
||||||
map.put("HAUNTING", HAUNTING);
|
map.put("HAUNTING", HAUNTING);
|
||||||
map.put("SMOKING", SMOKING);
|
map.put("SMOKING", SMOKING);
|
||||||
|
@ -95,6 +93,7 @@ public class AllFanProcessingTypes {
|
||||||
return LEGACY_NAME_MAP.get(name);
|
return LEGACY_NAME_MAP.get(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public static FanProcessingType parseLegacy(String str) {
|
public static FanProcessingType parseLegacy(String str) {
|
||||||
FanProcessingType type = ofLegacyName(str);
|
FanProcessingType type = ofLegacyName(str);
|
||||||
if (type != null) {
|
if (type != null) {
|
||||||
|
|
|
@ -96,6 +96,8 @@ public class FanProcessing {
|
||||||
|
|
||||||
if (!processing.contains("Type") || AllFanProcessingTypes.parseLegacy(processing.getString("Type")) != type) {
|
if (!processing.contains("Type") || AllFanProcessingTypes.parseLegacy(processing.getString("Type")) != type) {
|
||||||
ResourceLocation key = CreateBuiltInRegistries.FAN_PROCESSING_TYPE.getKey(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());
|
processing.putString("Type", key.toString());
|
||||||
int timeModifierForStackSize = ((entity.getItem()
|
int timeModifierForStackSize = ((entity.getItem()
|
||||||
|
|
|
@ -31,25 +31,19 @@ public interface FanProcessingType {
|
||||||
|
|
||||||
void affectEntity(Entity entity, Level level);
|
void affectEntity(Entity entity, Level level);
|
||||||
|
|
||||||
|
@Nullable
|
||||||
static FanProcessingType parse(String str) {
|
static FanProcessingType parse(String str) {
|
||||||
ResourceLocation id = ResourceLocation.tryParse(str);
|
return CreateBuiltInRegistries.FAN_PROCESSING_TYPE.get(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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
static FanProcessingType getAt(Level level, BlockPos pos) {
|
static FanProcessingType getAt(Level level, BlockPos pos) {
|
||||||
for (FanProcessingType type : FanProcessingTypeRegistry.getSortedTypesView()) {
|
for (FanProcessingType type : FanProcessingTypeRegistry.getSortedTypesView()) {
|
||||||
if (type.isValidAt(level, pos)) {
|
if (type.isValidAt(level, pos)) {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return AllFanProcessingTypes.NONE;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface AirFlowParticleAccess {
|
interface AirFlowParticleAccess {
|
||||||
|
|
Loading…
Add table
Reference in a new issue