Update Mappings Add Throwable Spawn Eggs
This commit is contained in:
parent
819c1a0577
commit
59a8c4c869
@ -1,4 +1,8 @@
|
||||
# Changelog
|
||||
|
||||
**1.0.1**
|
||||
* Update Mappings
|
||||
* Add Throwable Spawn Eggs
|
||||
|
||||
**1.0**
|
||||
* Initial Release
|
||||
|
@ -8,6 +8,7 @@ Suggest more tweaks in the issue tracker!
|
||||
* Use Respawn Anchor in Any Dimension
|
||||
* Instantly Kill In Creative Mode
|
||||
* Throwable Slimeballs
|
||||
* Throwable Spawn Eggs
|
||||
|
||||
## Changelog
|
||||
[View Changelog](CHANGELOG.md)
|
||||
|
@ -6,11 +6,11 @@ org.gradle.jvmargs = -Xmx1G
|
||||
minecraft_version = 20w12a
|
||||
curseforge_id = 368420
|
||||
simple_minecraft_version = 1.16-Snapshot
|
||||
yarn_build = 12
|
||||
fabric_loader_version = 0.7.8+build.187
|
||||
yarn_build = 14
|
||||
fabric_loader_version = 0.7.8+build.189
|
||||
|
||||
# Mod Properties
|
||||
mod_version = 1.0.0
|
||||
mod_version = 1.0.1
|
||||
maven_group = com.thebrokenrail
|
||||
archives_base_name = slightlyvanilla
|
||||
|
||||
|
@ -8,4 +8,5 @@ public class ModConfig implements ConfigData {
|
||||
public boolean useRespawnAnchorInAnyDimension = true;
|
||||
public boolean instantlyKillInCreative = true;
|
||||
public boolean throwableSlimeballs = true;
|
||||
public boolean throwableSpawnEggs = true;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.thebrokenrail.slightlyvanilla;
|
||||
|
||||
import com.thebrokenrail.slightlyvanilla.entity.SlimeballEntity;
|
||||
import com.thebrokenrail.slightlyvanilla.entity.SpawnEggEntity;
|
||||
import me.sargunvohra.mcmods.autoconfig1u.AutoConfig;
|
||||
import me.sargunvohra.mcmods.autoconfig1u.serializer.GsonConfigSerializer;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
@ -8,11 +9,14 @@ 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.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
||||
public class SlightlyVanilla implements ModInitializer {
|
||||
public static final String NAMESPACE = "slightlyvanilla";
|
||||
|
||||
public static EntityType<SlimeballEntity> SLIMEBALL_ENTITY;
|
||||
public static EntityType<SpawnEggEntity> SPAWN_EGG_ENTITY;
|
||||
|
||||
public static ModConfig getConfig() {
|
||||
return AutoConfig.getConfigHolder(ModConfig.class).getConfig();
|
||||
@ -23,5 +27,9 @@ public class SlightlyVanilla implements ModInitializer {
|
||||
AutoConfig.register(ModConfig.class, GsonConfigSerializer::new);
|
||||
|
||||
SLIMEBALL_ENTITY = FabricEntityTypeBuilder.create(EntityCategory.MISC, (EntityType.EntityFactory<SlimeballEntity>) SlimeballEntity::new).size(EntityDimensions.fixed(0.25f, 0.25f)).build();
|
||||
SPAWN_EGG_ENTITY = FabricEntityTypeBuilder.create(EntityCategory.MISC, (EntityType.EntityFactory<SpawnEggEntity>) SpawnEggEntity::new).size(EntityDimensions.fixed(0.25f, 0.25f)).build();
|
||||
|
||||
Registry.register(Registry.ENTITY_TYPE, new Identifier(NAMESPACE, "slimeball"), SLIMEBALL_ENTITY);
|
||||
Registry.register(Registry.ENTITY_TYPE, new Identifier(NAMESPACE, "spawn_egg"), SPAWN_EGG_ENTITY);
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.thebrokenrail.slightlyvanilla.client;
|
||||
import com.thebrokenrail.slightlyvanilla.SlightlyVanilla;
|
||||
import com.thebrokenrail.slightlyvanilla.ModConfig;
|
||||
import com.thebrokenrail.slightlyvanilla.entity.SlimeballEntity;
|
||||
import com.thebrokenrail.slightlyvanilla.entity.SpawnEggEntity;
|
||||
import io.github.prospector.modmenu.api.ConfigScreenFactory;
|
||||
import io.github.prospector.modmenu.api.ModMenuApi;
|
||||
import me.sargunvohra.mcmods.autoconfig1u.AutoConfig;
|
||||
@ -15,6 +16,7 @@ public class SlightlyVanillaClient implements ClientModInitializer, ModMenuApi {
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
EntityRendererRegistry.INSTANCE.register(SlightlyVanilla.SLIMEBALL_ENTITY, (entityRenderDispatcher, context) -> new FlyingItemEntityRenderer<SlimeballEntity>(entityRenderDispatcher, context.getItemRenderer()));
|
||||
EntityRendererRegistry.INSTANCE.register(SlightlyVanilla.SPAWN_EGG_ENTITY, (entityRenderDispatcher, context) -> new FlyingItemEntityRenderer<SpawnEggEntity>(entityRenderDispatcher, context.getItemRenderer()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -9,6 +9,7 @@ import net.minecraft.entity.projectile.thrown.ThrownItemEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.SpawnEggItem;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.packet.s2c.play.EntitySpawnS2CPacket;
|
||||
import net.minecraft.particle.ItemStackParticleEffect;
|
||||
@ -36,8 +37,7 @@ public class SlimeballEntity extends ThrownItemEntity {
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
private ParticleEffect getParticleParameters() {
|
||||
ItemStack itemStack = getItem();
|
||||
return itemStack.isEmpty() ? ParticleTypes.ITEM_SLIME : new ItemStackParticleEffect(ParticleTypes.ITEM, itemStack);
|
||||
return ParticleTypes.ITEM_SLIME;
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
|
@ -0,0 +1,69 @@
|
||||
package com.thebrokenrail.slightlyvanilla.entity;
|
||||
|
||||
import com.thebrokenrail.slightlyvanilla.SlightlyVanilla;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.SpawnType;
|
||||
import net.minecraft.entity.projectile.thrown.ThrownItemEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.SpawnEggItem;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.packet.s2c.play.EntitySpawnS2CPacket;
|
||||
import net.minecraft.particle.ItemStackParticleEffect;
|
||||
import net.minecraft.particle.ParticleEffect;
|
||||
import net.minecraft.particle.ParticleTypes;
|
||||
import net.minecraft.util.hit.HitResult;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class SpawnEggEntity extends ThrownItemEntity {
|
||||
public SpawnEggEntity(EntityType<SpawnEggEntity> entityType, World world) {
|
||||
super(entityType, world);
|
||||
}
|
||||
|
||||
public SpawnEggEntity(World world, LivingEntity owner) {
|
||||
super(SlightlyVanilla.SPAWN_EGG_ENTITY, owner, world);
|
||||
}
|
||||
|
||||
public SpawnEggEntity(World world, double x, double y, double z) {
|
||||
super(SlightlyVanilla.SPAWN_EGG_ENTITY, x, y, z, world);
|
||||
}
|
||||
|
||||
protected Item getDefaultItem() {
|
||||
return Items.PIG_SPAWN_EGG;
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
private ParticleEffect getParticleParameters() {
|
||||
return new ItemStackParticleEffect(ParticleTypes.ITEM, getStack());
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public void handleStatus(byte status) {
|
||||
if (status == 3) {
|
||||
ParticleEffect particleEffect = getParticleParameters();
|
||||
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
world.addParticle(particleEffect, getX(), getY(), getZ(), 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void onCollision(HitResult hitResult) {
|
||||
super.onCollision(hitResult);
|
||||
if (!world.isClient()) {
|
||||
world.sendEntityStatus(this, (byte) 3);
|
||||
EntityType<?> entityType = ((SpawnEggItem) getStack().getItem()).getEntityType(getStack().getTag());
|
||||
entityType.spawnFromItemStack(world, getItem(), null, getBlockPos(), SpawnType.SPAWN_EGG, false, false);
|
||||
remove();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet<?> createSpawnPacket() {
|
||||
return new EntitySpawnS2CPacket(this);
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@ package com.thebrokenrail.slightlyvanilla.mixin;
|
||||
|
||||
import com.thebrokenrail.slightlyvanilla.SlightlyVanilla;
|
||||
import com.thebrokenrail.slightlyvanilla.entity.SlimeballEntity;
|
||||
import com.thebrokenrail.slightlyvanilla.entity.SpawnEggEntity;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.entity.Entity;
|
||||
@ -26,6 +27,8 @@ public class MixinClientPlayNetworkHandler {
|
||||
|
||||
if (entityType == SlightlyVanilla.SLIMEBALL_ENTITY) {
|
||||
entity = new SlimeballEntity(world, packet.getX(), packet.getY(), packet.getZ());
|
||||
} else if (entityType == SlightlyVanilla.SPAWN_EGG_ENTITY) {
|
||||
entity = new SpawnEggEntity(world, packet.getX(), packet.getY(), packet.getZ());
|
||||
}
|
||||
|
||||
if (entity != null) {
|
||||
|
@ -15,6 +15,7 @@ import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Mixin(Item.class)
|
||||
public class MixinItem {
|
||||
@Inject(at = @At("HEAD"), method = "use", cancellable = true)
|
||||
|
@ -10,6 +10,7 @@ import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Mixin(PlayerEntity.class)
|
||||
public class MixinPlayerEntity {
|
||||
@Inject(at = @At("HEAD"), method = "attack", cancellable = true)
|
||||
|
@ -8,6 +8,7 @@ import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Mixin(RespawnAnchorBlock.class)
|
||||
public class MixinRespawnAnchorBlock {
|
||||
@Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/world/dimension/Dimension;getType()Lnet/minecraft/world/dimension/DimensionType;", ordinal = 0), method = "onUse")
|
||||
|
@ -0,0 +1,33 @@
|
||||
package com.thebrokenrail.slightlyvanilla.mixin;
|
||||
|
||||
import com.thebrokenrail.slightlyvanilla.SlightlyVanilla;
|
||||
import com.thebrokenrail.slightlyvanilla.entity.SpawnEggEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.SpawnEggItem;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.TypedActionResult;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Mixin(SpawnEggItem.class)
|
||||
public class MixinSpawnEggItem {
|
||||
@Inject(at = @At("RETURN"), method = "use", cancellable = true)
|
||||
public void use(World world, PlayerEntity user, Hand hand, CallbackInfoReturnable<TypedActionResult<ItemStack>> info) {
|
||||
if (SlightlyVanilla.getConfig().throwableSpawnEggs && info.getReturnValue().getResult() == ActionResult.PASS) {
|
||||
ItemStack stack = user.getStackInHand(hand);
|
||||
if (!world.isClient()) {
|
||||
SpawnEggEntity entity = new SpawnEggEntity(world, user);
|
||||
entity.setItem(stack);
|
||||
entity.setProperties(user, user.pitch, user.yaw, 0.0f, 1.5f, 1.0f);
|
||||
world.spawnEntity(entity);
|
||||
}
|
||||
info.setReturnValue(new TypedActionResult<>(ActionResult.SUCCESS, stack));
|
||||
}
|
||||
}
|
||||
}
|
@ -2,5 +2,7 @@
|
||||
"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.throwableSlimeballs": "Throwable Slimeballs"
|
||||
"text.autoconfig.slightlyvanilla.option.throwableSlimeballs": "Throwable Slimeballs",
|
||||
"entity.slightlyvanilla.slimeball": "Slimeball",
|
||||
"entity.slightlyvanilla.spawn_egg": "Spawn Egg"
|
||||
}
|
@ -8,7 +8,8 @@
|
||||
"mixins": [
|
||||
"MixinRespawnAnchorBlock",
|
||||
"MixinPlayerEntity",
|
||||
"MixinItem"
|
||||
"MixinItem",
|
||||
"MixinSpawnEggItem"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
Reference in New Issue
Block a user