Riding the engine

- Fixed incompatibility between seats and furnace cart contraptions
This commit is contained in:
simibubi 2020-07-24 19:43:33 +02:00
parent 80406e8782
commit f0abbaacd7
14 changed files with 36 additions and 18 deletions

View file

@ -2,7 +2,7 @@ import org.apache.commons.lang3.mutable.MutableObject;
import com.simibubi.create.content.contraptions.components.structureMovement.Contraption;
import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionEntity;
import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionInteractionPacket;
import com.simibubi.create.content.contraptions.components.structureMovement.sync.ContraptionInteractionPacket;
import com.simibubi.create.foundation.networking.AllPackets;
import com.simibubi.create.foundation.utility.RaycastHelper;
import com.simibubi.create.foundation.utility.RaycastHelper.PredicateTraceResult;

View file

@ -89,7 +89,6 @@ public class Create {
if (schematicReceiver == null)
schematicReceiver = new ServerSchematicLoader();
schematicReceiver.tick();
lagger.tick();
}

View file

@ -7,8 +7,8 @@ import java.util.function.Function;
import com.simibubi.create.content.contraptions.KineticDebugger;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.content.contraptions.components.structureMovement.ChassisRangeDisplay;
import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionRenderer;
import com.simibubi.create.content.contraptions.components.structureMovement.chassis.ChassisRangeDisplay;
import com.simibubi.create.content.contraptions.relays.belt.item.BeltConnectorHandler;
import com.simibubi.create.content.curiosities.tools.ExtendoGripRenderHandler;
import com.simibubi.create.content.curiosities.zapper.ZapperRenderHandler;

View file

@ -812,6 +812,10 @@ public abstract class Contraption {
return seatMapping;
}
public void setSeatMapping(Map<UUID, Integer> seatMapping) {
this.seatMapping = seatMapping;
}
public List<BlockPos> getSeats() {
return seats;
}

View file

@ -20,6 +20,7 @@ import com.google.common.cache.CacheBuilder;
import com.google.common.collect.ImmutableSet;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.content.contraptions.components.actors.BlockBreakingMovementBehaviour;
import com.simibubi.create.content.contraptions.components.structureMovement.sync.ClientMotionPacket;
import com.simibubi.create.foundation.collision.ContinuousOBBCollider.ContinuousSeparationManifold;
import com.simibubi.create.foundation.collision.Matrix3d;
import com.simibubi.create.foundation.collision.OrientedBB;

View file

@ -16,6 +16,7 @@ import com.simibubi.create.content.contraptions.components.structureMovement.bea
import com.simibubi.create.content.contraptions.components.structureMovement.glue.SuperGlueEntity;
import com.simibubi.create.content.contraptions.components.structureMovement.mounted.CartAssemblerTileEntity.CartMovementMode;
import com.simibubi.create.content.contraptions.components.structureMovement.mounted.MountedContraption;
import com.simibubi.create.content.contraptions.components.structureMovement.sync.ContraptionSeatMappingPacket;
import com.simibubi.create.foundation.item.ItemHelper;
import com.simibubi.create.foundation.networking.AllPackets;
import com.simibubi.create.foundation.utility.AngleHelper;
@ -69,6 +70,7 @@ public class ContraptionEntity extends Entity implements IEntityAdditionalSpawnD
protected boolean stationary;
protected boolean initialized;
final List<Entity> collidingEntities = new ArrayList<>();
private boolean isSerializingFurnaceCart;
private static final Ingredient FUEL_ITEMS = Ingredient.fromItems(Items.COAL, Items.CHARCOAL);
private static final DataParameter<Boolean> STALLED =
@ -90,6 +92,7 @@ public class ContraptionEntity extends Entity implements IEntityAdditionalSpawnD
super(entityTypeIn, worldIn);
motionBeforeStall = Vec3d.ZERO;
stationary = entityTypeIn == AllEntityTypes.STATIONARY_CONTRAPTION.get();
isSerializingFurnaceCart = false;
forcedAngle = -1;
}
@ -352,7 +355,12 @@ public class ContraptionEntity extends Entity implements IEntityAdditionalSpawnD
if (!isStalled() && (riding instanceof FurnaceMinecartEntity)) {
FurnaceMinecartEntity furnaceCart = (FurnaceMinecartEntity) riding;
// Notify to not trigger serialization side-effects
isSerializingFurnaceCart = true;
CompoundNBT nbt = furnaceCart.serializeNBT();
isSerializingFurnaceCart = false;
int fuel = nbt.getInt("Fuel");
int fuelBefore = fuel;
double pushX = nbt.getDouble("PushX");
@ -672,6 +680,9 @@ public class ContraptionEntity extends Entity implements IEntityAdditionalSpawnD
@SuppressWarnings("deprecation")
@Override
public CompoundNBT writeWithoutTypeId(CompoundNBT nbt) {
if (isSerializingFurnaceCart)
return nbt;
Vec3d vec = getPositionVec();
List<Entity> passengers = getPassengers();

View file

@ -1,4 +1,4 @@
package com.simibubi.create.content.contraptions.components.structureMovement;
package com.simibubi.create.content.contraptions.components.structureMovement.chassis;
import java.util.ArrayList;
import java.util.Collections;
@ -14,7 +14,6 @@ import com.simibubi.create.AllItems;
import com.simibubi.create.AllKeys;
import com.simibubi.create.AllSpecialTextures;
import com.simibubi.create.CreateClient;
import com.simibubi.create.content.contraptions.components.structureMovement.chassis.ChassisTileEntity;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.PlayerEntity;

View file

@ -11,7 +11,6 @@ import java.util.Set;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.content.contraptions.components.structureMovement.BlockMovementTraits;
import com.simibubi.create.content.contraptions.components.structureMovement.ChassisRangeDisplay;
import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;

View file

@ -1,4 +1,4 @@
package com.simibubi.create.content.contraptions.components.structureMovement;
package com.simibubi.create.content.contraptions.components.structureMovement.sync;
import java.util.function.Supplier;

View file

@ -1,7 +1,8 @@
package com.simibubi.create.content.contraptions.components.structureMovement;
package com.simibubi.create.content.contraptions.components.structureMovement.sync;
import java.util.function.Supplier;
import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionEntity;
import com.simibubi.create.foundation.networking.SimplePacketBase;
import net.minecraft.entity.Entity;

View file

@ -1,10 +1,11 @@
package com.simibubi.create.content.contraptions.components.structureMovement;
package com.simibubi.create.content.contraptions.components.structureMovement.sync;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.util.function.Supplier;
import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionEntity;
import com.simibubi.create.foundation.networking.SimplePacketBase;
import net.minecraft.client.Minecraft;
@ -44,12 +45,12 @@ public class ContraptionSeatMappingPacket extends SimplePacketBase {
public void handle(Supplier<Context> context) {
context.get()
.enqueueWork(() -> {
Entity entityByID = Minecraft.getInstance().world
.getEntityByID(entityID);
Entity entityByID = Minecraft.getInstance().world.getEntityByID(entityID);
if (!(entityByID instanceof ContraptionEntity))
return;
ContraptionEntity contraptionEntity = (ContraptionEntity) entityByID;
contraptionEntity.contraption.seatMapping = mapping;
contraptionEntity.getContraption()
.setSeatMapping(mapping);
});
context.get()
.setPacketHandled(true);

View file

@ -1,9 +1,11 @@
package com.simibubi.create;
package com.simibubi.create.events;
import java.util.ArrayList;
import java.util.List;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.Create;
import com.simibubi.create.CreateClient;
import com.simibubi.create.content.contraptions.KineticDebugger;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.content.contraptions.components.turntable.TurntableHandler;

View file

@ -1,5 +1,7 @@
package com.simibubi.create;
package com.simibubi.create.events;
import com.simibubi.create.Create;
import com.simibubi.create.CreateClient;
import com.simibubi.create.foundation.command.CreateCommand;
import net.minecraft.world.IWorld;
@ -20,7 +22,6 @@ public class CommonEvents {
public static void onTick(ServerTickEvent event) {
if (event.phase == Phase.END)
return;
Create.tick();
}

View file

@ -5,11 +5,11 @@ import java.util.function.Function;
import java.util.function.Supplier;
import com.simibubi.create.Create;
import com.simibubi.create.content.contraptions.components.structureMovement.ClientMotionPacket;
import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionInteractionPacket;
import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionSeatMappingPacket;
import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionStallPacket;
import com.simibubi.create.content.contraptions.components.structureMovement.glue.GlueEffectPacket;
import com.simibubi.create.content.contraptions.components.structureMovement.sync.ClientMotionPacket;
import com.simibubi.create.content.contraptions.components.structureMovement.sync.ContraptionInteractionPacket;
import com.simibubi.create.content.contraptions.components.structureMovement.sync.ContraptionSeatMappingPacket;
import com.simibubi.create.content.contraptions.relays.advanced.sequencer.ConfigureSequencedGearshiftPacket;
import com.simibubi.create.content.curiosities.symmetry.SymmetryEffectPacket;
import com.simibubi.create.content.curiosities.tools.ExtendoGripInteractionPacket;