mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 00:17:27 +00:00
Merge remote-tracking branch 'refs/remotes/origin/packet' into animation-events-2
# Conflicts: # src/api # src/main/java/noppes/npcs/CommonProxy.java # src/main/java/noppes/npcs/ServerEventsHandler.java # src/main/java/noppes/npcs/client/PacketHandlerClient.java # src/main/java/noppes/npcs/client/gui/global/GuiNPCManageAnimations.java # src/main/java/noppes/npcs/controllers/data/AnimationData.java
This commit is contained in:
commit
00af353e65
602 files changed
+29702
-6562
No files matched your search
@@ -3,6 +3,17 @@ package noppes.npcs;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import kamkeel.npcs.controllers.SyncController;
|
||||
import kamkeel.npcs.network.PacketHandler;
|
||||
import kamkeel.npcs.network.enums.EnumSoundOperation;
|
||||
import kamkeel.npcs.network.enums.EnumSyncAction;
|
||||
import kamkeel.npcs.network.enums.EnumSyncType;
|
||||
import kamkeel.npcs.network.packets.data.MarkDataPacket;
|
||||
import kamkeel.npcs.network.packets.data.SoundManagementPacket;
|
||||
import kamkeel.npcs.network.packets.data.VillagerListPacket;
|
||||
import kamkeel.npcs.network.packets.data.gui.GuiOpenPacket;
|
||||
import kamkeel.npcs.network.packets.data.ClonerPacket;
|
||||
import kamkeel.npcs.network.packets.data.large.SyncPacket;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
@@ -11,22 +22,19 @@ import net.minecraft.entity.passive.EntityVillager;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.village.MerchantRecipeList;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingAttackEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
||||
import net.minecraftforge.event.entity.player.EntityInteractEvent;
|
||||
import net.minecraftforge.event.entity.player.EntityItemPickupEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action;
|
||||
@@ -37,14 +45,12 @@ import noppes.npcs.config.ConfigMain;
|
||||
import noppes.npcs.constants.*;
|
||||
import noppes.npcs.controllers.PartyController;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.RecipeController;
|
||||
import noppes.npcs.controllers.ServerCloneController;
|
||||
import noppes.npcs.controllers.data.*;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.items.ItemExcalibur;
|
||||
import noppes.npcs.items.ItemShield;
|
||||
import noppes.npcs.items.ItemSoulstoneEmpty;
|
||||
import noppes.npcs.quests.QuestItem;
|
||||
import noppes.npcs.quests.QuestKill;
|
||||
import noppes.npcs.roles.RoleFollower;
|
||||
|
||||
@@ -94,8 +100,7 @@ public class ServerEventsHandler {
|
||||
return;
|
||||
PlayerData data = PlayerDataController.Instance.getPlayerData(event.entityPlayer);
|
||||
ServerCloneController.Instance.cleanTags(compound);
|
||||
if(!Server.sendDataChecked((EntityPlayerMP)event.entityPlayer, EnumPacketClient.CLONE, compound))
|
||||
event.entityPlayer.addChatMessage(new ChatComponentText("Entity too big to clone"));
|
||||
PacketHandler.Instance.sendToPlayer(new ClonerPacket(compound), (EntityPlayerMP)event.entityPlayer);
|
||||
data.cloned = compound;
|
||||
if (event.target instanceof EntityNPCInterface) {
|
||||
NoppesUtilServer.setEditingNpc(event.entityPlayer, (EntityNPCInterface) event.target);
|
||||
@@ -107,8 +112,8 @@ public class ServerEventsHandler {
|
||||
return;
|
||||
NoppesUtilServer.setEditingNpc(event.entityPlayer, (EntityNPCInterface)event.target);
|
||||
event.setCanceled(true);
|
||||
Server.sendData((EntityPlayerMP)event.entityPlayer, EnumPacketClient.GUI, EnumGuiType.Script.ordinal());
|
||||
if(ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){
|
||||
GuiOpenPacket.openGUI((EntityPlayerMP)event.entityPlayer, EnumGuiType.Script, 0, 0, 0);
|
||||
if(ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){
|
||||
LogWriter.script(String.format("[%s] (Player) %s OPEN NPC %s (%s, %s, %s) [%s]", "SCRIPTER", event.entityPlayer.getCommandSenderName(), ((EntityNPCInterface)(event.target)).display.getName(), (int)(event.target).posX, (int)(event.target).posY, (int)(event.target).posZ, (event.target).worldObj.getWorldInfo().getWorldName()));
|
||||
}
|
||||
}
|
||||
@@ -133,7 +138,7 @@ public class ServerEventsHandler {
|
||||
|
||||
if (merchantrecipelist != null)
|
||||
{
|
||||
Server.sendData(player, EnumPacketClient.VILLAGER_LIST, merchantrecipelist);
|
||||
PacketHandler.Instance.sendToPlayer(new VillagerListPacket(merchantrecipelist), player);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -193,48 +198,20 @@ public class ServerEventsHandler {
|
||||
}
|
||||
|
||||
if(block == Blocks.crafting_table && event.action == Action.RIGHT_CLICK_BLOCK && !player.worldObj.isRemote){
|
||||
RecipeController controller = RecipeController.Instance;
|
||||
NBTTagList list = new NBTTagList();
|
||||
int i = 0;
|
||||
for(RecipeCarpentry recipe : controller.globalRecipes.values()){
|
||||
list.appendTag(recipe.writeNBT());
|
||||
i++;
|
||||
if(i % 10 == 0){
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setTag("recipes", list);
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_ADD, compound);
|
||||
list = new NBTTagList();
|
||||
}
|
||||
}
|
||||
|
||||
if(i % 10 != 0){
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setTag("recipes", list);
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_ADD, compound);
|
||||
}
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_WORKBENCH);
|
||||
PacketHandler.Instance.sendToPlayer(new SyncPacket(
|
||||
EnumSyncType.WORKBENCH_RECIPES,
|
||||
EnumSyncAction.RELOAD,
|
||||
-1,
|
||||
SyncController.workbenchNBT()
|
||||
), (EntityPlayerMP) player);
|
||||
}
|
||||
if(block == CustomItems.carpentyBench && event.action == Action.RIGHT_CLICK_BLOCK && !player.worldObj.isRemote){
|
||||
RecipeController controller = RecipeController.Instance;
|
||||
NBTTagList list = new NBTTagList();
|
||||
int i = 0;
|
||||
for(RecipeCarpentry recipe : controller.anvilRecipes.values()){
|
||||
list.appendTag(recipe.writeNBT());
|
||||
i++;
|
||||
if(i % 10 == 0){
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setTag("recipes", list);
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_ADD, compound);
|
||||
list = new NBTTagList();
|
||||
}
|
||||
}
|
||||
|
||||
if(i % 10 != 0){
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setTag("recipes", list);
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_ADD, compound);
|
||||
}
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_CARPENTRYBENCH);
|
||||
PacketHandler.Instance.sendToPlayer(new SyncPacket(
|
||||
EnumSyncType.CARPENTRY_RECIPES,
|
||||
EnumSyncAction.RELOAD,
|
||||
-1,
|
||||
SyncController.carpentryNBT()
|
||||
), (EntityPlayerMP) player);
|
||||
}
|
||||
if((block == CustomItems.banner || block == CustomItems.wallBanner || block == CustomItems.sign) && event.action == Action.RIGHT_CLICK_BLOCK){
|
||||
ItemStack item = player.inventory.getCurrentItem();
|
||||
@@ -255,11 +232,23 @@ public class ServerEventsHandler {
|
||||
}
|
||||
|
||||
if(!player.worldObj.isRemote){
|
||||
if(block == CustomItems.banner || block == CustomItems.wallBanner){
|
||||
// If sneaking and using shear
|
||||
if(player.isSneaking() && item.getItem() == Items.shears){
|
||||
int currentVariantIndex = tile.variant.ordinal();
|
||||
int nextVariantIndex = (currentVariantIndex + 1) % EnumBannerVariant.values().length;
|
||||
tile.variant = EnumBannerVariant.values()[nextVariantIndex];
|
||||
|
||||
player.worldObj.markBlockForUpdate(event.x, y, event.z);
|
||||
event.setCanceled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
tile.icon = item.copy();
|
||||
player.worldObj.markBlockForUpdate(event.x, y, event.z);
|
||||
event.setCanceled(true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -314,7 +303,7 @@ public class ServerEventsHandler {
|
||||
ItemStack item = player.getCurrentEquippedItem();
|
||||
if(item == null || item.getItem() != CustomItems.excalibur)
|
||||
return;
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.PLAY_MUSIC, "customnpcs:songs.excalibur");
|
||||
PacketHandler.Instance.sendToPlayer(new SoundManagementPacket(EnumSoundOperation.PLAY_MUSIC, "customnpcs:songs.excalibur"), (EntityPlayerMP)player);
|
||||
player.addChatMessage(new ChatComponentTranslation("<" + StatCollector.translateToLocal(item.getItem().getUnlocalizedName() + ".name") + "> " + ItemExcalibur.quotes[player.getRNG().nextInt(ItemExcalibur.quotes.length)]));
|
||||
}
|
||||
|
||||
@@ -512,7 +501,7 @@ public class ServerEventsHandler {
|
||||
MarkData data = MarkData.get((EntityNPCInterface) event.target);
|
||||
if (data.marks.isEmpty())
|
||||
return;
|
||||
Server.sendData((EntityPlayerMP) event.entityPlayer, EnumPacketClient.MARK_DATA, event.target.getEntityId(), data.getNBT());
|
||||
PacketHandler.Instance.sendToPlayer(new MarkDataPacket(event.target.getEntityId(), data.getNBT()), (EntityPlayerMP)event.entityPlayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user