use of net.minecraft.potion.Potion in project Galacticraft by micdoodle8.
the class ItemInfo method addIDDumps.
private static void addIDDumps() {
API.addOption(new RegistryDumper<Item>("tools.dump.item") {
@Override
public String[] header() {
return new String[] { "Name", "ID", "Has Block", "Mod", "Class" };
}
@Override
public String[] dump(Item item, int id, String name) {
return new String[] { name, Integer.toString(id), Boolean.toString(Block.getBlockFromItem(item) != Blocks.air), ItemInfo.itemOwners.get(item), item.getClass().getCanonicalName() };
}
@Override
public RegistryNamespaced registry() {
return Item.itemRegistry;
}
});
API.addOption(new RegistryDumper<Block>("tools.dump.block") {
@Override
public String[] header() {
return new String[] { "Name", "ID", "Has Item", "Mod", "Class" };
}
@Override
public String[] dump(Block item, int id, String name) {
return new String[] { name, Integer.toString(id), Boolean.toString(Item.getItemFromBlock(item) != null), ItemInfo.itemOwners.get(item), item.getClass().getCanonicalName() };
}
@Override
public RegistryNamespaced registry() {
return Block.blockRegistry;
}
});
API.addOption(new ArrayDumper<Potion>("tools.dump.potion") {
public String[] header() {
return new String[] { "ID", "Unlocalised name", "Class" };
}
@Override
public String[] dump(Potion potion, int id) {
return new String[] { Integer.toString(id), potion.getName(), potion.getClass().getCanonicalName() };
}
@Override
public Potion[] array() {
return Potion.potionTypes;
}
});
API.addOption(new ArrayDumper<Enchantment>("tools.dump.enchantment") {
public String[] header() {
return new String[] { "ID", "Unlocalised name", "Type", "Min Level", "Max Level", "Class" };
}
@Override
public String[] dump(Enchantment ench, int id) {
return new String[] { Integer.toString(id), ench.getName(), ench.type.toString(), Integer.toString(ench.getMinLevel()), Integer.toString(ench.getMaxLevel()), ench.getClass().getCanonicalName() };
}
@Override
public Enchantment[] array() {
return Enchantment.enchantmentsList;
}
});
API.addOption(new ArrayDumper<BiomeGenBase>("tools.dump.biome") {
@Override
public String[] header() {
return new String[] { "ID", "Name", "Temperature", "Rainfall", "Spawn Chance", "Root Height", "Height Variation", "Types", "Class" };
}
@Override
public String[] dump(BiomeGenBase biome, int id) {
BiomeDictionary.Type[] types = BiomeDictionary.getTypesForBiome(biome);
StringBuilder s_types = new StringBuilder();
for (BiomeDictionary.Type t : types) {
if (s_types.length() > 0) {
s_types.append(", ");
}
s_types.append(t.name());
}
return new String[] { Integer.toString(id), biome.biomeName, Float.toString(biome.getFloatTemperature(BlockPos.ORIGIN)), Float.toString(biome.getFloatRainfall()), Float.toString(biome.getSpawningChance()), Float.toString(biome.minHeight), Float.toString(biome.maxHeight), s_types.toString(), biome.getClass().getCanonicalName() };
}
@Override
public BiomeGenBase[] array() {
return BiomeGenBase.getBiomeGenArray();
}
});
API.addOption(new ItemPanelDumper("tools.dump.itempanel"));
// TODO Fluid registry Dumper.
}
use of net.minecraft.potion.Potion in project Minechem by iopleke.
the class PotionInjector method inject.
public static void inject() {
int potionTotal = Potion.potionTypes.length;
Potion[] effectAray = new Potion[potionTotal + 1];
System.arraycopy(Potion.potionTypes, 0, effectAray, 0, potionTotal);
Field field = null;
Field[] fields = Potion.class.getDeclaredFields();
for (Field f : fields) {
if (f.getName().equals("potionTypes") || f.getName().equals("field_76425_a")) {
field = f;
break;
}
}
try {
field.setAccessible(true);
Field modfield = Field.class.getDeclaredField("modifiers");
modfield.setAccessible(true);
modfield.setInt(field, field.getModifiers() & ~Modifier.FINAL);
field.set(null, effectAray);
} catch (Exception e) {
LogHelper.debug("PotionInjector threw an exception:");
LogHelper.debug(e);
}
atropineHigh = new PotionProvider(potionTotal, true, 0x00FF6E).setPotionName("Delirium");
}
use of net.minecraft.potion.Potion in project BetterStorage by copygirl.
the class ItemBucketSlime method addInformation.
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean advancedTooltips) {
String id = getSlimeId(stack);
Handler handler = getHandler(id);
String name = StackUtils.get(stack, (String) null, "Slime", "name");
if ((name != null) || advancedTooltips)
list.add("Contains: " + ((name != null) ? ("\"" + name + "\"" + (advancedTooltips ? " (" + id + ")" : "")) : id));
NBTTagList effectList = (NBTTagList) StackUtils.getTag(stack, "Effects");
if ((effectList != null) && (handler != null)) {
int max = ((advancedTooltips || GuiScreen.isShiftKeyDown()) ? 6 : 3);
for (int i = 0; i < Math.min(effectList.tagCount(), max); i++) {
PotionEffect effect = PotionEffect.readCustomPotionEffectFromNBT(effectList.getCompoundTagAt(i));
Potion potion = Potion.potionTypes[effect.getPotionID()];
int duration = (int) (effect.getDuration() * handler.durationMultiplier());
StringBuilder str = new StringBuilder().append(potion.isBadEffect() ? EnumChatFormatting.RED : EnumChatFormatting.GRAY).append(StatCollector.translateToLocal(effect.getEffectName()));
if (effect.getAmplifier() > 0)
str.append(" ").append(StatCollector.translateToLocal("potion.potency." + effect.getAmplifier()));
str.append(" (").append(StringUtils.ticksToElapsedTime(duration)).append(")");
list.add(str.toString());
}
int more = (effectList.tagCount() - max);
if (more > 0)
list.add(EnumChatFormatting.DARK_GRAY.toString() + EnumChatFormatting.ITALIC + LanguageUtils.translateTooltip("bucketSlime.more." + ((more == 1) ? "1" : "x"), "%X%", Integer.toString(more)));
}
}
use of net.minecraft.potion.Potion in project Gaspunk by Ladysnake.
the class PotionAgent method applyEffect.
@Override
public void applyEffect(EntityLivingBase entity, IBreathingHandler handler, float concentration, boolean firstTick, float potency, boolean forced) {
// still check for server-side because doing otherwise is stupid
if (!entity.world.isRemote && (forced || entity.world.getWorldTime() % 20 == 0)) {
Potion potion = getPotion();
entity.addPotionEffect(new PotionEffect(potion, potionDuration, potionAmplifier));
}
}
use of net.minecraft.potion.Potion in project SpongeCommon by SpongePowered.
the class MixinPotion method onPotionRegister.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Redirect(method = "registerPotions", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/registry/RegistryNamespaced;register(ILjava/lang/Object;Ljava/lang/Object;)V"))
private static void onPotionRegister(RegistryNamespaced registry, int id, Object location, Object potion) {
final ResourceLocation resource = (ResourceLocation) location;
final Potion mcPotion = (Potion) potion;
((IMixinPotion) mcPotion).setId(resource.toString().toLowerCase(Locale.ENGLISH));
PotionEffectTypeRegistryModule.getInstance().registerFromGameData(resource.toString(), (PotionEffectType) mcPotion);
registry.register(id, location, potion);
}
Aggregations