Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6425ef6ecd | |||
| 7ebb2a0fbb | |||
| 20a1fec6fb | |||
| 0fffc829ab | |||
| 88635d9a8d | |||
| 0fd0ed1b1c | |||
| 87f884228e | |||
| 3495d3dfd4 | |||
| 0acb03b83d | |||
| 9adb0359dd |
@@ -54,6 +54,7 @@ import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumHand;
|
||||
@@ -82,6 +83,7 @@ import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
import static appeng.client.KeyBindings.WCT;
|
||||
import static appeng.client.KeyBindings.WFT;
|
||||
@@ -372,4 +374,16 @@ public class ClientHelper extends ServerHelper {
|
||||
public boolean isActionKey(ActionKey key, int pressedKeyCode) {
|
||||
return this.bindings.get(key).isActiveAndMatches(pressedKeyCode);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityPlayer getPlayerByUUID(UUID uuid) {
|
||||
if (Platform.isClient()) {
|
||||
if (Minecraft.getMinecraft().player.getUniqueID().equals(uuid)) {
|
||||
return Minecraft.getMinecraft().player;
|
||||
}
|
||||
return null;
|
||||
} else {
|
||||
return super.getPlayerByUUID(uuid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
package appeng.client.gui;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.gui.implementations.*;
|
||||
import appeng.client.gui.implementations.GuiCraftAmount;
|
||||
import appeng.client.gui.implementations.GuiCraftConfirm;
|
||||
import appeng.client.gui.implementations.GuiCraftingCPU;
|
||||
import appeng.client.gui.implementations.GuiExpandedProcessingPatternTerm;
|
||||
import appeng.client.gui.implementations.GuiPatternTerm;
|
||||
import appeng.client.gui.implementations.GuiUpgradeable;
|
||||
import appeng.container.interfaces.IJEIGhostIngredients;
|
||||
import appeng.container.slot.SlotFake;
|
||||
import appeng.fluids.client.gui.widgets.GuiFluidSlot;
|
||||
import appeng.container.slot.IJEITargetSlot;
|
||||
import mezz.jei.api.gui.IAdvancedGuiHandler;
|
||||
import mezz.jei.api.gui.IGhostIngredientHandler;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
@@ -78,12 +82,12 @@ public class AEGuiHandler implements IAdvancedGuiHandler<AEBaseGui>, IGhostIngre
|
||||
return (guiSloty * 3) + guiSlotx + (currentScroll * 3);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
@Nonnull
|
||||
public <I> List<Target<I>> getTargets(@Nonnull AEBaseGui gui, @Nonnull I ingredient, boolean doStart) {
|
||||
ArrayList<Target<I>> targets = new ArrayList<>();
|
||||
if (gui instanceof IJEIGhostIngredients) {
|
||||
IJEIGhostIngredients g = (IJEIGhostIngredients) gui;
|
||||
if (gui instanceof IJEIGhostIngredients g) {
|
||||
List<Target<?>> phantomTargets = g.getPhantomTargets(ingredient);
|
||||
targets.addAll((List<Target<I>>) (Object) phantomTargets);
|
||||
}
|
||||
@@ -91,13 +95,8 @@ public class AEGuiHandler implements IAdvancedGuiHandler<AEBaseGui>, IGhostIngre
|
||||
if (gui instanceof GuiUpgradeable || gui instanceof GuiPatternTerm || gui instanceof GuiExpandedProcessingPatternTerm) {
|
||||
IJEIGhostIngredients ghostGui = ((IJEIGhostIngredients) gui);
|
||||
for (Target<I> target : targets) {
|
||||
if (ghostGui.getFakeSlotTargetMap().get(target) instanceof SlotFake) {
|
||||
if (((SlotFake) ghostGui.getFakeSlotTargetMap().get(target)).getStack().isEmpty()) {
|
||||
target.accept(ingredient);
|
||||
break;
|
||||
}
|
||||
} else if (ghostGui.getFakeSlotTargetMap().get(target) instanceof GuiFluidSlot) {
|
||||
if (((GuiFluidSlot) ghostGui.getFakeSlotTargetMap().get(target)).getFluidStack() == null) {
|
||||
if (ghostGui.getFakeSlotTargetMap().get(target) instanceof IJEITargetSlot jeiSlot) {
|
||||
if (jeiSlot.needAccept()) {
|
||||
target.accept(ingredient);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
@@ -54,7 +55,7 @@ import java.util.*;
|
||||
|
||||
|
||||
public class GuiUpgradeable extends AEBaseGui implements IJEIGhostIngredients {
|
||||
private final Map<Target<?>, Object> mapTargetSlot = new HashMap<>();
|
||||
protected final Map<Target<?>, Object> mapTargetSlot = new HashMap<>();
|
||||
protected final ContainerUpgradeable cvb;
|
||||
protected final IUpgradeableHost bc;
|
||||
|
||||
@@ -218,24 +219,25 @@ public class GuiUpgradeable extends AEBaseGui implements IJEIGhostIngredients {
|
||||
List<Target<?>> targets = new ArrayList<>();
|
||||
|
||||
List<IJEITargetSlot> slots = new ArrayList<>();
|
||||
if (this.inventorySlots.inventorySlots.size() > 0) {
|
||||
if (!this.inventorySlots.inventorySlots.isEmpty()) {
|
||||
for (Slot slot : this.inventorySlots.inventorySlots) {
|
||||
if (slot instanceof SlotFake && (!itemStack.isEmpty() || this instanceof GuiCellWorkbench && fluidStack != null)) {
|
||||
slots.add((IJEITargetSlot) slot);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.getGuiSlots().size() > 0) {
|
||||
if (!this.getGuiSlots().isEmpty()) {
|
||||
for (GuiCustomSlot slot : this.getGuiSlots()) {
|
||||
if (slot instanceof GuiFluidSlot && fluidStack != null) {
|
||||
slots.add((IJEITargetSlot) slot);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Object slot : slots) {
|
||||
for (IJEITargetSlot slot : slots) {
|
||||
ItemStack finalItemStack = itemStack;
|
||||
FluidStack finalFluidStack = fluidStack;
|
||||
Target<Object> targetItem = new Target<Object>() {
|
||||
Target<Object> targetItem = new Target<>() {
|
||||
@Nonnull
|
||||
@Override
|
||||
public Rectangle getArea() {
|
||||
if (slot instanceof SlotFake && ((SlotFake) slot).isSlotEnabled()) {
|
||||
@@ -247,20 +249,20 @@ public class GuiUpgradeable extends AEBaseGui implements IJEIGhostIngredients {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(Object ingredient) {
|
||||
public void accept(@Nonnull Object ingredient) {
|
||||
PacketInventoryAction p = null;
|
||||
try {
|
||||
if (slot instanceof SlotFake && ((SlotFake) slot).isSlotEnabled()) {
|
||||
if (finalItemStack.isEmpty() && finalFluidStack != null) {
|
||||
p = new PacketInventoryAction(InventoryAction.PLACE_JEI_GHOST_ITEM, (IJEITargetSlot) slot, AEItemStack.fromItemStack(FluidUtil.getFilledBucket(finalFluidStack)));
|
||||
p = new PacketInventoryAction(InventoryAction.PLACE_JEI_GHOST_ITEM, slot, AEItemStack.fromItemStack(FluidUtil.getFilledBucket(finalFluidStack)));
|
||||
} else if (!finalItemStack.isEmpty()) {
|
||||
p = new PacketInventoryAction(InventoryAction.PLACE_JEI_GHOST_ITEM, (IJEITargetSlot) slot, AEItemStack.fromItemStack(finalItemStack));
|
||||
p = new PacketInventoryAction(InventoryAction.PLACE_JEI_GHOST_ITEM, slot, AEItemStack.fromItemStack(finalItemStack));
|
||||
}
|
||||
} else {
|
||||
if (finalFluidStack == null) {
|
||||
return;
|
||||
}
|
||||
p = new PacketInventoryAction(InventoryAction.PLACE_JEI_GHOST_ITEM, (IJEITargetSlot) slot, AEItemStack.fromItemStack(AEFluidStack.fromFluidStack(finalFluidStack).asItemStackRepresentation()));
|
||||
p = new PacketInventoryAction(InventoryAction.PLACE_JEI_GHOST_ITEM, slot, AEItemStack.fromItemStack(AEFluidStack.fromFluidStack(finalFluidStack).asItemStackRepresentation()));
|
||||
}
|
||||
NetworkHandler.instance().sendToServer(p);
|
||||
|
||||
|
||||
@@ -24,6 +24,10 @@ import appeng.api.parts.IPartModel;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.block.networking.BlockCableBus;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import com.google.common.cache.Weigher;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
@@ -38,6 +42,7 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
@@ -45,8 +50,6 @@ import java.util.Map.Entry;
|
||||
|
||||
public class CableBusBakedModel implements IBakedModel {
|
||||
|
||||
static final Map<CableBusRenderState, List<BakedQuad>> CABLE_MODEL_CACHE = new HashMap<>();
|
||||
|
||||
private final CableBuilder cableBuilder;
|
||||
|
||||
private final FacadeBuilder facadeBuilder;
|
||||
@@ -57,11 +60,24 @@ public class CableBusBakedModel implements IBakedModel {
|
||||
|
||||
private final TextureMap textureMap = Minecraft.getMinecraft().getTextureMapBlocks();
|
||||
|
||||
private final LoadingCache<CableBusRenderState, List<BakedQuad>> cableModelCache;
|
||||
|
||||
CableBusBakedModel(CableBuilder cableBuilder, FacadeBuilder facadeBuilder, Map<ResourceLocation, IBakedModel> partModels, TextureAtlasSprite particleTexture) {
|
||||
this.cableBuilder = cableBuilder;
|
||||
this.facadeBuilder = facadeBuilder;
|
||||
this.partModels = partModels;
|
||||
this.particleTexture = particleTexture;
|
||||
this.cableModelCache = CacheBuilder.newBuilder()
|
||||
.maximumWeight(5000)
|
||||
.weigher((Weigher<CableBusRenderState, List<BakedQuad>>) (k, v) -> v.size())
|
||||
.build(new CacheLoader<>() {
|
||||
@Override
|
||||
public List<BakedQuad> load(@Nonnull CableBusRenderState rs) {
|
||||
final List<BakedQuad> model = new ArrayList<>();
|
||||
addCableQuads(rs, model);
|
||||
return model;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -82,12 +98,7 @@ public class CableBusBakedModel implements IBakedModel {
|
||||
if (layer == BlockRenderLayer.CUTOUT) {
|
||||
|
||||
// First, handle the cable at the center of the cable bus
|
||||
final List<BakedQuad> cableModel = CABLE_MODEL_CACHE.computeIfAbsent(renderState, k ->
|
||||
{
|
||||
final List<BakedQuad> model = new ArrayList<>();
|
||||
this.addCableQuads(renderState, model);
|
||||
return model;
|
||||
});
|
||||
final List<BakedQuad> cableModel = cableModelCache.getUnchecked(renderState);
|
||||
quads.addAll(cableModel);
|
||||
|
||||
// Then handle attachments
|
||||
|
||||
@@ -27,26 +27,21 @@ import com.google.common.collect.ImmutableMap;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.IModel;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.client.resource.IResourceType;
|
||||
import net.minecraftforge.client.resource.ISelectiveResourceReloadListener;
|
||||
import net.minecraftforge.client.resource.VanillaResourceType;
|
||||
import net.minecraftforge.common.model.IModelState;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
|
||||
/**
|
||||
* The built-in model for the cable bus block.
|
||||
*/
|
||||
public class CableBusModel implements IModel, ISelectiveResourceReloadListener {
|
||||
public class CableBusModel implements IModel {
|
||||
|
||||
private final PartModels partModels;
|
||||
|
||||
@@ -106,12 +101,4 @@ public class CableBusModel implements IModel, ISelectiveResourceReloadListener {
|
||||
public IModelState getDefaultState() {
|
||||
return TRSRTransformation.identity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResourceManagerReload(IResourceManager resourceManager, Predicate<IResourceType> resourcePredicate) {
|
||||
if (resourcePredicate.test(VanillaResourceType.MODELS)) {
|
||||
CableBusBakedModel.CABLE_MODEL_CACHE.clear();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
package appeng.container.slot;
|
||||
|
||||
public interface IJEITargetSlot {
|
||||
|
||||
default boolean needAccept() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -50,7 +50,6 @@ public class SlotFake extends AppEngSlot implements IJEITargetSlot {
|
||||
if (!is.isEmpty()) {
|
||||
is = is.copy();
|
||||
}
|
||||
|
||||
super.putStack(is);
|
||||
}
|
||||
|
||||
@@ -58,4 +57,10 @@ public class SlotFake extends AppEngSlot implements IJEITargetSlot {
|
||||
public boolean canTakeStack(final EntityPlayer par1EntityPlayer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needAccept() {
|
||||
return this.getStack().isEmpty();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import appeng.client.ActionKey;
|
||||
import appeng.client.EffectType;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.world.World;
|
||||
@@ -32,6 +33,7 @@ import net.minecraft.world.World;
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
public abstract class CommonHelper {
|
||||
@@ -66,4 +68,5 @@ public abstract class CommonHelper {
|
||||
|
||||
public abstract boolean isActionKey(@Nonnull final ActionKey key, int pressedKeyCode);
|
||||
|
||||
public abstract EntityPlayer getPlayerByUUID(UUID uuid);
|
||||
}
|
||||
|
||||
@@ -387,6 +387,19 @@ final class Registration {
|
||||
Upgrades.FUZZY.registerItem(AEApi.instance().definitions().materials().cardMagnet(), 1);
|
||||
Upgrades.INVERTER.registerItem(AEApi.instance().definitions().materials().cardMagnet(), 1);
|
||||
|
||||
// Fluid Cells
|
||||
Upgrades.INVERTER.registerItem(items.fluidCell1k(), 1);
|
||||
Upgrades.STICKY.registerItem(items.fluidCell1k(), 1);
|
||||
|
||||
Upgrades.INVERTER.registerItem(items.fluidCell4k(), 1);
|
||||
Upgrades.STICKY.registerItem(items.fluidCell4k(), 1);
|
||||
|
||||
Upgrades.INVERTER.registerItem(items.fluidCell16k(), 1);
|
||||
Upgrades.STICKY.registerItem(items.fluidCell16k(), 1);
|
||||
|
||||
Upgrades.INVERTER.registerItem(items.fluidCell64k(), 1);
|
||||
Upgrades.STICKY.registerItem(items.fluidCell64k(), 1);
|
||||
|
||||
// Storage Bus
|
||||
Upgrades.FUZZY.registerItem(parts.storageBus(), 1);
|
||||
Upgrades.INVERTER.registerItem(parts.storageBus(), 1);
|
||||
|
||||
@@ -93,4 +93,10 @@ public class GuiFluidSlot extends GuiCustomSlot implements IJEITargetSlot {
|
||||
this.fluids.setFluidInSlot(this.slot, stack);
|
||||
NetworkHandler.instance().sendToServer(new PacketFluidSlot(Collections.singletonMap(this.getId(), this.getFluidStack())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needAccept() {
|
||||
return this.getFluidStack() == null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ package appeng.fluids.items;
|
||||
import appeng.bootstrap.IItemRendering;
|
||||
import appeng.bootstrap.ItemRenderingCustomizer;
|
||||
import appeng.client.render.DummyFluidItemModel;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
|
||||
/**
|
||||
@@ -33,5 +34,9 @@ public class FluidDummyItemRendering extends ItemRenderingCustomizer {
|
||||
@Override
|
||||
public void customize(IItemRendering rendering) {
|
||||
rendering.builtInModel("models/item/dummy_fluid_item", new DummyFluidItemModel());
|
||||
rendering.color(((s, i) -> {
|
||||
FluidStack fluid = ((FluidDummyItem) s.getItem()).getFluidStack(s);
|
||||
return fluid != null ? fluid.getFluid().getColor() : 0xFFFFFFFF;
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,6 +80,7 @@ import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -220,11 +221,13 @@ public class PartFluidStorageBus extends PartUpgradeable implements IGridTickabl
|
||||
@Override
|
||||
public void postChange(final IBaseMonitor<IAEFluidStack> monitor, final Iterable<IAEFluidStack> change, final IActionSource source) {
|
||||
if (this.getProxy().isActive()) {
|
||||
var filteredChanges = this.filterChanges(change);
|
||||
|
||||
AccessRestriction currentAccess = (AccessRestriction) ((ConfigManager) this.getConfigManager()).getSetting(Settings.ACCESS);
|
||||
if (readOncePass) {
|
||||
readOncePass = false;
|
||||
try {
|
||||
this.getProxy().getStorage().postAlterationOfStoredItems(AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class), change, this.source);
|
||||
this.getProxy().getStorage().postAlterationOfStoredItems(AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class), filteredChanges, this.source);
|
||||
} catch (final GridAccessException e) {
|
||||
// :(
|
||||
}
|
||||
@@ -234,7 +237,7 @@ public class PartFluidStorageBus extends PartUpgradeable implements IGridTickabl
|
||||
return;
|
||||
}
|
||||
try {
|
||||
this.getProxy().getStorage().postAlterationOfStoredItems(AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class), change, source);
|
||||
this.getProxy().getStorage().postAlterationOfStoredItems(AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class), filteredChanges, source);
|
||||
} catch (final GridAccessException e) {
|
||||
// :(
|
||||
}
|
||||
@@ -426,6 +429,7 @@ public class PartFluidStorageBus extends PartUpgradeable implements IGridTickabl
|
||||
this.handler.setBaseAccess((AccessRestriction) this.getConfigManager().getSetting(Settings.ACCESS));
|
||||
this.handler.setWhitelist(this.getInstalledUpgrades(Upgrades.INVERTER) > 0 ? IncludeExclude.BLACKLIST : IncludeExclude.WHITELIST);
|
||||
this.handler.setPriority(this.getPriority());
|
||||
this.handler.setStorageFilter((StorageFilter) this.getConfigManager().getSetting(Settings.STORAGE_FILTER));
|
||||
|
||||
final IItemList<IAEFluidStack> priorityList = AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class).createList();
|
||||
|
||||
@@ -537,4 +541,26 @@ public class PartFluidStorageBus extends PartUpgradeable implements IGridTickabl
|
||||
public GuiBridge getGuiBridge() {
|
||||
return GuiBridge.GUI_STORAGEBUS_FLUID;
|
||||
}
|
||||
|
||||
// TODO: 1/28/2024 Unify both methods.
|
||||
/**
|
||||
* Filters the changes to only include items that pass the storage filter.
|
||||
* Optimally, this should be handled by the underlying monitor.
|
||||
*
|
||||
* @see appeng.parts.misc.PartStorageBus#filterChanges
|
||||
*/
|
||||
protected Iterable<IAEFluidStack> filterChanges(Iterable<IAEFluidStack> change) {
|
||||
var storageFilter = this.getConfigManager().getSetting(Settings.STORAGE_FILTER);
|
||||
if (storageFilter == StorageFilter.EXTRACTABLE_ONLY && handler != null) {
|
||||
var filteredList = new ArrayList<IAEFluidStack>();
|
||||
for (final IAEFluidStack stack : change) {
|
||||
if (this.handler.passesBlackOrWhitelist(stack)) {
|
||||
filteredList.add(stack);
|
||||
}
|
||||
}
|
||||
|
||||
return filteredList;
|
||||
}
|
||||
return change;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
package appeng.helpers;
|
||||
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraftforge.fml.server.FMLServerHandler;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class PlayerHelper {
|
||||
@Nullable
|
||||
public static EntityPlayerMP getPlayerByUUID(UUID uuid) {
|
||||
final MinecraftServer server;
|
||||
if (Platform.isClientInstall()) {
|
||||
server = Minecraft.getMinecraft().getIntegratedServer();
|
||||
} else {
|
||||
server = FMLServerHandler.instance().getServer();
|
||||
}
|
||||
|
||||
if (server == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return server.getPlayerList().getPlayerByUUID(uuid);
|
||||
}
|
||||
}
|
||||
@@ -221,6 +221,9 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
// new craftables!
|
||||
for (final ICraftingPatternDetails details : this.craftingMethods.keySet()) {
|
||||
for (IAEItemStack out : details.getOutputs()) {
|
||||
if (out == null) {
|
||||
continue;
|
||||
}
|
||||
out = out.copy();
|
||||
out.reset();
|
||||
out.setCraftable(true);
|
||||
|
||||
@@ -41,12 +41,12 @@ import appeng.api.util.WorldCoord;
|
||||
import appeng.container.ContainerNull;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketCraftingToast;
|
||||
import appeng.crafting.*;
|
||||
import appeng.helpers.PatternHelper;
|
||||
import appeng.helpers.PlayerHelper;
|
||||
import appeng.me.cache.CraftingGridCache;
|
||||
import appeng.me.cluster.IAECluster;
|
||||
import appeng.me.helpers.MachineSource;
|
||||
@@ -57,6 +57,7 @@ import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -395,10 +396,10 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU {
|
||||
if (this.finalOutput == null) return;
|
||||
if (!AEConfig.instance().isFeatureEnabled(AEFeature.CRAFTING_TOASTS)) return;
|
||||
|
||||
var player = PlayerHelper.getPlayerByUUID(this.requestingPlayerUUID);
|
||||
if (player != null) {
|
||||
var player = AppEng.proxy.getPlayerByUUID(this.requestingPlayerUUID);
|
||||
if (player instanceof EntityPlayerMP playerMP) {
|
||||
try {
|
||||
NetworkHandler.instance().sendTo(new PacketCraftingToast(this.finalOutput, cancelled), player);
|
||||
NetworkHandler.instance().sendTo(new PacketCraftingToast(this.finalOutput, cancelled), playerMP);
|
||||
} catch (IOException ignored) {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ package appeng.me.storage;
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.IncludeExclude;
|
||||
import appeng.api.config.StorageFilter;
|
||||
import appeng.api.networking.security.IActionSource;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
@@ -38,12 +39,14 @@ public class MEInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHa
|
||||
private int myPriority;
|
||||
private IncludeExclude myWhitelist;
|
||||
private AccessRestriction myAccess;
|
||||
private StorageFilter storageFilter;
|
||||
private IPartitionList<T> myPartitionList;
|
||||
|
||||
private AccessRestriction cachedAccessRestriction;
|
||||
private boolean hasReadAccess;
|
||||
private boolean hasWriteAccess;
|
||||
private boolean isSticky;
|
||||
private boolean gettingAvailableContent;
|
||||
|
||||
public MEInventoryHandler(final IMEInventory<T> i, final IStorageChannel<T> channel) {
|
||||
if (i instanceof IMEInventoryHandler) {
|
||||
@@ -77,7 +80,7 @@ public class MEInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHa
|
||||
this.hasWriteAccess = this.cachedAccessRestriction.hasPermission(AccessRestriction.WRITE);
|
||||
}
|
||||
|
||||
IPartitionList<T> getPartitionList() {
|
||||
public IPartitionList<T> getPartitionList() {
|
||||
return this.myPartitionList;
|
||||
}
|
||||
|
||||
@@ -96,7 +99,7 @@ public class MEInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHa
|
||||
|
||||
@Override
|
||||
public T extractItems(final T request, final Actionable type, final IActionSource src) {
|
||||
if (!this.hasReadAccess) {
|
||||
if (!this.canExtract(request)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -105,11 +108,27 @@ public class MEInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHa
|
||||
|
||||
@Override
|
||||
public IItemList<T> getAvailableItems(final IItemList<T> out) {
|
||||
if (!this.hasReadAccess) {
|
||||
if (this.gettingAvailableContent || !this.hasReadAccess) {
|
||||
return out;
|
||||
}
|
||||
|
||||
return this.internal.getAvailableItems(out);
|
||||
this.gettingAvailableContent = true;
|
||||
try {
|
||||
if (this.storageFilter == StorageFilter.EXTRACTABLE_ONLY) {
|
||||
var stackList = this.internal.getAvailableItems(this.getChannel().createList());
|
||||
for (final T t : stackList) {
|
||||
if (this.shouldItemBeAvailable(t)) {
|
||||
out.add(t);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return this.internal.getAvailableItems(out);
|
||||
}
|
||||
} finally {
|
||||
this.gettingAvailableContent = false;
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -136,13 +155,11 @@ public class MEInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHa
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.myWhitelist == IncludeExclude.BLACKLIST && this.myPartitionList.isListed(input)) {
|
||||
if (!this.passesBlackOrWhitelist(input)) {
|
||||
return false;
|
||||
}
|
||||
if (this.myPartitionList.isEmpty() || this.myWhitelist == IncludeExclude.BLACKLIST) {
|
||||
return this.internal.canAccept(input);
|
||||
}
|
||||
return this.myPartitionList.isListed(input) && this.internal.canAccept(input);
|
||||
|
||||
return this.internal.canAccept(input);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -176,4 +193,31 @@ public class MEInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHa
|
||||
public void setSticky(boolean isSticky) {
|
||||
this.isSticky = isSticky;
|
||||
}
|
||||
|
||||
protected boolean canExtract(T request) {
|
||||
return this.hasReadAccess;
|
||||
}
|
||||
|
||||
private boolean shouldItemBeAvailable(T t) {
|
||||
return this.hasReadAccess && this.passesBlackOrWhitelist(t);
|
||||
}
|
||||
|
||||
public boolean passesBlackOrWhitelist(T input) {
|
||||
if (this.myPartitionList.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return switch (this.myWhitelist) {
|
||||
case WHITELIST -> this.myPartitionList.isListed(input);
|
||||
case BLACKLIST -> !this.myPartitionList.isListed(input);
|
||||
};
|
||||
}
|
||||
|
||||
public StorageFilter getStorageFilter() {
|
||||
return storageFilter;
|
||||
}
|
||||
|
||||
public void setStorageFilter(StorageFilter storageFilter) {
|
||||
this.storageFilter = storageFilter;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,8 +111,8 @@ public class PartOreDicStorageBus extends PartStorageBus {
|
||||
this.handler.setBaseAccess((AccessRestriction) this.getConfigManager().getSetting(Settings.ACCESS));
|
||||
this.handler.setWhitelist(this.getInstalledUpgrades(Upgrades.INVERTER) > 0 ? IncludeExclude.BLACKLIST : IncludeExclude.WHITELIST);
|
||||
this.handler.setPriority(this.priority);
|
||||
|
||||
this.handler.setPartitionList(this.getPriorityList());
|
||||
this.handler.setStorageFilter((StorageFilter) this.getConfigManager().getSetting(Settings.STORAGE_FILTER));
|
||||
|
||||
if (inv instanceof IBaseMonitor) {
|
||||
if (((AccessRestriction) ((ConfigManager) this.getConfigManager()).getSetting(Settings.ACCESS)).hasPermission(AccessRestriction.READ)) {
|
||||
@@ -165,9 +165,7 @@ public class PartOreDicStorageBus extends PartStorageBus {
|
||||
this.oreExp = oreMatch;
|
||||
|
||||
this.priorityList = new OreDictPriorityList<>(OreHelper.INSTANCE.getMatchingOre(oreExp), oreExp);
|
||||
if (this.handler != null) {
|
||||
handler.setPartitionList(this.priorityList);
|
||||
}
|
||||
this.resetCache(true);
|
||||
this.getHost().markForSave();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,6 +80,7 @@ import net.minecraftforge.common.capabilities.CapabilityInject;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -195,7 +196,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
|
||||
return super.getInventoryByName(name);
|
||||
}
|
||||
|
||||
private void resetCache(final boolean fullReset) {
|
||||
protected void resetCache(final boolean fullReset) {
|
||||
if (this.getHost() == null || this.getHost().getTile() == null || this.getHost().getTile().getWorld() == null || this.getHost().getTile().getWorld().isRemote) {
|
||||
return;
|
||||
}
|
||||
@@ -221,11 +222,13 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
|
||||
@Override
|
||||
public void postChange(final IBaseMonitor<IAEItemStack> monitor, final Iterable<IAEItemStack> change, final IActionSource source) {
|
||||
if (this.getProxy().isActive()) {
|
||||
var filteredChanges = this.filterChanges(change);
|
||||
|
||||
AccessRestriction currentAccess = (AccessRestriction) ((ConfigManager) this.getConfigManager()).getSetting(Settings.ACCESS);
|
||||
if (readOncePass) {
|
||||
readOncePass = false;
|
||||
try {
|
||||
this.getProxy().getStorage().postAlterationOfStoredItems(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class), change, mySrc);
|
||||
this.getProxy().getStorage().postAlterationOfStoredItems(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class), filteredChanges, mySrc);
|
||||
} catch (final GridAccessException e) {
|
||||
// :(
|
||||
}
|
||||
@@ -235,7 +238,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
|
||||
return;
|
||||
}
|
||||
try {
|
||||
this.getProxy().getStorage().postAlterationOfStoredItems(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class), change, source);
|
||||
this.getProxy().getStorage().postAlterationOfStoredItems(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class), filteredChanges, source);
|
||||
} catch (final GridAccessException e) {
|
||||
// :(
|
||||
}
|
||||
@@ -316,7 +319,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
|
||||
return TickRateModulation.SLEEP;
|
||||
}
|
||||
|
||||
private void resetCache() {
|
||||
protected void resetCache() {
|
||||
final boolean fullReset = this.resetCacheLogic == 2;
|
||||
this.resetCacheLogic = 0;
|
||||
|
||||
@@ -457,6 +460,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
|
||||
this.handler.setBaseAccess((AccessRestriction) this.getConfigManager().getSetting(Settings.ACCESS));
|
||||
this.handler.setWhitelist(this.getInstalledUpgrades(Upgrades.INVERTER) > 0 ? IncludeExclude.BLACKLIST : IncludeExclude.WHITELIST);
|
||||
this.handler.setPriority(this.priority);
|
||||
this.handler.setStorageFilter((StorageFilter) this.getConfigManager().getSetting(Settings.STORAGE_FILTER));
|
||||
|
||||
final IItemList<IAEItemStack> priorityList = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
|
||||
|
||||
@@ -571,4 +575,26 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
|
||||
public GuiBridge getGuiBridge() {
|
||||
return GuiBridge.GUI_STORAGEBUS;
|
||||
}
|
||||
|
||||
// TODO: 1/28/2024 Unify both methods.
|
||||
/**
|
||||
* Filters the changes to only include items that pass the storage filter.
|
||||
* Optimally, this should be handled by the underlying monitor.
|
||||
*
|
||||
* @see appeng.fluids.parts.PartFluidStorageBus#filterChanges
|
||||
*/
|
||||
protected Iterable<IAEItemStack> filterChanges(Iterable<IAEItemStack> change) {
|
||||
var storageFilter = this.getConfigManager().getSetting(Settings.STORAGE_FILTER);
|
||||
if (storageFilter == StorageFilter.EXTRACTABLE_ONLY && handler != null) {
|
||||
var filteredList = new ArrayList<IAEItemStack>();
|
||||
for (final IAEItemStack stack : change) {
|
||||
if (this.handler.passesBlackOrWhitelist(stack)) {
|
||||
filteredList.add(stack);
|
||||
}
|
||||
}
|
||||
|
||||
return filteredList;
|
||||
}
|
||||
return change;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
public class ServerHelper extends CommonHelper {
|
||||
@@ -167,4 +168,17 @@ public class ServerHelper extends CommonHelper {
|
||||
public boolean isActionKey(ActionKey key, int pressedKeyCode) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityPlayer getPlayerByUUID(UUID uuid) {
|
||||
if (!Platform.isClient()) {
|
||||
final MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
|
||||
|
||||
if (server != null) {
|
||||
return server.getPlayerList().getPlayerByUUID(uuid);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,6 +253,7 @@ gui.appliedenergistics2.Renamer=自定义名称(按下Enter以设定)
|
||||
gui.appliedenergistics2.Nothing=无
|
||||
gui.appliedenergistics2.CraftingToastDone=合成已完成!
|
||||
gui.appliedenergistics2.CraftingToastCancelled=合成已取消!
|
||||
gui.appliedenergistics2.Sticky=粘滞
|
||||
|
||||
// GUI Tooltips
|
||||
gui.tooltips.appliedenergistics2.Stash=存储物品
|
||||
@@ -524,6 +525,7 @@ item.appliedenergistics2.material.silicon_print.name=硅板
|
||||
item.appliedenergistics2.material.name_press.name=名称压印模板
|
||||
item.appliedenergistics2.material.sky_dust.name=陨石粉
|
||||
item.appliedenergistics2.material.card_crafting.name=合成卡
|
||||
item.appliedenergistics2.material.card_sticky.name=粘滞卡
|
||||
|
||||
item.appliedenergistics2.multi_part.annihilation_plane.name=ME破坏面板
|
||||
item.appliedenergistics2.multi_part.fluid_annihilation_plane.name=ME流体破坏面板
|
||||
|
||||
Reference in New Issue
Block a user