update BS+SA

This commit is contained in:
Martin Robertz committed 2022-10-22 12:08:16 +02:00
1 parent 49bcd403e9
commit 2ec3ad07a0
31 files changed
+2397 -1054

No files matched your search

@@ -1,5 +1,7 @@
package singulariteam.eternalsingularity;
import java.util.Iterator;
import javax.annotation.Nonnull;
import minetweaker.IUndoableAction;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
@@ -9,130 +11,107 @@ import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import wanion.lib.common.MineTweakerHelper;
import javax.annotation.Nonnull;
import java.util.Iterator;
@ZenClass("mods.eternalsingularity")
public final class EternalRecipeTweaker
{
private EternalRecipeTweaker() {}
public final class EternalRecipeTweaker {
private EternalRecipeTweaker() {}
public static void init()
{
MineTweakerAPI.registerClass(EternalRecipeTweaker.class);
}
public static void init() {
MineTweakerAPI.registerClass(EternalRecipeTweaker.class);
}
@ZenMethod
public static void add(@Nonnull final IItemStack input)
{
final ItemStack itemStack = MineTweakerHelper.toStack(input);
if (itemStack != null && itemStack.getItem() != null)
MineTweakerAPI.apply(new Add(itemStack));
}
@ZenMethod
public static void add(@Nonnull final IItemStack input) {
final ItemStack itemStack = MineTweakerHelper.toStack(input);
if (itemStack != null && itemStack.getItem() != null) MineTweakerAPI.apply(new Add(itemStack));
}
@ZenMethod
public static void remove(final IItemStack input)
{
final ItemStack itemStack = MineTweakerHelper.toStack(input);
if (itemStack != null && itemStack.getItem() != null)
MineTweakerAPI.apply(new Remove(itemStack));
}
@ZenMethod
public static void remove(final IItemStack input) {
final ItemStack itemStack = MineTweakerHelper.toStack(input);
if (itemStack != null && itemStack.getItem() != null) MineTweakerAPI.apply(new Remove(itemStack));
}
private static class Add implements IUndoableAction
{
private final ItemStack itemStack;
private static class Add implements IUndoableAction {
private final ItemStack itemStack;
public Add(@Nonnull final ItemStack itemStack)
{
this.itemStack = itemStack;
}
public Add(@Nonnull final ItemStack itemStack) {
this.itemStack = itemStack;
}
@Override
public void apply()
{
CommonProxy.getEternalSingularityRecipe().getInput().add(itemStack);
}
@Override
public void apply() {
CommonProxy.getEternalSingularityRecipe().getInput().add(itemStack);
}
@Override
public boolean canUndo()
{
return true;
}
@Override
public boolean canUndo() {
return true;
}
@Override
public void undo()
{
CommonProxy.getEternalSingularityRecipe().getInput().remove(itemStack);
}
@Override
public void undo() {
CommonProxy.getEternalSingularityRecipe().getInput().remove(itemStack);
}
@Override
public String describe()
{
return "Adding " + itemStack.getDisplayName() + " into Eternal Singularity Recipe.";
}
@Override
public String describe() {
return "Adding " + itemStack.getDisplayName() + " into Eternal Singularity Recipe.";
}
@Override
public String describeUndo()
{
return "Removing " + itemStack.getDisplayName() + " from Eternal Singularity Recipe.";
}
@Override
public String describeUndo() {
return "Removing " + itemStack.getDisplayName() + " from Eternal Singularity Recipe.";
}
@Override
public Object getOverrideKey()
{
return null;
}
}
@Override
public Object getOverrideKey() {
return null;
}
}
private static class Remove implements IUndoableAction
{
private final ItemStack itemStack;
private static class Remove implements IUndoableAction {
private final ItemStack itemStack;
private Remove(@Nonnull final ItemStack itemStackToRemove)
{
ItemStack itemStack = null;
for (final Iterator<Object> eternalSingularityRecipeIterator = CommonProxy.getEternalSingularityRecipe().getInput().iterator(); eternalSingularityRecipeIterator.hasNext() && itemStack == null; ) {
final Object input = eternalSingularityRecipeIterator.next();
if (input instanceof ItemStack && ((ItemStack) input).isItemEqual(itemStackToRemove))
itemStack = (ItemStack) input;
}
this.itemStack = itemStack;
}
private Remove(@Nonnull final ItemStack itemStackToRemove) {
ItemStack itemStack = null;
for (final Iterator<Object> eternalSingularityRecipeIterator =
CommonProxy.getEternalSingularityRecipe().getInput().iterator();
eternalSingularityRecipeIterator.hasNext() && itemStack == null; ) {
final Object input = eternalSingularityRecipeIterator.next();
if (input instanceof ItemStack && ((ItemStack) input).isItemEqual(itemStackToRemove))
itemStack = (ItemStack) input;
}
this.itemStack = itemStack;
}
@Override
public void apply()
{
CommonProxy.getEternalSingularityRecipe().getInput().remove(itemStack);
}
@Override
public void apply() {
CommonProxy.getEternalSingularityRecipe().getInput().remove(itemStack);
}
@Override
public boolean canUndo()
{
return itemStack != null;
}
@Override
public boolean canUndo() {
return itemStack != null;
}
@Override
public void undo()
{
CommonProxy.getEternalSingularityRecipe().getInput().add(itemStack);
}
@Override
public void undo() {
CommonProxy.getEternalSingularityRecipe().getInput().add(itemStack);
}
@Override
public String describe()
{
return "Removing " + itemStack.getDisplayName() + " from Eternal Singularity Recipe.";
}
@Override
public String describe() {
return "Removing " + itemStack.getDisplayName() + " from Eternal Singularity Recipe.";
}
@Override
public String describeUndo()
{
return "Adding " + itemStack.getDisplayName() + " into Eternal Singularity Recipe.";
}
@Override
public String describeUndo() {
return "Adding " + itemStack.getDisplayName() + " into Eternal Singularity Recipe.";
}
@Override
public Object getOverrideKey()
{
return null;
}
}
}
@Override
public Object getOverrideKey() {
return null;
}
}
}
@@ -1,5 +1,7 @@
package singulariteam.eternalsingularity;
import static singulariteam.eternalsingularity.Reference.*;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
@@ -13,45 +15,43 @@ import org.apache.logging.log4j.Logger;
import singulariteam.eternalsingularity.item.EternalSingularityItem;
import singulariteam.eternalsingularity.proxy.CommonProxy;
import static singulariteam.eternalsingularity.Reference.*;
@Mod(
modid = MOD_ID,
name = MOD_NAME,
version = MOD_VERSION,
acceptedMinecraftVersions = MC_VERSION,
dependencies =
"required-after:Avaritia;required-after:wanionlib@[1.7.10-1.3,);after:thermsingul;after:universalsingularities;after:aobdsingularities")
public class EternalSingularityMod {
@Mod.Instance(MOD_ID)
public static EternalSingularityMod instance;
@Mod(modid = MOD_ID, name = MOD_NAME, version = MOD_VERSION, acceptedMinecraftVersions = MC_VERSION, dependencies = "required-after:Avaritia;required-after:wanionlib@[1.7.10-1.3,);after:thermsingul;after:universalsingularities;after:aobdsingularities")
public class EternalSingularityMod
{
@Mod.Instance(MOD_ID)
public static EternalSingularityMod instance;
public static Logger logger;
public static Logger logger;
@SidedProxy(serverSide = COMMON_PROXY, clientSide = CLIENT_PROXY)
public static CommonProxy proxy;
@SidedProxy(serverSide = COMMON_PROXY, clientSide = CLIENT_PROXY)
public static CommonProxy proxy;
public static final CreativeTabs creativeTabs = new CreativeTabs(MOD_ID) {
@SideOnly(Side.CLIENT)
@Override
public Item getTabIconItem() {
return EternalSingularityItem.instance;
}
};
public static final CreativeTabs creativeTabs = new CreativeTabs(MOD_ID)
{
@SideOnly(Side.CLIENT)
@Override
public Item getTabIconItem()
{
return EternalSingularityItem.instance;
}
};
@Mod.EventHandler
public void preInit(final FMLPreInitializationEvent event) {
logger = event.getModLog();
proxy.preInit(event.getSuggestedConfigurationFile());
}
@Mod.EventHandler
public void preInit(final FMLPreInitializationEvent event)
{
logger = event.getModLog();
proxy.preInit(event.getSuggestedConfigurationFile());
}
@Mod.EventHandler
public void init(final FMLInitializationEvent event) {
proxy.init();
}
@Mod.EventHandler
public void init(final FMLInitializationEvent event)
{
proxy.init();
}
@Mod.EventHandler
public void postInit(final FMLPostInitializationEvent event)
{
proxy.postInit();
}
}
@Mod.EventHandler
public void postInit(final FMLPostInitializationEvent event) {
proxy.postInit();
}
}
@@ -1,13 +1,12 @@
package singulariteam.eternalsingularity;
public final class Reference
{
public static final String MOD_ID = "eternalsingularity";
public static final String MOD_NAME = "Eternal Singularity";
public static final String MOD_VERSION = "1.7.10-.1.0.4b";
public static final String MC_VERSION = "[1.7.10]";
static final String COMMON_PROXY = "singulariteam.eternalsingularity.proxy.CommonProxy";
static final String CLIENT_PROXY = "singulariteam.eternalsingularity.proxy.ClientProxy";
public final class Reference {
public static final String MOD_ID = "eternalsingularity";
public static final String MOD_NAME = "Eternal Singularity";
public static final String MOD_VERSION = "1.7.10-.1.0.4b";
public static final String MC_VERSION = "[1.7.10]";
static final String COMMON_PROXY = "singulariteam.eternalsingularity.proxy.CommonProxy";
static final String CLIENT_PROXY = "singulariteam.eternalsingularity.proxy.ClientProxy";
private Reference() {}
}
private Reference() {}
}
@@ -1,14 +1,12 @@
package singulariteam.eternalsingularity.item;
import java.util.List;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import fox.spiteful.avaritia.Avaritia;
import fox.spiteful.avaritia.items.ItemResource;
import fox.spiteful.avaritia.items.LudicrousItems;
import fox.spiteful.avaritia.render.ICosmicRenderItem;
import fox.spiteful.avaritia.render.IHaloRenderItem;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
@@ -19,111 +17,98 @@ import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import singulariteam.eternalsingularity.EternalSingularityMod;
public class CompoundSingularityItem extends Item implements IHaloRenderItem, ICosmicRenderItem
{
private final int max;
public class CompoundSingularityItem extends Item implements IHaloRenderItem, ICosmicRenderItem {
private final int max;
@SideOnly(Side.CLIENT)
private IIcon cosmicMask;
@SideOnly(Side.CLIENT)
private IIcon[] foregroundIcons, backgroundIcons;
@SideOnly(Side.CLIENT)
private IIcon cosmicMask;
public CompoundSingularityItem(final int max)
{
super();
setHasSubtypes(true);
this.max = max;
setCreativeTab(EternalSingularityMod.creativeTabs);
}
@SideOnly(Side.CLIENT)
private IIcon[] foregroundIcons, backgroundIcons;
public EnumRarity getRarity(ItemStack stack)
{
return EnumRarity.uncommon;
}
public CompoundSingularityItem(final int max) {
super();
setHasSubtypes(true);
this.max = max;
setCreativeTab(EternalSingularityMod.creativeTabs);
}
@Override
public String getUnlocalizedName(final ItemStack stack)
{
return "item.combined.singularity." + MathHelper.clamp_int(getDamage(stack), 0, max);
}
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.uncommon;
}
@SuppressWarnings("unchecked")
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs tab, List list)
{
for (int j = 0; j < max; j++)
list.add(new ItemStack(item, 1, j));
}
@Override
public String getUnlocalizedName(final ItemStack stack) {
return "item.combined.singularity." + MathHelper.clamp_int(getDamage(stack), 0, max);
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getMaskTexture(ItemStack stack, EntityPlayer player)
{
return cosmicMask;
}
@SuppressWarnings("unchecked")
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs tab, List list) {
for (int j = 0; j < max; j++) list.add(new ItemStack(item, 1, j));
}
@Override
@SideOnly(Side.CLIENT)
public float getMaskMultiplier(ItemStack stack, EntityPlayer player)
{
return 1.0f;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getMaskTexture(ItemStack stack, EntityPlayer player) {
return cosmicMask;
}
@SideOnly(Side.CLIENT)
@Override
public void registerIcons(IIconRegister ir)
{
super.registerIcons(ir);
foregroundIcons = new IIcon[max];
backgroundIcons = new IIcon[max];
@Override
@SideOnly(Side.CLIENT)
public float getMaskMultiplier(ItemStack stack, EntityPlayer player) {
return 1.0f;
}
for (int x = 0; x < max; x++) {
foregroundIcons[x] = ir.registerIcon("eternalsingularity:combined_singularity_" + x + "_overlay");
backgroundIcons[x] = ir.registerIcon("eternalsingularity:combined_singularity_" + x);
}
this.cosmicMask = ir.registerIcon("eternalsingularity:combined_singularity_mask");
}
@SideOnly(Side.CLIENT)
@Override
public void registerIcons(IIconRegister ir) {
super.registerIcons(ir);
foregroundIcons = new IIcon[max];
backgroundIcons = new IIcon[max];
@Override
public IIcon getIcon(ItemStack stack, int pass)
{
return pass == 1 ? this.foregroundIcons[stack.getItemDamage() % foregroundIcons.length] : this.backgroundIcons[stack.getItemDamage() % backgroundIcons.length];
}
for (int x = 0; x < max; x++) {
foregroundIcons[x] = ir.registerIcon("eternalsingularity:combined_singularity_" + x + "_overlay");
backgroundIcons[x] = ir.registerIcon("eternalsingularity:combined_singularity_" + x);
}
this.cosmicMask = ir.registerIcon("eternalsingularity:combined_singularity_mask");
}
@SideOnly(Side.CLIENT)
@Override
public boolean requiresMultipleRenderPasses()
{
return true;
}
@Override
public IIcon getIcon(ItemStack stack, int pass) {
return pass == 1
? this.foregroundIcons[stack.getItemDamage() % foregroundIcons.length]
: this.backgroundIcons[stack.getItemDamage() % backgroundIcons.length];
}
@SideOnly(Side.CLIENT)
public boolean drawHalo(ItemStack paramItemStack)
{
return true;
}
@SideOnly(Side.CLIENT)
@Override
public boolean requiresMultipleRenderPasses() {
return true;
}
@SideOnly(Side.CLIENT)
public IIcon getHaloTexture(ItemStack paramItemStack)
{
return ((ItemResource) LudicrousItems.resource).halo[0];
}
@SideOnly(Side.CLIENT)
public boolean drawHalo(ItemStack paramItemStack) {
return true;
}
@SideOnly(Side.CLIENT)
public int getHaloSize(ItemStack paramItemStack)
{
return 4;
}
@SideOnly(Side.CLIENT)
public IIcon getHaloTexture(ItemStack paramItemStack) {
return ((ItemResource) LudicrousItems.resource).halo[0];
}
@SideOnly(Side.CLIENT)
public boolean drawPulseEffect(ItemStack paramItemStack)
{
return false;
}
@SideOnly(Side.CLIENT)
public int getHaloSize(ItemStack paramItemStack) {
return 4;
}
@SideOnly(Side.CLIENT)
public int getHaloColour(ItemStack paramItemStack)
{
return -16777216;
}
}
@SideOnly(Side.CLIENT)
public boolean drawPulseEffect(ItemStack paramItemStack) {
return false;
}
@SideOnly(Side.CLIENT)
public int getHaloColour(ItemStack paramItemStack) {
return -16777216;
}
}
@@ -2,7 +2,6 @@ package singulariteam.eternalsingularity.item;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import fox.spiteful.avaritia.Avaritia;
import fox.spiteful.avaritia.entity.EntityImmortalItem;
import fox.spiteful.avaritia.items.ItemResource;
import fox.spiteful.avaritia.items.LudicrousItems;
@@ -18,106 +17,90 @@ import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import singulariteam.eternalsingularity.EternalSingularityMod;
public class EternalSingularityItem extends Item implements IHaloRenderItem, ICosmicRenderItem
{
public static final EternalSingularityItem instance = new EternalSingularityItem();
public class EternalSingularityItem extends Item implements IHaloRenderItem, ICosmicRenderItem {
public static final EternalSingularityItem instance = new EternalSingularityItem();
private IIcon cosmicMask;
private IIcon foregroundIcon;
private IIcon cosmicMask;
private IIcon foregroundIcon;
private EternalSingularityItem()
{
super();
setCreativeTab(EternalSingularityMod.creativeTabs);
setTextureName("eternalsingularity:eternal_singularity2");
}
private EternalSingularityItem() {
super();
setCreativeTab(EternalSingularityMod.creativeTabs);
setTextureName("eternalsingularity:eternal_singularity2");
}
public EnumRarity getRarity(ItemStack stack)
{
return LudicrousItems.cosmic;
}
public EnumRarity getRarity(ItemStack stack) {
return LudicrousItems.cosmic;
}
@Override
public String getUnlocalizedName(final ItemStack stack)
{
return "item.eternal.singularity";
}
@Override
public String getUnlocalizedName(final ItemStack stack) {
return "item.eternal.singularity";
}
@Override
public boolean hasCustomEntity(ItemStack stack)
{
return true;
}
@Override
public boolean hasCustomEntity(ItemStack stack) {
return true;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getMaskTexture(ItemStack stack, EntityPlayer player)
{
return cosmicMask;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getMaskTexture(ItemStack stack, EntityPlayer player) {
return cosmicMask;
}
@Override
@SideOnly(Side.CLIENT)
public float getMaskMultiplier(ItemStack stack, EntityPlayer player)
{
return 1.0f;
}
@Override
@SideOnly(Side.CLIENT)
public float getMaskMultiplier(ItemStack stack, EntityPlayer player) {
return 1.0f;
}
@SideOnly(Side.CLIENT)
@Override
public void registerIcons(IIconRegister ir)
{
super.registerIcons(ir);
this.cosmicMask = ir.registerIcon("eternalsingularity:eternal_singularity_mask");
this.foregroundIcon = ir.registerIcon("eternalsingularity:eternal_singularity");
}
@SideOnly(Side.CLIENT)
@Override
public void registerIcons(IIconRegister ir) {
super.registerIcons(ir);
this.cosmicMask = ir.registerIcon("eternalsingularity:eternal_singularity_mask");
this.foregroundIcon = ir.registerIcon("eternalsingularity:eternal_singularity");
}
@Override
public IIcon getIcon(ItemStack stack, int pass)
{
return pass == 1 ? foregroundIcon : super.getIcon(stack, pass);
}
@Override
public IIcon getIcon(ItemStack stack, int pass) {
return pass == 1 ? foregroundIcon : super.getIcon(stack, pass);
}
@SideOnly(Side.CLIENT)
@Override
public boolean requiresMultipleRenderPasses()
{
return true;
}
@SideOnly(Side.CLIENT)
@Override
public boolean requiresMultipleRenderPasses() {
return true;
}
@Override
public Entity createEntity(World world, Entity location, ItemStack itemstack)
{
return new EntityImmortalItem(world, location, itemstack);
}
@Override
public Entity createEntity(World world, Entity location, ItemStack itemstack) {
return new EntityImmortalItem(world, location, itemstack);
}
@SideOnly(Side.CLIENT)
public boolean drawHalo(ItemStack paramItemStack)
{
return true;
}
@SideOnly(Side.CLIENT)
public boolean drawHalo(ItemStack paramItemStack) {
return true;
}
@SideOnly(Side.CLIENT)
public IIcon getHaloTexture(ItemStack paramItemStack)
{
return ((ItemResource) LudicrousItems.resource).halo[0];
}
@SideOnly(Side.CLIENT)
public IIcon getHaloTexture(ItemStack paramItemStack) {
return ((ItemResource) LudicrousItems.resource).halo[0];
}
@SideOnly(Side.CLIENT)
public int getHaloSize(ItemStack paramItemStack)
{
return 4;
}
@SideOnly(Side.CLIENT)
public int getHaloSize(ItemStack paramItemStack) {
return 4;
}
@SideOnly(Side.CLIENT)
public boolean drawPulseEffect(ItemStack paramItemStack)
{
return false;
}
@SideOnly(Side.CLIENT)
public boolean drawPulseEffect(ItemStack paramItemStack) {
return false;
}
@SideOnly(Side.CLIENT)
public int getHaloColour(ItemStack paramItemStack)
{
return -16777216;
}
}
@SideOnly(Side.CLIENT)
public int getHaloColour(ItemStack paramItemStack) {
return -16777216;
}
}
@@ -5,22 +5,19 @@ import singulariteam.eternalsingularity.item.EternalSingularityItem;
import singulariteam.eternalsingularity.render.EternalItemRenderer;
import singulariteam.eternalsingularity.render.ShaderHelper;
public final class ClientProxy extends CommonProxy
{
EternalItemRenderer fancies = new EternalItemRenderer();
public final class ClientProxy extends CommonProxy {
EternalItemRenderer fancies = new EternalItemRenderer();
@Override
public void init()
{
MinecraftForgeClient.registerItemRenderer(EternalSingularityItem.instance, fancies);
ShaderHelper.initShaders();
}
@Override
public void init() {
MinecraftForgeClient.registerItemRenderer(EternalSingularityItem.instance, fancies);
ShaderHelper.initShaders();
}
@Override
public void postInit()
{
super.postInit();
if (compoundSingularityItem != null)
MinecraftForgeClient.registerItemRenderer(compoundSingularityItem, fancies);
}
@Override
public void postInit() {
super.postInit();
if (compoundSingularityItem != null)
MinecraftForgeClient.registerItemRenderer(compoundSingularityItem, fancies);
}
}
@@ -1,9 +1,14 @@
package singulariteam.eternalsingularity.proxy;
import static fox.spiteful.avaritia.Config.craftingOnly;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.registry.GameRegistry;
import fox.spiteful.avaritia.crafting.ExtremeCraftingManager;
import fox.spiteful.avaritia.crafting.Grinder;
import java.io.File;
import java.util.*;
import javax.annotation.Nonnull;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
@@ -14,99 +19,101 @@ import singulariteam.eternalsingularity.EternalSingularityMod;
import singulariteam.eternalsingularity.item.CompoundSingularityItem;
import singulariteam.eternalsingularity.item.EternalSingularityItem;
import javax.annotation.Nonnull;
import java.io.File;
import java.util.*;
public class CommonProxy {
private static ShapelessOreRecipe eternalSingularityRecipe = null;
private static final Set<Class> classSet = new HashSet<>();
protected CompoundSingularityItem compoundSingularityItem = null;
private File configFile;
import static fox.spiteful.avaritia.Config.craftingOnly;
public CommonProxy() {}
public class CommonProxy
{
private static ShapelessOreRecipe eternalSingularityRecipe = null;
private static final Set<Class> classSet = new HashSet<>();
protected CompoundSingularityItem compoundSingularityItem = null;
private File configFile;
public final void preInit(final File file) {
final Configuration config = new Configuration(configFile = file);
final String[] classNameList = config.getStringList(
"classNameList",
Configuration.CATEGORY_GENERAL,
new String[] {
"com.rcx.aobdsingularities.item.AOBDItemSingularity",
"fox.spiteful.avaritia.items.ItemSingularity",
"wanion.thermsingul.ThermalSingularityItem",
"wealthyturtle.uiesingularities.UniversalSingularityItem"
},
"here is the absolute class name of the Item Classes that must be removed from Infinity Catalyst recipe and inserted into Eternal Singularity.");
if (config.hasChanged()) config.save();
for (final String className : classNameList) {
try {
classSet.add(Class.forName(className));
} catch (ClassNotFoundException e) {
EternalSingularityMod.logger.warn("Couldn't find " + className);
}
}
GameRegistry.registerItem(EternalSingularityItem.instance, "eternal_singularity");
if (Loader.isModLoaded("MineTweaker3")) EternalRecipeTweaker.init();
}
public CommonProxy() { }
public void init() {}
public final void preInit(final File file)
{
final Configuration config = new Configuration(configFile = file);
final String[] classNameList = config.getStringList("classNameList", Configuration.CATEGORY_GENERAL, new String[]{
"com.rcx.aobdsingularities.item.AOBDItemSingularity",
"fox.spiteful.avaritia.items.ItemSingularity",
"wanion.thermsingul.ThermalSingularityItem",
"wealthyturtle.uiesingularities.UniversalSingularityItem"
}, "here is the absolute class name of the Item Classes that must be removed from Infinity Catalyst recipe and inserted into Eternal Singularity.");
if (config.hasChanged())
config.save();
for (final String className : classNameList) {
try {
classSet.add(Class.forName(className));
} catch (ClassNotFoundException e) {
EternalSingularityMod.logger.warn("Couldn't find " + className);
}
}
GameRegistry.registerItem(EternalSingularityItem.instance, "eternal_singularity");
if (Loader.isModLoaded("MineTweaker3"))
EternalRecipeTweaker.init();
}
@Nonnull
public static ShapelessOreRecipe getEternalSingularityRecipe() {
return eternalSingularityRecipe;
}
public void init() {}
@Nonnull
public static ShapelessOreRecipe getEternalSingularityRecipe()
{
return eternalSingularityRecipe;
}
@SuppressWarnings("unchecked")
public void postInit()
{
if (classSet.isEmpty() || craftingOnly)
return;
final List<ItemStack> singularities = new ArrayList<>();
for (final Iterator<Object> catalystRecipeIterator = Grinder.catalyst.getInput().iterator(); catalystRecipeIterator.hasNext(); ) {
final Object input = catalystRecipeIterator.next();
if (!(input instanceof ItemStack))
continue;
final Item item = ((ItemStack) input).getItem();
if (item != null && classSet.contains(item.getClass())) {
catalystRecipeIterator.remove();
singularities.add(((ItemStack) input).copy());
}
}
final Configuration config = new Configuration(configFile);
final int singularityCount = singularities.size();
final boolean aboveTheLimit = singularityCount > 81;
final boolean useCompoundSingularities = config.getBoolean("useCompoundSingularities", Configuration.CATEGORY_GENERAL, aboveTheLimit, "When useCompoundSingularities is Enabled, Basic Singularities will Need to be Crafted into Compound Singularities First.\n[If there are > 81 Basic Singularities, this Config Option will be Set to True Automatically]") || aboveTheLimit;
final boolean easyMode = config.getBoolean("easyMode", Configuration.CATEGORY_GENERAL, false, "If this Config Option is Enabled, for Every 9 Singularities Used in the Eternal Singularity Recipe, You will Receive an Additional Eternal Singularity for the Recipe Output.");
if (config.hasChanged())
config.save();
final int compoundMax = (int) Math.ceil((float) singularityCount / 9);
(eternalSingularityRecipe = new ShapelessOreRecipe(new ItemStack(EternalSingularityItem.instance, easyMode ? MathHelper.clamp_int(compoundMax, 1, 64) : 1))).getInput().addAll(singularities);
if (useCompoundSingularities) {
GameRegistry.registerItem(compoundSingularityItem = new CompoundSingularityItem(compoundMax), "combined_singularity");
final List<Object> eternalSingularityRecipeInputs = eternalSingularityRecipe.getInput();
for (int i = 0; i < compoundMax; i++) {
final ShapelessOreRecipe compoundRecipe = new ShapelessOreRecipe(new ItemStack(compoundSingularityItem, 1, MathHelper.clamp_int(i, 0, 64)));
for (int s = 0; s < 9; s++) {
final int pos = 9 * i + s;
if (pos > singularityCount - 1)
break;
final Object input = eternalSingularityRecipeInputs.get(pos);
if (!(input instanceof ItemStack))
continue;
compoundRecipe.getInput().add(((ItemStack) input).copy());
}
if (compoundRecipe.getInput().size() > 0)
GameRegistry.addRecipe(compoundRecipe);
}
eternalSingularityRecipeInputs.clear();
for (int i = 0; i < compoundMax; i++)
eternalSingularityRecipeInputs.add(new ItemStack(compoundSingularityItem, 1, i));
}
ExtremeCraftingManager.getInstance().getRecipeList().add(eternalSingularityRecipe);
Grinder.catalyst.getInput().add(new ItemStack(EternalSingularityItem.instance));
}
}
@SuppressWarnings("unchecked")
public void postInit() {
if (classSet.isEmpty() || craftingOnly) return;
final List<ItemStack> singularities = new ArrayList<>();
for (final Iterator<Object> catalystRecipeIterator =
Grinder.catalyst.getInput().iterator();
catalystRecipeIterator.hasNext(); ) {
final Object input = catalystRecipeIterator.next();
if (!(input instanceof ItemStack)) continue;
final Item item = ((ItemStack) input).getItem();
if (item != null && classSet.contains(item.getClass())) {
catalystRecipeIterator.remove();
singularities.add(((ItemStack) input).copy());
}
}
final Configuration config = new Configuration(configFile);
final int singularityCount = singularities.size();
final boolean aboveTheLimit = singularityCount > 81;
final boolean useCompoundSingularities = config.getBoolean(
"useCompoundSingularities",
Configuration.CATEGORY_GENERAL,
aboveTheLimit,
"When useCompoundSingularities is Enabled, Basic Singularities will Need to be Crafted into Compound Singularities First.\n[If there are > 81 Basic Singularities, this Config Option will be Set to True Automatically]")
|| aboveTheLimit;
final boolean easyMode = config.getBoolean(
"easyMode",
Configuration.CATEGORY_GENERAL,
false,
"If this Config Option is Enabled, for Every 9 Singularities Used in the Eternal Singularity Recipe, You will Receive an Additional Eternal Singularity for the Recipe Output.");
if (config.hasChanged()) config.save();
final int compoundMax = (int) Math.ceil((float) singularityCount / 9);
(eternalSingularityRecipe = new ShapelessOreRecipe(new ItemStack(
EternalSingularityItem.instance, easyMode ? MathHelper.clamp_int(compoundMax, 1, 64) : 1)))
.getInput()
.addAll(singularities);
if (useCompoundSingularities) {
GameRegistry.registerItem(
compoundSingularityItem = new CompoundSingularityItem(compoundMax), "combined_singularity");
final List<Object> eternalSingularityRecipeInputs = eternalSingularityRecipe.getInput();
for (int i = 0; i < compoundMax; i++) {
final ShapelessOreRecipe compoundRecipe = new ShapelessOreRecipe(
new ItemStack(compoundSingularityItem, 1, MathHelper.clamp_int(i, 0, 64)));
for (int s = 0; s < 9; s++) {
final int pos = 9 * i + s;
if (pos > singularityCount - 1) break;
final Object input = eternalSingularityRecipeInputs.get(pos);
if (!(input instanceof ItemStack)) continue;
compoundRecipe.getInput().add(((ItemStack) input).copy());
}
if (compoundRecipe.getInput().size() > 0) GameRegistry.addRecipe(compoundRecipe);
}
eternalSingularityRecipeInputs.clear();
for (int i = 0; i < compoundMax; i++)
eternalSingularityRecipeInputs.add(new ItemStack(compoundSingularityItem, 1, i));
}
ExtremeCraftingManager.getInstance().getRecipeList().add(eternalSingularityRecipe);
Grinder.catalyst.getInput().add(new ItemStack(EternalSingularityItem.instance));
}
}
@@ -1,116 +1,112 @@
package singulariteam.eternalsingularity.render;
import cpw.mods.fml.relauncher.ReflectionHelper;
import fox.spiteful.avaritia.render.LudicrousRenderEvents;
import java.lang.reflect.Field;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.EntityRenderer;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.world.World;
import org.apache.logging.log4j.Level;
import org.lwjgl.opengl.ARBShaderObjects;
import cpw.mods.fml.relauncher.ReflectionHelper;
import fox.spiteful.avaritia.render.LudicrousRenderEvents;
public class CosmicRenderStuffs {
public static final ShaderCallback shaderCallback;
public static float[] lightlevel = new float[3];
public static String[] lightmapobf = new String[] {"lightmapColors", "field_78504_Q", "U"};
public static boolean inventoryRender = false;
public static float cosmicOpacity = 1.0f;
static {
shaderCallback = new ShaderCallback() {
@Override
public void call(int shader) {
Minecraft mc = Minecraft.getMinecraft();
public static final ShaderCallback shaderCallback;
float yaw = 0;
float pitch = 0;
float scale = 1.0f;
if (!inventoryRender) {
yaw = (float)((mc.thePlayer.rotationYaw * 2 * Math.PI) / 360.0);
pitch = - (float)((mc.thePlayer.rotationPitch * 2 * Math.PI) / 360.0);
} else {
scale = 25.0f;
}
int x = ARBShaderObjects.glGetUniformLocationARB(shader, "yaw");
ARBShaderObjects.glUniform1fARB(x, yaw);
int z = ARBShaderObjects.glGetUniformLocationARB(shader, "pitch");
ARBShaderObjects.glUniform1fARB(z, pitch);
int l = ARBShaderObjects.glGetUniformLocationARB(shader, "lightlevel");
ARBShaderObjects.glUniform3fARB(l, lightlevel[0], lightlevel[1], lightlevel[2]);
int lightmix = ARBShaderObjects.glGetUniformLocationARB(shader, "lightmix");
ARBShaderObjects.glUniform1fARB(lightmix, 0.2f);
int uvs = ARBShaderObjects.glGetUniformLocationARB(shader, "cosmicuvs");
ARBShaderObjects.glUniformMatrix2ARB(uvs, false, LudicrousRenderEvents.cosmicUVs);
int s = ARBShaderObjects.glGetUniformLocationARB(shader, "externalScale");
ARBShaderObjects.glUniform1fARB(s, scale);
int o = ARBShaderObjects.glGetUniformLocationARB(shader, "opacity");
ARBShaderObjects.glUniform1fARB(o, cosmicOpacity);
}
};
}
public static void useShader() {
ShaderHelper.useShader(ShaderHelper.cosmicShader, shaderCallback);
}
public static void releaseShader() {
ShaderHelper.releaseShader();
}
private static Field mapfield = ReflectionHelper.findField(EntityRenderer.class, lightmapobf);
public static void setLightFromLocation(World world, int x, int y, int z) {
if(world == null){
public static float[] lightlevel = new float[3];
public static String[] lightmapobf = new String[] {"lightmapColors", "field_78504_Q", "U"};
public static boolean inventoryRender = false;
public static float cosmicOpacity = 1.0f;
static {
shaderCallback = new ShaderCallback() {
@Override
public void call(int shader) {
Minecraft mc = Minecraft.getMinecraft();
float yaw = 0;
float pitch = 0;
float scale = 1.0f;
if (!inventoryRender) {
yaw = (float) ((mc.thePlayer.rotationYaw * 2 * Math.PI) / 360.0);
pitch = -(float) ((mc.thePlayer.rotationPitch * 2 * Math.PI) / 360.0);
} else {
scale = 25.0f;
}
int x = ARBShaderObjects.glGetUniformLocationARB(shader, "yaw");
ARBShaderObjects.glUniform1fARB(x, yaw);
int z = ARBShaderObjects.glGetUniformLocationARB(shader, "pitch");
ARBShaderObjects.glUniform1fARB(z, pitch);
int l = ARBShaderObjects.glGetUniformLocationARB(shader, "lightlevel");
ARBShaderObjects.glUniform3fARB(l, lightlevel[0], lightlevel[1], lightlevel[2]);
int lightmix = ARBShaderObjects.glGetUniformLocationARB(shader, "lightmix");
ARBShaderObjects.glUniform1fARB(lightmix, 0.2f);
int uvs = ARBShaderObjects.glGetUniformLocationARB(shader, "cosmicuvs");
ARBShaderObjects.glUniformMatrix2ARB(uvs, false, LudicrousRenderEvents.cosmicUVs);
int s = ARBShaderObjects.glGetUniformLocationARB(shader, "externalScale");
ARBShaderObjects.glUniform1fARB(s, scale);
int o = ARBShaderObjects.glGetUniformLocationARB(shader, "opacity");
ARBShaderObjects.glUniform1fARB(o, cosmicOpacity);
}
};
}
public static void useShader() {
ShaderHelper.useShader(ShaderHelper.cosmicShader, shaderCallback);
}
public static void releaseShader() {
ShaderHelper.releaseShader();
}
private static Field mapfield = ReflectionHelper.findField(EntityRenderer.class, lightmapobf);
public static void setLightFromLocation(World world, int x, int y, int z) {
if (world == null) {
setLightLevel(1.0f);
return;
}
int coord = world.getLightBrightnessForSkyBlocks(x, y, z, 0);
int[] map = null;
try {
map = (int[]) mapfield.get(Minecraft.getMinecraft().entityRenderer);
} catch (Exception e) {}
if (map == null) {
setLightLevel(1.0f);
return;
}
int mx = (coord % 65536) / 16;
int[] map = null;
try {
map = (int[]) mapfield.get(Minecraft.getMinecraft().entityRenderer);
} catch (Exception e) {
}
if (map == null) {
setLightLevel(1.0f);
return;
}
int mx = (coord % 65536) / 16;
int my = (coord / 65536) / 16;
int lightcolour = map[my*16+mx];
setLightLevel(
1.0F,
1.0F,
1.0F
);
}
public static void setLightLevel(float level) {
setLightLevel(level, level, level);
}
public static void setLightLevel(float r, float g, float b) {
lightlevel[0] = Math.max(0.0f, Math.min(1.0f, r));
lightlevel[1] = Math.max(0.0f, Math.min(1.0f, g));
lightlevel[2] = Math.max(0.0f, Math.min(1.0f, b));
}
public static void bindItemTexture() {
Minecraft mc = Minecraft.getMinecraft();
mc.renderEngine.bindTexture(TextureMap.locationItemsTexture);
}
}
int lightcolour = map[my * 16 + mx];
setLightLevel(1.0F, 1.0F, 1.0F);
}
public static void setLightLevel(float level) {
setLightLevel(level, level, level);
}
public static void setLightLevel(float r, float g, float b) {
lightlevel[0] = Math.max(0.0f, Math.min(1.0f, r));
lightlevel[1] = Math.max(0.0f, Math.min(1.0f, g));
lightlevel[2] = Math.max(0.0f, Math.min(1.0f, b));
}
public static void bindItemTexture() {
Minecraft mc = Minecraft.getMinecraft();
mc.renderEngine.bindTexture(TextureMap.locationItemsTexture);
}
}
@@ -2,6 +2,7 @@ package singulariteam.eternalsingularity.render;
import fox.spiteful.avaritia.render.ICosmicRenderItem;
import fox.spiteful.avaritia.render.IHaloRenderItem;
import java.util.Random;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.client.renderer.RenderHelper;
@@ -17,286 +18,304 @@ import net.minecraftforge.client.IItemRenderer;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import java.util.Random;
public class EternalItemRenderer implements IItemRenderer {
public class EternalItemRenderer implements IItemRenderer {
public Random rand = new Random();
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
//return type != ItemRenderType.INVENTORY;
return true;
}
public Random rand = new Random();
@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
return helper == ItemRendererHelper.ENTITY_ROTATION || helper == ItemRendererHelper.ENTITY_BOBBING;
}
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
// return type != ItemRenderType.INVENTORY;
return true;
}
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
boolean renderHalo = false;
boolean renderPulse = false;
int spread = 0;
IIcon halo = null;
int haloColour = 0;
net.minecraft.item.Item itype = item.getItem();
if (itype instanceof IHaloRenderItem) {
IHaloRenderItem ihri = (IHaloRenderItem)itype;
spread = ihri.getHaloSize(item);
halo = ihri.getHaloTexture(item);
haloColour = ihri.getHaloColour(item);
renderHalo = ihri.drawHalo(item);
renderPulse = ihri.drawPulseEffect(item);
}
RenderItem r = RenderItem.getInstance();
Minecraft mc = Minecraft.getMinecraft();
Tessellator t = Tessellator.instance;
this.processLightLevel(type, item, data);
//ShaderHelper.useShader(ShaderHelper.testShader, this.shaderCallback);
switch(type) {
case ENTITY : {
GL11.glPushMatrix();
GL11.glTranslatef(-0.5F, 0F, 0F);
if(item.isOnItemFrame())
GL11.glTranslatef(0F, -0.3F, 0.01F);
render(item, null);
GL11.glPopMatrix();
break;
}
case EQUIPPED : {
render(item, data[1] instanceof EntityPlayer ? (EntityPlayer) data[1] : null);
break;
}
case EQUIPPED_FIRST_PERSON : {
render(item, data[1] instanceof EntityPlayer ? (EntityPlayer) data[1] : null);
break;
}
case INVENTORY: {
GL11.glPushMatrix();
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
RenderHelper.enableGUIStandardItemLighting();
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glDisable(GL11.GL_DEPTH_TEST);
if (renderHalo) {
float ca = (float)(haloColour >> 24 & 255) / 255.0F;
float cr = (float)(haloColour >> 16 & 255) / 255.0F;
float cg = (float)(haloColour >> 8 & 255) / 255.0F;
float cb = (float)(haloColour & 255) / 255.0F;
GL11.glColor4f(cr, cg, cb, ca);
t.startDrawingQuads();
t.addVertexWithUV(0-spread, 0-spread, 0, halo.getMinU(), halo.getMinV());
t.addVertexWithUV(0-spread, 16+spread, 0, halo.getMinU(), halo.getMaxV());
t.addVertexWithUV(16+spread, 16+spread, 0, halo.getMaxU(), halo.getMaxV());
t.addVertexWithUV(16+spread, 0-spread, 0, halo.getMaxU(), halo.getMinV());
t.draw();
}
if (renderPulse) {
GL11.glPushMatrix();
double xs = (rand.nextGaussian() * 0.15) + 0.95;
double ox = (1-xs)/2.0;
GL11.glEnable(GL11.GL_BLEND);
GL11.glTranslated(ox*16.0, ox*16.0, 1.0);
GL11.glScaled(xs, xs, 1.0);
IIcon icon = item.getItem().getIcon(item, 0);
t.startDrawingQuads();
t.setColorRGBA_F(1.0f, 1.0f, 1.0f, 0.6f);
t.addVertexWithUV(0-ox, 0-ox, 0, icon.getMinU(), icon.getMinV());
t.addVertexWithUV(0-ox, 16+ox, 0, icon.getMinU(), icon.getMaxV());
t.addVertexWithUV(16+ox, 16+ox, 0, icon.getMaxU(), icon.getMaxV());
t.addVertexWithUV(16+ox, 0-ox, 0, icon.getMaxU(), icon.getMinV());
t.draw();
GL11.glPopMatrix();
}
r.renderItemIntoGUI(mc.fontRenderer, mc.getTextureManager(), item, 0, 0, true);
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glEnable(GL11.GL_DEPTH_TEST);
r.renderWithColor = true;
GL11.glDisable(GL11.GL_BLEND);
GL11.glPopMatrix();
//middle?
GL11.glPushMatrix();
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
RenderHelper.enableGUIStandardItemLighting();
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glDisable(GL11.GL_DEPTH_TEST);
r.renderItemIntoGUI(mc.fontRenderer, mc.getTextureManager(), item, 0, 0, true);
if (item.getItem() instanceof ICosmicRenderItem) {
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
RenderHelper.enableGUIStandardItemLighting();
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glDisable(GL11.GL_DEPTH_TEST);
ICosmicRenderItem icri = (ICosmicRenderItem)(item.getItem());
CosmicRenderStuffs.cosmicOpacity = icri.getMaskMultiplier(item, null);
CosmicRenderStuffs.inventoryRender = true;
CosmicRenderStuffs.useShader();
IIcon cosmicicon = icri.getMaskTexture(item, null);
GL11.glColor4d(1, 1, 1, 1);
float minu = cosmicicon.getMinU();
float maxu = cosmicicon.getMaxU();
float minv = cosmicicon.getMinV();
float maxv = cosmicicon.getMaxV();
t.startDrawingQuads();
t.addVertexWithUV(0, 0, 0, minu, minv);
t.addVertexWithUV(0, 16, 0, minu, maxv);
t.addVertexWithUV(16, 16, 0, maxu, maxv);
t.addVertexWithUV(16, 0, 0, maxu, minv);
t.draw();
CosmicRenderStuffs.releaseShader();
CosmicRenderStuffs.inventoryRender = false;
}
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glEnable(GL11.GL_DEPTH_TEST);
r.renderWithColor = true;
GL11.glDisable(GL11.GL_BLEND);
GL11.glPopMatrix();
break;
}
default : break;
}
//ShaderHelper.releaseShader();
//Lumberjack.log(Level.INFO, light+"");
}
public void render(ItemStack item, EntityPlayer player) {
int passes = 1;
if (item.getItem().requiresMultipleRenderPasses())
{
passes = item.getItem().getRenderPasses(item.getItemDamage());
@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
return helper == ItemRendererHelper.ENTITY_ROTATION || helper == ItemRendererHelper.ENTITY_BOBBING;
}
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
boolean renderHalo = false;
boolean renderPulse = false;
int spread = 0;
IIcon halo = null;
int haloColour = 0;
net.minecraft.item.Item itype = item.getItem();
if (itype instanceof IHaloRenderItem) {
IHaloRenderItem ihri = (IHaloRenderItem) itype;
spread = ihri.getHaloSize(item);
halo = ihri.getHaloTexture(item);
haloColour = ihri.getHaloColour(item);
renderHalo = ihri.drawHalo(item);
renderPulse = ihri.drawPulseEffect(item);
}
GL11.glPushMatrix();
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glColor4f(1F, 1F, 1F, 1F);
//ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), scale);
float r,g,b;
IIcon icon;
float f,f1,f2,f3;
float scale = 1F / 16F;
RenderItem r = RenderItem.getInstance();
Minecraft mc = Minecraft.getMinecraft();
Tessellator t = Tessellator.instance;
this.processLightLevel(type, item, data);
// ShaderHelper.useShader(ShaderHelper.testShader, this.shaderCallback);
switch (type) {
case ENTITY: {
GL11.glPushMatrix();
GL11.glTranslatef(-0.5F, 0F, 0F);
if (item.isOnItemFrame()) GL11.glTranslatef(0F, -0.3F, 0.01F);
render(item, null);
GL11.glPopMatrix();
//Lumberjack.log(Level.INFO, "passes: "+passes);
for (int i = 0; i < passes; i++)
{
icon = this.getStackIcon(item, i, player);
//Lumberjack.log(Level.INFO, "icon "+i+": "+icon);
break;
}
case EQUIPPED: {
render(item, data[1] instanceof EntityPlayer ? (EntityPlayer) data[1] : null);
break;
}
case EQUIPPED_FIRST_PERSON: {
render(item, data[1] instanceof EntityPlayer ? (EntityPlayer) data[1] : null);
break;
}
case INVENTORY: {
GL11.glPushMatrix();
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
RenderHelper.enableGUIStandardItemLighting();
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glDisable(GL11.GL_DEPTH_TEST);
if (renderHalo) {
float ca = (float) (haloColour >> 24 & 255) / 255.0F;
float cr = (float) (haloColour >> 16 & 255) / 255.0F;
float cg = (float) (haloColour >> 8 & 255) / 255.0F;
float cb = (float) (haloColour & 255) / 255.0F;
GL11.glColor4f(cr, cg, cb, ca);
t.startDrawingQuads();
t.addVertexWithUV(0 - spread, 0 - spread, 0, halo.getMinU(), halo.getMinV());
t.addVertexWithUV(0 - spread, 16 + spread, 0, halo.getMinU(), halo.getMaxV());
t.addVertexWithUV(16 + spread, 16 + spread, 0, halo.getMaxU(), halo.getMaxV());
t.addVertexWithUV(16 + spread, 0 - spread, 0, halo.getMaxU(), halo.getMinV());
t.draw();
}
if (renderPulse) {
GL11.glPushMatrix();
double xs = (rand.nextGaussian() * 0.15) + 0.95;
double ox = (1 - xs) / 2.0;
GL11.glEnable(GL11.GL_BLEND);
GL11.glTranslated(ox * 16.0, ox * 16.0, 1.0);
GL11.glScaled(xs, xs, 1.0);
IIcon icon = item.getItem().getIcon(item, 0);
t.startDrawingQuads();
t.setColorRGBA_F(1.0f, 1.0f, 1.0f, 0.6f);
t.addVertexWithUV(0 - ox, 0 - ox, 0, icon.getMinU(), icon.getMinV());
t.addVertexWithUV(0 - ox, 16 + ox, 0, icon.getMinU(), icon.getMaxV());
t.addVertexWithUV(16 + ox, 16 + ox, 0, icon.getMaxU(), icon.getMaxV());
t.addVertexWithUV(16 + ox, 0 - ox, 0, icon.getMaxU(), icon.getMinV());
t.draw();
GL11.glPopMatrix();
}
r.renderItemIntoGUI(mc.fontRenderer, mc.getTextureManager(), item, 0, 0, true);
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glEnable(GL11.GL_DEPTH_TEST);
r.renderWithColor = true;
GL11.glDisable(GL11.GL_BLEND);
GL11.glPopMatrix();
// middle?
GL11.glPushMatrix();
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
RenderHelper.enableGUIStandardItemLighting();
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glDisable(GL11.GL_DEPTH_TEST);
r.renderItemIntoGUI(mc.fontRenderer, mc.getTextureManager(), item, 0, 0, true);
if (item.getItem() instanceof ICosmicRenderItem) {
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
RenderHelper.enableGUIStandardItemLighting();
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glDisable(GL11.GL_DEPTH_TEST);
ICosmicRenderItem icri = (ICosmicRenderItem) (item.getItem());
CosmicRenderStuffs.cosmicOpacity = icri.getMaskMultiplier(item, null);
CosmicRenderStuffs.inventoryRender = true;
CosmicRenderStuffs.useShader();
IIcon cosmicicon = icri.getMaskTexture(item, null);
GL11.glColor4d(1, 1, 1, 1);
float minu = cosmicicon.getMinU();
float maxu = cosmicicon.getMaxU();
float minv = cosmicicon.getMinV();
float maxv = cosmicicon.getMaxV();
t.startDrawingQuads();
t.addVertexWithUV(0, 0, 0, minu, minv);
t.addVertexWithUV(0, 16, 0, minu, maxv);
t.addVertexWithUV(16, 16, 0, maxu, maxv);
t.addVertexWithUV(16, 0, 0, maxu, minv);
t.draw();
CosmicRenderStuffs.releaseShader();
CosmicRenderStuffs.inventoryRender = false;
}
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glEnable(GL11.GL_DEPTH_TEST);
r.renderWithColor = true;
GL11.glDisable(GL11.GL_BLEND);
GL11.glPopMatrix();
break;
}
default:
break;
}
// ShaderHelper.releaseShader();
// Lumberjack.log(Level.INFO, light+"");
}
public void render(ItemStack item, EntityPlayer player) {
int passes = 1;
if (item.getItem().requiresMultipleRenderPasses()) {
passes = item.getItem().getRenderPasses(item.getItemDamage());
}
GL11.glPushMatrix();
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glColor4f(1F, 1F, 1F, 1F);
// ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(),
// scale);
float r, g, b;
IIcon icon;
float f, f1, f2, f3;
float scale = 1F / 16F;
// Lumberjack.log(Level.INFO, "passes: "+passes);
for (int i = 0; i < passes; i++) {
icon = this.getStackIcon(item, i, player);
// Lumberjack.log(Level.INFO, "icon "+i+": "+icon);
f = icon.getMinU();
f1 = icon.getMaxU();
f2 = icon.getMinV();
f3 = icon.getMaxV();
f = icon.getMinU();
f1 = icon.getMaxU();
f2 = icon.getMinV();
f3 = icon.getMaxV();
int colour = item.getItem().getColorFromItemStack(item, i);
r = (float)(colour & 255) / 255.0F;
g = (float)(colour & 255) / 255.0F;
b = (float)(colour & 255) / 255.0F;
r = (float) (colour & 255) / 255.0F;
g = (float) (colour & 255) / 255.0F;
b = (float) (colour & 255) / 255.0F;
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), scale);
ItemRenderer.renderItemIn2D(
Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), scale);
}
if (item.getItem() instanceof ICosmicRenderItem) {
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glDepthFunc(GL11.GL_EQUAL);
ICosmicRenderItem icri = (ICosmicRenderItem)(item.getItem());
CosmicRenderStuffs.cosmicOpacity = icri.getMaskMultiplier(item, player);
CosmicRenderStuffs.useShader();
IIcon cosmicicon = icri.getMaskTexture(item, player);
float minu = cosmicicon.getMinU();
float maxu = cosmicicon.getMaxU();
float minv = cosmicicon.getMinV();
float maxv = cosmicicon.getMaxV();
ItemRenderer.renderItemIn2D(Tessellator.instance, maxu, minv, minu, maxv, cosmicicon.getIconWidth(), cosmicicon.getIconHeight(), scale);
CosmicRenderStuffs.releaseShader();
GL11.glDepthFunc(GL11.GL_LEQUAL);
GL11.glEnable(GL11.GL_ALPHA_TEST);
}
GL11.glDisable(GL11.GL_BLEND);
GL11.glPopMatrix();
GL11.glColor4f(1F, 1F, 1F, 1F);
}
if (item.getItem() instanceof ICosmicRenderItem) {
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glDepthFunc(GL11.GL_EQUAL);
ICosmicRenderItem icri = (ICosmicRenderItem) (item.getItem());
CosmicRenderStuffs.cosmicOpacity = icri.getMaskMultiplier(item, player);
CosmicRenderStuffs.useShader();
public void processLightLevel(ItemRenderType type, ItemStack item, Object... data) {
switch(type) {
case ENTITY : {
EntityItem ent = (EntityItem)(data[1]);
if (ent != null) {
CosmicRenderStuffs.setLightFromLocation(ent.worldObj, MathHelper.floor_double(ent.posX), MathHelper.floor_double(ent.posY), MathHelper.floor_double(ent.posZ));
}
break;
}
case EQUIPPED : {
EntityLivingBase ent = (EntityLivingBase)(data[1]);
if (ent != null) {
CosmicRenderStuffs.setLightFromLocation(ent.worldObj, MathHelper.floor_double(ent.posX), MathHelper.floor_double(ent.posY), MathHelper.floor_double(ent.posZ));
}
break;
}
case EQUIPPED_FIRST_PERSON : {
EntityLivingBase ent = (EntityLivingBase)(data[1]);
if (ent != null) {
CosmicRenderStuffs.setLightFromLocation(ent.worldObj, MathHelper.floor_double(ent.posX), MathHelper.floor_double(ent.posY), MathHelper.floor_double(ent.posZ));
}
break;
}
case INVENTORY: {
CosmicRenderStuffs.setLightLevel(1.2f);
return;
}
default : {
CosmicRenderStuffs.setLightLevel(1.0f);
return;
}
}
}
public IIcon getStackIcon(ItemStack stack, int pass, EntityPlayer player) {
return stack.getItem().getIcon(stack, pass);
}
IIcon cosmicicon = icri.getMaskTexture(item, player);
float minu = cosmicicon.getMinU();
float maxu = cosmicicon.getMaxU();
float minv = cosmicicon.getMinV();
float maxv = cosmicicon.getMaxV();
ItemRenderer.renderItemIn2D(
Tessellator.instance,
maxu,
minv,
minu,
maxv,
cosmicicon.getIconWidth(),
cosmicicon.getIconHeight(),
scale);
CosmicRenderStuffs.releaseShader();
GL11.glDepthFunc(GL11.GL_LEQUAL);
GL11.glEnable(GL11.GL_ALPHA_TEST);
}
GL11.glDisable(GL11.GL_BLEND);
GL11.glPopMatrix();
GL11.glColor4f(1F, 1F, 1F, 1F);
}
public void processLightLevel(ItemRenderType type, ItemStack item, Object... data) {
switch (type) {
case ENTITY: {
EntityItem ent = (EntityItem) (data[1]);
if (ent != null) {
CosmicRenderStuffs.setLightFromLocation(
ent.worldObj,
MathHelper.floor_double(ent.posX),
MathHelper.floor_double(ent.posY),
MathHelper.floor_double(ent.posZ));
}
break;
}
case EQUIPPED: {
EntityLivingBase ent = (EntityLivingBase) (data[1]);
if (ent != null) {
CosmicRenderStuffs.setLightFromLocation(
ent.worldObj,
MathHelper.floor_double(ent.posX),
MathHelper.floor_double(ent.posY),
MathHelper.floor_double(ent.posZ));
}
break;
}
case EQUIPPED_FIRST_PERSON: {
EntityLivingBase ent = (EntityLivingBase) (data[1]);
if (ent != null) {
CosmicRenderStuffs.setLightFromLocation(
ent.worldObj,
MathHelper.floor_double(ent.posX),
MathHelper.floor_double(ent.posY),
MathHelper.floor_double(ent.posZ));
}
break;
}
case INVENTORY: {
CosmicRenderStuffs.setLightLevel(1.2f);
return;
}
default: {
CosmicRenderStuffs.setLightLevel(1.0f);
return;
}
}
}
public IIcon getStackIcon(ItemStack stack, int pass, EntityPlayer player) {
return stack.getItem().getIcon(stack, pass);
}
}
@@ -1,6 +1,5 @@
package singulariteam.eternalsingularity.render;
public abstract class ShaderCallback
{
public abstract void call(int paramInt);
public abstract class ShaderCallback {
public abstract void call(int paramInt);
}
@@ -1,169 +1,156 @@
package singulariteam.eternalsingularity.render;
//import fox.spiteful.avaritia.Lumberjack;
// import fox.spiteful.avaritia.Lumberjack;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.OpenGlHelper;
import org.apache.logging.log4j.Level;
import org.lwjgl.opengl.ARBFragmentShader;
import org.lwjgl.opengl.ARBShaderObjects;
import org.lwjgl.opengl.ARBVertexShader;
import org.lwjgl.opengl.GL11;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
public final class ShaderHelper {
private static final int VERT = ARBVertexShader.GL_VERTEX_SHADER_ARB;
private static final int FRAG = ARBFragmentShader.GL_FRAGMENT_SHADER_ARB;
private static final String PREFIX = "/assets/eternalsingularity/shader/";
private static final int VERT = ARBVertexShader.GL_VERTEX_SHADER_ARB;
private static final int FRAG = ARBFragmentShader.GL_FRAGMENT_SHADER_ARB;
private static final String PREFIX = "/assets/eternalsingularity/shader/";
public static int cosmicShader = 0;
public static int cosmicShader = 0;
public static void initShaders() {
if(!useShaders())
return;
cosmicShader = createProgram("cosmic.vert", "cosmic.frag");
}
public static void initShaders() {
if (!useShaders()) return;
public static void useShader(int shader, ShaderCallback callback) {
if(!useShaders())
return;
cosmicShader = createProgram("cosmic.vert", "cosmic.frag");
}
ARBShaderObjects.glUseProgramObjectARB(shader);
public static void useShader(int shader, ShaderCallback callback) {
if (!useShaders()) return;
if(shader != 0) {
int time = ARBShaderObjects.glGetUniformLocationARB(shader, "time");
Minecraft mc = Minecraft.getMinecraft();
if (mc.thePlayer != null && mc.thePlayer.worldObj != null) {
ARBShaderObjects.glUniform1iARB(time, (int)(mc.thePlayer.worldObj.getWorldTime() % Integer.MAX_VALUE));
}
ARBShaderObjects.glUseProgramObjectARB(shader);
if(callback != null)
callback.call(shader);
}
}
if (shader != 0) {
int time = ARBShaderObjects.glGetUniformLocationARB(shader, "time");
Minecraft mc = Minecraft.getMinecraft();
if (mc.thePlayer != null && mc.thePlayer.worldObj != null) {
ARBShaderObjects.glUniform1iARB(time, (int) (mc.thePlayer.worldObj.getWorldTime() % Integer.MAX_VALUE));
}
public static void useShader(int shader) {
useShader(shader, null);
}
if (callback != null) callback.call(shader);
}
}
public static void releaseShader() {
useShader(0);
}
public static void useShader(int shader) {
useShader(shader, null);
}
public static boolean useShaders() {
return OpenGlHelper.shadersSupported;
}
public static void releaseShader() {
useShader(0);
}
// Most of the code taken from the LWJGL wiki
// http://lwjgl.org/wiki/index.php?title=GLSL_Shaders_with_LWJGL
public static boolean useShaders() {
return OpenGlHelper.shadersSupported;
}
private static int createProgram(String vert, String frag) {
int vertId = 0, fragId = 0, program = 0;
if(vert != null)
vertId = createShader(PREFIX + vert, VERT);
if(frag != null)
fragId = createShader(PREFIX + frag, FRAG);
// Most of the code taken from the LWJGL wiki
// http://lwjgl.org/wiki/index.php?title=GLSL_Shaders_with_LWJGL
program = ARBShaderObjects.glCreateProgramObjectARB();
if(program == 0)
return 0;
private static int createProgram(String vert, String frag) {
int vertId = 0, fragId = 0, program = 0;
if (vert != null) vertId = createShader(PREFIX + vert, VERT);
if (frag != null) fragId = createShader(PREFIX + frag, FRAG);
if(vert != null)
ARBShaderObjects.glAttachObjectARB(program, vertId);
if(frag != null)
ARBShaderObjects.glAttachObjectARB(program, fragId);
program = ARBShaderObjects.glCreateProgramObjectARB();
if (program == 0) return 0;
ARBShaderObjects.glLinkProgramARB(program);
if(ARBShaderObjects.glGetObjectParameteriARB(program, ARBShaderObjects.GL_OBJECT_LINK_STATUS_ARB) == GL11.GL_FALSE) {
//Lumberjack.log(Level.ERROR, getLogInfo(program));
return 0;
}
if (vert != null) ARBShaderObjects.glAttachObjectARB(program, vertId);
if (frag != null) ARBShaderObjects.glAttachObjectARB(program, fragId);
ARBShaderObjects.glValidateProgramARB(program);
if (ARBShaderObjects.glGetObjectParameteriARB(program, ARBShaderObjects.GL_OBJECT_VALIDATE_STATUS_ARB) == GL11.GL_FALSE) {
//Lumberjack.log(Level.ERROR, getLogInfo(program));
return 0;
}
ARBShaderObjects.glLinkProgramARB(program);
if (ARBShaderObjects.glGetObjectParameteriARB(program, ARBShaderObjects.GL_OBJECT_LINK_STATUS_ARB)
== GL11.GL_FALSE) {
// Lumberjack.log(Level.ERROR, getLogInfo(program));
return 0;
}
return program;
}
ARBShaderObjects.glValidateProgramARB(program);
if (ARBShaderObjects.glGetObjectParameteriARB(program, ARBShaderObjects.GL_OBJECT_VALIDATE_STATUS_ARB)
== GL11.GL_FALSE) {
// Lumberjack.log(Level.ERROR, getLogInfo(program));
return 0;
}
private static int createShader(String filename, int shaderType){
int shader = 0;
try {
shader = ARBShaderObjects.glCreateShaderObjectARB(shaderType);
return program;
}
if(shader == 0)
return 0;
private static int createShader(String filename, int shaderType) {
int shader = 0;
try {
shader = ARBShaderObjects.glCreateShaderObjectARB(shaderType);
ARBShaderObjects.glShaderSourceARB(shader, readFileAsString(filename));
ARBShaderObjects.glCompileShaderARB(shader);
if (shader == 0) return 0;
if (ARBShaderObjects.glGetObjectParameteriARB(shader, ARBShaderObjects.GL_OBJECT_COMPILE_STATUS_ARB) == GL11.GL_FALSE)
throw new RuntimeException("Error creating shader \""+filename+"\": " + getLogInfo(shader));
ARBShaderObjects.glShaderSourceARB(shader, readFileAsString(filename));
ARBShaderObjects.glCompileShaderARB(shader);
return shader;
}
catch(Exception e) {
ARBShaderObjects.glDeleteObjectARB(shader);
e.printStackTrace();
return -1;
}
}
if (ARBShaderObjects.glGetObjectParameteriARB(shader, ARBShaderObjects.GL_OBJECT_COMPILE_STATUS_ARB)
== GL11.GL_FALSE)
throw new RuntimeException("Error creating shader \"" + filename + "\": " + getLogInfo(shader));
private static String getLogInfo(int obj) {
return ARBShaderObjects.glGetInfoLogARB(obj, ARBShaderObjects.glGetObjectParameteriARB(obj, ARBShaderObjects.GL_OBJECT_INFO_LOG_LENGTH_ARB));
}
return shader;
} catch (Exception e) {
ARBShaderObjects.glDeleteObjectARB(shader);
e.printStackTrace();
return -1;
}
}
private static String readFileAsString(String filename) throws Exception {
StringBuilder source = new StringBuilder();
InputStream in = ShaderHelper.class.getResourceAsStream(filename);
Exception exception = null;
BufferedReader reader;
private static String getLogInfo(int obj) {
return ARBShaderObjects.glGetInfoLogARB(
obj, ARBShaderObjects.glGetObjectParameteriARB(obj, ARBShaderObjects.GL_OBJECT_INFO_LOG_LENGTH_ARB));
}
if(in == null)
return "";
private static String readFileAsString(String filename) throws Exception {
StringBuilder source = new StringBuilder();
InputStream in = ShaderHelper.class.getResourceAsStream(filename);
Exception exception = null;
BufferedReader reader;
try {
reader = new BufferedReader(new InputStreamReader(in, "UTF-8"));
if (in == null) return "";
Exception innerExc= null;
try {
String line;
while((line = reader.readLine()) != null)
source.append(line).append('\n');
} catch(Exception exc) {
exception = exc;
} finally {
try {
reader.close();
} catch(Exception exc) {
if(innerExc == null)
innerExc = exc;
else exc.printStackTrace();
}
}
try {
reader = new BufferedReader(new InputStreamReader(in, "UTF-8"));
if(innerExc != null)
throw innerExc;
} catch(Exception exc) {
exception = exc;
} finally {
try {
in.close();
} catch(Exception exc) {
if(exception == null)
exception = exc;
else exc.printStackTrace();
}
Exception innerExc = null;
try {
String line;
while ((line = reader.readLine()) != null) source.append(line).append('\n');
} catch (Exception exc) {
exception = exc;
} finally {
try {
reader.close();
} catch (Exception exc) {
if (innerExc == null) innerExc = exc;
else exc.printStackTrace();
}
}
if(exception != null)
throw exception;
}
if (innerExc != null) throw innerExc;
} catch (Exception exc) {
exception = exc;
} finally {
try {
in.close();
} catch (Exception exc) {
if (exception == null) exception = exc;
else exc.printStackTrace();
}
return source.toString();
}
}
if (exception != null) throw exception;
}
return source.toString();
}
}