mirror of
https://github.com/GTNewHorizons/Draconic-Evolution.git
synced 2026-11-21 04:32:12 +00:00
Added Creative Key Stone
This commit is contained in:
1 parent
9733da3e31
commit
c9f3e01b17
15 files changed
+457
-16
No files matched your search
@@ -0,0 +1,114 @@
|
||||
package com.brandon3055.draconicevolution.common.blocks;
|
||||
|
||||
import com.brandon3055.draconicevolution.DraconicEvolution;
|
||||
import com.brandon3055.draconicevolution.common.blocks.itemblocks.CKeyStoneItemBlock;
|
||||
import com.brandon3055.draconicevolution.common.core.utills.ItemNBTHelper;
|
||||
import com.brandon3055.draconicevolution.common.items.ModItems;
|
||||
import com.brandon3055.draconicevolution.common.lib.References;
|
||||
import com.brandon3055.draconicevolution.common.lib.Strings;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.TileCKeyStone;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* Created by Brandon on 27/08/2014.
|
||||
*/
|
||||
public class CKeyStone extends BlockDE {
|
||||
private IIcon blockIcon1;
|
||||
public CKeyStone(){
|
||||
this.setHardness(10F);
|
||||
this.setResistance(100F);
|
||||
this.setCreativeTab(DraconicEvolution.tolkienTabBlocksItems);
|
||||
this.setBlockName(Strings.cKeyStoneName);
|
||||
ModBlocks.registerWithItem(this, CKeyStoneItemBlock.class);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(int metadata) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity(World world, int metadata) {
|
||||
return new TileCKeyStone();
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister iconRegister) {
|
||||
blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "key_stone_inactive");
|
||||
blockIcon1 = iconRegister.registerIcon(References.RESOURCESPREFIX + "key_stone_active");
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
if (side == 0 || side == 1) return Blocks.furnace.getIcon(side, meta);
|
||||
else return blockIcon1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
||||
if (side == 0 || side == 1) return Blocks.furnace.getIcon(side, 0);
|
||||
TileCKeyStone tile = world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileCKeyStone ? (TileCKeyStone) world.getTileEntity(x, y, z) : null;
|
||||
if (tile != null) return tile.isActivated ? blockIcon1 : blockIcon;
|
||||
else return blockIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) {
|
||||
TileCKeyStone tile = world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileCKeyStone ? (TileCKeyStone) world.getTileEntity(x, y, z) : null;
|
||||
|
||||
if (tile != null) return tile.onActivated(player.getHeldItem(), player);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvidePower(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int meta)
|
||||
{
|
||||
TileCKeyStone tile = world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileCKeyStone ? (TileCKeyStone) world.getTileEntity(x, y, z) : null;
|
||||
if (tile != null) return tile.isActivated ? 15 : 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int meta)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
|
||||
TileCKeyStone tile = world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileCKeyStone ? (TileCKeyStone) world.getTileEntity(x, y, z) : null;
|
||||
if (tile != null) {
|
||||
ItemStack key = new ItemStack(ModItems.key);
|
||||
ItemNBTHelper.setIntager(key, "KeyCode", tile.getKeyCode());
|
||||
ItemNBTHelper.setIntager(key, "X", x);
|
||||
ItemNBTHelper.setIntager(key, "Y", y);
|
||||
ItemNBTHelper.setIntager(key, "Z", z);
|
||||
return key;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ public class ModBlocks {
|
||||
public static BlockDE invisibleMultiblock;
|
||||
public static BlockDE energyPylon;
|
||||
public static BlockDE placedItem;
|
||||
public static BlockDE cKeyStone;
|
||||
public static Block safetyFlame;
|
||||
|
||||
public static void init()
|
||||
@@ -57,6 +58,7 @@ public class ModBlocks {
|
||||
energyPylon = new EnergyPylon();
|
||||
placedItem = new PlacedItem();
|
||||
safetyFlame = new SafetyFlame();
|
||||
cKeyStone = new CKeyStone();
|
||||
if(ConfigHandler.disable_LRD < 2) longRangeDislocator = new LongRangeDislocator();
|
||||
|
||||
if(DraconicEvolution.debug) testBlock = new TestBlock();
|
||||
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
package com.brandon3055.draconicevolution.common.blocks.itemblocks;
|
||||
|
||||
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.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by Brandon on 27/08/2014.
|
||||
*/
|
||||
public class CKeyStoneItemBlock extends ItemBlock {
|
||||
|
||||
public CKeyStoneItemBlock(Block block) {
|
||||
super(block);
|
||||
setHasSubtypes(true);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void getSubItems(Item item, CreativeTabs p_150895_2_, List list) {
|
||||
list.add(new ItemStack(item, 1, 0));
|
||||
list.add(new ItemStack(item, 1, 1));
|
||||
list.add(new ItemStack(item, 1, 2));
|
||||
list.add(new ItemStack(item, 1, 3));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(int par1) {
|
||||
return par1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer p_77624_2_, List list, boolean p_77624_4_) {
|
||||
int meta = stack.getItemDamage();
|
||||
switch (meta){
|
||||
case 0:
|
||||
list.add("Permanent Activation (Consume Key)");
|
||||
break;
|
||||
case 1:
|
||||
list.add("Button Activation");
|
||||
break;
|
||||
case 2:
|
||||
list.add("Toggle Activation");
|
||||
break;
|
||||
case 3:
|
||||
list.add("Button Activation (Consume Key)");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
+43
-13
@@ -17,11 +17,13 @@ import com.brandon3055.draconicevolution.common.items.weapons.DraconicBow;
|
||||
import com.brandon3055.draconicevolution.common.items.weapons.DraconicSword;
|
||||
import com.brandon3055.draconicevolution.common.items.weapons.WyvernBow;
|
||||
import com.brandon3055.draconicevolution.common.items.weapons.WyvernSword;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
|
||||
public class CraftingHandler {
|
||||
public static void init()
|
||||
@@ -53,34 +55,62 @@ public class CraftingHandler {
|
||||
|
||||
public static void registerShapedRecipes()
|
||||
{
|
||||
CraftingManager.getInstance().addRecipe(new ItemStack(ModItems.draconicCore), "GIG", "ISI", "GIG", 'S', Items.diamond, 'G', Items.gold_ingot, 'I', ModItems.draconiumIngot);
|
||||
//GameRegistry.addRecipe(new ShapedOreRecipe(rodObsidianFlux, new Object[]{" O", " B ", "O ", 'B', rodObsidian, 'O', "gemCrystalFlux"}));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModItems.draconicCore), "GIG", "ISI", "GIG", 'S', "gemDiamond", 'G', "ingotGold", 'I', ModItems.draconiumIngot));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModItems.infusedCompound, 2), "IDI", "DSD", "IDI", 'S', Items.nether_star, 'D', "gemDiamond", 'I', ModItems.draconiumIngot));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModItems.draconiumBlend), " D ", "DID", " D ", 'I', "ingotIron", 'D', ModItems.draconiumDust));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModItems.safetyMatch, 1, 1000), " O ", " S ", " ", 'O', "dyeOrange", 'S', "stickWood"));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModBlocks.grinder, 1, 3), "IXI", "DCD", "IFI", 'I', "ingotIron", 'X', ModItems.draconiumIngot, 'D', Items.diamond_sword, 'C', ModItems.draconicCore, 'F', Blocks.furnace));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModBlocks.weatherController), "RSR", "TPT", "IEI", 'R', Items.blaze_rod, 'S', ModItems.sunFocus, 'T', Blocks.tnt, 'P', ModItems.draconicCore, 'I', "ingotIron", 'E', Blocks.enchanting_table));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModBlocks.potentiometer), "ITI", "QCQ", "IRI", 'I', "ingotIron", 'T', Blocks.redstone_torch, 'Q', "gemQuartz", 'C', Items.comparator, 'R', Blocks.redstone_block));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModBlocks.rainSensor), " ", "RBR", "SPS", 'R', "dustRedstone", 'B', Items.bucket, 'S', Blocks.stone_slab, 'P', Blocks.heavy_weighted_pressure_plate));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModBlocks.playerDetector), "ITI", "CEC", "IDI", 'I', "ingotIron", 'E', Items.ender_eye, 'T', Blocks.redstone_torch, 'C', Items.comparator, 'D', ModItems.draconicCore));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModBlocks.generator, 1, 3), "NIN", "IFI", "NCN", 'N', Items.netherbrick, 'I', "ingotIron", 'F', Blocks.furnace, 'C', ModItems.draconicCore));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModBlocks.energyPylon, 2), "IEI", "MCM", "IDI", 'I', ModItems.draconiumIngot, 'E', Items.ender_eye, 'C', ModItems.draconicCore, 'D', "gemDiamond", 'M', "gemEmerald"));
|
||||
|
||||
|
||||
|
||||
//CraftingManager.getInstance().addRecipe(new ItemStack(ModItems.draconicCore), "GIG", "ISI", "GIG", 'S', "gemDiamond", 'G', "ingotGold", 'I', ModItems.draconiumIngot);
|
||||
// CraftingManager.getInstance().addRecipe(new ItemStack(ModItems.infusedCompound, 2), "IDI", "DSD", "IDI", 'S', Items.nether_star, 'D', "gemDiamond", 'I', ModItems.draconiumIngot);
|
||||
// CraftingManager.getInstance().addRecipe(new ItemStack(ModItems.draconiumBlend), " D ", "DID", " D ", 'I', "ingotIron", 'D', ModItems.draconiumDust);
|
||||
// CraftingManager.getInstance().addRecipe(new ItemStack(ModItems.safetyMatch, 1, 1000), " O ", " S ", " ", 'O', "dyeOrange", 'S', "woodStick");
|
||||
// CraftingManager.getInstance().addRecipe(new ItemStack(ModBlocks.grinder, 1, 3), "IXI", "DCD", "IFI", 'I', "ingotIron", 'X', ModItems.draconiumIngot, 'D', Items.diamond_sword, 'C', ModItems.draconicCore, 'F', Blocks.furnace);
|
||||
// CraftingManager.getInstance().addRecipe(new ItemStack(ModBlocks.weatherController), "RSR", "TPT", "IEI", 'R', Items.blaze_rod, 'S', ModItems.sunFocus, 'T', Blocks.tnt, 'P', ModItems.draconicCore, 'I', "ingotIron", 'E', Blocks.enchanting_table);
|
||||
// CraftingManager.getInstance().addRecipe(new ItemStack(ModBlocks.potentiometer), "ITI", "QCQ", "IRI", 'I', "ingotIron", 'T', Blocks.redstone_torch, 'Q', "gemQuartz", 'C', Items.comparator, 'R', Blocks.redstone_block);
|
||||
// CraftingManager.getInstance().addRecipe(new ItemStack(ModBlocks.rainSensor), " ", "RBR", "SPS", 'R', "dustRedstone", 'B', Items.bucket, 'S', Blocks.stone_slab, 'P', Blocks.heavy_weighted_pressure_plate);
|
||||
// CraftingManager.getInstance().addRecipe(new ItemStack(ModBlocks.playerDetector), "ITI", "CEC", "IDI", 'I', "ingotIron", 'E', Items.ender_eye, 'T', Blocks.redstone_torch, 'C', Items.comparator, 'D', ModItems.draconicCore);
|
||||
// CraftingManager.getInstance().addRecipe(new ItemStack(ModBlocks.generator, 1, 3), "NIN", "IFI", "NCN", 'N', Items.netherbrick, 'I', "ingotIron", 'F', Blocks.furnace, 'C', ModItems.draconicCore);
|
||||
// CraftingManager.getInstance().addRecipe(new ItemStack(ModBlocks.energyPylon, 2), "IEI", "MCM", "IDI", 'I', ModItems.draconiumIngot, 'E', Items.ender_eye, 'C', ModItems.draconicCore, 'D', "gemDiamond", 'M', "gemEmerald");
|
||||
|
||||
|
||||
CraftingManager.getInstance().addRecipe(new ItemStack(ModItems.sunFocus), "RIR", "ISI", "RIR", 'S', Items.nether_star, 'R', Items.blaze_rod, 'I', ModItems.draconiumIngot);
|
||||
CraftingManager.getInstance().addRecipe(new ItemStack(ModItems.infusedCompound, 2), "IDI", "DSD", "IDI", 'S', Items.nether_star, 'D', Items.diamond, 'I', ModItems.draconiumIngot);
|
||||
CraftingManager.getInstance().addRecipe(new ItemStack(ModItems.dragonHeart), " C ", "CEC", " C ", 'C', ModItems.infusedCompound, 'I', Blocks.dragon_egg);
|
||||
CraftingManager.getInstance().addRecipe(new ItemStack(ModItems.draconiumBlend), " D ", "DID", " D ", 'I', Items.iron_ingot, 'D', ModItems.draconiumDust);
|
||||
|
||||
//CraftingManager.getInstance().addRecipe(new ItemStack(ModItems.dragonHeart), " C ", "CEC", " C ", 'C', ModItems.infusedCompound, 'I', Blocks.dragon_egg);
|
||||
|
||||
CraftingManager.getInstance().addRecipe(new ItemStack(ModItems.draconicCompound, 2), " C ", "CHC", " C ", 'C', ModItems.infusedCompound, 'H', ModItems.dragonHeart);
|
||||
CraftingManager.getInstance().addRecipe(new ItemStack(ModItems.safetyMatch, 1, 1000), " O ", " S ", " ", 'O', new ItemStack(Items.dye, 1, 14), 'S', Items.stick);
|
||||
|
||||
CraftingManager.getInstance().addRecipe(new ItemStack(ModItems.safetyMatch, 0), "MMM", "MMM", "MMM", 'M', new ItemStack(ModItems.safetyMatch, 1, 1000));
|
||||
|
||||
CraftingManager.getInstance().addRecipe(new ItemStack(ModBlocks.grinder, 1, 3), "IXI", "DCD", "IFI", 'I', Items.iron_ingot, 'X', ModItems.draconiumIngot, 'D', Items.diamond_sword, 'C', ModItems.draconicCore, 'F', Blocks.furnace);
|
||||
CraftingManager.getInstance().addRecipe(new ItemStack(ModBlocks.weatherController), "RSR", "TPT", "IEI", 'R', Items.blaze_rod, 'S', ModItems.sunFocus, 'T', Blocks.tnt, 'P', ModItems.draconicCore, 'I', Items.iron_ingot, 'E', Blocks.enchanting_table);
|
||||
CraftingManager.getInstance().addRecipe(new ItemStack(ModBlocks.potentiometer), "ITI", "QCQ", "IRI", 'I', Items.iron_ingot, 'T', Blocks.redstone_torch, 'Q', Items.quartz, 'C', Items.comparator, 'R', Blocks.redstone_block);
|
||||
CraftingManager.getInstance().addRecipe(new ItemStack(ModBlocks.rainSensor), " ", "RBR", "SPS", 'R', Items.redstone, 'B', Items.bucket, 'S', Blocks.stone_slab, 'P', Blocks.heavy_weighted_pressure_plate);
|
||||
|
||||
|
||||
|
||||
|
||||
CraftingManager.getInstance().addRecipe(new ItemStack(ModBlocks.particleGenerator), "RBR", "BCB", "RBR", 'R', Blocks.redstone_block, 'B', Items.blaze_rod, 'C', ModItems.draconicCore);
|
||||
CraftingManager.getInstance().addRecipe(new ItemStack(ModBlocks.playerDetector), "ITI", "CEC", "IDI", 'I', Items.iron_ingot, 'E', Items.ender_eye, 'T', Blocks.redstone_torch, 'C', Items.comparator, 'D', ModItems.draconicCore);
|
||||
|
||||
CraftingManager.getInstance().addRecipe(new ItemStack(ModBlocks.playerDetectorAdvanced), "ISI", "EDE", "ICI", 'I', ModItems.draconiumIngot, 'E', Items.ender_eye, 'S', new ItemStack(Items.skull, 1, 1), 'C', Items.compass, 'D', ModBlocks.playerDetector);
|
||||
CraftingManager.getInstance().addRecipe(new ItemStack(ModBlocks.generator, 1, 3), "NIN", "IFI", "NCN", 'N', Items.netherbrick, 'I', Items.iron_ingot, 'F', Blocks.furnace, 'C', ModItems.draconicCore);
|
||||
|
||||
CraftingManager.getInstance().addRecipe(new ItemStack(ModBlocks.energyInfuser), "IPI", "CEC", "ICI", 'I', ModItems.draconiumIngot, 'P', ModBlocks.particleGenerator, 'C', ModItems.draconicCore, 'E', Blocks.enchanting_table);
|
||||
CraftingManager.getInstance().addRecipe(new ItemStack(ModBlocks.draconium), "III", "III", "III", 'I', ModItems.draconiumIngot);
|
||||
CraftingManager.getInstance().addRecipe(new ItemStack(ModBlocks.energyStorageCore), "SRS", "DCD", "SRS", 'S', Items.nether_star, 'R', Blocks.redstone_block, 'C', ModItems.draconicCore, 'D', new ItemStack(ModBlocks.draconium, 1, 0));
|
||||
CraftingManager.getInstance().addRecipe(new ItemStack(ModBlocks.energyPylon, 2), "IEI", "MCM", "IDI", 'I', ModItems.draconiumIngot, 'E', Items.ender_eye, 'C', ModItems.draconicCore, 'D', Items.diamond, 'M', Items.emerald);
|
||||
|
||||
|
||||
CraftingManager.getInstance().addRecipe(new ItemStack(ModBlocks.draconium, 1, 1), "CSC", "SDS", "CSC", 'C', ModItems.draconicCompound, 'S', ModItems.sunFocus, 'D', new ItemStack(ModBlocks.draconium, 1, 0));
|
||||
|
||||
if(ConfigHandler.disableSunDial == 0)
|
||||
CraftingManager.getInstance().addRecipe(new ItemStack(ModBlocks.sunDial), "IFI", "TDT", "GEG", 'I', ModItems.draconiumIngot, 'F', ModItems.sunFocus, 'T', ModItems.draconicCore, 'G', Blocks.glowstone, 'E', Blocks.enchanting_table, 'D', ModItems.dragonHeart);
|
||||
if(ConfigHandler.disableXrayBlock == 0)
|
||||
CraftingManager.getInstance().addRecipe(new ItemStack(ModBlocks.xRayBlock, 4), "SGS", "GDG", "SGS", 'S', Items.nether_star, 'G', Blocks.glass, 'D', Items.diamond);
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModBlocks.xRayBlock, 4), "SGS", "GDG", "SGS", 'S', Items.nether_star, 'G', "blockGlassColorless", 'D', "gemDiamond"));
|
||||
//CraftingManager.getInstance().addRecipe(new ItemStack(ModBlocks.xRayBlock, 4), "SGS", "GDG", "SGS", 'S', Items.nether_star, 'G', "blockGlassColorless", 'D', "gemDiamond");
|
||||
}
|
||||
|
||||
public static void registerSmeltingRecipes()
|
||||
|
||||
@@ -71,6 +71,7 @@ public class CommonProxy {
|
||||
GameRegistry.registerTileEntity(Utills.TileBlockChanger.class, References.RESOURCESPREFIX + "TileBlockChanger");
|
||||
GameRegistry.registerTileEntity(TileEnderResurrection.class, References.RESOURCESPREFIX + "TileEnderResurrection");
|
||||
GameRegistry.registerTileEntity(TilePlacedItem.class, References.RESOURCESPREFIX + "TilePlacedItem");
|
||||
GameRegistry.registerTileEntity(TileCKeyStone.class, References.RESOURCESPREFIX + "TileCKeyStone");
|
||||
if (DraconicEvolution.debug)
|
||||
GameRegistry.registerTileEntity(TileTestBlock.class, "References.RESOURCESPREFIX + TileTestBlock");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.brandon3055.draconicevolution.common.items;
|
||||
|
||||
import com.brandon3055.draconicevolution.DraconicEvolution;
|
||||
import com.brandon3055.draconicevolution.common.core.utills.ItemNBTHelper;
|
||||
import com.brandon3055.draconicevolution.common.lib.Strings;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by Brandon on 27/08/2014.
|
||||
*/
|
||||
public class Key extends ItemDE {
|
||||
public Key() {
|
||||
this.setUnlocalizedName(Strings.keyName);
|
||||
this.setCreativeTab(DraconicEvolution.tolkienTabBlocksItems);
|
||||
this.setHasSubtypes(true);
|
||||
this.setMaxStackSize(1);
|
||||
ModItems.register(this);
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void getSubItems(Item item, CreativeTabs p_150895_2_, List list) {
|
||||
list.add(new ItemStack(item, 1, 0));
|
||||
list.add(new ItemStack(item, 1, 1));
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
@Override
|
||||
public void addInformation(ItemStack key, EntityPlayer player, List list, boolean par4) {
|
||||
if (!player.capabilities.isCreativeMode) return;
|
||||
if (key.getItemDamage() == 1){
|
||||
list.add("Creative Master Key");
|
||||
return;
|
||||
}
|
||||
|
||||
int keyCode = ItemNBTHelper.getIntager(key, "KeyCode", 0);
|
||||
list.add(keyCode == 0 ? "Un-Bound" : "Key Code: " + String.valueOf(keyCode));
|
||||
|
||||
if (keyCode != 0){
|
||||
list.add("Linked to {X:"+ItemNBTHelper.getIntager(key, "X", 0)+" Y:"+ItemNBTHelper.getIntager(key, "Y", 0)+" X:"+ItemNBTHelper.getIntager(key, "Z", 0)+"}");
|
||||
if (ItemNBTHelper.getIntager(key, "LockCount", 0) == 0) return;
|
||||
for (int i = 1; i <= ItemNBTHelper.getIntager(key, "LockCount", 0); i++){
|
||||
list.add("Linked to {X:"+ItemNBTHelper.getIntager(key, "X_"+i, 0)+" Y:"+ItemNBTHelper.getIntager(key, "Y_"+i, 0)+" X:"+ItemNBTHelper.getIntager(key, "Z_"+i, 0)+"}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasEffect(ItemStack stack, int pass) {
|
||||
if (stack.getItemDamage() == 1) return true;
|
||||
return ItemNBTHelper.getIntager(stack, "KeyCode", 0) != 0;
|
||||
}
|
||||
}
|
||||
@@ -56,6 +56,7 @@ public class ModItems {
|
||||
public static ItemDE mobSoul;
|
||||
public static ItemDE enderArrow;
|
||||
public static ItemDE safetyMatch;
|
||||
public static ItemDE key;
|
||||
|
||||
public static ItemDE teleporterMKI;
|
||||
public static ItemDE teleporterMKII;
|
||||
@@ -98,6 +99,7 @@ public class ModItems {
|
||||
mobSoul = new MobSoul();
|
||||
enderArrow = new EnderArrow();
|
||||
safetyMatch = new SafetyMatch();
|
||||
key = new Key();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.brandon3055.draconicevolution.common.lib;
|
||||
public class References {
|
||||
public static final String MODID = "DraconicEvolution";
|
||||
public static final String MODNAME = "Draconic Evolution";
|
||||
public static final String VERSION = "0.9.32-Beta";
|
||||
public static final String VERSION = "0.9.4-Beta";
|
||||
public static final String MCVERSION = "1.7.10";
|
||||
public static final String CLIENTPROXYLOCATION = "com.brandon3055.draconicevolution.common.core.proxy.ClientProxy";
|
||||
public static final String COMMONPROXYLOCATION = "com.brandon3055.draconicevolution.common.core.proxy.CommonProxy";
|
||||
|
||||
@@ -55,4 +55,6 @@ public class Strings {// public sta
|
||||
public static final String enderArrowName = "enderArrow";
|
||||
public static final String safetyFlameName = "safetyFlame";
|
||||
public static final String safetyMatchName = "safetyMatch";
|
||||
public static final String cKeyStoneName = "cKeyStone";
|
||||
public static final String keyName = "key";
|
||||
}
|
||||
+168
@@ -0,0 +1,168 @@
|
||||
package com.brandon3055.draconicevolution.common.tileentities;
|
||||
|
||||
import com.brandon3055.draconicevolution.common.core.utills.ItemNBTHelper;
|
||||
import com.brandon3055.draconicevolution.common.items.ModItems;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
|
||||
/**
|
||||
* Created by Brandon on 27/08/2014.
|
||||
*/
|
||||
public class TileCKeyStone extends TileEntity {
|
||||
|
||||
public boolean isActivated = false;
|
||||
private int keyCode = 0;
|
||||
private int activeTicks = 0;
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
if (isActivated && (getMeta() == 1 || getMeta() == 3)) {
|
||||
activeTicks++;
|
||||
if (activeTicks == 20){
|
||||
activeTicks = 0;
|
||||
isActivated = false;
|
||||
updateBlocks();
|
||||
worldObj.playSoundEffect((double)xCoord + 0.5D, (double)yCoord + 0.5D, (double)zCoord + 0.5D, "random.click", 0.3F, 0.5F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean onActivated(ItemStack stack, EntityPlayer player){
|
||||
if (stack == null || stack.getItem() != ModItems.key) {
|
||||
if(player.capabilities.isCreativeMode && stack == null && player.isSneaking()) giveInformation(player);
|
||||
return false;
|
||||
}
|
||||
if (isMasterKey(stack)) return true;
|
||||
if (setKey(stack)) return true;
|
||||
if(!isKeyValid(stack, player)) return false;
|
||||
|
||||
switch (getMeta()){
|
||||
case 0: //Permanent Activation
|
||||
isActivated = true;
|
||||
player.destroyCurrentEquippedItem();
|
||||
worldObj.playSoundEffect((double)xCoord + 0.5D, (double)yCoord + 0.5D, (double)zCoord + 0.5D, "random.click", 0.3F, 0.6F);
|
||||
break;
|
||||
case 1: //Button Activation
|
||||
isActivated = true;
|
||||
worldObj.playSoundEffect((double)xCoord + 0.5D, (double)yCoord + 0.5D, (double)zCoord + 0.5D, "random.click", 0.3F, 0.6F);
|
||||
break;
|
||||
case 2: //Toggle Activation
|
||||
if (!isActivated)
|
||||
worldObj.playSoundEffect((double)xCoord + 0.5D, (double)yCoord + 0.5D, (double)zCoord + 0.5D, "random.click", 0.3F, 0.6F);
|
||||
else
|
||||
worldObj.playSoundEffect((double)xCoord + 0.5D, (double)yCoord + 0.5D, (double)zCoord + 0.5D, "random.click", 0.3F, 0.5F);
|
||||
isActivated = !isActivated;
|
||||
break;
|
||||
case 3: //Button Activation (Consume Key)
|
||||
isActivated = true;
|
||||
player.destroyCurrentEquippedItem();
|
||||
worldObj.playSoundEffect((double)xCoord + 0.5D, (double)yCoord + 0.5D, (double)zCoord + 0.5D, "random.click", 0.3F, 0.6F);
|
||||
break;
|
||||
case 4:
|
||||
break;
|
||||
}
|
||||
|
||||
updateBlocks();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void giveInformation(EntityPlayer player){
|
||||
if (worldObj.isRemote){
|
||||
player.addChatComponentMessage(new ChatComponentTranslation("msg.cKeyStoneType"+getMeta()+".txt"));
|
||||
player.addChatComponentMessage(new ChatComponentText("Key: "+keyCode));
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isMasterKey(ItemStack key){
|
||||
if (key.getItemDamage() == 1){
|
||||
if (!isActivated)
|
||||
worldObj.playSoundEffect((double)xCoord + 0.5D, (double)yCoord + 0.5D, (double)zCoord + 0.5D, "random.click", 0.3F, 0.6F);
|
||||
else
|
||||
worldObj.playSoundEffect((double)xCoord + 0.5D, (double)yCoord + 0.5D, (double)zCoord + 0.5D, "random.click", 0.3F, 0.5F);
|
||||
isActivated = !isActivated;
|
||||
updateBlocks();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean setKey(ItemStack key){
|
||||
if (keyCode == 0 && ItemNBTHelper.getIntager(key, "KeyCode", 0) == 0){
|
||||
keyCode = worldObj.rand.nextInt();
|
||||
ItemNBTHelper.setIntager(key, "KeyCode", keyCode);
|
||||
ItemNBTHelper.setIntager(key, "X", xCoord);
|
||||
ItemNBTHelper.setIntager(key, "Y", yCoord);
|
||||
ItemNBTHelper.setIntager(key, "Z", zCoord);
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
return true;
|
||||
}else if (keyCode == 0 && ItemNBTHelper.getIntager(key, "KeyCode", 0) != 0){
|
||||
keyCode = ItemNBTHelper.getIntager(key, "KeyCode", 0);
|
||||
ItemNBTHelper.setIntager(key, "LockCount", ItemNBTHelper.getIntager(key, "LockCount", 0) + 1);
|
||||
ItemNBTHelper.setIntager(key, "X_"+ItemNBTHelper.getIntager(key, "LockCount", 0), xCoord);
|
||||
ItemNBTHelper.setIntager(key, "Y_"+ItemNBTHelper.getIntager(key, "LockCount", 0), yCoord);
|
||||
ItemNBTHelper.setIntager(key, "Z_"+ItemNBTHelper.getIntager(key, "LockCount", 0), zCoord);
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isKeyValid(ItemStack key, EntityPlayer player){
|
||||
if (ItemNBTHelper.getIntager(key, "KeyCode", 0) != keyCode) {
|
||||
if (worldObj.isRemote) player.addChatComponentMessage(new ChatComponentTranslation("msg.wrongKey.txt"));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private int getMeta(){return worldObj.getBlockMetadata(xCoord, yCoord, zCoord);}
|
||||
|
||||
public int getKeyCode(){return keyCode;}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket() {
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
this.writeToNBT(tagCompound);
|
||||
return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, tagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
|
||||
readFromNBT(pkt.func_148857_g());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound compound)
|
||||
{
|
||||
compound.setBoolean("IsActivated", isActivated);
|
||||
compound.setInteger("KeyCode", keyCode);
|
||||
super.writeToNBT(compound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound compound)
|
||||
{
|
||||
isActivated = compound.getBoolean("IsActivated");
|
||||
keyCode = compound.getInteger("KeyCode");
|
||||
super.readFromNBT(compound);
|
||||
}
|
||||
|
||||
public void updateBlocks()
|
||||
{
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, blockType);
|
||||
worldObj.notifyBlocksOfNeighborChange(xCoord - 1, yCoord, zCoord, blockType);
|
||||
worldObj.notifyBlocksOfNeighborChange(xCoord + 1, yCoord, zCoord, blockType);
|
||||
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord - 1, zCoord, blockType);
|
||||
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord + 1, zCoord, blockType);
|
||||
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord - 1, blockType);
|
||||
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord + 1, blockType);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user