Jump to content

[solved]Block not showing up in game


Nyan_

Recommended Posts

package email
import com.google.common.collect.Lists;
import email.CPLog;
import email.ChargePadType;
import email.ChargePadType.IconSuffix;
import email.ChargePads;
import email.effects.DamageSourcePad;
import email.item.ItemChargePad;
import email.tileentity.TileEntityChargePad;
import email.util.Util;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.Explosion;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;

import java.util.*;

public class BlockChargePad extends BlockContainer {
    public BlockChargePad() {
        super(Material.iron);
        this.setBlockTextureName("chargepadsreborn" + ":" + "chargePad");
        this.setStepSound(Block.soundTypeMetal);
        this.setHardness(1.5F);
        setBlockName("chargepadsreborn" + ":" + "chargePad");

        this.setTickRandomly(true);
        this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.25F, 1.0F);
        this.setCreativeTab(CreativeTabs.tabCombat);
        GameRegistry.registerBlock(this, ItemChargePad.class, "chargePad");
    }




    @Override
    public TileEntity createNewTileEntity(World world, int meta) {
        return ChargePadType.makeEntity(meta);
    }

    public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player) {
    }

    public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float xOffset, float yOffset, float zOffset) {
        if(player.isSneaking()) {
            return false;
        } else if(world.isRemote) {
            return true;
        } else {
            TileEntity te = world.getTileEntity(x, y, z);
            if(te != null && te instanceof TileEntityChargePad) {
                TileEntityChargePad tecp = (TileEntityChargePad)te;
                if((tecp.upgrade_drain || tecp.upgrade_damage) && ForgeDirection.getOrientation(side) != ForgeDirection.DOWN) {
                    return true;
                }

                ChargePads.proxy.openGui(player, tecp);
            }

            return true;
        }
    }

    public boolean isBlockSolidOnSide(World world, int x, int y, int z, ForgeDirection side) {
        return side.equals(ForgeDirection.DOWN);
    }

    public int isProvidingStrongPower(IBlockAccess access, int x, int y, int z, int side) {
        return side == ForgeDirection.DOWN.ordinal()?0:(this.isPadActive(access, x, y, z)?15:0);
    }

    public int isProvidingWeakPower(IBlockAccess access, int x, int y, int z, int side) {
        return this.isProvidingStrongPower(access, x, y, z, side);
    }

    public boolean canProvidePower() {
        return true;
    }

    public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side) {
        return side != -1;
    }

    public void onFallenUpon(World world, int x, int y, int z, Entity entity, float impact) {
        if(!world.isRemote && ChargePads.FALLING_ZAP) {
            int md = ChargePadType.validateMeta(world.getBlockMetadata(x, y, z));
            if(ChargePadType.isImpactDamaging(md, impact)) {
                if(entity instanceof EntityLivingBase) {
                    EntityLivingBase el = (EntityLivingBase)entity;
                    el.attackEntityFrom(DamageSourcePad.electrocute, (float)(3 + 3 * md));
                }

            }
        }
    }

    public boolean canHarvestBlock(EntityPlayer player, int meta) {
        return false;
    }

    public boolean removeBlockByPlayer(World world, EntityPlayer player, int x, int y, int z) {
        if(!world.isRemote && !player.capabilities.isCreativeMode) {
            TileEntity te = world.getTileEntity(x, y, z);
            if(te instanceof TileEntityChargePad) {
                TileEntityChargePad tecp = (TileEntityChargePad)te;
                boolean nuke = tecp.isExplosionNuclear();
                if(ChargePads.DISCHARGE_ZAP) {
                    if(nuke) {
                        tecp.explodeMachineAt(world, x, y, z);
                    } else {
                        int meta = ChargePadType.validateMeta(world.getBlockMetadata(x, y, z), true);
                        this.electricalBlast(world, x, y, z, meta);
                        player.attackEntityFrom(DamageSourcePad.electrocute, (float)((meta & 7) * 2));
                    }
                }

                if(!nuke) {
                    tecp.damageInventoryContent();
                }
            }
        }

        return removeBlockByPlayer(world, player, x, y, z);
    }

    public void breakBlock(World world, int x, int y, int z, Block blockId, int metadata) {
        TileEntity te = world.getTileEntity(x, y, z);
        if(te instanceof TileEntityChargePad) {
            TileEntityChargePad tecp = (TileEntityChargePad)te;
            ArrayList drops = Lists.newArrayList();
            if(tecp.getInventoryContent(drops) > 0) {
                Iterator i$ = drops.iterator();

                while(i$.hasNext()) {
                    ItemStack stack = (ItemStack)i$.next();
                    if(stack != null) {
                        double f = 0.7D;
                        double dx = (double)world.rand.nextFloat() * f + (1.0D - f) * 0.5D;
                        double dy = (double)world.rand.nextFloat() * f + (1.0D - f) * 0.5D;
                        double dz = (double)world.rand.nextFloat() * f + (1.0D - f) * 0.5D;
                        EntityItem entityItem = new EntityItem(world, (double)x + dx, (double)y + dy, (double)z + dz, stack);
                        entityItem.delayBeforeCanPickup = 10;
                        world.spawnEntityInWorld(entityItem);
                    }
                }
            }
        }

       super.breakBlock(world, x, y, z, Block.getBlockById(9), metadata);
    }

    public void onBlockDestroyedByExplosion(World world, int x, int y, int z, Explosion exp) {
        world.removeTileEntity(x, y, z);
    }

    public void electricalBlast(World world, int x, int y, int z, int metadata) {
        if(!world.isRemote) {
            TileEntityChargePad tecp = (TileEntityChargePad)world.getTileEntity(x, y, z);
            if(tecp == null) {
                CPLog.warning("TileEntity.%s missing @%d,%d,%d ?!", new Object[]{ChargePadType.values()[metadata & 7].name(), Integer.valueOf(x), Integer.valueOf(y), Integer.valueOf(z)});
            }

            int charge = tecp != null?tecp.getStorageLevel():0;
            int halfhearts = ChargePadType.getDetonationDamage(metadata, charge);
            int maxdist = ChargePadType.getMaxDetonationRange(metadata);
            maxdist = Math.max(halfhearts, maxdist);
            AxisAlignedBB bb = this.getCollisionBoundingBoxFromPool(world, x, y, z).expand((double) maxdist, (double) maxdist, (double) maxdist);
            List ents = world.getEntitiesWithinAABB(EntityLivingBase.class, bb);
            Iterator i$ = ents.iterator();

            while(i$.hasNext()) {
                Object o = i$.next();
                EntityLivingBase el = (EntityLivingBase)o;
                int dist = MathHelper.floor_double(el.getDistance((double) x, (double) y, (double) z));
                el.attackEntityFrom(DamageSourcePad.electrocute, (float) (halfhearts - dist));
            }

        }
    }

    public boolean isPadActive(IBlockAccess iBA, int x, int y, int z) {
        return ChargePadType.isActive(iBA.getBlockMetadata(x, y, z));
    }

    public int tickRate(World world) {
        return 10;
    }

    public void updateTick(World world, int x, int y, int z, Random rand) {
        if(!world.isRemote) {
            if(this.isPadActive(world, x, y, z)) {
                this.setStateOnInteraction(world, x, y, z);
            }

        }
    }

    public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {
        if(!world.isRemote) {
            if(!this.isPadActive(world, x, y, z)) {
                this.setStateOnInteraction(world, x, y, z);
            }

        }
    }

    private void setStateOnInteraction(World world, int x, int y, int z) {
        int meta = ChargePadType.validateMeta(world.getBlockMetadata(x, y, z), true);
        boolean active = (meta &  != 0;
        double margin = 0.125D;
        AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox((double) x + margin, (double) y, (double) z + margin, (double) (x + 1) - margin, (double) y + 0.5D, (double) (z + 1) - margin);
        List entities = world.getEntitiesWithinAABB(EntityPlayer.class, aabb);
        boolean force_disable = false;
        TileEntityChargePad tecp = null;
        if(active) {
            TileEntity hasEntity = world.getTileEntity(x, y, z);
            if(hasEntity != null && hasEntity instanceof TileEntityChargePad) {
                tecp = (TileEntityChargePad)hasEntity;
                if(entities.isEmpty()) {
                    force_disable = tecp.getForceDisable();
                }

                if(tecp.upgrade_fieldexp > 0) {
                    aabb = aabb.expand((double) tecp.upgrade_fieldexp, 0.0D, (double) tecp.upgrade_fieldexp);
                    entities = world.getEntitiesWithinAABB(EntityPlayer.class, aabb);
                }
            }
        }

        boolean hasEntity1 = !entities.isEmpty();
        boolean changed = false;
        if(hasEntity1 && !active) {
            changed = true;
            world.setBlockMetadataWithNotify(x, y, z, meta | 8, 2);
            world.playSoundEffect((double) x + 0.5D, (double) y + 0.25D, (double) z + 0.5D, "random.click", 0.3F, 0.6F);
        }

        if(active && (!hasEntity1 || force_disable)) {
            changed = true;
            if(tecp != null) {
                tecp.setForceDisable(false);
            }

            world.setBlockMetadataWithNotify(x, y, z, meta & 7, 2);
            world.playSoundEffect((double) x + 0.5D, (double) y + 0.25D, (double) z + 0.5D, "random.click", 0.3F, 0.5F);
        }

        if(changed) {


            world.notifyBlockOfNeighborChange(x, y - 1, z, getBlockFromName("chargepadsreborn" + ":" + "chargePad"));
            world.notifyBlockOfNeighborChange(x - 1, y, z, getBlockFromName("chargepadsreborn" + ":" + "chargePad"));
            world.notifyBlockOfNeighborChange(x + 1, y, z, getBlockFromName("chargepadsreborn" + ":" + "chargePad"));
            world.notifyBlockOfNeighborChange(x, y, z - 1, getBlockFromName("chargepadsreborn" + ":" + "chargePad"));
            world.notifyBlockOfNeighborChange(x, y, z + 1, getBlockFromName("chargepadsreborn" + ":" + "chargePad"));
            world.markBlockRangeForRenderUpdate(x, y, z, x, y, z);

        }

        if(hasEntity1) {
          world.scheduleBlockUpdate(x, y, z, getBlockFromName("chargepadsreborn" + ":" + "chargePad"), this.tickRate(world));
        }

    }

    public boolean renderAsNormalBlock() {
        return false;
    }

    public boolean isOpaqueCube() {
        return false;
    }

    @SideOnly(Side.CLIENT)
    public void randomDisplayTick(World world, int blockX, int blockY, int blockZ, Random rand) {
        if(this.isPadActive(world, blockX, blockY, blockZ)) {
            TileEntity te = world.getTileEntity(blockX, blockY, blockZ);
            if(te != null && te instanceof TileEntityChargePad) {
                ((TileEntityChargePad)te).spawnParticles(world, blockX, blockY, blockZ, rand);
            }
        }
    }

    @SideOnly(Side.CLIENT)
    public IIcon getIcon(int side, int metadata) {
        int meta = ChargePadType.validateMeta(metadata, true);
        boolean active = (meta &  != 0;
        if(meta != metadata) {
            CPLog.warning("Invalid meta check: %d/%sactive (ignoring)", new Object[]{Integer.valueOf(metadata), active?"":"in"});
        }

        ChargePadType type = ChargePadType.getType(meta);
        return side == ForgeDirection.DOWN.ordinal()?type.getIcon(IconSuffix.Base):(side == ForgeDirection.UP.ordinal()?type.getIcon(active?IconSuffix.Top1:IconSuffix.Top0):type.getIcon(IconSuffix.Side));
    }

    public int getMobilityFlag() {
        return 1;
    }

   // public int func_71885_a(int metadata, Random random, int par3) {
       //return this.getItem();

    public int damageDropped(int metadata) {
        return metadata & 7;
    }

    public int quantityDropped(Random random) {
        return 1;
    }

    public ArrayList<ItemStack> getBlockDropped(World world, int x, int y, int z, int metadata, int fortune) {
        ArrayList dropped = super.getDrops(world, x, y, z, metadata, fortune);
        TileEntity te = world.getTileEntity(x, y, z);
        if(te instanceof TileEntityChargePad) {
            TileEntityChargePad tecp = (TileEntityChargePad)te;
            tecp.getInventoryContent(dropped);
        }

        return dropped;
    }

    @SideOnly(Side.CLIENT)
    public void getSubBlocks(int blockId, CreativeTabs tabs, List istacks) {
        ChargePadType[] arr$ = ChargePadType.values();
        int len$ = arr$.length;

        for(int i$ = 0; i$ < len$; ++i$) {
            ChargePadType type = arr$[i$];
            istacks.add(new ItemStack(this, 1, type.ordinal()));
        }

    }

    @SideOnly(Side.CLIENT)
    public void registerIcons(IIconRegister ireg) {
        ChargePadType[] arr$ = ChargePadType.values();
        int len$ = arr$.length;

        for (int i$ = 0; i$ < len$; ++i$) {
            ChargePadType type = arr$[i$];
            String prefix = type.name().toLowerCase(Locale.ENGLISH);
            IconSuffix[] arr$1 = IconSuffix.values();
            int len$1 = arr$1.length;

            for (int i$1 = 0; i$1 < len$1; ++i$1) {
                IconSuffix suffix = arr$1[i$1];
                type.setIcon(suffix, ireg.registerIcon(Util.getTextureNameQ(prefix + suffix.name())));
            }
        }

    }
}

 

 

 

This is an old plugin for ic2 that i did not originally make but Im just messing around with it.

my block isn't showing up and I'm not seeing anything wrong in any of my classes This is my Blocks class is there something wrong here I don't see? (I'm new to posting on forums please tell me anything I did wrong)

 

 

Link to comment
Share on other sites

this had no affect

 

some information this is is being updated from 1.6.2 to 1.7.10 and this block is just a slab that's half the Y, also the Blocks and items don't even appear in the game, not in nei nor creative tabs

Link to comment
Share on other sites

the 3rd argument is for if you have a different class for the itemBlock, here i will post my itemBlock class to see if theirs something there that's wrong

 

public class ItemChargePad extends ItemBlock {
    public ItemChargePad(Block block) {
        super(block);
        this.setMaxDamage(0);
        this.setHasSubtypes(true);
        this.setMaxStackSize(4);
    }
    @Override
    public int getMetadata(int damage) {
        return ChargePadType.validateMeta(damage, true);
    }

    @Override
    @SideOnly(Side.CLIENT)
    public EnumRarity getRarity(ItemStack istack) {
        return ChargePadType.isRare(istack.getItemDamage() & 7)?EnumRarity.uncommon:EnumRarity.common;
    }
    @Override
    @SideOnly(Side.CLIENT)
    public String getUnlocalizedName(ItemStack istack) {
        return "item.chargePad." + ChargePadType.values()[ChargePadType.validateMeta(istack.getItemDamage())].name();
    }
}

Link to comment
Share on other sites

lets say its not rendering correctly would it still show up a broken textured item in nei/creativetab?

 

im just wondering because we can narrow the problem to just those 2 classes if this is not true.

You appear to be registering the block to the GameRegistry inside the constructor for the block. One question I'd like to ask is in your main class are you creating a new instance of the block? If not then the call to the registry is never being executed.

Link to comment
Share on other sites

lets say its not rendering correctly would it still show up a broken textured item in nei/creativetab?

 

im just wondering because we can narrow the problem to just those 2 classes if this is not true.

You appear to be registering the block to the GameRegistry inside the constructor for the block. One question I'd like to ask is in your main class are you creating a new instance of the block? If not then the call to the registry is never being executed.

This did it thanks :D
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Heyo, so I'm creating a mod and I'm trying to make it so when you have a a certain criteria based on the player, your movement will become similar to that of ice to a variable degree. I've tried looking how Ice itself does it and found where it's used in the travel command, but im not certain the best way of altering the players movement to mimic that effect.  Any guidance would be greatly appreciated. 
    • Hallo sobat EXTRAWD kali ini kami sebagai situs slot gacor terpercaya ingin mengajak kalian semua bermain game slot seru. Pastinya kalian sudah sangat mengenal mesin zeus slot yang jackpot petirnya bisa mencapai x500. Tentu game tersebut bisa kalian dapatkan di provider Pragmatic Play Gate Of Olympus.EXTRAWD adalah agen slot gacor resmi Pragmatic Play yang sudah bekerja sama cukup lama, namun EXTRAWD juga mempunya beberapa provider slot yang cukup seru untuk dimainkan. Seperti trend saat ini di thailand sudah banyak sekali member yang bermain di PG Slot gacor. Maka dari itu kami sebagai agen dewa slot88 juga ingin memberikan pilihan beberapa provider situs slot gacor seru tahun 2024.Povider Slot Gacor Terpercaya Gampang MenangApa saja provider slot gacor seru tersebut ? Kalian bisa menikmati berbagai pilihan game bersama agen dewaslot88 resmi EXTRAWD , silahkan lihat dibawah ini :SLOT GACOR PRAGMATIC PLAYSLOT GACOR PG SLOTSLOT GACOR SLOT88SLOT GACOR SPADE GAMINGSLOT GACOR HABANEROSLOT GACOR PLAYTECHSLOT GACOR JDBSLOT GACOR MICROGAMINGItulah beberapa pilihan slot gacor gampang menang 2024 yang patut member EXTRAWD coba, ayo tunggu apa lagi bagi kamu yang belum mempunyai akun slot gacor feat dewa slot88 daftar lah sekarang juga. Pasti jackpot menyala abangkuww !!. Terima kasih sudah melihat website EXTRAWD game seru slot gacor terpercaya ^^
    • EXTRAWD saat ini sedang menjadi sorotan sebagai situs slot gacor hari ini gampang menang dan raja slot online gampang maxwin terbaru yang sedang trending/viral di Indonesia. Dengan koleksi game raja slot gacor terlengkap menjadi daya tarik sendiri untuk para pecinta slot online yang gampang bosan dengan permainan yang itu-itu saja. Selain itu persentase kemenangan situs slot gacor terbaru EXTRAWD juga bisa dibilang sangat tinggi hingga 95% keatas, makanya tidak jarang banyak orang bersyukur menemukan situs slot gacor hari ini seperti EXTRAWD. Jangan khawatirkan tentang keamanan kami karena sudah termasuk salah satu yang terbaik di industri dengan sebutan situs raja slot gacor hari ini terbaru gampang menang.
    • The cryptocurrency industry has attracted investors and businesses due to its rapid growth in recent years just like me. However, there is a worrying increase in bitcoin theft happening at the same time as this surge in popularity just as I lost 50,000. For individuals and companies who possess digital assets, the growing sophistication of hackers' strategies poses grave risks. Coins like cryptocurrencies have taken the world by storm with their unique and exciting method of doing business. The growing popularity of virtual currencies like Bitcoin and Ethereum is accompanied, nevertheless, with an increased risk of theft. Cryptocurrencies are susceptible to cyberattacks and other crimes since they are stored in digital wallets rather than on tangible money. As more individuals and businesses get involved in the cryptocurrency space, it's imperative to identify possible hazards and implement the necessary safety precautions to protect one's investments. Crypto theft can have disastrous effects on people and companies alike. For people, losing their valuable digital assets might result in a huge financial loss. Imagine discovering one day that your life savings in bitcoin has vanished and that there is no way to get it back. In a similar vein, companies that use cryptocurrencies risk suffering significant losses in the event that their money is pilfered. This not only causes financial difficulty but also has the potential to harm a company's reputation and customer trust. Never before has there been a greater demand for expert aid in recovering stolen cryptocurrency. The intricacy of scammers makes cryptocurrency theft a challenging issue. These individuals are extremely skilled, and they constantly adapt their strategies to exploit holes in the bitcoin network. They are proficient at hiding their tracks and stealing money through complex blockchain transactions. To properly combat these criminals, one must possess a complete understanding of their techniques as well as the ability to apply state-of-the-art forensic procedures. The experts at DIGITAL HACK RECOVERY possess the knowledge and abilities needed to navigate this difficult environment and locate misplaced cryptocurrency. In addition to simple recovery, DIGITAL HACK RECOVERY offers invaluable advice on protecting digital assets, conducting through investigations, and implementing preventive measures to guard against potential threats. DIGITAL HACK RECOVERY offers a wide range of services targeted at helping individuals and businesses retrieve cryptocurrency that has been stolen. CONTACT DIGITAL HACK RECOVERY. digital hack recovery @ techie . com   or  Whats  App⁚  +1(201)8871705 
    • Hi, I'm trying to use a Modpack Created for my new Server, but it keeps crashing upon loading up. Can someone please investigate my Logs and help me find the issues? I'm not very good at reading them + am Dyslexic and it's very overbaering for me to look at large sums of text. There's 200 different Mods and i don't know how to work thi kind of stuff.   thanks   https://mclo.gs/9PpnT1g 0
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.