siege drill basecode, some GUI util stuff

This commit is contained in:
Boblet 2022-01-25 16:34:19 +01:00
parent 21a9427933
commit ae6a39fdc7
11 changed files with 365 additions and 4 deletions

View File

@ -0,0 +1,83 @@
package com.hbm.entity.mob;
import net.minecraft.entity.EntityCreature;
import net.minecraft.world.World;
/**
* Base class for "digging" entities, removes things such as fall behavior, enables noClip and implements some basic movement code
* @author hbm
*/
public abstract class EntityBurrowingBase extends EntityCreature {
protected float airDrag;
protected float groundDrag;
public EntityBurrowingBase(World world) {
super(world);
this.noClip = true;
}
/**
* Since most burrowing entities (such as worms, drills and whatnot) rotate along with their movement, center the eye height.
* We can override this later on in case we have an "upright" burrowing entity.
*/
@Override
public float getEyeHeight() {
return this.height * 0.5F;
}
/**
* No fall and fallstate functions
*/
@Override
protected void fall(float dist) { }
@Override
protected void updateFallState(double distFallen, boolean onGround) { }
/**
* Calls moveFlying to add motion depending on our entity's rotation, then moves. Drag is applied depending on whether it is underground or airborne.
* Called in onLivingUpdate TODO: figure out if strafe and forward are set by one of the superclasses or if this part is pointless
*/
@Override
public void moveEntityWithHeading(float strafe, float forward) {
float drag = this.groundDrag;
if(!isEntityInsideOpaqueBlock() && !isInWater() && !handleLavaMovement()) {
drag = this.airDrag;
}
//misnomer, actually just sets the motion, the moving part happens the line after that
moveFlying(strafe, forward, 0.02F);
moveEntity(this.motionX, this.motionY, this.motionZ);
this.motionX *= drag;
this.motionY *= drag;
this.motionZ *= drag;
}
/**
* Sorry, can't use ladders.
*/
@Override
public boolean isOnLadder() {
return false;
}
/**
* If the mob supports the movement behavior through air
* @return true if the entity can fly and false if it can only move through ground.
*/
public boolean canFly() {
return false;
}
/**
* Whether the entity can freely dig up and down or if gravity should be applied instead.
* Some entities might not be able to course-correct when airborne, such as small non-worm entities.
* @return true if vertical movement can be performed and false if gravity should apply.
*/
protected boolean canSupportMovement() {
return isEntityInsideOpaqueBlock() || canFly();
}
}

View File

@ -3,6 +3,7 @@ package com.hbm.entity.mob.botprime;
import net.minecraft.entity.EntityCreature;
import net.minecraft.world.World;
@Deprecated
public abstract class EntityBurrowingNT extends EntityCreature {
protected float dragInAir;

View File

@ -1732,6 +1732,8 @@ public class GUIHandler implements IGuiHandler {
return new GUIScreenGuide(player);
case ModItems.guiID_item_bobble:
return new GUIScreenBobble((TileEntityBobble) world.getTileEntity(x, y, z));
case ModItems.guiID_item_holo_image:
return new GUIScreenHolotape();
}
return null;
}

View File

@ -102,16 +102,16 @@ public class GUIMachineRadar extends GuiInfoContainer {
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
drawTexturedModalRect(guiLeft - 14, guiTop + 94, 216, 198, 14, 46);
if(diFurnace.scanMissiles)
if(diFurnace.scanMissiles || (diFurnace.jammed && diFurnace.getWorldObj().rand.nextBoolean()))
drawTexturedModalRect(guiLeft - 10, guiTop + 98, 230, 202, 8, 8);
if(diFurnace.scanPlayers)
if(diFurnace.scanPlayers || (diFurnace.jammed && diFurnace.getWorldObj().rand.nextBoolean()))
drawTexturedModalRect(guiLeft - 10, guiTop + 108, 230, 212, 8, 8);
if(diFurnace.smartMode)
if(diFurnace.smartMode || (diFurnace.jammed && diFurnace.getWorldObj().rand.nextBoolean()))
drawTexturedModalRect(guiLeft - 10, guiTop + 118, 230, 222, 8, 8);
if(diFurnace.redMode)
if(diFurnace.redMode || (diFurnace.jammed && diFurnace.getWorldObj().rand.nextBoolean()))
drawTexturedModalRect(guiLeft - 10, guiTop + 128, 230, 232, 8, 8);
if(diFurnace.power > 0) {
@ -119,6 +119,17 @@ public class GUIMachineRadar extends GuiInfoContainer {
drawTexturedModalRect(guiLeft + 8, guiTop + 221, 0, 234, i, 16);
}
if(diFurnace.jammed) {
for(int i = 0; i < 5; i++) {
for(int j = 0; j < 5; j++) {
drawTexturedModalRect(guiLeft + 8 + i * 40, guiTop + 17 + j * 40, 216, 118 + diFurnace.getWorldObj().rand.nextInt(41), 40, 40);
}
}
return;
}
if(!diFurnace.nearbyMissiles.isEmpty()) {
for(int[] m : diFurnace.nearbyMissiles) {
int x = (int)((m[0] - diFurnace.xCoord) / ((double)WeaponConfig.radarRange * 2 + 1) * (200D - 8D)) - 4;

View File

@ -0,0 +1,96 @@
package com.hbm.inventory.gui;
import java.util.List;
import org.lwjgl.opengl.GL11;
import com.hbm.items.ModItems;
import com.hbm.items.special.ItemHolotapeImage.EnumHoloImage;
import com.hbm.util.EnumUtil;
import com.hbm.util.I18nUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
public class GUIScreenHolotape extends GuiScreen {
EnumHoloImage holo;
@Override
public void initGui() {
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("hbm:block.bobble"), 1.0F));
ItemStack stack = Minecraft.getMinecraft().thePlayer.getHeldItem();
if(stack != null && stack.getItem() == ModItems.holotape_image) {
this.holo = EnumUtil.grabEnumSafely(EnumHoloImage.class, stack.getItemDamage());
} else {
this.mc.thePlayer.closeScreen();
}
}
@Override
public void drawScreen(int mouseX, int mouseY, float f) {
if(this.holo == null)
return;
this.drawDefaultBackground();
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_ALPHA_TEST);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
GL11.glDisable(GL11.GL_TEXTURE_2D);
double sizeX = 300;
double sizeY = 150;
double left = (this.width - sizeX) / 2;
double top = (this.height - sizeY) / 2;
Tessellator tess = Tessellator.instance;
tess.startDrawingQuads();
tess.setColorRGBA_F(0F, 0.2F, 0F, 0.8F);
tess.addVertex(left + sizeX, top, this.zLevel);
tess.addVertex(left, top, this.zLevel);
tess.addVertex(left, top + sizeY, this.zLevel);
tess.addVertex(left + sizeX, top + sizeY, this.zLevel);
tess.draw();
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glDisable(GL11.GL_BLEND);
int nextLevel = (int)top + 30;
if(this.holo.getText() != null) {
List<String> lines = I18nUtil.autoBreak(this.fontRendererObj, this.holo.getText(), 50);
for(String text : lines) {
this.fontRendererObj.drawStringWithShadow(text, (int)(left + sizeX / 2 - this.fontRendererObj.getStringWidth(text) / 2), nextLevel, 0x009900);
nextLevel += 10;
}
nextLevel += 10;
}
GL11.glEnable(GL11.GL_LIGHTING);
}
@Override
protected void keyTyped(char c, int key) {
if(key == 1 || key == this.mc.gameSettings.keyBindInventory.getKeyCode()) {
this.mc.thePlayer.closeScreen();
}
}
@Override
public boolean doesGuiPauseGame() {
return false;
}
}

View File

@ -2336,6 +2336,7 @@ public class ModItems {
public static Item record_glass;
public static Item book_guide;
public static Item holotape_image;
public static Item polaroid;
public static Item glitch;
@ -2471,6 +2472,7 @@ public class ModItems {
public static final int guiID_item_book = 10105;
public static final int guiID_item_guide = 10106;
public static final int guiID_item_bobble = 10107;
public static final int guiID_item_holo_image = 10108;
public static Item mysteryshovel;
public static Item memory;
@ -5320,6 +5322,7 @@ public class ModItems {
record_glass = new ItemModRecord("glass").setUnlocalizedName("record_glass").setCreativeTab(null).setTextureName(RefStrings.MODID + ":record_glass");
book_guide = new ItemGuideBook().setUnlocalizedName("book_guide").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":book_guide");
holotape_image = new ItemHolotapeImage().setUnlocalizedName("holotape_image").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":holotape");
polaroid = new ItemPolaroid().setUnlocalizedName("polaroid").setMaxStackSize(1).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":polaroid_" + MainRegistry.polaroidID);
glitch = new ItemGlitch().setUnlocalizedName("glitch").setMaxStackSize(1).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":glitch_" + MainRegistry.polaroidID);
@ -7794,6 +7797,7 @@ public class ModItems {
//wow we're far down the item registry, is this the cellar?
GameRegistry.registerItem(book_guide, book_guide.getUnlocalizedName());
GameRegistry.registerItem(holotape_image, holotape_image.getUnlocalizedName());
//Technical Items
GameRegistry.registerItem(smoke1, smoke1.getUnlocalizedName());

View File

@ -0,0 +1,10 @@
package com.hbm.items.special;
import com.hbm.items.ItemEnumMulti;
public class ItemHoloTape extends ItemEnumMulti {
public ItemHoloTape(Class<? extends Enum> theEnum, boolean multiName, boolean multiTexture) {
super(theEnum, multiName, multiTexture);
}
}

View File

@ -0,0 +1,67 @@
package com.hbm.items.special;
import java.util.List;
import com.hbm.items.ModItems;
import com.hbm.main.MainRegistry;
import com.hbm.util.EnumUtil;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
public class ItemHolotapeImage extends ItemHoloTape {
public ItemHolotapeImage() {
super(EnumHoloImage.class, false, false);
}
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
if(world.isRemote) player.openGui(MainRegistry.instance, ModItems.guiID_item_holo_image, world, 0, 0, 0);
return stack;
}
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) {
EnumHoloImage holo = EnumUtil.grabEnumSafely(EnumHoloImage.class, stack.getItemDamage());
list.add("Band Color: " + holo.colorCode + holo.colorName);
list.add("Label: " + holo.name);
}
public static enum EnumHoloImage {
HOLO_DIGAMMA( EnumChatFormatting.RED, "Crimson", "-", "The tape contains a music track that has degraded heavily in quality, making it near-impossible to make out what it once was. There is an image file on it that has also lost its quality, being reduced to a blur of crimson and cream colors. The disk has small shreds of greasy wrapping paper stuck to it."),
HOLO_RESTORED( EnumChatFormatting.RED, "Crimson", "-", "The tape contains a music track that you do not recognize, consisting of mostly electric guitars with lyrics telling the story of a man being left by someone who is moving to another city. The tape also contains an image file, the crimson and cream colors sharp on an otherwise colorless background. You try to look closer but you can't. It feels as if reality itself is twisted and stretched and snapped back into shape like a rubber band."),
HOLO_FE_HALL( EnumChatFormatting.GREEN, "Lime", "-", "The tape contains an audio track that is mostly gabled sound and garbage noise. There is an image file on it, depicting a small hall with a fountain in the center, a metal door to the left and an open wooden door to the right, with faint green light coming through the doorway. On the left wall of the room, there is a wooden bench with a skeleton sitting on it."),
HOLO_FE_CORRIDOR( EnumChatFormatting.GREEN, "Lime", "-", "The tape contains an audio track that is mostly gabled sound and garbage noise. There is an image file on it, depicting a short hallway with a terminal screen mounted to the right wall, bathing the corridor in a phosphorus-green light. In front of the terminal, an unusually large skeleton is piled up on the floor. On the back of the hallway there's a sturdy metal door standing open."),
HOLO_FE_SERVER( EnumChatFormatting.GREEN, "Lime", "-", "The tape contains an audio track that is mostly gabled sound and garbage noise. There is an image file on it, depicting what appears to be a server room with racks covering every wall. In the center, what appears to be some sort of super computer is standing tall, with wires coming out from it, going in every direction. On the right side of the room, a small brass trapdoor stands open where one of the wall racks would be."),
HOLO_FEH_DOME( EnumChatFormatting.RED, "Red", "-", "The tape contains an audio track that is mostly gabled sound and garbage noise. There is an image file on it, depicting the insides of a large dome-like concrete structure that is mostly empty, save for a few catwalks and a shiny blueish metal capsule suspended in the center. In the background, the faint outline of a what appears to be a tank is visible, sporting mechanic legs instead of treads."),
HOLO_FEH_BOAT( EnumChatFormatting.RED, "Red", "-", "The tape contains an audio track that is mostly gabled sound and garbage noise. There is an image file on it, depicting the wooden deck of what appears to be an old rover boat. There are four rusted railway spikes stuck in the planks in a roughly square shape."),
HOLO_FEH_LSC( EnumChatFormatting.RED, "Red", "-", "The tape contains an audio track that is mostly gabled sound and garbage noise. There is an image file on it, depicting an array of launch pads surrounded by large metal bulwarks. Two of the launch pads are empty, the remaining rockets seem to be heavily damaged. A tipped-over booster is visible, creating plumes of fog."),
HOLO_F3_RC( EnumChatFormatting.DARK_GREEN, "Green", "-", "The tape contains an audio track that is mostly gabled sound and garbage noise. There is an image file on it, depicting an old aircraft carrier that has broken in two. A makeshift bridge held up by the ship's crane connects the tower with a small building on the shore."),
HOLO_F3_IV( EnumChatFormatting.DARK_GREEN, "Green", "-", "The tape contains an audio track that is mostly gabled sound and garbage noise. There is a very grainy image file on it, depicting what appears to be a crater with a small tunnel leading into the ground at the very bottom, closed off with a small wooden door."),
HOLO_F3_WM( EnumChatFormatting.DARK_GREEN, "Green", "-", "The tape contains an audio track that is mostly gabled sound and garbage noise. There is an image file on it, depicting a large white obelisk that seems half destroyed. At the top there is a radio dish sticking out of the structure."),
HOLO_NV_CRATER( EnumChatFormatting.GOLD, "Brown", "-", "The tape contains an audio track that is mostly gabled sound and garbage noise. There is an image file on it, depicting a large dome in blue light surrounded by many smaller buildings. In the distance, there is a smaller dome with red lights."),
HOLO_NV_DIVIDE( EnumChatFormatting.GOLD, "Brown", "-", "The tape contains an audio track that is mostly gabled sound and garbage noise. There is an image file on it, depicting a large chasm with broken highways and destroyed buildings littering the landscape."),
HOLO_NV_BM( EnumChatFormatting.GOLD, "Brown", "-", "The tape contains an audio track that is mostly gabled sound and garbage noise. There is an image file on it, depicting a satellite broadcasting station on top of a hill. In the distance, there is a very large person walking hand in hand with a robot into the sunset."),
;
private String name;
private String text;
private String colorName;
private EnumChatFormatting colorCode;
private EnumHoloImage(EnumChatFormatting colorCode, String colorName, String name, String text) {
this.name = name;
this.text = text;
this.colorName = name;
this.colorCode = colorCode;
}
public String getText() {
return this.text;
}
}
}

View File

@ -5,6 +5,7 @@ import java.util.List;
import com.hbm.blocks.ModBlocks;
import com.hbm.config.WeaponConfig;
import com.hbm.extprop.HbmLivingProps;
import com.hbm.interfaces.Untested;
import com.hbm.tileentity.TileEntityTickingBase;
@ -14,6 +15,7 @@ import api.hbm.entity.IRadarDetectable.RadarTargetType;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
@ -31,6 +33,8 @@ public class TileEntityMachineRadar extends TileEntityTickingBase implements IEn
public boolean scanPlayers = true;
public boolean smartMode = true;
public boolean redMode = true;
public boolean jammed = false;
public float prevRotation;
public float rotation;
@ -109,6 +113,7 @@ public class TileEntityMachineRadar extends TileEntityTickingBase implements IEn
nearbyMissiles.clear();
entList.clear();
jammed = false;
List<Entity> list = worldObj.getEntitiesWithinAABBExcludingEntity(null, AxisAlignedBB.getBoundingBox(xCoord + 0.5 - WeaponConfig.radarRange, 0, zCoord + 0.5 - WeaponConfig.radarRange, xCoord + 0.5 + WeaponConfig.radarRange, 5000, zCoord + 0.5 + WeaponConfig.radarRange));
@ -116,6 +121,13 @@ public class TileEntityMachineRadar extends TileEntityTickingBase implements IEn
if(e.posY < yCoord + WeaponConfig.radarBuffer)
continue;
if(e instanceof EntityLivingBase && HbmLivingProps.getDigamma((EntityLivingBase) e) > 0.001) {
this.jammed = true;
nearbyMissiles.clear();
entList.clear();
return;
}
if(e instanceof EntityPlayer && this.scanPlayers) {
nearbyMissiles.add(new int[] { (int)e.posX, (int)e.posZ, RadarTargetType.PLAYER.ordinal(), (int)e.posY });
@ -181,6 +193,7 @@ public class TileEntityMachineRadar extends TileEntityTickingBase implements IEn
data.setBoolean("scanPlayers", scanPlayers);
data.setBoolean("smartMode", smartMode);
data.setBoolean("redMode", redMode);
data.setBoolean("jammed", jammed);
data.setInteger("count", this.nearbyMissiles.size());
for(int i = 0; i < this.nearbyMissiles.size(); i++) {
@ -201,6 +214,7 @@ public class TileEntityMachineRadar extends TileEntityTickingBase implements IEn
this.scanPlayers = data.getBoolean("scanPlayers");
this.smartMode = data.getBoolean("smartMode");
this.redMode = data.getBoolean("redMode");
this.jammed = data.getBoolean("jammed");
int count = data.getInteger("count");

View File

@ -1,14 +1,87 @@
package com.hbm.util;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.resources.I18n;
public class I18nUtil {
/**
* Simple wrapper for I18n, for consistency
* @param s
* @param args
* @return
*/
public static String resolveKey(String s, Object... args) {
return I18n.format(s, args);
}
/**
* Wrapper for I18n but cuts up the result using NTM's line break character ($)
* @param s
* @param args
* @return
*/
public static String[] resolveKeyArray(String s, Object... args) {
return resolveKey(s, args).split("\\$");
}
/**
* The same as autoBreak, but it also respects NTM's break character ($) for manual line breaking in addition to the automatic ones
* @param fontRenderer
* @param text
* @param width
* @return
*/
public static List<String> autoBreakWithParagraphs(FontRenderer fontRenderer, String text, int width) {
String[] paragraphs = text.split("\\$");
List<String> lines = new ArrayList();
for(String paragraph : paragraphs) {
lines.addAll(autoBreak(fontRenderer, paragraph, width));
}
return lines;
}
/**
* Turns one string into a list of strings, cutting sentences up to fit within the defined width if they were rendered in a GUI
* @param fontRenderer
* @param text
* @param width
* @return
*/
public static List<String> autoBreak(FontRenderer fontRenderer, String text, int width) {
List<String> lines = new ArrayList();
//split the text by all spaces
String[] words = text.split(" ");
//add the first word to the first line, no matter what
lines.add(words[0]);
//starting indent is the width of the first word
int indent = fontRenderer.getStringWidth(words[0]);
for(int w = 1; w < words.length; w++) {
//increment the indent by the width of the next word + leading space
indent += fontRenderer.getStringWidth(" " + words[w]);
//if the indent is within bounds
if(indent <= width) {
//add the next word to the last line (i.e. the one in question)
String last = lines.get(lines.size() - 1);
lines.set(lines.size() - 1, last += (" " + words[w]));
} else {
//otherwise, start a new line and reset the indent
lines.add(words[w]);
indent = fontRenderer.getStringWidth(words[w]);
}
}
return lines;
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 12 KiB