mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2024-11-13 05:54:01 +01:00
better fan stream advancement trigger
This commit is contained in:
parent
d0357df863
commit
5b65a5d78b
@ -337,7 +337,7 @@ e8b0a401c10d1ba67ed71ba31bd5f9bc28571b65 assets/create/blockstates/powered_toggl
|
||||
d06cd9a1101b18d306a786320aab12018b1325d6 assets/create/blockstates/purple_sail.json
|
||||
92957119abd5fbcca36a113b2a80255fd70fc303 assets/create/blockstates/purple_seat.json
|
||||
61035f8afe75ff7bbd291da5d8690bcbebe679eb assets/create/blockstates/purple_valve_handle.json
|
||||
8d7e653bfd9846e684a0d3725595714a19201017 assets/create/blockstates/radial_chassis.json
|
||||
143d66a7262ccd29f36784d6b064d4a13ba374b6 assets/create/blockstates/radial_chassis.json
|
||||
45877c4d90a7185c2f304edbd67379d800920439 assets/create/blockstates/red_sail.json
|
||||
da1b08387af7afa0855ee8d040f620c01f20660a assets/create/blockstates/red_seat.json
|
||||
722fc77bbf387af8a4016e42cbf9501d2b968881 assets/create/blockstates/red_valve_handle.json
|
||||
@ -1616,10 +1616,10 @@ d1fbc14303c7327e9fc02e505e7e434591b7f785 data/create/advancements/crushing_wheel
|
||||
77edd30e3d60b4d492662c673387910f66b5a276 data/create/advancements/dual_extendo_grip.json
|
||||
04eaf829696d735244c0e4798dd3bdeb26e13a32 data/create/advancements/electron_tube.json
|
||||
b78fe4e539fef1b3419f2eb4d1db47cb4a201992 data/create/advancements/extendo_grip.json
|
||||
4dbbf5f39441fdfe0561022ea7bbaa8e1f9733b7 data/create/advancements/fan.json
|
||||
9e2369129a52ffb4c67907ca5e81e342766f7867 data/create/advancements/fan_lava.json
|
||||
acef16596b7ae82aaf853142d69bcea7094b8173 data/create/advancements/fan_smoke.json
|
||||
36f72396d1b4ac9a89f4a9139fa10ed659f5954a data/create/advancements/fan_water.json
|
||||
b1699baaadaac7ebce642c09428519d156e21594 data/create/advancements/fan.json
|
||||
5aa76cba3b40a1c234ffa84a89ecca630990fc0f data/create/advancements/fan_lava.json
|
||||
716a9816558300a3652ed8d8d568517017813f5c data/create/advancements/fan_smoke.json
|
||||
a61eb63d02604e88836519f89f74b252a640d485 data/create/advancements/fan_water.json
|
||||
69e96e926a4d72e59cc6390c25f064166ddb62d2 data/create/advancements/fist_bump.json
|
||||
99ee1bf5390b9a4f2a2419c78f259ff5d2ab9ae9 data/create/advancements/flywheel.json
|
||||
489c58a0508a2a41cc0849dfb933eb5ac96ef364 data/create/advancements/glass_pipe.json
|
||||
|
@ -29,8 +29,8 @@
|
||||
},
|
||||
{
|
||||
"when": {
|
||||
"sticky_south": "true",
|
||||
"axis": "x"
|
||||
"axis": "x",
|
||||
"sticky_south": "true"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/radial_chassis_side_x_sticky",
|
||||
@ -39,8 +39,8 @@
|
||||
},
|
||||
{
|
||||
"when": {
|
||||
"sticky_south": "true",
|
||||
"axis": "y"
|
||||
"axis": "y",
|
||||
"sticky_south": "true"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/radial_chassis_side_y_sticky"
|
||||
@ -48,8 +48,8 @@
|
||||
},
|
||||
{
|
||||
"when": {
|
||||
"sticky_south": "true",
|
||||
"axis": "z"
|
||||
"axis": "z",
|
||||
"sticky_south": "true"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/radial_chassis_side_x_sticky",
|
||||
@ -59,8 +59,8 @@
|
||||
},
|
||||
{
|
||||
"when": {
|
||||
"sticky_south": "false",
|
||||
"axis": "x"
|
||||
"axis": "x",
|
||||
"sticky_south": "false"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/radial_chassis_side_x",
|
||||
@ -69,8 +69,8 @@
|
||||
},
|
||||
{
|
||||
"when": {
|
||||
"sticky_south": "false",
|
||||
"axis": "y"
|
||||
"axis": "y",
|
||||
"sticky_south": "false"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/radial_chassis_side_y"
|
||||
@ -78,8 +78,8 @@
|
||||
},
|
||||
{
|
||||
"when": {
|
||||
"sticky_south": "false",
|
||||
"axis": "z"
|
||||
"axis": "z",
|
||||
"sticky_south": "false"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/radial_chassis_side_x",
|
||||
@ -89,8 +89,8 @@
|
||||
},
|
||||
{
|
||||
"when": {
|
||||
"sticky_west": "true",
|
||||
"axis": "x"
|
||||
"axis": "x",
|
||||
"sticky_west": "true"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/radial_chassis_side_x_sticky",
|
||||
@ -99,8 +99,8 @@
|
||||
},
|
||||
{
|
||||
"when": {
|
||||
"sticky_west": "true",
|
||||
"axis": "y"
|
||||
"axis": "y",
|
||||
"sticky_west": "true"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/radial_chassis_side_y_sticky",
|
||||
@ -109,8 +109,8 @@
|
||||
},
|
||||
{
|
||||
"when": {
|
||||
"sticky_west": "true",
|
||||
"axis": "z"
|
||||
"axis": "z",
|
||||
"sticky_west": "true"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/radial_chassis_side_z_sticky",
|
||||
@ -119,8 +119,8 @@
|
||||
},
|
||||
{
|
||||
"when": {
|
||||
"sticky_west": "false",
|
||||
"axis": "x"
|
||||
"axis": "x",
|
||||
"sticky_west": "false"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/radial_chassis_side_x",
|
||||
@ -129,8 +129,8 @@
|
||||
},
|
||||
{
|
||||
"when": {
|
||||
"sticky_west": "false",
|
||||
"axis": "y"
|
||||
"axis": "y",
|
||||
"sticky_west": "false"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/radial_chassis_side_y",
|
||||
@ -139,8 +139,8 @@
|
||||
},
|
||||
{
|
||||
"when": {
|
||||
"sticky_west": "false",
|
||||
"axis": "z"
|
||||
"axis": "z",
|
||||
"sticky_west": "false"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/radial_chassis_side_z",
|
||||
|
@ -17,7 +17,12 @@
|
||||
},
|
||||
"criteria": {
|
||||
"0": {
|
||||
"trigger": "create:fan"
|
||||
"trigger": "create:fan_processing",
|
||||
"conditions": {
|
||||
"accepted_entries": [
|
||||
"NONE"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"requirements": [
|
||||
|
@ -17,7 +17,12 @@
|
||||
},
|
||||
"criteria": {
|
||||
"0": {
|
||||
"trigger": "create:fan_lava"
|
||||
"trigger": "create:fan_processing",
|
||||
"conditions": {
|
||||
"accepted_entries": [
|
||||
"BLASTING"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"requirements": [
|
||||
|
@ -17,7 +17,12 @@
|
||||
},
|
||||
"criteria": {
|
||||
"0": {
|
||||
"trigger": "create:fan_smoke"
|
||||
"trigger": "create:fan_processing",
|
||||
"conditions": {
|
||||
"accepted_entries": [
|
||||
"SMOKING"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"requirements": [
|
||||
|
@ -17,7 +17,12 @@
|
||||
},
|
||||
"criteria": {
|
||||
"0": {
|
||||
"trigger": "create:fan_water"
|
||||
"trigger": "create:fan_processing",
|
||||
"conditions": {
|
||||
"accepted_entries": [
|
||||
"SPLASHING"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"requirements": [
|
||||
|
@ -114,9 +114,10 @@ public class AirCurrent {
|
||||
|
||||
entityDistance -= .5f;
|
||||
InWorldProcessing.Type processingType = getSegmentAt((float) entityDistance);
|
||||
if (processingType == null) {
|
||||
if (entity instanceof ServerPlayerEntity)
|
||||
AllTriggers.triggerFor(AllTriggers.FAN, (PlayerEntity) entity);
|
||||
if (entity instanceof ServerPlayerEntity)
|
||||
AllTriggers.triggerFor(AllTriggers.FAN_PROCESSING.constructTriggerFor(processingType), (PlayerEntity) entity);
|
||||
|
||||
if (processingType == null || processingType == Type.NONE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -139,24 +140,18 @@ public class AirCurrent {
|
||||
entity.setFire(10);
|
||||
entity.attackEntityFrom(damageSourceLava, 4);
|
||||
}
|
||||
if (entity instanceof ServerPlayerEntity)
|
||||
AllTriggers.triggerFor(AllTriggers.FAN_LAVA, (PlayerEntity) entity);
|
||||
break;
|
||||
case SMOKING:
|
||||
if (!entity.isImmuneToFire()) {
|
||||
entity.setFire(2);
|
||||
entity.attackEntityFrom(damageSourceFire, 2);
|
||||
}
|
||||
if (entity instanceof ServerPlayerEntity)
|
||||
AllTriggers.triggerFor(AllTriggers.FAN_SMOKE, (PlayerEntity) entity);
|
||||
break;
|
||||
case SPLASHING:
|
||||
if (entity instanceof EndermanEntity || entity.getType() == EntityType.SNOW_GOLEM
|
||||
|| entity.getType() == EntityType.BLAZE) {
|
||||
entity.attackEntityFrom(DamageSource.DROWN, 2);
|
||||
}
|
||||
if (entity instanceof ServerPlayerEntity)
|
||||
AllTriggers.triggerFor(AllTriggers.FAN_WATER, (PlayerEntity) entity);
|
||||
if (!entity.isBurning())
|
||||
break;
|
||||
entity.extinguish();
|
||||
@ -193,7 +188,7 @@ public class AirCurrent {
|
||||
AirCurrentSegment currentSegment = new AirCurrentSegment();
|
||||
segments.clear();
|
||||
currentSegment.startOffset = 0;
|
||||
InWorldProcessing.Type type = null;
|
||||
InWorldProcessing.Type type = Type.NONE;
|
||||
|
||||
int limit = (int) (maxDistance + .5f);
|
||||
int searchStart = pushing ? 0 : limit;
|
||||
@ -203,7 +198,7 @@ public class AirCurrent {
|
||||
for (int i = searchStart; i * searchStep <= searchEnd * searchStep; i += searchStep) {
|
||||
BlockPos currentPos = start.offset(direction, i);
|
||||
InWorldProcessing.Type newType = InWorldProcessing.Type.byBlock(world, currentPos);
|
||||
if (newType != null)
|
||||
if (newType != Type.NONE)
|
||||
type = newType;
|
||||
if (currentSegment.type != type || currentSegment.startOffset == 0) {
|
||||
currentSegment.endOffset = i;
|
||||
@ -341,7 +336,7 @@ public class AirCurrent {
|
||||
continue;
|
||||
return airCurrentSegment.type;
|
||||
}
|
||||
return null;
|
||||
return InWorldProcessing.Type.NONE;
|
||||
}
|
||||
|
||||
public static class AirCurrentSegment {
|
||||
|
@ -58,7 +58,7 @@ public class InWorldProcessing {
|
||||
public static SplashingInv splashingInv = new SplashingInv();
|
||||
|
||||
public enum Type {
|
||||
SMOKING, BLASTING, SPLASHING
|
||||
SMOKING, BLASTING, SPLASHING, NONE
|
||||
|
||||
;
|
||||
|
||||
@ -74,7 +74,7 @@ public class InWorldProcessing {
|
||||
return Type.SMOKING;
|
||||
if (block == Blocks.LAVA || getHeatLevelOf(blockState).isAtLeast(BlazeBurnerBlock.HeatLevel.FADING))
|
||||
return Type.BLASTING;
|
||||
return null;
|
||||
return Type.NONE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.simibubi.create.content.logistics.InWorldProcessing;
|
||||
import net.minecraft.fluid.FlowingFluid;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
@ -125,19 +126,19 @@ public class AllAdvancements implements IDataProvider {
|
||||
.register(t, id + ":press");
|
||||
|
||||
Advancement fan = advancement("fan", AllBlocks.ENCASED_FAN.get(), TaskType.NORMAL).withParent(press)
|
||||
.withCriterion("0", AllTriggers.FAN.instance())
|
||||
.withCriterion("0", AllTriggers.FAN_PROCESSING.forEntries(InWorldProcessing.Type.NONE))
|
||||
.register(t, id + ":fan");
|
||||
|
||||
Advancement fan_lava = advancement("fan_lava", Items.LAVA_BUCKET, TaskType.NORMAL).withParent(fan)
|
||||
.withCriterion("0", AllTriggers.FAN_LAVA.instance())
|
||||
.withCriterion("0", AllTriggers.FAN_PROCESSING.forEntries(InWorldProcessing.Type.BLASTING))
|
||||
.register(t, id + ":fan_lava");
|
||||
|
||||
Advancement fan_smoke = advancement("fan_smoke", Items.CAMPFIRE, TaskType.NORMAL).withParent(fan)
|
||||
.withCriterion("0", AllTriggers.FAN_SMOKE.instance())
|
||||
.withCriterion("0", AllTriggers.FAN_PROCESSING.forEntries(InWorldProcessing.Type.SMOKING))
|
||||
.register(t, id + ":fan_smoke");
|
||||
|
||||
Advancement fan_water = advancement("fan_water", Items.WATER_BUCKET, TaskType.NORMAL).withParent(fan)
|
||||
.withCriterion("0", AllTriggers.FAN_WATER.instance())
|
||||
.withCriterion("0", AllTriggers.FAN_PROCESSING.forEntries(InWorldProcessing.Type.SPLASHING))
|
||||
.register(t, id + ":fan_water");
|
||||
|
||||
Advancement rose_quartz =
|
||||
|
@ -4,6 +4,7 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import com.simibubi.create.content.logistics.InWorldProcessing;
|
||||
import net.minecraft.advancements.CriteriaTriggers;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@ -19,6 +20,7 @@ public class AllTriggers {
|
||||
|
||||
public static RegistryTrigger<Fluid> INFINITE_FLUID = add(new RegistryTrigger<>("infinite_fluid", Fluid.class));
|
||||
public static RegistryTrigger<Block> BRACKET_APPLY_TRIGGER = add(new RegistryTrigger<>("bracket_apply", Block.class));
|
||||
public static EnumTrigger<InWorldProcessing.Type> FAN_PROCESSING = add(new EnumTrigger<>("fan_processing", InWorldProcessing.Type.class));
|
||||
|
||||
public static SimpleTrigger
|
||||
ROTATION = simple("rotation"),
|
||||
@ -47,10 +49,6 @@ public class AllTriggers {
|
||||
PLACE_TUNNEL = simple("place_tunnel"),
|
||||
CONNECT_TUNNEL = simple("connect_tunnel"),
|
||||
UPWARD_CHUTE = simple("upward_chute"),
|
||||
FAN = simple("fan"),
|
||||
FAN_LAVA = simple("fan_lava"),
|
||||
FAN_SMOKE = simple("fan_smoke"),
|
||||
FAN_WATER = simple("fan_water"),
|
||||
BELT_FUNNEL = simple("belt_funnel"),
|
||||
BELT_FUNNEL_KISS = simple("belt_funnel_kiss"),
|
||||
CLOCKWORK_BEARING = simple("clockwork_bearing"),
|
||||
|
@ -0,0 +1,35 @@
|
||||
package com.simibubi.create.foundation.advancement;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
public class EnumTrigger<T extends Enum<T>> extends StringSerializableTrigger<T> {
|
||||
private final Class<T> reference;
|
||||
|
||||
public EnumTrigger(String id, Class<T> reference) {
|
||||
super(id);
|
||||
this.reference = reference;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected T getValue(String key) {
|
||||
try {
|
||||
return Enum.valueOf(reference, key);
|
||||
} catch (IllegalArgumentException | NullPointerException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected String getKey(@Nullable T value) {
|
||||
if (value == null)
|
||||
return null;
|
||||
return value.name();
|
||||
}
|
||||
}
|
@ -27,11 +27,11 @@ public abstract class StringSerializableTrigger<T> extends CriterionTriggerBase<
|
||||
return new Instance<>(this, entries == null ? null : Sets.newHashSet(entries));
|
||||
}
|
||||
|
||||
public void trigger(ServerPlayerEntity player, T registryEntry) {
|
||||
public void trigger(ServerPlayerEntity player, @Nullable T registryEntry) {
|
||||
trigger(player, Collections.singletonList(() -> registryEntry));
|
||||
}
|
||||
|
||||
public ITriggerable constructTriggerFor(T entry) {
|
||||
public ITriggerable constructTriggerFor(@Nullable T entry) {
|
||||
BiConsumer<ServerPlayerEntity, T> trigger = this::trigger;
|
||||
return player -> trigger.accept(player, entry);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user