Start migration

This commit is contained in:
Aleksey 2021-04-08 21:55:07 +03:00
parent 6630ce0cab
commit 47ed597358
491 changed files with 12045 additions and 11953 deletions

View file

@ -1,20 +1,20 @@
package ru.betterend.item;
import net.minecraft.advancement.criterion.Criteria;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUsage;
import net.minecraft.item.Items;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.PlayerEntity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.ItemUsage;
import net.minecraft.world.item.Items;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.stat.Stats;
import net.minecraft.util.Hand;
import net.minecraft.util.TypedActionResult;
import net.minecraft.util.UseAction;
import net.minecraft.world.World;
import net.minecraft.world.level.Level;
public class DrinkItem extends PatternedItem {
public DrinkItem(Settings settings) {
public DrinkItem(Properties settings) {
super(settings);
}
@ -29,14 +29,14 @@ public class DrinkItem extends PatternedItem {
}
@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
public TypedActionResult<ItemStack> use(Level world, PlayerEntity user, Hand hand) {
return ItemUsage.consumeHeldItem(world, user, hand);
}
@Override
public ItemStack finishUsing(ItemStack stack, World world, LivingEntity user) {
if (user instanceof ServerPlayerEntity) {
ServerPlayerEntity serverPlayerEntity = (ServerPlayerEntity) user;
public ItemStack finishUsing(ItemStack stack, Level world, LivingEntity user) {
if (user instanceof ServerPlayer) {
ServerPlayer serverPlayerEntity = (ServerPlayer) user;
Criteria.CONSUME_ITEM.trigger(serverPlayerEntity, stack);
serverPlayerEntity.incrementStat(Stats.USED.getOrCreateStat(this));
}
@ -45,7 +45,7 @@ public class DrinkItem extends PatternedItem {
stack.decrement(1);
}
if (!world.isClient) {
if (!world.isClientSide) {
user.clearStatusEffects();
}

View file

@ -1,7 +1,7 @@
package ru.betterend.item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Rarity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Rarity;
import ru.betterend.patterns.Patterns;
import ru.betterend.registry.EndItems;
@ -14,7 +14,7 @@ public class EnchantedPetalItem extends PatternedItem {
public boolean hasGlint(ItemStack stack) {
return true;
}
@Override
public String getModelPattern(String name) {
return Patterns.createJson(Patterns.ITEM_GENERATED, "item/hydralux_petal");

View file

@ -5,26 +5,27 @@ import java.util.UUID;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Multimap;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.attribute.EntityAttribute;
import net.minecraft.entity.attribute.EntityAttributeModifier;
import net.minecraft.entity.attribute.EntityAttributes;
import net.minecraft.item.ArmorItem;
import net.minecraft.item.ArmorMaterial;
import net.minecraft.item.Item;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.attribute.EntityAttribute;
import net.minecraft.world.entity.attribute.EntityAttributeModifier;
import net.minecraft.world.entity.attribute.EntityAttributes;
import net.minecraft.world.item.ArmorItem;
import net.minecraft.world.item.ArmorMaterial;
import net.minecraft.world.item.Item;
import ru.betterend.mixin.common.ArmorItemAccessor;
import ru.betterend.patterns.Patterned;
import ru.betterend.patterns.Patterns;
public class EndArmorItem extends ArmorItem implements Patterned {
public EndArmorItem(ArmorMaterial material, EquipmentSlot slot, Item.Settings settings) {
public EndArmorItem(ArmorMaterial material, EquipmentSlot slot, Item.Properties settings) {
super(material, slot, settings);
addKnockbackResistance((ArmorItemAccessor) this, slot, this.knockbackResistance);
}
/** Ensures knockback resistance is actually applied */
private static void addKnockbackResistance(ArmorItemAccessor accessor, EquipmentSlot slot, double knockbackResistance) {
private static void addKnockbackResistance(ArmorItemAccessor accessor, EquipmentSlot slot,
double knockbackResistance) {
if (knockbackResistance == 0) {
return;
}
@ -41,7 +42,8 @@ public class EndArmorItem extends ArmorItem implements Patterned {
// Rebuild attributeModifiers to include knockback resistance
ImmutableMultimap.Builder<EntityAttribute, EntityAttributeModifier> builder = ImmutableMultimap.builder();
builder.putAll(attributeModifiers);
builder.put(EntityAttributes.GENERIC_KNOCKBACK_RESISTANCE, new EntityAttributeModifier(uuid, "Armor knockback resistance", knockbackResistance, EntityAttributeModifier.Operation.ADDITION));
builder.put(EntityAttributes.GENERIC_KNOCKBACK_RESISTANCE, new EntityAttributeModifier(uuid,
"Armor knockback resistance", knockbackResistance, EntityAttributeModifier.Operation.ADDITION));
accessor.be_setAttributeModifiers(builder.build());
}

View file

@ -1,15 +1,15 @@
package ru.betterend.item;
import net.minecraft.entity.EntityType;
import net.minecraft.item.SpawnEggItem;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.item.SpawnEggItem;
import ru.betterend.patterns.Patterned;
import ru.betterend.patterns.Patterns;
public class EndSpawnEggItem extends SpawnEggItem implements Patterned {
public EndSpawnEggItem(EntityType<?> type, int primaryColor, int secondaryColor, Settings settings) {
public EndSpawnEggItem(EntityType<?> type, int primaryColor, int secondaryColor, Properties settings) {
super(type, primaryColor, secondaryColor, settings);
}
@Override
public String getModelPattern(String name) {
return Patterns.createJson(Patterns.ITEM_SPAWN_EGG, name);

View file

@ -1,6 +1,6 @@
package ru.betterend.item;
import net.minecraft.util.Rarity;
import net.minecraft.world.item.Rarity;
import ru.betterend.registry.EndItems;
public class EternalCrystalItem extends PatternedItem {

View file

@ -3,42 +3,44 @@ package ru.betterend.item;
import java.util.List;
import net.minecraft.client.item.TooltipContext;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.world.entity.player.PlayerEntity;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.util.Hand;
import net.minecraft.util.Identifier;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.TypedActionResult;
import net.minecraft.world.World;
import net.minecraft.world.level.Level;
import ru.betterend.BetterEnd;
import ru.betterend.registry.EndItems;
import ru.betterend.util.LangUtil;
import vazkii.patchouli.api.PatchouliAPI;
public class GuideBookItem extends PatternedItem {
public final static Identifier BOOK_ID = BetterEnd.makeID("guidebook");
public static final Item GUIDE_BOOK = EndItems.registerItem(BOOK_ID, new GuideBookItem());
public static void register() {}
public GuideBookItem() {
super(EndItems.makeItemSettings().maxCount(1));
}
public final static ResourceLocation BOOK_ID = BetterEnd.makeID("guidebook");
public static final Item GUIDE_BOOK = EndItems.registerItem(BOOK_ID, new GuideBookItem());
public static void register() {
}
public GuideBookItem() {
super(EndItems.makeItemSettings().maxCount(1));
}
@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
if (!world.isClient && user instanceof ServerPlayerEntity) {
PatchouliAPI.get().openBookGUI((ServerPlayerEntity) user, BOOK_ID);
public TypedActionResult<ItemStack> use(Level world, PlayerEntity user, Hand hand) {
if (!world.isClientSide && user instanceof ServerPlayer) {
PatchouliAPI.get().openBookGUI((ServerPlayer) user, BOOK_ID);
return TypedActionResult.success(user.getStackInHand(hand));
}
return TypedActionResult.consume(user.getStackInHand(hand));
}
@Override
public void appendTooltip(ItemStack stack, World world, List<Text> tooltip, TooltipContext context) {
tooltip.add(LangUtil.getText("book.betterend", "subtitle").formatted(Formatting.DARK_PURPLE, Formatting.ITALIC));
public void appendTooltip(ItemStack stack, Level world, List<Text> tooltip, TooltipContext context) {
tooltip.add(
LangUtil.getText("book.betterend", "subtitle").formatted(Formatting.DARK_PURPLE, Formatting.ITALIC));
}
}

View file

@ -1,12 +1,12 @@
package ru.betterend.item;
import net.minecraft.item.MusicDiscItem;
import net.minecraft.world.item.MusicDiscItem;
import net.minecraft.sound.SoundEvent;
import ru.betterend.patterns.Patterned;
import ru.betterend.patterns.Patterns;
public class PatternedDiscItem extends MusicDiscItem implements Patterned {
public PatternedDiscItem(int comparatorOutput, SoundEvent sound, Settings settings) {
public PatternedDiscItem(int comparatorOutput, SoundEvent sound, Properties settings) {
super(comparatorOutput, sound, settings);
}

View file

@ -1,14 +1,14 @@
package ru.betterend.item;
import net.minecraft.item.Item;
import net.minecraft.world.item.Item;
import ru.betterend.patterns.Patterned;
import ru.betterend.patterns.Patterns;
public class PatternedItem extends Item implements Patterned {
public PatternedItem(Settings settings) {
public PatternedItem(Properties settings) {
super(settings);
}
@Override
public String getModelPattern(String name) {
return Patterns.createJson(Patterns.ITEM_GENERATED, name);

View file

@ -4,27 +4,26 @@ import java.util.function.Supplier;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.item.ArmorMaterial;
import net.minecraft.recipe.Ingredient;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.item.ArmorMaterial;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.sound.SoundEvent;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.Lazy;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.util.LazyLoadedValue;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndItems;
public enum EndArmorMaterial implements ArmorMaterial {
THALLASIUM("thallasium", 17, new int[] { 1, 4, 5, 2 }, 12, SoundEvents.ITEM_ARMOR_EQUIP_IRON, 0.0F, 0.0F, () -> {
return Ingredient.ofItems(EndBlocks.THALLASIUM.ingot);
}),
TERMINITE("terminite", 26, new int[] { 3, 6, 7, 3 }, 14, SoundEvents.ITEM_ARMOR_EQUIP_IRON, 1.0F, 0.05F, () -> {
return Ingredient.ofItems(EndBlocks.TERMINITE.ingot);
return Ingredient.of(EndBlocks.THALLASIUM.ingot);
}), TERMINITE("terminite", 26, new int[] { 3, 6, 7, 3 }, 14, SoundEvents.ITEM_ARMOR_EQUIP_IRON, 1.0F, 0.05F, () -> {
return Ingredient.of(EndBlocks.TERMINITE.ingot);
}),
AETERNIUM("aeternium", 40, new int[] { 4, 7, 9, 4 }, 18, SoundEvents.ITEM_ARMOR_EQUIP_NETHERITE, 3.5F, 0.2F, () -> {
return Ingredient.ofItems(EndItems.AETERNIUM_INGOT);
return Ingredient.of(EndItems.AETERNIUM_INGOT);
}),
CRYSTALITE("crystalite", 30, new int[] { 3, 6, 8, 3 }, 24, SoundEvents.ITEM_ARMOR_EQUIP_DIAMOND, 1.2F, 0.1F, () -> {
return Ingredient.ofItems(EndBlocks.TERMINITE.ingot);
return Ingredient.of(EndBlocks.TERMINITE.ingot);
});
private static final int[] BASE_DURABILITY = new int[] { 13, 15, 16, 11 };
@ -35,12 +34,11 @@ public enum EndArmorMaterial implements ArmorMaterial {
private final SoundEvent equipSound;
private final float toughness;
private final float knockbackResistance;
private final Lazy<Ingredient> repairIngredient;
private final LazyLoadedValue<Ingredient> repairIngredient;
private EndArmorMaterial(String name, int durabilityMultiplier, int[] protectionAmounts, int enchantability,
SoundEvent equipSound, float toughness, float knockbackResistance,
Supplier<Ingredient> repairIngredient) {
SoundEvent equipSound, float toughness, float knockbackResistance, Supplier<Ingredient> repairIngredient) {
this.name = name;
this.durabilityMultiplier = durabilityMultiplier;
this.protectionAmounts = protectionAmounts;
@ -48,7 +46,7 @@ public enum EndArmorMaterial implements ArmorMaterial {
this.equipSound = equipSound;
this.toughness = toughness;
this.knockbackResistance = knockbackResistance;
this.repairIngredient = new Lazy<>(repairIngredient);
this.repairIngredient = new LazyLoadedValue<>(repairIngredient);
}
@Override

View file

@ -2,21 +2,19 @@ package ru.betterend.item.material;
import java.util.function.Supplier;
import net.minecraft.item.ToolMaterial;
import net.minecraft.recipe.Ingredient;
import net.minecraft.util.Lazy;
import net.minecraft.util.LazyLoadedValue;
import net.minecraft.world.item.Tier;
import net.minecraft.world.item.crafting.Ingredient;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndItems;
public enum EndToolMaterial implements ToolMaterial {
public enum EndToolMaterial implements Tier {
THALLASIUM(2, 320, 7.0F, 1.5F, 12, () -> {
return Ingredient.ofItems(EndBlocks.THALLASIUM.ingot);
}),
TERMINITE(3, 1230, 8.5F, 3.0F, 14, () -> {
return Ingredient.ofItems(EndBlocks.TERMINITE.ingot);
}),
AETERNIUM(5, 2196, 10.0F, 4.5F, 18, () -> {
return Ingredient.ofItems(EndItems.AETERNIUM_INGOT);
return Ingredient.of(EndBlocks.THALLASIUM.ingot);
}), TERMINITE(3, 1230, 8.5F, 3.0F, 14, () -> {
return Ingredient.of(EndBlocks.TERMINITE.ingot);
}), AETERNIUM(5, 2196, 10.0F, 4.5F, 18, () -> {
return Ingredient.of(EndItems.AETERNIUM_INGOT);
});
private final int durability;
@ -24,8 +22,8 @@ public enum EndToolMaterial implements ToolMaterial {
private final float attackDamage;
private final int miningLevel;
private final int enchantability;
private final Lazy<Ingredient> repairIngredient;
private final LazyLoadedValue<Ingredient> repairIngredient;
private EndToolMaterial(int miningLevel, int durability, float miningSpeed, float attackDamage, int enchantability,
Supplier<Ingredient> repairIngredient) {
@ -34,32 +32,32 @@ public enum EndToolMaterial implements ToolMaterial {
this.attackDamage = attackDamage;
this.miningLevel = miningLevel;
this.enchantability = enchantability;
this.repairIngredient = new Lazy<>(repairIngredient);
this.repairIngredient = new LazyLoadedValue<>(repairIngredient);
}
@Override
public int getDurability() {
return this.durability;
public int getUses() {
return durability;
}
@Override
public float getMiningSpeedMultiplier() {
return this.miningSpeed;
public float getSpeed() {
return miningSpeed;
}
@Override
public float getAttackDamage() {
return this.attackDamage;
public float getAttackDamageBonus() {
return attackDamage;
}
@Override
public int getMiningLevel() {
return this.miningLevel;
public int getLevel() {
return miningLevel;
}
@Override
public int getEnchantability() {
return this.enchantability;
public int getEnchantmentValue() {
return enchantability;
}
@Override

View file

@ -11,69 +11,73 @@ import net.fabricmc.fabric.api.client.rendering.v1.ArmorRenderingRegistry.ModelP
import net.fabricmc.fabric.api.client.rendering.v1.ArmorRenderingRegistry.TextureProvider;
import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.client.render.entity.model.BipedEntityModel;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.resources.ResourceLocation;
import ru.betterend.registry.EndItems;
@Environment(EnvType.CLIENT)
public class CrystaliteArmorProvider implements ModelProvider, TextureProvider {
private final static Identifier FIRST_LAYER = new Identifier("textures/models/armor/crystalite_layer_1.png");
private final static Identifier SECOND_LAYER = new Identifier("textures/models/armor/crystalite_layer_2.png");
private final static ResourceLocation FIRST_LAYER = new ResourceLocation(
"textures/models/armor/crystalite_layer_1.png");
private final static ResourceLocation SECOND_LAYER = new ResourceLocation(
"textures/models/armor/crystalite_layer_2.png");
private final static CrystaliteHelmetModel HELMET_MODEL = new CrystaliteHelmetModel(1.0F);
private final static CrystaliteChestplateModel CHEST_MODEL = new CrystaliteChestplateModel(1.0F, false);
private final static CrystaliteChestplateModel CHEST_MODEL_SLIM = new CrystaliteChestplateModel(1.0F, true);
private final static CrystaliteLeggingsModel LEGGINGS_MODEL = new CrystaliteLeggingsModel(1.0F);
private final static CrystaliteBootsModel BOOTS_MODEL = new CrystaliteBootsModel(1.0F);
@Override
public @NotNull Identifier getArmorTexture(LivingEntity entity, ItemStack stack, EquipmentSlot slot,
boolean secondLayer, @Nullable String suffix, Identifier defaultTexture) {
if (!isStackValid(stack)) return defaultTexture;
if (secondLayer) return SECOND_LAYER;
public @NotNull ResourceLocation getArmorTexture(LivingEntity entity, ItemStack stack, EquipmentSlot slot,
boolean secondLayer, @Nullable String suffix, ResourceLocation defaultTexture) {
if (!isStackValid(stack))
return defaultTexture;
if (secondLayer)
return SECOND_LAYER;
return FIRST_LAYER;
}
@Override
public @NotNull BipedEntityModel<LivingEntity> getArmorModel(LivingEntity entity, ItemStack stack,
EquipmentSlot slot, BipedEntityModel<LivingEntity> defaultModel) {
if (!isStackValid(stack)) return defaultModel;
switch(slot) {
case HEAD: {
return HELMET_MODEL;
}
case CHEST: {
if (entity instanceof AbstractClientPlayerEntity &&
((AbstractClientPlayerEntity) entity).getModel().equals("slim")) {
CHEST_MODEL_SLIM.setAttributes(defaultModel);
return CHEST_MODEL_SLIM;
}
CHEST_MODEL.setAttributes(defaultModel);
return CHEST_MODEL;
}
case LEGS: {
return LEGGINGS_MODEL;
}
case FEET: {
BOOTS_MODEL.setAttributes(defaultModel);
return BOOTS_MODEL;
}
default: {
return defaultModel;
if (!isStackValid(stack))
return defaultModel;
switch (slot) {
case HEAD: {
return HELMET_MODEL;
}
case CHEST: {
if (entity instanceof AbstractClientPlayerEntity
&& ((AbstractClientPlayerEntity) entity).getModel().equals("slim")) {
CHEST_MODEL_SLIM.setAttributes(defaultModel);
return CHEST_MODEL_SLIM;
}
CHEST_MODEL.setAttributes(defaultModel);
return CHEST_MODEL;
}
case LEGS: {
return LEGGINGS_MODEL;
}
case FEET: {
BOOTS_MODEL.setAttributes(defaultModel);
return BOOTS_MODEL;
}
default: {
return defaultModel;
}
}
}
public Iterable<Item> getRenderedItems() {
return Lists.newArrayList(EndItems.CRYSTALITE_HELMET, EndItems.CRYSTALITE_CHESTPLATE, EndItems.CRYSTALITE_LEGGINGS, EndItems.CRYSTALITE_BOOTS);
return Lists.newArrayList(EndItems.CRYSTALITE_HELMET, EndItems.CRYSTALITE_CHESTPLATE,
EndItems.CRYSTALITE_LEGGINGS, EndItems.CRYSTALITE_BOOTS);
}
private boolean isStackValid(ItemStack stack) {
return stack.getItem() == EndItems.CRYSTALITE_HELMET ||
stack.getItem() == EndItems.CRYSTALITE_CHESTPLATE ||
stack.getItem() == EndItems.CRYSTALITE_LEGGINGS ||
stack.getItem() == EndItems.CRYSTALITE_BOOTS;
return stack.getItem() == EndItems.CRYSTALITE_HELMET || stack.getItem() == EndItems.CRYSTALITE_CHESTPLATE
|| stack.getItem() == EndItems.CRYSTALITE_LEGGINGS || stack.getItem() == EndItems.CRYSTALITE_BOOTS;
}
}

View file

@ -7,13 +7,13 @@ import com.google.common.collect.Lists;
import net.minecraft.client.model.ModelPart;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.entity.model.BipedEntityModel;
import net.minecraft.entity.LivingEntity;
import net.minecraft.world.entity.LivingEntity;
public class CrystaliteBootsModel extends BipedEntityModel<LivingEntity> {
public ModelPart leftBoot;
public ModelPart rightBoot;
public CrystaliteBootsModel(float scale) {
super(RenderLayer::getEntityTranslucent, scale, 0.0F, 64, 48);
this.leftBoot = new ModelPart(this, 0, 32);
@ -23,7 +23,7 @@ public class CrystaliteBootsModel extends BipedEntityModel<LivingEntity> {
this.rightBoot.addCuboid(-2.0F, 0.0F, -2.0F, 4.0F, 12.0F, 4.0F, scale + 0.25F);
this.rightBoot.setPivot(-1.9F, 12.0F, 0.0F);
}
@Override
public void setAttributes(BipedEntityModel<LivingEntity> bipedEntityModel) {
super.setAttributes(bipedEntityModel);
@ -35,7 +35,7 @@ public class CrystaliteBootsModel extends BipedEntityModel<LivingEntity> {
protected Iterable<ModelPart> getHeadParts() {
return Collections::emptyIterator;
}
@Override
protected Iterable<ModelPart> getBodyParts() {
return Lists.newArrayList(leftBoot, rightBoot);

View file

@ -8,7 +8,7 @@ import net.minecraft.client.model.ModelPart;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.entity.model.BipedEntityModel;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.LivingEntity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.util.Arm;
public class CrystaliteChestplateModel extends BipedEntityModel<LivingEntity> {
@ -16,7 +16,7 @@ public class CrystaliteChestplateModel extends BipedEntityModel<LivingEntity> {
public ModelPart leftShoulder;
public ModelPart rightShoulder;
private boolean thinArms;
public CrystaliteChestplateModel(float scale, boolean thinArms) {
super(RenderLayer::getEntityTranslucent, scale, 0.0F, 64, 48);
this.thinArms = thinArms;
@ -41,29 +41,29 @@ public class CrystaliteChestplateModel extends BipedEntityModel<LivingEntity> {
this.rightShoulder.setPivot(-5.0F, 2.0F, 10.0F);
}
}
@Override
public void setAttributes(BipedEntityModel<LivingEntity> bipedEntityModel) {
super.setAttributes(bipedEntityModel);
this.leftShoulder.copyPositionAndRotation(leftArm);
this.rightShoulder.copyPositionAndRotation(rightArm);
}
@Override
protected Iterable<ModelPart> getHeadParts() {
return Collections::emptyIterator;
}
@Override
protected Iterable<ModelPart> getBodyParts() {
return Lists.newArrayList(torso, leftShoulder, rightShoulder);
}
@Override
public void setArmAngle(Arm arm, MatrixStack matrices) {
ModelPart modelPart = this.getArm(arm);
if (this.thinArms) {
float f = 0.5F * (float)(arm == Arm.RIGHT ? 1 : -1);
float f = 0.5F * (float) (arm == Arm.RIGHT ? 1 : -1);
modelPart.pivotX += f;
modelPart.rotate(matrices);
modelPart.pivotX -= f;

View file

@ -9,7 +9,7 @@ import net.fabricmc.api.Environment;
import net.minecraft.client.model.ModelPart;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.entity.model.BipedEntityModel;
import net.minecraft.entity.LivingEntity;
import net.minecraft.world.entity.LivingEntity;
@Environment(EnvType.CLIENT)
public class CrystaliteHelmetModel extends BipedEntityModel<LivingEntity> {
@ -20,12 +20,12 @@ public class CrystaliteHelmetModel extends BipedEntityModel<LivingEntity> {
this.helmet.addCuboid(-4.0F, -8.0F, -4.0F, 8.0F, 8.0F, 8.0F, scale + 0.5F);
this.helmet.setPivot(0.0F, 0.0F, 0.0F);
}
@Override
protected Iterable<ModelPart> getHeadParts() {
return Collections::emptyIterator;
}
@Override
protected Iterable<ModelPart> getBodyParts() {
return Lists.newArrayList(helmet);

View file

@ -7,7 +7,7 @@ import com.google.common.collect.Lists;
import net.minecraft.client.model.ModelPart;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.entity.model.BipedEntityModel;
import net.minecraft.entity.LivingEntity;
import net.minecraft.world.entity.LivingEntity;
public class CrystaliteLeggingsModel extends BipedEntityModel<LivingEntity> {
@ -28,7 +28,7 @@ public class CrystaliteLeggingsModel extends BipedEntityModel<LivingEntity> {
protected Iterable<ModelPart> getHeadParts() {
return Collections::emptyIterator;
}
@Override
protected Iterable<ModelPart> getBodyParts() {
return Lists.newArrayList(torso, rightLeg, leftLeg);

View file

@ -2,29 +2,29 @@ package ru.betterend.item.tool;
import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.block.BlockState;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.AxeItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ToolMaterial;
import net.minecraft.tag.Tag;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.AxeItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Tier;
import net.minecraft.tags.Tag;
import ru.betterend.patterns.Patterned;
import ru.betterend.patterns.Patterns;
public class EndAxeItem extends AxeItem implements DynamicAttributeTool, Patterned {
public EndAxeItem(ToolMaterial material, float attackDamage, float attackSpeed, Settings settings) {
public EndAxeItem(Tier material, float attackDamage, float attackSpeed, Properties settings) {
super(material, attackDamage, attackSpeed, settings);
}
@Override
public int getMiningLevel(Tag<Item> tag, BlockState state, ItemStack stack, LivingEntity user) {
if (tag.equals(FabricToolTags.AXES)) {
return this.getMaterial().getMiningLevel();
return this.getTier().getLevel();
}
return 0;
}
@Override
public String getModelPattern(String name) {
return Patterns.createJson(Patterns.ITEM_HANDHELD, name);

View file

@ -9,50 +9,51 @@ import com.google.common.collect.Sets;
import io.netty.util.internal.ThreadLocalRandom;
import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.Material;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.attribute.EntityAttribute;
import net.minecraft.entity.attribute.EntityAttributeModifier;
import net.minecraft.entity.attribute.EntityAttributes;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.MiningToolItem;
import net.minecraft.item.ToolMaterial;
import net.minecraft.tag.Tag;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.attribute.EntityAttribute;
import net.minecraft.world.entity.attribute.EntityAttributeModifier;
import net.minecraft.world.entity.attribute.EntityAttributes;
import net.minecraft.world.entity.player.PlayerEntity;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.MiningToolItem;
import net.minecraft.world.item.Tier;
import net.minecraft.tags.Tag;
import net.minecraft.core.BlockPos;
import net.minecraft.util.Mth;
import net.minecraft.world.level.Level;
import ru.betterend.patterns.Patterned;
import ru.betterend.patterns.Patterns;
import ru.betterend.registry.EndTags;
public class EndHammerItem extends MiningToolItem implements DynamicAttributeTool, Patterned {
public final static UUID ATTACK_KNOCKBACK_MODIFIER_ID = MathHelper.randomUuid(ThreadLocalRandom.current());
public final static UUID ATTACK_KNOCKBACK_MODIFIER_ID = Mth.randomUuid(ThreadLocalRandom.current());
private final Multimap<EntityAttribute, EntityAttributeModifier> attributeModifiers;
public EndHammerItem(ToolMaterial material, float attackDamage, float attackSpeed, double knockback, Settings settings) {
public EndHammerItem(Tier material, float attackDamage, float attackSpeed, double knockback, Properties settings) {
super(attackDamage, attackSpeed, material, Sets.newHashSet(), settings);
Builder<EntityAttribute, EntityAttributeModifier> builder = ImmutableMultimap.builder();
builder.put(EntityAttributes.GENERIC_ATTACK_DAMAGE, new EntityAttributeModifier(ATTACK_DAMAGE_MODIFIER_ID, "Weapon modifier", attackDamage + material.getAttackDamage(), EntityAttributeModifier.Operation.ADDITION));
builder.put(EntityAttributes.GENERIC_ATTACK_SPEED, new EntityAttributeModifier(ATTACK_SPEED_MODIFIER_ID, "Weapon modifier", attackSpeed, EntityAttributeModifier.Operation.ADDITION));
builder.put(EntityAttributes.GENERIC_ATTACK_KNOCKBACK, new EntityAttributeModifier(ATTACK_KNOCKBACK_MODIFIER_ID, "Weapon modifier", knockback, EntityAttributeModifier.Operation.ADDITION));
builder.put(EntityAttributes.GENERIC_ATTACK_DAMAGE,
new EntityAttributeModifier(ATTACK_DAMAGE_MODIFIER_ID, "Weapon modifier",
attackDamage + material.getAttackDamage(), EntityAttributeModifier.Operation.ADDITION));
builder.put(EntityAttributes.GENERIC_ATTACK_SPEED, new EntityAttributeModifier(ATTACK_SPEED_MODIFIER_ID,
"Weapon modifier", attackSpeed, EntityAttributeModifier.Operation.ADDITION));
builder.put(EntityAttributes.GENERIC_ATTACK_KNOCKBACK, new EntityAttributeModifier(ATTACK_KNOCKBACK_MODIFIER_ID,
"Weapon modifier", knockback, EntityAttributeModifier.Operation.ADDITION));
this.attributeModifiers = builder.build();
}
@Override
public boolean canMine(BlockState state, World world, BlockPos pos, PlayerEntity miner) {
return state.getMaterial().equals(Material.STONE) ||
state.getMaterial().equals(Material.GLASS) ||
state.isOf(Blocks.DIAMOND_BLOCK) ||
state.isOf(Blocks.EMERALD_BLOCK) ||
state.isOf(Blocks.LAPIS_BLOCK) ||
state.isOf(Blocks.REDSTONE_BLOCK);
public boolean canMine(BlockState state, Level world, BlockPos pos, PlayerEntity miner) {
return state.getMaterial().equals(Material.STONE) || state.getMaterial().equals(Material.GLASS)
|| state.is(Blocks.DIAMOND_BLOCK) || state.is(Blocks.EMERALD_BLOCK) || state.is(Blocks.LAPIS_BLOCK)
|| state.is(Blocks.REDSTONE_BLOCK);
}
@Override
@ -60,12 +61,12 @@ public class EndHammerItem extends MiningToolItem implements DynamicAttributeToo
stack.damage(1, attacker, ((entity) -> {
entity.sendEquipmentBreakStatus(EquipmentSlot.MAINHAND);
}));
return true;
}
@Override
public boolean postMine(ItemStack stack, World world, BlockState state, BlockPos pos, LivingEntity miner) {
public boolean postMine(ItemStack stack, Level world, BlockState state, BlockPos pos, LivingEntity miner) {
if (state.getHardness(world, pos) != 0.0F) {
stack.damage(1, miner, ((entity) -> {
entity.sendEquipmentBreakStatus(EquipmentSlot.MAINHAND);
@ -76,54 +77,58 @@ public class EndHammerItem extends MiningToolItem implements DynamicAttributeToo
}
@Override
public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) {
public float getDestroySpeed(ItemStack stack, BlockState state) {
if (state.getMaterial().equals(Material.GLASS)) {
return this.getMaterial().getMiningSpeedMultiplier() * 2.0F;
return this.getMaterial().getDestroySpeed() * 2.0F;
}
if (isEffectiveOn(state)) {
if (isCorrectToolForDrops(state)) {
float mult = 1.0F;
if (state.isOf(Blocks.DIAMOND_BLOCK) || state.isOf(Blocks.EMERALD_BLOCK) || state.isOf(Blocks.LAPIS_BLOCK) || state.isOf(Blocks.REDSTONE_BLOCK)) {
mult = this.getMaterial().getMiningSpeedMultiplier();
if (state.is(Blocks.DIAMOND_BLOCK) || state.is(Blocks.EMERALD_BLOCK) || state.is(Blocks.LAPIS_BLOCK)
|| state.is(Blocks.REDSTONE_BLOCK)) {
mult = this.getMaterial().getDestroySpeed();
} else {
mult = this.getMaterial().getMiningSpeedMultiplier() / 2.0F;
mult = this.getMaterial().getDestroySpeed() / 2.0F;
}
return mult > 1.0F ? mult : 1.0F;
}
return 1.0F;
}
@Override
public float getMiningSpeedMultiplier(Tag<Item> tag, BlockState state, ItemStack stack, LivingEntity user) {
public float getDestroySpeed(Tag<Item> tag, BlockState state, ItemStack stack, LivingEntity user) {
if (tag.equals(EndTags.HAMMERS)) {
return this.getMiningSpeedMultiplier(stack, state);
return this.getDestroySpeed(stack, state);
}
return 1.0F;
}
@Override
public int getMiningLevel(Tag<Item> tag, BlockState state, ItemStack stack, LivingEntity user) {
if (tag.equals(EndTags.HAMMERS)) {
return this.getMaterial().getMiningLevel();
return this.getTier().getLevel();
}
return 0;
}
@Override
public boolean isEffectiveOn(BlockState state) {
public boolean isCorrectToolForDrops(BlockState state) {
if (state.getMaterial().equals(Material.GLASS)) {
return true;
}
if (!state.isOf(Blocks.REDSTONE_BLOCK) && !state.isOf(Blocks.DIAMOND_BLOCK) && !state.isOf(Blocks.EMERALD_BLOCK) && !state.isOf(Blocks.LAPIS_BLOCK) && !state.getMaterial().equals(Material.STONE)) {
if (!state.is(Blocks.REDSTONE_BLOCK) && !state.is(Blocks.DIAMOND_BLOCK) && !state.is(Blocks.EMERALD_BLOCK)
&& !state.is(Blocks.LAPIS_BLOCK) && !state.getMaterial().equals(Material.STONE)) {
return false;
}
int level = this.getMaterial().getMiningLevel();
if (state.isOf(Blocks.IRON_ORE) || state.isOf(Blocks.LAPIS_BLOCK) || state.isOf(Blocks.LAPIS_ORE)) {
int level = this.getTier().getLevel();
if (state.is(Blocks.IRON_ORE) || state.is(Blocks.LAPIS_BLOCK) || state.is(Blocks.LAPIS_ORE)) {
return level >= 1;
}
if (state.isOf(Blocks.DIAMOND_BLOCK) && !state.isOf(Blocks.DIAMOND_ORE) || state.isOf(Blocks.EMERALD_ORE) || state.isOf(Blocks.EMERALD_BLOCK) || state.isOf(Blocks.GOLD_ORE) || state.isOf(Blocks.REDSTONE_ORE)) {
if (state.is(Blocks.DIAMOND_BLOCK) && !state.is(Blocks.DIAMOND_ORE) || state.is(Blocks.EMERALD_ORE)
|| state.is(Blocks.EMERALD_BLOCK) || state.is(Blocks.GOLD_ORE) || state.is(Blocks.REDSTONE_ORE)) {
return level >= 2;
}
if (state.isOf(Blocks.OBSIDIAN) || state.isOf(Blocks.CRYING_OBSIDIAN) || state.isOf(Blocks.RESPAWN_ANCHOR) || state.isOf(Blocks.ANCIENT_DEBRIS)) {
if (state.is(Blocks.OBSIDIAN) || state.is(Blocks.CRYING_OBSIDIAN) || state.is(Blocks.RESPAWN_ANCHOR)
|| state.is(Blocks.ANCIENT_DEBRIS)) {
return level >= 3;
}
return true;
@ -133,7 +138,7 @@ public class EndHammerItem extends MiningToolItem implements DynamicAttributeToo
public Multimap<EntityAttribute, EntityAttributeModifier> getAttributeModifiers(EquipmentSlot slot) {
return slot == EquipmentSlot.MAINHAND ? this.attributeModifiers : super.getAttributeModifiers(slot);
}
@Override
public String getModelPattern(String name) {
return Patterns.createJson(Patterns.ITEM_HANDHELD, name);

View file

@ -1,15 +1,15 @@
package ru.betterend.item.tool;
import net.minecraft.item.HoeItem;
import net.minecraft.item.ToolMaterial;
import net.minecraft.world.item.HoeItem;
import net.minecraft.world.item.Tier;
import ru.betterend.patterns.Patterned;
import ru.betterend.patterns.Patterns;
public class EndHoeItem extends HoeItem implements Patterned {
public EndHoeItem(ToolMaterial material, int attackDamage, float attackSpeed, Settings settings) {
public EndHoeItem(Tier material, int attackDamage, float attackSpeed, Properties settings) {
super(material, attackDamage, attackSpeed, settings);
}
@Override
public String getModelPattern(String name) {
return Patterns.createJson(Patterns.ITEM_HANDHELD, name);

View file

@ -4,39 +4,41 @@ import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.fabricmc.fabric.impl.tool.attribute.ToolManagerImpl;
import net.fabricmc.fabric.impl.tool.attribute.ToolManagerImpl.Entry;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.PickaxeItem;
import net.minecraft.item.ToolMaterial;
import net.minecraft.tag.Tag;
import net.minecraft.tags.Tag;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.PickaxeItem;
import net.minecraft.world.item.Tier;
import ru.betterend.patterns.Patterned;
import ru.betterend.patterns.Patterns;
public class EndPickaxeItem extends PickaxeItem implements DynamicAttributeTool, Patterned {
public EndPickaxeItem(ToolMaterial material, int attackDamage, float attackSpeed, Settings settings) {
public EndPickaxeItem(Tier material, int attackDamage, float attackSpeed, Properties settings) {
super(material, attackDamage, attackSpeed, settings);
}
@Override
public int getMiningLevel(Tag<Item> tag, BlockState state, ItemStack stack, LivingEntity user) {
if (tag.equals(FabricToolTags.PICKAXES)) {
return this.getMaterial().getMiningLevel();
return this.getTier().getLevel();
}
return 0;
}
@Override
public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) {
if (this.getMaterial().getMiningLevel() > 2 && state.getMaterial().equals(Blocks.END_STONE.getDefaultState().getMaterial())) {
return this.miningSpeed * 3;
public float getDestroySpeed(ItemStack stack, BlockState state) {
if (this.getTier().getLevel() > 2
&& state.getMaterial().equals(Blocks.END_STONE.defaultBlockState().getMaterial())) {
return this.speed * 3;
}
Entry entry = ToolManagerImpl.entryNullable(state.getBlock());
return (entry != null && entry.getMiningLevel(FabricToolTags.PICKAXES) >= 0) ? this.miningSpeed : super.getMiningSpeedMultiplier(stack, state);
return (entry != null && entry.getMiningLevel(FabricToolTags.PICKAXES) >= 0) ? speed
: super.getDestroySpeed(stack, state);
}
@Override
public String getModelPattern(String name) {
return Patterns.createJson(Patterns.ITEM_HANDHELD, name);

View file

@ -4,35 +4,36 @@ import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.fabricmc.fabric.impl.tool.attribute.ToolManagerImpl;
import net.fabricmc.fabric.impl.tool.attribute.ToolManagerImpl.Entry;
import net.minecraft.block.BlockState;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ShovelItem;
import net.minecraft.item.ToolMaterial;
import net.minecraft.tag.Tag;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.ShovelItem;
import net.minecraft.world.item.Tier;
import net.minecraft.tags.Tag;
import ru.betterend.patterns.Patterned;
import ru.betterend.patterns.Patterns;
public class EndShovelItem extends ShovelItem implements DynamicAttributeTool, Patterned {
public EndShovelItem(ToolMaterial material, float attackDamage, float attackSpeed, Settings settings) {
public EndShovelItem(Tier material, float attackDamage, float attackSpeed, Properties settings) {
super(material, attackDamage, attackSpeed, settings);
}
@Override
public int getMiningLevel(Tag<Item> tag, BlockState state, ItemStack stack, LivingEntity user) {
if (tag.equals(FabricToolTags.SHOVELS)) {
return this.getMaterial().getMiningLevel();
return this.getTier().getLevel();
}
return 0;
}
@Override
public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) {
public float getDestroySpeed(ItemStack stack, BlockState state) {
Entry entry = ToolManagerImpl.entryNullable(state.getBlock());
return (entry != null && entry.getMiningLevel(FabricToolTags.SHOVELS) >= 0) ? this.miningSpeed : super.getMiningSpeedMultiplier(stack, state);
return (entry != null && entry.getMiningLevel(FabricToolTags.SHOVELS) >= 0) ? speed
: super.getDestroySpeed(stack, state);
}
@Override
public String getModelPattern(String name) {
return Patterns.createJson(Patterns.ITEM_HANDHELD, name);

View file

@ -1,16 +1,16 @@
package ru.betterend.item.tool;
import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool;
import net.minecraft.item.SwordItem;
import net.minecraft.item.ToolMaterial;
import net.minecraft.world.item.SwordItem;
import net.minecraft.world.item.Tier;
import ru.betterend.patterns.Patterned;
import ru.betterend.patterns.Patterns;
public class EndSwordItem extends SwordItem implements DynamicAttributeTool, Patterned {
public EndSwordItem(ToolMaterial material, int attackDamage, float attackSpeed, Settings settings) {
public EndSwordItem(Tier material, int attackDamage, float attackSpeed, Properties settings) {
super(material, attackDamage, attackSpeed, settings);
}
@Override
public String getModelPattern(String name) {
return Patterns.createJson(Patterns.ITEM_HANDHELD, name);