you forgot beam cutting ya ding dong

This commit is contained in:
George Paton 2024-02-08 18:12:00 +11:00
parent 88a90aada7
commit a95079826c
2 changed files with 8 additions and 11 deletions

View File

@ -1,7 +1,6 @@
package com.hbm.blocks.machine;
import com.hbm.blocks.ModBlocks;
import com.hbm.main.MainRegistry;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
@ -75,15 +74,12 @@ public class Spotlight extends Block {
Block block = world.getBlock(x, y, z);
if (!block.isAir(world, x, y, z)) return;
// If we encounter a beam, add a new INCOMING direction to the metadata
// Otherwise, spawn a new beam
if (!(block instanceof SpotlightBeam)) {
world.setBlock(x, y, z, ModBlocks.spotlight_beam);
}
int meta = SpotlightBeam.setDirection(world, x, y, z, dir, true);
MainRegistry.logger.info("block meta set to: " + meta + " - should be at least: " + dir.flag);
// 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);
}

View File

@ -29,12 +29,13 @@ public class SpotlightBeam extends BlockContainer {
// 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) {
super.breakBlock(world, x, y, z, block, metadata);
if (world.isRemote) return;
for (ForgeDirection dir : getDirections(metadata)) {
Spotlight.unpropagateBeam(world, x, y, z, dir);
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);
}
// If a block in the beam path is removed, repropagate beam