mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-21 20:52:20 +00:00
Check direction of packets, don't overwrite recipes with sent ones in SP
Prevents lexicon upgrading after /reload losing other data on stack
This commit is contained in:
1 parent
e9166da71e
commit
d5001c79c8
7 files changed
+71
-58
No files matched your search
@@ -64,6 +64,10 @@ public class PacketBotaniaEffect {
|
||||
|
||||
public static class Handler {
|
||||
public static void handle(final PacketBotaniaEffect message, final Supplier<NetworkEvent.Context> ctx) {
|
||||
if (ctx.get().getDirection().getReceptionSide().isServer()) {
|
||||
ctx.get().setPacketHandled(true);
|
||||
return;
|
||||
}
|
||||
ctx.get().enqueueWork(new Runnable() {
|
||||
// Use anon - lambda causes classloading issues
|
||||
@Override
|
||||
@@ -76,13 +80,13 @@ public class PacketBotaniaEffect {
|
||||
int hex = placeColor.colorValue;
|
||||
int r = (hex & 0xFF0000) >> 16;
|
||||
int g = (hex & 0xFF00) >> 8;
|
||||
int b = hex & 0xFF;
|
||||
for(int i = 0; i < 10; i++) {
|
||||
BlockPos pos = new BlockPos(message.x, message.y, message.z).offset(Direction.random(world.rand));
|
||||
SparkleParticleData data = SparkleParticleData.sparkle(0.6F + (float) Math.random() * 0.5F, r / 255F, g / 255F, b / 255F, 5);
|
||||
world.addParticle(data, pos.getX() + (float) Math.random(), pos.getY() + (float) Math.random(), pos.getZ() + (float) Math.random(), 0, 0, 0);
|
||||
}
|
||||
break;
|
||||
int b = hex & 0xFF;
|
||||
for (int i = 0; i < 10; i++) {
|
||||
BlockPos pos = new BlockPos(message.x, message.y, message.z).offset(Direction.random(world.rand));
|
||||
SparkleParticleData data = SparkleParticleData.sparkle(0.6F + (float) Math.random() * 0.5F, r / 255F, g / 255F, b / 255F, 5);
|
||||
world.addParticle(data, pos.getX() + (float) Math.random(), pos.getY() + (float) Math.random(), pos.getZ() + (float) Math.random(), 0, 0, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ARENA_INDICATOR: {
|
||||
SparkleParticleData data = SparkleParticleData.sparkle(5F, 1, 0, 1, 120);
|
||||
|
||||
@@ -15,6 +15,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.network.NetworkEvent;
|
||||
import vazkii.botania.common.core.handler.EquipmentHandler;
|
||||
import vazkii.botania.common.core.handler.ModSounds;
|
||||
@@ -32,19 +33,20 @@ public class PacketDodge {
|
||||
}
|
||||
|
||||
public static void handle(PacketDodge msg, Supplier<NetworkEvent.Context> ctx) {
|
||||
ctx.get().enqueueWork(() -> {
|
||||
ServerPlayerEntity player = ctx.get().getSender();
|
||||
player.world.playSound(null, player.posX, player.posY, player.posZ, ModSounds.dash, SoundCategory.PLAYERS, 1F, 1F);
|
||||
if (ctx.get().getDirection().getReceptionSide().isServer())
|
||||
ctx.get().enqueueWork(() -> {
|
||||
ServerPlayerEntity player = ctx.get().getSender();
|
||||
player.world.playSound(null, player.posX, player.posY, player.posZ, ModSounds.dash, SoundCategory.PLAYERS, 1F, 1F);
|
||||
|
||||
ItemStack ringStack = EquipmentHandler.findOrEmpty(ModItems.dodgeRing, player);
|
||||
if(ringStack.isEmpty()) {
|
||||
player.connection.disconnect(new TranslationTextComponent("botaniamisc.invalidDodge"));
|
||||
return;
|
||||
}
|
||||
ItemStack ringStack = EquipmentHandler.findOrEmpty(ModItems.dodgeRing, player);
|
||||
if (ringStack.isEmpty()) {
|
||||
player.connection.disconnect(new TranslationTextComponent("botaniamisc.invalidDodge"));
|
||||
return;
|
||||
}
|
||||
|
||||
player.addExhaustion(0.3F);
|
||||
ItemNBTHelper.setInt(ringStack, ItemDodgeRing.TAG_DODGE_COOLDOWN, ItemDodgeRing.MAX_CD);
|
||||
});
|
||||
player.addExhaustion(0.3F);
|
||||
ItemNBTHelper.setInt(ringStack, ItemDodgeRing.TAG_DODGE_COOLDOWN, ItemDodgeRing.MAX_CD);
|
||||
});
|
||||
ctx.get().setPacketHandled(true);
|
||||
}
|
||||
}
|
||||
@@ -35,18 +35,19 @@ public class PacketIndexKeybindRequest {
|
||||
}
|
||||
|
||||
public static void handle(PacketIndexKeybindRequest message, Supplier<NetworkEvent.Context> ctx) {
|
||||
ctx.get().enqueueWork(() -> {
|
||||
ServerPlayerEntity player = ctx.get().getSender();
|
||||
if (player.isSpectator())
|
||||
return;
|
||||
if (ctx.get().getDirection().getReceptionSide().isServer())
|
||||
ctx.get().enqueueWork(() -> {
|
||||
ServerPlayerEntity player = ctx.get().getSender();
|
||||
if (player.isSpectator())
|
||||
return;
|
||||
|
||||
boolean checkNBT = message.stack.getTag() != null && !message.stack.getTag().isEmpty();
|
||||
for (TileCorporeaIndex index : TileCorporeaIndex.InputHandler.getNearbyIndexes(player)) {
|
||||
if (index.getSpark() != null) {
|
||||
index.performPlayerRequest(player, CorporeaHelper.createMatcher(message.stack, checkNBT), message.stack.getCount());
|
||||
boolean checkNBT = message.stack.getTag() != null && !message.stack.getTag().isEmpty();
|
||||
for (TileCorporeaIndex index : TileCorporeaIndex.InputHandler.getNearbyIndexes(player)) {
|
||||
if (index.getSpark() != null) {
|
||||
index.performPlayerRequest(player, CorporeaHelper.createMatcher(message.stack, checkNBT), message.stack.getCount());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
ctx.get().setPacketHandled(true);
|
||||
}
|
||||
}
|
||||
@@ -27,12 +27,13 @@ public class PacketItemAge {
|
||||
}
|
||||
|
||||
public static void handle(PacketItemAge message, Supplier<NetworkEvent.Context> ctx) {
|
||||
ctx.get().enqueueWork(() -> {
|
||||
Entity e = Minecraft.getInstance().world.getEntityByID(message.entityId);
|
||||
if(e instanceof ItemEntity) {
|
||||
((ItemEntity) e).age = message.age;
|
||||
}
|
||||
});
|
||||
if (ctx.get().getDirection().getReceptionSide().isClient())
|
||||
ctx.get().enqueueWork(() -> {
|
||||
Entity e = Minecraft.getInstance().world.getEntityByID(message.entityId);
|
||||
if (e instanceof ItemEntity) {
|
||||
((ItemEntity) e).age = message.age;
|
||||
}
|
||||
});
|
||||
ctx.get().setPacketHandled(true);
|
||||
}
|
||||
}
|
||||
@@ -2,10 +2,10 @@
|
||||
* This class was created by <Vazkii>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
*
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*
|
||||
*
|
||||
* File Created @ [22/10/2016, 18:18:19 (GMT)]
|
||||
*/
|
||||
package vazkii.botania.common.network;
|
||||
@@ -28,19 +28,20 @@ public class PacketJump {
|
||||
}
|
||||
|
||||
public void handle(Supplier<NetworkEvent.Context> ctx) {
|
||||
ctx.get().enqueueWork(() -> {
|
||||
ServerPlayerEntity player = ctx.get().getSender();
|
||||
if (ctx.get().getDirection().getReceptionSide().isServer())
|
||||
ctx.get().enqueueWork(() -> {
|
||||
ServerPlayerEntity player = ctx.get().getSender();
|
||||
|
||||
ItemStack amuletStack = EquipmentHandler.findOrEmpty(s -> s.getItem() instanceof ItemCloudPendant, player);
|
||||
if(!amuletStack.isEmpty()) {
|
||||
player.addExhaustion(0.3F);
|
||||
player.fallDistance = 0;
|
||||
ItemStack amuletStack = EquipmentHandler.findOrEmpty(s -> s.getItem() instanceof ItemCloudPendant, player);
|
||||
if (!amuletStack.isEmpty()) {
|
||||
player.addExhaustion(0.3F);
|
||||
player.fallDistance = 0;
|
||||
|
||||
ItemStack belt = EquipmentHandler.findOrEmpty(s -> s.getItem() instanceof ItemTravelBelt, player);
|
||||
if(!belt.isEmpty())
|
||||
player.fallDistance = -((ItemTravelBelt) belt.getItem()).fallBuffer * ((ItemCloudPendant) amuletStack.getItem()).getMaxAllowedJumps();
|
||||
}
|
||||
});
|
||||
ItemStack belt = EquipmentHandler.findOrEmpty(s -> s.getItem() instanceof ItemTravelBelt, player);
|
||||
if (!belt.isEmpty())
|
||||
player.fallDistance = -((ItemTravelBelt) belt.getItem()).fallBuffer * ((ItemCloudPendant) amuletStack.getItem()).getMaxAllowedJumps();
|
||||
}
|
||||
});
|
||||
ctx.get().setPacketHandled(true);
|
||||
}
|
||||
}
|
||||
@@ -15,9 +15,8 @@ public class PacketLeftClick {
|
||||
}
|
||||
|
||||
public static void handle(PacketLeftClick msg, Supplier<NetworkEvent.Context> ctx) {
|
||||
ctx.get().enqueueWork(() -> {
|
||||
((ItemTerraSword) ModItems.terraSword).trySpawnBurst(ctx.get().getSender());
|
||||
});
|
||||
if (ctx.get().getDirection().getReceptionSide().isServer())
|
||||
ctx.get().enqueueWork(() -> ((ItemTerraSword) ModItems.terraSword).trySpawnBurst(ctx.get().getSender()));
|
||||
ctx.get().setPacketHandled(true);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
package vazkii.botania.common.network;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.network.NetworkEvent;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.recipe.RecipeBrew;
|
||||
@@ -89,14 +91,17 @@ public class PacketSyncRecipes {
|
||||
}
|
||||
|
||||
public void handle(Supplier<NetworkEvent.Context> ctx) {
|
||||
ctx.get().enqueueWork(() -> {
|
||||
BotaniaAPI.brewRecipes = brew;
|
||||
BotaniaAPI.elvenTradeRecipes = elven;
|
||||
BotaniaAPI.manaInfusionRecipes = manaInfusion;
|
||||
BotaniaAPI.petalRecipes = petal;
|
||||
BotaniaAPI.pureDaisyRecipes = pureDaisy;
|
||||
BotaniaAPI.runeAltarRecipes = runeAltar;
|
||||
});
|
||||
if(ctx.get().getDirection().getReceptionSide().isClient())
|
||||
ctx.get().enqueueWork(() -> {
|
||||
if(Minecraft.getInstance().isSingleplayer())
|
||||
return;
|
||||
BotaniaAPI.brewRecipes = brew;
|
||||
BotaniaAPI.elvenTradeRecipes = elven;
|
||||
BotaniaAPI.manaInfusionRecipes = manaInfusion;
|
||||
BotaniaAPI.petalRecipes = petal;
|
||||
BotaniaAPI.pureDaisyRecipes = pureDaisy;
|
||||
BotaniaAPI.runeAltarRecipes = runeAltar;
|
||||
});
|
||||
ctx.get().setPacketHandled(true);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user