Infusion rituals
This commit is contained in:
parent
1e4b7377f2
commit
bdf3d0afb1
9 changed files with 68 additions and 4 deletions
|
@ -29,6 +29,7 @@ public class InfusionPedestal extends BlockPedestal {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
|
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
|
||||||
|
if (world.isClient || !state.isOf(this)) return ActionResult.CONSUME;
|
||||||
BlockEntity blockEntity = world.getBlockEntity(pos);
|
BlockEntity blockEntity = world.getBlockEntity(pos);
|
||||||
InfusionPedestalEntity pedestal = null;
|
InfusionPedestalEntity pedestal = null;
|
||||||
if (blockEntity instanceof InfusionPedestalEntity) {
|
if (blockEntity instanceof InfusionPedestalEntity) {
|
||||||
|
|
|
@ -4,11 +4,16 @@ import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import ru.betterend.registry.EndBlockEntities;
|
||||||
import ru.betterend.rituals.EternalRitual;
|
import ru.betterend.rituals.EternalRitual;
|
||||||
|
|
||||||
public class EternalPedestalEntity extends PedestalBlockEntity {
|
public class EternalPedestalEntity extends PedestalBlockEntity {
|
||||||
private EternalRitual linkedRitual;
|
private EternalRitual linkedRitual;
|
||||||
|
|
||||||
|
public EternalPedestalEntity() {
|
||||||
|
super(EndBlockEntities.ETERNAL_PEDESTAL);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean hasRitual() {
|
public boolean hasRitual() {
|
||||||
return this.linkedRitual != null;
|
return this.linkedRitual != null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,12 +4,17 @@ import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import ru.betterend.registry.EndBlockEntities;
|
||||||
import ru.betterend.rituals.InfusionRitual;
|
import ru.betterend.rituals.InfusionRitual;
|
||||||
|
|
||||||
public class InfusionPedestalEntity extends PedestalBlockEntity {
|
public class InfusionPedestalEntity extends PedestalBlockEntity {
|
||||||
|
|
||||||
private InfusionRitual linkedRitual;
|
private InfusionRitual linkedRitual;
|
||||||
|
|
||||||
|
public InfusionPedestalEntity() {
|
||||||
|
super(EndBlockEntities.INFUSION_PEDESTAL);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setLocation(World world, BlockPos pos) {
|
public void setLocation(World world, BlockPos pos) {
|
||||||
super.setLocation(world, pos);
|
super.setLocation(world, pos);
|
||||||
|
@ -38,6 +43,11 @@ public class InfusionPedestalEntity extends PedestalBlockEntity {
|
||||||
super.tick();
|
super.tick();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompoundTag toInitialChunkDataTag() {
|
||||||
|
return this.toTag(new CompoundTag());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fromTag(BlockState state, CompoundTag tag) {
|
public void fromTag(BlockState state, CompoundTag tag) {
|
||||||
super.fromTag(state, tag);
|
super.fromTag(state, tag);
|
||||||
|
|
|
@ -2,6 +2,7 @@ package ru.betterend.blocks.entities;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.entity.BlockEntity;
|
import net.minecraft.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.block.entity.BlockEntityType;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.inventory.Inventory;
|
import net.minecraft.inventory.Inventory;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
@ -22,6 +23,10 @@ public class PedestalBlockEntity extends BlockEntity implements Inventory, Ticka
|
||||||
super(EndBlockEntities.PEDESTAL);
|
super(EndBlockEntities.PEDESTAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PedestalBlockEntity(BlockEntityType<?> type) {
|
||||||
|
super(type);
|
||||||
|
}
|
||||||
|
|
||||||
public int getAge() {
|
public int getAge() {
|
||||||
return this.age;
|
return this.age;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ import ru.betterend.client.render.BeamRenderer;
|
||||||
import ru.betterend.registry.EndBlocks;
|
import ru.betterend.registry.EndBlocks;
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public class PedestalItemRenderer extends BlockEntityRenderer<PedestalBlockEntity> {
|
public class PedestalItemRenderer<T extends PedestalBlockEntity> extends BlockEntityRenderer<T> {
|
||||||
private static final Identifier BEAM_TEXTURE = new Identifier("textures/entity/end_gateway_beam.png");
|
private static final Identifier BEAM_TEXTURE = new Identifier("textures/entity/end_gateway_beam.png");
|
||||||
|
|
||||||
public PedestalItemRenderer(BlockEntityRenderDispatcher dispatcher) {
|
public PedestalItemRenderer(BlockEntityRenderDispatcher dispatcher) {
|
||||||
|
@ -34,7 +34,7 @@ public class PedestalItemRenderer extends BlockEntityRenderer<PedestalBlockEntit
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(PedestalBlockEntity blockEntity, float tickDelta, MatrixStack matrices,
|
public void render(T blockEntity, float tickDelta, MatrixStack matrices,
|
||||||
VertexConsumerProvider vertexConsumers, int light, int overlay) {
|
VertexConsumerProvider vertexConsumers, int light, int overlay) {
|
||||||
|
|
||||||
if (blockEntity.isEmpty()) return;
|
if (blockEntity.isEmpty()) return;
|
||||||
|
|
|
@ -14,6 +14,7 @@ public class InfusionRecipes {
|
||||||
.addCatalyst(2, EndItems.CRYSTAL_SHARDS)
|
.addCatalyst(2, EndItems.CRYSTAL_SHARDS)
|
||||||
.addCatalyst(4, EndItems.CRYSTAL_SHARDS)
|
.addCatalyst(4, EndItems.CRYSTAL_SHARDS)
|
||||||
.addCatalyst(6, EndItems.CRYSTAL_SHARDS)
|
.addCatalyst(6, EndItems.CRYSTAL_SHARDS)
|
||||||
|
.setTime(100)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
InfusionRecipe.Builder.create("eternal_crystal")
|
InfusionRecipe.Builder.create("eternal_crystal")
|
||||||
|
@ -27,6 +28,7 @@ public class InfusionRecipes {
|
||||||
.addCatalyst(3, EndItems.ENDER_DUST)
|
.addCatalyst(3, EndItems.ENDER_DUST)
|
||||||
.addCatalyst(5, EndItems.ENDER_DUST)
|
.addCatalyst(5, EndItems.ENDER_DUST)
|
||||||
.addCatalyst(7, EndItems.ENDER_DUST)
|
.addCatalyst(7, EndItems.ENDER_DUST)
|
||||||
|
.setTime(250)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,8 @@ import net.minecraft.item.BlockItem;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.util.registry.Registry;
|
||||||
import ru.betterend.BetterEnd;
|
import ru.betterend.BetterEnd;
|
||||||
import ru.betterend.blocks.EndStoneSmelter;
|
import ru.betterend.blocks.EndStoneSmelter;
|
||||||
|
import ru.betterend.blocks.EternalPedestal;
|
||||||
|
import ru.betterend.blocks.InfusionPedestal;
|
||||||
import ru.betterend.blocks.basis.BlockBarrel;
|
import ru.betterend.blocks.basis.BlockBarrel;
|
||||||
import ru.betterend.blocks.basis.BlockChest;
|
import ru.betterend.blocks.basis.BlockChest;
|
||||||
import ru.betterend.blocks.basis.BlockPedestal;
|
import ru.betterend.blocks.basis.BlockPedestal;
|
||||||
|
@ -28,9 +30,9 @@ public class EndBlockEntities {
|
||||||
BlockEntityType.Builder.create(EndStoneSmelterBlockEntity::new, EndBlocks.END_STONE_SMELTER));
|
BlockEntityType.Builder.create(EndStoneSmelterBlockEntity::new, EndBlocks.END_STONE_SMELTER));
|
||||||
public final static BlockEntityType<PedestalBlockEntity> PEDESTAL = registerBlockEntity("pedestal",
|
public final static BlockEntityType<PedestalBlockEntity> PEDESTAL = registerBlockEntity("pedestal",
|
||||||
BlockEntityType.Builder.create(PedestalBlockEntity::new, getPedestals()));
|
BlockEntityType.Builder.create(PedestalBlockEntity::new, getPedestals()));
|
||||||
public final static BlockEntityType<PedestalBlockEntity> ETERNAL_PEDESTAL = registerBlockEntity("eternal_pedestal",
|
public final static BlockEntityType<EternalPedestalEntity> ETERNAL_PEDESTAL = registerBlockEntity("eternal_pedestal",
|
||||||
BlockEntityType.Builder.create(EternalPedestalEntity::new, EndBlocks.ETERNAL_PEDESTAL));
|
BlockEntityType.Builder.create(EternalPedestalEntity::new, EndBlocks.ETERNAL_PEDESTAL));
|
||||||
public final static BlockEntityType<PedestalBlockEntity> INFUSION_PEDESTAL = registerBlockEntity("infusion_pedestal",
|
public final static BlockEntityType<InfusionPedestalEntity> INFUSION_PEDESTAL = registerBlockEntity("infusion_pedestal",
|
||||||
BlockEntityType.Builder.create(InfusionPedestalEntity::new, EndBlocks.INFUSION_PEDESTAL));
|
BlockEntityType.Builder.create(InfusionPedestalEntity::new, EndBlocks.INFUSION_PEDESTAL));
|
||||||
public static final BlockEntityType<EChestBlockEntity> CHEST = registerBlockEntity("chest",
|
public static final BlockEntityType<EChestBlockEntity> CHEST = registerBlockEntity("chest",
|
||||||
BlockEntityType.Builder.create(EChestBlockEntity::new, getChests()));
|
BlockEntityType.Builder.create(EChestBlockEntity::new, getChests()));
|
||||||
|
@ -89,6 +91,8 @@ public class EndBlockEntities {
|
||||||
EndItems.getModBlocks().forEach((item) -> {
|
EndItems.getModBlocks().forEach((item) -> {
|
||||||
if (item instanceof BlockItem) {
|
if (item instanceof BlockItem) {
|
||||||
Block block = ((BlockItem) item).getBlock();
|
Block block = ((BlockItem) item).getBlock();
|
||||||
|
if (block instanceof EternalPedestal ||
|
||||||
|
block instanceof InfusionPedestal) return;
|
||||||
if (block instanceof BlockPedestal) {
|
if (block instanceof BlockPedestal) {
|
||||||
result.add(block);
|
result.add(block);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,5 +13,7 @@ public class EndBlockEntityRenders {
|
||||||
BlockEntityRendererRegistry.INSTANCE.register(EndBlockEntities.CHEST, EndChestBlockEntityRenderer::new);
|
BlockEntityRendererRegistry.INSTANCE.register(EndBlockEntities.CHEST, EndChestBlockEntityRenderer::new);
|
||||||
BlockEntityRendererRegistry.INSTANCE.register(EndBlockEntities.SIGN, EndSignBlockEntityRenderer::new);
|
BlockEntityRendererRegistry.INSTANCE.register(EndBlockEntities.SIGN, EndSignBlockEntityRenderer::new);
|
||||||
BlockEntityRendererRegistry.INSTANCE.register(EndBlockEntities.PEDESTAL, PedestalItemRenderer::new);
|
BlockEntityRendererRegistry.INSTANCE.register(EndBlockEntities.PEDESTAL, PedestalItemRenderer::new);
|
||||||
|
BlockEntityRendererRegistry.INSTANCE.register(EndBlockEntities.ETERNAL_PEDESTAL, PedestalItemRenderer::new);
|
||||||
|
BlockEntityRendererRegistry.INSTANCE.register(EndBlockEntities.INFUSION_PEDESTAL, PedestalItemRenderer::new);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,10 +7,15 @@ import net.minecraft.block.entity.BlockEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.inventory.Inventory;
|
import net.minecraft.inventory.Inventory;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.item.Items;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.particle.ItemStackParticleEffect;
|
||||||
|
import net.minecraft.particle.ParticleTypes;
|
||||||
|
import net.minecraft.server.world.ServerWorld;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
import ru.betterend.blocks.entities.InfusionPedestalEntity;
|
import ru.betterend.blocks.entities.InfusionPedestalEntity;
|
||||||
import ru.betterend.blocks.entities.PedestalBlockEntity;
|
import ru.betterend.blocks.entities.PedestalBlockEntity;
|
||||||
import ru.betterend.recipe.builders.InfusionRecipe;
|
import ru.betterend.recipe.builders.InfusionRecipe;
|
||||||
|
@ -57,6 +62,20 @@ public class InfusionRitual implements Inventory {
|
||||||
|
|
||||||
public boolean checkRecipe() {
|
public boolean checkRecipe() {
|
||||||
if (!isValid()) return false;
|
if (!isValid()) return false;
|
||||||
|
if (hasRecipe()) {
|
||||||
|
InfusionRecipe recipe = this.world.getRecipeManager().getFirstMatch(InfusionRecipe.TYPE, this, world).orElse(null);
|
||||||
|
if (recipe == null) {
|
||||||
|
this.activeRecipe = null;
|
||||||
|
this.progress = 0;
|
||||||
|
this.time = 0;
|
||||||
|
return false;
|
||||||
|
} else if (recipe != activeRecipe) {
|
||||||
|
this.activeRecipe = recipe;
|
||||||
|
this.time = this.activeRecipe.getInfusionTime();
|
||||||
|
this.progress = 0;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
this.activeRecipe = this.world.getRecipeManager().getFirstMatch(InfusionRecipe.TYPE, this, world).orElse(null);
|
this.activeRecipe = this.world.getRecipeManager().getFirstMatch(InfusionRecipe.TYPE, this, world).orElse(null);
|
||||||
if (activeRecipe != null) {
|
if (activeRecipe != null) {
|
||||||
this.time = this.activeRecipe.getInfusionTime();
|
this.time = this.activeRecipe.getInfusionTime();
|
||||||
|
@ -68,6 +87,7 @@ public class InfusionRitual implements Inventory {
|
||||||
|
|
||||||
public void tick() {
|
public void tick() {
|
||||||
if (!isValid() || !hasRecipe()) return;
|
if (!isValid() || !hasRecipe()) return;
|
||||||
|
if (!checkRecipe()) return;
|
||||||
this.progress++;
|
this.progress++;
|
||||||
if (progress == time) {
|
if (progress == time) {
|
||||||
BlockState inputState = world.getBlockState(input.getPos());
|
BlockState inputState = world.getBlockState(input.getPos());
|
||||||
|
@ -79,7 +99,22 @@ public class InfusionRitual implements Inventory {
|
||||||
this.activeRecipe = null;
|
this.activeRecipe = null;
|
||||||
this.progress = 0;
|
this.progress = 0;
|
||||||
this.time = 0;
|
this.time = 0;
|
||||||
|
} else {
|
||||||
|
ServerWorld world = (ServerWorld) this.world;
|
||||||
|
BlockPos target = this.worldPos.up();
|
||||||
|
double tx = target.getX() + 0.5;
|
||||||
|
double ty = target.getY() + 1.75;
|
||||||
|
double tz = target.getZ() + 0.5;
|
||||||
|
for (PedestalBlockEntity catalyst : catalysts) {
|
||||||
|
BlockPos start = catalyst.getPos().up();
|
||||||
|
double sx = start.getX() + 0.5;
|
||||||
|
double sy = start.getY() + 0.25;
|
||||||
|
double sz = start.getZ() + 0.5;
|
||||||
|
ItemStackParticleEffect catalystParticle = new ItemStackParticleEffect(ParticleTypes.ITEM, catalyst.getStack(0));
|
||||||
|
world.spawnParticles(catalystParticle, sx, sy, sz, 0, tx - sx, ty - sy, tz - sz, 0.125);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue