Infusion pedestal (WIP), fix for #11

This commit is contained in:
Aleksey 2020-11-05 22:51:36 +03:00
parent 70f5e3e024
commit 36fa1ade9d
20 changed files with 220 additions and 21 deletions

View file

@ -33,21 +33,27 @@ public class BlockProperties {
}
public static enum PedestalState implements StringIdentifiable {
PEDESTAL_TOP,
COLUMN_TOP,
BOTTOM,
PILLAR,
COLUMN,
DEFAULT;
PEDESTAL_TOP("pedestal_top"),
COLUMN_TOP("column_top"),
BOTTOM("bottom"),
PILLAR("pillar"),
COLUMN("column"),
DEFAULT("default");
private final String name;
PedestalState(String name) {
this.name = name;
}
@Override
public String asString() {
return this.name().toLowerCase();
return this.name;
}
@Override
public String toString() {
return this.asString();
return this.name;
}
}
}

View file

@ -1,12 +1,22 @@
package ru.betterend.blocks;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.world.BlockView;
import ru.betterend.blocks.basis.BlockPedestal;
import ru.betterend.blocks.entities.InfusionPedestalEntity;
public class InfusionPedestal extends BlockPedestal {
public InfusionPedestal(Block parent) {
super(parent);
public InfusionPedestal() {
super(Blocks.OBSIDIAN);
this.height = 1.1F;
}
@Override
public BlockEntity createBlockEntity(BlockView world) {
return new InfusionPedestalEntity();
}
}

View file

@ -78,6 +78,7 @@ public class BlockPedestal extends BlockBaseNotFull implements BlockEntityProvid
}
protected final Block parent;
protected float height = 1.0F;
public BlockPedestal(Block parent) {
super(FabricBlockSettings.copyOf(parent));
@ -85,6 +86,13 @@ public class BlockPedestal extends BlockBaseNotFull implements BlockEntityProvid
this.parent = parent;
}
public float getHeight(BlockState state) {
if (state.getBlock() instanceof BlockPedestal && state.get(STATE) == PedestalState.PEDESTAL_TOP) {
return this.height - 0.2F;
}
return this.height;
}
@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
if (world.isClient || !state.isOf(this)) return ActionResult.CONSUME;

View file

@ -2,6 +2,7 @@ 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;
@ -19,7 +20,7 @@ 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.BlockProperties.PedestalState;
import ru.betterend.blocks.EternalPedestal;
import ru.betterend.blocks.basis.BlockPedestal;
import ru.betterend.blocks.entities.PedestalBlockEntity;
@ -46,12 +47,9 @@ public class PedestalItemRenderer extends BlockEntityRenderer<PedestalBlockEntit
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());
if (state.get(BlockPedestal.STATE) == PedestalState.DEFAULT) {
matrices.translate(0.5, 1.0, 0.5);
} else {
matrices.translate(0.5, 0.8, 0.5);
}
matrices.translate(0.5, pedestal.getHeight(state), 0.5);
if (activeItem.getItem() instanceof BlockItem) {
matrices.scale(1.5F, 1.5F, 1.5F);
} else {