Advertisement
Guest User

Untitled

a guest
Jul 4th, 2015
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.00 KB | None | 0 0
  1. package net.boreeas.lively.runeforge.render;
  2.  
  3. import cpw.mods.fml.common.eventhandler.SubscribeEvent;
  4. import cpw.mods.fml.common.network.simpleimpl.IMessage;
  5. import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
  6. import cpw.mods.fml.common.network.simpleimpl.MessageContext;
  7. import net.boreeas.lively.Lively;
  8. import net.boreeas.lively.runeforge.messages.RemoveActiveLightRune;
  9. import net.boreeas.lively.runeforge.messages.AddActiveLightRune;
  10. import net.boreeas.lively.runeforge.messages.RenderList;
  11. import net.boreeas.lively.util.Vec3Int;
  12. import net.minecraftforge.client.event.RenderWorldLastEvent;
  13. import org.jetbrains.annotations.NotNull;
  14. import org.lwjgl.opengl.GL11;
  15. import org.lwjgl.util.glu.Sphere;
  16.  
  17. import java.util.HashSet;
  18. import java.util.Set;
  19.  
  20. /**
  21.  *
  22.  */
  23. public class ClientRenderHandler {
  24.  
  25.     private static final Sphere sphere = new Sphere();
  26.  
  27.     private Set<Vec3Int> lightRuneFXs = new HashSet<>();
  28.  
  29.     public void addLightRuneFx(@NotNull Vec3Int pos) {
  30.         lightRuneFXs.add(pos);
  31.     }
  32.  
  33.     public void removeLightRuneFx(@NotNull Vec3Int pos) {
  34.         lightRuneFXs.remove(pos);
  35.     }
  36.  
  37.     @SubscribeEvent
  38.     public void renderWorldLast(RenderWorldLastEvent evt) {
  39.         lightRuneFXs.forEach(this::renderLightRuneFx);
  40.     }
  41.  
  42.     private void renderLightRuneFx(Vec3Int coord) {
  43.         GL11.glPushMatrix();
  44.         GL11.glTranslated(coord.x + 0.5, coord.y + 0.5, coord.z + 0.5);
  45.         GL11.glColor3b(((byte) 100), ((byte) 100), ((byte) 0));
  46.  
  47.         System.out.println("render at " + coord);
  48.         sphere.draw(3, 12, 6);
  49.  
  50.         GL11.glPopMatrix();
  51.     }
  52.  
  53.  
  54.  
  55.  
  56.     public static class RenderListMessageHandler implements IMessageHandler<RenderList, IMessage> {
  57.         @Override
  58.         public IMessage onMessage(RenderList renderList, MessageContext messageContext) {
  59.             System.out.println("Received initial locations: " + renderList.getActiveLightRuneLocations());
  60.             Lively.INSTANCE.clientRenderHandler.lightRuneFXs = renderList.getActiveLightRuneLocations();
  61.  
  62.             return null; // no response
  63.         }
  64.     }
  65.  
  66.     public static class AddLightRuneHandler implements IMessageHandler<AddActiveLightRune, IMessage> {
  67.  
  68.         @Override
  69.         public IMessage onMessage(AddActiveLightRune addActiveLightRune, MessageContext messageContext) {
  70.             System.out.println("New rune at " + addActiveLightRune.getLoc());
  71.             Lively.INSTANCE.clientRenderHandler.lightRuneFXs.add(addActiveLightRune.getLoc());
  72.  
  73.             return null;
  74.         }
  75.     }
  76.  
  77.     public static class RemoveLightRuneHandler implements IMessageHandler<RemoveActiveLightRune, IMessage> {
  78.  
  79.         @Override
  80.         public IMessage onMessage(RemoveActiveLightRune removeActiveLightRune, MessageContext messageContext) {
  81.             System.out.println("Remove rune at " + removeActiveLightRune.getLoc());
  82.             Lively.INSTANCE.clientRenderHandler.lightRuneFXs.remove(removeActiveLightRune.getLoc());
  83.  
  84.             return null;
  85.         }
  86.     }
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement