Some optimization and tweaks

- infusion ritual tweak;
- hydrotermal vent block entity tweak;
This commit is contained in:
Aleksey 2021-06-18 12:38:04 +03:00
parent edf82ce363
commit 9b1776879b
9 changed files with 49 additions and 58 deletions

View file

@ -20,15 +20,13 @@ group = project.maven_group
repositories {
maven { url "https://maven.dblsaiko.net/" }
maven { url "http://server.bbkr.space:8081/artifactory/libs-release/" }
maven { url "https://server.bbkr.space:8081/artifactory/libs-release/" }
maven { url "https://maven.fabricmc.net/" }
maven { url 'https://maven.blamejared.com' }
maven { url "https://maven.shedaniel.me/" }
maven { url 'https://jitpack.io' }
}
apply plugin: 'maven'
dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings minecraft.officialMojangMappings()
@ -72,15 +70,12 @@ def useApi(String dep) {
processResources {
inputs.property "version", project.version
duplicatesStrategy = 'WARN'
from(sourceSets.main.resources.srcDirs) {
include "fabric.mod.json"
expand "version": project.version
}
from(sourceSets.main.resources.srcDirs) {
exclude "fabric.mod.json"
}
}
// ensure that the encoding is set to UTF-8, no matter what the system default is
@ -143,21 +138,21 @@ task release(dependsOn: [remapJar, sourcesJar, javadocJar]) {
}
// configure the maven publication
publishing {
publications {
mavenJava(MavenPublication) {
artifact(remapJar) {
builtBy remapJar
}
artifact(sourcesJar) {
builtBy remapSourcesJar
}
}
}
// select the repositories you want to publish to
repositories {
// uncomment to publish to the local maven
// mavenLocal()
}
}
//publishing {
// publications {
// mavenJava(MavenPublication) {
// artifact(remapJar) {
// builtBy remapJar
// }
// artifact(sourcesJar) {
// builtBy remapSourcesJar
// }
// }
// }
//
// // select the repositories you want to publish to
// repositories {
// // uncomment to publish to the local maven
// // mavenLocal()
// }
//}

View file

@ -1,5 +1,4 @@
# Done to increase the memory available to gradle.
org.gradle.java.home=/usr/local/java/jdk-16.0.1
org.gradle.jvmargs=-Xmx2G
# Fabric Properties

View file

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View file

@ -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 {

View file

@ -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);
}
}
}

View file

@ -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();
}

View file

@ -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

View file

@ -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);
}
}

View file

@ -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",