radar now gets damaged, huge refactor

This commit is contained in:
2024-08-12 15:24:53 +03:00
parent 47b227618a
commit 0ad5bebcd0
25 changed files with 250 additions and 90 deletions

View File

@@ -1,27 +1,20 @@
package com.lumijiez.lumiscope; package com.lumijiez.lumiscope;
import com.lumijiez.lumiscope.handlers.radar.LongRadarPacketHandler; import com.lumijiez.lumiscope.events.LumiEventHandler;
import com.lumijiez.lumiscope.handlers.radar.ShortRadarPacketHandler; import com.lumijiez.lumiscope.events.RadarEventHandler;
import com.lumijiez.lumiscope.handlers.RegistryHandler;
import com.lumijiez.lumiscope.proxy.CommonProxy;
import com.lumijiez.lumiscope.render.radar.LongRadarRenderer; import com.lumijiez.lumiscope.render.radar.LongRadarRenderer;
import com.lumijiez.lumiscope.render.radar.ShortRadarRenderer; import com.lumijiez.lumiscope.render.radar.ShortRadarRenderer;
import com.lumijiez.lumiscope.proxy.CommonProxy;
import com.lumijiez.lumiscope.util.Ref; import com.lumijiez.lumiscope.util.Ref;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraftforge.client.event.RenderLivingEvent;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import static com.lumijiez.lumiscope.util.Ref.logger; import static com.lumijiez.lumiscope.util.Ref.logger;
@@ -30,18 +23,13 @@ public class Lumiscope {
@SidedProxy(clientSide = Ref.CLIENT_PROXY_CLASS, serverSide = Ref.COMMON_PROXY_CLASS) @SidedProxy(clientSide = Ref.CLIENT_PROXY_CLASS, serverSide = Ref.COMMON_PROXY_CLASS)
public static CommonProxy proxy; public static CommonProxy proxy;
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onRenderNameTag(RenderLivingEvent.Specials.Pre<EntityLivingBase> event) {
if (event.getEntity() instanceof EntityPlayer) event.setCanceled(true);
}
@EventHandler @EventHandler
public void preInit(FMLPreInitializationEvent event) public void preInit(FMLPreInitializationEvent event)
{ {
MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(this);
ShortRadarPacketHandler.registerMessages(); MinecraftForge.EVENT_BUS.register(new LumiEventHandler());
LongRadarPacketHandler.registerMessages(); MinecraftForge.EVENT_BUS.register(new RadarEventHandler());
RegistryHandler.preInitRegistry();
} }
@EventHandler @EventHandler
@@ -56,16 +44,6 @@ public class Lumiscope {
@EventHandler @EventHandler
public void postInit(FMLPostInitializationEvent event) public void postInit(FMLPostInitializationEvent event)
{ {
logger.info("Radar turned on!"); logger.info("Initialized!");
}
@SubscribeEvent
public void onServerTick(TickEvent.ServerTickEvent event) {
if (event.phase == TickEvent.Phase.END) {
for (EntityPlayerMP player : FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().getPlayers()) {
ShortRadarPacketHandler.sendRadarUpdate(player);
LongRadarPacketHandler.sendRadarUpdate(player);
}
}
} }
} }

View File

@@ -0,0 +1,19 @@
package com.lumijiez.lumiscope.events;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.client.event.RenderLivingEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@Mod.EventBusSubscriber
public class LumiEventHandler {
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onRenderNameTag(RenderLivingEvent.Specials.Pre<EntityLivingBase> event) {
if (event.getEntity() instanceof EntityPlayer) event.setCanceled(true);
}
}

View File

@@ -0,0 +1,42 @@
package com.lumijiez.lumiscope.events;
import com.lumijiez.lumiscope.items.radars.LongRadar;
import com.lumijiez.lumiscope.items.radars.ShortRadar;
import com.lumijiez.lumiscope.network.handlers.LongRadarPacketHandler;
import com.lumijiez.lumiscope.network.handlers.ShortRadarPacketHandler;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import java.util.Random;
@Mod.EventBusSubscriber
public class RadarEventHandler {
Random RANDOM = new Random();
@SubscribeEvent
public void onPlayerTick(TickEvent.PlayerTickEvent event) {
if (event.phase == TickEvent.PlayerTickEvent.Phase.START) {
ItemStack heldItem = event.player.getHeldItemMainhand();
if (heldItem.getItem() instanceof ShortRadar || heldItem.getItem() instanceof LongRadar) {
if (!heldItem.isEmpty() && heldItem.isItemStackDamageable()) {
if (RANDOM.nextInt(100) < 5) {
heldItem.damageItem(1, event.player);
}
}
}
}
}
@SubscribeEvent
public void onServerTick(TickEvent.ServerTickEvent event) {
if (event.phase == TickEvent.Phase.END) {
for (EntityPlayerMP player : FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().getPlayers()) {
ShortRadarPacketHandler.sendRadarUpdate(player);
LongRadarPacketHandler.sendRadarUpdate(player);
}
}
}
}

View File

@@ -1,6 +1,9 @@
package com.lumijiez.lumiscope.handlers; package com.lumijiez.lumiscope.handlers;
import com.lumijiez.lumiscope.init.ModItems; import com.lumijiez.lumiscope.init.ModItems;
import com.lumijiez.lumiscope.network.handlers.LongRadarPacketHandler;
import com.lumijiez.lumiscope.network.handlers.ShortRadarPacketHandler;
import com.lumijiez.lumiscope.potions.PotionManager;
import com.lumijiez.lumiscope.util.IHasModel; import com.lumijiez.lumiscope.util.IHasModel;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraftforge.client.event.ModelRegistryEvent; import net.minecraftforge.client.event.ModelRegistryEvent;
@@ -23,4 +26,11 @@ public class RegistryHandler {
} }
} }
} }
public static void preInitRegistry() {
PotionManager.registerPotions();
ShortRadarPacketHandler.registerMessages();
LongRadarPacketHandler.registerMessages();
}
} }

View File

@@ -1,6 +1,7 @@
package com.lumijiez.lumiscope.init; package com.lumijiez.lumiscope.init;
import com.lumijiez.lumiscope.items.ItemBase; import com.lumijiez.lumiscope.items.ItemBase;
import com.lumijiez.lumiscope.items.PortableJammer;
import com.lumijiez.lumiscope.items.radars.LongRadar; import com.lumijiez.lumiscope.items.radars.LongRadar;
import com.lumijiez.lumiscope.items.radars.ShortRadar; import com.lumijiez.lumiscope.items.radars.ShortRadar;
import net.minecraft.item.Item; import net.minecraft.item.Item;
@@ -9,9 +10,11 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
public class ModItems { public class ModItems {
public static final List<Item> ITEMS = new ArrayList<Item>(); public static final List<Item> ITEMS = new ArrayList<>();
public static final Item shortRadar = new ShortRadar(); public static final Item shortRadar = new ShortRadar();
public static final Item longRadar = new LongRadar(); public static final Item longRadar = new LongRadar();
public static final Item portable_jammer = new PortableJammer();
public static final Item radarAntenna = new ItemBase("radar_antenna"); public static final Item radarAntenna = new ItemBase("radar_antenna");
public static final Item radarScreen = new ItemBase("radar_screen"); public static final Item radarScreen = new ItemBase("radar_screen");
} }

View File

@@ -0,0 +1,39 @@
package com.lumijiez.lumiscope.items;
import com.lumijiez.lumiscope.potions.PotionManager;
import mcp.MethodsReturnNonnullByDefault;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.world.World;
import javax.annotation.ParametersAreNonnullByDefault;
public class PortableJammer extends ItemBase {
public PortableJammer() {
super("portable_jammer");
setMaxStackSize(1);
setMaxDamage(5);
}
@Override
@ParametersAreNonnullByDefault
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) {
ItemStack itemStack = playerIn.getHeldItem(handIn);
if (!worldIn.isRemote) {
PotionEffect effect = new PotionEffect(PotionManager.JAMMERED_POTION_EFFECT, 24000, 0);
playerIn.addPotionEffect(effect);
itemStack.damageItem(1, playerIn);
playerIn.getCooldownTracker().setCooldown(this, 36000);
} else {
return new ActionResult<>(EnumActionResult.PASS, itemStack);
}
return new ActionResult<>(EnumActionResult.SUCCESS, itemStack);
}
}

View File

@@ -18,6 +18,7 @@ public class LongRadar extends ItemBase {
public LongRadar() { public LongRadar() {
super("long_radar"); super("long_radar");
setMaxStackSize(1); setMaxStackSize(1);
setMaxDamage(1000);
} }
@Override @Override
@@ -32,7 +33,7 @@ public class LongRadar extends ItemBase {
tooltip.add(warning.getFormattedText()); tooltip.add(warning.getFormattedText());
tooltip.add(new TextComponentString("Does not detect invisible players!") tooltip.add(new TextComponentString("Does not detect invisible players!")
.setStyle(new Style().setColor(TextFormatting.DARK_RED).setBold(true).setItalic(true)).getFormattedText()); .setStyle(new Style().setColor(TextFormatting.DARK_RED).setItalic(true)).getFormattedText());
super.addInformation(stack, worldIn, tooltip, flagIn); super.addInformation(stack, worldIn, tooltip, flagIn);

View File

@@ -16,6 +16,7 @@ public class ShortRadar extends ItemBase {
public ShortRadar() { public ShortRadar() {
super("short_radar"); super("short_radar");
setMaxStackSize(1); setMaxStackSize(1);
setMaxDamage(1000);
} }
@Override @Override

View File

@@ -1,7 +1,9 @@
package com.lumijiez.lumiscope.handlers.radar; package com.lumijiez.lumiscope.network.handlers;
import com.lumijiez.lumiscope.items.radars.LongRadar; import com.lumijiez.lumiscope.items.radars.LongRadar;
import com.lumijiez.lumiscope.network.LongRadarPacket; import com.lumijiez.lumiscope.network.packets.LongRadarPacket;
import com.lumijiez.lumiscope.network.records.PlayerInfo;
import com.lumijiez.lumiscope.potions.PotionManager;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraftforge.fml.common.network.NetworkRegistry; import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper; import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
@@ -21,8 +23,8 @@ public class LongRadarPacketHandler {
} }
public static void sendRadarUpdate(EntityPlayerMP player) { public static void sendRadarUpdate(EntityPlayerMP player) {
if (isHoldingLongRadar(player)) { if (isHoldingLongRadar(player) && !isJammered(player)) {
List<LongRadarPacket.PlayerInfo> playerInfos = getNearbyPlayersInfo(player); List<PlayerInfo> playerInfos = getNearbyPlayersInfo(player);
NETWORK_CHANNEL.sendTo(new LongRadarPacket(playerInfos), player); NETWORK_CHANNEL.sendTo(new LongRadarPacket(playerInfos), player);
} }
} }
@@ -31,10 +33,10 @@ public class LongRadarPacketHandler {
return player.getHeldItemMainhand().getItem() instanceof LongRadar; return player.getHeldItemMainhand().getItem() instanceof LongRadar;
} }
private static List<LongRadarPacket.PlayerInfo> getNearbyPlayersInfo(EntityPlayerMP player) { private static List<PlayerInfo> getNearbyPlayersInfo(EntityPlayerMP player) {
return Objects.requireNonNull(player.getServerWorld().getMinecraftServer()).getPlayerList().getPlayers().stream() return Objects.requireNonNull(player.getServerWorld().getMinecraftServer()).getPlayerList().getPlayers().stream()
.filter(otherPlayer -> shouldIncludePlayer(player, otherPlayer)) .filter(otherPlayer -> shouldIncludePlayer(player, otherPlayer))
.map(otherPlayer -> new LongRadarPacket.PlayerInfo( .map(otherPlayer -> new PlayerInfo(
otherPlayer.getName(), otherPlayer.getName(),
getPlayerDirectionLong(player, otherPlayer), getPlayerDirectionLong(player, otherPlayer),
player.getDistance(otherPlayer) player.getDistance(otherPlayer)
@@ -42,7 +44,13 @@ public class LongRadarPacketHandler {
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
private static boolean isJammered(EntityPlayerMP player) {
return player.isPotionActive(PotionManager.JAMMERED_POTION_EFFECT);
}
private static boolean shouldIncludePlayer(EntityPlayerMP player, EntityPlayerMP otherPlayer) { private static boolean shouldIncludePlayer(EntityPlayerMP player, EntityPlayerMP otherPlayer) {
return !otherPlayer.equals(player) && player.getDistance(otherPlayer) >= 300; return !otherPlayer.equals(player)
&& player.getDistance(otherPlayer) >= 300
&& !otherPlayer.isPotionActive(PotionManager.JAMMERED_POTION_EFFECT);
} }
} }

View File

@@ -1,7 +1,9 @@
package com.lumijiez.lumiscope.handlers.radar; package com.lumijiez.lumiscope.network.handlers;
import com.lumijiez.lumiscope.items.radars.ShortRadar; import com.lumijiez.lumiscope.items.radars.ShortRadar;
import com.lumijiez.lumiscope.network.ShortRadarPacket; import com.lumijiez.lumiscope.network.packets.ShortRadarPacket;
import com.lumijiez.lumiscope.network.records.PlayerInfo;
import com.lumijiez.lumiscope.potions.PotionManager;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.MobEffects; import net.minecraft.init.MobEffects;
import net.minecraftforge.fml.common.network.NetworkRegistry; import net.minecraftforge.fml.common.network.NetworkRegistry;
@@ -22,8 +24,8 @@ public class ShortRadarPacketHandler {
} }
public static void sendRadarUpdate(EntityPlayerMP player) { public static void sendRadarUpdate(EntityPlayerMP player) {
if (isHoldingShortRadar(player)) { if (isHoldingShortRadar(player) && !isJammered(player)) {
List<ShortRadarPacket.PlayerInfo> playerInfos = getNearbyPlayersInfo(player); List<PlayerInfo> playerInfos = getNearbyPlayersInfo(player);
NETWORK_CHANNEL.sendTo(new ShortRadarPacket(playerInfos), player); NETWORK_CHANNEL.sendTo(new ShortRadarPacket(playerInfos), player);
} }
} }
@@ -32,10 +34,14 @@ public class ShortRadarPacketHandler {
return player.getHeldItemMainhand().getItem() instanceof ShortRadar; return player.getHeldItemMainhand().getItem() instanceof ShortRadar;
} }
private static List<ShortRadarPacket.PlayerInfo> getNearbyPlayersInfo(EntityPlayerMP player) { private static boolean isJammered(EntityPlayerMP player) {
return player.isPotionActive(PotionManager.JAMMERED_POTION_EFFECT);
}
private static List<PlayerInfo> getNearbyPlayersInfo(EntityPlayerMP player) {
return Objects.requireNonNull(player.getServerWorld().getMinecraftServer()).getPlayerList().getPlayers().stream() return Objects.requireNonNull(player.getServerWorld().getMinecraftServer()).getPlayerList().getPlayers().stream()
.filter(otherPlayer -> shouldIncludePlayer(player, otherPlayer)) .filter(otherPlayer -> shouldIncludePlayer(player, otherPlayer))
.map(otherPlayer -> new ShortRadarPacket.PlayerInfo( .map(otherPlayer -> new PlayerInfo(
otherPlayer.getName(), otherPlayer.getName(),
getPlayerDirectionShort(player, otherPlayer), getPlayerDirectionShort(player, otherPlayer),
player.getDistance(otherPlayer) player.getDistance(otherPlayer)
@@ -46,6 +52,7 @@ public class ShortRadarPacketHandler {
private static boolean shouldIncludePlayer(EntityPlayerMP player, EntityPlayerMP otherPlayer) { private static boolean shouldIncludePlayer(EntityPlayerMP player, EntityPlayerMP otherPlayer) {
return !otherPlayer.equals(player) && return !otherPlayer.equals(player) &&
player.getDistance(otherPlayer) <= 100 && player.getDistance(otherPlayer) <= 100 &&
!player.isPotionActive(MobEffects.INVISIBILITY); !otherPlayer.isPotionActive(MobEffects.INVISIBILITY) &&
!otherPlayer.isPotionActive(PotionManager.JAMMERED_POTION_EFFECT);
} }
} }

View File

@@ -1,6 +1,8 @@
package com.lumijiez.lumiscope.network; package com.lumijiez.lumiscope.network.packets;
import com.lumijiez.lumiscope.network.records.PlayerInfo;
import com.lumijiez.lumiscope.render.radar.LongRadarRenderer; import com.lumijiez.lumiscope.render.radar.LongRadarRenderer;
import com.lumijiez.lumiscope.util.Ref;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
@@ -11,17 +13,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
public class LongRadarPacket implements IMessage { public class LongRadarPacket implements IMessage {
public static class PlayerInfo {
public String name;
public double direction;
public double distance;
public PlayerInfo(String name, double direction, double distance) {
this.name = "none";
this.direction = direction;
this.distance = 0;
}
}
private List<PlayerInfo> playerInfos; private List<PlayerInfo> playerInfos;
@@ -66,6 +57,7 @@ public class LongRadarPacket implements IMessage {
Minecraft.getMinecraft().addScheduledTask(() -> { Minecraft.getMinecraft().addScheduledTask(() -> {
LongRadarRenderer renderer = LongRadarRenderer.getInstance(); LongRadarRenderer renderer = LongRadarRenderer.getInstance();
renderer.updatePlayerInfos(message.playerInfos); renderer.updatePlayerInfos(message.playerInfos);
Ref.logger.info("RECEIVED LONG PACKET");
}); });
return null; return null;
} }

View File

@@ -1,6 +1,8 @@
package com.lumijiez.lumiscope.network; package com.lumijiez.lumiscope.network.packets;
import com.lumijiez.lumiscope.network.records.PlayerInfo;
import com.lumijiez.lumiscope.render.radar.ShortRadarRenderer; import com.lumijiez.lumiscope.render.radar.ShortRadarRenderer;
import com.lumijiez.lumiscope.util.Ref;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
@@ -11,18 +13,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
public class ShortRadarPacket implements IMessage { public class ShortRadarPacket implements IMessage {
public static class PlayerInfo {
public String name;
public double direction;
public double distance;
public PlayerInfo(String name, double direction, double distance) {
this.name = name;
this.direction = direction;
this.distance = distance;
}
}
private List<PlayerInfo> playerInfos; private List<PlayerInfo> playerInfos;
public ShortRadarPacket() { public ShortRadarPacket() {
@@ -66,6 +56,7 @@ public class ShortRadarPacket implements IMessage {
Minecraft.getMinecraft().addScheduledTask(() -> { Minecraft.getMinecraft().addScheduledTask(() -> {
ShortRadarRenderer renderer = ShortRadarRenderer.getInstance(); ShortRadarRenderer renderer = ShortRadarRenderer.getInstance();
renderer.updatePlayerInfos(message.playerInfos); renderer.updatePlayerInfos(message.playerInfos);
Ref.logger.info("RECEIVED SHORT PACKET");
}); });
return null; return null;
} }

View File

@@ -0,0 +1,19 @@
package com.lumijiez.lumiscope.network.records;
public class PlayerInfo {
public String name;
public double direction;
public double distance;
public PlayerInfo(String name, double direction, double distance) {
this.name = name;
this.direction = direction;
this.distance = distance;
}
public PlayerInfo(double direction) {
this.name = "none";
this.direction = direction;
this.distance = 0;
}
}

View File

@@ -0,0 +1,25 @@
package com.lumijiez.lumiscope.potions;
import com.lumijiez.lumiscope.util.Ref;
import net.minecraft.client.Minecraft;
import net.minecraft.potion.Potion;
import net.minecraft.util.ResourceLocation;
public class CustomPotion extends Potion {
public CustomPotion(String registryName, int indexStart, int indexFinal, boolean isBad, int color) {
super(isBad, color);
setRegistryName(registryName);
setPotionName("effect." + registryName);
setIconIndex(indexStart, indexFinal);
}
@Override
public boolean hasStatusIcon() {
Minecraft
.getMinecraft()
.getTextureManager()
.bindTexture(new ResourceLocation(Ref.MODID , "textures/gui/potions/potion_effects.png"));
return true;
}
}

View File

@@ -0,0 +1,16 @@
package com.lumijiez.lumiscope.potions;
import net.minecraft.potion.Potion;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
public class PotionManager {
public static final Potion JAMMERED_POTION_EFFECT = new CustomPotion("jammered", 0, 0, false, 0x006400);
public static void registerPotions() {
registerPotion(JAMMERED_POTION_EFFECT);
}
private static void registerPotion(Potion effect) {
ForgeRegistries.POTIONS.register(effect);
}
}

View File

@@ -1,5 +1,6 @@
package com.lumijiez.lumiscope.render.radar; package com.lumijiez.lumiscope.render.radar;
import com.lumijiez.lumiscope.network.records.PlayerInfo;
import com.lumijiez.lumiscope.util.GLHelper; import com.lumijiez.lumiscope.util.GLHelper;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
@@ -8,22 +9,22 @@ import org.lwjgl.opengl.GL11;
import java.util.List; import java.util.List;
public abstract class BaseRadarRenderer<T> { public abstract class BaseRadarRenderer {
protected static final Minecraft mc = Minecraft.getMinecraft(); protected static final Minecraft mc = Minecraft.getMinecraft();
protected final ResourceLocation radarTexture = new ResourceLocation("lumiscope", "textures/gui/radar.png"); protected final ResourceLocation radarTexture = new ResourceLocation("lumiscope", "textures/gui/radar.png");
protected final ResourceLocation radarArrowTexture = new ResourceLocation("lumiscope", "textures/gui/radar_arrow.png"); protected final ResourceLocation radarArrowTexture = new ResourceLocation("lumiscope", "textures/gui/radar_arrow.png");
protected List<T> playerInfos; protected List<PlayerInfo> playerInfos;
protected abstract void drawTexturedCircle(float radius); protected abstract void drawTexturedCircle(float radius);
protected abstract void drawTexturedLine(float length, double angle); protected abstract void drawTexturedLine(float length, double angle);
protected abstract double getDirection(T info); protected abstract double getDirection(PlayerInfo info);
protected abstract boolean shouldRenderRadar(); protected abstract boolean shouldRenderRadar();
public void updatePlayerInfos(List<T> playerInfos) { public void updatePlayerInfos(List<PlayerInfo> playerInfos) {
this.playerInfos = playerInfos; this.playerInfos = playerInfos;
} }
@@ -36,7 +37,7 @@ public abstract class BaseRadarRenderer<T> {
GLHelper.setupForRadarRendering(); GLHelper.setupForRadarRendering();
drawTexturedCircle(1.4f); drawTexturedCircle(1.4f);
for (T info : playerInfos) { for (PlayerInfo info : playerInfos) {
double angle = getDirection(info) - Math.toRadians(90); double angle = getDirection(info) - Math.toRadians(90);
drawTexturedLine(1.4f, angle); drawTexturedLine(1.4f, angle);
} }

View File

@@ -1,7 +1,7 @@
package com.lumijiez.lumiscope.render.radar; package com.lumijiez.lumiscope.render.radar;
import com.lumijiez.lumiscope.items.radars.LongRadar; import com.lumijiez.lumiscope.items.radars.LongRadar;
import com.lumijiez.lumiscope.network.LongRadarPacket; import com.lumijiez.lumiscope.network.records.PlayerInfo;
import net.minecraftforge.client.event.RenderHandEvent; import net.minecraftforge.client.event.RenderHandEvent;
import net.minecraftforge.client.event.RenderWorldLastEvent; import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
@@ -9,7 +9,7 @@ import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public class LongRadarRenderer extends BaseRadarRenderer<LongRadarPacket.PlayerInfo> { public class LongRadarRenderer extends BaseRadarRenderer {
private static final LongRadarRenderer INSTANCE = new LongRadarRenderer(); private static final LongRadarRenderer INSTANCE = new LongRadarRenderer();
private LongRadarRenderer() {} private LongRadarRenderer() {}
@@ -51,7 +51,7 @@ public class LongRadarRenderer extends BaseRadarRenderer<LongRadarPacket.PlayerI
} }
@Override @Override
protected double getDirection(LongRadarPacket.PlayerInfo info) { protected double getDirection(PlayerInfo info) {
return info.direction; return info.direction;
} }
} }

View File

@@ -1,7 +1,7 @@
package com.lumijiez.lumiscope.render.radar; package com.lumijiez.lumiscope.render.radar;
import com.lumijiez.lumiscope.items.radars.ShortRadar; import com.lumijiez.lumiscope.items.radars.ShortRadar;
import com.lumijiez.lumiscope.network.ShortRadarPacket; import com.lumijiez.lumiscope.network.records.PlayerInfo;
import com.lumijiez.lumiscope.util.CustomMath; import com.lumijiez.lumiscope.util.CustomMath;
import com.lumijiez.lumiscope.util.GLHelper; import com.lumijiez.lumiscope.util.GLHelper;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
@@ -12,7 +12,7 @@ import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public class ShortRadarRenderer extends BaseRadarRenderer<ShortRadarPacket.PlayerInfo> { public class ShortRadarRenderer extends BaseRadarRenderer {
private static final ShortRadarRenderer INSTANCE = new ShortRadarRenderer(); private static final ShortRadarRenderer INSTANCE = new ShortRadarRenderer();
private ShortRadarRenderer() {} private ShortRadarRenderer() {}
@@ -47,14 +47,14 @@ public class ShortRadarRenderer extends BaseRadarRenderer<ShortRadarPacket.Playe
GLHelper.setupForRadarRendering(); GLHelper.setupForRadarRendering();
drawTexturedCircle(1.4f); drawTexturedCircle(1.4f);
for (ShortRadarPacket.PlayerInfo info : playerInfos) { for (PlayerInfo info : playerInfos) {
double angle = getDirection(info) - Math.toRadians(90); double angle = getDirection(info) - Math.toRadians(90);
drawTexturedLine(1.4f, angle); drawTexturedLine(1.4f, angle);
} }
GLHelper.setupForTextRendering(); GLHelper.setupForTextRendering();
for (ShortRadarPacket.PlayerInfo info : playerInfos) { for (PlayerInfo info : playerInfos) {
double angle = info.direction - Math.toRadians(90); double angle = info.direction - Math.toRadians(90);
GlStateManager.pushMatrix(); GlStateManager.pushMatrix();
GlStateManager.translate((float) (Math.cos(angle) * 1.2), 0.001, (float) (Math.sin(angle) * 1.2)); GlStateManager.translate((float) (Math.cos(angle) * 1.2), 0.001, (float) (Math.sin(angle) * 1.2));
@@ -91,7 +91,7 @@ public class ShortRadarRenderer extends BaseRadarRenderer<ShortRadarPacket.Playe
} }
@Override @Override
protected double getDirection(ShortRadarPacket.PlayerInfo info) { protected double getDirection(PlayerInfo info) {
return info.direction; return info.direction;
} }
} }

View File

@@ -2,3 +2,5 @@ item.short_radar.name=Short Distance Radar
item.long_radar.name=Long Distance Radar item.long_radar.name=Long Distance Radar
item.radar_antenna.name=Radar Antenna item.radar_antenna.name=Radar Antenna
item.radar_screen.name=Radar Screen item.radar_screen.name=Radar Screen
item.portable_jammer=Portable Jammer
effect.jammered=Jammered

View File

@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "lumiscope:items/portable_jammer"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 243 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 598 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 682 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 255 B

After

Width:  |  Height:  |  Size: 495 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 184 B

After

Width:  |  Height:  |  Size: 881 B