Created
July 4, 2014 21:14
-
-
Save WillR27/2b89357f27fcdb27e020 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.blocklings.network; | |
import io.netty.buffer.ByteBuf; | |
import io.netty.buffer.ByteBufInputStream; | |
import java.io.IOException; | |
import net.minecraft.client.Minecraft; | |
import net.minecraft.entity.Entity; | |
import net.minecraft.world.World; | |
import com.blocklings.entity.EntityBlockling; | |
import com.blocklings.main.Blocklings; | |
import cpw.mods.fml.relauncher.Side; | |
import cpw.mods.fml.relauncher.SideOnly; | |
public class ProcessPacketClientSide { | |
public ProcessPacketClientSide() { | |
} | |
@SideOnly(Side.CLIENT) | |
public static void processPacketOnClient(ByteBuf parBB, Side parSide) throws IOException { | |
if (parSide == Side.CLIENT) { | |
World world = Minecraft.getMinecraft().theWorld; | |
ByteBufInputStream bbis = new ByteBufInputStream(parBB); | |
int packetTypeID = bbis.readInt(); | |
switch (packetTypeID) { | |
case Blocklings.PACKET_TYPE_ENTITY_SYNC: | |
{ | |
int entityID = bbis.readInt(); | |
Entity foundEntity = world.getEntityByID(entityID); | |
if (foundEntity != null) { | |
} else { | |
} | |
if (foundEntity instanceof EntityBlockling) { | |
EntityBlockling blockling = (EntityBlockling) foundEntity; | |
blockling.setLevel(bbis.readInt()); | |
blockling.setCurrentUpgradeTier(bbis.readInt()); | |
blockling.setAttackTimer(bbis.readFloat()); | |
} | |
break; | |
} | |
} | |
bbis.close(); | |
} | |
} | |
public static Entity getEntityByID(int entityID, World world) { | |
for (Object o : world.getLoadedEntityList()) { | |
if (((Entity) o).getEntityId() == entityID) { | |
return ((Entity) o); | |
} | |
} | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment