2022-09-23 23:25:00 +02:00
|
|
|
package com.minelittlepony.unicopia.block;
|
|
|
|
|
|
|
|
import com.minelittlepony.unicopia.entity.player.Pony;
|
|
|
|
|
|
|
|
import net.minecraft.block.*;
|
|
|
|
import net.minecraft.entity.player.PlayerEntity;
|
2022-09-25 00:14:29 +02:00
|
|
|
import net.minecraft.item.ItemPlacementContext;
|
2022-09-23 23:25:00 +02:00
|
|
|
import net.minecraft.sound.BlockSoundGroup;
|
2022-09-25 00:14:29 +02:00
|
|
|
import net.minecraft.state.StateManager;
|
|
|
|
import net.minecraft.state.property.BooleanProperty;
|
2022-09-23 23:25:00 +02:00
|
|
|
import net.minecraft.util.math.*;
|
|
|
|
import net.minecraft.world.BlockView;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
|
|
|
public class ZapAppleLogBlock extends PillarBlock {
|
2023-05-25 12:56:42 +02:00
|
|
|
public static final BooleanProperty NATURAL = ZapBlock.NATURAL;
|
2022-09-25 00:14:29 +02:00
|
|
|
|
|
|
|
private final Block artifialModelBlock;
|
|
|
|
|
|
|
|
ZapAppleLogBlock(Block artifialModelBlock, MapColor topMapColor, MapColor sideMapColor) {
|
|
|
|
super(AbstractBlock.Settings.of(Material.WOOD,
|
|
|
|
state -> state.get(PillarBlock.AXIS) == Direction.Axis.Y ? topMapColor : sideMapColor
|
|
|
|
)
|
|
|
|
.sounds(BlockSoundGroup.WOOD)
|
|
|
|
.strength(500, 1200));
|
|
|
|
setDefaultState(getDefaultState().with(NATURAL, true));
|
|
|
|
this.artifialModelBlock = artifialModelBlock;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
|
|
|
super.appendProperties(builder);
|
|
|
|
builder.add(NATURAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public BlockState getPlacementState(ItemPlacementContext ctx) {
|
|
|
|
return getDefaultState().with(NATURAL, false);
|
2022-09-23 23:25:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Deprecated
|
|
|
|
@Override
|
|
|
|
public void onBlockBreakStart(BlockState state, World world, BlockPos pos, PlayerEntity player) {
|
2022-09-25 00:14:29 +02:00
|
|
|
ZapBlock.triggerLightning(state, world, pos, player);
|
2022-09-23 23:25:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Deprecated
|
|
|
|
@Override
|
|
|
|
public float calcBlockBreakingDelta(BlockState state, PlayerEntity player, BlockView world, BlockPos pos) {
|
2022-09-25 00:14:29 +02:00
|
|
|
if (!state.get(NATURAL)) {
|
|
|
|
return artifialModelBlock.calcBlockBreakingDelta(artifialModelBlock.getDefaultState(), player, world, pos);
|
|
|
|
}
|
|
|
|
|
2022-09-23 23:25:00 +02:00
|
|
|
float delta = super.calcBlockBreakingDelta(state, player, world, pos);
|
|
|
|
|
|
|
|
if (Pony.of(player).getSpecies().canUseEarth()) {
|
|
|
|
delta *= 50;
|
|
|
|
}
|
|
|
|
|
|
|
|
return MathHelper.clamp(delta, 0, 0.9F);
|
|
|
|
}
|
|
|
|
}
|