From 0ad5bebcd00574c70d13545c40bff136209f0e73 Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 12 Aug 2024 15:24:53 +0300 Subject: [PATCH] radar now gets damaged, huge refactor --- .../com/lumijiez/lumiscope/Lumiscope.java | 38 ++++------------ .../lumiscope/events/LumiEventHandler.java | 19 ++++++++ .../lumiscope/events/RadarEventHandler.java | 42 ++++++++++++++++++ .../lumiscope/handlers/RegistryHandler.java | 10 +++++ .../com/lumijiez/lumiscope/init/ModItems.java | 5 ++- .../lumiscope/items/PortableJammer.java | 39 ++++++++++++++++ .../lumiscope/items/radars/LongRadar.java | 3 +- .../lumiscope/items/radars/ShortRadar.java | 1 + .../handlers}/LongRadarPacketHandler.java | 26 +++++++---- .../handlers}/ShortRadarPacketHandler.java | 23 ++++++---- .../{ => packets}/LongRadarPacket.java | 18 +++----- .../{ => packets}/ShortRadarPacket.java | 19 +++----- .../lumiscope/network/records/PlayerInfo.java | 19 ++++++++ .../lumiscope/potions/CustomPotion.java | 25 +++++++++++ .../lumiscope/potions/PotionManager.java | 16 +++++++ .../render/radar/BaseRadarRenderer.java | 11 ++--- .../render/radar/LongRadarRenderer.java | 6 +-- .../render/radar/ShortRadarRenderer.java | 10 ++--- .../assets/lumiscope/lang/en_us.lang | 4 +- .../models/item/portable_jammer.json | 6 +++ .../textures/gui/potions/jammered.png | Bin 0 -> 243 bytes .../textures/gui/potions/potion_effects.png | Bin 0 -> 598 bytes .../textures/items/portable_jammer.png | Bin 0 -> 682 bytes .../textures/items/radar_antenna.png | Bin 255 -> 495 bytes .../lumiscope/textures/items/radar_screen.png | Bin 184 -> 881 bytes 25 files changed, 250 insertions(+), 90 deletions(-) create mode 100644 src/main/java/com/lumijiez/lumiscope/events/LumiEventHandler.java create mode 100644 src/main/java/com/lumijiez/lumiscope/events/RadarEventHandler.java create mode 100644 src/main/java/com/lumijiez/lumiscope/items/PortableJammer.java rename src/main/java/com/lumijiez/lumiscope/{handlers/radar => network/handlers}/LongRadarPacketHandler.java (66%) rename src/main/java/com/lumijiez/lumiscope/{handlers/radar => network/handlers}/ShortRadarPacketHandler.java (69%) rename src/main/java/com/lumijiez/lumiscope/network/{ => packets}/LongRadarPacket.java (84%) rename src/main/java/com/lumijiez/lumiscope/network/{ => packets}/ShortRadarPacket.java (84%) create mode 100644 src/main/java/com/lumijiez/lumiscope/network/records/PlayerInfo.java create mode 100644 src/main/java/com/lumijiez/lumiscope/potions/CustomPotion.java create mode 100644 src/main/java/com/lumijiez/lumiscope/potions/PotionManager.java create mode 100644 src/main/resources/assets/lumiscope/models/item/portable_jammer.json create mode 100644 src/main/resources/assets/lumiscope/textures/gui/potions/jammered.png create mode 100644 src/main/resources/assets/lumiscope/textures/gui/potions/potion_effects.png create mode 100644 src/main/resources/assets/lumiscope/textures/items/portable_jammer.png diff --git a/src/main/java/com/lumijiez/lumiscope/Lumiscope.java b/src/main/java/com/lumijiez/lumiscope/Lumiscope.java index 9a22b13..f9e0636 100644 --- a/src/main/java/com/lumijiez/lumiscope/Lumiscope.java +++ b/src/main/java/com/lumijiez/lumiscope/Lumiscope.java @@ -1,27 +1,20 @@ package com.lumijiez.lumiscope; -import com.lumijiez.lumiscope.handlers.radar.LongRadarPacketHandler; -import com.lumijiez.lumiscope.handlers.radar.ShortRadarPacketHandler; +import com.lumijiez.lumiscope.events.LumiEventHandler; +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.ShortRadarRenderer; -import com.lumijiez.lumiscope.proxy.CommonProxy; 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.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; 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.SideOnly; 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) public static CommonProxy proxy; - @SideOnly(Side.CLIENT) - @SubscribeEvent - public void onRenderNameTag(RenderLivingEvent.Specials.Pre event) { - if (event.getEntity() instanceof EntityPlayer) event.setCanceled(true); - } - @EventHandler public void preInit(FMLPreInitializationEvent event) { MinecraftForge.EVENT_BUS.register(this); - ShortRadarPacketHandler.registerMessages(); - LongRadarPacketHandler.registerMessages(); + MinecraftForge.EVENT_BUS.register(new LumiEventHandler()); + MinecraftForge.EVENT_BUS.register(new RadarEventHandler()); + RegistryHandler.preInitRegistry(); } @EventHandler @@ -56,16 +44,6 @@ public class Lumiscope { @EventHandler public void postInit(FMLPostInitializationEvent event) { - logger.info("Radar turned on!"); - } - - @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); - } - } + logger.info("Initialized!"); } } diff --git a/src/main/java/com/lumijiez/lumiscope/events/LumiEventHandler.java b/src/main/java/com/lumijiez/lumiscope/events/LumiEventHandler.java new file mode 100644 index 0000000..de8637d --- /dev/null +++ b/src/main/java/com/lumijiez/lumiscope/events/LumiEventHandler.java @@ -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 event) { + if (event.getEntity() instanceof EntityPlayer) event.setCanceled(true); + } +} diff --git a/src/main/java/com/lumijiez/lumiscope/events/RadarEventHandler.java b/src/main/java/com/lumijiez/lumiscope/events/RadarEventHandler.java new file mode 100644 index 0000000..09016d9 --- /dev/null +++ b/src/main/java/com/lumijiez/lumiscope/events/RadarEventHandler.java @@ -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); + } + } + } +} diff --git a/src/main/java/com/lumijiez/lumiscope/handlers/RegistryHandler.java b/src/main/java/com/lumijiez/lumiscope/handlers/RegistryHandler.java index c36522e..9d41600 100644 --- a/src/main/java/com/lumijiez/lumiscope/handlers/RegistryHandler.java +++ b/src/main/java/com/lumijiez/lumiscope/handlers/RegistryHandler.java @@ -1,6 +1,9 @@ package com.lumijiez.lumiscope.handlers; 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 net.minecraft.item.Item; import net.minecraftforge.client.event.ModelRegistryEvent; @@ -23,4 +26,11 @@ public class RegistryHandler { } } } + + public static void preInitRegistry() { + PotionManager.registerPotions(); + + ShortRadarPacketHandler.registerMessages(); + LongRadarPacketHandler.registerMessages(); + } } diff --git a/src/main/java/com/lumijiez/lumiscope/init/ModItems.java b/src/main/java/com/lumijiez/lumiscope/init/ModItems.java index 1d92359..310036d 100644 --- a/src/main/java/com/lumijiez/lumiscope/init/ModItems.java +++ b/src/main/java/com/lumijiez/lumiscope/init/ModItems.java @@ -1,6 +1,7 @@ package com.lumijiez.lumiscope.init; 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.ShortRadar; import net.minecraft.item.Item; @@ -9,9 +10,11 @@ import java.util.ArrayList; import java.util.List; public class ModItems { - public static final List ITEMS = new ArrayList(); + public static final List ITEMS = new ArrayList<>(); public static final Item shortRadar = new ShortRadar(); 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 radarScreen = new ItemBase("radar_screen"); + } diff --git a/src/main/java/com/lumijiez/lumiscope/items/PortableJammer.java b/src/main/java/com/lumijiez/lumiscope/items/PortableJammer.java new file mode 100644 index 0000000..dea1886 --- /dev/null +++ b/src/main/java/com/lumijiez/lumiscope/items/PortableJammer.java @@ -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 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); + } +} diff --git a/src/main/java/com/lumijiez/lumiscope/items/radars/LongRadar.java b/src/main/java/com/lumijiez/lumiscope/items/radars/LongRadar.java index 7bf63a9..2234db3 100644 --- a/src/main/java/com/lumijiez/lumiscope/items/radars/LongRadar.java +++ b/src/main/java/com/lumijiez/lumiscope/items/radars/LongRadar.java @@ -18,6 +18,7 @@ public class LongRadar extends ItemBase { public LongRadar() { super("long_radar"); setMaxStackSize(1); + setMaxDamage(1000); } @Override @@ -32,7 +33,7 @@ public class LongRadar extends ItemBase { tooltip.add(warning.getFormattedText()); 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); diff --git a/src/main/java/com/lumijiez/lumiscope/items/radars/ShortRadar.java b/src/main/java/com/lumijiez/lumiscope/items/radars/ShortRadar.java index 4b098c7..97aca62 100644 --- a/src/main/java/com/lumijiez/lumiscope/items/radars/ShortRadar.java +++ b/src/main/java/com/lumijiez/lumiscope/items/radars/ShortRadar.java @@ -16,6 +16,7 @@ public class ShortRadar extends ItemBase { public ShortRadar() { super("short_radar"); setMaxStackSize(1); + setMaxDamage(1000); } @Override diff --git a/src/main/java/com/lumijiez/lumiscope/handlers/radar/LongRadarPacketHandler.java b/src/main/java/com/lumijiez/lumiscope/network/handlers/LongRadarPacketHandler.java similarity index 66% rename from src/main/java/com/lumijiez/lumiscope/handlers/radar/LongRadarPacketHandler.java rename to src/main/java/com/lumijiez/lumiscope/network/handlers/LongRadarPacketHandler.java index a6058c4..c8904f0 100644 --- a/src/main/java/com/lumijiez/lumiscope/handlers/radar/LongRadarPacketHandler.java +++ b/src/main/java/com/lumijiez/lumiscope/network/handlers/LongRadarPacketHandler.java @@ -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.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.minecraftforge.fml.common.network.NetworkRegistry; import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper; @@ -21,8 +23,8 @@ public class LongRadarPacketHandler { } public static void sendRadarUpdate(EntityPlayerMP player) { - if (isHoldingLongRadar(player)) { - List playerInfos = getNearbyPlayersInfo(player); + if (isHoldingLongRadar(player) && !isJammered(player)) { + List playerInfos = getNearbyPlayersInfo(player); NETWORK_CHANNEL.sendTo(new LongRadarPacket(playerInfos), player); } } @@ -31,10 +33,10 @@ public class LongRadarPacketHandler { return player.getHeldItemMainhand().getItem() instanceof LongRadar; } - private static List getNearbyPlayersInfo(EntityPlayerMP player) { + private static List getNearbyPlayersInfo(EntityPlayerMP player) { return Objects.requireNonNull(player.getServerWorld().getMinecraftServer()).getPlayerList().getPlayers().stream() .filter(otherPlayer -> shouldIncludePlayer(player, otherPlayer)) - .map(otherPlayer -> new LongRadarPacket.PlayerInfo( + .map(otherPlayer -> new PlayerInfo( otherPlayer.getName(), getPlayerDirectionLong(player, otherPlayer), player.getDistance(otherPlayer) @@ -42,7 +44,13 @@ public class LongRadarPacketHandler { .collect(Collectors.toList()); } - private static boolean shouldIncludePlayer(EntityPlayerMP player, EntityPlayerMP otherPlayer) { - return !otherPlayer.equals(player) && player.getDistance(otherPlayer) >= 300; + private static boolean isJammered(EntityPlayerMP player) { + return player.isPotionActive(PotionManager.JAMMERED_POTION_EFFECT); } -} + + private static boolean shouldIncludePlayer(EntityPlayerMP player, EntityPlayerMP otherPlayer) { + return !otherPlayer.equals(player) + && player.getDistance(otherPlayer) >= 300 + && !otherPlayer.isPotionActive(PotionManager.JAMMERED_POTION_EFFECT); + } +} \ No newline at end of file diff --git a/src/main/java/com/lumijiez/lumiscope/handlers/radar/ShortRadarPacketHandler.java b/src/main/java/com/lumijiez/lumiscope/network/handlers/ShortRadarPacketHandler.java similarity index 69% rename from src/main/java/com/lumijiez/lumiscope/handlers/radar/ShortRadarPacketHandler.java rename to src/main/java/com/lumijiez/lumiscope/network/handlers/ShortRadarPacketHandler.java index cd008e7..a3d9c61 100644 --- a/src/main/java/com/lumijiez/lumiscope/handlers/radar/ShortRadarPacketHandler.java +++ b/src/main/java/com/lumijiez/lumiscope/network/handlers/ShortRadarPacketHandler.java @@ -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.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.init.MobEffects; import net.minecraftforge.fml.common.network.NetworkRegistry; @@ -22,8 +24,8 @@ public class ShortRadarPacketHandler { } public static void sendRadarUpdate(EntityPlayerMP player) { - if (isHoldingShortRadar(player)) { - List playerInfos = getNearbyPlayersInfo(player); + if (isHoldingShortRadar(player) && !isJammered(player)) { + List playerInfos = getNearbyPlayersInfo(player); NETWORK_CHANNEL.sendTo(new ShortRadarPacket(playerInfos), player); } } @@ -32,10 +34,14 @@ public class ShortRadarPacketHandler { return player.getHeldItemMainhand().getItem() instanceof ShortRadar; } - private static List getNearbyPlayersInfo(EntityPlayerMP player) { + private static boolean isJammered(EntityPlayerMP player) { + return player.isPotionActive(PotionManager.JAMMERED_POTION_EFFECT); + } + + private static List getNearbyPlayersInfo(EntityPlayerMP player) { return Objects.requireNonNull(player.getServerWorld().getMinecraftServer()).getPlayerList().getPlayers().stream() .filter(otherPlayer -> shouldIncludePlayer(player, otherPlayer)) - .map(otherPlayer -> new ShortRadarPacket.PlayerInfo( + .map(otherPlayer -> new PlayerInfo( otherPlayer.getName(), getPlayerDirectionShort(player, otherPlayer), player.getDistance(otherPlayer) @@ -46,6 +52,7 @@ public class ShortRadarPacketHandler { private static boolean shouldIncludePlayer(EntityPlayerMP player, EntityPlayerMP otherPlayer) { return !otherPlayer.equals(player) && player.getDistance(otherPlayer) <= 100 && - !player.isPotionActive(MobEffects.INVISIBILITY); + !otherPlayer.isPotionActive(MobEffects.INVISIBILITY) && + !otherPlayer.isPotionActive(PotionManager.JAMMERED_POTION_EFFECT); } -} +} \ No newline at end of file diff --git a/src/main/java/com/lumijiez/lumiscope/network/LongRadarPacket.java b/src/main/java/com/lumijiez/lumiscope/network/packets/LongRadarPacket.java similarity index 84% rename from src/main/java/com/lumijiez/lumiscope/network/LongRadarPacket.java rename to src/main/java/com/lumijiez/lumiscope/network/packets/LongRadarPacket.java index 588fc77..80cfa15 100644 --- a/src/main/java/com/lumijiez/lumiscope/network/LongRadarPacket.java +++ b/src/main/java/com/lumijiez/lumiscope/network/packets/LongRadarPacket.java @@ -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.util.Ref; import io.netty.buffer.ByteBuf; import net.minecraft.client.Minecraft; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; @@ -11,17 +13,6 @@ import java.util.ArrayList; import java.util.List; 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 playerInfos; @@ -66,8 +57,9 @@ public class LongRadarPacket implements IMessage { Minecraft.getMinecraft().addScheduledTask(() -> { LongRadarRenderer renderer = LongRadarRenderer.getInstance(); renderer.updatePlayerInfos(message.playerInfos); + Ref.logger.info("RECEIVED LONG PACKET"); }); return null; } } -} +} \ No newline at end of file diff --git a/src/main/java/com/lumijiez/lumiscope/network/ShortRadarPacket.java b/src/main/java/com/lumijiez/lumiscope/network/packets/ShortRadarPacket.java similarity index 84% rename from src/main/java/com/lumijiez/lumiscope/network/ShortRadarPacket.java rename to src/main/java/com/lumijiez/lumiscope/network/packets/ShortRadarPacket.java index 28f6348..9aa5f45 100644 --- a/src/main/java/com/lumijiez/lumiscope/network/ShortRadarPacket.java +++ b/src/main/java/com/lumijiez/lumiscope/network/packets/ShortRadarPacket.java @@ -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.util.Ref; import io.netty.buffer.ByteBuf; import net.minecraft.client.Minecraft; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; @@ -11,18 +13,6 @@ import java.util.ArrayList; import java.util.List; 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 playerInfos; public ShortRadarPacket() { @@ -66,8 +56,9 @@ public class ShortRadarPacket implements IMessage { Minecraft.getMinecraft().addScheduledTask(() -> { ShortRadarRenderer renderer = ShortRadarRenderer.getInstance(); renderer.updatePlayerInfos(message.playerInfos); + Ref.logger.info("RECEIVED SHORT PACKET"); }); return null; } } -} +} \ No newline at end of file diff --git a/src/main/java/com/lumijiez/lumiscope/network/records/PlayerInfo.java b/src/main/java/com/lumijiez/lumiscope/network/records/PlayerInfo.java new file mode 100644 index 0000000..6cb80a6 --- /dev/null +++ b/src/main/java/com/lumijiez/lumiscope/network/records/PlayerInfo.java @@ -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; + } +} \ No newline at end of file diff --git a/src/main/java/com/lumijiez/lumiscope/potions/CustomPotion.java b/src/main/java/com/lumijiez/lumiscope/potions/CustomPotion.java new file mode 100644 index 0000000..542a336 --- /dev/null +++ b/src/main/java/com/lumijiez/lumiscope/potions/CustomPotion.java @@ -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; + } +} diff --git a/src/main/java/com/lumijiez/lumiscope/potions/PotionManager.java b/src/main/java/com/lumijiez/lumiscope/potions/PotionManager.java new file mode 100644 index 0000000..3bf6bd4 --- /dev/null +++ b/src/main/java/com/lumijiez/lumiscope/potions/PotionManager.java @@ -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); + } +} diff --git a/src/main/java/com/lumijiez/lumiscope/render/radar/BaseRadarRenderer.java b/src/main/java/com/lumijiez/lumiscope/render/radar/BaseRadarRenderer.java index 84caea2..f493bea 100644 --- a/src/main/java/com/lumijiez/lumiscope/render/radar/BaseRadarRenderer.java +++ b/src/main/java/com/lumijiez/lumiscope/render/radar/BaseRadarRenderer.java @@ -1,5 +1,6 @@ package com.lumijiez.lumiscope.render.radar; +import com.lumijiez.lumiscope.network.records.PlayerInfo; import com.lumijiez.lumiscope.util.GLHelper; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; @@ -8,22 +9,22 @@ import org.lwjgl.opengl.GL11; import java.util.List; -public abstract class BaseRadarRenderer { +public abstract class BaseRadarRenderer { protected static final Minecraft mc = Minecraft.getMinecraft(); protected final ResourceLocation radarTexture = new ResourceLocation("lumiscope", "textures/gui/radar.png"); protected final ResourceLocation radarArrowTexture = new ResourceLocation("lumiscope", "textures/gui/radar_arrow.png"); - protected List playerInfos; + protected List playerInfos; protected abstract void drawTexturedCircle(float radius); protected abstract void drawTexturedLine(float length, double angle); - protected abstract double getDirection(T info); + protected abstract double getDirection(PlayerInfo info); protected abstract boolean shouldRenderRadar(); - public void updatePlayerInfos(List playerInfos) { + public void updatePlayerInfos(List playerInfos) { this.playerInfos = playerInfos; } @@ -36,7 +37,7 @@ public abstract class BaseRadarRenderer { GLHelper.setupForRadarRendering(); drawTexturedCircle(1.4f); - for (T info : playerInfos) { + for (PlayerInfo info : playerInfos) { double angle = getDirection(info) - Math.toRadians(90); drawTexturedLine(1.4f, angle); } diff --git a/src/main/java/com/lumijiez/lumiscope/render/radar/LongRadarRenderer.java b/src/main/java/com/lumijiez/lumiscope/render/radar/LongRadarRenderer.java index e3efd4c..c60c002 100644 --- a/src/main/java/com/lumijiez/lumiscope/render/radar/LongRadarRenderer.java +++ b/src/main/java/com/lumijiez/lumiscope/render/radar/LongRadarRenderer.java @@ -1,7 +1,7 @@ package com.lumijiez.lumiscope.render.radar; 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.RenderWorldLastEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; @@ -9,7 +9,7 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class LongRadarRenderer extends BaseRadarRenderer { +public class LongRadarRenderer extends BaseRadarRenderer { private static final LongRadarRenderer INSTANCE = new LongRadarRenderer(); private LongRadarRenderer() {} @@ -51,7 +51,7 @@ public class LongRadarRenderer extends BaseRadarRenderer { +public class ShortRadarRenderer extends BaseRadarRenderer { private static final ShortRadarRenderer INSTANCE = new ShortRadarRenderer(); private ShortRadarRenderer() {} @@ -47,14 +47,14 @@ public class ShortRadarRenderer extends BaseRadarRendererNS%G|^0G|-o{|pQV85sUYMl$?Ytgo*J3Lg}BlM1BRN`m}?|APR-=KV|d14TFs zJR*x382Ao@Fyrz36)8Z$2u~Ns5RKs6{y@G13LMTePyAiK$8Oc>m}~qQ@{ZsQJ(++ literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/lumiscope/textures/gui/potions/potion_effects.png b/src/main/resources/assets/lumiscope/textures/gui/potions/potion_effects.png new file mode 100644 index 0000000000000000000000000000000000000000..0205185b6f9aa661665524915173a0274ffbe077 GIT binary patch literal 598 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K5893O0R7}x|G!U;i$lZxy-8q?;Kn_c~qpu?a z!^VE@KZ&eBK4*bPWHAE+-(e7DJf6QI1*qY*r;B4qMcmt)+CfJgL|8AdwMrUDsPs8K zWNYMUyL-T??QX&bjvEX|`3xiy7!xm*1pPb^@c6|!OSP9ZPxh`4<^-BM^udJ2s>-nS zV%4Qld13O$pU*0PBz5BceANj}_hq(g@hI?1H}B=E3k^NQuR5FM&Xe{^NtRlhpSPVD zPF>}%slF%D$kbrzaqzu3kS=<&?D2$#!#aOr7_vXk{{Khej@|y2xyQd3)K&?F{a*i4 zFQ6%r@r&C3zt5w2{@?wiv`$~VeIv`dd2%2dQ`j%e|6?xi{_>T%HKWGqB@D+V*RQ$D zS+bv_F^8Ay!S<8(*WR*BVVJV;_tovK&*qkZk^-^dzcWXCPx%WJyFpR5(v#WIzHhUR>mUbo)v&3kSzFA#U!gzdybC`iqxOKwI1I5wbdDHY2)3 zNnS{siMjE4A5TBCKY#z+6cE*)gG)0=9MgdOm~>Z9j~R~kE)2JC-M_Mb@9~KBTemJ1 z5Dy{&c<-}{$mDq4o-&8pT0Bj za{b-@;QBc)oCYkLKfyI2t$HIfyAY?BuMflHC(jse-Mq`d!p6?<`RjKEHm2`4KEJ)M ziPM1H>z3IB#}sX6;Sk}Gk&$6|{pKA5Gcz;8pa1_D{{H{N!1V9)B6$ZeMp; zPD%S>F)4L6J|2FC=P#cz@CxuUFfspQc<|^R12_Ah2cJH_Rm5q)tiGO%%%X-VvND>? z;-V4^ckbR`VB=t7c>Dg@KQ11&=dm$C(UT|7K8VwR6MMGnIk*R%WMtyv(AUvpxPIg6 zuOB}@evOC@p1N@HvRZ6;0wXDd6xrGu&;Ih^v(ov?x18~1B&?Z<{907*qoM6N<$g7IRF3v literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/lumiscope/textures/items/radar_antenna.png b/src/main/resources/assets/lumiscope/textures/items/radar_antenna.png index 0e67d992f400e08b9e028c21609bf4150253638f..5f7e01d2e2548b99d3cbd4b90543c2fdaebeb220 100644 GIT binary patch delta 457 zcmV;)0XF{s0q+BlFnU*c5p~3Ly*I$NBn>I11tE)4Z znwj;UK6A3TuCkPwk&*EqvK~fc4vhWf*MI%sfS?Q4u3ckbW@ctMf99&7pdjN1Y-+I@ z@cI9L(J9>%uFaY?OC%~Pa$`$lZ4@IT<2RxW`2YVu%jwgX?0+L;qIUH5_5}s_x^Kp& z86<|)1^@s5XS#p?xoloR?)1{il45&H%j={Xzs@j^i({>3IIaEWI0hu}Fo>#73);PR>TR+JLY(8^_YtPb+0goO%QhD_7 ziP_mRdvV4DNo=u~ib_1!)z&`v=Ji|AWlI;QFfcH(FfjaMs6uOQsA;M#1seZ^Y5)}szzeXY4^+Uw000I8XD-cE RKvMt!002ovPDHLkV1l7&P4EB! diff --git a/src/main/resources/assets/lumiscope/textures/items/radar_screen.png b/src/main/resources/assets/lumiscope/textures/items/radar_screen.png index d6fd949c36bb664124e4c4e857b0c995cee03d6f..da97ad949bd54aa4ef0ea9e6adfc9fded5cf6949 100644 GIT binary patch delta 858 zcmV-g1Eu`90r3WqB!3BTNLh0L01m_e01m_fl`9S#0009cNklA5{?vvuFdvzw2x_AOgKuK0PN=gM8uc!h3>??hx_%~+E-rM(%9@Om;r}KGmKzm zZXr_`82o#-V}Dz7yls2rx&ke5Fnblim6EStAGv=dnVdRy;Eml_%rC>Ts;I5eu&}s@ zdcO~5xrBkCTdhX}^>qz?|3yh^i7OBT5W4XD;D?a*v7?_H!obbD@O$g9eQOAU3p52A zFglUMvP1a%;Jfdg|84N_LiWENjd8{~7@M4avNN4ZoqseO!lj|x=-;;srD_E?M;>7G zQ4)*A61FwJ3_##oJORJQb!c>QW*-1u0H}GI&g`l2cpzOmHWf`wjg7-}B!oYJVwGcP z_&$_np~+}K&?Qjj4C!pH%d#ww0H9lr-R|4mfON5fsv;DMCMukRbcXX62GG7`6Fz#s z4`#6pQh$KvcA;$9Ua1^62VjMK-uTnG6n3=7P-kp~^csjK#xRmdppbfo#DgTp=W@^j zO=ycoVb|0`+Sat&<;imeQm^&w917L@&i!$F7|liy<>frOyE>q38$GXf;p?wHL!;LN zUFTSKd+^Wr#EmZx_WcE*#8%#zXS139AJ3foK7TLq>EXS-h_p0e=E*#`rlGYpf_yHA zD>v@q-owe!6GuKc+yD0dUlgefTjv8_DVlFyx)%T9(cHiNg@PGuGwR)nGgg(79?xg3 z&S=Y>cX~T7c6G*nRiG3Hv)4?q5}b&_Q`0lwes}z*%bR0w&5BUxk}ujjeD%-4(?rxq zL{ol;l)h%d4FEVwvK3J5hf_a)>%1E;{X5v delta 156 zcmey!wu5nkNGZx^prw85kH?(j9#r85lP9bN@+X1@buyJR*x382Ao>Fr%o3 zR|8Pc*VDx@#KJ%M0F#7dimBwnHxn5Q{=9nd;Dh|BBV2qk77f-l4zn6}{r~+Z{m1zQ z-{iHWm$M$pXxliEH?iqbN^_$*1M39gjw`*#1UV%nL>aaUd-+OfDdz!AX7F_Nb6Mw< G&;$VaGBy(c