This commit is contained in:
rfresh2
2024-10-26 12:34:31 -07:00
parent 9eefcbc9b6
commit 55cb180755
24 changed files with 100 additions and 146 deletions

View File

@@ -84,7 +84,7 @@ public final class ChunkPacker {
Block block = state.getBlock();
if (CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.contains(block)) {
String name = BlockUtils.blockToString(block);
specialBlocks.computeIfAbsent(name, b -> new ArrayList<>()).add(new BlockPos(x, y+chunk.getMinBuildHeight(), z));
specialBlocks.computeIfAbsent(name, b -> new ArrayList<>()).add(new BlockPos(x, y+chunk.getMinY(), z));
}
}
}

View File

@@ -156,7 +156,7 @@ public enum FasterWorldScanner implements IWorldScanner {
long chunkX = (long) pos.x << 4;
long chunkZ = (long) pos.z << 4;
int playerSectionY = (ctx.playerFeet().y - ctx.world().getMinBuildHeight()) >> 4;
int playerSectionY = (ctx.playerFeet().y - ctx.world().getMinY()) >> 4;
return collectChunkSections(lookup, chunkProvider.getChunk(pos.x, pos.z, false), chunkX, chunkZ, playerSectionY).stream();
}
@@ -165,7 +165,7 @@ public enum FasterWorldScanner implements IWorldScanner {
private List<BlockPos> collectChunkSections(BlockOptionalMetaLookup lookup, LevelChunk chunk, long chunkX, long chunkZ, int playerSection) {
// iterate over sections relative to player
List<BlockPos> blocks = new ArrayList<>();
int chunkY = chunk.getMinBuildHeight();
int chunkY = chunk.getMinY();
LevelChunkSection[] sections = chunk.getSections();
int l = sections.length;
int i = playerSection - 1;

View File

@@ -140,7 +140,7 @@ public class MovementFall extends Movement {
}
state.setInput(Input.MOVE_FORWARD, true);
}
Vec3i avoid = Optional.ofNullable(avoid()).map(Direction::getNormal).orElse(null);
Vec3i avoid = Optional.ofNullable(avoid()).map(Direction::getUnitVec3i).orElse(null);
if (avoid == null) {
avoid = src.subtract(dest);
} else {

View File

@@ -310,7 +310,7 @@ public final class FarmProcess extends BaritoneProcessHelper implements IFarmPro
if (!(ctx.world().getBlockState(pos.relative(dir)).getBlock() instanceof AirBlock)) {
continue;
}
Vec3 faceCenter = Vec3.atCenterOf(pos).add(Vec3.atLowerCornerOf(dir.getNormal()).scale(0.5));
Vec3 faceCenter = Vec3.atCenterOf(pos).add(Vec3.atLowerCornerOf(dir.getUnitVec3i()).scale(0.5));
Optional<Rotation> rot = RotationUtils.reachableOffset(ctx, pos, faceCenter, blockReachDistance, false);
if (rot.isPresent() && isSafeToCancel && baritone.getInventoryBehavior().throwaway(true, this::isCocoa)) {
HitResult result = RayTraceUtils.rayTraceTowards(ctx.player(), rot.get(), blockReachDistance);

View File

@@ -60,7 +60,7 @@ public final class BlockStateInterfaceAccessWrapper implements BlockGetter {
}
@Override
public int getMinBuildHeight() {
public int getMinY() {
return 0;
}

View File

@@ -24,7 +24,10 @@ import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.*;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.CoreShaders;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.ShaderProgram;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
@@ -50,7 +53,7 @@ public interface IRenderer {
static BufferBuilder startLines(Color color, float alpha, float lineWidth, boolean ignoreDepth) {
RenderSystem.enableBlend();
RenderSystem.setShader(GameRenderer::getPositionColorShader);
RenderSystem.setShader(CoreShaders.POSITION_COLOR);
RenderSystem.blendFuncSeparate(
GlStateManager.SourceFactor.SRC_ALPHA,
GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA,
@@ -65,7 +68,7 @@ public interface IRenderer {
if (ignoreDepth) {
RenderSystem.disableDepthTest();
}
RenderSystem.setShader(GameRenderer::getRendertypeLinesShader);
RenderSystem.setShader(CoreShaders.RENDERTYPE_LINES);
return tessellator.begin(VertexFormat.Mode.LINES, DefaultVertexFormat.POSITION_COLOR_NORMAL);
}
@@ -78,7 +81,7 @@ public interface IRenderer {
if (meshData != null) {
BufferUploader.drawWithShader(meshData);
}
if (ignoredDepth) {
RenderSystem.enableDepthTest();
}

View File

@@ -262,12 +262,12 @@ public final class PathRenderer implements IRenderer {
drawDankLitGoalBox(bufferBuilder, stack, color, minX, maxX, minZ, maxZ, minY, maxY, y1, y2, setupRender);
} else if (goal instanceof GoalXZ) {
GoalXZ goalPos = (GoalXZ) goal;
minY = ctx.world().getMinBuildHeight();
maxY = ctx.world().getMaxBuildHeight();
minY = ctx.world().getMinY();
maxY = ctx.world().getMaxY();
if (settings.renderGoalXZBeacon.value) {
//TODO: check
textureManager.bindForSetup(TEXTURE_BEACON_BEAM);
textureManager.getTexture(TEXTURE_BEACON_BEAM).bind();
if (settings.renderGoalIgnoreDepth.value) {
RenderSystem.disableDepthTest();
}

View File

@@ -18,8 +18,9 @@
package baritone.utils;
import baritone.api.utils.input.Input;
import net.minecraft.client.player.ClientInput;
public class PlayerMovementInput extends net.minecraft.client.player.Input {
public class PlayerMovementInput extends ClientInput {
private final InputOverrideHandler handler;
@@ -31,28 +32,36 @@ public class PlayerMovementInput extends net.minecraft.client.player.Input {
public void tick(boolean p_225607_1_, float f) {
this.leftImpulse = 0.0F;
this.forwardImpulse = 0.0F;
boolean jumping = handler.isInputForcedDown(Input.JUMP); // oppa gangnam style
this.jumping = handler.isInputForcedDown(Input.JUMP); // oppa gangnam style
if (this.up = handler.isInputForcedDown(Input.MOVE_FORWARD)) {
boolean up = handler.isInputForcedDown(Input.MOVE_FORWARD);
if (up) {
this.forwardImpulse++;
}
if (this.down = handler.isInputForcedDown(Input.MOVE_BACK)) {
boolean down = handler.isInputForcedDown(Input.MOVE_BACK);
if (down) {
this.forwardImpulse--;
}
if (this.left = handler.isInputForcedDown(Input.MOVE_LEFT)) {
boolean left = handler.isInputForcedDown(Input.MOVE_LEFT);
if (left) {
this.leftImpulse++;
}
if (this.right = handler.isInputForcedDown(Input.MOVE_RIGHT)) {
boolean right = handler.isInputForcedDown(Input.MOVE_RIGHT);
if (right) {
this.leftImpulse--;
}
if (this.shiftKeyDown = handler.isInputForcedDown(Input.SNEAK)) {
boolean sneaking = handler.isInputForcedDown(Input.SNEAK);
if (sneaking) {
this.leftImpulse *= 0.3D;
this.forwardImpulse *= 0.3D;
}
boolean sprinting = handler.isInputForcedDown(Input.SPRINT);
this.keyPresses = new net.minecraft.world.entity.player.Input(up, down, left, right, jumping, sneaking, sprinting);
}
}

View File

@@ -20,11 +20,12 @@ package baritone.utils;
import baritone.Baritone;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.core.Holder;
import net.minecraft.core.component.DataComponents;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.SwordItem;
import net.minecraft.world.item.TieredItem;
import net.minecraft.world.item.component.Tool;
import net.minecraft.world.item.enchantment.*;
import net.minecraft.world.item.enchantment.effects.EnchantmentAttributeEffect;
import net.minecraft.world.level.block.Block;
@@ -87,12 +88,9 @@ public class ToolSet {
* @return values from 0 up
*/
private int getMaterialCost(ItemStack itemStack) {
if (itemStack.getItem() instanceof TieredItem) {
TieredItem tool = (TieredItem) itemStack.getItem();
return (int) tool.getTier().getAttackDamageBonus();
} else {
return -1;
}
Tool toolComponent = itemStack.get(DataComponents.TOOL);
if (toolComponent == null) return -1;
return toolComponent.damagePerBlock(); // todo: i have no idea what "material cost" means anymore
}
public boolean hasSilkTouch(ItemStack stack) {

View File

@@ -20,12 +20,14 @@ package baritone.utils.schematic.format.defaults;
import baritone.api.schematic.CompositeSchematic;
import baritone.api.schematic.IStaticSchematic;
import baritone.utils.schematic.StaticSchematic;
import net.minecraft.core.Holder;
import net.minecraft.core.Vec3i;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.Property;
import org.apache.commons.lang3.Validate;
@@ -81,8 +83,14 @@ public final class LitematicaSchematic extends CompositeSchematic implements ISt
BlockState[] blockList = new BlockState[blockStatePalette.size()];
for (int i = 0; i < blockStatePalette.size(); i++) {
Block block = BuiltInRegistries.BLOCK.get(ResourceLocation.parse((((CompoundTag) blockStatePalette.get(i)).getString("Name"))));
CompoundTag properties = ((CompoundTag) blockStatePalette.get(i)).getCompound("Properties");
CompoundTag tag = (CompoundTag) blockStatePalette.get(i);
ResourceLocation blockKey = ResourceLocation.tryParse(tag.getString("Name"));
Block block = blockKey == null
? Blocks.AIR
: BuiltInRegistries.BLOCK.get(blockKey)
.map(Holder.Reference::value)
.orElse(Blocks.AIR);
CompoundTag properties = tag.getCompound("Properties");
blockList[i] = getBlockState(block, properties);
}

View File

@@ -18,12 +18,14 @@
package baritone.utils.schematic.format.defaults;
import baritone.utils.schematic.StaticSchematic;
import net.minecraft.core.Holder;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.datafix.fixes.ItemIdFix;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
/**
@@ -63,7 +65,13 @@ public final class MCEditSchematic extends StaticSchematic {
// additional is 0 through 15 inclusive since it's & 0xF above
blockID |= additional[blockInd] << 8;
}
Block block = BuiltInRegistries.BLOCK.get(ResourceLocation.tryParse(ItemIdFix.getItem(blockID)));
ResourceLocation blockKey = ResourceLocation.tryParse(ItemIdFix.getItem(blockID));
Block block = blockKey == null
? Blocks.AIR
: BuiltInRegistries.BLOCK.get(blockKey)
.map(Holder.Reference::value)
.orElse(Blocks.AIR);
// int meta = metadata[blockInd] & 0xFF;
// this.states[x][z][y] = block.getStateFromMeta(meta);
this.states[x][z][y] = block.defaultBlockState();

View File

@@ -25,11 +25,14 @@ import java.util.Map;
import java.util.Optional;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.minecraft.core.Holder;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.Property;
@@ -107,7 +110,9 @@ public final class SpongeSchematic extends StaticSchematic {
private BlockState deserialize() {
if (this.blockState == null) {
Block block = BuiltInRegistries.BLOCK.get(this.resourceLocation);
Block block = BuiltInRegistries.BLOCK.get(this.resourceLocation)
.map(Holder.Reference::value)
.orElse(Blocks.AIR);
this.blockState = block.defaultBlockState();
this.properties.keySet().stream().sorted(String::compareTo).forEachOrdered(key -> {