Continue mapping migration

This commit is contained in:
Aleksey 2021-04-12 21:38:22 +03:00
parent 99ade39404
commit f03fd03bd0
499 changed files with 12567 additions and 12723 deletions

View file

@ -1,16 +1,16 @@
package ru.betterend.item;
import net.minecraft.advancement.criterion.Criteria;
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.ItemUsage;
import net.minecraft.world.item.ItemUtils;
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.item.UseAnim;
import net.minecraft.world.level.Level;
public class DrinkItem extends PatternedItem {
@ -19,34 +19,34 @@ public class DrinkItem extends PatternedItem {
}
@Override
public int getMaxUseTime(ItemStack stack) {
public int getUseDuration(ItemStack stack) {
return 32;
}
@Override
public UseAction getUseAction(ItemStack stack) {
return UseAction.DRINK;
public UseAnim getUseAnimation(ItemStack stack) {
return UseAnim.DRINK;
}
@Override
public TypedActionResult<ItemStack> use(Level world, Player user, Hand hand) {
return ItemUsage.consumeHeldItem(world, user, hand);
public InteractionResultHolder<ItemStack> use(Level world, Player user, InteractionHand hand) {
return ItemUtils.useDrink(world, user, hand);
}
@Override
public ItemStack finishUsing(ItemStack stack, Level world, LivingEntity user) {
public ItemStack finishUsingItem(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));
CriteriaTriggers.CONSUME_ITEM.trigger(serverPlayerEntity, stack);
serverPlayerEntity.awardStat(Stats.ITEM_USED.get(this));
}
if (user instanceof Player && !((Player) user).abilities.creativeMode) {
stack.decrement(1);
if (user instanceof Player && !((Player) user).abilities.instabuild) {
stack.shrink(1);
}
if (!world.isClientSide) {
user.clearMobEffects();
user.removeAllEffects();
}
return stack.isEmpty() ? new ItemStack(Items.GLASS_BOTTLE) : stack;

View file

@ -11,10 +11,10 @@ public class EnchantedPetalItem extends PatternedItem {
}
@Override
public boolean hasGlint(ItemStack stack) {
public boolean isFoil(ItemStack stack) {
return true;
}
@Override
public String getModelPattern(String name) {
return Patterns.createJson(Patterns.ITEM_GENERATED, "item/hydralux_petal");

View file

@ -1,17 +1,15 @@
package ru.betterend.item;
import java.util.UUID;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Multimap;
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.attribute.Attributes;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.item.ArmorItem;
import net.minecraft.world.item.ArmorMaterial;
import net.minecraft.world.item.Item;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Multimap;
import ru.betterend.mixin.common.ArmorItemAccessor;
import ru.betterend.patterns.Patterned;
import ru.betterend.patterns.Patterns;
@ -24,8 +22,7 @@ public class EndArmorItem extends ArmorItem implements Patterned {
}
/** 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;
}
@ -37,13 +34,12 @@ public class EndArmorItem extends ArmorItem implements Patterned {
return;
}
UUID uuid = accessor.be_getModifiers()[slot.getEntitySlotId()];
UUID uuid = accessor.be_getModifiers()[slot.getIndex()];
// Rebuild attributeModifiers to include knockback resistance
ImmutableMultimap.Builder<Attribute, AttributeModifier> builder = ImmutableMultimap.builder();
builder.putAll(attributeModifiers);
builder.put(Attributes.KNOCKBACK_RESISTANCE, new AttributeModifier(uuid, "Armor knockback resistance",
knockbackResistance, AttributeModifier.Operation.ADDITION));
builder.put(Attributes.KNOCKBACK_RESISTANCE, new AttributeModifier(uuid, "Armor knockback resistance", knockbackResistance, AttributeModifier.Operation.ADDITION));
accessor.be_setAttributeModifiers(builder.build());
}

View file

@ -9,7 +9,7 @@ public class EndSpawnEggItem extends SpawnEggItem implements Patterned {
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,17 +1,16 @@
package ru.betterend.item;
import java.util.List;
import net.minecraft.client.item.TooltipContext;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.entity.player.Player;
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.resources.ResourceLocation;
import net.minecraft.util.TypedActionResult;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.Level;
import ru.betterend.BetterEnd;
import ru.betterend.registry.EndItems;
@ -19,28 +18,26 @@ import ru.betterend.util.LangUtil;
import vazkii.patchouli.api.PatchouliAPI;
public class GuideBookItem extends PatternedItem {
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().stacksTo(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().stacksTo(1));
}
@Override
public TypedActionResult<ItemStack> use(Level world, Player user, Hand hand) {
if (!world.isClientSide && user instanceof ServerPlayer) {
public InteractionResultHolder<ItemStack> use(Level world, Player user, InteractionHand hand) {
if (!world.isClientSide && user instanceof ServerPlayer) {
PatchouliAPI.get().openBookGUI((ServerPlayer) user, BOOK_ID);
return TypedActionResult.success(user.getStackInHand(hand));
return InteractionResultHolder.success(user.getItemInHand(hand));
}
return TypedActionResult.consume(user.getStackInHand(hand));
return InteractionResultHolder.consume(user.getItemInHand(hand));
}
@Override
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));
public void appendHoverText(ItemStack stack, Level world, List<Component> tooltip, TooltipFlag context) {
tooltip.add(LangUtil.getText("book.betterend", "subtitle").withStyle(ChatFormatting.DARK_PURPLE, ChatFormatting.ITALIC));
}
}

View file

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

View file

@ -8,7 +8,7 @@ public class PatternedItem extends Item implements Patterned {
public PatternedItem(Properties settings) {
super(settings);
}
@Override
public String getModelPattern(String name) {
return Patterns.createJson(Patterns.ITEM_GENERATED, name);

View file

@ -4,25 +4,26 @@ import java.util.function.Supplier;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.item.ArmorMaterial;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.util.LazyLoadedValue;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.item.ArmorMaterial;
import net.minecraft.world.item.crafting.Ingredient;
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, () -> {
THALLASIUM("thallasium", 17, new int[] { 1, 4, 5, 2 }, 12, SoundEvents.ARMOR_EQUIP_IRON, 0.0F, 0.0F, () -> {
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, () -> {
}),
TERMINITE("terminite", 26, new int[] { 3, 6, 7, 3 }, 14, SoundEvents.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, () -> {
AETERNIUM("aeternium", 40, new int[] { 4, 7, 9, 4 }, 18, SoundEvents.ARMOR_EQUIP_NETHERITE, 3.5F, 0.2F, () -> {
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, () -> {
CRYSTALITE("crystalite", 30, new int[] { 3, 6, 8, 3 }, 24, SoundEvents.ARMOR_EQUIP_DIAMOND, 1.2F, 0.1F, () -> {
return Ingredient.of(EndBlocks.TERMINITE.ingot);
});
@ -35,10 +36,11 @@ public enum EndArmorMaterial implements ArmorMaterial {
private final float toughness;
private final float knockbackResistance;
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;
@ -50,17 +52,17 @@ public enum EndArmorMaterial implements ArmorMaterial {
}
@Override
public int getDurability(EquipmentSlot slot) {
return BASE_DURABILITY[slot.getEntitySlotId()] * this.durabilityMultiplier;
public int getDurabilityForSlot(EquipmentSlot slot) {
return BASE_DURABILITY[slot.getIndex()] * this.durabilityMultiplier;
}
@Override
public int getProtectionAmount(EquipmentSlot slot) {
return this.protectionAmounts[slot.getEntitySlotId()];
public int getDefenseForSlot(EquipmentSlot slot) {
return this.protectionAmounts[slot.getIndex()];
}
@Override
public int getEnchantability() {
public int getEnchantmentValue() {
return this.enchantability;
}

View file

@ -1,7 +1,6 @@
package ru.betterend.item.material;
import java.util.function.Supplier;
import net.minecraft.util.LazyLoadedValue;
import net.minecraft.world.item.Tier;
import net.minecraft.world.item.crafting.Ingredient;
@ -11,9 +10,11 @@ import ru.betterend.registry.EndItems;
public enum EndToolMaterial implements Tier {
THALLASIUM(2, 320, 7.0F, 1.5F, 12, () -> {
return Ingredient.of(EndBlocks.THALLASIUM.ingot);
}), TERMINITE(3, 1230, 8.5F, 3.0F, 14, () -> {
}),
TERMINITE(3, 1230, 8.5F, 3.0F, 14, () -> {
return Ingredient.of(EndBlocks.TERMINITE.ingot);
}), AETERNIUM(5, 2196, 10.0F, 4.5F, 18, () -> {
}),
AETERNIUM(5, 2196, 10.0F, 4.5F, 18, () -> {
return Ingredient.of(EndItems.AETERNIUM_INGOT);
});
@ -23,7 +24,7 @@ public enum EndToolMaterial implements Tier {
private final int miningLevel;
private final int enchantability;
private final LazyLoadedValue<Ingredient> repairIngredient;
private EndToolMaterial(int miningLevel, int durability, float miningSpeed, float attackDamage, int enchantability,
Supplier<Ingredient> repairIngredient) {
@ -37,27 +38,27 @@ public enum EndToolMaterial implements Tier {
@Override
public int getUses() {
return durability;
return this.durability;
}
@Override
public float getSpeed() {
return miningSpeed;
return this.miningSpeed;
}
@Override
public float getAttackDamageBonus() {
return attackDamage;
return this.attackDamage;
}
@Override
public int getLevel() {
return miningLevel;
return this.miningLevel;
}
@Override
public int getEnchantmentValue() {
return enchantability;
return this.enchantability;
}
@Override

View file

@ -9,75 +9,71 @@ import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.client.rendering.v1.ArmorRenderingRegistry.ModelProvider;
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.client.model.HumanoidModel;
import net.minecraft.client.player.AbstractClientPlayer;
import net.minecraft.resources.ResourceLocation;
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 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 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 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;
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;
public @NotNull HumanoidModel<LivingEntity> getArmorModel(LivingEntity entity, ItemStack stack,
EquipmentSlot slot, HumanoidModel<LivingEntity> defaultModel) {
if (!isStackValid(stack)) return defaultModel;
switch(slot) {
case HEAD: {
return HELMET_MODEL;
}
case CHEST: {
if (entity instanceof AbstractClientPlayer &&
((AbstractClientPlayer) entity).getModelName().equals("slim")) {
CHEST_MODEL_SLIM.copyPropertiesTo(defaultModel);
return CHEST_MODEL_SLIM;
}
CHEST_MODEL.copyPropertiesTo(defaultModel);
return CHEST_MODEL;
}
case LEGS: {
return LEGGINGS_MODEL;
}
case FEET: {
BOOTS_MODEL.copyPropertiesTo(defaultModel);
return BOOTS_MODEL;
}
default: {
return defaultModel;
}
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

@ -1,43 +1,41 @@
package ru.betterend.item.model;
import java.util.Collections;
import net.minecraft.client.model.HumanoidModel;
import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.world.entity.LivingEntity;
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.world.entity.LivingEntity;
public class CrystaliteBootsModel extends BipedEntityModel<LivingEntity> {
public class CrystaliteBootsModel extends HumanoidModel<LivingEntity> {
public ModelPart leftBoot;
public ModelPart rightBoot;
public CrystaliteBootsModel(float scale) {
super(RenderLayer::getEntityTranslucent, scale, 0.0F, 64, 48);
super(RenderType::entityTranslucent, scale, 0.0F, 64, 48);
this.leftBoot = new ModelPart(this, 0, 32);
this.leftBoot.addCuboid(-2.0F, 0.0F, -2.0F, 4.0F, 12.0F, 4.0F, scale + 0.25F);
this.leftBoot.setPivot(1.9F, 12.0F, 0.0F);
this.leftBoot.addBox(-2.0F, 0.0F, -2.0F, 4.0F, 12.0F, 4.0F, scale + 0.25F);
this.leftBoot.setPos(1.9F, 12.0F, 0.0F);
this.rightBoot = new ModelPart(this, 0, 16);
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);
this.rightBoot.addBox(-2.0F, 0.0F, -2.0F, 4.0F, 12.0F, 4.0F, scale + 0.25F);
this.rightBoot.setPos(-1.9F, 12.0F, 0.0F);
}
@Override
public void copyPropertiesTo(HumanoidModel<LivingEntity> bipedEntityModel) {
super.copyPropertiesTo(bipedEntityModel);
this.leftBoot.copyFrom(leftLeg);
this.rightBoot.copyFrom(rightLeg);
}
@Override
public void setAttributes(BipedEntityModel<LivingEntity> bipedEntityModel) {
super.setAttributes(bipedEntityModel);
this.leftBoot.copyPositionAndRotation(leftLeg);
this.rightBoot.copyPositionAndRotation(rightLeg);
}
@Override
protected Iterable<ModelPart> getHeadParts() {
protected Iterable<ModelPart> headParts() {
return Collections::emptyIterator;
}
@Override
protected Iterable<ModelPart> getBodyParts() {
protected Iterable<ModelPart> bodyParts() {
return Lists.newArrayList(leftBoot, rightBoot);
}
}

View file

@ -1,74 +1,72 @@
package ru.betterend.item.model;
import java.util.Collections;
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.client.util.math.MatrixStack;
import net.minecraft.client.model.HumanoidModel;
import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.world.entity.HumanoidArm;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.util.Arm;
import com.google.common.collect.Lists;
import com.mojang.blaze3d.vertex.PoseStack;
public class CrystaliteChestplateModel extends BipedEntityModel<LivingEntity> {
public class CrystaliteChestplateModel extends HumanoidModel<LivingEntity> {
public ModelPart leftShoulder;
public ModelPart rightShoulder;
private boolean thinArms;
public CrystaliteChestplateModel(float scale, boolean thinArms) {
super(RenderLayer::getEntityTranslucent, scale, 0.0F, 64, 48);
super(RenderType::entityTranslucent, scale, 0.0F, 64, 48);
this.thinArms = thinArms;
this.torso = new ModelPart(this, 16, 16);
this.torso.addCuboid(-4.0F, 0.0F, -2.0F, 8.0F, 12.0F, 4.0F, scale + 0.25F);
this.torso.setPivot(0.0F, 0.0F, 0.0F);
this.body = new ModelPart(this, 16, 16);
this.body.addBox(-4.0F, 0.0F, -2.0F, 8.0F, 12.0F, 4.0F, scale + 0.25F);
this.body.setPos(0.0F, 0.0F, 0.0F);
if (thinArms) {
this.leftShoulder = new ModelPart(this, 41, 32);
this.leftShoulder.addCuboid(-1.0F, -2.5F, -2.0F, 3.0F, 12.0F, 4.0F, scale + 0.35F);
this.leftShoulder.setPivot(5.0F, 2.5F, 0.0F);
this.leftShoulder.addBox(-1.0F, -2.5F, -2.0F, 3.0F, 12.0F, 4.0F, scale + 0.35F);
this.leftShoulder.setPos(5.0F, 2.5F, 0.0F);
this.leftShoulder.mirror = true;
this.rightShoulder = new ModelPart(this, 41, 16);
this.rightShoulder.addCuboid(-2.0F, -2.5F, -2.0F, 3.0F, 12.0F, 4.0F, scale + 0.35F);
this.rightShoulder.setPivot(-5.0F, 2.5F, 10.0F);
this.rightShoulder.addBox(-2.0F, -2.5F, -2.0F, 3.0F, 12.0F, 4.0F, scale + 0.35F);
this.rightShoulder.setPos(-5.0F, 2.5F, 10.0F);
} else {
this.leftShoulder = new ModelPart(this, 40, 32);
this.leftShoulder.addCuboid(-1.0F, -2.5F, -2.0F, 4.0F, 12.0F, 4.0F, scale + 0.45F);
this.leftShoulder.setPivot(5.0F, 2.0F, 0.0F);
this.leftShoulder.addBox(-1.0F, -2.5F, -2.0F, 4.0F, 12.0F, 4.0F, scale + 0.45F);
this.leftShoulder.setPos(5.0F, 2.0F, 0.0F);
this.leftShoulder.mirror = true;
this.rightShoulder = new ModelPart(this, 40, 16);
this.rightShoulder.addCuboid(-3.0F, -2.5F, -2.0F, 4.0F, 12.0F, 4.0F, scale + 0.45F);
this.rightShoulder.setPivot(-5.0F, 2.0F, 10.0F);
this.rightShoulder.addBox(-3.0F, -2.5F, -2.0F, 4.0F, 12.0F, 4.0F, scale + 0.45F);
this.rightShoulder.setPos(-5.0F, 2.0F, 10.0F);
}
}
@Override
public void setAttributes(BipedEntityModel<LivingEntity> bipedEntityModel) {
super.setAttributes(bipedEntityModel);
this.leftShoulder.copyPositionAndRotation(leftArm);
this.rightShoulder.copyPositionAndRotation(rightArm);
public void copyPropertiesTo(HumanoidModel<LivingEntity> bipedEntityModel) {
super.copyPropertiesTo(bipedEntityModel);
this.leftShoulder.copyFrom(leftArm);
this.rightShoulder.copyFrom(rightArm);
}
@Override
protected Iterable<ModelPart> getHeadParts() {
protected Iterable<ModelPart> headParts() {
return Collections::emptyIterator;
}
@Override
protected Iterable<ModelPart> getBodyParts() {
return Lists.newArrayList(torso, leftShoulder, rightShoulder);
protected Iterable<ModelPart> bodyParts() {
return Lists.newArrayList(body, leftShoulder, rightShoulder);
}
@Override
public void setArmAngle(Arm arm, MatrixStack matrices) {
public void translateToHand(HumanoidArm arm, PoseStack matrices) {
ModelPart modelPart = this.getArm(arm);
if (this.thinArms) {
float f = 0.5F * (float) (arm == Arm.RIGHT ? 1 : -1);
modelPart.pivotX += f;
modelPart.rotate(matrices);
modelPart.pivotX -= f;
float f = 0.5F * (float)(arm == HumanoidArm.RIGHT ? 1 : -1);
modelPart.x += f;
modelPart.translateAndRotate(matrices);
modelPart.x -= f;
} else {
modelPart.rotate(matrices);
modelPart.translateAndRotate(matrices);
}
}
}

View file

@ -6,28 +6,28 @@ import com.google.common.collect.Lists;
import net.fabricmc.api.EnvType;
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.client.model.HumanoidModel;
import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.world.entity.LivingEntity;
@Environment(EnvType.CLIENT)
public class CrystaliteHelmetModel extends BipedEntityModel<LivingEntity> {
public class CrystaliteHelmetModel extends HumanoidModel<LivingEntity> {
public CrystaliteHelmetModel(float scale) {
super(RenderLayer::getEntityTranslucent, scale, 0.0F, 64, 48);
this.helmet = new ModelPart(this, 0, 0);
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);
super(RenderType::entityTranslucent, scale, 0.0F, 64, 48);
this.hat = new ModelPart(this, 0, 0);
this.hat.addBox(-4.0F, -8.0F, -4.0F, 8.0F, 8.0F, 8.0F, scale + 0.5F);
this.hat.setPos(0.0F, 0.0F, 0.0F);
}
@Override
protected Iterable<ModelPart> getHeadParts() {
protected Iterable<ModelPart> headParts() {
return Collections::emptyIterator;
}
@Override
protected Iterable<ModelPart> getBodyParts() {
return Lists.newArrayList(helmet);
protected Iterable<ModelPart> bodyParts() {
return Lists.newArrayList(hat);
}
}

View file

@ -1,36 +1,34 @@
package ru.betterend.item.model;
import java.util.Collections;
import net.minecraft.client.model.HumanoidModel;
import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.world.entity.LivingEntity;
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.world.entity.LivingEntity;
public class CrystaliteLeggingsModel extends BipedEntityModel<LivingEntity> {
public class CrystaliteLeggingsModel extends HumanoidModel<LivingEntity> {
public CrystaliteLeggingsModel(float scale) {
super(RenderLayer::getEntityTranslucent, scale, 0.0F, 64, 48);
this.torso = new ModelPart(this, 16, 16);
this.torso.addCuboid(-4.0F, 0.0F, -2.0F, 8.0F, 12.0F, 4.0F, scale);
this.torso.setPivot(0.0F, 0.0F, 0.0F);
super(RenderType::entityTranslucent, scale, 0.0F, 64, 48);
this.body = new ModelPart(this, 16, 16);
this.body.addBox(-4.0F, 0.0F, -2.0F, 8.0F, 12.0F, 4.0F, scale);
this.body.setPos(0.0F, 0.0F, 0.0F);
this.leftLeg = new ModelPart(this, 0, 32);
this.leftLeg.addCuboid(-2.0F, 0.0F, -2.0F, 4.0F, 12.0F, 4.0F, scale);
this.leftLeg.setPivot(1.9F, 12.0F, 0.0F);
this.leftLeg.addBox(-2.0F, 0.0F, -2.0F, 4.0F, 12.0F, 4.0F, scale);
this.leftLeg.setPos(1.9F, 12.0F, 0.0F);
this.rightLeg = new ModelPart(this, 0, 16);
this.rightLeg.addCuboid(-2.0F, 0.0F, -2.0F, 4.0F, 12.0F, 4.0F, scale);
this.rightLeg.setPivot(-1.9F, 12.0F, 0.0F);
this.rightLeg.addBox(-2.0F, 0.0F, -2.0F, 4.0F, 12.0F, 4.0F, scale);
this.rightLeg.setPos(-1.9F, 12.0F, 0.0F);
}
@Override
protected Iterable<ModelPart> getHeadParts() {
protected Iterable<ModelPart> headParts() {
return Collections::emptyIterator;
}
@Override
protected Iterable<ModelPart> getBodyParts() {
return Lists.newArrayList(torso, rightLeg, leftLeg);
protected Iterable<ModelPart> bodyParts() {
return Lists.newArrayList(body, rightLeg, leftLeg);
}
}

View file

@ -2,13 +2,13 @@ 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.world.level.block.state.BlockState;
import net.minecraft.tags.Tag;
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 net.minecraft.world.level.block.state.BlockState;
import ru.betterend.patterns.Patterned;
import ru.betterend.patterns.Patterns;
@ -24,7 +24,7 @@ public class EndAxeItem extends AxeItem implements DynamicAttributeTool, Pattern
}
return 0;
}
@Override
public String getModelPattern(String name) {
return Patterns.createJson(Patterns.ITEM_HANDHELD, name);

View file

@ -9,90 +9,89 @@ import com.google.common.collect.Sets;
import io.netty.util.internal.ThreadLocalRandom;
import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool;
import net.minecraft.core.BlockPos;
import net.minecraft.tags.Tag;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;
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.entity.player.Player;
import net.minecraft.world.item.DiggerItem;
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.item.Item;
import net.minecraft.world.item.ItemStack;
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 net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import ru.betterend.patterns.Patterned;
import ru.betterend.patterns.Patterns;
import ru.betterend.registry.EndTags;
public class EndHammerItem extends DiggerItem implements DynamicAttributeTool, Patterned {
public final static UUID ATTACK_KNOCKBACK_MODIFIER_ID = Mth.createInsecureUUID(ThreadLocalRandom.current());
private final Multimap<Attribute, AttributeModifier> attributeModifiers;
public EndHammerItem(Tier material, float attackDamage, float attackSpeed, double knockback, Properties settings) {
super(attackDamage, attackSpeed, material, Sets.newHashSet(), settings);
Builder<Attribute, AttributeModifier> builder = ImmutableMultimap.builder();
builder.put(Attributes.ATTACK_DAMAGE, new AttributeModifier(BASE_ATTACK_DAMAGE_UUID, "Weapon modifier",
attackDamage + material.getAttackDamageBonus(), AttributeModifier.Operation.ADDITION));
builder.put(Attributes.ATTACK_SPEED, new AttributeModifier(BASE_ATTACK_SPEED_UUID, "Weapon modifier",
attackSpeed, AttributeModifier.Operation.ADDITION));
builder.put(Attributes.ATTACK_KNOCKBACK, new AttributeModifier(ATTACK_KNOCKBACK_MODIFIER_ID, "Weapon modifier",
knockback, AttributeModifier.Operation.ADDITION));
builder.put(Attributes.ATTACK_DAMAGE, new AttributeModifier(BASE_ATTACK_DAMAGE_UUID, "Weapon modifier", attackDamage + material.getAttackDamageBonus(), AttributeModifier.Operation.ADDITION));
builder.put(Attributes.ATTACK_SPEED, new AttributeModifier(BASE_ATTACK_SPEED_UUID, "Weapon modifier", attackSpeed, AttributeModifier.Operation.ADDITION));
builder.put(Attributes.ATTACK_KNOCKBACK, new AttributeModifier(ATTACK_KNOCKBACK_MODIFIER_ID, "Weapon modifier", knockback, AttributeModifier.Operation.ADDITION));
this.attributeModifiers = builder.build();
}
@Override
public boolean canAttackBlock(BlockState state, Level world, BlockPos pos, Player 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);
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
public boolean hurtEnemy(ItemStack stack, LivingEntity target, LivingEntity attacker) {
stack.hurtAndBreak(1, attacker, (entity -> {
stack.hurtAndBreak(1, attacker, ((entity) -> {
entity.broadcastBreakEvent(EquipmentSlot.MAINHAND);
}));
return true;
}
@Override
public boolean mineBlock(ItemStack stack, Level world, BlockState state, BlockPos pos, LivingEntity miner) {
if (state.getDestroySpeed(world, pos) != 0.0F) {
stack.hurtAndBreak(1, miner, (entity -> {
stack.hurtAndBreak(1, miner, ((entity) -> {
entity.broadcastBreakEvent(EquipmentSlot.MAINHAND);
}));
}
return true;
}
@Override
public float getDestroySpeed(ItemStack stack, BlockState state) {
if (state.getMaterial().equals(Material.GLASS)) {
return getTier().getSpeed() * 2.0F;
return this.getTier().getSpeed() * 2.0F;
}
if (isCorrectToolForDrops(state)) {
float mult = 1.0F;
if (state.is(Blocks.DIAMOND_BLOCK) || state.is(Blocks.EMERALD_BLOCK) || state.is(Blocks.LAPIS_BLOCK)
|| state.is(Blocks.REDSTONE_BLOCK)) {
mult = getTier().getSpeed();
if (state.is(Blocks.DIAMOND_BLOCK) || state.is(Blocks.EMERALD_BLOCK) || state.is(Blocks.LAPIS_BLOCK) || state.is(Blocks.REDSTONE_BLOCK)) {
mult = this.getTier().getSpeed();
} else {
mult = getTier().getSpeed() / 2.0F;
mult = this.getTier().getSpeed() / 2.0F;
}
return Math.max(mult, 1.0F);
return mult > 1.0F ? mult : 1.0F;
}
return 1.0F;
}
@Override
public float getMiningSpeedMultiplier(Tag<Item> tag, BlockState state, ItemStack stack, LivingEntity user) {
if (tag.equals(EndTags.HAMMERS)) {
@ -100,7 +99,7 @@ public class EndHammerItem extends DiggerItem implements DynamicAttributeTool, P
}
return 1.0F;
}
@Override
public int getMiningLevel(Tag<Item> tag, BlockState state, ItemStack stack, LivingEntity user) {
if (tag.equals(EndTags.HAMMERS)) {
@ -114,20 +113,17 @@ public class EndHammerItem extends DiggerItem implements DynamicAttributeTool, P
if (state.getMaterial().equals(Material.GLASS)) {
return true;
}
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)) {
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.getTier().getLevel();
if (state.is(Blocks.IRON_ORE) || state.is(Blocks.LAPIS_BLOCK) || state.is(Blocks.LAPIS_ORE)) {
return level >= 1;
}
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)) {
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.is(Blocks.OBSIDIAN) || state.is(Blocks.CRYING_OBSIDIAN) || state.is(Blocks.RESPAWN_ANCHOR)
|| state.is(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;
@ -137,7 +133,7 @@ public class EndHammerItem extends DiggerItem implements DynamicAttributeTool, P
public Multimap<Attribute, AttributeModifier> getDefaultAttributeModifiers(EquipmentSlot slot) {
return slot == EquipmentSlot.MAINHAND ? this.attributeModifiers : super.getDefaultAttributeModifiers(slot);
}
@Override
public String getModelPattern(String name) {
return Patterns.createJson(Patterns.ITEM_HANDHELD, name);

View file

@ -9,7 +9,7 @@ public class EndHoeItem extends HoeItem implements Patterned {
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

@ -5,13 +5,13 @@ 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.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 net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import ru.betterend.patterns.Patterned;
import ru.betterend.patterns.Patterns;
@ -19,7 +19,7 @@ public class EndPickaxeItem extends PickaxeItem implements DynamicAttributeTool,
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)) {
@ -27,18 +27,16 @@ public class EndPickaxeItem extends PickaxeItem implements DynamicAttributeTool,
}
return 0;
}
@Override
public float getDestroySpeed(ItemStack stack, BlockState state) {
if (this.getTier().getLevel() > 2
&& state.getMaterial().equals(Blocks.END_STONE.defaultBlockState().getMaterial())) {
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) ? speed
: super.getDestroySpeed(stack, state);
return (entry != null && entry.getMiningLevel(FabricToolTags.PICKAXES) >= 0) ? this.speed : super.getDestroySpeed(stack, state);
}
@Override
public String getModelPattern(String name) {
return Patterns.createJson(Patterns.ITEM_HANDHELD, name);

View file

@ -4,13 +4,13 @@ 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.world.level.block.state.BlockState;
import net.minecraft.tags.Tag;
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 net.minecraft.world.level.block.state.BlockState;
import ru.betterend.patterns.Patterned;
import ru.betterend.patterns.Patterns;
@ -18,7 +18,7 @@ public class EndShovelItem extends ShovelItem implements DynamicAttributeTool, P
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)) {
@ -26,14 +26,13 @@ public class EndShovelItem extends ShovelItem implements DynamicAttributeTool, P
}
return 0;
}
@Override
public float getDestroySpeed(ItemStack stack, BlockState state) {
Entry entry = ToolManagerImpl.entryNullable(state.getBlock());
return (entry != null && entry.getMiningLevel(FabricToolTags.SHOVELS) >= 0) ? speed
: super.getDestroySpeed(stack, state);
return (entry != null && entry.getMiningLevel(FabricToolTags.SHOVELS) >= 0) ? this.speed : super.getDestroySpeed(stack, state);
}
@Override
public String getModelPattern(String name) {
return Patterns.createJson(Patterns.ITEM_HANDHELD, name);

View file

@ -10,7 +10,7 @@ public class EndSwordItem extends SwordItem implements DynamicAttributeTool, Pat
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);