Moooooore pedestals!
This commit is contained in:
parent
e6cafec945
commit
454fd1439b
41 changed files with 468 additions and 14 deletions
46
src/main/java/ru/betterend/blocks/EndPedestal.java
Normal file
46
src/main/java/ru/betterend/blocks/EndPedestal.java
Normal file
|
@ -0,0 +1,46 @@
|
|||
package ru.betterend.blocks;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.blocks.basis.BlockPedestal;
|
||||
import ru.betterend.interfaces.Patterned;
|
||||
|
||||
public class EndPedestal extends BlockPedestal {
|
||||
|
||||
public EndPedestal(Block parent) {
|
||||
super(parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String block) {
|
||||
Identifier blockId = Registry.BLOCK.getId(parent);
|
||||
String name = blockId.getPath();
|
||||
Map<String, String> textures = new HashMap<String, String>() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
{
|
||||
put("%mod%", BetterEnd.MOD_ID );
|
||||
put("%top%", name + "_polished");
|
||||
put("%base%", name + "_polished");
|
||||
put("%pillar%", name + "_pillar_side");
|
||||
put("%bottom%", name + "_polished");
|
||||
}
|
||||
};
|
||||
if (block.contains("column_top")) {
|
||||
return Patterned.createJson(Patterned.PEDESTAL_MODEL_COLUMN_TOP, textures);
|
||||
} else if (block.contains("column")) {
|
||||
return Patterned.createJson(Patterned.PEDESTAL_MODEL_COLUMN, textures);
|
||||
} else if (block.contains("top")) {
|
||||
return Patterned.createJson(Patterned.PEDESTAL_MODEL_TOP, textures);
|
||||
} else if (block.contains("bottom")) {
|
||||
return Patterned.createJson(Patterned.PEDESTAL_MODEL_BOTTOM, textures);
|
||||
} else if (block.contains("pillar")) {
|
||||
return Patterned.createJson(Patterned.PEDESTAL_MODEL_PILLAR, textures);
|
||||
}
|
||||
return Patterned.createJson(Patterned.PEDESTAL_MODEL_DEFAULT, textures);
|
||||
}
|
||||
}
|
|
@ -23,6 +23,7 @@ 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.PedestalBlockEntity;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
|
|
45
src/main/java/ru/betterend/blocks/PedestalVanilla.java
Normal file
45
src/main/java/ru/betterend/blocks/PedestalVanilla.java
Normal file
|
@ -0,0 +1,45 @@
|
|||
package ru.betterend.blocks;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import ru.betterend.blocks.basis.BlockPedestal;
|
||||
import ru.betterend.interfaces.Patterned;
|
||||
|
||||
public class PedestalVanilla extends BlockPedestal {
|
||||
|
||||
public PedestalVanilla(Block parent) {
|
||||
super(parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String block) {
|
||||
Identifier blockId = Registry.BLOCK.getId(parent);
|
||||
String name = blockId.getPath().replace("_block", "");
|
||||
Map<String, String> textures = new HashMap<String, String>() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
{
|
||||
put("%mod%", blockId.getNamespace() );
|
||||
put("%top%", "polished_" + name);
|
||||
put("%base%", "polished_" + name);
|
||||
put("%pillar%", name + "_pillar");
|
||||
put("%bottom%", "polished_" + name);
|
||||
}
|
||||
};
|
||||
if (block.contains("column_top")) {
|
||||
return Patterned.createJson(Patterned.PEDESTAL_MODEL_COLUMN_TOP, textures);
|
||||
} else if (block.contains("column")) {
|
||||
return Patterned.createJson(Patterned.PEDESTAL_MODEL_COLUMN, textures);
|
||||
} else if (block.contains("top")) {
|
||||
return Patterned.createJson(Patterned.PEDESTAL_MODEL_TOP, textures);
|
||||
} else if (block.contains("bottom")) {
|
||||
return Patterned.createJson(Patterned.PEDESTAL_MODEL_BOTTOM, textures);
|
||||
} else if (block.contains("pillar")) {
|
||||
return Patterned.createJson(Patterned.PEDESTAL_MODEL_PILLAR, textures);
|
||||
}
|
||||
return Patterned.createJson(Patterned.PEDESTAL_MODEL_DEFAULT, textures);
|
||||
}
|
||||
}
|
|
@ -1,10 +1,14 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockEntityProvider;
|
||||
import net.minecraft.block.BlockState;
|
||||
|
@ -20,17 +24,21 @@ import net.minecraft.state.property.BooleanProperty;
|
|||
import net.minecraft.state.property.EnumProperty;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
|
||||
import ru.betterend.blocks.BlockProperties;
|
||||
import ru.betterend.blocks.BlockProperties.PedestalState;
|
||||
import ru.betterend.blocks.entities.PedestalBlockEntity;
|
||||
import ru.betterend.interfaces.Patterned;
|
||||
import ru.betterend.util.BlocksHelper;
|
||||
|
||||
public class BlockPedestal extends BlockBaseNotFull implements BlockEntityProvider {
|
||||
|
@ -44,9 +52,12 @@ public class BlockPedestal extends BlockBaseNotFull implements BlockEntityProvid
|
|||
private static final VoxelShape SHAPE_COLUMN_TOP;
|
||||
private static final VoxelShape SHAPE_BOTTOM;
|
||||
|
||||
protected final Block parent;
|
||||
|
||||
public BlockPedestal(Block parent) {
|
||||
super(FabricBlockSettings.copyOf(parent));
|
||||
this.setDefaultState(stateManager.getDefaultState().with(STATE, PedestalState.DEFAULT).with(HAS_ITEM, false));
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -131,9 +142,9 @@ public class BlockPedestal extends BlockBaseNotFull implements BlockEntityProvid
|
|||
return state.with(STATE, PedestalState.COLUMN);
|
||||
} else if (hasPedestalUnder && hasPedestalOver) {
|
||||
return state.with(STATE, PedestalState.PILLAR);
|
||||
} else if (hasPedestalUnder && !hasPedestalOver) {
|
||||
} else if (hasPedestalUnder) {
|
||||
return state.with(STATE, PedestalState.PEDESTAL_TOP);
|
||||
} else if (hasPedestalOver && !hasPedestalUnder) {
|
||||
} else if (hasPedestalOver) {
|
||||
return state.with(STATE, PedestalState.BOTTOM);
|
||||
}
|
||||
return state.with(STATE, PedestalState.DEFAULT);
|
||||
|
@ -260,15 +271,56 @@ public class BlockPedestal extends BlockBaseNotFull implements BlockEntityProvid
|
|||
return new PedestalBlockEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStatesPattern(Reader data) {
|
||||
Identifier blockId = Registry.BLOCK.getId(this);
|
||||
return Patterned.createJson(data, blockId, blockId.getPath());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String block) {
|
||||
Identifier blockId = Registry.BLOCK.getId(parent);
|
||||
String name = blockId.getPath();
|
||||
Map<String, String> textures = new HashMap<String, String>() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
{
|
||||
put("%mod%", blockId.getNamespace() );
|
||||
put("%top%", name + "_top");
|
||||
put("%base%", name + "_base");
|
||||
put("%pillar%", name + "_pillar");
|
||||
put("%bottom%", name + "_bottom");
|
||||
}
|
||||
};
|
||||
if (block.contains("column_top")) {
|
||||
return Patterned.createJson(Patterned.PEDESTAL_MODEL_COLUMN_TOP, textures);
|
||||
} else if (block.contains("column")) {
|
||||
return Patterned.createJson(Patterned.PEDESTAL_MODEL_COLUMN, textures);
|
||||
} else if (block.contains("top")) {
|
||||
return Patterned.createJson(Patterned.PEDESTAL_MODEL_TOP, textures);
|
||||
} else if (block.contains("bottom")) {
|
||||
return Patterned.createJson(Patterned.PEDESTAL_MODEL_BOTTOM, textures);
|
||||
} else if (block.contains("pillar")) {
|
||||
return Patterned.createJson(Patterned.PEDESTAL_MODEL_PILLAR, textures);
|
||||
}
|
||||
return Patterned.createJson(Patterned.PEDESTAL_MODEL_DEFAULT, textures);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier statePatternId() {
|
||||
return Patterned.PEDESTAL_STATES_PATTERN;
|
||||
}
|
||||
|
||||
static {
|
||||
VoxelShape basinUp = Block.createCuboidShape(2, 3, 2, 14, 4, 14);
|
||||
VoxelShape basinDown = Block.createCuboidShape(0, 0, 0, 16, 3, 16);
|
||||
VoxelShape basin = VoxelShapes.union(basinDown, basinUp);
|
||||
VoxelShape columnTop = Block.createCuboidShape(1, 14, 1, 15, 16, 15);
|
||||
VoxelShape columnTopUp = Block.createCuboidShape(1, 14, 1, 15, 16, 15);
|
||||
VoxelShape columnTopDown = Block.createCuboidShape(2, 13, 2, 14, 14, 14);
|
||||
VoxelShape pedestalTop = Block.createCuboidShape(1, 8, 1, 15, 10, 15);
|
||||
VoxelShape pedestalDefault = Block.createCuboidShape(1, 12, 1, 15, 14, 15);
|
||||
VoxelShape pillar = Block.createCuboidShape(3, 0, 3, 13, 8, 13);
|
||||
VoxelShape pillarDefault = Block.createCuboidShape(3, 0, 3, 13, 12, 13);
|
||||
VoxelShape columnTop = VoxelShapes.union(columnTopDown, columnTopUp);
|
||||
VoxelShape basin = VoxelShapes.union(basinDown, basinUp);
|
||||
SHAPE_PILLAR = Block.createCuboidShape(3, 0, 3, 13, 16, 13);
|
||||
SHAPE_DEFAULT = VoxelShapes.union(basin, pillarDefault, pedestalDefault);
|
||||
SHAPE_PEDESTAL_TOP = VoxelShapes.union(pillar, pedestalTop);
|
||||
|
|
|
@ -6,6 +6,7 @@ import net.minecraft.block.Blocks;
|
|||
import net.minecraft.block.MaterialColor;
|
||||
import net.minecraft.tag.BlockTags;
|
||||
import net.minecraft.tag.ItemTags;
|
||||
import ru.betterend.blocks.EndPedestal;
|
||||
import ru.betterend.blocks.basis.BlockBase;
|
||||
import ru.betterend.blocks.basis.BlockPillar;
|
||||
import ru.betterend.blocks.basis.BlockSlab;
|
||||
|
@ -28,6 +29,7 @@ public class StoneMaterial {
|
|||
public final Block wall;
|
||||
public final Block button;
|
||||
public final Block pressure_plate;
|
||||
public final Block pedestal;
|
||||
|
||||
public final Block bricks;
|
||||
public final Block brick_stairs;
|
||||
|
@ -46,6 +48,7 @@ public class StoneMaterial {
|
|||
wall = EndBlocks.registerBlock(name + "_wall", new BlockWall(stone));
|
||||
button = EndBlocks.registerBlock(name + "_button", new BlockStoneButton(stone));
|
||||
pressure_plate = EndBlocks.registerBlock(name + "_plate", new BlockStonePressurePlate(stone));
|
||||
pedestal = EndBlocks.registerBlock(name + "_pedestal", new EndPedestal(stone));
|
||||
|
||||
bricks = EndBlocks.registerBlock(name + "_bricks", new BlockBase(material));
|
||||
brick_stairs = EndBlocks.registerBlock(name + "_bricks_stairs", new BlockStairs(bricks));
|
||||
|
@ -57,6 +60,7 @@ public class StoneMaterial {
|
|||
GridRecipe.make(name + "_polished", polished).setOutputCount(4).setShape("##", "##").addMaterial('#', bricks).setGroup("end_tile").build();
|
||||
GridRecipe.make(name + "_tiles", tiles).setOutputCount(4).setShape("##", "##").addMaterial('#', polished).setGroup("end_small_tile").build();
|
||||
GridRecipe.make(name + "_pillar", pillar).setShape("#", "#").addMaterial('#', slab).setGroup("end_pillar").build();
|
||||
GridRecipe.make(name + "_pedestal", pedestal).setOutputCount(2).setShape("S", "#", "S").addMaterial('S', slab).addMaterial('#', pillar).setGroup("end_pedestal").build();
|
||||
|
||||
GridRecipe.make(name + "_stairs", stairs).setOutputCount(4).setShape("# ", "## ", "###").addMaterial('#', stone).setGroup("end_stone_stairs").build();
|
||||
GridRecipe.make(name + "_slab", slab).setOutputCount(6).setShape("###").addMaterial('#', stone).setGroup("end_stone_slabs").build();
|
||||
|
|
|
@ -16,7 +16,7 @@ public class PedestalBlockEntity extends BlockEntity implements Inventory, Ticka
|
|||
private int age;
|
||||
|
||||
public PedestalBlockEntity() {
|
||||
super(EndBlockEntities.ETERNAL_PEDESTAL);
|
||||
super(EndBlockEntities.PEDESTAL);
|
||||
}
|
||||
|
||||
public int getAge() {
|
||||
|
|
|
@ -12,11 +12,14 @@ import net.minecraft.client.render.block.entity.BlockEntityRenderer;
|
|||
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.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;
|
||||
import ru.betterend.client.render.BeamRenderer;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
|
@ -38,19 +41,29 @@ public class PedestalItemRenderer extends BlockEntityRenderer<PedestalBlockEntit
|
|||
BlockState state = blockEntity.getWorld().getBlockState(blockEntity.getPos());
|
||||
ItemStack activeItem = blockEntity.getStack(0);
|
||||
matrices.push();
|
||||
matrices.translate(0.5, 1.1, 0.5);
|
||||
if (state.get(BlockPedestal.STATE) == PedestalState.DEFAULT) {
|
||||
matrices.translate(0.5, 1.0, 0.5);
|
||||
} else {
|
||||
matrices.translate(0.5, 0.8, 0.5);
|
||||
}
|
||||
if (activeItem.getItem() instanceof BlockItem) {
|
||||
matrices.scale(1.5F, 1.5F, 1.5F);
|
||||
} else {
|
||||
matrices.scale(1.15F, 1.15F, 1.15F);
|
||||
}
|
||||
|
||||
float rotation = (blockEntity.getAge() + tickDelta) / 25.0F + 6.0F;
|
||||
float altitude = MathHelper.sin((blockEntity.getAge() + tickDelta) / 10.0F) * 0.1F;
|
||||
matrices.translate(0.0D, altitude, 0.0D);
|
||||
matrices.multiply(Vector3f.POSITIVE_Y.getRadialQuaternion(rotation));
|
||||
MinecraftClient minecraft = MinecraftClient.getInstance();
|
||||
minecraft.getItemRenderer().renderItem(activeItem, ModelTransformation.Mode.GROUND, light, overlay, matrices, vertexConsumers);
|
||||
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);
|
||||
}
|
||||
minecraft.getItemRenderer().renderItem(activeItem, ModelTransformation.Mode.GROUND, light, overlay, matrices, vertexConsumers);
|
||||
matrices.pop();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue