- 83
- 0
Здравствуйте и сразу вопрос. Какое событие отвечает за разрушение блоков игроком? Например, если игрок кликает ЛКМ по дереву, то ему накладывается какой нибудь эффект. В сурсах полазил, ничего не нашёл.
Follow along with the video below to see how to install our site as a web app on your home screen.
Примечание: This feature may not be available in some browsers.
public boolean func_150897_b(Block block) {
if (block == Blocks.sandstone) return true;
return false;
}
public boolean onBlockDestroyed(ItemStack is, World world, Block block, int x, int y, int z, EntityLivingBase entity) {
if (block == Blocks.sandstone) {
is.damageItem(1, entity);//ломается предмет у нас (или у моба)
return true;
}
return false;
}
@Override
public float getDigSpeed(ItemStack stack, Block block, int meta) {
if (block == Blocks.sandstone) {
return 2.0F;//В два раза быстрее
}
return super.getDigSpeed(stack, block, meta);
}
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
@SubscribeEvent
MinecraftForge.EVENT_BUS.register(new EventYouEvent());
FMLCommonHandler.instance().bus().register(new EventYouEvent());
import teemoxa.mods.hardcoremode.items.ItemLoader;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
import net.minecraft.world.biome.WorldChunkManager;
import net.minecraftforge.event.world.BlockEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
public class EventHandlerMod {
EntityPlayer ep;
@SubscribeEvent
public void hasPlayerTool(BlockEvent.BreakEvent e){
if(ep.inventory.getCurrentItem().getItem() == null){
System.out.println("Hello, minecraft!");
}
}
}
if(ep.inventory.getCurrentItem().getItem() == null){
@SubscribeEvent
public void hasPlayerTool(BlockEvent.BreakEvent e){
if (e.getPlayer().inventory.getCurrentItem() == null){
System.out.println("Hello, minecraft!");
}
}
@SubscribeEvent
public void hasPlayerTool(BlockEvent.BreakEvent e) {
ItemStack current = e.getPlayer().getCurrentEquippedItem();
if (current != null && current.getItem() instanceof ИмяКлассаПредмета) {
System.out.println("Hello, minecraft!");
}
}