mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
tritium lamps now have a shoddy light beam implementation too
more cargo cult behavior
This commit is contained in:
parent
d9a6788299
commit
a6ccd25119
13
changelog
13
changelog
@ -9,6 +9,15 @@
|
||||
* Using desulfurized oil skips the (rather destructive) desulfurization process of the standard refinery, yielding higher-quality oils
|
||||
* Hydrotreating also allows cracked diesel variants to turn into their normal counterparts
|
||||
* Can convert coal oil directly into coal gasoline
|
||||
* Rural house
|
||||
* A new structure of an old brick house
|
||||
* Industrial lighting
|
||||
* Three new lamps that project out a beam of light for more coverage
|
||||
* Cage lamps are made from tungsten filaments and project light by 2 additional blocks
|
||||
* Fluorescent lights are made from mercury and project light 8 blocks, they also connect with each other to form light strips
|
||||
* Halogen floodlights are made with bromine and cast a light beam 32 blocks long
|
||||
* Lights are on by default and can be toggled with redstone
|
||||
* Tritium lamps have also been retrofitted with longer range lighting, casting beams in all cardinal directions for 8 blocks
|
||||
|
||||
## Changed
|
||||
* Deco bocks now drop all of the time, but they drop themselves instead of ingots
|
||||
@ -37,6 +46,7 @@
|
||||
* Doomsday missiles are no longer laggy cluster missiles, instead they are now near-identical to thermonuclear missiles but with an added fallout radius of 100#
|
||||
* Fallout rain now uses the same variable length code that the MK5 uses for optimal tick utilization, making it a lot faster
|
||||
* Lighter sellafite variants should no longer replace darker ones in overlapping craters, making bombed-out landscapes look more natural
|
||||
* Fallout's range-based effects now have a more natural gradient instead of creating smooth rings
|
||||
|
||||
## Fixed
|
||||
* Fixed dupe caused by shift-clicking ashes out of the bricked furnace
|
||||
@ -50,4 +60,5 @@
|
||||
* Fixed chunk-loading drones not loading chunks
|
||||
* Fixed several chemistry templates missing names
|
||||
* Fixed rampant mode random scout spawns being able to appear inside blocks
|
||||
* Fixed turret rotation sometimes desyncing when out of range, this is especially noticeable with slow-moving arty
|
||||
* Fixed turret rotation sometimes desyncing when out of range, this is especially noticeable with slow-moving arty
|
||||
* Fixed research reactor OC integration allowing the control rods to be set out of bounds
|
||||
@ -17,5 +17,5 @@ credits=HbMinecraft, rodolphito (explosion algorithms), grangerave (explosion al
|
||||
\ JamesH2 (blood mechanics, nitric acid, particle emitter), sdddddf80 (recipe configs, chinese localization,\
|
||||
\ custom machine holograms, I18n improvements), SuperCraftAlex (tooltips) LePeep (coilgun model, BDCL QC),\
|
||||
\ 70k (textures, glyphid AI, strand caster), Maksymisio (polish localization) Ice-Arrow (research reactor tweaks),\
|
||||
\ 245tt (anvil GUI improvements), MellowArpeggiation (new animation system, turbine sounds, sound fixes),\
|
||||
\ FOlkvangrField (custom machine parts)
|
||||
\ 245tt (anvil GUI improvements), MellowArpeggiation (new animation system, turbine sounds, sound fixes,\
|
||||
\ industrial lights), FOlkvangrField (custom machine parts)
|
||||
|
||||
6
src/main/java/com/hbm/blocks/ISpotlight.java
Normal file
6
src/main/java/com/hbm/blocks/ISpotlight.java
Normal file
@ -0,0 +1,6 @@
|
||||
package com.hbm.blocks;
|
||||
|
||||
public interface ISpotlight {
|
||||
|
||||
public int getBeamLength();
|
||||
}
|
||||
@ -1557,10 +1557,10 @@ public class ModBlocks {
|
||||
reinforced_laminate = new BlockNTMGlassCT(1, RefStrings.MODID + ":reinforced_laminate", Material.rock, true).setBlockName("reinforced_laminate").setCreativeTab(MainRegistry.blockTab).setLightOpacity(0).setHardness(15.0F).setResistance(300.0F);
|
||||
reinforced_laminate_pane = new BlockNTMGlassPane(1, RefStrings.MODID + ":reinforced_laminate_pane", RefStrings.MODID + ":reinforced_laminate_pane_edge", Material.rock, true).setBlockName("reinforced_laminate_pane").setCreativeTab(MainRegistry.blockTab).setLightOpacity(1).setHardness(15.0F).setResistance(300.0F);
|
||||
|
||||
lamp_tritium_green_off = new ReinforcedLamp(Material.redstoneLight, false).setBlockName("lamp_tritium_green_off").setStepSound(Block.soundTypeGlass).setCreativeTab(MainRegistry.blockTab).setHardness(3.0F).setBlockTextureName(RefStrings.MODID + ":lamp_tritium_green_off");
|
||||
lamp_tritium_green_on = new ReinforcedLamp(Material.redstoneLight, true).setBlockName("lamp_tritium_green_on").setStepSound(Block.soundTypeGlass).setHardness(3.0F).setBlockTextureName(RefStrings.MODID + ":lamp_tritium_green_on");
|
||||
lamp_tritium_blue_off = new ReinforcedLamp(Material.redstoneLight, false).setBlockName("lamp_tritium_blue_off").setStepSound(Block.soundTypeGlass).setCreativeTab(MainRegistry.blockTab).setHardness(3.0F).setBlockTextureName(RefStrings.MODID + ":lamp_tritium_blue_off");
|
||||
lamp_tritium_blue_on = new ReinforcedLamp(Material.redstoneLight, true).setBlockName("lamp_tritium_blue_on").setStepSound(Block.soundTypeGlass).setHardness(3.0F).setBlockTextureName(RefStrings.MODID + ":lamp_tritium_blue_on");
|
||||
lamp_tritium_green_off = new TritiumLamp(Material.redstoneLight, false).setBlockName("lamp_tritium_green_off").setStepSound(Block.soundTypeGlass).setCreativeTab(MainRegistry.blockTab).setHardness(3.0F).setBlockTextureName(RefStrings.MODID + ":lamp_tritium_green_off");
|
||||
lamp_tritium_green_on = new TritiumLamp(Material.redstoneLight, true).setBlockName("lamp_tritium_green_on").setStepSound(Block.soundTypeGlass).setHardness(3.0F).setBlockTextureName(RefStrings.MODID + ":lamp_tritium_green_on");
|
||||
lamp_tritium_blue_off = new TritiumLamp(Material.redstoneLight, false).setBlockName("lamp_tritium_blue_off").setStepSound(Block.soundTypeGlass).setCreativeTab(MainRegistry.blockTab).setHardness(3.0F).setBlockTextureName(RefStrings.MODID + ":lamp_tritium_blue_off");
|
||||
lamp_tritium_blue_on = new TritiumLamp(Material.redstoneLight, true).setBlockName("lamp_tritium_blue_on").setStepSound(Block.soundTypeGlass).setHardness(3.0F).setBlockTextureName(RefStrings.MODID + ":lamp_tritium_blue_on");
|
||||
|
||||
lamp_uv_off = new UVLamp(false).setBlockName("lamp_uv_off").setCreativeTab(MainRegistry.blockTab);
|
||||
lamp_uv_on = new UVLamp(true).setBlockName("lamp_uv_on").setCreativeTab(null);
|
||||
|
||||
@ -78,26 +78,12 @@ public class ReinforcedLamp extends Block {
|
||||
}
|
||||
|
||||
protected Block getOff() {
|
||||
|
||||
if(this == ModBlocks.reinforced_lamp_on)
|
||||
return ModBlocks.reinforced_lamp_off;
|
||||
if(this == ModBlocks.lamp_tritium_green_on)
|
||||
return ModBlocks.lamp_tritium_green_off;
|
||||
if(this == ModBlocks.lamp_tritium_blue_on)
|
||||
return ModBlocks.lamp_tritium_blue_off;
|
||||
|
||||
if(this == ModBlocks.reinforced_lamp_on) return ModBlocks.reinforced_lamp_off;
|
||||
return this;
|
||||
}
|
||||
|
||||
protected Block getOn() {
|
||||
|
||||
if(this == ModBlocks.reinforced_lamp_off)
|
||||
return ModBlocks.reinforced_lamp_on;
|
||||
if(this == ModBlocks.lamp_tritium_green_off)
|
||||
return ModBlocks.lamp_tritium_green_on;
|
||||
if(this == ModBlocks.lamp_tritium_blue_off)
|
||||
return ModBlocks.lamp_tritium_blue_on;
|
||||
|
||||
if(this == ModBlocks.reinforced_lamp_off) return ModBlocks.reinforced_lamp_on;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
117
src/main/java/com/hbm/blocks/generic/TritiumLamp.java
Normal file
117
src/main/java/com/hbm/blocks/generic/TritiumLamp.java
Normal file
@ -0,0 +1,117 @@
|
||||
package com.hbm.blocks.generic;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.hbm.blocks.ISpotlight;
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.blocks.machine.Spotlight;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TritiumLamp extends Block implements ISpotlight {
|
||||
|
||||
private final boolean isOn;
|
||||
|
||||
public TritiumLamp(Material mat, boolean isOn) {
|
||||
super(mat);
|
||||
this.isOn = isOn;
|
||||
|
||||
if(isOn) {
|
||||
this.setLightLevel(1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World world, int x, int y, int z) {
|
||||
|
||||
if(!world.isRemote) {
|
||||
|
||||
if(this.isOn && !world.isBlockIndirectlyGettingPowered(x, y, z)) {
|
||||
world.scheduleBlockUpdate(x, y, z, this, 4);
|
||||
|
||||
} else if(!this.isOn && world.isBlockIndirectlyGettingPowered(x, y, z)) {
|
||||
world.setBlock(x, y, z, getOn(), 0, 2);
|
||||
}
|
||||
|
||||
updateBeam(world, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, Block b) {
|
||||
|
||||
if(!world.isRemote) {
|
||||
|
||||
if(this.isOn && !world.isBlockIndirectlyGettingPowered(x, y, z)) {
|
||||
world.scheduleBlockUpdate(x, y, z, this, 4);
|
||||
|
||||
} else if(!this.isOn && world.isBlockIndirectlyGettingPowered(x, y, z)) {
|
||||
world.setBlock(x, y, z, getOn(), 0, 2);
|
||||
}
|
||||
|
||||
updateBeam(world, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTick(World world, int x, int y, int z, Random p_149674_5_) {
|
||||
|
||||
if(!world.isRemote && this.isOn && !world.isBlockIndirectlyGettingPowered(x, y, z)) {
|
||||
world.setBlock(x, y, z, getOff(), 0, 2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, Block block, int metadata) {
|
||||
super.breakBlock(world, x, y, z, block, metadata);
|
||||
if(world.isRemote) return;
|
||||
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) Spotlight.unpropagateBeam(world, x, y, z, dir);
|
||||
}
|
||||
|
||||
private void updateBeam(World world, int x, int y, int z) {
|
||||
if(!isOn) return;
|
||||
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) Spotlight.propagateBeam(world, x, y, z, dir, getBeamLength());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemDropped(int i, Random r, int j) {
|
||||
return Item.getItemFromBlock(getOff());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Item getItem(World world, int x, int y, int z) {
|
||||
return Item.getItemFromBlock(getOff());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemStack createStackedBlock(int e) {
|
||||
return new ItemStack(getOff());
|
||||
}
|
||||
|
||||
protected Block getOff() {
|
||||
if(this == ModBlocks.lamp_tritium_green_on) return ModBlocks.lamp_tritium_green_off;
|
||||
if(this == ModBlocks.lamp_tritium_blue_on) return ModBlocks.lamp_tritium_blue_off;
|
||||
return this;
|
||||
}
|
||||
|
||||
protected Block getOn() {
|
||||
if(this == ModBlocks.lamp_tritium_green_off) return ModBlocks.lamp_tritium_green_on;
|
||||
if(this == ModBlocks.lamp_tritium_blue_off) return ModBlocks.lamp_tritium_blue_on;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBeamLength() {
|
||||
return 8;
|
||||
}
|
||||
}
|
||||
@ -5,6 +5,7 @@ import com.hbm.blocks.ModBlocks;
|
||||
import java.util.Random;
|
||||
|
||||
import com.hbm.blocks.BlockEnums.LightType;
|
||||
import com.hbm.blocks.ISpotlight;
|
||||
import com.hbm.main.ResourceManager;
|
||||
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
@ -21,24 +22,24 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.model.obj.WavefrontObject;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class Spotlight extends Block {
|
||||
public class Spotlight extends Block implements ISpotlight {
|
||||
|
||||
// I'd be extending the ReinforcedLamp class if it wasn't for the inverted behaviour of these specific lights
|
||||
// I want these blocks to be eminently useful, so removing the need for redstone by default is desired,
|
||||
// these act more like redstone torches, in that applying a signal turns them off
|
||||
public boolean isOn;
|
||||
// I'd be extending the ReinforcedLamp class if it wasn't for the inverted behaviour of these specific lights
|
||||
// I want these blocks to be eminently useful, so removing the need for redstone by default is desired,
|
||||
// these act more like redstone torches, in that applying a signal turns them off
|
||||
public boolean isOn;
|
||||
|
||||
public int beamLength;
|
||||
public LightType type;
|
||||
public int beamLength;
|
||||
public LightType type;
|
||||
|
||||
public Spotlight(Material mat, int beamLength, LightType type, boolean isOn) {
|
||||
super(mat);
|
||||
|
||||
this.beamLength = beamLength;
|
||||
this.type = type;
|
||||
this.isOn = isOn;
|
||||
|
||||
if (isOn) setLightLevel(1.0F);
|
||||
this.beamLength = beamLength;
|
||||
this.type = type;
|
||||
this.isOn = isOn;
|
||||
|
||||
if(isOn) setLightLevel(1.0F);
|
||||
}
|
||||
|
||||
public static int renderID = RenderingRegistry.getNextAvailableRenderId();
|
||||
@ -48,20 +49,20 @@ public class Spotlight extends Block {
|
||||
return renderID;
|
||||
}
|
||||
|
||||
public WavefrontObject getModel() {
|
||||
switch (type) {
|
||||
case FLUORESCENT: return (WavefrontObject) ResourceManager.fluorescent_lamp;
|
||||
case HALOGEN: return (WavefrontObject) ResourceManager.flood_lamp;
|
||||
default: return (WavefrontObject) ResourceManager.cage_lamp;
|
||||
}
|
||||
}
|
||||
public WavefrontObject getModel() {
|
||||
switch(type) {
|
||||
case FLUORESCENT: return (WavefrontObject) ResourceManager.fluorescent_lamp;
|
||||
case HALOGEN: return (WavefrontObject) ResourceManager.flood_lamp;
|
||||
default: return (WavefrontObject) ResourceManager.cage_lamp;
|
||||
}
|
||||
}
|
||||
|
||||
public String getPartName(int connectionCount) {
|
||||
switch (type) {
|
||||
case HALOGEN: return "FloodLamp";
|
||||
default: return "CageLamp";
|
||||
}
|
||||
}
|
||||
public String getPartName(int connectionCount) {
|
||||
switch(type) {
|
||||
case HALOGEN: return "FloodLamp";
|
||||
default: return "CageLamp";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube() {
|
||||
@ -81,75 +82,70 @@ public class Spotlight extends Block {
|
||||
@Override
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
|
||||
ForgeDirection dir = getDirection(world, x, y, z);
|
||||
float[] bounds = swizzleBounds(dir);
|
||||
float[] offset = new float[] { 0.5F - dir.offsetX * (0.5F - bounds[0]), 0.5F - dir.offsetY * (0.5F - bounds[1]), 0.5F - dir.offsetZ * (0.5F - bounds[2]) };
|
||||
|
||||
setBlockBounds(offset[0] - bounds[0], offset[1] - bounds[1], offset[2] - bounds[2], offset[0] + bounds[0], offset[1] + bounds[1], offset[2] + bounds[2]);
|
||||
float[] bounds = swizzleBounds(dir);
|
||||
float[] offset = new float[] { 0.5F - dir.offsetX * (0.5F - bounds[0]), 0.5F - dir.offsetY * (0.5F - bounds[1]), 0.5F - dir.offsetZ * (0.5F - bounds[2]) };
|
||||
|
||||
setBlockBounds(offset[0] - bounds[0], offset[1] - bounds[1], offset[2] - bounds[2], offset[0] + bounds[0], offset[1] + bounds[1], offset[2] + bounds[2]);
|
||||
}
|
||||
|
||||
private float[] swizzleBounds(ForgeDirection dir) {
|
||||
float[] bounds = getBounds();
|
||||
switch (dir) {
|
||||
case EAST:
|
||||
case WEST:
|
||||
return new float[] { bounds[2], bounds[1], bounds[0] };
|
||||
case UP:
|
||||
case DOWN:
|
||||
return new float[] { bounds[1], bounds[2], bounds[0] };
|
||||
default:
|
||||
return bounds;
|
||||
}
|
||||
}
|
||||
private float[] swizzleBounds(ForgeDirection dir) {
|
||||
float[] bounds = getBounds();
|
||||
switch(dir) {
|
||||
case EAST:
|
||||
case WEST: return new float[] { bounds[2], bounds[1], bounds[0] };
|
||||
case UP:
|
||||
case DOWN: return new float[] { bounds[1], bounds[2], bounds[0] };
|
||||
default: return bounds;
|
||||
}
|
||||
}
|
||||
|
||||
// Returns an xyz (half-)size for a given object type
|
||||
private float[] getBounds() {
|
||||
switch (type) {
|
||||
case FLUORESCENT: return new float[] {0.5F, 0.5F, 0.1F};
|
||||
case HALOGEN: return new float[] {0.35F, 0.25F, 0.2F};
|
||||
default: return new float[] {0.25F, 0.2F, 0.15F};
|
||||
}
|
||||
}
|
||||
// Returns an xyz (half-)size for a given object type
|
||||
private float[] getBounds() {
|
||||
switch(type) {
|
||||
case FLUORESCENT: return new float[] { 0.5F, 0.5F, 0.1F };
|
||||
case HALOGEN: return new float[] { 0.35F, 0.25F, 0.2F };
|
||||
default: return new float[] { 0.25F, 0.2F, 0.15F };
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onBlockPlaced(World world, int x, int y, int z, int side, float hx, float hy, float hz, int initData) {
|
||||
return side << 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onBlockPlaced(World world, int x, int y, int z, int side, float hx, float hy, float hz, int initData) {
|
||||
return side << 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World world, int x, int y, int z) {
|
||||
if (world.isRemote) return;
|
||||
|
||||
if (updatePower(world, x, y, z)) return;
|
||||
|
||||
if(world.isRemote) return;
|
||||
if(updatePower(world, x, y, z)) return;
|
||||
updateBeam(world, x, y, z);
|
||||
}
|
||||
|
||||
private boolean updatePower(World world, int x, int y, int z) {
|
||||
boolean isPowered = world.isBlockIndirectlyGettingPowered(x, y, z);
|
||||
if (isOn && isPowered) {
|
||||
world.scheduleBlockUpdate(x, y, z, this, 4);
|
||||
return true;
|
||||
} else if (!isOn && !isPowered) {
|
||||
world.setBlock(x, y, z, getOn(), world.getBlockMetadata(x, y, z), 2);
|
||||
return true;
|
||||
}
|
||||
private boolean updatePower(World world, int x, int y, int z) {
|
||||
boolean isPowered = world.isBlockIndirectlyGettingPowered(x, y, z);
|
||||
if(isOn && isPowered) {
|
||||
world.scheduleBlockUpdate(x, y, z, this, 4);
|
||||
return true;
|
||||
} else if(!isOn && !isPowered) {
|
||||
world.setBlock(x, y, z, getOn(), world.getBlockMetadata(x, y, z), 2);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, Block block, int metadata) {
|
||||
ForgeDirection dir = getDirection(metadata);
|
||||
super.breakBlock(world, x, y, z, block, metadata);
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, Block block, int metadata) {
|
||||
ForgeDirection dir = getDirection(metadata);
|
||||
super.breakBlock(world, x, y, z, block, metadata);
|
||||
|
||||
if (world.isRemote) return;
|
||||
|
||||
unpropagateBeam(world, x, y, z, dir);
|
||||
}
|
||||
if(world.isRemote) return;
|
||||
|
||||
unpropagateBeam(world, x, y, z, dir);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTick(World world, int x, int y, int z, Random p_149674_5_) {
|
||||
if (world.isRemote) return;
|
||||
if (world.isRemote) return;
|
||||
|
||||
if (isOn && world.isBlockIndirectlyGettingPowered(x, y, z)) {
|
||||
world.setBlock(x, y, z, getOff(), world.getBlockMetadata(x, y, z), 2);
|
||||
@ -159,20 +155,20 @@ public class Spotlight extends Block {
|
||||
// Repropagate the beam if we've become unblocked
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, Block neighborBlock) {
|
||||
if (world.isRemote) return;
|
||||
if (neighborBlock instanceof SpotlightBeam) return;
|
||||
if(world.isRemote) return;
|
||||
if(neighborBlock instanceof SpotlightBeam) return;
|
||||
|
||||
ForgeDirection dir = getDirection(world, x, y, z);
|
||||
ForgeDirection dir = getDirection(world, x, y, z);
|
||||
|
||||
if (!canPlace(world, x, y, z, dir)) {
|
||||
dropBlockAsItem(world, x, y, z, 0, 0);
|
||||
world.setBlockToAir(x, y, z);
|
||||
return;
|
||||
}
|
||||
if(!canPlace(world, x, y, z, dir)) {
|
||||
dropBlockAsItem(world, x, y, z, 0, 0);
|
||||
world.setBlockToAir(x, y, z);
|
||||
return;
|
||||
}
|
||||
|
||||
if (updatePower(world, x, y, z)) return;
|
||||
if(updatePower(world, x, y, z)) return;
|
||||
|
||||
updateBeam(world, x, y, z);
|
||||
updateBeam(world, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -184,38 +180,38 @@ public class Spotlight extends Block {
|
||||
return canPlace(world, x, y, z, dir);
|
||||
}
|
||||
|
||||
// BlockSlab doesn't actually properly return isSideSolid,
|
||||
// probably because MOJANK thought this would only ever be used for torches,
|
||||
// which can't be placed on ceilings...
|
||||
private boolean canPlace(World world, int x, int y, int z, ForgeDirection dir) {
|
||||
x -= dir.offsetX;
|
||||
y -= dir.offsetY;
|
||||
z -= dir.offsetZ;
|
||||
// BlockSlab doesn't actually properly return isSideSolid,
|
||||
// probably because MOJANK thought this would only ever be used for torches,
|
||||
// which can't be placed on ceilings...
|
||||
private boolean canPlace(World world, int x, int y, int z, ForgeDirection dir) {
|
||||
x -= dir.offsetX;
|
||||
y -= dir.offsetY;
|
||||
z -= dir.offsetZ;
|
||||
|
||||
Block block = world.getBlock(x, y, z);
|
||||
if (block instanceof BlockSlab) {
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
return dir == ((meta & 8) == 8 ? ForgeDirection.UP : ForgeDirection.DOWN) || block.func_149730_j();
|
||||
}
|
||||
Block block = world.getBlock(x, y, z);
|
||||
if(block instanceof BlockSlab) {
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
return dir == ((meta & 8) == 8 ? ForgeDirection.UP : ForgeDirection.DOWN) || block.func_149730_j();
|
||||
}
|
||||
|
||||
return block.isSideSolid(world, x, y, z, dir);
|
||||
}
|
||||
|
||||
private void updateBeam(World world, int x, int y, int z) {
|
||||
if (!isOn) return;
|
||||
|
||||
ForgeDirection dir = getDirection(world, x, y, z);
|
||||
propagateBeam(world, x, y, z, dir, beamLength);
|
||||
}
|
||||
|
||||
public ForgeDirection getDirection(IBlockAccess world, int x, int y, int z) {
|
||||
int metadata = world.getBlockMetadata(x, y, z);
|
||||
return getDirection(metadata);
|
||||
}
|
||||
private void updateBeam(World world, int x, int y, int z) {
|
||||
if(!isOn) return;
|
||||
|
||||
public ForgeDirection getDirection(int metadata) {
|
||||
return ForgeDirection.getOrientation(metadata >> 1);
|
||||
}
|
||||
ForgeDirection dir = getDirection(world, x, y, z);
|
||||
propagateBeam(world, x, y, z, dir, beamLength);
|
||||
}
|
||||
|
||||
public ForgeDirection getDirection(IBlockAccess world, int x, int y, int z) {
|
||||
int metadata = world.getBlockMetadata(x, y, z);
|
||||
return getDirection(metadata);
|
||||
}
|
||||
|
||||
public ForgeDirection getDirection(int metadata) {
|
||||
return ForgeDirection.getOrientation(metadata >> 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemDropped(int i, Random r, int j) {
|
||||
@ -233,62 +229,66 @@ public class Spotlight extends Block {
|
||||
return new ItemStack(getOn());
|
||||
}
|
||||
|
||||
// Recursively add beam blocks, updating any that already exist with new incoming light directions
|
||||
public static void propagateBeam(World world, int x, int y, int z, ForgeDirection dir, int distance) {
|
||||
distance--;
|
||||
if (distance <= 0) return;
|
||||
// Recursively add beam blocks, updating any that already exist with new incoming light directions
|
||||
public static void propagateBeam(World world, int x, int y, int z, ForgeDirection dir, int distance) {
|
||||
distance--;
|
||||
if(distance <= 0)
|
||||
return;
|
||||
|
||||
x += dir.offsetX;
|
||||
y += dir.offsetY;
|
||||
z += dir.offsetZ;
|
||||
x += dir.offsetX;
|
||||
y += dir.offsetY;
|
||||
z += dir.offsetZ;
|
||||
|
||||
Block block = world.getBlock(x, y, z);
|
||||
if (!block.isAir(world, x, y, z)) return;
|
||||
Block block = world.getBlock(x, y, z);
|
||||
if(!block.isAir(world, x, y, z))
|
||||
return;
|
||||
|
||||
if (!(block instanceof SpotlightBeam)) {
|
||||
world.setBlock(x, y, z, ModBlocks.spotlight_beam);
|
||||
}
|
||||
if(!(block instanceof SpotlightBeam)) {
|
||||
world.setBlock(x, y, z, ModBlocks.spotlight_beam);
|
||||
}
|
||||
|
||||
// If we encounter an existing beam, add a new INCOMING direction to the metadata
|
||||
SpotlightBeam.setDirection(world, x, y, z, dir, true);
|
||||
// If we encounter an existing beam, add a new INCOMING direction to the
|
||||
// metadata
|
||||
SpotlightBeam.setDirection(world, x, y, z, dir, true);
|
||||
|
||||
propagateBeam(world, x, y, z, dir, distance);
|
||||
}
|
||||
propagateBeam(world, x, y, z, dir, distance);
|
||||
}
|
||||
|
||||
// Recursively delete beam blocks, if they aren't still illuminated from a different direction
|
||||
public static void unpropagateBeam(World world, int x, int y, int z, ForgeDirection dir) {
|
||||
x += dir.offsetX;
|
||||
y += dir.offsetY;
|
||||
z += dir.offsetZ;
|
||||
// Recursively delete beam blocks, if they aren't still illuminated from a different direction
|
||||
public static void unpropagateBeam(World world, int x, int y, int z, ForgeDirection dir) {
|
||||
x += dir.offsetX;
|
||||
y += dir.offsetY;
|
||||
z += dir.offsetZ;
|
||||
|
||||
Block block = world.getBlock(x, y, z);
|
||||
if (!(block instanceof SpotlightBeam)) return;
|
||||
Block block = world.getBlock(x, y, z);
|
||||
if(!(block instanceof SpotlightBeam))
|
||||
return;
|
||||
|
||||
// Remove the metadata associated with this direction
|
||||
// If all directions are set to zero, delete the beam
|
||||
if (SpotlightBeam.setDirection(world, x, y, z, dir, false) == 0) {
|
||||
world.setBlockToAir(x, y, z);
|
||||
}
|
||||
// Remove the metadata associated with this direction
|
||||
// If all directions are set to zero, delete the beam
|
||||
if(SpotlightBeam.setDirection(world, x, y, z, dir, false) == 0) {
|
||||
world.setBlockToAir(x, y, z);
|
||||
}
|
||||
|
||||
unpropagateBeam(world, x, y, z, dir);
|
||||
}
|
||||
unpropagateBeam(world, x, y, z, dir);
|
||||
}
|
||||
|
||||
// Travels back through a beam to the source, and if found, repropagates the beam
|
||||
public static void backPropagate(World world, int x, int y, int z, ForgeDirection dir) {
|
||||
x -= dir.offsetX;
|
||||
y -= dir.offsetY;
|
||||
z -= dir.offsetZ;
|
||||
// Travels back through a beam to the source, and if found, repropagates the beam
|
||||
public static void backPropagate(World world, int x, int y, int z, ForgeDirection dir) {
|
||||
x -= dir.offsetX;
|
||||
y -= dir.offsetY;
|
||||
z -= dir.offsetZ;
|
||||
|
||||
Block block = world.getBlock(x, y, z);
|
||||
if (block instanceof Spotlight) {
|
||||
Spotlight spot = (Spotlight) block;
|
||||
propagateBeam(world, x, y, z, dir, spot.beamLength);
|
||||
} else if (!(block instanceof SpotlightBeam)) {
|
||||
return;
|
||||
}
|
||||
Block block = world.getBlock(x, y, z);
|
||||
if(block instanceof ISpotlight) {
|
||||
ISpotlight spot = (ISpotlight) block;
|
||||
propagateBeam(world, x, y, z, dir, spot.getBeamLength());
|
||||
} else if(!(block instanceof SpotlightBeam)) {
|
||||
return;
|
||||
}
|
||||
|
||||
backPropagate(world, x, y, z, dir);
|
||||
}
|
||||
backPropagate(world, x, y, z, dir);
|
||||
}
|
||||
|
||||
protected Block getOff() {
|
||||
if(this == ModBlocks.spotlight_incandescent)
|
||||
@ -311,5 +311,9 @@ public class Spotlight extends Block {
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getBeamLength() {
|
||||
return this.beamLength;
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,25 +16,25 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class SpotlightBeam extends BlockContainer {
|
||||
|
||||
public SpotlightBeam() {
|
||||
super(Material.air);
|
||||
setLightLevel(1.0F);
|
||||
setLightOpacity(0);
|
||||
setHardness(-1);
|
||||
setResistance(1_000_000);
|
||||
setBlockBounds(0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
public SpotlightBeam() {
|
||||
super(Material.air);
|
||||
setLightLevel(1.0F);
|
||||
setLightOpacity(0);
|
||||
setHardness(-1);
|
||||
setResistance(1_000_000);
|
||||
setBlockBounds(0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
// If a block is placed onto the beam, handle the new cutoff
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, Block block, int metadata) {
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, Block block, int metadata) {
|
||||
if (!world.isRemote) {
|
||||
for (ForgeDirection dir : getDirections(world, x, y, z)) {
|
||||
Spotlight.unpropagateBeam(world, x, y, z, dir);
|
||||
}
|
||||
}
|
||||
super.breakBlock(world, x, y, z, block, metadata);
|
||||
super.breakBlock(world, x, y, z, block, metadata);
|
||||
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ public class SpotlightBeam extends BlockContainer {
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isAir(IBlockAccess world, int x, int y, int z) {
|
||||
return true;
|
||||
@ -105,12 +105,11 @@ public class SpotlightBeam extends BlockContainer {
|
||||
|
||||
@Override
|
||||
public boolean isLeaves(IBlockAccess world, int x, int y, int z) {
|
||||
// This was taken from GregsLighting (cargo cult behaviour)
|
||||
// This was taken from GregsLighting (cargo cult behaviour)
|
||||
// This is a bit screwy, but it's needed so that trees are not prevented from growing
|
||||
// near a floodlight beam.
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
@ -131,5 +130,4 @@ public class SpotlightBeam extends BlockContainer {
|
||||
public int getRenderType() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -9,18 +9,18 @@ import net.minecraft.tileentity.TileEntity;
|
||||
// Use this TE if you need more bits, that's it. Blame Mojang
|
||||
public class TileEntityData extends TileEntity {
|
||||
|
||||
public int metadata;
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
metadata = nbt.getInteger("meta");
|
||||
}
|
||||
public int metadata;
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
nbt.setInteger("meta", metadata);
|
||||
}
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
metadata = nbt.getInteger("meta");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
nbt.setInteger("meta", metadata);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user