-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/1.19.2' into 1.20.1
# Conflicts: # src/main/scala/com/yogpc/qp/machines/marker/FlexMarkerMessage.java # src/main/scala/com/yogpc/qp/machines/marker/Marker16Message.java # src/main/scala/com/yogpc/qp/machines/marker/Tile16Marker.java # src/main/scala/com/yogpc/qp/machines/misc/CreativeGeneratorMenu.java # src/main/scala/com/yogpc/qp/machines/misc/CreativeGeneratorScreen.java # src/main/scala/com/yogpc/qp/machines/misc/CreativeGeneratorTile.java # src/main/scala/com/yogpc/qp/machines/workbench/TileWorkbench.java # src/main/scala/com/yogpc/qp/packet/TileMessage.java # temp_changelog.md
- Loading branch information
Showing
23 changed files
with
239 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/main/scala/com/yogpc/qp/machines/misc/CreativeGeneratorSyncMessage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.yogpc.qp.machines.misc; | ||
|
||
import com.yogpc.qp.Holder; | ||
import com.yogpc.qp.packet.IMessage; | ||
import com.yogpc.qp.packet.PacketHandler; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.core.Registry; | ||
import net.minecraft.network.FriendlyByteBuf; | ||
import net.minecraft.resources.ResourceKey; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraftforge.network.NetworkEvent; | ||
|
||
import java.util.function.Supplier; | ||
|
||
/** | ||
* To server only | ||
*/ | ||
public final class CreativeGeneratorSyncMessage implements IMessage { | ||
|
||
private final BlockPos pos; | ||
private final ResourceKey<Level> dim; | ||
private final long sendEnergy; | ||
|
||
CreativeGeneratorSyncMessage(BlockPos pos, ResourceKey<Level> dim, long sendEnergy) { | ||
this.pos = pos; | ||
this.dim = dim; | ||
this.sendEnergy = sendEnergy; | ||
} | ||
|
||
CreativeGeneratorSyncMessage(CreativeGeneratorTile tile) { | ||
this(tile.getBlockPos(), PacketHandler.getDimension(tile), tile.sendEnergy); | ||
} | ||
|
||
public CreativeGeneratorSyncMessage(FriendlyByteBuf buf) { | ||
this( | ||
buf.readBlockPos(), | ||
ResourceKey.create(Registry.DIMENSION_REGISTRY, buf.readResourceLocation()), | ||
buf.readLong() | ||
); | ||
} | ||
|
||
@Override | ||
public void write(FriendlyByteBuf buf) { | ||
buf.writeBlockPos(pos).writeResourceLocation(dim.location()); | ||
buf.writeLong(sendEnergy); | ||
} | ||
|
||
public static void onReceive(CreativeGeneratorSyncMessage message, Supplier<NetworkEvent.Context> supplier) { | ||
var world = PacketHandler.getWorld(supplier.get(), message.pos, message.dim); | ||
supplier.get().enqueueWork(() -> | ||
world.flatMap(l -> l.getBlockEntity(message.pos, Holder.CREATIVE_GENERATOR_TYPE)) | ||
.ifPresent(t -> t.sendEnergy = message.sendEnergy) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.