file_name
stringlengths 6
86
| file_path
stringlengths 45
249
| content
stringlengths 47
6.26M
| file_size
int64 47
6.26M
| language
stringclasses 1
value | extension
stringclasses 1
value | repo_name
stringclasses 767
values | repo_stars
int64 8
14.4k
| repo_forks
int64 0
1.17k
| repo_open_issues
int64 0
788
| repo_created_at
stringclasses 767
values | repo_pushed_at
stringclasses 767
values |
---|---|---|---|---|---|---|---|---|---|---|---|
ClientProfile.java | /FileExtraction/Java_unseen/gyurix_SpigotLib/src/main/java/gyurix/mojang/ClientProfile.java | package gyurix.mojang;
/**
* Created by GyuriX on 2016. 06. 10..
*/
public class ClientProfile {
public String id, name;
public boolean legacy;
}
| 153 | Java | .java | gyurix/SpigotLib | 53 | 6 | 3 | 2018-03-14T22:12:00Z | 2020-10-05T05:01:38Z |
MojangAPI.java | /FileExtraction/Java_unseen/gyurix_SpigotLib/src/main/java/gyurix/mojang/MojangAPI.java | package gyurix.mojang;
import gyurix.json.JsonAPI;
import gyurix.protocol.utils.GameProfile;
import gyurix.spigotlib.SU;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.UUID;
import static gyurix.mojang.WebApi.get;
import static gyurix.mojang.WebApi.post;
/**
* Created by GyuriX on 2015.12.27..
*/
public class MojangAPI {
/**
* @param userName - The username of the Mojang account
* @param password - The password of the Mojang account
* @return On successful login the ClientSession of the profile otherwise null
*/
public static ClientSession clientLogin(String userName, String password) {
try {
String s = post("https://authserver.mojang.com/authenticate",
"{\"agent\":{\"name\":\"Minecraft\",\"version\":1}," +
"\"username\":\"" + userName + "\"," +
"\"password\":\"" + password + "\"}");
System.out.println(s);
ClientSession client = JsonAPI.deserialize(s, ClientSession.class);
client.username = userName;
client.password = password;
return client;
} catch (Throwable e) {
e.printStackTrace();
return null;
}
}
/**
* @param id - The online UUID of the player
* @return A list of NameData which contains usernames of that player
*/
public static ArrayList<NameData> getNameHistory(UUID id) {
try {
return (ArrayList<NameData>) JsonAPI.deserialize(get("https://api.mojang.com/user/profiles/" + id.toString().replace("-", "") + "/names"), ArrayList.class, NameData.class);
} catch (Throwable e) {
e.printStackTrace();
}
return null;
}
/**
* @param name - The username of the player
* @return The GameProfile of the player
*/
public static GameProfile getProfile(String name) {
try {
return JsonAPI.deserialize(get("https://api.mojang.com/users/profiles/minecraft/" + name), GameProfile.class);
} catch (Throwable e) {
return new GameProfile(name, SU.getOfflineUUID(name));
}
}
public static GameProfile getProfile(String name, long time) {
return JsonAPI.deserialize(get("https://api.mojang.com/users/profiles/minecraft/" + name + "?at=" + time), GameProfile.class);
}
public static GameProfile getProfileWithSkin(UUID id) {
return JsonAPI.deserialize(get("https://sessionserver.mojang.com/session/minecraft/profile/" + id.toString().replace("-", "") + "?unsigned=false"), GameProfile.class);
}
public static ArrayList<GameProfile> getProfiles(String... names) {
return (ArrayList<GameProfile>) JsonAPI.deserialize(post("https://api.mojang.com/profiles/minecraft", JsonAPI.serialize(names)), ArrayList.class, GameProfile.class);
}
/**
* @return The states of the Mojang servers
*/
public static HashMap<String, MojangServerState> getServerState() {
HashMap<String, MojangServerState> out = new HashMap<>();
String[] d = get("https://status.mojang.com/check").split(",");
for (String s : d) {
String[] s2 = s.split(":");
out.put(s2[0].substring(s2[0].indexOf("\"") + 1, s2[0].length() - 1),
MojangServerState.valueOf(s2[1].substring(s2[1].indexOf("\"") + 1, s2[1].lastIndexOf("\"")).toUpperCase()));
}
return out;
}
public enum MojangServerState {
RED, GREEN, YELLOW
}
public static class NameData {
public long changedToAt;
public String name;
@Override
public String toString() {
return JsonAPI.serialize(this);
}
}
}
| 3,502 | Java | .java | gyurix/SpigotLib | 53 | 6 | 3 | 2018-03-14T22:12:00Z | 2020-10-05T05:01:38Z |
ClientProxy.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/ClientProxy.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.common.MinecraftForge;
import net.quetzi.bluepower.client.renderers.IconSupplier;
import net.quetzi.bluepower.client.renderers.Renderers;
import org.lwjgl.input.Keyboard;
import cpw.mods.fml.client.FMLClientHandler;
public class ClientProxy extends CommonProxy {
@Override
public void init() {
}
@Override
public void initRenderers() {
MinecraftForge.EVENT_BUS.register(new IconSupplier());
Renderers.init();
}
@Override
public EntityPlayer getPlayer() {
return FMLClientHandler.instance().getClientPlayerEntity();
}
@Override
public boolean isSneakingInGui() {
return Keyboard.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindSneak.getKeyCode());
}
public static GuiScreen getOpenedGui() {
return FMLClientHandler.instance().getClient().currentScreen;
}
}
| 1,826 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
BluePower.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/BluePower.java | /*
* This file is part of Blue Power. Blue Power is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Blue Power is
* distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along
* with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.config.Configuration;
import net.quetzi.bluepower.api.BPRegistry;
import net.quetzi.bluepower.api.part.PartRegistry;
import net.quetzi.bluepower.api.part.redstone.RedstoneNetworkTickHandler;
import net.quetzi.bluepower.client.gui.GUIHandler;
import net.quetzi.bluepower.compat.CompatibilityUtils;
import net.quetzi.bluepower.events.BPEventHandler;
import net.quetzi.bluepower.init.BPBlocks;
import net.quetzi.bluepower.init.BPEnchantments;
import net.quetzi.bluepower.init.BPItems;
import net.quetzi.bluepower.init.Config;
import net.quetzi.bluepower.init.CustomTabs;
import net.quetzi.bluepower.init.OreDictionarySetup;
import net.quetzi.bluepower.init.Recipes;
import net.quetzi.bluepower.network.NetworkHandler;
import net.quetzi.bluepower.recipe.AlloyFurnaceRegistry;
import net.quetzi.bluepower.references.Refs;
import net.quetzi.bluepower.tileentities.TileEntities;
import net.quetzi.bluepower.world.WorldGenerationHandler;
import org.apache.logging.log4j.Logger;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
@Mod(modid = Refs.MODID, name = Refs.NAME)
public class BluePower {
@Instance(Refs.MODID)
public static BluePower instance;
@SidedProxy(clientSide = Refs.PROXY_LOCATION + ".ClientProxy", serverSide = Refs.PROXY_LOCATION + ".CommonProxy")
public static CommonProxy proxy;
public static Logger log;
@EventHandler
public void PreInit(FMLPreInitializationEvent event) {
event.getModMetadata().version = Refs.fullVersionString();
log = event.getModLog();
Configuration config = new Configuration(event.getSuggestedConfigurationFile());
CustomTabs.init();
// Load configs
config.load();
Config.setUp(config);
config.save();
BPBlocks.init();
BPItems.init();
BPRegistry.alloyFurnaceRegistry = AlloyFurnaceRegistry.getInstance();
TileEntities.init();
OreDictionarySetup.init();
GameRegistry.registerWorldGenerator(new WorldGenerationHandler(), 0);
BPEnchantments.init();
PartRegistry.init();
CompatibilityUtils.preInit(event);
FMLCommonHandler.instance().bus().register(new RedstoneNetworkTickHandler());
BPEventHandler eventHandler =new BPEventHandler();
MinecraftForge.EVENT_BUS.register(eventHandler);
FMLCommonHandler.instance().bus().register(eventHandler);
}
@EventHandler
public void Init(FMLInitializationEvent event) {
Recipes.init(CraftingManager.getInstance());
proxy.init();
NetworkHandler.init();
NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GUIHandler());
CompatibilityUtils.init(event);
}
@EventHandler
public void PostInit(FMLPostInitializationEvent event) {
CompatibilityUtils.postInit(event);
AlloyFurnaceRegistry.getInstance().generateRecyclingRecipes();
proxy.initRenderers();
}
@EventHandler
public void ServerStarting(FMLServerStartingEvent event) {
// register commands
}
}
| 4,472 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
CommonProxy.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/CommonProxy.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower;
import net.minecraft.entity.player.EntityPlayer;
public class CommonProxy {
public void init() {
}
public void initRenderers() {
}
public EntityPlayer getPlayer() {
return null;
}
public boolean isSneakingInGui() {
return false;
}
}
| 1,079 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
EnchantmentDisjunction.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/enchantments/EnchantmentDisjunction.java | package net.quetzi.bluepower.enchantments;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnumEnchantmentType;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.monster.EntityEnderman;
import net.minecraft.entity.monster.EntitySkeleton;
import net.minecraft.util.StatCollector;
public class EnchantmentDisjunction extends Enchantment {
public EnchantmentDisjunction(int par1, int par2) {
super(par1, par2, EnumEnchantmentType.weapon);
}
@Override
public int getMaxLevel() {
return 5;
}
@Override
public int getMinEnchantability(int par1) {
return 5 + (par1 - 1) * 8;
}
@Override
public int getMaxEnchantability(int par1) {
return this.getMinEnchantability(par1) + 20;
}
@SuppressWarnings("cast")
@Override
public float calcModifierLiving(int par1, EntityLivingBase entity) {
return entity instanceof EntityEnderman ? (float)par1 * 2.5F : (entity instanceof EntitySkeleton ? (((EntitySkeleton) entity).getSkeletonType() == 1 ? (float)par1 * 2.5F : 0.0F) : 0.0F);
}
@Override
public String getTranslatedName(int level) {
return StatCollector.translateToLocal("enchantment.disjunction.name") + " " + StatCollector.translateToLocal("enchantment.level." + level);
}
}
| 1,282 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
EnchantmentVorpal.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/enchantments/EnchantmentVorpal.java | package net.quetzi.bluepower.enchantments;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnumEnchantmentType;
import net.minecraft.util.StatCollector;
public class EnchantmentVorpal extends Enchantment {
public EnchantmentVorpal(int par1, int par2) {
super(par1, par2, EnumEnchantmentType.weapon);
}
@Override
public int getMaxLevel() {
return 2;
}
@Override
public int getMinEnchantability(int par1) {
return 10 + 20 * (par1 - 1);
}
@Override
public int getMaxEnchantability(int par1) {
return super.getMinEnchantability(par1) + 50;
}
@Override
public String getTranslatedName(int level) {
return StatCollector.translateToLocal("enchantment.vorpal.name") + " " + StatCollector.translateToLocal("enchantment.level." + level);
}
}
| 798 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
ItemGemSpade.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/items/ItemGemSpade.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.items;
import net.minecraft.item.ItemSpade;
import net.quetzi.bluepower.init.CustomTabs;
import net.quetzi.bluepower.references.Refs;
public class ItemGemSpade extends ItemSpade {
public ItemGemSpade(ToolMaterial material, String name) {
super(material);
this.setUnlocalizedName(name);
this.setCreativeTab(CustomTabs.tabBluePowerTools);
this.setTextureName(Refs.MODID + ":" + name);
}
}
| 1,186 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
ItemFloppyDisk.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/items/ItemFloppyDisk.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.items;
import net.minecraft.item.Item;
import net.quetzi.bluepower.references.Refs;
public class ItemFloppyDisk extends Item {
public ItemFloppyDisk(String name) {
this.setUnlocalizedName(name);
this.setTextureName(Refs.MODID + ":" + name);
}
}
| 1,028 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
ItemGemHoe.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/items/ItemGemHoe.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.items;
import net.minecraft.item.ItemHoe;
import net.quetzi.bluepower.init.CustomTabs;
import net.quetzi.bluepower.references.Refs;
public class ItemGemHoe extends ItemHoe {
public ItemGemHoe(ToolMaterial material, String name) {
super(material);
this.setUnlocalizedName(name);
this.setCreativeTab(CustomTabs.tabBluePowerTools);
this.setTextureName(Refs.MODID + ":" + name);
}
}
| 1,179 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
ItemHandle.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/items/ItemHandle.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.items;
import net.minecraft.item.Item;
import net.quetzi.bluepower.init.CustomTabs;
import net.quetzi.bluepower.references.Refs;
public class ItemHandle extends Item {
public ItemHandle(String name) {
this.setUnlocalizedName(name);
this.setTextureName(Refs.MODID + ":" + name);
this.setCreativeTab(CustomTabs.tabBluePowerItems);
}
}
| 1,122 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
ItemCropSeed.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/items/ItemCropSeed.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.items;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemSeeds;
import net.minecraft.item.ItemStack;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.EnumPlantType;
import net.minecraftforge.common.IPlantable;
import net.minecraftforge.common.util.ForgeDirection;
import net.quetzi.bluepower.init.CustomTabs;
import net.quetzi.bluepower.references.Refs;
public class ItemCropSeed extends ItemSeeds implements IPlantable {
public static Block field_150925_a;
@SuppressWarnings("static-access")
public ItemCropSeed(Block blockCrop, Block blockSoil) {
super(blockCrop, blockSoil);
this.field_150925_a = blockCrop;
this.setCreativeTab(CustomTabs.tabBluePowerItems);
this.setTextureName(Refs.MODID + ":" + Refs.FLAXSEED_NAME);
}
@SuppressWarnings("static-access")
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
if (side != 1) {
return false;
} else if (player.canPlayerEdit(x, y, z, side, itemStack) && player.canPlayerEdit(x, y + 1, z, side, itemStack)) {
if (world.getBlock(x, y, z).canSustainPlant(world, x, y, z, ForgeDirection.UP, this) && world.isAirBlock(x, y + 1, z)
&& (world.getBlock(x, y, z).isFertile(world, x, y, z))) {
world.setBlock(x, y + 1, z, this.field_150925_a, 0, 2);
--itemStack.stackSize;
return true;
} else {
return false;
}
} else {
return false;
}
}
@Override
public EnumPlantType getPlantType(IBlockAccess world, int x, int y, int z) {
return EnumPlantType.Crop;
}
@Override
public Block getPlant(IBlockAccess world, int x, int y, int z) {
return field_150925_a;
}
@Override
public int getPlantMetadata(IBlockAccess world, int x, int y, int z) {
return 0;
}
}
| 2,871 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
ItemIngot.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/items/ItemIngot.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.items;
import net.minecraft.item.Item;
import net.quetzi.bluepower.init.CustomTabs;
import net.quetzi.bluepower.references.Refs;
public class ItemIngot extends Item {
public ItemIngot(String name) {
super();
this.setUnlocalizedName(name);
this.setCreativeTab(CustomTabs.tabBluePowerItems);
this.setTextureName(Refs.MODID + ":" + name);
}
}
| 1,139 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
ItemGem.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/items/ItemGem.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.items;
import net.minecraft.item.Item;
import net.quetzi.bluepower.init.CustomTabs;
import net.quetzi.bluepower.references.Refs;
public class ItemGem extends Item {
public ItemGem(String name) {
super();
this.setUnlocalizedName(name);
this.setCreativeTab(CustomTabs.tabBluePowerItems);
this.setTextureName(Refs.MODID + ":" + name);
}
}
| 1,135 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
ItemGemSword.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/items/ItemGemSword.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.items;
import net.minecraft.item.ItemSword;
import net.quetzi.bluepower.init.CustomTabs;
import net.quetzi.bluepower.references.Refs;
public class ItemGemSword extends ItemSword {
public ItemGemSword(ToolMaterial material, String name) {
super(material);
this.setUnlocalizedName(name);
this.setCreativeTab(CustomTabs.tabBluePowerTools);
this.setTextureName(Refs.MODID + ":" + name);
}
}
| 1,186 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
ItemIndigoDye.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/items/ItemIndigoDye.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.items;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.passive.EntitySheep;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.quetzi.bluepower.init.CustomTabs;
import net.quetzi.bluepower.references.Refs;
public class ItemIndigoDye extends Item {
public ItemIndigoDye(String name) {
this.setUnlocalizedName(name);
this.setCreativeTab(CustomTabs.tabBluePowerItems);
this.setTextureName(Refs.MODID + ":" + name);
}
@Override
public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer player, EntityLivingBase entity) {
if (entity instanceof EntitySheep) {
EntitySheep sheep = (EntitySheep) entity;
if (!sheep.getSheared() && sheep.getFleeceColor() != 10) {
sheep.setFleeceColor(10);
--stack.stackSize;
}
return true;
}
return false;
}
}
| 1,674 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
ItemAthame.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/items/ItemAthame.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.items;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.boss.EntityDragon;
import net.minecraft.entity.monster.EntityEnderman;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.util.DamageSource;
import net.minecraftforge.common.util.EnumHelper;
import net.quetzi.bluepower.init.CustomTabs;
import net.quetzi.bluepower.references.Refs;
public class ItemAthame extends ItemSword {
private float damageDealt;
private static ToolMaterial athameMaterial = EnumHelper.addToolMaterial("SILVER", 0, 100, 6.0F, 2.0F, 10);
public ItemAthame() {
super(athameMaterial);
this.setCreativeTab(CustomTabs.tabBluePowerTools);
this.setMaxDamage(100);
this.setUnlocalizedName(Refs.ATHAME_NAME);
this.setTextureName(Refs.MODID + ":" + Refs.ATHAME_NAME);
this.maxStackSize = 1;
this.setFull3D();
}
@Override
public float func_150931_i() {
return this.damageDealt;
}
@Override
public boolean hitEntity(ItemStack stack, EntityLivingBase entity, EntityLivingBase player) {
this.damageDealt = athameMaterial.getDamageVsEntity();
if ((entity instanceof EntityEnderman) || (entity instanceof EntityDragon)) {
this.damageDealt += 25.0F;
}
entity.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) player), this.damageDealt);
return super.hitEntity(stack, entity, player);
}
}
| 2,342 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
ItemLumar.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/items/ItemLumar.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*
* @author Quetzi
*/
package net.quetzi.bluepower.items;
import java.util.List;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemDye;
import net.minecraft.item.ItemStack;
import net.quetzi.bluepower.init.CustomTabs;
import net.quetzi.bluepower.references.Refs;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemLumar extends Item {
public ItemLumar() {
super();
this.setCreativeTab(CustomTabs.tabBluePowerItems);
this.setHasSubtypes(true);
this.setUnlocalizedName(Refs.LUMAR_NAME);
this.setTextureName(Refs.MODID + ":" + Refs.LUMAR_NAME);
}
@Override
public String getUnlocalizedName(ItemStack itemStack) {
return super.getUnlocalizedName() + "." + Refs.oreDictDyes[15 - itemStack.getItemDamage()].substring(3).toLowerCase();
}
@Override
@SideOnly(Side.CLIENT)
public int getColorFromItemStack(ItemStack itemStack, int colour) {
int damage = itemStack.getItemDamage();
if (damage >= 0 && damage < ItemDye.field_150922_c.length) { return ItemDye.field_150922_c[15 - damage]; }
return 16777215;
}
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs tab, List list) {
for (int i = 0; i < ItemDye.field_150922_c.length; i++) {
list.add(new ItemStack(this, 1, i));
}
}
}
| 2,198 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
ItemTinPlate.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/items/ItemTinPlate.java | package net.quetzi.bluepower.items;
import net.minecraft.item.Item;
import net.quetzi.bluepower.init.CustomTabs;
import net.quetzi.bluepower.references.Refs;
public class ItemTinPlate extends Item {
public ItemTinPlate() {
this.setUnlocalizedName(Refs.TINPLATE_NAME);
this.setCreativeTab(CustomTabs.tabBluePowerItems);
this.setTextureName(Refs.MODID + ":" + Refs.TINPLATE_NAME);
}
}
| 432 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
ItemGemPickaxe.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/items/ItemGemPickaxe.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.items;
import net.minecraft.item.ItemPickaxe;
import net.quetzi.bluepower.init.CustomTabs;
import net.quetzi.bluepower.references.Refs;
public class ItemGemPickaxe extends ItemPickaxe {
public ItemGemPickaxe(ToolMaterial material, String name) {
super(material);
this.setUnlocalizedName(name);
this.setCreativeTab(CustomTabs.tabBluePowerTools);
this.setTextureName(Refs.MODID + ":" + name);
}
}
| 1,194 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
ItemScrewdriver.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/items/ItemScrewdriver.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.items;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumAction;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.quetzi.bluepower.BluePower;
import net.quetzi.bluepower.api.part.BPPart;
import net.quetzi.bluepower.api.vec.Vector3;
import net.quetzi.bluepower.compat.CompatibilityUtils;
import net.quetzi.bluepower.compat.fmp.IMultipartCompat;
import net.quetzi.bluepower.init.BPBlocks;
import net.quetzi.bluepower.init.CustomTabs;
import net.quetzi.bluepower.references.Dependencies;
import net.quetzi.bluepower.references.GuiIDs;
import net.quetzi.bluepower.references.Refs;
import net.quetzi.bluepower.tileentities.tier3.IRedBusWindow;
import net.quetzi.bluepower.tileentities.tier3.TileCPU;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemScrewdriver extends Item {
public ItemScrewdriver() {
setUnlocalizedName(Refs.SCREWDRIVER_NAME);
setCreativeTab(CustomTabs.tabBluePowerTools);
setMaxDamage(250);
setMaxStackSize(1);
setTextureName(Refs.MODID + ":" + this.getUnlocalizedName().substring(5));
}
@Override
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
Block block = world.getBlock(x, y, z);
if (block == BPBlocks.multipart) {
IMultipartCompat compat = (IMultipartCompat) CompatibilityUtils.getModule(Dependencies.FMP);
BPPart p = compat.getClickedPart(new Vector3(x, y, z, world), new Vector3(hitX, hitY, hitZ), stack, player);
if (p != null && player.isSneaking()) {
p.onActivated(player, new MovingObjectPosition(x, y, z, side, Vec3.createVectorHelper(x + hitX, y + hitY, z + hitZ)), stack);
}
return false;
}
TileEntity te = world.getTileEntity(x, y, z);
if (te != null && te instanceof IRedBusWindow && player.isSneaking() && !(te instanceof TileCPU)) {
player.openGui(BluePower.instance, GuiIDs.REDBUS_ID.ordinal(), world, x, y, z);
}
block.rotateBlock(world, x, y, z, ForgeDirection.getOrientation(side));
if (!player.capabilities.isCreativeMode) {
stack.setItemDamage(stack.getItemDamage() + 1);
}
return false;
}
@SideOnly(Side.CLIENT)
@Override
public boolean isFull3D() {
return true;
}
@Override
public EnumAction getItemUseAction(ItemStack par1ItemStack) {
return EnumAction.block;
}
}
| 3,702 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
ItemNikolite.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/items/ItemNikolite.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.items;
import net.minecraft.item.Item;
import net.quetzi.bluepower.init.CustomTabs;
import net.quetzi.bluepower.references.Refs;
public class ItemNikolite extends Item {
public ItemNikolite() {
super();
this.setUnlocalizedName(Refs.NIKOLITE_NAME);
this.setCreativeTab(CustomTabs.tabBluePowerItems);
this.setTextureName(Refs.MODID + ":" + Refs.NIKOLITE_NAME);
}
}
| 1,162 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
ItemSickle.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/items/ItemSickle.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.items;
import com.google.common.collect.Sets;
import net.minecraft.block.Block;
import net.minecraft.block.BlockBush;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemTool;
import net.minecraft.world.World;
import net.quetzi.bluepower.init.CustomTabs;
import net.quetzi.bluepower.references.Refs;
import java.util.Set;
public class ItemSickle extends ItemTool {
@SuppressWarnings("rawtypes")
private static final Set toolBlocks = Sets.newHashSet(new Block[] { Blocks.leaves, Blocks.leaves2, Blocks.wheat, Blocks.potatoes, Blocks.carrots,
Blocks.nether_wart, Blocks.red_mushroom, Blocks.brown_mushroom, Blocks.reeds, Blocks.tallgrass, Blocks.vine, Blocks.waterlily,
Blocks.red_flower, Blocks.yellow_flower });
private int cropRadius = 2;
private int leafRadius = 1;
public ItemSickle(ToolMaterial material, String name) {
super(1.0F, material, toolBlocks);
this.setUnlocalizedName(name);
this.setCreativeTab(CustomTabs.tabBluePowerTools);
this.setTextureName(Refs.MODID + ":" + name);
}
@SuppressWarnings("static-access")
public float func_150893_a(ItemStack itemStack, Block block) {
if ((block.getMaterial() == Material.leaves) || (block.getMaterial() == Material.plants) || (block.getMaterial() == Material.grass) || this.toolBlocks.contains(block)) {
return this.efficiencyOnProperMaterial;
}
return 1.0F;
}
public boolean hitEntity(ItemStack itemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase) {
itemStack.damageItem(2, par3EntityLivingBase);
return true;
}
public boolean onBlockDestroyed(ItemStack itemStack, World world, Block block, int x, int y, int z, EntityLivingBase entityLiving) {
boolean used = false;
if (!(entityLiving instanceof EntityPlayer)) return false;
EntityPlayer player = (EntityPlayer) entityLiving;
if ((block != null) && (block.isLeaves(world, x, y, z))) {
for (int i = -this.leafRadius; i <= this.leafRadius; i++) {
for (int j = -this.leafRadius; j <= this.leafRadius; j++) {
for (int k = -this.leafRadius; k <= this.leafRadius; k++) {
Block blockToCheck = world.getBlock(x + i, y + j, z + k);
int meta = world.getBlockMetadata(x + i, y + j, z + k);
if ((blockToCheck != null) && (blockToCheck.isLeaves(world, x + i, y + j, z + k))) {
if (blockToCheck.canHarvestBlock(player, meta)) {
blockToCheck.harvestBlock(world, player, x + i, y + j, z + k, meta);
}
world.setBlock(x + i, y + j, z + k, Blocks.air);
used = true;
}
}
}
}
if (used) {
itemStack.damageItem(1, entityLiving);
}
return used;
}
for (int i = -this.cropRadius; i <= this.cropRadius; i++)
for (int j = -this.cropRadius; j <= this.cropRadius; j++) {
Block blockToCheck = world.getBlock(x + i, y, z + j);
int meta = world.getBlockMetadata(x + i, y, z + j);
if (blockToCheck != null) {
if (blockToCheck instanceof BlockBush) {
if (blockToCheck.canHarvestBlock(player, meta)) {
blockToCheck.harvestBlock(world, player, x + i, y, z + j, meta);
}
world.setBlock(x + i, y, z + j, Blocks.air);
used = true;
}
}
}
if (used) {
itemStack.damageItem(1, entityLiving);
}
return used;
}
}
| 4,879 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
ItemCanvasBag.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/items/ItemCanvasBag.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*
* @author Lumien
*/
package net.quetzi.bluepower.items;
import java.util.List;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemDye;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.quetzi.bluepower.BluePower;
import net.quetzi.bluepower.init.CustomTabs;
import net.quetzi.bluepower.references.GuiIDs;
import net.quetzi.bluepower.references.Refs;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemCanvasBag extends Item {
public ItemCanvasBag(String name) {
this.setCreativeTab(CustomTabs.tabBluePowerItems);
this.setUnlocalizedName(name);
this.setTextureName(Refs.MODID + ":" + name);
this.setHasSubtypes(true);
this.setMaxStackSize(1);
}
@Override
public ItemStack onItemRightClick(ItemStack itemstack, World worldObj, EntityPlayer playerEntity) {
if (!worldObj.isRemote) {
playerEntity.openGui(BluePower.instance, GuiIDs.CANVAS_BAG.ordinal(), worldObj, (int) playerEntity.posX, (int) playerEntity.posY,
(int) playerEntity.posZ);
}
return itemstack;
}
@Override
public String getUnlocalizedName(ItemStack par1ItemStack)
{
return super.getUnlocalizedName() + "." + ItemDye.field_150923_a[15-par1ItemStack.getItemDamage()];
}
@SideOnly(Side.CLIENT)
public int getColorFromItemStack(ItemStack par1ItemStack, int par2)
{
int damage = par1ItemStack.getItemDamage();
if (damage>=0 && damage < ItemDye.field_150922_c.length)
{
return ItemDye.field_150922_c[15-damage];
}
return 16777215;
}
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item p_150895_1_, CreativeTabs p_150895_2_, List p_150895_3_)
{
for (int i=0;i<ItemDye.field_150922_c.length;i++)
{
p_150895_3_.add(new ItemStack(this,1,i));
}
}
}
| 2,840 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
ItemGemAxe.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/items/ItemGemAxe.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.items;
import net.minecraft.item.ItemAxe;
import net.quetzi.bluepower.init.CustomTabs;
import net.quetzi.bluepower.references.Refs;
public class ItemGemAxe extends ItemAxe {
public ItemGemAxe(ToolMaterial material, String name) {
super(material);
this.setUnlocalizedName(name);
this.setCreativeTab(CustomTabs.tabBluePowerTools);
this.setTextureName(Refs.MODID + ":" + name);
}
}
| 1,179 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
ItemSaw.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/items/ItemSaw.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.items;
import net.minecraft.item.Item;
import net.quetzi.bluepower.init.CustomTabs;
import net.quetzi.bluepower.references.Refs;
public class ItemSaw extends Item {
private int sawLevel;
public ItemSaw(int sawLevel, String name) {
this.setCreativeTab(CustomTabs.tabBluePowerTools);
this.sawLevel = sawLevel;
this.setTextureName(Refs.MODID + ":" + name);
this.setUnlocalizedName(name);
this.maxStackSize = 1;
}
public int getSawLevel() {
return sawLevel;
}
}
| 1,288 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
ItemSeedBag.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/items/ItemSeedBag.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*
* @author Lumien
*/
package net.quetzi.bluepower.items;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.IPlantable;
import net.minecraftforge.common.util.ForgeDirection;
import net.quetzi.bluepower.BluePower;
import net.quetzi.bluepower.containers.inventorys.InventoryItem;
import net.quetzi.bluepower.init.CustomTabs;
import net.quetzi.bluepower.references.GuiIDs;
import net.quetzi.bluepower.references.Refs;
public class ItemSeedBag extends Item {
public ItemSeedBag(String name) {
this.setCreativeTab(CustomTabs.tabBluePowerItems);
this.setUnlocalizedName(name);
this.setTextureName(Refs.MODID + ":" + name);
}
public static ItemStack getSeedType(ItemStack seedBag)
{
ItemStack seed = null;
IInventory seedBagInventory = InventoryItem.getItemInventory(seedBag, "Seed Bag", 9);
seedBagInventory.openInventory();
for (int i = 0; i < seedBagInventory.getSizeInventory(); i++) {
ItemStack is = seedBagInventory.getStackInSlot(i);
if (is != null) {
seed = is;
}
}
return seed;
}
public double getDurabilityForDisplay(ItemStack stack) {
return 1D - (double) getItemDamageForDisplay(stack) / (double) 576;
}
public boolean showDurabilityBar(ItemStack stack) {
return stack.stackTagCompound!=null;
}
public int getItemDamageForDisplay(ItemStack stack) {
int items = 0;
IInventory seedBagInventory = InventoryItem.getItemInventory(stack, "Seed Bag", 9);
seedBagInventory.openInventory();
for (int i = 0; i < seedBagInventory.getSizeInventory(); i++) {
ItemStack is = seedBagInventory.getStackInSlot(i);
if (is != null) {
items += is.stackSize;
}
}
return items;
}
public int getMaxDamage(ItemStack stack) {
return 576;
}
@Override
public ItemStack onItemRightClick(ItemStack itemstack, World worldObj, EntityPlayer playerEntity) {
if (!worldObj.isRemote && playerEntity.isSneaking()) {
playerEntity.openGui(BluePower.instance, GuiIDs.SEEDBAG.ordinal(), worldObj, (int) playerEntity.posX, (int) playerEntity.posY,
(int) playerEntity.posZ);
}
return itemstack;
}
@Override
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int posX, int posY, int posZ, int par7,
float par8, float par9, float par10) {
if (par2EntityPlayer.isSneaking()) { return false; }
IInventory seedBagInventory = InventoryItem.getItemInventory(par2EntityPlayer,par2EntityPlayer.getCurrentEquippedItem(), "Seed Bag", 9);
seedBagInventory.openInventory();
ItemStack seed = getSeedType(par1ItemStack);
if (seed != null && seed.getItem() instanceof IPlantable) {
IPlantable plant = (IPlantable) seed.getItem();
for (int modX = -2; modX < 3; modX++) {
for (int modZ = -2; modZ < 3; modZ++) {
Block b = par3World.getBlock(posX + modX, posY, posZ + modZ);
if (b.canSustainPlant(par3World, posX, posY, posZ, ForgeDirection.UP, plant)
&& par3World.isAirBlock(posX + modX, posY + 1, posZ + modZ)) {
for (int i = 0; i < seedBagInventory.getSizeInventory(); i++) {
ItemStack is = seedBagInventory.getStackInSlot(i);
if (is != null) {
seedBagInventory.decrStackSize(i, 1);
par3World.setBlock(posX + modX, posY + 1, posZ + modZ, plant.getPlant(par3World, posX + modX, posY + 1, posZ + modZ),
plant.getPlantMetadata(par3World, posX + modX, posY + 1, modZ + modZ), 0x3);
break;
}
}
}
}
}
return true;
}
seedBagInventory.closeInventory();
return false;
}
}
| 5,239 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
ItemCrafting.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/items/ItemCrafting.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.items;
import net.quetzi.bluepower.init.CustomTabs;
import net.quetzi.bluepower.references.Refs;
public class ItemCrafting extends net.minecraft.item.Item {
public ItemCrafting(String name) {
this.setCreativeTab(CustomTabs.tabBluePowerItems);
this.setUnlocalizedName(name);
this.setTextureName(Refs.MODID + ":" + name);
}
}
| 1,114 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
ItemSiliconBoule.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/items/ItemSiliconBoule.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.items;
import net.minecraft.item.Item;
import net.quetzi.bluepower.references.Refs;
public class ItemSiliconBoule extends Item {
public ItemSiliconBoule(String name) {
this.setUnlocalizedName(name);
this.setTextureName(Refs.MODID + ":" + name);
}
}
| 1,032 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
ItemSiliconWafer.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/items/ItemSiliconWafer.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.items;
import net.minecraft.item.Item;
import net.quetzi.bluepower.references.Refs;
public class ItemSiliconWafer extends Item {
public ItemSiliconWafer(String name) {
this.setUnlocalizedName(name);
this.setTextureName(Refs.MODID + ":" + name);
}
}
| 1,032 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
ItemLimitedCrafting.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/items/ItemLimitedCrafting.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*
* @author Lumien
*/
package net.quetzi.bluepower.items;
import java.util.Random;
import net.minecraft.item.ItemStack;
import net.quetzi.bluepower.init.CustomTabs;
import net.quetzi.bluepower.references.Refs;
public class ItemLimitedCrafting extends net.minecraft.item.Item {
public ItemLimitedCrafting(String name, int uses) {
this.setCreativeTab(CustomTabs.tabBluePowerItems);
this.setUnlocalizedName(name);
this.setTextureName(Refs.MODID + ":" + name);
this.setMaxDamage(uses - 1);
this.setContainerItem(this);
}
public boolean doesContainerItemLeaveCraftingGrid(ItemStack par1ItemStack) {
return false;
}
public ItemStack getContainerItem(ItemStack itemStack) {
ItemStack container = itemStack.copy();
container.attemptDamageItem(1, new Random());
return container;
}
}
| 1,647 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
Dependencies.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/references/Dependencies.java | /*
* This file is part of Blue Power. Blue Power is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Blue Power is
* distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along
* with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.references;
public class Dependencies {
public static final String FMP = "ForgeMultipart";
public static final String COMPUTER_CRAFT = "ComputerCraft";
public static final String OPEN_COMPUTERS = "OpenComputers";
public static final String WAILA = "Waila";
}
| 992 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
Refs.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/references/Refs.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.references;
public class Refs {
public static final String NAME = "Blue Power";
public static final String MODID = "bluepower";
private static final String MAJOR = "@MAJOR@";
private static final String MINOR = "@MINOR@";
private static final String BUILD = "@BUILD_NUMBER@";
private static final String MCVERSION = "1.7.2";
public static final String MACHINE_TEXTURE_LOCATION = "machines/";
public static final String MODEL_LOCATION = "models/";
public static final String MODEL_TEXTURE_LOCATION = "textures/blocks/models/";
public static final double PACKET_UPDATE_DISTANCE = 64;
public static final String PROXY_LOCATION = "net.quetzi.bluepower";
public static final String MARBLE_NAME = "marble";
public static final String BASALT_NAME = "basalt";
public static final String BASALTCOBBLE_NAME = "basalt_cobble";
public static final String BASALTBRICK_NAME = "basalt_brick";
public static final String MARBLEBRICK_NAME = "marble_brick";
public static final String CRACKED_BASALT = "cracked_basalt_lava";
public static final String ALLOYFURNACE_NAME = "alloyfurnace";
public static final String AMETHYSTORE_NAME = "amethyst_ore";
public static final String RUBYORE_NAME = "ruby_ore";
public static final String SAPPHIREORE_NAME = "sapphire_ore";
public static final String NIKOLITEORE_NAME = "nikolite_ore";
public static final String AMETHYSTBLOCK_NAME = "amethyst_block";
public static final String SAPPHIREBLOCK_NAME = "sapphire_block";
public static final String RUBYBLOCK_NAME = "ruby_block";
public static final String NIKOLITEBLOCK_NAME = "nikolite_block";
public static final String AMETHYST_NAME = "amethyst_gem";
public static final String SAPPHIRE_NAME = "sapphire_gem";
public static final String RUBY_NAME = "ruby_gem";
public static final String NIKOLITE_NAME = "nikolite_dust";
public static final String COPPERORE_NAME = "copper_ore";
public static final String SILVERORE_NAME = "silver_ore";
public static final String TINORE_NAME = "tin_ore";
public static final String TUNGSTENORE_NAME = "tungsten_ore";
public static final String COPPERBLOCK_NAME = "copper_block";
public static final String SILVERBLOCK_NAME = "silver_block";
public static final String TINBLOCK_NAME = "tin_block";
public static final String TUNGSTENBLOCK_NAME = "tungsten_block";
public static final String COPPERINGOT_NAME = "copper_ingot";
public static final String SILVERINGOT_NAME = "silver_ingot";
public static final String TININGOT_NAME = "tin_ingot";
public static final String TUNGSTENINGOT_NAME = "tungsten_ingot";
public static final String AMETHYSTSAW_NAME = "amethyst_saw";
public static final String SAPPHIRESAW_NAME = "sapphire_saw";
public static final String RUBYSAW_NAME = "ruby_saw";
public static final String DIAMONDSAW_NAME = "diamond_saw";
public static final String IRONSAW_NAME = "iron_saw";
public static final String SILICONBOULE_NAME = "silicon_boule";
public static final String SILICONWAFER_NAME = "silicon_wafer";
public static final String BLUEDOPEDWAFER_NAME = "blue_doped_wafer";
public static final String REDDOPEDWAFER_NAME = "red_doped_wafer";
public static final String BLOCKBREAKER_NAME = "block_breaker";
public static final String SORTING_MACHINE_NAME = "sorting_machine";
public static final String TRANSPOSER_NAME = "transposer";
public static final String EJECTOR_NAME = "ejector";
public static final String RELAY_NAME = "relay";
public static final String ENGINE_NAME = "engine";
public static final String KINETICGENERATOR_NAME = "kinetic_generator";
public static final String WINDMILL_NAME = "windmill";
public static final String BRASSINGOT_NAME = "brass_ingot";
public static final String BLUEALLOYINGOT_NAME = "blue_alloy_ingot";
public static final String REDALLOYINGOT_NAME = "red_alloy_ingot";
public static final String TINPLATE_NAME = "tinplate";
public static final String RUBYAXE_NAME = "ruby_axe";
public static final String RUBYSWORD_NAME = "ruby_sword";
public static final String RUBYPICKAXE_NAME = "ruby_pickaxe";
public static final String RUBYSPADE_NAME = "ruby_shovel";
public static final String RUBYHOE_NAME = "ruby_hoe";
public static final String RUBYSICKLE_NAME = "ruby_sickle";
public static final String SAPPHIREAXE_NAME = "sapphire_axe";
public static final String SAPPHIRESWORD_NAME = "sapphire_sword";
public static final String SAPPHIREPICKAXE_NAME = "sapphire_pickaxe";
public static final String SAPPHIRESPADE_NAME = "sapphire_shovel";
public static final String SAPPHIREHOE_NAME = "sapphire_hoe";
public static final String SAPPHIRESICKLE_NAME = "sapphire_sickle";
public static final String AMETHYSTAXE_NAME = "amethyst_axe";
public static final String AMETHYSTSWORD_NAME = "amethyst_sword";
public static final String AMETHYSTPICKAXE_NAME = "amethyst_pickaxe";
public static final String AMETHYSTSPADE_NAME = "amethyst_shovel";
public static final String AMETHYSTHOE_NAME = "amethyst_hoe";
public static final String AMETHYSTSICKLE_NAME = "amethyst_sickle";
public static final String FLAXSEED_NAME = "flax_seeds";
public static final String FLAXCROP_NAME = "flax_crop";
public static final String INDIGOFLOWER_NAME = "indigo_flower";
public static final String INDIGODYE_NAME = "indigo_dye";
public static final String WOODSICKLE_NAME = "wood_sickle";
public static final String STONESICKLE_NAME = "stone_sickle";
public static final String IRONSICKLE_NAME = "iron_sickle";
public static final String GOLDSICKLE_NAME = "gold_sickle";
public static final String DIAMONDSICKLE_NAME = "diamond_sickle";
public static final String SCREWDRIVER_NAME = "screwdriver";
public static final String MULTIPART_NAME = "bluepower_multipart";
public static final String CRACKEDBASALTBRICK_NAME = "basaltbrick_cracked";
public static final String SMALLBASALTBRICK_NAME = "basalt_brick_small";
public static final String SMALLMARBLEBRICK_NAME = "marble_brick_small";
public static final String CHISELEDBASALTBRICK_NAME = "fancy_basalt";
public static final String CHISELEDMARBLEBRICK_NAME = "fancy_marble";
public static final String MARBLETILE_NAME = "marble_tile";
public static final String BASALTTILE_NAME = "basalt_tile";
public static final String MARBLEPAVER_NAME = "marble_paver";
public static final String BASALTPAVER_NAME = "basalt_paver";
public static final String LAMP_WHITE = "lamp_white";
public static final String INVERTEDLAMP_WHITE = "invertedlamp_white";
public static final String LAMP_ORANGE = "lamp_orange";
public static final String INVERTEDLAMP_ORANGE = "invertedlamp_orange";
public static final String LAMP_MAGENTA = "lamp_magenta";
public static final String INVERTEDLAMP_MAGENTA = "invertedlamp_magenta";
public static final String LAMP_LIGHTBLUE = "lamp_lightblue";
public static final String INVERTEDLAMP_LIGHTBLUE = "invertedlamp_lightblue";
public static final String LAMP_YELLOW = "lamp_yellow";
public static final String INVERTEDLAMP_YELLOW = "invertedlamp_yellow";
public static final String LAMP_LIME = "lamp_lime";
public static final String INVERTEDLAMP_LIME = "invertedlamp_lime";
public static final String LAMP_PINK = "lamp_pink";
public static final String INVERTEDLAMP_PINK = "invertedlamp_pink";
public static final String LAMP_GRAY = "lamp_gray";
public static final String INVERTEDLAMP_GRAY = "invertedlamp_gray";
public static final String LAMP_LIGHTGRAY = "lamp_lightgray";
public static final String INVERTEDLAMP_LIGHTGRAY = "invertedlamp_lightgray";
public static final String LAMP_CYAN = "lamp_cyan";
public static final String INVERTEDLAMP_CYAN = "invertedlamp_cyan";
public static final String LAMP_PURPLE = "lamp_purple";
public static final String INVERTEDLAMP_PURPLE = "invertedlamp_purple";
public static final String LAMP_BLUE = "lamp_blue";
public static final String INVERTEDLAMP_BLUE = "invertedlamp_blue";
public static final String LAMP_BROWN = "lamp_brown";
public static final String INVERTEDLAMP_BROWN = "invertedlamp_brown";
public static final String LAMP_GREEN = "lamp_green";
public static final String INVERTEDLAMP_GREEN = "invertedlamp_green";
public static final String LAMP_RED = "lamp_red";
public static final String INVERTEDLAMP_RED = "invertedlamp_red";
public static final String LAMP_BLACK = "lamp_black";
public static final String INVERTEDLAMP_BLACK = "invertedlamp_black";
public static final String ATHAME_NAME = "athame";
public static final String BLOCKIGNITER_NAME = "igniter";
public static final String STONEWAFER_NAME = "stone_wafer";
public static final String STONEWIRE_NAME = "stone_wire";
public static final String STONEANODE_NAME = "stone_anode";
public static final String STONECATHODE_NAME = "stone_cathode";
public static final String STONEPOINTER_NAME = "stone_pointer";
public static final String SILICONCHIP_NAME = "silicon_chip";
public static final String TAINTEDSILICONCHIP_NAME = "taintedsilicon_chip";
public static final String STONEREDWIRE_NAME = "stone_redwire";
public static final String PLATEASSEMBLY_NAME = "plate_assembly";
public static final String STONEBUNDLE_NAME = "stone_bundle";
public static final String SCREWDRIVERHANDLE_NAME = "screwdriver_handle";
public static final String BLOCKBUFFER_NAME = "buffer";
public static final String BLOCKDEPLOYER_NAME = "deployer";
public static final String BLOCKSORTRON_NAME = "sortron";
public static final String SEEDBAG_NAME = "seed_bag";
public static final String CANVASBAG_NAME = "canvas_bag";
public static final String CANVAS_NAME = "canvas";
public static final String LUMAR_NAME = "lumar";
public static final String COPPERWIRE_NAME = "copper_wire";
public static final String IRONWIRE_NAME = "iron_wire";
public static final String WOOLCARD_NAME = "wool_card";
public static final String DIAMONDDRAWPLATE_NAME = "diamond_drawplate";
public static final String PROJECTTABLE_NAME = "project_table";
public static final String BLOCKCPU_NAME = "cpu";
public static final String BLOCKMONITOR_NAME = "monitor";
public static final String BLOCKDISKDRIVE_NAME = "disk_drive";
public static final String BLOCKIOEXPANDER_NAME = "io_expander";
public static final String FLOPPY_DISK = "floppy_disk";
public static final String[] oreDictDyes = new String[] { "dyeBlack", "dyeRed", "dyeGreen", "dyeBrown", "dyeBlue", "dyePurple", "dyeCyan", "dyeLightGray", "dyeGray", "dyePink",
"dyeLime", "dyeYellow", "dyeLightBlue", "dyeMagenta", "dyeOrange", "dyeWhite" };
public static final String LAMP_NAME = "lamp";
public static String fullVersionString() {
return String.format("%s-%s.%s.%s", MCVERSION, MAJOR, MINOR, BUILD);
}
}
| 13,669 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
GuiIDs.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/references/GuiIDs.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.references;
public enum GuiIDs {
INVALID,
ALLOY_FURNACE,
BUFFER,
SORTING_MACHINE,
SEEDBAG,
CANVAS_BAG,
CPU,
MONITOR,
DISK_DRIVE,
IO_EXPANDER,
REDBUS_ID,
KINETICGENERATOR_ID,
DEPLOYER_ID,
RELAY_ID,
EJECTOR_ID;
}
| 1,027 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
RenderWindmill.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/client/renderers/RenderWindmill.java | package net.quetzi.bluepower.client.renderers;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.AdvancedModelLoader;
import net.minecraftforge.client.model.IModelCustom;
import net.quetzi.bluepower.references.Refs;
import net.quetzi.bluepower.tileentities.tier1.TileWindmill;
public class RenderWindmill extends TileEntitySpecialRenderer {
private ResourceLocation modelLocation = new ResourceLocation(Refs.MODID + ":" + Refs.MODEL_LOCATION + "windmill.obj");
private ResourceLocation textureLocation = new ResourceLocation(Refs.MODID + ":" + Refs.MODEL_TEXTURE_LOCATION + "windmill.png");
IModelCustom model;
public RenderWindmill(){
model = AdvancedModelLoader.loadModel(modelLocation);
}
@Override
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float var8) {
TileWindmill mill = (TileWindmill)tile.getWorldObj().getTileEntity(tile.xCoord, tile.yCoord, tile.zCoord);
GL11.glPushMatrix();
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glTranslated(x + .5, y, z + .5);
GL11.glScaled(.15, .15, .15);
this.bindTexture(textureLocation);
GL11.glRotated(mill.turbineTick, 0, 1, 0);
model.renderAll();
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glPopMatrix();
}
}
| 1,408 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
IconSupplier.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/client/renderers/IconSupplier.java | package net.quetzi.bluepower.client.renderers;
import net.minecraft.util.IIcon;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.quetzi.bluepower.references.Refs;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
public class IconSupplier {
public static IIcon pneumaticTubeSide;
public static IIcon pneumaticTubeNode;
public static IIcon pneumaticTubeColorNode;
public static IIcon pneumaticTubeColorSide;
public static IIcon cagedLampFootSide;
public static IIcon cagedLampFootTop;
public static IIcon cagedLampCageSide;
public static IIcon cagedLampCageTop;
public static IIcon cagedLampLampActive;
public static IIcon cagedLampLampInactive;
public static IIcon cagedLampLampActiveTop;
public static IIcon cagedLampLampInactiveTop;
public static IIcon fixtureFootSide;
public static IIcon fixtureFootTop;
public static IIcon fixtureLampSideOn;
public static IIcon fixtureLampTopOn;
public static IIcon fixtureLampSideOff;
public static IIcon fixtureLampTopOff;
public static IIcon lampOn;
public static IIcon lampOff;
@SubscribeEvent
public void onTextureStitch(TextureStitchEvent.Pre event) {
if (event.map.getTextureType() == 0) {
pneumaticTubeSide = event.map.registerIcon(Refs.MODID + ":tubes/pneumatic_tube_side");
pneumaticTubeNode = event.map.registerIcon(Refs.MODID + ":tubes/tube_end");
pneumaticTubeColorSide = event.map.registerIcon(Refs.MODID + ":tubes/tube_color_side");
pneumaticTubeColorNode = event.map.registerIcon(Refs.MODID + ":tubes/tube_color_end");
cagedLampFootSide = event.map.registerIcon(Refs.MODID + ":lamps/cage_foot_side");
cagedLampFootTop = event.map.registerIcon(Refs.MODID + ":lamps/cage_foot_top");
cagedLampCageSide = event.map.registerIcon(Refs.MODID + ":lamps/cage");
cagedLampCageTop = event.map.registerIcon(Refs.MODID + ":lamps/cage_top");
cagedLampLampActive = event.map.registerIcon(Refs.MODID + ":lamps/cage_lamp_on");
cagedLampLampInactive = event.map.registerIcon(Refs.MODID + ":lamps/cage_lamp_off");
cagedLampLampActiveTop = event.map.registerIcon(Refs.MODID + ":lamps/cage_lamp_on_top");
cagedLampLampInactiveTop = event.map.registerIcon(Refs.MODID + ":lamps/cage_lamp_off_top");
fixtureFootSide = event.map.registerIcon(Refs.MODID + ":lamps/fixture_foot_side");
fixtureFootTop = event.map.registerIcon(Refs.MODID + ":lamps/fixture_foot_top");
fixtureLampSideOn = event.map.registerIcon(Refs.MODID + ":lamps/fixture_lamp_on");
fixtureLampTopOn = event.map.registerIcon(Refs.MODID + ":lamps/fixture_lamp_on_top");
fixtureLampSideOff = event.map.registerIcon(Refs.MODID + ":lamps/fixture_lamp_off");
fixtureLampTopOff = event.map.registerIcon(Refs.MODID + ":lamps/fixture_lamp_off_top");
lampOn = event.map.registerIcon(Refs.MODID + ":lamps/lamp_off");
lampOff = event.map.registerIcon(Refs.MODID + ":lamps/lamp_on");
}
}
}
| 3,243 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
RenderItemBPPart.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/client/renderers/RenderItemBPPart.java | /*
* This file is part of Blue Power. Blue Power is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Blue Power is
* distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along
* with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.client.renderers;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.IItemRenderer;
import net.quetzi.bluepower.api.part.BPPart;
import net.quetzi.bluepower.api.part.PartRegistry;
import org.lwjgl.opengl.GL11;
public class RenderItemBPPart implements IItemRenderer {
private List<BPPart> parts = new ArrayList<BPPart>();
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
return true;
}
@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
return true;
}
@SuppressWarnings("incomplete-switch")
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
BPPart part = null;
try {
for (BPPart p : parts)
if (p.getType().equals(PartRegistry.getPartIdFromItem(item))) {
part = p;
break;
}
if (part == null) {
part = PartRegistry.createPartFromItem(item);
if (part != null) parts.add(part);
}
} catch (Exception ex) {
}
if (part == null) {
part = PartRegistry.createPart(PartRegistry.ICON_PART);
}
GL11.glPushMatrix();
{
switch (type) {
case ENTITY:
GL11.glScaled(0.5, 0.5, 0.5);
GL11.glTranslated(-0.5, 0, -0.5);
if(item.getItemFrame() != null)
GL11.glTranslated(0, -0.25, 0);
break;
case EQUIPPED:
break;
case EQUIPPED_FIRST_PERSON:
break;
case INVENTORY:
GL11.glTranslated(0, -0.1, 0);
break;
}
part.renderItem(type, item, data);
}
GL11.glPopMatrix();
}
}
| 2,758 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
RendererBlockBase.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/client/renderers/RendererBlockBase.java | package net.quetzi.bluepower.client.renderers;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import cpw.mods.fml.client.registry.RenderingRegistry;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.init.Blocks;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
public class RendererBlockBase implements ISimpleBlockRenderingHandler {
public static final int RENDER_ID = RenderingRegistry.getNextAvailableRenderId();
public static final Block FAKE_RENDER_BLOCK = new Block(Material.rock) {
@Override
public IIcon getIcon(int meta, int side) {
return currentBlockToRender.getIcon(meta, side);
}
};
public static Block currentBlockToRender = Blocks.stone;
@Override
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {
currentBlockToRender = block;
renderer.renderBlockAsItem(FAKE_RENDER_BLOCK, 1, 1.0F);
}
/*
UV Deobfurscation derp:
West = South
East = North
North = East
South = West
*/
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
int meta = world.getBlockMetadata(x, y, z);
switch (meta)
{
case 0:
renderer.uvRotateSouth = 3;
renderer.uvRotateNorth = 3;
renderer.uvRotateEast = 3;
renderer.uvRotateWest = 3;
break;
case 2:
renderer.uvRotateSouth = 1;
renderer.uvRotateNorth = 2;
break;
case 3:
renderer.uvRotateSouth = 2;
renderer.uvRotateNorth = 1;
renderer.uvRotateTop = 3;
renderer.uvRotateBottom = 3;
break;
case 4:
renderer.uvRotateEast = 1;
renderer.uvRotateWest = 2;
renderer.uvRotateTop = 2;
renderer.uvRotateBottom = 1;
break;
case 5:
renderer.uvRotateEast = 2;
renderer.uvRotateWest = 1;
renderer.uvRotateTop = 1;
renderer.uvRotateBottom = 2;
break;
}
boolean ret = renderer.renderStandardBlock(block, x, y, z);
renderer.uvRotateSouth = 0;
renderer.uvRotateEast = 0;
renderer.uvRotateWest = 0;
renderer.uvRotateNorth = 0;
renderer.uvRotateTop = 0;
renderer.uvRotateBottom = 0;
return ret;
}
@Override
public boolean shouldRender3DInInventory(int modelId) {
return true;
}
@Override
public int getRenderId() {
return RENDER_ID;
}
}
| 2,932 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
RenderEngine.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/client/renderers/RenderEngine.java | package net.quetzi.bluepower.client.renderers;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.AdvancedModelLoader;
import net.minecraftforge.client.model.IModelCustom;
import net.minecraftforge.common.util.ForgeDirection;
import net.quetzi.bluepower.references.Refs;
import net.quetzi.bluepower.tileentities.tier1.TileEngine;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/**
*
* @author TheFjong
*
*/
@SideOnly(Side.CLIENT)
public class RenderEngine extends TileEntitySpecialRenderer {
private ResourceLocation modelLocation = new ResourceLocation(Refs.MODID + ":" + Refs.MODEL_LOCATION + "engine.obj");
private ResourceLocation textureLocationOff = new ResourceLocation(Refs.MODID + ":" + Refs.MODEL_TEXTURE_LOCATION + "engineoff.png");
private ResourceLocation textureLocationOn = new ResourceLocation(Refs.MODID + ":" + Refs.MODEL_TEXTURE_LOCATION + "engineon.png");
IModelCustom engineModel;
float rotateAmount = 0F;
public RenderEngine() {
engineModel = AdvancedModelLoader.loadModel(modelLocation);
}
@SuppressWarnings("cast")
@Override
public void renderTileEntityAt(TileEntity engine, double x, double y, double z, float f) {
if (engine instanceof TileEngine) {
GL11.glPushMatrix();
GL11.glDisable(GL11.GL_LIGHTING);
TileEngine tile = (TileEngine) engine.getWorldObj().getTileEntity(engine.xCoord, engine.yCoord, engine.zCoord);
ForgeDirection direction = tile.getOrientation();
GL11.glTranslated(x, y, z);
GL11.glScaled(.0315, .0315, .0315);
if (direction == ForgeDirection.UP) {
GL11.glTranslated(16, 28, 16);
GL11.glRotatef(180, 1, 0, 0);
}
if (direction == ForgeDirection.DOWN) {
GL11.glTranslated(16, 4, 16);
GL11.glRotatef(0, 0, 0, 0);
}
if (direction == ForgeDirection.EAST) {
GL11.glTranslated(28, 16, 16);
GL11.glRotatef(90, 0, 0, 1);
}
if (direction == ForgeDirection.WEST) {
GL11.glTranslated(4, 16, 16);
GL11.glRotatef(90, 0, 0, -1);
}
if (direction == ForgeDirection.NORTH) {
GL11.glTranslated(16, 16, 4);
GL11.glRotatef(90, 1, 0, 0);
}
if (direction == ForgeDirection.SOUTH) {
GL11.glTranslated(16, 16, 28);
GL11.glRotatef(90, -1, 0, 0);
}
if (tile.isActive) {
bindTexture(textureLocationOn);
} else {
bindTexture(textureLocationOff);
}
engineModel.renderAllExcept("gear", "glider");
if (tile.isActive) {
f += tile.pumpTick;
if (tile.pumpSpeed > 0) {
f /= tile.pumpSpeed;
}
} else {
f = 0;
}
f = (float) ((float) 6 * (.5 - .5 * Math.cos(3.1415926535897931D * (double) f)));
GL11.glTranslatef(0, f, 0);
engineModel.renderPart("glider");
GL11.glTranslatef(0, -f, 0);
if (tile.isActive) {
if (tile.getWorldObj().isRemote) {
rotateAmount++;
GL11.glRotated(tile.gearTick * 19, 0, 1.5707963267948966D * (double) f, 0);
}
}
engineModel.renderPart("gear");
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glPopMatrix();
}
}
}
| 4,043 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
Renderers.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/client/renderers/Renderers.java | /*
* This file is part of Blue Power. Blue Power is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Blue Power is
* distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along
* with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.client.renderers;
import net.minecraft.item.Item;
import net.minecraftforge.client.MinecraftForgeClient;
import net.quetzi.bluepower.init.BPBlocks;
import net.quetzi.bluepower.init.BPItems;
import net.quetzi.bluepower.tileentities.tier1.TileEngine;
import net.quetzi.bluepower.tileentities.tier1.TileLamp;
import net.quetzi.bluepower.tileentities.tier1.TileWindmill;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry;
public class Renderers {
public static int RenderIdLamps;
public static void init() {
MinecraftForgeClient.registerItemRenderer(BPItems.multipart, new RenderItemBPPart());
RenderingRegistry.registerBlockHandler(new RendererBlockBase());
RenderingRegistry.registerBlockHandler(new RenderLamp());
ClientRegistry.bindTileEntitySpecialRenderer(TileEngine.class, new RenderEngine());
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BPBlocks.engine), new RenderItemEngine());
ClientRegistry.bindTileEntitySpecialRenderer(TileWindmill.class, new RenderWindmill());
ClientRegistry.bindTileEntitySpecialRenderer(TileLamp.class, new RenderLamp());
}
}
| 1,939 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
RenderHelper.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/client/renderers/RenderHelper.java | package net.quetzi.bluepower.client.renderers;
import java.nio.DoubleBuffer;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.init.Blocks;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.util.ForgeDirection;
import net.quetzi.bluepower.api.vec.Vector3Cube;
import net.quetzi.bluepower.part.gate.GateBase;
import net.quetzi.bluepower.references.Refs;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL11;
public class RenderHelper {
/**
* Adds a vertex. Just a wrapper function for openGL
*
* @author Koen Beckers (K4Unl)
* @param x
* @param y
* @param z
*/
public static void addVertex(double x, double y, double z) {
GL11.glVertex3d(x, y, z);
}
/**
* Adds a vertex with a texture.
*
* @author Koen Beckers (K4Unl)
* @param x
* @param y
* @param z
* @param tx
* @param ty
*/
public static void addVertexWithTexture(double x, double y, double z, double tx, double ty) {
GL11.glTexCoord2d(tx, ty);
GL11.glVertex3d(x, y, z);
}
private static RenderBlocks rb = new RenderBlocks();
/**
* @author amadornes
* @param x
* @param y
* @param z
* @param height
* @param state
*/
public static void renderRedstoneTorch(double x, double y, double z, double height, boolean state) {
Block b = null;
if (state) b = Blocks.redstone_torch;
else b = Blocks.unlit_redstone_torch;
GL11.glTranslated(x, y, z);
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
GL11.glEnable(GL11.GL_CLIP_PLANE0);
GL11.glClipPlane(GL11.GL_CLIP_PLANE0, planeEquation(0, 0, 0, 0, 0, 1, 1, 0, 1));
Tessellator t = Tessellator.instance;
t.startDrawingQuads();
t.setColorOpaque_F(1.0F, 1.0F, 1.0F);
rb.renderTorchAtAngle(b, 0, y + height - 1, 0, 0, 0, 0);
t.draw();
GL11.glDisable(GL11.GL_CLIP_PLANE0);
GL11.glTranslated(-x, -y, -z);
}
/**
* @author amadornes
* @param gate
* @param x
* @param y
* @param z
* @param state
*/
public static void renderRandomizerButton(GateBase gate, double x, double y, double z, boolean state) {
String res = Refs.MODID + ":textures/blocks/gates/randomizer/button_" + (state ? "on" : "off") + ".png";
String resSide = Refs.MODID + ":textures/blocks/gates/randomizer/button_side.png";
GL11.glPushMatrix();
{
GL11.glTranslated(x, y, z);
GL11.glPushMatrix();
{
GL11.glTranslated(6 / 16D, 2 / 16D, 4 / 16D);
Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation(resSide));
for (int i = 0; i < 4; i++) {
GL11.glTranslated(2 / 16D, 0, 2 / 16D);
GL11.glRotated(90, 0, 1, 0);
GL11.glTranslated(-2 / 16D, 0, -2 / 16D);
GL11.glBegin(GL11.GL_QUADS);
{
GL11.glNormal3d(1, 0, 0);
addVertexWithTexture(0, 0, 0, 0, 0);
addVertexWithTexture(0, 1 / 16D, 0, 0, 1);
addVertexWithTexture(4 / 16D, 1 / 16D, 0, 1, 1);
addVertexWithTexture(4 / 16D, 0, 0, 1, 0);
}
GL11.glEnd();
}
}
GL11.glPopMatrix();
GL11.glTranslated(0, 1 / 16D, 0);
gate.renderTopTexture(res);
}
GL11.glPopMatrix();
}
/**
* @author amadornes
* @param x
* @param y
* @param z
* @param angle
*/
public static void renderPointer(double x, double y, double z, double angle) {
GL11.glPushMatrix();
{
GL11.glTranslated(x, y, z);
GL11.glTranslated(0.5, 0.5, 0.5);
GL11.glRotated(360 * angle, 0, 1, 0);
GL11.glTranslated(-0.5, -0.5, -0.5);
Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation("minecraft:textures/blocks/stone.png"));
GL11.glBegin(GL11.GL_QUADS);
{
GL11.glNormal3d(0, -1, 0);
// Bottom
addVertexWithTexture(0.5, 0, 1D / 16D, 0.5, 1D / 16D);
addVertexWithTexture(0.5 + 1D / 8D, 0, 0.5, 0.5 + 1D / 8D, 0.5);
addVertexWithTexture(0.5, 0, 0.5 + 1D / 8D, 0.5, 0.5 + 1D / 8D);
addVertexWithTexture(0.5 - 1D / 8D, 0, 0.5, 0.5 - 1D / 8D, 0.5);
GL11.glNormal3d(0, 1, 0);
// Top
addVertexWithTexture(0.5, 1D / 16D, 1D / 16D, 0.5, 1D / 16D);
addVertexWithTexture(0.5 - 1D / 8D, 1D / 16D, 0.5, 0.5 - 1D / 8D, 0.5);
addVertexWithTexture(0.5, 1D / 16D, 0.5 + 1D / 8D, 0.5, 0.5 + 1D / 8D);
addVertexWithTexture(0.5 + 1D / 8D, 1D / 16D, 0.5, 0.5 + 1D / 8D, 0.5);
GL11.glNormal3d(1, 0, 0);
// Side 1
addVertexWithTexture(0.5, 1D / 16D, 1D / 16D, 0.5, 1D / 16D);
addVertexWithTexture(0.5, 0, 1D / 16D, 0.5, 1D / 16D);
addVertexWithTexture(0.5 - 1D / 8D, 0, 0.5, 0.5 - 1D / 8D, 0.5);
addVertexWithTexture(0.5 - 1D / 8D, 1D / 16D, 0.5, 0.5 - 1D / 8D, 0.5);
// Side 2
addVertexWithTexture(0.5 - 1D / 8D, 1D / 16D, 0.5, 0.5 - 1D / 8D, 0.5);
addVertexWithTexture(0.5 - 1D / 8D, 0, 0.5, 0.5 - 1D / 8D, 0.5);
addVertexWithTexture(0.5, 0, 0.5 + 1D / 8D, 0.5, 0.5 + 1D / 8D);
addVertexWithTexture(0.5, 1D / 16D, 0.5 + 1D / 8D, 0.5, 0.5 + 1D / 8D);
GL11.glNormal3d(-1, 0, 0);
// Side 3
addVertexWithTexture(0.5, 1D / 16D, 0.5 + 1D / 8D, 0.5, 0.5 + 1D / 8D);
addVertexWithTexture(0.5, 0, 0.5 + 1D / 8D, 0.5, 0.5 + 1D / 8D);
addVertexWithTexture(0.5 + 1D / 8D, 0, 0.5, 0.5 + 1D / 8D, 0.5);
addVertexWithTexture(0.5 + 1D / 8D, 1D / 16D, 0.5, 0.5 + 1D / 8D, 0.5);
// Side 4
addVertexWithTexture(0.5 + 1D / 8D, 1D / 16D, 0.5, 0.5 + 1D / 8D, 0.5);
addVertexWithTexture(0.5 + 1D / 8D, 0, 0.5, 0.5 + 1D / 8D, 0.5);
addVertexWithTexture(0.5, 0, 1D / 16D, 0.5, 1D / 16D);
addVertexWithTexture(0.5, 1D / 16D, 1D / 16D, 0.5, 1D / 16D);
}
GL11.glEnd();
}
GL11.glPopMatrix();
}
/**
* @author amadornes
* @param x1
* @param y1
* @param z1
* @param x2
* @param y2
* @param z2
* @param x3
* @param y3
* @param z3
* @return TODO: Maybe move this function?
*/
public static DoubleBuffer planeEquation(double x1, double y1, double z1, double x2, double y2, double z2, double x3, double y3, double z3) {
double[] eq = new double[4];
eq[0] = y1 * (z2 - z3) + y2 * (z3 - z1) + y3 * (z1 - z2);
eq[1] = z1 * (x2 - x3) + z2 * (x3 - x1) + z3 * (x1 - x2);
eq[2] = x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2);
eq[3] = -(x1 * (y2 * z3 - y3 * z2) + x2 * (y3 * z1 - y1 * z3) + x3 * (y1 * z2 - y2 * z1));
DoubleBuffer b = BufferUtils.createDoubleBuffer(8).put(eq);
b.flip();
return b;
}
/**
* Draws a colored cube with the size of vector. Every face has a different color This uses OpenGL
*
* @author Koen Beckers (K4Unl)
* @param vector
*/
public static void drawColoredCube(Vector3Cube vector) {
// Top side
GL11.glColor3f(1.0F, 0.0F, 0.0F);
GL11.glNormal3d(0, 1, 0);
addVertex(vector.getMinX(), vector.getMaxY(), vector.getMaxZ());
addVertex(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ());
addVertex(vector.getMaxX(), vector.getMaxY(), vector.getMinZ());
addVertex(vector.getMinX(), vector.getMaxY(), vector.getMinZ());
// Bottom side
GL11.glColor3f(1.0F, 1.0F, 0.0F);
GL11.glNormal3d(0, -1, 0);
addVertex(vector.getMaxX(), vector.getMinY(), vector.getMaxZ());
addVertex(vector.getMinX(), vector.getMinY(), vector.getMaxZ());
addVertex(vector.getMinX(), vector.getMinY(), vector.getMinZ());
addVertex(vector.getMaxX(), vector.getMinY(), vector.getMinZ());
// Draw west side:
GL11.glColor3f(0.0F, 1.0F, 0.0F);
GL11.glNormal3d(-1, 0, 0);
addVertex(vector.getMinX(), vector.getMinY(), vector.getMaxZ());
addVertex(vector.getMinX(), vector.getMaxY(), vector.getMaxZ());
addVertex(vector.getMinX(), vector.getMaxY(), vector.getMinZ());
addVertex(vector.getMinX(), vector.getMinY(), vector.getMinZ());
// Draw east side:
GL11.glColor3f(0.0F, 1.0F, 1.0F);
GL11.glNormal3d(1, 0, 0);
addVertex(vector.getMaxX(), vector.getMinY(), vector.getMinZ());
addVertex(vector.getMaxX(), vector.getMaxY(), vector.getMinZ());
addVertex(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ());
addVertex(vector.getMaxX(), vector.getMinY(), vector.getMaxZ());
// Draw north side
GL11.glColor3f(0.0F, 0.0F, 1.0F);
GL11.glNormal3d(0, 0, -1);
addVertex(vector.getMinX(), vector.getMinY(), vector.getMinZ());
addVertex(vector.getMinX(), vector.getMaxY(), vector.getMinZ());
addVertex(vector.getMaxX(), vector.getMaxY(), vector.getMinZ());
addVertex(vector.getMaxX(), vector.getMinY(), vector.getMinZ());
// Draw south side
GL11.glColor3f(0.0F, 0.0F, 0.0F);
GL11.glNormal3d(0, 0, 1);
addVertex(vector.getMinX(), vector.getMinY(), vector.getMaxZ());
addVertex(vector.getMaxX(), vector.getMinY(), vector.getMaxZ());
addVertex(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ());
addVertex(vector.getMinX(), vector.getMaxY(), vector.getMaxZ());
}
/**
* Draws a colored cube with the size of vector. All faces have the specified color. This uses OpenGL
*
* @author Koen Beckers (K4Unl) and Amadornes
* @param vector
* @param color
*/
public static void drawColoredCube(Vector3Cube vector, double r, double g, double b, double a) {
GL11.glColor4d(r, g, b, a);
// Top side
GL11.glNormal3d(0, 1, 0);
addVertex(vector.getMinX(), vector.getMaxY(), vector.getMaxZ());
addVertex(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ());
addVertex(vector.getMaxX(), vector.getMaxY(), vector.getMinZ());
addVertex(vector.getMinX(), vector.getMaxY(), vector.getMinZ());
// Bottom side
GL11.glNormal3d(0, -1, 0);
addVertex(vector.getMaxX(), vector.getMinY(), vector.getMaxZ());
addVertex(vector.getMinX(), vector.getMinY(), vector.getMaxZ());
addVertex(vector.getMinX(), vector.getMinY(), vector.getMinZ());
addVertex(vector.getMaxX(), vector.getMinY(), vector.getMinZ());
// Draw west side:
GL11.glNormal3d(-1, 0, 0);
addVertex(vector.getMinX(), vector.getMinY(), vector.getMaxZ());
addVertex(vector.getMinX(), vector.getMaxY(), vector.getMaxZ());
addVertex(vector.getMinX(), vector.getMaxY(), vector.getMinZ());
addVertex(vector.getMinX(), vector.getMinY(), vector.getMinZ());
// Draw east side:
GL11.glNormal3d(1, 0, 0);
addVertex(vector.getMaxX(), vector.getMinY(), vector.getMinZ());
addVertex(vector.getMaxX(), vector.getMaxY(), vector.getMinZ());
addVertex(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ());
addVertex(vector.getMaxX(), vector.getMinY(), vector.getMaxZ());
// Draw north side
GL11.glNormal3d(0, 0, -1);
addVertex(vector.getMinX(), vector.getMinY(), vector.getMinZ());
addVertex(vector.getMinX(), vector.getMaxY(), vector.getMinZ());
addVertex(vector.getMaxX(), vector.getMaxY(), vector.getMinZ());
addVertex(vector.getMaxX(), vector.getMinY(), vector.getMinZ());
// Draw south side
GL11.glNormal3d(0, 0, 1);
addVertex(vector.getMinX(), vector.getMinY(), vector.getMaxZ());
addVertex(vector.getMaxX(), vector.getMinY(), vector.getMaxZ());
addVertex(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ());
addVertex(vector.getMinX(), vector.getMaxY(), vector.getMaxZ());
GL11.glColor4d(1, 1, 1, 1);
}
/**
* Draws a colored cube with the size of vector. All faces have the specified color. This uses Tesselator
*
* @author Koen Beckers (K4Unl) and Amadornes
* @param vector
* @param color
*/
public static void drawTesselatedColoredCube(Vector3Cube vector, int r, int g, int b, int a) {
Tessellator t = Tessellator.instance;
boolean wasTesselating = false;
// Check if we were already tesselating
try {
t.startDrawingQuads();
} catch (IllegalStateException e) {
wasTesselating = true;
}
t.setColorRGBA(r, g, b, a);
t.setNormal(0, 1, 0);
t.addVertex(vector.getMinX(), vector.getMaxY(), vector.getMaxZ());
t.addVertex(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ());
t.addVertex(vector.getMaxX(), vector.getMaxY(), vector.getMinZ());
t.addVertex(vector.getMinX(), vector.getMaxY(), vector.getMinZ());
// Bottom side
t.setNormal(0, -1, 0);
t.addVertex(vector.getMaxX(), vector.getMinY(), vector.getMaxZ());
t.addVertex(vector.getMinX(), vector.getMinY(), vector.getMaxZ());
t.addVertex(vector.getMinX(), vector.getMinY(), vector.getMinZ());
t.addVertex(vector.getMaxX(), vector.getMinY(), vector.getMinZ());
// Draw west side:
t.setNormal(-1, 0, 0);
t.addVertex(vector.getMinX(), vector.getMinY(), vector.getMaxZ());
t.addVertex(vector.getMinX(), vector.getMaxY(), vector.getMaxZ());
t.addVertex(vector.getMinX(), vector.getMaxY(), vector.getMinZ());
t.addVertex(vector.getMinX(), vector.getMinY(), vector.getMinZ());
// Draw east side:
t.setNormal(1, 0, 0);
t.addVertex(vector.getMaxX(), vector.getMinY(), vector.getMinZ());
t.addVertex(vector.getMaxX(), vector.getMaxY(), vector.getMinZ());
t.addVertex(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ());
t.addVertex(vector.getMaxX(), vector.getMinY(), vector.getMaxZ());
// Draw north side
t.setNormal(0, 0, -1);
t.addVertex(vector.getMinX(), vector.getMinY(), vector.getMinZ());
t.addVertex(vector.getMinX(), vector.getMaxY(), vector.getMinZ());
t.addVertex(vector.getMaxX(), vector.getMaxY(), vector.getMinZ());
t.addVertex(vector.getMaxX(), vector.getMinY(), vector.getMinZ());
// Draw south side
t.setNormal(0, 0, 1);
t.addVertex(vector.getMinX(), vector.getMinY(), vector.getMaxZ());
t.addVertex(vector.getMaxX(), vector.getMinY(), vector.getMaxZ());
t.addVertex(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ());
t.addVertex(vector.getMinX(), vector.getMaxY(), vector.getMaxZ());
GL11.glColor4d(1, 1, 1, 1);
if(!wasTesselating){
t.draw();
}
}
/**
* Draws a colored cube with the size of vector. Every face has a different color This uses the Tessellator
*
* @author Koen Beckers (K4Unl)
* @param vector
*/
public static void drawTesselatedColoredCube(Vector3Cube vector) {
Tessellator t = Tessellator.instance;
boolean wasTesselating = false;
// Check if we were already tesselating
try {
t.startDrawingQuads();
} catch (IllegalStateException e) {
wasTesselating = true;
}
// Top side
t.setColorRGBA_F(1.0F, 0.0F, 0.0F, 1.0F);
t.setNormal(0, 1, 0);
t.addVertex(vector.getMinX(), vector.getMaxY(), vector.getMaxZ());
t.addVertex(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ());
t.addVertex(vector.getMaxX(), vector.getMaxY(), vector.getMinZ());
t.addVertex(vector.getMinX(), vector.getMaxY(), vector.getMinZ());
// Bottom side
t.setColorRGBA_F(1.0F, 1.0F, 0.0F, 1.0F);
t.setNormal(0, -1, 0);
t.addVertex(vector.getMaxX(), vector.getMinY(), vector.getMaxZ());
t.addVertex(vector.getMinX(), vector.getMinY(), vector.getMaxZ());
t.addVertex(vector.getMinX(), vector.getMinY(), vector.getMinZ());
t.addVertex(vector.getMaxX(), vector.getMinY(), vector.getMinZ());
// Draw west side:
t.setColorRGBA_F(0.0F, 1.0F, 0.0F, 1.0F);
t.setNormal(-1, 0, 0);
t.addVertex(vector.getMinX(), vector.getMinY(), vector.getMaxZ());
t.addVertex(vector.getMinX(), vector.getMaxY(), vector.getMaxZ());
t.addVertex(vector.getMinX(), vector.getMaxY(), vector.getMinZ());
t.addVertex(vector.getMinX(), vector.getMinY(), vector.getMinZ());
// Draw east side:
t.setColorRGBA_F(0.0F, 1.0F, 1.0F, 1.0F);
t.setNormal(1, 0, 0);
t.addVertex(vector.getMaxX(), vector.getMinY(), vector.getMinZ());
t.addVertex(vector.getMaxX(), vector.getMaxY(), vector.getMinZ());
t.addVertex(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ());
t.addVertex(vector.getMaxX(), vector.getMinY(), vector.getMaxZ());
// Draw north side
t.setColorRGBA_F(0.0F, 0.0F, 1.0F, 1.0F);
t.setNormal(0, 0, -1);
t.addVertex(vector.getMinX(), vector.getMinY(), vector.getMinZ());
t.addVertex(vector.getMinX(), vector.getMaxY(), vector.getMinZ());
t.addVertex(vector.getMaxX(), vector.getMaxY(), vector.getMinZ());
t.addVertex(vector.getMaxX(), vector.getMinY(), vector.getMinZ());
// Draw south side
t.setColorRGBA_F(0.0F, 0.0F, 0.0F, 1.0F);
t.setNormal(0, 0, 1);
t.addVertex(vector.getMinX(), vector.getMinY(), vector.getMaxZ());
t.addVertex(vector.getMaxX(), vector.getMinY(), vector.getMaxZ());
t.addVertex(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ());
t.addVertex(vector.getMinX(), vector.getMaxY(), vector.getMaxZ());
if (!wasTesselating) {
t.draw();
}
}
/**
* Draws a cube with the size of vector. It uses the texture that is already bound and maps that completely This uses the Tessellator
*
* @author Koen Beckers (K4Unl)
* @param vector
*/
public static void drawTesselatedTexturedCube(Vector3Cube vector) {
Tessellator t = Tessellator.instance;
boolean wasTesselating = false;
// Check if we were already tesselating
try {
t.startDrawingQuads();
} catch (IllegalStateException e) {
wasTesselating = true;
}
double minU = 0;
double maxU = 1;
double minV = 0;
double maxV = 1;
// Top side
t.setNormal(0, 1, 0);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMaxZ(), minU, maxV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ(), minU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMinZ(), maxU, minV);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMinZ(), maxU, maxV);
// Bottom side
t.setNormal(0, -1, 0);
t.addVertexWithUV(vector.getMaxX(), vector.getMinY(), vector.getMaxZ(), minU, maxV);
t.addVertexWithUV(vector.getMinX(), vector.getMinY(), vector.getMaxZ(), minU, minV);
t.addVertexWithUV(vector.getMinX(), vector.getMinY(), vector.getMinZ(), maxU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMinY(), vector.getMinZ(), maxU, maxV);
// Draw west side:
t.setNormal(-1, 0, 0);
t.addVertexWithUV(vector.getMinX(), vector.getMinY(), vector.getMaxZ(), minU, maxV);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMaxZ(), minU, minV);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMinZ(), maxU, minV);
t.addVertexWithUV(vector.getMinX(), vector.getMinY(), vector.getMinZ(), maxU, maxV);
// Draw east side:
t.setNormal(1, 0, 0);
t.addVertexWithUV(vector.getMaxX(), vector.getMinY(), vector.getMinZ(), minU, maxV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMinZ(), minU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ(), maxU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMinY(), vector.getMaxZ(), maxU, maxV);
// Draw north side
t.setNormal(0, 0, -1);
t.addVertexWithUV(vector.getMinX(), vector.getMinY(), vector.getMinZ(), minU, maxV);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMinZ(), minU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMinZ(), maxU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMinY(), vector.getMinZ(), maxU, maxV);
// Draw south side
t.setNormal(0, 0, 1);
t.addVertexWithUV(vector.getMinX(), vector.getMinY(), vector.getMaxZ(), minU, maxV);
t.addVertexWithUV(vector.getMaxX(), vector.getMinY(), vector.getMaxZ(), minU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ(), maxU, minV);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMaxZ(), maxU, maxV);
if (!wasTesselating) {
t.draw();
}
}
/**
* Draws a cube with the size of vector. Every face has the same color This uses the Tessellator
*
* @author Koen Beckers (K4Unl)
* @param vector
*/
public static void drawTesselatedCube(Vector3Cube vector) {
Tessellator t = Tessellator.instance;
boolean wasTesselating = false;
// Check if we were already tesselating
try {
t.startDrawingQuads();
} catch (IllegalStateException e) {
wasTesselating = true;
}
// Top side
t.setNormal(0, 1, 0);
t.addVertex(vector.getMinX(), vector.getMaxY(), vector.getMaxZ());
t.addVertex(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ());
t.addVertex(vector.getMaxX(), vector.getMaxY(), vector.getMinZ());
t.addVertex(vector.getMinX(), vector.getMaxY(), vector.getMinZ());
// Bottom side
t.setNormal(0, -1, 0);
t.addVertex(vector.getMaxX(), vector.getMinY(), vector.getMaxZ());
t.addVertex(vector.getMinX(), vector.getMinY(), vector.getMaxZ());
t.addVertex(vector.getMinX(), vector.getMinY(), vector.getMinZ());
t.addVertex(vector.getMaxX(), vector.getMinY(), vector.getMinZ());
// Draw west side:
t.setNormal(-1, 0, 0);
t.addVertex(vector.getMinX(), vector.getMinY(), vector.getMaxZ());
t.addVertex(vector.getMinX(), vector.getMaxY(), vector.getMaxZ());
t.addVertex(vector.getMinX(), vector.getMaxY(), vector.getMinZ());
t.addVertex(vector.getMinX(), vector.getMinY(), vector.getMinZ());
// Draw east side:
t.setNormal(1, 0, 0);
t.addVertex(vector.getMaxX(), vector.getMinY(), vector.getMinZ());
t.addVertex(vector.getMaxX(), vector.getMaxY(), vector.getMinZ());
t.addVertex(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ());
t.addVertex(vector.getMaxX(), vector.getMinY(), vector.getMaxZ());
// Draw north side
t.setNormal(0, 0, -1);
t.addVertex(vector.getMinX(), vector.getMinY(), vector.getMinZ());
t.addVertex(vector.getMinX(), vector.getMaxY(), vector.getMinZ());
t.addVertex(vector.getMaxX(), vector.getMaxY(), vector.getMinZ());
t.addVertex(vector.getMaxX(), vector.getMinY(), vector.getMinZ());
// Draw south side
t.setNormal(0, 0, 1);
t.addVertex(vector.getMinX(), vector.getMinY(), vector.getMaxZ());
t.addVertex(vector.getMaxX(), vector.getMinY(), vector.getMaxZ());
t.addVertex(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ());
t.addVertex(vector.getMinX(), vector.getMaxY(), vector.getMaxZ());
if (!wasTesselating) {
t.draw();
}
}
/**
* ???
*
* @author ???
* @param vector
*/
public static void drawTesselatedCubeWithoutNormals(Vector3Cube vector) {
Tessellator t = Tessellator.instance;
boolean wasTesselating = false;
// Check if we were already tesselating
try {
t.startDrawingQuads();
} catch (IllegalStateException e) {
wasTesselating = true;
}
// Top side
t.addVertex(vector.getMinX(), vector.getMaxY(), vector.getMaxZ());
t.addVertex(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ());
t.addVertex(vector.getMaxX(), vector.getMaxY(), vector.getMinZ());
t.addVertex(vector.getMinX(), vector.getMaxY(), vector.getMinZ());
// Bottom side
t.addVertex(vector.getMaxX(), vector.getMinY(), vector.getMaxZ());
t.addVertex(vector.getMinX(), vector.getMinY(), vector.getMaxZ());
t.addVertex(vector.getMinX(), vector.getMinY(), vector.getMinZ());
t.addVertex(vector.getMaxX(), vector.getMinY(), vector.getMinZ());
// Draw west side:
t.addVertex(vector.getMinX(), vector.getMinY(), vector.getMaxZ());
t.addVertex(vector.getMinX(), vector.getMaxY(), vector.getMaxZ());
t.addVertex(vector.getMinX(), vector.getMaxY(), vector.getMinZ());
t.addVertex(vector.getMinX(), vector.getMinY(), vector.getMinZ());
// Draw east side:
t.addVertex(vector.getMaxX(), vector.getMinY(), vector.getMinZ());
t.addVertex(vector.getMaxX(), vector.getMaxY(), vector.getMinZ());
t.addVertex(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ());
t.addVertex(vector.getMaxX(), vector.getMinY(), vector.getMaxZ());
// Draw north side
t.addVertex(vector.getMinX(), vector.getMinY(), vector.getMinZ());
t.addVertex(vector.getMinX(), vector.getMaxY(), vector.getMinZ());
t.addVertex(vector.getMaxX(), vector.getMaxY(), vector.getMinZ());
t.addVertex(vector.getMaxX(), vector.getMinY(), vector.getMinZ());
// Draw south side
t.addVertex(vector.getMinX(), vector.getMinY(), vector.getMaxZ());
t.addVertex(vector.getMaxX(), vector.getMinY(), vector.getMaxZ());
t.addVertex(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ());
t.addVertex(vector.getMinX(), vector.getMaxY(), vector.getMaxZ());
if (!wasTesselating) {
t.draw();
}
}
/**
* ???
*
* @author amadornes
* @param d
*/
public static void rotateRenderMatrix(ForgeDirection d) {
switch (d) {
case UP:
GL11.glRotatef(1, 0, 0, -90);
break;
case DOWN:
GL11.glRotatef(1, 0, 0, 90);
break;
case NORTH:
GL11.glRotatef(1, 0, -90, 0);
break;
case SOUTH:
GL11.glRotatef(1, 0, 90, 0);
break;
case WEST:
GL11.glRotatef(1, 0, 0, 180);
break;
case EAST:
GL11.glRotatef(1, 0, 0, 0);
break;
default:
break;
}
}
}
| 28,701 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
RenderLamp.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/client/renderers/RenderLamp.java | package net.quetzi.bluepower.client.renderers;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.quetzi.bluepower.api.vec.Vector3Cube;
import net.quetzi.bluepower.blocks.machines.BlockLamp;
import net.quetzi.bluepower.tileentities.tier1.TileLamp;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import cpw.mods.fml.client.registry.RenderingRegistry;
public class RenderLamp extends TileEntitySpecialRenderer implements ISimpleBlockRenderingHandler {
public static final int RENDER_ID = RenderingRegistry.getNextAvailableRenderId();
@Override
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {
BlockLamp bLamp = (BlockLamp) block;
int redMask = 0xFF0000, greenMask = 0xFF00, blueMask = 0xFF;
int r = (bLamp.getColor() & redMask) >> 16;
int g = (bLamp.getColor() & greenMask) >> 8;
int b = (bLamp.getColor() & blueMask);
Vector3Cube vector = new Vector3Cube(0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
// if (pass == 0) {
Tessellator t = Tessellator.instance;
t.startDrawingQuads();
t.setColorOpaque(r, g, b);
IIcon iconToUse;
int power = 0;
if (power == 0) {
iconToUse = IconSupplier.lampOff;
} else {
iconToUse = IconSupplier.lampOn;
}
double minU = iconToUse.getMinU();
double maxU = iconToUse.getMaxU();
double minV = iconToUse.getMinV();
double maxV = iconToUse.getMaxV();
// Top side
t.setNormal(0, 1, 0);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMaxZ(), minU, maxV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ(), minU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMinZ(), maxU, minV);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMinZ(), maxU, maxV);
// Draw west side:
t.setNormal(-1, 0, 0);
t.addVertexWithUV(vector.getMinX(), vector.getMinY(), vector.getMaxZ(), minU, maxV);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMaxZ(), minU, minV);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMinZ(), maxU, minV);
t.addVertexWithUV(vector.getMinX(), vector.getMinY(), vector.getMinZ(), maxU, maxV);
// Draw east side:
t.setNormal(1, 0, 0);
t.addVertexWithUV(vector.getMaxX(), vector.getMinY(), vector.getMinZ(), minU, maxV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMinZ(), minU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ(), maxU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMinY(), vector.getMaxZ(), maxU, maxV);
// Draw north side
t.setNormal(0, 0, -1);
t.addVertexWithUV(vector.getMinX(), vector.getMinY(), vector.getMinZ(), minU, maxV);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMinZ(), minU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMinZ(), maxU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMinY(), vector.getMinZ(), maxU, maxV);
// Draw south side
t.setNormal(0, 0, 1);
t.addVertexWithUV(vector.getMinX(), vector.getMinY(), vector.getMaxZ(), minU, maxV);
t.addVertexWithUV(vector.getMaxX(), vector.getMinY(), vector.getMaxZ(), maxU, maxV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ(), maxU, minV);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMaxZ(), minU, minV);
t.draw();
// }
}
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
BlockLamp bLamp = (BlockLamp) block;
int redMask = 0xFF0000, greenMask = 0xFF00, blueMask = 0xFF;
int r = (bLamp.getColor() & redMask) >> 16;
int g = (bLamp.getColor() & greenMask) >> 8;
int b = (bLamp.getColor() & blueMask);
Vector3Cube vector = new Vector3Cube(0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
// if (pass == 0) {
Tessellator t = Tessellator.instance;
t.addTranslation(x, y, z);
t.setColorOpaque(r, g, b);
IIcon iconToUse;
int power = ((TileLamp) world.getTileEntity(x, y, z)).getPower();
if (bLamp.isInverted()) {
power = 15 - power;
}
if (power == 0) {
iconToUse = IconSupplier.lampOn;
} else {
iconToUse = IconSupplier.lampOff;
}
double minU = iconToUse.getMinU();
double maxU = iconToUse.getMaxU();
double minV = iconToUse.getMinV();
double maxV = iconToUse.getMaxV();
// Bottom side
t.setNormal(0, -1, 0);
t.addVertexWithUV(vector.getMaxX(), vector.getMinY(), vector.getMaxZ(), minU, maxV);
t.addVertexWithUV(vector.getMinX(), vector.getMinY(), vector.getMaxZ(), minU, minV);
t.addVertexWithUV(vector.getMinX(), vector.getMinY(), vector.getMinZ(), maxU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMinY(), vector.getMinZ(), maxU, maxV);
// Top side
t.setNormal(0, 1, 0);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMaxZ(), minU, maxV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ(), minU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMinZ(), maxU, minV);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMinZ(), maxU, maxV);
// Draw west side:
t.setNormal(-1, 0, 0);
t.addVertexWithUV(vector.getMinX(), vector.getMinY(), vector.getMaxZ(), minU, maxV);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMaxZ(), minU, minV);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMinZ(), maxU, minV);
t.addVertexWithUV(vector.getMinX(), vector.getMinY(), vector.getMinZ(), maxU, maxV);
// Draw east side:
t.setNormal(1, 0, 0);
t.addVertexWithUV(vector.getMaxX(), vector.getMinY(), vector.getMinZ(), minU, maxV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMinZ(), minU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ(), maxU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMinY(), vector.getMaxZ(), maxU, maxV);
// Draw north side
t.setNormal(0, 0, -1);
t.addVertexWithUV(vector.getMinX(), vector.getMinY(), vector.getMinZ(), minU, maxV);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMinZ(), minU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMinZ(), maxU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMinY(), vector.getMinZ(), maxU, maxV);
// Draw south side
t.setNormal(0, 0, 1);
t.addVertexWithUV(vector.getMinX(), vector.getMinY(), vector.getMaxZ(), minU, maxV);
t.addVertexWithUV(vector.getMaxX(), vector.getMinY(), vector.getMaxZ(), maxU, maxV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ(), maxU, minV);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMaxZ(), minU, minV);
// }
// if (power > 0) {
// }
t.addTranslation(-x, -y, -z);
return true;
}
@Override
public boolean shouldRender3DInInventory(int modelId) {
return true;
}
@Override
public int getRenderId() {
return RENDER_ID;
}
/******* TESR ***********/
@Override
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float f) {
int power = ((TileLamp) te).getPower();
BlockLamp bLamp = (BlockLamp) te.getBlockType();
int redMask = 0xFF0000, greenMask = 0xFF00, blueMask = 0xFF;
int r = (bLamp.getColor() & redMask) >> 16;
int g = (bLamp.getColor() & greenMask) >> 8;
int b = (bLamp.getColor() & blueMask);
if (bLamp.isInverted()) {
power = 15 - power;
}
// power = 15;
Vector3Cube vector = new Vector3Cube(0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
GL11.glTranslated(x, y, z);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
// GL11.glAlphaFunc(GL11.GL_EQUAL, (power / 15F) * 1F);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glDisable(GL11.GL_LIGHTING);
// GL11.glDisable(GL11.GL_CULL_FACE);
GL11.glDepthMask(false);
GL11.glBegin(GL11.GL_QUADS);
double powerDivision = (power / 15D);
RenderHelper.drawColoredCube(vector.clone().expand(0.8 / 16D), r / 256D, g / 256D, b / 256D, powerDivision * 0.625D);
GL11.glEnd();
GL11.glDepthMask(true);
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
// GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
GL11.glDisable(GL11.GL_BLEND);
GL11.glTranslated(-x, -y, -z);
}
}
| 9,873 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
RenderItemEngine.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/client/renderers/RenderItemEngine.java | package net.quetzi.bluepower.client.renderers;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.IItemRenderer;
import net.minecraftforge.client.model.AdvancedModelLoader;
import net.minecraftforge.client.model.IModelCustom;
import net.quetzi.bluepower.references.Refs;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/**
*
* @author TheFjonG
*
*/
@SideOnly(Side.CLIENT)
public class RenderItemEngine implements IItemRenderer{
private ResourceLocation modelLocation = new ResourceLocation(Refs.MODID + ":" + Refs.MODEL_LOCATION + "engine.obj");
private ResourceLocation textureLocation = new ResourceLocation(Refs.MODID + ":" + Refs.MODEL_TEXTURE_LOCATION + "engineoff.png");
private IModelCustom model;
public RenderItemEngine(){
model = AdvancedModelLoader.loadModel(modelLocation);
}
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
return true;
}
@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item,ItemRendererHelper helper) {
return true;
}
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
switch (type){
case ENTITY:
{
renderEngine(0.0F, 0F, 0.0F, 0, 0, 0, 0);
return;
}
case EQUIPPED:
{
renderEngine( 8F, 8F, 8F, 10, 1, 0, 0-1F);
return;
}
case EQUIPPED_FIRST_PERSON:
{
renderEngine(14F, 2F, 16F, 4, -.8F, 0, -.8F);
return;
}
case INVENTORY:
{
renderEngine(0.0F, -10F, 0.0F, 0, 0, 0, 0);
return;
}
default:
}
}
private void renderEngine(float x, float y, float z, float rotateAmount, float rotatex, float rotatey, float rotatez) {
GL11.glPushMatrix();
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glScalef(.034F, .034F, .034F);
GL11.glTranslated(x ,y, z);
GL11.glRotatef(rotateAmount, rotatex, rotatey, rotatez);
FMLClientHandler.instance().getClient().renderEngine.bindTexture(textureLocation);
model.renderAll();
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glPopMatrix();
}
}
| 2,497 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
GuiSeedBag.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/client/gui/GuiSeedBag.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*
* @author Lumien
*/
package net.quetzi.bluepower.client.gui;
import net.minecraft.client.resources.I18n;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.quetzi.bluepower.containers.ContainerSeedBag;
import net.quetzi.bluepower.references.Refs;
public class GuiSeedBag extends GuiBase {
private static final ResourceLocation resLoc = new ResourceLocation(Refs.MODID, "textures/gui/seedBag.png");
public GuiSeedBag(ItemStack bag, IInventory playerInventory, IInventory seedBagInventory) {
super(new ContainerSeedBag(bag, playerInventory, seedBagInventory), resLoc);
}
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
this.drawString(60, 5, I18n.format("item.seed_bag.name", new Object[] {}), false);
}
}
| 1,670 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
GUIHandler.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/client/gui/GUIHandler.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.client.gui;
import cpw.mods.fml.common.network.IGuiHandler;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.quetzi.bluepower.containers.*;
import net.quetzi.bluepower.containers.inventorys.InventoryItem;
import net.quetzi.bluepower.items.ItemCanvasBag;
import net.quetzi.bluepower.items.ItemFloppyDisk;
import net.quetzi.bluepower.items.ItemScrewdriver;
import net.quetzi.bluepower.items.ItemSeedBag;
import net.quetzi.bluepower.references.GuiIDs;
import net.quetzi.bluepower.tileentities.tier1.*;
import net.quetzi.bluepower.tileentities.tier2.TileSortingMachine;
import net.quetzi.bluepower.tileentities.tier3.*;
public class GUIHandler implements IGuiHandler {
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
// This function creates a container
TileEntity ent = world.getTileEntity(x, y, z);
// ID is the GUI ID
switch (GuiIDs.values()[ID]) {
case ALLOY_FURNACE:
return new ContainerAlloyFurnace(player.inventory, (TileAlloyFurnace) ent);
case BUFFER:
return new ContainerBuffer(player.inventory, (TileBuffer) ent);
case SORTING_MACHINE:
return new ContainerSortingMachine(player.inventory, (TileSortingMachine) ent);
case SEEDBAG:
if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemSeedBag) { return new ContainerSeedBag(
player.getCurrentEquippedItem(), player.inventory, InventoryItem.getItemInventory(player, player.getCurrentEquippedItem(),
"Seed Bag", 9)); }
break;
case CANVAS_BAG:
if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemCanvasBag) { return new ContainerCanvasBag(
player.getCurrentEquippedItem(), player.inventory, InventoryItem.getItemInventory(player, player.getCurrentEquippedItem(),
"Canvas Bag", 27)); }
break;
case CPU:
return new ContainerCPU(player.inventory, (TileCPU) ent);
case MONITOR:
if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemScrewdriver) {
return null;
}
return new ContainerMonitor(player.inventory, (TileMonitor) ent);
case DISK_DRIVE: // FIXME: this conditional will always be false (for fabricator77)
if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemScrewdriver
&& player.getCurrentEquippedItem().getItem() instanceof ItemFloppyDisk) {
return null;
}
return new ContainerDiskDrive(player.inventory, (TileDiskDrive) ent);
case IO_EXPANDER:
if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemScrewdriver) {
return null;
}
return new ContainerIOExpander(player.inventory, (TileIOExpander) ent);
case REDBUS_ID:
return new ContainerRedbusID(player.inventory, (IRedBusWindow) ent);
case KINETICGENERATOR_ID:
return new ContainerKinect(player.inventory, (TileKinectGenerator) ent);
case DEPLOYER_ID:
return new ContainerDeployer(player.inventory, (TileDeployer) ent);
case RELAY_ID:
return new ContainerRelay(player.inventory, (TileRelay) ent);
case EJECTOR_ID:
return new ContainerEjector(player.inventory, (TileEjector) ent);
default:
break;
}
return null;
}
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
TileEntity ent = world.getTileEntity(x, y, z);
// ID is the GUI ID
switch (GuiIDs.values()[ID]) {
case ALLOY_FURNACE:
return new GuiAlloyFurnace(player.inventory, (TileAlloyFurnace) ent);
case BUFFER:
return new GuiBuffer(player.inventory, (TileBuffer) ent);
case SORTING_MACHINE:
return new GuiSortingMachine(player.inventory, (TileSortingMachine) ent);
case SEEDBAG:
if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemSeedBag) { return new GuiSeedBag(
player.getCurrentEquippedItem(), player.inventory, InventoryItem.getItemInventory(player, player.getCurrentEquippedItem(),
"Seed Bag", 9)); }
case CANVAS_BAG:
if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemCanvasBag) { return new GuiCanvasBag(
player.getCurrentEquippedItem(), player.inventory, InventoryItem.getItemInventory(player, player.getCurrentEquippedItem(),
"Canvas Bag", 27)); }
break;
case CPU:
return new GuiCPU(player.inventory, (TileCPU) ent);
case MONITOR:
if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemScrewdriver) {
return null;
}
return new GuiMonitor(player.inventory, (TileMonitor) ent);
case DISK_DRIVE: // FIXME: this conditional will always be false (for fabricator77)
if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemScrewdriver
&& player.getCurrentEquippedItem().getItem() instanceof ItemFloppyDisk) {
return null;
}
return new GuiDiskDrive(player.inventory, (TileDiskDrive) ent);
case IO_EXPANDER:
if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemScrewdriver) {
return null;
}
return new GuiIOExpander(player.inventory, (TileIOExpander) ent);
case REDBUS_ID:
return new GuiRedbusID(player.inventory, (IRedBusWindow) ent);
case KINETICGENERATOR_ID:
return new GuiKinect(player.inventory, (TileKinectGenerator) ent);
case DEPLOYER_ID:
return new GuiDeployer(player.inventory, (TileDeployer) ent);
case RELAY_ID:
return new GuiRelay(player.inventory, (TileRelay) ent);
case EJECTOR_ID:
return new GuiEjector(player.inventory, (TileEjector) ent);
default:
break;
}
return null;
}
}
| 7,824 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
GuiBuffer.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/client/gui/GuiBuffer.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*
* @author Quetzi
*/
package net.quetzi.bluepower.client.gui;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import net.quetzi.bluepower.containers.ContainerBuffer;
import net.quetzi.bluepower.references.Refs;
import net.quetzi.bluepower.tileentities.tier1.TileBuffer;
public class GuiBuffer extends GuiBase {
private static final ResourceLocation resLoc = new ResourceLocation(Refs.MODID, "textures/gui/buffer.png");
private final TileBuffer buffer;
public GuiBuffer(InventoryPlayer invPlayer, TileBuffer buffer) {
super(new ContainerBuffer(invPlayer, buffer), resLoc);
this.buffer = buffer;
this.ySize = 186;
}
}
| 1,457 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
GuiCanvasBag.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/client/gui/GuiCanvasBag.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*
* @author Lumien
*/
package net.quetzi.bluepower.client.gui;
import net.minecraft.client.resources.I18n;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.quetzi.bluepower.containers.ContainerCanvasBag;
import net.quetzi.bluepower.references.Refs;
public class GuiCanvasBag extends GuiBase {
private static final ResourceLocation resLoc = new ResourceLocation(Refs.MODID, "textures/gui/canvas_bag.png");
ItemStack bag;
public GuiCanvasBag(ItemStack bag, IInventory playerInventory, IInventory canvasBagInventory) {
super(new ContainerCanvasBag(bag, playerInventory, canvasBagInventory), resLoc);
this.bag = bag;
}
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
this.fontRendererObj.drawString(bag.hasDisplayName() ? bag.getDisplayName() : I18n.format("item.canvas_bag.name", new Object[] {}), 8, 6, 4210752);
}
}
| 1,822 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
GuiKinect.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/client/gui/GuiKinect.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*
* @author Quetzi
*/
package net.quetzi.bluepower.client.gui;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import net.quetzi.bluepower.containers.ContainerKinect;
import net.quetzi.bluepower.references.Refs;
import net.quetzi.bluepower.tileentities.tier1.TileKinectGenerator;
public class GuiKinect extends GuiBase {
private static final ResourceLocation resLoc = new ResourceLocation(Refs.MODID, "textures/gui/kinect.png");
private final TileKinectGenerator kinect;
public GuiKinect(InventoryPlayer invPlayer, TileKinectGenerator kinect) {
super(new ContainerKinect(invPlayer, kinect), resLoc);
this.kinect = kinect;
this.ySize = 165;
}
}
| 1,484 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
GuiDiskDrive.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/client/gui/GuiDiskDrive.java | package net.quetzi.bluepower.client.gui;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import net.quetzi.bluepower.containers.ContainerDiskDrive;
import net.quetzi.bluepower.references.Refs;
import net.quetzi.bluepower.tileentities.tier3.TileDiskDrive;
public class GuiDiskDrive extends GuiBase {
private final TileDiskDrive diskDrive;
private static final ResourceLocation resLoc = new ResourceLocation(Refs.MODID+":textures/gui/diskdrivegui.png");
public GuiDiskDrive (InventoryPlayer invPlayer, TileDiskDrive diskDrive) {
super(new ContainerDiskDrive(invPlayer, diskDrive), resLoc);
this.diskDrive = diskDrive;
}
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
}
}
| 775 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
GuiDeployer.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/client/gui/GuiDeployer.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*
* @author Quetzi
*/
package net.quetzi.bluepower.client.gui;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import net.quetzi.bluepower.containers.ContainerDeployer;
import net.quetzi.bluepower.references.Refs;
import net.quetzi.bluepower.tileentities.tier1.TileDeployer;
public class GuiDeployer extends GuiBase {
private static final ResourceLocation resLoc = new ResourceLocation(Refs.MODID, "textures/gui/deployer.png");
private final TileDeployer deployer;
public GuiDeployer(InventoryPlayer invPlayer, TileDeployer deployer) {
super(new ContainerDeployer(invPlayer, deployer), resLoc);
this.deployer = deployer;
this.ySize = 166;
}
}
| 1,470 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
GuiRedbusID.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/client/gui/GuiRedbusID.java | package net.quetzi.bluepower.client.gui;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import net.quetzi.bluepower.containers.ContainerRedbusID;
import net.quetzi.bluepower.references.Refs;
import net.quetzi.bluepower.tileentities.tier3.IRedBusWindow;
public class GuiRedbusID extends GuiBase {
private final IRedBusWindow device;
private static final ResourceLocation resLoc = new ResourceLocation(Refs.MODID+":textures/gui/redbusgui.png");
public GuiRedbusID (InventoryPlayer invPlayer, IRedBusWindow device) {
super(new ContainerRedbusID(invPlayer, device), resLoc);
this.device = device;
this.xSize = 123;
this.ySize = 81;
}
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
drawHorizontalAlignedString(7, 4, xSize - 14, StatCollector.translateToLocal("gui.redbusgui"), true);
drawHorizontalAlignedString(7, 60, xSize - 14, StatCollector.translateToLocal("gui.redbus.id") + ":" + device.redbus_id, true);
}
//TODO: clicking on switches toggles state and updates redbus_id
}
| 1,159 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
GuiCPU.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/client/gui/GuiCPU.java | package net.quetzi.bluepower.client.gui;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import net.quetzi.bluepower.containers.ContainerCPU;
import net.quetzi.bluepower.references.Refs;
import net.quetzi.bluepower.tileentities.tier3.TileCPU;
public class GuiCPU extends GuiBase {
private final TileCPU cpu;
private static final ResourceLocation resLoc = new ResourceLocation(Refs.MODID+":textures/gui/cpugui.png");
public GuiCPU (InventoryPlayer invPlayer, TileCPU cpu) {
super(new ContainerCPU(invPlayer, cpu), resLoc);
this.cpu = cpu;
}
}
| 601 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
GuiIOExpander.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/client/gui/GuiIOExpander.java | package net.quetzi.bluepower.client.gui;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import net.quetzi.bluepower.containers.ContainerIOExpander;
import net.quetzi.bluepower.references.Refs;
import net.quetzi.bluepower.tileentities.tier3.TileIOExpander;
public class GuiIOExpander extends GuiBase {
private final TileIOExpander ioExpander;
private static final ResourceLocation resLoc = new ResourceLocation(Refs.MODID+":textures/gui/ioexpandergui.png");
public GuiIOExpander (InventoryPlayer invPlayer, TileIOExpander ioExpander) {
super(new ContainerIOExpander (invPlayer, ioExpander), resLoc);
this.ioExpander = ioExpander;
}
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
}
}
| 789 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
GuiMonitor.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/client/gui/GuiMonitor.java | package net.quetzi.bluepower.client.gui;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import net.quetzi.bluepower.containers.ContainerMonitor;
import net.quetzi.bluepower.references.Refs;
import net.quetzi.bluepower.tileentities.tier3.TileMonitor;
import org.lwjgl.opengl.GL11;
public class GuiMonitor extends GuiBase {
private static final ResourceLocation resLoc = new ResourceLocation(Refs.MODID + ":textures/gui/monitorgui.png");
private static final ResourceLocation chracterSetResLoc = new ResourceLocation(Refs.MODID + ":textures/gui/65el02_chars.png");
private final TileMonitor monitor;
public GuiMonitor(InventoryPlayer invPlayer, TileMonitor monitor) {
super(new ContainerMonitor(invPlayer, monitor), resLoc);
this.monitor = monitor;
xSize = 350;
ySize = 230;
width = 350 / 2;
// TODO: fix height and width fields as well
}
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
}
@Override
protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(resLoc);
int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect2(k, l, 0, 0, this.xSize, this.ySize);
// screen color
this.mc.getTextureManager().bindTexture(chracterSetResLoc);
GL11.glColor4f(monitor.screenColor[0], monitor.screenColor[1], monitor.screenColor[2], 1.0F);
for (int row = 0; row < 50; row++) {
for (int col = 0; col < 80; col++) {
byte character = monitor.screenMemory[row * 80 + col];
// TODO: overlay cursor character
if (character != 32) {
drawCharacter(row, col, character);
}
}
}
}
private void drawCharacter(int row, int col, byte character) {
int x = (width - xSize) / 2;
int y = (height - ySize) / 2;
int tempOffset = 0; // 350;
if (monitor.mode80x40) {
// Not implemented yet
drawTexturedModalRect3(x + 15 + col * 4, y + 15 + row * 4, tempOffset + (character & 0xF) * 8, (character >> 4) * 8, 8, 8);
} else {
// TODO: fix texture mapping issues
drawTexturedModalRect3(x + 15 + col * 4, y + 15 + row * 4, tempOffset + (character & 0xF) * 8, (character >> 4) * 8, 8, 8);
}
}
/**
* Draws a textured rectangle at the stored z-value. Args: x, y, u, v, width, height
*/
@SuppressWarnings("cast")
public void drawTexturedModalRect2(int x, int z, int u, int v, int w, int h) {
float f = 0.00195313F;
float f1 = 0.00390625F;
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.addVertexWithUV((double) (x + 0), (double) (z + h), (double) this.zLevel, (double) ((float) (u + 0) * f),
(double) ((float) (v + h) * f1));
tessellator.addVertexWithUV((double) (x + w), (double) (z + h), (double) this.zLevel, (double) ((float) (u + w) * f),
(double) ((float) (v + h) * f1));
tessellator.addVertexWithUV((double) (x + w), (double) (z + 0), (double) this.zLevel, (double) ((float) (u + w) * f),
(double) ((float) (v + 0) * f1));
tessellator.addVertexWithUV((double) (x + 0), (double) (z + 0), (double) this.zLevel, (double) ((float) (u + 0) * f),
(double) ((float) (v + 0) * f1));
tessellator.draw();
}
@SuppressWarnings("cast")
public void drawTexturedModalRect3(int x, int z, int u, int v, int w, int h) {
float f = 0.00390625F;
float f1 = 0.00390625F;
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.addVertexWithUV((double) (x + 0), (double) (z + h), (double) this.zLevel, (double) ((float) (u + 0) * f),
(double) ((float) (v + h) * f1));
tessellator.addVertexWithUV((double) (x + w), (double) (z + h), (double) this.zLevel, (double) ((float) (u + w) * f),
(double) ((float) (v + h) * f1));
tessellator.addVertexWithUV((double) (x + w), (double) (z + 0), (double) this.zLevel, (double) ((float) (u + w) * f),
(double) ((float) (v + 0) * f1));
tessellator.addVertexWithUV((double) (x + 0), (double) (z + 0), (double) this.zLevel, (double) ((float) (u + 0) * f),
(double) ((float) (v + 0) * f1));
tessellator.draw();
}
}
| 4,853 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
GuiRelay.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/client/gui/GuiRelay.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*
* @author Quetzi
*/
package net.quetzi.bluepower.client.gui;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import net.quetzi.bluepower.containers.ContainerRelay;
import net.quetzi.bluepower.references.Refs;
import net.quetzi.bluepower.tileentities.tier1.TileRelay;
public class GuiRelay extends GuiBase {
private static final ResourceLocation resLoc = new ResourceLocation(Refs.MODID, "textures/gui/seedBag.png");
public GuiRelay(InventoryPlayer invPlayer, TileRelay relay) {
super(new ContainerRelay(invPlayer, relay), resLoc);
}
}
| 1,340 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
GuiSortingMachine.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/client/gui/GuiSortingMachine.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.client.gui;
import java.util.List;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import net.quetzi.bluepower.client.gui.widget.BaseWidget;
import net.quetzi.bluepower.client.gui.widget.IGuiWidget;
import net.quetzi.bluepower.client.gui.widget.WidgetColor;
import net.quetzi.bluepower.client.gui.widget.WidgetMode;
import net.quetzi.bluepower.containers.ContainerSortingMachine;
import net.quetzi.bluepower.network.NetworkHandler;
import net.quetzi.bluepower.network.messages.MessageGuiUpdate;
import net.quetzi.bluepower.references.Refs;
import net.quetzi.bluepower.tileentities.tier2.TileSortingMachine;
import net.quetzi.bluepower.tileentities.tier2.TileSortingMachine.PullMode;
import net.quetzi.bluepower.tileentities.tier2.TileSortingMachine.SortMode;
/**
*
* @author MineMaarten
*/
public class GuiSortingMachine extends GuiBase {
private static final ResourceLocation resLoc = new ResourceLocation(Refs.MODID, "textures/gui/sorting_machine.png");
private final TileSortingMachine sortingMachine;
public GuiSortingMachine(InventoryPlayer invPlayer, TileSortingMachine sortingMachine) {
super(new ContainerSortingMachine(invPlayer, sortingMachine), resLoc);
this.sortingMachine = sortingMachine;
ySize = 222;
}
@Override
public void initGui() {
super.initGui();
for (int i = 0; i < 8; i++) {
WidgetColor colorWidget = new WidgetColor(i, guiLeft + 27 + 18 * i, guiTop + 110);
colorWidget.value = sortingMachine.colors[i].ordinal();
addWidget(colorWidget);
}
switch (sortingMachine.sortMode) {
case ANY_ITEM_DEFAULT:
case ANY_STACK_DEFAULT:
WidgetColor colorWidget = new WidgetColor(8, guiLeft + 7, guiTop + 122);
colorWidget.value = sortingMachine.colors[8].ordinal();
addWidget(colorWidget);
}
WidgetMode pullModeWidget = new WidgetMode(9, guiLeft + 7, guiTop + 90, 196, PullMode.values().length, Refs.MODID + ":textures/GUI/sorting_machine.png") {
@Override
public void addTooltip(List<String> curTip, boolean shiftPressed) {
curTip.add("gui.pullMode");
curTip.add(PullMode.values()[value].toString());
if (shiftPressed) {
curTip.add(PullMode.values()[value].toString() + ".info");
} else {
curTip.add("gui.sneakForInfo");
}
}
};
pullModeWidget.value = sortingMachine.pullMode.ordinal();
addWidget(pullModeWidget);
WidgetMode sortModeWidget = new WidgetMode(10, guiLeft + 7, guiTop + 106, 210, TileSortingMachine.SortMode.values().length, Refs.MODID + ":textures/GUI/sorting_machine.png") {
@Override
public void addTooltip(List<String> curTip, boolean shiftPressed) {
curTip.add("gui.sortMode");
curTip.add(TileSortingMachine.SortMode.values()[value].toString());
if (shiftPressed) {
curTip.add(TileSortingMachine.SortMode.values()[value].toString() + ".info");
} else {
curTip.add("gui.sneakForInfo");
}
}
};
sortModeWidget.value = sortingMachine.sortMode.ordinal();
addWidget(sortModeWidget);
}
@Override
public void actionPerformed(IGuiWidget widget) {
BaseWidget baseWidget = (BaseWidget) widget;
NetworkHandler.sendToServer(new MessageGuiUpdate(sortingMachine, widget.getID(), baseWidget.value));
}
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
// fontRenderer.drawString(pump.getInvName(), 8, 6, 0xFFFFFF);
drawHorizontalAlignedString(7, 6, xSize - 14, I18n.format("tile." + sortingMachine.getInventoryName() + ".name"), false);
}
@Override
protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
super.drawGuiContainerBackgroundLayer(f, i, j);
if (sortingMachine.sortMode == SortMode.ALLSTACK_SEQUENTIAL || sortingMachine.sortMode == SortMode.ANYSTACK_SEQUENTIAL) Gui.func_146110_a(guiLeft + 24 + sortingMachine.curColumn * 18, guiTop + 16, 176, 0, 20, 92, 256, 256);
}
}
| 5,418 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
GuiAlloyFurnace.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/client/gui/GuiAlloyFurnace.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.client.gui;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import net.quetzi.bluepower.containers.ContainerAlloyFurnace;
import net.quetzi.bluepower.references.Refs;
import net.quetzi.bluepower.tileentities.tier1.TileAlloyFurnace;
public class GuiAlloyFurnace extends GuiBase {
private static final ResourceLocation resLoc = new ResourceLocation(Refs.MODID, "textures/gui/alloy_furnace.png");
private final TileAlloyFurnace furnace;
public GuiAlloyFurnace(InventoryPlayer invPlayer, TileAlloyFurnace _furnace) {
super(new ContainerAlloyFurnace(invPlayer, _furnace), resLoc);
furnace = _furnace;
}
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
// fontRenderer.drawString(pump.getInvName(), 8, 6, 0xFFFFFF);
drawHorizontalAlignedString(7, 3, xSize - 14, furnace.getInventoryName(), true);
}
@Override
protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
super.drawGuiContainerBackgroundLayer(f, i, j);
int x = (width - xSize) / 2;
int y = (height - ySize) / 2;
int burningPercentage = (int) (furnace.getBurningPercentage() * 14);
// Todo: Tweak these variables a bit till it lines up perfectly.
drawTexturedModalRect(x + 22, y + 54 + 14 - burningPercentage, 177, 14 - burningPercentage, 14, burningPercentage + 0);
int processPercentage = (int) (furnace.getProcessPercentage() * 22);
drawTexturedModalRect(x + 103, y + 35, 178, 14, processPercentage, 15);
}
}
| 2,438 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
GuiBase.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/client/gui/GuiBase.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.client.gui;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.resources.I18n;
import net.minecraft.inventory.Container;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import net.quetzi.bluepower.BluePower;
import net.quetzi.bluepower.client.gui.widget.IGuiWidget;
import net.quetzi.bluepower.client.gui.widget.IWidgetListener;
import org.apache.commons.lang3.text.WordUtils;
import org.lwjgl.opengl.GL11;
public class GuiBase extends GuiContainer implements IWidgetListener {
private static final int COLOR_TEXT = 4210752;
private final List<IGuiWidget> widgets = new ArrayList<IGuiWidget>();
private final ResourceLocation resLoc;
public GuiBase(Container mainContainer, ResourceLocation _resLoc) {
super(mainContainer);
resLoc = _resLoc;
}
protected void addWidget(IGuiWidget widget) {
widgets.add(widget);
widget.setListener(this);
}
@Override
public void setWorldAndResolution(Minecraft par1Minecraft, int par2, int par3) {
widgets.clear();
super.setWorldAndResolution(par1Minecraft, par2, par3);
}
public static void drawVerticalProgressBar(int xOffset, int yOffset, int h, int w, float value, float max, int color) {
float perc = value / max;
int height = (int) (h * perc);
drawRect(xOffset, yOffset + h - height, xOffset + w, yOffset + h, color);
}
public void drawHorizontalAlignedString(int xOffset, int yOffset, int w, String text, boolean useShadow) {
int stringWidth = fontRendererObj.getStringWidth(text);
int newX = xOffset;
if (stringWidth < w) {
newX = w / 2 - stringWidth / 2 + xOffset;
}
fontRendererObj.drawString(text, newX, yOffset, COLOR_TEXT, useShadow);
}
public void drawString(int xOffset, int yOffset, String text, boolean useShadow) {
fontRendererObj.drawString(text, xOffset, yOffset, COLOR_TEXT, useShadow);
}
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, ySize - 94 + 2, COLOR_TEXT);
}
@Override
protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.renderEngine.bindTexture(resLoc);
int x = (width - xSize) / 2;
int y = (height - ySize) / 2;
drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
for (IGuiWidget widget : widgets) {
widget.render(i, j);
}
}
@Override
public void drawScreen(int x, int y, float partialTick) {
super.drawScreen(x, y, partialTick);
List<String> tooltip = new ArrayList<String>();
boolean shift = BluePower.proxy.isSneakingInGui();
for (IGuiWidget widget : widgets) {
if (widget.getBounds().contains(x, y)) widget.addTooltip(tooltip, shift);
}
if (!tooltip.isEmpty()) {
List<String> localizedTooltip = new ArrayList<String>();
for (String line : tooltip) {
String localizedLine = I18n.format(line);
String[] lines = WordUtils.wrap(localizedLine, 50).split(System.getProperty("line.separator"));
for (String locLine : lines) {
localizedTooltip.add(locLine);
}
}
drawHoveringText(localizedTooltip, x, y, fontRendererObj);
}
}
@Override
protected void mouseClicked(int x, int y, int button) {
super.mouseClicked(x, y, button);
for (IGuiWidget widget : widgets) {
if (widget.getBounds().contains(x, y)) widget.onMouseClicked(x, y, button);
}
}
@Override
public void actionPerformed(IGuiWidget widget) {
}
public void redraw() {
buttonList.clear();
widgets.clear();
initGui();
}
}
| 5,015 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
GuiScreenBase.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/client/gui/GuiScreenBase.java | package net.quetzi.bluepower.client.gui;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.util.ResourceLocation;
import cpw.mods.fml.client.FMLClientHandler;
/**
*
* @author MineMaarten
*/
public abstract class GuiScreenBase extends GuiScreen {
protected int guiLeft, guiTop, xSize, ySize;
public GuiScreenBase(int xSize, int ySize) {
this.xSize = xSize;
this.ySize = ySize;
}
@Override
public void initGui() {
super.initGui();
guiLeft = width / 2 - xSize / 2;
guiTop = height / 2 - ySize / 2;
}
protected abstract ResourceLocation getTexture();
@Override
public void drawScreen(int x, int y, float partialTicks) {
if (getTexture() != null) {
drawDefaultBackground();
FMLClientHandler.instance().getClient().getTextureManager().bindTexture(getTexture());
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
}
super.drawScreen(x, y, partialTicks);
}
}
| 1,061 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
GuiEjector.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/client/gui/GuiEjector.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*
* @author Quetzi
*/
package net.quetzi.bluepower.client.gui;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import net.quetzi.bluepower.containers.ContainerEjector;
import net.quetzi.bluepower.references.Refs;
import net.quetzi.bluepower.tileentities.tier1.TileEjector;
public class GuiEjector extends GuiBase {
private static final ResourceLocation resLoc = new ResourceLocation(Refs.MODID, "textures/gui/seedBag.png");
public GuiEjector(InventoryPlayer invPlayer, TileEjector ejector) {
super(new ContainerEjector(invPlayer, ejector), resLoc);
}
}
| 1,355 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
GuiGateSingleTime.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/client/gui/gate/GuiGateSingleTime.java | package net.quetzi.bluepower.client.gui.gate;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.ResourceLocation;
import net.quetzi.bluepower.part.gate.GateBase;
import net.quetzi.bluepower.references.Refs;
/**
*
* @author MineMaarten
*/
public abstract class GuiGateSingleTime extends GuiGate {
private static final ResourceLocation resLoc = new ResourceLocation(Refs.MODID, "textures/gui/gate.png");
private static final String[] buttonTexts = { "-10s", "-1s", "-50ms", "+50ms", "+1s", "+10s" };
private static final int[] buttonActions = { -200, -20, -1, 1, 20, 200 };
public GuiGateSingleTime(GateBase gate) {
super(gate, 228, 66);
}
@SuppressWarnings("unchecked")
@Override
public void initGui() {
super.initGui();
int buttonWidth = 35;
for (int i = 0; i < buttonTexts.length; i++) {
buttonList.add(new GuiButton(i, guiLeft + 4 + i * (buttonWidth + 2), guiTop + 35, buttonWidth, 20, buttonTexts[i]));
}
}
@Override
public void actionPerformed(GuiButton button) {
int newTimerValue = getCurrentIntervalTicks() + buttonActions[button.id];
if (newTimerValue <= 1) newTimerValue = 2;
sendToServer(0, newTimerValue);
}
@Override
protected ResourceLocation getTexture() {
return resLoc;
}
@Override
public void drawScreen(int x, int y, float partialTicks) {
super.drawScreen(x, y, partialTicks);
drawCenteredString(fontRendererObj, I18n.format("gui.timerInterval") + ": " + getTimerValue(getCurrentIntervalTicks()), guiLeft + xSize / 2, guiTop + 10, 0xFFFFFF);
}
private String getTimerValue(int ticks) {
int time = ticks * 50;
if (time >= 1000) {
return time / 1000 + "." + time % 1000 + "s";
} else {
return time + "ms";
}
}
protected abstract int getCurrentIntervalTicks();
}
| 2,031 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
GuiGateCounter.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/client/gui/gate/GuiGateCounter.java | package net.quetzi.bluepower.client.gui.gate;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.ResourceLocation;
import net.quetzi.bluepower.part.gate.GateBase;
import net.quetzi.bluepower.references.Refs;
public abstract class GuiGateCounter extends GuiGate {
private static final ResourceLocation resLoc = new ResourceLocation(Refs.MODID, "textures/gui/gateBig.png");
private static final String[] buttonTexts = { "-25", "-5", "-1", "+1", "+5", "+25" };
private static final int[] buttonActions = { -25, -5, -1, +1, +5, +25 };
public GuiGateCounter(GateBase gate) {
super(gate, 228, 120);
}
@SuppressWarnings("unchecked")
@Override
public void initGui() {
super.initGui();
int buttonWidth = 35;
for (int y = 0; y < 3; y++) {
for (int i = 0; i < buttonTexts.length; i++) {
buttonList.add(new GuiButton(y * buttonTexts.length + i, guiLeft + 4 + i * (buttonWidth + 2), guiTop + 25 + (y * 35), buttonWidth, 20, buttonTexts[i]));
}
}
}
@Override
public void actionPerformed(GuiButton button) {
int id = (int) Math.floor(button.id / buttonTexts.length);
int subButton = button.id % buttonTexts.length;
int val = 0;
int min = 0;
int max = 0;
switch (id) {
case 0:
val = getCurrentMax();
min = 1;
max = Short.MAX_VALUE;
break;
case 1:
val = getCurrentIncrement();
min = 1;
max = Short.MAX_VALUE;
break;
case 2:
val = getCurrentDecrement();
min = 1;
max = Short.MAX_VALUE;
break;
}
val += buttonActions[subButton];
if (val < min) val = min;
if (val > max) val = max;
System.out.println("Val: " + val + " - " + id);
sendToServer(id, val);
}
@Override
protected ResourceLocation getTexture() {
return resLoc;
}
@Override
public void drawScreen(int x, int y, float partialTicks) {
super.drawScreen(x, y, partialTicks);
drawCenteredString(fontRendererObj, I18n.format("gui.counterMax") + ": " + getCurrentMax(), guiLeft + xSize / 2, guiTop + 10, 0xFFFFFF);
drawCenteredString(fontRendererObj, I18n.format("gui.counterIncrement") + ": " + getCurrentIncrement(), guiLeft + xSize / 2, guiTop + 10 + 38, 0xFFFFFF);
drawCenteredString(fontRendererObj, I18n.format("gui.counterDecrement") + ": " + getCurrentDecrement(), guiLeft + xSize / 2, guiTop + 10 + 38 + 35, 0xFFFFFF);
}
protected abstract int getCurrentMax();
protected abstract int getCurrentIncrement();
protected abstract int getCurrentDecrement();
}
| 2,937 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
GuiGate.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/client/gui/gate/GuiGate.java | package net.quetzi.bluepower.client.gui.gate;
import net.quetzi.bluepower.client.gui.GuiScreenBase;
import net.quetzi.bluepower.network.NetworkHandler;
import net.quetzi.bluepower.network.messages.MessageGuiUpdate;
import net.quetzi.bluepower.part.gate.GateBase;
/**
*
* @author MineMaarten
*/
public abstract class GuiGate extends GuiScreenBase {
private final GateBase gate;
public GuiGate(GateBase gate, int xSize, int ySize) {
super(xSize, ySize);
this.gate = gate;
}
protected void sendToServer(int id, int value) {
NetworkHandler.sendToServer(new MessageGuiUpdate(gate, id, value));
}
@Override
public boolean doesGuiPauseGame() {
return false;
}
}
| 761 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
IGuiWidget.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/client/gui/widget/IGuiWidget.java | package net.quetzi.bluepower.client.gui.widget;
import java.awt.Rectangle;
import java.util.List;
public interface IGuiWidget {
public void setListener(IWidgetListener gui);
public int getID();
public void render(int mouseX, int mouseY);
public void onMouseClicked(int mouseX, int mouseY, int button);
public void addTooltip(List<String> curTip, boolean shiftPressed);
public Rectangle getBounds();
}
| 457 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
WidgetMode.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/client/gui/widget/WidgetMode.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.client.gui.widget;
/**
* @author MineMaarten
*/
public class WidgetMode extends BaseWidget {
public final int maxMode;
public WidgetMode(int id, int x, int y, int textureX, int maxMode, String texture) {
super(id, x, y, 14, 14, textureX, 0, texture);
this.maxMode = maxMode;
}
@Override
public void onMouseClicked(int mouseX, int mouseY, int button) {
if (button == 0) {
if (++value >= maxMode) value = 0;
} else if (button == 1) {
if (--value < 0) value = maxMode - 1;
}
super.onMouseClicked(mouseX, mouseY, button);
}
@Override
protected int getTextureV() {
return value * 14;
}
@Override
protected int getTextureWidth() {
return 256;
}
@Override
protected int getTextureHeight() {
return 256;
}
}
| 1,673 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
WidgetColor.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/client/gui/widget/WidgetColor.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.client.gui.widget;
import java.util.List;
import net.minecraft.client.gui.Gui;
import net.minecraft.item.ItemDye;
import net.quetzi.bluepower.references.Refs;
import org.lwjgl.opengl.GL11;
/**
* @author MineMaarten
*/
public class WidgetColor extends BaseWidget {
public WidgetColor(int id, int x, int y) {
super(id, x, y, 14, 14, Refs.MODID + ":textures/gui/widgets/color_widget.png");
}
@Override
public void onMouseClicked(int mouseX, int mouseY, int button) {
if (button == 0) {
if (++value > 16) value = 0;
} else if (button == 1) {
if (--value < 0) value = 16;
}
super.onMouseClicked(mouseX, mouseY, button);
}
@Override
public void render(int mouseX, int mouseY) {
super.render(mouseX, mouseY);
if (value < 16) {
Gui.drawRect(x + 5, y + 5, x + 9, y + 9, 0xFF000000 + ItemDye.field_150922_c[value]);
GL11.glColor4d(1, 1, 1, 1);
}
}
@Override
public void addTooltip(List<String> curTooltip, boolean shiftPressed) {
if (value < 16) {
curTooltip.add("gui.widget.color." + ItemDye.field_150923_a[value]);
} else {
curTooltip.add("gui.widget.color.none");
}
}
}
| 2,072 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
IWidgetListener.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/client/gui/widget/IWidgetListener.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.client.gui.widget;
/**
* @author MineMaarten
*/
public interface IWidgetListener {
public void actionPerformed(IGuiWidget widget);
}
| 899 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
BaseWidget.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/client/gui/widget/BaseWidget.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.client.gui.widget;
import java.awt.Rectangle;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
/**
* @author MineMaarten
*/
public class BaseWidget implements IGuiWidget {
private final int id;
public int value; //just a generic value
protected final int x, y;
private final int width;
private final int height;
private final int textureU;
private final int textureV;
private final ResourceLocation[] textures;
protected int textureIndex = 0;
protected IWidgetListener gui;
public BaseWidget(int id, int x, int y, int width, int height, String... textureLocs) {
this(id, x, y, width, height, 0, 0, textureLocs);
}
public BaseWidget(int id, int x, int y, int width, int height, int textureU, int textureV, String... textureLocs) {
this.id = id;
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.textureU = textureU;
this.textureV = textureV;
textures = new ResourceLocation[textureLocs.length];
for (int i = 0; i < textures.length; i++) {
textures[i] = new ResourceLocation(textureLocs[i]);
}
}
@Override
public int getID() {
return id;
}
@Override
public void setListener(IWidgetListener gui) {
this.gui = gui;
}
@Override
public void render(int mouseX, int mouseY) {
GL11.glColor4d(1, 1, 1, 1);
if (textures.length > 0) Minecraft.getMinecraft().getTextureManager().bindTexture(textures[textureIndex]);
Gui.func_146110_a(x, y, getTextureU(), getTextureV(), width, height, getTextureWidth(), getTextureHeight());
}
protected int getTextureU() {
return textureU;
}
protected int getTextureV() {
return textureV;
}
protected int getTextureWidth() {
return width;
}
protected int getTextureHeight() {
return height;
}
@Override
public void onMouseClicked(int mouseX, int mouseY, int button) {
gui.actionPerformed(this);
}
@Override
public Rectangle getBounds() {
return new Rectangle(x, y, width, height);
}
@Override
public void addTooltip(List<String> curTip, boolean shiftPressed) {
}
}
| 3,415 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
NetworkHandler.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/network/NetworkHandler.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.network;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.world.World;
import net.quetzi.bluepower.network.messages.LocationDoublePacket;
import net.quetzi.bluepower.network.messages.LocationIntPacket;
import net.quetzi.bluepower.network.messages.MessageGuiUpdate;
import net.quetzi.bluepower.references.Refs;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import cpw.mods.fml.relauncher.Side;
/**
*
* @author MineMaarten
*/
public class NetworkHandler {
public static final SimpleNetworkWrapper INSTANCE = NetworkRegistry.INSTANCE.newSimpleChannel(Refs.MODID);
private static int discriminant;
/*
* The integer is the ID of the message, the Side is the side this message will be handled (received) on!
*/
public static void init() {
INSTANCE.registerMessage(MessageGuiUpdate.class, MessageGuiUpdate.class, discriminant++, Side.SERVER);
}
/* public static void INSTANCE.registerMessage(Class<? extends AbstractPacket<? extends IMessage>> clazz){
INSTANCE.registerMessage(clazz, clazz, discriminant++, Side.SERVER, discriminant++, Side.SERVER);
}*/
public static void sendToAll(IMessage message) {
INSTANCE.sendToAll(message);
}
public static void sendTo(IMessage message, EntityPlayerMP player) {
INSTANCE.sendTo(message, player);
}
@SuppressWarnings("rawtypes")
public static void sendToAllAround(LocationIntPacket message, World world, double distance) {
sendToAllAround(message, message.getTargetPoint(world, distance));
}
@SuppressWarnings("rawtypes")
public static void sendToAllAround(LocationIntPacket message, World world) {
sendToAllAround(message, message.getTargetPoint(world));
}
@SuppressWarnings("rawtypes")
public static void sendToAllAround(LocationDoublePacket message, World world) {
sendToAllAround(message, message.getTargetPoint(world));
}
public static void sendToAllAround(IMessage message, NetworkRegistry.TargetPoint point) {
INSTANCE.sendToAllAround(message, point);
}
public static void sendToDimension(IMessage message, int dimensionId) {
INSTANCE.sendToDimension(message, dimensionId);
}
public static void sendToServer(IMessage message) {
INSTANCE.sendToServer(message);
}
}
| 3,346 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
LocationIntPacket.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/network/messages/LocationIntPacket.java | package net.quetzi.bluepower.network.messages;
import io.netty.buffer.ByteBuf;
import net.minecraft.block.Block;
import net.minecraft.world.World;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
/**
*
* @author MineMaarten
*/
public abstract class LocationIntPacket<REQ extends IMessage> extends AbstractPacket<REQ> {
protected int x, y, z;
public LocationIntPacket() {
}
public LocationIntPacket(int x, int y, int z) {
this.x = x;
this.y = y;
this.z = z;
}
@Override
public void toBytes(ByteBuf buf) {
buf.writeInt(x);
buf.writeInt(y);
buf.writeInt(z);
}
@Override
public void fromBytes(ByteBuf buf) {
x = buf.readInt();
y = buf.readInt();
z = buf.readInt();
}
public NetworkRegistry.TargetPoint getTargetPoint(World world) {
return getTargetPoint(world, 64);
}
public NetworkRegistry.TargetPoint getTargetPoint(World world, double updateDistance) {
return new NetworkRegistry.TargetPoint(world.provider.dimensionId, x, y, z, updateDistance);
}
protected Block getBlock(World world) {
return world.getBlock(x, y, z);
}
}
| 1,328 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
LocationDoublePacket.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/network/messages/LocationDoublePacket.java | package net.quetzi.bluepower.network.messages;
import io.netty.buffer.ByteBuf;
import net.minecraft.world.World;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
/**
*
* @author MineMaarten
*/
public abstract class LocationDoublePacket<REQ extends IMessage> extends AbstractPacket<REQ> {
protected double x, y, z;
public LocationDoublePacket() {
}
public LocationDoublePacket(double x, double y, double z) {
this.x = x;
this.y = y;
this.z = z;
}
@Override
public void toBytes(ByteBuf buf) {
buf.writeDouble(x);
buf.writeDouble(y);
buf.writeDouble(z);
}
@Override
public void fromBytes(ByteBuf buf) {
x = buf.readDouble();
y = buf.readDouble();
z = buf.readDouble();
}
public NetworkRegistry.TargetPoint getTargetPoint(World world) {
return getTargetPoint(world, 64);
}
public NetworkRegistry.TargetPoint getTargetPoint(World world, double updateDistance) {
return new NetworkRegistry.TargetPoint(world.provider.dimensionId, x, y, z, updateDistance);
}
}
| 1,233 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
AbstractPacket.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/network/messages/AbstractPacket.java | package net.quetzi.bluepower.network.messages;
import net.minecraft.entity.player.EntityPlayer;
import net.quetzi.bluepower.BluePower;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import cpw.mods.fml.relauncher.Side;
/**
*
* @author MineMaarten
*/
public abstract class AbstractPacket<REQ extends IMessage> implements IMessage, IMessageHandler<REQ, REQ> {
@Override
public REQ onMessage(REQ message, MessageContext ctx) {
if (ctx.side == Side.SERVER) {
handleServerSide(message, ctx.getServerHandler().playerEntity);
} else {
handleClientSide(message, BluePower.proxy.getPlayer());
}
return null;
}
/**
* Handle a packet on the client side.
* @param message TODO
* @param player the player reference
*/
public abstract void handleClientSide(REQ message, EntityPlayer player);
/**
* Handle a packet on the server side.
* @param message TODO
* @param player the player reference
*/
public abstract void handleServerSide(REQ message, EntityPlayer player);
}
| 1,241 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
MessageGuiUpdate.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/network/messages/MessageGuiUpdate.java | package net.quetzi.bluepower.network.messages;
import io.netty.buffer.ByteBuf;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.quetzi.bluepower.BluePower;
import net.quetzi.bluepower.api.part.BPPart;
import net.quetzi.bluepower.compat.CompatibilityUtils;
import net.quetzi.bluepower.compat.fmp.IMultipartCompat;
import net.quetzi.bluepower.compat.fmp.MultipartBPPart;
import net.quetzi.bluepower.part.IGuiButtonSensitive;
import net.quetzi.bluepower.references.Dependencies;
import codechicken.multipart.TMultiPart;
import codechicken.multipart.TileMultipart;
import cpw.mods.fml.common.Optional;
/**
*
* @author MineMaarten
*/
public class MessageGuiUpdate extends LocationIntPacket<MessageGuiUpdate> {
private int partId;
private int messageId;
private int value;
public MessageGuiUpdate() {
}
/**
*
* @param part should also implement IGuiButtonSensitive to be able to receive this packet.
* @param messageId
* @param value
*/
public MessageGuiUpdate(BPPart part, int messageId, int value) {
super(part.x, part.y, part.z);
if (part.isFMPMultipart()) {
partId = getPartId(part);
}
this.messageId = messageId;
this.value = value;
}
public MessageGuiUpdate(TileEntity tile, int messageId, int value) {
super(tile.xCoord, tile.yCoord, tile.zCoord);
partId = -1;
this.messageId = messageId;
this.value = value;
}
@Optional.Method(modid = Dependencies.FMP)
private int getPartId(BPPart part) {
List<TMultiPart> parts = ((TileMultipart) part.world.getTileEntity(part.x, part.y, part.z)).jPartList();
for (int i = 0; i < parts.size(); i++) {
if (parts.get(i) instanceof MultipartBPPart) {
if (((MultipartBPPart) parts.get(i)).getPart() == part) return i;
}
}
throw new IllegalArgumentException("[BluePower][MessageGuiPacket] No part found for sent GUI packet");
}
@Override
public void toBytes(ByteBuf buf) {
super.toBytes(buf);
buf.writeInt(messageId);
buf.writeInt(partId);
buf.writeInt(value);
}
@Override
public void fromBytes(ByteBuf buf) {
super.fromBytes(buf);
messageId = buf.readInt();
partId = buf.readInt();
value = buf.readInt();
}
@Override
public void handleClientSide(MessageGuiUpdate message, EntityPlayer player) {
}
@Override
public void handleServerSide(MessageGuiUpdate message, EntityPlayer player) {
IMultipartCompat compat = (IMultipartCompat) CompatibilityUtils.getModule(Dependencies.FMP);
TileEntity te = player.worldObj.getTileEntity(message.x, message.y, message.z);
if (compat.isMultipart(te)) {
messagePart(te, message);
} else {
if (te instanceof IGuiButtonSensitive) {
((IGuiButtonSensitive) te).onButtonPress(message.messageId, message.value);
}
}
}
@Optional.Method(modid = Dependencies.FMP)
private void messagePart(TileEntity te, MessageGuiUpdate message) {
List<TMultiPart> parts = ((TileMultipart) te).jPartList();
if (message.partId < parts.size()) {
TMultiPart part = parts.get(message.partId);
if (part instanceof MultipartBPPart) {
if (((MultipartBPPart) part).getPart() instanceof IGuiButtonSensitive) {
((IGuiButtonSensitive) ((MultipartBPPart) part).getPart()).onButtonPress(message.messageId, message.value);
} else {
BluePower.log.error("[BluePower][MessageGuiPacket] Part doesn't implement IGuiButtonSensitive");
}
}
}
}
}
| 3,952 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
ItemBPPart.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/part/ItemBPPart.java | /*
* This file is part of Blue Power. Blue Power is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Blue Power is
* distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along
* with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.part;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.quetzi.bluepower.api.part.PartRegistry;
import net.quetzi.bluepower.references.Refs;
public class ItemBPPart extends Item {
public ItemBPPart() {
super();
setUnlocalizedName(Refs.MODID + ".part");
}
public static String getUnlocalizedName_(ItemStack item) {
return Refs.MODID + ".part." + PartRegistry.getPartIdFromItem(item);// TODO Unlocalized names for parts
}
@SuppressWarnings({ "rawtypes", "unchecked" })
public static void getSubItems(List l) {
for (String id : PartRegistry.getRegisteredParts())
l.add(PartRegistry.getItemForPart(id));
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World w, int x, int y, int z, int side, float f, float f2, float f3) {
boolean flag = true;
if (flag) {
w.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, Block.soundTypeWood.soundName, Block.soundTypeWood.getVolume(),
Block.soundTypeWood.getPitch());
// TODO Place part without FMP
return true;
}
return false;
}
@Override
public boolean getHasSubtypes() {
return true;
}
@Override
public String getUnlocalizedName(ItemStack item) {
return getUnlocalizedName_(item);
}
@SuppressWarnings({ "rawtypes" })
@Override
public void getSubItems(Item unused, CreativeTabs tab, List l) {
getSubItems(l);
}
}
| 2,507 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
IGuiButtonSensitive.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/part/IGuiButtonSensitive.java | package net.quetzi.bluepower.part;
/**
* Implemented by BPParts, this interface can be used to sync client side gui input with server.
* TODO: make work for ordinary TileEntities
* @author MineMaarten
*/
public interface IGuiButtonSensitive {
public void onButtonPress(int messageId, int value);
}
| 312 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
RedAlloyWire.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/part/cable/RedAlloyWire.java | package net.quetzi.bluepower.part.cable;
import java.util.List;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraftforge.common.util.ForgeDirection;
import net.quetzi.bluepower.api.part.BPPartFace;
import net.quetzi.bluepower.api.part.redstone.IBPRedstoneConductor;
import net.quetzi.bluepower.api.part.redstone.IBPRedstonePart;
import net.quetzi.bluepower.api.part.redstone.RedstoneNetwork;
import net.quetzi.bluepower.api.vec.Vector3;
import net.quetzi.bluepower.init.CustomTabs;
public class RedAlloyWire extends BPPartFace implements IBPRedstoneConductor {
private int color = -1;
private String name = "";
/**
* @author amadornes
*
*/
public RedAlloyWire(String name, Integer color) {
this.color = color.intValue();
this.name = name;
}
/**
* @author amadornes
*
*/
public RedAlloyWire() {
}
@Override
public String getType() {
return "redalloy" + (color >= 0 ? "." + name : "");
}
@Override
public String getUnlocalizedName() {
return "redalloy" + (color >= 0 ? "." + name : "");
}
@Override
public List<IBPRedstonePart> getConnections(ForgeDirection side) {
return null;
}
private RedstoneNetwork net;
@Override
public RedstoneNetwork getNetwork() {
return net;
}
@Override
public void setNetwork(RedstoneNetwork network) {
net = network;
}
@Override
public void onUpdateConnection() {
markPartForRenderUpdate();
}
@Override
public void onRedstoneUpdate() {
markPartForRenderUpdate();
}
@Override
public boolean renderStatic(Vector3 loc, int pass) {
return true;
}
@Override
public CreativeTabs getCreativeTab() {
return CustomTabs.tabBluePowerCircuits;
}
@Override
public int getCreativeTabIndex() {
return 1;
}
}
| 2,063 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
GateMux.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/part/gate/GateMux.java | package net.quetzi.bluepower.part.gate;
import java.util.List;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.AxisAlignedBB;
import net.quetzi.bluepower.api.part.FaceDirection;
import net.quetzi.bluepower.api.part.RedstoneConnection;
import net.quetzi.bluepower.client.renderers.RenderHelper;
import net.quetzi.bluepower.references.Refs;
import net.quetzi.bluepower.util.Color;
public class GateMux extends GateBase {
@Override
public void initializeConnections(RedstoneConnection front, RedstoneConnection left, RedstoneConnection back, RedstoneConnection right) {
// Init front
front.enable();
front.setOutput();
// Init left
left.enable();
left.setInput();
// Init back
back.enable();
back.setInput();
// Init right
right.enable();
right.setInput();
}
@Override
public String getGateID() {
return "multiplexer";
}
@Override
public void renderTop(RedstoneConnection front, RedstoneConnection left, RedstoneConnection back, RedstoneConnection right, float frame) {
// renderTopTexture(FaceDirection.FRONT, false);
renderTopTexture(FaceDirection.LEFT, left.getPower() > 0 || back.getPower() == 0);
renderTopTexture(FaceDirection.RIGHT, right.getPower() > 0 || back.getPower() > 0);
renderTopTexture(FaceDirection.BACK, back.getPower() > 0);
RenderHelper.renderRedstoneTorch(0, 1D / 8D, 2 / 16D, 9D / 16D, back.getPower() == 0);
boolean frontLeft = !(left.getPower() > 0 || back.getPower() == 0);
boolean frontRight = !(right.getPower() > 0 || back.getPower() > 0);
RenderHelper.renderRedstoneTorch(4 / 16D, 1D / 8D, -1 / 16D, 9D / 16D, frontRight);
RenderHelper.renderRedstoneTorch(-4 / 16D, 1D / 8D, -1 / 16D, 9D / 16D, frontLeft);
renderTopTexture(Refs.MODID + ":textures/blocks/gates/" + getType() + "/frontleft_" + (frontLeft ? "on" : "off") + ".png");
renderTopTexture(Refs.MODID + ":textures/blocks/gates/" + getType() + "/frontright_" + (frontRight ? "on" : "off") + ".png");
RenderHelper.renderRedstoneTorch(0, 1D / 8D, -4 / 16D, 9D / 16D, !frontLeft && !frontRight);
}
@Override
public void addOcclusionBoxes(List<AxisAlignedBB> boxes) {
super.addOcclusionBoxes(boxes);
boxes.add(AxisAlignedBB.getBoundingBox(7D / 16D, 2D / 16D, 7D / 16D, 9D / 16D, 8D / 16D, 9D / 16D));
}
@Override
public void doLogic(RedstoneConnection front, RedstoneConnection left, RedstoneConnection back, RedstoneConnection right) {
boolean selected = back.getPower() > 0;
int out = 0;
if (selected) {
out = left.getPower();
} else {
out = right.getPower();
}
front.setPower(out);
}
@Override
public void addWailaInfo(List<String> info) {
info.add(I18n.format("gui.passThrough") + ": " + Color.YELLOW
+ (getConnection(FaceDirection.BACK).getPower() > 0 ? FaceDirection.LEFT.getLocalizedName() : FaceDirection.RIGHT.getLocalizedName()));
}
}
| 3,262 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
GatePulseFormer.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/part/gate/GatePulseFormer.java | package net.quetzi.bluepower.part.gate;
import java.util.List;
import net.minecraft.util.AxisAlignedBB;
import net.quetzi.bluepower.api.part.FaceDirection;
import net.quetzi.bluepower.api.part.RedstoneConnection;
import net.quetzi.bluepower.client.renderers.RenderHelper;
public class GatePulseFormer extends GateBase {
private boolean power[] = new boolean[4];
@Override
public void initializeConnections(RedstoneConnection front, RedstoneConnection left, RedstoneConnection back, RedstoneConnection right) {
// Init front
front.enable();
front.setOutput();
// Init left
left.disable();
// Init back
back.enable();
back.setInput();
// Init right
right.disable();
}
@Override
public String getGateID() {
return "pulseformer";
}
@Override
public void renderTop(RedstoneConnection front, RedstoneConnection left, RedstoneConnection back, RedstoneConnection right, float frame) {
RenderHelper.renderRedstoneTorch(-3 / 16D, 1D / 8D, 1 / 16D, 9D / 16D, !power[0]);
RenderHelper.renderRedstoneTorch(3 / 16D, 1D / 8D, 1 / 16D, 9D / 16D, false);
RenderHelper.renderRedstoneTorch(0, 1D / 8D, -5 / 16D, 9D / 16D, !power[2] && power[1]);
renderTopTexture(FaceDirection.BACK, power[0]);
renderTopTexture(FaceDirection.LEFT, !power[1]);
renderTopTexture(FaceDirection.RIGHT, power[2]);
}
@Override
public void addOcclusionBoxes(List<AxisAlignedBB> boxes) {
super.addOcclusionBoxes(boxes);
}
@Override
public void doLogic(RedstoneConnection front, RedstoneConnection left, RedstoneConnection back, RedstoneConnection right) {
power[3] = power[2];
power[2] = power[1];
power[1] = power[0];
power[0] = back.getPower() > 0;
if (power[2] && !power[3]) {
front.setPower(15);
} else {
front.setPower(0);
}
}
@Override
public void addWailaInfo(List<String> info) {
}
}
| 2,175 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
GateNot.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/part/gate/GateNot.java | package net.quetzi.bluepower.part.gate;
import java.util.List;
import net.minecraft.util.AxisAlignedBB;
import net.quetzi.bluepower.api.part.FaceDirection;
import net.quetzi.bluepower.api.part.RedstoneConnection;
import net.quetzi.bluepower.client.renderers.RenderHelper;
public class GateNot extends GateBase {
private boolean power = false;
@Override
public void initializeConnections(RedstoneConnection front, RedstoneConnection left, RedstoneConnection back, RedstoneConnection right) {
// Init front
front.enable();
front.setOutput();
// Init left
left.enable();
left.setOutput();
// Init back
back.enable();
back.setInput();
// Init right
right.enable();
right.setOutput();
}
@Override
public String getGateID() {
return "not";
}
@Override
public void renderTop(RedstoneConnection front, RedstoneConnection left, RedstoneConnection back, RedstoneConnection right, float frame) {
renderTopTexture(FaceDirection.FRONT, !power);
renderTopTexture(FaceDirection.LEFT, !power);
renderTopTexture(FaceDirection.RIGHT, !power);
renderTopTexture(FaceDirection.BACK, back.getPower() > 0);
RenderHelper.renderRedstoneTorch(0, 1D / 8D, 0, 9D / 16D, !power);
}
@Override
public void addOcclusionBoxes(List<AxisAlignedBB> boxes) {
super.addOcclusionBoxes(boxes);
boxes.add(AxisAlignedBB.getBoundingBox(7D / 16D, 2D / 16D, 7D / 16D, 9D / 16D, 8D / 16D, 9D / 16D));
}
@Override
public void doLogic(RedstoneConnection front, RedstoneConnection left, RedstoneConnection back, RedstoneConnection right) {
power = back.getPower() > 0;
left.setPower(!power ? 15 : 0);
front.setPower(!power ? 15 : 0);
right.setPower(!power ? 15 : 0);
}
@Override
public void addWailaInfo(List<String> info) {
}
}
| 2,066 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
GateBuffer.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/part/gate/GateBuffer.java | package net.quetzi.bluepower.part.gate;
import java.util.List;
import net.minecraft.util.AxisAlignedBB;
import net.quetzi.bluepower.api.part.FaceDirection;
import net.quetzi.bluepower.api.part.RedstoneConnection;
import net.quetzi.bluepower.client.renderers.RenderHelper;
import net.quetzi.bluepower.references.Refs;
public class GateBuffer extends GateBase {
private boolean[] power = new boolean[] { false, false, false };
@Override
public void initializeConnections(RedstoneConnection front, RedstoneConnection left, RedstoneConnection back, RedstoneConnection right) {
// Init front
front.enable();
front.setOutput();
// Init left
left.enable();
left.setOutput();
// Init back
back.enable();
back.setInput();
// Init right
right.enable();
right.setOutput();
}
@Override
public String getGateID() {
return "buffer";
}
@Override
public void renderTop(RedstoneConnection front, RedstoneConnection left, RedstoneConnection back, RedstoneConnection right, float frame) {
renderTopTexture(Refs.MODID + ":textures/blocks/gates/" + getType() + "/center_" + (!power[1] ? "on" : "off") + ".png");
renderTopTexture(FaceDirection.LEFT, power[0]);
renderTopTexture(FaceDirection.RIGHT, power[0]);
renderTopTexture(FaceDirection.BACK, back.getPower() > 0);
RenderHelper.renderRedstoneTorch(0, 1D / 8D, 0, 8D / 16D, !power[1]);
RenderHelper.renderRedstoneTorch(0, 1D / 8D, -4D / 16D, 10D / 16D, power[0]);
}
@Override
public void addOcclusionBoxes(List<AxisAlignedBB> boxes) {
super.addOcclusionBoxes(boxes);
boxes.add(AxisAlignedBB.getBoundingBox(7D / 16D, 2D / 16D, 7D / 16D, 9D / 16D, 8D / 16D, 9D / 16D));
}
@Override
public void doLogic(RedstoneConnection front, RedstoneConnection left, RedstoneConnection back, RedstoneConnection right) {
power[2] = back.getPower() > 0;
left.setPower(power[0] ? 15 : 0);
front.setPower(power[0] ? 15 : 0);
right.setPower(power[0] ? 15 : 0);
power[0] = power[1];
power[1] = power[2];
power[2] = false;
}
@Override
public void addWailaInfo(List<String> info) {
}
}
| 2,420 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
GateSequencer.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/part/gate/GateSequencer.java | package net.quetzi.bluepower.part.gate;
import java.util.Arrays;
import java.util.List;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.resources.I18n;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import net.quetzi.bluepower.api.part.RedstoneConnection;
import net.quetzi.bluepower.client.gui.gate.GuiGateSingleTime;
import net.quetzi.bluepower.client.renderers.RenderHelper;
import net.quetzi.bluepower.part.IGuiButtonSensitive;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class GateSequencer extends GateBase implements IGuiButtonSensitive {
private final boolean[] power = new boolean[4];
private int start = -1;
private int time = 160;
private int ticks = 0;
@Override
public void initializeConnections(RedstoneConnection front, RedstoneConnection left, RedstoneConnection back, RedstoneConnection right) {
// Init front
front.enable();
front.setOutput();
// Init left
left.enable();
left.setOutput();
// Init back
back.enable();
back.setOutput();
// Init right
right.enable();
right.setOutput();
}
@Override
public String getGateID() {
return "sequencer";
}
@Override
public void renderTop(RedstoneConnection front, RedstoneConnection left, RedstoneConnection back, RedstoneConnection right, float frame) {
RenderHelper.renderRedstoneTorch(0, 1D / 8D, -5D / 16D, 8D / 16D, power[1]);
RenderHelper.renderRedstoneTorch(5D / 16D, 1D / 8D, 0, 8D / 16D, power[2]);
RenderHelper.renderRedstoneTorch(0, 1D / 8D, 5D / 16D, 8D / 16D, power[3]);
RenderHelper.renderRedstoneTorch(-5D / 16D, 1D / 8D, 0, 8D / 16D, power[0]);
RenderHelper.renderRedstoneTorch(0, 1D / 8D, 0, 13D / 16D, true);
RenderHelper.renderPointer(0, 7D / 16D, 0, world != null ? start >= 0 ? 1 - (double) (ticks - start + frame) / (double) time : 0 : 0);
}
@Override
public void addOcclusionBoxes(List<AxisAlignedBB> boxes) {
super.addOcclusionBoxes(boxes);
boxes.add(AxisAlignedBB.getBoundingBox(7D / 16D, 2D / 16D, 7D / 16D, 9D / 16D, 12D / 16D, 9D / 16D));
}
@Override
public void doLogic(RedstoneConnection front, RedstoneConnection left, RedstoneConnection back, RedstoneConnection right) {
Arrays.fill(power, false);
if (start >= 0) {
if (ticks >= start + time) {
start = ticks;
}
} else {
start = ticks;
}
double t = (double) (ticks - start) / (double) time;
if (t >= 1D / 8D && t < 3D / 8D) {
power[2] = true;
} else if (t >= 3D / 8D && t < 5D / 8D) {
power[3] = true;
} else if (t >= 5D / 8D && t < 7D / 8D) {
power[0] = true;
} else if (t >= 7D / 8D && t < 1 || t >= 0 && t < 1D / 8D) {
power[1] = true;
}
left.setPower(power[0] ? 15 : 0);
front.setPower(power[1] ? 15 : 0);
right.setPower(power[2] ? 15 : 0);
back.setPower(power[3] ? 15 : 0);
ticks++;
}
@Override
public void save(NBTTagCompound tag) {
super.save(tag);
tag.setInteger("start", start);
tag.setInteger("ticks", ticks);
tag.setInteger("time", time);
}
@Override
public void load(NBTTagCompound tag) {
super.load(tag);
start = tag.getInteger("start");
ticks = tag.getInteger("ticks");
time = tag.getInteger("time");
}
@Override
public void onButtonPress(int messageId, int value) {
time = value * 4;
sendUpdatePacket();
}
@Override
@SideOnly(Side.CLIENT)
public GuiScreen getGui() {
return new GuiGateSingleTime(this) {
@Override
protected int getCurrentIntervalTicks() {
return time / 4;
}
};
}
@Override
protected boolean hasGUI() {
return true;
}
@Override
public void addWailaInfo(List<String> info) {
String t = "";
int time = (this.time / 4) * 50;
if (time >= 1000) {
t = time / 1000 + "." + time % 1000 + "s";
} else {
t = time + "ms";
}
info.add(I18n.format("gui.timerInterval") + ": " + t);
}
}
| 4,713 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
GateRandomizer.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/part/gate/GateRandomizer.java | package net.quetzi.bluepower.part.gate;
import java.util.List;
import java.util.Random;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import net.quetzi.bluepower.api.part.FaceDirection;
import net.quetzi.bluepower.api.part.RedstoneConnection;
import net.quetzi.bluepower.client.renderers.RenderHelper;
import net.quetzi.bluepower.references.Refs;
public class GateRandomizer extends GateBase {
private static final Random random = new Random();
private int ticks = 0;
private boolean out[] = new boolean[3];
@Override
public void initializeConnections(RedstoneConnection front, RedstoneConnection left, RedstoneConnection back, RedstoneConnection right) {
// Init front
front.enable();
front.setOutput();
// Init left
left.enable();
left.setOutput();
// Init back
back.enable();
back.setInput();
// Init right
right.enable();
right.setOutput();
}
@Override
public String getGateID() {
return "randomizer";
}
@Override
public void renderTop(RedstoneConnection front, RedstoneConnection left, RedstoneConnection back, RedstoneConnection right, float frame) {
renderTopTexture(FaceDirection.LEFT, out[0]);
renderTopTexture(FaceDirection.FRONT, out[1]);
renderTopTexture(FaceDirection.RIGHT, out[2]);
renderTopTexture(Refs.MODID + ":textures/blocks/gates/" + getType() + "/center_" + (back.getPower() > 0 ? "on" : "off") + ".png");
RenderHelper.renderRandomizerButton(this, -4 / 16D, 0, 6 / 16D, out[0]);
RenderHelper.renderRandomizerButton(this, 0, 0, 0, out[1]);
RenderHelper.renderRandomizerButton(this, 4 / 16D, 0, 6 / 16D, out[2]);
}
@Override
public void addOcclusionBoxes(List<AxisAlignedBB> boxes) {
super.addOcclusionBoxes(boxes);
boxes.add(AxisAlignedBB.getBoundingBox(7D / 16D, 2D / 16D, 7D / 16D, 9D / 16D, 8D / 16D, 9D / 16D));
}
@Override
public void doLogic(RedstoneConnection front, RedstoneConnection left, RedstoneConnection back, RedstoneConnection right) {
if (!world.isRemote) {
if (back.getPower() > 0) {
if (ticks % 5 == 0) {
out[0] = random.nextBoolean();
out[1] = random.nextBoolean();
out[2] = random.nextBoolean();
sendUpdatePacket();
}
ticks++;
} else {
ticks = 0;
}
left.setPower(out[0] ? 15 : 0);
front.setPower(out[1] ? 15 : 0);
right.setPower(out[2] ? 15 : 0);
}
}
@Override
public void save(NBTTagCompound tag) {
super.save(tag);
tag.setBoolean("out_0", out[0]);
tag.setBoolean("out_1", out[1]);
tag.setBoolean("out_2", out[2]);
}
@Override
public void load(NBTTagCompound tag) {
super.load(tag);
out[0] = tag.getBoolean("out_0");
out[1] = tag.getBoolean("out_1");
out[2] = tag.getBoolean("out_2");
}
@Override
public void addWailaInfo(List<String> info) {
}
}
| 3,379 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
GateTimer.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/part/gate/GateTimer.java | package net.quetzi.bluepower.part.gate;
import java.util.List;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.resources.I18n;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import net.quetzi.bluepower.api.part.FaceDirection;
import net.quetzi.bluepower.api.part.RedstoneConnection;
import net.quetzi.bluepower.client.gui.gate.GuiGateSingleTime;
import net.quetzi.bluepower.client.renderers.RenderHelper;
import net.quetzi.bluepower.part.IGuiButtonSensitive;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class GateTimer extends GateBase implements IGuiButtonSensitive {
private boolean power = false;
private int time = 40;
private int ticks = 0;
@Override
public void initializeConnections(RedstoneConnection front, RedstoneConnection left, RedstoneConnection back, RedstoneConnection right) {
// Init front
front.enable();
front.setOutput();
// Init left
left.enable();
left.setOutput();
// Init back
back.enable();
back.setInput();
// Init right
right.enable();
right.setOutput();
}
@Override
public String getGateID() {
return "timer";
}
@Override
public void renderTop(RedstoneConnection front, RedstoneConnection left, RedstoneConnection back, RedstoneConnection right, float frame) {
// renderTopTexture(FaceDirection.FRONT, power);
renderTopTexture(FaceDirection.LEFT, power);
renderTopTexture(FaceDirection.RIGHT, power);
renderTopTexture(FaceDirection.BACK, back.getPower() > 0);
RenderHelper.renderRedstoneTorch(0, 1D / 8D, 0, 13D / 16D, true);
RenderHelper.renderPointer(0, 7D / 16D, 0, world != null ? back.getPower() == 0 ? 1 - (double) (ticks + frame) / (double) time : 0 : 0);
}
@Override
public void addOcclusionBoxes(List<AxisAlignedBB> boxes) {
super.addOcclusionBoxes(boxes);
boxes.add(AxisAlignedBB.getBoundingBox(7D / 16D, 2D / 16D, 7D / 16D, 9D / 16D, 12D / 16D, 9D / 16D));
}
@Override
public void doLogic(RedstoneConnection front, RedstoneConnection left, RedstoneConnection back, RedstoneConnection right) {
power = false;
if (back.getPower() == 0) {
if (ticks++ >= time) {
ticks = 0;
power = true;
}
} else {
ticks = 0;
}
left.setPower(power ? 15 : 0);
front.setPower(power ? 15 : 0);
right.setPower(power ? 15 : 0);
}
@Override
public void save(NBTTagCompound tag) {
super.save(tag);
tag.setInteger("ticks", ticks);
tag.setInteger("time", time);
}
@Override
public void load(NBTTagCompound tag) {
super.load(tag);
ticks = tag.getInteger("ticks");
time = tag.getInteger("time");
}
@Override
public void onButtonPress(int messageId, int value) {
time = value;
sendUpdatePacket();
}
@Override
@SideOnly(Side.CLIENT)
protected GuiScreen getGui() {
return new GuiGateSingleTime(this) {
@Override
protected int getCurrentIntervalTicks() {
return time;
}
};
}
@Override
protected boolean hasGUI() {
return true;
}
@Override
public void addWailaInfo(List<String> info) {
String t = "";
int time = this.time * 50;
if (time >= 1000) {
t = time / 1000 + "." + time % 1000 + "s";
} else {
t = time + "ms";
}
info.add(I18n.format("gui.timerInterval") + ": " + t);
}
}
| 3,971 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
GateBase.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/part/gate/GateBase.java | /*
* This file is part of Blue Power. Blue Power is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Blue Power is
* distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along
* with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.part.gate;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
import net.quetzi.bluepower.api.part.BPPartFace;
import net.quetzi.bluepower.api.part.FaceDirection;
import net.quetzi.bluepower.api.part.RedstoneConnection;
import net.quetzi.bluepower.api.vec.Vector3;
import net.quetzi.bluepower.api.vec.Vector3Cube;
import net.quetzi.bluepower.client.renderers.RenderHelper;
import net.quetzi.bluepower.init.BPItems;
import net.quetzi.bluepower.init.CustomTabs;
import net.quetzi.bluepower.references.Refs;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public abstract class GateBase extends BPPartFace {
protected static Vector3Cube BOX = new Vector3Cube(0, 0, 0, 1, 1D / 8D, 1);
public GateBase() {
for (int i = 0; i < 4; i++)
connections[i] = new RedstoneConnection(this, i + "", true, false);
initializeConnections(getConnection(FaceDirection.FRONT), getConnection(FaceDirection.LEFT), getConnection(FaceDirection.BACK),
getConnection(FaceDirection.RIGHT));
}
public abstract void initializeConnections(RedstoneConnection front, RedstoneConnection left, RedstoneConnection back, RedstoneConnection right);
@Override
public void setFace(int face) {
super.setFace(face);
}
@Override
public String getType() {
return getGateID();
}
@Override
public String getUnlocalizedName() {
return "gate." + getGateID();
}
public abstract String getGateID();
@Override
public void addCollisionBoxes(List<AxisAlignedBB> boxes) {
boxes.add(BOX.clone().toAABB());
}
@Override
public void addOcclusionBoxes(List<AxisAlignedBB> boxes) {
boxes.add(BOX.clone().toAABB());
}
@Override
public void addSelectionBoxes(List<AxisAlignedBB> boxes) {
boxes.add(BOX.clone().toAABB());
}
@Override
public final void renderDynamic(Vector3 loc, int pass, float frame) {
GL11.glPushMatrix();
{
super.rotateAndTranslateDynamic(loc, pass, frame);
/* Top */
renderTop(frame);
Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation(Refs.MODID + ":textures/blocks/gates/bottom.png"));
GL11.glBegin(GL11.GL_QUADS);
/* Bottom */
GL11.glNormal3d(0, -1, 0);
RenderHelper.addVertexWithTexture(0, 0, 0, 0, 0);
RenderHelper.addVertexWithTexture(1, 0, 0, 1, 0);
RenderHelper.addVertexWithTexture(1, 0, 1, 1, 1);
RenderHelper.addVertexWithTexture(0, 0, 1, 0, 1);
GL11.glEnd();
Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation(Refs.MODID + ":textures/blocks/gates/side.png"));
GL11.glBegin(GL11.GL_QUADS);
/* East */
GL11.glNormal3d(1, 0, 0);
RenderHelper.addVertexWithTexture(1, 0, 0, 0, 0);
RenderHelper.addVertexWithTexture(1, 1D / 8D, 0, 1, 0);
RenderHelper.addVertexWithTexture(1, 1D / 8D, 1, 1, 1);
RenderHelper.addVertexWithTexture(1, 0, 1, 0, 1);
/* West */
GL11.glNormal3d(-1, 0, 0);
RenderHelper.addVertexWithTexture(0, 0, 0, 0, 0);
RenderHelper.addVertexWithTexture(0, 0, 1, 0, 1);
RenderHelper.addVertexWithTexture(0, 1D / 8D, 1, 1, 1);
RenderHelper.addVertexWithTexture(0, 1D / 8D, 0, 1, 0);
/* North */
GL11.glNormal3d(0, 0, -1);
RenderHelper.addVertexWithTexture(0, 0, 0, 0, 0);
RenderHelper.addVertexWithTexture(0, 1D / 8D, 0, 1, 0);
RenderHelper.addVertexWithTexture(1, 1D / 8D, 0, 1, 1);
RenderHelper.addVertexWithTexture(1, 0, 0, 0, 1);
/* South */
GL11.glNormal3d(0, 0, 1);
RenderHelper.addVertexWithTexture(0, 0, 1, 0, 0);
RenderHelper.addVertexWithTexture(1, 0, 1, 0, 1);
RenderHelper.addVertexWithTexture(1, 1D / 8D, 1, 1, 1);
RenderHelper.addVertexWithTexture(0, 1D / 8D, 1, 1, 0);
GL11.glEnd();
}
GL11.glPopMatrix();
}
protected void renderTopTexture(FaceDirection side, RedstoneConnection connection) {
if (connection.isEnabled()) {
renderTopTexture(side, connection.getPower() > 0);
} else {
renderTopTexture(Refs.MODID + ":textures/blocks/gates/" + getType() + "/" + side.getName() + "_disabled.png");
}
}
protected void renderTopTexture(FaceDirection side, boolean state) {
renderTopTexture(Refs.MODID + ":textures/blocks/gates/" + getType() + "/" + side.getName() + "_" + (state ? "on" : "off") + ".png");
}
public void renderTopTexture(String texture) {
Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation(texture));
GL11.glBegin(GL11.GL_QUADS);
GL11.glNormal3d(0, 1, 0);
RenderHelper.addVertexWithTexture(0, 1D / 8D, 0, 0, 0);
RenderHelper.addVertexWithTexture(0, 1D / 8D, 1, 0, 1);
RenderHelper.addVertexWithTexture(1, 1D / 8D, 1, 1, 1);
RenderHelper.addVertexWithTexture(1, 1D / 8D, 0, 1, 0);
GL11.glEnd();
}
@Override
public final boolean renderStatic(Vector3 loc, int pass) {
return super.renderStatic(loc, pass);
}
@Override
public final void renderItem(ItemRenderType type, ItemStack item, Object... data) {
GL11.glPushMatrix();
{
if (type == ItemRenderType.INVENTORY) {
GL11.glTranslated(0, 0.5, 0);
GL11.glRotated(-12, -1, 0, 1);
}
/* Top */
renderTop();
Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation(Refs.MODID + ":textures/blocks/gates/bottom.png"));
GL11.glBegin(GL11.GL_QUADS);
/* Bottom */
GL11.glNormal3d(0, -1, 0);
RenderHelper.addVertexWithTexture(0, 0, 0, 0, 0);
RenderHelper.addVertexWithTexture(1, 0, 0, 1, 0);
RenderHelper.addVertexWithTexture(1, 0, 1, 1, 1);
RenderHelper.addVertexWithTexture(0, 0, 1, 0, 1);
GL11.glEnd();
Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation(Refs.MODID + ":textures/blocks/gates/side.png"));
GL11.glBegin(GL11.GL_QUADS);
/* East */
GL11.glNormal3d(1, 0, 0);
RenderHelper.addVertexWithTexture(1, 0, 0, 0, 0);
RenderHelper.addVertexWithTexture(1, 1D / 8D, 0, 1, 0);
RenderHelper.addVertexWithTexture(1, 1D / 8D, 1, 1, 1);
RenderHelper.addVertexWithTexture(1, 0, 1, 0, 1);
/* West */
GL11.glNormal3d(-1, 0, 0);
RenderHelper.addVertexWithTexture(0, 0, 0, 0, 0);
RenderHelper.addVertexWithTexture(0, 0, 1, 0, 1);
RenderHelper.addVertexWithTexture(0, 1D / 8D, 1, 1, 1);
RenderHelper.addVertexWithTexture(0, 1D / 8D, 0, 1, 0);
/* North */
GL11.glNormal3d(0, 0, -1);
RenderHelper.addVertexWithTexture(0, 0, 0, 0, 0);
RenderHelper.addVertexWithTexture(0, 1D / 8D, 0, 1, 0);
RenderHelper.addVertexWithTexture(1, 1D / 8D, 0, 1, 1);
RenderHelper.addVertexWithTexture(1, 0, 0, 0, 1);
/* South */
GL11.glNormal3d(0, 0, 1);
RenderHelper.addVertexWithTexture(0, 0, 1, 0, 0);
RenderHelper.addVertexWithTexture(1, 0, 1, 0, 1);
RenderHelper.addVertexWithTexture(1, 1D / 8D, 1, 1, 1);
RenderHelper.addVertexWithTexture(0, 1D / 8D, 1, 1, 0);
GL11.glEnd();
}
GL11.glPopMatrix();
}
public void renderTop(float frame) {
renderTopTexture(Refs.MODID + ":textures/blocks/gates/" + getType() + "/base.png");
renderTop(getConnection(FaceDirection.FRONT), getConnection(FaceDirection.LEFT), getConnection(FaceDirection.BACK),
getConnection(FaceDirection.RIGHT), frame);
}
public void renderTop() {
renderTopTexture(Refs.MODID + ":textures/blocks/gates/" + getType() + "/base.png");
renderTopItem(getConnection(FaceDirection.FRONT), getConnection(FaceDirection.LEFT), getConnection(FaceDirection.BACK),
getConnection(FaceDirection.RIGHT));
}
protected void renderTopItem(RedstoneConnection front, RedstoneConnection left, RedstoneConnection back, RedstoneConnection right) {
renderTop(getConnection(FaceDirection.FRONT), getConnection(FaceDirection.LEFT), getConnection(FaceDirection.BACK),
getConnection(FaceDirection.RIGHT), 0);
}
protected abstract void renderTop(RedstoneConnection front, RedstoneConnection left, RedstoneConnection back, RedstoneConnection right,
float frame);
@Override
public void update() {
super.update();
doLogic(getConnection(FaceDirection.FRONT), getConnection(FaceDirection.LEFT), getConnection(FaceDirection.BACK),
getConnection(FaceDirection.RIGHT));
}
public abstract void doLogic(RedstoneConnection front, RedstoneConnection left, RedstoneConnection back, RedstoneConnection right);
@Override
public boolean onActivated(EntityPlayer player, MovingObjectPosition mop, ItemStack item) {
if (item != null && item.getItem() == BPItems.screwdriver) {
if (player.isSneaking()) {
if (!world.isRemote) {
if (changeMode(getConnection(FaceDirection.FRONT), getConnection(FaceDirection.LEFT), getConnection(FaceDirection.BACK),
getConnection(FaceDirection.RIGHT))) {
notifyUpdate();
sendUpdatePacket();
return true;
} else {
return false;
}
}
} else {
setRotation(getRotation() + 1);
}
return true;
} else if (hasGUI()) {
if (world.isRemote) {
FMLCommonHandler.instance().showGuiScreen(getGui());
}
return true;
}
return super.onActivated(player, mop, item);
}
@SideOnly(Side.CLIENT)
protected GuiScreen getGui() {
return null;
}
protected boolean hasGUI() {
return false;
}
protected boolean changeMode(RedstoneConnection front, RedstoneConnection left, RedstoneConnection back, RedstoneConnection right) {
return false;
}
@Override
public CreativeTabs getCreativeTab() {
return CustomTabs.tabBluePowerCircuits;
}
@Override
public abstract void addWailaInfo(List<String> info);
}
| 12,270 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
GateOr.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/part/gate/GateOr.java | package net.quetzi.bluepower.part.gate;
import java.util.List;
import net.minecraft.util.AxisAlignedBB;
import net.quetzi.bluepower.api.part.FaceDirection;
import net.quetzi.bluepower.api.part.RedstoneConnection;
import net.quetzi.bluepower.client.renderers.RenderHelper;
public class GateOr extends GateBase {
private boolean power = false;
@Override
public void initializeConnections(RedstoneConnection front, RedstoneConnection left, RedstoneConnection back, RedstoneConnection right) {
// Init front
front.enable();
front.setOutput();
// Init left
left.enable();
left.setInput();
// Init back
back.enable();
back.setInput();
// Init right
right.enable();
right.setInput();
}
@Override
public String getGateID() {
return "or";
}
@Override
public void renderTop(RedstoneConnection front, RedstoneConnection left, RedstoneConnection back, RedstoneConnection right, float frame) {
renderTopTexture(FaceDirection.FRONT, !power);
renderTopTexture(FaceDirection.LEFT, left.getPower() > 0);
renderTopTexture(FaceDirection.RIGHT, right.getPower() > 0);
renderTopTexture(FaceDirection.BACK, back.getPower() > 0);
RenderHelper.renderRedstoneTorch(0, 1D / 8D, 0, 9D / 16D, !power);
RenderHelper.renderRedstoneTorch(0, 1D / 8D, -6D / 16D, 9D / 16D, power);
}
@Override
public void addOcclusionBoxes(List<AxisAlignedBB> boxes) {
super.addOcclusionBoxes(boxes);
boxes.add(AxisAlignedBB.getBoundingBox(7D / 16D, 2D / 16D, 7D / 16D, 9D / 16D, 8D / 16D, 9D / 16D));
}
@Override
public void doLogic(RedstoneConnection front, RedstoneConnection left, RedstoneConnection back, RedstoneConnection right) {
power = back.getPower() > 0 || left.getPower() > 0 || right.getPower() > 0;
front.setPower(power ? 15 : 0);
}
@Override
public void addWailaInfo(List<String> info) {
}
}
| 2,136 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
GateNand.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/part/gate/GateNand.java | package net.quetzi.bluepower.part.gate;
import java.util.List;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.AxisAlignedBB;
import net.quetzi.bluepower.api.part.FaceDirection;
import net.quetzi.bluepower.api.part.RedstoneConnection;
import net.quetzi.bluepower.client.renderers.RenderHelper;
import net.quetzi.bluepower.util.Color;
public class GateNand extends GateBase {
private boolean power = false;
@Override
public void initializeConnections(RedstoneConnection front, RedstoneConnection left, RedstoneConnection back, RedstoneConnection right) {
// Init front
front.enable();
front.setOutput();
// Init left
left.enable();
left.setInput();
// Init back
back.enable();
back.setInput();
// Init right
right.enable();
right.setInput();
}
@Override
public String getGateID() {
return "nand";
}
@Override
public void renderTop(RedstoneConnection front, RedstoneConnection left, RedstoneConnection back, RedstoneConnection right, float frame) {
renderTopTexture(FaceDirection.FRONT, !power);
renderTopTexture(FaceDirection.LEFT, left);
RenderHelper.renderRedstoneTorch(-3D / 16D, 1D / 8D, 0, 8D / 16D, left.getPower() == 0 && left.isEnabled());
renderTopTexture(FaceDirection.BACK, back);
RenderHelper.renderRedstoneTorch(0, 1D / 8D, 0, 8D / 16D, back.getPower() == 0 && back.isEnabled());
renderTopTexture(FaceDirection.RIGHT, right);
RenderHelper.renderRedstoneTorch(3D / 16D, 1D / 8D, 0, 8D / 16D, right.getPower() == 0 && right.isEnabled());
}
@Override
public void addOcclusionBoxes(List<AxisAlignedBB> boxes) {
super.addOcclusionBoxes(boxes);
boxes.add(AxisAlignedBB.getBoundingBox(7D / 16D, 2D / 16D, 7D / 16D, 9D / 16D, 9D / 16D, 9D / 16D));
}
@Override
public void doLogic(RedstoneConnection front, RedstoneConnection left, RedstoneConnection back, RedstoneConnection right) {
power = true;
if (left.isEnabled()) power &= left.getPower() > 0;
if (back.isEnabled()) power &= back.getPower() > 0;
if (right.isEnabled()) power &= right.getPower() > 0;
front.setPower(!power ? 15 : 0);
}
@Override
protected boolean changeMode(RedstoneConnection front, RedstoneConnection left, RedstoneConnection back, RedstoneConnection right) {
if (left.isEnabled() && back.isEnabled() && right.isEnabled()) {
right.disable();
} else if (left.isEnabled() && back.isEnabled()) {
back.disable();
right.enable();
} else if (left.isEnabled() && right.isEnabled()) {
left.disable();
back.enable();
} else if (back.isEnabled() && right.isEnabled()) {
left.enable();
back.disable();
right.disable();
} else if (left.isEnabled()) {
left.disable();
back.enable();
} else if (back.isEnabled()) {
back.disable();
right.enable();
} else {// right enabled
left.enable();
back.enable();
}
return true;
}
@Override
public void addWailaInfo(List<String> info) {
info.add(Color.YELLOW + I18n.format("gui.connections") + ":");
info.add(" "
+ FaceDirection.LEFT.getLocalizedName()
+ ": "
+ (getConnection(FaceDirection.LEFT).isEnabled() ? Color.GREEN + I18n.format("random.enabled") : Color.RED
+ I18n.format("random.disabled")));
info.add(" "
+ FaceDirection.BACK.getLocalizedName()
+ ": "
+ (getConnection(FaceDirection.BACK).isEnabled() ? Color.GREEN + I18n.format("random.enabled") : Color.RED
+ I18n.format("random.disabled")));
info.add(" "
+ FaceDirection.RIGHT.getLocalizedName()
+ ": "
+ (getConnection(FaceDirection.RIGHT).isEnabled() ? Color.GREEN + I18n.format("random.enabled") : Color.RED
+ I18n.format("random.disabled")));
}
}
| 4,380 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
GateCounter.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/part/gate/GateCounter.java | package net.quetzi.bluepower.part.gate;
import java.util.List;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.resources.I18n;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import net.quetzi.bluepower.api.part.FaceDirection;
import net.quetzi.bluepower.api.part.RedstoneConnection;
import net.quetzi.bluepower.client.gui.gate.GuiGateCounter;
import net.quetzi.bluepower.client.renderers.RenderHelper;
import net.quetzi.bluepower.part.IGuiButtonSensitive;
import net.quetzi.bluepower.references.Refs;
import net.quetzi.bluepower.util.Color;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class GateCounter extends GateBase implements IGuiButtonSensitive {
private int count = 0, max = 10, increment = 1, decrement = 1;
private boolean wasOnLeft = false, wasOnRight = false;
@Override
public void initializeConnections(RedstoneConnection front, RedstoneConnection left, RedstoneConnection back, RedstoneConnection right) {
// Init front (+ out)
front.enable();
front.setOutput();
// Init left (- in)
left.enable();
left.setInput();
// Init back (- out)
back.enable();
back.setOutput();
// Init right (+ in)
right.enable();
right.setInput();
}
@Override
public String getGateID() {
return "counter";
}
@Override
public void renderTop(RedstoneConnection front, RedstoneConnection left, RedstoneConnection back, RedstoneConnection right, float frame) {
renderTopTexture(FaceDirection.LEFT, left.getPower() > 0);
renderTopTexture(FaceDirection.RIGHT, right.getPower() > 0);
renderTopTexture(Refs.MODID + ":textures/blocks/gates/" + getType() + "/centerleft_" + (left.getPower() > 0 ? "on" : "off") + ".png");
renderTopTexture(Refs.MODID + ":textures/blocks/gates/" + getType() + "/centerright_" + (left.getPower() > 0 ? "on" : "off") + ".png");
RenderHelper.renderRedstoneTorch(2 / 16D, 1D / 8D, 0, 13D / 16D, true);
RenderHelper.renderRedstoneTorch(0, 1D / 8D, 5D / 16D, 8D / 16D, count == 0);
RenderHelper.renderRedstoneTorch(0, 1D / 8D, -5D / 16D, 8D / 16D, count == max);
GL11.glPushMatrix();
{
GL11.glTranslated(2 / 16D, 0, 0);
double min = 0.555;
double max = 0.385;
double angle = min + (max * (count / ((double) this.max)));
RenderHelper.renderPointer(0, 7 / 16D, 0, -angle);
}
GL11.glPopMatrix();
}
@Override
public void addOcclusionBoxes(List<AxisAlignedBB> boxes) {
super.addOcclusionBoxes(boxes);
boxes.add(AxisAlignedBB.getBoundingBox(7D / 16D, 2D / 16D, 7D / 16D, 9D / 16D, 8D / 16D, 9D / 16D));
}
@Override
public void doLogic(RedstoneConnection front, RedstoneConnection left, RedstoneConnection back, RedstoneConnection right) {
if (left.getPower() > 0 && !wasOnLeft) {
wasOnLeft = true;
count -= decrement;
}
if (left.getPower() == 0) wasOnLeft = false;
if (right.getPower() > 0 && !wasOnRight) {
wasOnRight = true;
count += increment;
}
if (right.getPower() == 0) wasOnRight = false;
count = Math.max(Math.min(count, max), 0);
increment = Math.max(Math.min(increment, max), 0);
decrement = Math.max(Math.min(decrement, max), 0);
front.setPower(count == max ? 15 : 0);
back.setPower(count == 0 ? 15 : 0);
}
@Override
public void save(NBTTagCompound tag) {
super.save(tag);
tag.setInteger("count", count);
tag.setInteger("max", max);
tag.setInteger("increment", increment);
tag.setInteger("decrement", decrement);
tag.setBoolean("left", wasOnLeft);
tag.setBoolean("right", wasOnRight);
}
@Override
public void load(NBTTagCompound tag) {
super.load(tag);
count = tag.getInteger("count");
max = tag.getInteger("max");
increment = tag.getInteger("increment");
decrement = tag.getInteger("decrement");
wasOnLeft = tag.getBoolean("left");
wasOnRight = tag.getBoolean("right");
}
@Override
public void onButtonPress(int messageId, int value) {
switch (messageId) {
case 0:
max = value;
break;
case 1:
increment = value;
break;
case 2:
decrement = value;
break;
}
sendUpdatePacket();
}
@Override
@SideOnly(Side.CLIENT)
protected GuiScreen getGui() {
return new GuiGateCounter(this) {
@Override
protected int getCurrentMax() {
return max;
}
@Override
protected int getCurrentIncrement() {
return increment;
}
@Override
protected int getCurrentDecrement() {
return decrement;
}
};
}
@Override
protected boolean hasGUI() {
return true;
}
@Override
public void addWailaInfo(List<String> info) {
info.add(I18n.format("gui.counterMax") + ": " + Color.YELLOW + max);
info.add(I18n.format("gui.counterCount") + ": " + Color.YELLOW + count);
info.add(I18n.format("gui.counterIncrement") + ": " + Color.WHITE + increment);
info.add(I18n.format("gui.counterDecrement") + ": " + Color.WHITE + decrement);
}
}
| 5,984 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
GateNor.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/part/gate/GateNor.java | package net.quetzi.bluepower.part.gate;
import java.util.List;
import net.minecraft.util.AxisAlignedBB;
import net.quetzi.bluepower.api.part.FaceDirection;
import net.quetzi.bluepower.api.part.RedstoneConnection;
import net.quetzi.bluepower.client.renderers.RenderHelper;
public class GateNor extends GateBase {
private boolean power = false;
@Override
public void initializeConnections(RedstoneConnection front, RedstoneConnection left, RedstoneConnection back, RedstoneConnection right) {
// Init front
front.enable();
front.setOutput();
// Init left
left.enable();
left.setInput();
// Init back
back.enable();
back.setInput();
// Init right
right.enable();
right.setInput();
}
@Override
public String getGateID() {
return "nor";
}
@Override
public void renderTop(RedstoneConnection front, RedstoneConnection left, RedstoneConnection back, RedstoneConnection right, float frame) {
renderTopTexture(FaceDirection.FRONT, !power);
renderTopTexture(FaceDirection.LEFT, left.getPower() > 0);
renderTopTexture(FaceDirection.RIGHT, right.getPower() > 0);
renderTopTexture(FaceDirection.BACK, back.getPower() > 0);
RenderHelper.renderRedstoneTorch(0, 1D / 8D, 0, 9D / 16D, !power);
// RenderHelper.renderRedstoneTorch(0, 1D / 8D, -6D/16D, 9D / 16D, power);
}
@Override
public void addOcclusionBoxes(List<AxisAlignedBB> boxes) {
super.addOcclusionBoxes(boxes);
boxes.add(AxisAlignedBB.getBoundingBox(7D / 16D, 2D / 16D, 7D / 16D, 9D / 16D, 8D / 16D, 9D / 16D));
}
@Override
public void doLogic(RedstoneConnection front, RedstoneConnection left, RedstoneConnection back, RedstoneConnection right) {
power = back.getPower() > 0 || left.getPower() > 0 || right.getPower() > 0;
front.setPower(!power ? 15 : 0);
}
@Override
public void addWailaInfo(List<String> info) {
}
}
| 2,140 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
GateAnd.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/part/gate/GateAnd.java | package net.quetzi.bluepower.part.gate;
import java.util.List;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.AxisAlignedBB;
import net.quetzi.bluepower.api.part.FaceDirection;
import net.quetzi.bluepower.api.part.RedstoneConnection;
import net.quetzi.bluepower.client.renderers.RenderHelper;
import net.quetzi.bluepower.util.Color;
public class GateAnd extends GateBase {
private boolean power = false;
@Override
public void initializeConnections(RedstoneConnection front, RedstoneConnection left, RedstoneConnection back, RedstoneConnection right) {
// Init front
front.enable();
front.setOutput();
// Init left
left.enable();
left.setInput();
// Init back
back.enable();
back.setInput();
// Init right
right.enable();
right.setInput();
}
@Override
public String getGateID() {
return "and";
}
@Override
public void renderTop(RedstoneConnection front, RedstoneConnection left, RedstoneConnection back, RedstoneConnection right, float frame) {
renderTopTexture(FaceDirection.FRONT, !power);
RenderHelper.renderRedstoneTorch(0, 1D / 8D, -4D / 16D, 10D / 16D, power);
renderTopTexture(FaceDirection.LEFT, left);
RenderHelper.renderRedstoneTorch(-3D / 16D, 1D / 8D, 0, 8D / 16D, left.getPower() == 0 && left.isEnabled());
renderTopTexture(FaceDirection.BACK, back);
RenderHelper.renderRedstoneTorch(0, 1D / 8D, 0, 8D / 16D, back.getPower() == 0 && back.isEnabled());
renderTopTexture(FaceDirection.RIGHT, right);
RenderHelper.renderRedstoneTorch(3D / 16D, 1D / 8D, 0, 8D / 16D, right.getPower() == 0 && right.isEnabled());
}
@Override
public void addOcclusionBoxes(List<AxisAlignedBB> boxes) {
super.addOcclusionBoxes(boxes);
boxes.add(AxisAlignedBB.getBoundingBox(7D / 16D, 2D / 16D, 7D / 16D, 9D / 16D, 9D / 16D, 9D / 16D));
}
@Override
public void doLogic(RedstoneConnection front, RedstoneConnection left, RedstoneConnection back, RedstoneConnection right) {
power = true;
if (left.isEnabled()) power &= left.getPower() > 0;
if (back.isEnabled()) power &= back.getPower() > 0;
if (right.isEnabled()) power &= right.getPower() > 0;
front.setPower(power ? 15 : 0);
}
@Override
protected boolean changeMode(RedstoneConnection front, RedstoneConnection left, RedstoneConnection back, RedstoneConnection right) {
if (left.isEnabled() && back.isEnabled() && right.isEnabled()) {
right.disable();
} else if (left.isEnabled() && back.isEnabled()) {
back.disable();
right.enable();
} else if (left.isEnabled() && right.isEnabled()) {
left.disable();
back.enable();
} else if (back.isEnabled() && right.isEnabled()) {
left.enable();
back.disable();
right.disable();
} else if (left.isEnabled()) {
left.disable();
back.enable();
} else if (back.isEnabled()) {
back.disable();
right.enable();
} else {// right enabled
left.enable();
back.enable();
}
return true;
}
@Override
public void addWailaInfo(List<String> info) {
info.add(Color.YELLOW + I18n.format("gui.connections") + ":");
info.add(" "
+ FaceDirection.LEFT.getLocalizedName()
+ ": "
+ (getConnection(FaceDirection.LEFT).isEnabled() ? Color.GREEN + I18n.format("random.enabled") : Color.RED
+ I18n.format("random.disabled")));
info.add(" "
+ FaceDirection.BACK.getLocalizedName()
+ ": "
+ (getConnection(FaceDirection.BACK).isEnabled() ? Color.GREEN + I18n.format("random.enabled") : Color.RED
+ I18n.format("random.disabled")));
info.add(" "
+ FaceDirection.RIGHT.getLocalizedName()
+ ": "
+ (getConnection(FaceDirection.RIGHT).isEnabled() ? Color.GREEN + I18n.format("random.enabled") : Color.RED
+ I18n.format("random.disabled")));
}
}
| 4,460 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
TubeLogic.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/part/tube/TubeLogic.java | package net.quetzi.bluepower.part.tube;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import java.util.Stack;
import java.util.concurrent.LinkedBlockingQueue;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import net.quetzi.bluepower.api.tube.IPneumaticTube;
import net.quetzi.bluepower.api.vec.Vector3;
import net.quetzi.bluepower.compat.CompatibilityUtils;
import net.quetzi.bluepower.compat.fmp.IMultipartCompat;
import net.quetzi.bluepower.helper.IOHelper;
import net.quetzi.bluepower.helper.TileEntityCache;
import net.quetzi.bluepower.references.Dependencies;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/**
*
* @author MineMaarten
*/
public class TubeLogic implements IPneumaticTube {
private final PneumaticTube tube;
private TubeNode connectionNode; //contains a cache of connected TileEntities (not necessarily directly adjacent, but nodes, intersections, or inventories). Also contains a colormask and distance.
public List<TubeStack> tubeStacks = new ArrayList<TubeStack>();
private static final double ITEM_SPEED = 0.04;
private int roundRobinCounter;
public TubeLogic(PneumaticTube tube) {
this.tube = tube;
}
public void clearNodeCaches() {
List<PneumaticTube> clearedTubes = new ArrayList<PneumaticTube>();
Stack<PneumaticTube> todoTubes = new Stack<PneumaticTube>();
IMultipartCompat compat = (IMultipartCompat) CompatibilityUtils.getModule(Dependencies.FMP);
clearNodeCache();
boolean firstRun = true;
todoTubes.push(tube);
while (!todoTubes.isEmpty()) {
for (TileEntityCache cache : todoTubes.pop().getTileCache()) {
PneumaticTube neighbor = compat.getBPPart(cache.getTileEntity(), PneumaticTube.class);
if (neighbor != null) {
if (!clearedTubes.contains(neighbor)) {
neighbor.getLogic().clearNodeCache();
clearedTubes.add(neighbor);
if (firstRun || !neighbor.isCrossOver) todoTubes.push(neighbor);
}
}
}
firstRun = false;
}
}
private void clearNodeCache() {
connectionNode = null;
}
TubeNode getNode() {
if (connectionNode == null && tube.world != null) {
connectionNode = new TubeNode(tube);
connectionNode.init();
}
return connectionNode;
}
public void update() {
clearNodeCache();//TODO remove this line, which will enable node caching. Disabled for now, because I want to test stability with the non-cached system first.
Iterator<TubeStack> iterator = tubeStacks.iterator();
while (iterator.hasNext()) {
TubeStack tubeStack = iterator.next();
if (tubeStack.update(ITEM_SPEED)) {
if (!tube.isCrossOver) {
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
if (tube.connections[dir.ordinal()] && dir != tubeStack.heading.getOpposite()) {
tubeStack.heading = dir;
break;
}
}
} else {//when we are at an intersection
if (!tube.world.isRemote) {
Pair<ForgeDirection, TileEntity> heading = getHeadingForItem(tubeStack, false);
if (heading == null) {//if no valid destination
for (int i = 0; i < 6; i++) {
TubeEdge edge = getNode().edges[i];
if (edge != null) {
tubeStack.heading = ForgeDirection.getOrientation(i);//this will allow the item to ignore the color mask when there's really no option left.
if (canPassThroughMask(tubeStack.color, edge.colorMask)) {
tubeStack.heading = ForgeDirection.getOrientation(i);//just a specific direction for now.
break;
}
}
}
} else {
tubeStack.heading = heading.getKey();
}
tube.sendUpdatePacket();
} else {
tubeStack.enabled = false;
}
}
} else if (tubeStack.progress >= 1) {//when the item reached the end of the tube.
TileEntity output = tube.getTileCache()[tubeStack.heading.ordinal()].getTileEntity();
IMultipartCompat compat = (IMultipartCompat) CompatibilityUtils.getModule(Dependencies.FMP);
PneumaticTube tube = compat.getBPPart(output, PneumaticTube.class);
if (tube != null) {//we don't need to check connections, that's catched earlier.
TubeLogic logic = tube.getLogic();
tubeStack.progress = 0;
tubeStack.oldProgress = -ITEM_SPEED;
logic.tubeStacks.add(tubeStack);//transfer to another tube.
iterator.remove();
} else if (!this.tube.world.isRemote) {
ItemStack remainder = tubeStack.stack;
if (output instanceof ITubeConnection && ((ITubeConnection) output).isConnectedTo(tubeStack.heading.getOpposite())) {
TubeStack rem = ((ITubeConnection) output).acceptItemFromTube(tubeStack, tubeStack.heading.getOpposite(), false);
if (rem != null) remainder = rem.stack;
else remainder = null;
}
if (remainder != null) remainder = IOHelper.insert(output, tubeStack.stack, tubeStack.heading.getOpposite(), tubeStack.color, false);
if (remainder != null) {
if (injectStack(remainder, tubeStack.heading.getOpposite(), tubeStack.color, true)) {
tubeStack.stack = remainder;
tubeStack.progress = 0;
tubeStack.oldProgress = 0;
tubeStack.heading = tubeStack.heading.getOpposite();
this.tube.sendUpdatePacket();
} else {
EntityItem entity = new EntityItem(this.tube.world, this.tube.x + 0.5 + tubeStack.heading.offsetX * tubeStack.progress * 0.5, this.tube.y + 0.5 + tubeStack.heading.offsetY * tubeStack.progress * 0.5, this.tube.z + 0.5 + tubeStack.heading.offsetX * tubeStack.progress
* 0.5, remainder);
this.tube.world.spawnEntityInWorld(entity);
iterator.remove();
}
} else {
iterator.remove();
}
} else {
iterator.remove();
}
}
}
}
/**
This method gets the end target and heading for a TubeStack.
When the tubestack's target variable is null, this is an exporting item, meaning the returned target will be the TileEntity the item is going to transport to.
When the tubestack's target variable is not not, the item is being retrieved to this inventory. The returned target is the inventory the item came/should come from.
@param simulate The only difference between simulate and not simulate is the fact that the round robin handling will be updated in non-simulate.
@param from The direction this item came from, this direction will never be a valid heading. Is null in normal item routing, as the from direction IS a valid output.
*/
private Pair<ForgeDirection, TileEntity> getHeadingForItem(TubeStack stack, boolean simulate) {
Map<TubeNode, Integer> distances = new HashMap<TubeNode, Integer>();
Queue<TubeNode> traversingNodes = new LinkedBlockingQueue<TubeNode>();
Queue<ForgeDirection> trackingExportDirection = new LinkedBlockingQueue<ForgeDirection>();
Map<TubeEdge, ForgeDirection> validDestinations = new LinkedHashMap<TubeEdge, ForgeDirection>();//using a LinkedHashMap so the order doesn't change, used for round robin.
distances.put(getNode(), 0);//make this the origin.
traversingNodes.add(getNode());
boolean firstRun = true;
int closestDest = 0;
while (!traversingNodes.isEmpty()) {
TubeNode node = traversingNodes.poll();
ForgeDirection heading = firstRun ? null : trackingExportDirection.poll();
for (int i = 0; i < 6; i++) {
if (firstRun) heading = ForgeDirection.getOrientation(i);
TubeEdge edge = node.edges[i];
if (edge != null && canPassThroughMask(stack.color, edge.colorMask)) {//if this item can travel through this color mask proceed.
Integer distance = distances.get(edge.target);
if (distance == null || distances.get(node) + edge.distance < distance) {
distances.put(edge.target, distances.get(node) + edge.distance);
if (edge.target.target instanceof PneumaticTube) {
traversingNodes.add(edge.target);
trackingExportDirection.add(heading);
} else if (stack.getTarget(tube.world) == null && edge.isValidForExportItem(stack.stack) || stack.getTarget(tube.world) != null && edge.isValidForImportItem(stack.stack)) {
validDestinations.put(edge, heading);
}
}
}
}
//Check the distances of the current breadth first search layer. if no points are closer than the currently valid destination(s), we're done searching.
boolean isDoneSearching = true;
closestDest = getClosestDestination(validDestinations.keySet(), distances);
for (TubeNode checkingNode : traversingNodes) {
if (distances.get(checkingNode) <= closestDest) {
isDoneSearching = false;
break;
}
}
if (isDoneSearching) break;
firstRun = false;
}
if (validDestinations.size() == 0) {
if (stack.getTarget(tube.world) != null && !simulate) {
stack.setTarget(null);//if we can't reach the retrieving target anymore, reroute as normal.
return getHeadingForItem(stack, simulate);
} else {
return null;
}
}
List<Pair<ForgeDirection, TileEntity>> validDirections = new ArrayList<Pair<ForgeDirection, TileEntity>>();
for (Map.Entry<TubeEdge, ForgeDirection> entry : validDestinations.entrySet()) {
if (distances.get(entry.getKey().target) == closestDest) {
validDirections.add(new ImmutablePair(entry.getValue(), entry.getKey().target));
}
}
//handle round robin
if (!simulate) roundRobinCounter++;
if (roundRobinCounter >= validDirections.size()) roundRobinCounter = 0;
return validDirections.get(roundRobinCounter);
}
private boolean canPassThroughMask(TubeColor color, int colorMask) {
return color == TubeColor.NONE || Integer.bitCount(colorMask) == 0 || Integer.bitCount(colorMask) == 1 && (colorMask & 1 << color.ordinal()) != 0;
}
/**
* Used to get an indication for when the search is done.
* @param validDestinations
* @param distances
* @return
*/
private int getClosestDestination(Set<TubeEdge> validDestinations, Map<TubeNode, Integer> distances) {
int minDest = Integer.MAX_VALUE;
for (TubeEdge edge : validDestinations) {
if (distances.get(edge.target) < minDest) {
minDest = distances.get(edge.target);
}
}
return minDest;
}
@Override
public boolean injectStack(ItemStack stack, ForgeDirection from, TubeColor itemColor, boolean simulate) {
if (tube.world.isRemote) throw new IllegalArgumentException("[Pneumatic Tube] You can't inject items from the client side!");
TubeStack tubeStack = new TubeStack(stack.copy(), from, itemColor);
Pair<ForgeDirection, TileEntity> heading = getHeadingForItem(tubeStack, simulate);
if (heading != null && heading.getKey() != from.getOpposite()) {
if (!simulate) {
tubeStacks.add(tubeStack);
tube.sendUpdatePacket();
}
return true;
} else {
return false;
}
}
public void writeToNBT(NBTTagCompound tag) {
NBTTagList tagList = new NBTTagList();
for (TubeStack stack : tubeStacks) {
NBTTagCompound stackTag = new NBTTagCompound();
stack.writeToNBT(stackTag);
tagList.appendTag(stackTag);
}
tag.setTag("tubeStacks", tagList);
tag.setInteger("roundRobinCounter", roundRobinCounter);
}
public void readFromNBT(NBTTagCompound tag) {
tubeStacks = new ArrayList<TubeStack>();
NBTTagList tagList = tag.getTagList("tubeStacks", 10);
for (int i = 0; i < tagList.tagCount(); i++) {
NBTTagCompound stackTag = tagList.getCompoundTagAt(i);
tubeStacks.add(TubeStack.loadFromNBT(stackTag));
}
roundRobinCounter = tag.getInteger("roundRobinCounter");
}
@SideOnly(Side.CLIENT)
public void renderDynamic(Vector3 pos, float partialTick) {
GL11.glPushMatrix();
GL11.glTranslated(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
for (TubeStack stack : tubeStacks) {
stack.render(partialTick);
}
GL11.glPopMatrix();
}
/**
Contains the distance and a reference to a connected node, directional.
*/
public class TubeNode {
public TubeEdge[] edges;
public Object target; //Either a TileEntity (inventory), or a PneumaticTube
public TubeNode(TileEntity te) {
target = te;
}
public TubeNode(PneumaticTube tube) {
target = tube;
}
public void init() {
PneumaticTube nodeTube = (PneumaticTube) target;
edges = new TubeEdge[6];
for (int i = 0; i < 6; i++) {
if (tube.connections[i]) {
TileEntity neighbor = nodeTube.getTileCache()[i].getTileEntity();
IMultipartCompat compat = (IMultipartCompat) CompatibilityUtils.getModule(Dependencies.FMP);
PneumaticTube tube = compat.getBPPart(neighbor, PneumaticTube.class);
if (tube != null) {
int dist = tube.getWeigth();
int colorMask = 0;
if (tube.getColor() != TubeColor.NONE) colorMask = colorMask | 1 << tube.getColor().ordinal();
ForgeDirection curDir = ForgeDirection.getOrientation(i);
while (!tube.isCrossOver && tube.initialized) {//traverse the tubes
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
if (dir != curDir.getOpposite() && tube.connections[dir.ordinal()]) {
curDir = dir;
break;
}
}
neighbor = tube.getTileCache()[curDir.ordinal()].getTileEntity();
if (neighbor != null) {
tube = compat.getBPPart(neighbor, PneumaticTube.class);
if (tube == null) {
edges[i] = new TubeEdge(new TubeNode(neighbor), curDir, colorMask, dist + (neighbor instanceof IWeightedTubeInventory ? ((IWeightedTubeInventory) neighbor).getWeight(curDir) : 0));
break;
} else {
if (!tube.initialized) break;
dist += tube.getWeigth();
if (tube.getColor() != TubeColor.NONE) {
colorMask = colorMask | 1 << tube.getColor().ordinal();
}
}
}
}
if (tube != null && tube != nodeTube) edges[i] = new TubeEdge(tube.getLogic().getNode(), curDir, colorMask, dist);//only add an edge that isn't just connected to itself.
} else if (neighbor != null) {
edges[i] = new TubeEdge(new TubeNode(neighbor), ForgeDirection.getOrientation(i), 0, neighbor instanceof IWeightedTubeInventory ? ((IWeightedTubeInventory) neighbor).getWeight(ForgeDirection.getOrientation(i)) : 0);
}
}
}
}
}
public class TubeEdge {
public TubeNode target;
private final ForgeDirection targetConnectionSide;
public final int distance;
public int colorMask; //bitmask of disallowed colored items through the tube. Least significant bit is TubeColor.values()[0]. only least significant 16 bits are used
public TubeEdge(TubeNode target, ForgeDirection targetConnectionSide, int colorMask, int distance) {
this.target = target;
this.targetConnectionSide = targetConnectionSide;
this.distance = distance;
this.colorMask = colorMask;
}
public boolean isValidForExportItem(ItemStack stack) {
if (target.target instanceof PneumaticTube) return false;
if (target.target instanceof IWeightedTubeInventory && ((IWeightedTubeInventory) target.target).getWeight(targetConnectionSide) > 10000) return true;
ItemStack remainder = IOHelper.insert((TileEntity) target.target, stack.copy(), targetConnectionSide.getOpposite(), true);
return remainder == null || remainder.stackSize < stack.stackSize;
}
public boolean isValidForImportItem(ItemStack stack) {
if (target.target instanceof PneumaticTube) return false;
ItemStack extractedItems = IOHelper.extract((TileEntity) target.target, targetConnectionSide, stack, true);
return extractedItems != null;
}
}
}
| 19,934 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
TubeStack.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/part/tube/TubeStack.java | package net.quetzi.bluepower.part.tube;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemDye;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.quetzi.bluepower.api.tube.IPneumaticTube.TubeColor;
import net.quetzi.bluepower.api.vec.Vector3Cube;
import net.quetzi.bluepower.client.renderers.RenderHelper;
import net.quetzi.bluepower.references.Refs;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/**
*
* @author MineMaarten
*/
public class TubeStack {
public ItemStack stack;
public final TubeColor color;
public double progress; //0 at the start, 0.5 on an intersection, 1 at the end.
public double oldProgress;
public ForgeDirection heading;
public boolean enabled = true; //will be disabled when the client sided stack is at an intersection, at which point it needs to wait for server input. This just serves a visual purpose.
private TileEntity target; //only should have a value when retrieving items. this is the target the item wants to go to.
private int targetX, targetY, targetZ;
@SideOnly(Side.CLIENT)
private static RenderItem customRenderItem;
private static EntityItem renderedItem;
public TubeStack(ItemStack stack, ForgeDirection from) {
this(stack, from, TubeColor.NONE);
}
public TubeStack(ItemStack stack, ForgeDirection from, TubeColor color) {
heading = from;
this.stack = stack;
this.color = color;
}
/**
* Updates the movement by the given m/tick.
* @return true if the stack has gone past the center, meaning logic needs to be triggered.
*/
public boolean update(double move) {
oldProgress = progress;
if (enabled) {
boolean isEntering = progress < 0.5;
progress += move;
return progress >= 0.5 && isEntering;
} else {
return false;
}
}
public TileEntity getTarget(World world) {
if (target == null && (targetX != 0 || targetY != 0 || targetZ != 0)) {
target = world.getTileEntity(targetX, targetY, targetZ);
}
return target;
}
public void setTarget(TileEntity tileEntity) {
target = tileEntity;
if (target != null) {
targetX = target.xCoord;
targetY = target.yCoord;
targetZ = target.zCoord;
} else {
targetX = 0;
targetY = 0;
targetZ = 0;
}
}
public void writeToNBT(NBTTagCompound tag) {
stack.writeToNBT(tag);
tag.setByte("color", (byte) color.ordinal());
tag.setByte("heading", (byte) heading.ordinal());
tag.setDouble("progress", progress);
tag.setInteger("targetX", targetX);
tag.setInteger("targetY", targetY);
tag.setInteger("targetZ", targetZ);
}
public static TubeStack loadFromNBT(NBTTagCompound tag) {
TubeStack stack = new TubeStack(ItemStack.loadItemStackFromNBT(tag), ForgeDirection.getOrientation(tag.getByte("heading")), TubeColor.values()[tag.getByte("color")]);
stack.progress = tag.getDouble("progress");
stack.targetX = tag.getInteger("targetX");
stack.targetY = tag.getInteger("targetY");
stack.targetZ = tag.getInteger("targetZ");
return stack;
}
@SideOnly(Side.CLIENT)
public void render(float partialTick) {
if (customRenderItem == null) {
customRenderItem = new RenderItem() {
@Override
public boolean shouldBob() {
return false;
};
};
customRenderItem.setRenderManager(RenderManager.instance);
renderedItem = new EntityItem(FMLClientHandler.instance().getWorldClient());
renderedItem.hoverStart = 0.0F;
}
renderedItem.setEntityItemStack(stack);
double renderProgress = (oldProgress + (progress - oldProgress) * partialTick) * 2 - 1;
GL11.glPushMatrix();
GL11.glTranslated(heading.offsetX * renderProgress * 0.5, heading.offsetY * renderProgress * 0.5, heading.offsetZ * renderProgress * 0.5);
customRenderItem.doRender(renderedItem, 0, 0, 0, 0, 0);
if (color != TubeColor.NONE) {
float size = 0.2F;
int colorInt = ItemDye.field_150922_c[color.ordinal()];
float red = (colorInt >> 16) / 256F;
float green = (colorInt >> 8 & 255) / 256F;
float blue = (colorInt & 255) / 256F;
GL11.glDisable(GL11.GL_CULL_FACE);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glColor3f(red, green, blue);
Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation(Refs.MODID, "textures/blocks/tubes/inside_color_border.png"));
RenderHelper.drawTesselatedTexturedCube(new Vector3Cube(-size, -size, -size, size, size, size));
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glEnable(GL11.GL_LIGHTING);
}
GL11.glPopMatrix();
}
}
| 5,811 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
IWeightedTubeInventory.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/part/tube/IWeightedTubeInventory.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.part.tube;
import net.minecraftforge.common.util.ForgeDirection;
/**
This interface is implemented by inventories with a buffer inventory, in which the tube _can_ but doesn't prefer to
insert items back into the buffer. An arbitrarily large number is returned, 1000000. A Restriction Tube has a weight
of 1000, a normal tube 1.
@author MineMaarten
*/
public interface IWeightedTubeInventory {
/**
By default this can be seen as 0 for non implementing inventories. return a high value to make it less prefered
by the tubes.
*/
public int getWeight(ForgeDirection from);
}
| 1,381 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
PneumaticTube.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/part/tube/PneumaticTube.java | package net.quetzi.bluepower.part.tube;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemDye;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
import net.minecraftforge.common.util.ForgeDirection;
import net.quetzi.bluepower.api.part.BPPart;
import net.quetzi.bluepower.api.tube.IPneumaticTube.TubeColor;
import net.quetzi.bluepower.api.vec.Vector3;
import net.quetzi.bluepower.api.vec.Vector3Cube;
import net.quetzi.bluepower.client.renderers.IconSupplier;
import net.quetzi.bluepower.helper.IOHelper;
import net.quetzi.bluepower.helper.TileEntityCache;
import net.quetzi.bluepower.init.CustomTabs;
/**
*
* @author MineMaarten
*/
public class PneumaticTube extends BPPart {
public final boolean[] connections = new boolean[6];
/**
* true when != 2 connections, when this is true the logic doesn't have to 'think' which way an item should go.
*/
public boolean isCrossOver;
private final Vector3Cube sideBB = new Vector3Cube(AxisAlignedBB.getBoundingBox(0.25, 0, 0.25, 0.75, 0.25, 0.75));
private TileEntityCache[] tileCache;
private TubeColor color = TubeColor.NONE;
private final TubeLogic logic = new TubeLogic(this);
public boolean initialized; //workaround to the connections not properly initialized, but being tried to be used.
// private final ResourceLocation tubeSideTexture = new ResourceLocation(Refs.MODID + ":textures/blocks/Tubes/pneumatic_tube_side.png");
// private final ResourceLocation tubeNodeTexture = new ResourceLocation(Refs.MODID + ":textures/blocks/Tubes/tube_end.png");
@Override
public String getType() {
return "pneumaticTube";
}
@Override
public String getUnlocalizedName() {
return "pneumaticTube";
}
/**
* Gets all the collision boxes for this block
*
* @return A list with the collision boxes
*/
@Override
public List<AxisAlignedBB> getCollisionBoxes() {
return getSelectionBoxes();
}
/**
* Gets all the selection boxes for this block
*
* @return A list with the selection boxes
*/
@Override
public List<AxisAlignedBB> getSelectionBoxes() {
List<AxisAlignedBB> aabbs = getOcclusionBoxes();
for (int i = 0; i < 6; i++) {
if (connections[i]) {
ForgeDirection d = ForgeDirection.getOrientation(i);
if (d == ForgeDirection.UP || d == ForgeDirection.DOWN) d = d.getOpposite();
Vector3Cube c = sideBB.clone().rotate90Degrees(d);
aabbs.add(c.toAABB());
}
}
return aabbs;
}
/**
* Gets all the occlusion boxes for this block
*
* @return A list with the occlusion boxes
*/
@Override
public List<AxisAlignedBB> getOcclusionBoxes() {
List<AxisAlignedBB> aabbs = new ArrayList<AxisAlignedBB>();
aabbs.add(AxisAlignedBB.getBoundingBox(0.25, 0.25, 0.25, 0.75, 0.75, 0.75));
return aabbs;
}
@Override
public void update() {
if (initialized) logic.update();
super.update();
if (tick == 3) updateConnections();
if (world.isRemote && tick % 40 == 0) tileCache = null;//reset on the client, as it doesn't get update on neighbor block updates (as the method isn't called on the client)
}
/**
* Event called whenever a nearby block updates
*/
@Override
public void onNeighborUpdate() {
for (TileEntityCache cache : getTileCache()) {
cache.update();
}
updateConnections();
}
@Override
public void onPartChanged() {
updateConnections();
}
public TileEntityCache[] getTileCache() {
if (tileCache == null) {
tileCache = TileEntityCache.getDefaultCache(world, x, y, z);
}
return tileCache;
}
public TubeLogic getLogic() {
return logic;
}
private void updateConnections() {
if (world != null && !world.isRemote) {
int connectionCount = 0;
boolean clearedCache = false;
for (int i = 0; i < 6; i++) {
boolean oldState = connections[i];
getTileCache()[i].update();
ForgeDirection d = ForgeDirection.getOrientation(i);
TileEntity neighbor = getTileCache()[i].getTileEntity();
connections[i] = IOHelper.canInterfaceWith(neighbor, d.getOpposite(), this);
if (!connections[i]) connections[i] = neighbor instanceof ITubeConnection && ((ITubeConnection) neighbor).isConnectedTo(d.getOpposite());
if (connections[i]) {
connections[i] = isConnected(d, null);
}
if (connections[i]) connectionCount++;
if (!clearedCache && oldState != connections[i]) {
// getLogic().clearNodeCaches();
clearedCache = true;
}
}
isCrossOver = connectionCount != 2;
sendUpdatePacket();
}
initialized = true;
}
public boolean isConnected(ForgeDirection dir, PneumaticTube otherTube) {
if (otherTube != null && otherTube.color != TubeColor.NONE && color != TubeColor.NONE && color != otherTube.color) return false;
if (dir == ForgeDirection.UP || dir == ForgeDirection.DOWN) dir = dir.getOpposite();
return world == null || !checkOcclusion(sideBB.clone().rotate90Degrees(dir).toAABB());
}
@Override
public void save(NBTTagCompound tag) {
super.save(tag);
for (int i = 0; i < 6; i++) {
tag.setBoolean("connections" + i, connections[i]);
}
tag.setByte("tubeColor", (byte) color.ordinal());
NBTTagCompound logicTag = new NBTTagCompound();
logic.writeToNBT(logicTag);
tag.setTag("logic", logicTag);
}
@Override
public void load(NBTTagCompound tag) {
super.load(tag);
int connectionCount = 0;
for (int i = 0; i < 6; i++) {
connections[i] = tag.getBoolean("connections" + i);
if (connections[i]) connectionCount++;
}
isCrossOver = connectionCount != 2;
color = TubeColor.values()[tag.getByte("tubeColor")];
NBTTagCompound logicTag = tag.getCompoundTag("logic");
logic.readFromNBT(logicTag);
}
/**
* Event called when the part is activated (right clicked)
*
* @param player
* Player that right clicked the part
* @param item
* Item that was used to click it
* @return Whether or not an action occurred
*/
@Override
public boolean onActivated(EntityPlayer player, ItemStack item) {
if (world == null) return false;
if (!world.isRemote) {
if (item != null && item.getItem() == Items.dye) {
if (item.getItemDamage() < 16) {
color = TubeColor.values()[item.getItemDamage()];
updateConnections();
notifyUpdate();
return true;
}
}
}
return false;
}
@Override
public List<ItemStack> getDrops() {
List<ItemStack> drops = super.getDrops();
for (TubeStack stack : logic.tubeStacks) {
drops.add(stack.stack);
}
return drops;
}
/**
* How 'dense' the tube is to the pathfinding algorithm. Is altered in the RestrictionTube
* @return
*/
public int getWeigth() {
return 1;
}
public TubeColor getColor() {
return color;
}
/**
* This render method gets called every tick. You should use this if you're doing animations
*
* @param loc
* Distance from the player's position
* @param pass
* Render pass (0 or 1)
* @param frame
* Partial tick for smoother animations
*/
@Override
public void renderDynamic(Vector3 loc, int pass, float frame) {
logic.renderDynamic(loc, frame);
}
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
Tessellator t = Tessellator.instance;
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
t.startDrawingQuads();
connections[2] = true;
connections[3] = true;
List<AxisAlignedBB> aabbs = getSelectionBoxes();
renderMiddle(aabbs.get(0), IconSupplier.pneumaticTubeSide);
for (int i = 1; i < aabbs.size(); i++) {
AxisAlignedBB aabb = aabbs.get(i);
IIcon icon = IconSupplier.pneumaticTubeNode;
if (aabb.minZ == 0) {
double minX = icon.getInterpolatedU(aabb.minX * 16);
double maxX = icon.getInterpolatedU(aabb.maxX * 16);
double minY = icon.getInterpolatedV(aabb.minY * 16);
double maxY = icon.getInterpolatedV(aabb.maxY * 16);
t.setNormal(0, 0, -1);
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.minZ, minX, maxY);// minZ
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.minZ, maxX, maxY);
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.minZ, maxX, minY);
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.minZ, minX, minY);
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.minZ, minX, maxY);// minZ
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.minZ, minX, minY);
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.minZ, maxX, minY);
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.minZ, maxX, maxY);
}
if (aabb.maxZ == 1) {
double minX = icon.getInterpolatedU(aabb.minX * 16);
double maxX = icon.getInterpolatedU(aabb.maxX * 16);
double minY = icon.getInterpolatedV(aabb.minY * 16);
double maxY = icon.getInterpolatedV(aabb.maxY * 16);
t.setNormal(0, 0, 1);
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.maxZ, minX, minY);
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.maxZ, minX, maxY);// maxZ
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.maxZ, maxX, maxY);
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.maxZ, maxX, minY);
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.maxZ, minX, minY);
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.maxZ, maxX, minY);
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.maxZ, maxX, maxY);
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.maxZ, minX, maxY);// maxZ
}
icon = IconSupplier.pneumaticTubeSide;
if (!connections[0]) {
double minX = icon.getInterpolatedU(aabb.minX * 16);
double maxX = icon.getInterpolatedU(aabb.maxX * 16);
double minZ = icon.getInterpolatedV(aabb.minZ * 16);
double maxZ = icon.getInterpolatedV(aabb.maxZ * 16);
t.setNormal(0, -1, 0);
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.minZ, maxX, maxZ);// bottom
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.minZ, minX, maxZ);
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.maxZ, minX, minZ);
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.maxZ, maxX, minZ);
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.minZ, maxX, maxZ);// bottom
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.maxZ, maxX, minZ);
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.maxZ, minX, minZ);
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.minZ, minX, maxZ);
}
if (!connections[1]) {
double minX = icon.getInterpolatedU(aabb.minX * 16);
double maxX = icon.getInterpolatedU(aabb.maxX * 16);
double minZ = icon.getInterpolatedV(aabb.minZ * 16);
double maxZ = icon.getInterpolatedV(aabb.maxZ * 16);
t.setNormal(0, 1, 0);
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.minZ, maxX, minZ);// top
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.minZ, minX, minZ);
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.maxZ, minX, maxZ);
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.maxZ, maxX, maxZ);
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.minZ, maxX, minZ);// top
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.maxZ, maxX, maxZ);
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.maxZ, minX, maxZ);
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.minZ, minX, minZ);
}
if (!connections[4]) {
double minY = icon.getInterpolatedU(aabb.minY * 16);
double maxY = icon.getInterpolatedU(aabb.maxY * 16);
double minZ = icon.getInterpolatedV(aabb.minZ * 16);
double maxZ = icon.getInterpolatedV(aabb.maxZ * 16);
t.setNormal(-1, 0, 0);
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.minZ, minY, minZ);// minX
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.minZ, maxY, minZ);
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.maxX, maxY, maxZ);
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.maxZ, minY, maxZ);
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.minZ, minY, minZ);// minX
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.maxZ, minY, maxZ);
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.maxX, maxY, maxZ);
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.minZ, maxY, minZ);
}
if (!connections[5]) {
double minY = icon.getInterpolatedU(aabb.minY * 16);
double maxY = icon.getInterpolatedU(aabb.maxY * 16);
double minZ = icon.getInterpolatedV(aabb.minZ * 16);
double maxZ = icon.getInterpolatedV(aabb.maxZ * 16);
t.setNormal(1, 0, 0);
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.minZ, minY, maxZ);// maxX
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.minZ, maxY, maxZ);
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.maxZ, maxY, minZ);
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.maxZ, minY, minZ);
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.minZ, minY, maxZ);// maxX
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.maxZ, minY, minZ);
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.maxZ, maxY, minZ);
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.minZ, maxY, maxZ);
}
}
t.draw();
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture);
}
private void renderMiddle(AxisAlignedBB aabb, IIcon icon) {
Tessellator t = Tessellator.instance;
if (!connections[2]) {
double minX = icon.getInterpolatedU(aabb.minX * 16);
double maxX = icon.getInterpolatedU(aabb.maxX * 16);
double minY = icon.getInterpolatedV(aabb.minY * 16);
double maxY = icon.getInterpolatedV(aabb.maxY * 16);
t.setNormal(0, 0, -1);
if (connections[4]) {// or 5
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.minZ, minX, maxY);// minZ
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.minZ, minX, minY);
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.minZ, maxX, minY);
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.minZ, maxX, maxY);
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.minZ, minX, maxY);// minZ
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.minZ, maxX, maxY);
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.minZ, maxX, minY);
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.minZ, minX, minY);
} else {
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.minZ, minX, maxY);// minZ
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.minZ, maxX, maxY);
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.minZ, maxX, minY);
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.minZ, minX, minY);
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.minZ, minX, maxY);// minZ
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.minZ, minX, minY);
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.minZ, maxX, minY);
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.minZ, maxX, maxY);
}
}
if (!connections[3]) {
double minX = icon.getInterpolatedU(aabb.minX * 16);
double maxX = icon.getInterpolatedU(aabb.maxX * 16);
double minY = icon.getInterpolatedV(aabb.minY * 16);
double maxY = icon.getInterpolatedV(aabb.maxY * 16);
t.setNormal(0, 0, 1);
if (connections[4]) {// or 5
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.maxZ, maxX, maxY);
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.maxZ, minX, maxY);// maxZ
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.maxZ, minX, minY);
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.maxZ, maxX, minY);
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.maxZ, maxX, maxY);
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.maxZ, maxX, minY);
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.maxZ, minX, minY);
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.maxZ, minX, maxY);// maxZ
} else {
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.maxZ, minX, minY);
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.maxZ, minX, maxY);// maxZ
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.maxZ, maxX, maxY);
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.maxZ, maxX, minY);
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.maxZ, minX, minY);
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.maxZ, maxX, minY);
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.maxZ, maxX, maxY);
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.maxZ, minX, maxY);// maxZ
}
}
if (!connections[0]) {
double minX = icon.getInterpolatedU(aabb.minX * 16);
double maxX = icon.getInterpolatedU(aabb.maxX * 16);
double minZ = icon.getInterpolatedV(aabb.minZ * 16);
double maxZ = icon.getInterpolatedV(aabb.maxZ * 16);
t.setNormal(0, -1, 0);
if (connections[4]) {// or 5
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.minZ, maxX, maxZ);// bottom
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.maxZ, minX, maxZ);
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.maxZ, minX, minZ);
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.minZ, maxX, minZ);
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.minZ, maxX, maxZ);// bottom
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.minZ, maxX, minZ);
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.maxZ, minX, minZ);
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.maxZ, minX, maxZ);
} else {
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.minZ, maxX, maxZ);// bottom
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.minZ, minX, maxZ);
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.maxZ, minX, minZ);
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.maxZ, maxX, minZ);
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.minZ, maxX, maxZ);// bottom
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.maxZ, maxX, minZ);
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.maxZ, minX, minZ);
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.minZ, minX, maxZ);
}
}
if (!connections[1]) {
double minX = icon.getInterpolatedU(aabb.minX * 16);
double maxX = icon.getInterpolatedU(aabb.maxX * 16);
double minZ = icon.getInterpolatedV(aabb.minZ * 16);
double maxZ = icon.getInterpolatedV(aabb.maxZ * 16);
t.setNormal(0, 1, 0);
if (connections[4]) {// or 5
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.minZ, maxX, maxZ);// top
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.minZ, maxX, minZ);
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.maxZ, minX, minZ);
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.maxZ, minX, maxZ);
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.minZ, maxX, maxZ);// top
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.maxZ, minX, maxZ);
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.maxZ, minX, minZ);
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.minZ, maxX, minZ);
} else {
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.minZ, maxX, minZ);// top
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.minZ, minX, minZ);
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.maxZ, minX, maxZ);
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.maxZ, maxX, maxZ);
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.minZ, maxX, minZ);// top
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.maxZ, maxX, maxZ);
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.maxZ, minX, maxZ);
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.minZ, minX, minZ);
}
}
if (!connections[4]) {
double minY = icon.getInterpolatedU(aabb.minY * 16);
double maxY = icon.getInterpolatedU(aabb.maxY * 16);
double minZ = icon.getInterpolatedV(aabb.minZ * 16);
double maxZ = icon.getInterpolatedV(aabb.maxZ * 16);
t.setNormal(-1, 0, 0);
if (connections[0]) {
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.minZ, maxY, maxZ);// minX
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.maxZ, minY, maxZ);
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.maxX, minY, minZ);
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.minZ, maxY, minZ);
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.minZ, maxY, maxZ);// minX
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.minZ, maxY, minZ);
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.maxX, minY, minZ);
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.maxZ, minY, maxZ);
} else {
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.minZ, minY, minZ);// minX
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.minZ, maxY, minZ);
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.maxX, maxY, maxZ);
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.maxZ, minY, maxZ);
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.minZ, minY, minZ);// minX
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.maxZ, minY, maxZ);
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.maxX, maxY, maxZ);
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.minZ, maxY, minZ);
}
}
if (!connections[5]) {
double minY = icon.getInterpolatedU(aabb.minY * 16);
double maxY = icon.getInterpolatedU(aabb.maxY * 16);
double minZ = icon.getInterpolatedV(aabb.minZ * 16);
double maxZ = icon.getInterpolatedV(aabb.maxZ * 16);
t.setNormal(1, 0, 0);
if (connections[0]) {
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.minZ, minY, maxZ);// maxX
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.minZ, minY, minZ);
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.maxZ, maxY, minZ);
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.maxZ, maxY, maxZ);
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.minZ, minY, maxZ);// maxX
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.maxZ, maxY, maxZ);
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.maxZ, maxY, minZ);
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.minZ, minY, minZ);
} else {
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.minZ, minY, maxZ);// maxX
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.minZ, maxY, maxZ);
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.maxZ, maxY, minZ);
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.maxZ, minY, minZ);
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.minZ, minY, maxZ);// maxX
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.maxZ, minY, minZ);
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.maxZ, maxY, minZ);
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.minZ, maxY, maxZ);
}
}
}
public void renderTexturedCuboid(AxisAlignedBB aabb, IIcon icon) {
Tessellator t = Tessellator.instance;
if (aabb.minZ != 0 && (!connections[3] || aabb.minZ != 0.75)) {
if (aabb.maxY == 1 || aabb.minY == 0) {
double minX = icon.getInterpolatedU(aabb.minX * 16);
double maxX = icon.getInterpolatedU(aabb.maxX * 16);
double minY = icon.getInterpolatedV(aabb.minY * 16);
double maxY = icon.getInterpolatedV(aabb.maxY * 16);
t.setNormal(0, 0, -1);
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.minZ, maxX, maxY);// minZ
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.minZ, minX, maxY);
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.minZ, minX, minY);
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.minZ, maxX, minY);
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.minZ, maxX, maxY);// minZ
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.minZ, maxX, minY);
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.minZ, minX, minY);
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.minZ, minX, maxY);
} else {
double minX = icon.getInterpolatedU(aabb.minY * 16);
double maxX = icon.getInterpolatedU(aabb.maxY * 16);
double minY = icon.getInterpolatedV(aabb.minX * 16);
double maxY = icon.getInterpolatedV(aabb.maxX * 16);
t.setNormal(0, 0, -1);
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.minZ, maxX, maxY);// minZ
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.minZ, minX, maxY);
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.minZ, minX, minY);
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.minZ, maxX, minY);
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.minZ, maxX, maxY);// minZ
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.minZ, maxX, minY);
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.minZ, minX, minY);
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.minZ, minX, maxY);
}
}
if (aabb.maxZ != 1 && (!connections[2] || aabb.maxZ != 0.25)) {
if (aabb.minY == 0 || aabb.maxY == 1) {
double minX = icon.getInterpolatedU(aabb.minX * 16);
double maxX = icon.getInterpolatedU(aabb.maxX * 16);
double minY = icon.getInterpolatedV(aabb.minY * 16);
double maxY = icon.getInterpolatedV(aabb.maxY * 16);
t.setNormal(0, 0, 1);
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.maxZ, minX, minY);
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.maxZ, minX, maxY);// maxZ
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.maxZ, maxX, maxY);
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.maxZ, maxX, minY);
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.maxZ, minX, minY);
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.maxZ, maxX, minY);
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.maxZ, maxX, maxY);
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.maxZ, minX, maxY);// maxZ
} else {
double minX = icon.getInterpolatedU(aabb.minY * 16);
double maxX = icon.getInterpolatedU(aabb.maxY * 16);
double minY = icon.getInterpolatedV(aabb.minX * 16);
double maxY = icon.getInterpolatedV(aabb.maxX * 16);
t.setNormal(0, 0, 1);
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.maxZ, minX, minY);
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.maxZ, minX, maxY);// maxZ
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.maxZ, maxX, maxY);
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.maxZ, maxX, minY);
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.maxZ, minX, minY);
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.maxZ, maxX, minY);
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.maxZ, maxX, maxY);
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.maxZ, minX, maxY);// maxZ
}
}
if (aabb.minY != 0 && (!connections[1] || aabb.minY != 0.75)) {
if (aabb.minX == 0 || aabb.maxX == 1) {
double minX = icon.getInterpolatedU(aabb.minZ * 16);
double maxX = icon.getInterpolatedU(aabb.maxZ * 16);
double minZ = icon.getInterpolatedV(aabb.minX * 16);
double maxZ = icon.getInterpolatedV(aabb.maxX * 16);
t.setNormal(0, -1, 0);
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.minZ, minX, maxZ);// bottom
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.maxZ, maxX, maxZ);
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.maxZ, maxX, minZ);
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.minZ, minX, minZ);
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.minZ, minX, maxZ);// bottom
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.minZ, minX, minZ);
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.maxZ, maxX, minZ);
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.maxZ, maxX, maxZ);
} else {
double minX = icon.getInterpolatedU(aabb.minX * 16);
double maxX = icon.getInterpolatedU(aabb.maxX * 16);
double minZ = icon.getInterpolatedV(aabb.minZ * 16);
double maxZ = icon.getInterpolatedV(aabb.maxZ * 16);
t.setNormal(0, -1, 0);
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.maxZ, minX, maxZ);// bottom
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.maxZ, maxX, maxZ);
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.minZ, maxX, minZ);
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.minZ, minX, minZ);
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.maxZ, minX, maxZ);// bottom
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.minZ, minX, minZ);
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.minZ, maxX, minZ);
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.maxZ, maxX, maxZ);
}
}
if (aabb.maxY != 1 && (!connections[0] || aabb.maxY != 0.25)) {
if (aabb.minX == 0 || aabb.maxX == 1) {
double minX = icon.getInterpolatedU(aabb.minZ * 16);
double maxX = icon.getInterpolatedU(aabb.maxZ * 16);
double minZ = icon.getInterpolatedV(aabb.minX * 16);
double maxZ = icon.getInterpolatedV(aabb.maxX * 16);
t.setNormal(0, 1, 0);
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.minZ, minX, minZ);// top
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.maxZ, maxX, minZ);
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.maxZ, maxX, maxZ);
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.minZ, minX, maxZ);
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.minZ, minX, minZ);// top
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.minZ, minX, maxZ);
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.maxZ, maxX, maxZ);
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.maxZ, maxX, minZ);
} else {
double minX = icon.getInterpolatedU(aabb.minX * 16);
double maxX = icon.getInterpolatedU(aabb.maxX * 16);
double minZ = icon.getInterpolatedV(aabb.minZ * 16);
double maxZ = icon.getInterpolatedV(aabb.maxZ * 16);
t.setNormal(0, 1, 0);
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.maxZ, minX, minZ);// top
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.maxZ, maxX, minZ);
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.minZ, maxX, maxZ);
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.minZ, minX, maxZ);
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.maxZ, minX, minZ);// top
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.minZ, minX, maxZ);
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.minZ, maxX, maxZ);
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.maxZ, maxX, minZ);
}
}
if (aabb.minX != 0 && (!connections[5] || aabb.minX != 0.75)) {
if (aabb.minY == 0 || aabb.maxY == 1) {
double minY = icon.getInterpolatedU(aabb.minZ * 16);
double maxY = icon.getInterpolatedU(aabb.maxZ * 16);
double minZ = icon.getInterpolatedV(aabb.minY * 16);
double maxZ = icon.getInterpolatedV(aabb.maxY * 16);
t.setNormal(-1, 0, 0);
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.minZ, minY, minZ);// minX
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.minZ, minY, maxZ);
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.maxZ, maxY, maxZ);
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.maxZ, maxY, minZ);
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.minZ, minY, minZ);// minX
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.maxZ, maxY, minZ);
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.maxZ, maxY, maxZ);
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.minZ, minY, maxZ);
} else {
double minY = icon.getInterpolatedU(aabb.minY * 16);
double maxY = icon.getInterpolatedU(aabb.maxY * 16);
double minZ = icon.getInterpolatedV(aabb.minZ * 16);
double maxZ = icon.getInterpolatedV(aabb.maxZ * 16);
t.setNormal(-1, 0, 0);
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.minZ, minY, minZ);// minX
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.maxZ, minY, maxZ);
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.maxZ, maxY, maxZ);
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.minZ, maxY, minZ);
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.minZ, minY, minZ);// minX
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.minZ, maxY, minZ);
t.addVertexWithUV(aabb.minX, aabb.minY, aabb.maxZ, maxY, maxZ);
t.addVertexWithUV(aabb.minX, aabb.maxY, aabb.maxZ, minY, maxZ);
}
}
if (aabb.maxX != 1 && (!connections[4] || aabb.maxX != 0.25)) {
if (aabb.minY == 0 || aabb.maxY == 1) {
double minY = icon.getInterpolatedU(aabb.minZ * 16);
double maxY = icon.getInterpolatedU(aabb.maxZ * 16);
double minZ = icon.getInterpolatedV(aabb.minY * 16);
double maxZ = icon.getInterpolatedV(aabb.maxY * 16);
t.setNormal(1, 0, 0);
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.minZ, minY, maxZ);// maxX
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.maxZ, maxY, maxZ);
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.maxZ, maxY, minZ);
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.minZ, minY, minZ);
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.minZ, minY, maxZ);// maxX
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.minZ, minY, minZ);
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.maxZ, maxY, minZ);
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.maxZ, maxY, maxZ);
} else {
double minY = icon.getInterpolatedU(aabb.minY * 16);
double maxY = icon.getInterpolatedU(aabb.maxY * 16);
double minZ = icon.getInterpolatedV(aabb.minZ * 16);
double maxZ = icon.getInterpolatedV(aabb.maxZ * 16);
t.setNormal(1, 0, 0);
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.maxZ, minY, maxZ);// maxX
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.maxZ, maxY, maxZ);
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.minZ, maxY, minZ);
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.minZ, minY, minZ);
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.maxZ, minY, maxZ);// maxX
t.addVertexWithUV(aabb.maxX, aabb.minY, aabb.minZ, minY, minZ);
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.minZ, maxY, minZ);
t.addVertexWithUV(aabb.maxX, aabb.maxY, aabb.maxZ, maxY, maxZ);
}
}
}
/**
* This render method gets called whenever there's a block update in the chunk. You should use this to remove load from the renderer if a part of
* the rendering code doesn't need to get called too often or just doesn't change at all. To call a render update to re-render this just call
* {@link BPPart#markPartForRenderUpdate()}
*
* @param loc
* Distance from the player's position
* @param pass
* Render pass (0 or 1)
* @return Whether or not it rendered something
*/
@Override
public boolean renderStatic(Vector3 loc, int pass) {
Tessellator t = Tessellator.instance;
t.setColorOpaque_F(1, 1, 1);
t.addTranslation((float) loc.getX(), (float) loc.getY(), (float) loc.getZ());
List<AxisAlignedBB> aabbs = getSelectionBoxes();
boolean shouldRenderNode = false;
int connectionCount = 0;
for (int i = 0; i < 6; i += 2) {
if (connections[i] != connections[i + 1]) {
shouldRenderNode = true;
break;
}
if (connections[i]) connectionCount++;
if (connections[i + 1]) connectionCount++;
}
if (shouldRenderNode || connectionCount == 0 || connectionCount > 2) {
renderMiddle(aabbs.get(0), IconSupplier.pneumaticTubeNode);
if (color != TubeColor.NONE) {
t.setColorOpaque_I(ItemDye.field_150922_c[color.ordinal()]);
renderMiddle(aabbs.get(0), IconSupplier.pneumaticTubeColorNode);
t.setColorOpaque_F(1, 1, 1);
}
} else {
renderMiddle(aabbs.get(0), IconSupplier.pneumaticTubeSide);
if (color != TubeColor.NONE) {
t.setColorOpaque_I(ItemDye.field_150922_c[color.ordinal()]);
renderMiddle(aabbs.get(0), IconSupplier.pneumaticTubeColorSide);
t.setColorOpaque_F(1, 1, 1);
}
}
for (int i = 1; i < aabbs.size(); i++) {
renderTexturedCuboid(aabbs.get(i), IconSupplier.pneumaticTubeSide);
if (color != TubeColor.NONE) {
t.setColorOpaque_I(ItemDye.field_150922_c[color.ordinal()]);
renderTexturedCuboid(aabbs.get(i), IconSupplier.pneumaticTubeColorSide);
t.setColorOpaque_F(1, 1, 1);
}
}
t.addTranslation((float) -loc.getX(), (float) -loc.getY(), (float) -loc.getZ());
return true;
}
@Override
public CreativeTabs getCreativeTab() {
return CustomTabs.tabBluePowerMachines;
}
}
| 42,930 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
ITubeConnection.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/part/tube/ITubeConnection.java | package net.quetzi.bluepower.part.tube;
import net.minecraftforge.common.util.ForgeDirection;
/**
*
* @author MineMaarten
*/
public interface ITubeConnection {
public boolean isConnectedTo(ForgeDirection from);
/**
*
* @param stack TubeStack, as it needs to save the color if it bounced into the buffer.
* @param from
* @param simulate TODO
* @return The TubeStack that was unable to enter the ITubeConnector
*/
public TubeStack acceptItemFromTube(TubeStack stack, ForgeDirection from, boolean simulate);
}
| 567 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
PartCageLamp.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/part/lamp/PartCageLamp.java | package net.quetzi.bluepower.part.lamp;
import java.util.List;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.quetzi.bluepower.api.vec.Vector3Cube;
import net.quetzi.bluepower.client.renderers.IconSupplier;
import net.quetzi.bluepower.client.renderers.RenderHelper;
import org.lwjgl.opengl.GL11;
/**
*
* @author Koen Beckers (K4Unl)
*
*/
public class PartCageLamp extends PartLamp {
public PartCageLamp(String colorName, Integer colorVal, Boolean inverted) {
super(colorName, colorVal, inverted);
}
/**
* @author Koen Beckers (K4Unl)
*/
@Override
public void addSelectionBoxes(List<AxisAlignedBB> boxes) {
boxes.add(AxisAlignedBB.getBoundingBox(pixel * 3, 0.0, pixel * 3, 1.0 - (pixel * 3), pixel * 2, 1.0 - pixel * 3));
boxes.add(AxisAlignedBB.getBoundingBox(pixel * 4, pixel * 2, pixel * 4, 1.0 - (pixel * 4), 1.0 - (pixel * 4), 1.0 - pixel * 4));
}
@Override
public void renderBase(int pass) {
if(pass != 0) return;
Tessellator t = Tessellator.instance;
Vector3Cube vector = new Vector3Cube(pixel * 3, 0.0, pixel * 3, 1.0 - (pixel * 3), pixel * 2, 1.0 - pixel * 3);
IIcon topIcon = IconSupplier.cagedLampFootTop;
IIcon sideIcon = IconSupplier.cagedLampFootSide;
double minU = topIcon.getInterpolatedU(vector.getMinX() * 16);
double maxU = topIcon.getInterpolatedU(vector.getMaxX() * 16);
double minV = topIcon.getInterpolatedV(vector.getMinZ() * 16);
double maxV = topIcon.getInterpolatedV(vector.getMaxZ() * 16);
// Top side
t.setNormal(0, 1, 0);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMaxZ(), minU, maxV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ(), minU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMinZ(), maxU, minV);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMinZ(), maxU, maxV);
/*
* minU = sideIcon.getInterpolatedU(vector.getMinX() * 16); maxU = sideIcon.getInterpolatedU(vector.getMaxX() * 16); minV =
* sideIcon.getInterpolatedV(vector.getMinY() * 16); maxV = sideIcon.getInterpolatedV(vector.getMaxY() * 16);
*/
// Draw west side:
t.setNormal(-1, 0, 0);
t.addVertexWithUV(vector.getMinX(), vector.getMinY(), vector.getMaxZ(), minU, maxV);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMaxZ(), minU, minV);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMinZ(), maxU, minV);
t.addVertexWithUV(vector.getMinX(), vector.getMinY(), vector.getMinZ(), maxU, maxV);
// Draw east side:
t.setNormal(1, 0, 0);
t.addVertexWithUV(vector.getMaxX(), vector.getMinY(), vector.getMinZ(), minU, maxV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMinZ(), minU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ(), maxU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMinY(), vector.getMaxZ(), maxU, maxV);
// Draw north side
t.setNormal(0, 0, -1);
t.addVertexWithUV(vector.getMinX(), vector.getMinY(), vector.getMinZ(), minU, maxV);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMinZ(), minU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMinZ(), maxU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMinY(), vector.getMinZ(), maxU, maxV);
// Draw south side
t.setNormal(0, 0, 1);
t.addVertexWithUV(vector.getMinX(), vector.getMinY(), vector.getMaxZ(), minU, maxV);
t.addVertexWithUV(vector.getMaxX(), vector.getMinY(), vector.getMaxZ(), minU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ(), maxU, minV);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMaxZ(), maxU, maxV);
// And now, the cage itself!
// No. Not Nicholas Cage. The lamp-cage!
vector = new Vector3Cube(pixel * 4, pixel * 2, pixel * 4, 1.0 - (pixel * 4), 1.0 - (pixel * 4), 1.0 - pixel * 4);
topIcon = IconSupplier.cagedLampCageTop;
sideIcon = IconSupplier.cagedLampCageSide;
minU = topIcon.getInterpolatedU(vector.getMinX() * 16);
maxU = topIcon.getInterpolatedU(vector.getMaxX() * 16);
minV = topIcon.getInterpolatedV(vector.getMinZ() * 16);
maxV = topIcon.getInterpolatedV(vector.getMaxZ() * 16);
// Top side
t.setNormal(0, 1, 0);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMaxZ(), minU, maxV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ(), minU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMinZ(), maxU, minV);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMinZ(), maxU, maxV);
minU = sideIcon.getInterpolatedU(vector.getMinX() * 16);
maxU = sideIcon.getInterpolatedU(vector.getMaxX() * 16);
minV = sideIcon.getInterpolatedV(vector.getMinY() * 16);
maxV = sideIcon.getInterpolatedV(vector.getMaxY() * 16);
// Draw west side:
t.setNormal(-1, 0, 0);
t.addVertexWithUV(vector.getMinX(), vector.getMinY(), vector.getMaxZ(), minU, maxV);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMaxZ(), minU, minV);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMinZ(), maxU, minV);
t.addVertexWithUV(vector.getMinX(), vector.getMinY(), vector.getMinZ(), maxU, maxV);
t.setNormal(1, 0, 0);
t.addVertexWithUV(vector.getMinX(), vector.getMinY(), vector.getMinZ(), minU, maxV);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMinZ(), minU, minV);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMaxZ(), maxU, minV);
t.addVertexWithUV(vector.getMinX(), vector.getMinY(), vector.getMaxZ(), maxU, maxV);
// Draw east side:
t.setNormal(1, 0, 0);
t.addVertexWithUV(vector.getMaxX(), vector.getMinY(), vector.getMinZ(), minU, maxV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMinZ(), minU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ(), maxU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMinY(), vector.getMaxZ(), maxU, maxV);
t.setNormal(-1, 0, 0);
t.addVertexWithUV(vector.getMaxX(), vector.getMinY(), vector.getMaxZ(), minU, maxV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ(), minU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMinZ(), maxU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMinY(), vector.getMinZ(), maxU, maxV);
// Draw north side
t.setNormal(0, 0, 1);
t.addVertexWithUV(vector.getMaxX(), vector.getMinY(), vector.getMinZ(), minU, maxV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMinZ(), minU, minV);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMinZ(), maxU, minV);
t.addVertexWithUV(vector.getMinX(), vector.getMinY(), vector.getMinZ(), maxU, maxV);
t.setNormal(0, 0, -1);
t.addVertexWithUV(vector.getMaxX(), vector.getMinY(), vector.getMinZ(), minU, maxV);
t.addVertexWithUV(vector.getMinX(), vector.getMinY(), vector.getMinZ(), maxU, maxV);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMinZ(), maxU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMinZ(), minU, minV);
// Draw south side
t.setNormal(0, 0, 1);
t.addVertexWithUV(vector.getMaxX(), vector.getMinY(), vector.getMaxZ(), minU, maxV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ(), minU, minV);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMaxZ(), maxU, minV);
t.addVertexWithUV(vector.getMinX(), vector.getMinY(), vector.getMaxZ(), maxU, maxV);
t.setNormal(0, 0, -1);
t.addVertexWithUV(vector.getMaxX(), vector.getMinY(), vector.getMaxZ(), minU, maxV);
t.addVertexWithUV(vector.getMinX(), vector.getMinY(), vector.getMaxZ(), maxU, maxV);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMaxZ(), maxU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ(), minU, minV);
}
@Override
public void renderLamp(int pass, int r, int g, int b) {
Vector3Cube vector = new Vector3Cube(pixel * 5, pixel * 2, pixel * 5, 1.0 - (pixel * 5), 1.0 - (pixel * 5), 1.0 - pixel * 5);
Tessellator t = Tessellator.instance;
IIcon iconToUseTop;
IIcon iconToUseSide;
if (power == 0) {
iconToUseSide = IconSupplier.cagedLampLampInactive;
iconToUseTop = IconSupplier.cagedLampLampInactiveTop;
} else {
iconToUseSide = IconSupplier.cagedLampLampActive;
iconToUseTop = IconSupplier.cagedLampLampActiveTop;
t.setColorRGBA(r, g, b, 20);
RenderHelper.drawTesselatedCube(new Vector3Cube(pixel * 4.5, pixel * 2, pixel * 4.5, 1.0 - (pixel * 4.5), 1.0 - (pixel * 4.5),
1.0 - pixel * 4.5));
t.setColorRGBA(r, g, b, 255);
}
if (pass == 0) {
double minU = iconToUseTop.getInterpolatedU(vector.getMinX() * 16);
double maxU = iconToUseTop.getInterpolatedU(vector.getMaxX() * 16);
double minV = iconToUseTop.getInterpolatedV(vector.getMinZ() * 16);
double maxV = iconToUseTop.getInterpolatedV(vector.getMaxZ() * 16);
// Top side
t.setNormal(0, 1, 0);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMaxZ(), minU, maxV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ(), minU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMinZ(), maxU, minV);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMinZ(), maxU, maxV);
minU = iconToUseSide.getInterpolatedU(vector.getMinX() * 16);
maxU = iconToUseSide.getInterpolatedU(vector.getMaxX() * 16);
minV = iconToUseSide.getInterpolatedV(vector.getMinZ() * 16);
maxV = iconToUseSide.getInterpolatedV(vector.getMaxZ() * 16);
// Draw west side:
t.setNormal(-1, 0, 0);
t.addVertexWithUV(vector.getMinX(), vector.getMinY(), vector.getMaxZ(), minU, maxV);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMaxZ(), minU, minV);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMinZ(), maxU, minV);
t.addVertexWithUV(vector.getMinX(), vector.getMinY(), vector.getMinZ(), maxU, maxV);
// Draw east side:
t.setNormal(1, 0, 0);
t.addVertexWithUV(vector.getMaxX(), vector.getMinY(), vector.getMinZ(), minU, maxV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMinZ(), minU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ(), maxU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMinY(), vector.getMaxZ(), maxU, maxV);
// Draw north side
t.setNormal(0, 0, -1);
t.addVertexWithUV(vector.getMinX(), vector.getMinY(), vector.getMinZ(), minU, maxV);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMinZ(), minU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMinZ(), maxU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMinY(), vector.getMinZ(), maxU, maxV);
// Draw south side
t.setNormal(0, 0, 1);
t.addVertexWithUV(vector.getMinX(), vector.getMinY(), vector.getMaxZ(), minU, maxV);
t.addVertexWithUV(vector.getMaxX(), vector.getMinY(), vector.getMaxZ(), minU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ(), maxU, minV);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMaxZ(), maxU, maxV);
}
if (power > 0 && pass == 1) {
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glDisable(GL11.GL_LIGHTING);
// GL11.glDisable(GL11.GL_CULL_FACE);
GL11.glDepthMask(false);
GL11.glBegin(GL11.GL_QUADS);
RenderHelper.drawColoredCube(vector.clone().expand(0.5 / 16D), r / 256D, g / 256D, b / 256D, (power / 15D) * 0.625);
GL11.glEnd();
GL11.glDepthMask(true);
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glDisable(GL11.GL_BLEND);
}
}
@Override
public String getType() {
return (this.inverted ? "inverted" : "") + "cagelamp" + colorName;
}
@Override
public String getUnlocalizedName() {
return (this.inverted ? "inverted" : "") + "cagelamp." + colorName;
}
}
| 13,881 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
PartFixture.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/part/lamp/PartFixture.java | package net.quetzi.bluepower.part.lamp;
import java.util.List;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.quetzi.bluepower.api.vec.Vector3Cube;
import net.quetzi.bluepower.client.renderers.IconSupplier;
import net.quetzi.bluepower.client.renderers.RenderHelper;
import org.lwjgl.opengl.GL11;
/**
*
* @author Koen Beckers (K4Unl)
*
*/
public class PartFixture extends PartLamp {
public PartFixture(String colorName, Integer colorVal, Boolean inverted) {
super(colorName, colorVal, inverted);
}
/**
* @author Koen Beckers (K4Unl)
*/
@Override
public void addSelectionBoxes(List<AxisAlignedBB> boxes) {
boxes.add(AxisAlignedBB.getBoundingBox(pixel * 2, 0.0, pixel * 2, 1.0 - (pixel * 2), pixel * 2, 1.0 - pixel * 2));
boxes.add(AxisAlignedBB.getBoundingBox(pixel * 3, pixel * 2, pixel * 3, 1.0 - (pixel * 3), pixel * 8, 1.0 - pixel * 3));
}
@Override
public String getType() {
return (this.inverted ? "inverted" : "") + "fixture" + colorName;
}
@Override
public String getUnlocalizedName() {
return (this.inverted ? "inverted" : "") + "fixture." + colorName;
}
@Override
public void renderBase(int pass) {
if(pass != 0) return;
Tessellator t = Tessellator.instance;
Vector3Cube vector = new Vector3Cube(pixel * 2, 0.0, pixel * 2, 1.0 - (pixel * 2), pixel * 2, 1.0 - pixel * 2);
IIcon topIcon = IconSupplier.fixtureFootTop;
// IIcon sideIcon = IconSupplier.fixtureFootSide;
double minU = topIcon.getInterpolatedU(vector.getMinX() * 16);
double maxU = topIcon.getInterpolatedU(vector.getMaxX() * 16);
double minV = topIcon.getInterpolatedV(vector.getMinZ() * 16);
double maxV = topIcon.getInterpolatedV(vector.getMaxZ() * 16);
// Top side
t.setNormal(0, 1, 0);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMaxZ(), minU, maxV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ(), minU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMinZ(), maxU, minV);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMinZ(), maxU, maxV);
// FIXME: Icons for the side aren't rendered..
/*
* minU = sideIcon.getInterpolatedU(vector.getMinX() * 16); maxU = sideIcon.getInterpolatedU(vector.getMaxX() * 16); minV =
* sideIcon.getInterpolatedV((vector.getMinY() + (3*pixel) )* 16); maxV = sideIcon.getInterpolatedV((vector.getMaxY() + (3*pixel) )* 16);
*/
// Draw west side:
t.setNormal(-1, 0, 0);
t.addVertexWithUV(vector.getMinX(), vector.getMinY(), vector.getMaxZ(), minU, maxV);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMaxZ(), minU, minV);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMinZ(), maxU, minV);
t.addVertexWithUV(vector.getMinX(), vector.getMinY(), vector.getMinZ(), maxU, maxV);
// Draw east side:
t.setNormal(1, 0, 0);
t.addVertexWithUV(vector.getMaxX(), vector.getMinY(), vector.getMinZ(), minU, maxV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMinZ(), minU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ(), maxU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMinY(), vector.getMaxZ(), maxU, maxV);
// Draw north side
t.setNormal(0, 0, -1);
t.addVertexWithUV(vector.getMinX(), vector.getMinY(), vector.getMinZ(), minU, maxV);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMinZ(), minU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMinZ(), maxU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMinY(), vector.getMinZ(), maxU, maxV);
// Draw south side
t.setNormal(0, 0, 1);
t.addVertexWithUV(vector.getMinX(), vector.getMinY(), vector.getMaxZ(), minU, maxV);
t.addVertexWithUV(vector.getMaxX(), vector.getMinY(), vector.getMaxZ(), minU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ(), maxU, minV);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMaxZ(), maxU, maxV);
}
@Override
public void renderLamp(int pass, int r, int g, int b) {
Vector3Cube vector = new Vector3Cube(pixel * 3, pixel * 2, pixel * 3, 1.0 - (pixel * 3), pixel * 8, 1.0 - pixel * 3);
if (pass == 0) {
Tessellator t = Tessellator.instance;
IIcon iconToUseTop;
IIcon iconToUseSide;
if (power == 0) {
iconToUseSide = IconSupplier.fixtureLampSideOff;
iconToUseTop = IconSupplier.fixtureLampTopOff;
} else {
iconToUseSide = IconSupplier.fixtureLampSideOn;
iconToUseTop = IconSupplier.fixtureLampTopOn;
t.setColorRGBA(r, g, b, 20);
RenderHelper.drawTesselatedCube(new Vector3Cube(pixel * 4.5, pixel * 2, pixel * 4.5, 1.0 - (pixel * 4.5), 1.0 - (pixel * 4.5),
1.0 - pixel * 4.5));
t.setColorRGBA(r, g, b, 255);
}
double minU = iconToUseTop.getInterpolatedU(vector.getMinX() * 16);
double maxU = iconToUseTop.getInterpolatedU(vector.getMaxX() * 16);
double minV = iconToUseTop.getInterpolatedV(vector.getMinZ() * 16);
double maxV = iconToUseTop.getInterpolatedV(vector.getMaxZ() * 16);
// Top side
t.setNormal(0, 1, 0);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMaxZ(), minU, maxV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ(), minU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMinZ(), maxU, minV);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMinZ(), maxU, maxV);
// I think there might be something wrong with the textures here..
minU = iconToUseSide.getInterpolatedU(vector.getMinZ() * 16);
maxU = iconToUseSide.getInterpolatedU(vector.getMaxZ() * 16);
minV = iconToUseSide.getInterpolatedV((vector.getMinY() + (3 * pixel)) * 16);
maxV = iconToUseSide.getInterpolatedV((vector.getMaxY() + (3 * pixel)) * 16);
// Draw west side:
t.setNormal(-1, 0, 0);
t.addVertexWithUV(vector.getMinX(), vector.getMinY(), vector.getMaxZ(), minU, maxV);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMaxZ(), minU, minV);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMinZ(), maxU, minV);
t.addVertexWithUV(vector.getMinX(), vector.getMinY(), vector.getMinZ(), maxU, maxV);
// Draw east side:
t.setNormal(1, 0, 0);
t.addVertexWithUV(vector.getMaxX(), vector.getMinY(), vector.getMinZ(), minU, maxV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMinZ(), minU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ(), maxU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMinY(), vector.getMaxZ(), maxU, maxV);
// Draw north side
t.setNormal(0, 0, -1);
t.addVertexWithUV(vector.getMinX(), vector.getMinY(), vector.getMinZ(), minU, maxV);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMinZ(), minU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMinZ(), maxU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMinY(), vector.getMinZ(), maxU, maxV);
// Draw south side
t.setNormal(0, 0, 1);
t.addVertexWithUV(vector.getMinX(), vector.getMinY(), vector.getMaxZ(), minU, maxV);
t.addVertexWithUV(vector.getMaxX(), vector.getMinY(), vector.getMaxZ(), maxU, maxV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ(), maxU, minV);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMaxZ(), minU, minV);
}
if (power > 0 && pass == 1) {
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glDisable(GL11.GL_LIGHTING);
// GL11.glDisable(GL11.GL_CULL_FACE);
GL11.glDepthMask(false);
GL11.glBegin(GL11.GL_QUADS);
RenderHelper.drawColoredCube(vector.clone().expand(0.8 / 16D), r / 256D, g / 256D, b / 256D, (power / 15D) * 0.625);
GL11.glEnd();
GL11.glDepthMask(true);
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glDisable(GL11.GL_BLEND);
}
}
}
| 9,422 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
PartLamp.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/part/lamp/PartLamp.java | package net.quetzi.bluepower.part.lamp;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.world.EnumSkyBlock;
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
import net.minecraftforge.common.util.ForgeDirection;
import net.quetzi.bluepower.api.part.BPPartFace;
import net.quetzi.bluepower.api.part.RedstoneConnection;
import net.quetzi.bluepower.api.vec.Vector3;
import net.quetzi.bluepower.api.vec.Vector3Cube;
import net.quetzi.bluepower.client.renderers.IconSupplier;
import net.quetzi.bluepower.client.renderers.RenderHelper;
import net.quetzi.bluepower.helper.RedstoneHelper;
import net.quetzi.bluepower.init.CustomTabs;
import org.lwjgl.opengl.GL11;
/**
* Base class for the lamps that are multiparts.
*
* @author Koen Beckers (K4Unl)
*
*/
public class PartLamp extends BPPartFace {
protected String colorName;
private int colorVal;
protected boolean inverted;
protected int power = 0;
/**
* @author amadornes
* @param colorName
* @param colorVal
* @param inverted
* TODO
*/
public PartLamp(String colorName, Integer colorVal, Boolean inverted) {
this.colorName = colorName;
this.colorVal = colorVal;
this.inverted = inverted;
for (int i = 0; i < 4; i++)
connections[i] = new RedstoneConnection(this, i + "", true, false);
for (RedstoneConnection c : connections) {
c.enable();
c.setInput();
}
}
@Override
public String getType() {
return (inverted ? "inverted" : "") + "lamp" + colorName;
}
/**
* @author amadornes
*/
@Override
public String getUnlocalizedName() {
return (inverted ? "inverted" : "") + "lamp." + colorName;
}
/**
* @author amadornes
*/
@Override
public void addCollisionBoxes(List<AxisAlignedBB> boxes) {
addSelectionBoxes(boxes);
}
/**
* @author Koen Beckers (K4Unl)
*/
@Override
public void addSelectionBoxes(List<AxisAlignedBB> boxes) {
boxes.add(AxisAlignedBB.getBoundingBox(0.0, 0.0, 0.0, 1.0, 1.0, 1.0));
}
/**
* @author amadornes
*/
@Override
public void addOcclusionBoxes(List<AxisAlignedBB> boxes) {
addSelectionBoxes(boxes);
}
/**
* @author Koen Beckers (K4Unl)
*/
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
power = inverted ? 15 : 0;
GL11.glPushMatrix();
GL11.glTranslated(0.5, 0.5, 0.5);
GL11.glRotated(180, 1, 0, 0);
GL11.glTranslated(-0.5, -0.5, -0.5);
Tessellator t = Tessellator.instance;
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
GL11.glPushMatrix();
t.startDrawingQuads();
renderStatic(new Vector3(0, 0, 0), 0);
t.draw();
GL11.glPopMatrix();
GL11.glPushMatrix();
t.startDrawingQuads();
renderStatic(new Vector3(0, 0, 0), 1);
t.draw();
GL11.glPopMatrix();
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture);
GL11.glPopMatrix();
}
/**
* @author Koen Beckers (K4Unl)
*/
@Override
public boolean renderStatic(Vector3 loc, int pass) {
rotateAndTranslateDynamic(loc, pass, 0);
Tessellator t = Tessellator.instance;
t.setColorOpaque_F(1, 1, 1);
// Render base
renderBase(pass);
// Color multiplier
int redMask = 0xFF0000, greenMask = 0xFF00, blueMask = 0xFF;
int r = (colorVal & redMask) >> 16;
int g = (colorVal & greenMask) >> 8;
int b = (colorVal & blueMask);
t.setColorOpaque(r, g, b);
// Render lamp itself here
renderLamp(pass, r, g, b);
return true;
}
@Override
public boolean shouldRenderStaticOnPass(int pass) {
return true;
}
/**
* Code to render the base portion of the lamp. Will not be colored
*
* @author Koen Beckers (K4Unl)
* @param pass
* The pass that is rendered now. Pass 1 for solids. Pass 2 for transparents
*/
public void renderBase(int pass) {
}
/**
* Code to render the actual lamp portion of the lamp. Will be colored
*
* @author Koen Beckers (K4Unl)
* @param pass
* The pass that is rendered now. Pass 1 for solids. Pass 2 for transparents
* @param r
* The ammount of red in the lamp
* @param g
* The ammount of green in the lamp
* @param b
* The ammount of blue in the lamp
*/
public void renderLamp(int pass, int r, int g, int b) {
Vector3Cube vector = new Vector3Cube(0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
if (pass == 0) {
Tessellator t = Tessellator.instance;
IIcon iconToUse;
if (power == 0) {
iconToUse = IconSupplier.lampOff;
} else {
iconToUse = IconSupplier.lampOn;
/*
* t.setColorRGBA(r, g, b, 20); RenderHelper.drawTesselatedCube(new Vector3Cube(pixel * 4.5, pixel * 2, pixel * 4.5, 1.0 -
* (pixel*4.5), 1.0 - (pixel * 4.5), 1.0 - pixel * 4.5)); t.setColorRGBA(r, g, b, 255);
*/
}
double minU = iconToUse.getMinU();
double maxU = iconToUse.getMaxU();
double minV = iconToUse.getMinV();
double maxV = iconToUse.getMaxV();
// Top side
t.setNormal(0, 1, 0);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMaxZ(), minU, maxV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ(), minU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMinZ(), maxU, minV);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMinZ(), maxU, maxV);
// Draw west side:
t.setNormal(-1, 0, 0);
t.addVertexWithUV(vector.getMinX(), vector.getMinY(), vector.getMaxZ(), minU, maxV);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMaxZ(), minU, minV);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMinZ(), maxU, minV);
t.addVertexWithUV(vector.getMinX(), vector.getMinY(), vector.getMinZ(), maxU, maxV);
// Draw east side:
t.setNormal(1, 0, 0);
t.addVertexWithUV(vector.getMaxX(), vector.getMinY(), vector.getMinZ(), minU, maxV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMinZ(), minU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ(), maxU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMinY(), vector.getMaxZ(), maxU, maxV);
// Draw north side
t.setNormal(0, 0, -1);
t.addVertexWithUV(vector.getMinX(), vector.getMinY(), vector.getMinZ(), minU, maxV);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMinZ(), minU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMinZ(), maxU, minV);
t.addVertexWithUV(vector.getMaxX(), vector.getMinY(), vector.getMinZ(), maxU, maxV);
// Draw south side
t.setNormal(0, 0, 1);
t.addVertexWithUV(vector.getMinX(), vector.getMinY(), vector.getMaxZ(), minU, maxV);
t.addVertexWithUV(vector.getMaxX(), vector.getMinY(), vector.getMaxZ(), maxU, maxV);
t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ(), maxU, minV);
t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMaxZ(), minU, minV);
}
if (power > 0 && pass == 1) {
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glDisable(GL11.GL_LIGHTING);
// GL11.glDisable(GL11.GL_CULL_FACE);
GL11.glDepthMask(false);
GL11.glBegin(GL11.GL_QUADS);
RenderHelper.drawColoredCube(vector.clone().expand(0.8 / 16D), r / 256D, g / 256D, b / 256D, (power / 15D) * 0.625);
GL11.glEnd();
GL11.glDepthMask(true);
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glDisable(GL11.GL_BLEND);
}
}
@Override
public int getLightValue() {
return power;
}
/**
* @author amadornes
*/
@Override
public void update() {
super.update();
int old = power;
power = 0;
for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS)
power = Math.max(power, RedstoneHelper.getInput(world, x, y, z, d));
if (inverted) {
power = 15 - power;
}
if (old != power) {
notifyUpdate();
world.updateLightByType(EnumSkyBlock.Block, x, y, z);
}
}
/**
* @author amadornes
*/
@Override
public CreativeTabs getCreativeTab() {
return CustomTabs.tabBluePowerLighting;
}
}
| 10,078 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
Config.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/init/Config.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.init;
import net.minecraftforge.common.config.Configuration;
public class Config {
public static boolean generateTungsten;
public static int minTungstenY;
public static int maxTungstenY;
public static int veinCountTungsten;
public static int veinSizeTungsten;
public static boolean generateCopper;
public static int minCopperY;
public static int maxCopperY;
public static int veinCountCopper;
public static int veinSizeCopper;
public static boolean generateSilver;
public static int minSilverY;
public static int maxSilverY;
public static int veinCountSilver;
public static int veinSizeSilver;
public static boolean generateTin;
public static int minTinY;
public static int maxTinY;
public static int veinCountTin;
public static int veinSizeTin;
public static boolean generateNikolite;
public static int minNikoliteY;
public static int maxNikoliteY;
public static int veinCountNikolite;
public static int veinSizeNikolite;
public static boolean generateRuby;
public static int minRubyY;
public static int maxRubyY;
public static int veinCountRuby;
public static int veinSizeRuby;
public static boolean generateAmethyst;
public static int minAmethystY;
public static int maxAmethystY;
public static int veinCountAmethyst;
public static int veinSizeAmethyst;
public static boolean generateSapphire;
public static int minSapphireY;
public static int maxSapphireY;
public static int veinCountSapphire;
public static int veinSizeSapphire;
public static double volcanoActiveToInactiveRatio;
public static double volcanoSpawnChance; // chance of a volcano spawning per chunk.
public static boolean useAltScrewdriverRecipe;
public static int vorpalEnchantmentId;
public static int disjunctionEnchantmentId;
public static String[] alloyFurnaceBlacklist;
public static void setUp(Configuration config) {
config.addCustomCategoryComment("World Gen", "Toggle blocks being generated into the world");
generateTungsten = config.get("World Gen Tungsten", "generateTungsten", true).getBoolean(true);
minTungstenY = config.get("World Gen Tungsten", "minTungstenY", 5).getInt();
maxTungstenY = config.get("World Gen Tungsten", "maxTungstenY", 32).getInt();
veinCountTungsten = config.get("World Gen Tungsten", "veinCountTungsten", 2).getInt();
veinSizeTungsten = config.get("World Gen Tungsten", "veinSizeTungsten", 3).getInt();
generateCopper = config.get("World Gen Copper", "generateCopper", true).getBoolean(true);
minCopperY = config.get("World Gen Copper", "minCopperY", 0).getInt();
maxCopperY = config.get("World Gen Copper", "maxCopperY", 64).getInt();
veinCountCopper = config.get("World Gen Copper", "veinCountCopper", 20).getInt();
veinSizeCopper = config.get("World Gen Copper", "veinSizeCopper", 10).getInt();
generateTin = config.get("World Gen Tin", "generateTin", true).getBoolean(true);
minTinY = config.get("World Gen Tin", "minTinY", 0).getInt();
maxTinY = config.get("World Gen Tin", "maxTinY", 48).getInt();
veinCountTin = config.get("World Gen Tin", "veinCountTin", 10).getInt();
veinSizeTin = config.get("World Gen Tin", "veinSizeTin", 8).getInt();
generateSilver = config.get("World Gen Silver", "generateSilver", true).getBoolean(true);
minSilverY = config.get("World Gen Silver", "minSilverY", 0).getInt();
maxSilverY = config.get("World Gen Silver", "maxSilverY", 32).getInt();
veinCountSilver = config.get("World Gen Silver", "veinCountSilver", 4).getInt();
veinSizeSilver = config.get("World Gen Silver", "veinSizeSilver", 8).getInt();
generateNikolite = config.get("World Gen Nikolite", "generateNikolite", true).getBoolean(true);
minNikoliteY = config.get("World Gen Nikolite", "minNikoliteY", 0).getInt();
maxNikoliteY = config.get("World Gen Nikolite", "maxNikoliteY", 16).getInt();
veinCountNikolite = config.get("World Gen Nikolite", "veinCountNikolite", 4).getInt();
veinSizeNikolite = config.get("World Gen Nikolite", "veinSizeNikolite", 10).getInt();
generateRuby = config.get("World Gen Ruby", "generateRuby", true).getBoolean(true);
minRubyY = config.get("World Gen Ruby", "minRubyY", 0).getInt();
maxRubyY = config.get("World Gen Ruby", "maxRubyY", 48).getInt();
veinCountRuby = config.get("World Gen Ruby", "veinCountRuby", 2).getInt();
veinSizeRuby = config.get("World Gen Ruby", "veinSizeRuby", 7).getInt();
generateAmethyst = config.get("World Gen Amethyst", "generateAmethyst", true).getBoolean(true);
minAmethystY = config.get("World Gen Amethyst", "minAmethystY", 0).getInt();
maxAmethystY = config.get("World Gen Amethyst", "maxAmethystY", 48).getInt();
veinCountAmethyst = config.get("World Gen Amethyst", "veinCountAmethyst", 2).getInt();
veinSizeAmethyst = config.get("World Gen Amethyst", "veinSizeAmethyst", 7).getInt();
generateSapphire = config.get("World Gen Sapphire", "generateSapphire", true).getBoolean(true);
minSapphireY = config.get("World Gen Sapphire", "minSapphireY", 0).getInt();
maxSapphireY = config.get("World Gen Sapphire", "maxSapphireY", 48).getInt();
veinCountSapphire = config.get("World Gen Sapphire", "veinCountSapphire", 7).getInt();
veinSizeSapphire = config.get("World Gen Sapphire", "veinSizeSapphire", 2).getInt();
volcanoSpawnChance = config.get("World Gen", "volcanoSpawnChance", 0.02).getDouble(0);
volcanoActiveToInactiveRatio = config.get("World Gen", "volcanoActiveToInactiveRatio", 0.5).getDouble(0);
useAltScrewdriverRecipe = config.get("Settings", "useAltScrewdriverRecipe", false).getBoolean(false);
config.addCustomCategoryComment("Recipe Enabling", "Toggle recipes to be enabled or not");
alloyFurnaceBlacklist = config.get("Recipe Enabling", "alloyFurnaceBlacklist", new String[0]).getStringList();
config.addCustomCategoryComment("Enchantment IDs", "Toggle enchantment ids");
vorpalEnchantmentId = config.get("Enchantment IDs", "vorpalEnchantmentId", 100).getInt();
disjunctionEnchantmentId = config.get("Enchantment IDs", "disjunctionEnchantmentId", 101).getInt();
}
}
| 7,401 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
CustomTabs.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/init/CustomTabs.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.init;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.quetzi.bluepower.api.part.PartRegistry;
public class CustomTabs {
public static CreativeTabs tabBluePowerBlocks;
public static CreativeTabs tabBluePowerMachines;
public static CreativeTabs tabBluePowerItems;
public static CreativeTabs tabBluePowerTools;
public static CreativeTabs tabBluePowerCircuits;
public static CreativeTabs tabBluePowerLighting;
public static void init() {
tabBluePowerBlocks = new BPCreativeTab("tabBluePowerBlocks") {
@Override
public Item getTabIconItem() {
Block iconBlock = BPBlocks.marble;
if (iconBlock != null) {
return Item.getItemFromBlock(iconBlock);
} else {
return Item.getItemFromBlock(Blocks.stone);
}
}
};
tabBluePowerMachines = new BPCreativeTab("tabBluePowerMachines") {
@Override
public Item getTabIconItem() {
Block iconBlock = BPBlocks.alloy_furnace;
if (iconBlock != null) {
return Item.getItemFromBlock(iconBlock);
} else {
return Item.getItemFromBlock(Blocks.furnace);
}
}
};
tabBluePowerItems = new BPCreativeTab("tabBluePowerItems") {
@Override
public Item getTabIconItem() {
Item iconItem = BPItems.ruby;
if (iconItem != null) {
return BPItems.ruby;
} else {
return Items.diamond;
}
}
};
tabBluePowerTools = new BPCreativeTab("tabBluePowerTools") {
@Override
public Item getTabIconItem() {
Item iconItem = BPItems.screwdriver;
if (iconItem != null) {
return BPItems.screwdriver;
} else {
return Items.diamond_pickaxe;
}
}
};
tabBluePowerCircuits = new BPCreativeTab("tabBluePowerCircuits") {
@Override
public Item getTabIconItem() {
return BPItems.multipart;
}
};
tabBluePowerLighting = new BPCreativeTab("tabBluePowerLighting") {
@Override
public Item getTabIconItem() {
return Item.getItemFromBlock(Blocks.redstone_lamp);
}
};
}
private static abstract class BPCreativeTab extends CreativeTabs{
public BPCreativeTab(String label) {
super(label);
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void displayAllReleventItems(List l) {
super.displayAllReleventItems(l);
for(String s : PartRegistry.getRegisteredPartsForTab(this))
l.add(PartRegistry.getItemForPart(s));
}
}
}
| 4,073 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
BPEnchantments.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/init/BPEnchantments.java | package net.quetzi.bluepower.init;
import net.minecraft.enchantment.Enchantment;
import net.quetzi.bluepower.enchantments.EnchantmentDisjunction;
import net.quetzi.bluepower.enchantments.EnchantmentVorpal;
public class BPEnchantments {
public static Enchantment vorpal;
public static Enchantment disjunction;
public static void init() {
vorpal = new EnchantmentVorpal(Config.vorpalEnchantmentId, 10);
disjunction = new EnchantmentDisjunction(Config.disjunctionEnchantmentId, 10);
}
}
| 499 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.