Compare commits

...

18 Commits

Author SHA1 Message Date
ZacSharp
12ddeee278 v1.11.2 2025-05-13 20:42:51 +02:00
ZacSharp
26e0af1188 Merge branch '1.20.5' into 1.21.1 2025-05-13 15:39:08 +02:00
ZacSharp
aff430ac51 Merge branch '1.20.5' into 1.21.1 2025-04-23 00:27:46 +02:00
leijurv
7e5dedd8f3 Merge pull request #4634 from IceTank/1.21.1
Expose current layer in IBuilderProcess
2025-02-07 16:57:06 -08:00
Ic3Tank
ba1ccce962 Expose current layer in IBuilderProcess 2025-02-04 22:04:21 +01:00
leijurv
1dc5be3985 Merge pull request #4589 from ZacSharp/1.21.1-update
Merge 1.20.6 into 1.21.1
2024-12-21 23:07:27 -08:00
ZacSharp
1d6f5df155 Merge branch '1.20.5' into 1.21.1 2024-12-14 20:48:52 +01:00
leijurv
9eefcbc9b6 Merge pull request #4534 from ZacSharp/1.21.1-update
Merge 1.20.5 into 1.21.1
2024-10-30 02:04:49 -07:00
ZacSharp
52cfe5cf7e Merge branch '1.20.5' into 1.21.1 2024-10-23 01:12:52 +02:00
leijurv
50291089db Merge pull request #4520 from KKyleK/update-docker-java
Update Java version used by Docker
2024-10-15 16:04:42 -07:00
Kyle Koivuneva
5102d9164e Update Java version used by Docker
In 6b2fd5acee the java version used to build baritone
was bumped from 17 to 21, but the Docker build was not updated accordingly.
2024-10-15 21:58:23 +00:00
leijurv
a231748b4e Merge pull request #4466 from rfresh2/1.21.1-compat
mark 1.21.1 as compatible
2024-08-22 11:04:21 -07:00
leijurv
ec57888ce1 Merge pull request #4451 from ZacSharp/1.21-update
Merge 1.20.5 into 1.21
2024-08-22 10:58:20 -07:00
rfresh2
960ff6ed98 mark 1.21.1 as compatible 2024-08-09 20:31:29 -07:00
ZacSharp
8867fb7010 Merge branch '1.20.5' into 1.21 2024-08-02 00:45:15 +02:00
leijurv
8786148fef Merge pull request #4394 from rfresh2/1.21
1.21
2024-07-20 11:52:24 -07:00
rfresh2
e66fdea500 update supported litematic version 2024-07-19 13:37:16 -07:00
rfresh2
74f46cd6eb 1.21 2024-06-20 01:03:15 -07:00
29 changed files with 210 additions and 140 deletions

View File

@@ -5,7 +5,7 @@ ENV DEBIAN_FRONTEND noninteractive
RUN apt update -y
RUN apt install \
openjdk-17-jdk \
openjdk-21-jdk \
git \
--assume-yes

View File

@@ -26,7 +26,7 @@
"depends": {
"fabricloader": ">=0.14.22",
"minecraft": ["1.20.5", "1.20.6"]
"minecraft": ["1.21","1.21.1"]
},
"custom": {
"modmenu": {

View File

@@ -35,6 +35,6 @@ A Minecraft pathfinder bot.
modId="minecraft"
mandatory=true
# This version range declares a minimum of the current minecraft version up to but not including the next major version
versionRange="[1.20.5, 1.20.6]"
versionRange="[1.21, 1.21.1]"
ordering="NONE"
side="BOTH"

View File

@@ -2,17 +2,17 @@ org.gradle.jvmargs=-Xmx4G
available_loaders=fabric,forge,neoforge,tweaker
mod_version=1.10.2
mod_version=1.11.2
maven_group=baritone
archives_base_name=baritone
java_version=21
minecraft_version=1.20.6
minecraft_version=1.21
forge_version=50.0.8
forge_version=51.0.16
neoforge_version=43-beta
neoforge_version=20-beta
fabric_version=0.15.11

View File

@@ -127,4 +127,4 @@ publishing {
repositories {
// Add repositories to publish to here.
}
}
}

View File

@@ -17,8 +17,9 @@
package baritone.launch;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.fml.common.Mod;
@Mod("baritoe")
@Mod(value = "baritoe", dist = Dist.CLIENT)
public class BaritoneForgeModXD {
}

View File

@@ -35,6 +35,6 @@ A Minecraft pathfinder bot.
modId="minecraft"
type="required"
# This version range declares a minimum of the current minecraft version up to but not including the next major version
versionRange="[1.20.5, 1.20.6]"
versionRange="[1.21,1.21.1]"
ordering="NONE"
side="BOTH"

View File

@@ -30,7 +30,7 @@ public enum BlockById implements IDatatypeFor<Block> {
@Override
public Block get(IDatatypeContext ctx) throws CommandException {
ResourceLocation id = new ResourceLocation(ctx.getConsumer().getString());
ResourceLocation id = ResourceLocation.parse(ctx.getConsumer().getString());
Block block;
if ((block = BuiltInRegistries.BLOCK.getOptional(id).orElse(null)) == null) {
throw new IllegalArgumentException("no block found by that id");

View File

@@ -30,7 +30,7 @@ public enum EntityClassById implements IDatatypeFor<EntityType> {
@Override
public EntityType get(IDatatypeContext ctx) throws CommandException {
ResourceLocation id = new ResourceLocation(ctx.getConsumer().getString());
ResourceLocation id = ResourceLocation.parse(ctx.getConsumer().getString());
EntityType entity;
if ((entity = BuiltInRegistries.ENTITY_TYPE.getOptional(id).orElse(null)) == null) {
throw new IllegalArgumentException("no entity found by that id");

View File

@@ -77,7 +77,7 @@ public enum ForBlockOptionalMeta implements IDatatypeFor<BlockOptionalMeta> {
properties = parts[1];
}
Block block = BuiltInRegistries.BLOCK.getOptional(new ResourceLocation(blockId)).orElse(null);
Block block = BuiltInRegistries.BLOCK.getOptional(ResourceLocation.parse(blockId)).orElse(null);
if (block == null) {
// This block doesn't exist so there's no properties to complete.
return Stream.empty();

View File

@@ -30,7 +30,7 @@ public enum ItemById implements IDatatypeFor<Item> {
@Override
public Item get(IDatatypeContext ctx) throws CommandException {
ResourceLocation id = new ResourceLocation(ctx.getConsumer().getString());
ResourceLocation id = ResourceLocation.parse(ctx.getConsumer().getString());
Item item;
if ((item = BuiltInRegistries.ITEM.getOptional(id).orElse(null)) == null) {
throw new IllegalArgumentException("No item found by that id");

View File

@@ -52,7 +52,6 @@ import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.CustomSpawner;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.WorldDataConfiguration;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.Property;

View File

@@ -246,7 +246,7 @@ public class SettingsUtil {
),
ITEM(
Item.class,
str -> BuiltInRegistries.ITEM.get(new ResourceLocation(str.trim())), // TODO this now returns AIR on failure instead of null, is that an issue?
str -> BuiltInRegistries.ITEM.get(ResourceLocation.parse(str.trim())), // TODO this now returns AIR on failure instead of null, is that an issue?
item -> BuiltInRegistries.ITEM.getKey(item).toString()
),
LIST() {

View File

@@ -47,7 +47,7 @@ public class BaritoneToast implements Toast {
//TODO: check
gui.blit(new ResourceLocation("textures/gui/toasts.png"), 0, 0, 0, 32, 160, 32);
gui.blit(ResourceLocation.parse("textures/gui/toasts.png"), 0, 0, 0, 32, 160, 32);
if (this.subtitle == null) {
gui.drawString(toastGui.getMinecraft().font, this.title, 18, 12, -11534256);

View File

@@ -37,11 +37,6 @@ import static baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX;
@Mixin(Screen.class)
public abstract class MixinScreen implements IGuiScreen {
@Override
@Invoker("openLink")
public abstract void openLinkInvoker(URI url);
//TODO: switch to enum extention with mixin 9.0 or whenever Mumfrey gets around to it
@Inject(at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;error(Ljava/lang/String;Ljava/lang/Object;)V", remap = false, ordinal = 1), method = "handleComponentClicked", cancellable = true)
public void handleCustomClickEvent(Style style, CallbackInfoReturnable<Boolean> cir) {

View File

@@ -22,6 +22,7 @@ import baritone.api.IBaritone;
import baritone.api.event.events.RenderEvent;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Camera;
import net.minecraft.client.DeltaTracker;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.renderer.LevelRenderer;
import net.minecraft.client.renderer.LightTexture;
@@ -41,14 +42,13 @@ public class MixinWorldRenderer {
@Inject(
method = "renderLevel",
at = @At("RETURN"),
locals = LocalCapture.CAPTURE_FAILSOFT
at = @At("RETURN")
)
private void onStartHand(float f, long l, boolean bl, Camera arg, GameRenderer arg2, LightTexture arg3, Matrix4f matrix4f, Matrix4f matrix4f2, CallbackInfo ci) {
private void onStartHand(final DeltaTracker deltaTracker, final boolean bl, final Camera camera, final GameRenderer gameRenderer, final LightTexture lightTexture, final Matrix4f matrix4f, final Matrix4f matrix4f2, final CallbackInfo ci) {
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
PoseStack poseStack = new PoseStack();
poseStack.mulPose(matrix4f);
ibaritone.getGameEventHandler().onRenderPass(new RenderEvent(f, poseStack, matrix4f2));
ibaritone.getGameEventHandler().onRenderPass(new RenderEvent(deltaTracker.getGameTimeDeltaPartialTick(false), poseStack, matrix4f2));
}
}
}
}

View File

@@ -35,6 +35,7 @@ import baritone.command.argument.CommandArguments;
import baritone.command.manager.CommandManager;
import baritone.utils.accessor.IGuiScreen;
import net.minecraft.ChatFormatting;
import net.minecraft.Util;
import net.minecraft.network.chat.*;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.util.Tuple;
@@ -97,8 +98,8 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
return false;
} else if (msg.trim().equalsIgnoreCase("orderpizza")) {
try {
((IGuiScreen) ctx.minecraft().screen).openLinkInvoker(new URI("https://www.dominos.com/en/pages/order/"));
} catch (NullPointerException | URISyntaxException ignored) {}
Util.getPlatform().openUri("https://www.dominos.com/en/pages/order/");
} catch (Exception ignored) {}
return false;
}
if (msg.isEmpty()) {

View File

@@ -42,6 +42,7 @@ import baritone.api.utils.BlockOptionalMetaLookup;
import baritone.utils.BlockStateInterface;
import baritone.utils.IRenderer;
import baritone.utils.schematic.StaticSchematic;
import com.mojang.blaze3d.vertex.BufferBuilder;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.Vec3i;
@@ -75,9 +76,9 @@ public class SelCommand extends Command {
float opacity = Baritone.settings().selectionOpacity.value;
float lineWidth = Baritone.settings().selectionLineWidth.value;
boolean ignoreDepth = Baritone.settings().renderSelectionIgnoreDepth.value;
IRenderer.startLines(color, opacity, lineWidth, ignoreDepth);
IRenderer.emitAABB(event.getModelViewStack(), new AABB(pos1));
IRenderer.endLines(ignoreDepth);
BufferBuilder bufferBuilder = IRenderer.startLines(color, opacity, lineWidth, ignoreDepth);
IRenderer.emitAABB(bufferBuilder, event.getModelViewStack(), new AABB(pos1));
IRenderer.endLines(bufferBuilder, ignoreDepth);
}
});
}

View File

@@ -27,11 +27,14 @@ import baritone.utils.ToolSet;
import baritone.utils.pathing.BetterWorldBorder;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Holder;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.item.enchantment.*;
import net.minecraft.world.item.enchantment.effects.EnchantmentAttributeEffect;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
@@ -108,19 +111,44 @@ public class CalculationContext {
this.allowParkourAscend = Baritone.settings().allowParkourAscend.value;
this.assumeWalkOnWater = Baritone.settings().assumeWalkOnWater.value;
this.allowFallIntoLava = false; // Super secret internal setting for ElytraBehavior
this.frostWalker = EnchantmentHelper.getEnchantmentLevel(Enchantments.FROST_WALKER, baritone.getPlayerContext().player());
// todo: technically there can now be datapack enchants that replace blocks with any other at any range
int frostWalkerLevel = 0;
for (EquipmentSlot slot : EquipmentSlot.values()) {
ItemEnchantments itemEnchantments = baritone.getPlayerContext()
.player()
.getItemBySlot(slot)
.getEnchantments();
for (Holder<Enchantment> enchant : itemEnchantments.keySet()) {
if (enchant.is(Enchantments.FROST_WALKER)) {
frostWalkerLevel = itemEnchantments.getLevel(enchant);
}
}
}
this.frostWalker = frostWalkerLevel;
this.allowDiagonalDescend = Baritone.settings().allowDiagonalDescend.value;
this.allowDiagonalAscend = Baritone.settings().allowDiagonalAscend.value;
this.allowDownward = Baritone.settings().allowDownward.value;
this.minFallHeight = 3; // Minimum fall height used by MovementFall
this.maxFallHeightNoWater = Baritone.settings().maxFallHeightNoWater.value;
this.maxFallHeightBucket = Baritone.settings().maxFallHeightBucket.value;
int depth = EnchantmentHelper.getDepthStrider(player);
if (depth > 3) {
depth = 3;
float waterSpeedMultiplier = 1.0f;
OUTER: for (EquipmentSlot slot : EquipmentSlot.values()) {
ItemEnchantments itemEnchantments = baritone.getPlayerContext()
.player()
.getItemBySlot(slot)
.getEnchantments();
for (Holder<Enchantment> enchant : itemEnchantments.keySet()) {
List<EnchantmentAttributeEffect> effects = enchant.value()
.getEffects(EnchantmentEffectComponents.ATTRIBUTES);
for (EnchantmentAttributeEffect effect : effects) {
if (effect.attribute().is(Attributes.WATER_MOVEMENT_EFFICIENCY.unwrapKey().get())) {
waterSpeedMultiplier = effect.amount().calculate(itemEnchantments.getLevel(enchant));
break OUTER;
}
}
}
}
float mult = depth / 3.0F;
this.waterWalkSpeed = ActionCosts.WALK_ONE_IN_WATER_COST * (1 - mult) + ActionCosts.WALK_ONE_BLOCK_COST * mult;
this.waterWalkSpeed = ActionCosts.WALK_ONE_IN_WATER_COST * (1 - waterSpeedMultiplier) + ActionCosts.WALK_ONE_BLOCK_COST * waterSpeedMultiplier;
this.breakBlockAdditionalCost = Baritone.settings().blockBreakAdditionalPenalty.value;
this.backtrackCostFavoringCoefficient = Baritone.settings().backtrackCostFavoringCoefficient.value;
this.jumpPenalty = Baritone.settings().jumpPenalty.value;

View File

@@ -31,7 +31,11 @@ import baritone.utils.BlockStateInterface;
import baritone.utils.ToolSet;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.core.Holder;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.item.enchantment.Enchantment;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.item.enchantment.ItemEnchantments;
import net.minecraft.world.level.block.*;
import net.minecraft.world.level.block.piston.MovingPistonBlock;
import net.minecraft.world.level.block.state.BlockState;
@@ -500,14 +504,27 @@ public interface MovementHelper extends ActionCosts, Helper {
static boolean canUseFrostWalker(CalculationContext context, BlockState state) {
return context.frostWalker != 0
&& state == FrostedIceBlock.meltsInto()
&& ((Integer) state.getValue(LiquidBlock.LEVEL)) == 0;
&& state.getValue(LiquidBlock.LEVEL) == 0;
}
static boolean canUseFrostWalker(IPlayerContext ctx, BlockPos pos) {
boolean hasFrostWalker = false;
OUTER: for (EquipmentSlot slot : EquipmentSlot.values()) {
ItemEnchantments itemEnchantments = ctx
.player()
.getItemBySlot(slot)
.getEnchantments();
for (Holder<Enchantment> enchant : itemEnchantments.keySet()) {
if (enchant.is(Enchantments.FROST_WALKER)) {
hasFrostWalker = true;
break OUTER;
}
}
}
BlockState state = BlockStateInterface.get(ctx, pos);
return EnchantmentHelper.hasFrostWalker(ctx.player())
return hasFrostWalker
&& state == FrostedIceBlock.meltsInto()
&& ((Integer) state.getValue(LiquidBlock.LEVEL)) == 0;
&& state.getValue(LiquidBlock.LEVEL) == 0;
}
/**

View File

@@ -31,6 +31,7 @@ import baritone.utils.BlockStateInterface;
import baritone.utils.IRenderer;
import baritone.utils.PathRenderer;
import baritone.utils.accessor.IFireworkRocketEntity;
import com.mojang.blaze3d.vertex.BufferBuilder;
import it.unimi.dsi.fastutil.floats.FloatArrayList;
import it.unimi.dsi.fastutil.floats.FloatIterator;
import net.minecraft.core.BlockPos;
@@ -424,28 +425,28 @@ public final class ElytraBehavior implements Helper {
PathRenderer.drawGoal(event.getModelViewStack(), ctx, new GoalBlock(this.aimPos), event.getPartialTicks(), Color.GREEN);
}
if (!this.clearLines.isEmpty() && settings.elytraRenderRaytraces.value) {
IRenderer.startLines(Color.GREEN, settings.pathRenderLineWidthPixels.value, settings.renderPathIgnoreDepth.value);
BufferBuilder bufferBuilder = IRenderer.startLines(Color.GREEN, settings.pathRenderLineWidthPixels.value, settings.renderPathIgnoreDepth.value);
for (Pair<Vec3, Vec3> line : this.clearLines) {
IRenderer.emitLine(event.getModelViewStack(), line.first(), line.second());
IRenderer.emitLine(bufferBuilder, event.getModelViewStack(), line.first(), line.second());
}
IRenderer.endLines(settings.renderPathIgnoreDepth.value);
IRenderer.endLines(bufferBuilder, settings.renderPathIgnoreDepth.value);
}
if (!this.blockedLines.isEmpty() && Baritone.settings().elytraRenderRaytraces.value) {
IRenderer.startLines(Color.BLUE, settings.pathRenderLineWidthPixels.value, settings.renderPathIgnoreDepth.value);
BufferBuilder bufferBuilder = IRenderer.startLines(Color.BLUE, settings.pathRenderLineWidthPixels.value, settings.renderPathIgnoreDepth.value);
for (Pair<Vec3, Vec3> line : this.blockedLines) {
IRenderer.emitLine(event.getModelViewStack(), line.first(), line.second());
IRenderer.emitLine(bufferBuilder, event.getModelViewStack(), line.first(), line.second());
}
IRenderer.endLines(settings.renderPathIgnoreDepth.value);
IRenderer.endLines(bufferBuilder, settings.renderPathIgnoreDepth.value);
}
if (this.simulationLine != null && Baritone.settings().elytraRenderSimulation.value) {
IRenderer.startLines(new Color(0x36CCDC), settings.pathRenderLineWidthPixels.value, settings.renderPathIgnoreDepth.value);
BufferBuilder bufferBuilder = IRenderer.startLines(new Color(0x36CCDC), settings.pathRenderLineWidthPixels.value, settings.renderPathIgnoreDepth.value);
final Vec3 offset = ctx.player().getPosition(event.getPartialTicks());
for (int i = 0; i < this.simulationLine.size() - 1; i++) {
final Vec3 src = this.simulationLine.get(i).add(offset);
final Vec3 dst = this.simulationLine.get(i + 1).add(offset);
IRenderer.emitLine(event.getModelViewStack(), src, dst);
IRenderer.emitLine(bufferBuilder, event.getModelViewStack(), src, dst);
}
IRenderer.endLines(settings.renderPathIgnoreDepth.value);
IRenderer.endLines(bufferBuilder, settings.renderPathIgnoreDepth.value);
}
}

View File

@@ -5,6 +5,7 @@ import baritone.api.event.events.RenderEvent;
import baritone.api.event.listener.AbstractGameEventListener;
import baritone.api.selection.ISelection;
import baritone.utils.IRenderer;
import com.mojang.blaze3d.vertex.BufferBuilder;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.world.phys.AABB;
@@ -28,27 +29,27 @@ public class SelectionRenderer implements IRenderer, AbstractGameEventListener {
return;
}
IRenderer.startLines(settings.colorSelection.value, opacity, lineWidth, ignoreDepth);
BufferBuilder bufferBuilder = IRenderer.startLines(settings.colorSelection.value, opacity, lineWidth, ignoreDepth);
for (ISelection selection : selections) {
IRenderer.emitAABB(stack, selection.aabb(), SELECTION_BOX_EXPANSION);
IRenderer.emitAABB(bufferBuilder, stack, selection.aabb(), SELECTION_BOX_EXPANSION);
}
if (settings.renderSelectionCorners.value) {
IRenderer.glColor(settings.colorSelectionPos1.value, opacity);
for (ISelection selection : selections) {
IRenderer.emitAABB(stack, new AABB(selection.pos1()));
IRenderer.emitAABB(bufferBuilder, stack, new AABB(selection.pos1()));
}
IRenderer.glColor(settings.colorSelectionPos2.value, opacity);
for (ISelection selection : selections) {
IRenderer.emitAABB(stack, new AABB(selection.pos2()));
IRenderer.emitAABB(bufferBuilder, stack, new AABB(selection.pos2()));
}
}
IRenderer.endLines(ignoreDepth);
IRenderer.endLines(bufferBuilder, ignoreDepth);
}
@Override

View File

@@ -22,6 +22,7 @@ import baritone.api.BaritoneAPI;
import baritone.api.pathing.goals.GoalBlock;
import baritone.api.utils.BetterBlockPos;
import baritone.api.utils.Helper;
import com.mojang.blaze3d.vertex.BufferBuilder;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.ChatFormatting;
import net.minecraft.client.gui.GuiGraphics;
@@ -126,11 +127,11 @@ public class GuiClick extends Screen implements Helper {
// drawSingleSelectionBox WHEN?
PathRenderer.drawManySelectionBoxes(modelViewStack, e, Collections.singletonList(currentMouseOver), Color.CYAN);
if (clickStart != null && !clickStart.equals(currentMouseOver)) {
IRenderer.startLines(Color.RED, Baritone.settings().pathRenderLineWidthPixels.value, true);
BufferBuilder bufferBuilder = IRenderer.startLines(Color.RED, Baritone.settings().pathRenderLineWidthPixels.value, true);
BetterBlockPos a = new BetterBlockPos(currentMouseOver);
BetterBlockPos b = new BetterBlockPos(clickStart);
IRenderer.emitAABB(modelViewStack, new AABB(Math.min(a.x, b.x), Math.min(a.y, b.y), Math.min(a.z, b.z), Math.max(a.x, b.x) + 1, Math.max(a.y, b.y) + 1, Math.max(a.z, b.z) + 1));
IRenderer.endLines(true);
IRenderer.emitAABB(bufferBuilder, modelViewStack, new AABB(Math.min(a.x, b.x), Math.min(a.y, b.y), Math.min(a.z, b.z), Math.max(a.x, b.x) + 1, Math.max(a.y, b.y) + 1, Math.max(a.z, b.z) + 1));
IRenderer.endLines(bufferBuilder, true);
}
}
}

View File

@@ -28,15 +28,12 @@ import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import org.joml.Matrix3f;
import org.joml.Matrix4f;
import java.awt.*;
public interface IRenderer {
Tesselator tessellator = Tesselator.getInstance();
BufferBuilder buffer = tessellator.getBuilder();
IEntityRenderManager renderManager = (IEntityRenderManager) Minecraft.getInstance().getEntityRenderDispatcher();
TextureManager textureManager = Minecraft.getInstance().getTextureManager();
Settings settings = BaritoneAPI.getSettings();
@@ -51,7 +48,7 @@ public interface IRenderer {
IRenderer.color[3] = alpha;
}
static void startLines(Color color, float alpha, float lineWidth, boolean ignoreDepth) {
static BufferBuilder startLines(Color color, float alpha, float lineWidth, boolean ignoreDepth) {
RenderSystem.enableBlend();
RenderSystem.setShader(GameRenderer::getPositionColorShader);
RenderSystem.blendFuncSeparate(
@@ -69,15 +66,19 @@ public interface IRenderer {
RenderSystem.disableDepthTest();
}
RenderSystem.setShader(GameRenderer::getRendertypeLinesShader);
buffer.begin(VertexFormat.Mode.LINES, DefaultVertexFormat.POSITION_COLOR_NORMAL);
return tessellator.begin(VertexFormat.Mode.LINES, DefaultVertexFormat.POSITION_COLOR_NORMAL);
}
static void startLines(Color color, float lineWidth, boolean ignoreDepth) {
startLines(color, .4f, lineWidth, ignoreDepth);
static BufferBuilder startLines(Color color, float lineWidth, boolean ignoreDepth) {
return startLines(color, .4f, lineWidth, ignoreDepth);
}
static void endLines(boolean ignoredDepth) {
tessellator.end();
static void endLines(BufferBuilder bufferBuilder, boolean ignoredDepth) {
MeshData meshData = bufferBuilder.build();
if (meshData != null) {
BufferUploader.drawWithShader(meshData);
}
if (ignoredDepth) {
RenderSystem.enableDepthTest();
}
@@ -87,7 +88,7 @@ public interface IRenderer {
RenderSystem.disableBlend();
}
static void emitLine(PoseStack stack, double x1, double y1, double z1, double x2, double y2, double z2) {
static void emitLine(BufferBuilder bufferBuilder, PoseStack stack, double x1, double y1, double z1, double x2, double y2, double z2) {
final double dx = x2 - x1;
final double dy = y2 - y1;
final double dz = z2 - z1;
@@ -97,59 +98,59 @@ public interface IRenderer {
final float ny = (float) (dy * invMag);
final float nz = (float) (dz * invMag);
emitLine(stack, x1, y1, z1, x2, y2, z2, nx, ny, nz);
emitLine(bufferBuilder, stack, x1, y1, z1, x2, y2, z2, nx, ny, nz);
}
static void emitLine(PoseStack stack,
static void emitLine(BufferBuilder bufferBuilder, PoseStack stack,
double x1, double y1, double z1,
double x2, double y2, double z2,
double nx, double ny, double nz) {
emitLine(stack,
emitLine(bufferBuilder, stack,
(float) x1, (float) y1, (float) z1,
(float) x2, (float) y2, (float) z2,
(float) nx, (float) ny, (float) nz
);
}
static void emitLine(PoseStack stack,
static void emitLine(BufferBuilder bufferBuilder, PoseStack stack,
float x1, float y1, float z1,
float x2, float y2, float z2,
float nx, float ny, float nz) {
PoseStack.Pose pose = stack.last();
buffer.vertex(pose, x1, y1, z1).color(color[0], color[1], color[2], color[3]).normal(pose, nx, ny, nz).endVertex();
buffer.vertex(pose, x2, y2, z2).color(color[0], color[1], color[2], color[3]).normal(pose, nx, ny, nz).endVertex();
bufferBuilder.addVertex(pose, x1, y1, z1).setColor(color[0], color[1], color[2], color[3]).setNormal(pose, nx, ny, nz);
bufferBuilder.addVertex(pose, x2, y2, z2).setColor(color[0], color[1], color[2], color[3]).setNormal(pose, nx, ny, nz);
}
static void emitAABB(PoseStack stack, AABB aabb) {
static void emitAABB(BufferBuilder bufferBuilder, PoseStack stack, AABB aabb) {
AABB toDraw = aabb.move(-renderManager.renderPosX(), -renderManager.renderPosY(), -renderManager.renderPosZ());
// bottom
emitLine(stack, toDraw.minX, toDraw.minY, toDraw.minZ, toDraw.maxX, toDraw.minY, toDraw.minZ, 1.0, 0.0, 0.0);
emitLine(stack, toDraw.maxX, toDraw.minY, toDraw.minZ, toDraw.maxX, toDraw.minY, toDraw.maxZ, 0.0, 0.0, 1.0);
emitLine(stack, toDraw.maxX, toDraw.minY, toDraw.maxZ, toDraw.minX, toDraw.minY, toDraw.maxZ, -1.0, 0.0, 0.0);
emitLine(stack, toDraw.minX, toDraw.minY, toDraw.maxZ, toDraw.minX, toDraw.minY, toDraw.minZ, 0.0, 0.0, -1.0);
emitLine(bufferBuilder, stack, toDraw.minX, toDraw.minY, toDraw.minZ, toDraw.maxX, toDraw.minY, toDraw.minZ, 1.0, 0.0, 0.0);
emitLine(bufferBuilder, stack, toDraw.maxX, toDraw.minY, toDraw.minZ, toDraw.maxX, toDraw.minY, toDraw.maxZ, 0.0, 0.0, 1.0);
emitLine(bufferBuilder, stack, toDraw.maxX, toDraw.minY, toDraw.maxZ, toDraw.minX, toDraw.minY, toDraw.maxZ, -1.0, 0.0, 0.0);
emitLine(bufferBuilder, stack, toDraw.minX, toDraw.minY, toDraw.maxZ, toDraw.minX, toDraw.minY, toDraw.minZ, 0.0, 0.0, -1.0);
// top
emitLine(stack, toDraw.minX, toDraw.maxY, toDraw.minZ, toDraw.maxX, toDraw.maxY, toDraw.minZ, 1.0, 0.0, 0.0);
emitLine(stack, toDraw.maxX, toDraw.maxY, toDraw.minZ, toDraw.maxX, toDraw.maxY, toDraw.maxZ, 0.0, 0.0, 1.0);
emitLine(stack, toDraw.maxX, toDraw.maxY, toDraw.maxZ, toDraw.minX, toDraw.maxY, toDraw.maxZ, -1.0, 0.0, 0.0);
emitLine(stack, toDraw.minX, toDraw.maxY, toDraw.maxZ, toDraw.minX, toDraw.maxY, toDraw.minZ, 0.0, 0.0, -1.0);
emitLine(bufferBuilder, stack, toDraw.minX, toDraw.maxY, toDraw.minZ, toDraw.maxX, toDraw.maxY, toDraw.minZ, 1.0, 0.0, 0.0);
emitLine(bufferBuilder, stack, toDraw.maxX, toDraw.maxY, toDraw.minZ, toDraw.maxX, toDraw.maxY, toDraw.maxZ, 0.0, 0.0, 1.0);
emitLine(bufferBuilder, stack, toDraw.maxX, toDraw.maxY, toDraw.maxZ, toDraw.minX, toDraw.maxY, toDraw.maxZ, -1.0, 0.0, 0.0);
emitLine(bufferBuilder, stack, toDraw.minX, toDraw.maxY, toDraw.maxZ, toDraw.minX, toDraw.maxY, toDraw.minZ, 0.0, 0.0, -1.0);
// corners
emitLine(stack, toDraw.minX, toDraw.minY, toDraw.minZ, toDraw.minX, toDraw.maxY, toDraw.minZ, 0.0, 1.0, 0.0);
emitLine(stack, toDraw.maxX, toDraw.minY, toDraw.minZ, toDraw.maxX, toDraw.maxY, toDraw.minZ, 0.0, 1.0, 0.0);
emitLine(stack, toDraw.maxX, toDraw.minY, toDraw.maxZ, toDraw.maxX, toDraw.maxY, toDraw.maxZ, 0.0, 1.0, 0.0);
emitLine(stack, toDraw.minX, toDraw.minY, toDraw.maxZ, toDraw.minX, toDraw.maxY, toDraw.maxZ, 0.0, 1.0, 0.0);
emitLine(bufferBuilder, stack, toDraw.minX, toDraw.minY, toDraw.minZ, toDraw.minX, toDraw.maxY, toDraw.minZ, 0.0, 1.0, 0.0);
emitLine(bufferBuilder, stack, toDraw.maxX, toDraw.minY, toDraw.minZ, toDraw.maxX, toDraw.maxY, toDraw.minZ, 0.0, 1.0, 0.0);
emitLine(bufferBuilder, stack, toDraw.maxX, toDraw.minY, toDraw.maxZ, toDraw.maxX, toDraw.maxY, toDraw.maxZ, 0.0, 1.0, 0.0);
emitLine(bufferBuilder, stack, toDraw.minX, toDraw.minY, toDraw.maxZ, toDraw.minX, toDraw.maxY, toDraw.maxZ, 0.0, 1.0, 0.0);
}
static void emitAABB(PoseStack stack, AABB aabb, double expand) {
emitAABB(stack, aabb.inflate(expand, expand, expand));
static void emitAABB(BufferBuilder bufferBuilder, PoseStack stack, AABB aabb, double expand) {
emitAABB(bufferBuilder, stack, aabb.inflate(expand, expand, expand));
}
static void emitLine(PoseStack stack, Vec3 start, Vec3 end) {
static void emitLine(BufferBuilder bufferBuilder, PoseStack stack, Vec3 start, Vec3 end) {
double vpX = renderManager.renderPosX();
double vpY = renderManager.renderPosY();
double vpZ = renderManager.renderPosZ();
emitLine(stack, start.x - vpX, start.y - vpY, start.z - vpZ, end.x - vpX, end.y - vpY, end.z - vpZ);
emitLine(bufferBuilder, stack, start.x - vpX, start.y - vpY, start.z - vpZ, end.x - vpX, end.y - vpY, end.z - vpZ);
}
}

View File

@@ -26,6 +26,7 @@ import baritone.api.utils.interfaces.IGoalRenderPos;
import baritone.behavior.PathingBehavior;
import baritone.pathing.path.PathExecutor;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.BufferBuilder;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.renderer.blockentity.BeaconRenderer;
import net.minecraft.core.BlockPos;
@@ -37,6 +38,7 @@ import net.minecraft.world.level.dimension.DimensionType;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.jetbrains.annotations.Nullable;
import java.awt.*;
import java.util.Arrays;
@@ -50,7 +52,7 @@ import java.util.List;
*/
public final class PathRenderer implements IRenderer {
private static final ResourceLocation TEXTURE_BEACON_BEAM = new ResourceLocation("textures/entity/beacon_beam.png");
private static final ResourceLocation TEXTURE_BEACON_BEAM = ResourceLocation.parse("textures/entity/beacon_beam.png");
private PathRenderer() {}
@@ -133,7 +135,7 @@ public final class PathRenderer implements IRenderer {
}
public static void drawPath(PoseStack stack, List<BetterBlockPos> positions, int startIndex, Color color, boolean fadeOut, int fadeStart0, int fadeEnd0, double offset) {
IRenderer.startLines(color, settings.pathRenderLineWidthPixels.value, settings.renderPathIgnoreDepth.value);
BufferBuilder bufferBuilder = IRenderer.startLines(color, settings.pathRenderLineWidthPixels.value, settings.renderPathIgnoreDepth.value);
int fadeStart = fadeStart0 + startIndex;
int fadeEnd = fadeEnd0 + startIndex;
@@ -167,13 +169,13 @@ public final class PathRenderer implements IRenderer {
IRenderer.glColor(color, alpha);
}
emitPathLine(stack, start.x, start.y, start.z, end.x, end.y, end.z, offset);
emitPathLine(bufferBuilder, stack, start.x, start.y, start.z, end.x, end.y, end.z, offset);
}
IRenderer.endLines(settings.renderPathIgnoreDepth.value);
IRenderer.endLines(bufferBuilder, settings.renderPathIgnoreDepth.value);
}
private static void emitPathLine(PoseStack stack, double x1, double y1, double z1, double x2, double y2, double z2, double offset) {
private static void emitPathLine(BufferBuilder bufferBuilder, PoseStack stack, double x1, double y1, double z1, double x2, double y2, double z2, double offset) {
final double extraOffset = offset + 0.03D;
double vpX = posX();
@@ -181,20 +183,20 @@ public final class PathRenderer implements IRenderer {
double vpZ = posZ();
boolean renderPathAsFrickinThingy = !settings.renderPathAsLine.value;
IRenderer.emitLine(stack,
IRenderer.emitLine(bufferBuilder, stack,
x1 + offset - vpX, y1 + offset - vpY, z1 + offset - vpZ,
x2 + offset - vpX, y2 + offset - vpY, z2 + offset - vpZ
);
if (renderPathAsFrickinThingy) {
IRenderer.emitLine(stack,
IRenderer.emitLine(bufferBuilder, stack,
x2 + offset - vpX, y2 + offset - vpY, z2 + offset - vpZ,
x2 + offset - vpX, y2 + extraOffset - vpY, z2 + offset - vpZ
);
IRenderer.emitLine(stack,
IRenderer.emitLine(bufferBuilder, stack,
x2 + offset - vpX, y2 + extraOffset - vpY, z2 + offset - vpZ,
x1 + offset - vpX, y1 + extraOffset - vpY, z1 + offset - vpZ
);
IRenderer.emitLine(stack,
IRenderer.emitLine(bufferBuilder, stack,
x1 + offset - vpX, y1 + extraOffset - vpY, z1 + offset - vpZ,
x1 + offset - vpX, y1 + offset - vpY, z1 + offset - vpZ
);
@@ -202,7 +204,7 @@ public final class PathRenderer implements IRenderer {
}
public static void drawManySelectionBoxes(PoseStack stack, Entity player, Collection<BlockPos> positions, Color color) {
IRenderer.startLines(color, settings.pathRenderLineWidthPixels.value, settings.renderSelectionBoxesIgnoreDepth.value);
BufferBuilder bufferBuilder = IRenderer.startLines(color, settings.pathRenderLineWidthPixels.value, settings.renderSelectionBoxesIgnoreDepth.value);
//BlockPos blockpos = movingObjectPositionIn.getBlockPos();
BlockStateInterface bsi = new BlockStateInterface(BaritoneAPI.getProvider().getPrimaryBaritone().getPlayerContext()); // TODO this assumes same dimension between primary baritone and render view? is this safe?
@@ -212,17 +214,20 @@ public final class PathRenderer implements IRenderer {
VoxelShape shape = state.getShape(player.level(), pos);
AABB toDraw = shape.isEmpty() ? Shapes.block().bounds() : shape.bounds();
toDraw = toDraw.move(pos);
IRenderer.emitAABB(stack, toDraw, .002D);
IRenderer.emitAABB(bufferBuilder, stack, toDraw, .002D);
});
IRenderer.endLines(settings.renderSelectionBoxesIgnoreDepth.value);
IRenderer.endLines(bufferBuilder, settings.renderSelectionBoxesIgnoreDepth.value);
}
public static void drawGoal(PoseStack stack, IPlayerContext ctx, Goal goal, float partialTicks, Color color) {
drawGoal(stack, ctx, goal, partialTicks, color, true);
drawGoal(null, stack, ctx, goal, partialTicks, color, true);
}
private static void drawGoal(PoseStack stack, IPlayerContext ctx, Goal goal, float partialTicks, Color color, boolean setupRender) {
private static void drawGoal(@Nullable BufferBuilder bufferBuilder, PoseStack stack, IPlayerContext ctx, Goal goal, float partialTicks, Color color, boolean setupRender) {
if (!setupRender && bufferBuilder == null) {
throw new RuntimeException("BufferBuilder must not be null if setupRender is false");
}
double renderPosX = posX();
double renderPosY = posY();
double renderPosZ = posZ();
@@ -254,7 +259,7 @@ public final class PathRenderer implements IRenderer {
y2 -= 0.5;
maxY--;
}
drawDankLitGoalBox(stack, color, minX, maxX, minZ, maxZ, minY, maxY, y1, y2, setupRender);
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();
@@ -280,7 +285,7 @@ public final class PathRenderer implements IRenderer {
settings.renderGoalAnimated.value ? ctx.world().getGameTime() : 0,
(int) minY,
(int) maxY,
color.getColorComponents(null),
color.getRGB(),
// Arguments filled by the private method lol
0.2F,
@@ -304,19 +309,19 @@ public final class PathRenderer implements IRenderer {
y2 = 0;
minY -= renderPosY;
maxY -= renderPosY;
drawDankLitGoalBox(stack, color, minX, maxX, minZ, maxZ, minY, maxY, y1, y2, setupRender);
drawDankLitGoalBox(bufferBuilder, stack, color, minX, maxX, minZ, maxZ, minY, maxY, y1, y2, setupRender);
} else if (goal instanceof GoalComposite) {
// Simple way to determine if goals can be batched, without having some sort of GoalRenderer
boolean batch = Arrays.stream(((GoalComposite) goal).goals()).allMatch(IGoalRenderPos.class::isInstance);
BufferBuilder buf = bufferBuilder;
if (batch) {
IRenderer.startLines(color, settings.goalRenderLineWidthPixels.value, settings.renderGoalIgnoreDepth.value);
buf = IRenderer.startLines(color, settings.goalRenderLineWidthPixels.value, settings.renderGoalIgnoreDepth.value);
}
for (Goal g : ((GoalComposite) goal).goals()) {
drawGoal(stack, ctx, g, partialTicks, color, !batch);
drawGoal(buf, stack, ctx, g, partialTicks, color, !batch);
}
if (batch) {
IRenderer.endLines(settings.renderGoalIgnoreDepth.value);
IRenderer.endLines(buf, settings.renderGoalIgnoreDepth.value);
}
} else if (goal instanceof GoalInverted) {
drawGoal(stack, ctx, ((GoalInverted) goal).origin, partialTicks, settings.colorInvertedGoalBox.value);
@@ -330,37 +335,37 @@ public final class PathRenderer implements IRenderer {
maxY = minY + 2;
y1 = 1 + y + goalpos.level - renderPosY;
y2 = 1 - y + goalpos.level - renderPosY;
drawDankLitGoalBox(stack, color, minX, maxX, minZ, maxZ, minY, maxY, y1, y2, setupRender);
drawDankLitGoalBox(bufferBuilder, stack, color, minX, maxX, minZ, maxZ, minY, maxY, y1, y2, setupRender);
}
}
private static void drawDankLitGoalBox(PoseStack stack, Color colorIn, double minX, double maxX, double minZ, double maxZ, double minY, double maxY, double y1, double y2, boolean setupRender) {
private static void drawDankLitGoalBox(BufferBuilder bufferBuilder, PoseStack stack, Color colorIn, double minX, double maxX, double minZ, double maxZ, double minY, double maxY, double y1, double y2, boolean setupRender) {
if (setupRender) {
IRenderer.startLines(colorIn, settings.goalRenderLineWidthPixels.value, settings.renderGoalIgnoreDepth.value);
bufferBuilder = IRenderer.startLines(colorIn, settings.goalRenderLineWidthPixels.value, settings.renderGoalIgnoreDepth.value);
}
renderHorizontalQuad(stack, minX, maxX, minZ, maxZ, y1);
renderHorizontalQuad(stack, minX, maxX, minZ, maxZ, y2);
renderHorizontalQuad(bufferBuilder, stack, minX, maxX, minZ, maxZ, y1);
renderHorizontalQuad(bufferBuilder, stack, minX, maxX, minZ, maxZ, y2);
for (double y = minY; y < maxY; y += 16) {
double max = Math.min(maxY, y + 16);
IRenderer.emitLine(stack, minX, y, minZ, minX, max, minZ, 0.0, 1.0, 0.0);
IRenderer.emitLine(stack, maxX, y, minZ, maxX, max, minZ, 0.0, 1.0, 0.0);
IRenderer.emitLine(stack, maxX, y, maxZ, maxX, max, maxZ, 0.0, 1.0, 0.0);
IRenderer.emitLine(stack, minX, y, maxZ, minX, max, maxZ, 0.0, 1.0, 0.0);
IRenderer.emitLine(bufferBuilder, stack, minX, y, minZ, minX, max, minZ, 0.0, 1.0, 0.0);
IRenderer.emitLine(bufferBuilder, stack, maxX, y, minZ, maxX, max, minZ, 0.0, 1.0, 0.0);
IRenderer.emitLine(bufferBuilder, stack, maxX, y, maxZ, maxX, max, maxZ, 0.0, 1.0, 0.0);
IRenderer.emitLine(bufferBuilder, stack, minX, y, maxZ, minX, max, maxZ, 0.0, 1.0, 0.0);
}
if (setupRender) {
IRenderer.endLines(settings.renderGoalIgnoreDepth.value);
IRenderer.endLines(bufferBuilder, settings.renderGoalIgnoreDepth.value);
}
}
private static void renderHorizontalQuad(PoseStack stack, double minX, double maxX, double minZ, double maxZ, double y) {
private static void renderHorizontalQuad(BufferBuilder bufferBuilder, PoseStack stack, double minX, double maxX, double minZ, double maxZ, double y) {
if (y != 0) {
IRenderer.emitLine(stack, minX, y, minZ, maxX, y, minZ, 1.0, 0.0, 0.0);
IRenderer.emitLine(stack, maxX, y, minZ, maxX, y, maxZ, 0.0, 0.0, 1.0);
IRenderer.emitLine(stack, maxX, y, maxZ, minX, y, maxZ, -1.0, 0.0, 0.0);
IRenderer.emitLine(stack, minX, y, maxZ, minX, y, minZ, 0.0, 0.0, -1.0);
IRenderer.emitLine(bufferBuilder, stack, minX, y, minZ, maxX, y, minZ, 1.0, 0.0, 0.0);
IRenderer.emitLine(bufferBuilder, stack, maxX, y, minZ, maxX, y, maxZ, 0.0, 0.0, 1.0);
IRenderer.emitLine(bufferBuilder, stack, maxX, y, maxZ, minX, y, maxZ, -1.0, 0.0, 0.0);
IRenderer.emitLine(bufferBuilder, stack, minX, y, maxZ, minX, y, minZ, 0.0, 0.0, -1.0);
}
}
}

View File

@@ -19,16 +19,19 @@ package baritone.utils;
import baritone.Baritone;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.core.Holder;
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.enchantment.EnchantmentHelper;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.item.enchantment.*;
import net.minecraft.world.item.enchantment.effects.EnchantmentAttributeEffect;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
@@ -93,7 +96,15 @@ public class ToolSet {
}
public boolean hasSilkTouch(ItemStack stack) {
return EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, stack) > 0;
ItemEnchantments enchantments = stack.getEnchantments();
for (Holder<Enchantment> enchant : enchantments.keySet()) {
// silk touch enchantment is still special cased as affecting block drops
// not possible to add custom attribute via datapack
if (enchant.is(Enchantments.SILK_TOUCH) && enchantments.getLevel(enchant) > 0) {
return true;
}
}
return false;
}
/**
@@ -190,9 +201,15 @@ public class ToolSet {
float speed = item.getDestroySpeed(state);
if (speed > 1) {
int effLevel = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.EFFICIENCY, item);
if (effLevel > 0 && !item.isEmpty()) {
speed += effLevel * effLevel + 1;
final ItemEnchantments itemEnchantments = item.getEnchantments();
OUTER: for (Holder<Enchantment> enchant : itemEnchantments.keySet()) {
List<EnchantmentAttributeEffect> effects = enchant.value().getEffects(EnchantmentEffectComponents.ATTRIBUTES);
for (EnchantmentAttributeEffect e : effects) {
if (e.attribute().is(Attributes.MINING_EFFICIENCY.unwrapKey().get())) {
speed += e.amount().calculate(itemEnchantments.getLevel(enchant));
break OUTER;
}
}
}
}

View File

@@ -83,7 +83,9 @@ public enum DefaultSchematicFormats implements ISchematicFormat {
case 4: //1.12
case 5: //1.13-1.17
throw new UnsupportedOperationException("This litematic Version is too old.");
case 6: //1.18+
case 6: //1.18-1.20
throw new UnsupportedOperationException("This litematic Version is too old.");
case 7: //1.21+
return new LitematicaSchematic(nbt);
default:
throw new UnsupportedOperationException("Unsuported Version of a Litematica Schematic");

View File

@@ -81,7 +81,7 @@ 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(new ResourceLocation((((CompoundTag) blockStatePalette.get(i)).getString("Name"))));
Block block = BuiltInRegistries.BLOCK.get(ResourceLocation.parse((((CompoundTag) blockStatePalette.get(i)).getString("Name"))));
CompoundTag properties = ((CompoundTag) blockStatePalette.get(i)).getCompound("Properties");
blockList[i] = getBlockState(block, properties);
@@ -273,4 +273,4 @@ public final class LitematicaSchematic extends CompositeSchematic implements ISt
return this.arraySize;
}
}
}
}

View File

@@ -130,7 +130,7 @@ public final class SpongeSchematic extends StaticSchematic {
String location = m.group("location");
String properties = m.group("properties");
ResourceLocation resourceLocation = new ResourceLocation(location);
ResourceLocation resourceLocation = ResourceLocation.parse(location);
Map<String, String> propertiesMap = new HashMap<>();
if (properties != null) {
for (String property : properties.split(",")) {