超级样板核心修复影子库存问题
This commit is contained in:
parent
4669029490
commit
8fd56ce4ef
|
|
@ -1,170 +1,67 @@
|
|||
package com.extendedae_plus.content.matrix;
|
||||
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.api.crafting.IPatternDetails;
|
||||
import appeng.api.crafting.PatternDetailsHelper;
|
||||
import appeng.api.implementations.blockentities.PatternContainerGroup;
|
||||
import appeng.api.inventories.InternalInventory;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.crafting.ICraftingProvider;
|
||||
import appeng.api.stacks.AEItemKey;
|
||||
import appeng.api.stacks.KeyCounter;
|
||||
import appeng.blockentity.crafting.IMolecularAssemblerSupportedPattern;
|
||||
import appeng.crafting.pattern.EncodedPatternItem;
|
||||
import appeng.helpers.patternprovider.PatternContainer;
|
||||
import appeng.util.inv.AppEngInternalInventory;
|
||||
import appeng.util.inv.FilteredInternalInventory;
|
||||
import appeng.util.inv.InternalInventoryHost;
|
||||
import appeng.util.inv.filter.AEItemFilters;
|
||||
import appeng.util.inv.filter.IAEItemFilter;
|
||||
import com.extendedae_plus.init.ModBlockEntities;
|
||||
import com.glodblock.github.extendedae.common.EPPItemAndBlock;
|
||||
import com.glodblock.github.extendedae.common.me.matrix.ClusterAssemblerMatrix;
|
||||
import com.extendedae_plus.init.ModItems;
|
||||
import com.extendedae_plus.mixin.extendedae.accessor.TileAssemblerMatrixPatternAccessor;
|
||||
import com.extendedae_plus.mixin.minecraft.accessor.BlockEntityAccessor;
|
||||
import com.glodblock.github.extendedae.common.tileentities.matrix.TileAssemblerMatrixPattern;
|
||||
import com.glodblock.github.glodium.util.GlodUtil;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import static com.extendedae_plus.init.ModBlockEntities.BLOCK_ENTITY_TYPES;
|
||||
|
||||
public class PatternCorePlusBlockEntity extends TileAssemblerMatrixPattern {
|
||||
|
||||
public final static int INV_SIZE = 72;
|
||||
private final AppEngInternalInventory patternInventory;
|
||||
public static final int INV_SIZE = 72;
|
||||
|
||||
private final FilteredInternalInventory exposedInventory;
|
||||
private final List<IPatternDetails> patterns = new ArrayList<>();
|
||||
private final BlockEntityType<?> overriddenType;
|
||||
|
||||
public PatternCorePlusBlockEntity(BlockPos pos, BlockState blockState) {
|
||||
super(pos, blockState);
|
||||
this.overriddenType = ModBlockEntities.ASSEMBLER_MATRIX_PATTERN_PLUS_BE.get();
|
||||
|
||||
this.patternInventory = new AppEngInternalInventory(this, INV_SIZE, 1);
|
||||
this.patternInventory.setFilter(new Filter(this::getLevel));
|
||||
this.exposedInventory = new FilteredInternalInventory(this.patternInventory, AEItemFilters.INSERT_ONLY);
|
||||
this.getMainNode().addService(ICraftingProvider.class, this);
|
||||
((BlockEntityAccessor) (Object) this)
|
||||
.extendedae_plus$setType(ModBlockEntities.ASSEMBLER_MATRIX_PATTERN_PLUS_BE.get());
|
||||
|
||||
var inventory = new AppEngInternalInventory(this, INV_SIZE, 1);
|
||||
inventory.setFilter(new Filter(this::getLevel));
|
||||
((TileAssemblerMatrixPatternAccessor) (Object) this).extendedae_plus$setPatternInventory(inventory);
|
||||
this.exposedInventory = new FilteredInternalInventory(inventory, AEItemFilters.INSERT_ONLY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveAdditional(CompoundTag data) {
|
||||
super.saveAdditional(data);
|
||||
this.patternInventory.writeToNBT(data, "pattern");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadTag(CompoundTag data) {
|
||||
super.loadTag(data);
|
||||
this.patternInventory.readFromNBT(data, "pattern");
|
||||
}
|
||||
|
||||
public AppEngInternalInventory getPatternInventory() {
|
||||
return this.patternInventory;
|
||||
}
|
||||
|
||||
public FilteredInternalInventory getExposedInventory() {
|
||||
return this.exposedInventory;
|
||||
}
|
||||
|
||||
public long getLocateID() {
|
||||
return this.worldPosition.asLong();
|
||||
}
|
||||
|
||||
public void updatePatterns() {
|
||||
this.patterns.clear();
|
||||
for (var stack : this.patternInventory) {
|
||||
var details = PatternDetailsHelper.decodePattern(stack, this.getLevel());
|
||||
if (details != null) {
|
||||
patterns.add(details);
|
||||
}
|
||||
}
|
||||
ICraftingProvider.requestUpdate(this.getMainNode());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAdditionalDrops(Level level, BlockPos pos, List<ItemStack> drops) {
|
||||
super.addAdditionalDrops(level, pos, drops);
|
||||
for (var pattern : this.patternInventory) {
|
||||
drops.add(pattern);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearContent() {
|
||||
super.clearContent();
|
||||
this.patternInventory.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(ClusterAssemblerMatrix c) {
|
||||
c.addPattern(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(InternalInventory inv, int slot) {
|
||||
this.saveChanges();
|
||||
this.updatePatterns();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReady() {
|
||||
super.onReady();
|
||||
this.updatePatterns();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IPatternDetails> getAvailablePatterns() {
|
||||
return this.patterns;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pushPattern(IPatternDetails patternDetails, KeyCounter[] inputHolder) {
|
||||
if (!isFormed() || !this.getMainNode().isActive() || !this.patterns.contains(patternDetails)) {
|
||||
return false;
|
||||
}
|
||||
return this.cluster.pushCraftingJob(patternDetails, inputHolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBusy() {
|
||||
return this.cluster == null || this.cluster.isBusy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable IGrid getGrid() {
|
||||
return this.getMainNode().getGrid();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InternalInventory getTerminalPatternInventory() {
|
||||
return this.patternInventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTerminal() {
|
||||
return this.manager.getSetting(Settings.PATTERN_ACCESS_TERMINAL) == YesNo.YES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PatternContainerGroup getTerminalGroup() {
|
||||
var icon = AEItemKey.of(EPPItemAndBlock.ASSEMBLER_MATRIX_PATTERN);
|
||||
return new PatternContainerGroup(icon, icon.getDisplayName(), List.of(Component.translatable("gui.expatternprovider.assembler_matrix.pattern")));
|
||||
var icon = AEItemKey.of(ModItems.ASSEMBLER_MATRIX_PATTERN_PLUS.get());
|
||||
var name = this.hasCustomName() ? this.getCustomName() : icon.getDisplayName();
|
||||
return new PatternContainerGroup(
|
||||
icon,
|
||||
name,
|
||||
List.of(Component.translatable("gui.extendedae_plus.assembler_matrix.pattern"))
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<?> getType() {
|
||||
return this.overriddenType;
|
||||
public BlockEntityType<?> getType() {
|
||||
return ModBlockEntities.ASSEMBLER_MATRIX_PATTERN_PLUS_BE.get();
|
||||
}
|
||||
|
||||
public record Filter(Supplier<Level> world) implements IAEItemFilter {
|
||||
|
|
@ -172,11 +69,10 @@ public class PatternCorePlusBlockEntity extends TileAssemblerMatrixPattern {
|
|||
@Override
|
||||
public boolean allowInsert(InternalInventory inv, int slot, ItemStack stack) {
|
||||
if (stack.getItem() instanceof EncodedPatternItem) {
|
||||
return PatternDetailsHelper.decodePattern(stack, world.get()) instanceof IMolecularAssemblerSupportedPattern;
|
||||
return PatternDetailsHelper.decodePattern(stack, world.get())
|
||||
instanceof IMolecularAssemblerSupportedPattern;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
package com.extendedae_plus.mixin.extendedae.accessor;
|
||||
|
||||
import appeng.util.inv.AppEngInternalInventory;
|
||||
import com.glodblock.github.extendedae.common.tileentities.matrix.TileAssemblerMatrixPattern;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Mutable;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(TileAssemblerMatrixPattern.class)
|
||||
public interface TileAssemblerMatrixPatternAccessor {
|
||||
|
||||
@Accessor("patternInventory")
|
||||
@Mutable
|
||||
void extendedae_plus$setPatternInventory(AppEngInternalInventory inventory);
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.extendedae_plus.mixin.minecraft.accessor;
|
||||
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Mutable;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(BlockEntity.class)
|
||||
public interface BlockEntityAccessor {
|
||||
|
||||
@Accessor("type")
|
||||
@Mutable
|
||||
void extendedae_plus$setType(BlockEntityType<?> type);
|
||||
}
|
||||
|
|
@ -72,6 +72,7 @@
|
|||
"block.extendedae_plus.assembler_matrix_speed_plus": "Assembler Matrix Speed Core Plus",
|
||||
"block.extendedae_plus.assembler_matrix_crafter_plus": "Assembler Matrix Crafter Core Plus",
|
||||
"block.extendedae_plus.assembler_matrix_pattern_plus": "Assembler Matrix Pattern Core Plus",
|
||||
"gui.extendedae_plus.assembler_matrix.pattern": "Assembler Matrix Pattern Core Plus",
|
||||
|
||||
"extendedae_plus.upload_to_matrix": "Upload to Assembly Matrix",
|
||||
"extendedae_plus.upload_to_matrix.success": "Pattern uploaded to the assembly matrix",
|
||||
|
|
@ -239,4 +240,4 @@
|
|||
"key.extendedae_plus.create_pattern": "Create Pattern from JEI",
|
||||
"key.extendedae_plus.fill_search": "Fill Search Field from JEI",
|
||||
"key.categories.extendedae_plus": "ExtendedAE Plus"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@
|
|||
"block.extendedae_plus.assembler_matrix_speed_plus": "超级装配矩阵速度核心",
|
||||
"block.extendedae_plus.assembler_matrix_crafter_plus": "超级装配矩阵合成核心",
|
||||
"block.extendedae_plus.assembler_matrix_pattern_plus": "超级装配矩阵样板核心",
|
||||
"gui.extendedae_plus.assembler_matrix.pattern": "超级装配矩阵样板核心",
|
||||
"block.extendedae_plus.labeled_wireless_transceiver": "标签无线收发器",
|
||||
|
||||
"extendedae_plus.upload_to_matrix": "上传到装配矩阵",
|
||||
|
|
@ -238,4 +239,4 @@
|
|||
"key.extendedae_plus.create_pattern": "从JEI创建样板",
|
||||
"key.extendedae_plus.fill_search": "从JEI填充搜索框",
|
||||
"key.categories.extendedae_plus": "ExtendedAE Plus"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,7 +69,8 @@
|
|||
"block.extendedae_plus.assembler_matrix_upload_core": "裝配矩陣上傳核心",
|
||||
"block.extendedae_plus.assembler_matrix_speed_plus": "超級裝配矩陣速度核心",
|
||||
"block.extendedae_plus.assembler_matrix_crafter_plus": "超級裝配矩陣合成核心",
|
||||
"block.extendedae_plus.assembler_matrix_pattern_plus": "超級裝配矩陣樣板核心",
|
||||
"block.extendedae_plus.assembler_matrix_pattern_plus": "超級裝配矩陣樣板核心",
|
||||
"gui.extendedae_plus.assembler_matrix.pattern": "超級裝配矩陣樣板核心",
|
||||
"block.extendedae_plus.labeled_wireless_transceiver": "標籤無線收發器",
|
||||
|
||||
"extendedae_plus.upload_to_matrix": "上傳到裝配矩陣",
|
||||
|
|
|
|||
|
|
@ -86,12 +86,14 @@
|
|||
"ae2.parts.storagebus.StorageBusPartTickerChannelCardMixin",
|
||||
"ae2WTlib.ContainerUWirelessExPatternTerminalMixin",
|
||||
"appflux.AppfluxPatternProviderLogicMixin",
|
||||
"extendedae.accessor.TileAssemblerMatrixPatternAccessor",
|
||||
"extendedae.common.PartExPatternProviderMixin",
|
||||
"extendedae.common.TileExPatternProviderMixin",
|
||||
"extendedae.container.ContainerAssemblerMatrixPatternSlotTrackerMixin",
|
||||
"extendedae.container.ContainerExPatternProviderMixin",
|
||||
"extendedae.container.ContainerExPatternTerminalMixin",
|
||||
"extendedae.container.ContainerWirelessExPatternTerminalMixin",
|
||||
"minecraft.accessor.BlockEntityAccessor",
|
||||
"guideme.ItemLinkCompilerMixin",
|
||||
"guideme.MdxAttrsMixin"
|
||||
],
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user