From 36f1f31bad99b03dea7a8bf1c6d6ace9f61a72fb Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Thu, 19 Mar 2020 18:03:42 -0400 Subject: [PATCH] 1.0.2 Allow Shooting Slimeballs from Dispensers Update Lang --- CHANGELOG.md | 4 +++ gradle.properties | 2 +- .../slightlyvanilla/ModConfig.java | 2 +- .../slightlyvanilla/SlightlyVanilla.java | 25 +++++++++++++++++++ .../mixin/MixinPlayerEntity.java | 2 +- .../assets/slightlyvanilla/lang/en_us.json | 3 ++- 6 files changed, 34 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e28982..63f300b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +**1.0.2** +* Allow Shooting Slimeballs from Dispensers +* Update Lang + **1.0.1** * Update Mappings * Add Throwable Spawn Eggs diff --git a/gradle.properties b/gradle.properties index 4bf903f..816bb11 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,7 +10,7 @@ org.gradle.jvmargs = -Xmx1G fabric_loader_version = 0.7.8+build.189 # Mod Properties - mod_version = 1.0.1 + mod_version = 1.0.2 maven_group = com.thebrokenrail archives_base_name = slightlyvanilla diff --git a/src/main/java/com/thebrokenrail/slightlyvanilla/ModConfig.java b/src/main/java/com/thebrokenrail/slightlyvanilla/ModConfig.java index 5010fa5..3384c5e 100644 --- a/src/main/java/com/thebrokenrail/slightlyvanilla/ModConfig.java +++ b/src/main/java/com/thebrokenrail/slightlyvanilla/ModConfig.java @@ -6,7 +6,7 @@ import me.sargunvohra.mcmods.autoconfig1u.annotation.Config; @Config(name = SlightlyVanilla.NAMESPACE) public class ModConfig implements ConfigData { public boolean useRespawnAnchorInAnyDimension = true; - public boolean instantlyKillInCreative = true; + public boolean instantKillInCreative = true; public boolean throwableSlimeballs = true; public boolean throwableSpawnEggs = true; } diff --git a/src/main/java/com/thebrokenrail/slightlyvanilla/SlightlyVanilla.java b/src/main/java/com/thebrokenrail/slightlyvanilla/SlightlyVanilla.java index 41a9c96..cb35466 100644 --- a/src/main/java/com/thebrokenrail/slightlyvanilla/SlightlyVanilla.java +++ b/src/main/java/com/thebrokenrail/slightlyvanilla/SlightlyVanilla.java @@ -6,11 +6,21 @@ import me.sargunvohra.mcmods.autoconfig1u.AutoConfig; import me.sargunvohra.mcmods.autoconfig1u.serializer.GsonConfigSerializer; import net.fabricmc.api.ModInitializer; import net.fabricmc.fabric.api.entity.FabricEntityTypeBuilder; +import net.minecraft.block.DispenserBlock; +import net.minecraft.block.dispenser.DispenserBehavior; +import net.minecraft.block.dispenser.ItemDispenserBehavior; +import net.minecraft.block.dispenser.ProjectileDispenserBehavior; import net.minecraft.entity.EntityCategory; import net.minecraft.entity.EntityDimensions; import net.minecraft.entity.EntityType; +import net.minecraft.entity.projectile.ProjectileEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; import net.minecraft.util.Identifier; +import net.minecraft.util.math.BlockPointer; +import net.minecraft.util.math.Position; import net.minecraft.util.registry.Registry; +import net.minecraft.world.World; public class SlightlyVanilla implements ModInitializer { public static final String NAMESPACE = "slightlyvanilla"; @@ -31,5 +41,20 @@ public class SlightlyVanilla implements ModInitializer { Registry.register(Registry.ENTITY_TYPE, new Identifier(NAMESPACE, "slimeball"), SLIMEBALL_ENTITY); Registry.register(Registry.ENTITY_TYPE, new Identifier(NAMESPACE, "spawn_egg"), SPAWN_EGG_ENTITY); + + DispenserBlock.registerBehavior(Items.SLIME_BALL, (pointer, stack) -> { + if (getConfig().throwableSlimeballs) { + return new ProjectileDispenserBehavior() { + @Override + protected ProjectileEntity createProjectile(World position, Position stack, ItemStack itemStack) { + SlimeballEntity entity = new SlimeballEntity(position, stack.getX(), stack.getY(), stack.getZ()); + entity.setItem(itemStack); + return entity; + } + }.dispense(pointer, stack); + } else { + return new ItemDispenserBehavior().dispense(pointer, stack); + } + }); } } diff --git a/src/main/java/com/thebrokenrail/slightlyvanilla/mixin/MixinPlayerEntity.java b/src/main/java/com/thebrokenrail/slightlyvanilla/mixin/MixinPlayerEntity.java index a1cb1ea..7dbaffb 100644 --- a/src/main/java/com/thebrokenrail/slightlyvanilla/mixin/MixinPlayerEntity.java +++ b/src/main/java/com/thebrokenrail/slightlyvanilla/mixin/MixinPlayerEntity.java @@ -15,7 +15,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; public class MixinPlayerEntity { @Inject(at = @At("HEAD"), method = "attack", cancellable = true) public void attack(Entity target, CallbackInfo info) { - if (SlightlyVanilla.getConfig().instantlyKillInCreative && target.isAttackable()) { + if (SlightlyVanilla.getConfig().instantKillInCreative && target.isAttackable()) { if (target instanceof EnderDragonPart) { target = ((EnderDragonPart)target).owner; } diff --git a/src/main/resources/assets/slightlyvanilla/lang/en_us.json b/src/main/resources/assets/slightlyvanilla/lang/en_us.json index 3c74eb5..62bbcb7 100644 --- a/src/main/resources/assets/slightlyvanilla/lang/en_us.json +++ b/src/main/resources/assets/slightlyvanilla/lang/en_us.json @@ -1,8 +1,9 @@ { "text.autoconfig.slightlyvanilla.title": "SlightlyVanilla Tweaks", "text.autoconfig.slightlyvanilla.option.useRespawnAnchorInAnyDimension": "Use Respawn Anchor In Any Dimension", - "text.autoconfig.slightlyvanilla.option.instantlyKillInCreative": "Instantly Kill In Creative Mode", + "text.autoconfig.slightlyvanilla.option.instantKillInCreative": "Instant Kill In Creative Mode", "text.autoconfig.slightlyvanilla.option.throwableSlimeballs": "Throwable Slimeballs", + "text.autoconfig.slightlyvanilla.option.throwableSpawnEggs": "Throwable Spawn Eggs", "entity.slightlyvanilla.slimeball": "Slimeball", "entity.slightlyvanilla.spawn_egg": "Spawn Egg" } \ No newline at end of file