Initial commit
This commit is contained in:
37
src/main/java/com/lumijiez/lumiscope/Lumiscope.java
Normal file
37
src/main/java/com/lumijiez/lumiscope/Lumiscope.java
Normal file
@@ -0,0 +1,37 @@
|
||||
package com.lumijiez.lumiscope;
|
||||
|
||||
import com.lumijiez.lumiscope.proxy.CommonProxy;
|
||||
import com.lumijiez.lumiscope.util.Ref;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
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 static com.lumijiez.lumiscope.util.Ref.logger;
|
||||
|
||||
@Mod(modid = Ref.MODID, name = Ref.NAME, version = Ref.VERSION)
|
||||
public class Lumiscope {
|
||||
@SidedProxy(clientSide = Ref.CLIENT_PROXY_CLASS, serverSide = Ref.COMMON_PROXY_CLASS)
|
||||
public static CommonProxy proxy;
|
||||
|
||||
@EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void init(FMLInitializationEvent event)
|
||||
{
|
||||
logger.info("Radar turned on!");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void postInit(FMLPostInitializationEvent event)
|
||||
{
|
||||
logger.info("Radar turned on!");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.lumijiez.lumiscope.handlers;
|
||||
|
||||
import com.lumijiez.lumiscope.init.ModItems;
|
||||
import com.lumijiez.lumiscope.util.IHasModel;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
@Mod.EventBusSubscriber
|
||||
public class RegistryHandler {
|
||||
@SubscribeEvent
|
||||
public static void onItemRegister(RegistryEvent.Register<Item> event) {
|
||||
event.getRegistry().registerAll(ModItems.ITEMS.toArray(new Item[0]));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onModelRegister(ModelRegistryEvent event) {
|
||||
for (Item item : ModItems.ITEMS) {
|
||||
if(item instanceof IHasModel) {
|
||||
((IHasModel) item).registerModels();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
17
src/main/java/com/lumijiez/lumiscope/init/ModItems.java
Normal file
17
src/main/java/com/lumijiez/lumiscope/init/ModItems.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.lumijiez.lumiscope.init;
|
||||
|
||||
import com.lumijiez.lumiscope.items.ItemBase;
|
||||
import com.lumijiez.lumiscope.items.radars.LongRadar;
|
||||
import com.lumijiez.lumiscope.items.radars.ShortRadar;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ModItems {
|
||||
public static final List<Item> ITEMS = new ArrayList<Item>();
|
||||
public static final Item shortRadar = new ShortRadar();
|
||||
public static final Item longRadar = new LongRadar();
|
||||
public static final Item radarAntenna = new ItemBase("radar_antenna");
|
||||
public static final Item radarScreen = new ItemBase("radar_screen");
|
||||
}
|
||||
21
src/main/java/com/lumijiez/lumiscope/items/ItemBase.java
Normal file
21
src/main/java/com/lumijiez/lumiscope/items/ItemBase.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package com.lumijiez.lumiscope.items;
|
||||
|
||||
import com.lumijiez.lumiscope.Lumiscope;
|
||||
import com.lumijiez.lumiscope.init.ModItems;
|
||||
import com.lumijiez.lumiscope.util.IHasModel;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
public class ItemBase extends Item implements IHasModel {
|
||||
public ItemBase(String name) {
|
||||
setUnlocalizedName(name);
|
||||
setRegistryName(name);
|
||||
setCreativeTab(CreativeTabs.COMBAT);
|
||||
|
||||
ModItems.ITEMS.add(this);
|
||||
}
|
||||
@Override
|
||||
public void registerModels() {
|
||||
Lumiscope.proxy.registerItemRenderer(this, 0, "inventory");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package com.lumijiez.lumiscope.items.radars;
|
||||
|
||||
import com.lumijiez.lumiscope.items.ItemBase;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.Style;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class LongRadar extends ItemBase {
|
||||
private static final Random RANDOM = new Random();
|
||||
|
||||
public LongRadar() {
|
||||
super("long_radar");
|
||||
setMaxStackSize(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
|
||||
ITextComponent info = new TextComponentString("Checks for faraway players.")
|
||||
.setStyle(new Style().setColor(TextFormatting.AQUA));
|
||||
tooltip.add(info.getFormattedText());
|
||||
|
||||
ITextComponent warning = new TextComponentString("Can be imprecise!")
|
||||
.setStyle(new Style().setColor(TextFormatting.RED));
|
||||
tooltip.add(warning.getFormattedText());
|
||||
|
||||
super.addInformation(stack, worldIn, tooltip, flagIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
|
||||
if (!world.isRemote) {
|
||||
StringBuilder message = new StringBuilder();
|
||||
boolean playerNearby = false;
|
||||
|
||||
ITextComponent warningMessage = new TextComponentString("WARNING: Cannot detect players less than 500 meters from you!")
|
||||
.setStyle(new Style().setColor(TextFormatting.RED));
|
||||
player.sendMessage(warningMessage);
|
||||
|
||||
for (EntityPlayer otherPlayer : world.playerEntities) {
|
||||
if (!otherPlayer.equals(player)) {
|
||||
playerNearby = true;
|
||||
|
||||
double deltaX = otherPlayer.posX - player.posX;
|
||||
double deltaZ = otherPlayer.posZ - player.posZ;
|
||||
double distance = Math.sqrt(deltaX * deltaX + deltaZ * deltaZ);
|
||||
|
||||
if (distance <= 500) continue;
|
||||
|
||||
double angle = Math.atan2(deltaZ, deltaX);
|
||||
double angleDegrees = Math.toDegrees(angle) - 90;
|
||||
angleDegrees = (angleDegrees + 360) % 360;
|
||||
|
||||
double margin = RANDOM.nextDouble() * 20;
|
||||
double halfMargin = margin / 2;
|
||||
|
||||
double startAngle = (angleDegrees - halfMargin + 360) % 360;
|
||||
double endAngle = (angleDegrees + halfMargin + 360) % 360;
|
||||
|
||||
String distanceMessage = distance > 50000 ? " (very far)" : "";
|
||||
|
||||
ITextComponent intervalMessage;
|
||||
if (startAngle > endAngle) {
|
||||
intervalMessage = new TextComponentString(String.format("Look in the interval (%.1f - %.1f degrees)%s", startAngle, endAngle, distanceMessage))
|
||||
.setStyle(new Style().setColor(TextFormatting.GREEN));
|
||||
} else {
|
||||
intervalMessage = new TextComponentString(String.format("Look in the interval (%.1f - %.1f degrees)%s", startAngle, endAngle, distanceMessage))
|
||||
.setStyle(new Style().setColor(TextFormatting.GREEN));
|
||||
}
|
||||
|
||||
message.append(intervalMessage.getFormattedText()).append("\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (playerNearby) {
|
||||
player.sendMessage(new TextComponentString(message.toString()));
|
||||
} else {
|
||||
ITextComponent noPlayersMessage = new TextComponentString("No other players found.")
|
||||
.setStyle(new Style().setColor(TextFormatting.GRAY));
|
||||
player.sendMessage(noPlayersMessage);
|
||||
}
|
||||
|
||||
player.getCooldownTracker().setCooldown(this, 3600);
|
||||
}
|
||||
return new ActionResult<>(EnumActionResult.SUCCESS, player.getHeldItem(hand));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.lumijiez.lumiscope.items.radars;
|
||||
|
||||
import com.lumijiez.lumiscope.items.ItemBase;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.Style;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public class ShortRadar extends ItemBase {
|
||||
public ShortRadar() {
|
||||
super("short_radar");
|
||||
setMaxStackSize(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
|
||||
ITextComponent info = new TextComponentString("Checks for nearby players.")
|
||||
.setStyle(new Style().setColor(TextFormatting.AQUA));
|
||||
tooltip.add(info.getFormattedText());
|
||||
|
||||
super.addInformation(stack, worldIn, tooltip, flagIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
|
||||
if (!world.isRemote) {
|
||||
boolean playerNearby = false;
|
||||
|
||||
ITextComponent message;
|
||||
if (isPlayerNearby(world, player)) {
|
||||
message = new TextComponentString("There are players within 200 meters!")
|
||||
.setStyle(new Style().setColor(TextFormatting.GREEN));
|
||||
} else {
|
||||
message = new TextComponentString("No players within 200 meters.")
|
||||
.setStyle(new Style().setColor(TextFormatting.RED));
|
||||
}
|
||||
|
||||
player.sendMessage(message);
|
||||
player.getCooldownTracker().setCooldown(this, 1200);
|
||||
}
|
||||
return new ActionResult<>(EnumActionResult.SUCCESS, player.getHeldItem(hand));
|
||||
}
|
||||
|
||||
private boolean isPlayerNearby(World world, EntityPlayer player) {
|
||||
for (EntityPlayer otherPlayer : world.playerEntities) {
|
||||
if (!otherPlayer.equals(player) && player.getDistance(otherPlayer) <= 200) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
11
src/main/java/com/lumijiez/lumiscope/proxy/ClientProxy.java
Normal file
11
src/main/java/com/lumijiez/lumiscope/proxy/ClientProxy.java
Normal file
@@ -0,0 +1,11 @@
|
||||
package com.lumijiez.lumiscope.proxy;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
|
||||
public class ClientProxy extends CommonProxy {
|
||||
public void registerItemRenderer(Item item, int meta, String id) {
|
||||
ModelLoader.setCustomModelResourceLocation(item, meta, new ModelResourceLocation(item.getRegistryName(), id));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.lumijiez.lumiscope.proxy;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
public class CommonProxy {
|
||||
public void registerItemRenderer(Item item, int meta, String id) {
|
||||
|
||||
}
|
||||
}
|
||||
5
src/main/java/com/lumijiez/lumiscope/util/IHasModel.java
Normal file
5
src/main/java/com/lumijiez/lumiscope/util/IHasModel.java
Normal file
@@ -0,0 +1,5 @@
|
||||
package com.lumijiez.lumiscope.util;
|
||||
|
||||
public interface IHasModel {
|
||||
public void registerModels();
|
||||
}
|
||||
13
src/main/java/com/lumijiez/lumiscope/util/Ref.java
Normal file
13
src/main/java/com/lumijiez/lumiscope/util/Ref.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package com.lumijiez.lumiscope.util;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class Ref {
|
||||
public static final String MODID = "lumiscope";
|
||||
public static final String NAME = "Lumiscope";
|
||||
public static final String VERSION = "1.0";
|
||||
public static final String CLIENT_PROXY_CLASS = "com.lumijiez.lumiscope.proxy.ClientProxy";
|
||||
public static final String COMMON_PROXY_CLASS = "com.lumijiez.lumiscope.proxy.CommonProxy";
|
||||
public static final Logger logger = LogManager.getLogger();
|
||||
}
|
||||
4
src/main/resources/assets/lumiscope/lang/en_us.lang
Normal file
4
src/main/resources/assets/lumiscope/lang/en_us.lang
Normal file
@@ -0,0 +1,4 @@
|
||||
item.short_radar.name=Short Distance Radar
|
||||
item.long_radar.name=Long Distance Radar
|
||||
item.radar_antenna.name=Radar Antenna
|
||||
item.radar_screen.name=Radar Screen
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "lumiscope:items/long_radar"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "lumiscope:items/radar_antenna"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "lumiscope:items/radar_screen"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "lumiscope:items/short_radar"
|
||||
}
|
||||
}
|
||||
29
src/main/resources/assets/lumiscope/recipes/long_radar.json
Normal file
29
src/main/resources/assets/lumiscope/recipes/long_radar.json
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"type": "minecraft:crafting_shaped",
|
||||
"pattern": [
|
||||
"AAA",
|
||||
"SES",
|
||||
"ONO"
|
||||
],
|
||||
"key": {
|
||||
"E": {
|
||||
"item": "minecraft:ender_pearl"
|
||||
},
|
||||
"A": {
|
||||
"item": "lumiscope:radar_antenna"
|
||||
},
|
||||
"S": {
|
||||
"item": "lumiscope:short_radar"
|
||||
},
|
||||
"O": {
|
||||
"item": "minecraft:obsidian"
|
||||
},
|
||||
"N": {
|
||||
"item": "minecraft:nether_star"
|
||||
}
|
||||
},
|
||||
"result": {
|
||||
"item": "lumiscope:long_radar",
|
||||
"count": 1
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"type": "minecraft:crafting_shaped",
|
||||
"pattern": [
|
||||
"RIR",
|
||||
"RIR",
|
||||
"RIR"
|
||||
],
|
||||
"key": {
|
||||
"R": {
|
||||
"item": "minecraft:redstone"
|
||||
},
|
||||
"I": {
|
||||
"item": "minecraft:iron_ingot"
|
||||
}
|
||||
},
|
||||
"result": {
|
||||
"item": "lumiscope:radar_antenna",
|
||||
"count": 1
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"type": "minecraft:crafting_shaped",
|
||||
"pattern": [
|
||||
"GGG",
|
||||
"RIR",
|
||||
"GGG"
|
||||
],
|
||||
"key": {
|
||||
"G": {
|
||||
"item": "minecraft:glass_pane"
|
||||
},
|
||||
"R": {
|
||||
"item": "minecraft:redstone"
|
||||
},
|
||||
"I": {
|
||||
"item": "minecraft:item_frame"
|
||||
}
|
||||
},
|
||||
"result": {
|
||||
"item": "lumiscope:radar_screen",
|
||||
"count": 1
|
||||
}
|
||||
}
|
||||
32
src/main/resources/assets/lumiscope/recipes/short_radar.json
Normal file
32
src/main/resources/assets/lumiscope/recipes/short_radar.json
Normal file
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"type": "minecraft:crafting_shaped",
|
||||
"pattern": [
|
||||
"EAE",
|
||||
"RSR",
|
||||
"OIO"
|
||||
],
|
||||
"key": {
|
||||
"E": {
|
||||
"item": "minecraft:ender_pearl"
|
||||
},
|
||||
"A": {
|
||||
"item": "lumiscope:radar_antenna"
|
||||
},
|
||||
"R": {
|
||||
"item": "minecraft:redstone"
|
||||
},
|
||||
"S": {
|
||||
"item": "lumiscope:radar_screen"
|
||||
},
|
||||
"O": {
|
||||
"item": "minecraft:obsidian"
|
||||
},
|
||||
"I": {
|
||||
"item": "minecraft:iron_ingot"
|
||||
}
|
||||
},
|
||||
"result": {
|
||||
"item": "lumiscope:short_radar",
|
||||
"count": 1
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 238 B |
Binary file not shown.
|
After Width: | Height: | Size: 255 B |
Binary file not shown.
|
After Width: | Height: | Size: 184 B |
Binary file not shown.
|
After Width: | Height: | Size: 238 B |
16
src/main/resources/mcmod.info
Normal file
16
src/main/resources/mcmod.info
Normal file
@@ -0,0 +1,16 @@
|
||||
[
|
||||
{
|
||||
"modid": "lumiscope",
|
||||
"name": "Lumiscope",
|
||||
"description": "Balanced, long distance radar mod.",
|
||||
"version": "${version}",
|
||||
"mcversion": "${mcversion}",
|
||||
"url": "",
|
||||
"updateUrl": "",
|
||||
"authorList": ["Lumijiez"],
|
||||
"credits": "Me :P",
|
||||
"logoFile": "",
|
||||
"screenshots": [],
|
||||
"dependencies": []
|
||||
}
|
||||
]
|
||||
7
src/main/resources/pack.mcmeta
Normal file
7
src/main/resources/pack.mcmeta
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"pack": {
|
||||
"description": "Lumiscope resources",
|
||||
"pack_format": 3,
|
||||
"_comment": "A pack_format of 3 should be used starting with Minecraft 1.11. All resources, including language files, should be lowercase (eg: en_us.lang). A pack_format of 2 will load your mod resources with LegacyV2Adapter, which requires language files to have uppercase letters (eg: en_US.lang)."
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user