Activation function

This commit is contained in:
paulevsGitch 2021-01-22 22:35:11 +03:00
parent c9aacbff2b
commit 3e9195b20b
7 changed files with 38 additions and 4 deletions

View file

@ -43,7 +43,10 @@ public class InfusionPedestal extends PedestalBlock {
}
}
}
ActionResult result = super.onUse(state, world, pos, player, hand, hit);
ActionResult result = ActionResult.FAIL;
if (hand != null) {
result = super.onUse(state, world, pos, player, hand, hit);
}
if (result == ActionResult.SUCCESS) {
if (pedestal != null) {
if (pedestal.hasRitual()) {

View file

@ -1,5 +1,6 @@
package ru.betterend.blocks.basis;
import java.awt.Point;
import java.io.Reader;
import java.util.HashMap;
import java.util.List;
@ -29,6 +30,7 @@ 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.BlockPos.Mutable;
import net.minecraft.util.math.Direction;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.shape.VoxelShape;
@ -38,9 +40,11 @@ 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.InfusionPedestal;
import ru.betterend.blocks.entities.PedestalBlockEntity;
import ru.betterend.patterns.Patterns;
import ru.betterend.registry.EndBlocks;
import ru.betterend.rituals.InfusionRitual;
import ru.betterend.util.BlocksHelper;
public class PedestalBlock extends BlockBaseNotFull implements BlockEntityProvider {
@ -110,6 +114,7 @@ public class PedestalBlock extends BlockBaseNotFull implements BlockEntityProvid
ItemStack itemStack = player.getStackInHand(hand);
if (itemStack.isEmpty()) return ActionResult.CONSUME;
pedestal.setStack(0, itemStack.split(1));
activate(world, pos, player, hand, hit);
return ActionResult.SUCCESS;
} else {
ItemStack itemStack = pedestal.getStack(0);
@ -123,6 +128,21 @@ public class PedestalBlock extends BlockBaseNotFull implements BlockEntityProvid
return ActionResult.PASS;
}
private void activate(World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
Mutable mut = new Mutable();
Point[] points = InfusionRitual.getMap();
for (Point p: points) {
mut.set(pos).move(p.x, 0, p.y);
BlockState state = world.getBlockState(mut);
if (state.getBlock() instanceof InfusionPedestal) {
ActionResult result = state.getBlock().onUse(state, world, mut, player, null, hit);
if (result == ActionResult.SUCCESS) {
break;
}
}
}
}
@Override
@Nullable
public BlockState getPlacementState(ItemPlacementContext context) {

View file

@ -18,7 +18,7 @@ import ru.betterend.particle.InfusionParticleType;
import ru.betterend.recipe.builders.InfusionRecipe;
public class InfusionRitual implements Inventory {
private static Point[] pedestalsMap = new Point[] {
private static final Point[] PEDESTALS_MAP = new Point[] {
new Point(0, 3), new Point(2, 2), new Point(3, 0), new Point(2, -2),
new Point(0, -3), new Point(-2, -2), new Point(-3, 0), new Point(-2, 2)
};
@ -40,6 +40,10 @@ public class InfusionRitual implements Inventory {
this.configure();
}
public static Point[] getMap() {
return PEDESTALS_MAP;
}
public void configure() {
if (world == null || world.isClient || worldPos == null) return;
BlockEntity inputEntity = world.getBlockEntity(worldPos);
@ -47,7 +51,7 @@ public class InfusionRitual implements Inventory {
this.input = (InfusionPedestalEntity) inputEntity;
}
int i = 0;
for(Point point : pedestalsMap) {
for(Point point : PEDESTALS_MAP) {
BlockPos.Mutable checkPos = worldPos.mutableCopy().move(Direction.EAST, point.x).move(Direction.NORTH, point.y);
BlockEntity catalystEntity = world.getBlockEntity(checkPos);
if (catalystEntity instanceof PedestalBlockEntity) {

View file

@ -2,7 +2,9 @@
"layers": [
{
"vertexSource": "canvas:shaders/material/default.vert",
"fragmentSource": "betterend:shaders/material/glow_green.frag"
"fragmentSource": "betterend:shaders/material/glow_green.frag",
"disableAo": true,
"disableDiffuse": true
}
]
}

View file

@ -9,6 +9,7 @@
"__comment": "Box1",
"from": [ 6, 0, 6 ],
"to": [ 10, 1, 10 ],
"shade": false,
"faces": {
"down": { "uv": [ 0, 0, 4, 4 ], "texture": "#texture" },
"up": { "uv": [ 0, 0, 4, 4 ], "texture": "#texture" },

View file

@ -10,6 +10,7 @@
"__comment": "Box1",
"from": [ 6, 15, 6 ],
"to": [ 10, 16, 10 ],
"shade": false,
"faces": {
"down": { "uv": [ 0, 0, 4, 4 ], "texture": "#rod" },
"up": { "uv": [ 0, 0, 4, 4 ], "texture": "#rod" },

View file

@ -19,6 +19,7 @@
"__comment": "Box3",
"from": [ 7, 3, 0 ],
"to": [ 9, 5, 3 ],
"shade": false,
"faces": {
"down": { "uv": [ 0, 8, 2, 11 ], "texture": "#texture" },
"up": { "uv": [ 0, 11, 2, 8 ], "texture": "#texture" },
@ -32,6 +33,7 @@
"__comment": "Box4",
"from": [ 3, 6, 1 ],
"to": [ 5, 9, 3 ],
"shade": false,
"faces": {
"down": { "uv": [ 0, 12, 2, 14 ], "texture": "#texture" },
"up": { "uv": [ 0, 12, 2, 14 ], "texture": "#texture" },
@ -45,6 +47,7 @@
"__comment": "Box4",
"from": [ 11, 6, 1 ],
"to": [ 13, 9, 3 ],
"shade": false,
"faces": {
"down": { "uv": [ 0, 12, 2, 14 ], "texture": "#texture" },
"up": { "uv": [ 0, 12, 2, 14 ], "texture": "#texture" },