finished RBMK auto control GUI, basic functionality, block spiders

This commit is contained in:
Bob 2021-04-21 22:56:36 +02:00
parent 6235e886de
commit 23fb11a3e4
11 changed files with 1571 additions and 25 deletions

View File

@ -0,0 +1,54 @@
package com.hbm.entity.mob;
import net.minecraft.block.Block;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
public class EntityBlockSpider extends EntityMob {
public EntityBlockSpider(World world) {
super(world);
this.setSize(0.95F, 1.25F);
this.getNavigator().setAvoidsWater(true);
this.tasks.addTask(1, new EntityAIWander(this, 0.5F));
this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, true));
}
@Override
protected void applyEntityAttributes() {
super.applyEntityAttributes();
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(10.0D);
this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(1F);
}
@Override
public boolean isAIEnabled() {
return true;
}
@Override
protected void entityInit() {
super.entityInit();
this.dataWatcher.addObject(12, 1);
this.dataWatcher.addObject(13, 0);
}
public void makeBlock(Block block, int meta) {
int b = Block.getIdFromBlock(block);
this.dataWatcher.updateObject(12, b);
this.dataWatcher.updateObject(13, meta);
double health = Math.max(1D, block.getExplosionResistance(null));
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(health);
this.setHealth(this.getMaxHealth());
}
}

View File

@ -1,64 +1,128 @@
package com.hbm.inventory.gui;
import org.apache.commons.lang3.math.NumberUtils;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
import com.hbm.inventory.container.ContainerRBMKControlAuto;
import com.hbm.lib.RefStrings;
import com.hbm.packet.AuxButtonPacket;
import com.hbm.packet.NBTControlPacket;
import com.hbm.packet.PacketDispatcher;
import com.hbm.tileentity.machine.rbmk.TileEntityRBMKControlAuto;
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
public class GUIRBMKControlAuto extends GuiInfoContainer {
private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/reactors/gui_rbmk_control_auto.png");
private TileEntityRBMKControlAuto rod;
private GuiTextField[] fields;
public GUIRBMKControlAuto(InventoryPlayer invPlayer, TileEntityRBMKControlAuto tedf) {
super(new ContainerRBMKControlAuto(invPlayer, tedf));
rod = tedf;
fields = new GuiTextField[4];
this.xSize = 176;
this.ySize = 186;
}
public void initGui() {
super.initGui();
Keyboard.enableRepeatEvents(true);
for(int i = 0; i < 4; i++) {
this.fields[i] = new GuiTextField(this.fontRendererObj, guiLeft + 30, guiTop + 27 + 11 * i, 26, 6);
this.fields[i].setTextColor(-1);
this.fields[i].setDisabledTextColour(-1);
this.fields[i].setEnableBackgroundDrawing(false);
if(i < 2)
this.fields[i].setMaxStringLength(3);
else
this.fields[i].setMaxStringLength(4);
}
this.fields[0].setText(String.valueOf((int)rod.levelUpper));
this.fields[1].setText(String.valueOf((int)rod.levelLower));
this.fields[2].setText(String.valueOf((int)rod.heatUpper));
this.fields[3].setText(String.valueOf((int)rod.heatLower));
}
@Override
public void drawScreen(int mouseX, int mouseY, float f) {
super.drawScreen(mouseX, mouseY, f);
this.drawCustomInfoStat(mouseX, mouseY, guiLeft + 124, guiTop + 29, 16, 56, mouseX, mouseY, new String[]{ (int)(rod.level * 100) + "%" } );
String func = "Function: ";
switch(rod.function) {
case LINEAR: func += " Linear"; break;
case QUAD_UP: func += " Quadratic"; break;
case QUAD_DOWN: func += " Negative Quadratic"; break;
}
this.drawCustomInfoStat(mouseX, mouseY, guiLeft + 69, guiTop + 27, 26, 19, mouseX, mouseY, new String[]{ (int)(rod.level * 100) + "%" } );
}
@Override
protected void mouseClicked(int x, int y, int i) {
super.mouseClicked(x, y, i);
/*for(int k = 0; k < 5; k++) {
for(int j = 0; j < 4; j++) {
this.fields[j].mouseClicked(x, y, i);
}
if(guiLeft + 28 <= x && guiLeft + 28 + 30 > x && guiTop + 70 < y && guiTop + 70 +10 >= y) {
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
NBTTagCompound data = new NBTTagCompound();
double[] vals = new double[] {0D ,0D, 0D, 0D};
for(int k = 0; k < 4; k++) {
double clamp = k < 2 ? 100 : 9999;
if(NumberUtils.isNumber(fields[k].getText())) {
int j = (int)MathHelper.clamp_double(Double.parseDouble(fields[k].getText()), 0, clamp);
fields[k].setText(j + "");
vals[k] = j;
} else {
fields[k].setText("0");
}
}
data.setDouble("levelUpper", vals[0]);
data.setDouble("levelLower", vals[1]);
data.setDouble("heatUpper", vals[2]);
data.setDouble("heatLower", vals[3]);
PacketDispatcher.wrapper.sendToServer(new NBTControlPacket(data, rod.xCoord, rod.yCoord, rod.zCoord));
}
for(int k = 0; k < 3; k++) {
//manual rod control
if(guiLeft + 118 <= x && guiLeft + 118 + 30 > x && guiTop + 26 + k * 11 < y && guiTop + 26 + 10 + k * 11 >= y) {
if(guiLeft + 61 <= x && guiLeft + 61 + 22 > x && guiTop + 48 + k * 11 < y && guiTop + 48 + 10 + k * 11 >= y) {
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
NBTTagCompound data = new NBTTagCompound();
data.setDouble("level", 1.0D - (k * 0.25D));
data.setInteger("function", k);
PacketDispatcher.wrapper.sendToServer(new NBTControlPacket(data, rod.xCoord, rod.yCoord, rod.zCoord));
}
//color groups
if(guiLeft + 28 <= x && guiLeft + 28 + 12 > x && guiTop + 26 + k * 11 < y && guiTop + 26 + 10 + k * 11 >= y) {
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
NBTTagCompound data = new NBTTagCompound();
data.setInteger("color", k);
PacketDispatcher.wrapper.sendToServer(new NBTControlPacket(data, rod.xCoord, rod.yCoord, rod.zCoord));
}
}*/
}
}
@Override
@ -80,6 +144,22 @@ public class GUIRBMKControlAuto extends GuiInfoContainer {
if(height > 0)
drawTexturedModalRect(guiLeft + 124, guiTop + 29, 176, 56 - height, 8, height);
drawTexturedModalRect(guiLeft + 59, guiTop + 27, 184, 0, 26, 19);
int f = rod.function.ordinal();
drawTexturedModalRect(guiLeft + 59, guiTop + 27, 184, f * 19, 26, 19);
for(int i = 0; i < 4; i++) {
this.fields[i].drawTextBox();
}
}
@Override
protected void keyTyped(char c, int i) {
for(int j = 0; j < 4; j++) {
if(this.fields[j].textboxKeyTyped(c, i))
return;
}
super.keyTyped(c, i);
}
}

View File

@ -2,16 +2,12 @@ package com.hbm.items.tool;
import java.util.List;
import com.hbm.entity.mob.EntityBlockSpider;
import com.hbm.lib.Library;
import com.hbm.main.MainRegistry;
import com.hbm.world.dungeon.AncientTomb;
import com.hbm.world.dungeon.Spaceship;
import com.hbm.world.generator.CellularDungeonFactory;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
@ -29,8 +25,16 @@ public class ItemWandD extends Item {
int x = pos.blockX;
int z = pos.blockZ;
int y = world.getHeightValue(x, z);
//int y = world.getHeightValue(x, z);
int y = pos.blockY;
EntityBlockSpider spider = new EntityBlockSpider(world);
spider.setPosition(x + 0.5, y, z + 0.5);
spider.makeBlock(world.getBlock(x, y, z), world.getBlockMetadata(x, y, z));
world.setBlockToAir(x, y, z);
world.spawnEntityInWorld(spider);
/*NBTTagCompound data = new NBTTagCompound();
data.setString("type", "rift");
data.setDouble("posX", x);
@ -47,7 +51,7 @@ public class ItemWandD extends Item {
//CellularDungeonFactory.jungle.generate(world, x, y + 4, z, world.rand);
//CellularDungeonFactory.jungle.generate(world, x, y + 8, z, world.rand);
new AncientTomb().build(world, world.rand, x, y + 10, z);
//new AncientTomb().build(world, world.rand, x, y + 10, z);
//new ArcticVault().trySpawn(world, x, y, z);

View File

@ -503,6 +503,7 @@ public class ClientProxy extends ServerProxy {
RenderingRegistry.registerEntityRenderingHandler(EntityQuackos.class, new RenderQuacc(new ModelChicken(), 7.5F));
RenderingRegistry.registerEntityRenderingHandler(EntityFBI.class, new RenderFBI());
RenderingRegistry.registerEntityRenderingHandler(EntityRADBeast.class, new RenderRADBeast());
RenderingRegistry.registerEntityRenderingHandler(EntityBlockSpider.class, new RenderBlockSpider());
//"particles"
RenderingRegistry.registerEntityRenderingHandler(EntitySmokeFX.class, new MultiCloudRenderer(new Item[] { ModItems.smoke1, ModItems.smoke2, ModItems.smoke3, ModItems.smoke4, ModItems.smoke5, ModItems.smoke6, ModItems.smoke7, ModItems.smoke8 }));
RenderingRegistry.registerEntityRenderingHandler(EntityBSmokeFX.class, new MultiCloudRenderer(new Item[] { ModItems.b_smoke1, ModItems.b_smoke2, ModItems.b_smoke3, ModItems.b_smoke4, ModItems.b_smoke5, ModItems.b_smoke6, ModItems.b_smoke7, ModItems.b_smoke8 }));

View File

@ -622,6 +622,7 @@ public class MainRegistry {
EntityRegistry.registerModEntity(EntityWastePearl.class, "entity_waste_pearl", 150, this, 1000, 1, true);
EntityRegistry.registerModEntity(EntityBOTPrimeHead.class, "entity_balls_o_tron", 151, this, 1000, 1, true);
EntityRegistry.registerModEntity(EntityBOTPrimeBody.class, "entity_balls_o_tron_seg", 152, this, 1000, 1, true);
EntityRegistry.registerModEntity(EntityBlockSpider.class, "entity_taintcrawler", 153, this, 1000, 1, true);
EntityRegistry.registerGlobalEntityID(EntityNuclearCreeper.class, "entity_mob_nuclear_creeper", EntityRegistry.findGlobalUniqueEntityId(), 0x204131, 0x75CE00);
EntityRegistry.registerGlobalEntityID(EntityTaintedCreeper.class, "entity_mob_tainted_creeper", EntityRegistry.findGlobalUniqueEntityId(), 0x813b9b, 0xd71fdd);

View File

@ -238,6 +238,7 @@ public class ResourceManager {
public static final IModelCustom teslacrab = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/mobs/teslacrab.obj"));
public static final IModelCustom taintcrab = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/mobs/taintcrab.obj"));
public static final IModelCustom maskman = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/mobs/maskman.obj"));
public static final IModelCustom spider = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/mobs/blockspider.obj"));
//Belt
public static final IModelCustom arrow = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/blocks/arrow.obj"));
@ -496,6 +497,7 @@ public class ResourceManager {
public static final ResourceLocation taintcrab_tex = new ResourceLocation(RefStrings.MODID, "textures/entity/taintcrab.png");
public static final ResourceLocation maskman_tex = new ResourceLocation(RefStrings.MODID, "textures/entity/maskman.png");
public static final ResourceLocation iou = new ResourceLocation(RefStrings.MODID, "textures/entity/iou.png");
public static final ResourceLocation spider_tex = new ResourceLocation(RefStrings.MODID, "textures/entity/blockspider.png");

View File

@ -0,0 +1,20 @@
package com.hbm.render.entity.mob;
import com.hbm.main.ResourceManager;
import com.hbm.render.model.ModelBlockSpider;
import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;
public class RenderBlockSpider extends RenderLiving {
public RenderBlockSpider() {
super(new ModelBlockSpider(), 1.0F);
}
@Override
protected ResourceLocation getEntityTexture(Entity p_110775_1_) {
return ResourceManager.spider_tex;
}
}

View File

@ -0,0 +1,69 @@
package com.hbm.render.model;
import org.lwjgl.opengl.GL11;
import com.hbm.main.ResourceManager;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.Entity;
import net.minecraft.util.MathHelper;
public class ModelBlockSpider extends ModelBase {
private final RenderBlocks field_147920_a = new RenderBlocks();
@Override
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {
super.render(entity, f, f1, f2, f3, f4, f5);
GL11.glPushMatrix();
GL11.glRotatef(90, 0, -1, 0);
GL11.glRotatef(180, 0, 0, 1);
GL11.glTranslatef(0, -1.5F, 0);
float rot = -(MathHelper.cos(f * 0.6662F * 2.0F + 0.0F) * 0.4F) * f1 * 57.3F;
int blockid = entity.getDataWatcher().getWatchableObjectInt(12);
int meta = entity.getDataWatcher().getWatchableObjectInt(13);
Block block = Block.getBlockById(blockid);
if(block == null) {
GL11.glPopMatrix();
return;
}
GL11.glPushMatrix();
GL11.glTranslated(0, rot * 0.005, 0);
GL11.glRotatef(rot, 0, 1, 0);
ResourceManager.spider.renderPart("Leg1");
ResourceManager.spider.renderPart("Leg3");
ResourceManager.spider.renderPart("Leg5");
ResourceManager.spider.renderPart("Leg7");
GL11.glPopMatrix();
GL11.glPushMatrix();
GL11.glTranslated(0, rot * -0.005, 0);
GL11.glRotatef(rot, 0, -1, 0);
ResourceManager.spider.renderPart("Leg2");
ResourceManager.spider.renderPart("Leg4");
ResourceManager.spider.renderPart("Leg6");
ResourceManager.spider.renderPart("Leg8");
GL11.glPopMatrix();
GL11.glPushMatrix();
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
GL11.glTranslated(0, 0.75, 0);
this.field_147920_a.renderBlockAsItem(block, meta, entity.getBrightness(f5));
GL11.glPopMatrix();
//this.field_147920_a.setRenderBoundsFromBlock(block);
//this.field_147920_a.renderBlockSandFalling(block, entity.worldObj, (int)Math.floor(entity.posX), (int)Math.floor(entity.posY), (int)Math.floor(entity.posZ), blockid);
GL11.glPopMatrix();
}
}

View File

@ -1,10 +1,119 @@
package com.hbm.tileentity.machine.rbmk;
public class TileEntityRBMKControlAuto extends TileEntityRBMKControl {
import com.hbm.interfaces.IControlReceiver;
import com.hbm.tileentity.machine.rbmk.TileEntityRBMKControlManual.RBMKColor;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.Vec3;
public class TileEntityRBMKControlAuto extends TileEntityRBMKControl implements IControlReceiver {
public RBMKFunction function = RBMKFunction.LINEAR;
public double levelLower;
public double levelUpper;
public double heatLower;
public double heatUpper;
@Override
public String getName() {
return "container.rbmkControlAuto";
}
}
@Override
public boolean hasPermission(EntityPlayer player) {
return Vec3.createVectorHelper(xCoord - player.posX, yCoord - player.posY, zCoord - player.posZ).lengthVector() < 20;
}
@Override
public void updateEntity() {
if(!worldObj.isRemote) {
double fauxLevel = 0;
if(this.heat < heatLower) {
fauxLevel = this.levelLower;
} else if(this.heat > heatUpper) {
fauxLevel = this.levelUpper;
} else {
switch(this.function) {
case LINEAR:
//my brain hasn't been this challenged since my math finals in '19
fauxLevel = (this.heat - this.heatLower) * ((this.levelUpper - this.levelLower) / (this.heatUpper - this.heatLower)) + this.heatLower;
break;
//TODO: all this bullshit
case QUAD_UP:
//AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
//AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
//AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
//this.targetLevel = Math.pow((this.heat - this.heatLower) / 100, 2) * (this.levelUpper - this.levelLower) + this.levelLower;
break;
case QUAD_DOWN:
break;
}
}
this.targetLevel = fauxLevel * 0.01D;
}
super.updateEntity();
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
this.levelLower = nbt.getDouble("levelLower");
this.levelUpper = nbt.getDouble("levelUpper");
this.heatLower = nbt.getDouble("heatLower");
this.heatUpper = nbt.getDouble("heatUpper");
if(nbt.hasKey("function"))
this.function = RBMKFunction.values()[nbt.getInteger("function")];
else
this.function = null;
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
nbt.setDouble("levelLower", levelLower);
nbt.setDouble("levelUpper", levelUpper);
nbt.setDouble("heatLower", heatLower);
nbt.setDouble("heatUpper", heatUpper);
if(function != null)
nbt.setInteger("function", function.ordinal());
}
@Override
public void receiveControl(NBTTagCompound data) {
if(data.hasKey("function")) {
int c = Math.abs(data.getInteger("function")) % RBMKColor.values().length;
this.function = RBMKFunction.values()[c];
} else {
this.levelLower = data.getDouble("levelLower");
this.levelUpper = data.getDouble("levelUpper");
this.heatLower = data.getDouble("heatLower");
this.heatUpper = data.getDouble("heatUpper");
}
this.markDirty();
}
public static enum RBMKFunction {
LINEAR,
QUAD_UP,
QUAD_DOWN
}
}

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 531 B