Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I want to make my blocks able to be waterlogged but I do not know how,

surly you would just overwrite a method in Blocks.java, right?

Edited by MrNoodles75

18 hours ago, MrNoodles75 said:

surly you would just overwrite a method in Blocks.java, right?

 

What? What are you trying to do? Create your own block or edit vanilla blocks?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

10 hours ago, kaydogz said:

you can use the interface IWaterLoggable

This is only true for creating your own blocks, the OP seems to be looking for something else. Also this is not sufficient. You also have to add the WATERLOGGED property to your block's blockstatecontainer.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

  • Author
On 9/22/2019 at 10:10 AM, Draco18s said:

This is only true for creating your own blocks, the OP seems to be looking for something else. Also this is not sufficient. You also have to add the WATERLOGGED property to your block's blockstatecontainer.

@Draco18s sorry that I couldn't say earlier as I was away for the weekend and couldn't look at my posts.

but I am trying to create my own blocks and I want to make them waterloggable

I had to ask because of the portion I bolded earlier.

 

Water logged blocks are easy. Implement the interface and add the property to the blockstatecontainer.

https://github.com/Draco18s/ReasonableRealism/blob/1.14.4/src/main/java/com/draco18s/harderores/block/SluiceOutput.java#L22

 

Note that blocks can only contain water sources currently, even though they can return any fluid state:

https://github.com/Draco18s/ReasonableRealism/blob/1.14.4/src/main/java/com/draco18s/harderores/block/SluiceOutput.java#L40

Returning anything else results in a block that is not waterlogged.

 

(Do note that my block there is always waterlogged and can't exist in a non-waterlogged state, as I'm using that property to fake a water source block without it actually *being* a water source block.)

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

  • Author

Here is what happens:

1111098521_ScreenShot2019-09-23at10_56_09AM.png.ab269366f45d70a819b4942210daf756.png

and here is my code so far i don't know what is wrong:

 
 
0
 Advanced issues found
 
 
Spoiler

package com.runningmanstudios.extrablocks.blocks;

import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.IWaterLoggable;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.Fluids;
import net.minecraft.fluid.IFluidState;
import net.minecraft.inventory.container.INamedContainerProvider;
import net.minecraft.item.ItemStack;
import net.minecraft.state.StateContainer;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.shapes.VoxelShapes;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorld;
import net.minecraft.world.World;
import net.minecraftforge.common.ToolType;
import net.minecraftforge.fml.network.NetworkHooks;

import javax.annotation.Nullable;

public class NautilusStatue extends Block implements IWaterLoggable {
    public static AxisAlignedBB blocksize = new AxisAlignedBB(1 - 0.125, 0.600, 1 - 0.125, 0.125, 0, 0.125);


    public NautilusStatue() {
        super(Properties.create(Material.WATER)
                .sound(SoundType.WOOD)
                .hardnessAndResistance(20.0f)
                .lightValue(10)
                .harvestTool(ToolType.PICKAXE)
        );
        setDefaultState(stateContainer.getBaseState().with(BlockStateProperties.WATERLOGGED, true));
    }

    @Override
    public void onBlockPlacedBy(World world, BlockPos pos, BlockState state, @Nullable LivingEntity entity, ItemStack stack) {
        if (entity != null) {
            world.setBlockState(pos, state.with(BlockStateProperties.FACING, getFacingFromEntity(pos, entity)), 2);
        }
    }

    @Override
    public boolean onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult result) {
        if (!world.isRemote) {
            TileEntity tileEntity = world.getTileEntity(pos);
            if (tileEntity instanceof INamedContainerProvider) {
                NetworkHooks.openGui((ServerPlayerEntity) player, (INamedContainerProvider) tileEntity, tileEntity.getPos());
            } else {
                throw new IllegalStateException("Our named container provider is missing!");
            }
            return true;
        }
        return super.onBlockActivated(state, world, pos, player, hand, result);
    }

    public static Direction getFacingFromEntity(BlockPos clickedBlock, LivingEntity entity) {
        return Direction.getFacingFromVector((float) (entity.posX - clickedBlock.getX()), (float) (entity.posY - clickedBlock.getY()), (float) (entity.posZ - clickedBlock.getZ()));
    }

    protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
        builder.add(BlockStateProperties.WATERLOGGED, BlockStateProperties.FACING);
    }

    @Override
    @Deprecated
    public BlockRenderLayer getRenderLayer() {
        return BlockRenderLayer.CUTOUT;
    }

    public IFluidState getFluidState(BlockState state) {
        return Fluids.WATER.getStillFluidState(false);
    }

    public boolean receiveFluid(IWorld worldIn, BlockPos pos, BlockState state, IFluidState fluidStateIn) {
        return IWaterLoggable.super.receiveFluid(worldIn, pos, state, fluidStateIn);
    }

    public boolean canContainFluid(IBlockReader worldIn, BlockPos pos, BlockState state, Fluid fluidIn) {
        return true;//state.get(TYPE) != SlabType.DOUBLE ? IWaterLoggable.super.canContainFluid(worldIn, pos, state, fluidIn) : false;
    }

    @Deprecated
    public BlockState updatePostPlacement(BlockState stateIn, Direction facing, BlockState facingState, IWorld worldIn, BlockPos currentPos, BlockPos facingPos) {
        if (!stateIn.get(BlockStateProperties.WATERLOGGED)) {
            this.receiveFluid(worldIn, currentPos, stateIn, Fluids.WATER.getStillFluidState(false));
        }
        worldIn.getPendingFluidTicks().scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickRate(worldIn));
        return super.updatePostPlacement(stateIn, facing, facingState, worldIn, currentPos, facingPos);
    }
    @Override
    public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
        return VoxelShapes.create(blocksize);
    }

    public void onBlockAdded(BlockState state, World worldIn, BlockPos pos, BlockState oldState, boolean isMoving) {
        worldIn.getPendingFluidTicks().scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(worldIn));
    }

    public Fluid pickupFluid(IWorld worldIn, BlockPos pos, BlockState state) {
        return Fluids.EMPTY;
    }

   /*@Override
   @Deprecated
   public boolean isReplaceable(BlockState state, BlockItemUseContext useContext) {
      return true;
   }*/
}

 

Edited by MrNoodles75

1) What does the log say about the error?

2) Looks like you just copied my entire class without regards to what I said regarding what I was using it for that is entirely non-standard.

3) You haven't shown your registration code.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

  • Author
1 hour ago, Draco18s said:

1) What does the log say about the error?

2) Looks like you just copied my entire class without regards to what I said regarding what I was using it for that is entirely non-standard.

3) You haven't shown your registration code.

@Draco18s

 

1) I don't know I didn't check, sorry

2) Yes, I did because you said just add it your blockstatecontainer but in your class that you showed and from what I could find from vanilla classes is that they all had stuff like onBlockActivated, canContainFluid and updatePostPlacement and I became unsure.

3) if you mean setRegistryName then I saw that and I added it and now it works and the game opens. and I may seem stupid scince I don't know if you said this already so I'll say sorry in advance, but now it's always waterlogged.

Edited by MrNoodles75

2 hours ago, MrNoodles75 said:

2) Yes, I did because you said just add it your blockstatecontainer but in your class that you showed and from what I could find from vanilla classes is that they all had stuff like onBlockActivated, canContainFluid and updatePostPlacement and I became unsure.

Look at the vanilla blocks for standard implementation.

 

2 hours ago, MrNoodles75 said:

but now it's always waterlogged.

...yes:

6 hours ago, Draco18s said:

my block there is always waterlogged

 

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.