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 { repositories {
maven { url "https://maven.dblsaiko.net/" } 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.fabricmc.net/" }
maven { url 'https://maven.blamejared.com' } maven { url 'https://maven.blamejared.com' }
maven { url "https://maven.shedaniel.me/" } maven { url "https://maven.shedaniel.me/" }
maven { url 'https://jitpack.io' } maven { url 'https://jitpack.io' }
} }
apply plugin: 'maven'
dependencies { dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}" minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings minecraft.officialMojangMappings() mappings minecraft.officialMojangMappings()
@ -72,15 +70,12 @@ def useApi(String dep) {
processResources { processResources {
inputs.property "version", project.version inputs.property "version", project.version
duplicatesStrategy = 'WARN'
from(sourceSets.main.resources.srcDirs) { from(sourceSets.main.resources.srcDirs) {
include "fabric.mod.json" include "fabric.mod.json"
expand "version": project.version 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 // 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 // configure the maven publication
publishing { //publishing {
publications { // publications {
mavenJava(MavenPublication) { // mavenJava(MavenPublication) {
artifact(remapJar) { // artifact(remapJar) {
builtBy remapJar // builtBy remapJar
} // }
artifact(sourcesJar) { // artifact(sourcesJar) {
builtBy remapSourcesJar // builtBy remapSourcesJar
} // }
} // }
} // }
//
// select the repositories you want to publish to // // select the repositories you want to publish to
repositories { // repositories {
// uncomment to publish to the local maven // // uncomment to publish to the local maven
// mavenLocal() // // mavenLocal()
} // }
} //}

View file

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

View file

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists 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 zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

View file

@ -118,7 +118,7 @@ public class PedestalBlock extends BaseBlockNotFull implements EntityBlock {
if (pedestal.isEmpty()) { if (pedestal.isEmpty()) {
ItemStack itemStack = player.getItemInHand(hand); ItemStack itemStack = player.getItemInHand(hand);
if (itemStack.isEmpty()) return InteractionResult.CONSUME; if (itemStack.isEmpty()) return InteractionResult.CONSUME;
pedestal.setItem(0, itemStack.split(1)); pedestal.setItem(0, itemStack);
checkRitual(world, pos); checkRitual(world, pos);
return InteractionResult.SUCCESS; return InteractionResult.SUCCESS;
} else { } else {

View file

@ -31,9 +31,10 @@ public class BlockEntityHydrothermalVent extends BlockEntity implements Tickable
@Override @Override
public void tick() { public void tick() {
if (level != null) { if (level != null) {
if (level.random.nextInt(20) == 0) {
BlockState state = getBlockState(); BlockState state = getBlockState();
if (state.is(EndBlocks.HYDROTHERMAL_VENT) && state.getValue(HydrothermalVentBlock.ACTIVATED)) { 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 x = worldPosition.getX() + level.random.nextDouble();
double y = worldPosition.getY() + 0.9 + level.random.nextDouble() * 0.3; double y = worldPosition.getY() + 0.9 + level.random.nextDouble() * 0.3;
double z = worldPosition.getZ() + level.random.nextDouble(); double z = worldPosition.getZ() + level.random.nextDouble();
@ -43,16 +44,17 @@ public class BlockEntityHydrothermalVent extends BlockEntity implements Tickable
level.addParticle(ParticleTypes.BUBBLE, x, y, z, 0, 0, 0); level.addParticle(ParticleTypes.BUBBLE, x, y, z, 0, 0, 0);
} }
} }
}
MutableBlockPos mutable = worldPosition.mutable().move(Direction.UP); MutableBlockPos mutable = worldPosition.mutable().move(Direction.UP);
AABB box = new AABB(mutable.offset(-1, 0, -1), mutable.offset(1, 25, 1)); 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); List<LivingEntity> entities = level.getEntitiesOfClass(LivingEntity.class, box);
if (entities.size() > 0) { if (entities.size() > 0) {
while (mutable.getY() < box.maxY) { while (mutable.getY() < box.maxY) {
BlockState blockState = level.getBlockState(mutable); BlockState blockState = level.getBlockState(mutable);
if (blockState.isSolidRender(level, mutable)) break; if (blockState.isSolidRender(level, mutable)) break;
if (blockState.isAir()) { if (blockState.isAir()) {
float force = (float) ((1.0 - (mutable.getY() / box.maxY)) / 5.0); 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() && entities.stream().filter(entity -> (int) entity.getY() == mutable.getY() &&
hasElytra(entity) && entity.isFallFlying()) hasElytra(entity) && entity.isFallFlying())
.forEach(entity -> entity.moveRelative(force, POSITIVE_Y)); .forEach(entity -> entity.moveRelative(force, POSITIVE_Y));
@ -62,6 +64,7 @@ public class BlockEntityHydrothermalVent extends BlockEntity implements Tickable
} }
} }
} }
}
private boolean hasElytra(LivingEntity entity) { private boolean hasElytra(LivingEntity entity) {
Item item = entity.getItemBySlot(EquipmentSlot.CHEST).getItem(); Item item = entity.getItemBySlot(EquipmentSlot.CHEST).getItem();

View file

@ -75,7 +75,7 @@ public class PedestalBlockEntity extends BlockEntity implements Container, Ticka
@Override @Override
public void setItem(int slot, ItemStack stack) { public void setItem(int slot, ItemStack stack) {
activeItem = stack; activeItem = stack.split(1);
setChanged(); setChanged();
} }

View file

@ -66,7 +66,7 @@ public class InfusionRecipe implements Recipe<InfusionRitual>, BetterEndRecipe {
@Override @Override
public ItemStack assemble(InfusionRitual ritual) { public ItemStack assemble(InfusionRitual ritual) {
return this.output.copy(); return output.copy();
} }
@Override @Override

View file

@ -11,6 +11,7 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.Container; import net.minecraft.world.Container;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntity;
@ -109,11 +110,8 @@ public class InfusionRitual implements Container {
if (!checkRecipe()) return; if (!checkRecipe()) return;
progress++; progress++;
if (progress == time) { if (progress == time) {
input.removeItemNoUpdate(0); clearContent();
input.setItem(0, activeRecipe.assemble(this)); input.setItem(0, activeRecipe.assemble(this));
for (PedestalBlockEntity catalyst : catalysts) {
catalyst.removeItemNoUpdate(0);
}
reset(); reset();
} else { } else {
ServerLevel serverLevel = (ServerLevel) world; ServerLevel serverLevel = (ServerLevel) world;
@ -159,9 +157,7 @@ public class InfusionRitual implements Container {
public void clearContent() { public void clearContent() {
if (!isValid()) return; if (!isValid()) return;
input.clearContent(); input.clearContent();
for (PedestalBlockEntity catalyst : catalysts) { Arrays.stream(catalysts).forEach(PedestalBlockEntity::clearContent);
catalyst.clearContent();
}
} }
@Override @Override
@ -213,9 +209,7 @@ public class InfusionRitual implements Container {
public void setChanged() { public void setChanged() {
if (isValid()) { if (isValid()) {
input.setChanged(); input.setChanged();
for (PedestalBlockEntity catalyst : catalysts) { Arrays.stream(catalysts).forEach(PedestalBlockEntity::setChanged);
catalyst.setChanged();
}
} }
} }

View file

@ -46,7 +46,7 @@
"fabricloader": ">=0.11.0", "fabricloader": ">=0.11.0",
"fabric": ">=0.32.0", "fabric": ">=0.32.0",
"minecraft": ">=1.16.4", "minecraft": ">=1.16.4",
"bclib": ">=0.1.30" "bclib": ">=0.1.38"
}, },
"suggests": { "suggests": {
"byg": ">=1.1.3", "byg": ">=1.1.3",