Name change
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
package com.oierbravo.mechanical_lemon_lib.utility;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class ItemHandlerUtils {
|
||||
public static boolean tryToPushBottom(Level pLevel, BlockPos pBlockPos, ItemStackHandler outputItems, boolean simulate){
|
||||
ItemStack outputItemStack = outputItems.extractItem(0,64,true);
|
||||
if(outputItemStack.isEmpty())
|
||||
return false;
|
||||
|
||||
Optional<IItemHandler> belowItemHandler = getItemHandler(pLevel, pBlockPos.below());
|
||||
if(belowItemHandler.isEmpty())
|
||||
return false;
|
||||
|
||||
if(simulate)
|
||||
return true;
|
||||
|
||||
ItemStack remainderItemStack = ItemHandlerHelper.insertItem(belowItemHandler.get(), outputItemStack, true);
|
||||
outputItems.setStackInSlot(0,remainderItemStack);
|
||||
ItemHandlerHelper.insertItem(belowItemHandler.get(), outputItemStack, false);
|
||||
return true;
|
||||
}
|
||||
public static Optional<IItemHandler> getItemHandler(Level pLevel, BlockPos pBlockPos){
|
||||
if(pLevel != null && pLevel.isClientSide())
|
||||
return Optional.empty();
|
||||
BlockEntity blockEntity = pLevel.getBlockEntity(pBlockPos);
|
||||
if(blockEntity == null)
|
||||
return Optional.empty();
|
||||
|
||||
@NotNull LazyOptional<IItemHandler> inventoryHandler = blockEntity.getCapability(ForgeCapabilities.ITEM_HANDLER);
|
||||
if(!inventoryHandler.isPresent())
|
||||
return Optional.empty();
|
||||
return blockEntity.getCapability(ForgeCapabilities.ITEM_HANDLER).resolve();
|
||||
}
|
||||
}
|
||||
17
src/main/java/com/oierbravo/mechanicals/utility/LibLang.java
Normal file
17
src/main/java/com/oierbravo/mechanicals/utility/LibLang.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.oierbravo.mechanicals.utility;
|
||||
|
||||
import com.oierbravo.mechanicals.Mechanicals;
|
||||
import net.createmod.catnip.lang.Lang;
|
||||
import net.createmod.catnip.lang.LangBuilder;
|
||||
|
||||
public class LibLang extends Lang {
|
||||
public LibLang() {
|
||||
super();
|
||||
}
|
||||
public static LangBuilder builder() {
|
||||
return new LangBuilder(Mechanicals.MODID);
|
||||
}
|
||||
public static LangBuilder translate(String langKey, Object... args) {
|
||||
return builder().translate(langKey, args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.oierbravo.mechanicals.utility;
|
||||
|
||||
import com.simibubi.create.api.stress.BlockStressValues;
|
||||
import com.tterrag.registrate.util.nullness.NonNullConsumer;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MechanicalRegistrate {
|
||||
public static <B extends Block> @NotNull NonNullConsumer<B> setImpact(double value) {
|
||||
return (block) -> {
|
||||
BlockStressValues.IMPACTS.register(block, () -> value);
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user