partial AI chip implementation, nuclear waste placeholders

This commit is contained in:
Bob 2021-03-03 22:36:42 +01:00
parent bc89c4a1e1
commit adcc7e4bd6
18 changed files with 231 additions and 45 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 315 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 312 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 317 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 181 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 181 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 372 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 362 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 367 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 187 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 185 B

View File

@ -28,6 +28,15 @@ public class MineralRecipes {
RecipesCommon.add9To1(ModItems.ingot_dineutronium, ModBlocks.block_dineutronium);
RecipesCommon.add1To9(ModBlocks.block_dineutronium, ModItems.ingot_dineutronium);
RecipesCommon.add9To1(ModItems.nuclear_waste_long_tiny, ModItems.nuclear_waste_long);
RecipesCommon.add1To9(ModItems.nuclear_waste_long, ModItems.nuclear_waste_long_tiny);
RecipesCommon.add9To1(ModItems.nuclear_waste_long_depleted_tiny, ModItems.nuclear_waste_long_depleted);
RecipesCommon.add1To9(ModItems.nuclear_waste_long_depleted, ModItems.nuclear_waste_long_depleted_tiny);
RecipesCommon.add9To1(ModItems.nuclear_waste_short_tiny, ModItems.nuclear_waste_short);
RecipesCommon.add1To9(ModItems.nuclear_waste_short, ModItems.nuclear_waste_short_tiny);
RecipesCommon.add9To1(ModItems.nuclear_waste_short_depleted_tiny, ModItems.nuclear_waste_short_depleted);
RecipesCommon.add1To9(ModItems.nuclear_waste_short_depleted, ModItems.nuclear_waste_short_depleted_tiny);
RecipesCommon.add9To1(ModItems.fallout, ModBlocks.block_fallout);
RecipesCommon.add1To9(ModBlocks.block_fallout, ModItems.fallout);

View File

@ -1,5 +1,7 @@
package com.hbm.inventory.gui;
import java.util.List;
import org.lwjgl.opengl.GL11;
import com.hbm.inventory.container.ContainerTurretChekhov;
@ -12,12 +14,14 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
public class GUITurretChekhov extends GuiInfoContainer {
private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/weapon/gui_turret_base.png");
private TileEntityTurretChekhov turret;
int index;
public GUITurretChekhov(InventoryPlayer invPlayer, TileEntityTurretChekhov tedf) {
super(new ContainerTurretChekhov(invPlayer, tedf));
@ -41,30 +45,57 @@ public class GUITurretChekhov extends GuiInfoContainer {
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
PacketDispatcher.wrapper.sendToServer(new AuxButtonPacket(turret.xCoord, turret.yCoord, turret.zCoord, 0, 0));
return;
}
if(guiLeft + 8 <= x && guiLeft + 8 + 10 > x && guiTop + 30 < y && guiTop + 30 + 10 >= y) {
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
PacketDispatcher.wrapper.sendToServer(new AuxButtonPacket(turret.xCoord, turret.yCoord, turret.zCoord, 0, 1));
return;
}
if(guiLeft + 22 <= x && guiLeft + 22 + 10 > x && guiTop + 30 < y && guiTop + 30 + 10 >= y) {
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
PacketDispatcher.wrapper.sendToServer(new AuxButtonPacket(turret.xCoord, turret.yCoord, turret.zCoord, 0, 2));
return;
}
if(guiLeft + 36 <= x && guiLeft + 36 + 10 > x && guiTop + 30 < y && guiTop + 30 + 10 >= y) {
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
PacketDispatcher.wrapper.sendToServer(new AuxButtonPacket(turret.xCoord, turret.yCoord, turret.zCoord, 0, 3));
return;
}
if(guiLeft + 50 <= x && guiLeft + 50 + 10 > x && guiTop + 30 < y && guiTop + 30 + 10 >= y) {
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
PacketDispatcher.wrapper.sendToServer(new AuxButtonPacket(turret.xCoord, turret.yCoord, turret.zCoord, 0, 4));
return;
}
int count = getCount();
if(count > 0) {
if(guiLeft + 7 <= x && guiLeft + 7 + 18 > x && guiTop + 80 < y && guiTop + 80 + 18 >= y) {
index--;
if(index < 0)
index = count - 1;
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
return;
}
if(guiLeft + 43 <= x && guiLeft + 43 + 18 > x && guiTop + 80 < y && guiTop + 80 + 18 >= y) {
index++;
index %= count;
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
return;
}
}
}
@ -74,13 +105,40 @@ public class GUITurretChekhov extends GuiInfoContainer {
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752);
this.fontRendererObj.drawString(I18n.format("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
List<String> names = turret.getWhitelist();
String n = EnumChatFormatting.ITALIC + "None";
if(names != null) {
n = names.get(index);
}
double scale = 2;
GL11.glScaled(1D / scale, 1D / scale, 1);
this.fontRendererObj.drawString(n, (int)(12 * scale), (int)(51 * scale), 0x00ff00);
GL11.glScaled(scale, scale, 1);
}
@Override
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int mX, int mY) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
if(guiLeft + 7 <= mX && guiLeft + 7 + 18 > mX && guiTop + 80 < mY && guiTop + 80 + 18 >=mY) {
drawTexturedModalRect(guiLeft + 7, guiTop + 80, 176, 58, 18, 18);
}
if(guiLeft + 43 <= mX && guiLeft + 43 + 18 > mX && guiTop + 80 < mY && guiTop + 80 + 18 >=mY) {
drawTexturedModalRect(guiLeft + 43, guiTop + 80, 194, 58, 18, 18);
}
if(guiLeft + 7 <= mX && guiLeft + 7 + 18 > mX && guiTop + 98 < mY && guiTop + 98 + 18 >=mY) {
drawTexturedModalRect(guiLeft + 7, guiTop + 98, 176, 76, 18, 18);
}
if(guiLeft + 43 <= mX && guiLeft + 43 + 18 > mX && guiTop + 98 < mY && guiTop + 98 + 18 >=mY) {
drawTexturedModalRect(guiLeft + 43, guiTop + 98, 194, 76, 18, 18);
}
int i = turret.getPowerScaled(53);
drawTexturedModalRect(guiLeft + 152, guiTop + 97 - i, 194, 52 - i, 16, i);
@ -99,5 +157,38 @@ public class GUITurretChekhov extends GuiInfoContainer {
if(turret.targetMachines)
drawTexturedModalRect(guiLeft + 50, guiTop + 30, 176, 30, 10, 10);
int tallies = turret.stattrak;
if(tallies >= 36) {
drawTexturedModalRect(guiLeft + 77, guiTop + 50, 176, 120, 63, 6);
} else {
int steps = (int)Math.ceil(tallies / 5D);
for(int s = 0; s < steps; s++) {
int m = tallies % 5;
if(s < steps - 1 || m == 0) {
drawTexturedModalRect(guiLeft + 77 + 9 * s, guiTop + 50, 194, 94, 9, 6);
} else {
drawTexturedModalRect(guiLeft + 77 + 9 * s, guiTop + 50, 176, 94, m * 2, 6);
}
}
}
}
private int getCount() {
List<String> names = turret.getWhitelist();
if(names == null)
return 0;
return names.size();
}
}

View File

@ -871,6 +871,14 @@ public class ModItems {
public static Item scrap;
public static Item trinitite;
public static Item nuclear_waste_long;
public static Item nuclear_waste_long_tiny;
public static Item nuclear_waste_short;
public static Item nuclear_waste_short_tiny;
public static Item nuclear_waste_long_depleted;
public static Item nuclear_waste_long_depleted_tiny;
public static Item nuclear_waste_short_depleted;
public static Item nuclear_waste_short_depleted_tiny;
public static Item nuclear_waste;
public static Item nuclear_waste_tiny;
public static Item rod_uranium_fuel_depleted;
@ -3005,6 +3013,14 @@ public class ModItems {
rod_quad_tritium = new ItemRadioactive(2F).setUnlocalizedName("rod_quad_tritium").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setContainerItem(ModItems.rod_quad_empty).setTextureName(RefStrings.MODID + ":rod_quad_tritium");
trinitite = new ItemRadioactive(5F).setUnlocalizedName("trinitite").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":trinitite_new");
nuclear_waste_long = new ItemRadioactive(5F).setUnlocalizedName("nuclear_waste_long").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":nuclear_waste_long");
nuclear_waste_long_tiny = new ItemRadioactive(0.5F).setUnlocalizedName("nuclear_waste_long_tiny").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":nuclear_waste_long_tiny");
nuclear_waste_short = new ItemRadioactive(30F, true).setUnlocalizedName("nuclear_waste_short").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":nuclear_waste_short");
nuclear_waste_short_tiny = new ItemRadioactive(3F, true).setUnlocalizedName("nuclear_waste_short_tiny").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":nuclear_waste_short_tiny");
nuclear_waste_long_depleted = new ItemRadioactive(0.5F).setUnlocalizedName("nuclear_waste_long_depleted").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":nuclear_waste_long_depleted");
nuclear_waste_long_depleted_tiny = new ItemRadioactive(0.05F).setUnlocalizedName("nuclear_waste_long_depleted_tiny").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":nuclear_waste_long_depleted_tiny");
nuclear_waste_short_depleted = new ItemRadioactive(3F).setUnlocalizedName("nuclear_waste_short_depleted").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":nuclear_waste_short_depleted");
nuclear_waste_short_depleted_tiny = new ItemRadioactive(0.3F).setUnlocalizedName("nuclear_waste_short_depleted_tiny").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":nuclear_waste_short_depleted_tiny");
nuclear_waste = new ItemRadioactive(15F).setUnlocalizedName("nuclear_waste").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":nuclear_waste");
nuclear_waste_tiny = new ItemRadioactive(2F).setUnlocalizedName("nuclear_waste_tiny").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":nuclear_waste_tiny");
waste_uranium = new ItemRadioactive(15F).setUnlocalizedName("waste_uranium").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":waste_uranium");
@ -5519,6 +5535,14 @@ public class ModItems {
GameRegistry.registerItem(waste_mox, waste_mox.getUnlocalizedName());
GameRegistry.registerItem(waste_schrabidium, waste_schrabidium.getUnlocalizedName());
GameRegistry.registerItem(trinitite, trinitite.getUnlocalizedName());
GameRegistry.registerItem(nuclear_waste_long, nuclear_waste_long.getUnlocalizedName());
GameRegistry.registerItem(nuclear_waste_long_tiny, nuclear_waste_long_tiny.getUnlocalizedName());
GameRegistry.registerItem(nuclear_waste_short, nuclear_waste_short.getUnlocalizedName());
GameRegistry.registerItem(nuclear_waste_short_tiny, nuclear_waste_short_tiny.getUnlocalizedName());
GameRegistry.registerItem(nuclear_waste_long_depleted, nuclear_waste_long_depleted.getUnlocalizedName());
GameRegistry.registerItem(nuclear_waste_long_depleted_tiny, nuclear_waste_long_depleted_tiny.getUnlocalizedName());
GameRegistry.registerItem(nuclear_waste_short_depleted, nuclear_waste_short_depleted.getUnlocalizedName());
GameRegistry.registerItem(nuclear_waste_short_depleted_tiny, nuclear_waste_short_depleted_tiny.getUnlocalizedName());
GameRegistry.registerItem(nuclear_waste, nuclear_waste.getUnlocalizedName());
GameRegistry.registerItem(nuclear_waste_tiny, nuclear_waste_tiny.getUnlocalizedName());

View File

@ -11,10 +11,9 @@ import net.minecraft.util.ChatComponentText;
import net.minecraft.world.World;
public class ItemTurretBiometry extends Item {
@Override
public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean bool)
{
public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean bool) {
String[] names = getNames(itemstack);
if(names != null)
for(int i = 0; i < names.length; i++)
@ -24,60 +23,60 @@ public class ItemTurretBiometry extends Item {
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
addName(stack, player.getUniqueID().toString());
addName(stack, player.getDisplayName());
if(world.isRemote)
player.addChatMessage(new ChatComponentText("Added player data!"));
if(world.isRemote)
player.addChatMessage(new ChatComponentText("Added player data!"));
world.playSoundAtEntity(player, "hbm:item.techBleep", 1.0F, 1.0F);
world.playSoundAtEntity(player, "hbm:item.techBleep", 1.0F, 1.0F);
player.swingItem();
return stack;
}
public static String[] getNames(ItemStack stack) {
if(stack.stackTagCompound == null) {
stack.stackTagCompound = new NBTTagCompound();
return null;
}
String[] names = new String [stack.stackTagCompound.getInteger("playercount")];
String[] names = new String[stack.stackTagCompound.getInteger("playercount")];
for(int i = 0; i < names.length; i++) {
names[i] = stack.stackTagCompound.getString("player_" + i);
}
if(names.length == 0)
return null;
return names;
}
public static void addName(ItemStack stack, String s) {
if(stack.stackTagCompound == null) {
stack.stackTagCompound = new NBTTagCompound();
}
String[] names = getNames(stack);
int count = 0;
if(names != null && Arrays.asList(names).contains(s))
return;
if(names != null)
count = names.length;
stack.stackTagCompound.setInteger("playercount", count + 1);
stack.stackTagCompound.setString("player_" + count, s);
}
public static void clearNames(ItemStack stack) {
if(stack.stackTagCompound == null) {
stack.stackTagCompound = new NBTTagCompound();
}
stack.stackTagCompound.setInteger("playercount", 0);
}
}

View File

@ -12,30 +12,28 @@ import net.minecraft.util.ChatComponentText;
import net.minecraft.world.World;
public class ItemTurretChip extends ItemTurretBiometry {
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_)
{
if((world.getBlock(x, y, z) instanceof TurretBase))
{
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_) {
if((world.getBlock(x, y, z) instanceof TurretBase)) {
if(getNames(stack) == null)
return false;
TileEntity te = world.getTileEntity(x, y, z);
if(te instanceof TileEntityTurretBase) {
((TileEntityTurretBase)te).isAI = true;
((TileEntityTurretBase)te).players = Arrays.asList(getNames(stack));
((TileEntityTurretBase) te).isAI = true;
((TileEntityTurretBase) te).players = Arrays.asList(getNames(stack));
}
if(world.isRemote)
{
player.addChatMessage(new ChatComponentText("Transferred turret ownership!"));
if(world.isRemote) {
player.addChatMessage(new ChatComponentText("Transferred turret ownership!"));
}
world.playSoundAtEntity(player, "hbm:item.techBleep", 1.0F, 1.0F);
return true;
return true;
}
return false;
}
return false;
}
}

View File

@ -106,7 +106,7 @@ public abstract class TileEntityTurretBase extends TileEntity {
if(this instanceof TileEntityTurretCIWS && !(e instanceof EntityMissileBaseAdvanced) && !(e instanceof EntityBomber) && !(e instanceof EntityMissileCustom))
return false;
if(e instanceof EntityPlayer && players.contains((((EntityPlayer)e).getUniqueID().toString())))
if(e instanceof EntityPlayer && players.contains((((EntityPlayer)e).getDisplayName())))
return false;
Vec3 turret;

View File

@ -1,5 +1,6 @@
package com.hbm.tileentity.turret;
import java.util.Arrays;
import java.util.List;
import com.hbm.blocks.BlockDummyable;
@ -9,6 +10,8 @@ import com.hbm.entity.projectile.EntityBulletBase;
import com.hbm.handler.BulletConfigSyncingUtil;
import com.hbm.handler.BulletConfiguration;
import com.hbm.interfaces.IConsumer;
import com.hbm.items.ModItems;
import com.hbm.items.machine.ItemTurretBiometry;
import com.hbm.lib.Library;
import com.hbm.tileentity.TileEntityMachineBase;
@ -111,6 +114,14 @@ public abstract class TileEntityTurretBaseNT extends TileEntityMachineBase imple
this.aligned = false;
if(!worldObj.isRemote) {
if(this.target != null && !target.isEntityAlive()) {
this.target = null;
this.stattrak++;
}
}
if(target != null) {
if(!this.entityInLOS(this.target)) {
this.target = null;
@ -269,9 +280,54 @@ public abstract class TileEntityTurretBaseNT extends TileEntityMachineBase imple
* @return null if there is either no chip to be found or if the name list is empty, otherwise it just reads the strings from the chip's NBT
*/
public List<String> getWhitelist() {
if(slots[0] != null && slots[0].getItem() == ModItems.turret_chip) {
String[] array = ItemTurretBiometry.getNames(slots[0]);
if(array == null)
return null;
return Arrays.asList(ItemTurretBiometry.getNames(slots[0]));
}
return null;
}
/**
* Appends a new name to the chip
* @param name
*/
public void addName(String name) {
if(slots[0] != null && slots[0].getItem() == ModItems.turret_chip) {
ItemTurretBiometry.addName(slots[0], name);
}
}
/**
* Removes the chip's entry at a given
* @param index
*/
public void removeName(String index) {
if(slots[0] != null && slots[0].getItem() == ModItems.turret_chip) {
String[] array = ItemTurretBiometry.getNames(slots[0]);
if(array == null)
return;
List<String> names = Arrays.asList(array);
ItemTurretBiometry.clearNames(slots[0]);
names.remove(index);
for(String name : names)
ItemTurretBiometry.addName(slots[0], name);
}
}
/**
* Finds the nearest acceptable target within range and in line of sight
*/
@ -400,6 +456,7 @@ public abstract class TileEntityTurretBaseNT extends TileEntityMachineBase imple
if(pitchDeg < -this.getTurretDepression() || pitchDeg > this.getTurretElevation())
return false;
//TODO: figure out why this shit apparently doesn't work
return !Library.isObstructed(worldObj, pos.xCoord, pos.yCoord, pos.zCoord, ent.xCoord, ent.yCoord, ent.zCoord);
}
@ -489,7 +546,7 @@ public abstract class TileEntityTurretBaseNT extends TileEntityMachineBase imple
* @return
*/
public int getDecetorInterval() {
return 20;
return 10;
}
/**

View File

@ -95,7 +95,7 @@ public class TileEntityTurretChekhov extends TileEntityTurretBaseNT {
if(worldObj.isRemote) {
if(this.aligned) {
if(this.target != null) {
this.accel = Math.min(45F, this.accel += 2);
} else {
this.accel = Math.max(0F, this.accel -= 2);
@ -110,8 +110,16 @@ public class TileEntityTurretChekhov extends TileEntityTurretBaseNT {
}
} else {
if(!this.aligned)
this.timer = 0;
if(this.target == null) {
this.timer--;
if(timer > 20)
timer = 20;
if(timer < 0)
timer = 0;
}
}
}
}