Jump to content

Kaboom Roads

Members
  • Posts

    20
  • Joined

  • Last visited

Everything posted by Kaboom Roads

  1. It doesn't seem to be canContinueToUse, especially since it's just a check for if the button still exists. But the moveTo method in the tick method returns false when in this broken state, it usually returns true. It seems to be because mob.getNavigation().getPath() is "done", but I don't know how to fix it.
  2. I am using a modified MeleeAttackGoal to make an entity pick a random button, go to it and press it. But after a while it just stops and stares at the current button target. I found out that it's just staring at it because it's too far away to press it. And its's not moving because the current path in the mob navigation is "done". If I move it further away it recalculates a non weird path and fixes itself. If I push it towards the button so it can press it, it sets the target to null, so it once again calculates a new path and fixes itself. What is causing the path to be "done"? And how can I fix this? This is the tick method in the custom goal class: public void tick() { if (mob.buttonTarget != null) { float x = mob.buttonTarget.getX(); float y = mob.buttonTarget.getY(); float z = mob.buttonTarget.getZ(); float hx = x + 0.5f; float hy = y + 0.5f; float hz = z + 0.5f; mob.getLookControl().setLookAt(hx, hy, hz, 30.0F, 30.0F); double distSqr = mob.distanceToSqr(hx, hy, hz); ticksUntilNextPathRecalculation = Math.max(ticksUntilNextPathRecalculation - 1, 0); if ((followingTargetEvenIfNotSeen || hasLineOfSight(mob, mob.buttonTarget)) && ticksUntilNextPathRecalculation <= 0 && ((pathedTargetX == 0.0D && pathedTargetY == 0.0D && pathedTargetZ == 0.0D) || mob.buttonTarget.distSqr(new Vec3i(pathedTargetX, pathedTargetY, pathedTargetZ)) >= 1.0D || mob.getRandom().nextFloat() < 0.05F)) { pathedTargetX = hx; pathedTargetY = hy; pathedTargetZ = hz; ticksUntilNextPathRecalculation = 4 + mob.getRandom().nextInt(7); if (distSqr > 1024.0D) ticksUntilNextPathRecalculation += 10; else if (distSqr > 256.0D) ticksUntilNextPathRecalculation += 5; Path newPath = mob.getNavigation().createPath(mob.buttonTarget, 0); if (newPath != null && !newPath.canReach()) { mob.buttonTarget = null; return; } if (!mob.getNavigation().moveTo(newPath, speedModifier)) ticksUntilNextPathRecalculation += 15; ticksUntilNextPathRecalculation = adjustedTickDelay(ticksUntilNextPathRecalculation); } ticksUntilNextAttack = Math.max(getTicksUntilNextAttack() - 1, 0); checkAndPerformAttack(mob.buttonTarget, distSqr); } }
  3. I've been trying many different ways and I found a way, but it doesn't work with Forge, only Fabric, probably because of the way Forge registers things. @Mixin(NetherFortressStructure.class) public abstract class NetherFortressStructureMixin { @SuppressWarnings("unchecked") @Redirect(method = "<clinit>", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/random/WeightedRandomList;create([Lnet/minecraft/util/random/WeightedEntry;)Lnet/minecraft/util/random/WeightedRandomList;")) private static <E extends WeightedEntry> WeightedRandomList<E> redirectSpawnerData(E[] array) { ArrayList<E> list = new ArrayList<>(List.of(array)); list.add((E) new MobSpawnSettings.SpawnerData(ModEntityTypes.WILDFIRE.get(), 5, 1, 1)); return WeightedRandomList.create(list); } } It tells me "Registry Object not present" with the ModEntityTypes.WILDFIRE.get(). Is there a way I can fix this, and is this even a good way to do this? Also how do I check if the spawn location is inside a structure if the mixin way fails?
  4. I want to make my custom entity spawn naturally in a nether fortress, but I have no idea how. I found out that structure modifiers exist but I can't find any information about them.
  5. I changed new ResourceLocation(name) to new ResourceLocation(SculkyExtras.MOD_ID, name) and now it works. Thanks!
  6. I have a custom tree. I can place it with the place command, and it generates in world gen. But when I try to grow the custom sapling it doesn't work. The sapling works with a vanilla tree grower, but not with my own tree grower. This is my sapling: public static final RegistryObject<Block> ABYSSAL_SAPLING = registerBlockAndItem("abyssal_sapling", () -> new AbyssalSaplingBlock(new AbyssalTreeGrower(), BlockBehaviour.Properties.copy(Blocks.OAK_SAPLING).color(MaterialColor.COLOR_CYAN))); This is my configured features class: public class ExtraConfiguredFeatures { public static final DeferredRegister<ConfiguredFeature<?, ?>> CONFIGURED_FEATURES = DeferredRegister.create(Registries.CONFIGURED_FEATURE, SculkyExtras.MOD_ID); public static final ResourceKey<ConfiguredFeature<?, ?>> ABYSSAL_TREE = createKey("abyssal_tree"); public static final ResourceKey<ConfiguredFeature<?, ?>> ORE_DEEPSLATE = createKey("ore_deepslate"); public static final ResourceKey<ConfiguredFeature<?, ?>> ORE_SCULK = createKey("ore_sculk"); public static final ResourceKey<ConfiguredFeature<?, ?>> ORE_TUFF = createKey("ore_tuff"); public static final ResourceKey<ConfiguredFeature<?, ?>> SCULK_LUSTRE_EXTRA = createKey("sculk_lustre_extra"); public static final ResourceKey<ConfiguredFeature<?, ?>> SCULK_TENDRIL_PATCH = createKey("sculk_tendril_patch"); public static final ResourceKey<ConfiguredFeature<?, ?>> SPRING_SCULK_OPEN = createKey("spring_sculk_open"); public static ResourceKey<ConfiguredFeature<?, ?>> createKey(String name) { return ResourceKey.create(CONFIGURED_FEATURES.getRegistryKey(), new ResourceLocation(name)); } public static void register(IEventBus eventBus) { CONFIGURED_FEATURES.register(eventBus); } } This is my custom tree grower class: public class AbyssalTreeGrower extends AbstractTreeGrower { @Nullable @Override protected ResourceKey<ConfiguredFeature<?, ?>> getConfiguredFeature(@NotNull RandomSource randomSource, boolean largeHive) { return ExtraConfiguredFeatures.ABYSSAL_TREE; } } This is my configured feature { "type": "minecraft:tree", "config": { "decorators": [], "dirt_provider": { "type": "minecraft:simple_state_provider", "state": { "Name": "minecraft:sculk" } }, "foliage_placer": { "type": "minecraft:random_spread_foliage_placer", "foliage_height": 2, "leaf_placement_attempts": 70, "offset": 0, "radius": 3 }, "foliage_provider": { "type": "minecraft:simple_state_provider", "state": { "Name": "sculkyextras:abyssal_leaves", "Properties": { "distance": "7", "persistent": "false", "waterlogged": "false" } } }, "force_dirt": false, "ignore_vines": true, "minimum_size": { "type": "minecraft:two_layers_feature_size", "limit": 1, "lower_size": 0, "upper_size": 1 }, "trunk_placer": { "type": "minecraft:straight_trunk_placer", "base_height": 4, "height_rand_a": 2, "height_rand_b": 0 }, "trunk_provider": { "type": "minecraft:simple_state_provider", "state": { "Name": "sculkyextras:abyssal_log", "Properties": { "axis": "y" } } } } }
  7. I want to inject into the Warden canTargetEntity method, but it just doesn't seem to work. There isn't a single error in the console. Here is my WardenMixin class: package com.kaboomroads.sculkybits.mixin; import com.kaboomroads.sculkybits.block.entity.custom.SculkAttacker; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.monster.warden.Warden; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(Warden.class) public abstract class WardenMixin { @Inject(method = "canTargetEntity(Lnet/minecraft/world/entity/Entity;)Z", at = @At("HEAD"), cancellable = true) public void canTargetEntity(Entity entity, CallbackInfoReturnable<Boolean> cir) { System.out.println("mixin working!"); if (!SculkAttacker.testAttackable(entity)) cir.setReturnValue(false); } } It does not print "mixin working!" And this is my sculkybits.mixins.json: { "required": true, "minVersion": "0.8", "package": "com.kaboomroads.sculkybits.mixin", "compatibilityLevel": "JAVA_17", "refmap": "sculkybits.refmap.json", "mixins": [ "WardenMixin" ], "client": [ ], "injectors": { "defaultRequire": 1 } }
  8. i want to animate the texture of a tile entity using a block entity renderer. how can i change the texture of a tile entity with a BER?
  9. it now works very well, i cant really find any problems with it at the moment. these are the access transformers i used: # Access visit in GameRuleTypeVisitor public net.minecraft.world.level.GameRules$GameRuleTypeVisitor m_6889_(Lnet/minecraft/world/level/GameRules$Key;Lnet/minecraft/world/level/GameRules$Type;)V # visit # Access VisitorCaller in GameRules public net.minecraft.world.level.GameRules$VisitorCaller # Access Type constructor in GameRules$Type public net.minecraft.world.level.GameRules$Type <init>(Ljava/util/function/Supplier;Ljava/util/function/Function;Ljava/util/function/BiConsumer;Lnet/minecraft/world/level/GameRules$VisitorCaller;)V
  10. if i ctrl click on it, it takes me to the correct constructor. i cant find anything about constructor access transformers. adding params is weird because it wants a return type as if it was a method, even though it is a constructor. i cant find anything about constructors in the AT documentation. when i have public net.minecraft.world.level.GameRules$Type <init> it tells me Access Transformer entry is never used.
  11. after refreshing gradle project a lot of things now line up with the compilation errors. now it only says the Type constructor is private. Type(java.util.function.Supplier<com.mojang.brigadier.arguments.ArgumentType<?>>, java.util.function.Function<net.minecraft.world.level.GameRules.Type<T>,T>, java.util.function.BiConsumer<net.minecraft.server.MinecraftServer,T>, net.minecraft.world.level.GameRules.VisitorCaller<T>)' is not public in 'net.minecraft.world.level.GameRules.Type'. Cannot be accessed from outside package this is the access transformer i use for it: public net.minecraft.world.level.GameRules$Type <init>
  12. i want to make a gamerule with a float value. is this possible and how can i do it. so far i have tried copying an existing type and changing it: public static class FloatValue extends GameRules.Value<FloatValue> { private float value; private static GameRules.Type<FloatValue> create(float p_46295_, BiConsumer<MinecraftServer, FloatValue> p_46296_) { return new GameRules.Type<>(FloatArgumentType::floatArg, (p_46293_) -> new FloatValue(p_46293_, p_46295_), p_46296_, GameRules.GameRuleTypeVisitor::visit); } public static GameRules.Type<FloatValue> create(float p_46313_) { return create(p_46313_, (p_46309_, p_46310_) -> { }); } public FloatValue(GameRules.Type<FloatValue> p_46286_, float p_46287_) { super(p_46286_); this.value = p_46287_; } protected void updateFromArgument(@NotNull CommandContext<CommandSourceStack> p_46304_, @NotNull String p_46305_) { this.value = FloatArgumentType.getFloat(p_46304_, p_46305_); } public float get() { return this.value; } public void set(float p_151490_, @Nullable MinecraftServer p_151491_) { this.value = p_151490_; this.onChanged(p_151491_); } @NotNull public String serialize() { return Float.toString(this.value); } protected void deserialize(@NotNull String p_46307_) { this.value = safeParse(p_46307_); } public boolean tryDeserialize(String p_46315_) { try { this.value = Float.parseFloat(p_46315_); return true; } catch (NumberFormatException numberformatexception) { return false; } } private static float safeParse(String p_46318_) { if (!p_46318_.isEmpty()) { try { return Float.parseFloat(p_46318_); } catch (NumberFormatException numberformatexception) { LogUtils.getLogger().warn("Failed to parse float {}", p_46318_); } } return 0; } public int getCommandResult() { return (int) this.value; } @NotNull protected FloatValue getSelf() { return this; } @NotNull protected FloatValue copy() { return new FloatValue(this.type, this.value); } public void setFrom(FloatValue p_46298_, @Nullable MinecraftServer p_46299_) { this.value = p_46298_.value; this.onChanged(p_46299_); } } there is a problem with the private static GameRules.Type<FloatValue> create(float p_46295_, BiConsumer<MinecraftServer, FloatValue> p_46296_) method. the last parameter shows me this error when i hover over it: 'net.minecraft.world.level.GameRules.VisitorCaller' is not public in 'net.minecraft.world.level.GameRules'. Cannot be accessed from outside package when i try compiling it tells me this: error: <T>Type(Supplier<ArgumentType<?>>,Function<Type<T>,T>,BiConsumer<MinecraftServer,T>,VisitorCaller<T>) is not public in Type; cannot be accessed from outside package return new GameRules.Type<>(FloatArgumentType::floatArg, (p_46293_) -> new FloatValue(p_46293_, p_46295_), p_46296_, GameRules.GameRuleTypeVisitor::visit); ^ where T is a type-variable: T extends Value<T> declared in class Type i tried using access transformers for this, one for the visitor caller as it tells me its private, and one for the Type constructor that it also tells me is private. public net.minecraft.world.level.GameRules$VisitorCaller public net.minecraft.world.level.GameRules$Type <init> doesnt seem to do anything. nothing shows up in the ide with the second error, its only when i try to compile.
  13. solved! using access transformers to make BooleanValue.create(boolean value) public, same with IntegerValue.
  14. i actually have exactly that right now, but texture animation is synchronized for all textures and so it looks kinda weird and the timing is wrong. @Override public void stepOn(@NotNull Level level, @NotNull BlockPos pos, @NotNull BlockState blockState, @NotNull Entity entity) { if (!level.isClientSide) { if (entity instanceof LivingEntity livingEntity) { if (!blockState.getValue(BITING)) { level.setBlock(pos, blockState.setValue(BITING, true), 3); livingEntity.hurt(ModDamageSource.GROUND_ATTACK, 6); level.scheduleTick(pos, this, 20); } } } super.stepOn(level, pos, blockState, entity); } @Override public void tick(@NotNull BlockState blockState, @NotNull ServerLevel level, @NotNull BlockPos pos, @NotNull RandomSource source) { if (!level.isClientSide) { level.setBlock(pos, blockState.setValue(BITING, false), 3); } super.tick(blockState, level, pos, source); }
  15. is it possible to make an animation (texture animation) that only triggers once when i want it to?
  16. for some reason i can jump normally in my custom fluid if i am touching the ground, this doesnt happen with lava or water, is there anything that changes how jumping works in fluids?
  17. how do i get the color i want for a potion and turn it into the integer value mincraft uses?
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.