Compare commits

...

9 Commits

Author SHA1 Message Date
Serenibyss ac259dce6a Fix Network Tool not working (#377) 2024-01-16 15:56:12 +11:00
Neeve 7a6d49412e Fix minor slot merge/update regressions (#376) 2024-01-16 15:55:13 +11:00
Yang Xizhi 10f47a560a Fix transformers causing NCDF on specific servers (#374) 2024-01-16 12:36:22 +11:00
Serenibyss a8f0bbe06b Add Sticky Card (#371)
Co-authored-by: NotMyWing <winwyv@gmail.com>
2024-01-16 12:27:13 +11:00
Serenibyss dd3cdfcec5 Fix landing/running particles for cable bus (#372)
Co-authored-by: NotMyWing <winwyv@gmail.com>
2024-01-15 13:40:01 -06:00
Neeve 503f14f0a6 Fix minor slot stack size regression (#375) 2024-01-15 13:39:04 -06:00
Neeve 30af345ceb Update mod base name (#373) 2024-01-16 01:13:04 +11:00
Serenibyss e8af0f228b Update ME IO Port tasks on grid changes (#370) 2024-01-15 18:01:53 +11:00
Serenibyss 0291ceff30 Fix Toast server crash (#367) 2024-01-14 13:15:45 +11:00
33 changed files with 422 additions and 28 deletions
+1 -1
View File
@@ -18,7 +18,7 @@ aebuild=7
includeMCVersionJar = false
# The name of your jar when you produce builds, not including any versioning info
modArchivesBaseName = appliedenergistics2
modArchivesBaseName = ae2-uel
# Will update your build.gradle automatically whenever an update is available
autoUpdateBuildScript = false
+5 -1
View File
@@ -81,7 +81,11 @@ public enum Settings
PLACE_BLOCK( EnumSet.of( YesNo.YES, YesNo.NO ) ),
SCHEDULING_MODE( EnumSet.allOf( SchedulingMode.class ) );
SCHEDULING_MODE( EnumSet.allOf( SchedulingMode.class ) ),
STICKY_MODE( EnumSet.of( YesNo.YES, YesNo.NO ) ),
;
private final EnumSet<? extends Enum<?>> values;
@@ -40,6 +40,7 @@ public enum Upgrades {
REDSTONE(0),
CRAFTING(0),
MAGNET(0),
STICKY(0),
/**
* Diamond Tier Upgrades.
@@ -100,6 +100,8 @@ public interface IMaterials {
IItemDefinition cardCrafting();
IItemDefinition cardSticky();
IItemDefinition enderDust();
IItemDefinition flour();
@@ -89,4 +89,12 @@ public interface IMEInventoryHandler<T extends IAEStack<T>> extends IMEInventory
* @return true, if this inventory is valid for this pass.
*/
boolean validForPass( int i );
/**
* Gets whether an inventory is "Sticky" i.e. only it and other sticky storages that have partitions with certain
* items are allowed to be put into sticky storages.
*/
default boolean isSticky() {
return false;
}
}
@@ -29,8 +29,10 @@ import appeng.block.AEBaseTileBlock;
import appeng.client.UnlistedProperty;
import appeng.client.render.cablebus.CableBusBakedModel;
import appeng.client.render.cablebus.CableBusRenderState;
import appeng.client.render.cablebus.FacadeRenderState;
import appeng.core.AppEng;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketCableBusLandingParticle;
import appeng.core.sync.packets.PacketClick;
import appeng.helpers.AEGlassMaterial;
import appeng.integration.abstraction.IAEFacade;
@@ -70,10 +72,12 @@ import net.minecraft.util.math.RayTraceResult.Type;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.property.ExtendedBlockState;
import net.minecraftforge.common.property.IExtendedBlockState;
import net.minecraftforge.common.property.IUnlistedProperty;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@@ -298,6 +302,90 @@ public class BlockCableBus extends AEBaseTileBlock implements IAEFacade {
return true;
}
@Override
public boolean addRunningEffects(IBlockState state, World world, BlockPos pos, Entity entity) {
if (world.isRemote) {
addRunningParticle(world, pos, entity);
}
return true;
}
@SideOnly(Side.CLIENT)
private void addRunningParticle(World world, BlockPos pos, Entity entity) {
final ICableBusContainer cb = this.cb(world, pos);
final IBakedModel model = Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState(this.getDefaultState());
if (!(model instanceof CableBusBakedModel cableBusModel)) {
return;
}
final CableBusRenderState renderState = cb.getRenderState();
final TextureAtlasSprite texture = getSpriteForParticle(renderState, cableBusModel);
if (texture != null) {
final double d0 = entity.posX + (world.rand.nextFloat() - 0.5f) * entity.width;
final double d1 = entity.getEntityBoundingBox().minY + 0.1f;
final double d2 = entity.posZ + (world.rand.nextFloat() - 0.5f) * entity.width;
final ParticleDigging particle = new DestroyFX(world, d0, d1, d2, -entity.motionX * 4.0f, 1.5f, -entity.motionZ * 4.0f, this.getDefaultState()).setBlockPos(pos);
particle.setParticleTexture(texture);
Minecraft.getMinecraft().effectRenderer.addEffect(particle);
}
}
@Override
public boolean addLandingEffects(IBlockState state, WorldServer world, BlockPos pos, IBlockState iblockstate, EntityLivingBase entity, int numberOfParticles) {
// for reasons only notch can explain, this method is only called on the server, so we have to sync
// a packet to all tracking players for landing particle effects
if (!world.isRemote) {
final PacketCableBusLandingParticle packet = new PacketCableBusLandingParticle(pos, entity, numberOfParticles);
final NetworkRegistry.TargetPoint point = new NetworkRegistry.TargetPoint(world.provider.getDimension(), pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 32);
NetworkHandler.instance().sendToAllTracking(packet, point);
}
return true;
}
@SideOnly(Side.CLIENT)
public void addLandingParticle(BlockPos pos, double entityX, double entityY, double entityZ, int numberOfParticles) {
final World world = Minecraft.getMinecraft().world;
final ICableBusContainer cb = this.cb(world, pos);
final IBakedModel model = Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState(this.getDefaultState());
if (!(model instanceof CableBusBakedModel cableBusModel)) {
return;
}
final TextureAtlasSprite texture = getSpriteForParticle(cb.getRenderState(), cableBusModel);
if (texture != null) {
final Vec3d startVec = new Vec3d(entityX, entityY, entityZ);
final Vec3d endVec = startVec.add(0.0f, -4.0f, 0.0f);
RayTraceResult result = world.rayTraceBlocks(startVec, endVec, true, false, true);
final double speed = 0.15f;
if (result != null && result.typeOfHit == Type.BLOCK && numberOfParticles != 0) {
for (int i = 0; i < numberOfParticles; i++) {
final double d0 = world.rand.nextGaussian() * speed;
final double d1 = world.rand.nextGaussian() * speed;
final double d2 = world.rand.nextGaussian() * speed;
final ParticleDigging particle = new DestroyFX(world, entityX, entityY, entityZ, d0, d1, d2, this.getDefaultState()).setBlockPos(pos);
particle.setParticleTexture(texture);
Minecraft.getMinecraft().effectRenderer.addEffect(particle);
}
}
}
}
@SideOnly(Side.CLIENT)
private TextureAtlasSprite getSpriteForParticle(CableBusRenderState renderState, CableBusBakedModel cableBusModel) {
final FacadeRenderState frs = renderState.getFacades().get(EnumFacing.UP);
if (frs != null) {
final IBlockState state = frs.getSourceBlock();
final IBakedModel model = Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState(state);
return model.getParticleTexture();
}
return Platform.pickRandom(cableBusModel.getParticleTextures(renderState));
}
@Override
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos) {
if (Platform.isServer()) {
@@ -399,7 +399,7 @@ public abstract class AEBaseContainer extends Container {
return ItemStack.EMPTY; // don't insert duplicate encoded patterns to interfaces
}
int maxSize = Math.max(tis.getMaxStackSize(), d.getSlotStackLimit());
int maxSize = Math.min(tis.getMaxStackSize(), d.getSlotStackLimit());
int placeAble = maxSize - t.getCount();
@@ -435,7 +435,7 @@ public abstract class AEBaseContainer extends Container {
if (d.isItemValid(tis)) {
if (!d.getHasStack()) {
int maxSize = Math.max(tis.getMaxStackSize(), d.getSlotStackLimit());
int maxSize = Math.min(tis.getMaxStackSize(), d.getSlotStackLimit());
final ItemStack tmp = tis.copy();
if (tmp.getCount() > maxSize) {
@@ -964,26 +964,34 @@ public abstract class AEBaseContainer extends Container {
if (!draggedStack.isEmpty()) {
if (appEngSlot.isItemValid(draggedStack)) {
if (slotStack.getItem() == draggedStack.getItem() && slotStack.getMetadata() == draggedStack.getMetadata() && ItemStack.areItemStackTagsEqual(slotStack, draggedStack)) {
var maxSize = Math.max(appEngSlot.getSlotStackLimit(), draggedStack.getMaxStackSize());
var maxInsertable = Math.min(draggedStack.getCount(), maxSize - appEngSlot.getStack().getCount());
var toInsert = Math.min(maxInsertable, dragType == 0 ? maxInsertable : 1);
// Slot size or stack size, whichever is smaller.
var maxSize = Math.min(appEngSlot.getSlotStackLimit(), draggedStack.getMaxStackSize());
draggedStack.shrink(toInsert);
slotStack.grow(toInsert);
// The maximum number of items that can be inserted into the slot, non-negative.
var maxInsertable = Math.min(draggedStack.getCount(),
Math.max(0, maxSize - appEngSlot.getStack().getCount()));
slot.onSlotChanged();
return ItemStack.EMPTY;
if (maxInsertable != 0) {
var toInsert = Math.min(maxInsertable, dragType == 0 ? maxInsertable : 1);
draggedStack.shrink(toInsert);
slotStack.grow(toInsert);
slot.putStack(slot.getStack());
return ItemStack.EMPTY;
}
}
}
}
// Fixes taking and halving issues from oversized slots.
else if (dragType == 0 || dragType == 1) {
if (slot.canTakeStack(player) && !slotStack.isEmpty()) {
var result = slotStack.copy();
var toTake = Math.min(slotStack.getCount(), slotStack.getMaxStackSize());
this.invPlayer.setItemStack(slot.decrStackSize(dragType == 0 ? toTake : (toTake + 1) / 2));
slot.onTake(player, invPlayer.getItemStack());
return ItemStack.EMPTY;
slot.putStack(slot.getStack());
return result;
}
}
@@ -50,6 +50,9 @@ public class ContainerStorageBus extends ContainerUpgradeable {
@GuiSync(4)
public StorageFilter storageFilter = StorageFilter.EXTRACTABLE_ONLY;
@GuiSync(7)
public YesNo stickyMode = YesNo.NO;
public ContainerStorageBus(final InventoryPlayer ip, final PartStorageBus te) {
super(ip, te);
this.storageBus = te;
@@ -111,6 +114,7 @@ public class ContainerStorageBus extends ContainerUpgradeable {
this.setFuzzyMode((FuzzyMode) this.getUpgradeable().getConfigManager().getSetting(Settings.FUZZY_MODE));
this.setReadWriteMode((AccessRestriction) this.getUpgradeable().getConfigManager().getSetting(Settings.ACCESS));
this.setStorageFilter((StorageFilter) this.getUpgradeable().getConfigManager().getSetting(Settings.STORAGE_FILTER));
this.setStickyMode((YesNo) this.getUpgradeable().getConfigManager().getSetting(Settings.STICKY_MODE));
}
this.standardDetectAndSendChanges();
@@ -168,4 +172,12 @@ public class ContainerStorageBus extends ContainerUpgradeable {
private void setStorageFilter(final StorageFilter storageFilter) {
this.storageFilter = storageFilter;
}
public YesNo getStickyMode() {
return this.stickyMode;
}
private void setStickyMode(final YesNo stickyMode) {
this.stickyMode = stickyMode;
}
}
@@ -364,15 +364,19 @@ final class Registration {
// Storage Cells
Upgrades.FUZZY.registerItem(items.cell1k(), 1);
Upgrades.INVERTER.registerItem(items.cell1k(), 1);
Upgrades.STICKY.registerItem(items.cell1k(), 1);
Upgrades.FUZZY.registerItem(items.cell4k(), 1);
Upgrades.INVERTER.registerItem(items.cell4k(), 1);
Upgrades.STICKY.registerItem(items.cell4k(), 1);
Upgrades.FUZZY.registerItem(items.cell16k(), 1);
Upgrades.INVERTER.registerItem(items.cell16k(), 1);
Upgrades.STICKY.registerItem(items.cell16k(), 1);
Upgrades.FUZZY.registerItem(items.cell64k(), 1);
Upgrades.INVERTER.registerItem(items.cell64k(), 1);
Upgrades.STICKY.registerItem(items.cell64k(), 1);
Upgrades.FUZZY.registerItem(items.portableCell(), 1);
Upgrades.INVERTER.registerItem(items.portableCell(), 1);
@@ -387,10 +391,12 @@ final class Registration {
Upgrades.FUZZY.registerItem(parts.storageBus(), 1);
Upgrades.INVERTER.registerItem(parts.storageBus(), 1);
Upgrades.CAPACITY.registerItem(parts.storageBus(), 5);
Upgrades.STICKY.registerItem(parts.storageBus(), 1);
// Storage Bus Fluids
Upgrades.INVERTER.registerItem(parts.fluidStorageBus(), 1);
Upgrades.CAPACITY.registerItem(parts.fluidStorageBus(), 5);
Upgrades.STICKY.registerItem(parts.fluidStorageBus(), 1);
// Formation Plane
Upgrades.FUZZY.registerItem(parts.formationPlane(), 1);
@@ -60,6 +60,10 @@ public class ApiClientHelper implements IClientHelper {
lines.add("[" + GuiText.Partitioned.getLocal() + "]" + " - " + list + ' ' + GuiText.Precise.getLocal());
}
if (handler.isSticky()) {
lines.add(GuiText.Sticky.getLocal());
}
if (Minecraft.getMinecraft().gameSettings.advancedItemTooltips || Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
IItemHandler inv = cellInventory.getConfigInventory();
cellInventory.getAvailableItems((IItemList) itemList);
@@ -90,6 +90,7 @@ public final class ApiMaterials implements IMaterials {
private final IItemDefinition cardFuzzy;
private final IItemDefinition cardInverter;
private final IItemDefinition cardCrafting;
private final IItemDefinition cardSticky;
private final IItemDefinition enderDust;
private final IItemDefinition flour;
@@ -208,6 +209,7 @@ public final class ApiMaterials implements IMaterials {
this.cardFuzzy = new DamagedItemDefinition("material.card.fuzzy", materials.createMaterial(MaterialType.CARD_FUZZY));
this.cardInverter = new DamagedItemDefinition("material.card.inverter", materials.createMaterial(MaterialType.CARD_INVERTER));
this.cardCrafting = new DamagedItemDefinition("material.card.crafting", materials.createMaterial(MaterialType.CARD_CRAFTING));
this.cardSticky = new DamagedItemDefinition("material.card.sticky", materials.createMaterial(MaterialType.CARD_STICKY));
this.enderDust = new DamagedItemDefinition("material.dust.ender", materials.createMaterial(MaterialType.ENDER_DUST));
this.flour = new DamagedItemDefinition("material.flour", materials.createMaterial(MaterialType.FLOUR));
@@ -425,6 +427,11 @@ public final class ApiMaterials implements IMaterials {
return this.cardCrafting;
}
@Override
public IItemDefinition cardSticky() {
return this.cardSticky;
}
@Override
public IItemDefinition enderDust() {
return this.enderDust;
@@ -195,6 +195,7 @@ public enum GuiText {
Partitioned,
Precise,
Fuzzy,
Sticky,
// Used in a terminal to indicate that an item is craftable
SmallFontCraft,
@@ -88,7 +88,11 @@ public class AppEngPacketHandlerBase {
PACKET_CRAFTING_TOAST(PacketCraftingToast.class),
PACKET_COLOR_APPLICATOR_SELECT_COLOR(PacketColorApplicatorSelectColor.class);
PACKET_COLOR_APPLICATOR_SELECT_COLOR(PacketColorApplicatorSelectColor.class),
PACKET_CABLE_BUS_LANDING_PARTICLE(PacketCableBusLandingParticle.class),
;
private final Class<? extends AppEngPacket> packetClass;
@@ -112,6 +112,10 @@ public class NetworkHandler {
this.ec.sendToAllAround(message.getProxy(), point);
}
public void sendToAllTracking(final AppEngPacket message, final NetworkRegistry.TargetPoint point) {
this.ec.sendToAllTracking(message.getProxy(), point);
}
public void sendToDimension(final AppEngPacket message, final int dimensionId) {
this.ec.sendToDimension(message.getProxy(), dimensionId);
}
@@ -0,0 +1,55 @@
package appeng.core.sync.packets;
import appeng.block.networking.BlockCableBus;
import appeng.core.sync.AppEngPacket;
import appeng.core.sync.network.INetworkInfo;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class PacketCableBusLandingParticle extends AppEngPacket {
private BlockPos pos;
private double entityX;
private double entityY;
private double entityZ;
private int numberOfParticles;
public PacketCableBusLandingParticle(final ByteBuf stream) {
this.pos = BlockPos.fromLong(stream.readLong());
this.entityX = stream.readDouble();
this.entityY = stream.readDouble();
this.entityZ = stream.readDouble();
this.numberOfParticles = stream.readInt();
}
public PacketCableBusLandingParticle(final BlockPos pos, final Entity entity, final int numberOfParticles) {
final ByteBuf data = Unpooled.buffer();
data.writeInt(this.getPacketID());
data.writeLong(pos.toLong());
data.writeDouble(entity.posX);
data.writeDouble(entity.posY);
data.writeDouble(entity.posZ);
data.writeInt(numberOfParticles);
this.configureWrite(data);
}
@Override
@SideOnly(Side.CLIENT)
public void clientPacketData(INetworkInfo network, AppEngPacket packet, EntityPlayer player) {
final World world = Minecraft.getMinecraft().world;
final IBlockState state = world.getBlockState(pos);
if (state.getBlock() instanceof BlockCableBus cb) {
cb.addLandingParticle(pos, entityX, entityY, entityZ, numberOfParticles);
}
}
}
@@ -22,10 +22,12 @@ package appeng.core.sync.packets;
import appeng.block.networking.BlockCableBus;
import appeng.core.sync.AppEngPacket;
import appeng.core.sync.network.INetworkInfo;
import appeng.items.tools.ToolNetworkTool;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
@@ -97,6 +99,11 @@ public class PacketClick extends AppEngPacket {
if (block instanceof BlockCableBus) {
((BlockCableBus) block).onBlockClickPacket(player.world, pos, player, this.hand, new Vec3d(this.hitX, this.hitY, this.hitZ));
}
} else {
final ItemStack is = player.inventory.getCurrentItem();
if (!is.isEmpty() && is.getItem() instanceof ToolNetworkTool tnt) {
tnt.serverSideToolLogic(is, player, hand, player.world, pos, side, hitX, hitY, hitZ);
}
}
}
}
@@ -11,6 +11,8 @@ import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.io.IOException;
@@ -39,11 +41,15 @@ public class PacketCraftingToast extends AppEngPacket {
@Override
public void clientPacketData(INetworkInfo network, AppEngPacket packet, EntityPlayer player) {
if (AEConfig.instance().isFeatureEnabled(AEFeature.CRAFTING_TOASTS)) {
Minecraft.getMinecraft()
.getToastGui().add(new CraftingStatusToast(stack.asItemStackRepresentation(), cancelled));
doCraftingToast();
}
}
@SideOnly(Side.CLIENT)
private void doCraftingToast() {
Minecraft.getMinecraft().getToastGui().add(new CraftingStatusToast(stack.asItemStackRepresentation(), cancelled));
}
@Override
public void serverPacketData(INetworkInfo manager, AppEngPacket packet, EntityPlayer player) {}
}
@@ -24,6 +24,7 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.google.common.io.ByteStreams;
import net.minecraft.launchwrapper.IClassTransformer;
import net.minecraft.launchwrapper.Launch;
import net.minecraftforge.fml.common.Loader;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
@@ -31,7 +32,11 @@ import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.commons.ClassRemapper;
import org.objectweb.asm.commons.Remapper;
import org.objectweb.asm.tree.*;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.FieldNode;
import org.objectweb.asm.tree.MethodInsnNode;
import org.objectweb.asm.tree.MethodNode;
import java.io.IOException;
import java.io.InputStream;
@@ -48,7 +53,7 @@ public class AE2ELTransformer implements IClassTransformer {
if ("net.minecraftforge.common.ForgeHooks".equals(transformedName)) {
ClassReader cr = new ClassReader(basicClass);
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);
ClassWriter cw = new SafeClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);
ClassVisitor cv = new PickBlockPatch(cw);
cr.accept(cv, ClassReader.EXPAND_FRAMES);
return cw.toByteArray();
@@ -188,4 +193,39 @@ public class AE2ELTransformer implements IClassTransformer {
}
private static class SafeClassWriter extends ClassWriter {
public SafeClassWriter(int flags) {
super(flags);
}
@Override
protected String getCommonSuperClass(final String type1, final String type2) {
Class<?> c, d;
// clueless
ClassLoader classLoader = Launch.classLoader;
try {
c = Class.forName(type1.replace('/', '.'), false, classLoader);
d = Class.forName(type2.replace('/', '.'), false, classLoader);
} catch (Exception e) {
throw new RuntimeException(e.toString());
}
if (c.isAssignableFrom(d)) {
return type1;
}
if (d.isAssignableFrom(c)) {
return type2;
}
if (c.isInterface() || d.isInterface()) {
return "java/lang/Object";
} else {
do {
c = c.getSuperclass();
} while (!c.isAssignableFrom(d));
return c.getName().replace('.', '/');
}
}
}
}
@@ -437,6 +437,10 @@ public class PartFluidStorageBus extends PartUpgradeable implements IGridTickabl
}
}
if (this.getInstalledUpgrades(Upgrades.STICKY) > 0) {
this.handler.setSticky(true);
}
if (this.getInstalledUpgrades(Upgrades.FUZZY) > 0) {
this.handler.setPartitionList(new FuzzyPriorityList<IAEFluidStack>(priorityList, (FuzzyMode) this.getConfigManager().getSetting(Settings.FUZZY_MODE)));
} else {
@@ -166,6 +166,8 @@ public final class ItemMaterial extends AEBaseItem implements IStorageComponent,
return Upgrades.MAGNET;
case CARD_QUANTUM_LINK:
return Upgrades.QUANTUM_LINK;
case CARD_STICKY:
return Upgrades.STICKY;
default:
return null;
}
@@ -120,7 +120,9 @@ public enum MaterialType {
CARD_PATTERN_EXPANSION(58, "material_card_pattern_expansion", EnumSet.of(AEFeature.ADVANCED_CARDS)),
CARD_QUANTUM_LINK(59, "material_card_quantum_link", EnumSet.of(AEFeature.ADVANCED_CARDS, AEFeature.QUANTUM_LINKING_CARD)),
CARD_MAGNET(60, "material_card_magnet", EnumSet.of(AEFeature.BASIC_CARDS));
CARD_MAGNET(60, "material_card_magnet", EnumSet.of(AEFeature.BASIC_CARDS)),
CARD_STICKY(61, "material_card_sticky", EnumSet.of(AEFeature.BASIC_CARDS)),
;
private final Set<AEFeature> features;
@@ -160,4 +160,8 @@ public class MEMonitorHandler<T extends IAEStack<T>> implements IMEMonitor<T> {
return this.getHandler().validForPass(i);
}
@Override
public boolean isSticky() {
return this.internalHandler.isSticky();
}
}
@@ -56,6 +56,7 @@ public class BasicCellInventoryHandler<T extends IAEStack<T>> extends MEInventor
boolean hasInverter = false;
boolean hasFuzzy = false;
boolean hasSticky = false;
for (int x = 0; x < upgrades.getSlots(); x++) {
final ItemStack is = upgrades.getStackInSlot(x);
@@ -69,6 +70,9 @@ public class BasicCellInventoryHandler<T extends IAEStack<T>> extends MEInventor
case INVERTER:
hasInverter = true;
break;
case STICKY:
hasSticky = true;
break;
default:
}
}
@@ -87,6 +91,10 @@ public class BasicCellInventoryHandler<T extends IAEStack<T>> extends MEInventor
this.setWhitelist(hasInverter ? IncludeExclude.BLACKLIST : IncludeExclude.WHITELIST);
if (hasSticky) {
setSticky(true);
}
if (!priorityList.isEmpty()) {
if (hasFuzzy) {
this.setPartitionList(new FuzzyPriorityList<>(priorityList, fzMode));
@@ -40,7 +40,6 @@ public class DriveWatcher<T extends IAEStack<T>> extends MEInventoryHandler<T> {
private final ICellHandler handler;
private final TileDrive drive;
private final IActionSource source;
public DriveWatcher(final ICellInventoryHandler<T> i, final ItemStack is, final ICellHandler han, final TileDrive drive) {
super(i, i.getChannel());
this.is = is;
@@ -100,4 +99,13 @@ public class DriveWatcher<T extends IAEStack<T>> extends MEInventoryHandler<T> {
return extractable;
}
@Override
public boolean isSticky() {
if (this.getInternal() instanceof ICellInventoryHandler<?> cellInventoryHandler) {
return cellInventoryHandler.isSticky();
}
return super.isSticky();
}
}
@@ -43,6 +43,7 @@ public class MEInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHa
private AccessRestriction cachedAccessRestriction;
private boolean hasReadAccess;
private boolean hasWriteAccess;
private boolean isSticky;
public MEInventoryHandler(final IMEInventory<T> i, final IStorageChannel<T> channel) {
if (i instanceof IMEInventoryHandler) {
@@ -166,4 +167,13 @@ public class MEInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHa
public IMEInventory<T> getInternal() {
return this.internal;
}
@Override
public boolean isSticky() {
return isSticky;
}
public void setSticky(boolean isSticky) {
this.isSticky = isSticky;
}
}
@@ -31,6 +31,7 @@ import appeng.api.storage.IStorageChannel;
import appeng.api.storage.data.IAEStack;
import appeng.api.storage.data.IItemList;
import appeng.me.cache.SecurityCache;
import net.minecraft.network.Packet;
import java.util.*;
@@ -45,19 +46,24 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
private final IStorageChannel<T> myChannel;
private final SecurityCache security;
private final NavigableMap<Integer, List<IMEInventoryHandler<T>>> priorityInventory;
private final NavigableMap<Integer, List<IMEInventoryHandler<T>>> stickyPriorityInventory;
private int myPass = 0;
public NetworkInventoryHandler(final IStorageChannel<T> chan, final SecurityCache security) {
this.myChannel = chan;
this.security = security;
this.priorityInventory = new TreeMap<>(PRIORITY_SORTER);
this.stickyPriorityInventory = new TreeMap<>(PRIORITY_SORTER);
}
public void addNewStorage(final IMEInventoryHandler<T> h) {
final int priority = h.getPriority();
List<IMEInventoryHandler<T>> list = this.priorityInventory.get(priority);
if (list == null) {
this.priorityInventory.put(priority, list = new ArrayList<>());
final List<IMEInventoryHandler<T>> list;
if (h.isSticky()) {
list = this.stickyPriorityInventory.computeIfAbsent(priority, $ -> new ArrayList<>());
} else {
list = this.priorityInventory.computeIfAbsent(priority, $ -> new ArrayList<>());
}
list.add(h);
@@ -74,6 +80,25 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
return input;
}
boolean stickyInventoryFound = false;
// For this pass we do return input if the item is able to go into a sticky inventory. We NEVER want to try and
// insert the item into a non-sticky inventory if it could already go into a sticky inventory.
for (final List<IMEInventoryHandler<T>> stickyInvList : this.stickyPriorityInventory.values()) {
Iterator<IMEInventoryHandler<T>> ii = stickyInvList.iterator();
while (ii.hasNext() && input != null) {
final IMEInventoryHandler<T> inv = ii.next();
if (inv.validForPass(1) && inv.canAccept(input) && (inv.isPrioritized(input) || inv.extractItems(input, Actionable.SIMULATE, src) != null)) {
input = inv.injectItems(input, type, src);
stickyInventoryFound = true;
}
}
}
if (stickyInventoryFound) {
this.surface(this, type);
return input;
}
for (final List<IMEInventoryHandler<T>> invList : this.priorityInventory.values()) {
Iterator<IMEInventoryHandler<T>> ii = invList.iterator();
while (ii.hasNext() && input != null) {
@@ -186,6 +211,16 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
}
}
for (List<IMEInventoryHandler<T>> invList : this.stickyPriorityInventory.descendingMap().values()) {
final Iterator<IMEInventoryHandler<T>> jj = invList.iterator();
while (jj.hasNext() && output.getStackSize() < req) {
final IMEInventoryHandler<T> inv = jj.next();
request.setStackSize(req - output.getStackSize());
output.add(inv.extractItems(request, mode, src));
}
}
this.surface(this, mode);
if (output.getStackSize() <= 0) {
@@ -201,15 +236,21 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
return out;
}
// for (Entry<Integer, IMEInventoryHandler<T>> h : priorityInventory.entries())
for (final List<IMEInventoryHandler<T>> i : this.priorityInventory.values()) {
out = iterateInventories(out, priorityInventory);
out = iterateInventories(out, stickyPriorityInventory);
this.surface(this, Actionable.SIMULATE);
return out;
}
private IItemList<T> iterateInventories(IItemList<T> out, final NavigableMap<Integer, List<IMEInventoryHandler<T>>> map) {
for (final List<IMEInventoryHandler<T>> i : map.values()) {
for (final IMEInventoryHandler<T> j : i) {
out = j.getAvailableItems(out);
}
}
this.surface(this, Actionable.SIMULATE);
return out;
}
@@ -48,6 +48,7 @@ public abstract class UpgradeInventory extends AppEngInternalInventory implement
private int patternExpansionUpgrades = 0;
private int magnetUpgrades = 0;
private int quantumUpgrades = 0;
private int stickyUpgrades = 0;
public UpgradeInventory(final IAEAppEngInventory parent, final int s) {
super(null, s, 1);
@@ -85,6 +86,8 @@ public abstract class UpgradeInventory extends AppEngInternalInventory implement
return this.magnetUpgrades;
case QUANTUM_LINK:
return this.quantumUpgrades;
case STICKY:
return this.stickyUpgrades;
default:
return 0;
}
@@ -94,7 +97,7 @@ public abstract class UpgradeInventory extends AppEngInternalInventory implement
private void updateUpgradeInfo() {
this.cached = true;
this.patternExpansionUpgrades = this.inverterUpgrades = this.capacityUpgrades = this.redstoneUpgrades = this.speedUpgrades = this.fuzzyUpgrades = this.craftingUpgrades = magnetUpgrades = quantumUpgrades = 0;
this.patternExpansionUpgrades = this.inverterUpgrades = this.capacityUpgrades = this.redstoneUpgrades = this.speedUpgrades = this.fuzzyUpgrades = this.craftingUpgrades = magnetUpgrades = quantumUpgrades = stickyUpgrades = 0;
for (final ItemStack is : this) {
if (is == null || is.getItem() == Items.AIR || !(is.getItem() instanceof IUpgradeModule)) {
@@ -129,6 +132,10 @@ public abstract class UpgradeInventory extends AppEngInternalInventory implement
break;
case QUANTUM_LINK:
this.quantumUpgrades++;
break;
case STICKY:
this.stickyUpgrades++;
break;
default:
break;
}
@@ -143,6 +150,7 @@ public abstract class UpgradeInventory extends AppEngInternalInventory implement
this.patternExpansionUpgrades = Math.min(this.patternExpansionUpgrades, this.getMaxInstalled(Upgrades.PATTERN_EXPANSION));
this.magnetUpgrades = Math.min(this.magnetUpgrades, this.getMaxInstalled(Upgrades.MAGNET));
this.quantumUpgrades = Math.min(this.quantumUpgrades, this.getMaxInstalled(Upgrades.QUANTUM_LINK));
this.stickyUpgrades = Math.min(this.stickyUpgrades, this.getMaxInstalled(Upgrades.STICKY));
}
@Override
@@ -113,6 +113,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
this.getConfigManager().registerSetting(Settings.ACCESS, AccessRestriction.READ_WRITE);
this.getConfigManager().registerSetting(Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL);
this.getConfigManager().registerSetting(Settings.STORAGE_FILTER, StorageFilter.EXTRACTABLE_ONLY);
this.getConfigManager().registerSetting(Settings.STICKY_MODE, YesNo.NO);
this.mySrc = new MachineSource(this);
}
@@ -467,6 +468,10 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
}
}
if (this.getInstalledUpgrades(Upgrades.STICKY) > 0) {
this.handler.setSticky(true);
}
if (this.getInstalledUpgrades(Upgrades.FUZZY) > 0) {
this.handler.setPartitionList(new FuzzyPriorityList<>(priorityList, (FuzzyMode) this.getConfigManager().getSetting(Settings.FUZZY_MODE)));
} else {
@@ -178,6 +178,12 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
}
}
@Override
public void gridChanged() {
super.gridChanged();
updateTask();
}
public void updateRedstoneState() {
final YesNo currentState = this.world.getRedstonePowerFromNeighbors(this.pos) != 0 ? YesNo.YES : YesNo.NO;
if (this.lastRedstoneState != currentState) {
@@ -253,6 +253,7 @@ gui.appliedenergistics2.Renamer=Custom Name: (Enter to set)
gui.appliedenergistics2.Nothing=Nothing
gui.appliedenergistics2.CraftingToastDone=Crafting Done!
gui.appliedenergistics2.CraftingToastCancelled=Crafting Cancelled!
gui.appliedenergistics2.Sticky=Sticky
// GUI Tooltips
gui.tooltips.appliedenergistics2.Stash=Store Items
@@ -524,6 +525,7 @@ item.appliedenergistics2.material.silicon_print.name=Printed Silicon
item.appliedenergistics2.material.name_press.name=Inscriber Name Press
item.appliedenergistics2.material.sky_dust.name=Sky Stone Dust
item.appliedenergistics2.material.card_crafting.name=Crafting Card
item.appliedenergistics2.material.card_sticky.name=Sticky Card
item.appliedenergistics2.multi_part.annihilation_plane.name=ME Annihilation Plane
item.appliedenergistics2.multi_part.fluid_annihilation_plane.name=ME Fluid Annihilation Plane
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "appliedenergistics2:items/material_card_sticky"
}
}
@@ -0,0 +1,31 @@
{
"conditions": [
{
"type": "forge:and",
"values": [
{
"type": "appliedenergistics2:material_exists",
"material": "material.card_sticky"
},
{
"type": "appliedenergistics2:material_exists",
"material": "material.basic_card"
}
]
}
],
"result": {
"type": "appliedenergistics2:part",
"part": "material.card_sticky"
},
"type": "appliedenergistics2:part_shapeless",
"ingredients": [
{
"item": "minecraft:slime_ball"
},
{
"type": "appliedenergistics2:part",
"part": "material.basic_card"
}
]
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 448 B