mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-10 03:53:12 +01:00
port changes to 1.16
This commit is contained in:
parent
1a4814e724
commit
3e3b0dad6e
14 changed files with 59 additions and 528 deletions
|
@ -6,7 +6,7 @@ org.gradle.daemon=false
|
|||
# mod version info
|
||||
mod_version=0.3
|
||||
minecraft_version=1.16.3
|
||||
forge_version=34.0.9
|
||||
forge_version=34.1.17
|
||||
|
||||
# dependency versions
|
||||
registrate_version=1.0.0-beta.6
|
||||
|
|
|
@ -312,7 +312,7 @@ e8b0a401c10d1ba67ed71ba31bd5f9bc28571b65 assets/create/blockstates/powered_toggl
|
|||
469e430d96cb0a5e1aaf6b7cc5d401d488c9e600 assets/create/blockstates/pulse_repeater.json
|
||||
92957119abd5fbcca36a113b2a80255fd70fc303 assets/create/blockstates/purple_seat.json
|
||||
61035f8afe75ff7bbd291da5d8690bcbebe679eb assets/create/blockstates/purple_valve_handle.json
|
||||
4439fc83a8c7370ab44b211a3fd48abde20a4728 assets/create/blockstates/radial_chassis.json
|
||||
143d66a7262ccd29f36784d6b064d4a13ba374b6 assets/create/blockstates/radial_chassis.json
|
||||
da1b08387af7afa0855ee8d040f620c01f20660a assets/create/blockstates/red_seat.json
|
||||
722fc77bbf387af8a4016e42cbf9501d2b968881 assets/create/blockstates/red_valve_handle.json
|
||||
8929677f2cc5354aa19ef182af69f9f0b41eb242 assets/create/blockstates/redstone_contact.json
|
||||
|
@ -368,24 +368,6 @@ a3a11524cd3515fc01d905767b4b7ea782adaf03 assets/create/blockstates/yellow_seat.j
|
|||
7f39521b211441f5c3e06d60c5978cebe16cacfb assets/create/blockstates/zinc_block.json
|
||||
b7181bcd8182b2f17088e5aa881f374c9c65470c assets/create/blockstates/zinc_ore.json
|
||||
c113d0a180880243538e9b1c3019c863df3fbdc1 assets/create/lang/en_ud.json
|
||||
<<<<<<< HEAD
|
||||
a4cd12907a1ddfd60883077b2d11c5459d436016 assets/create/lang/en_us.json
|
||||
063195daed96a4420588e6d6d13f4a9b1f099ff4 assets/create/lang/unfinished/de_de.json
|
||||
30da89bafac8a5ea4d82903928ba4d2a63385117 assets/create/lang/unfinished/fr_fr.json
|
||||
faddc5022cc10c8fca1649d66427e910cfa28286 assets/create/lang/unfinished/it_it.json
|
||||
7f448e863397725c11ab083d39af68d205d579d7 assets/create/lang/unfinished/ja_jp.json
|
||||
48d61d21ee096513f2b9e06df38882cf6ace96db assets/create/lang/unfinished/ko_kr.json
|
||||
a908ecd03bd7ede95b5e5f0698157353ae2bec6c assets/create/lang/unfinished/nl_nl.json
|
||||
ffa305b619c58bdff92d2e69b2bbc81ad5b8dcb6 assets/create/lang/unfinished/pt_br.json
|
||||
6588d559aaafb4f036ba47ba2414caaa9d2f6f6a assets/create/lang/unfinished/ru_ru.json
|
||||
4593a6013875039a6a30ac64d45bb4f140190fe1 assets/create/lang/unfinished/zh_cn.json
|
||||
487a511a01b2a4531fb672f917922312db78f958 assets/create/models/block/acacia_window.json
|
||||
b48060cba1a382f373a05bf0039054053eccf076 assets/create/models/block/acacia_window_pane_noside.json
|
||||
3066db1bf03cffa1a9c7fbacf47ae586632f4eb3 assets/create/models/block/acacia_window_pane_noside_alt.json
|
||||
1358ff546e99004444fccca5355853d1738ef191 assets/create/models/block/acacia_window_pane_post.json
|
||||
bd33b944ec6ad89850a1d275b3d2843fe6f831cc assets/create/models/block/acacia_window_pane_side.json
|
||||
b272035cd746364a0bd3bf13061f51190e9b46d6 assets/create/models/block/acacia_window_pane_side_alt.json
|
||||
=======
|
||||
ee39bea21ca57e7b61f1af0d609d63cbbf8c8425 assets/create/lang/en_us.json
|
||||
233e7fae9df99bcb79d3e08f57e6d5e02bdf49ad assets/create/lang/unfinished/de_de.json
|
||||
d56a40fa6097af1badd3ab24bbcfa191ea5074ca assets/create/lang/unfinished/fr_fr.json
|
||||
|
@ -396,13 +378,12 @@ d56a40fa6097af1badd3ab24bbcfa191ea5074ca assets/create/lang/unfinished/fr_fr.jso
|
|||
2c0f9c853b85a47b91877cd7b89faddc918f0170 assets/create/lang/unfinished/pt_br.json
|
||||
7193bf2573473b3fa8ffd7c8a6dd58ce069201a7 assets/create/lang/unfinished/ru_ru.json
|
||||
28b75a0dd8c021a7e385b3479b91b1edd47f13f4 assets/create/lang/unfinished/zh_cn.json
|
||||
846200eb548d3bfa2e77b41039de159b4b6cfb45 assets/create/models/block/acacia_window.json
|
||||
1930fa3a3c98d53dd19e4ee7f55bc27fd47aa281 assets/create/models/block/acacia_window_pane_noside.json
|
||||
1763ea2c9b981d187f5031ba608f3d5d3be3986a assets/create/models/block/acacia_window_pane_noside_alt.json
|
||||
7d23c8e4543108f5f53b78ccb4908f7a5bb76c54 assets/create/models/block/acacia_window_pane_post.json
|
||||
3bdcc6bd616a179ffc22e66307aab538e9bcb75f assets/create/models/block/acacia_window_pane_side.json
|
||||
7b5b6809e3ef685a497ba15b549d3918aeb6c135 assets/create/models/block/acacia_window_pane_side_alt.json
|
||||
>>>>>>> mc1.15/dev
|
||||
487a511a01b2a4531fb672f917922312db78f958 assets/create/models/block/acacia_window.json
|
||||
b48060cba1a382f373a05bf0039054053eccf076 assets/create/models/block/acacia_window_pane_noside.json
|
||||
3066db1bf03cffa1a9c7fbacf47ae586632f4eb3 assets/create/models/block/acacia_window_pane_noside_alt.json
|
||||
1358ff546e99004444fccca5355853d1738ef191 assets/create/models/block/acacia_window_pane_post.json
|
||||
bd33b944ec6ad89850a1d275b3d2843fe6f831cc assets/create/models/block/acacia_window_pane_side.json
|
||||
b272035cd746364a0bd3bf13061f51190e9b46d6 assets/create/models/block/acacia_window_pane_side_alt.json
|
||||
7c81658c8839fdb23429e54f847c2a0aee0e866e assets/create/models/block/adjustable_pulley_end_horizontal.json
|
||||
20cfb751fc395a0e07c66ce87ab035207f9d1e0e assets/create/models/block/adjustable_pulley_end_horizontal_powered.json
|
||||
bb02f94b260be8fe1944b801cc4050b4d213f1df assets/create/models/block/adjustable_pulley_end_vertical.json
|
||||
|
@ -1105,15 +1086,9 @@ b0f664dd6de3d0ee9afcb6223fbcd53b97fa0d65 assets/create/models/item/andesite_cobb
|
|||
8861d656eb6f61320b4d80eb079105705c762079 assets/create/models/item/andesite_cobblestone_wall.json
|
||||
7490819e7e5445019b6b8cb2538f12a5b6717a46 assets/create/models/item/andesite_funnel.json
|
||||
75b8b00c2418b9660d35a7fabd0774925cf1c02f assets/create/models/item/andesite_pillar.json
|
||||
<<<<<<< HEAD
|
||||
795541cf7205d90531a23cd5b388f93a03bbf925 assets/create/models/item/andesite_tunnel.json
|
||||
bf1fc6bdf7fca6f1958a2d3e96202c1cecb50669 assets/create/models/item/basin.json
|
||||
ffdb36349fa2e50451c208585162b6a8386ec494 assets/create/models/item/belt_connector.json
|
||||
=======
|
||||
c0e35daccfb398947532e9499d6bda963387cd9c assets/create/models/item/andesite_tunnel.json
|
||||
421e481b7fbca4c4a1080ed703401eb25375e087 assets/create/models/item/basin.json
|
||||
1da382e7e58eaa9788f5b1d92221ccac573e068f assets/create/models/item/belt_connector.json
|
||||
>>>>>>> mc1.15/dev
|
||||
ffdb36349fa2e50451c208585162b6a8386ec494 assets/create/models/item/belt_connector.json
|
||||
9044243882cfd49a2827e1b910a4c9b0e46daa47 assets/create/models/item/birch_window.json
|
||||
d537fffaede521efa525fb2a7f9863fe6a80054e assets/create/models/item/birch_window_pane.json
|
||||
22632bd681c8a605f0845f7549770389a741156a assets/create/models/item/black_seat.json
|
||||
|
|
|
@ -149,8 +149,8 @@
|
|||
},
|
||||
{
|
||||
"when": {
|
||||
"axis": "x",
|
||||
"sticky_north": "true"
|
||||
"sticky_north": "true",
|
||||
"axis": "x"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/radial_chassis_side_x_sticky"
|
||||
|
@ -158,8 +158,8 @@
|
|||
},
|
||||
{
|
||||
"when": {
|
||||
"axis": "y",
|
||||
"sticky_north": "true"
|
||||
"sticky_north": "true",
|
||||
"axis": "y"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/radial_chassis_side_y_sticky",
|
||||
|
@ -168,8 +168,8 @@
|
|||
},
|
||||
{
|
||||
"when": {
|
||||
"axis": "z",
|
||||
"sticky_north": "true"
|
||||
"sticky_north": "true",
|
||||
"axis": "z"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/radial_chassis_side_x_sticky",
|
||||
|
@ -178,8 +178,8 @@
|
|||
},
|
||||
{
|
||||
"when": {
|
||||
"axis": "x",
|
||||
"sticky_north": "false"
|
||||
"sticky_north": "false",
|
||||
"axis": "x"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/radial_chassis_side_x"
|
||||
|
@ -187,8 +187,8 @@
|
|||
},
|
||||
{
|
||||
"when": {
|
||||
"axis": "y",
|
||||
"sticky_north": "false"
|
||||
"sticky_north": "false",
|
||||
"axis": "y"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/radial_chassis_side_y",
|
||||
|
@ -197,8 +197,8 @@
|
|||
},
|
||||
{
|
||||
"when": {
|
||||
"axis": "z",
|
||||
"sticky_north": "false"
|
||||
"sticky_north": "false",
|
||||
"axis": "z"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/radial_chassis_side_x",
|
||||
|
@ -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"
|
||||
|
|
|
@ -14,6 +14,7 @@ import com.simibubi.create.foundation.item.ItemHelper;
|
|||
import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
|
||||
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
|
||||
import com.simibubi.create.foundation.tileEntity.behaviour.belt.DirectBeltInputBehaviour;
|
||||
import com.simibubi.create.foundation.utility.NBTHelper;
|
||||
import com.simibubi.create.foundation.utility.VecHelper;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
|
@ -224,7 +225,7 @@ public class CrushingWheelControllerTileEntity extends SmartTileEntity {
|
|||
protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) {
|
||||
super.fromTag(state, compound, clientPacket);
|
||||
if (compound.contains("Entity") && !isOccupied()) {
|
||||
entityUUID = NBTUtil.readUniqueId(compound.getCompound("Entity"));
|
||||
entityUUID = NBTUtil.readUniqueId(NBTHelper.getINBT(compound, "Entity"));
|
||||
this.searchForEntity = true;
|
||||
}
|
||||
crushingspeed = compound.getFloat("Speed");
|
||||
|
|
|
@ -512,7 +512,7 @@ public abstract class Contraption {
|
|||
|
||||
seatMapping.clear();
|
||||
NBTHelper.iterateCompoundList(nbt.getList("Passengers", NBT.TAG_COMPOUND),
|
||||
c -> seatMapping.put(NBTUtil.readUniqueId(c.getCompound("Id")), c.getInt("Seat")));
|
||||
c -> seatMapping.put(NBTUtil.readUniqueId(NBTHelper.getINBT(c, "Id")), c.getInt("Seat")));
|
||||
|
||||
storage.clear();
|
||||
NBTHelper.iterateCompoundList(nbt.getList("Storage", NBT.TAG_COMPOUND), c -> storage
|
||||
|
|
|
@ -765,7 +765,7 @@ public class ContraptionEntity extends Entity implements IEntityAdditionalSpawnD
|
|||
if (compound.contains("Controller"))
|
||||
controllerPos = NBTUtil.readBlockPos(compound.getCompound("Controller"));
|
||||
setCouplingId(
|
||||
compound.contains("OnCoupling") ? NBTUtil.readUniqueId(compound.getCompound("OnCoupling")) : null);
|
||||
compound.contains("OnCoupling") ? NBTUtil.readUniqueId(NBTHelper.getINBT(compound, "OnCoupling")) : null);
|
||||
}
|
||||
|
||||
public void startAtInitialYaw() {
|
||||
|
|
|
@ -21,7 +21,6 @@ import net.minecraft.entity.item.minecart.AbstractMinecartEntity;
|
|||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.event.entity.EntityMountEvent;
|
||||
|
@ -178,7 +177,7 @@ public class CouplingHandler {
|
|||
public static void status(PlayerEntity player, String key) {
|
||||
if (player == null)
|
||||
return;
|
||||
player.sendStatusMessage(new StringTextComponent(Lang.translate("minecart_coupling." + key)), true);
|
||||
player.sendStatusMessage(Lang.translate("minecart_coupling." + key), true);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import net.minecraft.entity.MoverType;
|
|||
import net.minecraft.entity.item.minecart.AbstractMinecartEntity;
|
||||
import net.minecraft.state.properties.RailShape;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vector3d;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class CouplingPhysics {
|
||||
|
@ -76,7 +76,7 @@ public class CouplingPhysics {
|
|||
|
||||
public static void softCollisionStep(World world, Couple<AbstractMinecartEntity> carts, double couplingLength) {
|
||||
|
||||
Couple<Vector3d> positions = carts.map(Entity::getPositionVector);
|
||||
Couple<Vector3d> positions = carts.map(Entity::getPositionVec);
|
||||
Couple<Float> maxSpeed = carts.map(AbstractMinecartEntity::getMaxCartSpeedOnRail);
|
||||
Couple<Boolean> canAddmotion = carts.map(MinecartSim2020::canAddMotion);
|
||||
|
||||
|
|
|
@ -1,65 +0,0 @@
|
|||
package com.simibubi.create.content.contraptions.components.structureMovement.train;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.simibubi.create.foundation.utility.NBTHelper;
|
||||
|
||||
import net.minecraft.entity.item.minecart.AbstractMinecartEntity;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.nbt.NBTUtil;
|
||||
import net.minecraftforge.common.util.Constants.NBT;
|
||||
|
||||
public class MinecartCouplingSerializer {
|
||||
|
||||
public static void addCouplingToCart(AbstractMinecartEntity minecart, MinecartCoupling coupling) {
|
||||
CompoundNBT nbt = minecart.getPersistentData();
|
||||
ListNBT couplingList = nbt.getList("Couplings", NBT.TAG_COMPOUND);
|
||||
boolean main = coupling.mainCart.get() == minecart;
|
||||
couplingList.add(createCouplingTag(main, coupling));
|
||||
nbt.put("Couplings", couplingList);
|
||||
}
|
||||
|
||||
public static void removeCouplingFromCart(AbstractMinecartEntity minecart, MinecartCoupling coupling) {
|
||||
CompoundNBT nbt = minecart.getPersistentData();
|
||||
ListNBT couplingList = nbt.getList("Couplings", NBT.TAG_COMPOUND);
|
||||
couplingList.removeIf(inbt -> coupling.getId()
|
||||
.equals(NBTUtil.readUniqueId(((CompoundNBT) inbt).getCompound("Id"))));
|
||||
nbt.put("Couplings", couplingList);
|
||||
}
|
||||
|
||||
private static CompoundNBT createCouplingTag(boolean main, MinecartCoupling coupling) {
|
||||
CompoundNBT nbt = new CompoundNBT();
|
||||
nbt.put("Id", NBTUtil.fromUuid(coupling.getId()));
|
||||
nbt.putBoolean("Main", main);
|
||||
nbt.putDouble("Length", coupling.length);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
public static List<CouplingData> getCouplingData(AbstractMinecartEntity minecart) {
|
||||
List<CouplingData> list = new ArrayList<>();
|
||||
CompoundNBT nbt = minecart.getPersistentData();
|
||||
NBTHelper.iterateCompoundList(nbt.getList("Couplings", NBT.TAG_COMPOUND), c -> {
|
||||
boolean main = c.getBoolean("Main");
|
||||
UUID id = NBTUtil.readUniqueId(c.getCompound("Id"));
|
||||
double length = c.getDouble("Length");
|
||||
list.add(new CouplingData(main, id, length));
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
static class CouplingData {
|
||||
boolean main;
|
||||
UUID id;
|
||||
double length;
|
||||
|
||||
public CouplingData(boolean main, UUID id, double length) {
|
||||
this.main = main;
|
||||
this.id = id;
|
||||
this.length = length;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,385 +0,0 @@
|
|||
package com.simibubi.create.content.contraptions.components.structureMovement.train;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.simibubi.create.CreateClient;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionEntity;
|
||||
import com.simibubi.create.foundation.utility.ColorHelper;
|
||||
import com.simibubi.create.foundation.utility.Couple;
|
||||
import com.simibubi.create.foundation.utility.Iterate;
|
||||
import com.simibubi.create.foundation.utility.VecHelper;
|
||||
|
||||
import net.minecraft.block.AbstractRailBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.MoverType;
|
||||
import net.minecraft.entity.item.minecart.AbstractMinecartEntity;
|
||||
import net.minecraft.state.properties.RailShape;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class MinecartTrain {
|
||||
|
||||
protected ArrayList<MinecartCoupling> couplings;
|
||||
protected double momentum;
|
||||
boolean complete;
|
||||
|
||||
public MinecartTrain(MinecartCoupling coupling) {
|
||||
couplings = new ArrayList<>();
|
||||
couplings.add(coupling);
|
||||
tickOrder = 1; // start at most stressed
|
||||
}
|
||||
|
||||
public void flip(World world) {
|
||||
Collections.reverse(couplings);
|
||||
couplings.forEach(c -> MinecartCouplingHandler.flipCoupling(world, c));
|
||||
}
|
||||
|
||||
public void mergeOnto(World world, MinecartTrain other) {
|
||||
AbstractMinecartEntity trailingOfOther = other.couplings.get(other.couplings.size() - 1).connectedCart.get();
|
||||
AbstractMinecartEntity leadingOfThis = couplings.get(0).mainCart.get();
|
||||
|
||||
if (trailingOfOther != leadingOfThis)
|
||||
flip(world);
|
||||
|
||||
other.couplings.addAll(couplings);
|
||||
}
|
||||
|
||||
public int tickOrder;
|
||||
|
||||
public void tickCouplings(World world) {
|
||||
|
||||
// SOFT collision - modify motion of carts with stressed links @t+1
|
||||
double sharedMotion = 0;
|
||||
int participants = 0;
|
||||
boolean stall = false;
|
||||
|
||||
for (int i = 0; i < couplings.size(); i++) {
|
||||
MinecartCoupling minecartCoupling = couplings.get(i);
|
||||
boolean last = i + 1 == couplings.size();
|
||||
if (!minecartCoupling.areBothEndsPresent())
|
||||
continue;
|
||||
participants++;
|
||||
sharedMotion += minecartCoupling.mainCart.get()
|
||||
.getMotion()
|
||||
.length();
|
||||
|
||||
List<Entity> passengers = minecartCoupling.mainCart.get().getPassengers();
|
||||
if (!passengers.isEmpty() && passengers.get(0) instanceof ContraptionEntity)
|
||||
if (((ContraptionEntity) passengers.get(0)).isStalled()) {
|
||||
stall = true;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (last) {
|
||||
participants++;
|
||||
sharedMotion += minecartCoupling.connectedCart.get()
|
||||
.getMotion()
|
||||
.length();
|
||||
}
|
||||
}
|
||||
|
||||
if (participants == 0)
|
||||
return;
|
||||
|
||||
sharedMotion /= participants;
|
||||
|
||||
/*
|
||||
* Tick order testing: 0: start from motion outlier 1: start at most stressed
|
||||
* coupling 2: start at front 3: start at back
|
||||
*/
|
||||
|
||||
if (tickOrder == 0) {
|
||||
// Iterate starting from biggest outlier in motion
|
||||
double maxDiff = 0;
|
||||
int argMax = 0;
|
||||
for (int i = 0; i < couplings.size(); i++) {
|
||||
MinecartCoupling minecartCoupling = couplings.get(i);
|
||||
boolean last = i + 1 == couplings.size();
|
||||
if (!minecartCoupling.areBothEndsPresent())
|
||||
continue;
|
||||
|
||||
double diff = Math.abs(minecartCoupling.mainCart.get()
|
||||
.getMotion()
|
||||
.length() - sharedMotion);
|
||||
if (diff > maxDiff) {
|
||||
maxDiff = diff;
|
||||
argMax = i;
|
||||
}
|
||||
|
||||
if (last) {
|
||||
diff = Math.abs(minecartCoupling.connectedCart.get()
|
||||
.getMotion()
|
||||
.length() - sharedMotion);
|
||||
if (diff > maxDiff) {
|
||||
maxDiff = diff;
|
||||
argMax = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (boolean hard : Iterate.trueAndFalse) {
|
||||
for (int i = argMax - 1; i >= 0; i--)
|
||||
if (couplings.get(i)
|
||||
.areBothEndsPresent())
|
||||
collisionStep(world, couplings.get(i)
|
||||
.asCouple()
|
||||
.swap(), couplings.get(i).length, hard);
|
||||
for (int i = argMax; i < couplings.size(); i++)
|
||||
if (couplings.get(i)
|
||||
.areBothEndsPresent())
|
||||
collisionStep(world, couplings.get(i)
|
||||
.asCouple()
|
||||
.swap(), couplings.get(i).length, hard);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (tickOrder == 1) {
|
||||
// Iterate starting from biggest stress
|
||||
double maxStress = 0;
|
||||
int argMax = 0;
|
||||
for (int i = 0; i < couplings.size(); i++) {
|
||||
MinecartCoupling minecartCoupling = couplings.get(i);
|
||||
if (!minecartCoupling.areBothEndsPresent())
|
||||
continue;
|
||||
|
||||
if (stall) {
|
||||
minecartCoupling.asCouple().forEach(ame -> ame.setMotion(Vector3d.ZERO));
|
||||
continue;
|
||||
}
|
||||
|
||||
double stress = getStressOfCoupling(minecartCoupling);
|
||||
if (stress > maxStress) {
|
||||
maxStress = stress;
|
||||
argMax = i;
|
||||
}
|
||||
}
|
||||
|
||||
for (boolean hard : Iterate.trueAndFalse) {
|
||||
for (int i = argMax - 1; i >= 0; i--)
|
||||
if (couplings.get(i)
|
||||
.areBothEndsPresent())
|
||||
collisionStep(world, couplings.get(i)
|
||||
.asCouple()
|
||||
.swap(), couplings.get(i).length, hard);
|
||||
for (int i = argMax; i < couplings.size(); i++)
|
||||
if (couplings.get(i)
|
||||
.areBothEndsPresent())
|
||||
collisionStep(world, couplings.get(i)
|
||||
.asCouple()
|
||||
.swap(), couplings.get(i).length, hard);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (momentum >= 0 == (tickOrder == 2)) {
|
||||
// Iterate front to back
|
||||
for (boolean hard : Iterate.trueAndFalse)
|
||||
for (int i = 0; i < couplings.size(); i++)
|
||||
if (couplings.get(i)
|
||||
.areBothEndsPresent())
|
||||
collisionStep(world, couplings.get(i)
|
||||
.asCouple()
|
||||
.swap(), couplings.get(i).length, hard);
|
||||
|
||||
} else {
|
||||
// Iterate back to front
|
||||
for (boolean hard : Iterate.trueAndFalse)
|
||||
for (int i = couplings.size() - 1; i >= 0; i--)
|
||||
if (couplings.get(i)
|
||||
.areBothEndsPresent())
|
||||
collisionStep(world, couplings.get(i)
|
||||
.asCouple()
|
||||
.swap(), couplings.get(i).length, hard);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private float getStressOfCoupling(MinecartCoupling coupling) {
|
||||
if (!coupling.areBothEndsPresent())
|
||||
return 0;
|
||||
return (float) (coupling.length - coupling.mainCart.get()
|
||||
.getPositionVec()
|
||||
.distanceTo(coupling.connectedCart.get()
|
||||
.getPositionVec()));
|
||||
}
|
||||
|
||||
public void collisionStep(World world, Couple<AbstractMinecartEntity> carts, double couplingLength, boolean hard) {
|
||||
if (hard)
|
||||
hardCollisionStep(world, carts, couplingLength);
|
||||
else
|
||||
softCollisionStep(world, carts, couplingLength);
|
||||
}
|
||||
|
||||
public void hardCollisionStep(World world, Couple<AbstractMinecartEntity> carts, double couplingLength) {
|
||||
Couple<Vector3d> corrections = Couple.create(null, null);
|
||||
Couple<Float> maxSpeed = carts.map(AbstractMinecartEntity::getMaxCartSpeedOnRail);
|
||||
boolean firstLoop = true;
|
||||
for (boolean current : new boolean[] { true, false, true }) {
|
||||
AbstractMinecartEntity cart = carts.get(current);
|
||||
AbstractMinecartEntity otherCart = carts.get(!current);
|
||||
|
||||
float stress = (float) (couplingLength - cart.getPositionVec()
|
||||
.distanceTo(otherCart.getPositionVec()));
|
||||
|
||||
RailShape shape = null;
|
||||
BlockPos railPosition = cart.getCurrentRailPosition();
|
||||
BlockState railState = world.getBlockState(railPosition.up());
|
||||
|
||||
if (railState.getBlock() instanceof AbstractRailBlock) {
|
||||
AbstractRailBlock block = (AbstractRailBlock) railState.getBlock();
|
||||
shape = block.getRailDirection(railState, world, railPosition, cart);
|
||||
}
|
||||
|
||||
Vector3d correction = Vector3d.ZERO;
|
||||
Vector3d pos = cart.getPositionVec();
|
||||
Vector3d link = otherCart.getPositionVec()
|
||||
.subtract(pos);
|
||||
float correctionMagnitude = firstLoop ? -stress / 2f : -stress;
|
||||
correction = shape != null ? followLinkOnRail(link, pos, correctionMagnitude, shape).subtract(pos)
|
||||
: link.normalize()
|
||||
.scale(correctionMagnitude);
|
||||
|
||||
float maxResolveSpeed = 1.75f;
|
||||
correction = VecHelper.clamp(correction, Math.min(maxResolveSpeed, maxSpeed.get(current)));
|
||||
|
||||
if (corrections.get(current) == null)
|
||||
corrections.set(current, correction);
|
||||
|
||||
if (shape != null)
|
||||
MinecartSim2020.moveCartAlongTrack(cart, correction, railPosition, railState);
|
||||
else {
|
||||
cart.move(MoverType.SELF, correction);
|
||||
cart.setMotion(cart.getMotion()
|
||||
.scale(0.5f));
|
||||
}
|
||||
firstLoop = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void softCollisionStep(World world, Couple<AbstractMinecartEntity> carts, double couplingLength) {
|
||||
|
||||
Couple<Vector3d> positions = carts.map(Entity::getPositionVec);
|
||||
Couple<Float> maxSpeed = carts.map(AbstractMinecartEntity::getMaxCartSpeedOnRail);
|
||||
Couple<Boolean> canAddmotion = carts.map(MinecartSim2020::canAddMotion);
|
||||
|
||||
Couple<RailShape> shapes = carts.map(current -> {
|
||||
BlockPos railPosition = current.getCurrentRailPosition();
|
||||
BlockState railState = world.getBlockState(railPosition.up());
|
||||
if (!(railState.getBlock() instanceof AbstractRailBlock))
|
||||
return null;
|
||||
AbstractRailBlock block = (AbstractRailBlock) railState.getBlock();
|
||||
return block.getRailDirection(railState, world, railPosition, current);
|
||||
});
|
||||
|
||||
Couple<Vector3d> motions = carts.map(MinecartSim2020::predictMotionOf);
|
||||
Couple<Vector3d> nextPositions = positions.copy();
|
||||
nextPositions.replaceWithParams(Vector3d::add, motions);
|
||||
|
||||
float futureStress = (float) (couplingLength - nextPositions.getFirst()
|
||||
.distanceTo(nextPositions.getSecond()));
|
||||
if (Math.abs(futureStress) < 1 / 128f)
|
||||
return;
|
||||
|
||||
for (boolean current : Iterate.trueAndFalse) {
|
||||
Vector3d correction = Vector3d.ZERO;
|
||||
Vector3d pos = nextPositions.get(current);
|
||||
Vector3d link = nextPositions.get(!current)
|
||||
.subtract(pos);
|
||||
float correctionMagnitude = -futureStress / 2f;
|
||||
|
||||
if (canAddmotion.get(current) != canAddmotion.get(!current))
|
||||
correctionMagnitude = !canAddmotion.get(current) ? 0 : correctionMagnitude * 2;
|
||||
|
||||
RailShape shape = shapes.get(current);
|
||||
correction = shape != null ? followLinkOnRail(link, pos, correctionMagnitude, shape).subtract(pos)
|
||||
: link.normalize()
|
||||
.scale(correctionMagnitude);
|
||||
correction = VecHelper.clamp(correction, maxSpeed.get(current));
|
||||
motions.set(current, motions.get(current)
|
||||
.add(correction));
|
||||
}
|
||||
|
||||
motions.replaceWithParams(VecHelper::clamp, maxSpeed);
|
||||
carts.forEachWithParams(Entity::setMotion, motions);
|
||||
}
|
||||
|
||||
public static Vector3d followLinkOnRail(Vector3d link, Vector3d cart, float diffToReduce, RailShape shape) {
|
||||
Vector3d railAxis = getRailVec(shape);
|
||||
double dotProduct = railAxis.dotProduct(link);
|
||||
if (Double.isNaN(dotProduct) || dotProduct == 0 || diffToReduce == 0)
|
||||
return cart;
|
||||
|
||||
Vector3d axis = railAxis.scale(-Math.signum(dotProduct));
|
||||
Vector3d center = cart.add(link);
|
||||
double radius = link.length() - diffToReduce;
|
||||
Vector3d intersectSphere = VecHelper.intersectSphere(cart, axis, center, radius);
|
||||
|
||||
// Cannot satisfy on current rail vector
|
||||
if (intersectSphere == null)
|
||||
return cart.add(VecHelper.project(link, axis));
|
||||
|
||||
return intersectSphere;
|
||||
}
|
||||
|
||||
private static Vector3d getRailVec(RailShape shape) {
|
||||
switch (shape) {
|
||||
case ASCENDING_NORTH:
|
||||
case ASCENDING_SOUTH:
|
||||
case NORTH_SOUTH:
|
||||
return new Vector3d(0, 0, 1);
|
||||
case ASCENDING_EAST:
|
||||
case ASCENDING_WEST:
|
||||
case EAST_WEST:
|
||||
return new Vector3d(1, 0, 0);
|
||||
case NORTH_EAST:
|
||||
case SOUTH_WEST:
|
||||
return new Vector3d(1, 0, 1).normalize();
|
||||
case NORTH_WEST:
|
||||
case SOUTH_EAST:
|
||||
return new Vector3d(1, 0, -1).normalize();
|
||||
default:
|
||||
return new Vector3d(0, 1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public UUID getId() {
|
||||
return couplings.get(0)
|
||||
.getId();
|
||||
}
|
||||
|
||||
public static void doDebugRender(World world, MinecartCoupling coupling, int index) {
|
||||
AbstractMinecartEntity mainCart = coupling.mainCart.get();
|
||||
AbstractMinecartEntity connectedCart = coupling.connectedCart.get();
|
||||
|
||||
if (!coupling.areBothEndsPresent())
|
||||
return;
|
||||
|
||||
int yOffset = 1;
|
||||
Vector3d mainCenter = mainCart.getPositionVec()
|
||||
.add(0, yOffset, 0);
|
||||
Vector3d connectedCenter = connectedCart.getPositionVec()
|
||||
.add(0, yOffset, 0);
|
||||
|
||||
int color = ColorHelper.mixColors(0xabf0e9, 0xee8572,
|
||||
(float) MathHelper.clamp(Math.abs(coupling.length - connectedCenter.distanceTo(mainCenter)) * 8, 0, 1));
|
||||
|
||||
CreateClient.outliner.showLine(coupling + "" + index, mainCenter, connectedCenter)
|
||||
.colored(color)
|
||||
.lineWidth(1 / 8f);
|
||||
|
||||
Vector3d point = mainCart.getPositionVec()
|
||||
.add(0, yOffset, 0);
|
||||
CreateClient.outliner.showLine(coupling.getId() + "" + index, point, point.add(0, 1 / 128f, 0))
|
||||
.colored(0xffffff)
|
||||
.lineWidth(1 / 4f);
|
||||
}
|
||||
|
||||
}
|
|
@ -26,7 +26,7 @@ import net.minecraft.nbt.CompoundNBT;
|
|||
import net.minecraft.nbt.INBT;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.util.math.Vector3d;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.CapabilityInject;
|
||||
|
|
|
@ -8,6 +8,8 @@ import java.util.UUID;
|
|||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.simibubi.create.foundation.utility.NBTHelper;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import org.apache.commons.lang3.mutable.MutableBoolean;
|
||||
|
||||
import com.simibubi.create.Create;
|
||||
|
@ -22,7 +24,6 @@ import net.minecraft.entity.Entity;
|
|||
import net.minecraft.entity.item.minecart.AbstractMinecartEntity;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.NBTUtil;
|
||||
import net.minecraft.util.math.Vector3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.Constants.NBT;
|
||||
import net.minecraftforge.common.util.INBTSerializable;
|
||||
|
@ -323,16 +324,16 @@ public class MinecartController implements INBTSerializable<CompoundNBT> {
|
|||
|
||||
CompoundNBT serialize() {
|
||||
CompoundNBT nbt = new CompoundNBT();
|
||||
nbt.put("Main", NBTUtil.writeUniqueId(mainCartID));
|
||||
nbt.put("Connected", NBTUtil.writeUniqueId(connectedCartID));
|
||||
nbt.put("Main", NBTUtil.fromUuid(mainCartID));
|
||||
nbt.put("Connected", NBTUtil.fromUuid(connectedCartID));
|
||||
nbt.putFloat("Length", length);
|
||||
nbt.putBoolean("Contraption", contraption);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
static CouplingData read(CompoundNBT nbt) {
|
||||
UUID mainCartID = NBTUtil.readUniqueId(nbt.getCompound("Main"));
|
||||
UUID connectedCartID = NBTUtil.readUniqueId(nbt.getCompound("Connected"));
|
||||
UUID mainCartID = NBTUtil.readUniqueId(NBTHelper.getINBT(nbt, "Main"));
|
||||
UUID connectedCartID = NBTUtil.readUniqueId(NBTHelper.getINBT(nbt, "Connected"));
|
||||
float length = nbt.getFloat("Length");
|
||||
boolean contraption = nbt.getBoolean("Contraption");
|
||||
return new CouplingData(mainCartID, connectedCartID, length, contraption);
|
||||
|
|
|
@ -21,18 +21,12 @@ import net.minecraft.block.Blocks;
|
|||
import net.minecraft.block.FireBlock;
|
||||
import net.minecraft.block.FlowingFluidBlock;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.Atlases;
|
||||
import net.minecraft.client.renderer.BlockRendererDispatcher;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.RenderTypeLookup;
|
||||
import net.minecraft.client.renderer.*;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraft.inventory.container.PlayerContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
|
|
@ -8,9 +8,12 @@ import java.util.function.Function;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.FloatNBT;
|
||||
import net.minecraft.nbt.INBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class NBTHelper {
|
||||
|
||||
public static void putMarker(CompoundNBT nbt, String marker) {
|
||||
|
@ -76,4 +79,12 @@ public class NBTHelper {
|
|||
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static INBT getINBT(CompoundNBT nbt, String id) {
|
||||
INBT inbt = nbt.get(id);
|
||||
if (inbt != null)
|
||||
return inbt;
|
||||
return new CompoundNBT();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue