move block interaction to different place so it doesnt clash with item interaction
This commit is contained in:
@@ -22,7 +22,6 @@ public class FlanForge {
|
||||
forge.addListener(ItemInteractEventsForge::useItem);
|
||||
forge.addListener(BlockInteractEventsForge::startBreakBlocks);
|
||||
forge.addListener(BlockInteractEventsForge::breakBlocks);
|
||||
forge.addListener(BlockInteractEventsForge::useBlocks);
|
||||
forge.addListener(EntityInteractEventsForge::attackEntity);
|
||||
forge.addListener(EntityInteractEventsForge::useAtEntity);
|
||||
forge.addListener(EntityInteractEventsForge::useEntity);
|
||||
|
||||
@@ -3,9 +3,13 @@ package io.github.flemmli97.flan.forge;
|
||||
import io.github.flemmli97.flan.ForgeRegistryWrapper;
|
||||
import io.github.flemmli97.flan.SimpleRegistryWrapper;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.InventoryProvider;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.entity.effect.StatusEffect;
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.fml.loading.FMLPaths;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
import java.nio.file.Path;
|
||||
@@ -27,4 +31,8 @@ public class CrossPlatformStuffImpl {
|
||||
public static SimpleRegistryWrapper<Item> registryItems() {
|
||||
return new ForgeRegistryWrapper<>(ForgeRegistries.ITEMS);
|
||||
}
|
||||
|
||||
public static boolean isInventoryTile(BlockEntity blockEntity) {
|
||||
return blockEntity instanceof Inventory || blockEntity instanceof InventoryProvider || blockEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).isPresent();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
package io.github.flemmli97.flan.forgeevent;
|
||||
|
||||
import io.github.flemmli97.flan.event.BlockInteractEvents;
|
||||
import net.minecraft.block.InventoryProvider;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
|
||||
public class BlockInteractEventsForge {
|
||||
|
||||
@@ -26,17 +22,4 @@ public class BlockInteractEventsForge {
|
||||
if (!BlockInteractEvents.breakBlocks((World) event.getWorld(), event.getPlayer(), event.getPos(), event.getState(), event.getWorld().getBlockEntity(event.getPos())))
|
||||
event.setCanceled(true);
|
||||
}
|
||||
|
||||
//Right click block
|
||||
public static void useBlocks(PlayerInteractEvent.RightClickBlock event) {
|
||||
ActionResult result = BlockInteractEvents.useBlocks(event.getPlayer(), event.getWorld(), event.getHand(), event.getHitVec(), BlockInteractEventsForge::isContainer);
|
||||
if (result != ActionResult.PASS) {
|
||||
event.setCancellationResult(result);
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isContainer(BlockEntity blockEntity) {
|
||||
return blockEntity instanceof Inventory || blockEntity instanceof InventoryProvider || blockEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).isPresent();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user