use of net.geforcemods.securitycraft.api.CustomizableSCTE in project SecurityCraft by Geforce132.
the class GuiSCManual method updateRecipeAndIcons.
private void updateRecipeAndIcons() {
if (this.currentPage < 0) {
recipe = null;
this.hoverCheckers.clear();
return;
}
this.hoverCheckers.clear();
if (mod_SecurityCraft.instance.manualPages.get(currentPage).hasCustomRecipe()) {
this.recipe = mod_SecurityCraft.instance.manualPages.get(currentPage).getRecipe();
} else {
for (Object object : CraftingManager.getInstance().getRecipeList()) {
if (object instanceof ShapedRecipes) {
ShapedRecipes recipe = (ShapedRecipes) object;
if (recipe.getRecipeOutput() != null && recipe.getRecipeOutput().getItem() == mod_SecurityCraft.instance.manualPages.get(currentPage).getItem()) {
this.recipe = recipe.recipeItems;
break;
}
} else if (object instanceof ShapelessRecipes) {
ShapelessRecipes recipe = (ShapelessRecipes) object;
if (recipe.getRecipeOutput() != null && recipe.getRecipeOutput().getItem() == mod_SecurityCraft.instance.manualPages.get(currentPage).getItem()) {
this.recipe = this.toItemStackArray(recipe.recipeItems);
break;
}
}
this.recipe = null;
}
}
if (recipe != null) {
outer: for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
if ((i * 3) + j == recipe.length)
break outer;
if (recipe[(i * 3) + j] != null)
hoverCheckers.add(new CustomHoverChecker(144 + (i * 20), 144 + (i * 20) + 16, (k + 100) + (j * 20), (k + 100) + (j * 20) + 16, 20, recipe[(i * 3) + j].getDisplayName()));
}
}
} else {
String name = mod_SecurityCraft.instance.manualPages.get(currentPage).getItemName();
//make first character lower case and remove spaces
name = name.substring(0, 1).toLowerCase() + name.substring(1, name.length()).replace(" ", "");
hoverCheckers.add(new CustomHoverChecker(144, 144 + (2 * 20) + 16, k + 100, (k + 100) + (2 * 20) + 16, 20, I18n.translateToLocal("gui.scManual.recipe." + name)));
}
Item item = mod_SecurityCraft.instance.manualPages.get(currentPage).getItem();
TileEntity te = ((item instanceof ItemBlock && ((ItemBlock) item).getBlock() instanceof ITileEntityProvider) ? ((ITileEntityProvider) ((ItemBlock) item).getBlock()).createNewTileEntity(Minecraft.getMinecraft().theWorld, 0) : null);
Block itemBlock = ((item instanceof ItemBlock) ? ((ItemBlock) item).getBlock() : null);
if (te != null) {
if (te instanceof IOwnable) {
this.hoverCheckers.add(new CustomHoverChecker(118, 118 + 16, k + 29, (k + 29) + 16, 20, I18n.translateToLocal("gui.scManual.ownableBlock")));
}
if (te instanceof IPasswordProtected) {
this.hoverCheckers.add(new CustomHoverChecker(118, 118 + 16, k + 55, (k + 55) + 16, 20, I18n.translateToLocal("gui.scManual.passwordProtectedBlock")));
}
if (te instanceof TileEntitySCTE && ((TileEntitySCTE) te).isActivatedByView()) {
this.hoverCheckers.add(new CustomHoverChecker(118, 118 + 16, k + 81, (k + 81) + 16, 20, I18n.translateToLocal("gui.scManual.viewActivatedBlock")));
}
if (itemBlock instanceof IExplosive) {
this.hoverCheckers.add(new CustomHoverChecker(118, 118 + 16, k + 107, (k + 107) + 16, 20, I18n.translateToLocal("gui.scManual.explosiveBlock")));
}
if (te instanceof CustomizableSCTE) {
this.hoverCheckers.add(new CustomHoverChecker(118, 118 + 16, k + 213, (k + 213) + 16, 20, I18n.translateToLocal("gui.scManual.customizableBlock")));
}
}
}
use of net.geforcemods.securitycraft.api.CustomizableSCTE in project SecurityCraft by Geforce132.
the class ForgeEventHandler method onBlockBroken.
@SubscribeEvent
public void onBlockBroken(BreakEvent event) {
if (!event.getWorld().isRemote) {
if (event.getWorld().getTileEntity(event.getPos()) != null && event.getWorld().getTileEntity(event.getPos()) instanceof CustomizableSCTE) {
CustomizableSCTE te = (CustomizableSCTE) event.getWorld().getTileEntity(event.getPos());
for (int i = 0; i < te.getNumberOfCustomizableOptions(); i++) {
if (te.itemStacks[i] != null) {
ItemStack stack = te.itemStacks[i];
EntityItem item = new EntityItem(event.getWorld(), event.getPos().getX(), event.getPos().getY(), event.getPos().getZ(), stack);
event.getWorld().spawnEntityInWorld(item);
te.onModuleRemoved(stack, ((ItemModule) stack.getItem()).getModule());
te.createLinkedBlockAction(EnumLinkedAction.MODULE_REMOVED, new Object[] { stack, ((ItemModule) stack.getItem()).getModule() }, te);
}
}
}
}
}
use of net.geforcemods.securitycraft.api.CustomizableSCTE in project SecurityCraft by Geforce132.
the class BlockUtils method setBlockProperty.
public static void setBlockProperty(World par1World, int par2, int par3, int par4, PropertyBool property, boolean value) {
ItemStack[] modules = null;
if (par1World.getTileEntity(new BlockPos(par2, par3, par4)) instanceof CustomizableSCTE) {
modules = ((CustomizableSCTE) par1World.getTileEntity(toPos(par2, par3, par4))).itemStacks;
}
TileEntity tileEntity = par1World.getTileEntity(toPos(par2, par3, par4));
par1World.setBlockState(new BlockPos(par2, par3, par4), par1World.getBlockState(new BlockPos(par2, par3, par4)).withProperty(property, value));
par1World.setTileEntity(new BlockPos(par2, par3, par4), tileEntity);
if (modules != null) {
((CustomizableSCTE) par1World.getTileEntity(toPos(par2, par3, par4))).itemStacks = modules;
}
}
use of net.geforcemods.securitycraft.api.CustomizableSCTE in project SecurityCraft by Geforce132.
the class BlockUtils method setBlockProperty.
public static void setBlockProperty(World par1World, BlockPos pos, PropertyBool property, boolean value, boolean retainOldTileEntity) {
if (retainOldTileEntity) {
ItemStack[] modules = null;
ItemStack[] inventory = null;
int[] times = new int[4];
String password = "";
Owner owner = null;
int cooldown = -1;
if (par1World.getTileEntity(pos) instanceof CustomizableSCTE) {
modules = ((CustomizableSCTE) par1World.getTileEntity(pos)).itemStacks;
}
if (par1World.getTileEntity(pos) instanceof TileEntityKeypadFurnace) {
inventory = ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).furnaceItemStacks;
times[0] = ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).furnaceBurnTime;
times[1] = ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).currentItemBurnTime;
times[2] = ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).cookTime;
times[3] = ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).totalCookTime;
}
if (par1World.getTileEntity(pos) instanceof TileEntityOwnable && ((TileEntityOwnable) par1World.getTileEntity(pos)).getOwner() != null) {
owner = ((TileEntityOwnable) par1World.getTileEntity(pos)).getOwner();
}
if (par1World.getTileEntity(pos) instanceof TileEntityKeypad && ((TileEntityKeypad) par1World.getTileEntity(pos)).getPassword() != null) {
password = ((TileEntityKeypad) par1World.getTileEntity(pos)).getPassword();
}
if (par1World.getTileEntity(pos) instanceof TileEntityKeypadFurnace && ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).getPassword() != null) {
password = ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).getPassword();
}
if (par1World.getTileEntity(pos) instanceof TileEntityKeypadChest && ((TileEntityKeypadChest) par1World.getTileEntity(pos)).getPassword() != null) {
password = ((TileEntityKeypadChest) par1World.getTileEntity(pos)).getPassword();
}
if (par1World.getTileEntity(pos) instanceof TileEntityPortableRadar && ((TileEntityPortableRadar) par1World.getTileEntity(pos)).getAttackCooldown() != 0) {
cooldown = ((TileEntityPortableRadar) par1World.getTileEntity(pos)).getAttackCooldown();
}
TileEntity tileEntity = par1World.getTileEntity(pos);
par1World.setBlockState(pos, par1World.getBlockState(pos).withProperty(property, value));
par1World.setTileEntity(pos, tileEntity);
if (modules != null) {
((CustomizableSCTE) par1World.getTileEntity(pos)).itemStacks = modules;
}
if (inventory != null && par1World.getTileEntity(pos) instanceof TileEntityKeypadFurnace) {
((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).furnaceItemStacks = inventory;
((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).furnaceBurnTime = times[0];
((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).currentItemBurnTime = times[1];
((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).cookTime = times[2];
((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).totalCookTime = times[3];
}
if (owner != null) {
((TileEntityOwnable) par1World.getTileEntity(pos)).getOwner().set(owner);
}
if (!password.isEmpty() && par1World.getTileEntity(pos) instanceof TileEntityKeypad) {
((TileEntityKeypad) par1World.getTileEntity(pos)).setPassword(password);
}
if (!password.isEmpty() && par1World.getTileEntity(pos) instanceof TileEntityKeypadFurnace) {
((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).setPassword(password);
}
if (!password.isEmpty() && par1World.getTileEntity(pos) instanceof TileEntityKeypadChest) {
((TileEntityKeypadChest) par1World.getTileEntity(pos)).setPassword(password);
}
if (cooldown != -1 && par1World.getTileEntity(pos) instanceof TileEntityPortableRadar) {
((TileEntityPortableRadar) par1World.getTileEntity(pos)).setAttackCooldown(cooldown);
}
} else {
par1World.setBlockState(pos, par1World.getBlockState(pos).withProperty(property, value));
}
}
use of net.geforcemods.securitycraft.api.CustomizableSCTE in project SecurityCraft by Geforce132.
the class ModuleUtils method getPlayersFromModule.
public static List<String> getPlayersFromModule(World par1World, BlockPos pos, EnumCustomModules module) {
List<String> list = new ArrayList<String>();
CustomizableSCTE te = (CustomizableSCTE) par1World.getTileEntity(pos);
if (te.hasModule(module)) {
ItemStack item = te.getModule(module);
for (int i = 1; i <= 10; i++) {
if (item.getTagCompound() != null && item.getTagCompound().getString("Player" + i) != null && !item.getTagCompound().getString("Player" + i).isEmpty()) {
list.add(item.getTagCompound().getString("Player" + i).toLowerCase());
}
}
}
return list;
}
Aggregations