Compare commits

..

No commits in common. "41bf05a17ee5fa18e18b5755b04e3037de1cf20f" and "e340f52fb4e1152a3786d48627b3bfb160a90116" have entirely different histories.

9 changed files with 18 additions and 55 deletions

View file

@ -13,7 +13,7 @@ apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'
version = '1.12.1'
version = '1.12.0'
group = 'de.ellpeck.prettypipes' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'PrettyPipes'
@ -105,11 +105,11 @@ configurations {
}
dependencies {
minecraft 'net.minecraftforge:forge:1.18.2-40.0.32'
minecraft 'net.minecraftforge:forge:1.18.2-40.0.3'
embed 'org.jgrapht:jgrapht-core:1.5.1'
compileOnly fg.deobf("mezz.jei:jei-1.18.2:9.5.5.174:api")
runtimeOnly fg.deobf("mezz.jei:jei-1.18.2:9.5.5.174")
compileOnly fg.deobf("mezz.jei:jei-1.18.2:9.4.1.117:api")
runtimeOnly fg.deobf("mezz.jei:jei-1.18.2:9.4.1.117")
// to test the rf requiring and crafting stuff
/* runtimeOnly fg.deobf("curse.maven:powah-352656:3057732")

View file

@ -112,7 +112,7 @@ public class PacketButton {
}),
CRAFT_TERMINAL_REQUEST((pos, data, player) -> {
var tile = Utility.getBlockEntity(CraftingTerminalBlockEntity.class, player.level, pos);
tile.requestCraftingItems(player, data[0], data[1] > 0);
tile.requestCraftingItems(player, data[0]);
}),
CANCEL_CRAFTING((pos, data, player) -> {
var tile = Utility.getBlockEntity(ItemTerminalBlockEntity.class, player.level, pos);

View file

@ -14,13 +14,11 @@ public class PacketRequest {
private BlockPos pos;
private ItemStack stack;
private int nbtHash;
private int amount;
public PacketRequest(BlockPos pos, ItemStack stack, int amount) {
this.pos = pos;
this.stack = stack;
this.nbtHash = stack.getTag().hashCode();
this.amount = amount;
}
@ -32,15 +30,14 @@ public class PacketRequest {
var packet = new PacketRequest();
packet.pos = buf.readBlockPos();
packet.stack = buf.readItem();
packet.nbtHash = buf.readVarInt();
packet.amount = buf.readVarInt();
return packet;
}
public static void toBytes(PacketRequest packet, FriendlyByteBuf buf) {
buf.writeBlockPos(packet.pos);
buf.writeItem(packet.stack);
buf.writeVarInt(packet.nbtHash);
// if we limit the tag here, non-shared data will be omitted, making the requested item not match the stored one
buf.writeItemStack(packet.stack, false);
buf.writeVarInt(packet.amount);
}
@ -52,7 +49,7 @@ public class PacketRequest {
Player player = ctx.get().getSender();
var tile = Utility.getBlockEntity(ItemTerminalBlockEntity.class, player.level, message.pos);
message.stack.setCount(message.amount);
tile.requestItem(player, message.stack, message.nbtHash);
tile.requestItem(player, message.stack);
}
});
ctx.get().setPacketHandled(true);

View file

@ -65,17 +65,4 @@ public class PressurizerBlock extends BaseEntityBlock {
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState state, BlockEntityType<T> type) {
return level.isClientSide ? null : createTickerHelper(type, Registry.pressurizerBlockEntity, PressurizerBlockEntity::tick);
}
@Override
public boolean hasAnalogOutputSignal(BlockState state) {
return true;
}
@Override
public int getAnalogOutputSignal(BlockState state, Level world, BlockPos pos) {
var pipe = Utility.getBlockEntity(PressurizerBlockEntity.class, world, pos);
if (pipe == null)
return 0;
return (int) (pipe.getEnergy() / (float) pipe.getMaxEnergy() * 15);
}
}

View file

@ -134,10 +134,9 @@ public class PressurizerBlockEntity extends BlockEntity implements MenuProvider,
}
}
// send energy update and comparator output
// send energy update
if (pressurizer.lastEnergy != pressurizer.storage.getEnergyStored() && pressurizer.level.getGameTime() % 10 == 0) {
pressurizer.lastEnergy = pressurizer.storage.getEnergyStored();
level.updateNeighbourForOutputSignal(pos, state.getBlock());
Utility.sendBlockEntityToClients(pressurizer);
}
}

View file

@ -105,7 +105,7 @@ public class CraftingTerminalBlockEntity extends ItemTerminalBlockEntity {
}
}
public void requestCraftingItems(Player player, int maxAmount, boolean force) {
public void requestCraftingItems(Player player, int maxAmount) {
var pipe = this.getConnectedPipe();
if (pipe == null)
return;
@ -116,10 +116,7 @@ public class CraftingTerminalBlockEntity extends ItemTerminalBlockEntity {
var lowestAvailable = getAvailableCrafts(pipe, this.craftItems.getSlots(), i -> ItemHandlerHelper.copyStackWithSize(this.getRequestedCraftItem(i), 1), this::isGhostItem, s -> {
var item = this.networkItems.get(s);
return item != null ? item.getLocations() : Collections.emptyList();
}, onItemUnavailable(player, force), new Stack<>(), ItemEquality.NBT);
// if we're forcing, just pretend we have one available
if (lowestAvailable <= 0 && force)
lowestAvailable = maxAmount;
}, onItemUnavailable(player), new Stack<>(), ItemEquality.NBT);
if (lowestAvailable > 0) {
// if we're limiting the amount, pretend we only have that amount available
if (maxAmount < lowestAvailable)
@ -130,13 +127,10 @@ public class CraftingTerminalBlockEntity extends ItemTerminalBlockEntity {
continue;
requested = requested.copy();
requested.setCount(lowestAvailable);
this.requestItemImpl(requested, onItemUnavailable(player, force));
this.requestItemImpl(requested, onItemUnavailable(player));
}
player.sendMessage(new TranslatableComponent("info." + PrettyPipes.ID + ".sending_ingredients", lowestAvailable).setStyle(Style.EMPTY.applyFormat(ChatFormatting.GREEN)), UUID.randomUUID());
}
else{
player.sendMessage(new TranslatableComponent("info." + PrettyPipes.ID + ".hold_alt"), UUID.randomUUID());
}
network.endProfile();
}

View file

@ -151,23 +151,15 @@ public class ItemTerminalBlockEntity extends BlockEntity implements IPipeConnect
}
}
public void requestItem(Player player, ItemStack stack, int nbtHash) {
public void requestItem(Player player, ItemStack stack) {
var network = PipeNetwork.get(this.level);
network.startProfile("terminal_request_item");
this.updateItems();
if (nbtHash != 0) {
var filter = stack;
stack = this.networkItems.values().stream()
.map(NetworkItem::asStack)
// don't compare with nbt equality here or the whole hashing thing is pointless
.filter(s -> ItemEquality.compareItems(s, filter) && s.getTag().hashCode() == nbtHash)
.findFirst().orElse(filter);
}
var requested = this.requestItemImpl(stack, onItemUnavailable(player, false));
var requested = this.requestItemImpl(stack, onItemUnavailable(player));
if (requested > 0) {
player.sendMessage(new TranslatableComponent("info." + PrettyPipes.ID + ".sending", requested, stack.getHoverName()).setStyle(Style.EMPTY.applyFormat(ChatFormatting.GREEN)), UUID.randomUUID());
} else {
onItemUnavailable(player, false).accept(stack);
onItemUnavailable(player).accept(stack);
}
network.endProfile();
}
@ -315,11 +307,7 @@ public class ItemTerminalBlockEntity extends BlockEntity implements IPipeConnect
return Pair.of(requests, remain);
}
public static Consumer<ItemStack> onItemUnavailable(Player player, boolean ignore) {
return s -> {
if (ignore)
return;
player.sendMessage(new TranslatableComponent("info." + PrettyPipes.ID + ".not_found", s.getHoverName()).setStyle(Style.EMPTY.applyFormat(ChatFormatting.RED)), UUID.randomUUID());
};
public static Consumer<ItemStack> onItemUnavailable(Player player) {
return s -> player.sendMessage(new TranslatableComponent("info." + PrettyPipes.ID + ".not_found", s.getHoverName()).setStyle(Style.EMPTY.applyFormat(ChatFormatting.RED)), UUID.randomUUID());
}
}

View file

@ -25,8 +25,7 @@ public class CraftingTerminalGui extends ItemTerminalGui {
super.init();
this.requestButton = this.addRenderableWidget(new Button(this.leftPos + 8, this.topPos + 100, 50, 20, new TranslatableComponent("info." + PrettyPipes.ID + ".request"), button -> {
var amount = requestModifier();
var force = hasAltDown() ? 1 : 0;
PacketHandler.sendToServer(new PacketButton(this.menu.tile.getBlockPos(), PacketButton.ButtonResult.CRAFT_TERMINAL_REQUEST, amount, force));
PacketHandler.sendToServer(new PacketButton(this.menu.tile.getBlockPos(), PacketButton.ButtonResult.CRAFT_TERMINAL_REQUEST, amount));
}));
this.tick();
}

View file

@ -72,7 +72,6 @@
"info.prettypipes.limit_to_max_off": "Don't limit to one stack",
"info.prettypipes.request": "Request",
"info.prettypipes.not_found": "%s not found",
"info.prettypipes.hold_alt": "Hold Alt to request anyway",
"info.prettypipes.sending": "Sending %s %s",
"info.prettypipes.sending_ingredients": "Sending %s sets of ingredients",
"info.prettypipes.order": "Order by %s",