CreateMod/src/main/java/com/simibubi/create/content/schematics/packet/SchematicPlacePacket.java
simibubi 5eea1cac70 Copycant
- Fixed Elevator Contraptions misaligning with their contacts after switching target floor mid-travel
- Fixed crash when placing a clipboard into replaceable blocks mid-air
- Fixed a typo in Smart Observer ponder scene
- Fixed funnel flaps being offset to the side when flywheel is disabled
- Fixed dyed valve handle using incorrect block particle textures
- Fixed copycat blocks able to take on invalid materials through the use of data commands
- Copycat blocks no longer retain nbt contents of their contained material's item when loaded from a schematic
- Fixed pipe connector attachments missing textures on some orientations
- Players can now sneak-pick to receive the copycat block itself, rather than its applied material
- Fixed value input screen not closing correctly when 'use' keybind is not on its default setting
- Deployers no longer fail to activate bearings and other components with value input slots
- Fixed an incompatibility between legacy copper pack and xycraft override
- Fixed netherite diving suit not protecting from fire damage when Quark is installed
- Attempt to fix lighting issues with elevator contacts
- Schematic and Quill no longer displays the full directory path in its confirmation message
- Fixed z-fighting on metal bars models
2023-05-23 21:26:59 +02:00

69 lines
1.9 KiB
Java

package com.simibubi.create.content.schematics.packet;
import com.simibubi.create.content.schematics.SchematicPrinter;
import com.simibubi.create.foundation.networking.SimplePacketBase;
import com.simibubi.create.foundation.utility.BlockHelper;
import com.simibubi.create.infrastructure.config.AllConfigs;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraftforge.network.NetworkEvent.Context;
public class SchematicPlacePacket extends SimplePacketBase {
public ItemStack stack;
public SchematicPlacePacket(ItemStack stack) {
this.stack = stack;
}
public SchematicPlacePacket(FriendlyByteBuf buffer) {
stack = buffer.readItem();
}
@Override
public void write(FriendlyByteBuf buffer) {
buffer.writeItem(stack);
}
@Override
public boolean handle(Context context) {
context.enqueueWork(() -> {
ServerPlayer player = context.getSender();
if (player == null)
return;
if (!player.isCreative())
return;
Level world = player.getLevel();
SchematicPrinter printer = new SchematicPrinter();
printer.loadSchematic(stack, world, !player.canUseGameMasterBlocks());
if (!printer.isLoaded() || printer.isErrored())
return;
boolean includeAir = AllConfigs.server().schematics.creativePrintIncludesAir.get();
while (printer.advanceCurrentPos()) {
if (!printer.shouldPlaceCurrent(world))
continue;
printer.handleCurrentTarget((pos, state, blockEntity) -> {
boolean placingAir = state.isAir();
if (placingAir && !includeAir)
return;
CompoundTag data = BlockHelper.prepareBlockEntityData(state, blockEntity);
BlockHelper.placeSchematicBlock(world, state, pos, null, data);
}, (pos, entity) -> {
world.addFreshEntity(entity);
});
}
});
return true;
}
}