From 33776df3982c9717691662107a45184efc7d770f Mon Sep 17 00:00:00 2001 From: Draylar Date: Mon, 2 Nov 2020 21:15:18 -0600 Subject: [PATCH] update to 1.16.2/.3/.4 --- LICENSE | 122 +----------------- build.gradle | 33 ++++- gradle.properties | 8 +- .../draylar/targetdummy/TargetDummy.java | 24 ---- .../targetdummy/TargetDummyClient.java | 15 --- .../targetdummy/entity/TargetDummyModel.java | 38 ------ .../targetdummy/item/TargetDummyItem.java | 48 ------- .../java/draylar/targetdummy/TargetDummy.java | 29 +++++ .../targetdummy/TargetDummyClient.java | 13 ++ .../targetdummy/entity/TargetDummyEntity.java | 54 ++++---- .../targetdummy/entity/TargetDummyModel.java | 38 ++++++ .../targetdummy/entity/TargetDummyRender.java | 12 +- .../targetdummy/item/TargetDummyItem.java | 43 ++++++ .../assets/target-dummy/lang/en_us.json | 3 +- src/main/resources/fabric.mod.json | 8 +- 15 files changed, 193 insertions(+), 295 deletions(-) delete mode 100644 src/main/java/com/github/draylar/targetdummy/TargetDummy.java delete mode 100644 src/main/java/com/github/draylar/targetdummy/TargetDummyClient.java delete mode 100644 src/main/java/com/github/draylar/targetdummy/entity/TargetDummyModel.java delete mode 100644 src/main/java/com/github/draylar/targetdummy/item/TargetDummyItem.java create mode 100644 src/main/java/draylar/targetdummy/TargetDummy.java create mode 100644 src/main/java/draylar/targetdummy/TargetDummyClient.java rename src/main/java/{com/github => }/draylar/targetdummy/entity/TargetDummyEntity.java (52%) create mode 100644 src/main/java/draylar/targetdummy/entity/TargetDummyModel.java rename src/main/java/{com/github => }/draylar/targetdummy/entity/TargetDummyRender.java (73%) create mode 100644 src/main/java/draylar/targetdummy/item/TargetDummyItem.java diff --git a/LICENSE b/LICENSE index 0e259d4..4af71c6 100644 --- a/LICENSE +++ b/LICENSE @@ -1,121 +1,7 @@ -Creative Commons Legal Code +Copyright Draylar 2020 -CC0 1.0 Universal +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE - LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN - ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS - INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES - REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS - PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM - THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED - HEREUNDER. +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator -and subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for -the purpose of contributing to a commons of creative, cultural and -scientific works ("Commons") that the public can reliably and without fear -of later claims of infringement build upon, modify, incorporate in other -works, reuse and redistribute as freely as possible in any form whatsoever -and for any purposes, including without limitation commercial purposes. -These owners may contribute to the Commons to promote the ideal of a free -culture and the further production of creative, cultural and scientific -works, or to gain reputation or greater distribution for their Work in -part through the use and efforts of others. - -For these and/or other purposes and motivations, and without any -expectation of additional consideration or compensation, the person -associating CC0 with a Work (the "Affirmer"), to the extent that he or she -is an owner of Copyright and Related Rights in the Work, voluntarily -elects to apply CC0 to the Work and publicly distribute the Work under its -terms, with knowledge of his or her Copyright and Related Rights in the -Work and the meaning and intended legal effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not -limited to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, - communicate, and translate a Work; - ii. moral rights retained by the original author(s) and/or performer(s); -iii. publicity and privacy rights pertaining to a person's image or - likeness depicted in a Work; - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - v. rights protecting the extraction, dissemination, use and reuse of data - in a Work; - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation - thereof, including any amended or successor version of such - directive); and -vii. other similar, equivalent or corresponding rights throughout the - world based on applicable law or treaty, and any national - implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention -of, applicable law, Affirmer hereby overtly, fully, permanently, -irrevocably and unconditionally waives, abandons, and surrenders all of -Affirmer's Copyright and Related Rights and associated claims and causes -of action, whether now known or unknown (including existing as well as -future claims and causes of action), in the Work (i) in all territories -worldwide, (ii) for the maximum duration provided by applicable law or -treaty (including future time extensions), (iii) in any current or future -medium and for any number of copies, and (iv) for any purpose whatsoever, -including without limitation commercial, advertising or promotional -purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each -member of the public at large and to the detriment of Affirmer's heirs and -successors, fully intending that such Waiver shall not be subject to -revocation, rescission, cancellation, termination, or any other legal or -equitable action to disrupt the quiet enjoyment of the Work by the public -as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason -be judged legally invalid or ineffective under applicable law, then the -Waiver shall be preserved to the maximum extent permitted taking into -account Affirmer's express Statement of Purpose. In addition, to the -extent the Waiver is so judged Affirmer hereby grants to each affected -person a royalty-free, non transferable, non sublicensable, non exclusive, -irrevocable and unconditional license to exercise Affirmer's Copyright and -Related Rights in the Work (i) in all territories worldwide, (ii) for the -maximum duration provided by applicable law or treaty (including future -time extensions), (iii) in any current or future medium and for any number -of copies, and (iv) for any purpose whatsoever, including without -limitation commercial, advertising or promotional purposes (the -"License"). The License shall be deemed effective as of the date CC0 was -applied by Affirmer to the Work. Should any part of the License for any -reason be judged legally invalid or ineffective under applicable law, such -partial invalidity or ineffectiveness shall not invalidate the remainder -of the License, and in such case Affirmer hereby affirms that he or she -will not (i) exercise any of his or her remaining Copyright and Related -Rights in the Work or (ii) assert any associated claims and causes of -action with respect to the Work, in either case contrary to Affirmer's -express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - b. Affirmer offers the Work as-is and makes no representations or - warranties of any kind concerning the Work, express, implied, - statutory or otherwise, including without limitation warranties of - title, merchantability, fitness for a particular purpose, non - infringement, or the absence of latent or other defects, accuracy, or - the present or absence of errors, whether or not discoverable, all to - the greatest extent permissible under applicable law. - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without - limitation any person's Copyright and Related Rights in the Work. - Further, Affirmer disclaims responsibility for obtaining any necessary - consents, permissions or other rights required for any use of the - Work. - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to - this CC0 or use of the Work. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/build.gradle b/build.gradle index 0f57c42..375db63 100644 --- a/build.gradle +++ b/build.gradle @@ -1,12 +1,12 @@ plugins { - id 'fabric-loom' version '0.2.4-SNAPSHOT' + id 'fabric-loom' version '0.5-SNAPSHOT' } sourceCompatibility = 1.8 targetCompatibility = 1.8 archivesBaseName = "target-dummy" -version = "1.0.1" +version = project.mod_version + "-" + project.minecraft_version minecraft { } @@ -16,16 +16,35 @@ repositories { } dependencies { - minecraft "com.mojang:minecraft:1.14.4" - mappings "net.fabricmc:yarn:1.14.4+build.2" - modCompile "net.fabricmc:fabric-loader:0.4.8+build.158" - modCompile "net.fabricmc.fabric-api:fabric-api:0.3.0+build.200" + minecraft "com.mojang:minecraft:${project.minecraft_version}" + mappings "net.fabricmc:yarn:1.16.4+build.1:v2" + modImplementation "net.fabricmc:fabric-loader:0.10.6+build.214" + modImplementation "net.fabricmc.fabric-api:fabric-api:0.25.1+build.416-1.16" +} + +processResources { + inputs.property "version", project.version + + filesMatching("fabric.mod.json") { + expand "version": project.version + } +} + +// ensure that the encoding is set to UTF-8, no matter what the system default is +// this fixes some edge cases with special characters not displaying correctly +// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html +tasks.withType(JavaCompile) { + options.encoding = "UTF-8" } // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task // if it is present. // If you remove this task, sources will not be generated. task sourcesJar(type: Jar, dependsOn: classes) { - classifier = 'sources' + classifier = "sources" from sourceSets.main.allSource } + +jar { + from "LICENSE" +} diff --git a/gradle.properties b/gradle.properties index d8e54c1..18a52ca 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,8 @@ #Done to increase the memory available to gradle. -org.gradle.jvmargs=-Xmx1G \ No newline at end of file +org.gradle.jvmargs=-Xmx1G + +# Mod Values +mod_version=1.0.2 + +# Minecraft Dep Versions +minecraft_version=1.16.4 diff --git a/src/main/java/com/github/draylar/targetdummy/TargetDummy.java b/src/main/java/com/github/draylar/targetdummy/TargetDummy.java deleted file mode 100644 index a30886f..0000000 --- a/src/main/java/com/github/draylar/targetdummy/TargetDummy.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.github.draylar.targetdummy; - -import com.github.draylar.targetdummy.entity.TargetDummyEntity; -import com.github.draylar.targetdummy.item.TargetDummyItem; -import net.fabricmc.api.ModInitializer; -import net.fabricmc.fabric.api.entity.FabricEntityTypeBuilder; -import net.minecraft.entity.EntityCategory; -import net.minecraft.entity.EntityDimensions; -import net.minecraft.entity.EntityType; -import net.minecraft.item.Item; -import net.minecraft.item.ItemGroup; -import net.minecraft.util.registry.Registry; - -public class TargetDummy implements ModInitializer -{ - public static final EntityType TARGET_DUMMY = FabricEntityTypeBuilder.create(EntityCategory.AMBIENT, (EntityType.EntityFactory) TargetDummyEntity::new).size(EntityDimensions.fixed(1, 2)).build(); - public static Item targetDummyItem; - - @Override - public void onInitialize() { - Registry.register(Registry.ENTITY_TYPE, "target-dummy:target_dummy", TARGET_DUMMY); - targetDummyItem = Registry.register(Registry.ITEM, "target-dummy:target_dummy", new TargetDummyItem(new Item.Settings().group(ItemGroup.TOOLS))); - } -} diff --git a/src/main/java/com/github/draylar/targetdummy/TargetDummyClient.java b/src/main/java/com/github/draylar/targetdummy/TargetDummyClient.java deleted file mode 100644 index 5873552..0000000 --- a/src/main/java/com/github/draylar/targetdummy/TargetDummyClient.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.github.draylar.targetdummy; - -import com.github.draylar.targetdummy.entity.TargetDummyEntity; -import com.github.draylar.targetdummy.entity.TargetDummyRender; -import net.fabricmc.api.ClientModInitializer; -import net.fabricmc.fabric.api.client.render.EntityRendererRegistry; - -public class TargetDummyClient implements ClientModInitializer -{ - @Override - public void onInitializeClient() - { - EntityRendererRegistry.INSTANCE.register(TargetDummyEntity.class, ((entityRenderDispatcher, context) -> new TargetDummyRender(entityRenderDispatcher))); - } -} diff --git a/src/main/java/com/github/draylar/targetdummy/entity/TargetDummyModel.java b/src/main/java/com/github/draylar/targetdummy/entity/TargetDummyModel.java deleted file mode 100644 index 37e729d..0000000 --- a/src/main/java/com/github/draylar/targetdummy/entity/TargetDummyModel.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.github.draylar.targetdummy.entity; - -//Paste this code into your mod. - -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.model.Cuboid; -import net.minecraft.client.render.entity.model.EntityModel; -import org.lwjgl.opengl.GL11; - -import java.awt.*; - -public class TargetDummyModel extends EntityModel -{ - private final Cuboid bone; - - public TargetDummyModel() { - textureWidth = 64; - textureHeight = 64; - - bone = new Cuboid(this); - bone.y = -.3f; - bone.setRotationPoint(0.0F, 24.0F, 0.0F); - - bone.addBox("bone1", -4, -10, -1, 2, 9, 2, 0, 8, 31); - bone.addBox("bone2", 2, -10, -1, 2, 9, 2, 0, 0, 31); - bone.addBox("bone3", -4, -23, -1.5f, 8, 13, 3, 0, 0, 15); - bone.addBox("bone4", -3, -29, -2, 6, 6, 4, 0, 22, 15); - bone.addBox("bone5", -7, -21, -1, 3, 2, 2, 0, 16, 35); - bone.addBox("bone6", 4, -21, -1, 3, 2, 2, 0, 16, 31); - bone.addBox("bone7", -7, -1, -7, 14, 1, 14, 0, 0, 0); - } - - @Override - public void render(TargetDummyEntity entity_1, float float_1, float float_2, float float_3, float float_4, float float_5, float float_6) - { - bone.render(.075f); - } -} diff --git a/src/main/java/com/github/draylar/targetdummy/item/TargetDummyItem.java b/src/main/java/com/github/draylar/targetdummy/item/TargetDummyItem.java deleted file mode 100644 index e15bf13..0000000 --- a/src/main/java/com/github/draylar/targetdummy/item/TargetDummyItem.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.github.draylar.targetdummy.item; - -import com.github.draylar.targetdummy.TargetDummy; -import com.github.draylar.targetdummy.entity.TargetDummyEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUsageContext; -import net.minecraft.util.ActionResult; -import net.minecraft.util.math.BlockPos; - -public class TargetDummyItem extends Item -{ - public TargetDummyItem(Settings item$Settings_1) - { - super(item$Settings_1); - } - - @Override - public ActionResult useOnBlock(ItemUsageContext itemUsageContext_1) - { - if(!itemUsageContext_1.getWorld().isClient) - { - PlayerEntity playerEntity = itemUsageContext_1.getPlayer(); - BlockPos blockPos = itemUsageContext_1.getBlockPos(); - - - // set entity settings - TargetDummyEntity targetDummyEntity = TargetDummy.TARGET_DUMMY.create(itemUsageContext_1.getWorld()); - targetDummyEntity.setPosition(Math.floor(blockPos.getX()) + .5, Math.floor(blockPos.getY()) + 1, Math.floor(blockPos.getZ()) + .5); - targetDummyEntity.setHeadYaw(playerEntity.getHeadYaw() + 180); - if(targetDummyEntity.getHeadYaw() > 180) targetDummyEntity.setHeadYaw(targetDummyEntity.getHeadYaw() - 360); - - - // spawn entity - itemUsageContext_1.getWorld().spawnEntity(targetDummyEntity); - - - // remove item - int index = playerEntity.inventory.selectedSlot; - ItemStack currentStack = itemUsageContext_1.getStack(); - currentStack.setCount(currentStack.getCount() - 1); - playerEntity.inventory.main.set(index, currentStack); - } - - return super.useOnBlock(itemUsageContext_1); - } -} diff --git a/src/main/java/draylar/targetdummy/TargetDummy.java b/src/main/java/draylar/targetdummy/TargetDummy.java new file mode 100644 index 0000000..dc15366 --- /dev/null +++ b/src/main/java/draylar/targetdummy/TargetDummy.java @@ -0,0 +1,29 @@ +package draylar.targetdummy; + +import draylar.targetdummy.entity.TargetDummyEntity; +import draylar.targetdummy.item.TargetDummyItem; +import net.fabricmc.api.ModInitializer; +import net.fabricmc.fabric.api.object.builder.v1.entity.FabricDefaultAttributeRegistry; +import net.fabricmc.fabric.api.object.builder.v1.entity.FabricEntityTypeBuilder; +import net.minecraft.entity.EntityDimensions; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.SpawnGroup; +import net.minecraft.entity.attribute.DefaultAttributeContainer; +import net.minecraft.entity.attribute.EntityAttributes; +import net.minecraft.entity.mob.MobEntity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemGroup; +import net.minecraft.util.registry.Registry; + +public class TargetDummy implements ModInitializer { + + public static final EntityType TARGET_DUMMY = FabricEntityTypeBuilder.create(SpawnGroup.AMBIENT, (EntityType.EntityFactory) TargetDummyEntity::new).dimensions(EntityDimensions.fixed(1, 2)).build(); + public static Item targetDummyItem = Registry.register(Registry.ITEM, "target-dummy:target_dummy", new TargetDummyItem(new Item.Settings().group(ItemGroup.TOOLS))); + + @Override + public void onInitialize() { + Registry.register(Registry.ENTITY_TYPE, "target-dummy:target_dummy", TARGET_DUMMY); + + FabricDefaultAttributeRegistry.register(TARGET_DUMMY, MobEntity.createMobAttributes().add(EntityAttributes.GENERIC_MAX_HEALTH, 20).add(EntityAttributes.GENERIC_KNOCKBACK_RESISTANCE, 1)); + } +} diff --git a/src/main/java/draylar/targetdummy/TargetDummyClient.java b/src/main/java/draylar/targetdummy/TargetDummyClient.java new file mode 100644 index 0000000..bf9097f --- /dev/null +++ b/src/main/java/draylar/targetdummy/TargetDummyClient.java @@ -0,0 +1,13 @@ +package draylar.targetdummy; + +import draylar.targetdummy.entity.TargetDummyRender; +import net.fabricmc.api.ClientModInitializer; +import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry; + +public class TargetDummyClient implements ClientModInitializer { + + @Override + public void onInitializeClient() { + EntityRendererRegistry.INSTANCE.register(TargetDummy.TARGET_DUMMY, ((entityRenderDispatcher, context) -> new TargetDummyRender(entityRenderDispatcher))); + } +} \ No newline at end of file diff --git a/src/main/java/com/github/draylar/targetdummy/entity/TargetDummyEntity.java b/src/main/java/draylar/targetdummy/entity/TargetDummyEntity.java similarity index 52% rename from src/main/java/com/github/draylar/targetdummy/entity/TargetDummyEntity.java rename to src/main/java/draylar/targetdummy/entity/TargetDummyEntity.java index 4f04211..1bd1699 100644 --- a/src/main/java/com/github/draylar/targetdummy/entity/TargetDummyEntity.java +++ b/src/main/java/draylar/targetdummy/entity/TargetDummyEntity.java @@ -1,60 +1,52 @@ -package com.github.draylar.targetdummy.entity; +package draylar.targetdummy.entity; -import com.github.draylar.targetdummy.TargetDummy; +import draylar.targetdummy.TargetDummy; +import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; import net.minecraft.entity.ItemEntity; -import net.minecraft.entity.attribute.EntityAttributes; import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.mob.MobEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.text.LiteralText; +import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; -public class TargetDummyEntity extends MobEntity -{ - public TargetDummyEntity(EntityType type, World world_1) - { - super(TargetDummy.TARGET_DUMMY, world_1); +public class TargetDummyEntity extends MobEntity { + + public TargetDummyEntity(EntityType type, World world) { + super(TargetDummy.TARGET_DUMMY, world); setAiDisabled(true); setCanPickUpLoot(false); } - public TargetDummyEntity(World world_1) - { - super(TargetDummy.TARGET_DUMMY, world_1); - setAiDisabled(true); - setCanPickUpLoot(false); + @Override + public boolean cannotDespawn() { + return true; } @Override - protected void initAttributes() - { - super.initAttributes(); - this.getAttributeInstance(EntityAttributes.MAX_HEALTH).setBaseValue(20); - this.getAttributeInstance(EntityAttributes.KNOCKBACK_RESISTANCE).setBaseValue(1); + public void pushAwayFrom(Entity entity) { + } @Override - public boolean cannotDespawn() { - return true; + public void pushAway(Entity entity) { + } @Override - protected void applyDamage(DamageSource damageSource_1, float float_1) - { + public void applyDamage(DamageSource damageSource_1, float float_1) { String newName = String.format("%.0f", float_1); this.setCustomName(new LiteralText(newName)); } @Override - protected boolean interactMob(PlayerEntity playerEntity_1, Hand hand_1) - { + public ActionResult interactMob(PlayerEntity player, Hand hand) { // kill entity & drop summon item - if(playerEntity_1.isSneaking()) - { + if (player.isSneaking()) { ItemEntity itemEntity = new ItemEntity(world, this.getPos().getX() + .5, this.getPos().getY() + .5, this.getPos().getZ() + .5); itemEntity.setStack(new ItemStack(TargetDummy.targetDummyItem)); itemEntity.setVelocity(new Vec3d(0, 0, 0)); @@ -63,19 +55,17 @@ protected boolean interactMob(PlayerEntity playerEntity_1, Hand hand_1) this.kill(); } - return super.interactMob(playerEntity_1, hand_1); + return super.interactMob(player, hand); } @Override - public void kill() - { - this.setPosition(this.getPos().getX(), -50, this.getPos().getZ()); + public void kill() { + this.setPos(this.getPos().getX(), -50, this.getPos().getZ()); this.damage(DamageSource.GENERIC, 3.4028235E38F); } @Override - protected void mobTick() - { + public void mobTick() { super.mobTick(); } } diff --git a/src/main/java/draylar/targetdummy/entity/TargetDummyModel.java b/src/main/java/draylar/targetdummy/entity/TargetDummyModel.java new file mode 100644 index 0000000..0cfcbc5 --- /dev/null +++ b/src/main/java/draylar/targetdummy/entity/TargetDummyModel.java @@ -0,0 +1,38 @@ +package draylar.targetdummy.entity; + +import net.minecraft.client.model.ModelPart; +import net.minecraft.client.render.VertexConsumer; +import net.minecraft.client.render.entity.model.EntityModel; +import net.minecraft.client.util.math.MatrixStack; + +public class TargetDummyModel extends EntityModel { + + private final ModelPart bone; + + public TargetDummyModel() { + textureWidth = 64; + textureHeight = 64; + + bone = new ModelPart(this); + bone.pivotY = -.3f; + bone.setPivot(0.0F, 24.0F, 0.0F); + + bone.addCuboid("bone1", -4, -10, -1, 2, 9, 2, 0, 8, 31); + bone.addCuboid("bone2", 2, -10, -1, 2, 9, 2, 0, 0, 31); + bone.addCuboid("bone3", -4, -23, -1.5f, 8, 13, 3, 0, 0, 15); + bone.addCuboid("bone4", -3, -29, -2, 6, 6, 4, 0, 22, 15); + bone.addCuboid("bone5", -7, -21, -1, 3, 2, 2, 0, 16, 35); + bone.addCuboid("bone6", 4, -21, -1, 3, 2, 2, 0, 16, 31); + bone.addCuboid("bone7", -7, -1, -7, 14, 1, 14, 0, 0, 0); + } + + @Override + public void setAngles(TargetDummyEntity entity, float limbAngle, float limbDistance, float animationProgress, float headYaw, float headPitch) { + + } + + @Override + public void render(MatrixStack matrices, VertexConsumer vertices, int light, int overlay, float red, float green, float blue, float alpha) { + bone.render(matrices, vertices, light, overlay, red, green, blue, alpha); + } +} diff --git a/src/main/java/com/github/draylar/targetdummy/entity/TargetDummyRender.java b/src/main/java/draylar/targetdummy/entity/TargetDummyRender.java similarity index 73% rename from src/main/java/com/github/draylar/targetdummy/entity/TargetDummyRender.java rename to src/main/java/draylar/targetdummy/entity/TargetDummyRender.java index b53ea3e..8f056f3 100644 --- a/src/main/java/com/github/draylar/targetdummy/entity/TargetDummyRender.java +++ b/src/main/java/draylar/targetdummy/entity/TargetDummyRender.java @@ -1,19 +1,17 @@ -package com.github.draylar.targetdummy.entity; +package draylar.targetdummy.entity; import net.minecraft.client.render.entity.EntityRenderDispatcher; import net.minecraft.client.render.entity.MobEntityRenderer; import net.minecraft.util.Identifier; -public class TargetDummyRender extends MobEntityRenderer -{ - public TargetDummyRender(EntityRenderDispatcher entityRenderDispatcher_1) - { +public class TargetDummyRender extends MobEntityRenderer { + + public TargetDummyRender(EntityRenderDispatcher entityRenderDispatcher_1) { super(entityRenderDispatcher_1, new TargetDummyModel(), .5f); } @Override - protected Identifier getTexture(TargetDummyEntity targetDummyEntity) - { + public Identifier getTexture(TargetDummyEntity targetDummyEntity) { return new Identifier("target-dummy:textures/entity/target_dummy/target-dummy.png"); } } diff --git a/src/main/java/draylar/targetdummy/item/TargetDummyItem.java b/src/main/java/draylar/targetdummy/item/TargetDummyItem.java new file mode 100644 index 0000000..23266fb --- /dev/null +++ b/src/main/java/draylar/targetdummy/item/TargetDummyItem.java @@ -0,0 +1,43 @@ +package draylar.targetdummy.item; + +import draylar.targetdummy.TargetDummy; +import draylar.targetdummy.entity.TargetDummyEntity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemUsageContext; +import net.minecraft.util.ActionResult; +import net.minecraft.util.math.BlockPos; + +public class TargetDummyItem extends Item { + + public TargetDummyItem(Settings settings) { + super(settings); + } + + @Override + public ActionResult useOnBlock(ItemUsageContext context) { + if (!context.getWorld().isClient) { + PlayerEntity playerEntity = context.getPlayer(); + BlockPos blockPos = context.getBlockPos(); + + // set entity settings + TargetDummyEntity targetDummy = TargetDummy.TARGET_DUMMY.create(context.getWorld()); + targetDummy.setPos(Math.floor(blockPos.getX()) + .5, Math.floor(blockPos.getY()) + 1, Math.floor(blockPos.getZ()) + .5); + targetDummy.setHeadYaw(playerEntity.getHeadYaw() + 180); + if (targetDummy.getHeadYaw() > 180) + targetDummy.setHeadYaw(targetDummy.getHeadYaw() - 360); + + // spawn entity + context.getWorld().spawnEntity(targetDummy); + + // remove item + int index = playerEntity.inventory.selectedSlot; + ItemStack currentStack = context.getStack(); + currentStack.setCount(currentStack.getCount() - 1); + playerEntity.inventory.main.set(index, currentStack); + } + + return super.useOnBlock(context); + } +} \ No newline at end of file diff --git a/src/main/resources/assets/target-dummy/lang/en_us.json b/src/main/resources/assets/target-dummy/lang/en_us.json index 6d989f8..29c3106 100644 --- a/src/main/resources/assets/target-dummy/lang/en_us.json +++ b/src/main/resources/assets/target-dummy/lang/en_us.json @@ -1,3 +1,4 @@ { - "item.target-dummy.target_dummy": "Target Dummy" + "item.target-dummy.target_dummy": "Target Dummy", + "entity.target-dummy.target_dummy": "Target Dummy" } \ No newline at end of file diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 542daf4..0b8720a 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -1,7 +1,7 @@ { "schemaVersion": 1, "id": "target-dummy", - "version": "1.0.1", + "version": "${version}", "name": "Target Dummy", "description": "Adds in a Target Dummy to the game which tells you how much damage you're doing per hit.", @@ -9,16 +9,16 @@ "Draylar" ], - "license": "GPLv3", + "license": "MIT", "icon": "assets/target-dummy/icon.png", "environment": "*", "entrypoints": { "main": [ - "com.github.draylar.targetdummy.TargetDummy" + "draylar.targetdummy.TargetDummy" ], "client": [ - "com.github.draylar.targetdummy.TargetDummyClient" + "draylar.targetdummy.TargetDummyClient" ] },