Skip to content

Commit

Permalink
sync sakura-ryoko/litematica 1.21.3-0.20.2-sakura.4
Browse files Browse the repository at this point in the history
  • Loading branch information
TexBlock committed Dec 11, 2024
1 parent ed5809d commit 9406a5c
Show file tree
Hide file tree
Showing 42 changed files with 5,276 additions and 4,026 deletions.
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
minecraft_version="1.21.3"
yarn_mappings="1.21.3+build.2"
mappings_patch="1.21+build.4"
neoforge="21.3.2-beta"
neoforge="21.3.57"

# Mod properties
version="0.1.14"
version="0.1.15"
maven-group="org.thinkingstudio.forgematica"
archives-name="Forgematica"

Expand All @@ -15,7 +15,7 @@ id-modrinth="dCKRaeBC"
id-curseforge="912441"

# Mod dependencies
mafglib="0.1.25-mc1.21.3"
mafglib="0.1.27-mc1.21.3"
badpackets="neo-0.8.1"

# Libraries
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/fi/dy/masa/litematica/config/Configs.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static class Generic
public static final ConfigBoolean COMMAND_DISABLE_FEEDBACK = new ConfigBoolean("commandDisableFeedback", true).apply(GENERIC_KEY);
public static final ConfigInteger COMMAND_FILL_MAX_VOLUME = new ConfigInteger("commandFillMaxVolume", 32768, 256, 10000000).apply(GENERIC_KEY);
public static final ConfigBoolean COMMAND_FILL_NO_CHUNK_CLAMP = new ConfigBoolean("commandFillNoChunkClamp", false).apply(GENERIC_KEY);
public static final ConfigInteger COMMAND_LIMIT = new ConfigInteger("commandLimitPerTick", 24, 1, 256).apply(GENERIC_KEY);
public static final ConfigInteger COMMAND_LIMIT = new ConfigInteger("commandLimitPerTick", 8, 1, 256).apply(GENERIC_KEY);
public static final ConfigString COMMAND_NAME_CLONE = new ConfigString( "commandNameClone", "clone").apply(GENERIC_KEY);
public static final ConfigString COMMAND_NAME_FILL = new ConfigString( "commandNameFill", "fill").apply(GENERIC_KEY);
public static final ConfigString COMMAND_NAME_SETBLOCK = new ConfigString( "commandNameSetblock", "setblock").apply(GENERIC_KEY);
Expand All @@ -65,6 +65,7 @@ public static class Generic
public static final ConfigBoolean EASY_PLACE_VANILLA_REACH = new ConfigBoolean("easyPlaceVanillaReach", false).apply(GENERIC_KEY);
public static final ConfigBoolean ENTITY_DATA_SYNC = new ConfigBoolean("entityDataSync", true).apply(GENERIC_KEY);
public static final ConfigBoolean ENTITY_DATA_SYNC_BACKUP = new ConfigBoolean("entityDataSyncBackup", true).apply(GENERIC_KEY);
public static final ConfigFloat ENTITY_DATA_SYNC_CACHE_TIMEOUT= new ConfigFloat("entityDataSyncCacheTimeout", 2.0f, 0.25f, 30.0f).apply(GENERIC_KEY);
public static final ConfigBoolean ENTITY_DATA_LOAD_NBT = new ConfigBoolean("entityDataSyncLoadNbt", true).apply(GENERIC_KEY);
public static final ConfigBoolean EXECUTE_REQUIRE_TOOL = new ConfigBoolean("executeRequireHoldingTool", true).apply(GENERIC_KEY);
public static final ConfigBoolean FIX_CHEST_MIRROR = new ConfigBoolean("fixChestMirror", true).apply(GENERIC_KEY);
Expand Down Expand Up @@ -124,6 +125,7 @@ public static class Generic
EASY_PLACE_VANILLA_REACH,
ENTITY_DATA_SYNC,
ENTITY_DATA_SYNC_BACKUP,
ENTITY_DATA_SYNC_CACHE_TIMEOUT,
ENTITY_DATA_LOAD_NBT,
EXECUTE_REQUIRE_TOOL,
FIX_CHEST_MIRROR,
Expand Down Expand Up @@ -193,11 +195,13 @@ public static class Visuals
public static final ConfigBoolean IGNORE_EXISTING_FLUIDS = new ConfigBoolean("ignoreExistingFluids", false).apply(VISUALS_KEY);
public static final ConfigBoolean OVERLAY_REDUCED_INNER_SIDES = new ConfigBoolean("overlayReducedInnerSides", false).apply(VISUALS_KEY);
public static final ConfigDouble PLACEMENT_BOX_SIDE_ALPHA = new ConfigDouble( "placementBoxSideAlpha", 0.2, 0, 1).apply(VISUALS_KEY);
public static final ConfigBoolean RENDER_AO_MODERN_ENABLE = new ConfigBoolean("renderAOModernEnable", false).apply(VISUALS_KEY);
public static final ConfigBoolean RENDER_AREA_SELECTION_BOX_SIDES = new ConfigBoolean("renderAreaSelectionBoxSides", true).apply(VISUALS_KEY);
public static final ConfigBoolean RENDER_BLOCKS_AS_TRANSLUCENT = new ConfigBoolean("renderBlocksAsTranslucent", false).apply(VISUALS_KEY);
public static final ConfigBoolean RENDER_COLLIDING_SCHEMATIC_BLOCKS = new ConfigBoolean("renderCollidingSchematicBlocks", false).apply(VISUALS_KEY);
public static final ConfigBoolean RENDER_ERROR_MARKER_CONNECTIONS = new ConfigBoolean("renderErrorMarkerConnections", false).apply(VISUALS_KEY);
public static final ConfigBoolean RENDER_ERROR_MARKER_SIDES = new ConfigBoolean("renderErrorMarkerSides", true).apply(VISUALS_KEY);
//public static final ConfigInteger RENDER_FAKE_LIGHTING_LEVEL = new ConfigInteger("renderFakeLightingLevel", 15, 0, 15).apply(VISUALS_KEY);
public static final ConfigBoolean RENDER_PLACEMENT_BOX_SIDES = new ConfigBoolean("renderPlacementBoxSides", false).apply(VISUALS_KEY);
public static final ConfigBoolean RENDER_PLACEMENT_ENCLOSING_BOX = new ConfigBoolean("renderPlacementEnclosingBox", true).apply(VISUALS_KEY);
public static final ConfigBoolean RENDER_PLACEMENT_ENCLOSING_BOX_SIDES= new ConfigBoolean("renderPlacementEnclosingBoxSides", false).apply(VISUALS_KEY);
Expand Down Expand Up @@ -228,11 +232,13 @@ public static class Visuals
ENABLE_SCHEMATIC_OVERLAY,
IGNORE_EXISTING_FLUIDS,
OVERLAY_REDUCED_INNER_SIDES,
RENDER_AO_MODERN_ENABLE,
RENDER_AREA_SELECTION_BOX_SIDES,
RENDER_BLOCKS_AS_TRANSLUCENT,
RENDER_COLLIDING_SCHEMATIC_BLOCKS,
RENDER_ERROR_MARKER_CONNECTIONS,
RENDER_ERROR_MARKER_SIDES,
//RENDER_FAKE_LIGHTING_LEVEL,
RENDER_PLACEMENT_BOX_SIDES,
RENDER_PLACEMENT_ENCLOSING_BOX,
RENDER_PLACEMENT_ENCLOSING_BOX_SIDES,
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/fi/dy/masa/litematica/config/Hotkeys.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class Hotkeys
public static final ConfigHotkey PICK_BLOCK_FIRST = new ConfigHotkey("pickBlockFirst", "BUTTON_3", KeybindSettings.PRESS_ALLOWEXTRA).apply(HOTKEYS_KEY);
public static final ConfigHotkey PICK_BLOCK_LAST = new ConfigHotkey("pickBlockLast", "", KeybindSettings.MODIFIER_INGAME).apply(HOTKEYS_KEY);
public static final ConfigHotkey PICK_BLOCK_TOGGLE = new ConfigHotkey("pickBlockToggle", "M,BUTTON_3").apply(HOTKEYS_KEY);
public static final ConfigHotkey RENDER_INFO_OVERLAY = new ConfigHotkey("renderInfoOverlay", "I", KeybindSettings.PRESS_ALLOWEXTRA).apply(HOTKEYS_KEY);
public static final ConfigHotkey RENDER_INFO_OVERLAY = new ConfigHotkey("renderInfoOverlay", "I", KeybindSettings.PRESS_ALLOWEXTRA_EMPTY).apply(HOTKEYS_KEY);
public static final ConfigHotkey RENDER_OVERLAY_THROUGH_BLOCKS = new ConfigHotkey("renderOverlayThroughBlocks", "RIGHT_CONTROL", KeybindSettings.PRESS_ALLOWEXTRA).apply(HOTKEYS_KEY);
public static final ConfigHotkey RERENDER_SCHEMATIC = new ConfigHotkey("rerenderSchematic", "F3,M").apply(HOTKEYS_KEY);
public static final ConfigHotkey SAVE_AREA_AS_IN_MEMORY_SCHEMATIC = new ConfigHotkey("saveAreaAsInMemorySchematic", "").apply(HOTKEYS_KEY);
Expand Down
47 changes: 29 additions & 18 deletions src/main/java/fi/dy/masa/litematica/data/EntitiesDataStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,12 @@
import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.mob.PiglinEntity;
import net.minecraft.entity.passive.AbstractHorseEntity;
import net.minecraft.entity.passive.VillagerEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.DoubleInventory;
import net.minecraft.inventory.Inventory;
import net.minecraft.inventory.SimpleInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtList;
import net.minecraft.registry.Registries;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.Identifier;
import net.minecraft.util.Util;
import net.minecraft.util.math.BlockPos;
Expand All @@ -39,8 +32,6 @@
import net.minecraft.world.World;

import fi.dy.masa.malilib.interfaces.IClientTickHandler;
import fi.dy.masa.malilib.mixin.IMixinAbstractHorseEntity;
import fi.dy.masa.malilib.mixin.IMixinPiglinEntity;
import fi.dy.masa.malilib.network.ClientPlayHandler;
import fi.dy.masa.malilib.network.IPluginClientPlayHandler;
import fi.dy.masa.malilib.util.Constants;
Expand Down Expand Up @@ -213,7 +204,7 @@ public void reset(boolean isLogout)
else
{
Litematica.debugLog("EntitiesDataStorage#reset() - dimension change or log-in");
this.serverTickTime = System.currentTimeMillis() - (this.cacheTimeout + 5) * 1000L;
this.serverTickTime = System.currentTimeMillis() - (this.getCacheTimeout() + 5000L);
this.tickCache();
this.serverTickTime = System.currentTimeMillis();
this.clientWorld = mc.world;
Expand All @@ -225,19 +216,31 @@ public void reset(boolean isLogout)
this.pendingEntitiesQueue.clear();
}

private long getCacheTimeout()
{
return (long) (MathHelper.clamp(Configs.Generic.ENTITY_DATA_SYNC_CACHE_TIMEOUT.getFloatValue(), 0.25f, 30.0f) * 1000L);
}

private long getCacheTimeoutLong()
{
return (long) (MathHelper.clamp((Configs.Generic.ENTITY_DATA_SYNC_CACHE_TIMEOUT.getFloatValue() * this.longCacheTimeout), 120.0f, 300.0f) * 1000L);
}

private void tickCache()
{
long nowTime = System.currentTimeMillis();
long blockTimeout = (this.cacheTimeout) * 1000L;
long entityTimeout = (this.cacheTimeout / 2) * 1000L;
long blockTimeout = this.getCacheTimeout();
long entityTimeout = this.getCacheTimeout() * 2;
int count;
boolean beEmpty = false;
boolean entEmpty = false;

// Use LongTimeouts when saving a Litematic Selection,
// which is pretty much the standard value x 30 (min 120, max 300 seconds)
if (this.shouldUseLongTimeout)
{
blockTimeout = this.longCacheTimeout * 1000L;
entityTimeout = (this.longCacheTimeout / 2) * 1000L;
blockTimeout = this.getCacheTimeoutLong();
entityTimeout = this.getCacheTimeoutLong();
}

synchronized (this.blockEntityCache)
Expand All @@ -250,7 +253,7 @@ private void tickCache()

if (nowTime - pair.getLeft() > blockTimeout || pair.getLeft() - nowTime > 0)
{
Litematica.debugLog("entityCache: be at pos [{}] has timed out", pos.toShortString());
Litematica.debugLog("entityCache: be at pos [{}] has timed out by [{}] ms", pos.toShortString(), blockTimeout);
this.blockEntityCache.remove(pos);
}
else
Expand All @@ -275,7 +278,7 @@ private void tickCache()

if (nowTime - pair.getLeft() > entityTimeout || pair.getLeft() - nowTime > 0)
{
Litematica.debugLog("entityCache: entity Id [{}] has timed out", entityId);
Litematica.debugLog("entityCache: entity Id [{}] has timed out by [{}] ms", entityId, entityTimeout);
this.entityCache.remove(entityId);
}
else
Expand Down Expand Up @@ -479,7 +482,10 @@ else if (world.getBlockState(pos).getBlock() instanceof BlockEntityProvider)
NbtCompound nbt = be.createNbtWithIdentifyingData(world.getRegistryManager());
Pair<BlockEntity, NbtCompound> pair = Pair.of(be, nbt);

this.blockEntityCache.put(pos, Pair.of(System.currentTimeMillis(), pair));
synchronized (this.blockEntityCache)
{
this.blockEntityCache.put(pos, Pair.of(System.currentTimeMillis(), pair));
}

return pair;
}
Expand Down Expand Up @@ -512,7 +518,12 @@ else if (world.getBlockState(pos).getBlock() instanceof BlockEntityProvider)
if (entity != null && entity.saveSelfNbt(nbt))
{
Pair<Entity, NbtCompound> pair = Pair.of(entity, nbt);
this.entityCache.put(entityId, Pair.of(System.currentTimeMillis(), pair));

synchronized (this.entityCache)
{
this.entityCache.put(entityId, Pair.of(System.currentTimeMillis(), pair));
}

return pair;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public GuiSchematicSaveBase(@Nullable LitematicaSchematic schematic)
this.textField.setMaxLength(256);
this.textField.setFocused(true);

this.checkboxSaveFromSchematicWorld = new WidgetCheckBox(0, 0, Icons.CHECKBOX_UNSELECTED, Icons.CHECKBOX_SELECTED, "Save from schematic world", "If enabled, then the schematic is created by saving the\ncontents of the selection from the schematic world\ninstead of the normal vanilla world.\nThis allows you to combine or trim schematics without having\nto paste them to a temporary creative world.");
this.checkboxSaveFromSchematicWorld = new WidgetCheckBox(0, 0, Icons.CHECKBOX_UNSELECTED, Icons.CHECKBOX_SELECTED, StringUtils.translate("litematica.gui.label.schematic_save.checkbox.save_from_schematic_world"), StringUtils.translate("litematica.gui.label.schematic_save.hover_info.save_from_schematic_world"));
}

@Override
Expand Down Expand Up @@ -86,10 +86,11 @@ else if (this.schematic != null)
this.checkboxSaveFromSchematicWorld.setPosition(x, y + 12);
this.addWidget(this.checkboxSaveFromSchematicWorld);

this.checkboxVisibleOnly = new WidgetCheckBox(x, y + 24, Icons.CHECKBOX_UNSELECTED, Icons.CHECKBOX_SELECTED, "Visible blocks only [experimental quick hax]");
// this.checkboxVisibleOnly = new WidgetCheckBox(x, y + 24, Icons.CHECKBOX_UNSELECTED, Icons.CHECKBOX_SELECTED, "Visible blocks only [experimental quick hax]");
this.checkboxVisibleOnly = new WidgetCheckBox(x, y + 24, Icons.CHECKBOX_UNSELECTED, Icons.CHECKBOX_SELECTED, StringUtils.translate("litematica.gui.label.schematic_save.checkbox.visible_blocks_only"));
this.addWidget(this.checkboxVisibleOnly);

this.checkboxIncludeSupportBlocks = new WidgetCheckBox(x, y + 36, Icons.CHECKBOX_UNSELECTED, Icons.CHECKBOX_SELECTED, "Support blocks", "Include any necessary support blocks in \"Visible blocks only\" mode,\nfor things like Repeaters, Comparators, Carpets or gravity blocks that would be visible");
this.checkboxIncludeSupportBlocks = new WidgetCheckBox(x, y + 36, Icons.CHECKBOX_UNSELECTED, Icons.CHECKBOX_SELECTED, StringUtils.translate("litematica.gui.label.schematic_save.checkbox.support_blocks"), StringUtils.translate("litematica.gui.label.schematic_save.hover_info.support_blocks"));
this.addWidget(this.checkboxIncludeSupportBlocks);

this.createButton(10, 54, ButtonType.SAVE);
Expand Down Expand Up @@ -117,7 +118,7 @@ private int createButton(int x, int y, ButtonType type)

if (type == ButtonType.SAVE)
{
button = new ButtonGeneric(x, y, width, 20, label, "litematica.gui.label.schematic_save.hoverinfo.hold_shift_to_overwrite");
button = new ButtonGeneric(x, y, width, 20, label, "litematica.gui.label.schematic_save.hover_info.hold_shift_to_overwrite");
}
else
{
Expand Down
Loading

0 comments on commit 9406a5c

Please sign in to comment.