Reorganized Imports/Packages
This commit is contained in:
parent
cb9459f176
commit
3ee10482ab
721 changed files with 34873 additions and 33558 deletions
77
src/main/java/org/betterx/bclib/items/BaseAnvilItem.java
Normal file
77
src/main/java/org/betterx/bclib/items/BaseAnvilItem.java
Normal file
|
@ -0,0 +1,77 @@
|
|||
package org.betterx.bclib.items;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.TooltipFlag;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.IntegerProperty;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
||||
import org.betterx.bclib.blocks.BaseAnvilBlock;
|
||||
import org.betterx.bclib.interfaces.BlockModelProvider;
|
||||
import org.betterx.bclib.interfaces.ItemModelProvider;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class BaseAnvilItem extends BlockItem implements ItemModelProvider {
|
||||
public final static String DESTRUCTION = "destruction";
|
||||
|
||||
public BaseAnvilItem(Block block, Properties properties) {
|
||||
super(block, properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockState getPlacementState(BlockPlaceContext blockPlaceContext) {
|
||||
BlockState blockState = super.getPlacementState(blockPlaceContext);
|
||||
ItemStack stack = blockPlaceContext.getItemInHand();
|
||||
int destruction = stack.getOrCreateTag().getInt(DESTRUCTION);
|
||||
if (blockState != null) {
|
||||
BaseAnvilBlock block = (BaseAnvilBlock) blockState.getBlock();
|
||||
IntegerProperty durabilityProp = block.getDurabilityProp();
|
||||
if (destruction == 0) {
|
||||
blockState = blockState.setValue(durabilityProp, 0).setValue(BaseAnvilBlock.DESTRUCTION, 0);
|
||||
} else {
|
||||
int destructionValue = destruction / block.getMaxDurability();
|
||||
int durabilityValue = destruction - destructionValue * block.getMaxDurability();
|
||||
blockState = blockState.setValue(durabilityProp, durabilityValue)
|
||||
.setValue(BaseAnvilBlock.DESTRUCTION, destructionValue);
|
||||
}
|
||||
}
|
||||
return blockState;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public void appendHoverText(ItemStack itemStack,
|
||||
@Nullable Level level,
|
||||
List<Component> list,
|
||||
TooltipFlag tooltipFlag) {
|
||||
int destruction = itemStack.getOrCreateTag().getInt(DESTRUCTION);
|
||||
if (destruction > 0) {
|
||||
BaseAnvilBlock block = (BaseAnvilBlock) ((BaseAnvilItem) itemStack.getItem()).getBlock();
|
||||
int maxValue = block.getMaxDurability() * 3;
|
||||
float damage = maxValue - destruction;
|
||||
String percents = String.format(Locale.ROOT, "%.0f%%", damage);
|
||||
list.add(Component.translatable("message.bclib.anvil_damage").append(": " + percents));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public BlockModel getItemModel(ResourceLocation resourceLocation) {
|
||||
Block anvilBlock = getBlock();
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(anvilBlock);
|
||||
return ((BlockModelProvider) anvilBlock).getBlockModel(blockId, anvilBlock.defaultBlockState());
|
||||
}
|
||||
}
|
62
src/main/java/org/betterx/bclib/items/BaseArmorItem.java
Normal file
62
src/main/java/org/betterx/bclib/items/BaseArmorItem.java
Normal file
|
@ -0,0 +1,62 @@
|
|||
package org.betterx.bclib.items;
|
||||
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.entity.ai.attributes.Attribute;
|
||||
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
|
||||
import net.minecraft.world.entity.ai.attributes.Attributes;
|
||||
import net.minecraft.world.item.ArmorItem;
|
||||
import net.minecraft.world.item.ArmorMaterial;
|
||||
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import org.betterx.bclib.interfaces.ItemModelProvider;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class BaseArmorItem extends ArmorItem implements ItemModelProvider {
|
||||
|
||||
protected static final UUID[] ARMOR_MODIFIER_UUID_PER_SLOT = new UUID[]{
|
||||
UUID.fromString("845DB27C-C624-495F-8C9F-6020A9A58B6B"),
|
||||
UUID.fromString("D8499B04-0E66-4726-AB29-64469D734E0D"),
|
||||
UUID.fromString("9F3D476D-C118-4544-8365-64846904B48E"),
|
||||
UUID.fromString("2AD3F246-FEE1-4E67-B886-69FD380BB150")
|
||||
};
|
||||
|
||||
protected final Multimap<Attribute, AttributeModifier> defaultModifiers;
|
||||
|
||||
public BaseArmorItem(ArmorMaterial material, EquipmentSlot equipmentSlot, Properties settings) {
|
||||
super(material, equipmentSlot, settings);
|
||||
this.defaultModifiers = HashMultimap.create();
|
||||
UUID uuid = ARMOR_MODIFIER_UUID_PER_SLOT[equipmentSlot.getIndex()];
|
||||
addAttributeModifier(
|
||||
Attributes.ARMOR,
|
||||
new AttributeModifier(uuid, "Armor modifier", getDefense(), AttributeModifier.Operation.ADDITION)
|
||||
);
|
||||
addAttributeModifier(
|
||||
Attributes.ARMOR_TOUGHNESS,
|
||||
new AttributeModifier(uuid, "Armor toughness", getToughness(), AttributeModifier.Operation.ADDITION)
|
||||
);
|
||||
if (knockbackResistance > 0.0F) {
|
||||
addAttributeModifier(
|
||||
Attributes.KNOCKBACK_RESISTANCE,
|
||||
new AttributeModifier(uuid,
|
||||
"Armor knockback resistance",
|
||||
knockbackResistance,
|
||||
AttributeModifier.Operation.ADDITION
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Multimap<Attribute, AttributeModifier> getDefaultAttributeModifiers(EquipmentSlot equipmentSlot) {
|
||||
return equipmentSlot == slot ? defaultModifiers : super.getDefaultAttributeModifiers(equipmentSlot);
|
||||
}
|
||||
|
||||
protected void addAttributeModifier(Attribute attribute, AttributeModifier modifier) {
|
||||
if (defaultModifiers.containsKey(attribute)) {
|
||||
defaultModifiers.removeAll(attribute);
|
||||
}
|
||||
defaultModifiers.put(attribute, modifier);
|
||||
}
|
||||
}
|
9
src/main/java/org/betterx/bclib/items/BaseAttribute.java
Normal file
9
src/main/java/org/betterx/bclib/items/BaseAttribute.java
Normal file
|
@ -0,0 +1,9 @@
|
|||
package org.betterx.bclib.items;
|
||||
|
||||
import net.minecraft.world.entity.ai.attributes.Attribute;
|
||||
|
||||
public class BaseAttribute extends Attribute {
|
||||
public BaseAttribute(String description, double value) {
|
||||
super(description, value);
|
||||
}
|
||||
}
|
16
src/main/java/org/betterx/bclib/items/BaseBucketItem.java
Normal file
16
src/main/java/org/betterx/bclib/items/BaseBucketItem.java
Normal file
|
@ -0,0 +1,16 @@
|
|||
package org.betterx.bclib.items;
|
||||
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.item.MobBucketItem;
|
||||
import net.minecraft.world.level.material.Fluids;
|
||||
|
||||
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
|
||||
|
||||
import org.betterx.bclib.interfaces.ItemModelProvider;
|
||||
|
||||
public class BaseBucketItem extends MobBucketItem implements ItemModelProvider {
|
||||
public BaseBucketItem(EntityType<?> type, FabricItemSettings settings) {
|
||||
super(type, Fluids.WATER, SoundEvents.BUCKET_EMPTY_FISH, settings.stacksTo(1));
|
||||
}
|
||||
}
|
12
src/main/java/org/betterx/bclib/items/BaseDiscItem.java
Normal file
12
src/main/java/org/betterx/bclib/items/BaseDiscItem.java
Normal file
|
@ -0,0 +1,12 @@
|
|||
package org.betterx.bclib.items;
|
||||
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.world.item.RecordItem;
|
||||
|
||||
import org.betterx.bclib.interfaces.ItemModelProvider;
|
||||
|
||||
public class BaseDiscItem extends RecordItem implements ItemModelProvider {
|
||||
public BaseDiscItem(int comparatorOutput, SoundEvent sound, Properties settings) {
|
||||
super(comparatorOutput, sound, settings);
|
||||
}
|
||||
}
|
59
src/main/java/org/betterx/bclib/items/BaseDrinkItem.java
Normal file
59
src/main/java/org/betterx/bclib/items/BaseDrinkItem.java
Normal file
|
@ -0,0 +1,59 @@
|
|||
package org.betterx.bclib.items;
|
||||
|
||||
import net.minecraft.advancements.CriteriaTriggers;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.stats.Stats;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResultHolder;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.ItemUtils;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.UseAnim;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
public class BaseDrinkItem extends ModelProviderItem {
|
||||
public BaseDrinkItem(Properties settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUseDuration(ItemStack stack) {
|
||||
return 32;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UseAnim getUseAnimation(ItemStack stack) {
|
||||
return UseAnim.DRINK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResultHolder<ItemStack> use(Level world, Player user, InteractionHand hand) {
|
||||
return ItemUtils.startUsingInstantly(world, user, hand);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack finishUsingItem(ItemStack stack, Level level, LivingEntity user) {
|
||||
if (this.isEdible()) {
|
||||
int count = stack.getCount();
|
||||
user.eat(level, stack);
|
||||
stack.setCount(count);
|
||||
}
|
||||
|
||||
if (user instanceof ServerPlayer serverPlayerEntity) {
|
||||
CriteriaTriggers.CONSUME_ITEM.trigger(serverPlayerEntity, stack);
|
||||
serverPlayerEntity.awardStat(Stats.ITEM_USED.get(this));
|
||||
}
|
||||
|
||||
if (user instanceof Player && !((Player) user).getAbilities().instabuild) {
|
||||
stack.shrink(1);
|
||||
}
|
||||
|
||||
if (!level.isClientSide) {
|
||||
user.removeAllEffects();
|
||||
}
|
||||
|
||||
return stack.isEmpty() ? new ItemStack(Items.GLASS_BOTTLE) : stack;
|
||||
}
|
||||
}
|
30
src/main/java/org/betterx/bclib/items/BaseSpawnEggItem.java
Normal file
30
src/main/java/org/betterx/bclib/items/BaseSpawnEggItem.java
Normal file
|
@ -0,0 +1,30 @@
|
|||
package org.betterx.bclib.items;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.item.SpawnEggItem;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
||||
import org.betterx.bclib.client.models.BasePatterns;
|
||||
import org.betterx.bclib.client.models.ModelsHelper;
|
||||
import org.betterx.bclib.client.models.PatternsHelper;
|
||||
import org.betterx.bclib.interfaces.ItemModelProvider;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class BaseSpawnEggItem extends SpawnEggItem implements ItemModelProvider {
|
||||
public BaseSpawnEggItem(EntityType<? extends Mob> type, int primaryColor, int secondaryColor, Properties settings) {
|
||||
super(type, primaryColor, secondaryColor, settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public BlockModel getItemModel(ResourceLocation resourceLocation) {
|
||||
Optional<String> pattern = PatternsHelper.createJson(BasePatterns.ITEM_SPAWN_EGG, resourceLocation);
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
}
|
23
src/main/java/org/betterx/bclib/items/ModelProviderItem.java
Normal file
23
src/main/java/org/betterx/bclib/items/ModelProviderItem.java
Normal file
|
@ -0,0 +1,23 @@
|
|||
package org.betterx.bclib.items;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.Item;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
||||
import org.betterx.bclib.client.models.ModelsHelper;
|
||||
import org.betterx.bclib.interfaces.ItemModelProvider;
|
||||
|
||||
public class ModelProviderItem extends Item implements ItemModelProvider {
|
||||
public ModelProviderItem(Properties settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public BlockModel getItemModel(ResourceLocation resourceLocation) {
|
||||
return ModelsHelper.createItemModel(resourceLocation);
|
||||
}
|
||||
}
|
24
src/main/java/org/betterx/bclib/items/tool/BaseAxeItem.java
Normal file
24
src/main/java/org/betterx/bclib/items/tool/BaseAxeItem.java
Normal file
|
@ -0,0 +1,24 @@
|
|||
package org.betterx.bclib.items.tool;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.AxeItem;
|
||||
import net.minecraft.world.item.Tier;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
||||
import org.betterx.bclib.client.models.ModelsHelper;
|
||||
import org.betterx.bclib.interfaces.ItemModelProvider;
|
||||
|
||||
public class BaseAxeItem extends AxeItem implements ItemModelProvider {
|
||||
public BaseAxeItem(Tier material, float attackDamage, float attackSpeed, Properties settings) {
|
||||
super(material, attackDamage, attackSpeed, settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public BlockModel getItemModel(ResourceLocation resourceLocation) {
|
||||
return ModelsHelper.createHandheldItem(resourceLocation);
|
||||
}
|
||||
}
|
24
src/main/java/org/betterx/bclib/items/tool/BaseHoeItem.java
Normal file
24
src/main/java/org/betterx/bclib/items/tool/BaseHoeItem.java
Normal file
|
@ -0,0 +1,24 @@
|
|||
package org.betterx.bclib.items.tool;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.HoeItem;
|
||||
import net.minecraft.world.item.Tier;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
||||
import org.betterx.bclib.client.models.ModelsHelper;
|
||||
import org.betterx.bclib.interfaces.ItemModelProvider;
|
||||
|
||||
public class BaseHoeItem extends HoeItem implements ItemModelProvider {
|
||||
public BaseHoeItem(Tier material, int attackDamage, float attackSpeed, Properties settings) {
|
||||
super(material, attackDamage, attackSpeed, settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public BlockModel getItemModel(ResourceLocation resourceLocation) {
|
||||
return ModelsHelper.createHandheldItem(resourceLocation);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package org.betterx.bclib.items.tool;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.PickaxeItem;
|
||||
import net.minecraft.world.item.Tier;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
||||
import org.betterx.bclib.client.models.ModelsHelper;
|
||||
import org.betterx.bclib.interfaces.ItemModelProvider;
|
||||
|
||||
public class BasePickaxeItem extends PickaxeItem implements ItemModelProvider {
|
||||
public BasePickaxeItem(Tier material, int attackDamage, float attackSpeed, Properties settings) {
|
||||
super(material, attackDamage, attackSpeed, settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public BlockModel getItemModel(ResourceLocation resourceLocation) {
|
||||
return ModelsHelper.createHandheldItem(resourceLocation);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package org.betterx.bclib.items.tool;
|
||||
|
||||
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.ShearsItem;
|
||||
|
||||
import net.fabricmc.fabric.api.mininglevel.v1.FabricMineableTags;
|
||||
|
||||
import org.betterx.bclib.api.tag.CommonItemTags;
|
||||
import org.betterx.bclib.api.tag.TagAPI;
|
||||
|
||||
public class BaseShearsItem extends ShearsItem {
|
||||
public BaseShearsItem(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
public static boolean isShear(ItemStack tool) {
|
||||
return tool.is(Items.SHEARS) | tool.is(CommonItemTags.SHEARS) || TagAPI.isToolWithMineableTag(tool,
|
||||
FabricMineableTags.SHEARS_MINEABLE);
|
||||
}
|
||||
|
||||
public static boolean isShear(ItemStack itemStack, Item item) {
|
||||
if (item == Items.SHEARS) {
|
||||
return itemStack.is(item) | itemStack.is(CommonItemTags.SHEARS);
|
||||
} else {
|
||||
return itemStack.is(item);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package org.betterx.bclib.items.tool;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ShovelItem;
|
||||
import net.minecraft.world.item.Tier;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
||||
import org.betterx.bclib.client.models.ModelsHelper;
|
||||
import org.betterx.bclib.interfaces.ItemModelProvider;
|
||||
|
||||
public class BaseShovelItem extends ShovelItem implements ItemModelProvider {
|
||||
public BaseShovelItem(Tier material, float attackDamage, float attackSpeed, Properties settings) {
|
||||
super(material, attackDamage, attackSpeed, settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public BlockModel getItemModel(ResourceLocation resourceLocation) {
|
||||
return ModelsHelper.createHandheldItem(resourceLocation);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package org.betterx.bclib.items.tool;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.SwordItem;
|
||||
import net.minecraft.world.item.Tier;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
||||
import org.betterx.bclib.client.models.ModelsHelper;
|
||||
import org.betterx.bclib.interfaces.ItemModelProvider;
|
||||
|
||||
public class BaseSwordItem extends SwordItem implements ItemModelProvider {
|
||||
public BaseSwordItem(Tier material, int attackDamage, float attackSpeed, Properties settings) {
|
||||
super(material, attackDamage, attackSpeed, settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public BlockModel getItemModel(ResourceLocation resourceLocation) {
|
||||
return ModelsHelper.createHandheldItem(resourceLocation);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue