Some optimization and tweaks
- infusion ritual tweak; - hydrotermal vent block entity tweak;
This commit is contained in:
parent
edf82ce363
commit
9b1776879b
9 changed files with 49 additions and 58 deletions
|
@ -118,7 +118,7 @@ public class PedestalBlock extends BaseBlockNotFull implements EntityBlock {
|
|||
if (pedestal.isEmpty()) {
|
||||
ItemStack itemStack = player.getItemInHand(hand);
|
||||
if (itemStack.isEmpty()) return InteractionResult.CONSUME;
|
||||
pedestal.setItem(0, itemStack.split(1));
|
||||
pedestal.setItem(0, itemStack);
|
||||
checkRitual(world, pos);
|
||||
return InteractionResult.SUCCESS;
|
||||
} else {
|
||||
|
|
|
@ -31,9 +31,10 @@ public class BlockEntityHydrothermalVent extends BlockEntity implements Tickable
|
|||
@Override
|
||||
public void tick() {
|
||||
if (level != null) {
|
||||
if (level.random.nextInt(20) == 0) {
|
||||
BlockState state = getBlockState();
|
||||
if (state.is(EndBlocks.HYDROTHERMAL_VENT) && state.getValue(HydrothermalVentBlock.ACTIVATED)) {
|
||||
BlockState state = getBlockState();
|
||||
if (state.is(EndBlocks.HYDROTHERMAL_VENT)) {
|
||||
boolean active = state.getValue(HydrothermalVentBlock.ACTIVATED);
|
||||
if (active && level.random.nextInt(20) == 0) {
|
||||
double x = worldPosition.getX() + level.random.nextDouble();
|
||||
double y = worldPosition.getY() + 0.9 + level.random.nextDouble() * 0.3;
|
||||
double z = worldPosition.getZ() + level.random.nextDouble();
|
||||
|
@ -43,21 +44,23 @@ public class BlockEntityHydrothermalVent extends BlockEntity implements Tickable
|
|||
level.addParticle(ParticleTypes.BUBBLE, x, y, z, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
MutableBlockPos mutable = worldPosition.mutable().move(Direction.UP);
|
||||
AABB box = new AABB(mutable.offset(-1, 0, -1), mutable.offset(1, 25, 1));
|
||||
List<LivingEntity> entities = level.getEntitiesOfClass(LivingEntity.class, box);
|
||||
if (entities.size() > 0) {
|
||||
while (mutable.getY() < box.maxY) {
|
||||
BlockState blockState = level.getBlockState(mutable);
|
||||
if (blockState.isSolidRender(level, mutable)) break;
|
||||
if (blockState.isAir()) {
|
||||
float force = (float) ((1.0 - (mutable.getY() / box.maxY)) / 5.0);
|
||||
entities.stream().filter(entity -> (int) entity.getY() == mutable.getY() &&
|
||||
hasElytra(entity) && entity.isFallFlying())
|
||||
.forEach(entity -> entity.moveRelative(force, POSITIVE_Y));
|
||||
MutableBlockPos mutable = worldPosition.mutable().move(Direction.UP);
|
||||
int height = active ? 85 : 25;
|
||||
AABB box = new AABB(mutable.offset(-1, 0, -1), mutable.offset(1, height, 1));
|
||||
List<LivingEntity> entities = level.getEntitiesOfClass(LivingEntity.class, box);
|
||||
if (entities.size() > 0) {
|
||||
while (mutable.getY() < box.maxY) {
|
||||
BlockState blockState = level.getBlockState(mutable);
|
||||
if (blockState.isSolidRender(level, mutable)) break;
|
||||
if (blockState.isAir()) {
|
||||
double mult = active ? 3.0 : 5.0;
|
||||
float force = (float) ((1.0 - (mutable.getY() / box.maxY)) / mult);
|
||||
entities.stream().filter(entity -> (int) entity.getY() == mutable.getY() &&
|
||||
hasElytra(entity) && entity.isFallFlying())
|
||||
.forEach(entity -> entity.moveRelative(force, POSITIVE_Y));
|
||||
}
|
||||
mutable.move(Direction.UP);
|
||||
}
|
||||
mutable.move(Direction.UP);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ public class PedestalBlockEntity extends BlockEntity implements Container, Ticka
|
|||
|
||||
@Override
|
||||
public void setItem(int slot, ItemStack stack) {
|
||||
activeItem = stack;
|
||||
activeItem = stack.split(1);
|
||||
setChanged();
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ public class InfusionRecipe implements Recipe<InfusionRitual>, BetterEndRecipe {
|
|||
|
||||
@Override
|
||||
public ItemStack assemble(InfusionRitual ritual) {
|
||||
return this.output.copy();
|
||||
return output.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -11,6 +11,7 @@ import net.minecraft.nbt.CompoundTag;
|
|||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.Container;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
|
@ -109,11 +110,8 @@ public class InfusionRitual implements Container {
|
|||
if (!checkRecipe()) return;
|
||||
progress++;
|
||||
if (progress == time) {
|
||||
input.removeItemNoUpdate(0);
|
||||
clearContent();
|
||||
input.setItem(0, activeRecipe.assemble(this));
|
||||
for (PedestalBlockEntity catalyst : catalysts) {
|
||||
catalyst.removeItemNoUpdate(0);
|
||||
}
|
||||
reset();
|
||||
} else {
|
||||
ServerLevel serverLevel = (ServerLevel) world;
|
||||
|
@ -159,9 +157,7 @@ public class InfusionRitual implements Container {
|
|||
public void clearContent() {
|
||||
if (!isValid()) return;
|
||||
input.clearContent();
|
||||
for (PedestalBlockEntity catalyst : catalysts) {
|
||||
catalyst.clearContent();
|
||||
}
|
||||
Arrays.stream(catalysts).forEach(PedestalBlockEntity::clearContent);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -213,9 +209,7 @@ public class InfusionRitual implements Container {
|
|||
public void setChanged() {
|
||||
if (isValid()) {
|
||||
input.setChanged();
|
||||
for (PedestalBlockEntity catalyst : catalysts) {
|
||||
catalyst.setChanged();
|
||||
}
|
||||
Arrays.stream(catalysts).forEach(PedestalBlockEntity::setChanged);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
"fabricloader": ">=0.11.0",
|
||||
"fabric": ">=0.32.0",
|
||||
"minecraft": ">=1.16.4",
|
||||
"bclib": ">=0.1.30"
|
||||
"bclib": ">=0.1.38"
|
||||
},
|
||||
"suggests": {
|
||||
"byg": ">=1.1.3",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue