use of icbm.classic.api.caps.IExplosive in project ICBM-Classic by BuiltBrokenModding.
the class ExplosiveInit method enderBlockCoordSet.
private static boolean enderBlockCoordSet(World world, BlockPos pos, EntityPlayer entityPlayer, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
final ItemStack heldItem = entityPlayer.getHeldItem(hand);
if (heldItem.getItem() instanceof IWorldPosItem) {
final IWorldPosItem posItem = ((IWorldPosItem) heldItem.getItem());
final IWorldPosition link = posItem.getLocation(heldItem);
if (link instanceof Location) {
TileEntity tileEntity = world.getTileEntity(pos);
if (tileEntity.hasCapability(ICBMClassicAPI.EXPLOSIVE_CAPABILITY, facing)) {
IExplosive explosive = tileEntity.getCapability(ICBMClassicAPI.EXPLOSIVE_CAPABILITY, facing);
if (explosive != null) {
NBTTagCompound tag = new NBTTagCompound();
((Location) link).writeIntNBT(tag);
explosive.getCustomBlastData().setTag("", tag);
if (!world.isRemote) {
// entityPlayer.sendMessage(new TextComponentString("Synced coordinate with " + this.getExplosiveName())); //TODO translate
}
return true;
}
}
}
}
return false;
}
use of icbm.classic.api.caps.IExplosive in project ICBM-Classic by BuiltBrokenModding.
the class ItemDefuser method onLeftClickEntity.
/**
* Called when the player Left Clicks (attacks) an entity. Processed before damage is done, if
* return value is true further processing is canceled and the entity is not attacked.
*
* @param itemStack The Item being used
* @param player The player that is attacking
* @param entity The entity being attacked
* @return True to cancel the rest of the interaction.
*/
@Override
public boolean onLeftClickEntity(ItemStack itemStack, EntityPlayer player, Entity entity) {
if (this.getEnergy(itemStack) >= ENERGY_COST) {
if (ICBMClassicHelpers.isExplosive(entity)) {
if (!entity.world.isRemote) {
final IExplosive explosive = ICBMClassicHelpers.getExplosive(entity);
if (explosive != null) {
if (MinecraftForge.EVENT_BUS.post(new ExplosiveDefuseEvent.ICBMExplosive(player, entity, explosive))) {
return false;
}
explosive.onDefuse();
}
entity.setDead();
}
} else if (entity instanceof EntityTNTPrimed) {
if (MinecraftForge.EVENT_BUS.post(new ExplosiveDefuseEvent.TNTExplosive(player, entity))) {
return false;
}
if (!entity.world.isRemote) {
entity.world.spawnEntity(new EntityItem(entity.world, entity.posX, entity.posY, entity.posZ, new ItemStack(Blocks.TNT)));
}
entity.setDead();
} else if (entity instanceof EntityBombCart) {
if (MinecraftForge.EVENT_BUS.post(new ExplosiveDefuseEvent.ICBMBombCart(player, entity))) {
return false;
}
((EntityBombCart) entity).killMinecart(DamageSource.GENERIC);
}
this.discharge(itemStack, ENERGY_COST, true);
return true;
} else {
player.sendMessage(new TextComponentString(LanguageUtility.getLocal("message.defuser.nopower")));
}
return false;
}
use of icbm.classic.api.caps.IExplosive in project ICBM-Classic by BuiltBrokenModding.
the class EntityGrenadeTest method getCapability_explosiveCap.
@Test
void getCapability_explosiveCap() {
final EntityGrenade entityGrenade = new EntityGrenade(testManager.getWorld());
// Mock cast as mockito is odd
Mockito.when(ICBMClassicAPI.EXPLOSIVE_CAPABILITY.cast(entityGrenade.explosive)).thenReturn(entityGrenade.explosive);
final IExplosive capability = entityGrenade.getCapability(ICBMClassicAPI.EXPLOSIVE_CAPABILITY, null);
// Should return a capability for an entity
Assertions.assertTrue(capability instanceof CapabilityExplosiveEntity, "Should have an explosive entity cap");
final CapabilityExplosiveEntity cap = (CapabilityExplosiveEntity) capability;
// Should contain the entity in question
Assertions.assertSame(cap.entity, entityGrenade);
}
use of icbm.classic.api.caps.IExplosive in project ICBM-Classic by BuiltBrokenModding.
the class ICBMCreativeTab method compareExplosives.
private int compareExplosives(ItemStack itemA, ItemStack itemB) {
final IExplosive explosiveA = ICBMClassicHelpers.getExplosive(itemA);
final IExplosive explosiveB = ICBMClassicHelpers.getExplosive(itemB);
if (explosiveA != null && explosiveB != null) {
return compareExplosives(explosiveA, explosiveB);
}
return 0;
}
use of icbm.classic.api.caps.IExplosive in project ICBM-Classic by BuiltBrokenModding.
the class TileCruiseLauncher method getStatus.
/**
* Gets the display status of the missile launcher
*
* @return The string to be displayed
*/
@Override
public String getStatus() {
String color = "\u00a74";
String status;
if (!hasChargeToFire()) {
status = LanguageUtility.getLocal("gui.launcherCruise.statusNoPower");
} else if (this.getInventory().getStackInSlot(0).isEmpty()) {
status = LanguageUtility.getLocal("gui.launcherCruise.statusEmpty");
} else if (this.getInventory().getStackInSlot(0).getItem() != ItemReg.itemMissile) {
status = LanguageUtility.getLocal("gui.launcherCruise.invalidMissile");
} else {
final IExplosive explosive = ICBMClassicHelpers.getExplosive(this.getInventory().getStackInSlot(0));
if (explosive == null) {
status = LanguageUtility.getLocal("gui.launcherCruise.invalidMissile");
} else if (!hasMissile()) {
status = LanguageUtility.getLocal("gui.launcherCruise.notCruiseMissile");
} else if (!hasTarget()) {
status = LanguageUtility.getLocal("gui.launcherCruise.statusInvalid");
} else if (this.isTooClose(getTarget())) {
status = LanguageUtility.getLocal("gui.launcherCruise.targetToClose");
} else if (!canSpawnMissileWithNoCollision()) {
status = LanguageUtility.getLocal("gui.launcherCruise.noRoom");
} else {
color = "\u00a72";
status = LanguageUtility.getLocal("gui.launcherCruise.statusReady");
}
}
return color + status;
}
Aggregations