Update Dispenser Behavior
This commit is contained in:
parent
36f1f31bad
commit
bc7c87aeab
@ -1,5 +1,8 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
**1.0.3**
|
||||||
|
* Update Dispenser Behavior
|
||||||
|
|
||||||
**1.0.2**
|
**1.0.2**
|
||||||
* Allow Shooting Slimeballs from Dispensers
|
* Allow Shooting Slimeballs from Dispensers
|
||||||
* Update Lang
|
* Update Lang
|
||||||
|
@ -6,7 +6,7 @@ Suggest more tweaks in the issue tracker!
|
|||||||
|
|
||||||
## Tweaks
|
## Tweaks
|
||||||
* Use Respawn Anchor in Any Dimension
|
* Use Respawn Anchor in Any Dimension
|
||||||
* Instantly Kill In Creative Mode
|
* Instant Kill In Creative Mode
|
||||||
* Throwable Slimeballs
|
* Throwable Slimeballs
|
||||||
* Throwable Spawn Eggs
|
* Throwable Spawn Eggs
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ org.gradle.jvmargs = -Xmx1G
|
|||||||
fabric_loader_version = 0.7.8+build.189
|
fabric_loader_version = 0.7.8+build.189
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version = 1.0.2
|
mod_version = 1.0.3
|
||||||
maven_group = com.thebrokenrail
|
maven_group = com.thebrokenrail
|
||||||
archives_base_name = slightlyvanilla
|
archives_base_name = slightlyvanilla
|
||||||
|
|
||||||
|
@ -2,11 +2,24 @@ package com.thebrokenrail.slightlyvanilla;
|
|||||||
|
|
||||||
import me.sargunvohra.mcmods.autoconfig1u.ConfigData;
|
import me.sargunvohra.mcmods.autoconfig1u.ConfigData;
|
||||||
import me.sargunvohra.mcmods.autoconfig1u.annotation.Config;
|
import me.sargunvohra.mcmods.autoconfig1u.annotation.Config;
|
||||||
|
import me.sargunvohra.mcmods.autoconfig1u.annotation.ConfigEntry;
|
||||||
|
|
||||||
@Config(name = SlightlyVanilla.NAMESPACE)
|
@Config(name = SlightlyVanilla.NAMESPACE)
|
||||||
public class ModConfig implements ConfigData {
|
public class ModConfig implements ConfigData {
|
||||||
public boolean useRespawnAnchorInAnyDimension = true;
|
public boolean useRespawnAnchorInAnyDimension = true;
|
||||||
public boolean instantKillInCreative = true;
|
public boolean instantKillInCreative = true;
|
||||||
public boolean throwableSlimeballs = true;
|
@ConfigEntry.Gui.CollapsibleObject(startExpanded = true)
|
||||||
public boolean throwableSpawnEggs = true;
|
public ThrowableOption throwableSlimeballs = new ThrowableOption(true, true);
|
||||||
|
@ConfigEntry.Gui.CollapsibleObject(startExpanded = true)
|
||||||
|
public ThrowableOption throwableSpawnEggs = new ThrowableOption(true, false);
|
||||||
|
|
||||||
|
public static class ThrowableOption {
|
||||||
|
public boolean player;
|
||||||
|
public boolean dispenser;
|
||||||
|
|
||||||
|
private ThrowableOption(boolean player, boolean dispenser) {
|
||||||
|
this.player = player;
|
||||||
|
this.dispenser = dispenser;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,17 +7,19 @@ import me.sargunvohra.mcmods.autoconfig1u.serializer.GsonConfigSerializer;
|
|||||||
import net.fabricmc.api.ModInitializer;
|
import net.fabricmc.api.ModInitializer;
|
||||||
import net.fabricmc.fabric.api.entity.FabricEntityTypeBuilder;
|
import net.fabricmc.fabric.api.entity.FabricEntityTypeBuilder;
|
||||||
import net.minecraft.block.DispenserBlock;
|
import net.minecraft.block.DispenserBlock;
|
||||||
import net.minecraft.block.dispenser.DispenserBehavior;
|
|
||||||
import net.minecraft.block.dispenser.ItemDispenserBehavior;
|
import net.minecraft.block.dispenser.ItemDispenserBehavior;
|
||||||
import net.minecraft.block.dispenser.ProjectileDispenserBehavior;
|
import net.minecraft.block.dispenser.ProjectileDispenserBehavior;
|
||||||
import net.minecraft.entity.EntityCategory;
|
import net.minecraft.entity.EntityCategory;
|
||||||
import net.minecraft.entity.EntityDimensions;
|
import net.minecraft.entity.EntityDimensions;
|
||||||
import net.minecraft.entity.EntityType;
|
import net.minecraft.entity.EntityType;
|
||||||
|
import net.minecraft.entity.SpawnType;
|
||||||
import net.minecraft.entity.projectile.ProjectileEntity;
|
import net.minecraft.entity.projectile.ProjectileEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.Items;
|
import net.minecraft.item.Items;
|
||||||
|
import net.minecraft.item.SpawnEggItem;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.math.BlockPointer;
|
import net.minecraft.util.math.BlockPointer;
|
||||||
|
import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.util.math.Position;
|
import net.minecraft.util.math.Position;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.util.registry.Registry;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
@ -43,7 +45,7 @@ public class SlightlyVanilla implements ModInitializer {
|
|||||||
Registry.register(Registry.ENTITY_TYPE, new Identifier(NAMESPACE, "spawn_egg"), SPAWN_EGG_ENTITY);
|
Registry.register(Registry.ENTITY_TYPE, new Identifier(NAMESPACE, "spawn_egg"), SPAWN_EGG_ENTITY);
|
||||||
|
|
||||||
DispenserBlock.registerBehavior(Items.SLIME_BALL, (pointer, stack) -> {
|
DispenserBlock.registerBehavior(Items.SLIME_BALL, (pointer, stack) -> {
|
||||||
if (getConfig().throwableSlimeballs) {
|
if (getConfig().throwableSlimeballs.dispenser) {
|
||||||
return new ProjectileDispenserBehavior() {
|
return new ProjectileDispenserBehavior() {
|
||||||
@Override
|
@Override
|
||||||
protected ProjectileEntity createProjectile(World position, Position stack, ItemStack itemStack) {
|
protected ProjectileEntity createProjectile(World position, Position stack, ItemStack itemStack) {
|
||||||
@ -56,5 +58,31 @@ public class SlightlyVanilla implements ModInitializer {
|
|||||||
return new ItemDispenserBehavior().dispense(pointer, stack);
|
return new ItemDispenserBehavior().dispense(pointer, stack);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
for (SpawnEggItem spawnEgg : SpawnEggItem.getAll()) {
|
||||||
|
DispenserBlock.registerBehavior(spawnEgg, (pointer, stack) -> {
|
||||||
|
if (getConfig().throwableSpawnEggs.dispenser) {
|
||||||
|
return new ProjectileDispenserBehavior() {
|
||||||
|
@Override
|
||||||
|
protected ProjectileEntity createProjectile(World position, Position stack, ItemStack itemStack) {
|
||||||
|
SpawnEggEntity entity = new SpawnEggEntity(position, stack.getX(), stack.getY(), stack.getZ());
|
||||||
|
entity.setItem(itemStack);
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
}.dispense(pointer, stack);
|
||||||
|
} else {
|
||||||
|
return new ItemDispenserBehavior() {
|
||||||
|
@Override
|
||||||
|
protected ItemStack dispenseSilently(BlockPointer pointer, ItemStack stack) {
|
||||||
|
Direction direction = pointer.getBlockState().get(DispenserBlock.FACING);
|
||||||
|
EntityType<?> entityType = ((SpawnEggItem)stack.getItem()).getEntityType(stack.getTag());
|
||||||
|
entityType.spawnFromItemStack(pointer.getWorld(), stack, null, pointer.getBlockPos().offset(direction), SpawnType.DISPENSER, direction != Direction.UP, false);
|
||||||
|
stack.decrement(1);
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
}.dispense(pointer, stack);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.thebrokenrail.slightlyvanilla.client;
|
package com.thebrokenrail.slightlyvanilla.client;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import com.thebrokenrail.slightlyvanilla.SlightlyVanilla;
|
import com.thebrokenrail.slightlyvanilla.SlightlyVanilla;
|
||||||
import com.thebrokenrail.slightlyvanilla.ModConfig;
|
import com.thebrokenrail.slightlyvanilla.ModConfig;
|
||||||
import com.thebrokenrail.slightlyvanilla.entity.SlimeballEntity;
|
import com.thebrokenrail.slightlyvanilla.entity.SlimeballEntity;
|
||||||
|
@ -8,7 +8,6 @@ import net.minecraft.entity.LivingEntity;
|
|||||||
import net.minecraft.entity.SpawnType;
|
import net.minecraft.entity.SpawnType;
|
||||||
import net.minecraft.entity.projectile.thrown.ThrownItemEntity;
|
import net.minecraft.entity.projectile.thrown.ThrownItemEntity;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.item.Items;
|
import net.minecraft.item.Items;
|
||||||
import net.minecraft.item.SpawnEggItem;
|
import net.minecraft.item.SpawnEggItem;
|
||||||
import net.minecraft.network.Packet;
|
import net.minecraft.network.Packet;
|
||||||
|
@ -21,7 +21,7 @@ public class MixinItem {
|
|||||||
@Inject(at = @At("HEAD"), method = "use", cancellable = true)
|
@Inject(at = @At("HEAD"), method = "use", cancellable = true)
|
||||||
public void use(World world, PlayerEntity playerEntity, Hand hand, CallbackInfoReturnable<TypedActionResult<ItemStack>> info) {
|
public void use(World world, PlayerEntity playerEntity, Hand hand, CallbackInfoReturnable<TypedActionResult<ItemStack>> info) {
|
||||||
ItemStack stack = playerEntity.getStackInHand(hand);
|
ItemStack stack = playerEntity.getStackInHand(hand);
|
||||||
if (stack.getItem() == Items.SLIME_BALL && SlightlyVanilla.getConfig().throwableSlimeballs) {
|
if (stack.getItem() == Items.SLIME_BALL && SlightlyVanilla.getConfig().throwableSlimeballs.player) {
|
||||||
if (!world.isClient()) {
|
if (!world.isClient()) {
|
||||||
SlimeballEntity entity = new SlimeballEntity(world, playerEntity);
|
SlimeballEntity entity = new SlimeballEntity(world, playerEntity);
|
||||||
entity.setItem(stack);
|
entity.setItem(stack);
|
||||||
|
@ -19,7 +19,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|||||||
public class MixinSpawnEggItem {
|
public class MixinSpawnEggItem {
|
||||||
@Inject(at = @At("RETURN"), method = "use", cancellable = true)
|
@Inject(at = @At("RETURN"), method = "use", cancellable = true)
|
||||||
public void use(World world, PlayerEntity user, Hand hand, CallbackInfoReturnable<TypedActionResult<ItemStack>> info) {
|
public void use(World world, PlayerEntity user, Hand hand, CallbackInfoReturnable<TypedActionResult<ItemStack>> info) {
|
||||||
if (SlightlyVanilla.getConfig().throwableSpawnEggs && info.getReturnValue().getResult() == ActionResult.PASS) {
|
if (SlightlyVanilla.getConfig().throwableSpawnEggs.player && info.getReturnValue().getResult() == ActionResult.PASS) {
|
||||||
ItemStack stack = user.getStackInHand(hand);
|
ItemStack stack = user.getStackInHand(hand);
|
||||||
if (!world.isClient()) {
|
if (!world.isClient()) {
|
||||||
SpawnEggEntity entity = new SpawnEggEntity(world, user);
|
SpawnEggEntity entity = new SpawnEggEntity(world, user);
|
||||||
|
@ -3,7 +3,11 @@
|
|||||||
"text.autoconfig.slightlyvanilla.option.useRespawnAnchorInAnyDimension": "Use Respawn Anchor In Any Dimension",
|
"text.autoconfig.slightlyvanilla.option.useRespawnAnchorInAnyDimension": "Use Respawn Anchor In Any Dimension",
|
||||||
"text.autoconfig.slightlyvanilla.option.instantKillInCreative": "Instant 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.throwableSlimeballs": "Throwable Slimeballs",
|
||||||
|
"text.autoconfig.slightlyvanilla.option.throwableSlimeballs.player": "Player",
|
||||||
|
"text.autoconfig.slightlyvanilla.option.throwableSlimeballs.dispenser": "Dispenser",
|
||||||
"text.autoconfig.slightlyvanilla.option.throwableSpawnEggs": "Throwable Spawn Eggs",
|
"text.autoconfig.slightlyvanilla.option.throwableSpawnEggs": "Throwable Spawn Eggs",
|
||||||
|
"text.autoconfig.slightlyvanilla.option.throwableSpawnEggs.player": "Player",
|
||||||
|
"text.autoconfig.slightlyvanilla.option.throwableSpawnEggs.dispenser": "Dispenser",
|
||||||
"entity.slightlyvanilla.slimeball": "Slimeball",
|
"entity.slightlyvanilla.slimeball": "Slimeball",
|
||||||
"entity.slightlyvanilla.spawn_egg": "Spawn Egg"
|
"entity.slightlyvanilla.spawn_egg": "Spawn Egg"
|
||||||
}
|
}
|
Reference in New Issue
Block a user