use of micdoodle8.mods.galacticraft.core.event.EventLandingPadRemoval in project Galacticraft by micdoodle8.
the class EntityAutoRocket method onLaunch.
@Override
public void onLaunch() {
if (!(this.worldObj.provider.getDimensionId() == GalacticraftCore.planetOverworld.getDimensionID() || this.worldObj.provider instanceof IGalacticraftWorldProvider)) {
if (ConfigManagerCore.disableRocketLaunchAllNonGC) {
this.cancelLaunch();
return;
}
// No rocket flight in the Nether, the End etc
for (int i = ConfigManagerCore.disableRocketLaunchDimensions.length - 1; i >= 0; i--) {
if (ConfigManagerCore.disableRocketLaunchDimensions[i] == this.worldObj.provider.getDimensionId()) {
this.cancelLaunch();
return;
}
}
}
super.onLaunch();
if (!this.worldObj.isRemote) {
GCPlayerStats stats = null;
if (this.riddenByEntity != null && this.riddenByEntity instanceof EntityPlayerMP) {
stats = GCPlayerStats.get(this.riddenByEntity);
if (!(this.worldObj.provider instanceof IOrbitDimension)) {
stats.setCoordsTeleportedFromX(this.riddenByEntity.posX);
stats.setCoordsTeleportedFromZ(this.riddenByEntity.posZ);
}
}
int amountRemoved = 0;
PADSEARCH: for (int x = MathHelper.floor_double(this.posX) - 1; x <= MathHelper.floor_double(this.posX) + 1; x++) {
for (int y = MathHelper.floor_double(this.posY) - 3; y <= MathHelper.floor_double(this.posY) + 1; y++) {
for (int z = MathHelper.floor_double(this.posZ) - 1; z <= MathHelper.floor_double(this.posZ) + 1; z++) {
BlockPos pos = new BlockPos(x, y, z);
final Block block = this.worldObj.getBlockState(pos).getBlock();
if (block != null && block instanceof BlockLandingPadFull) {
if (amountRemoved < 9) {
EventLandingPadRemoval event = new EventLandingPadRemoval(this.worldObj, pos);
MinecraftForge.EVENT_BUS.post(event);
if (event.allow) {
this.worldObj.setBlockToAir(pos);
amountRemoved = 9;
}
break PADSEARCH;
}
}
}
}
}
// Set the player's launchpad item for return on landing - or null if launchpads not removed
if (stats != null) {
stats.setLaunchpadStack(amountRemoved == 9 ? new ItemStack(GCBlocks.landingPad, 9, 0) : null);
}
this.playSound("random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
}
}
Aggregations