MC1.16.5 supported. Fixed Labeled Crate import (issue #157), additional Labeled Crate tile sync added on frame slot change.

This commit is contained in:
stfwi 2021-01-17 11:47:49 +01:00
parent 915ef88029
commit 47936fb76f
9 changed files with 98 additions and 37 deletions

View file

@ -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

View file

@ -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"
}
}

View file

@ -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.

View file

@ -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<String> 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()

View file

@ -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<Pair<String,Integer>> itmes = new ArrayList<>();
for(Map.Entry<Item,Integer> e:item_map.entrySet()) itmes.add(new Pair<>(e.getKey().getTranslationKey(), e.getValue()));
itmes.sort((a,b)->b.getValue()-a.getValue());
List<Tuple<String,Integer>> itmes = new ArrayList<>();
for(Map.Entry<Item,Integer> 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<IItemHandler> 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 <T> LazyOptional<T> getCapability(net.minecraftforge.common.capabilities.Capability<T> 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<IItemHandler> 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 <T> LazyOptional<T> getCapability(net.minecraftforge.common.capabilities.Capability<T> 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: {

View file

@ -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);
}
}
}

View file

@ -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<Integer, ItemStack> 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<Integer, ItemStack> validator)
{ validator_ = validator; return this; }
public BiPredicate<Integer, ItemStack> 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<size; ++i) if(!inventory.getStackInSlot(offset+i).isEmpty()){return false;} return true; }
@Override
public ItemStack getStackInSlot(int index)
{ return inventory.getStackInSlot(offset+index); }
@Override
public ItemStack decrStackSize(int index, int count)
{ return inventory.decrStackSize(offset+index, count); }
@Override
public ItemStack removeStackFromSlot(int index)
{ return inventory.removeStackFromSlot(offset+index); }
@Override
public void setInventorySlotContents(int index, ItemStack stack)
{ inventory.setInventorySlotContents(offset+index, stack); }
@Override
public int getInventoryStackLimit()
{ return inventory.getInventoryStackLimit(); }
{ return Math.min(max_stack_size_, inventory.getInventoryStackLimit()); }
@Override
public void markDirty()
{ inventory.markDirty(); }
@Override
public boolean isUsableByPlayer(PlayerEntity player)
{ return inventory.isUsableByPlayer(player); }
@Override
public void openInventory(PlayerEntity player)
{ inventory.openInventory(player); }
@Override
public void closeInventory(PlayerEntity player)
{ inventory.closeInventory(player); }
@Override
public boolean isItemValidForSlot(int index, ItemStack stack)
{ return inventory.isItemValidForSlot(offset+index, stack); }
{ return validator_.test(offset+index, stack) && inventory.isItemValidForSlot(offset+index, stack); }
//------------------------------------------------------------------------------------------------------------------
@ -597,6 +625,7 @@ public class Inventories
protected BiPredicate<Integer, ItemStack> validator_ = (index, stack)->true;
protected Consumer<PlayerEntity> open_action_ = (player)->{};
protected Consumer<PlayerEntity> close_action_ = (player)->{};
protected BiConsumer<Integer,ItemStack> 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<PlayerEntity> fn)
{ close_action_ = fn; return this; }
public StorageInventory setSlotChangeAction(BiConsumer<Integer,ItemStack> 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<Integer, ItemStack> validator)
{ validator_ = validator; return this; }
public BiPredicate<Integer, ItemStack> getValidator()
{ return validator_; }
// Iterable<ItemStack> ---------------------------------------------------------------------
public Iterator<ItemStack> 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()

View file

@ -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);
}

View file

@ -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"