Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override //method inside my custom fireblock class
- public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) {
- if (entity instanceof ItemEntity && ((ItemEntity) entity).getStack().getItem().isFood()) {
- ItemStack foodItem = ((ItemEntity) entity).getStack();
- if (canCook(foodItem)) { //I apologize for all this casting mess
- IFriendlyFireCookable cookableItem = (IFriendlyFireCookable)entity;//applied interface
- if (cookableItem.incrementCookPercentAndCheckIfCooked()) {//check for cook% and spawn new item
- cookableItem.spawnCookedItemEntity(foodItem, (ItemEntity) entity);
- entity.remove(Entity.RemovalReason.DISCARDED); //remove old item (since it was "cooked"
- }
- }
- }
- super.onEntityCollision(state, world, pos, entity);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement