超级样板核心修复影子库存问题
This commit is contained in:
parent
d2e8362d61
commit
ff8678ecb6
|
|
@ -1,176 +1,54 @@
|
|||
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.filter.AEItemFilters;
|
||||
import appeng.util.inv.filter.IAEItemFilter;
|
||||
import com.extendedae_plus.init.ModBlockEntities;
|
||||
import com.extendedae_plus.init.ModItems;
|
||||
import com.glodblock.github.extendedae.common.me.matrix.ClusterAssemblerMatrix;
|
||||
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 net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
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 appeng.api.crafting.PatternDetailsHelper;
|
||||
|
||||
public class PatternCorePlusBlockEntity extends TileAssemblerMatrixPattern {
|
||||
|
||||
public static final int INV_SIZE = 72;
|
||||
|
||||
private final AppEngInternalInventory patternInventory;
|
||||
private final FilteredInternalInventory insertOnlyInventory;
|
||||
private final List<IPatternDetails> patterns = new ArrayList<>();
|
||||
|
||||
public PatternCorePlusBlockEntity(BlockPos pos, BlockState blockState) {
|
||||
super(pos, blockState);
|
||||
this.patternInventory = new AppEngInternalInventory(this, INV_SIZE, 1);
|
||||
this.patternInventory.setFilter(new Filter(this::getLevel));
|
||||
this.insertOnlyInventory = new FilteredInternalInventory(this.patternInventory, AEItemFilters.INSERT_ONLY);
|
||||
this.getMainNode().addService(ICraftingProvider.class, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveAdditional(CompoundTag data, HolderLookup.Provider registries) {
|
||||
super.saveAdditional(data, registries);
|
||||
this.patternInventory.writeToNBT(data, "pattern", registries);
|
||||
}
|
||||
((BlockEntityAccessor) (Object) this)
|
||||
.extendedae_plus$setType(ModBlockEntities.ASSEMBLER_MATRIX_PATTERN_PLUS_BE.get());
|
||||
|
||||
@Override
|
||||
public void loadTag(CompoundTag data, HolderLookup.Provider registries) {
|
||||
super.loadTag(data, registries);
|
||||
this.patternInventory.readFromNBT(data, "pattern", registries);
|
||||
}
|
||||
|
||||
public AppEngInternalInventory getPatternInventory() {
|
||||
return this.patternInventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppEngInternalInventory getExposedInventory() {
|
||||
return this.patternInventory;
|
||||
}
|
||||
|
||||
|
||||
public InternalInventory getInsertOnlyInventory() {
|
||||
return this.insertOnlyInventory;
|
||||
}
|
||||
|
||||
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) {
|
||||
this.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 cluster) {
|
||||
cluster.addPattern(this);
|
||||
}
|
||||
|
||||
public void onChangeInventory(InternalInventory inv, int slot) {
|
||||
this.saveChanges();
|
||||
this.updatePatterns();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveChangedInventory(AppEngInternalInventory inv) {
|
||||
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;
|
||||
var inventory = new AppEngInternalInventory(this, INV_SIZE, 1);
|
||||
inventory.setFilter(new Filter(this::getLevel));
|
||||
((TileAssemblerMatrixPatternAccessor) (Object) this).extendedae_plus$setPatternInventory(inventory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PatternContainerGroup getTerminalGroup() {
|
||||
var icon = AEItemKey.of(ModItems.ASSEMBLER_MATRIX_PATTERN_PLUS.get());
|
||||
return new PatternContainerGroup(icon, icon.getDisplayName(), List.of(Component.translatable("gui.expatternprovider.assembler_matrix.pattern")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTerminalSortOrder() {
|
||||
return this.getLocateID();
|
||||
var name = this.hasCustomName() ? this.getCustomName() : icon.getDisplayName();
|
||||
return new PatternContainerGroup(
|
||||
icon,
|
||||
name,
|
||||
List.of(Component.translatable("gui.extendedae_plus.assembler_matrix.pattern"))
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -182,8 +60,9 @@ 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;
|
||||
if (stack.getItem() instanceof EncodedPatternItem<?>) {
|
||||
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);
|
||||
}
|
||||
|
|
@ -50,6 +50,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 Assembly Matrix",
|
||||
|
|
|
|||
|
|
@ -50,6 +50,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": "超级装配矩阵样板核心",
|
||||
|
||||
"extendedae_plus.upload_to_matrix": "上传到装配矩阵",
|
||||
"extendedae_plus.upload_to_matrix.success": "样板已上传到装配矩阵",
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@
|
|||
"ae2.parts.automation.IOBusPartChannelCardMixin",
|
||||
"ae2.parts.storagebus.StorageBusPartChannelCardMixin",
|
||||
"ae2WTlib.ContainerUWirelessExPatternTerminalMixin",
|
||||
"extendedae.accessor.TileAssemblerMatrixPatternAccessor",
|
||||
"extendedae.common.PartExPatternProviderMixin",
|
||||
"extendedae.common.TileExPatternProviderMixin",
|
||||
"extendedae.common.matrix.ClusterAssemblerMatrixMixin",
|
||||
|
|
@ -60,7 +61,8 @@
|
|||
"extendedae.container.ContainerAssemblerMatrixPatternSlotTrackerMixin",
|
||||
"extendedae.container.ContainerExPatternProviderMixin",
|
||||
"extendedae.container.ContainerExPatternTerminalMixin",
|
||||
"extendedae.container.ContainerWirelessExPatternTerminalMixin"
|
||||
"extendedae.container.ContainerWirelessExPatternTerminalMixin",
|
||||
"minecraft.accessor.BlockEntityAccessor"
|
||||
],
|
||||
"client": [
|
||||
"accessor.AbstractContainerScreenAccessor",
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user