mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-28 16:06:48 +01:00
Merge branch 'mc1.15/dev' of https://github.com/Creators-of-Create/Create into mc1.15/dev
This commit is contained in:
commit
f8b3a77f26
2 changed files with 30 additions and 10 deletions
|
@ -27,6 +27,7 @@ import net.minecraft.state.EnumProperty;
|
||||||
import net.minecraft.state.IProperty;
|
import net.minecraft.state.IProperty;
|
||||||
import net.minecraft.state.StateContainer.Builder;
|
import net.minecraft.state.StateContainer.Builder;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.ActionResult;
|
||||||
import net.minecraft.util.ActionResultType;
|
import net.minecraft.util.ActionResultType;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.IItemProvider;
|
import net.minecraft.util.IItemProvider;
|
||||||
|
@ -123,29 +124,42 @@ public class BlazeBurnerBlock extends Block implements ITE<BlazeBurnerTileEntity
|
||||||
return ActionResultType.PASS;
|
return ActionResultType.PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tryInsert(state, world, pos, dontConsume ? heldItem.copy() : heldItem, forceOverflow, false))
|
ActionResult<ItemStack> res = tryInsert(state, world, pos, dontConsume ? heldItem.copy() : heldItem, forceOverflow, false);
|
||||||
return ActionResultType.PASS;
|
ItemStack leftover = res.getResult();
|
||||||
return ActionResultType.SUCCESS;
|
if (!world.isRemote && !dontConsume && !leftover.isEmpty()) {
|
||||||
|
if (heldItem.isEmpty()) {
|
||||||
|
player.setHeldItem(hand, leftover);
|
||||||
|
} else if (!player.inventory.addItemStackToInventory(leftover)) {
|
||||||
|
player.dropItem(leftover, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean tryInsert(BlockState state, World world, BlockPos pos, ItemStack stack, boolean forceOverflow,
|
return res.getType() == ActionResultType.SUCCESS ? res.getType() : ActionResultType.PASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ActionResult<ItemStack> tryInsert(BlockState state, World world, BlockPos pos, ItemStack stack, boolean forceOverflow,
|
||||||
boolean simulate) {
|
boolean simulate) {
|
||||||
if (!state.hasTileEntity())
|
if (!state.hasTileEntity())
|
||||||
return false;
|
return ActionResult.fail(ItemStack.EMPTY);
|
||||||
|
|
||||||
TileEntity te = world.getTileEntity(pos);
|
TileEntity te = world.getTileEntity(pos);
|
||||||
if (!(te instanceof BlazeBurnerTileEntity))
|
if (!(te instanceof BlazeBurnerTileEntity))
|
||||||
return false;
|
return ActionResult.fail(ItemStack.EMPTY);
|
||||||
BlazeBurnerTileEntity burnerTE = (BlazeBurnerTileEntity) te;
|
BlazeBurnerTileEntity burnerTE = (BlazeBurnerTileEntity) te;
|
||||||
|
|
||||||
if (!burnerTE.tryUpdateFuel(stack, forceOverflow, simulate))
|
if (!burnerTE.tryUpdateFuel(stack, forceOverflow, simulate))
|
||||||
return false;
|
return ActionResult.fail(ItemStack.EMPTY);
|
||||||
|
|
||||||
|
ItemStack container = stack.getContainerItem();
|
||||||
if (!simulate && !world.isRemote) {
|
if (!simulate && !world.isRemote) {
|
||||||
world.playSound(null, pos, SoundEvents.ENTITY_BLAZE_SHOOT, SoundCategory.BLOCKS,
|
world.playSound(null, pos, SoundEvents.ENTITY_BLAZE_SHOOT, SoundCategory.BLOCKS,
|
||||||
.125f + world.rand.nextFloat() * .125f, .75f - world.rand.nextFloat() * .25f);
|
.125f + world.rand.nextFloat() * .125f, .75f - world.rand.nextFloat() * .25f);
|
||||||
stack.shrink(1);
|
stack.shrink(1);
|
||||||
}
|
}
|
||||||
return true;
|
if (!container.isEmpty()) {
|
||||||
|
return ActionResult.success(container);
|
||||||
|
}
|
||||||
|
return ActionResult.success(ItemStack.EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -36,6 +36,8 @@ import net.minecraft.nbt.NBTUtil;
|
||||||
import net.minecraft.state.properties.BlockStateProperties;
|
import net.minecraft.state.properties.BlockStateProperties;
|
||||||
import net.minecraft.tileentity.JukeboxTileEntity;
|
import net.minecraft.tileentity.JukeboxTileEntity;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.ActionResult;
|
||||||
|
import net.minecraft.util.ActionResultType;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
@ -277,8 +279,12 @@ public abstract class ArmInteractionPoint {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
ItemStack insert(World world, ItemStack stack, boolean simulate) {
|
ItemStack insert(World world, ItemStack stack, boolean simulate) {
|
||||||
boolean success = BlazeBurnerBlock.tryInsert(state, world, pos, stack.copy(), false, simulate);
|
ItemStack input = stack.copy();
|
||||||
return success ? ItemHandlerHelper.copyStackWithSize(stack, stack.getCount() - 1) : stack;
|
if (!BlazeBurnerBlock.tryInsert(state, world, pos, input, false, true).getResult().isEmpty()) {
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
ActionResult<ItemStack> res = BlazeBurnerBlock.tryInsert(state, world, pos, input, false, simulate);
|
||||||
|
return res.getType() == ActionResultType.SUCCESS ? ItemHandlerHelper.copyStackWithSize(stack, stack.getCount() - 1) : stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue