Skip to content

Commit

Permalink
update for 1.17.1
Browse files Browse the repository at this point in the history
  • Loading branch information
dootus committed Aug 2, 2021
1 parent cda0655 commit dcd42b9
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 54 deletions.
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
plugins {
id 'fabric-loom' version '0.7-SNAPSHOT'
id 'fabric-loom' version '0.8-SNAPSHOT'
id 'maven-publish'
}

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_16
targetCompatibility = JavaVersion.VERSION_16

archivesBaseName = project.archives_base_name
version = project.mod_version
Expand Down Expand Up @@ -33,7 +33,7 @@ dependencies {
// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

modImplementation "de.siphalor:nbtcrafting-1.16:2+"
modImplementation "de.siphalor:nbtcrafting-1.17:2+"

// PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs.
// You may need to force-disable transitiveness on them.
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://modmuss50.me/fabric.html
minecraft_version=1.16.5
yarn_mappings=1.16.5+build.8
loader_version=0.11.3
minecraft_version=1.17.1
yarn_mappings=1.17.1+build.14
loader_version=0.11.6
# Mod Properties
mod_version=1.0-1.16.5
mod_version=1.0-1.17.1
maven_group=DeadlyDaggers
archives_base_name=DeadlyDaggers
# Dependencies
# check this on https://modmuss50.me/fabric.html
fabric_version=0.34.1+1.16
fabric_version=0.37.1+1.17
reach_entity_attributes_version=1.0.1
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 0 additions & 2 deletions src/main/java/deadlydaggers/DeadlyDaggers.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ToolMaterials;
import net.minecraft.loot.ConstantLootTableRange;
import net.minecraft.loot.entry.ItemEntry;
import net.minecraft.loot.entry.LootPoolEntry;
import net.minecraft.loot.entry.LootTableEntry;
import net.minecraft.text.Text;
Expand Down
20 changes: 13 additions & 7 deletions src/main/java/deadlydaggers/client/DeadlyDaggersClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,24 @@ public class DeadlyDaggersClient implements ClientModInitializer {
@Override
public void onInitializeClient() {

EntityRendererRegistry.INSTANCE.register(DeadlyDaggers.THROWN_WOODEN_DAGGER, (dispatcher, context) -> new ThrownDaggerEntityRenderer(dispatcher));
EntityRendererRegistry.INSTANCE.register(DeadlyDaggers.THROWN_STONE_DAGGER, (dispatcher, context) -> new ThrownDaggerEntityRenderer(dispatcher));
EntityRendererRegistry.INSTANCE.register(DeadlyDaggers.THROWN_IRON_DAGGER, (dispatcher, context) -> new ThrownDaggerEntityRenderer(dispatcher));
EntityRendererRegistry.INSTANCE.register(DeadlyDaggers.THROWN_GOLD_DAGGER, (dispatcher, context) -> new ThrownDaggerEntityRenderer(dispatcher));
EntityRendererRegistry.INSTANCE.register(DeadlyDaggers.THROWN_DIAMOND_DAGGER, (dispatcher, context) -> new ThrownDaggerEntityRenderer(dispatcher));
EntityRendererRegistry.INSTANCE.register(DeadlyDaggers.THROWN_NETHERITE_DAGGER, (dispatcher, context) -> new ThrownDaggerEntityRenderer(dispatcher));
EntityRendererRegistry.INSTANCE.register(DeadlyDaggers.THROWN_DIAMOND_DAGGER,(context) -> new ThrownDaggerEntityRenderer(context));
EntityRendererRegistry.INSTANCE.register(DeadlyDaggers.THROWN_WOODEN_DAGGER,(context) -> new ThrownDaggerEntityRenderer(context));
EntityRendererRegistry.INSTANCE.register(DeadlyDaggers.THROWN_STONE_DAGGER,(context) -> new ThrownDaggerEntityRenderer(context));
EntityRendererRegistry.INSTANCE.register(DeadlyDaggers.THROWN_IRON_DAGGER,(context) -> new ThrownDaggerEntityRenderer(context));
EntityRendererRegistry.INSTANCE.register(DeadlyDaggers.THROWN_GOLD_DAGGER,(context) -> new ThrownDaggerEntityRenderer(context));
EntityRendererRegistry.INSTANCE.register(DeadlyDaggers.THROWN_NETHERITE_DAGGER,(context) -> new ThrownDaggerEntityRenderer(context));
//EntityRendererRegistry.INSTANCE.register(DeadlyDaggers.THROWN_WOODEN_DAGGER, (dispatcher, context) -> new ThrownDaggerEntityRenderer(dispatcher));
// EntityRendererRegistry.INSTANCE.register(DeadlyDaggers.THROWN_STONE_DAGGER, (dispatcher, context) -> new ThrownDaggerEntityRenderer(dispatcher));
// EntityRendererRegistry.INSTANCE.register(DeadlyDaggers.THROWN_IRON_DAGGER, (dispatcher, context) -> new ThrownDaggerEntityRenderer(dispatcher));
// EntityRendererRegistry.INSTANCE.register(DeadlyDaggers.THROWN_GOLD_DAGGER, (dispatcher, context) -> new ThrownDaggerEntityRenderer(dispatcher));
// EntityRendererRegistry.INSTANCE.register(DeadlyDaggers.THROWN_DIAMOND_DAGGER, (dispatcher, context) -> new ThrownDaggerEntityRenderer(dispatcher));
// EntityRendererRegistry.INSTANCE.register(DeadlyDaggers.THROWN_NETHERITE_DAGGER, (dispatcher, context) -> new ThrownDaggerEntityRenderer(dispatcher));

ClientPlayNetworking.registerGlobalReceiver(ThrownDaggerProjectileSpawnPacket.ID, ThrownDaggerProjectileSpawnPacket::onPacket);


for (Item dagger : DeadlyDaggers.DAGGER_MAP.inverse().keySet()) {
FabricModelPredicateProviderRegistry.register(dagger, new Identifier("poisoned"), (itemStack, clientWorld, livingEntity) -> {
FabricModelPredicateProviderRegistry.register(dagger, new Identifier("poisoned"), (itemStack, clientWorld, livingEntity,provider) -> {
if (PotionUtil.getPotionEffects(itemStack).isEmpty()) {
return 0.0F;
} else return 1.0F;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,23 @@
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.render.entity.EntityRenderer;
import net.minecraft.client.render.entity.EntityRendererFactory;
import net.minecraft.client.render.entity.ProjectileEntityRenderer;
import net.minecraft.client.render.item.ItemRenderer;
import net.minecraft.client.render.model.json.ModelTransformation;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.util.math.Vector3f;
import net.minecraft.client.util.math.*;
import net.minecraft.util.math.Vec3f;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Quaternion;
import net.minecraft.util.math.Vec3d;

public class ThrownDaggerEntityRenderer extends EntityRenderer<ThrownDaggerEntity> {
public ThrownDaggerEntityRenderer(EntityRenderDispatcher entityRenderDispatcher) {
super(entityRenderDispatcher);
}
// public ThrownDaggerEntityRenderer(EntityRenderDispatcher entityRenderDispatcher) {
// super(entityRenderDispatcher);
// }
public ThrownDaggerEntityRenderer(EntityRendererFactory.Context context){super(context);}

//rendering the item directly so we don't use this
@Override
Expand All @@ -34,14 +37,14 @@ public Identifier getTexture(ThrownDaggerEntity entity) {

public void render(ThrownDaggerEntity daggerEntity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i) {
matrixStack.push();
matrixStack.multiply((Vector3f.POSITIVE_Y.getDegreesQuaternion(daggerEntity.yaw-90)));
matrixStack.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(daggerEntity.pitch - 30));
matrixStack.multiply((Vec3f.POSITIVE_Y.getDegreesQuaternion(daggerEntity.getYaw()-90)));
matrixStack.multiply(Vec3f.POSITIVE_Z.getDegreesQuaternion(daggerEntity.getPitch() - 30));
//spinning daggers in flight
if(!daggerEntity.isInGround()){
matrixStack.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(daggerEntity.age*-20));
matrixStack.multiply(Vec3f.POSITIVE_Z.getDegreesQuaternion(daggerEntity.age*-20));
}
MinecraftClient.getInstance().getItemRenderer()
.renderItem(daggerEntity.asItemStack(), ModelTransformation.Mode.THIRD_PERSON_RIGHT_HAND, i, 700000, matrixStack, vertexConsumerProvider);
.renderItem(daggerEntity.asItemStack(), ModelTransformation.Mode.THIRD_PERSON_RIGHT_HAND, i, 700000, matrixStack, vertexConsumerProvider,1);
matrixStack.pop();
super.render(daggerEntity, f, g, matrixStack, vertexConsumerProvider, i);
}
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/deadlydaggers/entity/ThrownDaggerEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.PersistentProjectileEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.network.Packet;
import net.minecraft.potion.PotionUtil;
import net.minecraft.server.network.ServerPlayerEntity;
Expand Down Expand Up @@ -90,7 +90,7 @@ public void tick() {
this.dropStack(this.asItemStack(), 0.1F);
}

this.remove();
this.remove(RemovalReason.DISCARDED);
} else if (i > 0) {
this.setNoClip(true);
Vec3d vec3d = new Vec3d(entity.getX() - this.getX(), entity.getEyeY() - this.getY(), entity.getZ() - this.getZ());
Expand Down Expand Up @@ -189,7 +189,7 @@ protected void onEntityHit(EntityHitResult entityHitResult) {


for(StatusEffectInstance effect:PotionUtil.getPotionEffects(daggerStack)){livingEntity2.addStatusEffect(new StatusEffectInstance(effect));}
CompoundTag t = daggerStack.getTag();
NbtCompound t = daggerStack.getNbt();
if(t!=null){t.remove("Potion");
t.remove("CustomPotionEffects");
t.remove("CustomPotionColor");}
Expand All @@ -205,18 +205,18 @@ protected void onEntityHit(EntityHitResult entityHitResult) {
}

@Override
public void writeCustomDataToTag(CompoundTag tag) {
super.writeCustomDataToTag(tag);
tag.put("daggerStack", daggerStack.toTag(new CompoundTag()));
public void writeCustomDataToNbt(NbtCompound tag) {
super.writeCustomDataToNbt(tag);
tag.put("daggerStack", daggerStack.writeNbt(new NbtCompound()));
tag.putBoolean("DealtDamage", this.dealtDamage);

}

@Override
public void readCustomDataFromTag(CompoundTag tag) {
super.readCustomDataFromTag(tag);
public void readCustomDataFromNbt(NbtCompound tag) {
super.readCustomDataFromNbt(tag);
if(tag.contains("daggerStack")){
daggerStack = ItemStack.fromTag(tag.getCompound("daggerStack"));
daggerStack = ItemStack.fromNbt(tag.getCompound("daggerStack"));
this.dataTracker.set(LOYALTY, (byte) EnchantmentHelper.getLoyalty(daggerStack));
this.dataTracker.set(ENCHANTED, daggerStack.hasGlint());
}
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/deadlydaggers/item/DaggerItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.PersistentProjectileEntity;
import net.minecraft.item.*;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.potion.PotionUtil;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
Expand Down Expand Up @@ -65,7 +65,7 @@ public boolean canMine(BlockState state, World world, BlockPos pos, PlayerEntity
public boolean postHit(ItemStack stack, LivingEntity target, LivingEntity attacker) {

for(StatusEffectInstance effect:PotionUtil.getPotionEffects(stack)){target.addStatusEffect(new StatusEffectInstance(effect));}
CompoundTag t = stack.getTag();
NbtCompound t = stack.getNbt();
if(t!=null){t.remove("Potion");
t.remove("CustomPotionEffects");
t.remove("CustomPotionColor");}
Expand Down Expand Up @@ -109,7 +109,7 @@ public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) {
return 15.0F;
} else {
Material material = state.getMaterial();
return material != Material.PLANT && material != Material.REPLACEABLE_PLANT && material != Material.UNUSED_PLANT && !state.isIn(BlockTags.LEAVES) && material != Material.GOURD ? 1.0F : 1.5F;
return material != Material.PLANT && material != Material.REPLACEABLE_PLANT && !state.isIn(BlockTags.LEAVES) && material != Material.GOURD ? 1.0F : 1.5F;
}
}

Expand All @@ -123,16 +123,16 @@ public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand han


ThrownDaggerEntity daggerEntity = new ThrownDaggerEntity(world, user, stack.copy());
daggerEntity.setProperties(user, user.pitch, user.yaw, 0.0F, 2.5F, 1.0F);
daggerEntity.setProperties(user, user.getPitch(), user.getYaw(), 0.0F, 2.5F, 1.0F);
daggerEntity.setPos(daggerEntity.getX(),daggerEntity.getY()-0.1,daggerEntity.getZ());
daggerEntity.setVelocity(daggerEntity.getVelocity().multiply(0.5D));
if (user.abilities.creativeMode) {
if (user.getAbilities().creativeMode) {
daggerEntity.pickupType = PersistentProjectileEntity.PickupPermission.CREATIVE_ONLY;
}

world.spawnEntity(daggerEntity);
world.playSoundFromEntity(null, daggerEntity, SoundEvents.ITEM_TRIDENT_THROW, SoundCategory.PLAYERS, 1.0F, 1.0F);
if (!user.abilities.creativeMode) {
if (!user.getAbilities().creativeMode) {
stack.decrement(1);
}
return TypedActionResult.success(stack,world.isClient());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,20 @@ public static Packet<?> createPacket(ThrownDaggerEntity entity) {
PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer());
buf.writeVarInt(Registry.ENTITY_TYPE.getRawId(entity.getType())); //1
buf.writeUuid(entity.getUuid()); //2
buf.writeVarInt(entity.getEntityId()); //3
buf.writeVarInt(entity.getId()); //3
buf.writeDouble(entity.getX()); //4
buf.writeDouble(entity.getY()); //5
buf.writeDouble(entity.getZ()); //6
buf.writeByte(MathHelper.floor(entity.pitch * 256.0F / 360.0F)); //7
buf.writeByte(MathHelper.floor(entity.yaw * 256.0F / 360.0F)); //8
buf.writeByte(MathHelper.floor(entity.getPitch() * 256.0F / 360.0F)); //7
buf.writeByte(MathHelper.floor(entity.getYaw() * 256.0F / 360.0F)); //8

ItemStack i = entity.asItemStack();
buf.writeBoolean(i.hasEnchantments()); // 9

//probably won't nullpointer :^)
buf.writeString(i.getTag().getString("Potion")); //10
if(i.getTag().contains("CustomPotionColor")) {
buf.writeString(i.getTag().getString("CustomPotionColor"));//11
buf.writeString(i.getNbt().getString("Potion")); //10
if(i.getNbt().contains("CustomPotionColor")) {
buf.writeString(i.getNbt().getString("CustomPotionColor"));//11
}
else{buf.writeInt(-1);}
return ServerPlayNetworking.createS2CPacket(ID, buf);
Expand All @@ -75,10 +75,10 @@ public static void onPacket(MinecraftClient client, ClientPlayNetworkHandler net
if(hasEnchantments){fakeDagger.addEnchantment(Enchantments.UNBREAKING,1);}

String potion = buffer.readString(); //10
fakeDagger.getOrCreateTag().putString("Potion",potion);
fakeDagger.getOrCreateNbt().putString("Potion",potion);
int customPotionColor = buffer.readInt(); //11
if(customPotionColor!=-1){
fakeDagger.getTag().putInt("CustomPotionColor",customPotionColor);}
fakeDagger.getNbt().putInt("CustomPotionColor",customPotionColor);}

//--------
ClientWorld world = MinecraftClient.getInstance().world;
Expand All @@ -90,9 +90,9 @@ public static void onPacket(MinecraftClient client, ClientPlayNetworkHandler net
if (world != null && entity != null) {
entity.updatePosition(x, y, z);
entity.updateTrackedPosition(x, y, z);
entity.pitch = pitch;
entity.yaw = yaw;
entity.setEntityId(entityID);
entity.setPitch(pitch);
entity.setYaw(yaw);
entity.setId(entityID);
entity.setUuid(entityUUID);
world.addEntity(entityID, entity);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"depends": {
"fabricloader": ">=0.11.3",
"fabric": "*",
"minecraft": "1.16.5",
"minecraft": "1.17.*",
"nbtcrafting": "*"
}
}

0 comments on commit dcd42b9

Please sign in to comment.