2020-10-17 21:13:45 +02:00
|
|
|
package de.ellpeck.naturesaura.blocks;
|
|
|
|
|
2021-12-04 15:40:09 +01:00
|
|
|
import de.ellpeck.naturesaura.blocks.tiles.BlockEntitySpring;
|
2020-10-17 21:13:45 +02:00
|
|
|
import de.ellpeck.naturesaura.data.BlockStateGenerator;
|
|
|
|
import de.ellpeck.naturesaura.reg.IColorProvidingBlock;
|
|
|
|
import de.ellpeck.naturesaura.reg.IColorProvidingItem;
|
|
|
|
import de.ellpeck.naturesaura.reg.ICustomBlockState;
|
|
|
|
import de.ellpeck.naturesaura.reg.ICustomRenderType;
|
|
|
|
import net.minecraft.client.Minecraft;
|
2021-12-15 16:24:53 +01:00
|
|
|
import net.minecraft.client.color.block.BlockColor;
|
|
|
|
import net.minecraft.client.color.item.ItemColor;
|
|
|
|
import net.minecraft.client.renderer.BiomeColors;
|
2020-10-17 21:13:45 +02:00
|
|
|
import net.minecraft.client.renderer.RenderType;
|
2021-12-15 16:24:53 +01:00
|
|
|
import net.minecraft.core.BlockPos;
|
|
|
|
import net.minecraft.sounds.SoundEvent;
|
|
|
|
import net.minecraft.world.entity.player.Player;
|
|
|
|
import net.minecraft.world.item.ItemStack;
|
|
|
|
import net.minecraft.world.item.Items;
|
|
|
|
import net.minecraft.world.level.LevelAccessor;
|
|
|
|
import net.minecraft.world.level.block.Blocks;
|
|
|
|
import net.minecraft.world.level.block.BucketPickup;
|
|
|
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
|
|
|
import net.minecraft.world.level.block.state.BlockState;
|
|
|
|
import net.minecraft.world.level.material.Fluids;
|
2020-10-17 21:13:45 +02:00
|
|
|
import net.minecraftforge.api.distmarker.Dist;
|
|
|
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
|
|
|
|
2021-12-15 16:24:53 +01:00
|
|
|
import java.util.Optional;
|
2020-10-17 21:13:45 +02:00
|
|
|
import java.util.function.Supplier;
|
|
|
|
|
2021-12-15 16:24:53 +01:00
|
|
|
public class BlockSpring extends BlockContainerImpl implements ICustomBlockState, IColorProvidingBlock, IColorProvidingItem, BucketPickup, ICustomRenderType {
|
|
|
|
|
2020-10-17 21:13:45 +02:00
|
|
|
public BlockSpring() {
|
2021-12-15 16:24:53 +01:00
|
|
|
super("spring", BlockEntitySpring::new, Properties.copy(Blocks.STONE_BRICKS));
|
2020-10-17 21:13:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@OnlyIn(Dist.CLIENT)
|
2021-12-15 16:24:53 +01:00
|
|
|
public BlockColor getBlockColor() {
|
|
|
|
return (state, level, pos, i) -> BiomeColors.getAverageWaterColor(level, pos);
|
2020-10-17 21:13:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@OnlyIn(Dist.CLIENT)
|
|
|
|
@SuppressWarnings("Convert2Lambda")
|
2021-12-15 16:24:53 +01:00
|
|
|
public ItemColor getItemColor() {
|
|
|
|
return new ItemColor() {
|
2020-10-17 21:13:45 +02:00
|
|
|
@Override
|
|
|
|
public int getColor(ItemStack stack, int i) {
|
2021-12-04 15:40:09 +01:00
|
|
|
Player player = Minecraft.getInstance().player;
|
2021-12-15 16:24:53 +01:00
|
|
|
return BiomeColors.getAverageWaterColor(player.level, player.blockPosition());
|
2020-10-17 21:13:45 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void generateCustomBlockState(BlockStateGenerator generator) {
|
|
|
|
generator.simpleBlock(this, generator.models().getExistingFile(generator.modLoc(this.getBaseName())));
|
|
|
|
}
|
|
|
|
|
2021-12-15 16:24:53 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public Supplier<RenderType> getRenderType() {
|
|
|
|
return RenderType::translucent;
|
|
|
|
}
|
|
|
|
|
2020-10-17 21:13:45 +02:00
|
|
|
@Override
|
2021-12-15 16:24:53 +01:00
|
|
|
public ItemStack pickupBlock(LevelAccessor levelIn, BlockPos pos, BlockState state) {
|
2021-12-04 15:40:09 +01:00
|
|
|
BlockEntity tile = levelIn.getBlockEntity(pos);
|
|
|
|
if (tile instanceof BlockEntitySpring)
|
|
|
|
((BlockEntitySpring) tile).consumeAura(2500);
|
2021-12-15 16:24:53 +01:00
|
|
|
return new ItemStack(Items.WATER_BUCKET); }
|
2020-10-17 21:13:45 +02:00
|
|
|
|
|
|
|
@Override
|
2021-12-15 16:24:53 +01:00
|
|
|
public Optional<SoundEvent> getPickupSound() {
|
|
|
|
return Fluids.WATER.getPickupSound();
|
2020-10-17 21:13:45 +02:00
|
|
|
}
|
|
|
|
}
|