diff options
| author | Benjamin Culkin <scorpress@gmail.com> | 2024-08-24 08:16:37 -0400 |
|---|---|---|
| committer | Benjamin Culkin <scorpress@gmail.com> | 2024-08-24 08:16:37 -0400 |
| commit | 70c1354a4a96698758a88c032866288f79de6f5a (patch) | |
| tree | eca51294e84b90a4cb3230bc2c7900469e784184 /src/main/java/jp/plusplus/fbs/packet | |
Diffstat (limited to 'src/main/java/jp/plusplus/fbs/packet')
32 files changed, 713 insertions, 0 deletions
diff --git a/src/main/java/jp/plusplus/fbs/packet/MessageGuiButton$Handler.class b/src/main/java/jp/plusplus/fbs/packet/MessageGuiButton$Handler.class Binary files differnew file mode 100644 index 0000000..f991f87 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/packet/MessageGuiButton$Handler.class diff --git a/src/main/java/jp/plusplus/fbs/packet/MessageGuiButton.class b/src/main/java/jp/plusplus/fbs/packet/MessageGuiButton.class Binary files differnew file mode 100644 index 0000000..3dd092d --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/packet/MessageGuiButton.class diff --git a/src/main/java/jp/plusplus/fbs/packet/MessageGuiButton.java b/src/main/java/jp/plusplus/fbs/packet/MessageGuiButton.java new file mode 100644 index 0000000..bc58920 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/packet/MessageGuiButton.java @@ -0,0 +1,107 @@ +package jp.plusplus.fbs.packet;
+
+import cpw.mods.fml.common.network.ByteBufUtils;
+import cpw.mods.fml.common.network.simpleimpl.IMessage;
+import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
+import cpw.mods.fml.common.network.simpleimpl.MessageContext;
+import io.netty.buffer.ByteBuf;
+import jp.plusplus.fbs.FBS;
+import jp.plusplus.fbs.container.ContainerAlchemyCauldron;
+import jp.plusplus.fbs.container.ContainerTFKEnchantment;
+import jp.plusplus.fbs.container.ContainerWarp;
+import jp.plusplus.fbs.container.spirit.ContainerSpiritLearn;
+import jp.plusplus.fbs.container.spirit.ContainerSpiritMain;
+import jp.plusplus.fbs.exprop.FBSEntityProperties;
+import jp.plusplus.fbs.exprop.SanityManager;
+import jp.plusplus.fbs.spirit.SpiritManager;
+import jp.plusplus.fbs.spirit.SpiritStatus;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.Container;
+import net.minecraft.util.MathHelper;
+
+/**
+ * Created by plusplus_F on 2015/10/21.
+ */
+public class MessageGuiButton implements IMessage {
+ protected int buttonId;
+
+ public MessageGuiButton(){}
+ public MessageGuiButton(int id){
+ buttonId=id;
+ }
+
+ @Override
+ public void fromBytes(ByteBuf buf) {
+ buttonId= ByteBufUtils.readVarInt(buf, 4);
+ }
+
+ @Override
+ public void toBytes(ByteBuf buf) {
+ ByteBufUtils.writeVarInt(buf, buttonId, 4);
+ }
+
+ public static class Handler implements IMessageHandler<MessageGuiButton, IMessage>{
+
+ @Override
+ public IMessage onMessage(MessageGuiButton message, MessageContext ctx) {
+ Container con=ctx.getServerHandler().playerEntity.openContainer;
+
+ if(con instanceof ContainerTFKEnchantment){
+ //エンチャントできそうならエンチャントする
+ ContainerTFKEnchantment c=(ContainerTFKEnchantment)con;
+ if(c.canEnchant()){
+ c.tryEnchant();
+ }
+ }
+ else if(con instanceof ContainerAlchemyCauldron){
+ ContainerAlchemyCauldron c=(ContainerAlchemyCauldron)con;
+ if(c.entity.canCompounding()){
+ c.entity.tryCompounding(ctx.getServerHandler().playerEntity);
+ }
+ }
+ else if(con instanceof ContainerSpiritMain){
+ ContainerSpiritMain c=(ContainerSpiritMain)con;
+ EntityPlayer player=ctx.getServerHandler().playerEntity;
+ int x= MathHelper.floor_double(player.posX);
+ int y=MathHelper.floor_double(player.posY);
+ int z=MathHelper.floor_double(player.posZ);
+
+ if(c.type==0){
+ switch (message.buttonId){
+ case 0:
+ player.openGui(FBS.instance, FBS.GUI_SPIRIT_SKILL_ID, player.worldObj, x,y,z);
+ break;
+
+ case 1:
+ player.openGui(FBS.instance, FBS.GUI_SPIRIT_LEARN_ID, player.worldObj, x,y,z);
+ break;
+
+ case 2:
+ SpiritManager.bless(player, SpiritManager.findSpiritTool(player));
+ break;
+
+ case 3:
+ SpiritManager.repair(player, SpiritManager.findSpiritTool(player), -1);
+ break;
+
+ case 5:
+ player.openGui(FBS.instance, FBS.GUI_SPIRIT_CONFIG_ID, player.worldObj, x,y,z);
+ break;
+
+ default:
+ break;
+ }
+ }
+ }
+ else if(con instanceof ContainerSpiritLearn){
+ EntityPlayer player=ctx.getServerHandler().playerEntity;
+ int x= MathHelper.floor_double(player.posX);
+ int y=MathHelper.floor_double(player.posY);
+ int z=MathHelper.floor_double(player.posZ);
+ player.openGui(FBS.instance, FBS.GUI_SPIRIT_MAIN_ID, player.worldObj, x,y,z);
+ }
+
+ return null;
+ }
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/packet/MessageGuiButtonDecide$Handler.class b/src/main/java/jp/plusplus/fbs/packet/MessageGuiButtonDecide$Handler.class Binary files differnew file mode 100644 index 0000000..6b01e4e --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/packet/MessageGuiButtonDecide$Handler.class diff --git a/src/main/java/jp/plusplus/fbs/packet/MessageGuiButtonDecide.class b/src/main/java/jp/plusplus/fbs/packet/MessageGuiButtonDecide.class Binary files differnew file mode 100644 index 0000000..b232fcb --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/packet/MessageGuiButtonDecide.class diff --git a/src/main/java/jp/plusplus/fbs/packet/MessageGuiButtonDecide.java b/src/main/java/jp/plusplus/fbs/packet/MessageGuiButtonDecide.java new file mode 100644 index 0000000..cf203de --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/packet/MessageGuiButtonDecide.java @@ -0,0 +1,109 @@ +package jp.plusplus.fbs.packet;
+
+import cpw.mods.fml.common.network.ByteBufUtils;
+import cpw.mods.fml.common.network.simpleimpl.IMessage;
+import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
+import cpw.mods.fml.common.network.simpleimpl.MessageContext;
+import io.netty.buffer.ByteBuf;
+import jp.plusplus.fbs.FBS;
+import jp.plusplus.fbs.block.BlockCore;
+import jp.plusplus.fbs.container.ContainerWarp;
+import jp.plusplus.fbs.exprop.FBSEntityProperties;
+import jp.plusplus.fbs.item.ItemBookSorcery;
+import jp.plusplus.fbs.tileentity.TileEntityPortalWarp;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.MathHelper;
+import net.minecraft.world.World;
+
+import java.util.Random;
+
+/**
+ * Created by plusplus_F on 2015/10/22.
+ */
+public class MessageGuiButtonDecide implements IMessage {
+ public FBSEntityProperties.WarpPosition destination;
+ public EntityPlayer player;
+
+ public MessageGuiButtonDecide(){}
+ public MessageGuiButtonDecide(EntityPlayer ep, FBSEntityProperties.WarpPosition dest){
+ player=ep;
+ destination=dest;
+ }
+
+ @Override
+ public void fromBytes(ByteBuf buf) {
+
+ destination=new FBSEntityProperties.WarpPosition(ByteBufUtils.readTag(buf));
+ }
+
+ @Override
+ public void toBytes(ByteBuf buf) {
+ NBTTagCompound nbt=new NBTTagCompound();
+ destination.writeToNBT(nbt);
+ ByteBufUtils.writeTag(buf, nbt);
+ }
+
+ public static class Handler implements IMessageHandler<MessageGuiButtonDecide, IMessage> {
+ protected Random rand=new Random();
+ @Override
+ public IMessage onMessage(MessageGuiButtonDecide message, MessageContext ctx) {
+ EntityPlayer ep=ctx.getServerHandler().playerEntity;
+ World w=ctx.getServerHandler().playerEntity.worldObj;
+
+ if(ep.openContainer instanceof ContainerWarp){
+ ContainerWarp con=(ContainerWarp)ep.openContainer;
+
+ //ポータルの生成
+ if(!w.isRemote){
+ FBSEntityProperties.WarpPosition wp=message.destination;
+
+ int x=MathHelper.floor_double(ep.posX);
+ int y=MathHelper.floor_double(ep.posY);
+ int z=MathHelper.floor_double(ep.posZ);
+ int rx=(rand.nextBoolean()?1:-1)*(1+rand.nextInt(2));
+ int ry=0;
+ int rz=(rand.nextBoolean()?1:-1)*(1+rand.nextInt(2));
+ int meta=0;
+
+ if(MathHelper.abs_int(rx)>MathHelper.abs_int(rz)){
+ meta=(meta|8);
+ }
+ if(wp.dimId==FBS.dimensionCrackId && wp.x==-1 && wp.y==-1 && wp.z==-1){
+ //狭間生成用
+ meta=(meta|4);
+ }
+
+ rx+=x;
+ ry+=y;
+ rz+=z;
+ for(int i=0;i<2;i++){
+ w.setBlock(rx, ry+i, rz, BlockCore.portal1, meta+i, 2);
+ TileEntity te=w.getTileEntity(rx,ry+i,rz);
+ if(te instanceof TileEntityPortalWarp){
+ ((TileEntityPortalWarp) te).destination=message.destination;
+ te.markDirty();
+ }
+ }
+ }
+
+ //魔導書の使用回数を減らす
+ if(!ep.capabilities.isCreativeMode){
+ ItemStack item=ep.getCurrentEquippedItem();
+ if(item != null && item.getItem() instanceof ItemBookSorcery){
+ ItemBookSorcery.reduceMagicMaxUse(item);
+ }
+ }
+
+ //GUI閉じる
+ con.close=true;
+ }
+
+ //
+
+ return null;
+ }
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/packet/MessageGuiButtonWithNBT$Handler.class b/src/main/java/jp/plusplus/fbs/packet/MessageGuiButtonWithNBT$Handler.class Binary files differnew file mode 100644 index 0000000..874a1f0 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/packet/MessageGuiButtonWithNBT$Handler.class diff --git a/src/main/java/jp/plusplus/fbs/packet/MessageGuiButtonWithNBT.class b/src/main/java/jp/plusplus/fbs/packet/MessageGuiButtonWithNBT.class Binary files differnew file mode 100644 index 0000000..8068b49 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/packet/MessageGuiButtonWithNBT.class diff --git a/src/main/java/jp/plusplus/fbs/packet/MessageGuiButtonWithNBT.java b/src/main/java/jp/plusplus/fbs/packet/MessageGuiButtonWithNBT.java new file mode 100644 index 0000000..3f30062 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/packet/MessageGuiButtonWithNBT.java @@ -0,0 +1,78 @@ +package jp.plusplus.fbs.packet;
+
+import cpw.mods.fml.common.network.ByteBufUtils;
+import cpw.mods.fml.common.network.simpleimpl.IMessage;
+import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
+import cpw.mods.fml.common.network.simpleimpl.MessageContext;
+import io.netty.buffer.ByteBuf;
+import jp.plusplus.fbs.FBS;
+import jp.plusplus.fbs.container.ContainerAlchemyCauldron;
+import jp.plusplus.fbs.container.ContainerTFKEnchantment;
+import jp.plusplus.fbs.container.spirit.ContainerSpiritMain;
+import jp.plusplus.fbs.spirit.SpiritManager;
+import jp.plusplus.fbs.spirit.SpiritStatus;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.Container;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.MathHelper;
+
+/**
+ * Created by plusplus_F on 2015/10/21.
+ */
+public class MessageGuiButtonWithNBT implements IMessage {
+ protected int buttonId;
+ protected NBTTagCompound nbt;
+
+ public MessageGuiButtonWithNBT(){}
+ public MessageGuiButtonWithNBT(int id, NBTTagCompound nbt){
+ buttonId=id;
+ this.nbt=nbt;
+ }
+
+ @Override
+ public void fromBytes(ByteBuf buf) {
+ buttonId= ByteBufUtils.readVarInt(buf, 4);
+ nbt=ByteBufUtils.readTag(buf);
+ }
+
+ @Override
+ public void toBytes(ByteBuf buf) {
+ ByteBufUtils.writeVarInt(buf, buttonId, 4);
+ ByteBufUtils.writeTag(buf, nbt);
+ }
+
+ public static class Handler implements IMessageHandler<MessageGuiButtonWithNBT, IMessage>{
+
+ @Override
+ public IMessage onMessage(MessageGuiButtonWithNBT message, MessageContext ctx) {
+ EntityPlayer player=ctx.getServerHandler().playerEntity;
+ Container con=player.openContainer;
+ int x= MathHelper.floor_double(player.posX);
+ int y=MathHelper.floor_double(player.posY);
+ int z=MathHelper.floor_double(player.posZ);
+
+ if(con instanceof ContainerSpiritMain){
+ int type=((ContainerSpiritMain) con).type;
+ if(type==1){
+ if(message.buttonId==0){
+ //OKの場合、設定を反映する
+ int index=SpiritManager.findSpiritToolIndex(player);
+ if(index!=-1){
+ ItemStack itemStack= player.inventory.getStackInSlot(index);
+ SpiritStatus ss=SpiritStatus.readFromNBT(itemStack.getTagCompound());
+ ss.getConfiguration().readFromNBT(message.nbt);
+
+ NBTTagCompound nbt1=new NBTTagCompound();
+ SpiritStatus.writeToNBT(ss, nbt1);
+ itemStack.setTagCompound(nbt1);
+ }
+ }
+ player.openGui(FBS.instance, FBS.GUI_SPIRIT_MAIN_ID, player.worldObj, x,y,z);
+ }
+ }
+
+ return null;
+ }
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/packet/MessageGuiButtonWithString$Handler.class b/src/main/java/jp/plusplus/fbs/packet/MessageGuiButtonWithString$Handler.class Binary files differnew file mode 100644 index 0000000..9ec420d --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/packet/MessageGuiButtonWithString$Handler.class diff --git a/src/main/java/jp/plusplus/fbs/packet/MessageGuiButtonWithString.class b/src/main/java/jp/plusplus/fbs/packet/MessageGuiButtonWithString.class Binary files differnew file mode 100644 index 0000000..093a7ea --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/packet/MessageGuiButtonWithString.class diff --git a/src/main/java/jp/plusplus/fbs/packet/MessageGuiButtonWithString.java b/src/main/java/jp/plusplus/fbs/packet/MessageGuiButtonWithString.java new file mode 100644 index 0000000..2df2b77 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/packet/MessageGuiButtonWithString.java @@ -0,0 +1,68 @@ +package jp.plusplus.fbs.packet;
+
+import cpw.mods.fml.common.network.ByteBufUtils;
+import cpw.mods.fml.common.network.simpleimpl.IMessage;
+import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
+import cpw.mods.fml.common.network.simpleimpl.MessageContext;
+import io.netty.buffer.ByteBuf;
+import jp.plusplus.fbs.FBS;
+import jp.plusplus.fbs.container.ContainerContract;
+import jp.plusplus.fbs.container.ContainerWarp;
+import jp.plusplus.fbs.container.spirit.ContainerSpiritLearn;
+import jp.plusplus.fbs.exprop.FBSEntityProperties;
+import jp.plusplus.fbs.exprop.SanityManager;
+import jp.plusplus.fbs.spirit.SpiritManager;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.Container;
+
+/**
+ * Created by plusplus_F on 2015/10/23.
+ */
+public class MessageGuiButtonWithString implements IMessage {
+ protected int index;
+ protected String name;
+
+ public MessageGuiButtonWithString(){}
+ public MessageGuiButtonWithString(int index, String str){
+ this.index=index;
+ this.name=str;
+ }
+
+ @Override
+ public void fromBytes(ByteBuf buf) {
+ index= ByteBufUtils.readVarInt(buf, 4);
+ name=ByteBufUtils.readUTF8String(buf);
+ }
+
+ @Override
+ public void toBytes(ByteBuf buf) {
+ ByteBufUtils.writeVarInt(buf, index, 4);
+ ByteBufUtils.writeUTF8String(buf, name);
+ }
+
+ public static class Handler implements IMessageHandler<MessageGuiButtonWithString, IMessage>{
+ @Override
+ public IMessage onMessage(MessageGuiButtonWithString message, MessageContext ctx) {
+ Container con=ctx.getServerHandler().playerEntity.openContainer;
+ EntityPlayer player=ctx.getServerHandler().playerEntity;
+
+ if(con instanceof ContainerWarp){
+ //時空間の航行
+ FBSEntityProperties prop=FBSEntityProperties.get(player);
+ prop.getDestinations().get(message.index).setName(message.name);
+ SanityManager.sendPacket(player);
+ }
+ else if(con instanceof ContainerContract){
+ //精霊との契約
+ String ch=((ContainerContract) con).contract(message.name, player);
+ }
+ else if(con instanceof ContainerSpiritLearn){
+ ContainerSpiritLearn c=(ContainerSpiritLearn)con;
+ //FBS.logger.info(message.name);
+ c.learn(message.name);
+ }
+
+ return null;
+ }
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/packet/MessageMagicFlexible.class b/src/main/java/jp/plusplus/fbs/packet/MessageMagicFlexible.class Binary files differnew file mode 100644 index 0000000..a6e2905 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/packet/MessageMagicFlexible.class diff --git a/src/main/java/jp/plusplus/fbs/packet/MessageMagicFlexible.java b/src/main/java/jp/plusplus/fbs/packet/MessageMagicFlexible.java new file mode 100644 index 0000000..f9a581a --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/packet/MessageMagicFlexible.java @@ -0,0 +1,40 @@ +package jp.plusplus.fbs.packet;
+
+import cpw.mods.fml.common.network.ByteBufUtils;
+import cpw.mods.fml.common.network.simpleimpl.IMessage;
+import io.netty.buffer.ByteBuf;
+import jp.plusplus.fbs.entity.EntityMagicArrowFlexible;
+import net.minecraft.nbt.NBTTagCompound;
+
+import java.util.UUID;
+
+/**
+ * Created by plusplus_F on 2015/10/17.
+ */
+public class MessageMagicFlexible implements IMessage {
+ public int shooterId;
+ public int entityId;
+ public NBTTagCompound data;
+
+ public MessageMagicFlexible(){}
+ public MessageMagicFlexible(EntityMagicArrowFlexible entity){
+ shooterId=entity.shootingEntity.getEntityId();
+ entityId=entity.getEntityId();
+ data=new NBTTagCompound();
+ entity.writeMagicsToNBT(data);
+ }
+
+ @Override
+ public void fromBytes(ByteBuf buf) {
+ shooterId=ByteBufUtils.readVarInt(buf, 4);
+ entityId=ByteBufUtils.readVarInt(buf, 4);
+ data = ByteBufUtils.readTag(buf);
+ }
+
+ @Override
+ public void toBytes(ByteBuf buf) {
+ ByteBufUtils.writeVarInt(buf, shooterId, 4);
+ ByteBufUtils.writeVarInt(buf, entityId, 4);
+ ByteBufUtils.writeTag(buf, data);
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/packet/MessageMagicFlexibleHandler.class b/src/main/java/jp/plusplus/fbs/packet/MessageMagicFlexibleHandler.class Binary files differnew file mode 100644 index 0000000..1054bde --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/packet/MessageMagicFlexibleHandler.class diff --git a/src/main/java/jp/plusplus/fbs/packet/MessageMagicFlexibleHandler.java b/src/main/java/jp/plusplus/fbs/packet/MessageMagicFlexibleHandler.java new file mode 100644 index 0000000..c699e8f --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/packet/MessageMagicFlexibleHandler.java @@ -0,0 +1,28 @@ +package jp.plusplus.fbs.packet;
+
+import cpw.mods.fml.common.network.simpleimpl.IMessage;
+import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
+import cpw.mods.fml.common.network.simpleimpl.MessageContext;
+import jp.plusplus.fbs.FBS;
+import jp.plusplus.fbs.entity.EntityMagicArrowFlexible;
+import net.minecraft.entity.Entity;
+import net.minecraft.world.World;
+
+import java.util.List;
+
+/**
+ * Created by plusplus_F on 2015/10/17.
+ */
+public class MessageMagicFlexibleHandler implements IMessageHandler<MessageMagicFlexible, IMessage> {
+ @Override
+ public IMessage onMessage(MessageMagicFlexible message, MessageContext ctx) {
+ World w=FBS.proxy.getClientWorld();
+
+ Entity e=w.getEntityByID(message.entityId);
+ if(e instanceof EntityMagicArrowFlexible){
+ ((EntityMagicArrowFlexible) e).shootingEntity=w.getEntityByID(message.shooterId);
+ ((EntityMagicArrowFlexible) e).readMagicsFromNBT(message.data);
+ }
+ return null;
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/packet/MessageMagicVortex$Handler.class b/src/main/java/jp/plusplus/fbs/packet/MessageMagicVortex$Handler.class Binary files differnew file mode 100644 index 0000000..46ebc00 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/packet/MessageMagicVortex$Handler.class diff --git a/src/main/java/jp/plusplus/fbs/packet/MessageMagicVortex.class b/src/main/java/jp/plusplus/fbs/packet/MessageMagicVortex.class Binary files differnew file mode 100644 index 0000000..d7ef61d --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/packet/MessageMagicVortex.class diff --git a/src/main/java/jp/plusplus/fbs/packet/MessageMagicVortex.java b/src/main/java/jp/plusplus/fbs/packet/MessageMagicVortex.java new file mode 100644 index 0000000..f9642d5 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/packet/MessageMagicVortex.java @@ -0,0 +1,104 @@ +package jp.plusplus.fbs.packet;
+
+import cpw.mods.fml.client.FMLClientHandler;
+import cpw.mods.fml.common.network.ByteBufUtils;
+import cpw.mods.fml.common.network.simpleimpl.IMessage;
+import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
+import cpw.mods.fml.common.network.simpleimpl.MessageContext;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import io.netty.buffer.ByteBuf;
+import jp.plusplus.fbs.FBS;
+import jp.plusplus.fbs.Registry;
+import jp.plusplus.fbs.api.IMagicEnchant;
+import jp.plusplus.fbs.entity.EntityMagicArrowFlexible;
+import jp.plusplus.fbs.particle.EntityVortexFX;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
+import net.minecraft.world.World;
+
+import java.util.Random;
+
+/**
+ * Created by plusplus_F on 2015/10/20.
+ */
+public class MessageMagicVortex implements IMessage {
+ private int shooterId;
+ private double range;
+ private NBTTagCompound data;
+
+ public MessageMagicVortex(){}
+ public MessageMagicVortex(EntityPlayer ep, double range, NBTTagCompound magics){
+ shooterId=ep.getEntityId();
+ this.range=range;
+ data=magics;
+ }
+
+ @Override
+ public void fromBytes(ByteBuf buf) {
+ shooterId= ByteBufUtils.readVarInt(buf, 4);
+ range=ByteBufUtils.readVarInt(buf, 4)/100.0;
+ data=ByteBufUtils.readTag(buf);
+ }
+
+ @Override
+ public void toBytes(ByteBuf buf) {
+ ByteBufUtils.writeVarInt(buf, shooterId, 4);
+ ByteBufUtils.writeVarInt(buf, (int)(range*100), 4);
+ ByteBufUtils.writeTag(buf, data);
+ }
+
+ public static class Handler implements IMessageHandler<MessageMagicVortex, IMessage>{
+ @Override
+ public IMessage onMessage(MessageMagicVortex message, MessageContext ctx) {
+ World w= FBS.proxy.getClientWorld();
+
+ if(w!=null){
+ Entity e=w.getEntityByID(message.shooterId);
+ if(e!=null){
+ if(message.data.hasKey("EnchantMagics")){
+ //1.魔法のリストを生成
+ NBTTagList nbttaglist = (NBTTagList)message.data.getTag("EnchantMagics");
+ IMagicEnchant[] magics=new IMagicEnchant[nbttaglist.tagCount()];
+ for(int i=0;i<nbttaglist.tagCount();i++){
+ NBTTagCompound nbt1 = nbttaglist.getCompoundTagAt(i);
+ magics[i]=(IMagicEnchant)Registry.GetMagic(nbt1.getString("MagicName")).getMagic(w, (EntityPlayer)e, false);
+ }
+
+ //2.ループする
+ Random rand=new Random();
+ IMagicEnchant.ParticleColor col;
+ for(int i=0;i<5;i++){
+ for(int k=0;k<8;k++){
+ col=magics[rand.nextInt(magics.length)].setParticleColor();
+ spawnParticle(w, e.posX, e.posY+e.getEyeHeight()/2, e.posZ, i, message.range, col.red, col.green, col.blue);
+ }
+ }
+ }
+ else{
+ //通常のやつ
+ for(int i=0;i<5;i++){
+ for(int k=0;k<8;k++){
+ spawnParticle(w, e.posX, e.posY+e.getEyeHeight()/2, e.posZ, i, message.range, 1.f, 1.f, 1.f);
+ }
+ }
+ }
+ }
+
+ if(e instanceof EntityMagicArrowFlexible){
+ ((EntityMagicArrowFlexible) e).shootingEntity=w.getEntityByID(message.shooterId);
+ ((EntityMagicArrowFlexible) e).readMagicsFromNBT(message.data);
+ }
+ }
+ return null;
+ }
+
+ @SideOnly(Side.CLIENT)
+ private void spawnParticle(World w, double x, double y, double z, int d, double r, float red, float green, float blue){
+ EntityVortexFX fx=new EntityVortexFX(w, x, y, z, d, r, red, green, blue, 1.f);
+ FMLClientHandler.instance().getClient().effectRenderer.addEffect(fx);
+ }
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/packet/MessagePlayerJoinInAnnouncement.class b/src/main/java/jp/plusplus/fbs/packet/MessagePlayerJoinInAnnouncement.class Binary files differnew file mode 100644 index 0000000..4585258 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/packet/MessagePlayerJoinInAnnouncement.class diff --git a/src/main/java/jp/plusplus/fbs/packet/MessagePlayerJoinInAnnouncement.java b/src/main/java/jp/plusplus/fbs/packet/MessagePlayerJoinInAnnouncement.java new file mode 100644 index 0000000..70c8ce8 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/packet/MessagePlayerJoinInAnnouncement.java @@ -0,0 +1,37 @@ +package jp.plusplus.fbs.packet;
+
+import cpw.mods.fml.common.network.ByteBufUtils;
+import cpw.mods.fml.common.network.simpleimpl.IMessage;
+import io.netty.buffer.ByteBuf;
+import net.minecraft.entity.player.EntityPlayer;
+
+/**
+ * Createdby pluslus_Fon 2015/06/05.
+ */
+public class MessagePlayerJoinInAnnouncement implements IMessage {
+
+ private String uuid;
+
+ public MessagePlayerJoinInAnnouncement(){}
+ public MessagePlayerJoinInAnnouncement(EntityPlayer player) {
+ this.uuid = player.getGameProfile().getId().toString();
+ }
+
+ @Override
+ public void fromBytes(ByteBuf buf) {
+ this.uuid = ByteBufUtils.readUTF8String(buf);
+ }
+
+ @Override
+ public void toBytes(ByteBuf buf) {
+ ByteBufUtils.writeUTF8String(buf, this.uuid);
+ }
+
+ public String getUuid() {
+ return uuid;
+ }
+
+ public void setUuid(String uuid) {
+ this.uuid = uuid;
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/packet/MessagePlayerJoinInAnoucementHandler.class b/src/main/java/jp/plusplus/fbs/packet/MessagePlayerJoinInAnoucementHandler.class Binary files differnew file mode 100644 index 0000000..439ffac --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/packet/MessagePlayerJoinInAnoucementHandler.class diff --git a/src/main/java/jp/plusplus/fbs/packet/MessagePlayerJoinInAnoucementHandler.java b/src/main/java/jp/plusplus/fbs/packet/MessagePlayerJoinInAnoucementHandler.java new file mode 100644 index 0000000..100f41b --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/packet/MessagePlayerJoinInAnoucementHandler.java @@ -0,0 +1,20 @@ +package jp.plusplus.fbs.packet;
+
+import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
+import cpw.mods.fml.common.network.simpleimpl.MessageContext;
+import net.minecraft.entity.player.EntityPlayer;
+
+/**
+ * Createdby pluslus_Fon 2015/06/05.
+ */
+public class MessagePlayerJoinInAnoucementHandler implements IMessageHandler<MessagePlayerJoinInAnnouncement, MessagePlayerProperties> {
+ @Override
+ public MessagePlayerProperties onMessage(MessagePlayerJoinInAnnouncement message, MessageContext ctx) {
+ String uuidString = message.getUuid();
+ EntityPlayer player = ctx.getServerHandler().playerEntity;
+ if (player.getGameProfile().getId().toString().equals(uuidString)) {
+ return new MessagePlayerProperties(player);
+ }
+ return null;
+ }
+}
\ No newline at end of file diff --git a/src/main/java/jp/plusplus/fbs/packet/MessagePlayerProperties.class b/src/main/java/jp/plusplus/fbs/packet/MessagePlayerProperties.class Binary files differnew file mode 100644 index 0000000..dd532b5 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/packet/MessagePlayerProperties.class diff --git a/src/main/java/jp/plusplus/fbs/packet/MessagePlayerProperties.java b/src/main/java/jp/plusplus/fbs/packet/MessagePlayerProperties.java new file mode 100644 index 0000000..7e1eefa --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/packet/MessagePlayerProperties.java @@ -0,0 +1,31 @@ +package jp.plusplus.fbs.packet;
+
+import cpw.mods.fml.common.network.ByteBufUtils;
+import cpw.mods.fml.common.network.simpleimpl.IMessage;
+import io.netty.buffer.ByteBuf;
+import jp.plusplus.fbs.exprop.FBSEntityProperties;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.nbt.NBTTagCompound;
+
+/**
+ * Createdby pluslus_Fon 2015/06/05.
+ */
+public class MessagePlayerProperties implements IMessage {
+ public NBTTagCompound data;
+
+ public MessagePlayerProperties(){}
+ public MessagePlayerProperties(EntityPlayer entityPlayer) {
+ this.data = new NBTTagCompound();
+ FBSEntityProperties.get(entityPlayer).saveNBTData(data);
+ }
+
+ @Override
+ public void fromBytes(ByteBuf buf) {
+ data = ByteBufUtils.readTag(buf);
+ }
+
+ @Override
+ public void toBytes(ByteBuf buf) {
+ ByteBufUtils.writeTag(buf, data);
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/packet/MessagePlayerPropertiesHandler.class b/src/main/java/jp/plusplus/fbs/packet/MessagePlayerPropertiesHandler.class Binary files differnew file mode 100644 index 0000000..41cc364 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/packet/MessagePlayerPropertiesHandler.class diff --git a/src/main/java/jp/plusplus/fbs/packet/MessagePlayerPropertiesHandler.java b/src/main/java/jp/plusplus/fbs/packet/MessagePlayerPropertiesHandler.java new file mode 100644 index 0000000..86cdc7c --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/packet/MessagePlayerPropertiesHandler.java @@ -0,0 +1,18 @@ +package jp.plusplus.fbs.packet;
+
+import cpw.mods.fml.common.network.simpleimpl.IMessage;
+import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
+import cpw.mods.fml.common.network.simpleimpl.MessageContext;
+import jp.plusplus.fbs.FBS;
+import jp.plusplus.fbs.exprop.FBSEntityProperties;
+
+/**
+ * Createdby pluslus_Fon 2015/06/05.
+ */
+public class MessagePlayerPropertiesHandler implements IMessageHandler<MessagePlayerProperties, IMessage> {
+ @Override
+ public IMessage onMessage(MessagePlayerProperties message, MessageContext ctx) {
+ FBSEntityProperties.get(FBS.proxy.getEntityPlayerInstance()).loadNBTData(message.data);
+ return null;
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/packet/MessageWish$Handler.class b/src/main/java/jp/plusplus/fbs/packet/MessageWish$Handler.class Binary files differnew file mode 100644 index 0000000..792663c --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/packet/MessageWish$Handler.class diff --git a/src/main/java/jp/plusplus/fbs/packet/MessageWish.class b/src/main/java/jp/plusplus/fbs/packet/MessageWish.class Binary files differnew file mode 100644 index 0000000..6822ac9 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/packet/MessageWish.class diff --git a/src/main/java/jp/plusplus/fbs/packet/MessageWish.java b/src/main/java/jp/plusplus/fbs/packet/MessageWish.java new file mode 100644 index 0000000..d9c6623 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/packet/MessageWish.java @@ -0,0 +1,42 @@ +package jp.plusplus.fbs.packet;
+
+import cpw.mods.fml.common.network.ByteBufUtils;
+import cpw.mods.fml.common.network.simpleimpl.IMessage;
+import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
+import cpw.mods.fml.common.network.simpleimpl.MessageContext;
+import io.netty.buffer.ByteBuf;
+import jp.plusplus.fbs.event.wish.WishHandler;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.network.play.client.C01PacketChatMessage;
+
+/**
+ * Created by plusplus_F on 2016/03/31.
+ */
+public class MessageWish implements IMessage {
+ public String wish;
+
+ public MessageWish(){}
+ public MessageWish(String wish){
+ this.wish=wish;
+ }
+
+ @Override
+ public void fromBytes(ByteBuf buf) {
+ wish=ByteBufUtils.readUTF8String(buf);
+ }
+
+ @Override
+ public void toBytes(ByteBuf buf) {
+ ByteBufUtils.writeUTF8String(buf, wish);
+ }
+
+ public static class Handler implements IMessageHandler<MessageWish, IMessage>{
+ @Override
+ public IMessage onMessage(MessageWish message, MessageContext ctx) {
+ EntityPlayer ep=ctx.getServerHandler().playerEntity;
+ ctx.getServerHandler().processChatMessage(new C01PacketChatMessage(message.wish+"!!!"));
+ WishHandler.handleWish(ep, message.wish);
+ return null;
+ }
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/packet/PacketHandler.class b/src/main/java/jp/plusplus/fbs/packet/PacketHandler.class Binary files differnew file mode 100644 index 0000000..530b3ec --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/packet/PacketHandler.class diff --git a/src/main/java/jp/plusplus/fbs/packet/PacketHandler.java b/src/main/java/jp/plusplus/fbs/packet/PacketHandler.java new file mode 100644 index 0000000..5fd2ce0 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/packet/PacketHandler.java @@ -0,0 +1,31 @@ +package jp.plusplus.fbs.packet;
+
+import cpw.mods.fml.common.network.NetworkRegistry;
+import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
+import cpw.mods.fml.relauncher.Side;
+import jp.plusplus.fbs.FBS;
+import jp.plusplus.fbs.storage.MessageMealTerminal;
+import jp.plusplus.fbs.storage.MessageMealTerminalScroll;
+
+/**
+ * Createdby pluslus_Fon 2015/06/05.
+ */
+public class PacketHandler {
+ public static final SimpleNetworkWrapper INSTANCE = NetworkRegistry.INSTANCE.newSimpleChannel(FBS.MODID);
+
+ public static void init() {
+ INSTANCE.registerMessage(MessagePlayerPropertiesHandler.class, MessagePlayerProperties.class, 0, Side.CLIENT);
+ INSTANCE.registerMessage(MessagePlayerJoinInAnoucementHandler.class, MessagePlayerJoinInAnnouncement.class, 1, Side.SERVER);
+ INSTANCE.registerMessage(MessageMagicFlexibleHandler.class, MessageMagicFlexible.class, 2, Side.CLIENT);
+ INSTANCE.registerMessage(MessageMagicVortex.Handler.class, MessageMagicVortex.class, 3, Side.CLIENT);
+ INSTANCE.registerMessage(MessageGuiButton.Handler.class, MessageGuiButton.class, 4, Side.SERVER);
+ INSTANCE.registerMessage(MessageGuiButtonWithString.Handler.class, MessageGuiButtonWithString.class, 5, Side.SERVER);
+ INSTANCE.registerMessage(MessageGuiButtonDecide.Handler.class, MessageGuiButtonDecide.class, 6, Side.SERVER);
+ INSTANCE.registerMessage(MessageGuiButtonWithNBT.Handler.class, MessageGuiButtonWithNBT.class, 7, Side.SERVER);
+ INSTANCE.registerMessage(MessageMealTerminal.Handler.class, MessageMealTerminal.class, 8, Side.SERVER);
+ INSTANCE.registerMessage(MessageMealTerminal.HandlerClient.class, MessageMealTerminal.class, 9, Side.CLIENT);
+ INSTANCE.registerMessage(MessageMealTerminalScroll.Handler.class, MessageMealTerminalScroll.class, 10, Side.SERVER);
+ INSTANCE.registerMessage(MessageWish.Handler.class, MessageWish.class, 11, Side.SERVER);
+
+ }
+}
|
