Jump to content

Recommended Posts

Posted

I'm trying to get my custom sand block to fall upwards, but changing things has zero effect on anything. I must be missing something obvious, but search as I might, I am not finding it. I've flipped what I thought were the relevant values from negative to positive, and even if that doesn't do what I want, I figure it ought to do something, but the block still acts just like normal sand. Is the normal sand entity being created, instead of mine?

 

Here's my code (red text is altered from sand's code EDIT: Or, ah, I suppose you can't change color in code tags):

 

Sand Block:

package nethseaar.bacon.blocks;

import java.util.Random;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockSand;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.item.EntityFallingSand;
import net.minecraft.util.Icon;
import net.minecraft.world.World;
import nethseaar.bacon.entities.EntityFallingAscender;

public class BlockUp extends BlockSand {

@SideOnly(Side.CLIENT)
    private Icon upTop;
@SideOnly(Side.CLIENT)
    private Icon upBottom;
    
        public BlockUp(int id, Material material) {
                super(id, material);
        }
        
        /**
         * If there is space to fall below will start this block falling
         */
        private void tryToFall(World par1World, int par2, int par3, int par4)
        {
            [color=red]if (canFallAbove(par1World, par2, par3 + 1, par4) && par3 >= 0)[/color]
            {
                byte b0 = 32;

                if (!fallInstantly && par1World.checkChunksExist(par2 - b0, par3 - b0, par4 - b0, par2 + b0, par3 + b0, par4 + b0))
                {
                    if (!par1World.isRemote)
                    {
                        [color=red]EntityFallingAscender entityfallingascender = new EntityFallingAscender(par1World, (double)((float)par2 + 0.5F), (double)((float)par3 + 0.5F), (double)((float)par4 + 0.5F), this.blockID, par1World.getBlockMetadata(par2, par3, par4));
                        this.onStartFalling(entityfallingascender);
                        par1World.spawnEntityInWorld(entityfallingascender);[/color]
                    }
                }
                else
                {
                    par1World.setBlockToAir(par2, par3, par4);

                 [color=red]   while (canFallBelow(par1World, par2, par3 + 1, par4) && par3 > 0)
                    {
                        ++par3;
                    }
[/color]
                    if (par3 > 0)
                    {
                        par1World.setBlock(par2, par3, par4, this.blockID);
                    }
                }
            }
        }
        
        public static boolean canFallAbove(World par0World, int par1, int par2, int par3)
        {
            int l = par0World.getBlockId(par1, par2, par3);

            if (par0World.isAirBlock(par1, par2, par3))
            {
                return true;
            }
            else if (l == Block.fire.blockID)
            {
                return true;
            }
            else
            {
                Material material = Block.blocksList[l].blockMaterial;
                return material == Material.water ? true : material == Material.lava;
            }
        }
        
        
        @SideOnly(Side.CLIENT)
        public Icon getIcon(int par1, int par2)
        {
            return par1 == 0 ? this.upBottom : (par1 == 1 ? this.upTop: this.blockIcon);
        }
        
        @SideOnly(Side.CLIENT)
        public void registerIcons(IconRegister par1IconRegister)
        {
            this.blockIcon = par1IconRegister.registerIcon("upDownSides");
            this.upTop = par1IconRegister.registerIcon("upTop");
            this.upBottom = par1IconRegister.registerIcon("upBottom");
        }
}

 

FallingSand Entity:

package nethseaar.bacon.entities;

import java.util.Iterator;

import net.minecraft.block.Block;
import net.minecraft.block.BlockSand;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityFallingSand;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;

public class EntityFallingAscender extends EntityFallingSand {

 public int blockID;
    public int metadata;

    /** How long the block has been falling for. */
    public int fallTime;
    public boolean shouldDropItem;
    private boolean isBreakingAnvil;
    private boolean isAnvil;

    /** Maximum amount of damage dealt to entities hit by falling block */
    private int fallHurtMax;

    /** Actual damage dealt to entities hit by falling block */
    private float fallHurtAmount;
    public NBTTagCompound fallingBlockTileEntityData;

    public EntityFallingAscender(World par1World)
    {
        super(par1World);
        this.fallTime = 0;
        this.shouldDropItem = true;
        this.isBreakingAnvil = false;
        this.isAnvil = false;
        this.fallHurtMax = 40;
        this.fallHurtAmount = 2.0F;
        this.fallingBlockTileEntityData = null;
    }

    public EntityFallingAscender(World par1World, double par2, double par4, double par6, int par8)
    {
        this(par1World, par2, par4, par6, par8, 0);
    }

    public EntityFallingAscender(World par1World, double par2, double par4, double par6, int par8, int par9)
    {
        super(par1World);
        this.fallTime = 0;
        this.shouldDropItem = true;
        this.isBreakingAnvil = false;
        this.isAnvil = false;
        this.fallHurtMax = 40;
        this.fallHurtAmount = 2.0F;
        this.fallingBlockTileEntityData = null;
        this.blockID = par8;
        this.metadata = par9;
        this.preventEntitySpawning = true;
        this.setSize(0.98F, 0.98F);
        this.yOffset = this.height / 2.0F;
        this.setPosition(par2, par4, par6);
        this.motionX = 0.0D;
        this.motionY = 0.0D;
        this.motionZ = 0.0D;
        this.prevPosX = par2;
        this.prevPosY = par4;
        this.prevPosZ = par6;
    }

    public void onUpdate()
    {
        if (this.blockID == 0)
        {
            this.setDead();
        }
        else
        {
            this.prevPosX = this.posX;
            this.prevPosY = this.posY;
            this.prevPosZ = this.posZ;
            ++this.fallTime;
           [color=red] this.motionY += 0.03999999910593033D;[/color]
            this.moveEntity(this.motionX, this.motionY, this.motionZ);
            this.motionX *= 0.9800000190734863D;
            this.motionY *= 0.9800000190734863D;
            this.motionZ *= 0.9800000190734863D;

            if (!this.worldObj.isRemote)
            {
                int i = MathHelper.floor_double(this.posX);
                int j = MathHelper.floor_double(this.posY);
                int k = MathHelper.floor_double(this.posZ);

                if (this.fallTime == 1)
                {
                    if (this.worldObj.getBlockId(i, j, k) != this.blockID)
                    {
                        this.setDead();
                        return;
                    }

                    this.worldObj.setBlockToAir(i, j, k);
                }

                if (this.onGround)
                {
                    this.motionX *= 0.699999988079071D;
                    this.motionZ *= 0.699999988079071D;
                    this.motionY *= 0.5D;

                    if (this.worldObj.getBlockId(i, j, k) != Block.pistonMoving.blockID)
                    {
                        this.setDead();

                        if (!this.isBreakingAnvil && this.worldObj.canPlaceEntityOnSide(this.blockID, i, j, k, true, 1, (Entity)null, (ItemStack)null) && !BlockSand.canFallBelow(this.worldObj, i, j - 1, k) && this.worldObj.setBlock(i, j, k, this.blockID, this.metadata, 3))
                        {
                            if (Block.blocksList[this.blockID] instanceof BlockSand)
                            {
                                ((BlockSand)Block.blocksList[this.blockID]).onFinishFalling(this.worldObj, i, j, k, this.metadata);
                            }

                            if (this.fallingBlockTileEntityData != null && Block.blocksList[this.blockID] instanceof ITileEntityProvider)
                            {
                                TileEntity tileentity = this.worldObj.getBlockTileEntity(i, j, k);

                                if (tileentity != null)
                                {
                                    NBTTagCompound nbttagcompound = new NBTTagCompound();
                                    tileentity.writeToNBT(nbttagcompound);
                                    Iterator iterator = this.fallingBlockTileEntityData.getTags().iterator();

                                    while (iterator.hasNext())
                                    {
                                        NBTBase nbtbase = (NBTBase)iterator.next();

                                        if (!nbtbase.getName().equals("x") && !nbtbase.getName().equals("y") && !nbtbase.getName().equals("z"))
                                        {
                                            nbttagcompound.setTag(nbtbase.getName(), nbtbase.copy());
                                        }
                                    }

                                    tileentity.readFromNBT(nbttagcompound);
                                    tileentity.onInventoryChanged();
                                }
                            }
                        }
                        else if (this.shouldDropItem && !this.isBreakingAnvil)
                        {
                            this.entityDropItem(new ItemStack(this.blockID, 1, Block.blocksList[this.blockID].damageDropped(this.metadata)), 0.0F);
                        }
                    }
                }
                else if (this.fallTime > 100 && !this.worldObj.isRemote && (j < 1 || j > 256) || this.fallTime > 600)
                {
                    if (this.shouldDropItem)
                    {
                        this.entityDropItem(new ItemStack(this.blockID, 1, Block.blocksList[this.blockID].damageDropped(this.metadata)), 0.0F);
                    }

                    this.setDead();
                }
            }
        }
    }
    
}

Posted

This is due to one of the basics of Java. You can't override a private method.

private void tryToFall(World par1World, int par2, int par3, int par4)

This method in your block will never be called, since it is the one in BlockSand that is declared first.

 

Solution: don't extend BlockSand :)

Posted

There also is a possibility to override from the parent class (BlockSand).

public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
    {
        if (!par1World.isRemote)
        {
            this.tryToFall(par1World, par2, par3, par4);
        }
    }

since this is the only call to tryToFall(args) ;)

Posted

Are there any tutorials for creating and rendering entities like FallingSand? I've copied (and made appropriate changes to) the FallingSand code, and its renderer, but either my entity isn't spawning or it isn't rendering; the sand just disappears when it can fall, and then breaks (drops itself) at some point as it rises. I don't understand how renderers work at all, so I'm blaming the problem on my renderer.

Posted

Might you point me toward them? I've searched, to no avail.

 

I've registered my renderer thusly, in Common Proxy:

 

 public void registerRenderers() {
        	   RenderingRegistry.registerEntityRenderingHandler(Entity.class, new RenderFallingAscender());
        }

 

But I haven't registered my entity! Where/how does one do that?

Posted

Might you point me toward them? I've searched, to no avail.

 

I've registered my renderer thusly, in Common Proxy:

 

 public void registerRenderers() {
        	   RenderingRegistry.registerEntityRenderingHandler(Entity.class, new RenderFallingAscender());
        }

 

But I haven't registered my entity! Where/how does one do that?

You're registering renderers server sided? This is not correct. Register it only client sided instead.

Also why are you registering the renderer for all Entities (by calling the register with Entity.class)? Use your own entity instead.

Author of PneumaticCraft, MineChess, Minesweeper Mod and Sokoban Mod. Visit www.minemaarten.com to take a look at them.

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

    • It is also worth mentioning that I have tested this modpack on two hosts, exoroton and minecraftHosting In the first one it seemed to go well but when changing files from one to another it started to cause problems, maybe there have been some changes since I tried it in exoroton, I have been doing everything to make it work
    • It also takes a long time to load but that could be normal. The modpack has the synatra connected mod and at this point I don't know if it is working correctly because of a couple of strange things it does. for example in the client it generates a folder but in the case of the server this is empty this is called .conneted https://mclo.gs/1X2Elct
    • When i try to join my friends server with mods it just says failed to log in: the authentication servers are currently not reachable. I've been having this issue for a while now and no method I've tried to fix it works. I've seen a lot of people fixing it by modifying the host.txt file and removing anything related to Mojang but when I open mine there's nothing related to Mojang there. I also tried flushing DNS cache, and changing my IPV6 to 8888, but nothing works.  It only happens when the mods are on too. When I join my friends server on vanilla it works, but not with mods. I can join multiplayer servers like hypixel. I can also play singleplayer with the mods and it works perfectly. The mods are up to date with the versions and the servers, but it just never gets past "Logging in" when i try to join their server. I use Curseforge to launch my mods, so that could maybe have something to do with it because it's technically a third party server, but it hasn't given me any trouble besides this one issue. I do not have MCLeaks and don't know what that is, but how can i search for it anyway to make sure? I have uninstalled minecraft launcher, updated my microsoft and my videocard drivers, reset my wifi and checked my parental settings (I am the owner on my computer), flushed my dns, modifying my host file to delete mojang but there's nothing with mojang on there, disabled my firewall, changed my IPV6 domain to 8888, restarted my router, and none of that works. I have researched this issue thoroughly and tried every solution I have came across and nothing is fixing the problem so i have come here as a last ditch effort. All i want to do is play mods with my friend. My friend has no issues with the server or mods and he has it through curseforge too. I would like further assistance in any way you think could help or even refer me to another forum that could help with this. Genuinely I cannot figure out why it doesn't work I would love any sort of further help.  
    • been getting this error and followed the old tick loop post however i cant figure out what file to delete Description: Exception in server tick loop java.lang.NullPointerException: Cannot invoke "net.minecraft.world.level.LevelAccessor.m_7654_()" because the return value of "net.minecraftforge.event.level.LevelEvent$Unload.getLevel()" is null     at com.lion.graveyard.platform.forge.HordeSpawner.onWorldUnload(HordeSpawner.java:41) ~[The_Graveyard_3.1_(FORGE)_for_1.20.1.jar%23196!/:?] {re:classloading}     at com.lion.graveyard.platform.forge.__HordeSpawner_onWorldUnload_Unload.invoke(.dynamic) ~[The_Graveyard_3.1_(FORGE)_for_1.20.1.jar%23196!/:?] {re:classloading,pl:eventbus:B}     at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:73) ~[eventbus-6.0.5.jar%2352!/:?] {}     at net.minecraftforge.eventbus.EventBus.post(EventBus.java:315) ~[eventbus-6.0.5.jar%2352!/:?] {}     at net.minecraftforge.eventbus.EventBus.post(EventBus.java:296) ~[eventbus-6.0.5.jar%2352!/:?] {}     at net.mehvahdjukaar.moonlight.api.platform.forge.PlatHelperImpl.invokeLevelUnload(PlatHelperImpl.java:279) ~[moonlight-1.20-2.13.66-forge.jar%23185!/:?] {re:classloading}     at net.mehvahdjukaar.moonlight.api.platform.PlatHelper.invokeLevelUnload(PlatHelper.java) ~[moonlight-1.20-2.13.66-forge.jar%23185!/:?] {re:mixin,re:classloading}     at net.mehvahdjukaar.moonlight.core.misc.FakeLevelManager.invalidate(FakeLevelManager.java:29) ~[moonlight-1.20-2.13.66-forge.jar%23185!/:?] {re:classloading}     at net.mehvahdjukaar.supplementaries.common.utils.fake_level.BlockTestLevel.invalidate(BlockTestLevel.java:34) ~[supplementaries-1.20-3.1.13.jar%23192!/:?] {re:classloading}     at net.mehvahdjukaar.supplementaries.common.block.faucet.FaucetBehaviorsManager.onReloadWithLevel(FaucetBehaviorsManager.java:129) ~[supplementaries-1.20-3.1.13.jar%23192!/:?] {re:classloading}     at net.mehvahdjukaar.supplementaries.common.events.ServerEvents.onServerStart(ServerEvents.java:160) ~[supplementaries-1.20-3.1.13.jar%23192!/:?] {re:mixin,re:classloading}     at net.mehvahdjukaar.supplementaries.common.events.forge.ServerEventsForge.onServerStart(ServerEventsForge.java:119) ~[supplementaries-1.20-3.1.13.jar%23192!/:?] {re:classloading}     at net.mehvahdjukaar.supplementaries.common.events.forge.__ServerEventsForge_onServerStart_ServerStartedEvent.invoke(.dynamic) ~[supplementaries-1.20-3.1.13.jar%23192!/:?] {re:classloading,pl:eventbus:B}     at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:73) ~[eventbus-6.0.5.jar%2352!/:?] {}     at net.minecraftforge.eventbus.EventBus.post(EventBus.java:315) ~[eventbus-6.0.5.jar%2352!/:?] {}     at net.minecraftforge.eventbus.EventBus.post(EventBus.java:296) ~[eventbus-6.0.5.jar%2352!/:?] {}     at net.minecraftforge.server.ServerLifecycleHooks.handleServerStarted(ServerLifecycleHooks.java:115) ~[forge-1.20.1-47.3.29-universal.jar%23212!/:?] {re:classloading}     at net.minecraft.server.MinecraftServer.m_130011_(MinecraftServer.java:638) ~[server-1.20.1-20230612.114412-srg.jar%23207!/:?] {re:mixin,pl:accesstransformer:B,xf:fml:xaeroworldmap:xaero_wm_minecraftserver,xf:fml:xaerominimap:xaero_minecraftserver,re:classloading,pl:accesstransformer:B,xf:fml:xaeroworldmap:xaero_wm_minecraftserver,xf:fml:xaerominimap:xaero_minecraftserver,pl:mixin:APP:unionlib.mixins.json:MinecraftServerMixin,pl:mixin:APP:citadel.mixins.json:MinecraftServerMixin,pl:mixin:APP:balm.mixins.json:MinecraftServerMixin,pl:mixin:A}     at net.minecraft.server.MinecraftServer.m_206580_(MinecraftServer.java:251) ~[server-1.20.1-20230612.114412-srg.jar%23207!/:?] {re:mixin,pl:accesstransformer:B,xf:fml:xaeroworldmap:xaero_wm_minecraftserver,xf:fml:xaerominimap:xaero_minecraftserver,re:classloading,pl:accesstransformer:B,xf:fml:xaeroworldmap:xaero_wm_minecraftserver,xf:fml:xaerominimap:xaero_minecraftserver,pl:mixin:APP:unionlib.mixins.json:MinecraftServerMixin,pl:mixin:APP:citadel.mixins.json:MinecraftServerMixin,pl:mixin:APP:balm.mixins.json:MinecraftServerMixin,pl:mixin:A}     at java.lang.Thread.run(Thread.java:833) ~[?:?] {}  
    • Online forums in general seem to be declining in popularity imo. There’s still value here for certain types of content, such as written tutorials and blog posts which would otherwise get lost in the chat history fairly quickly on Discord. Also for those that prefer the forums format ofc. But for faster support related topics, I agree that the Discord is probably your best bet at the moment. The speed of responses is also down to the ratio of volunteers - the player support forum still seems pretty active, but the coding ones much less so. Once you’re feeling more confident in your modding skills, be the change you want to see
  • Topics

×
×
  • Create New...

Important Information

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