mffs/src/main/java/mffs/event/BlockNotifyDelayedEvent.java

64 lines
2.2 KiB
Java
Raw Normal View History

2022-10-28 16:20:12 +02:00
package mffs.event;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.relauncher.ReflectionHelper;
import mffs.DelayedEvent;
import mffs.IDelayedEventHandler;
import mffs.api.ISpecialForceManipulation;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import universalelectricity.core.vector.Vector3;
public class BlockNotifyDelayedEvent extends DelayedEvent {
private World world;
private Vector3 position;
2023-01-08 16:58:21 +01:00
public BlockNotifyDelayedEvent(
final IDelayedEventHandler handler,
final int ticks,
final World world,
final Vector3 position
) {
2022-10-28 16:20:12 +02:00
super(handler, ticks);
this.world = world;
this.position = position;
}
@Override
protected void onEvent() {
if (!this.world.isRemote) {
this.world.notifyBlocksOfNeighborChange(
2023-01-08 16:58:21 +01:00
this.position.intX(),
this.position.intY(),
this.position.intZ(),
this.position.getBlock((IBlockAccess) this.world)
);
final TileEntity newTile
= this.position.getTileEntity((IBlockAccess) this.world);
2022-10-28 16:20:12 +02:00
if (newTile != null) {
if (newTile instanceof ISpecialForceManipulation) {
((ISpecialForceManipulation) newTile).postMove();
}
if (Loader.isModLoaded("BuildCraft|Factory")) {
try {
2023-01-08 16:58:21 +01:00
final Class clazz
= Class.forName("buildcraft.factory.TileQuarry");
2022-10-28 16:20:12 +02:00
if (clazz == newTile.getClass()) {
// TODO: W T F AAAAAAAAAAAAA
2023-01-08 16:58:21 +01:00
ReflectionHelper.setPrivateValue(
clazz,
(Object) newTile,
(Object) true,
new String[] { "isAlive" }
);
2022-10-28 16:20:12 +02:00
}
} catch (final Exception e) {
e.printStackTrace();
}
}
}
}
}
}