Mapper and scanner functionality, sat textures, bugfixes

This commit is contained in:
HbmMods 2018-05-05 19:00:57 +02:00
parent afcb143d7d
commit abbe0adf0b
15 changed files with 314 additions and 4 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 190 B

After

Width:  |  Height:  |  Size: 368 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 176 B

After

Width:  |  Height:  |  Size: 338 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 194 B

After

Width:  |  Height:  |  Size: 332 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 186 B

After

Width:  |  Height:  |  Size: 349 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 195 B

After

Width:  |  Height:  |  Size: 398 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 189 B

After

Width:  |  Height:  |  Size: 367 B

View File

@ -125,6 +125,8 @@ public class EntityCarrier extends EntityThrowable {
SatelliteSavedData data = (SatelliteSavedData)worldObj.perWorldStorage.loadData(SatelliteSavedData.class, "satellites");
if(data == null) {
worldObj.perWorldStorage.setData("satellites", new SatelliteSavedData(worldObj));
data = (SatelliteSavedData)worldObj.perWorldStorage.loadData(SatelliteSavedData.class, "satellites");
}
int freq = ItemSatChip.getFreq(payload);

View File

@ -1235,6 +1235,8 @@ public class GUIHandler implements IGuiHandler {
return new GUIScreenTemplateFolder(player);
case ModItems.guiID_item_designator:
return new GUIScreenDesignator(player);
case ModItems.guiID_item_sat_interface:
return new GUIScreenSatInterface(player);
}
}
return null;

View File

@ -0,0 +1,263 @@
package com.hbm.inventory.gui;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.lwjgl.opengl.GL11;
import com.hbm.handler.FluidTypeHandler.FluidType;
import com.hbm.inventory.MachineRecipes;
import com.hbm.items.ModItems;
import com.hbm.items.tool.ItemAssemblyTemplate.EnumAssemblyTemplate;
import com.hbm.items.tool.ItemCassette;
import com.hbm.items.tool.ItemCassette.TrackType;
import com.hbm.items.tool.ItemChemistryTemplate;
import com.hbm.items.tool.ItemFluidIdentifier;
import com.hbm.items.tool.ItemSatChip;
import com.hbm.lib.RefStrings;
import com.hbm.packet.ItemFolderPacket;
import com.hbm.packet.PacketDispatcher;
import com.hbm.saveddata.SatelliteSaveStructure;
import com.hbm.saveddata.SatelliteSavedData;
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.oredict.OreDictionary;
public class GUIScreenSatInterface extends GuiScreen {
protected static final ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/gui_sat_interface.png");
protected int xSize = 216;
protected int ySize = 216;
protected int guiLeft;
protected int guiTop;
private final EntityPlayer player;
protected SatelliteSaveStructure connectedSat;
public static SatelliteSavedData satData;
public GUIScreenSatInterface(EntityPlayer player) {
this.player = player;
}
public void updateScreen() {
}
public void drawScreen(int mouseX, int mouseY, float f)
{
this.drawDefaultBackground();
this.drawGuiContainerBackgroundLayer(f, mouseX, mouseY);
GL11.glDisable(GL11.GL_LIGHTING);
this.drawGuiContainerForegroundLayer(mouseX, mouseY);
GL11.glEnable(GL11.GL_LIGHTING);
}
public void initGui()
{
super.initGui();
this.guiLeft = (this.width - this.xSize) / 2;
this.guiTop = (this.height - this.ySize) / 2;
if(satData != null && player.getHeldItem() != null && player.getHeldItem().getItem() == ModItems.sat_interface) {
int freq = ItemSatChip.getFreq(player.getHeldItem());
connectedSat = satData.getSatFromFreq(freq);
}
}
protected void drawGuiContainerForegroundLayer(int i, int j) {
}
protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
if(connectedSat == null) {
drawNotConnected();
} else {
switch(connectedSat.satelliteType) {
case LASER:
break;
case MAPPER:
drawMap(); break;
case RADAR:
drawRadar(); break;
case SCANNER:
drawScan(); break;
case RELAY:
case RESONATOR:
drawNoService(); break;
}
}
}
private int scanPos = 0;
private long lastMilli = 0;
private void progresScan() {
if(lastMilli + 25 < System.currentTimeMillis()) {
lastMilli = System.currentTimeMillis();
scanPos++;
}
if(scanPos >= 200)
scanPos -= 200;
}
private int[][] map = new int[200][200];
private void drawMap() {
World world = player.worldObj;
for(int i = -100; i < 100; i++) {
int x = (int)player.posX + i;
int z = (int)player.posZ + scanPos - 100;
int y = world.getHeightValue(x, z) - 1;
map[i + 100][scanPos] = world.getBlock(x, y, z).getMaterial().getMaterialMapColor().func_151643_b(2);
}
prontMap();
progresScan();
}
private void drawScan() {
World world = player.worldObj;
for(int i = -100; i < 100; i++) {
int x = (int)player.posX + i;
int z = (int)player.posZ + scanPos - 100;
//int y = world.getHeightValue(x, z) - 1;
//map[i + 100][scanPos] = 0x081F0D + world.getBlock(x, y, z).getMaterial().getMaterialMapColor().func_151643_b(3);
for(int j = 255; j >= 0; j--) {
int c = getColorFromBlock(new ItemStack(world.getBlock(x, j, z), 1, world.getBlockMetadata(x, j, z)));
if(c != 0) {
map[i + 100][scanPos] = c;
break;
}
}
}
prontMap();
progresScan();
}
private int getColorFromBlock(ItemStack stack) {
if(stack == null || stack.getItem() == null/* || stack.getItemDamage() < 0*/)
return 0;
if(MachineRecipes.mODE(stack, "oreCoal"))
return 0x333333;
if(MachineRecipes.mODE(stack, "oreIron"))
return 0xb2aa92;
if(MachineRecipes.mODE(stack, "oreGold"))
return 0xffe460;
if(MachineRecipes.mODE(stack, "oreSilver"))
return 0xe5e5e5;
if(MachineRecipes.mODE(stack, "oreDiamond"))
return 0x6ed5ef;
if(MachineRecipes.mODE(stack, "oreEmerald"))
return 0x6cf756;
if(MachineRecipes.mODE(stack, "oreLapis"))
return 0x092f7a;
if(MachineRecipes.mODE(stack, "oreRedstone"))
return 0xe50000;
if(MachineRecipes.mODE(stack, "oreTin"))
return 0xa09797;
if(MachineRecipes.mODE(stack, "oreCopper"))
return 0xd16208;
if(MachineRecipes.mODE(stack, "oreLead"))
return 0x384b68;
if(MachineRecipes.mODE(stack, "oreAluminum"))
return 0xdbdbdb;
if(MachineRecipes.mODE(stack, "oreTungsten"))
return 0x333333;
if(MachineRecipes.mODE(stack, "oreUranium"))
return 0x3e4f3c;
if(MachineRecipes.mODE(stack, "oreBeryllium"))
return 0x8e8d7d;
if(MachineRecipes.mODE(stack, "oreSulfur"))
return 0x9b9309;
if(MachineRecipes.mODE(stack, "oreSalpeter"))
return 0xa5a09d;
if(MachineRecipes.mODE(stack, "oreFluorite"))
return 0xffffff;
if(MachineRecipes.mODE(stack, "oreSchrabidium"))
return 0x1cffff;
return isOre(stack) ? 0xBA00AF : 0x000000;
}
private static boolean isOre(ItemStack stack) {
int[] ids = OreDictionary.getOreIDs(new ItemStack(stack.getItem(), 1, stack.getItemDamage()));
for(int i = 0; i < ids.length; i++) {
String s = OreDictionary.getOreName(ids[i]);
if(s.length() > 3 && s.substring(3).equals("ore"))
return true;
}
return false;
}
private void drawRadar() {
}
private void prontMap() {
for(int x = 0; x < 200; x++) {
for(int z = 0; z < 200; z++) {
if(map[x][z] != 0) {
GL11.glColor3ub((byte)((map[x][z] & 0xFF0000) >> 16), (byte)((map[x][z] & 0x00FF00) >> 8), (byte)(map[x][z] & 0x0000FF));
drawTexturedModalRect(guiLeft + 8 + x, guiTop + 8 + z, 216, 216, 1, 1);
}
}
}
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
}
private void drawNoService() {
drawTexturedModalRect((this.width - 77) / 2, (this.height - 12) / 2, 0, 228, 77, 12);
}
private void drawNotConnected() {
drawTexturedModalRect((this.width - 121) / 2, (this.height - 12) / 2, 0, 216, 121, 12);
}
protected void keyTyped(char p_73869_1_, int p_73869_2_)
{
if (p_73869_2_ == 1 || p_73869_2_ == this.mc.gameSettings.keyBindInventory.getKeyCode())
{
this.mc.thePlayer.closeScreen();
}
}
}

View File

@ -684,6 +684,7 @@ public class ModItems {
public static Item sat_foeq;
public static Item sat_resonator;
public static Item sat_chip;
public static Item sat_interface;
public static Item gun_rpg;
public static Item gun_rpg_ammo;
@ -1219,6 +1220,7 @@ public class ModItems {
public static final int guiID_item_folder = 99;
public static final int guiID_item_designator = 100;
public static final int guiID_item_sat_interface = 101;
public static void initializeItem()
{
@ -1833,6 +1835,7 @@ public class ModItems {
sat_foeq = new ItemSatChip().setUnlocalizedName("sat_foeq").setMaxStackSize(1).setCreativeTab(MainRegistry.tabNuke).setTextureName(RefStrings.MODID + ":sat_foeq");
sat_resonator = new ItemSatChip().setUnlocalizedName("sat_resonator").setMaxStackSize(1).setCreativeTab(MainRegistry.tabNuke).setTextureName(RefStrings.MODID + ":sat_resonator");
sat_chip = new ItemSatChip().setUnlocalizedName("sat_chip").setMaxStackSize(1).setCreativeTab(MainRegistry.tabNuke).setTextureName(RefStrings.MODID + ":sat_chip");
sat_interface = new ItemSatInterface().setUnlocalizedName("sat_interface").setMaxStackSize(1).setCreativeTab(MainRegistry.tabNuke).setTextureName(RefStrings.MODID + ":sat_interface");
gun_rpg = new GunRpg().setUnlocalizedName("gun_rpg").setCreativeTab(MainRegistry.tabNuke).setTextureName(RefStrings.MODID + ":gun_rpg_new");
gun_rpg_ammo = new Item().setUnlocalizedName("gun_rpg_ammo").setCreativeTab(MainRegistry.tabNuke).setTextureName(RefStrings.MODID + ":gun_rpg_ammo_new");
@ -3158,6 +3161,7 @@ public class ModItems {
GameRegistry.registerItem(sat_foeq, sat_foeq.getUnlocalizedName());
GameRegistry.registerItem(sat_resonator, sat_resonator.getUnlocalizedName());
GameRegistry.registerItem(sat_chip, sat_chip.getUnlocalizedName());
GameRegistry.registerItem(sat_interface, sat_interface.getUnlocalizedName());
//Guns
GameRegistry.registerItem(gun_revolver_iron, gun_revolver_iron.getUnlocalizedName());

View File

@ -0,0 +1,34 @@
package com.hbm.items.tool;
import com.hbm.inventory.gui.GUIScreenSatInterface;
import com.hbm.items.ModItems;
import com.hbm.main.MainRegistry;
import com.hbm.saveddata.SatelliteSavedData;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class ItemSatInterface extends ItemSatChip {
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
if(world.isRemote)
player.openGui(MainRegistry.instance, ModItems.guiID_item_sat_interface, world, 0, 0, 0);
return stack;
}
public void onUpdate(ItemStack stack, World world, Entity entity, int i, boolean b) {
if(!world.isRemote) {
SatelliteSavedData data = (SatelliteSavedData)entity.worldObj.perWorldStorage.loadData(SatelliteSavedData.class, "satellites");
GUIScreenSatInterface.satData = data;
}
}
}

View File

@ -893,8 +893,8 @@ public class CraftingManager {
GameRegistry.addRecipe(new ShapedOreRecipe(ItemBattery.getEmptyBattery(ModItems.battery_advanced), new Object[] { " A ", "PLP", "PSP", 'A', ModItems.wire_red_copper, 'P', "plateCopper", 'S', "dustSulfur", 'L', "dustLead" }));
GameRegistry.addRecipe(new ShapedOreRecipe(ItemBattery.getEmptyBattery(ModItems.battery_lithium), new Object[] { "A A", "PSP", "PLP", 'A', ModItems.wire_gold, 'P', "plateTitanium", 'S', "dustLithium", 'L', ModItems.powder_cobalt }));
GameRegistry.addRecipe(new ShapedOreRecipe(ItemBattery.getEmptyBattery(ModItems.battery_lithium), new Object[] { "A A", "PLP", "PSP", 'A', ModItems.wire_gold, 'P', "plateTitanium", 'S', "dustLithium", 'L', ModItems.powder_cobalt }));
GameRegistry.addRecipe(new ShapedOreRecipe(ItemBattery.getEmptyBattery(ModItems.battery_schrabidium), new Object[] { " A ", "PNP", "PSP", 'A', ModItems.wire_schrabidium, 'P', "plateSchrabidium", 'S', "powderSchrabidium", 'N', ModItems.powder_neptunium }));
GameRegistry.addRecipe(new ShapedOreRecipe(ItemBattery.getEmptyBattery(ModItems.battery_schrabidium), new Object[] { " A ", "PSP", "PNP", 'A', ModItems.wire_schrabidium, 'P', "plateSchrabidium", 'S', "powderSchrabidium", 'N', ModItems.powder_neptunium }));
GameRegistry.addRecipe(new ShapedOreRecipe(ItemBattery.getEmptyBattery(ModItems.battery_schrabidium), new Object[] { " A ", "PNP", "PSP", 'A', ModItems.wire_schrabidium, 'P', "plateSchrabidium", 'S', "dustSchrabidium", 'N', ModItems.powder_neptunium }));
GameRegistry.addRecipe(new ShapedOreRecipe(ItemBattery.getEmptyBattery(ModItems.battery_schrabidium), new Object[] { " A ", "PSP", "PNP", 'A', ModItems.wire_schrabidium, 'P', "plateSchrabidium", 'S', "dustSchrabidium", 'N', ModItems.powder_neptunium }));
GameRegistry.addRecipe(new ShapedOreRecipe(ItemBattery.getEmptyBattery(ModItems.battery_spark), new Object[] { " A ", "PSP", "PSP", 'A', ModItems.wire_magnetized_tungsten, 'P', "plateDineutronium", 'S', ModItems.powder_spark_mix }));
GameRegistry.addRecipe(new ShapedOreRecipe(ItemBattery.getFullBattery(ModItems.energy_core), new Object[] { "PCW", "TRD", "PCW", 'P', ModItems.plate_advanced_alloy, 'C', ModItems.coil_advanced_alloy, 'W', ModItems.wire_advanced_alloy, 'R', ModItems.cell_tritium, 'D', ModItems.cell_deuterium, 'T', "ingotTungsten" }));
GameRegistry.addRecipe(new ShapedOreRecipe(ItemBattery.getFullBattery(ModItems.energy_core), new Object[] { "PCW", "TDR", "PCW", 'P', ModItems.plate_advanced_alloy, 'C', ModItems.coil_advanced_alloy, 'W', ModItems.wire_advanced_alloy, 'R', ModItems.cell_tritium, 'D', ModItems.cell_deuterium, 'T', "ingotTungsten" }));

View File

@ -28,11 +28,16 @@ public class SatelliteSavedData extends WorldSavedData {
public boolean isFreqTaken(int freq) {
return getSatFromFreq(freq) != null;
}
public SatelliteSaveStructure getSatFromFreq(int freq) {
for(SatelliteSaveStructure sat : satellites)
if(sat.satelliteID == freq)
return true;
return sat;
return false;
return null;
}
@Override