use of com.mraof.minestuck.network.MinestuckPacket in project Minestuck by mraof.
the class CaptchaDeckHandler method dropSylladex.
public static void dropSylladex(EntityPlayer player) {
Modus modus = getModus(player);
if (modus == null)
return;
NonNullList<ItemStack> stacks = modus.getItems();
int size = modus.getSize();
int cardsToKeep = MinestuckConfig.sylladexDropMode == 2 ? 0 : MinestuckConfig.initialModusSize;
if (!MinestuckConfig.dropItemsInCards || MinestuckConfig.sylladexDropMode == 0) {
for (ItemStack stack : stacks) if (!stack.isEmpty())
player.dropItem(stack, true, false);
} else
for (ItemStack stack : stacks) if (!stack.isEmpty())
if (size > cardsToKeep) {
ItemStack card = AlchemyRecipeHandler.createCard(stack, false);
player.dropItem(card, true, false);
size--;
} else
player.dropItem(stack, true, false);
int stackLimit = MinestuckItems.captchaCard.getItemStackLimit(new ItemStack(MinestuckItems.captchaCard));
if (MinestuckConfig.sylladexDropMode >= 1)
for (; size > cardsToKeep; size = Math.max(size - stackLimit, cardsToKeep)) player.dropItem(new ItemStack(MinestuckItems.captchaCard, Math.min(stackLimit, size - cardsToKeep)), true, false);
if (MinestuckConfig.sylladexDropMode == 2) {
// TODO Add a method to the modus to get the itemstack instead
player.dropItem(getItem(getType(modus.getClass())), true, false);
setModus(player, null);
} else
modus.initModus(null, size);
MinestuckPacket packet = MinestuckPacket.makePacket(MinestuckPacket.Type.CAPTCHA, CaptchaDeckPacket.DATA, writeToNBT(getModus(player)));
MinestuckChannelHandler.sendToPlayer(packet, player);
}
use of com.mraof.minestuck.network.MinestuckPacket in project Minestuck by mraof.
the class HashmapModus method onChatMessage.
public void onChatMessage(String str) {
if (!ejectByChat && MinestuckConfig.hashmapChatModusSetting != 1 || MinestuckConfig.hashmapChatModusSetting == 2)
return;
boolean isPrevLetter = false;
String number = "";
for (int i = 0; i < str.length(); i++) {
char c = str.charAt(i);
if (Character.isLetter(c))
isPrevLetter = true;
else if (Character.isDigit(c) || (number.isEmpty() && c == '-')) {
if (!isPrevLetter)
number = number + c;
continue;
} else {
isPrevLetter = false;
if (!number.isEmpty())
handleNumber(number);
}
number = "";
}
if (!number.isEmpty())
handleNumber(number);
MinestuckPacket packet = MinestuckPacket.makePacket(MinestuckPacket.Type.CAPTCHA, CaptchaDeckPacket.DATA, CaptchaDeckHandler.writeToNBT(this));
MinestuckChannelHandler.sendToPlayer(packet, player);
}
use of com.mraof.minestuck.network.MinestuckPacket in project Minestuck by mraof.
the class SkaiaClient method sendConnectRequest.
public static // Used for both connect, open server and resume
void sendConnectRequest(// Used for both connect, open server and resume
TileEntityComputer te, // Used for both connect, open server and resume
int otherPlayer, // Used for both connect, open server and resume
boolean isClient) {
MinestuckPacket packet = MinestuckPacket.makePacket(Type.SBURB_CONNECT, ComputerData.createData(te), otherPlayer, isClient);
MinestuckChannelHandler.sendToServer(packet);
}
use of com.mraof.minestuck.network.MinestuckPacket in project Minestuck by mraof.
the class SkaianetHandler method updatePlayer.
private static void updatePlayer(PlayerIdentifier player) {
PlayerIdentifier[] iden = infoToSend.get(player);
EntityPlayerMP playerMP = player.getPlayer();
if (// If the player disconnected
iden == null || playerMP == null)
return;
for (SburbConnection c : connections) if (c.isActive && (c.getClientIdentifier().equals(player) || c.getServerIdentifier().equals(player))) {
// playerMP.addStat(MinestuckAchievementHandler.setupConnection);
break;
}
for (PlayerIdentifier i : iden) if (i != null) {
MinestuckPacket packet = MinestuckPacket.makePacket(Type.SBURB_INFO, generateClientInfo(i));
MinestuckChannelHandler.sendToPlayer(packet, playerMP);
}
}
use of com.mraof.minestuck.network.MinestuckPacket in project Minestuck by mraof.
the class GuiMachine method keyTyped.
@Override
protected void keyTyped(char typedChar, int keyCode) throws IOException {
super.keyTyped(typedChar, keyCode);
if (keyCode == 28) {
this.mc.getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1.0F));
boolean mode = te.allowOverrideStop() && (Keyboard.isKeyDown(42) || Keyboard.isKeyDown(54));
MinestuckPacket packet = MinestuckPacket.makePacket(Type.GOBUTTON, true, mode && !te.overrideStop);
MinestuckChannelHandler.sendToServer(packet);
if (!mode)
te.ready = true;
te.overrideStop = mode && !te.overrideStop;
goButton.displayString = I18n.format(te.overrideStop ? "gui.buttonStop" : "gui.buttonGo");
}
}
Aggregations