mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
camera, lights, action
This commit is contained in:
parent
01830fd877
commit
e7428fb5ab
@ -11,4 +11,5 @@
|
||||
## Fixed
|
||||
* Fixed issue where the NEI universal handler can not correctly display more than 4 outputs (now supports up to 8, which should cover all possible electrolyzer cases too)
|
||||
* Fixed the metal electrolysis duration variable not being part of the config
|
||||
* Removed the global energy transfer cap (only per-machine caps apply now), fixing issues where FENSUs in buffer mode would not charge past 10THE, and constantly void energy if above that threshold
|
||||
* Removed the global energy transfer cap (only per-machine caps apply now), fixing issues where FENSUs in buffer mode would not charge past 10THE, and constantly void energy if above that threshold
|
||||
* Fixed a bug where the power transfer would sometimes have leftovers due to rounding errors which are send but not used up, effectively creating small amounts of energy out of nothing
|
||||
@ -11,12 +11,14 @@ import java.util.Set;
|
||||
import com.hbm.util.Tuple.Pair;
|
||||
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Random;
|
||||
|
||||
import api.hbm.energymk2.IEnergyReceiverMK2.ConnectionPriority;
|
||||
import api.hbm.energymk2.Nodespace.PowerNode;
|
||||
|
||||
public class PowerNetMK2 {
|
||||
|
||||
public static Random rand = new Random();
|
||||
public boolean valid = true;
|
||||
public Set<PowerNode> links = new HashSet();
|
||||
|
||||
@ -170,11 +172,26 @@ public class PowerNetMK2 {
|
||||
}
|
||||
|
||||
this.energyTracker += energyUsed;
|
||||
long leftover = energyUsed;
|
||||
|
||||
for(Pair<IEnergyProviderMK2, Long> entry : providers) {
|
||||
double weight = (double) entry.getValue() / (double) powerAvailable;
|
||||
long toUse = (long) Math.max(energyUsed * weight, 0D);
|
||||
entry.getKey().usePower(toUse);
|
||||
leftover -= toUse;
|
||||
}
|
||||
|
||||
//rounding error compensation, detects surplus that hasn't been used and removes it from random providers
|
||||
int iterationsLeft = 100; // whiles without emergency brakes are a bad idea
|
||||
while(iterationsLeft > 0 && leftover > 0 && providers.size() > 0) {
|
||||
iterationsLeft--;
|
||||
|
||||
Pair<IEnergyProviderMK2, Long> selected = providers.get(rand.nextInt(providers.size()));
|
||||
IEnergyProviderMK2 scapegoat = selected.getKey();
|
||||
|
||||
long toUse = Math.min(leftover, scapegoat.getPower());
|
||||
scapegoat.usePower(toUse);
|
||||
leftover -= toUse;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2633,6 +2633,7 @@ public class ModBlocks {
|
||||
GameRegistry.registerBlock(spotlight_halogen_off, spotlight_halogen_off.getUnlocalizedName());
|
||||
GameRegistry.registerBlock(spotlight_beam, spotlight_beam.getUnlocalizedName());
|
||||
register(floodlight);
|
||||
GameRegistry.registerBlock(floodlight_beam, floodlight_beam.getUnlocalizedName());
|
||||
|
||||
//Reinforced Blocks
|
||||
GameRegistry.registerBlock(asphalt, ItemBlockBlastInfo.class, asphalt.getUnlocalizedName());
|
||||
|
||||
@ -1,13 +1,18 @@
|
||||
package com.hbm.blocks.machine;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.blocks.machine.FloodlightBeam.TileEntityFloodlightBeam;
|
||||
import com.hbm.util.Compat;
|
||||
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||
|
||||
import api.hbm.block.IToolable;
|
||||
import api.hbm.energymk2.IEnergyReceiverMK2;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
@ -15,7 +20,9 @@ import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class Floodlight extends BlockContainer implements IToolable {
|
||||
|
||||
@ -41,17 +48,17 @@ public class Floodlight extends BlockContainer implements IToolable {
|
||||
//only method with player param, called second for variable rotation
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
|
||||
setAngle(world, x, y, z, player);
|
||||
setAngle(world, x, y, z, player, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onScrew(World world, EntityPlayer player, int x, int y, int z, int side, float fX, float fY, float fZ, ToolType tool) {
|
||||
if(tool != ToolType.SCREWDRIVER) return false;
|
||||
setAngle(world, x, y, z, player);
|
||||
setAngle(world, x, y, z, player, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setAngle(World world, int x, int y, int z, EntityLivingBase player) {
|
||||
public void setAngle(World world, int x, int y, int z, EntityLivingBase player, boolean updateMeta) {
|
||||
|
||||
int i = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
|
||||
float rotation = player.rotationPitch;
|
||||
@ -59,16 +66,17 @@ public class Floodlight extends BlockContainer implements IToolable {
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
|
||||
if(tile instanceof TileEntityFloodlight) {
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
int meta = world.getBlockMetadata(x, y, z) % 6;
|
||||
TileEntityFloodlight floodlight = (TileEntityFloodlight) tile;
|
||||
|
||||
if(meta == 0 || meta == 1) {
|
||||
if(i == 0 || i == 2) world.setBlockMetadataWithNotify(x, y, z, meta + 6, 3);
|
||||
if(i == 0 || i == 2) if(updateMeta) world.setBlockMetadataWithNotify(x, y, z, meta + 6, 3);
|
||||
if(meta == 1) if(i == 0 || i == 1) rotation = 180F - rotation;
|
||||
if(meta == 0) if(i == 0 || i == 3) rotation = 180F - rotation;
|
||||
}
|
||||
|
||||
floodlight.rotation = -Math.round(rotation / 5F) * 5F;
|
||||
if(floodlight.isOn) floodlight.destroyLights();
|
||||
tile.markDirty();
|
||||
}
|
||||
}
|
||||
@ -76,13 +84,150 @@ public class Floodlight extends BlockContainer implements IToolable {
|
||||
public static class TileEntityFloodlight extends TileEntity implements IEnergyReceiverMK2 {
|
||||
|
||||
public float rotation;
|
||||
protected BlockPos[] lightPos = new BlockPos[9];
|
||||
public static final long maxPower = 10_000;
|
||||
protected BlockPos[] lightPos = new BlockPos[15];
|
||||
public static final long maxPower = 5_000;
|
||||
public long power;
|
||||
|
||||
public int delay;
|
||||
public boolean isOn;
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() % 6).getOpposite();
|
||||
this.trySubscribe(worldObj, xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir);
|
||||
|
||||
if(delay > 0) {
|
||||
delay --;
|
||||
return;
|
||||
}
|
||||
|
||||
if(power >= 100) {
|
||||
power -= 100;
|
||||
|
||||
if(!isOn) {
|
||||
this.isOn = true;
|
||||
this.castLights();
|
||||
this.worldObj.markTileEntityChunkModified(this.xCoord, this.yCoord, this.zCoord, this);
|
||||
this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
|
||||
} else {
|
||||
|
||||
long timer = worldObj.getTotalWorldTime();
|
||||
if(timer % 5 == 0) {
|
||||
timer = timer / 5;
|
||||
this.castLight((int) Math.abs(timer % this.lightPos.length));
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
if(isOn) {
|
||||
this.isOn = false;
|
||||
this.delay = 60;
|
||||
this.destroyLights();
|
||||
this.worldObj.markTileEntityChunkModified(this.xCoord, this.yCoord, this.zCoord, this);
|
||||
this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void castLight(int index) {
|
||||
BlockPos newPos = this.getRayEndpoint(index);
|
||||
BlockPos oldPos = this.lightPos[index];
|
||||
this.lightPos[index] = null;
|
||||
|
||||
if(newPos == null || !newPos.equals(oldPos)) { //if the new end point is null or not equal to the previous, delete the previous spot
|
||||
if(oldPos != null) {
|
||||
TileEntity tile = Compat.getTileStandard(worldObj, oldPos.getX(), oldPos.getY(), oldPos.getZ());
|
||||
if(tile instanceof TileEntityFloodlightBeam) {
|
||||
TileEntityFloodlightBeam beam = (TileEntityFloodlightBeam) tile;
|
||||
if(beam.cache == this) {
|
||||
worldObj.setBlock(oldPos.getX(), oldPos.getY(), oldPos.getZ(), Blocks.air, 0, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(newPos == null) return;
|
||||
|
||||
if(worldObj.getBlock(newPos.getX(), newPos.getY(), newPos.getZ()) == Blocks.air) {
|
||||
worldObj.setBlock(newPos.getX(), newPos.getY(), newPos.getZ(), ModBlocks.floodlight_beam, 0, 2);
|
||||
TileEntity tile = Compat.getTileStandard(worldObj, newPos.getX(), newPos.getY(), newPos.getZ());
|
||||
if(tile instanceof TileEntityFloodlightBeam) ((TileEntityFloodlightBeam) tile).setSource(this, newPos.getX(), newPos.getY(), newPos.getZ(), index);
|
||||
this.lightPos[index] = newPos;
|
||||
}
|
||||
|
||||
if(worldObj.getBlock(newPos.getX(), newPos.getY(), newPos.getZ()) == ModBlocks.floodlight_beam) {
|
||||
this.lightPos[index] = newPos;
|
||||
}
|
||||
}
|
||||
|
||||
public BlockPos getRayEndpoint(int index) {
|
||||
|
||||
if(index < 0 || index >= lightPos.length) return null;
|
||||
|
||||
int meta = this.getBlockMetadata();
|
||||
Vec3 dir = Vec3.createVectorHelper(1, 0, 0);
|
||||
|
||||
float[] angles = getVariation(index);
|
||||
|
||||
float rotation = this.rotation;
|
||||
if(meta == 1 || meta == 7) rotation = 180 - rotation;
|
||||
if(meta == 6) rotation = 180 - rotation;
|
||||
dir.rotateAroundZ((float) (rotation / 180D * Math.PI) + angles[0]);
|
||||
|
||||
if(meta == 6) dir.rotateAroundY((float) (Math.PI / 2D));
|
||||
if(meta == 7) dir.rotateAroundY((float) (Math.PI / 2D));
|
||||
if(meta == 2) dir.rotateAroundY((float) (Math.PI / 2D));
|
||||
if(meta == 3) dir.rotateAroundY((float) -(Math.PI / 2D));
|
||||
if(meta == 4) dir.rotateAroundY((float) (Math.PI));
|
||||
dir.rotateAroundY(angles[1]);
|
||||
|
||||
for(int i = 1; i < 64; i++) {
|
||||
int iX = (int) Math.floor(xCoord + 0.5 + dir.xCoord * i);
|
||||
int iY = (int) Math.floor(yCoord + 0.5 + dir.yCoord * i);
|
||||
int iZ = (int) Math.floor(zCoord + 0.5 + dir.zCoord * i);
|
||||
|
||||
if(iX == xCoord && iY == yCoord && iZ == zCoord) continue;
|
||||
|
||||
Block block = worldObj.getBlock(iX, iY, iZ);
|
||||
if(block.getLightOpacity(worldObj, iX, iY, iZ) < 127) continue;
|
||||
|
||||
int fX = (int) Math.floor(xCoord + 0.5 + dir.xCoord * (i - 1));
|
||||
int fY = (int) Math.floor(yCoord + 0.5 + dir.yCoord * (i - 1));
|
||||
int fZ = (int) Math.floor(zCoord + 0.5 + dir.zCoord * (i - 1));
|
||||
|
||||
if(i > 1) return new BlockPos(fX, fY, fZ);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void castLights() {
|
||||
for(int i = 0; i < this.lightPos.length; i++) this.castLight(i);
|
||||
}
|
||||
|
||||
private void destroyLight(int index) {
|
||||
BlockPos pos = lightPos[index];
|
||||
if(pos != null) {
|
||||
if(pos != null && worldObj.getBlock(pos.getX(), pos.getY(), pos.getZ()) == ModBlocks.floodlight_beam) {
|
||||
worldObj.setBlock(pos.getX(), pos.getY(), pos.getZ(), Blocks.air, 0, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void destroyLights() {
|
||||
for(int i = 0; i < this.lightPos.length; i++) destroyLight(i);
|
||||
}
|
||||
|
||||
private float[] getVariation(int index) {
|
||||
return new float[] {
|
||||
(((index / 3) - 2) * 7.5F) / 180F * (float) Math.PI,
|
||||
(((index % 3) - 1) * 15F) / 180F * (float) Math.PI
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -102,6 +247,7 @@ public class Floodlight extends BlockContainer implements IToolable {
|
||||
super.readFromNBT(nbt);
|
||||
this.rotation = nbt.getFloat("rotation");
|
||||
this.power = nbt.getLong("power");
|
||||
this.isOn = nbt.getBoolean("isOn");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -109,6 +255,7 @@ public class Floodlight extends BlockContainer implements IToolable {
|
||||
super.writeToNBT(nbt);
|
||||
nbt.setFloat("rotation", rotation);
|
||||
nbt.setLong("power", power);
|
||||
nbt.setBoolean("isOn", isOn);
|
||||
}
|
||||
|
||||
@Override public long getPower() { return power; }
|
||||
|
||||
@ -1,5 +1,10 @@
|
||||
package com.hbm.blocks.machine;
|
||||
|
||||
import com.hbm.blocks.machine.Floodlight.TileEntityFloodlight;
|
||||
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@ -12,5 +17,59 @@ public class FloodlightBeam extends BlockBeamBase {
|
||||
|
||||
public static class TileEntityFloodlightBeam extends TileEntity {
|
||||
|
||||
public TileEntityFloodlight cache;
|
||||
public int sourceX;
|
||||
public int sourceY;
|
||||
public int sourceZ;
|
||||
public int index;
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
if(!worldObj.isRemote && worldObj.getTotalWorldTime() % 5 == 0) {
|
||||
|
||||
if(cache == null) {
|
||||
|
||||
if(worldObj.getChunkProvider().chunkExists(sourceX >> 4, sourceZ >> 4)) {
|
||||
TileEntity tile = worldObj.getTileEntity(sourceX, sourceY, sourceZ);
|
||||
if(tile instanceof TileEntityFloodlight) {
|
||||
cache = (TileEntityFloodlight) tile; // chunk is loaded, tile exists -> cache
|
||||
} else {
|
||||
worldObj.setBlock(xCoord, yCoord, zCoord, Blocks.air, 0, 2); // chunk is loaded, tile does not exist -> delete self
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if((cache != null && (cache.isInvalid() || !cache.isOn || !new BlockPos(xCoord, yCoord, zCoord).equals(cache.lightPos[index]))) || sourceY == 0) {
|
||||
worldObj.setBlock(xCoord, yCoord, zCoord, Blocks.air, 0, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setSource(TileEntityFloodlight floodlight, int x, int y, int z, int i) {
|
||||
cache = floodlight;
|
||||
sourceX = x;
|
||||
sourceY = y;
|
||||
sourceZ = z;
|
||||
index = i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
this.sourceX = nbt.getInteger("sourceX");
|
||||
this.sourceY = nbt.getInteger("sourceY");
|
||||
this.sourceZ = nbt.getInteger("sourceZ");
|
||||
this.index = nbt.getInteger("index");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
nbt.setInteger("sourceX", sourceX);
|
||||
nbt.setInteger("sourceY", sourceY);
|
||||
nbt.setInteger("sourceZ", sourceZ);
|
||||
nbt.setInteger("index", index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -449,6 +449,7 @@ public class CraftingManager {
|
||||
addRecipeAuto(new ItemStack(ModBlocks.spotlight_incandescent, 8), new Object[] { " G ", " T ", " I ", 'G', KEY_ANYPANE, 'T', W.wireFine(), 'I', IRON.ingot() });
|
||||
addRecipeAuto(new ItemStack(ModBlocks.spotlight_fluoro, 8), new Object[] { " G ", " M ", " A ", 'G', KEY_ANYPANE, 'M', ModItems.ingot_mercury, 'A', ModItems.plate_aluminium });
|
||||
addRecipeAuto(new ItemStack(ModBlocks.spotlight_halogen, 8), new Object[] { " G ", " B ", " S ", 'G', KEY_ANYPANE, 'B', ModItems.powder_bromine, 'S', STEEL.plate() });
|
||||
addRecipeAuto(new ItemStack(ModBlocks.floodlight, 2), new Object[] { "CSC", "TST", "G G", 'C', DictFrame.fromOne(ModItems.circuit, EnumCircuitType.CAPACITOR), 'S', STEEL.plate(), 'T', ModItems.coil_tungsten, 'G', KEY_ANYPANE });
|
||||
|
||||
addRecipeAuto(new ItemStack(ModBlocks.barbed_wire, 16), new Object[] { "AIA", "I I", "AIA", 'A', STEEL.wireFine(), 'I', IRON.ingot() });
|
||||
addRecipeAuto(new ItemStack(ModBlocks.barbed_wire_fire, 8), new Object[] { "BBB", "BIB", "BBB", 'B', ModBlocks.barbed_wire, 'I', P_RED.dust() });
|
||||
|
||||
@ -48,9 +48,16 @@ public class RenderFloodlight extends TileEntitySpecialRenderer {
|
||||
GL11.glTranslated(0, -0.5, 0);
|
||||
|
||||
floodlight.renderPart("Lights");
|
||||
RenderArcFurnace.fullbright(true);
|
||||
floodlight.renderPart("Lamps");
|
||||
RenderArcFurnace.fullbright(false);
|
||||
|
||||
if(floodtile.isOn) {
|
||||
RenderArcFurnace.fullbright(true);
|
||||
floodlight.renderPart("Lamps");
|
||||
RenderArcFurnace.fullbright(false);
|
||||
} else {
|
||||
GL11.glColor4f(0.25F, 0.25F, 0.25F, 1F);
|
||||
floodlight.renderPart("Lamps");
|
||||
GL11.glColor4f(1F, 1F, 1F, 1F);
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@ -159,6 +159,7 @@ public class RenderLoot extends TileEntitySpecialRenderer {
|
||||
GL11.glTranslated(0.25, 0, 0.25);
|
||||
GL11.glScaled(0.5, 0.5, 0.5);
|
||||
GL11.glRotated(90, 1, 0, 0);
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
|
||||
bindTexture(TextureMap.locationItemsTexture);
|
||||
|
||||
|
||||
@ -18,6 +18,7 @@ import com.hbm.blocks.generic.PartEmitter.TileEntityPartEmitter;
|
||||
import com.hbm.blocks.machine.BlockICF.TileEntityBlockICF;
|
||||
import com.hbm.blocks.machine.BlockPWR.TileEntityBlockPWR;
|
||||
import com.hbm.blocks.machine.Floodlight.TileEntityFloodlight;
|
||||
import com.hbm.blocks.machine.FloodlightBeam.TileEntityFloodlightBeam;
|
||||
import com.hbm.blocks.machine.MachineCapacitor.TileEntityCapacitor;
|
||||
import com.hbm.blocks.machine.MachineFan.TileEntityFan;
|
||||
import com.hbm.blocks.machine.PistonInserter.TileEntityPistonInserter;
|
||||
@ -186,6 +187,7 @@ public class TileMappings {
|
||||
put(TileEntityFEL.class, "tileentity_fel");
|
||||
put(TileEntityDemonLamp.class, "tileentity_demonlamp");
|
||||
put(TileEntityFloodlight.class, "tileentity_floodlight");
|
||||
put(TileEntityFloodlightBeam.class, "tileentity_floodlight_beam");
|
||||
put(TileEntityLantern.class, "tileentity_lantern_ordinary");
|
||||
put(TileEntityLanternBehemoth.class, "tileentity_lantern_behemoth");
|
||||
put(TileEntityStorageDrum.class, "tileentity_waste_storage_drum");
|
||||
|
||||
4436
src/main/resources/assets/hbm/models/weapons/missile_launcher.obj
Normal file
4436
src/main/resources/assets/hbm/models/weapons/missile_launcher.obj
Normal file
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
After Width: | Height: | Size: 3.7 KiB |
Loading…
x
Reference in New Issue
Block a user