Merge branch 'mc1.15/dev' of https://github.com/Creators-of-Create/Create into mc1.15/dev

This commit is contained in:
simibubi 2021-02-19 16:59:59 +01:00
commit afe2c4497d
25 changed files with 257 additions and 172 deletions

View file

@ -1587,7 +1587,7 @@ d080b1b25e5bc8baf5aee68691b08c7f12ece3b0 assets/create/models/item/windmill_bear
9f9455ccb5fc9e3cbfce73862b46078346a522a5 assets/create/models/item/zinc_nugget.json 9f9455ccb5fc9e3cbfce73862b46078346a522a5 assets/create/models/item/zinc_nugget.json
b1689617190c05ef34bd18456b0c7ae09bb3210f assets/create/models/item/zinc_ore.json b1689617190c05ef34bd18456b0c7ae09bb3210f assets/create/models/item/zinc_ore.json
e76041b7ae829fdd7dc0524f6ca4d2f89fca51bb assets/create/sounds.json e76041b7ae829fdd7dc0524f6ca4d2f89fca51bb assets/create/sounds.json
cb9641eaf33211af46daf57241c76733cf371ed2 data/create/advancements/aesthetics.json 0f1b4b980afba9bf2caf583b88e261bba8b10313 data/create/advancements/aesthetics.json
187921fa131b06721bfaf63f2623a28c141aae9a data/create/advancements/andesite_alloy.json 187921fa131b06721bfaf63f2623a28c141aae9a data/create/advancements/andesite_alloy.json
0ea2db7173b5be28b289ea7c9a6a0cf5805c60c7 data/create/advancements/andesite_casing.json 0ea2db7173b5be28b289ea7c9a6a0cf5805c60c7 data/create/advancements/andesite_casing.json
356f4855a2a6c65be3fb51d7d1aabf2ca6034d42 data/create/advancements/arm_blaze_burner.json 356f4855a2a6c65be3fb51d7d1aabf2ca6034d42 data/create/advancements/arm_blaze_burner.json
@ -1617,18 +1617,18 @@ d1fbc14303c7327e9fc02e505e7e434591b7f785 data/create/advancements/crushing_wheel
77edd30e3d60b4d492662c673387910f66b5a276 data/create/advancements/dual_extendo_grip.json 77edd30e3d60b4d492662c673387910f66b5a276 data/create/advancements/dual_extendo_grip.json
04eaf829696d735244c0e4798dd3bdeb26e13a32 data/create/advancements/electron_tube.json 04eaf829696d735244c0e4798dd3bdeb26e13a32 data/create/advancements/electron_tube.json
b78fe4e539fef1b3419f2eb4d1db47cb4a201992 data/create/advancements/extendo_grip.json b78fe4e539fef1b3419f2eb4d1db47cb4a201992 data/create/advancements/extendo_grip.json
4dbbf5f39441fdfe0561022ea7bbaa8e1f9733b7 data/create/advancements/fan.json b1699baaadaac7ebce642c09428519d156e21594 data/create/advancements/fan.json
9e2369129a52ffb4c67907ca5e81e342766f7867 data/create/advancements/fan_lava.json 5aa76cba3b40a1c234ffa84a89ecca630990fc0f data/create/advancements/fan_lava.json
acef16596b7ae82aaf853142d69bcea7094b8173 data/create/advancements/fan_smoke.json 716a9816558300a3652ed8d8d568517017813f5c data/create/advancements/fan_smoke.json
36f72396d1b4ac9a89f4a9139fa10ed659f5954a data/create/advancements/fan_water.json a61eb63d02604e88836519f89f74b252a640d485 data/create/advancements/fan_water.json
69e96e926a4d72e59cc6390c25f064166ddb62d2 data/create/advancements/fist_bump.json 69e96e926a4d72e59cc6390c25f064166ddb62d2 data/create/advancements/fist_bump.json
99ee1bf5390b9a4f2a2419c78f259ff5d2ab9ae9 data/create/advancements/flywheel.json 99ee1bf5390b9a4f2a2419c78f259ff5d2ab9ae9 data/create/advancements/flywheel.json
489c58a0508a2a41cc0849dfb933eb5ac96ef364 data/create/advancements/glass_pipe.json 489c58a0508a2a41cc0849dfb933eb5ac96ef364 data/create/advancements/glass_pipe.json
62f3610188f7dbd3900ab305edc2d06282705a38 data/create/advancements/goggles.json 62f3610188f7dbd3900ab305edc2d06282705a38 data/create/advancements/goggles.json
10c8686da9cec2ae30c10f434836ac15a1b88666 data/create/advancements/hose_pulley.json 10c8686da9cec2ae30c10f434836ac15a1b88666 data/create/advancements/hose_pulley.json
a8595e5fdf6517e5c9c790afccc99fe9d3dd95aa data/create/advancements/infinite_chocolate.json 9f642faf92b75a28c564e90be8448b9a4328af5e data/create/advancements/infinite_chocolate.json
50460d4470e9630b2d3ae1ec4f24d00d8d7c7e6b data/create/advancements/infinite_lava.json a933fa5e7217e2ffe123ae035cfbc9210ba69fd5 data/create/advancements/infinite_lava.json
19d9794ac08cee962c7c718085d3e3ba5e89a328 data/create/advancements/infinite_water.json a8ab0e4ffba358d23f9efaa9f51245b6d490a8be data/create/advancements/infinite_water.json
9beb622c79e9f5ce2397c22222cac0faf272f388 data/create/advancements/integrated_circuit.json 9beb622c79e9f5ce2397c22222cac0faf272f388 data/create/advancements/integrated_circuit.json
316bed3d8985d0a371200967d7edd2936f1b9f94 data/create/advancements/integrated_circuit_eob.json 316bed3d8985d0a371200967d7edd2936f1b9f94 data/create/advancements/integrated_circuit_eob.json
a80eea863bfdc7777b8bade39a81655b2f99e02f data/create/advancements/item_drain.json a80eea863bfdc7777b8bade39a81655b2f99e02f data/create/advancements/item_drain.json
@ -1639,7 +1639,7 @@ a80eea863bfdc7777b8bade39a81655b2f99e02f data/create/advancements/item_drain.jso
218568a4e416c5fa559c55a5c92aa4e93f88b837 data/create/advancements/mechanical_drill.json 218568a4e416c5fa559c55a5c92aa4e93f88b837 data/create/advancements/mechanical_drill.json
6dc84ad2f0512495fe3f01f99d3c547849351e33 data/create/advancements/mechanical_saw.json 6dc84ad2f0512495fe3f01f99d3c547849351e33 data/create/advancements/mechanical_saw.json
3bc549c06dc6d9568f92e1abc9654c9b4c33f035 data/create/advancements/millstone.json 3bc549c06dc6d9568f92e1abc9654c9b4c33f035 data/create/advancements/millstone.json
6f872e1e8be9d8e5fa378db1384b1de72fadac23 data/create/advancements/mixer.json 238ac410eb4de16a82ae05cc16fef80e55a4b61b data/create/advancements/mixer.json
325d4cef263ce301b143ee0498fb15afdb2c125b data/create/advancements/musical_arm.json 325d4cef263ce301b143ee0498fb15afdb2c125b data/create/advancements/musical_arm.json
c9c4060ed207226b69fada2d61e01a97d7077eae data/create/advancements/nixie_tube.json c9c4060ed207226b69fada2d61e01a97d7077eae data/create/advancements/nixie_tube.json
9329cb210a954c0de1dcf517e7dff1ece77c19c0 data/create/advancements/overstress_flywheel.json 9329cb210a954c0de1dcf517e7dff1ece77c19c0 data/create/advancements/overstress_flywheel.json

View file

@ -149,8 +149,8 @@
}, },
{ {
"when": { "when": {
"axis": "x", "sticky_north": "true",
"sticky_north": "true" "axis": "x"
}, },
"apply": { "apply": {
"model": "create:block/radial_chassis_side_x_sticky" "model": "create:block/radial_chassis_side_x_sticky"
@ -158,8 +158,8 @@
}, },
{ {
"when": { "when": {
"axis": "y", "sticky_north": "true",
"sticky_north": "true" "axis": "y"
}, },
"apply": { "apply": {
"model": "create:block/radial_chassis_side_y_sticky", "model": "create:block/radial_chassis_side_y_sticky",
@ -168,8 +168,8 @@
}, },
{ {
"when": { "when": {
"axis": "z", "sticky_north": "true",
"sticky_north": "true" "axis": "z"
}, },
"apply": { "apply": {
"model": "create:block/radial_chassis_side_x_sticky", "model": "create:block/radial_chassis_side_x_sticky",
@ -178,8 +178,8 @@
}, },
{ {
"when": { "when": {
"axis": "x", "sticky_north": "false",
"sticky_north": "false" "axis": "x"
}, },
"apply": { "apply": {
"model": "create:block/radial_chassis_side_x" "model": "create:block/radial_chassis_side_x"
@ -187,8 +187,8 @@
}, },
{ {
"when": { "when": {
"axis": "y", "sticky_north": "false",
"sticky_north": "false" "axis": "y"
}, },
"apply": { "apply": {
"model": "create:block/radial_chassis_side_y", "model": "create:block/radial_chassis_side_y",
@ -197,8 +197,8 @@
}, },
{ {
"when": { "when": {
"axis": "z", "sticky_north": "false",
"sticky_north": "false" "axis": "z"
}, },
"apply": { "apply": {
"model": "create:block/radial_chassis_side_x", "model": "create:block/radial_chassis_side_x",

View file

@ -17,13 +17,29 @@
}, },
"criteria": { "criteria": {
"0": { "0": {
"trigger": "create:bracket_shaft" "trigger": "create:bracket_apply",
"conditions": {
"accepted_entries": [
"create:shaft"
]
}
}, },
"1": { "1": {
"trigger": "create:bracket_cog" "trigger": "create:bracket_apply",
"conditions": {
"accepted_entries": [
"create:cogwheel",
"create:large_cogwheel"
]
}
}, },
"2": { "2": {
"trigger": "create:bracket_pipe" "trigger": "create:bracket_apply",
"conditions": {
"accepted_entries": [
"create:fluid_pipe"
]
}
} }
}, },
"requirements": [ "requirements": [

View file

@ -17,7 +17,12 @@
}, },
"criteria": { "criteria": {
"0": { "0": {
"trigger": "create:fan" "trigger": "create:fan_processing",
"conditions": {
"accepted_entries": [
"NONE"
]
}
} }
}, },
"requirements": [ "requirements": [

View file

@ -17,7 +17,12 @@
}, },
"criteria": { "criteria": {
"0": { "0": {
"trigger": "create:fan_lava" "trigger": "create:fan_processing",
"conditions": {
"accepted_entries": [
"BLASTING"
]
}
} }
}, },
"requirements": [ "requirements": [

View file

@ -17,7 +17,12 @@
}, },
"criteria": { "criteria": {
"0": { "0": {
"trigger": "create:fan_smoke" "trigger": "create:fan_processing",
"conditions": {
"accepted_entries": [
"SMOKING"
]
}
} }
}, },
"requirements": [ "requirements": [

View file

@ -17,7 +17,12 @@
}, },
"criteria": { "criteria": {
"0": { "0": {
"trigger": "create:fan_water" "trigger": "create:fan_processing",
"conditions": {
"accepted_entries": [
"SPLASHING"
]
}
} }
}, },
"requirements": [ "requirements": [

View file

@ -19,7 +19,9 @@
"0": { "0": {
"trigger": "create:infinite_fluid", "trigger": "create:infinite_fluid",
"conditions": { "conditions": {
"registry_entry": "create:chocolate" "accepted_entries": [
"create:chocolate"
]
} }
} }
}, },

View file

@ -19,7 +19,9 @@
"0": { "0": {
"trigger": "create:infinite_fluid", "trigger": "create:infinite_fluid",
"conditions": { "conditions": {
"registry_entry": "minecraft:lava" "accepted_entries": [
"minecraft:lava"
]
} }
} }
}, },

View file

@ -19,7 +19,9 @@
"0": { "0": {
"trigger": "create:infinite_fluid", "trigger": "create:infinite_fluid",
"conditions": { "conditions": {
"registry_entry": "minecraft:water" "accepted_entries": [
"minecraft:water"
]
} }
} }
}, },

View file

@ -23,12 +23,6 @@
} }
}, },
"1": { "1": {
"trigger": "create:kinetic_block",
"conditions": {
"registry_entry": "create:mechanical_mixer"
}
},
"2": {
"trigger": "create:mixer" "trigger": "create:mixer"
} }
}, },
@ -38,9 +32,6 @@
], ],
[ [
"1" "1"
],
[
"2"
] ]
] ]
} }

View file

@ -173,10 +173,6 @@ public abstract class KineticTileEntity extends SmartTileEntity
boolean directionSwap = !fromOrToZero && Math.signum(previousSpeed) != Math.signum(getSpeed()); boolean directionSwap = !fromOrToZero && Math.signum(previousSpeed) != Math.signum(getSpeed());
if (fromOrToZero || directionSwap) if (fromOrToZero || directionSwap)
flickerTally = getFlickerScore() + 5; flickerTally = getFlickerScore() + 5;
if (fromOrToZero && previousSpeed == 0 && !world.isRemote)
AllTriggers.getPlayersInRange(world, pos, 4)
.forEach(p -> AllTriggers.KINETIC_BLOCK.trigger(p, getBlockState().getBlock()));
} }
@Override @Override

View file

@ -114,9 +114,10 @@ public class AirCurrent {
entityDistance -= .5f; entityDistance -= .5f;
InWorldProcessing.Type processingType = getSegmentAt((float) entityDistance); InWorldProcessing.Type processingType = getSegmentAt((float) entityDistance);
if (processingType == null) { if (entity instanceof ServerPlayerEntity)
if (entity instanceof ServerPlayerEntity) AllTriggers.triggerFor(AllTriggers.FAN_PROCESSING.constructTriggerFor(processingType), (PlayerEntity) entity);
AllTriggers.triggerFor(AllTriggers.FAN, (PlayerEntity) entity);
if (processingType == null || processingType == Type.NONE) {
continue; continue;
} }
@ -139,24 +140,18 @@ public class AirCurrent {
entity.setFire(10); entity.setFire(10);
entity.attackEntityFrom(damageSourceLava, 4); entity.attackEntityFrom(damageSourceLava, 4);
} }
if (entity instanceof ServerPlayerEntity)
AllTriggers.triggerFor(AllTriggers.FAN_LAVA, (PlayerEntity) entity);
break; break;
case SMOKING: case SMOKING:
if (!entity.isImmuneToFire()) { if (!entity.isImmuneToFire()) {
entity.setFire(2); entity.setFire(2);
entity.attackEntityFrom(damageSourceFire, 2); entity.attackEntityFrom(damageSourceFire, 2);
} }
if (entity instanceof ServerPlayerEntity)
AllTriggers.triggerFor(AllTriggers.FAN_SMOKE, (PlayerEntity) entity);
break; break;
case SPLASHING: case SPLASHING:
if (entity instanceof EndermanEntity || entity.getType() == EntityType.SNOW_GOLEM if (entity instanceof EndermanEntity || entity.getType() == EntityType.SNOW_GOLEM
|| entity.getType() == EntityType.BLAZE) { || entity.getType() == EntityType.BLAZE) {
entity.attackEntityFrom(DamageSource.DROWN, 2); entity.attackEntityFrom(DamageSource.DROWN, 2);
} }
if (entity instanceof ServerPlayerEntity)
AllTriggers.triggerFor(AllTriggers.FAN_WATER, (PlayerEntity) entity);
if (!entity.isBurning()) if (!entity.isBurning())
break; break;
entity.extinguish(); entity.extinguish();
@ -193,7 +188,7 @@ public class AirCurrent {
AirCurrentSegment currentSegment = new AirCurrentSegment(); AirCurrentSegment currentSegment = new AirCurrentSegment();
segments.clear(); segments.clear();
currentSegment.startOffset = 0; currentSegment.startOffset = 0;
InWorldProcessing.Type type = null; InWorldProcessing.Type type = Type.NONE;
int limit = (int) (maxDistance + .5f); int limit = (int) (maxDistance + .5f);
int searchStart = pushing ? 0 : limit; int searchStart = pushing ? 0 : limit;
@ -203,7 +198,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.offset(direction, i); BlockPos currentPos = start.offset(direction, i);
InWorldProcessing.Type newType = InWorldProcessing.Type.byBlock(world, currentPos); InWorldProcessing.Type newType = InWorldProcessing.Type.byBlock(world, currentPos);
if (newType != null) if (newType != Type.NONE)
type = newType; type = newType;
if (currentSegment.type != type || currentSegment.startOffset == 0) { if (currentSegment.type != type || currentSegment.startOffset == 0) {
currentSegment.endOffset = i; currentSegment.endOffset = i;
@ -341,7 +336,7 @@ public class AirCurrent {
continue; continue;
return airCurrentSegment.type; return airCurrentSegment.type;
} }
return null; return InWorldProcessing.Type.NONE;
} }
public static class AirCurrentSegment { public static class AirCurrentSegment {

View file

@ -132,16 +132,7 @@ public class FluidDrainingBehaviour extends FluidManipulationBehaviour {
AllTriggers.triggerForNearbyPlayers(AllTriggers.HOSE_PULLEY, world, tileEntity.getPos(), 8); AllTriggers.triggerForNearbyPlayers(AllTriggers.HOSE_PULLEY, world, tileEntity.getPos(), 8);
if (infinite) { if (infinite) {
Fluid stillFluid = FluidHelper.convertToStill(fluid); AllTriggers.triggerForNearbyPlayers(AllTriggers.INFINITE_FLUID.constructTriggerFor(FluidHelper.convertToStill(fluid)), world, tileEntity.getPos(), 8);
AllTriggers.getPlayersInRange(world, tileEntity.getPos(), 8)
.forEach(p -> AllTriggers.INFINITE_FLUID.trigger(p, FluidHelper.convertToStill(stillFluid)));
/*
if (FluidHelper.isLava(fluid))
AllTriggers.triggerForNearbyPlayers(AllTriggers.INFINITE_LAVA, world, tileEntity.getPos(), 8);
if (FluidHelper.isWater(fluid))
AllTriggers.triggerForNearbyPlayers(AllTriggers.INFINITE_WATER, world, tileEntity.getPos(), 8);
if (fluid.isEquivalentTo(AllFluids.CHOCOLATE.get()))
AllTriggers.triggerForNearbyPlayers(AllTriggers.INFINITE_CHOCOLATE, world, tileEntity.getPos(), 8);*/
return true; return true;
} }

View file

@ -25,7 +25,7 @@ public class FluidPipeTileEntity extends SmartTileEntity {
public void addBehaviours(List<TileEntityBehaviour> behaviours) { public void addBehaviours(List<TileEntityBehaviour> behaviours) {
behaviours.add(new StandardPipeFluidTransportBehaviour(this)); behaviours.add(new StandardPipeFluidTransportBehaviour(this));
behaviours.add(new BracketedTileEntityBehaviour(this, this::canHaveBracket) behaviours.add(new BracketedTileEntityBehaviour(this, this::canHaveBracket)
.withTrigger(state -> AllTriggers.BRACKET_PIPE)); .withTrigger(state -> AllTriggers.BRACKET_APPLY_TRIGGER.constructTriggerFor(state.getBlock())));
} }
private boolean canHaveBracket(BlockState state) { private boolean canHaveBracket(BlockState state) {

View file

@ -1,17 +1,11 @@
package com.simibubi.create.content.contraptions.relays.elementary; package com.simibubi.create.content.contraptions.relays.elementary;
import java.util.Optional;
import java.util.function.Function;
import java.util.function.Predicate;
import com.google.common.base.Predicates;
import com.simibubi.create.foundation.advancement.AllTriggers; import com.simibubi.create.foundation.advancement.AllTriggers;
import com.simibubi.create.foundation.advancement.SimpleTrigger; import com.simibubi.create.foundation.advancement.ITriggerable;
import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.tileEntity.behaviour.BehaviourType; import com.simibubi.create.foundation.tileEntity.behaviour.BehaviourType;
import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.NBTHelper;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
@ -20,6 +14,10 @@ import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.NBTUtil; import net.minecraft.nbt.NBTUtil;
import net.minecraft.world.World; import net.minecraft.world.World;
import java.util.Optional;
import java.util.function.Function;
import java.util.function.Predicate;
public class BracketedTileEntityBehaviour extends TileEntityBehaviour { public class BracketedTileEntityBehaviour extends TileEntityBehaviour {
public static BehaviourType<BracketedTileEntityBehaviour> TYPE = new BehaviourType<>(); public static BehaviourType<BracketedTileEntityBehaviour> TYPE = new BehaviourType<>();
@ -28,10 +26,10 @@ public class BracketedTileEntityBehaviour extends TileEntityBehaviour {
private boolean reRender; private boolean reRender;
private Predicate<BlockState> pred; private Predicate<BlockState> pred;
private Function<BlockState, SimpleTrigger> trigger; private Function<BlockState, ITriggerable> trigger;
public BracketedTileEntityBehaviour(SmartTileEntity te) { public BracketedTileEntityBehaviour(SmartTileEntity te) {
this(te, Predicates.alwaysTrue()); this(te, state -> true);
} }
public BracketedTileEntityBehaviour(SmartTileEntity te, Predicate<BlockState> pred) { public BracketedTileEntityBehaviour(SmartTileEntity te, Predicate<BlockState> pred) {
@ -40,7 +38,7 @@ public class BracketedTileEntityBehaviour extends TileEntityBehaviour {
bracket = Optional.empty(); bracket = Optional.empty();
} }
public BracketedTileEntityBehaviour withTrigger(Function<BlockState, SimpleTrigger> trigger) { public BracketedTileEntityBehaviour withTrigger(Function<BlockState, ITriggerable> trigger) {
this.trigger = trigger; this.trigger = trigger;
return this; return this;
} }

View file

@ -23,7 +23,7 @@ public class SimpleKineticTileEntity extends KineticTileEntity {
public void addBehaviours(List<TileEntityBehaviour> behaviours) { public void addBehaviours(List<TileEntityBehaviour> behaviours) {
behaviours.add( behaviours.add(
new BracketedTileEntityBehaviour(this, state -> state.getBlock() instanceof AbstractShaftBlock).withTrigger( new BracketedTileEntityBehaviour(this, state -> state.getBlock() instanceof AbstractShaftBlock).withTrigger(
state -> state.getBlock() instanceof ShaftBlock ? AllTriggers.BRACKET_SHAFT : AllTriggers.BRACKET_COG)); state -> AllTriggers.BRACKET_APPLY_TRIGGER.constructTriggerFor(state.getBlock())));
super.addBehaviours(behaviours); super.addBehaviours(behaviours);
} }

View file

@ -1,10 +1,8 @@
package com.simibubi.create.content.curiosities; package com.simibubi.create.content.curiosities;
import java.util.List;
import java.util.Random; import java.util.Random;
import com.simibubi.create.AllItems; import com.simibubi.create.AllItems;
import com.simibubi.create.foundation.advancement.AllTriggers;
import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.config.CRecipes; import com.simibubi.create.foundation.config.CRecipes;
import com.simibubi.create.foundation.utility.ColorHelper; import com.simibubi.create.foundation.utility.ColorHelper;
@ -13,7 +11,6 @@ import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.entity.item.ItemEntity; import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
@ -21,7 +18,6 @@ import net.minecraft.particles.ParticleTypes;
import net.minecraft.tileentity.BeaconTileEntity; import net.minecraft.tileentity.BeaconTileEntity;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RayTraceContext; import net.minecraft.util.math.RayTraceContext;
@ -152,10 +148,6 @@ public class ChromaticCompoundItem extends Item {
data.putBoolean("FromLight", true); data.putBoolean("FromLight", true);
entity.setItem(newStack); entity.setItem(newStack);
List<ServerPlayerEntity> players =
world.getEntitiesWithinAABB(ServerPlayerEntity.class, new AxisAlignedBB(entity.getPosition()).grow(8));
players.forEach(AllTriggers.ABSORBED_LIGHT::trigger);
return false; return false;
} }

View file

@ -58,7 +58,7 @@ public class InWorldProcessing {
public static SplashingInv splashingInv = new SplashingInv(); public static SplashingInv splashingInv = new SplashingInv();
public enum Type { public enum Type {
SMOKING, BLASTING, SPLASHING SMOKING, BLASTING, SPLASHING, NONE
; ;
@ -74,7 +74,7 @@ public class InWorldProcessing {
return Type.SMOKING; return Type.SMOKING;
if (block == Blocks.LAVA || getHeatLevelOf(blockState).isAtLeast(BlazeBurnerBlock.HeatLevel.FADING)) if (block == Blocks.LAVA || getHeatLevelOf(blockState).isAtLeast(BlazeBurnerBlock.HeatLevel.FADING))
return Type.BLASTING; return Type.BLASTING;
return null; return Type.NONE;
} }
} }

View file

@ -6,6 +6,7 @@ import java.util.Set;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Supplier; import java.util.function.Supplier;
import com.simibubi.create.content.logistics.InWorldProcessing;
import net.minecraft.fluid.FlowingFluid; import net.minecraft.fluid.FlowingFluid;
import net.minecraft.fluid.Fluid; import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.Fluids; import net.minecraft.fluid.Fluids;
@ -64,9 +65,9 @@ public class AllAdvancements implements IDataProvider {
Advancement aesthetics = Advancement aesthetics =
advancement("aesthetics", AllBlocks.WOODEN_BRACKET.get(), TaskType.NORMAL).withParent(andesite_alloy) advancement("aesthetics", AllBlocks.WOODEN_BRACKET.get(), TaskType.NORMAL).withParent(andesite_alloy)
.withCriterion("0", AllTriggers.BRACKET_SHAFT.instance()) .withCriterion("0", AllTriggers.BRACKET_APPLY_TRIGGER.forEntries(AllBlocks.SHAFT.get()))
.withCriterion("1", AllTriggers.BRACKET_COG.instance()) .withCriterion("1", AllTriggers.BRACKET_APPLY_TRIGGER.forEntries(AllBlocks.COGWHEEL.get(), AllBlocks.LARGE_COGWHEEL.get()))
.withCriterion("2", AllTriggers.BRACKET_PIPE.instance()) .withCriterion("2", AllTriggers.BRACKET_APPLY_TRIGGER.forEntries(AllBlocks.FLUID_PIPE.get()))
.register(t, id + ":aesthetics"); .register(t, id + ":aesthetics");
Advancement reinforced = Advancement reinforced =
@ -125,19 +126,19 @@ public class AllAdvancements implements IDataProvider {
.register(t, id + ":press"); .register(t, id + ":press");
Advancement fan = advancement("fan", AllBlocks.ENCASED_FAN.get(), TaskType.NORMAL).withParent(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"); .register(t, id + ":fan");
Advancement fan_lava = advancement("fan_lava", Items.LAVA_BUCKET, TaskType.NORMAL).withParent(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"); .register(t, id + ":fan_lava");
Advancement fan_smoke = advancement("fan_smoke", Items.CAMPFIRE, TaskType.NORMAL).withParent(fan) 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"); .register(t, id + ":fan_smoke");
Advancement fan_water = advancement("fan_water", Items.WATER_BUCKET, TaskType.NORMAL).withParent(fan) 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"); .register(t, id + ":fan_water");
Advancement rose_quartz = Advancement rose_quartz =
@ -160,8 +161,7 @@ public class AllAdvancements implements IDataProvider {
Advancement mixer = advancement("mixer", AllBlocks.MECHANICAL_MIXER.get(), TaskType.MILESTONE) Advancement mixer = advancement("mixer", AllBlocks.MECHANICAL_MIXER.get(), TaskType.MILESTONE)
.withCriterion("0", placeBlock(AllBlocks.MECHANICAL_MIXER.get())) .withCriterion("0", placeBlock(AllBlocks.MECHANICAL_MIXER.get()))
.withCriterion("1", isPowered(AllBlocks.MECHANICAL_MIXER.get())) .withCriterion("1", AllTriggers.MIXER_MIX.instance())
.withCriterion("2", AllTriggers.MIXER_MIX.instance())
.withParent(basin) .withParent(basin)
.register(t, id + ":mixer"); .register(t, id + ":mixer");
@ -496,12 +496,8 @@ public class AllAdvancements implements IDataProvider {
return PlacedBlockTrigger.Instance.placedBlock(block); return PlacedBlockTrigger.Instance.placedBlock(block);
} }
public RegistryTrigger.Instance<Block> isPowered(Block block) {
return AllTriggers.KINETIC_BLOCK.forEntry(block);
}
public RegistryTrigger.Instance<Fluid> isInfinite(FlowingFluid fluid) { public RegistryTrigger.Instance<Fluid> isInfinite(FlowingFluid fluid) {
return AllTriggers.INFINITE_FLUID.forEntry(fluid.getStillFluid()); return AllTriggers.INFINITE_FLUID.forEntries(fluid.getStillFluid());
} }
public InventoryChangeTrigger.Instance itemGathered(IItemProvider itemprovider) { public InventoryChangeTrigger.Instance itemGathered(IItemProvider itemprovider) {

View file

@ -4,6 +4,7 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.function.Predicate; import java.util.function.Predicate;
import com.simibubi.create.content.logistics.InWorldProcessing;
import net.minecraft.advancements.CriteriaTriggers; import net.minecraft.advancements.CriteriaTriggers;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
@ -17,8 +18,9 @@ public class AllTriggers {
private static final List<CriterionTriggerBase<?>> triggers = new LinkedList<>(); private static final List<CriterionTriggerBase<?>> triggers = new LinkedList<>();
public static RegistryTrigger<Block> KINETIC_BLOCK = add(new RegistryTrigger<>("kinetic_block", Block.class));
public static RegistryTrigger<Fluid> INFINITE_FLUID = add(new RegistryTrigger<>("infinite_fluid", Fluid.class)); 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 public static SimpleTrigger
ROTATION = simple("rotation"), ROTATION = simple("rotation"),
@ -30,7 +32,6 @@ public class AllTriggers {
LAVA_WHEEL = simple("lava_wheel"), LAVA_WHEEL = simple("lava_wheel"),
CHOCOLATE_WHEEL = simple("chocolate_wheel"), CHOCOLATE_WHEEL = simple("chocolate_wheel"),
DEPLOYER_BOOP = simple("deployer"), DEPLOYER_BOOP = simple("deployer"),
ABSORBED_LIGHT = simple("light_absorbed"),
SPEED_READ = simple("speed_read"), SPEED_READ = simple("speed_read"),
BASIN_THROW = simple("basin"), BASIN_THROW = simple("basin"),
PRESS_COMPACT = simple("compact"), PRESS_COMPACT = simple("compact"),
@ -40,9 +41,6 @@ public class AllTriggers {
MECHANICAL_ARM = simple("mechanical_arm"), MECHANICAL_ARM = simple("mechanical_arm"),
MUSICAL_ARM = simple("musical_arm"), MUSICAL_ARM = simple("musical_arm"),
CUCKOO = simple("cuckoo"), CUCKOO = simple("cuckoo"),
BRACKET_SHAFT = simple("bracket_shaft"),
BRACKET_COG = simple("bracket_cog"),
BRACKET_PIPE = simple("bracket_pipe"),
CASING_SHAFT = simple("casing_shaft"), CASING_SHAFT = simple("casing_shaft"),
CASING_BELT = simple("casing_belt"), CASING_BELT = simple("casing_belt"),
CASING_PIPE = simple("casing_pipe"), CASING_PIPE = simple("casing_pipe"),
@ -51,10 +49,6 @@ public class AllTriggers {
PLACE_TUNNEL = simple("place_tunnel"), PLACE_TUNNEL = simple("place_tunnel"),
CONNECT_TUNNEL = simple("connect_tunnel"), CONNECT_TUNNEL = simple("connect_tunnel"),
UPWARD_CHUTE = simple("upward_chute"), 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 = simple("belt_funnel"),
BELT_FUNNEL_KISS = simple("belt_funnel_kiss"), BELT_FUNNEL_KISS = simple("belt_funnel_kiss"),
CLOCKWORK_BEARING = simple("clockwork_bearing"), CLOCKWORK_BEARING = simple("clockwork_bearing"),

View file

@ -77,7 +77,7 @@ public abstract class CriterionTriggerBase<T extends CriterionTriggerBase.Instan
} }
} }
protected abstract static class Instance extends CriterionInstance { public abstract static class Instance extends CriterionInstance {
public Instance(ResourceLocation idIn) { public Instance(ResourceLocation idIn) {
super(idIn); super(idIn);

View file

@ -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();
}
}

View file

@ -1,83 +1,35 @@
package com.simibubi.create.foundation.advancement; package com.simibubi.create.foundation.advancement;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonSyntaxException;
import mcp.MethodsReturnNonnullByDefault; import mcp.MethodsReturnNonnullByDefault;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.util.JSONUtils;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.registries.IForgeRegistry;
import net.minecraftforge.registries.IForgeRegistryEntry; import net.minecraftforge.registries.IForgeRegistryEntry;
import net.minecraftforge.registries.RegistryManager; import net.minecraftforge.registries.RegistryManager;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault;
import java.util.Collections;
import java.util.List;
import java.util.function.Supplier;
@ParametersAreNonnullByDefault @ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault @MethodsReturnNonnullByDefault
public class RegistryTrigger<T extends IForgeRegistryEntry<T>> extends CriterionTriggerBase<RegistryTrigger.Instance<T>> { public class RegistryTrigger<T extends IForgeRegistryEntry<T>> extends StringSerializableTrigger<T> {
private final Class<T> registryType; private final IForgeRegistry<T> registry;
public RegistryTrigger(String id, Class<T> registryType) { public RegistryTrigger(String id, Class<T> registryType) {
super(id); super(id);
this.registryType = registryType; this.registry = RegistryManager.ACTIVE.getRegistry(registryType);
}
public Instance<T> forEntry(@Nullable T registryEntry) {
return new Instance<>(getId(), registryEntry);
}
public void trigger(ServerPlayerEntity player, T registryEntry) {
trigger(player, Collections.singletonList(() -> registryEntry));
} }
@Nullable
@Override @Override
public Instance<T> deserializeInstance(JsonObject json, JsonDeserializationContext context) { protected T getValue(String key) {
T entry = null;
if (json.has("registry_entry")) {
ResourceLocation entryLocation = new ResourceLocation(JSONUtils.getString(json, "registry_entry"));
entry = RegistryManager.ACTIVE.getRegistry(registryType).getValue(entryLocation);
if (entry == null) return registry.getValue(new ResourceLocation(key));
throw new JsonSyntaxException("Unknown registry entry '" + entryLocation + "'");
}
return forEntry(entry);
} }
@Nullable
public static class Instance<T extends IForgeRegistryEntry<T>> extends CriterionTriggerBase.Instance { @Override
protected String getKey(T value) {
@Nullable ResourceLocation key = registry.getKey(value);
private final T entry; return key == null ? null : key.toString();
public Instance(ResourceLocation id, @Nullable T registryEntry) {
super(id);
entry = registryEntry;
}
@Override
protected boolean test(@Nullable List<Supplier<Object>> suppliers) {
if (entry == null || suppliers == null || suppliers.isEmpty())
return false;
return entry.equals(suppliers.get(0).get());
}
@Override
public JsonElement serialize() {
JsonObject jsonobject = new JsonObject();
if (entry == null)
return jsonobject;
ResourceLocation key = RegistryManager.ACTIVE.getRegistry(entry.getRegistryType()).getKey(entry);
if (key != null) {
jsonobject.addProperty("registry_entry", key.toString());
}
return jsonobject;
}
} }
} }

View file

@ -0,0 +1,103 @@
package com.simibubi.create.foundation.advancement;
import com.google.common.collect.Sets;
import com.google.gson.*;
import mcp.MethodsReturnNonnullByDefault;
import net.minecraft.entity.player.ServerPlayerEntity;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.function.BiConsumer;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
public abstract class StringSerializableTrigger<T> extends CriterionTriggerBase<StringSerializableTrigger.Instance<T>> {
public StringSerializableTrigger(String id) {
super(id);
}
@SafeVarargs
public final Instance<T> forEntries(@Nullable T... entries) {
return new Instance<>(this, entries == null ? null : Sets.newHashSet(entries));
}
public void trigger(ServerPlayerEntity player, @Nullable T registryEntry) {
trigger(player, Collections.singletonList(() -> registryEntry));
}
public ITriggerable constructTriggerFor(@Nullable T entry) {
BiConsumer<ServerPlayerEntity, T> trigger = this::trigger;
return player -> trigger.accept(player, entry);
}
@Override
public Instance<T> deserializeInstance(JsonObject json, JsonDeserializationContext context) {
if (json.has("accepted_entries")) {
JsonArray elements = json.getAsJsonArray("accepted_entries");
return new Instance<>(this,
StreamSupport.stream(elements.spliterator(), false).map(JsonElement::getAsString)
.map(rl -> {
T entry = getValue(rl);
if (entry == null)
throw new JsonSyntaxException("Unknown entry '" + rl + "'");
return entry;
}).collect(Collectors.toSet()));
}
return forEntries((T) null);
}
@Nullable
abstract protected T getValue(String key);
@Nullable
abstract protected String getKey(T value);
public static class Instance<T> extends CriterionTriggerBase.Instance {
@Nullable
private final Set<T> entries;
private final StringSerializableTrigger<T> trigger;
public Instance(StringSerializableTrigger<T> trigger, @Nullable Set<T> entries) {
super(trigger.getId());
this.trigger = trigger;
this.entries = entries;
}
@Override
protected boolean test(@Nullable List<Supplier<Object>> suppliers) {
if (entries == null || suppliers == null || suppliers.isEmpty())
return false;
return entries.contains(suppliers.get(0).get());
}
@Override
public JsonElement serialize() {
JsonObject jsonobject = new JsonObject();
JsonArray elements = new JsonArray();
if (entries == null) {
jsonobject.add("accepted_entries", elements);
return jsonobject;
}
for (T entry : entries) {
if (entry == null)
continue;
String key = trigger.getKey(entry);
if (key != null)
elements.add(key);
}
jsonobject.add("accepted_entries", elements);
return jsonobject;
}
}
}