use of icbm.classic.api.reg.IExplosiveData in project ICBM-Classic by BuiltBrokenModding.
the class ItemRocketLauncher method onPlayerStoppedUsing.
@Override
public void onPlayerStoppedUsing(ItemStack stack, World world, EntityLivingBase entityLiving, int timeLeft) {
if (entityLiving instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) entityLiving;
if (this.getEnergy(stack) >= ENERGY || player.capabilities.isCreativeMode) {
// Check the player's inventory and look for missiles.
for (int slot = 0; slot < player.inventory.getSizeInventory(); slot++) {
ItemStack inventoryStack = player.inventory.getStackInSlot(slot);
if (inventoryStack != null) {
if (// TODO add capability
inventoryStack.getItem() instanceof ItemMissile) {
final int explosiveID = inventoryStack.getItemDamage();
final IExplosiveData exData = ICBMClassicHelpers.getExplosive(explosiveID, true);
if (exData != null) {
// TODO add hook to block firing some missiles from launcher
if (exData.getTier().ordinal() + 1 <= ConfigMain.ROCKET_LAUNCHER_TIER_FIRE_LIMIT || player.capabilities.isCreativeMode) {
if (!world.isRemote) {
EntityMissile entityMissile = new EntityMissile(player);
entityMissile.missileType = MissileFlightType.HAND_LAUNCHER;
entityMissile.explosiveID = explosiveID;
entityMissile.acceleration = 1;
entityMissile.capabilityMissile.launchNoTarget();
world.spawnEntity(entityMissile);
if (player.isSneaking()) {
player.startRiding(entityMissile);
player.setSneaking(false);
}
if (!player.capabilities.isCreativeMode) {
player.inventory.setInventorySlotContents(slot, ItemStack.EMPTY);
player.inventoryContainer.detectAndSendChanges();
this.discharge(stack, ENERGY, true);
}
}
// Store last time player launched a rocket
clickTimePlayer.put(player.getName(), System.currentTimeMillis());
return;
}
}
}
}
}
}
}
}
use of icbm.classic.api.reg.IExplosiveData in project ICBM-Classic by BuiltBrokenModding.
the class ExBlockContentReg method lockRegistry.
@Override
public void lockRegistry() {
if (!isLocked()) {
super.lockRegistry();
fuseSetSupplierMap.forEach((regName, func) -> {
final IExplosiveData data = ICBMClassicAPI.EXPLOSIVE_REGISTRY.getExplosiveData(regName);
if (data != null) {
fuseSetSupplier.addKey(data.getRegistryID(), func);
}
});
fuseTickCallbackMap.forEach((regName, func) -> {
final IExplosiveData data = ICBMClassicAPI.EXPLOSIVE_REGISTRY.getExplosiveData(regName);
if (data != null) {
fuseTickCallback.addKey(data.getRegistryID(), func);
}
});
blockActivationCallbackMap.forEach((regName, func) -> {
final IExplosiveData data = ICBMClassicAPI.EXPLOSIVE_REGISTRY.getExplosiveData(regName);
if (data != null) {
blockActiviationCallback.addKey(data.getRegistryID(), func);
}
});
} else
throw new RuntimeException(this + ": Registry was locked twice!");
}
use of icbm.classic.api.reg.IExplosiveData in project ICBM-Classic by BuiltBrokenModding.
the class ExMinecartContentReg method lockRegistry.
@Override
public void lockRegistry() {
if (!isLocked()) {
super.lockRegistry();
fuseSetSupplierMap.forEach((regName, func) -> {
final IExplosiveData data = ICBMClassicAPI.EXPLOSIVE_REGISTRY.getExplosiveData(regName);
if (data != null) {
fuseSetSupplier.addKey(data.getRegistryID(), func);
}
});
fuseTickCallbackMap.forEach((regName, func) -> {
final IExplosiveData data = ICBMClassicAPI.EXPLOSIVE_REGISTRY.getExplosiveData(regName);
if (data != null) {
fuseTickCallback.addKey(data.getRegistryID(), func);
}
});
} else
throw new RuntimeException(this + ": Registry was locked twice!");
}
use of icbm.classic.api.reg.IExplosiveData in project ICBM-Classic by BuiltBrokenModding.
the class ExGrenadeContentReg method lockRegistry.
@Override
public void lockRegistry() {
if (!isLocked()) {
super.lockRegistry();
fuseSetSupplierMap.forEach((regName, func) -> {
final IExplosiveData data = ICBMClassicAPI.EXPLOSIVE_REGISTRY.getExplosiveData(regName);
if (data != null) {
fuseSetSupplier.addKey(data.getRegistryID(), func);
}
});
fuseTickCallbackMap.forEach((regName, func) -> {
final IExplosiveData data = ICBMClassicAPI.EXPLOSIVE_REGISTRY.getExplosiveData(regName);
if (data != null) {
fuseTickCallback.addKey(data.getRegistryID(), func);
}
});
} else
throw new RuntimeException(this + ": Registry was locked twice!");
}
use of icbm.classic.api.reg.IExplosiveData in project ICBM-Classic by BuiltBrokenModding.
the class EntityExplosion method constructBlast.
/**
* Constructs a blast based on the parameters and sets the blast field to that value
*/
private void constructBlast(String exId, double yOffset) {
ResourceLocation id = new ResourceLocation(exId);
IExplosiveData exData = ICBMClassicAPI.EXPLOSIVE_REGISTRY.getExplosiveData(id);
if (exData != null) {
// TODO convert load code to blast creation helper
final IBlastFactory factory = exData.getBlastFactory();
if (factory != null) {
blast = factory.create();
((IBlastInit) blast).setBlastWorld(world);
((IBlastInit) blast).setBlastPosition(posX, posY + yOffset, posZ);
((IBlastInit) blast).setEntityController(this);
((IBlastInit) blast).setExplosiveData(exData);
((IBlastInit) blast).buildBlast();
return;
}
}
ICBMClassic.logger().error("EntityExplosion: Failed to locate explosive with id '" + id + "'!");
}
Aggregations