use of icbm.classic.api.reg.IExplosiveData in project ICBM-Classic by BuiltBrokenModding.
the class ItemBlockExplosive method getDetailedInfo.
@Override
public void getDetailedInfo(ItemStack stack, @Nullable EntityPlayer player, List list) {
final IExplosiveData data = ICBMClassicHelpers.getExplosive(stack.getItemDamage(), true);
if (data != null) {
final EnumTier tierdata = data.getTier();
list.add(TextFormatting.DARK_RED + LanguageUtility.getLocal("info.misc.tier") + ": " + tierdata.getTooltipColor() + tierdata.getLocalizedName());
}
if (// TODO add hook for any explosive via content reg
stack.getItemDamage() == ICBMExplosives.REDMATTER.getRegistryID()) {
// /Shhh!!! tell no one this exists, tis a surprise
boolean taunt = shouldTauntPlayer(player);
if (taunt) {
switch(tauntCount) {
case 0:
list.add("Place me, you know you want to :)");
// $FALL-THROUGH$
case 1:
list.add("Mine with me, lets get some minerals!!");
// $FALL-THROUGH$
case 2:
list.add("Can you hear the noises in the dark?");
// $FALL-THROUGH$
case 3:
list.add("One does not simply use");
list.add("redmatter to cancel redmatter");
// $FALL-THROUGH$
case 4:
list.add("Nice base you have");
list.add("be a shame if something");
list.add("would happen to it");
// $FALL-THROUGH$
case 5:
list.add("Don't worry i've changed");
// $FALL-THROUGH$
case 6:
list.add("Lets eat a world together");
// $FALL-THROUGH$
case 7:
list.add("I'm back for you");
}
} else {
normalDetailedInfo(list);
}
// Cycle next message
if (player != null && System.currentTimeMillis() - lastTranslationChange > changeOverDelay) {
lastTranslationChange = System.currentTimeMillis();
if (taunt) {
tauntCount = player.world.rand.nextInt(7);
} else if (redmatterRandomTranslations > 0) {
tauntCount = player.world.rand.nextInt(redmatterRandomTranslations);
}
}
} else {
super.getDetailedInfo(stack, player, list);
}
}
use of icbm.classic.api.reg.IExplosiveData in project ICBM-Classic by BuiltBrokenModding.
the class TileLauncherBase method launchMissile.
/**
* Launches the missile
*
* @param target - The target in which the missile will land in
* @param lockHeight - height to wait before curving the missile
*/
public boolean launchMissile(Pos target, int lockHeight) {
// Allow canceling missile launches
if (MinecraftForge.EVENT_BUS.post(new LauncherEvent.PreLaunch(missileLauncher, missileHolder))) {
return false;
}
final ItemStack stack = getMissileStack();
if (// TODO capability
stack.getItem() == ItemReg.itemMissile) {
IExplosiveData explosiveData = ICBMClassicHelpers.getExplosive(stack.getItemDamage(), true);
if (explosiveData != null) {
target = applyInaccuracy(target);
if (isServer()) {
// TODO generate entity from item using handler
EntityMissile missile = new EntityMissile(getWorld());
// Set data
missile.explosiveID = explosiveData.getRegistryID();
// TODO store our launcher instance or UUID
missile.launcherPos = new Pos((TileEntity) this);
// TODO store offset
missile.setPosition(xi() + 0.5, yi() + 3, zi() + 0.5);
// Trigger launch event
missile.capabilityMissile.launch(target.x(), target.y(), target.z(), lockHeight);
// Spawn entity
((WorldServer) getWorld()).addScheduledTask(() -> getWorld().spawnEntity(missile));
// Grab rider
if (// TODO add hook to disable riding some missiles
seat != null && seat.getRidingEntity() != null) {
Entity entity = seat.getRidingEntity();
seat.getRidingEntity().startRiding(null);
entity.startRiding(missile);
}
// Remove item
getInventory().decrStackSize(0, 1);
}
return true;
}
}
return false;
}
use of icbm.classic.api.reg.IExplosiveData in project ICBM-Classic by BuiltBrokenModding.
the class BlockExplosive method getActualState.
@Override
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) {
IExplosiveData explosiveData = null;
TileEntity tile = worldIn.getTileEntity(pos);
if (tile instanceof TileEntityExplosive && ((TileEntityExplosive) tile).capabilityExplosive != null) {
explosiveData = ((TileEntityExplosive) tile).capabilityExplosive.getExplosiveData();
}
if (explosiveData != null) {
return state.withProperty(EX_PROP, explosiveData);
}
return state;
}
use of icbm.classic.api.reg.IExplosiveData in project ICBM-Classic by BuiltBrokenModding.
the class ICBMClassicHelpers method getExplosive.
/**
* Called to get explosive
*
* @param name - registry name of the explosive
* @return explosive desired, or default TNT
*/
public static IExplosiveData getExplosive(ResourceLocation name, boolean returnNull) {
final IExplosiveData data = ICBMClassicAPI.EXPLOSIVE_REGISTRY.getExplosiveData(name);
if (data != null) {
return data;
}
System.out.println("ICBMClassicAPI: Error - Failed to locate explosive for Name[" + name + "] this may cause unexpected logic");
return returnNull ? null : ICBMExplosives.CONDENSED;
}
use of icbm.classic.api.reg.IExplosiveData in project ICBM-Classic by BuiltBrokenModding.
the class ClientReg method registerGrenadeRenders.
protected static void registerGrenadeRenders() {
for (// TODO run loop once for all 4 content types
IExplosiveData data : // TODO run loop once for all 4 content types
ICBMClassicAPI.EX_GRENADE_REGISTRY.getExplosives()) {
final String resourcePath = data.getRegistryName().getNamespace() + ":grenades/" + data.getRegistryName().getPath();
grenadeModelMap.put(data, new ModelResourceLocation(resourcePath, "inventory"));
}
ModelLoader.registerItemVariants(ItemReg.itemGrenade, grenadeModelMap.values().stream().map(model -> new ResourceLocation(model.getNamespace() + ":" + model.getPath())).toArray(ResourceLocation[]::new));
ModelLoader.setCustomMeshDefinition(ItemReg.itemGrenade, new ItemModelMapperExplosive(grenadeModelMap, grenadeModelMap.get(ICBMExplosives.CONDENSED)));
}
Aggregations