Merge branch 'mc1.18/dev' into mc1.19/dev

This commit is contained in:
simibubi 2023-01-30 00:03:46 +01:00
commit 5223cbe4fc
19 changed files with 150 additions and 158 deletions

View file

@ -5,7 +5,7 @@
<a href="https://github.com/Creators-of-Create/Create/blob/master/LICENSE"><img src="https://img.shields.io/github/license/Creators-of-Create/Create?style=flat&color=900c3f" alt="License"></a> <a href="https://github.com/Creators-of-Create/Create/blob/master/LICENSE"><img src="https://img.shields.io/github/license/Creators-of-Create/Create?style=flat&color=900c3f" alt="License"></a>
<a href="https://discord.gg/hmaD7Se"><img src="https://img.shields.io/discord/620934202875183104?color=5865f2&label=Discord&style=flat" alt="Discord"></a> <a href="https://discord.gg/hmaD7Se"><img src="https://img.shields.io/discord/620934202875183104?color=5865f2&label=Discord&style=flat" alt="Discord"></a>
<a href="https://www.curseforge.com/minecraft/mc-mods/create"><img src="http://cf.way2muchnoise.eu/328085.svg" alt="CF"></a> <a href="https://www.curseforge.com/minecraft/mc-mods/create"><img src="http://cf.way2muchnoise.eu/328085.svg" alt="CF"></a>
<a href="https://modrinth.com/mod/create"><img src="https://img.shields.io/badge/dynamic/json?logo=data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+Cjxzdmcgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDUxMiA1MTQiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSIgeG1sbnM6c2VyaWY9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MS4zNSw0NDQuNjQgNDE5LjQsNDAyLjU2IDQ0NS40MiwzNDkuMzhMNDg4LjA2LDM2NC44OEM0NTcuMTcsNDMxLjE2IDM5OC4yMiw0ODMuODIgMzIxLjk5LDUwNC4yMloiIHN0eWxlPSJmaWxsOnJnYigyMywyMywyNSk7ZmlsbC1ydWxlOm5vbnplcm87Ii8+CiAgICAgICAgPC9nPgogICAgPC9nPgo8L3N2Zz4K&label=&suffix=%20&query=downloads&url=https://api.modrinth.com/api/v1/mod/LNytGWDc&style=flat&color=242629&labelColor=5ca424" alt="Modrinth"></a> <a href="https://modrinth.com/mod/create"><img src="https://img.shields.io/modrinth/dt/create?logo=modrinth&label=&suffix=%20&style=flat&color=242629&labelColor=5ca424&logoColor=1c1c1c" alt="Modrinth"></a>
<br><br> <br><br>
</h1> </h1>

View file

@ -4,11 +4,11 @@ org.gradle.jvmargs = -Xmx3G
org.gradle.daemon = false org.gradle.daemon = false
# mod version info # mod version info
mod_version = 0.5.0.h mod_version = 0.5.0.i
artifact_minecraft_version = 1.19.2 artifact_minecraft_version = 1.19.2
minecraft_version = 1.19.2 minecraft_version = 1.19.2
forge_version = 43.1.52 forge_version = 43.2.4
# build dependency versions # build dependency versions
forgegradle_version = 5.1.53 forgegradle_version = 5.1.53

View file

@ -1121,6 +1121,7 @@
"create.schematicAndQuill.saved": "Saved as %1$s", "create.schematicAndQuill.saved": "Saved as %1$s",
"create.schematic.invalid": "[!] Invalid Item - Use the Schematic Table instead", "create.schematic.invalid": "[!] Invalid Item - Use the Schematic Table instead",
"create.schematic.error": "Schematic failed to Load - Check Game Logs",
"create.schematic.position": "Position", "create.schematic.position": "Position",
"create.schematic.rotation": "Rotation", "create.schematic.rotation": "Rotation",
"create.schematic.rotation.none": "None", "create.schematic.rotation.none": "None",
@ -1214,6 +1215,8 @@
"create.schematicannon.status.schematicInvalid": "Schematic Invalid", "create.schematicannon.status.schematicInvalid": "Schematic Invalid",
"create.schematicannon.status.schematicNotPlaced": "Schematic not Positioned", "create.schematicannon.status.schematicNotPlaced": "Schematic not Positioned",
"create.schematicannon.status.schematicExpired": "Schematic File Expired", "create.schematicannon.status.schematicExpired": "Schematic File Expired",
"create.schematicannon.status.schematicErrored": "Incompatible Blocks",
"create.schematicannon.status.schematicErroredCheckLogs": "Check Server Logs",
"create.materialChecklist": "Material Checklist", "create.materialChecklist": "Material Checklist",
"create.materialChecklist.blocksNotLoaded": "* Disclaimer *\n\nMaterial List may be inaccurate due to relevant chunks not being loaded.", "create.materialChecklist.blocksNotLoaded": "* Disclaimer *\n\nMaterial List may be inaccurate due to relevant chunks not being loaded.",
@ -1750,6 +1753,9 @@
"create.contraption.minecart_contraption_too_big": "This Cart Contraption seems too big to pick up", "create.contraption.minecart_contraption_too_big": "This Cart Contraption seems too big to pick up",
"create.contraption.minecart_contraption_illegal_pickup": "A mystical force is binding this Cart Contraption to the world", "create.contraption.minecart_contraption_illegal_pickup": "A mystical force is binding this Cart Contraption to the world",
"enchantment.create.capacity.desc": "Increases Backtank air capacity.",
"enchantment.create.potato_recovery.desc": "Potato Cannon projectiles have a chance to be reused.",
"_": "->------------------------] Subtitles [------------------------<-", "_": "->------------------------] Subtitles [------------------------<-",

View file

@ -65,7 +65,7 @@ public class Create {
public static final String ID = "create"; public static final String ID = "create";
public static final String NAME = "Create"; public static final String NAME = "Create";
public static final String VERSION = "0.5h"; public static final String VERSION = "0.5i";
public static final Logger LOGGER = LogUtils.getLogger(); public static final Logger LOGGER = LogUtils.getLogger();

View file

@ -168,6 +168,8 @@ public class BeltTileEntity extends KineticTileEntity {
protected void initializeItemHandler() { protected void initializeItemHandler() {
if (level.isClientSide || itemHandler.isPresent()) if (level.isClientSide || itemHandler.isPresent())
return; return;
if (beltLength == 0 || controller == null)
return;
if (!level.isLoaded(controller)) if (!level.isLoaded(controller))
return; return;
BlockEntity te = level.getBlockEntity(controller); BlockEntity te = level.getBlockEntity(controller);

View file

@ -52,6 +52,8 @@ public class ItemHandlerBeltSegment implements IItemHandler {
amount = Math.min(amount, transported.stack.getCount()); amount = Math.min(amount, transported.stack.getCount());
ItemStack extracted = simulate ? transported.stack.copy().split(amount) : transported.stack.split(amount); ItemStack extracted = simulate ? transported.stack.copy().split(amount) : transported.stack.split(amount);
if (!simulate) { if (!simulate) {
if (transported.stack.isEmpty())
this.beltInventory.toRemove.add(transported);
this.beltInventory.belt.setChanged(); this.beltInventory.belt.setChanged();
this.beltInventory.belt.sendData(); this.beltInventory.belt.sendData();
} }

View file

@ -54,22 +54,26 @@ public class TrackGraphSync {
public void nodeAdded(TrackGraph graph, TrackNode node) { public void nodeAdded(TrackGraph graph, TrackNode node) {
flushGraphPacket(graph); flushGraphPacket(graph);
currentGraphSyncPacket.addedNodes.put(node.getNetId(), Pair.of(node.getLocation(), node.getNormal())); currentGraphSyncPacket.addedNodes.put(node.getNetId(), Pair.of(node.getLocation(), node.getNormal()));
currentPayload++;
} }
public void edgeAdded(TrackGraph graph, TrackNode node1, TrackNode node2, TrackEdge edge) { public void edgeAdded(TrackGraph graph, TrackNode node1, TrackNode node2, TrackEdge edge) {
flushGraphPacket(graph); flushGraphPacket(graph);
currentGraphSyncPacket.addedEdges currentGraphSyncPacket.addedEdges
.add(Pair.of(Couple.create(node1.getNetId(), node2.getNetId()), edge.getTurn())); .add(Pair.of(Couple.create(node1.getNetId(), node2.getNetId()), edge.getTurn()));
currentPayload++;
} }
public void pointAdded(TrackGraph graph, TrackEdgePoint point) { public void pointAdded(TrackGraph graph, TrackEdgePoint point) {
flushGraphPacket(graph); flushGraphPacket(graph);
currentGraphSyncPacket.addedEdgePoints.add(point); currentGraphSyncPacket.addedEdgePoints.add(point);
currentPayload++;
} }
public void pointRemoved(TrackGraph graph, TrackEdgePoint point) { public void pointRemoved(TrackGraph graph, TrackEdgePoint point) {
flushGraphPacket(graph); flushGraphPacket(graph);
currentGraphSyncPacket.removedEdgePoints.add(point.getId()); currentGraphSyncPacket.removedEdgePoints.add(point.getId());
currentPayload++;
} }
public void nodeRemoved(TrackGraph graph, TrackNode node) { public void nodeRemoved(TrackGraph graph, TrackNode node) {
@ -120,12 +124,14 @@ public class TrackGraphSync {
public void edgeDataChanged(TrackGraph graph, TrackNode node1, TrackNode node2, TrackEdge edge) { public void edgeDataChanged(TrackGraph graph, TrackNode node1, TrackNode node2, TrackEdge edge) {
flushGraphPacket(graph); flushGraphPacket(graph);
currentGraphSyncPacket.syncEdgeData(node1, node2, edge); currentGraphSyncPacket.syncEdgeData(node1, node2, edge);
currentPayload++;
} }
public void edgeDataChanged(TrackGraph graph, TrackNode node1, TrackNode node2, TrackEdge edge, TrackEdge edge2) { public void edgeDataChanged(TrackGraph graph, TrackNode node1, TrackNode node2, TrackEdge edge, TrackEdge edge2) {
flushGraphPacket(graph); flushGraphPacket(graph);
currentGraphSyncPacket.syncEdgeData(node1, node2, edge); currentGraphSyncPacket.syncEdgeData(node1, node2, edge);
currentGraphSyncPacket.syncEdgeData(node2, node1, edge2); currentGraphSyncPacket.syncEdgeData(node2, node1, edge2);
currentPayload++;
} }
public void sendFullGraphTo(TrackGraph graph, ServerPlayer player) { public void sendFullGraphTo(TrackGraph graph, ServerPlayer player) {
@ -190,6 +196,7 @@ public class TrackGraphSync {
// //
private TrackGraphSyncPacket currentGraphSyncPacket; private TrackGraphSyncPacket currentGraphSyncPacket;
private int currentPayload;
private void flushGraphPacket() { private void flushGraphPacket() {
flushGraphPacket(null, 0); flushGraphPacket(null, 0);
@ -201,14 +208,17 @@ public class TrackGraphSync {
private void flushGraphPacket(@Nullable UUID graphId, int netId) { private void flushGraphPacket(@Nullable UUID graphId, int netId) {
if (currentGraphSyncPacket != null) { if (currentGraphSyncPacket != null) {
if (currentGraphSyncPacket.graphId.equals(graphId)) if (currentGraphSyncPacket.graphId.equals(graphId) && currentPayload < 1000)
return; return;
queuedPackets.add(currentGraphSyncPacket); queuedPackets.add(currentGraphSyncPacket);
currentGraphSyncPacket = null; currentGraphSyncPacket = null;
currentPayload = 0;
} }
if (graphId != null) if (graphId != null) {
currentGraphSyncPacket = new TrackGraphSyncPacket(graphId, netId); currentGraphSyncPacket = new TrackGraphSyncPacket(graphId, netId);
currentPayload = 0;
}
} }
} }

View file

@ -16,6 +16,8 @@ import java.util.function.Function;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import net.minecraft.server.MinecraftServer;
import org.apache.commons.lang3.mutable.MutableDouble; import org.apache.commons.lang3.mutable.MutableDouble;
import com.simibubi.create.content.contraptions.components.structureMovement.Contraption; import com.simibubi.create.content.contraptions.components.structureMovement.Contraption;
@ -249,8 +251,11 @@ public class Carriage {
boolean discard = boolean discard =
!currentlyTraversedDimensions.isEmpty() && !currentlyTraversedDimensions.contains(entry.getKey()); !currentlyTraversedDimensions.isEmpty() && !currentlyTraversedDimensions.contains(entry.getKey());
ServerLevel currentLevel = level.getServer()
.getLevel(entry.getKey()); MinecraftServer server = level.getServer();
if (server == null)
continue;
ServerLevel currentLevel = server.getLevel(entry.getKey());
if (currentLevel == null) if (currentLevel == null)
continue; continue;

View file

@ -5,6 +5,7 @@ import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.Create;
import com.simibubi.create.content.contraptions.components.structureMovement.BlockMovementChecks; import com.simibubi.create.content.contraptions.components.structureMovement.BlockMovementChecks;
import com.simibubi.create.content.contraptions.components.structureMovement.StructureTransform; import com.simibubi.create.content.contraptions.components.structureMovement.StructureTransform;
import com.simibubi.create.content.schematics.item.SchematicItem; import com.simibubi.create.content.schematics.item.SchematicItem;
@ -37,6 +38,7 @@ public class SchematicPrinter {
} }
private boolean schematicLoaded; private boolean schematicLoaded;
private boolean isErrored;
private SchematicWorld blockReader; private SchematicWorld blockReader;
private BlockPos schematicAnchor; private BlockPos schematicAnchor;
@ -93,7 +95,16 @@ public class SchematicPrinter {
schematicAnchor = NbtUtils.readBlockPos(blueprint.getTag() schematicAnchor = NbtUtils.readBlockPos(blueprint.getTag()
.getCompound("Anchor")); .getCompound("Anchor"));
blockReader = new SchematicWorld(schematicAnchor, originalWorld); blockReader = new SchematicWorld(schematicAnchor, originalWorld);
activeTemplate.placeInWorld(blockReader, schematicAnchor, schematicAnchor, settings, blockReader.getRandom(), Block.UPDATE_CLIENTS);
try {
activeTemplate.placeInWorld(blockReader, schematicAnchor, schematicAnchor, settings,
blockReader.getRandom(), Block.UPDATE_CLIENTS);
} catch (Exception e) {
Create.LOGGER.error("Failed to load Schematic for Printing", e);
schematicLoaded = true;
isErrored = true;
return;
}
BlockPos extraBounds = StructureTemplate.calculateRelativePosition(settings, new BlockPos(activeTemplate.getSize()) BlockPos extraBounds = StructureTemplate.calculateRelativePosition(settings, new BlockPos(activeTemplate.getSize())
.offset(-1, -1, -1)); .offset(-1, -1, -1));
@ -115,6 +126,7 @@ public class SchematicPrinter {
public void resetSchematic() { public void resetSchematic() {
schematicLoaded = false; schematicLoaded = false;
schematicAnchor = null; schematicAnchor = null;
isErrored = false;
currentPos = null; currentPos = null;
blockReader = null; blockReader = null;
printingEntityIndex = -1; printingEntityIndex = -1;
@ -126,8 +138,12 @@ public class SchematicPrinter {
return schematicLoaded; return schematicLoaded;
} }
public boolean isErrored() {
return isErrored;
}
public BlockPos getCurrentTarget() { public BlockPos getCurrentTarget() {
if (!isLoaded()) if (!isLoaded() || isErrored())
return null; return null;
return schematicAnchor.offset(currentPos); return schematicAnchor.offset(currentPos);
} }

View file

@ -310,6 +310,10 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen<Schematica
} }
font.drawShadow(ms, msg, x + 103 - stringWidth / 2, y + 53, 0xCCDDFF); font.drawShadow(ms, msg, x + 103 - stringWidth / 2, y + 53, 0xCCDDFF);
if ("schematicErrored".equals(te.statusMsg))
font.drawShadow(ms, Lang.translateDirect("schematicannon.status.schematicErroredCheckLogs"),
x + 103 - stringWidth / 2, y + 65, 0xCCDDFF);
} }
protected void renderBlueprintHighlight(PoseStack matrixStack, int x, int y) { protected void renderBlueprintHighlight(PoseStack matrixStack, int x, int y) {

View file

@ -304,7 +304,8 @@ public class SchematicannonTileEntity extends SmartTileEntity implements MenuPro
ItemStack blueprint = inventory.getStackInSlot(0); ItemStack blueprint = inventory.getStackInSlot(0);
blockSkipped = false; blockSkipped = false;
if (blueprint.isEmpty() && !statusMsg.equals("idle")) { if (blueprint.isEmpty() && !statusMsg.equals("idle") && inventory.getStackInSlot(1)
.isEmpty()) {
state = State.STOPPED; state = State.STOPPED;
statusMsg = "idle"; statusMsg = "idle";
sendUpdate = true; sendUpdate = true;
@ -448,12 +449,23 @@ public class SchematicannonTileEntity extends SmartTileEntity implements MenuPro
// Load blocks into reader // Load blocks into reader
printer.loadSchematic(blueprint, level, true); printer.loadSchematic(blueprint, level, true);
if (printer.isErrored()) {
state = State.STOPPED;
statusMsg = "schematicErrored";
inventory.setStackInSlot(0, ItemStack.EMPTY);
inventory.setStackInSlot(1, new ItemStack(AllItems.EMPTY_SCHEMATIC.get()));
printer.resetSchematic();
sendUpdate = true;
return;
}
if (printer.isWorldEmpty()) { if (printer.isWorldEmpty()) {
state = State.STOPPED; state = State.STOPPED;
statusMsg = "schematicExpired"; statusMsg = "schematicExpired";
inventory.setStackInSlot(0, ItemStack.EMPTY); inventory.setStackInSlot(0, ItemStack.EMPTY);
inventory.setStackInSlot(1, new ItemStack(AllItems.EMPTY_SCHEMATIC.get())); inventory.setStackInSlot(1, new ItemStack(AllItems.EMPTY_SCHEMATIC.get()));
printer.resetSchematic(); printer.resetSchematic();
sendUpdate = true;
return; return;
} }
@ -462,6 +474,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements MenuPro
state = State.STOPPED; state = State.STOPPED;
statusMsg = "targetOutsideRange"; statusMsg = "targetOutsideRange";
printer.resetSchematic(); printer.resetSchematic();
sendUpdate = true;
return; return;
} }
@ -663,6 +676,9 @@ public class SchematicannonTileEntity extends SmartTileEntity implements MenuPro
boolean outputFull = inventory.getStackInSlot(BookOutput) boolean outputFull = inventory.getStackInSlot(BookOutput)
.getCount() == inventory.getSlotLimit(BookOutput); .getCount() == inventory.getSlotLimit(BookOutput);
if (printer.isErrored())
return;
if (!printer.isLoaded()) { if (!printer.isLoaded()) {
if (!blueprint.isEmpty()) if (!blueprint.isEmpty())
initializePrinter(blueprint); initializePrinter(blueprint);
@ -796,11 +812,12 @@ public class SchematicannonTileEntity extends SmartTileEntity implements MenuPro
checklist.damageRequired.clear(); checklist.damageRequired.clear();
checklist.blocksNotLoaded = false; checklist.blocksNotLoaded = false;
if (printer.isLoaded()) { if (printer.isLoaded() && !printer.isErrored()) {
blocksToPlace = blocksPlaced; blocksToPlace = blocksPlaced;
blocksToPlace += printer.markAllBlockRequirements(checklist, level, this::shouldPlace); blocksToPlace += printer.markAllBlockRequirements(checklist, level, this::shouldPlace);
printer.markAllEntityRequirements(checklist); printer.markAllEntityRequirements(checklist);
} }
checklist.gathered.clear(); checklist.gathered.clear();
findInventories(); findInventories();
for (LazyOptional<IItemHandler> cap : attachedInventories) { for (LazyOptional<IItemHandler> cap : attachedInventories) {

View file

@ -8,6 +8,7 @@ import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllItems; import com.simibubi.create.AllItems;
import com.simibubi.create.AllKeys; import com.simibubi.create.AllKeys;
import com.simibubi.create.Create;
import com.simibubi.create.content.contraptions.components.structureMovement.StructureTransform; import com.simibubi.create.content.contraptions.components.structureMovement.StructureTransform;
import com.simibubi.create.content.schematics.SchematicWorld; import com.simibubi.create.content.schematics.SchematicWorld;
import com.simibubi.create.content.schematics.client.tools.Tools; import com.simibubi.create.content.schematics.client.tools.Tools;
@ -18,6 +19,7 @@ import com.simibubi.create.content.schematics.packet.SchematicSyncPacket;
import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.networking.AllPackets;
import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; import com.simibubi.create.foundation.render.SuperRenderTypeBuffer;
import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.NBTHelper;
import com.simibubi.create.foundation.utility.outliner.AABBOutline; import com.simibubi.create.foundation.utility.outliner.AABBOutline;
@ -157,7 +159,15 @@ public class SchematicHandler {
BlockPos pos; BlockPos pos;
pos = BlockPos.ZERO; pos = BlockPos.ZERO;
try {
schematic.placeInWorld(w, pos, pos, placementSettings, w.getRandom(), Block.UPDATE_CLIENTS); schematic.placeInWorld(w, pos, pos, placementSettings, w.getRandom(), Block.UPDATE_CLIENTS);
} catch (Exception e) {
Minecraft.getInstance().player.displayClientMessage(Lang.translate("schematic.error")
.component(), false);
Create.LOGGER.error("Failed to load Schematic for Previewing", e);
return;
}
placementSettings.setMirror(Mirror.FRONT_BACK); placementSettings.setMirror(Mirror.FRONT_BACK);
pos = BlockPos.ZERO.east(size.getX() - 1); pos = BlockPos.ZERO.east(size.getX() - 1);

View file

@ -39,7 +39,7 @@ public class SchematicPlacePacket extends SimplePacketBase {
Level world = player.getLevel(); Level world = player.getLevel();
SchematicPrinter printer = new SchematicPrinter(); SchematicPrinter printer = new SchematicPrinter();
printer.loadSchematic(stack, world, !player.canUseGameMasterBlocks()); printer.loadSchematic(stack, world, !player.canUseGameMasterBlocks());
if (!printer.isLoaded()) if (!printer.isLoaded() || printer.isErrored())
return; return;
boolean includeAir = AllConfigs.SERVER.schematics.creativePrintIncludesAir.get(); boolean includeAir = AllConfigs.SERVER.schematics.creativePrintIncludesAir.get();

View file

@ -48,6 +48,7 @@ import net.minecraftforge.event.level.ChunkEvent;
import net.minecraftforge.event.level.LevelEvent; import net.minecraftforge.event.level.LevelEvent;
import net.minecraftforge.event.server.ServerStoppingEvent; import net.minecraftforge.event.server.ServerStoppingEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.LogicalSide;
import net.minecraftforge.fml.ModList; import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber; import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.forgespi.language.IModFileInfo; import net.minecraftforge.forgespi.language.IModFileInfo;
@ -85,9 +86,11 @@ public class CommonEvents {
} }
@SubscribeEvent @SubscribeEvent
public static void onWorldTick(LevelTickEvent event) { public static void onServerWorldTick(LevelTickEvent event) {
if (event.phase == Phase.START) if (event.phase == Phase.START)
return; return;
if (event.side == LogicalSide.CLIENT)
return;
Level world = event.level; Level world = event.level;
ContraptionHandler.tick(world); ContraptionHandler.tick(world);
CapabilityMinecartController.tick(world); CapabilityMinecartController.tick(world);

View file

@ -3,35 +3,26 @@ package com.simibubi.create.foundation.data;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
import java.io.Writer; import java.io.Writer;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import org.apache.commons.lang3.mutable.MutableBoolean; import org.apache.commons.lang3.mutable.MutableBoolean;
import org.apache.commons.lang3.mutable.MutableInt;
import org.apache.commons.lang3.mutable.MutableObject; import org.apache.commons.lang3.mutable.MutableObject;
import org.apache.commons.lang3.tuple.Pair;
import com.google.common.hash.Hashing; import com.google.common.hash.Hashing;
import com.google.common.hash.HashingOutputStream; import com.google.common.hash.HashingOutputStream;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.simibubi.create.Create; import com.simibubi.create.Create;
import com.simibubi.create.foundation.ponder.PonderScene; import com.simibubi.create.foundation.ponder.PonderScene;
import com.simibubi.create.foundation.utility.FilesHelper;
import net.minecraft.data.CachedOutput; import net.minecraft.data.CachedOutput;
import net.minecraft.data.DataGenerator; import net.minecraft.data.DataGenerator;
@ -51,10 +42,6 @@ public class LangMerger implements DataProvider {
private final LangPartial[] langPartials; private final LangPartial[] langPartials;
private List<Object> mergedLangData; private List<Object> mergedLangData;
private Map<String, List<Object>> populatedLangData;
private Map<String, Map<String, String>> allLocalizedEntries;
private Map<String, MutableInt> missingTranslationTally;
private List<String> langIgnore; private List<String> langIgnore;
public <T extends LangPartial> LangMerger(DataGenerator gen, String modid, String displayName, T[] langPartials) { public <T extends LangPartial> LangMerger(DataGenerator gen, String modid, String displayName, T[] langPartials) {
@ -64,9 +51,6 @@ public class LangMerger implements DataProvider {
this.langPartials = langPartials; this.langPartials = langPartials;
this.mergedLangData = new ArrayList<>(); this.mergedLangData = new ArrayList<>();
this.langIgnore = new ArrayList<>(); this.langIgnore = new ArrayList<>();
this.allLocalizedEntries = new HashMap<>();
this.populatedLangData = new HashMap<>();
this.missingTranslationTally = new HashMap<>();
populateLangIgnore(); populateLangIgnore();
} }
@ -93,42 +77,11 @@ public class LangMerger implements DataProvider {
Path path = this.gen.getOutputFolder() Path path = this.gen.getOutputFolder()
.resolve("assets/" + modid + "/lang/" + "en_us.json"); .resolve("assets/" + modid + "/lang/" + "en_us.json");
for (Pair<String, JsonElement> pair : getAllLocalizationFiles()) {
if (!pair.getRight()
.isJsonObject())
continue;
Map<String, String> localizedEntries = new HashMap<>();
JsonObject jsonobject = pair.getRight()
.getAsJsonObject();
jsonobject.entrySet()
.stream()
.forEachOrdered(entry -> {
String key = entry.getKey();
if (key.startsWith("_"))
return;
String value = entry.getValue()
.getAsString();
localizedEntries.put(key, value);
});
String key = pair.getKey();
allLocalizedEntries.put(key, localizedEntries);
populatedLangData.put(key, new ArrayList<>());
missingTranslationTally.put(key, new MutableInt(0));
}
collectExistingEntries(path); collectExistingEntries(path);
collectEntries(); collectEntries();
if (mergedLangData.isEmpty()) if (mergedLangData.isEmpty())
return; return;
save(cache, mergedLangData, path, "Merging en_us.json with hand-written lang entries...");
save(cache, mergedLangData, -1, path, "Merging en_us.json with hand-written lang entries...");
for (Entry<String, List<Object>> localization : populatedLangData.entrySet()) {
String key = localization.getKey();
Path populatedLangPath = this.gen.getOutputFolder()
.resolve("assets/" + modid + "/lang/unfinished/" + key);
save(cache, localization.getValue(), missingTranslationTally.get(key)
.intValue(), populatedLangPath, "Populating " + key + " with missing entries...");
}
} }
private void collectExistingEntries(Path path) throws IOException { private void collectExistingEntries(Path path) throws IOException {
@ -195,19 +148,10 @@ public class LangMerger implements DataProvider {
private void writeData(String data) { private void writeData(String data) {
mergedLangData.add(data); mergedLangData.add(data);
populatedLangData.values()
.forEach(l -> l.add(data));
} }
private void writeEntry(String key, String value) { private void writeEntry(String key, String value) {
mergedLangData.add(new LangEntry(key, value)); mergedLangData.add(new LangEntry(key, value));
populatedLangData.forEach((k, l) -> {
ForeignLangEntry entry = new ForeignLangEntry(key, value, allLocalizedEntries.get(k));
if (entry.isMissing())
missingTranslationTally.get(k)
.increment();
l.add(entry);
});
} }
protected boolean shouldAddLineBreak(String key, String previousKey) { protected boolean shouldAddLineBreak(String key, String previousKey) {
@ -229,29 +173,6 @@ public class LangMerger implements DataProvider {
return !split[0].equals(split2[0]); return !split[0].equals(split2[0]);
} }
private List<Pair<String, JsonElement>> getAllLocalizationFiles() {
ArrayList<Pair<String, JsonElement>> list = new ArrayList<>();
String filepath = "assets/" + modid + "/lang/";
try (InputStream resourceStream = ClassLoader.getSystemResourceAsStream(filepath)) {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(resourceStream));
while (true) {
String readLine = bufferedReader.readLine();
if (readLine == null)
break;
if (!readLine.endsWith(".json"))
continue;
if (readLine.startsWith("en_us") || readLine.startsWith("en_ud"))
continue;
list.add(Pair.of(readLine, FilesHelper.loadJsonResource(filepath + readLine)));
}
} catch (IOException | NullPointerException e) {
e.printStackTrace();
}
return list;
}
private void collectEntries() { private void collectEntries() {
for (LangPartial partial : langPartials) for (LangPartial partial : langPartials)
addAll(partial.getDisplayName(), partial.provide() addAll(partial.getDisplayName(), partial.provide()
@ -259,25 +180,22 @@ public class LangMerger implements DataProvider {
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private void save(CachedOutput cache, List<Object> dataIn, int missingKeys, Path target, String message) private void save(CachedOutput cache, List<Object> dataIn, Path target, String message)
throws IOException { throws IOException {
Create.LOGGER.info(message);
ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream(); ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream();
HashingOutputStream hashingoutputstream = new HashingOutputStream(Hashing.sha1(), bytearrayoutputstream); HashingOutputStream hashingoutputstream = new HashingOutputStream(Hashing.sha1(), bytearrayoutputstream);
Writer writer = new OutputStreamWriter(hashingoutputstream, StandardCharsets.UTF_8); Writer writer = new OutputStreamWriter(hashingoutputstream, StandardCharsets.UTF_8);
writer.append(createString(dataIn, missingKeys)); writer.append(createString(dataIn));
writer.close(); writer.close();
cache.writeIfNeeded(target, bytearrayoutputstream.toByteArray(), hashingoutputstream.hash()); cache.writeIfNeeded(target, bytearrayoutputstream.toByteArray(), hashingoutputstream.hash());
} }
protected String createString(List<Object> data, int missingKeys) { protected String createString(List<Object> data) {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append("{\n"); builder.append("{\n");
if (missingKeys != -1)
builder.append("\t\"_\": \"Missing Localizations: " + missingKeys + "\",\n");
data.forEach(builder::append); data.forEach(builder::append);
builder.append("\t\"_\": \"Thank you for translating ").append(displayName).append("!\"\n\n"); builder.append("\t\"_\": \"Thank you for translating ").append(displayName).append("!\"\n\n");
builder.append("}"); builder.append("}");
@ -302,19 +220,4 @@ public class LangMerger implements DataProvider {
} }
private class ForeignLangEntry extends LangEntry {
private boolean missing;
ForeignLangEntry(String key, String value, Map<String, String> localizationMap) {
super(key, localizationMap.getOrDefault(key, "UNLOCALIZED: " + value));
missing = !localizationMap.containsKey(key);
}
public boolean isMissing() {
return missing;
}
}
} }

View file

@ -271,6 +271,7 @@
"create.schematicAndQuill.saved": "Saved as %1$s", "create.schematicAndQuill.saved": "Saved as %1$s",
"create.schematic.invalid": "[!] Invalid Item - Use the Schematic Table instead", "create.schematic.invalid": "[!] Invalid Item - Use the Schematic Table instead",
"create.schematic.error": "Schematic failed to Load - Check Game Logs",
"create.schematic.position": "Position", "create.schematic.position": "Position",
"create.schematic.rotation": "Rotation", "create.schematic.rotation": "Rotation",
"create.schematic.rotation.none": "None", "create.schematic.rotation.none": "None",
@ -369,6 +370,8 @@
"create.schematicannon.status.schematicInvalid": "Schematic Invalid", "create.schematicannon.status.schematicInvalid": "Schematic Invalid",
"create.schematicannon.status.schematicNotPlaced": "Schematic not Positioned", "create.schematicannon.status.schematicNotPlaced": "Schematic not Positioned",
"create.schematicannon.status.schematicExpired": "Schematic File Expired", "create.schematicannon.status.schematicExpired": "Schematic File Expired",
"create.schematicannon.status.schematicErrored": "Incompatible Blocks",
"create.schematicannon.status.schematicErroredCheckLogs": "Check Server Logs",
"create.materialChecklist": "Material Checklist", "create.materialChecklist": "Material Checklist",
"create.materialChecklist.blocksNotLoaded": "* Disclaimer *\n\nMaterial List may be inaccurate due to relevant chunks not being loaded.", "create.materialChecklist.blocksNotLoaded": "* Disclaimer *\n\nMaterial List may be inaccurate due to relevant chunks not being loaded.",
@ -916,6 +919,9 @@
"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", "create.contraption.minecart_contraption_too_big": "This Cart Contraption seems too big to pick up",
"create.contraption.minecart_contraption_illegal_pickup": "A mystical force is binding this Cart Contraption to the world" "create.contraption.minecart_contraption_illegal_pickup": "A mystical force is binding this Cart Contraption to the world",
"enchantment.create.capacity.desc": "Increases Backtank air capacity.",
"enchantment.create.potato_recovery.desc": "Potato Cannon projectiles have a chance to be reused."
} }

View file

@ -1,31 +0,0 @@
{
"conditions": [
{
"type": "forge:mod_loaded",
"modid": "appliedenergistics2"
}
],
"type": "create:crushing",
"ingredients": [
{
"item": "appliedenergistics2:charged_quartz_ore"
}
],
"results": [
{
"item": "appliedenergistics2:charged_certus_quartz_crystal",
"count": 2
},
{
"item": "appliedenergistics2:certus_quartz_dust",
"count": 1,
"chance": 0.25
},
{
"item": "minecraft:cobblestone",
"count": 1,
"chance": 0.125
}
],
"processingTime": 300
}

View file

@ -0,0 +1,35 @@
{
"conditions": [
{
"type": "forge:mod_loaded",
"modid": "ae2"
}
],
"type": "create:crushing",
"ingredients": [
{
"item": "ae2:deepslate_quartz_ore"
}
],
"results": [
{
"item": "ae2:certus_quartz_crystal",
"count": 1
},
{
"item": "ae2:certus_quartz_dust",
"count": 4
},
{
"item": "ae2:certus_quartz_dust",
"count": 1,
"chance": 0.5
},
{
"item": "minecraft:cobbled_deepslate",
"count": 1,
"chance": 0.125
}
],
"processingTime": 300
}

View file

@ -2,24 +2,28 @@
"conditions": [ "conditions": [
{ {
"type": "forge:mod_loaded", "type": "forge:mod_loaded",
"modid": "appliedenergistics2" "modid": "ae2"
} }
], ],
"type": "create:crushing", "type": "create:crushing",
"ingredients": [ "ingredients": [
{ {
"item": "appliedenergistics2:quartz_ore" "item": "ae2:quartz_ore"
} }
], ],
"results": [ "results": [
{ {
"item": "appliedenergistics2:certus_quartz_crystal", "item": "ae2:certus_quartz_crystal",
"count": 2 "count": 1
}, },
{ {
"item": "appliedenergistics2:certus_quartz_dust", "item": "ae2:certus_quartz_dust",
"count": 4
},
{
"item": "ae2:certus_quartz_dust",
"count": 1, "count": 1,
"chance": 0.25 "chance": 0.5
}, },
{ {
"item": "minecraft:cobblestone", "item": "minecraft:cobblestone",