Minecarts of Mass Destruction

- Contraptions with exceeding spawn packet sizes no longer get sent to the client
- Minecart Contraptions with exceeding nbt packet sizes can no longer be picked up
- Renamed "Metal Blocks" to "Blocks of Metal"
This commit is contained in:
simibubi 2021-04-15 20:23:50 +02:00
parent f9d48386ca
commit 3dfe67cd1e
19 changed files with 155 additions and 71 deletions

View file

@ -406,20 +406,20 @@ a3a11524cd3515fc01d905767b4b7ea782adaf03 assets/create/blockstates/yellow_seat.j
6801fa1f466f172700e573e5b8ee8ee5f9ca4583 assets/create/blockstates/yellow_valve_handle.json
7f39521b211441f5c3e06d60c5978cebe16cacfb assets/create/blockstates/zinc_block.json
b7181bcd8182b2f17088e5aa881f374c9c65470c assets/create/blockstates/zinc_ore.json
768a724d6c921cb92790364cf7a692fe8742a885 assets/create/lang/en_ud.json
5f5c7ddeea65263977262ae9eef8284a27b342ed assets/create/lang/en_us.json
784fce1f5ae7d571449e8c2645aedca2ae54017d assets/create/lang/unfinished/de_de.json
72dc91f3968daa908451a91514573fa081ba1011 assets/create/lang/unfinished/es_es.json
e7f818f6250f6a9bcb68d29e3c4a42f4d97d191f assets/create/lang/unfinished/es_mx.json
a3c830d49cb7fbc3942c316859ffe46304dcbb07 assets/create/lang/unfinished/fr_fr.json
8263ba5d778e8d8a3255319ab08cee080930345d assets/create/lang/unfinished/it_it.json
76d31adf175b248b9a4b63d7b02005155a0e961f assets/create/lang/unfinished/ja_jp.json
78fc9b2f5695019465930da7b3d20b519d53d128 assets/create/lang/unfinished/ko_kr.json
c3d24b55cf0f6a4a3ff673e3a07872f055a8747a assets/create/lang/unfinished/nl_nl.json
dee268b4a8c1aace69527b8064b40590a8c63165 assets/create/lang/unfinished/pt_br.json
651af36f14adb7851c1a78551bd6631847893b8c assets/create/lang/unfinished/ru_ru.json
67dde4056c63b166a48bd9b6dec95ef42d28f826 assets/create/lang/unfinished/zh_cn.json
1f3e13923f4d9285b14d494576a10589fe2f3c6d assets/create/lang/unfinished/zh_tw.json
97e9ee471ea650f6b7f3d3f39f00201cd5ad752d assets/create/lang/en_ud.json
3878d0d84b9575728bd299385af2a61bd3a84243 assets/create/lang/en_us.json
33296621c4421a2dc329a3739d8efafbb3b5b57a assets/create/lang/unfinished/de_de.json
052248ce9880cb3db937fed06c6d46a3ca77d1b4 assets/create/lang/unfinished/es_es.json
05d9d186ad4888c2dcb1eb08fe9b78e1e5482cd7 assets/create/lang/unfinished/es_mx.json
dea56d5fcda7baf23d5938b43c1770b5cd76c6f6 assets/create/lang/unfinished/fr_fr.json
56513c7dd8f8ce309b0f77019a2b1b0a55c0cf38 assets/create/lang/unfinished/it_it.json
888191ed07af611597d5ff852ca3d6cb6bf803b7 assets/create/lang/unfinished/ja_jp.json
95fcbeeffd2ced25371f86c9529d4108bf26f930 assets/create/lang/unfinished/ko_kr.json
03e170a7196c4c76942e8b6fde2b0a0b9b877113 assets/create/lang/unfinished/nl_nl.json
a1e092ee4a6eb19568f36535f183afe1d326f0cf assets/create/lang/unfinished/pt_br.json
74b3356506bdb4bf7046768bd7735fa95057d61a assets/create/lang/unfinished/ru_ru.json
ce16cef5a488c2f86def742ca2e436cb42e18552 assets/create/lang/unfinished/zh_cn.json
b55d5abac95ba2649f656857f54b39f98e686767 assets/create/lang/unfinished/zh_tw.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

View file

@ -32,7 +32,7 @@
"block.create.blue_seat": "\u0287\u0250\u01DDS \u01DDn\u05DF\u15FA",
"block.create.blue_valve_handle": "\u01DD\u05DFpu\u0250H \u01DD\u028C\u05DF\u0250\u039B \u01DDn\u05DF\u15FA",
"block.create.brass_belt_funnel": "\u05DF\u01DDuun\u2132 \u0287\u05DF\u01DD\u15FA ss\u0250\u0279\u15FA",
"block.create.brass_block": "\u029E\u0254o\u05DF\u15FA ss\u0250\u0279\u15FA",
"block.create.brass_block": "ss\u0250\u0279\u15FA \u025Fo \u029E\u0254o\u05DF\u15FA",
"block.create.brass_casing": "bu\u0131s\u0250\u0186 ss\u0250\u0279\u15FA",
"block.create.brass_encased_shaft": "\u0287\u025F\u0250\u0265S p\u01DDs\u0250\u0254u\u018E ss\u0250\u0279\u15FA",
"block.create.brass_funnel": "\u05DF\u01DDuun\u2132 ss\u0250\u0279\u15FA",
@ -54,7 +54,7 @@
"block.create.cogwheel": "\u05DF\u01DD\u01DD\u0265\u028Dbo\u0186",
"block.create.content_observer": "\u0279\u01DD\u028C\u0279\u01DDsqO \u0287u\u01DD\u0287uo\u0186",
"block.create.controller_rail": "\u05DF\u0131\u0250\u1D1A \u0279\u01DD\u05DF\u05DFo\u0279\u0287uo\u0186",
"block.create.copper_block": "\u029E\u0254o\u05DF\u15FA \u0279\u01DDddo\u0186",
"block.create.copper_block": "\u0279\u01DDddo\u0186 \u025Fo \u029E\u0254o\u05DF\u15FA",
"block.create.copper_casing": "bu\u0131s\u0250\u0186 \u0279\u01DDddo\u0186",
"block.create.copper_ore": "\u01DD\u0279O \u0279\u01DDddo\u0186",
"block.create.copper_shingles": "s\u01DD\u05DFbu\u0131\u0265S \u0279\u01DDddo\u0186",
@ -405,7 +405,7 @@
"block.create.yellow_sail": "\u05DF\u0131\u0250S \u028Do\u05DF\u05DF\u01DD\u028E",
"block.create.yellow_seat": "\u0287\u0250\u01DDS \u028Do\u05DF\u05DF\u01DD\u028E",
"block.create.yellow_valve_handle": "\u01DD\u05DFpu\u0250H \u01DD\u028C\u05DF\u0250\u039B \u028Do\u05DF\u05DF\u01DD\u028E",
"block.create.zinc_block": "\u029E\u0254o\u05DF\u15FA \u0254u\u0131Z",
"block.create.zinc_block": "\u0254u\u0131Z \u025Fo \u029E\u0254o\u05DF\u15FA",
"block.create.zinc_ore": "\u01DD\u0279O \u0254u\u0131Z",
"entity.create.contraption": "uo\u0131\u0287d\u0250\u0279\u0287uo\u0186",
"entity.create.gantry_contraption": "uo\u0131\u0287d\u0250\u0279\u0287uo\u0186 \u028E\u0279\u0287u\u0250\u2141",

View file

@ -35,7 +35,7 @@
"block.create.blue_seat": "Blue Seat",
"block.create.blue_valve_handle": "Blue Valve Handle",
"block.create.brass_belt_funnel": "Brass Belt Funnel",
"block.create.brass_block": "Brass Block",
"block.create.brass_block": "Block of Brass",
"block.create.brass_casing": "Brass Casing",
"block.create.brass_encased_shaft": "Brass Encased Shaft",
"block.create.brass_funnel": "Brass Funnel",
@ -57,7 +57,7 @@
"block.create.cogwheel": "Cogwheel",
"block.create.content_observer": "Content Observer",
"block.create.controller_rail": "Controller Rail",
"block.create.copper_block": "Copper Block",
"block.create.copper_block": "Block of Copper",
"block.create.copper_casing": "Copper Casing",
"block.create.copper_ore": "Copper Ore",
"block.create.copper_shingles": "Copper Shingles",
@ -408,7 +408,7 @@
"block.create.yellow_sail": "Yellow Sail",
"block.create.yellow_seat": "Yellow Seat",
"block.create.yellow_valve_handle": "Yellow Valve Handle",
"block.create.zinc_block": "Zinc Block",
"block.create.zinc_block": "Block of Zinc",
"block.create.zinc_ore": "Zinc Ore",
"entity.create.contraption": "Contraption",
@ -1147,6 +1147,8 @@
"create.command.killTPSCommand.status.usage.1": "[Create]: use /killtps start <tickTime> to artificially slow down the server tick",
"create.command.killTPSCommand.argument.tickTime": "tickTime",
"create.contraption.minecart_contraption_too_big": "This Cart Contraption seems too big to pick up",
"_": "->------------------------] Subtitles [------------------------<-",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 913",
"_": "Missing Localizations: 914",
"_": "->------------------------] Game Elements [------------------------<-",
@ -1148,6 +1148,8 @@
"create.command.killTPSCommand.status.usage.1": "[Create]: Benutze /killtps start <tickTime> um den Server Tick künstlich zu verlangsamen",
"create.command.killTPSCommand.argument.tickTime": "tickTime",
"create.contraption.minecart_contraption_too_big": "UNLOCALIZED: This Cart Contraption seems too big to pick up",
"_": "->------------------------] Subtitles [------------------------<-",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 606",
"_": "Missing Localizations: 607",
"_": "->------------------------] Game Elements [------------------------<-",
@ -1148,6 +1148,8 @@
"create.command.killTPSCommand.status.usage.1": "[Create]: usar /killtps start <tickTime> para ralentizar artificialmente el tick del servidor",
"create.command.killTPSCommand.argument.tickTime": "tickTime",
"create.contraption.minecart_contraption_too_big": "UNLOCALIZED: This Cart Contraption seems too big to pick up",
"_": "->------------------------] Subtitles [------------------------<-",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 1264",
"_": "Missing Localizations: 1265",
"_": "->------------------------] Game Elements [------------------------<-",
@ -1148,6 +1148,8 @@
"create.command.killTPSCommand.status.usage.1": "UNLOCALIZED: [Create]: use /killtps start <tickTime> to artificially slow down the server tick",
"create.command.killTPSCommand.argument.tickTime": "UNLOCALIZED: tickTime",
"create.contraption.minecart_contraption_too_big": "UNLOCALIZED: This Cart Contraption seems too big to pick up",
"_": "->------------------------] Subtitles [------------------------<-",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 1163",
"_": "Missing Localizations: 1164",
"_": "->------------------------] Game Elements [------------------------<-",
@ -1148,6 +1148,8 @@
"create.command.killTPSCommand.status.usage.1": "[Create]: use /killtps start <tickTime> to artificially slow down the server tick",
"create.command.killTPSCommand.argument.tickTime": "tickTime",
"create.contraption.minecart_contraption_too_big": "UNLOCALIZED: This Cart Contraption seems too big to pick up",
"_": "->------------------------] Subtitles [------------------------<-",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 623",
"_": "Missing Localizations: 624",
"_": "->------------------------] Game Elements [------------------------<-",
@ -1148,6 +1148,8 @@
"create.command.killTPSCommand.status.usage.1": "[Create]: usa /killtps avvia <tickTime> per rallentare artificialmente il tick del server",
"create.command.killTPSCommand.argument.tickTime": "tickTime",
"create.contraption.minecart_contraption_too_big": "UNLOCALIZED: This Cart Contraption seems too big to pick up",
"_": "->------------------------] Subtitles [------------------------<-",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 605",
"_": "Missing Localizations: 606",
"_": "->------------------------] Game Elements [------------------------<-",
@ -1148,6 +1148,8 @@
"create.command.killTPSCommand.status.usage.1": "[Create]: /killtps start <tickTime>を使用して、サーバーのティックを意図的に遅くします",
"create.command.killTPSCommand.argument.tickTime": "tickTime",
"create.contraption.minecart_contraption_too_big": "UNLOCALIZED: This Cart Contraption seems too big to pick up",
"_": "->------------------------] Subtitles [------------------------<-",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 676",
"_": "Missing Localizations: 677",
"_": "->------------------------] Game Elements [------------------------<-",
@ -1148,6 +1148,8 @@
"create.command.killTPSCommand.status.usage.1": "[Create]: use /killtps start <tickTime> to artificially slow down the server tick",
"create.command.killTPSCommand.argument.tickTime": "tickTime",
"create.contraption.minecart_contraption_too_big": "UNLOCALIZED: This Cart Contraption seems too big to pick up",
"_": "->------------------------] Subtitles [------------------------<-",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 1553",
"_": "Missing Localizations: 1554",
"_": "->------------------------] Game Elements [------------------------<-",
@ -36,7 +36,7 @@
"block.create.blue_seat": "UNLOCALIZED: Blue Seat",
"block.create.blue_valve_handle": "UNLOCALIZED: Blue Valve Handle",
"block.create.brass_belt_funnel": "UNLOCALIZED: Brass Belt Funnel",
"block.create.brass_block": "UNLOCALIZED: Brass Block",
"block.create.brass_block": "UNLOCALIZED: Block of Brass",
"block.create.brass_casing": "UNLOCALIZED: Brass Casing",
"block.create.brass_encased_shaft": "UNLOCALIZED: Brass Encased Shaft",
"block.create.brass_funnel": "UNLOCALIZED: Brass Funnel",
@ -58,7 +58,7 @@
"block.create.cogwheel": "Tandwiel",
"block.create.content_observer": "UNLOCALIZED: Content Observer",
"block.create.controller_rail": "UNLOCALIZED: Controller Rail",
"block.create.copper_block": "UNLOCALIZED: Copper Block",
"block.create.copper_block": "UNLOCALIZED: Block of Copper",
"block.create.copper_casing": "UNLOCALIZED: Copper Casing",
"block.create.copper_ore": "UNLOCALIZED: Copper Ore",
"block.create.copper_shingles": "UNLOCALIZED: Copper Shingles",
@ -409,7 +409,7 @@
"block.create.yellow_sail": "UNLOCALIZED: Yellow Sail",
"block.create.yellow_seat": "UNLOCALIZED: Yellow Seat",
"block.create.yellow_valve_handle": "UNLOCALIZED: Yellow Valve Handle",
"block.create.zinc_block": "UNLOCALIZED: Zinc Block",
"block.create.zinc_block": "UNLOCALIZED: Block of Zinc",
"block.create.zinc_ore": "UNLOCALIZED: Zinc Ore",
"entity.create.contraption": "UNLOCALIZED: Contraption",
@ -1148,6 +1148,8 @@
"create.command.killTPSCommand.status.usage.1": "UNLOCALIZED: [Create]: use /killtps start <tickTime> to artificially slow down the server tick",
"create.command.killTPSCommand.argument.tickTime": "UNLOCALIZED: tickTime",
"create.contraption.minecart_contraption_too_big": "UNLOCALIZED: This Cart Contraption seems too big to pick up",
"_": "->------------------------] Subtitles [------------------------<-",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 1607",
"_": "Missing Localizations: 1608",
"_": "->------------------------] Game Elements [------------------------<-",
@ -36,7 +36,7 @@
"block.create.blue_seat": "UNLOCALIZED: Blue Seat",
"block.create.blue_valve_handle": "UNLOCALIZED: Blue Valve Handle",
"block.create.brass_belt_funnel": "UNLOCALIZED: Brass Belt Funnel",
"block.create.brass_block": "UNLOCALIZED: Brass Block",
"block.create.brass_block": "UNLOCALIZED: Block of Brass",
"block.create.brass_casing": "UNLOCALIZED: Brass Casing",
"block.create.brass_encased_shaft": "UNLOCALIZED: Brass Encased Shaft",
"block.create.brass_funnel": "UNLOCALIZED: Brass Funnel",
@ -58,7 +58,7 @@
"block.create.cogwheel": "Roda Dentada",
"block.create.content_observer": "UNLOCALIZED: Content Observer",
"block.create.controller_rail": "UNLOCALIZED: Controller Rail",
"block.create.copper_block": "UNLOCALIZED: Copper Block",
"block.create.copper_block": "UNLOCALIZED: Block of Copper",
"block.create.copper_casing": "UNLOCALIZED: Copper Casing",
"block.create.copper_ore": "UNLOCALIZED: Copper Ore",
"block.create.copper_shingles": "UNLOCALIZED: Copper Shingles",
@ -409,7 +409,7 @@
"block.create.yellow_sail": "UNLOCALIZED: Yellow Sail",
"block.create.yellow_seat": "UNLOCALIZED: Yellow Seat",
"block.create.yellow_valve_handle": "UNLOCALIZED: Yellow Valve Handle",
"block.create.zinc_block": "UNLOCALIZED: Zinc Block",
"block.create.zinc_block": "UNLOCALIZED: Block of Zinc",
"block.create.zinc_ore": "UNLOCALIZED: Zinc Ore",
"entity.create.contraption": "UNLOCALIZED: Contraption",
@ -1148,6 +1148,8 @@
"create.command.killTPSCommand.status.usage.1": "UNLOCALIZED: [Create]: use /killtps start <tickTime> to artificially slow down the server tick",
"create.command.killTPSCommand.argument.tickTime": "UNLOCALIZED: tickTime",
"create.contraption.minecart_contraption_too_big": "UNLOCALIZED: This Cart Contraption seems too big to pick up",
"_": "->------------------------] Subtitles [------------------------<-",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 520",
"_": "Missing Localizations: 521",
"_": "->------------------------] Game Elements [------------------------<-",
@ -1148,6 +1148,8 @@
"create.command.killTPSCommand.status.usage.1": "[Create]: используйте /killtps start <Время тика>, чтобы искусственно замедлить тик сервера",
"create.command.killTPSCommand.argument.tickTime": "Время тика",
"create.contraption.minecart_contraption_too_big": "UNLOCALIZED: This Cart Contraption seems too big to pick up",
"_": "->------------------------] Subtitles [------------------------<-",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 620",
"_": "Missing Localizations: 621",
"_": "->------------------------] Game Elements [------------------------<-",
@ -1148,6 +1148,8 @@
"create.command.killTPSCommand.status.usage.1": "[Create]: 用 /killtps start <tickTime> 来手动降低服务器TPS速度",
"create.command.killTPSCommand.argument.tickTime": "tickTime",
"create.contraption.minecart_contraption_too_big": "UNLOCALIZED: This Cart Contraption seems too big to pick up",
"_": "->------------------------] Subtitles [------------------------<-",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 625",
"_": "Missing Localizations: 626",
"_": "->------------------------] Game Elements [------------------------<-",
@ -1148,6 +1148,8 @@
"create.command.killTPSCommand.status.usage.1": "[Create]: 用 /killtps start <tickTime> 來手動降低伺服器TPS",
"create.command.killTPSCommand.argument.tickTime": "tickTime",
"create.contraption.minecart_contraption_too_big": "UNLOCALIZED: This Cart Contraption seems too big to pick up",
"_": "->------------------------] Subtitles [------------------------<-",

View file

@ -1302,6 +1302,7 @@ public class AllBlocks {
.tag(Tags.Items.STORAGE_BLOCKS)
.transform(oxidizedItemModel())
.transform(oxidizedBlockstate())
.lang("Block of Copper")
.register();
public static final BlockEntry<OxidizingBlock> COPPER_SHINGLES =
@ -1327,6 +1328,7 @@ public class AllBlocks {
.transform(tagBlockAndItem("storage_blocks/zinc"))
.tag(Tags.Items.STORAGE_BLOCKS)
.build()
.lang("Block of Zinc")
.register();
public static final BlockEntry<Block> BRASS_BLOCK = REGISTRATE.block("brass_block", p -> new Block(p))
@ -1338,6 +1340,7 @@ public class AllBlocks {
.transform(tagBlockAndItem("storage_blocks/brass"))
.tag(Tags.Items.STORAGE_BLOCKS)
.build()
.lang("Block of Brass")
.register();
// Load this class

View file

@ -1,5 +1,6 @@
package com.simibubi.create.content.contraptions.components.structureMovement;
import java.io.IOException;
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.List;
@ -10,8 +11,11 @@ import java.util.UUID;
import org.apache.commons.lang3.mutable.MutableInt;
import org.apache.commons.lang3.tuple.MutablePair;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.AllMovementBehaviours;
import com.simibubi.create.Create;
import com.simibubi.create.content.contraptions.components.actors.SeatEntity;
import com.simibubi.create.content.contraptions.components.structureMovement.glue.SuperGlueEntity;
import com.simibubi.create.content.contraptions.components.structureMovement.mounted.MountedContraption;
@ -30,6 +34,7 @@ import net.minecraft.entity.item.minecart.AbstractMinecartEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.ProjectileEntity;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.network.IPacket;
import net.minecraft.network.PacketBuffer;
import net.minecraft.network.datasync.DataParameter;
@ -75,7 +80,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
return;
contraption.onEntityCreated(this);
}
public boolean supportsTerrainCollision() {
return contraption instanceof TranslatingContraption;
}
@ -139,9 +144,8 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
BlockPos seat = contraption.getSeatOf(id);
if (seat == null)
return null;
Vector3d transformedVector =
toGlobalVector(Vector3d.of(seat).add(.5, passenger.getYOffset() + ySize - .15f, .5), partialTicks)
.add(VecHelper.getCenterOf(BlockPos.ZERO))
Vector3d transformedVector = toGlobalVector(Vector3d.of(seat)
.add(.5, passenger.getYOffset() + ySize - .15f, .5), partialTicks).add(VecHelper.getCenterOf(BlockPos.ZERO))
.subtract(0.5, ySize, 0.5);
return transformedVector;
}
@ -380,14 +384,34 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
public void writeSpawnData(PacketBuffer buffer) {
CompoundNBT compound = new CompoundNBT();
writeAdditional(compound, true);
buffer.writeCompoundTag(compound);
byte[] byteArray = null;
try {
ByteArrayDataOutput dataOutput = ByteStreams.newDataOutput();
CompressedStreamTools.write(compound, dataOutput);
byteArray = dataOutput.toByteArray();
int estimatedPacketSize = byteArray.length;
if (estimatedPacketSize > 2_000_000) {
Create.logger.warn("Could not send Contraption Spawn Data (Packet too big): "
+ getContraption().getType().id + " @" + getPositionVec() + " (" + getUniqueID().toString() + ")");
buffer.writeCompoundTag(new CompoundNBT());
return;
}
} catch (IOException e) {
e.printStackTrace();
buffer.writeCompoundTag(new CompoundNBT());
return;
}
buffer.writeByteArray(byteArray);
}
@Override
protected final void writeAdditional(CompoundNBT compound) {
writeAdditional(compound, false);
}
protected void writeAdditional(CompoundNBT compound, boolean spawnPacket) {
if (contraption != null)
compound.put("Contraption", contraption.writeNBT(spawnPacket));
@ -399,13 +423,16 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
public void readSpawnData(PacketBuffer additionalData) {
readAdditional(additionalData.readCompoundTag(), true);
}
@Override
protected final void readAdditional(CompoundNBT compound) {
readAdditional(compound, false);
}
protected void readAdditional(CompoundNBT compound, boolean spawnData) {
if (compound.isEmpty())
return;
initialized = compound.getBoolean("Initialized");
contraption = Contraption.fromNBT(world, compound.getCompound("Contraption"), spawnData);
contraption.entity = this;
@ -510,7 +537,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
@OnlyIn(Dist.CLIENT)
static void handleDisassemblyPacket(ContraptionDisassemblyPacket packet) {
Entity entity = Minecraft.getInstance().world.getEntityByID(packet.entityID);
Entity entity = Minecraft.getInstance().world.getEntityByID(packet.entityID);
if (!(entity instanceof AbstractContraptionEntity))
return;
AbstractContraptionEntity ce = (AbstractContraptionEntity) entity;
@ -650,25 +677,24 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
}
//@Override //TODO find 1.16 replacement
//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 //TODO find 1.16 replacement
// 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
// Contraptions no longer catch fire
}
}

View file

@ -1,19 +1,24 @@
package com.simibubi.create.content.contraptions.components.structureMovement.mounted;
import java.io.IOException;
import java.util.List;
import java.util.Optional;
import javax.annotation.Nullable;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import com.simibubi.create.AllItems;
import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity;
import com.simibubi.create.content.contraptions.components.structureMovement.Contraption;
import com.simibubi.create.content.contraptions.components.structureMovement.OrientedContraptionEntity;
import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.NBTHelper;
import net.minecraft.block.AbstractRailBlock;
import net.minecraft.block.BlockState;
import net.minecraft.block.DispenserBlock;
import net.minecraft.block.material.Material;
import net.minecraft.dispenser.DefaultDispenseItemBehavior;
import net.minecraft.dispenser.IBlockSource;
import net.minecraft.dispenser.IDispenseItemBehavior;
@ -26,12 +31,15 @@ import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.state.properties.RailShape;
import net.minecraft.tags.BlockTags;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Direction;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.World;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
@ -86,7 +94,7 @@ public class MinecartContraptionItem extends Item {
d3 = 0.1D;
}
} else {
if (!blockstate.isAir(world, blockpos) || !world.getBlockState(blockpos.down())
if (blockstate.getMaterial() != Material.AIR || !world.getBlockState(blockpos.down())
.isIn(BlockTags.RAILS)) {
return this.behaviourDefaultDispenseItem.dispense(source, stack);
}
@ -210,13 +218,32 @@ public class MinecartContraptionItem extends Item {
return;
OrientedContraptionEntity contraption = (OrientedContraptionEntity) passengers.get(0);
if (!event.getWorld().isRemote) {
player.inventory.placeItemBackInInventory(event.getWorld(),
create(type, contraption).setDisplayName(entity.getCustomName()));
contraption.remove();
entity.remove();
if (event.getWorld().isRemote) {
event.setCancellationResult(ActionResultType.SUCCESS);
event.setCanceled(true);
return;
}
ItemStack generatedStack = create(type, contraption).setDisplayName(entity.getCustomName());
try {
ByteArrayDataOutput dataOutput = ByteStreams.newDataOutput();
CompressedStreamTools.write(generatedStack.serializeNBT(), dataOutput);
int estimatedPacketSize = dataOutput.toByteArray().length;
if (estimatedPacketSize > 2_000_000) {
player.sendStatusMessage(Lang.translate("contraption.minecart_contraption_too_big")
.formatted(TextFormatting.RED), true);
return;
}
} catch (IOException e) {
e.printStackTrace();
return;
}
player.inventory.placeItemBackInInventory(event.getWorld(), generatedStack);
contraption.remove();
entity.remove();
event.setCancellationResult(ActionResultType.SUCCESS);
event.setCanceled(true);
}

View file

@ -501,6 +501,8 @@
"create.command.killTPSCommand.status.slowed_by.2": "[Create]: Server tick is back to regular speed :D",
"create.command.killTPSCommand.status.usage.0": "[Create]: use /killtps stop to bring back server tick to regular speed",
"create.command.killTPSCommand.status.usage.1": "[Create]: use /killtps start <tickTime> to artificially slow down the server tick",
"create.command.killTPSCommand.argument.tickTime": "tickTime"
"create.command.killTPSCommand.argument.tickTime": "tickTime",
"create.contraption.minecart_contraption_too_big": "This Cart Contraption seems too big to pick up"
}