Make contraptions not take that stupid amount of cpu time when in water

This commit is contained in:
grimmauld 2021-03-01 10:37:49 +01:00
parent 55f1b538b5
commit 1e28bc998a
8 changed files with 152 additions and 123 deletions

View File

@ -140,7 +140,7 @@ de8a40b7daf1497d5aecee47a43b3e0b1d030b00 assets/create/blockstates/fancy_scoria_
fc9ac0a7e7191b93516719455a17177fa6524ecc assets/create/blockstates/fancy_weathered_limestone_bricks_slab.json
b2a7c321b1795f20e7433f81a55ce4683de081b8 assets/create/blockstates/fancy_weathered_limestone_bricks_stairs.json
6372fe02ba0065acb0758121c45a15a1a8fdc5de assets/create/blockstates/fancy_weathered_limestone_bricks_wall.json
48086bf71a824faf14841b698050cc8544b09a9b assets/create/blockstates/fluid_pipe.json
3d97226b5e8d8f70ed08e45e78db1faf78d5e28b assets/create/blockstates/fluid_pipe.json
f0eaab18e16c4f3f65ebf3b55b08f0dc445720fe assets/create/blockstates/fluid_tank.json
5408d92ab02af86539ac42971d4033545970bb3a assets/create/blockstates/fluid_valve.json
e9da1794b6ece7f9aa8bcb43d42c23a55446133b assets/create/blockstates/flywheel.json
@ -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
4439fc83a8c7370ab44b211a3fd48abde20a4728 assets/create/blockstates/radial_chassis.json
8d7e653bfd9846e684a0d3725595714a19201017 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

View File

@ -61,9 +61,9 @@
{
"when": {
"down": "false",
"north": "true",
"up": "true",
"south": "false",
"north": "true"
"south": "false"
},
"apply": {
"model": "create:block/fluid_pipe/lu_x"
@ -72,9 +72,9 @@
{
"when": {
"down": "false",
"north": "false",
"up": "true",
"south": "true",
"north": "false"
"south": "true"
},
"apply": {
"model": "create:block/fluid_pipe/ru_x"
@ -83,9 +83,9 @@
{
"when": {
"down": "true",
"north": "true",
"up": "false",
"south": "false",
"north": "true"
"south": "false"
},
"apply": {
"model": "create:block/fluid_pipe/ld_x"
@ -94,9 +94,9 @@
{
"when": {
"down": "true",
"north": "false",
"up": "false",
"south": "true",
"north": "false"
"south": "true"
},
"apply": {
"model": "create:block/fluid_pipe/rd_x"
@ -105,9 +105,9 @@
{
"when": {
"down": "true",
"north": "false",
"up": "true",
"south": "false",
"north": "false"
"south": "false"
},
"apply": {
"model": "create:block/fluid_pipe/ud_x"
@ -116,9 +116,9 @@
{
"when": {
"down": "false",
"north": "false",
"up": "true",
"south": "false",
"north": "false"
"south": "false"
},
"apply": {
"model": "create:block/fluid_pipe/ud_x"
@ -127,9 +127,9 @@
{
"when": {
"down": "true",
"north": "false",
"up": "false",
"south": "false",
"north": "false"
"south": "false"
},
"apply": {
"model": "create:block/fluid_pipe/ud_x"
@ -138,9 +138,9 @@
{
"when": {
"down": "false",
"north": "true",
"up": "false",
"south": "true",
"north": "true"
"south": "true"
},
"apply": {
"model": "create:block/fluid_pipe/lr_x"
@ -149,9 +149,9 @@
{
"when": {
"down": "false",
"north": "true",
"up": "false",
"south": "false",
"north": "true"
"south": "false"
},
"apply": {
"model": "create:block/fluid_pipe/lr_x"
@ -160,9 +160,9 @@
{
"when": {
"down": "false",
"north": "false",
"up": "false",
"south": "true",
"north": "false"
"south": "true"
},
"apply": {
"model": "create:block/fluid_pipe/lr_x"
@ -171,9 +171,9 @@
{
"when": {
"down": "false",
"north": "false",
"up": "false",
"south": "false",
"north": "false"
"south": "false"
},
"apply": {
"model": "create:block/fluid_pipe/none_x"
@ -181,10 +181,10 @@
},
{
"when": {
"south": "true",
"west": "true",
"east": "false",
"north": "false",
"east": "false"
"south": "true"
},
"apply": {
"model": "create:block/fluid_pipe/lu_y"
@ -192,10 +192,10 @@
},
{
"when": {
"south": "true",
"west": "false",
"east": "true",
"north": "false",
"east": "true"
"south": "true"
},
"apply": {
"model": "create:block/fluid_pipe/ru_y"
@ -203,10 +203,10 @@
},
{
"when": {
"south": "false",
"west": "true",
"east": "false",
"north": "true",
"east": "false"
"south": "false"
},
"apply": {
"model": "create:block/fluid_pipe/ld_y"
@ -214,10 +214,10 @@
},
{
"when": {
"south": "false",
"west": "false",
"east": "true",
"north": "true",
"east": "true"
"south": "false"
},
"apply": {
"model": "create:block/fluid_pipe/rd_y"
@ -225,10 +225,10 @@
},
{
"when": {
"south": "true",
"west": "false",
"east": "false",
"north": "true",
"east": "false"
"south": "true"
},
"apply": {
"model": "create:block/fluid_pipe/ud_y"
@ -236,10 +236,10 @@
},
{
"when": {
"south": "true",
"west": "false",
"east": "false",
"north": "false",
"east": "false"
"south": "true"
},
"apply": {
"model": "create:block/fluid_pipe/ud_y"
@ -247,10 +247,10 @@
},
{
"when": {
"south": "false",
"west": "false",
"east": "false",
"north": "true",
"east": "false"
"south": "false"
},
"apply": {
"model": "create:block/fluid_pipe/ud_y"
@ -258,10 +258,10 @@
},
{
"when": {
"south": "false",
"west": "true",
"east": "true",
"north": "false",
"east": "true"
"south": "false"
},
"apply": {
"model": "create:block/fluid_pipe/lr_y"
@ -269,10 +269,10 @@
},
{
"when": {
"south": "false",
"west": "true",
"east": "false",
"north": "false",
"east": "false"
"south": "false"
},
"apply": {
"model": "create:block/fluid_pipe/lr_y"
@ -280,10 +280,10 @@
},
{
"when": {
"south": "false",
"west": "false",
"east": "true",
"north": "false",
"east": "true"
"south": "false"
},
"apply": {
"model": "create:block/fluid_pipe/lr_y"
@ -291,10 +291,10 @@
},
{
"when": {
"south": "false",
"west": "false",
"east": "false",
"north": "false",
"east": "false"
"south": "false"
},
"apply": {
"model": "create:block/fluid_pipe/none_y"
@ -302,10 +302,10 @@
},
{
"when": {
"down": "false",
"up": "true",
"west": "false",
"east": "true"
"down": "false",
"east": "true",
"up": "true"
},
"apply": {
"model": "create:block/fluid_pipe/lu_z"
@ -313,10 +313,10 @@
},
{
"when": {
"down": "false",
"up": "true",
"west": "true",
"east": "false"
"down": "false",
"east": "false",
"up": "true"
},
"apply": {
"model": "create:block/fluid_pipe/ru_z"
@ -324,10 +324,10 @@
},
{
"when": {
"down": "true",
"up": "false",
"west": "false",
"east": "true"
"down": "true",
"east": "true",
"up": "false"
},
"apply": {
"model": "create:block/fluid_pipe/ld_z"
@ -335,10 +335,10 @@
},
{
"when": {
"down": "true",
"up": "false",
"west": "true",
"east": "false"
"down": "true",
"east": "false",
"up": "false"
},
"apply": {
"model": "create:block/fluid_pipe/rd_z"
@ -346,10 +346,10 @@
},
{
"when": {
"west": "false",
"down": "true",
"up": "true",
"west": "false",
"east": "false"
"east": "false",
"up": "true"
},
"apply": {
"model": "create:block/fluid_pipe/ud_z"
@ -357,10 +357,10 @@
},
{
"when": {
"west": "false",
"down": "false",
"up": "true",
"west": "false",
"east": "false"
"east": "false",
"up": "true"
},
"apply": {
"model": "create:block/fluid_pipe/ud_z"
@ -368,10 +368,10 @@
},
{
"when": {
"west": "false",
"down": "true",
"up": "false",
"west": "false",
"east": "false"
"east": "false",
"up": "false"
},
"apply": {
"model": "create:block/fluid_pipe/ud_z"
@ -379,10 +379,10 @@
},
{
"when": {
"down": "false",
"up": "false",
"west": "true",
"east": "true"
"down": "false",
"east": "true",
"up": "false"
},
"apply": {
"model": "create:block/fluid_pipe/lr_z"
@ -390,10 +390,10 @@
},
{
"when": {
"down": "false",
"up": "false",
"west": "false",
"east": "true"
"down": "false",
"east": "true",
"up": "false"
},
"apply": {
"model": "create:block/fluid_pipe/lr_z"
@ -401,10 +401,10 @@
},
{
"when": {
"down": "false",
"up": "false",
"west": "true",
"east": "false"
"down": "false",
"east": "false",
"up": "false"
},
"apply": {
"model": "create:block/fluid_pipe/lr_z"
@ -412,10 +412,10 @@
},
{
"when": {
"down": "false",
"up": "false",
"west": "false",
"east": "false"
"down": "false",
"east": "false",
"up": "false"
},
"apply": {
"model": "create:block/fluid_pipe/none_z"

View File

@ -29,8 +29,8 @@
},
{
"when": {
"axis": "x",
"sticky_south": "true"
"sticky_south": "true",
"axis": "x"
},
"apply": {
"model": "create:block/radial_chassis_side_x_sticky",
@ -39,8 +39,8 @@
},
{
"when": {
"axis": "y",
"sticky_south": "true"
"sticky_south": "true",
"axis": "y"
},
"apply": {
"model": "create:block/radial_chassis_side_y_sticky"
@ -48,8 +48,8 @@
},
{
"when": {
"axis": "z",
"sticky_south": "true"
"sticky_south": "true",
"axis": "z"
},
"apply": {
"model": "create:block/radial_chassis_side_x_sticky",
@ -59,8 +59,8 @@
},
{
"when": {
"axis": "x",
"sticky_south": "false"
"sticky_south": "false",
"axis": "x"
},
"apply": {
"model": "create:block/radial_chassis_side_x",
@ -69,8 +69,8 @@
},
{
"when": {
"axis": "y",
"sticky_south": "false"
"sticky_south": "false",
"axis": "y"
},
"apply": {
"model": "create:block/radial_chassis_side_y"
@ -78,8 +78,8 @@
},
{
"when": {
"axis": "z",
"sticky_south": "false"
"sticky_south": "false",
"axis": "z"
},
"apply": {
"model": "create:block/radial_chassis_side_x",
@ -89,8 +89,8 @@
},
{
"when": {
"axis": "x",
"sticky_west": "true"
"sticky_west": "true",
"axis": "x"
},
"apply": {
"model": "create:block/radial_chassis_side_x_sticky",
@ -99,8 +99,8 @@
},
{
"when": {
"axis": "y",
"sticky_west": "true"
"sticky_west": "true",
"axis": "y"
},
"apply": {
"model": "create:block/radial_chassis_side_y_sticky",
@ -109,8 +109,8 @@
},
{
"when": {
"axis": "z",
"sticky_west": "true"
"sticky_west": "true",
"axis": "z"
},
"apply": {
"model": "create:block/radial_chassis_side_z_sticky",
@ -119,8 +119,8 @@
},
{
"when": {
"axis": "x",
"sticky_west": "false"
"sticky_west": "false",
"axis": "x"
},
"apply": {
"model": "create:block/radial_chassis_side_x",
@ -129,8 +129,8 @@
},
{
"when": {
"axis": "y",
"sticky_west": "false"
"sticky_west": "false",
"axis": "y"
},
"apply": {
"model": "create:block/radial_chassis_side_y",
@ -139,8 +139,8 @@
},
{
"when": {
"axis": "z",
"sticky_west": "false"
"sticky_west": "false",
"axis": "z"
},
"apply": {
"model": "create:block/radial_chassis_side_z",
@ -207,8 +207,8 @@
},
{
"when": {
"axis": "x",
"sticky_east": "true"
"sticky_east": "true",
"axis": "x"
},
"apply": {
"model": "create:block/radial_chassis_side_x_sticky",
@ -217,8 +217,8 @@
},
{
"when": {
"axis": "y",
"sticky_east": "true"
"sticky_east": "true",
"axis": "y"
},
"apply": {
"model": "create:block/radial_chassis_side_y_sticky",
@ -227,8 +227,8 @@
},
{
"when": {
"axis": "z",
"sticky_east": "true"
"sticky_east": "true",
"axis": "z"
},
"apply": {
"model": "create:block/radial_chassis_side_z_sticky"
@ -236,8 +236,8 @@
},
{
"when": {
"axis": "x",
"sticky_east": "false"
"sticky_east": "false",
"axis": "x"
},
"apply": {
"model": "create:block/radial_chassis_side_x",
@ -246,8 +246,8 @@
},
{
"when": {
"axis": "y",
"sticky_east": "false"
"sticky_east": "false",
"axis": "y"
},
"apply": {
"model": "create:block/radial_chassis_side_y",
@ -256,8 +256,8 @@
},
{
"when": {
"axis": "z",
"sticky_east": "false"
"sticky_east": "false",
"axis": "z"
},
"apply": {
"model": "create:block/radial_chassis_side_z"

View File

@ -31,9 +31,9 @@ public class AllEntityTypes {
contraption("gantry_contraption", GantryContraptionEntity::new, 10, 40, false);
public static final RegistryEntry<EntityType<SuperGlueEntity>> SUPER_GLUE = register("super_glue",
SuperGlueEntity::new, EntityClassification.MISC, 10, Integer.MAX_VALUE, false, SuperGlueEntity::build);
SuperGlueEntity::new, EntityClassification.MISC, 10, Integer.MAX_VALUE, false, true, SuperGlueEntity::build);
public static final RegistryEntry<EntityType<SeatEntity>> SEAT =
register("seat", SeatEntity::new, EntityClassification.MISC, 0, Integer.MAX_VALUE, false, SeatEntity::build);
register("seat", SeatEntity::new, EntityClassification.MISC, 0, Integer.MAX_VALUE, false, true, SeatEntity::build);
//
@ -41,12 +41,12 @@ public class AllEntityTypes {
private static <T extends Entity> RegistryEntry<EntityType<T>> contraption(String name, IFactory<T> factory,
int range, int updateFrequency, boolean sendVelocity) {
return register(name, factory, EntityClassification.MISC, range, updateFrequency, sendVelocity,
return register(name, factory, EntityClassification.MISC, range, updateFrequency, sendVelocity, true,
AbstractContraptionEntity::build);
}
private static <T extends Entity> RegistryEntry<EntityType<T>> register(String name, IFactory<T> factory,
EntityClassification group, int range, int updateFrequency, boolean sendVelocity,
EntityClassification group, int range, int updateFrequency, boolean sendVelocity, boolean immuneToFire,
NonNullConsumer<EntityType.Builder<T>> propertyBuilder) {
String id = Lang.asId(name);
return Create.registrate()
@ -55,6 +55,10 @@ public class AllEntityTypes {
.setUpdateInterval(updateFrequency)
.setShouldReceiveVelocityUpdates(sendVelocity))
.properties(propertyBuilder)
.properties(b -> {
if (immuneToFire)
b.immuneToFire();
})
.register();
}

View File

@ -649,4 +649,25 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
}
@Override
public void updateAquatics() {
/*
Override this with an empty method to reduce enormous calculation time when contraptions are in water
WARNING: THIS HAS A BUNCH OF SIDE EFFECTS!
- Fluids will not try to change contraption movement direction
- this.inWater and this.isInWater() will return unreliable data
- entities riding a contraption will not cause water splashes (seats are their own entity so this should be fine)
- fall distance is not reset when the contraption is in water
- this.eyesInWater and this.canSwim() will always be false
- swimming state will never be updated
*/
extinguish();
}
@Override
public void setFire(int p_70015_1_) {
// Contraptions no longer catch fire
}
}

View File

@ -55,6 +55,8 @@ public class ProcessingInventory extends ItemStackHandler {
recipeDuration = nbt.getFloat("RecipeTime");
appliedRecipe = nbt.getBoolean("AppliedRecipe");
super.deserializeNBT(nbt);
if(isEmpty())
appliedRecipe = false;
}
@Override

View File

@ -19,9 +19,9 @@ public class AllTriggers {
private static final List<CriterionTriggerBase<?>> triggers = new LinkedList<>();
public static final RegistryTrigger<Fluid> INFINITE_FLUID = add(new RegistryTrigger<>("infinite_fluid", ForgeRegistries.FLUIDS));
public static final RegistryTrigger<Block> BRACKET_APPLY_TRIGGER = add(new RegistryTrigger<>("bracket_apply", ForgeRegistries.BLOCKS));
public static final EnumTrigger<InWorldProcessing.Type> FAN_PROCESSING = add(new EnumTrigger<>("fan_processing", InWorldProcessing.Type.class));
public static final StringSerializableTrigger<Fluid> INFINITE_FLUID = add(new RegistryTrigger<>("infinite_fluid", ForgeRegistries.FLUIDS));
public static final StringSerializableTrigger<Block> BRACKET_APPLY_TRIGGER = add(new RegistryTrigger<>("bracket_apply", ForgeRegistries.BLOCKS));
public static final StringSerializableTrigger<InWorldProcessing.Type> FAN_PROCESSING = add(new EnumTrigger<>("fan_processing", InWorldProcessing.Type.class));
public static final SimpleTrigger
ROTATION = simple("rotation"),

View File

@ -44,4 +44,6 @@ public com.mojang.blaze3d.platform.GlStateManager$BooleanState field_179201_b #f
public net.minecraft.client.renderer.GameRenderer func_215311_a(Lnet/minecraft/client/renderer/ActiveRenderInfo;FZ)D #getFOVModifier
# IResizeCallback
public net.minecraft.util.palette.IResizeCallback
public net.minecraft.util.palette.IResizeCallback
public net.minecraft.entity.Entity func_205011_p()V # updateAquatics