Search in sources :

Example 1 with ItemBase

use of net.minecraft.item.ItemBase in project StationAPI by ModificationStation.

the class TagItemInit method addItemIgnoreDamage.

private static void addItemIgnoreDamage(String oreDictString, ItemBase itemBase) {
    ItemInstance itemInstanceToUse = new ItemInstance(itemBase);
    TagRegistry.INSTANCE.register(new TagEntry(new ItemInstance(itemBase), itemInstance -> itemInstanceToUse.itemId == itemInstance.itemId, Identifier.of(oreDictString)));
}
Also used : EventListener(net.mine_diver.unsafeevents.listener.EventListener) ItemBase(net.minecraft.item.ItemBase) ListenerPriority(net.mine_diver.unsafeevents.listener.ListenerPriority) EventBusPolicy(net.modificationstation.stationapi.api.mod.entrypoint.EventBusPolicy) LOGGER(net.modificationstation.stationapi.api.StationAPI.LOGGER) TagRegistry(net.modificationstation.stationapi.api.tags.TagRegistry) Entrypoint(net.modificationstation.stationapi.api.mod.entrypoint.Entrypoint) Identifier(net.modificationstation.stationapi.api.registry.Identifier) ItemInstance(net.minecraft.item.ItemInstance) TagRegisterEvent(net.modificationstation.stationapi.api.event.tags.TagRegisterEvent) TagEntry(net.modificationstation.stationapi.api.tags.TagEntry) TagEntry(net.modificationstation.stationapi.api.tags.TagEntry) ItemInstance(net.minecraft.item.ItemInstance)

Example 2 with ItemBase

use of net.minecraft.item.ItemBase in project StationAPI by ModificationStation.

the class ModelOverride method matches.

boolean matches(ItemInstance stack, @Nullable ClientLevel world, @Nullable Living entity) {
    ItemBase item = stack.getType();
    Iterator<Entry<Identifier, Float>> var5 = this.predicateToThresholds.entrySet().iterator();
    Entry<Identifier, Float> entry;
    ModelPredicateProvider modelPredicateProvider;
    if (!var5.hasNext()) {
        return true;
    }
    entry = var5.next();
    modelPredicateProvider = ModelPredicateProviderRegistry.INSTANCE.get(item, entry.getKey());
    while (modelPredicateProvider != null && modelPredicateProvider.call(stack, world, entity) >= entry.getValue()) {
        if (!var5.hasNext()) {
            return true;
        }
        entry = var5.next();
        modelPredicateProvider = ModelPredicateProviderRegistry.INSTANCE.get(item, entry.getKey());
    }
    return false;
}
Also used : Identifier(net.modificationstation.stationapi.api.registry.Identifier) ItemBase(net.minecraft.item.ItemBase) ModelPredicateProvider(net.modificationstation.stationapi.api.client.model.item.ModelPredicateProvider)

Example 3 with ItemBase

use of net.minecraft.item.ItemBase in project StationAPI by ModificationStation.

the class BlockRegistry method setSize.

@Override
protected boolean setSize(int newSize) {
    if (!super.setSize(newSize)) {
        int oldSize = getSize();
        BlockBaseAccessor.stationapi$setById(Arrays.copyOf(BlockBase.BY_ID, newSize));
        BlockBaseAccessor.stationapi$setTicksRandomly(Arrays.copyOf(BlockBase.TICKS_RANDOMLY, newSize));
        BlockBaseAccessor.stationapi$setFullOpaque(Arrays.copyOf(BlockBase.FULL_OPAQUE, newSize));
        BlockBaseAccessor.stationapi$setHasTileEntity(Arrays.copyOf(BlockBase.HAS_TILE_ENTITY, newSize));
        BlockBaseAccessor.stationapi$setLightOpacity(Arrays.copyOf(BlockBase.LIGHT_OPACITY, newSize));
        BlockBaseAccessor.stationapi$setAllowsGrassUnder(Arrays.copyOf(BlockBase.ALLOWS_GRASS_UNDER, newSize));
        BlockBaseAccessor.stationapi$setEmittance(Arrays.copyOf(BlockBase.EMITTANCE, newSize));
        BlockBaseAccessor.stationapi$setNoNotifyOnMetaChange(Arrays.copyOf(BlockBase.NO_NOTIFY_ON_META_CHANGE, newSize));
        ItemBase[] oldItems = ItemBase.byId.clone();
        for (int i = oldSize; i < oldItems.length; i++) {
            ItemBase item = oldItems[i];
            if (item != null) {
                ItemBase.byId[i] = null;
                int newId = i - oldSize + newSize;
                ((ItemBaseAccessor) item).setId(newId);
                (newId < ItemBase.byId.length ? ItemBase.byId : (ItemBase.byId = Arrays.copyOf(ItemBase.byId, MathHelper.isPowerOfTwo(newId + 1) ? newId + 1 : MathHelper.smallestEncompassingPowerOfTwo(newId))))[newId] = item;
            }
        }
    }
    return true;
}
Also used : ItemBaseAccessor(net.modificationstation.stationapi.mixin.block.ItemBaseAccessor) ItemBase(net.minecraft.item.ItemBase)

Aggregations

ItemBase (net.minecraft.item.ItemBase)3 Identifier (net.modificationstation.stationapi.api.registry.Identifier)2 EventListener (net.mine_diver.unsafeevents.listener.EventListener)1 ListenerPriority (net.mine_diver.unsafeevents.listener.ListenerPriority)1 ItemInstance (net.minecraft.item.ItemInstance)1 LOGGER (net.modificationstation.stationapi.api.StationAPI.LOGGER)1 ModelPredicateProvider (net.modificationstation.stationapi.api.client.model.item.ModelPredicateProvider)1 TagRegisterEvent (net.modificationstation.stationapi.api.event.tags.TagRegisterEvent)1 Entrypoint (net.modificationstation.stationapi.api.mod.entrypoint.Entrypoint)1 EventBusPolicy (net.modificationstation.stationapi.api.mod.entrypoint.EventBusPolicy)1 TagEntry (net.modificationstation.stationapi.api.tags.TagEntry)1 TagRegistry (net.modificationstation.stationapi.api.tags.TagRegistry)1 ItemBaseAccessor (net.modificationstation.stationapi.mixin.block.ItemBaseAccessor)1