diff --git a/gradle.properties b/gradle.properties index a3b8e9c..a48a883 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,4 +5,4 @@ version_minecraft=1.16.4 version_forge_minecraft=1.16.4-35.1.10 version_fml_mappings=20201028-1.16.3 version_jei=1.16.4:7.6.1.63 -version_engineersdecor=1.1.6 +version_engineersdecor=1.1.7 diff --git a/meta/update.json b/meta/update.json index 089c749..8365b68 100644 --- a/meta/update.json +++ b/meta/update.json @@ -1,6 +1,7 @@ { "homepage": "https://www.curseforge.com/minecraft/mc-mods/engineers-decor/", "1.16.4": { + "1.1.7": "[M] 1.16.5 support.\n[F] Fixed Labeled Crate include (issue #157, ty NillerMedDild).", "1.1.6": "[F] Added common-config opt-out specification for pack level opt-outs (issue #154, ty gekkone), will replace server config opt-out in MC1.17.", "1.1.6-b3": "[M] Config logging edited, E-Furnace GUI capacitor tooltip added, E-Furnace power consumption independent of config speed setting (issue #152 ty Staegrin).", "1.1.6-b2": "[M] Alternative Clinker Brick recipe (swapped Bricks/Nether Bricks) added.\n[M] Furnace XP handling simplified (simply stores/releases XP for each smelting process).\n[M] Mod devices do not propagate strong Redstone power to adjacent blocks.\n[M] Minor \"librarizing\" changes under the hood.", @@ -24,7 +25,7 @@ "1.1.2-b1": "[U] Ported to MC1.16.2." }, "promos": { - "1.16.4-recommended": "1.1.6", - "1.16.4-latest": "1.1.6" + "1.16.4-recommended": "1.1.7", + "1.16.4-latest": "1.1.7" } } \ No newline at end of file diff --git a/readme.md b/readme.md index d0deb24..96a0db0 100644 --- a/readme.md +++ b/readme.md @@ -11,6 +11,9 @@ Mod sources for Minecraft version 1.16.x. ## Version history + - v1.1.7 [M] 1.16.5 support. + [F] Fixed Labeled Crate include (issue #157, ty NillerMedDild). + - v1.1.6 [F] Added common-config opt-out specification for pack level opt-outs (issue #154, ty gekkone), will replace server config opt-out in MC1.17. diff --git a/src/main/java/wile/engineersdecor/ModConfig.java b/src/main/java/wile/engineersdecor/ModConfig.java index 3f24407..8775ebc 100644 --- a/src/main/java/wile/engineersdecor/ModConfig.java +++ b/src/main/java/wile/engineersdecor/ModConfig.java @@ -585,7 +585,6 @@ public class ModConfig if(SERVER_CONFIG_SPEC.isLoaded()) { /// @todo: remove for MC1.17/1.16.5 String inc = SERVER.pattern_includes.get().toLowerCase().replaceAll(MODID+":", "").replaceAll("[^*_,a-z0-9]", ""); - if(SERVER.pattern_includes.get() != inc) SERVER.pattern_includes.set(inc); String[] incl = inc.split(","); for(int i=0; i< incl.length; ++i) { incl[i] = incl[i].replaceAll("[*]", ".*?"); @@ -601,8 +600,8 @@ public class ModConfig if(!excl[i].isEmpty()) excludes.add(excl[i]); } } - if(!excludes.isEmpty()) LOGGER.info("Config pattern excludes: '" + String.join(",", excludes) + "'"); - if(!includes.isEmpty()) LOGGER.info("Config pattern includes: '" + String.join(",", includes) + "'"); + if(!excludes.isEmpty()) log("Config pattern excludes: '" + String.join(",", excludes) + "'"); + if(!includes.isEmpty()) log("Config pattern includes: '" + String.join(",", includes) + "'"); { HashSet optouts = new HashSet<>(); ModContent.getRegisteredItems().stream().filter((item)->(item!=null)).forEach( @@ -701,7 +700,7 @@ public class ModConfig ); optouts_ = optouts; } - OptionalRecipeCondition.on_config(withExperimental(), withoutRecipes(), (block)->isOptedOut(block), (item)->isOptedOut(item)); + OptionalRecipeCondition.on_config(withExperimental(), withoutRecipes(), ModConfig::isOptedOut, ModConfig::isOptedOut); } public static final void apply() diff --git a/src/main/java/wile/engineersdecor/blocks/EdLabeledCrate.java b/src/main/java/wile/engineersdecor/blocks/EdLabeledCrate.java index d55f0c3..5b48350 100644 --- a/src/main/java/wile/engineersdecor/blocks/EdLabeledCrate.java +++ b/src/main/java/wile/engineersdecor/blocks/EdLabeledCrate.java @@ -10,7 +10,6 @@ package wile.engineersdecor.blocks; import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.matrix.MatrixStack; -import javafx.util.Pair; import net.minecraft.world.IWorldReader; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; @@ -195,12 +194,12 @@ public class EdLabeledCrate total_items += e.getCount(); } } - List> itmes = new ArrayList<>(); - for(Map.Entry e:item_map.entrySet()) itmes.add(new Pair<>(e.getKey().getTranslationKey(), e.getValue())); - itmes.sort((a,b)->b.getValue()-a.getValue()); + List> itmes = new ArrayList<>(); + for(Map.Entry e:item_map.entrySet()) itmes.add(new Tuple<>(e.getKey().getTranslationKey(), e.getValue())); + itmes.sort((a,b)->b.getB()-a.getB()); boolean dotdotdot = false; if(itmes.size() > 8) { itmes.subList(8, itmes.size()).clear(); dotdotdot = true; } - stats = itmes.stream().map(e->Auxiliaries.localize(e.getKey())).collect(Collectors.joining(", ")); + stats = itmes.stream().map(e->Auxiliaries.localize(e.getA())).collect(Collectors.joining(", ")); if(dotdotdot) stats += "..."; } } @@ -230,8 +229,9 @@ public class EdLabeledCrate public static final int NUM_OF_STORAGE_ROWS = 6; public static final int ITEMFRAME_SLOTNO = NUM_OF_STORAGE_SLOTS; - protected final Inventories.StorageInventory main_inventory_ = new StorageInventory(this, NUM_OF_SLOTS, 1); - protected final InventoryRange storage_range_ = new InventoryRange(main_inventory_, 0, NUM_OF_STORAGE_SLOTS, NUM_OF_STORAGE_ROWS); + protected final Inventories.StorageInventory main_inventory_; + protected LazyOptional item_handler_; + protected final InventoryRange storage_range_; private @Nullable ITextComponent custom_name_; public LabeledCrateTileEntity() @@ -239,9 +239,17 @@ public class EdLabeledCrate public LabeledCrateTileEntity(TileEntityType te_type) { - super(te_type); reset(); - main_inventory_.setCloseAction(player->{ - if(!getWorld().isRemote()) Networking.PacketTileNotifyServerToClient.sendToPlayers(this, writenbt(new CompoundNBT())); + super(te_type); + main_inventory_ = new StorageInventory(this, NUM_OF_SLOTS, 1); + storage_range_ = new InventoryRange(main_inventory_, 0, NUM_OF_STORAGE_SLOTS, NUM_OF_STORAGE_ROWS); + item_handler_ = MappedItemHandler.createGenericHandler(storage_range_, + (slot,stack)->(slot!=ITEMFRAME_SLOTNO), + (slot,stack)->(slot!=ITEMFRAME_SLOTNO), + IntStream.range(0, NUM_OF_STORAGE_SLOTS).boxed().collect(Collectors.toList()) + ); + main_inventory_.setCloseAction((player)->{ Networking.PacketTileNotifyServerToClient.sendToPlayers(this, writenbt(new CompoundNBT())); }); + main_inventory_.setSlotChangeAction((index,stack)->{ + if(index==ITEMFRAME_SLOTNO) Networking.PacketTileNotifyServerToClient.sendToPlayers(this, writenbt(new CompoundNBT())); }); } @@ -282,6 +290,15 @@ public class EdLabeledCrate public void onServerPacketReceived(CompoundNBT nbt) { readnbt(nbt); } + // Capability export ---------------------------------------------------------------------------- + + @Override + public LazyOptional getCapability(net.minecraftforge.common.capabilities.Capability capability, @Nullable Direction facing) + { + if(capability==CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) return item_handler_.cast(); + return super.getCapability(capability, facing); + } + // TileEntity ------------------------------------------------------------------------------ @Override @@ -373,20 +390,6 @@ public class EdLabeledCrate } }; - // Capability export ---------------------------------------------------------------------------- - - protected LazyOptional item_handler_ = MappedItemHandler.createGenericHandler(storage_range_, - (slot,stack)->(slot!=ITEMFRAME_SLOTNO), - (slot,stack)->(slot!=ITEMFRAME_SLOTNO), - IntStream.range(0, NUM_OF_STORAGE_SLOTS).boxed().collect(Collectors.toList()) - ); - - @Override - public LazyOptional getCapability(net.minecraftforge.common.capabilities.Capability capability, @Nullable Direction facing) - { - if(capability==CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) return item_handler_.cast(); - return super.getCapability(capability, facing); - } } //-------------------------------------------------------------------------------------------------------------------- @@ -528,8 +531,8 @@ public class EdLabeledCrate @Override public void onClientPacketReceived(int windowId, PlayerEntity player, CompoundNBT nbt) { - boolean changed = false; if(!nbt.contains("action")) return; + boolean changed = false; final int slotId = nbt.contains("slot") ? nbt.getInt("slot") : -1; switch(nbt.getString("action")) { case QUICK_MOVE_ALL: { diff --git a/src/main/java/wile/engineersdecor/eapi/jei/JEIPlugin.java b/src/main/java/wile/engineersdecor/eapi/jei/JEIPlugin.java index 5cb8fd0..258a935 100644 --- a/src/main/java/wile/engineersdecor/eapi/jei/JEIPlugin.java +++ b/src/main/java/wile/engineersdecor/eapi/jei/JEIPlugin.java @@ -9,6 +9,7 @@ package wile.engineersdecor.eapi.jei; //public class JEIPlugin {} +import mezz.jei.api.registration.IRecipeCatalystRegistration; import wile.engineersdecor.ModEngineersDecor; import wile.engineersdecor.ModConfig; import wile.engineersdecor.ModContent; @@ -75,4 +76,18 @@ public class JEIPlugin implements mezz.jei.api.IModPlugin } } } + + @Override + public void registerRecipeCatalysts(IRecipeCatalystRegistration registration) + { + if(!ModConfig.isOptedOut(ModContent.CRAFTING_TABLE)) { + registration.addRecipeCatalyst(new ItemStack(ModContent.CRAFTING_TABLE), VanillaRecipeCategoryUid.CRAFTING); + } + if(!ModConfig.isOptedOut(ModContent.SMALL_LAB_FURNACE)) { + registration.addRecipeCatalyst(new ItemStack(ModContent.SMALL_LAB_FURNACE), VanillaRecipeCategoryUid.FURNACE); + } + if(!ModConfig.isOptedOut(ModContent.SMALL_ELECTRICAL_FURNACE)) { + registration.addRecipeCatalyst(new ItemStack(ModContent.SMALL_ELECTRICAL_FURNACE), VanillaRecipeCategoryUid.FURNACE); + } + } } diff --git a/src/main/java/wile/engineersdecor/libmc/detail/Inventories.java b/src/main/java/wile/engineersdecor/libmc/detail/Inventories.java index 02e3785..589053a 100644 --- a/src/main/java/wile/engineersdecor/libmc/detail/Inventories.java +++ b/src/main/java/wile/engineersdecor/libmc/detail/Inventories.java @@ -33,6 +33,7 @@ import net.minecraftforge.items.wrapper.SidedInvWrapper; import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.util.*; +import java.util.function.BiConsumer; import java.util.function.BiPredicate; import java.util.function.Consumer; import java.util.stream.Collectors; @@ -287,6 +288,8 @@ public class Inventories { public final IInventory inventory; public final int offset, size, num_rows; + protected int max_stack_size_ = 64; + protected BiPredicate validator_ = (index, stack)->true; public InventoryRange(IInventory inventory, int offset, int size, int num_rows) { @@ -308,46 +311,71 @@ public class Inventories public static InventoryRange fromPlayerInventory(PlayerEntity player) { return new InventoryRange(player.inventory, 0, 36, 4); } + public InventoryRange setValidator(BiPredicate validator) + { validator_ = validator; return this; } + + public BiPredicate getValidator() + { return validator_; } + + public InventoryRange setMaxStackSize(int count) + { max_stack_size_ = Math.max(count, 1) ; return this; } + + public int getMaxStackSize() + { return max_stack_size_ ; } + // IInventory ------------------------------------------------------------------------------------------------------ + @Override public void clear() { inventory.clear(); } + @Override public int getSizeInventory() { return size; } + @Override public boolean isEmpty() { for(int i=0; i validator_ = (index, stack)->true; protected Consumer open_action_ = (player)->{}; protected Consumer close_action_ = (player)->{}; + protected BiConsumer slot_set_action_ = (index, stack)->{}; public StorageInventory(TileEntity te, int size) { this(te, size, 1); } @@ -637,12 +666,18 @@ public class Inventories public StorageInventory setCloseAction(Consumer fn) { close_action_ = fn; return this; } + public StorageInventory setSlotChangeAction(BiConsumer fn) + { slot_set_action_ = fn; return this; } + public StorageInventory setStackLimit(int max_slot_stack_size) { stack_limit_ = Math.max(max_slot_stack_size, 1); return this; } public StorageInventory setValidator(BiPredicate validator) { validator_ = validator; return this; } + public BiPredicate getValidator() + { return validator_; } + // Iterable --------------------------------------------------------------------- public Iterator iterator() @@ -675,7 +710,12 @@ public class Inventories @Override public void setInventorySlotContents(int index, ItemStack stack) - { stacks_.set(index, stack); } + { + stacks_.set(index, stack); + if((stack.getCount() != stacks_.get(index).getCount()) || !areItemStacksDifferent(stacks_.get(index),stack)) { + slot_set_action_.accept(index, stack); + } + } @Override public int getInventoryStackLimit() diff --git a/src/main/java/wile/engineersdecor/libmc/detail/Networking.java b/src/main/java/wile/engineersdecor/libmc/detail/Networking.java index e51b96e..9b5f2d2 100644 --- a/src/main/java/wile/engineersdecor/libmc/detail/Networking.java +++ b/src/main/java/wile/engineersdecor/libmc/detail/Networking.java @@ -113,7 +113,7 @@ public class Networking public static void sendToPlayers(TileEntity te, CompoundNBT nbt) { - if(te==null) return; + if(te==null || te.getWorld().isRemote()) return; for(PlayerEntity player: te.getWorld().getPlayers()) sendToPlayer(player, te, nbt); } diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 29596df..3c470e0 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -26,6 +26,6 @@ logoFile="logo.png" [[dependencies.engineersdecor]] modId="minecraft" mandatory=true - versionRange="[1.16.4]" + versionRange="[1.16.4,)" ordering="NONE" side="BOTH"