mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-16 03:53:42 +01:00
Restrict schematicannon configuration
This commit is contained in:
parent
e1d1b062f8
commit
7c8bd28421
1 changed files with 8 additions and 27 deletions
|
@ -2,15 +2,13 @@ package com.simibubi.create.content.schematics.packet;
|
|||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.simibubi.create.content.schematics.block.SchematicannonContainer;
|
||||
import com.simibubi.create.content.schematics.block.SchematicannonTileEntity;
|
||||
import com.simibubi.create.content.schematics.block.SchematicannonTileEntity.State;
|
||||
import com.simibubi.create.foundation.networking.SimplePacketBase;
|
||||
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.network.NetworkEvent.Context;
|
||||
|
||||
public class ConfigureSchematicannonPacket extends SimplePacketBase {
|
||||
|
@ -21,45 +19,28 @@ public class ConfigureSchematicannonPacket extends SimplePacketBase {
|
|||
|
||||
private Option option;
|
||||
private boolean set;
|
||||
private BlockPos pos;
|
||||
|
||||
public static ConfigureSchematicannonPacket setOption(BlockPos pos, Option option, boolean set) {
|
||||
ConfigureSchematicannonPacket packet = new ConfigureSchematicannonPacket(pos);
|
||||
packet.option = option;
|
||||
packet.set = set;
|
||||
return packet;
|
||||
}
|
||||
|
||||
public ConfigureSchematicannonPacket(BlockPos pos) {
|
||||
this.pos = pos;
|
||||
public ConfigureSchematicannonPacket(Option option, boolean set) {
|
||||
this.option = option;
|
||||
this.set = set;
|
||||
}
|
||||
|
||||
public ConfigureSchematicannonPacket(PacketBuffer buffer) {
|
||||
pos = buffer.readBlockPos();
|
||||
option = Option.values()[buffer.readInt()];
|
||||
set = buffer.readBoolean();
|
||||
this(buffer.readEnumValue(Option.class), buffer.readBoolean());
|
||||
}
|
||||
|
||||
public void write(PacketBuffer buffer) {
|
||||
buffer.writeBlockPos(pos);
|
||||
buffer.writeInt(option.ordinal());
|
||||
buffer.writeEnumValue(option);
|
||||
buffer.writeBoolean(set);
|
||||
}
|
||||
|
||||
public void handle(Supplier<Context> context) {
|
||||
context.get().enqueueWork(() -> {
|
||||
ServerPlayerEntity player = context.get().getSender();
|
||||
if (player == null)
|
||||
return;
|
||||
World world = player.world;
|
||||
if (world == null || !world.isBlockPresent(pos))
|
||||
if (player == null || !(player.openContainer instanceof SchematicannonContainer))
|
||||
return;
|
||||
|
||||
TileEntity tileEntity = world.getTileEntity(pos);
|
||||
if (!(tileEntity instanceof SchematicannonTileEntity))
|
||||
return;
|
||||
|
||||
SchematicannonTileEntity te = (SchematicannonTileEntity) tileEntity;
|
||||
SchematicannonTileEntity te = ((SchematicannonContainer) player.openContainer).getTileEntity();
|
||||
switch (option) {
|
||||
case DONT_REPLACE:
|
||||
case REPLACE_ANY:
|
||||
|
|
Loading…
Reference in a new issue