mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-10-24 02:17:39 +00:00
A lot is broken, but at least we can get in game: - GUIs render a whole bunch of additional "inventory" text, which we really don't want. - Computers load from the wrong location. - There's some issues with using Forge's tags from outside of JSON recipes. We need to work out why.
54 lines
1.6 KiB
Java
54 lines
1.6 KiB
Java
/*
|
|
* This file is part of ComputerCraft - http://www.computercraft.info
|
|
* Copyright Daniel Ratcliffe, 2011-2020. Do not distribute without permission.
|
|
* Send enquiries to dratcliffe@gmail.com
|
|
*/
|
|
package dan200.computercraft.shared.data;
|
|
|
|
import dan200.computercraft.shared.computer.blocks.IComputerTile;
|
|
import net.minecraft.loot.LootConditionType;
|
|
import net.minecraft.loot.LootContext;
|
|
import net.minecraft.loot.LootParameter;
|
|
import net.minecraft.loot.LootParameters;
|
|
import net.minecraft.loot.conditions.ILootCondition;
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
import javax.annotation.Nonnull;
|
|
import java.util.Collections;
|
|
import java.util.Set;
|
|
|
|
/**
|
|
* A loot condition which checks if the tile entity has has a non-0 ID.
|
|
*/
|
|
public final class HasComputerIdLootCondition implements ILootCondition
|
|
{
|
|
public static final HasComputerIdLootCondition INSTANCE = new HasComputerIdLootCondition();
|
|
public static final LootConditionType TYPE = ConstantLootConditionSerializer.type( INSTANCE );
|
|
public static final IBuilder BUILDER = () -> INSTANCE;
|
|
|
|
private HasComputerIdLootCondition()
|
|
{
|
|
}
|
|
|
|
@Override
|
|
public boolean test( LootContext lootContext )
|
|
{
|
|
TileEntity tile = lootContext.get( LootParameters.BLOCK_ENTITY );
|
|
return tile instanceof IComputerTile && ((IComputerTile) tile).getComputerID() >= 0;
|
|
}
|
|
|
|
@Nonnull
|
|
@Override
|
|
public Set<LootParameter<?>> getRequiredParameters()
|
|
{
|
|
return Collections.singleton( LootParameters.BLOCK_ENTITY );
|
|
}
|
|
|
|
@Override
|
|
@Nonnull
|
|
public LootConditionType func_230419_b_()
|
|
{
|
|
return TYPE;
|
|
}
|
|
}
|