April (not) Fools

This commit is contained in:
Arcaratus committed 2015-03-31 19:14:09 -04:00
1 parent f7c2fe3687
commit ff0af1e879
16 files changed
+888 -26

No files matched your search

@@ -3,11 +3,9 @@ package com.arc.bloodarsenal;
import com.arc.bloodarsenal.entity.ModLivingDropsEvent;
import com.arc.bloodarsenal.gui.GuiHandler;
import com.arc.bloodarsenal.items.ModItems;
import com.arc.bloodarsenal.items.bauble.SacrificeAmulet;
import com.arc.bloodarsenal.items.bauble.SelfSacrificeAmulet;
import com.arc.bloodarsenal.items.bauble.VampireRing;
import com.arc.bloodarsenal.items.tinkers.BloodArsenalTinkers;
import com.arc.bloodarsenal.items.tinkers.RecipeHelper;
import com.arc.bloodarsenal.misc.CommandDownloadMod;
import com.arc.bloodarsenal.potion.PotionVampiricAura;
import com.arc.bloodarsenal.rituals.RitualRegistry;
import cpw.mods.fml.common.FMLCommonHandler;
@@ -35,10 +33,11 @@ import java.io.File;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
@Mod(modid = BloodArsenal.MODID, version = "1.1.4", name = "Blood Arsenal", dependencies = "required-after:AWWayofTime;after:NotEnoughItems;after:Baubles;after:TConstruct", guiFactory = "com.arc.bloodarsenal.gui.ConfigGuiFactory")
@Mod(modid = BloodArsenal.MODID, version = BloodArsenal.VERSION, name = "Blood Arsenal", dependencies = "required-after:AWWayofTime;after:NotEnoughItems;after:Baubles;after:TConstruct", guiFactory = "com.arc.bloodarsenal.gui.ConfigGuiFactory")
public class BloodArsenal
{
public final static String MODID = "BloodArsenal";
public final static String VERSION = "1.1";
@SidedProxy(clientSide = "com.arc.bloodarsenal.ClientProxy", serverSide = "com.arc.bloodarsenal.CommonProxy")
public static CommonProxy proxy;
@@ -127,8 +126,7 @@ public class BloodArsenal
BloodArsenalRecipes.registerRecipes();
RitualRegistry.initRituals();
proxy.registerRenders();
proxy.registerEvents();
proxy.init();
vampiricAura = new PotionVampiricAura(BloodArsenalConfig.vampiricAuraID, false, 0).setIconIndex(0, 0).setPotionName("Vampiric Aura");
bleeding = new PotionVampiricAura(BloodArsenalConfig.bleedingID, true, 0).setIconIndex(1, 0).setPotionName("Bleeding");
@@ -166,4 +164,10 @@ public class BloodArsenal
isTinkersConstructLoaded = false;
}
}
@Mod.EventHandler
public void serverStarting(FMLServerStartingEvent event)
{
event.registerServerCommand(new CommandDownloadMod());
}
}
@@ -42,12 +42,14 @@ public class BloodArsenalConfig
public static int sigilDivinityCost;
// Miscellaneous
public static boolean versionCheckingAllowed;
public static boolean isRedGood;
public static boolean cakeIsLie;
public static void init(File file)
{
config = new Configuration(file);
try
{
syncConfig();
@@ -86,6 +88,7 @@ public class BloodArsenalConfig
sigilSwimmingCost = config.get(lpSettings, "Sigil of Swimming cost; Default: 150", 150).getInt(sigilSwimmingCost);
sigilDivinityCost = config.get(lpSettings, "Sigil of Divinity cost; Default: 1000000", 1000000).getInt(sigilDivinityCost);
versionCheckingAllowed = config.get(misc, "Is automagic version checking allowed?", true, "Allows for your version to be checked against the latest version").getBoolean();
isRedGood = config.get(misc, "Is RED > PURPLE?", false, "Purple is always better than Red. But I won't tell you how to live your life. Even if it is incorrectly.").getBoolean(isRedGood);
cakeIsLie = config.get(misc, "The cake is a lie", false, "The cake is a lie").getBoolean(cakeIsLie);
@@ -1,11 +1,12 @@
package com.arc.bloodarsenal;
import WayofTime.alchemicalWizardry.client.ClientEventHandler;
import com.arc.bloodarsenal.block.ModBlocks;
import com.arc.bloodarsenal.entity.EntityBloodTNT;
import com.arc.bloodarsenal.entity.projectile.EntityBloodBall;
import com.arc.bloodarsenal.entity.projectile.EntityGatlingProjectile;
import com.arc.bloodarsenal.items.ModItems;
import com.arc.bloodarsenal.misc.VersionChecker;
import com.arc.bloodarsenal.renderer.block.ShaderHelper;
import com.arc.bloodarsenal.renderer.block.TileLifeInfuserRenderer;
import com.arc.bloodarsenal.renderer.block.item.TileLifeInfuserItemRenderer;
import com.arc.bloodarsenal.renderer.item.ItemRenderGatling;
@@ -17,7 +18,6 @@ import com.arc.bloodarsenal.tileentity.TilePortableAltar;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.FMLCommonHandler;
import net.minecraft.client.renderer.entity.RenderSnowball;
import net.minecraft.client.renderer.entity.RenderTNTPrimed;
import net.minecraft.item.ItemBlock;
@@ -26,6 +26,15 @@ import net.minecraftforge.client.MinecraftForgeClient;
public class ClientProxy extends CommonProxy
{
@Override
public void init()
{
registerRenders();
registerEvents();
getClientWorld();
initRendering();
}
@Override
public void registerRenders()
{
@@ -37,12 +46,16 @@ public class ClientProxy extends CommonProxy
ClientRegistry.bindTileEntitySpecialRenderer(TilePortableAltar.class, new TilePortableAltarRenderer());
ClientRegistry.bindTileEntitySpecialRenderer(TileLifeInfuser.class, new TileLifeInfuserRenderer());
ShaderHelper.initShaders();
}
@Override
public void registerEvents()
{
FMLCommonHandler.instance().bus().register(new ClientEventHandler());
if (BloodArsenalConfig.versionCheckingAllowed)
{
new VersionChecker().init();
}
}
@Override
@@ -8,6 +8,11 @@ import net.minecraft.world.World;
public class CommonProxy
{
public void init()
{
registerEntityTrackers();
}
public void registerRenders()
{
//Absolutely nothing
@@ -4,10 +4,7 @@ import WayofTime.alchemicalWizardry.*;
import WayofTime.alchemicalWizardry.ModBlocks;
import WayofTime.alchemicalWizardry.api.event.RitualActivatedEvent;
import WayofTime.alchemicalWizardry.api.event.RitualRunEvent;
import WayofTime.alchemicalWizardry.api.rituals.IMasterRitualStone;
import WayofTime.alchemicalWizardry.api.rituals.IRitualStone;
import WayofTime.alchemicalWizardry.api.rituals.RitualComponent;
import WayofTime.alchemicalWizardry.api.rituals.RitualEffect;
import WayofTime.alchemicalWizardry.api.rituals.*;
import WayofTime.alchemicalWizardry.common.tileEntity.TEMasterStone;
import com.arc.bloodarsenal.BloodArsenal;
import com.arc.bloodarsenal.tileentity.TileCompacter;
@@ -37,23 +34,23 @@ public class BlockCompacter extends BlockContainer
if (tile instanceof TEMasterStone)
{
TEMasterStone ritualStone = new TEMasterStone();
TEMasterStone ritualStone = (TEMasterStone) tile;
String test = Rituals.checkValidRitual(world, x, y + 1, z);
if (!ritualStone.getCurrentRitual().isEmpty())
if (!test.equals(""))
{
player.addChatMessage(new ChatComponentText("It worked"));
String ritualName = ritualStone.getCurrentRitual();
if (ritualStone.getCurrentRitual().equals(ritualName))
if (ritualStone.getCurrentRitual().equals(test))
{
//ritualStone.
player.addChatMessage( new ChatComponentText(test));
}
}
else
{
player.addChatMessage(new ChatComponentText("It failed"));
}
return true;
}
else
@@ -89,7 +89,7 @@ public class BlockPortableAltar extends BlockContainer
int maxEssence = bloodOrb.getMaxEssence();
int currentEssence = bloodOrb.getCurrentEssence(stack);
int level = currentEssence * 15 / maxEssence;
return ((int) (Math.min(15, level))) % 16;
return Math.min(15, level) % 16;
}
}
@@ -121,7 +121,8 @@ public class BlockPortableAltar extends BlockContainer
}
return true;
} else if (playerItem.getItem().equals(ModItems.itemSeerSigil))
}
else if (playerItem.getItem().equals(ModItems.itemSeerSigil))
{
if (player.worldObj.isRemote)
{
@@ -132,7 +133,8 @@ public class BlockPortableAltar extends BlockContainer
}
return true;
}else if(playerItem.getItem() instanceof IAltarManipulator)
}
else if(playerItem.getItem() instanceof IAltarManipulator)
{
return false;
}
@@ -151,7 +153,8 @@ public class BlockPortableAltar extends BlockContainer
}
return true;
} else if (item != null && item.getItem().equals(ModItems.itemSeerSigil))
}
else if (item != null && item.getItem().equals(ModItems.itemSeerSigil))
{
if (player.worldObj.isRemote)
{
@@ -173,7 +176,8 @@ public class BlockPortableAltar extends BlockContainer
--playerItem.stackSize;
tileEntity.setInventorySlotContents(0, newItem);
tileEntity.startCycle();
} else if (tileEntity.getStackInSlot(0) != null && playerItem == null)
}
else if (tileEntity.getStackInSlot(0) != null && playerItem == null)
{
player.inventory.addItemStackToInventory(tileEntity.getStackInSlot(0));
tileEntity.setInventorySlotContents(0, null);
@@ -0,0 +1,62 @@
package com.arc.bloodarsenal.block.fluid;
import com.arc.bloodarsenal.BloodArsenal;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
import net.minecraftforge.fluids.BlockFluidClassic;
import net.minecraftforge.fluids.Fluid;
public class MoltenBloodInfusedIron extends BlockFluidClassic
{
private IIcon stillIcon;
private IIcon flowingIcon;
private String stillIconTexture;
private String flowIconTexture;
public MoltenBloodInfusedIron(Fluid fluid, String unlocalizedName, String stillIconTexture, String flowIconTexture)
{
super(fluid, Material.lava);
setResistance(100.0F);
setLightLevel(1.0F);
setCreativeTab(BloodArsenal.BA_TAB);
setBlockName(unlocalizedName);
this.stillIconTexture = (BloodArsenal.MODID + ":" + stillIconTexture);
this.flowIconTexture = (BloodArsenal.MODID + ":" + flowIconTexture);
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister icon)
{
this.stillIcon = icon.registerIcon(this.stillIconTexture);
this.flowingIcon = icon.registerIcon(this.flowIconTexture);
getFluid().setIcons(this.stillIcon, this.flowingIcon);
}
public IIcon getStillIcon()
{
return this.stillIcon;
}
public IIcon getFlowingIcon()
{
return this.flowingIcon;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon func_149735_b(int side, int meta)
{
if (side <= 1)
{
return this.stillIcon;
}
return this.flowingIcon;
}
}
@@ -0,0 +1,115 @@
package com.arc.bloodarsenal.items;
import cpw.mods.fml.common.eventhandler.Event;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraftforge.event.entity.player.FillBucketEvent;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import java.util.HashMap;
import java.util.Map;
public class BucketHandler
{
private static BucketHandler INSTANCE = new BucketHandler();
private static HashMap<Block, ItemStack> FILLED_BUCKETS = new HashMap();
public static BucketHandler getInstance()
{
return INSTANCE;
}
public static void addBuckets()
{
MoltenBucket bucket = new MoltenBucket(null);
GameRegistry.registerItem(bucket, "extra.bucket");
int bucketVol = 1000;
ItemStack emptyBucketStack = FluidContainerRegistry.EMPTY_BUCKET.copy();
FluidStack fluidStack = FluidRegistry.getFluidStack("molten.blood.infused.iron", bucketVol);
if (fluidStack != null)
{
int bucketId = 1;
bucket.addTextureMapping(bucketId, fluidStack.getFluid().getName(), "bucket_fill_blood_infused_iron");
ItemStack bucketStack = new ItemStack(bucket, 1, bucketId);
FILLED_BUCKETS.put(fluidStack.getFluid().getBlock(), bucketStack);
FluidContainerRegistry.registerFluidContainer(fluidStack, bucketStack, emptyBucketStack);
}
}
public void fillEvent(FillBucketEvent event)
{
World world = event.world;
MovingObjectPosition pos = event.target;
Block block = world.getBlock(pos.blockX, pos.blockY, pos.blockZ);
ItemStack bucketStack = getFilledBucket(block);
if (bucketStack == null)
{
return;
}
world.setBlockToAir(pos.blockX, pos.blockY, pos.blockZ);
event.result = bucketStack;
event.setResult(Event.Result.ALLOW);
}
public static HashMap<Block, ItemStack> getAllBuckets()
{
return FILLED_BUCKETS;
}
public static ItemStack getFilledBucket(Block fluidBlock)
{
return FILLED_BUCKETS.get(fluidBlock);
}
public static ItemStack getFilledBucket(String fluidName)
{
Block fluidBlock = FluidRegistry.getFluid(fluidName).getBlock();
return FILLED_BUCKETS.get(fluidBlock).copy();
}
public static boolean isAvailableBucket(int fluidBlockId)
{
return FILLED_BUCKETS.containsKey(Integer.valueOf(fluidBlockId));
}
public static boolean isAvailableBucket(String fluidName)
{
Block fluidBlock = FluidRegistry.getFluid(fluidName).getBlock();
return FILLED_BUCKETS.containsKey(fluidBlock);
}
public static Block getBlock(ItemStack bucketStack)
{
Block block = Blocks.air;
for (Map.Entry<Block, ItemStack> entry : FILLED_BUCKETS.entrySet())
{
ItemStack stack = entry.getValue();
if (stack.isItemEqual(bucketStack))
{
block = entry.getKey();
break;
}
}
return block;
}
}
@@ -0,0 +1,249 @@
package com.arc.bloodarsenal.items;
import com.arc.bloodarsenal.BloodArsenal;
import com.google.common.collect.HashBiMap;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBucket;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class MoltenBucket extends ItemBucket
{
private IIcon _filling = null;
private Block _fluidBlock = null;
private int _capacity = 1000;
private HashBiMap<Integer, String> fluidNames = HashBiMap.create();
private HashMap<Integer, String> textures = new HashMap();
private HashMap<Integer, IIcon> icons = new HashMap();
protected static final String pathToTextures = BloodArsenal.MODID + ":" + "bucket/";
public MoltenBucket(Block fluidBlock)
{
super(fluidBlock);
this._fluidBlock = fluidBlock;
setUnlocalizedName("extratic.bucket");
setCreativeTab(BloodArsenal.BA_TAB );
setContainerItem(Items.bucket);
setTextureName("minecraft:bucket_empty");
setMaxDamage(0);
setHasSubtypes(true);
}
@Override
@SideOnly(Side.CLIENT)
public boolean requiresMultipleRenderPasses()
{
return true;
}
@Override
public int getRenderPasses(int damage)
{
return 2;
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister register)
{
this.itemIcon = register.registerIcon(getIconString());
this._filling = register.registerIcon(pathToTextures + "bucket_fill_fblood_infused_iron");
for (Map.Entry<Integer, String> entry : this.textures.entrySet())
{
IIcon filling = register.registerIcon(pathToTextures + entry.getValue());
this.icons.put(entry.getKey(), filling);
}
}
@Override
public IIcon getIcon(ItemStack itemStack, int pass)
{
int index = itemStack.getItemDamage();
if ((pass == 0) || (index <= 0))
{
return this.itemIcon;
}
IIcon icon = this.icons.get(Integer.valueOf(index));
if (icon != null)
{
return icon;
}
return this.itemIcon;
}
@Override
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player)
{
if ((itemStack == null) || (itemStack.getItem() != this))
{
return itemStack;
}
int index = itemStack.getItemDamage();
String fluidName = this.fluidNames.get(Integer.valueOf(index));
if (fluidName == null)
{
return itemStack;
}
Block block = BucketHandler.getBlock(itemStack);
boolean isAir = block == null;
MovingObjectPosition movingobjectposition = getMovingObjectPositionFromPlayer(world, player, isAir);
if (movingobjectposition == null)
{
return itemStack;
}
if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
{
int xCoord = movingobjectposition.blockX;
int yCoord = movingobjectposition.blockY;
int zCoord = movingobjectposition.blockZ;
if (!world.canMineBlock(player, xCoord, yCoord, zCoord))
{
return itemStack;
}
if (block == Blocks.air)
{
return new ItemStack(getContainerItem());
}
if (movingobjectposition.sideHit == 0)
{
yCoord--;
}
if (movingobjectposition.sideHit == 1)
{
yCoord++;
}
if (movingobjectposition.sideHit == 2)
{
zCoord--;
}
if (movingobjectposition.sideHit == 3)
{
zCoord++;
}
if (movingobjectposition.sideHit == 4)
{
xCoord--;
}
if (movingobjectposition.sideHit == 5)
{
xCoord++;
}
if (!player.canPlayerEdit(xCoord, yCoord, zCoord, movingobjectposition.sideHit, itemStack))
{
return itemStack;
}
Material material = world.getBlock(xCoord, yCoord, zCoord).getMaterial();
if (world.isAirBlock(xCoord, yCoord, zCoord) && !material.isSolid())
{
if (!world.isRemote && !material.isSolid() && !material.isLiquid())
{
world.func_147480_a(xCoord, yCoord, zCoord, true);
}
world.setBlock(xCoord, yCoord, zCoord, block, 0, 3);
if (!player.capabilities.isCreativeMode)
{
return new ItemStack(getContainerItem());
}
}
}
return itemStack;
}
@Override
public boolean tryPlaceContainedLiquid(World world, int xCoord, int yCoord, int zCoord)
{
return false;
}
public void setCapcity(int capacity)
{
this._capacity = capacity;
}
@Override
public String getUnlocalizedName(ItemStack itemStack)
{
if (itemStack == null)
{
return getUnlocalizedName();
}
int index = itemStack.getItemDamage();
String fluidName = this.fluidNames.get(Integer.valueOf(index));
if (fluidName == null)
{
return getUnlocalizedName();
}
return "item.ba.bucket.filled." + fluidName;
}
public void addTextureMapping(int id, String fluidName, String texture)
{
this.fluidNames.put(id, fluidName);
this.textures.put(id, texture);
}
@Override
public void getSubItems(Item item, CreativeTabs tab, List itemStackList)
{
if (!this.fluidNames.isEmpty())
{
for (Map.Entry<Integer, String> subItem : this.fluidNames.entrySet())
{
int entryId = subItem.getKey().intValue();
ItemStack bucketStack = new ItemStack(this, 1, entryId);
itemStackList.add(bucketStack);
}
}
else
{
itemStackList.add(new ItemStack(this, 1, 0));
}
}
}
@@ -215,7 +215,7 @@ public class VampireCostume extends ItemArmor
{
player.removePotionEffect(Potion.damageBoost.id);
}
player.addPotionEffect(new PotionEffect(Potion.damageBoost.id, 2, 2));
player.addPotionEffect(new PotionEffect(Potion.damageBoost.id, 2, 1));
setIsInvisible(armor, player.isPotionActive(Potion.invisibility.id));
}
@@ -0,0 +1,38 @@
package com.arc.bloodarsenal.misc;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.ChatStyle;
import net.minecraft.util.EnumChatFormatting;
public class CommandDownloadMod extends CommandBase
{
private static final boolean ENABLED = true;
@Override
public String getCommandName()
{
return "bloodarsenal-download-latest";
}
@Override
public String getCommandUsage(ICommandSender var1)
{
return "/bloodarsenal-download-latest <version>";
}
@Override
public void processCommand(ICommandSender var1, String[] var2)
{
if (!ENABLED)
var1.addChatMessage(new ChatComponentTranslation("ba.versioning.disabled").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED)));
else if (var2.length == 1)
if (VersionChecker.downloadedFile)
var1.addChatMessage(new ChatComponentTranslation("ba.versioning.downloadedAlready").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED)));
else if (VersionChecker.startedDownload)
var1.addChatMessage(new ChatComponentTranslation("ba.versioning.downloadingAlready").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED)));
else new ThreadDownloadMod("BloodArsenal " + var2[0] + ".jar");
}
}
@@ -0,0 +1,98 @@
package com.arc.bloodarsenal.misc;
import net.minecraft.client.Minecraft;
import net.minecraft.util.*;
import java.awt.*;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
public class ThreadDownloadMod extends Thread
{
String fileName;
byte[] buffer = new byte[10240];
int totalBytesDownloaded;
int bytesJustDownloaded;
InputStream webReader;
public ThreadDownloadMod(String fileName)
{
setName("Blood Arsenal Download File Thread");
this.fileName = fileName;
setDaemon(true);
start();
}
@Override
public void run()
{
try
{
IChatComponent component = IChatComponent.Serializer.func_150699_a(String.format(StatCollector.translateToLocal("ba.versioning.startingDownload"), fileName));
if (Minecraft.getMinecraft().thePlayer != null)
{
Minecraft.getMinecraft().thePlayer.addChatMessage(component);
}
VersionChecker.startedDownload = true;
String base = "http://minecraft.curseforge.com/mc-mods/228823-blood-magic-addon-blood-arsenal";
String file = fileName.replaceAll(" ", "%20");
URL url = new URL(base + "/files/latest");
try
{
url.openStream().close(); // Add to DL Counter
}
catch(IOException e) {}
url = new URL(base + "files/" + file);
webReader = url.openStream();
File dir = new File(".", "mods");
File f = new File(dir, fileName);
f.createNewFile();
FileOutputStream outputStream = new FileOutputStream(f.getAbsolutePath());
while ((bytesJustDownloaded = webReader.read(buffer)) > 0)
{
outputStream.write(buffer, 0, bytesJustDownloaded);
buffer = new byte[10240];
totalBytesDownloaded += bytesJustDownloaded;
}
if (Minecraft.getMinecraft().thePlayer != null)
{
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentTranslation("ba.versioning.doneDownloading", fileName).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GREEN)));
}
Desktop.getDesktop().open(dir);
VersionChecker.downloadedFile = true;
outputStream.close();
webReader.close();
finalize();
}
catch (Throwable e)
{
e.printStackTrace();
}
}
private void sendError()
{
if (Minecraft.getMinecraft().thePlayer != null)
{
Minecraft.getMinecraft().thePlayer.addChatComponentMessage(new ChatComponentTranslation("ba.versioning.error").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED)));
}
}
}
@@ -0,0 +1,35 @@
package com.arc.bloodarsenal.misc;
import net.minecraftforge.common.MinecraftForge;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
public class ThreadVersionChecker extends Thread
{
public ThreadVersionChecker()
{
setName("Blood Arsenal Version Checker Thread");
setDaemon(true);
start();
}
@Override
public void run()
{
try
{
URL url = new URL("https://raw.githubusercontent.com/Arcaratus/BloodArsenal/master/version/" + MinecraftForge.MC_VERSION + ".txt");
BufferedReader r = new BufferedReader(new InputStreamReader(url.openStream()));
VersionChecker.onlineVersion = r.readLine();
r.close();
}
catch (Exception e)
{
e.printStackTrace();
}
VersionChecker.doneChecking = true;
}
}
@@ -0,0 +1,54 @@
package com.arc.bloodarsenal.misc;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.*;
public class VersionChecker
{
public static boolean doneChecking = false;
public static String onlineVersion = "";
public static boolean triedToWarnPlayer = false;
public static boolean startedDownload = false;
public static boolean downloadedFile = false;
private static String BUILD = "GRADLE:BUILD";
public void init()
{
new ThreadVersionChecker();
FMLCommonHandler.instance().bus().register(this);
}
@SubscribeEvent
public void onTick(TickEvent.ClientTickEvent event)
{
if (doneChecking && event.phase == TickEvent.Phase.END && Minecraft.getMinecraft().thePlayer != null && !triedToWarnPlayer)
{
Minecraft.getMinecraft().thePlayer.addChatComponentMessage(new ChatComponentText("Passed stage 1"));
if (!onlineVersion.isEmpty())
{
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
player.addChatComponentMessage(new ChatComponentText("Passed stage 2"));
int onlineBuild = Integer.parseInt(onlineVersion.split("-1.7.10-1.1.4-")[1]);
int clientBuild = BUILD.contains("GRADLE") ? Integer.MAX_VALUE : Integer.parseInt(BUILD);
if (onlineBuild > clientBuild)
{
player.addChatComponentMessage(new ChatComponentText("Passed stage 3"));
player.addChatComponentMessage(new ChatComponentTranslation("ba.versioning.update").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.LIGHT_PURPLE)));
player.addChatComponentMessage(new ChatComponentTranslation("ba.versioning.outdated", clientBuild, onlineBuild));
IChatComponent component = IChatComponent.Serializer.func_150699_a(StatCollector.translateToLocal("ba.versioning.updateMessage").replaceAll("%version%", onlineVersion));
player.addChatComponentMessage(component);
}
}
triedToWarnPlayer = true;
}
}
}
@@ -0,0 +1,185 @@
package com.arc.bloodarsenal.renderer.block;
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;
public static int beam = 0;
public static void initShaders()
{
beam = createProgram(null, "/assets/bloodarsenal/shaders/beam.frag");
}
public static void useShaderWithProps(int shader, Object... props)
{
ARBShaderObjects.glUseProgramObjectARB(shader);
if (shader != 0 && props.length % 2 == 0)
{
int propCount = props.length / 2;
for (int i = 0; i < propCount; i++)
{
String propName = (String) props[i * 2];
Object propVal = props[i * 2 + 1];
int uniform = ARBShaderObjects.glGetUniformLocationARB(shader, propName);
if (propVal instanceof Integer) ARBShaderObjects.glUniform1iARB(uniform, (Integer) propVal);
if (propVal instanceof Float) ARBShaderObjects.glUniform1fARB(uniform, (Float) propVal);
}
}
}
public static void useShader(int shader)
{
useShaderWithProps(shader);
}
public static void releaseShader()
{
useShader(0);
}
public static boolean useShaders()
{
return true;
}
// Most of the code taken from the LWJGL wiki
// http://lwjgl.org/wiki/index.php?title=GLSL_Shaders_with_LWJGL
private static int createProgram(String vert, String frag)
{
int vertId = 0, fragId = 0, program = 0;
if (vert != null) vertId = createShader(vert, VERT);
if (frag != null) fragId = createShader(frag, FRAG);
program = ARBShaderObjects.glCreateProgramObjectARB();
if (program == 0) return 0;
if (vert != null) ARBShaderObjects.glAttachObjectARB(program, vertId);
if (frag != null) ARBShaderObjects.glAttachObjectARB(program, fragId);
ARBShaderObjects.glLinkProgramARB(program);
if (ARBShaderObjects.glGetObjectParameteriARB(program, ARBShaderObjects.GL_OBJECT_LINK_STATUS_ARB) == GL11.GL_FALSE)
{
return 0;
}
ARBShaderObjects.glValidateProgramARB(program);
if (ARBShaderObjects.glGetObjectParameteriARB(program, ARBShaderObjects.GL_OBJECT_VALIDATE_STATUS_ARB) == GL11.GL_FALSE)
{
return 0;
}
return program;
}
private static int createShader(String filename, int shaderType)
{
int shader = 0;
try
{
shader = ARBShaderObjects.glCreateShaderObjectARB(shaderType);
if (shader == 0) return 0;
ARBShaderObjects.glShaderSourceARB(shader, readFileAsString(filename));
ARBShaderObjects.glCompileShaderARB(shader);
if (ARBShaderObjects.glGetObjectParameteriARB(shader, ARBShaderObjects.GL_OBJECT_COMPILE_STATUS_ARB) == GL11.GL_FALSE) throw new RuntimeException("Error creating shader: " + getLogInfo(shader));
return shader;
}
catch (Exception e)
{
ARBShaderObjects.glDeleteObjectARB(shader);
e.printStackTrace();
return -1;
}
}
private static String getLogInfo(int obj)
{
return ARBShaderObjects.glGetInfoLogARB(obj, ARBShaderObjects.glGetObjectParameteriARB(obj, ARBShaderObjects.GL_OBJECT_INFO_LOG_LENGTH_ARB));
}
private static String readFileAsString(String filename) throws Exception
{
StringBuilder source = new StringBuilder();
InputStream in = ShaderHelper.class.getResourceAsStream(filename);
Exception exception = null;
BufferedReader reader;
if (in == null)
return "";
try
{
reader = new BufferedReader(new InputStreamReader(in, "UTF-8"));
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 (innerExc != null) throw innerExc;
}
catch (Exception exc)
{
exception = exc;
}
finally
{
try
{
in.close();
}
catch (Exception exc)
{
if (exception == null) exception = exc;
else exc.printStackTrace();
}
if (exception != null) throw exception;
}
return source.toString();
}
}
@@ -440,7 +440,7 @@ public class TileLifeInfuser extends TileEntity implements IInventory, IFluidTan
return 0;
}
if (resource.fluidID != (new FluidStack(AlchemicalWizardry.lifeEssenceFluid, 1)).fluidID)
if (resource.fluidID != (fluidInput).fluidID)
{
return 0;
}