mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-03-04 06:44:40 +01:00
Water whe doing
- Fixed factory gauge sending incomplete orders when activating in the same tick as a competing gauge - Water wheels now maintain their texture material when pasted in a schematic
This commit is contained in:
parent
312f5a2929
commit
01a9532678
4 changed files with 30 additions and 4 deletions
|
@ -199,6 +199,12 @@ public class WaterWheelBlockEntity extends GeneratingKineticBlockEntity {
|
|||
redraw();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSafe(CompoundTag tag) {
|
||||
super.writeSafe(tag);
|
||||
tag.put("Material", NbtUtils.writeBlockState(material));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(CompoundTag compound, boolean clientPacket) {
|
||||
super.write(compound, clientPacket);
|
||||
|
|
|
@ -778,6 +778,7 @@ public class FactoryPanelBehaviour extends FilteringBehaviour implements MenuPro
|
|||
CompoundTag panelTag = new CompoundTag();
|
||||
super.write(panelTag, clientPacket);
|
||||
|
||||
panelTag.putInt("Timer", timer);
|
||||
panelTag.putInt("LastLevel", lastReportedLevelInStorage);
|
||||
panelTag.putInt("LastPromised", lastReportedPromises);
|
||||
panelTag.putInt("LastUnloadedLinks", lastReportedUnloadedLinks);
|
||||
|
@ -813,6 +814,7 @@ public class FactoryPanelBehaviour extends FilteringBehaviour implements MenuPro
|
|||
filter = FilterItemStack.of(panelTag.getCompound("Filter"));
|
||||
count = panelTag.getInt("FilterAmount");
|
||||
upTo = panelTag.getBoolean("UpTo");
|
||||
timer = panelTag.getInt("Timer");
|
||||
lastReportedLevelInStorage = panelTag.getInt("LastLevel");
|
||||
lastReportedPromises = panelTag.getInt("LastPromised");
|
||||
lastReportedUnloadedLinks = panelTag.getInt("LastUnloadedLinks");
|
||||
|
|
|
@ -260,7 +260,7 @@ public class PackagerBlockEntity extends SmartBlockEntity {
|
|||
BlockState blockState = getBlockState();
|
||||
if (!blockState.hasProperty(PackagerBlock.LINKED))
|
||||
return;
|
||||
boolean shouldBeLinked = shouldBeLinked();
|
||||
boolean shouldBeLinked = getLinkPos() != null;
|
||||
boolean isLinked = blockState.getValue(PackagerBlock.LINKED);
|
||||
if (shouldBeLinked == isLinked)
|
||||
return;
|
||||
|
@ -272,16 +272,16 @@ public class PackagerBlockEntity extends SmartBlockEntity {
|
|||
.orElse(false);
|
||||
}
|
||||
|
||||
private boolean shouldBeLinked() {
|
||||
private BlockPos getLinkPos() {
|
||||
for (Direction d : Iterate.directions) {
|
||||
BlockState adjacentState = level.getBlockState(worldPosition.relative(d));
|
||||
if (!AllBlocks.STOCK_LINK.has(adjacentState))
|
||||
continue;
|
||||
if (PackagerLinkBlock.getConnectedDirection(adjacentState) != d)
|
||||
continue;
|
||||
return true;
|
||||
return worldPosition.relative(d);
|
||||
}
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
public void flashLink() {
|
||||
|
@ -545,6 +545,11 @@ public class PackagerBlockEntity extends SmartBlockEntity {
|
|||
if (!requestQueue && !signBasedAddress.isBlank())
|
||||
PackageItem.addAddress(createdBox, signBasedAddress);
|
||||
|
||||
BlockPos linkPos = getLinkPos();
|
||||
if (extractedPackageItem.isEmpty() && linkPos != null
|
||||
&& level.getBlockEntity(linkPos) instanceof PackagerLinkBlockEntity plbe)
|
||||
plbe.behaviour.deductFromAccurateSummary(extractedItems);
|
||||
|
||||
if (!heldBox.isEmpty() || animationTicks != 0) {
|
||||
queuedExitingPackages.add(createdBox);
|
||||
return;
|
||||
|
|
|
@ -32,6 +32,7 @@ import net.minecraft.nbt.CompoundTag;
|
|||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
|
||||
public class LogisticallyLinkedBehaviour extends BlockEntityBehaviour {
|
||||
|
||||
|
@ -185,6 +186,18 @@ public class LogisticallyLinkedBehaviour extends BlockEntityBehaviour {
|
|||
return plbe.fetchSummaryFromPackager(ignoredHandler);
|
||||
return InventorySummary.EMPTY;
|
||||
}
|
||||
|
||||
public void deductFromAccurateSummary(ItemStackHandler packageContents) {
|
||||
InventorySummary summary = LogisticsManager.ACCURATE_SUMMARIES.getIfPresent(freqId);
|
||||
if (summary == null)
|
||||
return;
|
||||
for (int i = 0; i < packageContents.getSlots(); i++) {
|
||||
ItemStack orderedStack = packageContents.getStackInSlot(i);
|
||||
if (orderedStack.isEmpty())
|
||||
continue;
|
||||
summary.add(orderedStack, -Math.min(summary.getCountOf(orderedStack), orderedStack.getCount()));
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue