Continue mapping migration

This commit is contained in:
Aleksey 2021-04-12 21:38:22 +03:00
parent 99ade39404
commit f03fd03bd0
499 changed files with 12567 additions and 12723 deletions

View file

@ -5,26 +5,26 @@ import java.util.List;
import java.util.Random;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.world.level.block.BarrelBlock;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.BlockRenderType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.mob.PiglinBrain;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.stat.Stats;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.stats.Stats;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.monster.piglin.PiglinAi;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.BarrelBlock;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.RenderShape;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.phys.BlockHitResult;
import ru.betterend.blocks.entities.EBarrelBlockEntity;
import ru.betterend.patterns.BlockPatterned;
import ru.betterend.patterns.Patterns;
@ -32,12 +32,12 @@ import ru.betterend.registry.EndBlockEntities;
public class EndBarrelBlock extends BarrelBlock implements BlockPatterned {
public EndBarrelBlock(Block source) {
super(FabricBlockSettings.copyOf(source).nonOpaque());
super(FabricBlockSettings.copyOf(source).noOcclusion());
}
@Override
public BlockEntity createBlockEntity(BlockView world) {
return EndBlockEntities.BARREL.instantiate();
public BlockEntity newBlockEntity(BlockGetter world) {
return EndBlockEntities.BARREL.create();
}
@Override
@ -48,24 +48,24 @@ public class EndBarrelBlock extends BarrelBlock implements BlockPatterned {
}
@Override
public ActionResult onUse(BlockState state, Level world, BlockPos pos, Player player, Hand hand,
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand,
BlockHitResult hit) {
if (world.isClientSide) {
return ActionResult.SUCCESS;
return InteractionResult.SUCCESS;
} else {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity instanceof EBarrelBlockEntity) {
player.openHandledScreen((EBarrelBlockEntity) blockEntity);
player.incrementStat(Stats.OPEN_BARREL);
PiglinBrain.onGuardedBlockInteracted(player, true);
player.openMenu((EBarrelBlockEntity) blockEntity);
player.awardStat(Stats.OPEN_BARREL);
PiglinAi.angerNearbyPiglins(player, true);
}
return ActionResult.CONSUME;
return InteractionResult.CONSUME;
}
}
@Override
public void scheduledTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
public void tick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity instanceof EBarrelBlockEntity) {
((EBarrelBlockEntity) blockEntity).tick();
@ -73,26 +73,27 @@ public class EndBarrelBlock extends BarrelBlock implements BlockPatterned {
}
@Override
public BlockRenderType getRenderType(BlockState state) {
return BlockRenderType.MODEL;
public RenderShape getRenderShape(BlockState state) {
return RenderShape.MODEL;
}
@Override
public void onPlaced(Level world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack itemStack) {
if (itemStack.hasCustomName()) {
public void setPlacedBy(Level world, BlockPos pos, BlockState state, LivingEntity placer,
ItemStack itemStack) {
if (itemStack.hasCustomHoverName()) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity instanceof EBarrelBlockEntity) {
((EBarrelBlockEntity) blockEntity).setCustomName(itemStack.getName());
((EBarrelBlockEntity) blockEntity).setCustomName(itemStack.getHoverName());
}
}
}
@Override
public String getStatesPattern(Reader data) {
String block = Registry.BLOCK.getKey(this).getPath();
return Patterns.createJson(data, block, block);
}
@Override
public String getModelPattern(String block) {
String texture = Registry.BLOCK.getKey(this).getPath();
@ -101,7 +102,7 @@ public class EndBarrelBlock extends BarrelBlock implements BlockPatterned {
}
return Patterns.createJson(Patterns.BLOCK_BOTTOM_TOP, texture, texture);
}
@Override
public ResourceLocation statePatternId() {
return Patterns.STATE_BARREL;