WeatheringCopperGolemStatueBlock .java

net.minecraft.world.level.block.WeatheringCopperGolemStatueBlock (class): members: getAge, useItemOn, isRandomlyTicking, hand, itemStack, randomTick, pos.

net.minecraft.world.level.blockclass72 linescommonextends CopperGolemStatueBlock2.4 KB

Implements

API Surface (4)

boolean isRandomlyTicking(final BlockState state)
void randomTick(final BlockState state, final ServerLevel level, final BlockPos pos, final RandomSource random)
WeatheringCopper.WeatherState getAge()
InteractionResult useItemOn(final ItemStack itemStack, final BlockState state, final Level level, final BlockPos pos, final Player player, final InteractionHand hand, final BlockHitResult hitResult)

Fields & Constants (6)

itemStack
state
level
pos
player
hand

Full Source

WeatheringCopperGolemStatueBlock.java72 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.level.block;
2
3
import net.minecraft.core.BlockPos;
4
import net.minecraft.server.level.ServerLevel;
5
import net.minecraft.tags.ItemTags;
6
import net.minecraft.util.RandomSource;
7
import net.minecraft.world.InteractionHand;
8
import net.minecraft.world.InteractionResult;
9
import net.minecraft.world.entity.animal.golem.CopperGolem;
10
import net.minecraft.world.entity.player.Player;
11
import net.minecraft.world.item.ItemStack;
12
import net.minecraft.world.item.Items;
13
import net.minecraft.world.level.Level;
14
import net.minecraft.world.level.block.entity.CopperGolemStatueBlockEntity;
15
import net.minecraft.world.level.block.state.BlockBehaviour;
16
import net.minecraft.world.level.block.state.BlockState;
17
import net.minecraft.world.phys.BlockHitResult;
18
19
public class WeatheringCopperGolemStatueBlock extends CopperGolemStatueBlock implements WeatheringCopper {
20
	public WeatheringCopperGolemStatueBlock(final WeatheringCopper.WeatherState weatherState, final BlockBehaviour.Properties properties) {
21
		super(weatherState, properties);
22
	}
23
24
	@Override
25
	protected boolean isRandomlyTicking(final BlockState state) {
26
		return WeatheringCopper.getNext(state.getBlock()).isPresent();
27
	}
28
29
	@Override
30
	protected void randomTick(final BlockState state, final ServerLevel level, final BlockPos pos, final RandomSource random) {
31
		this.changeOverTime(state, level, pos, random);
32
	}
33
34
	public WeatheringCopper.WeatherState getAge() {
35
		return this.getWeatheringState();
36
	}
37
38
	@Override
39
	protected InteractionResult useItemOn(
40
		final ItemStack itemStack,
41
		final BlockState state,
42
		final Level level,
43
		final BlockPos pos,
44
		final Player player,
45
		final InteractionHand hand,
46
		final BlockHitResult hitResult
47
	) {
48
		if (level.getBlockEntity(pos) instanceof CopperGolemStatueBlockEntity copperGolemStatueBlockEntity) {
49
			if (!itemStack.is(ItemTags.AXES)) {
50
				if (itemStack.is(Items.HONEYCOMB)) {
51
					return InteractionResult.PASS;
52
				}
53
54
				this.updatePose(level, state, pos, player);
55
				return InteractionResult.SUCCESS;
56
			}
57
58
			if (this.getAge().equals(WeatheringCopper.WeatherState.UNAFFECTED)) {
59
				CopperGolem copperGolem = copperGolemStatueBlockEntity.removeStatue(state);
60
				itemStack.hurtAndBreak(1, player, hand.asEquipmentSlot());
61
				if (copperGolem != null) {
62
					level.addFreshEntity(copperGolem);
63
					level.removeBlock(pos, false);
64
					return InteractionResult.SUCCESS;
65
				}
66
			}
67
		}
68
69
		return InteractionResult.PASS;
70
	}
71
}
72

Decompiled Minecraft 26.3 source of WeatheringCopperGolemStatueBlock (net/minecraft/world/level/block/WeatheringCopperGolemStatueBlock.java) with Mojang official mappings, stored verbatim on the site.