use of com.mraof.minestuck.network.MinestuckPacket in project Minestuck by mraof.
the class SkaianetHandler method resetGivenItems.
public static void resetGivenItems() {
for (SburbConnection c : connections) {
for (int i = 0; i < c.givenItemList.length; i++) c.givenItemList[i] = false;
c.unregisteredItems = new NBTTagList();
EditData data = ServerEditHandler.getData(c);
if (data != null) {
MinestuckPacket packet = MinestuckPacket.makePacket(Type.SERVER_EDIT, c.givenItemList);
MinestuckChannelHandler.sendToPlayer(packet, data.getEditor());
}
}
}
use of com.mraof.minestuck.network.MinestuckPacket in project Minestuck by mraof.
the class SkaiaClient method sendCloseRequest.
public static void sendCloseRequest(TileEntityComputer te, int otherPlayer, boolean isClient) {
MinestuckPacket packet = MinestuckPacket.makePacket(Type.SBURB_CLOSE, te.ownerId, otherPlayer, isClient);
MinestuckChannelHandler.sendToServer(packet);
}
use of com.mraof.minestuck.network.MinestuckPacket in project Minestuck by mraof.
the class SkaiaClient method requestData.
/**
* Called by a computer on interact. If it doesn't have the sufficient information,
* returns false and sends a request about that information.
* @param computer The computer. Will save this variable for later if it sends a request.
* @return If it currently has the necessary information.
*/
public static boolean requestData(TileEntityComputer computer) {
boolean b = openServers.get(computer.ownerId) != null;
if (!b) {
MinestuckPacket packet = MinestuckPacket.makePacket(Type.SBURB_INFO, computer.ownerId);
MinestuckChannelHandler.sendToServer(packet);
te = computer;
}
return b;
}
use of com.mraof.minestuck.network.MinestuckPacket in project Minestuck by mraof.
the class CaptchaDeckHandler method getItem.
public static void getItem(EntityPlayerMP player, int index, boolean asCard) {
Modus modus = getModus(player);
if (modus == null)
return;
ItemStack stack = modus.getItem(index, asCard);
if (!stack.isEmpty()) {
ItemStack otherStack = player.getHeldItemMainhand();
if (otherStack.isEmpty())
player.setHeldItem(EnumHand.MAIN_HAND, stack);
else if (canMergeItemStacks(stack, otherStack)) {
otherStack.grow(stack.getCount());
stack.setCount(0);
} else {
boolean placed = false;
for (int i = 0; i < player.inventory.mainInventory.size(); i++) {
otherStack = player.inventory.mainInventory.get(i);
if (otherStack.isEmpty())
player.inventory.mainInventory.set(i, stack.copy());
else if (canMergeItemStacks(stack, otherStack))
otherStack.grow(stack.getCount());
else
continue;
stack.setCount(0);
placed = true;
player.inventory.markDirty();
player.inventoryContainer.detectAndSendChanges();
break;
}
if (!placed)
launchAnyItem(player, stack);
}
}
MinestuckPacket packet = MinestuckPacket.makePacket(MinestuckPacket.Type.CAPTCHA, CaptchaDeckPacket.DATA, writeToNBT(modus));
MinestuckChannelHandler.sendToPlayer(packet, player);
}
use of com.mraof.minestuck.network.MinestuckPacket in project Minestuck by mraof.
the class ServerEditHandler method reset.
/**
* Called when the server stops editing the clients house.
* @param damageSource If the process was cancelled by the decoy taking damage, this parameter will be the damage source. Else null.
* @param damage If the damageSource isn't null, this is the damage taken, else this parameter is ignored.
* @param data editdata to identify the editmode session
*/
public static void reset(DamageSource damageSource, float damage, EditData data) {
if (data == null)
return;
list.remove(data);
EntityPlayerMP player = data.player;
player.closeScreen();
EntityDecoy decoy = data.decoy;
if (player.dimension != decoy.dimension)
if (!Teleport.teleportEntity(player, decoy.dimension, null)) {
list.add(data);
throw new IllegalStateException("Was not able to reset editmode player for " + player.getName() + "! Likely caused by mod collision.");
}
data.connection.useCoordinates = true;
data.connection.posX = player.posX;
data.connection.posZ = player.posZ;
player.setGameType(decoy.gameType);
player.connection.setPlayerLocation(decoy.posX, decoy.posY, decoy.posZ, decoy.rotationYaw, decoy.rotationPitch);
player.capabilities.readCapabilitiesFromNBT(decoy.capabilities);
player.sendPlayerAbilities();
player.fallDistance = 0;
player.setHealth(decoy.getHealth());
NBTTagCompound nbt = new NBTTagCompound();
decoy.foodStats.writeNBT(nbt);
player.getFoodStats().readNBT(nbt);
data.connection.inventory = player.inventory.writeToNBT(new NBTTagList());
player.inventory.copyInventory(decoy.inventory);
decoy.markedForDespawn = true;
MinestuckPacket packet = MinestuckPacket.makePacket(Type.SERVER_EDIT);
MinestuckChannelHandler.sendToPlayer(packet, player);
if (damageSource != null && damageSource.getImmediateSource() != player)
player.attackEntityFrom(damageSource, damage);
}
Aggregations