Merge and fix
This commit is contained in:
parent
b91c85529d
commit
ce9f4add97
548 changed files with 17517 additions and 16862 deletions
|
@ -1,28 +1,28 @@
|
|||
package ru.betterend.blocks;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.block.MaterialColor;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.BlockView;
|
||||
import ru.betterend.blocks.basis.BlockBase;
|
||||
|
||||
public class AeterniumBlock extends BlockBase {
|
||||
|
||||
public AeterniumBlock() {
|
||||
super(FabricBlockSettings.of(Material.METAL, MaterialColor.GRAY)
|
||||
.hardness(65F)
|
||||
.resistance(1200F)
|
||||
.requiresTool()
|
||||
.sounds(BlockSoundGroup.NETHERITE));
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public int getColor(BlockState state, BlockView world, BlockPos pos) {
|
||||
return 0xFF657A7A;
|
||||
}
|
||||
}
|
||||
package ru.betterend.blocks;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.block.MaterialColor;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.BlockView;
|
||||
import ru.betterend.blocks.basis.BlockBase;
|
||||
|
||||
public class AeterniumBlock extends BlockBase {
|
||||
|
||||
public AeterniumBlock() {
|
||||
super(FabricBlockSettings.of(Material.METAL, MaterialColor.GRAY)
|
||||
.hardness(65F)
|
||||
.resistance(1200F)
|
||||
.requiresTool()
|
||||
.sounds(BlockSoundGroup.NETHERITE));
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public int getColor(BlockState state, BlockView world, BlockPos pos) {
|
||||
return 0xFF657A7A;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
package ru.betterend.blocks;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.MaterialColor;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
import ru.betterend.blocks.basis.BlockBase;
|
||||
|
||||
public class BlockStone extends BlockBase {
|
||||
|
||||
public BlockStone(MaterialColor color) {
|
||||
super(FabricBlockSettings.copyOf(Blocks.END_STONE).materialColor(color).sounds(BlockSoundGroup.STONE));
|
||||
}
|
||||
}
|
||||
package ru.betterend.blocks;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.MaterialColor;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
import ru.betterend.blocks.basis.BlockBase;
|
||||
|
||||
public class BlockStone extends BlockBase {
|
||||
|
||||
public BlockStone(MaterialColor color) {
|
||||
super(FabricBlockSettings.copyOf(Blocks.END_STONE).materialColor(color).sounds(BlockSoundGroup.STONE));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,119 +1,119 @@
|
|||
package ru.betterend.blocks;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.NetherPortalBlock;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import ru.betterend.client.render.ERenderLayer;
|
||||
import ru.betterend.interfaces.IRenderTypeable;
|
||||
import ru.betterend.interfaces.TeleportingEntity;
|
||||
import ru.betterend.registry.EndParticles;
|
||||
|
||||
public class EndPortalBlock extends NetherPortalBlock implements IRenderTypeable {
|
||||
public EndPortalBlock() {
|
||||
super(FabricBlockSettings.copyOf(Blocks.NETHER_PORTAL).resistance(Blocks.BEDROCK.getBlastResistance()).luminance(state -> {
|
||||
return 12;
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) {
|
||||
if (random.nextInt(100) == 0) {
|
||||
world.playSound(pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, SoundEvents.BLOCK_PORTAL_AMBIENT, SoundCategory.BLOCKS, 0.5F, random.nextFloat() * 0.4F + 0.8F, false);
|
||||
}
|
||||
|
||||
double x = pos.getX() + random.nextDouble();
|
||||
double y = pos.getY() + random.nextDouble();
|
||||
double z = pos.getZ() + random.nextDouble();
|
||||
int k = random.nextInt(2) * 2 - 1;
|
||||
if (!world.getBlockState(pos.west()).isOf(this) && !world.getBlockState(pos.east()).isOf(this)) {
|
||||
x = pos.getX() + 0.5D + 0.25D * k;
|
||||
} else {
|
||||
z = pos.getZ() + 0.5D + 0.25D * k;
|
||||
}
|
||||
|
||||
world.addParticle(EndParticles.PORTAL_SPHERE, x, y, z, 0, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState newState, WorldAccess world, BlockPos pos, BlockPos posFrom) {
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) {
|
||||
if (world instanceof ServerWorld && !entity.hasVehicle() && !entity.hasPassengers() && entity.canUsePortals()) {
|
||||
TeleportingEntity teleEntity = TeleportingEntity.class.cast(entity);
|
||||
if (teleEntity.hasCooldown()) return;
|
||||
boolean isOverworld = world.getRegistryKey().equals(World.OVERWORLD);
|
||||
ServerWorld destination = ((ServerWorld) world).getServer().getWorld(isOverworld ? World.END : World.OVERWORLD);
|
||||
BlockPos exitPos = this.findExitPos(destination, pos, entity);
|
||||
if (exitPos == null) return;
|
||||
if (entity instanceof ServerPlayerEntity) {
|
||||
ServerPlayerEntity player = (ServerPlayerEntity) entity;
|
||||
player.teleport(destination, exitPos.getX(), exitPos.getY(), exitPos.getZ(), entity.yaw, entity.pitch);
|
||||
teleEntity.beSetCooldown(player.isCreative() ? 50 : 300);
|
||||
} else {
|
||||
teleEntity.beSetExitPos(exitPos);
|
||||
entity.moveToWorld(destination);
|
||||
teleEntity.beSetCooldown(300);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ERenderLayer getRenderLayer() {
|
||||
return ERenderLayer.TRANSLUCENT;
|
||||
}
|
||||
|
||||
private BlockPos findExitPos(ServerWorld world, BlockPos pos, Entity entity) {
|
||||
Registry<DimensionType> registry = world.getRegistryManager().getDimensionTypes();
|
||||
double mult = registry.get(DimensionType.THE_END_ID).getCoordinateScale();
|
||||
BlockPos.Mutable basePos;
|
||||
if (world.getRegistryKey().equals(World.OVERWORLD)) {
|
||||
basePos = pos.mutableCopy().set(pos.getX() / mult, pos.getY(), pos.getZ() / mult);
|
||||
} else {
|
||||
basePos = pos.mutableCopy().set(pos.getX() * mult, pos.getY(), pos.getZ() * mult);
|
||||
}
|
||||
Direction direction = Direction.EAST;
|
||||
BlockPos.Mutable checkPos = basePos.mutableCopy();
|
||||
for (int step = 1; step < 64; step++) {
|
||||
for (int i = 0; i < step; i++) {
|
||||
checkPos.setY(5);
|
||||
while(checkPos.getY() < world.getHeight()) {
|
||||
BlockState state = world.getBlockState(checkPos);
|
||||
if(state.isOf(this)) {
|
||||
if (state.get(AXIS).equals(Direction.Axis.X)) {
|
||||
return checkPos.add(0, 0, 1);
|
||||
} else {
|
||||
return checkPos.add(1, 0, 0);
|
||||
}
|
||||
}
|
||||
checkPos.move(Direction.UP);
|
||||
}
|
||||
checkPos.move(direction);
|
||||
}
|
||||
direction = direction.rotateYClockwise();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
package ru.betterend.blocks;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.NetherPortalBlock;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import ru.betterend.client.render.ERenderLayer;
|
||||
import ru.betterend.interfaces.IRenderTypeable;
|
||||
import ru.betterend.interfaces.TeleportingEntity;
|
||||
import ru.betterend.registry.EndParticles;
|
||||
|
||||
public class EndPortalBlock extends NetherPortalBlock implements IRenderTypeable {
|
||||
public EndPortalBlock() {
|
||||
super(FabricBlockSettings.copyOf(Blocks.NETHER_PORTAL).resistance(Blocks.BEDROCK.getBlastResistance()).luminance(state -> {
|
||||
return 12;
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) {
|
||||
if (random.nextInt(100) == 0) {
|
||||
world.playSound(pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, SoundEvents.BLOCK_PORTAL_AMBIENT, SoundCategory.BLOCKS, 0.5F, random.nextFloat() * 0.4F + 0.8F, false);
|
||||
}
|
||||
|
||||
double x = pos.getX() + random.nextDouble();
|
||||
double y = pos.getY() + random.nextDouble();
|
||||
double z = pos.getZ() + random.nextDouble();
|
||||
int k = random.nextInt(2) * 2 - 1;
|
||||
if (!world.getBlockState(pos.west()).isOf(this) && !world.getBlockState(pos.east()).isOf(this)) {
|
||||
x = pos.getX() + 0.5D + 0.25D * k;
|
||||
} else {
|
||||
z = pos.getZ() + 0.5D + 0.25D * k;
|
||||
}
|
||||
|
||||
world.addParticle(EndParticles.PORTAL_SPHERE, x, y, z, 0, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState newState, WorldAccess world, BlockPos pos, BlockPos posFrom) {
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) {
|
||||
if (world instanceof ServerWorld && !entity.hasVehicle() && !entity.hasPassengers() && entity.canUsePortals()) {
|
||||
TeleportingEntity teleEntity = TeleportingEntity.class.cast(entity);
|
||||
if (teleEntity.hasCooldown()) return;
|
||||
boolean isOverworld = world.getRegistryKey().equals(World.OVERWORLD);
|
||||
ServerWorld destination = ((ServerWorld) world).getServer().getWorld(isOverworld ? World.END : World.OVERWORLD);
|
||||
BlockPos exitPos = this.findExitPos(destination, pos, entity);
|
||||
if (exitPos == null) return;
|
||||
if (entity instanceof ServerPlayerEntity) {
|
||||
ServerPlayerEntity player = (ServerPlayerEntity) entity;
|
||||
player.teleport(destination, exitPos.getX(), exitPos.getY(), exitPos.getZ(), entity.yaw, entity.pitch);
|
||||
teleEntity.beSetCooldown(player.isCreative() ? 50 : 300);
|
||||
} else {
|
||||
teleEntity.beSetExitPos(exitPos);
|
||||
entity.moveToWorld(destination);
|
||||
teleEntity.beSetCooldown(300);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ERenderLayer getRenderLayer() {
|
||||
return ERenderLayer.TRANSLUCENT;
|
||||
}
|
||||
|
||||
private BlockPos findExitPos(ServerWorld world, BlockPos pos, Entity entity) {
|
||||
Registry<DimensionType> registry = world.getRegistryManager().getDimensionTypes();
|
||||
double mult = registry.get(DimensionType.THE_END_ID).getCoordinateScale();
|
||||
BlockPos.Mutable basePos;
|
||||
if (world.getRegistryKey().equals(World.OVERWORLD)) {
|
||||
basePos = pos.mutableCopy().set(pos.getX() / mult, pos.getY(), pos.getZ() / mult);
|
||||
} else {
|
||||
basePos = pos.mutableCopy().set(pos.getX() * mult, pos.getY(), pos.getZ() * mult);
|
||||
}
|
||||
Direction direction = Direction.EAST;
|
||||
BlockPos.Mutable checkPos = basePos.mutableCopy();
|
||||
for (int step = 1; step < 64; step++) {
|
||||
for (int i = 0; i < step; i++) {
|
||||
checkPos.setY(5);
|
||||
while(checkPos.getY() < world.getHeight()) {
|
||||
BlockState state = world.getBlockState(checkPos);
|
||||
if(state.isOf(this)) {
|
||||
if (state.get(AXIS).equals(Direction.Axis.X)) {
|
||||
return checkPos.add(0, 0, 1);
|
||||
} else {
|
||||
return checkPos.add(1, 0, 0);
|
||||
}
|
||||
}
|
||||
checkPos.move(Direction.UP);
|
||||
}
|
||||
checkPos.move(direction);
|
||||
}
|
||||
direction = direction.rotateYClockwise();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,140 +1,140 @@
|
|||
package ru.betterend.blocks;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.HorizontalFacingBlock;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.block.MaterialColor;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemPlacementContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.context.LootContext;
|
||||
import net.minecraft.particle.ParticleTypes;
|
||||
import net.minecraft.screen.NamedScreenHandlerFactory;
|
||||
import net.minecraft.screen.ScreenHandler;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.state.property.BooleanProperty;
|
||||
import net.minecraft.state.property.DirectionProperty;
|
||||
import net.minecraft.state.property.Properties;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.BlockMirror;
|
||||
import net.minecraft.util.BlockRotation;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.World;
|
||||
import ru.betterend.blocks.basis.BaseBlockWithEntity;
|
||||
import ru.betterend.blocks.entities.EndStoneSmelterBlockEntity;
|
||||
|
||||
public class EndStoneSmelter extends BaseBlockWithEntity {
|
||||
public static final DirectionProperty FACING = HorizontalFacingBlock.FACING;
|
||||
public static final BooleanProperty LIT = Properties.LIT;
|
||||
public static final String ID = "end_stone_smelter";
|
||||
|
||||
public EndStoneSmelter() {
|
||||
super(FabricBlockSettings.of(Material.STONE, MaterialColor.GRAY)
|
||||
.hardness(4F)
|
||||
.resistance(100F)
|
||||
.requiresTool()
|
||||
.sounds(BlockSoundGroup.STONE));
|
||||
this.setDefaultState(this.stateManager.getDefaultState()
|
||||
.with(FACING, Direction.NORTH)
|
||||
.with(LIT, false));
|
||||
}
|
||||
|
||||
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
|
||||
if (world.isClient) {
|
||||
return ActionResult.SUCCESS;
|
||||
} else {
|
||||
this.openScreen(world, pos, player);
|
||||
return ActionResult.CONSUME;
|
||||
}
|
||||
}
|
||||
|
||||
private void openScreen(World world, BlockPos pos, PlayerEntity player) {
|
||||
BlockEntity blockEntity = world.getBlockEntity(pos);
|
||||
if (blockEntity instanceof EndStoneSmelterBlockEntity) {
|
||||
player.openHandledScreen((NamedScreenHandlerFactory) blockEntity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getPlacementState(ItemPlacementContext ctx) {
|
||||
return this.getDefaultState().with(FACING, ctx.getPlayerFacing().getOpposite());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createBlockEntity(BlockView world) {
|
||||
return new EndStoneSmelterBlockEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
||||
return Collections.singletonList(new ItemStack(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasComparatorOutput(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorOutput(BlockState state, World world, BlockPos pos) {
|
||||
//TODO
|
||||
return ScreenHandler.calculateComparatorOutput(world.getBlockEntity(pos));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state) {
|
||||
return BlockRenderType.MODEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState rotate(BlockState state, BlockRotation rotation) {
|
||||
return (BlockState)state.with(FACING, rotation.rotate((Direction)state.get(FACING)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState mirror(BlockState state, BlockMirror mirror) {
|
||||
return state.rotate(mirror.getRotation((Direction)state.get(FACING)));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
||||
builder.add(FACING, LIT);
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) {
|
||||
if (state.get(LIT)) {
|
||||
double x = pos.getX() + 0.5D;
|
||||
double y = pos.getY();
|
||||
double z = pos.getZ() + 0.5D;
|
||||
if (random.nextDouble() < 0.1D) {
|
||||
world.playSound(x, y, z, SoundEvents.BLOCK_BLASTFURNACE_FIRE_CRACKLE, SoundCategory.BLOCKS, 1.0F, 1.0F, false);
|
||||
}
|
||||
|
||||
Direction direction = (Direction)state.get(FACING);
|
||||
Direction.Axis axis = direction.getAxis();
|
||||
double defOffset = random.nextDouble() * 0.6D - 0.3D;
|
||||
double offX = axis == Direction.Axis.X ? direction.getOffsetX() * 0.52D : defOffset;
|
||||
double offY = random.nextDouble() * 9.0D / 16.0D;
|
||||
double offZ = axis == Direction.Axis.Z ? direction.getOffsetZ() * 0.52D : defOffset;
|
||||
world.addParticle(ParticleTypes.SMOKE, x + offX, y + offY, z + offZ, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
}
|
||||
package ru.betterend.blocks;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.HorizontalFacingBlock;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.block.MaterialColor;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemPlacementContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.context.LootContext;
|
||||
import net.minecraft.particle.ParticleTypes;
|
||||
import net.minecraft.screen.NamedScreenHandlerFactory;
|
||||
import net.minecraft.screen.ScreenHandler;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.state.property.BooleanProperty;
|
||||
import net.minecraft.state.property.DirectionProperty;
|
||||
import net.minecraft.state.property.Properties;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.BlockMirror;
|
||||
import net.minecraft.util.BlockRotation;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.World;
|
||||
import ru.betterend.blocks.basis.BaseBlockWithEntity;
|
||||
import ru.betterend.blocks.entities.EndStoneSmelterBlockEntity;
|
||||
|
||||
public class EndStoneSmelter extends BaseBlockWithEntity {
|
||||
public static final DirectionProperty FACING = HorizontalFacingBlock.FACING;
|
||||
public static final BooleanProperty LIT = Properties.LIT;
|
||||
public static final String ID = "end_stone_smelter";
|
||||
|
||||
public EndStoneSmelter() {
|
||||
super(FabricBlockSettings.of(Material.STONE, MaterialColor.GRAY)
|
||||
.hardness(4F)
|
||||
.resistance(100F)
|
||||
.requiresTool()
|
||||
.sounds(BlockSoundGroup.STONE));
|
||||
this.setDefaultState(this.stateManager.getDefaultState()
|
||||
.with(FACING, Direction.NORTH)
|
||||
.with(LIT, false));
|
||||
}
|
||||
|
||||
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
|
||||
if (world.isClient) {
|
||||
return ActionResult.SUCCESS;
|
||||
} else {
|
||||
this.openScreen(world, pos, player);
|
||||
return ActionResult.CONSUME;
|
||||
}
|
||||
}
|
||||
|
||||
private void openScreen(World world, BlockPos pos, PlayerEntity player) {
|
||||
BlockEntity blockEntity = world.getBlockEntity(pos);
|
||||
if (blockEntity instanceof EndStoneSmelterBlockEntity) {
|
||||
player.openHandledScreen((NamedScreenHandlerFactory) blockEntity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getPlacementState(ItemPlacementContext ctx) {
|
||||
return this.getDefaultState().with(FACING, ctx.getPlayerFacing().getOpposite());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createBlockEntity(BlockView world) {
|
||||
return new EndStoneSmelterBlockEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
||||
return Collections.singletonList(new ItemStack(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasComparatorOutput(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorOutput(BlockState state, World world, BlockPos pos) {
|
||||
//TODO
|
||||
return ScreenHandler.calculateComparatorOutput(world.getBlockEntity(pos));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state) {
|
||||
return BlockRenderType.MODEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState rotate(BlockState state, BlockRotation rotation) {
|
||||
return (BlockState)state.with(FACING, rotation.rotate((Direction)state.get(FACING)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState mirror(BlockState state, BlockMirror mirror) {
|
||||
return state.rotate(mirror.getRotation((Direction)state.get(FACING)));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
||||
builder.add(FACING, LIT);
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) {
|
||||
if (state.get(LIT)) {
|
||||
double x = pos.getX() + 0.5D;
|
||||
double y = pos.getY();
|
||||
double z = pos.getZ() + 0.5D;
|
||||
if (random.nextDouble() < 0.1D) {
|
||||
world.playSound(x, y, z, SoundEvents.BLOCK_BLASTFURNACE_FIRE_CRACKLE, SoundCategory.BLOCKS, 1.0F, 1.0F, false);
|
||||
}
|
||||
|
||||
Direction direction = (Direction)state.get(FACING);
|
||||
Direction.Axis axis = direction.getAxis();
|
||||
double defOffset = random.nextDouble() * 0.6D - 0.3D;
|
||||
double offX = axis == Direction.Axis.X ? direction.getOffsetX() * 0.52D : defOffset;
|
||||
double offY = random.nextDouble() * 9.0D / 16.0D;
|
||||
double offZ = axis == Direction.Axis.Z ? direction.getOffsetZ() * 0.52D : defOffset;
|
||||
world.addParticle(ParticleTypes.SMOKE, x + offX, y + offY, z + offZ, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
package ru.betterend.blocks;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.block.MaterialColor;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.BlockView;
|
||||
import ru.betterend.blocks.basis.BlockBase;
|
||||
|
||||
public class EnderBlock extends BlockBase {
|
||||
|
||||
public EnderBlock() {
|
||||
super(FabricBlockSettings.of(Material.STONE, MaterialColor.field_25708)
|
||||
.hardness(5F)
|
||||
.resistance(6F)
|
||||
.requiresTool()
|
||||
.sounds(BlockSoundGroup.STONE));
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public int getColor(BlockState state, BlockView world, BlockPos pos) {
|
||||
return 0xFF005548;
|
||||
}
|
||||
}
|
||||
package ru.betterend.blocks;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.block.MaterialColor;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.BlockView;
|
||||
import ru.betterend.blocks.basis.BlockBase;
|
||||
|
||||
public class EnderBlock extends BlockBase {
|
||||
|
||||
public EnderBlock() {
|
||||
super(FabricBlockSettings.of(Material.STONE, MaterialColor.field_25708)
|
||||
.hardness(5F)
|
||||
.resistance(6F)
|
||||
.requiresTool()
|
||||
.sounds(BlockSoundGroup.STONE));
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public int getColor(BlockState state, BlockView world, BlockPos pos) {
|
||||
return 0xFF005548;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,125 +1,125 @@
|
|||
package ru.betterend.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.context.LootContext;
|
||||
import net.minecraft.loot.context.LootContextParameters;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.state.property.BooleanProperty;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
import net.minecraft.world.explosion.Explosion;
|
||||
import ru.betterend.blocks.basis.BlockPedestal;
|
||||
import ru.betterend.blocks.entities.EternalPedestalEntity;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
import ru.betterend.registry.EndItems;
|
||||
import ru.betterend.rituals.EternalRitual;
|
||||
|
||||
public class EternalPedestal extends BlockPedestal {
|
||||
public static final BooleanProperty ACTIVATED = BlockProperties.ACTIVATED;
|
||||
|
||||
public EternalPedestal() {
|
||||
super(EndBlocks.FLAVOLITE_RUNED_ETERNAL);
|
||||
this.setDefaultState(this.getDefaultState().with(ACTIVATED, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
|
||||
ActionResult result = super.onUse(state, world, pos, player, hand, hit);
|
||||
if (result.equals(ActionResult.SUCCESS)) {
|
||||
BlockEntity blockEntity = world.getBlockEntity(pos);
|
||||
if (blockEntity instanceof EternalPedestalEntity) {
|
||||
EternalPedestalEntity pedestal = (EternalPedestalEntity) blockEntity;
|
||||
BlockState updatedState = world.getBlockState(pos);
|
||||
if (pedestal.isEmpty() && updatedState.get(ACTIVATED)) {
|
||||
if (pedestal.hasRitual()) {
|
||||
EternalRitual ritual = pedestal.getRitual();
|
||||
ritual.removePortal();
|
||||
}
|
||||
world.setBlockState(pos, updatedState.with(ACTIVATED, false));
|
||||
} else {
|
||||
ItemStack itemStack = pedestal.getStack(0);
|
||||
if (itemStack.getItem() == EndItems.ETERNAL_CRYSTAL) {
|
||||
world.setBlockState(pos, updatedState.with(ACTIVATED, true));
|
||||
if (pedestal.hasRitual()) {
|
||||
pedestal.getRitual().checkStructure();
|
||||
} else {
|
||||
EternalRitual ritual = new EternalRitual(world, pos);
|
||||
ritual.checkStructure();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState newState, WorldAccess world, BlockPos pos, BlockPos posFrom) {
|
||||
BlockState updated = super.getStateForNeighborUpdate(state, direction, newState, world, pos, posFrom);
|
||||
if (!updated.isOf(this)) return updated;
|
||||
if (!this.isPlaceable(updated)) {
|
||||
return updated.with(ACTIVATED, false);
|
||||
}
|
||||
return updated;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float calcBlockBreakingDelta(BlockState state, PlayerEntity player, BlockView world, BlockPos pos) {
|
||||
return 0.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBlastResistance() {
|
||||
return Blocks.BEDROCK.getBlastResistance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldDropItemsOnExplosion(Explosion explosion) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
||||
if (state.isOf(this)) {
|
||||
BlockProperties.PedestalState currentState = state.get(BlockProperties.PEDESTAL_STATE);
|
||||
if (currentState.equals(BlockProperties.PedestalState.BOTTOM) || currentState.equals(BlockProperties.PedestalState.PILLAR)) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
}
|
||||
List<ItemStack> drop = Lists.newArrayList();
|
||||
BlockEntity blockEntity = builder.getNullable(LootContextParameters.BLOCK_ENTITY);
|
||||
if (blockEntity != null && blockEntity instanceof EternalPedestalEntity) {
|
||||
EternalPedestalEntity pedestal = (EternalPedestalEntity) blockEntity;
|
||||
if (!pedestal.isEmpty()) {
|
||||
drop.add(pedestal.getStack(0));
|
||||
}
|
||||
}
|
||||
return drop;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
|
||||
super.appendProperties(stateManager);
|
||||
stateManager.add(ACTIVATED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createBlockEntity(BlockView world) {
|
||||
return new EternalPedestalEntity();
|
||||
}
|
||||
}
|
||||
package ru.betterend.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.context.LootContext;
|
||||
import net.minecraft.loot.context.LootContextParameters;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.state.property.BooleanProperty;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
import net.minecraft.world.explosion.Explosion;
|
||||
import ru.betterend.blocks.basis.BlockPedestal;
|
||||
import ru.betterend.blocks.entities.EternalPedestalEntity;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
import ru.betterend.registry.EndItems;
|
||||
import ru.betterend.rituals.EternalRitual;
|
||||
|
||||
public class EternalPedestal extends BlockPedestal {
|
||||
public static final BooleanProperty ACTIVATED = BlockProperties.ACTIVATED;
|
||||
|
||||
public EternalPedestal() {
|
||||
super(EndBlocks.FLAVOLITE_RUNED_ETERNAL);
|
||||
this.setDefaultState(this.getDefaultState().with(ACTIVATED, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
|
||||
ActionResult result = super.onUse(state, world, pos, player, hand, hit);
|
||||
if (result.equals(ActionResult.SUCCESS)) {
|
||||
BlockEntity blockEntity = world.getBlockEntity(pos);
|
||||
if (blockEntity instanceof EternalPedestalEntity) {
|
||||
EternalPedestalEntity pedestal = (EternalPedestalEntity) blockEntity;
|
||||
BlockState updatedState = world.getBlockState(pos);
|
||||
if (pedestal.isEmpty() && updatedState.get(ACTIVATED)) {
|
||||
if (pedestal.hasRitual()) {
|
||||
EternalRitual ritual = pedestal.getRitual();
|
||||
ritual.removePortal();
|
||||
}
|
||||
world.setBlockState(pos, updatedState.with(ACTIVATED, false));
|
||||
} else {
|
||||
ItemStack itemStack = pedestal.getStack(0);
|
||||
if (itemStack.getItem() == EndItems.ETERNAL_CRYSTAL) {
|
||||
world.setBlockState(pos, updatedState.with(ACTIVATED, true));
|
||||
if (pedestal.hasRitual()) {
|
||||
pedestal.getRitual().checkStructure();
|
||||
} else {
|
||||
EternalRitual ritual = new EternalRitual(world, pos);
|
||||
ritual.checkStructure();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState newState, WorldAccess world, BlockPos pos, BlockPos posFrom) {
|
||||
BlockState updated = super.getStateForNeighborUpdate(state, direction, newState, world, pos, posFrom);
|
||||
if (!updated.isOf(this)) return updated;
|
||||
if (!this.isPlaceable(updated)) {
|
||||
return updated.with(ACTIVATED, false);
|
||||
}
|
||||
return updated;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float calcBlockBreakingDelta(BlockState state, PlayerEntity player, BlockView world, BlockPos pos) {
|
||||
return 0.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBlastResistance() {
|
||||
return Blocks.BEDROCK.getBlastResistance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldDropItemsOnExplosion(Explosion explosion) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
||||
if (state.isOf(this)) {
|
||||
BlockProperties.PedestalState currentState = state.get(BlockProperties.PEDESTAL_STATE);
|
||||
if (currentState.equals(BlockProperties.PedestalState.BOTTOM) || currentState.equals(BlockProperties.PedestalState.PILLAR)) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
}
|
||||
List<ItemStack> drop = Lists.newArrayList();
|
||||
BlockEntity blockEntity = builder.getNullable(LootContextParameters.BLOCK_ENTITY);
|
||||
if (blockEntity != null && blockEntity instanceof EternalPedestalEntity) {
|
||||
EternalPedestalEntity pedestal = (EternalPedestalEntity) blockEntity;
|
||||
if (!pedestal.isEmpty()) {
|
||||
drop.add(pedestal.getStack(0));
|
||||
}
|
||||
}
|
||||
return drop;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
|
||||
super.appendProperties(stateManager);
|
||||
stateManager.add(ACTIVATED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createBlockEntity(BlockView world) {
|
||||
return new EternalPedestalEntity();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,37 +1,37 @@
|
|||
package ru.betterend.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.context.LootContext;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.explosion.Explosion;
|
||||
|
||||
public class EternalRunedFlavolite extends RunedFlavolite {
|
||||
|
||||
@Override
|
||||
public float calcBlockBreakingDelta(BlockState state, PlayerEntity player, BlockView world, BlockPos pos) {
|
||||
return 0.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBlastResistance() {
|
||||
return Blocks.BEDROCK.getBlastResistance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldDropItemsOnExplosion(Explosion explosion) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
}
|
||||
package ru.betterend.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.context.LootContext;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.explosion.Explosion;
|
||||
|
||||
public class EternalRunedFlavolite extends RunedFlavolite {
|
||||
|
||||
@Override
|
||||
public float calcBlockBreakingDelta(BlockState state, PlayerEntity player, BlockView world, BlockPos pos) {
|
||||
return 0.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBlastResistance() {
|
||||
return Blocks.BEDROCK.getBlastResistance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldDropItemsOnExplosion(Explosion explosion) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,71 +1,71 @@
|
|||
package ru.betterend.blocks;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.ShapeContext;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.World;
|
||||
import ru.betterend.blocks.basis.BlockPedestal;
|
||||
import ru.betterend.blocks.entities.InfusionPedestalEntity;
|
||||
|
||||
public class InfusionPedestal extends BlockPedestal {
|
||||
private static final VoxelShape SHAPE_DEFAULT;
|
||||
private static final VoxelShape SHAPE_PEDESTAL_TOP;
|
||||
|
||||
public InfusionPedestal() {
|
||||
super(Blocks.OBSIDIAN);
|
||||
this.height = 1.08F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
|
||||
ActionResult result = super.onUse(state, world, pos, player, hand, hit);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createBlockEntity(BlockView world) {
|
||||
return new InfusionPedestalEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
||||
if (state.isOf(this)) {
|
||||
switch(state.get(STATE)) {
|
||||
case PEDESTAL_TOP: {
|
||||
return SHAPE_PEDESTAL_TOP;
|
||||
}
|
||||
case DEFAULT: {
|
||||
return SHAPE_DEFAULT;
|
||||
}
|
||||
default: {
|
||||
return super.getOutlineShape(state, world, pos, context);
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.getOutlineShape(state, world, pos, context);
|
||||
}
|
||||
|
||||
static {
|
||||
VoxelShape basinUp = Block.createCuboidShape(2, 3, 2, 14, 4, 14);
|
||||
VoxelShape basinDown = Block.createCuboidShape(0, 0, 0, 16, 3, 16);
|
||||
VoxelShape pedestalTop = Block.createCuboidShape(1, 9, 1, 15, 11, 15);
|
||||
VoxelShape pedestalDefault = Block.createCuboidShape(1, 13, 1, 15, 15, 15);
|
||||
VoxelShape pillar = Block.createCuboidShape(3, 0, 3, 13, 9, 13);
|
||||
VoxelShape pillarDefault = Block.createCuboidShape(3, 4, 3, 13, 13, 13);
|
||||
VoxelShape eyeDefault = Block.createCuboidShape(4, 15, 4, 12, 16, 12);
|
||||
VoxelShape eyeTop = Block.createCuboidShape(4, 11, 4, 12, 12, 12);
|
||||
VoxelShape basin = VoxelShapes.union(basinDown, basinUp);
|
||||
SHAPE_DEFAULT = VoxelShapes.union(basin, pillarDefault, pedestalDefault, eyeDefault);
|
||||
SHAPE_PEDESTAL_TOP = VoxelShapes.union(pillar, pedestalTop, eyeTop);
|
||||
}
|
||||
}
|
||||
package ru.betterend.blocks;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.ShapeContext;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.World;
|
||||
import ru.betterend.blocks.basis.BlockPedestal;
|
||||
import ru.betterend.blocks.entities.InfusionPedestalEntity;
|
||||
|
||||
public class InfusionPedestal extends BlockPedestal {
|
||||
private static final VoxelShape SHAPE_DEFAULT;
|
||||
private static final VoxelShape SHAPE_PEDESTAL_TOP;
|
||||
|
||||
public InfusionPedestal() {
|
||||
super(Blocks.OBSIDIAN);
|
||||
this.height = 1.08F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
|
||||
ActionResult result = super.onUse(state, world, pos, player, hand, hit);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createBlockEntity(BlockView world) {
|
||||
return new InfusionPedestalEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
||||
if (state.isOf(this)) {
|
||||
switch(state.get(STATE)) {
|
||||
case PEDESTAL_TOP: {
|
||||
return SHAPE_PEDESTAL_TOP;
|
||||
}
|
||||
case DEFAULT: {
|
||||
return SHAPE_DEFAULT;
|
||||
}
|
||||
default: {
|
||||
return super.getOutlineShape(state, world, pos, context);
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.getOutlineShape(state, world, pos, context);
|
||||
}
|
||||
|
||||
static {
|
||||
VoxelShape basinUp = Block.createCuboidShape(2, 3, 2, 14, 4, 14);
|
||||
VoxelShape basinDown = Block.createCuboidShape(0, 0, 0, 16, 3, 16);
|
||||
VoxelShape pedestalTop = Block.createCuboidShape(1, 9, 1, 15, 11, 15);
|
||||
VoxelShape pedestalDefault = Block.createCuboidShape(1, 13, 1, 15, 15, 15);
|
||||
VoxelShape pillar = Block.createCuboidShape(3, 0, 3, 13, 9, 13);
|
||||
VoxelShape pillarDefault = Block.createCuboidShape(3, 4, 3, 13, 13, 13);
|
||||
VoxelShape eyeDefault = Block.createCuboidShape(4, 15, 4, 12, 16, 12);
|
||||
VoxelShape eyeTop = Block.createCuboidShape(4, 11, 4, 12, 12, 12);
|
||||
VoxelShape basin = VoxelShapes.union(basinDown, basinUp);
|
||||
SHAPE_DEFAULT = VoxelShapes.union(basin, pillarDefault, pedestalDefault, eyeDefault);
|
||||
SHAPE_PEDESTAL_TOP = VoxelShapes.union(pillar, pedestalTop, eyeTop);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
package ru.betterend.blocks;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.state.property.BooleanProperty;
|
||||
import ru.betterend.blocks.basis.BlockBase;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
|
||||
public class RunedFlavolite extends BlockBase {
|
||||
public static final BooleanProperty ACTIVATED = BlockProperties.ACTIVATED;
|
||||
|
||||
public RunedFlavolite() {
|
||||
super(FabricBlockSettings.copyOf(EndBlocks.FLAVOLITE.polished).resistance(Blocks.OBSIDIAN.getBlastResistance()).luminance(state -> {
|
||||
return state.get(ACTIVATED) ? 8 : 0;
|
||||
}));
|
||||
this.setDefaultState(stateManager.getDefaultState().with(ACTIVATED, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
|
||||
stateManager.add(ACTIVATED);
|
||||
}
|
||||
}
|
||||
package ru.betterend.blocks;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.state.property.BooleanProperty;
|
||||
import ru.betterend.blocks.basis.BlockBase;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
|
||||
public class RunedFlavolite extends BlockBase {
|
||||
public static final BooleanProperty ACTIVATED = BlockProperties.ACTIVATED;
|
||||
|
||||
public RunedFlavolite() {
|
||||
super(FabricBlockSettings.copyOf(EndBlocks.FLAVOLITE.polished).resistance(Blocks.OBSIDIAN.getBlastResistance()).luminance(state -> {
|
||||
return state.get(ACTIVATED) ? 8 : 0;
|
||||
}));
|
||||
this.setDefaultState(stateManager.getDefaultState().with(ACTIVATED, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
|
||||
stateManager.add(ACTIVATED);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
package ru.betterend.blocks;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.block.MaterialColor;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
import ru.betterend.blocks.basis.BlockBase;
|
||||
|
||||
public class TerminiteBlock extends BlockBase {
|
||||
public TerminiteBlock() {
|
||||
super(FabricBlockSettings.of(Material.METAL, MaterialColor.field_25708)
|
||||
.hardness(7F)
|
||||
.resistance(9F)
|
||||
.requiresTool()
|
||||
.sounds(BlockSoundGroup.METAL));
|
||||
}
|
||||
}
|
||||
package ru.betterend.blocks;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.block.MaterialColor;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
import ru.betterend.blocks.basis.BlockBase;
|
||||
|
||||
public class TerminiteBlock extends BlockBase {
|
||||
public TerminiteBlock() {
|
||||
super(FabricBlockSettings.of(Material.METAL, MaterialColor.field_25708)
|
||||
.hardness(7F)
|
||||
.resistance(9F)
|
||||
.requiresTool()
|
||||
.sounds(BlockSoundGroup.METAL));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.BlockWithEntity;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.context.LootContext;
|
||||
import net.minecraft.world.BlockView;
|
||||
|
||||
public class BaseBlockWithEntity extends BlockWithEntity {
|
||||
|
||||
public BaseBlockWithEntity(Settings settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createBlockEntity(BlockView world) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
||||
return Collections.singletonList(new ItemStack(this));
|
||||
}
|
||||
}
|
||||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.BlockWithEntity;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.context.LootContext;
|
||||
import net.minecraft.world.BlockView;
|
||||
|
||||
public class BaseBlockWithEntity extends BlockWithEntity {
|
||||
|
||||
public BaseBlockWithEntity(Settings settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createBlockEntity(BlockView world) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
||||
return Collections.singletonList(new ItemStack(this));
|
||||
}
|
||||
}
|
||||
|
|
146
src/main/java/ru/betterend/blocks/basis/BlockStoneLantern.java
Normal file
146
src/main/java/ru/betterend/blocks/basis/BlockStoneLantern.java
Normal file
|
@ -0,0 +1,146 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.io.Reader;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.ShapeContext;
|
||||
import net.minecraft.block.Waterloggable;
|
||||
import net.minecraft.client.color.block.BlockColorProvider;
|
||||
import net.minecraft.client.color.item.ItemColorProvider;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.item.ItemPlacementContext;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.state.property.BooleanProperty;
|
||||
import net.minecraft.state.property.Properties;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
import net.minecraft.world.WorldView;
|
||||
import ru.betterend.blocks.AuroraCrystalBlock;
|
||||
import ru.betterend.interfaces.IColorProvider;
|
||||
import ru.betterend.interfaces.Patterned;
|
||||
import ru.betterend.util.MHelper;
|
||||
|
||||
public class BlockStoneLantern extends BlockBaseNotFull implements IColorProvider, Waterloggable {
|
||||
public static final BooleanProperty IS_FLOOR = BooleanProperty.of("is_floor");
|
||||
public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED;
|
||||
|
||||
private static final VoxelShape SHAPE_CEIL = Block.createCuboidShape(3, 1, 3, 13, 16, 13);
|
||||
private static final VoxelShape SHAPE_FLOOR = Block.createCuboidShape(3, 0, 3, 13, 15, 13);
|
||||
private static final Vec3i[] COLORS = AuroraCrystalBlock.COLORS;
|
||||
|
||||
public BlockStoneLantern(Block source) {
|
||||
super(FabricBlockSettings.copyOf(source).luminance(15));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
|
||||
stateManager.add(IS_FLOOR, WATERLOGGED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getPlacementState(ItemPlacementContext ctx) {
|
||||
WorldView worldView = ctx.getWorld();
|
||||
BlockPos blockPos = ctx.getBlockPos();
|
||||
Direction dir = ctx.getSide();
|
||||
if (dir == Direction.DOWN) {
|
||||
if (sideCoversSmallSquare(worldView, blockPos.up(), Direction.DOWN)) {
|
||||
boolean water = worldView.getFluidState(blockPos).getFluid() == Fluids.WATER;
|
||||
return getDefaultState().with(IS_FLOOR, false).with(WATERLOGGED, water);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (sideCoversSmallSquare(worldView, blockPos.down(), Direction.UP)) {
|
||||
boolean water = worldView.getFluidState(blockPos).getFluid() == Fluids.WATER;
|
||||
return getDefaultState().with(IS_FLOOR, true).with(WATERLOGGED, water);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockColorProvider getProvider() {
|
||||
return (state, world, pos, tintIndex) -> {
|
||||
long i = (long) pos.getX() + (long) pos.getY() + (long) pos.getZ();
|
||||
double delta = i * 0.1;
|
||||
int index = MHelper.floor(delta);
|
||||
int index2 = (index + 1) & 3;
|
||||
delta -= index;
|
||||
index &= 3;
|
||||
|
||||
Vec3i color1 = COLORS[index];
|
||||
Vec3i color2 = COLORS[index2];
|
||||
|
||||
int r = MHelper.floor(MathHelper.lerp(delta, color1.getX(), color2.getX()));
|
||||
int g = MHelper.floor(MathHelper.lerp(delta, color1.getY(), color2.getY()));
|
||||
int b = MHelper.floor(MathHelper.lerp(delta, color1.getZ(), color2.getZ()));
|
||||
|
||||
return MHelper.color(r, g, b);
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemColorProvider getItemProvider() {
|
||||
return (stack, tintIndex) -> {
|
||||
return MHelper.color(COLORS[3].getX(), COLORS[3].getY(), COLORS[3].getZ());
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
|
||||
return state.get(IS_FLOOR) ? SHAPE_FLOOR : SHAPE_CEIL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
||||
if (state.get(IS_FLOOR)) {
|
||||
return sideCoversSmallSquare(world, pos.down(), Direction.UP);
|
||||
}
|
||||
else {
|
||||
return sideCoversSmallSquare(world, pos.up(), Direction.DOWN);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
|
||||
Boolean water = state.get(WATERLOGGED);
|
||||
if (water) {
|
||||
world.getFluidTickScheduler().schedule(pos, Fluids.WATER, Fluids.WATER.getTickRate(world));
|
||||
}
|
||||
if (!canPlaceAt(state, world, pos)) {
|
||||
return water ? Blocks.WATER.getDefaultState() : Blocks.AIR.getDefaultState();
|
||||
}
|
||||
else {
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier statePatternId() {
|
||||
return Patterned.STATE_STONE_LANTERN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String block) {
|
||||
Identifier blockId = Registry.BLOCK.getId(this);
|
||||
if (block.contains("ceil")) {
|
||||
return Patterned.createJson(Patterned.BLOCK_STONE_LANTERN_CEIL, blockId, blockId.getPath());
|
||||
}
|
||||
return Patterned.createJson(Patterned.BLOCK_STONE_LANTERN_FLOOR, blockId, blockId.getPath());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStatesPattern(Reader data) {
|
||||
Identifier blockId = Registry.BLOCK.getId(this);
|
||||
return Patterned.createJson(data, blockId, blockId.getPath());
|
||||
}
|
||||
}
|
|
@ -1,48 +1,48 @@
|
|||
package ru.betterend.blocks.entities;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import ru.betterend.rituals.EternalRitual;
|
||||
|
||||
public class EternalPedestalEntity extends PedestalBlockEntity {
|
||||
private EternalRitual linkedRitual;
|
||||
|
||||
public boolean hasRitual() {
|
||||
return this.linkedRitual != null;
|
||||
}
|
||||
|
||||
public void linkRitual(EternalRitual ritual) {
|
||||
this.linkedRitual = ritual;
|
||||
}
|
||||
|
||||
public EternalRitual getRitual() {
|
||||
return this.linkedRitual;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocation(World world, BlockPos pos) {
|
||||
super.setLocation(world, pos);
|
||||
if (hasRitual()) {
|
||||
this.linkedRitual.setWorld(world);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromTag(BlockState state, CompoundTag tag) {
|
||||
super.fromTag(state, tag);
|
||||
if (tag.contains("ritual")) {
|
||||
this.linkedRitual = new EternalRitual(world);
|
||||
this.linkedRitual.fromTag(tag.getCompound("ritual"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag toTag(CompoundTag tag) {
|
||||
if (this.hasRitual()) {
|
||||
tag.put("ritual", linkedRitual.toTag(new CompoundTag()));
|
||||
}
|
||||
return super.toTag(tag);
|
||||
}
|
||||
}
|
||||
package ru.betterend.blocks.entities;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import ru.betterend.rituals.EternalRitual;
|
||||
|
||||
public class EternalPedestalEntity extends PedestalBlockEntity {
|
||||
private EternalRitual linkedRitual;
|
||||
|
||||
public boolean hasRitual() {
|
||||
return this.linkedRitual != null;
|
||||
}
|
||||
|
||||
public void linkRitual(EternalRitual ritual) {
|
||||
this.linkedRitual = ritual;
|
||||
}
|
||||
|
||||
public EternalRitual getRitual() {
|
||||
return this.linkedRitual;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocation(World world, BlockPos pos) {
|
||||
super.setLocation(world, pos);
|
||||
if (hasRitual()) {
|
||||
this.linkedRitual.setWorld(world);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromTag(BlockState state, CompoundTag tag) {
|
||||
super.fromTag(state, tag);
|
||||
if (tag.contains("ritual")) {
|
||||
this.linkedRitual = new EternalRitual(world);
|
||||
this.linkedRitual.fromTag(tag.getCompound("ritual"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag toTag(CompoundTag tag) {
|
||||
if (this.hasRitual()) {
|
||||
tag.put("ritual", linkedRitual.toTag(new CompoundTag()));
|
||||
}
|
||||
return super.toTag(tag);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
package ru.betterend.blocks.entities;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import ru.betterend.rituals.InfusionRitual;
|
||||
|
||||
public class InfusionPedestalEntity extends PedestalBlockEntity {
|
||||
|
||||
private InfusionRitual activeRitual;
|
||||
|
||||
public boolean hasRitual() {
|
||||
return this.activeRitual != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromTag(BlockState state, CompoundTag tag) {
|
||||
super.fromTag(state, tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag toTag(CompoundTag tag) {
|
||||
return super.toTag(tag);
|
||||
}
|
||||
}
|
||||
package ru.betterend.blocks.entities;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import ru.betterend.rituals.InfusionRitual;
|
||||
|
||||
public class InfusionPedestalEntity extends PedestalBlockEntity {
|
||||
|
||||
private InfusionRitual activeRitual;
|
||||
|
||||
public boolean hasRitual() {
|
||||
return this.activeRitual != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromTag(BlockState state, CompoundTag tag) {
|
||||
super.fromTag(state, tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag toTag(CompoundTag tag) {
|
||||
return super.toTag(tag);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,105 +1,105 @@
|
|||
package ru.betterend.blocks.entities;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket;
|
||||
import net.minecraft.util.Tickable;
|
||||
import ru.betterend.registry.EndBlockEntities;
|
||||
|
||||
public class PedestalBlockEntity extends BlockEntity implements Inventory, Tickable {
|
||||
private ItemStack activeItem = ItemStack.EMPTY;
|
||||
|
||||
private final int maxAge = 314;
|
||||
private int age;
|
||||
|
||||
public PedestalBlockEntity() {
|
||||
super(EndBlockEntities.PEDESTAL);
|
||||
}
|
||||
|
||||
public int getAge() {
|
||||
return this.age;
|
||||
}
|
||||
|
||||
public int getMaxAge() {
|
||||
return this.maxAge;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
this.activeItem = ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return this.activeItem.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStack(int slot) {
|
||||
return this.activeItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack removeStack(int slot, int amount) {
|
||||
return this.removeStack(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack removeStack(int slot) {
|
||||
return this.activeItem = ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStack(int slot, ItemStack stack) {
|
||||
this.activeItem = stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlayerUse(PlayerEntity player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityUpdateS2CPacket toUpdatePacket() {
|
||||
return new BlockEntityUpdateS2CPacket(pos, 32, this.toInitialChunkDataTag());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag toInitialChunkDataTag() {
|
||||
return this.toTag(new CompoundTag());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromTag(BlockState state, CompoundTag tag) {
|
||||
super.fromTag(state, tag);
|
||||
if (tag.contains("active_item")) {
|
||||
CompoundTag itemTag = tag.getCompound("active_item");
|
||||
this.activeItem = ItemStack.fromTag(itemTag);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag toTag(CompoundTag tag) {
|
||||
tag.put("active_item", activeItem.toTag(new CompoundTag()));
|
||||
return super.toTag(tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
if (!isEmpty()) {
|
||||
this.age++;
|
||||
if (age > maxAge) {
|
||||
this.age = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
package ru.betterend.blocks.entities;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket;
|
||||
import net.minecraft.util.Tickable;
|
||||
import ru.betterend.registry.EndBlockEntities;
|
||||
|
||||
public class PedestalBlockEntity extends BlockEntity implements Inventory, Tickable {
|
||||
private ItemStack activeItem = ItemStack.EMPTY;
|
||||
|
||||
private final int maxAge = 314;
|
||||
private int age;
|
||||
|
||||
public PedestalBlockEntity() {
|
||||
super(EndBlockEntities.PEDESTAL);
|
||||
}
|
||||
|
||||
public int getAge() {
|
||||
return this.age;
|
||||
}
|
||||
|
||||
public int getMaxAge() {
|
||||
return this.maxAge;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
this.activeItem = ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return this.activeItem.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStack(int slot) {
|
||||
return this.activeItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack removeStack(int slot, int amount) {
|
||||
return this.removeStack(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack removeStack(int slot) {
|
||||
return this.activeItem = ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStack(int slot, ItemStack stack) {
|
||||
this.activeItem = stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlayerUse(PlayerEntity player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityUpdateS2CPacket toUpdatePacket() {
|
||||
return new BlockEntityUpdateS2CPacket(pos, 32, this.toInitialChunkDataTag());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag toInitialChunkDataTag() {
|
||||
return this.toTag(new CompoundTag());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromTag(BlockState state, CompoundTag tag) {
|
||||
super.fromTag(state, tag);
|
||||
if (tag.contains("active_item")) {
|
||||
CompoundTag itemTag = tag.getCompound("active_item");
|
||||
this.activeItem = ItemStack.fromTag(itemTag);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag toTag(CompoundTag tag) {
|
||||
tag.put("active_item", activeItem.toTag(new CompoundTag()));
|
||||
return super.toTag(tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
if (!isEmpty()) {
|
||||
this.age++;
|
||||
if (age > maxAge) {
|
||||
this.age = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,94 +1,94 @@
|
|||
package ru.betterend.blocks.entities.render;
|
||||
|
||||
import net.minecraft.client.model.ModelPart;
|
||||
import net.minecraft.client.render.OverlayTexture;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Matrix3f;
|
||||
import net.minecraft.util.math.Matrix4f;
|
||||
import net.minecraft.util.math.Quaternion;
|
||||
|
||||
public class EndCrystalRenderer {
|
||||
private static final Identifier CRYSTAL_TEXTURE = new Identifier("textures/entity/end_crystal/end_crystal.png");
|
||||
private static final Identifier CRYSTAL_BEAM_TEXTURE = new Identifier("textures/entity/end_crystal/end_crystal_beam.png");
|
||||
private static final RenderLayer CRYSTAL_BEAM_LAYER;
|
||||
private static final RenderLayer END_CRYSTAL;
|
||||
private static final ModelPart CORE;
|
||||
private static final ModelPart FRAME;
|
||||
private static final int AGE_CYCLE = 240;
|
||||
private static final float SINE_45_DEGREES;
|
||||
|
||||
public static void render(int age, int maxAge, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumerProvider, int light) {
|
||||
float k = (float) AGE_CYCLE / maxAge;
|
||||
float rotation = (age * k + tickDelta) * 3.0F;
|
||||
VertexConsumer vertexConsumer = vertexConsumerProvider.getBuffer(END_CRYSTAL);
|
||||
matrices.push();
|
||||
matrices.scale(0.8F, 0.8F, 0.8F);
|
||||
matrices.translate(0.0D, -0.5D, 0.0D);
|
||||
matrices.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(rotation));
|
||||
matrices.translate(0.0D, 0.8F, 0.0D);
|
||||
matrices.multiply(new Quaternion(new Vector3f(SINE_45_DEGREES, 0.0F, SINE_45_DEGREES), 60.0F, true));
|
||||
FRAME.render(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV);
|
||||
matrices.scale(0.875F, 0.875F, 0.875F);
|
||||
matrices.multiply(new Quaternion(new Vector3f(SINE_45_DEGREES, 0.0F, SINE_45_DEGREES), 60.0F, true));
|
||||
matrices.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(rotation));
|
||||
FRAME.render(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV);
|
||||
matrices.scale(0.875F, 0.875F, 0.875F);
|
||||
matrices.multiply(new Quaternion(new Vector3f(SINE_45_DEGREES, 0.0F, SINE_45_DEGREES), 60.0F, true));
|
||||
matrices.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(rotation));
|
||||
CORE.render(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV);
|
||||
matrices.pop();
|
||||
}
|
||||
|
||||
public static void renderBeam(BlockPos start, BlockPos end, float tickDelta, int age, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light) {
|
||||
float dx = start.getX() - end.getX() + 1.0F;
|
||||
float dy = start.getY() - end.getY() + 1.0F;
|
||||
float dz = start.getZ() - end.getZ() + 1.0F;
|
||||
float f = MathHelper.sqrt(dx * dx + dz * dz);
|
||||
float g = MathHelper.sqrt(dx * dx + dy * dy + dz * dz);
|
||||
matrices.push();
|
||||
matrices.translate(0.0D, 2.0D, 0.0D);
|
||||
matrices.multiply(Vector3f.POSITIVE_Y.getRadialQuaternion((float)(-Math.atan2((double)dz, (double)dx)) - 1.5707964F));
|
||||
matrices.multiply(Vector3f.POSITIVE_X.getRadialQuaternion((float)(-Math.atan2((double)f, (double)dy)) - 1.5707964F));
|
||||
VertexConsumer vertexConsumer = vertexConsumers.getBuffer(CRYSTAL_BEAM_LAYER);
|
||||
float h = 0.0F - ((float)age + tickDelta) * 0.01F;
|
||||
float i = MathHelper.sqrt(dx * dx + dy * dy + dz * dz) / 32.0F - ((float)age + tickDelta) * 0.01F;
|
||||
float k = 0.0F;
|
||||
float l = 0.75F;
|
||||
float m = 0.0F;
|
||||
MatrixStack.Entry entry = matrices.peek();
|
||||
Matrix4f matrix4f = entry.getModel();
|
||||
Matrix3f matrix3f = entry.getNormal();
|
||||
|
||||
for(int n = 1; n <= 8; ++n) {
|
||||
float o = MathHelper.sin((float)n * 6.2831855F / 8.0F) * 0.75F;
|
||||
float p = MathHelper.cos((float)n * 6.2831855F / 8.0F) * 0.75F;
|
||||
float q = (float)n / 8.0F;
|
||||
vertexConsumer.vertex(matrix4f, k * 0.2F, l * 0.2F, 0.0F).color(0, 0, 0, 255).texture(m, h).overlay(OverlayTexture.DEFAULT_UV).light(light).normal(matrix3f, 0.0F, -1.0F, 0.0F).next();
|
||||
vertexConsumer.vertex(matrix4f, k, l, g).color(255, 255, 255, 255).texture(m, i).overlay(OverlayTexture.DEFAULT_UV).light(light).normal(matrix3f, 0.0F, -1.0F, 0.0F).next();
|
||||
vertexConsumer.vertex(matrix4f, o, p, g).color(255, 255, 255, 255).texture(q, i).overlay(OverlayTexture.DEFAULT_UV).light(light).normal(matrix3f, 0.0F, -1.0F, 0.0F).next();
|
||||
vertexConsumer.vertex(matrix4f, o * 0.2F, p * 0.2F, 0.0F).color(0, 0, 0, 255).texture(q, h).overlay(OverlayTexture.DEFAULT_UV).light(light).normal(matrix3f, 0.0F, -1.0F, 0.0F).next();
|
||||
k = o;
|
||||
l = p;
|
||||
m = q;
|
||||
}
|
||||
|
||||
matrices.pop();
|
||||
}
|
||||
|
||||
static {
|
||||
END_CRYSTAL = RenderLayer.getEntityCutoutNoCull(CRYSTAL_TEXTURE);
|
||||
CRYSTAL_BEAM_LAYER = RenderLayer.getEntitySmoothCutout(CRYSTAL_BEAM_TEXTURE);
|
||||
SINE_45_DEGREES = (float) Math.sin(0.7853981633974483D);
|
||||
FRAME = new ModelPart(64, 32, 0, 0);
|
||||
FRAME.addCuboid(-4.0F, -4.0F, -4.0F, 8.0F, 8.0F, 8.0F);
|
||||
CORE = new ModelPart(64, 32, 32, 0);
|
||||
CORE.addCuboid(-4.0F, -4.0F, -4.0F, 8.0F, 8.0F, 8.0F);
|
||||
}
|
||||
}
|
||||
package ru.betterend.blocks.entities.render;
|
||||
|
||||
import net.minecraft.client.model.ModelPart;
|
||||
import net.minecraft.client.render.OverlayTexture;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Matrix3f;
|
||||
import net.minecraft.util.math.Matrix4f;
|
||||
import net.minecraft.util.math.Quaternion;
|
||||
|
||||
public class EndCrystalRenderer {
|
||||
private static final Identifier CRYSTAL_TEXTURE = new Identifier("textures/entity/end_crystal/end_crystal.png");
|
||||
private static final Identifier CRYSTAL_BEAM_TEXTURE = new Identifier("textures/entity/end_crystal/end_crystal_beam.png");
|
||||
private static final RenderLayer CRYSTAL_BEAM_LAYER;
|
||||
private static final RenderLayer END_CRYSTAL;
|
||||
private static final ModelPart CORE;
|
||||
private static final ModelPart FRAME;
|
||||
private static final int AGE_CYCLE = 240;
|
||||
private static final float SINE_45_DEGREES;
|
||||
|
||||
public static void render(int age, int maxAge, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumerProvider, int light) {
|
||||
float k = (float) AGE_CYCLE / maxAge;
|
||||
float rotation = (age * k + tickDelta) * 3.0F;
|
||||
VertexConsumer vertexConsumer = vertexConsumerProvider.getBuffer(END_CRYSTAL);
|
||||
matrices.push();
|
||||
matrices.scale(0.8F, 0.8F, 0.8F);
|
||||
matrices.translate(0.0D, -0.5D, 0.0D);
|
||||
matrices.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(rotation));
|
||||
matrices.translate(0.0D, 0.8F, 0.0D);
|
||||
matrices.multiply(new Quaternion(new Vector3f(SINE_45_DEGREES, 0.0F, SINE_45_DEGREES), 60.0F, true));
|
||||
FRAME.render(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV);
|
||||
matrices.scale(0.875F, 0.875F, 0.875F);
|
||||
matrices.multiply(new Quaternion(new Vector3f(SINE_45_DEGREES, 0.0F, SINE_45_DEGREES), 60.0F, true));
|
||||
matrices.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(rotation));
|
||||
FRAME.render(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV);
|
||||
matrices.scale(0.875F, 0.875F, 0.875F);
|
||||
matrices.multiply(new Quaternion(new Vector3f(SINE_45_DEGREES, 0.0F, SINE_45_DEGREES), 60.0F, true));
|
||||
matrices.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(rotation));
|
||||
CORE.render(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV);
|
||||
matrices.pop();
|
||||
}
|
||||
|
||||
public static void renderBeam(BlockPos start, BlockPos end, float tickDelta, int age, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light) {
|
||||
float dx = start.getX() - end.getX() + 1.0F;
|
||||
float dy = start.getY() - end.getY() + 1.0F;
|
||||
float dz = start.getZ() - end.getZ() + 1.0F;
|
||||
float f = MathHelper.sqrt(dx * dx + dz * dz);
|
||||
float g = MathHelper.sqrt(dx * dx + dy * dy + dz * dz);
|
||||
matrices.push();
|
||||
matrices.translate(0.0D, 2.0D, 0.0D);
|
||||
matrices.multiply(Vector3f.POSITIVE_Y.getRadialQuaternion((float)(-Math.atan2((double)dz, (double)dx)) - 1.5707964F));
|
||||
matrices.multiply(Vector3f.POSITIVE_X.getRadialQuaternion((float)(-Math.atan2((double)f, (double)dy)) - 1.5707964F));
|
||||
VertexConsumer vertexConsumer = vertexConsumers.getBuffer(CRYSTAL_BEAM_LAYER);
|
||||
float h = 0.0F - ((float)age + tickDelta) * 0.01F;
|
||||
float i = MathHelper.sqrt(dx * dx + dy * dy + dz * dz) / 32.0F - ((float)age + tickDelta) * 0.01F;
|
||||
float k = 0.0F;
|
||||
float l = 0.75F;
|
||||
float m = 0.0F;
|
||||
MatrixStack.Entry entry = matrices.peek();
|
||||
Matrix4f matrix4f = entry.getModel();
|
||||
Matrix3f matrix3f = entry.getNormal();
|
||||
|
||||
for(int n = 1; n <= 8; ++n) {
|
||||
float o = MathHelper.sin((float)n * 6.2831855F / 8.0F) * 0.75F;
|
||||
float p = MathHelper.cos((float)n * 6.2831855F / 8.0F) * 0.75F;
|
||||
float q = (float)n / 8.0F;
|
||||
vertexConsumer.vertex(matrix4f, k * 0.2F, l * 0.2F, 0.0F).color(0, 0, 0, 255).texture(m, h).overlay(OverlayTexture.DEFAULT_UV).light(light).normal(matrix3f, 0.0F, -1.0F, 0.0F).next();
|
||||
vertexConsumer.vertex(matrix4f, k, l, g).color(255, 255, 255, 255).texture(m, i).overlay(OverlayTexture.DEFAULT_UV).light(light).normal(matrix3f, 0.0F, -1.0F, 0.0F).next();
|
||||
vertexConsumer.vertex(matrix4f, o, p, g).color(255, 255, 255, 255).texture(q, i).overlay(OverlayTexture.DEFAULT_UV).light(light).normal(matrix3f, 0.0F, -1.0F, 0.0F).next();
|
||||
vertexConsumer.vertex(matrix4f, o * 0.2F, p * 0.2F, 0.0F).color(0, 0, 0, 255).texture(q, h).overlay(OverlayTexture.DEFAULT_UV).light(light).normal(matrix3f, 0.0F, -1.0F, 0.0F).next();
|
||||
k = o;
|
||||
l = p;
|
||||
m = q;
|
||||
}
|
||||
|
||||
matrices.pop();
|
||||
}
|
||||
|
||||
static {
|
||||
END_CRYSTAL = RenderLayer.getEntityCutoutNoCull(CRYSTAL_TEXTURE);
|
||||
CRYSTAL_BEAM_LAYER = RenderLayer.getEntitySmoothCutout(CRYSTAL_BEAM_TEXTURE);
|
||||
SINE_45_DEGREES = (float) Math.sin(0.7853981633974483D);
|
||||
FRAME = new ModelPart(64, 32, 0, 0);
|
||||
FRAME.addCuboid(-4.0F, -4.0F, -4.0F, 8.0F, 8.0F, 8.0F);
|
||||
CORE = new ModelPart(64, 32, 32, 0);
|
||||
CORE.addCuboid(-4.0F, -4.0F, -4.0F, 8.0F, 8.0F, 8.0F);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,75 +1,75 @@
|
|||
package ru.betterend.blocks.entities.render;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
|
||||
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
|
||||
import net.minecraft.client.render.model.BakedModel;
|
||||
import net.minecraft.client.render.model.json.ModelTransformation;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.util.DyeColor;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import ru.betterend.blocks.EternalPedestal;
|
||||
import ru.betterend.blocks.basis.BlockPedestal;
|
||||
import ru.betterend.blocks.entities.PedestalBlockEntity;
|
||||
import ru.betterend.client.render.BeamRenderer;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class PedestalItemRenderer extends BlockEntityRenderer<PedestalBlockEntity> {
|
||||
private static final Identifier BEAM_TEXTURE = new Identifier("textures/entity/end_gateway_beam.png");
|
||||
|
||||
public PedestalItemRenderer(BlockEntityRenderDispatcher dispatcher) {
|
||||
super(dispatcher);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(PedestalBlockEntity blockEntity, float tickDelta, MatrixStack matrices,
|
||||
VertexConsumerProvider vertexConsumers, int light, int overlay) {
|
||||
|
||||
if (blockEntity.isEmpty()) return;
|
||||
|
||||
BlockState state = blockEntity.getWorld().getBlockState(blockEntity.getPos());
|
||||
ItemStack activeItem = blockEntity.getStack(0);
|
||||
matrices.push();
|
||||
MinecraftClient minecraft = MinecraftClient.getInstance();
|
||||
BakedModel model = minecraft.getItemRenderer().getHeldItemModel(activeItem, blockEntity.getWorld(), null);
|
||||
Vector3f translate = model.getTransformation().ground.translation;
|
||||
BlockPedestal pedestal = (BlockPedestal) state.getBlock();
|
||||
matrices.translate(translate.getX(), translate.getY(), translate.getZ());
|
||||
matrices.translate(0.5, pedestal.getHeight(state), 0.5);
|
||||
if (activeItem.getItem() instanceof BlockItem) {
|
||||
matrices.scale(1.5F, 1.5F, 1.5F);
|
||||
} else {
|
||||
matrices.scale(1.25F, 1.25F, 1.25F);
|
||||
}
|
||||
|
||||
float rotation = (blockEntity.getAge() + tickDelta) / 25.0F + 6.0F;
|
||||
matrices.multiply(Vector3f.POSITIVE_Y.getRadialQuaternion(rotation));
|
||||
if (state.isOf(EndBlocks.ETERNAL_PEDESTAL) && state.get(EternalPedestal.ACTIVATED)) {
|
||||
float altitude = MathHelper.sin((blockEntity.getAge() + tickDelta) / 10.0F) * 0.1F + 0.1F;
|
||||
matrices.translate(0.0D, altitude, 0.0D);
|
||||
float[] colors = DyeColor.MAGENTA.getColorComponents();
|
||||
int y = blockEntity.getPos().getY();
|
||||
VertexConsumer vertexConsumer = vertexConsumers.getBuffer(RenderLayer.getBeaconBeam(BEAM_TEXTURE, true));
|
||||
BeamRenderer.renderLightBeam(matrices, vertexConsumer, tickDelta, -y, 1024 - y, colors, 0.25F, 0.15F, 0.2F);
|
||||
}
|
||||
|
||||
if (activeItem.getItem() == Items.END_CRYSTAL) {
|
||||
EndCrystalRenderer.render(blockEntity.getAge(), blockEntity.getMaxAge(), tickDelta, matrices, vertexConsumers, light);
|
||||
} else {
|
||||
minecraft.getItemRenderer().renderItem(activeItem, ModelTransformation.Mode.GROUND, false, matrices, vertexConsumers, light, overlay, model);
|
||||
}
|
||||
matrices.pop();
|
||||
}
|
||||
}
|
||||
package ru.betterend.blocks.entities.render;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
|
||||
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
|
||||
import net.minecraft.client.render.model.BakedModel;
|
||||
import net.minecraft.client.render.model.json.ModelTransformation;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.util.DyeColor;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import ru.betterend.blocks.EternalPedestal;
|
||||
import ru.betterend.blocks.basis.BlockPedestal;
|
||||
import ru.betterend.blocks.entities.PedestalBlockEntity;
|
||||
import ru.betterend.client.render.BeamRenderer;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class PedestalItemRenderer extends BlockEntityRenderer<PedestalBlockEntity> {
|
||||
private static final Identifier BEAM_TEXTURE = new Identifier("textures/entity/end_gateway_beam.png");
|
||||
|
||||
public PedestalItemRenderer(BlockEntityRenderDispatcher dispatcher) {
|
||||
super(dispatcher);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(PedestalBlockEntity blockEntity, float tickDelta, MatrixStack matrices,
|
||||
VertexConsumerProvider vertexConsumers, int light, int overlay) {
|
||||
|
||||
if (blockEntity.isEmpty()) return;
|
||||
|
||||
BlockState state = blockEntity.getWorld().getBlockState(blockEntity.getPos());
|
||||
ItemStack activeItem = blockEntity.getStack(0);
|
||||
matrices.push();
|
||||
MinecraftClient minecraft = MinecraftClient.getInstance();
|
||||
BakedModel model = minecraft.getItemRenderer().getHeldItemModel(activeItem, blockEntity.getWorld(), null);
|
||||
Vector3f translate = model.getTransformation().ground.translation;
|
||||
BlockPedestal pedestal = (BlockPedestal) state.getBlock();
|
||||
matrices.translate(translate.getX(), translate.getY(), translate.getZ());
|
||||
matrices.translate(0.5, pedestal.getHeight(state), 0.5);
|
||||
if (activeItem.getItem() instanceof BlockItem) {
|
||||
matrices.scale(1.5F, 1.5F, 1.5F);
|
||||
} else {
|
||||
matrices.scale(1.25F, 1.25F, 1.25F);
|
||||
}
|
||||
|
||||
float rotation = (blockEntity.getAge() + tickDelta) / 25.0F + 6.0F;
|
||||
matrices.multiply(Vector3f.POSITIVE_Y.getRadialQuaternion(rotation));
|
||||
if (state.isOf(EndBlocks.ETERNAL_PEDESTAL) && state.get(EternalPedestal.ACTIVATED)) {
|
||||
float altitude = MathHelper.sin((blockEntity.getAge() + tickDelta) / 10.0F) * 0.1F + 0.1F;
|
||||
matrices.translate(0.0D, altitude, 0.0D);
|
||||
float[] colors = DyeColor.MAGENTA.getColorComponents();
|
||||
int y = blockEntity.getPos().getY();
|
||||
VertexConsumer vertexConsumer = vertexConsumers.getBuffer(RenderLayer.getBeaconBeam(BEAM_TEXTURE, true));
|
||||
BeamRenderer.renderLightBeam(matrices, vertexConsumer, tickDelta, -y, 1024 - y, colors, 0.25F, 0.15F, 0.2F);
|
||||
}
|
||||
|
||||
if (activeItem.getItem() == Items.END_CRYSTAL) {
|
||||
EndCrystalRenderer.render(blockEntity.getAge(), blockEntity.getMaxAge(), tickDelta, matrices, vertexConsumers, light);
|
||||
} else {
|
||||
minecraft.getItemRenderer().renderItem(activeItem, ModelTransformation.Mode.GROUND, false, matrices, vertexConsumers, light, overlay, model);
|
||||
}
|
||||
matrices.pop();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue