Программисты JAVA общаются здесь
Anonymous
Почему мой мод не ломает визуальные блоки на сервере майнкрафт
Сообщение
Anonymous » 24 окт 2025, 05:36
Добрый день/вечер. Столкнулся с проблемой в моде: почему, когда я пытаюсь визуально разбить блок на спавне, он возвращает его обратно, хотя не должен?
Код: Выделить всё
package com.example.visualbreakmod;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.DestroyBlockProgress;
import net.minecraft.init.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import java.util.HashMap;
import java.util.Map;
@Mod(modid = VisualBreakMod.MODID, name = VisualBreakMod.NAME, version = VisualBreakMod.VERSION, clientSideOnly = true)
public class VisualBreakMod {
public static final String MODID = "visualbreakmod";
public static final String NAME = "Visual Break Mod";
public static final String VERSION = "1.0";
private Minecraft mc = Minecraft.getMinecraft();
private Map breakingBlocks = new HashMap();
@Mod.EventHandler
public void init(FMLInitializationEvent event) {
MinecraftForge.EVENT_BUS.register(this);
}
public void startVisualBreak(BlockPos pos) {
breakingBlocks.put(pos, 0);
mc.world.setBlockState(pos, Blocks.AIR.getDefaultState(), 8);
}
@SubscribeEvent
public void onRenderWorld(RenderWorldLastEvent event) {
for (Map.Entry entry : breakingBlocks.entrySet()) {
BlockPos pos = entry.getKey();
int progress = entry.getValue();
mc.world.sendBlockBreakProgress(mc.player.getEntityId(), pos, progress);
if (progress < 10) {
entry.setValue(progress + 1);
}
}
breakingBlocks.entrySet().removeIf(e -> e.getValue() > 10);
}
}
Я пытался решить эту проблему с помощью ChatGPT, так как не вижу ошибок в коде, но мне это тоже не помоглоррр
Подробнее здесь:
https://stackoverflow.com/questions/797 ... -minecraft
1761273363
Anonymous
Добрый день/вечер. Столкнулся с проблемой в моде: почему, когда я пытаюсь визуально разбить блок на спавне, он возвращает его обратно, хотя не должен? [code]package com.example.visualbreakmod; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.DestroyBlockProgress; import net.minecraft.init.Blocks; import net.minecraft.util.math.BlockPos; import net.minecraftforge.client.event.RenderWorldLastEvent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import java.util.HashMap; import java.util.Map; @Mod(modid = VisualBreakMod.MODID, name = VisualBreakMod.NAME, version = VisualBreakMod.VERSION, clientSideOnly = true) public class VisualBreakMod { public static final String MODID = "visualbreakmod"; public static final String NAME = "Visual Break Mod"; public static final String VERSION = "1.0"; private Minecraft mc = Minecraft.getMinecraft(); private Map breakingBlocks = new HashMap(); @Mod.EventHandler public void init(FMLInitializationEvent event) { MinecraftForge.EVENT_BUS.register(this); } public void startVisualBreak(BlockPos pos) { breakingBlocks.put(pos, 0); mc.world.setBlockState(pos, Blocks.AIR.getDefaultState(), 8); } @SubscribeEvent public void onRenderWorld(RenderWorldLastEvent event) { for (Map.Entry entry : breakingBlocks.entrySet()) { BlockPos pos = entry.getKey(); int progress = entry.getValue(); mc.world.sendBlockBreakProgress(mc.player.getEntityId(), pos, progress); if (progress < 10) { entry.setValue(progress + 1); } } breakingBlocks.entrySet().removeIf(e -> e.getValue() > 10); } } [/code] Я пытался решить эту проблему с помощью ChatGPT, так как не вижу ошибок в коде, но мне это тоже не помоглоррр Подробнее здесь: [url]https://stackoverflow.com/questions/79791538/why-my-mod-not-breaks-visual-blocks-on-the-server-minecraft[/url]