Compare commits
14 Commits
Author | SHA1 | Date | |
---|---|---|---|
3a323ad3f9 | |||
dd4694ec40 | |||
e04dc6ffe2 | |||
a1b67ed622 | |||
e7f639092b | |||
dc61f79b95 | |||
f3ea21bea5 | |||
b6614da325 | |||
ed494fd52a | |||
8342ef83ec | |||
f030fce712 | |||
6fa51c4650 | |||
cabf4162ca | |||
c82406bb47 |
10
CHANGELOG.md
10
CHANGELOG.md
@ -1,5 +1,15 @@
|
||||
# Changelog
|
||||
|
||||
**1.0.12**
|
||||
* Allow Disabling Beds Setting Spawn
|
||||
|
||||
**1.0.11**
|
||||
* Fix Loading On Client Without ModMenu
|
||||
* Fix Loading On Server
|
||||
|
||||
**1.0.10**
|
||||
* Add Note Block Screen Tweak
|
||||
|
||||
**1.0.9**
|
||||
* Disable Instant Nether Portal In Creative
|
||||
|
||||
|
12
Jenkinsfile
vendored
12
Jenkinsfile
vendored
@ -15,5 +15,17 @@ pipeline {
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Publish') {
|
||||
when {
|
||||
expression {
|
||||
return sh(returnStdout: true, script: 'git tag --contains').trim().length() > 0
|
||||
}
|
||||
}
|
||||
steps {
|
||||
withCredentials([string(credentialsId: 'curseforge_key', variable: 'CURSEFORGE_KEY')]) {
|
||||
sh './gradlew -Pcurseforge.api_key="${CURSEFORGE_KEY}" curseforge'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ Suggest more tweaks in the issue tracker!
|
||||
* Crying Obsidian Nether Portal
|
||||
* Allow Leashing Villagers
|
||||
* Disable Instant Nether Portal In Creative
|
||||
* Add Note Block Screen
|
||||
|
||||
## Changelog
|
||||
[View Changelog](CHANGELOG.md)
|
||||
|
12
build.gradle
12
build.gradle
@ -1,5 +1,5 @@
|
||||
plugins {
|
||||
id 'fabric-loom' version '0.2.7-SNAPSHOT'
|
||||
id 'fabric-loom' version '0.4-SNAPSHOT'
|
||||
id 'com.matthewprenger.cursegradle' version '1.4.0'
|
||||
}
|
||||
|
||||
@ -31,18 +31,18 @@ dependencies {
|
||||
|
||||
modImplementation "me.shedaniel.cloth:config-2:${project.cloth_config_version}"
|
||||
include "me.shedaniel.cloth:config-2:${project.cloth_config_version}"
|
||||
modImplementation "me.sargunvohra.mcmods:autoconfig1u:${project.auto_config_version}"
|
||||
include "me.sargunvohra.mcmods:autoconfig1u:${project.auto_config_version}"
|
||||
modImplementation "io.github.prospector:modmenu:${project.mod_menu_version}"
|
||||
modImplementation "me.sargunvohra.mcmods:autoconfig1u:${project.autoconfig_version}"
|
||||
include "me.sargunvohra.mcmods:autoconfig1u:${project.autoconfig_version}"
|
||||
modImplementation "io.github.prospector:modmenu:${project.modmenu_version}"
|
||||
}
|
||||
|
||||
processResources {
|
||||
inputs.property 'version', mod_version
|
||||
inputs.property 'version', project.version
|
||||
inputs.property 'name', rootProject.name
|
||||
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
include 'fabric.mod.json'
|
||||
expand 'version': mod_version, 'name': rootProject.name
|
||||
expand 'version': project.version, 'name': rootProject.name
|
||||
}
|
||||
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
|
@ -3,20 +3,20 @@ org.gradle.jvmargs = -Xmx1G
|
||||
|
||||
# Fabric Properties
|
||||
# check these on https://fabricmc.net/use
|
||||
minecraft_version = 20w12a
|
||||
minecraft_version = 1.16.4
|
||||
curseforge_id = 368420
|
||||
simple_minecraft_version = 1.16-Snapshot
|
||||
yarn_build = 18
|
||||
fabric_loader_version = 0.7.8+build.189
|
||||
simple_minecraft_version = 1.16.4
|
||||
yarn_build = 7
|
||||
fabric_loader_version = 0.10.8
|
||||
|
||||
# Mod Properties
|
||||
mod_version = 1.0.9
|
||||
mod_version = 1.0.12
|
||||
maven_group = com.thebrokenrail
|
||||
archives_base_name = slightlyvanilla
|
||||
|
||||
# Dependencies
|
||||
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
|
||||
fabric_api_version = 0.5.5+build.311-1.16
|
||||
cloth_config_version = 3.1.0-unstable
|
||||
auto_config_version = 1.2.4
|
||||
mod_menu_version = 1.11.0+build.2
|
||||
fabric_api_version = 0.28.1+1.16
|
||||
modmenu_version = 1.14.6+build.31
|
||||
cloth_config_version = 4.7.0-unstable
|
||||
autoconfig_version = 3.2.0-unstable
|
||||
|
@ -3,6 +3,9 @@ package com.thebrokenrail.slightlyvanilla;
|
||||
import me.sargunvohra.mcmods.autoconfig1u.ConfigData;
|
||||
import me.sargunvohra.mcmods.autoconfig1u.annotation.Config;
|
||||
import me.sargunvohra.mcmods.autoconfig1u.annotation.ConfigEntry;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.gui.screen.ingame.GenericContainerScreen;
|
||||
|
||||
@Config(name = SlightlyVanilla.NAMESPACE)
|
||||
public class ModConfig implements ConfigData {
|
||||
@ -16,6 +19,9 @@ public class ModConfig implements ConfigData {
|
||||
public boolean cryingObsidianNetherPortal = true;
|
||||
public boolean allowLeashingVillagers = true;
|
||||
public boolean disableInstantNetherPortalInCreative = true;
|
||||
@Environment(EnvType.CLIENT)
|
||||
public boolean noteBlockScreen = true;
|
||||
public boolean bedsSetSpawn = true;
|
||||
|
||||
public static class ThrowableOption {
|
||||
public boolean player;
|
||||
|
@ -1,34 +1,27 @@
|
||||
package com.thebrokenrail.slightlyvanilla;
|
||||
|
||||
import com.thebrokenrail.slightlyvanilla.dispenser.SlimeballDispenserBehavior;
|
||||
import com.thebrokenrail.slightlyvanilla.dispenser.SpawnEggDispenserBehavior;
|
||||
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;
|
||||
import net.fabricmc.fabric.api.entity.FabricEntityTypeBuilder;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.entity.FabricEntityTypeBuilder;
|
||||
import net.fabricmc.fabric.api.tag.TagRegistry;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.DispenserBlock;
|
||||
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.SpawnType;
|
||||
import net.minecraft.entity.SpawnGroup;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.projectile.ProjectileEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.SpawnEggItem;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
import net.minecraft.tag.Tag;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPointer;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.Position;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@ -38,7 +31,7 @@ public class SlightlyVanilla implements ModInitializer {
|
||||
public static EntityType<SlimeballEntity> SLIMEBALL_ENTITY;
|
||||
public static EntityType<SpawnEggEntity> SPAWN_EGG_ENTITY;
|
||||
|
||||
public static final Tag<Block> EXTRA_PORTAL_BLOCKS_TAG = TagRegistry.block(new Identifier(NAMESPACE, "extra_portal_blocks"));
|
||||
public static final Tag<Block> NETHER_PORTAL_FRAME_BLOCKS_TAG = TagRegistry.block(new Identifier(NAMESPACE, "nether_portal_frame_blocks"));
|
||||
|
||||
public static ModConfig getConfig() {
|
||||
return AutoConfig.getConfigHolder(ModConfig.class).getConfig();
|
||||
@ -48,51 +41,16 @@ public class SlightlyVanilla implements ModInitializer {
|
||||
public void onInitialize() {
|
||||
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();
|
||||
SLIMEBALL_ENTITY = FabricEntityTypeBuilder.create(SpawnGroup.MISC, (EntityType.EntityFactory<SlimeballEntity>) SlimeballEntity::new).dimensions(new EntityDimensions(0.25f, 0.25f, true)).build();
|
||||
SPAWN_EGG_ENTITY = FabricEntityTypeBuilder.create(SpawnGroup.MISC, (EntityType.EntityFactory<SpawnEggEntity>) SpawnEggEntity::new).dimensions(new EntityDimensions(0.25f, 0.25f, true)).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);
|
||||
|
||||
DispenserBlock.registerBehavior(Items.SLIME_BALL, (pointer, stack) -> {
|
||||
if (getConfig().throwableSlimeballs.dispenser) {
|
||||
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);
|
||||
}
|
||||
});
|
||||
DispenserBlock.registerBehavior(Items.SLIME_BALL, new SlimeballDispenserBehavior());
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
DispenserBlock.registerBehavior(spawnEgg, new SpawnEggDispenserBehavior());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,18 @@
|
||||
package com.thebrokenrail.slightlyvanilla.client;
|
||||
|
||||
import com.thebrokenrail.slightlyvanilla.ModConfig;
|
||||
import io.github.prospector.modmenu.api.ConfigScreenFactory;
|
||||
import io.github.prospector.modmenu.api.ModMenuApi;
|
||||
import me.sargunvohra.mcmods.autoconfig1u.AutoConfig;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class ModMenu implements ModMenuApi {
|
||||
@Override
|
||||
public ConfigScreenFactory<?> getModConfigScreenFactory() {
|
||||
return (ConfigScreenFactory<Screen>) screen -> AutoConfig.getConfigScreen(ModConfig.class, screen).get();
|
||||
}
|
||||
}
|
@ -1,35 +1,20 @@
|
||||
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;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.render.entity.FlyingItemEntityRenderer;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class SlightlyVanillaClient implements ClientModInitializer, ModMenuApi {
|
||||
public class SlightlyVanillaClient implements ClientModInitializer {
|
||||
@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
|
||||
public String getModId() {
|
||||
return SlightlyVanilla.NAMESPACE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigScreenFactory<?> getModConfigScreenFactory() {
|
||||
return (ConfigScreenFactory<Screen>) screen -> AutoConfig.getConfigScreen(ModConfig.class, screen).get();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,144 @@
|
||||
package com.thebrokenrail.slightlyvanilla.client.screen;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.thebrokenrail.slightlyvanilla.SlightlyVanilla;
|
||||
import com.thebrokenrail.slightlyvanilla.mixin.ScreenHandlerAccessor;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.widget.SliderWidget;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.network.packet.c2s.play.PlayerInteractBlockC2SPacket;
|
||||
import net.minecraft.screen.ScreenHandlerContext;
|
||||
import net.minecraft.state.property.Properties;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class NoteBlockScreen extends Screen {
|
||||
private static class NoteSliderWidget extends SliderWidget {
|
||||
private final ScreenHandlerContext context;
|
||||
|
||||
public NoteSliderWidget(ScreenHandlerContext context, int x, int y, int width, int height) {
|
||||
super(x, y, width, height, LiteralText.EMPTY, (double) getNote(context) / getMax());
|
||||
this.context = context;
|
||||
updateMessage();
|
||||
}
|
||||
|
||||
private static double getMax() {
|
||||
return (double) Properties.NOTE.getValues().size() - 1;
|
||||
}
|
||||
|
||||
@SuppressWarnings("OptionalGetWithoutIsPresent")
|
||||
private static int getNote(ScreenHandlerContext context) {
|
||||
return context.run((BiFunction<World, BlockPos, Integer>) (world, pos) -> world.getBlockState(pos).get(Properties.NOTE)).get();
|
||||
}
|
||||
|
||||
private int toNote() {
|
||||
return (int) (value * getMax());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateMessage() {
|
||||
int note = toNote();
|
||||
setMessage(new TranslatableText("text." + SlightlyVanilla.NAMESPACE + ".noteblock_screen_slider", note, new TranslatableText("text." + SlightlyVanilla.NAMESPACE + ".noteblock_note." + note)));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyValue() {
|
||||
context.run((world, blockPos) -> {
|
||||
BlockState target = world.getBlockState(blockPos);
|
||||
|
||||
int currentNote = target.get(Properties.NOTE);
|
||||
int targetNote = toNote();
|
||||
|
||||
int amount;
|
||||
if (targetNote >= currentNote) {
|
||||
amount = targetNote - currentNote;
|
||||
} else {
|
||||
amount = ((int) getMax()) - currentNote + 1 + targetNote;
|
||||
}
|
||||
|
||||
MinecraftClient client = MinecraftClient.getInstance();
|
||||
assert client != null;
|
||||
assert client.getNetworkHandler() != null;
|
||||
|
||||
BlockHitResult hitResult = new BlockHitResult(Vec3d.ofCenter(blockPos), Direction.UP, blockPos, false);
|
||||
for (int i = 0; i < amount; i++) {
|
||||
client.getNetworkHandler().sendPacket(new PlayerInteractBlockC2SPacket(Hand.MAIN_HAND, hitResult));
|
||||
}
|
||||
|
||||
world.setBlockState(blockPos, target.with(Properties.NOTE, targetNote));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private static final Identifier TEXTURE = new Identifier(SlightlyVanilla.NAMESPACE, "textures/gui/noteblock.png");
|
||||
|
||||
private final ScreenHandlerContext context;
|
||||
|
||||
public NoteBlockScreen(ScreenHandlerContext context) {
|
||||
super(Blocks.NOTE_BLOCK.getName());
|
||||
passEvents = true;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
super.init();
|
||||
int sliderWidth = BACKGROUND_WIDTH - 36;
|
||||
int sliderHeight = 20;
|
||||
addButton(new NoteSliderWidget(context, width / 2 - sliderWidth / 2, (height / 2) - (sliderHeight / 2) + 4, sliderWidth, sliderHeight));
|
||||
}
|
||||
|
||||
private static final int BACKGROUND_WIDTH = 176;
|
||||
private static final int BACKGROUND_HEIGHT = 60;
|
||||
|
||||
private static final int TITLE_X_OFFSET = 8;
|
||||
private static final int TITLE_Y_OFFSEt = 6;
|
||||
|
||||
@Override
|
||||
public void renderBackground(MatrixStack matrices) {
|
||||
super.renderBackground(matrices);
|
||||
|
||||
//noinspection deprecation
|
||||
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
assert client != null;
|
||||
client.getTextureManager().bindTexture(TEXTURE);
|
||||
int centerX = width / 2;
|
||||
int centerY = height / 2;
|
||||
drawTexture(matrices, centerX - (BACKGROUND_WIDTH / 2), centerY - (BACKGROUND_HEIGHT / 2), 0, 0, BACKGROUND_WIDTH, BACKGROUND_HEIGHT);
|
||||
|
||||
int titleX = centerX - (BACKGROUND_WIDTH / 2) + TITLE_X_OFFSET;
|
||||
int titleY = centerY - (BACKGROUND_HEIGHT / 2) + TITLE_Y_OFFSEt;
|
||||
textRenderer.draw(matrices, title, titleX, titleY, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
|
||||
renderBackground(matrices);
|
||||
super.render(matrices, mouseX, mouseY, delta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
assert client != null;
|
||||
if (!ScreenHandlerAccessor.callCanUse(context, client.player, Blocks.NOTE_BLOCK)) {
|
||||
assert client.player != null;
|
||||
client.player.closeScreen();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package com.thebrokenrail.slightlyvanilla.dispenser;
|
||||
|
||||
import com.thebrokenrail.slightlyvanilla.SlightlyVanilla;
|
||||
import com.thebrokenrail.slightlyvanilla.entity.SlimeballEntity;
|
||||
import net.minecraft.block.dispenser.DispenserBehavior;
|
||||
import net.minecraft.block.dispenser.ItemDispenserBehavior;
|
||||
import net.minecraft.block.dispenser.ProjectileDispenserBehavior;
|
||||
import net.minecraft.entity.projectile.ProjectileEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPointer;
|
||||
import net.minecraft.util.math.Position;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class SlimeballDispenserBehavior implements DispenserBehavior {
|
||||
private static class Default extends ItemDispenserBehavior {
|
||||
}
|
||||
|
||||
private static class Modified extends 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;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack dispense(BlockPointer pointer, ItemStack stack) {
|
||||
if (SlightlyVanilla.getConfig().throwableSlimeballs.dispenser) {
|
||||
return new Modified().dispense(pointer, stack);
|
||||
} else {
|
||||
return new Default().dispense(pointer, stack);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package com.thebrokenrail.slightlyvanilla.dispenser;
|
||||
|
||||
import com.thebrokenrail.slightlyvanilla.SlightlyVanilla;
|
||||
import com.thebrokenrail.slightlyvanilla.entity.SpawnEggEntity;
|
||||
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.EntityType;
|
||||
import net.minecraft.entity.SpawnReason;
|
||||
import net.minecraft.entity.projectile.ProjectileEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.SpawnEggItem;
|
||||
import net.minecraft.util.math.BlockPointer;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.Position;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class SpawnEggDispenserBehavior implements DispenserBehavior {
|
||||
private static class Default extends 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), SpawnReason.DISPENSER, direction != Direction.UP, false);
|
||||
stack.decrement(1);
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
|
||||
private static class Modified extends 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;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack dispense(BlockPointer pointer, ItemStack stack) {
|
||||
if (SlightlyVanilla.getConfig().throwableSpawnEggs.dispenser) {
|
||||
return new Modified().dispense(pointer, stack);
|
||||
} else {
|
||||
return new Default().dispense(pointer, stack);
|
||||
}
|
||||
}
|
||||
}
|
@ -49,7 +49,7 @@ public class SlimeballEntity extends ThrownItemEntity {
|
||||
ParticleEffect particleEffect = getParticleParameters();
|
||||
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
world.addParticle(particleEffect, getX(), getY(), getZ(), 0.0D, 0.0D, 0.0D);
|
||||
getEntityWorld().addParticle(particleEffect, getX(), getY(), getZ(), 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -57,8 +57,8 @@ public class SlimeballEntity extends ThrownItemEntity {
|
||||
@Override
|
||||
protected void onCollision(HitResult hitResult) {
|
||||
super.onCollision(hitResult);
|
||||
if (!world.isClient()) {
|
||||
world.sendEntityStatus(this, (byte) 3);
|
||||
if (!getEntityWorld().isClient()) {
|
||||
getEntityWorld().sendEntityStatus(this, (byte) 3);
|
||||
remove();
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ 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.SpawnReason;
|
||||
import net.minecraft.entity.projectile.thrown.ThrownItemEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.Items;
|
||||
@ -15,6 +15,7 @@ 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.server.world.ServerWorld;
|
||||
import net.minecraft.util.hit.HitResult;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@ -52,7 +53,7 @@ public class SpawnEggEntity extends ThrownItemEntity {
|
||||
ParticleEffect particleEffect = getParticleParameters();
|
||||
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
world.addParticle(particleEffect, getX(), getY(), getZ(), 0.0D, 0.0D, 0.0D);
|
||||
getEntityWorld().addParticle(particleEffect, getX(), getY(), getZ(), 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -60,10 +61,10 @@ public class SpawnEggEntity extends ThrownItemEntity {
|
||||
@Override
|
||||
protected void onCollision(HitResult hitResult) {
|
||||
super.onCollision(hitResult);
|
||||
if (!world.isClient()) {
|
||||
world.sendEntityStatus(this, (byte) 3);
|
||||
if (!getEntityWorld().isClient()) {
|
||||
getEntityWorld().sendEntityStatus(this, (byte) 3);
|
||||
EntityType<?> entityType = ((SpawnEggItem) getStack().getItem()).getEntityType(getStack().getTag());
|
||||
entityType.spawnFromItemStack(world, getItem(), null, getBlockPos(), SpawnType.SPAWN_EGG, false, false);
|
||||
entityType.spawnFromItemStack((ServerWorld) getEntityWorld(), getItem(), null, getBlockPos(), SpawnReason.SPAWN_EGG, false, false);
|
||||
remove();
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package com.thebrokenrail.slightlyvanilla.mixin;
|
||||
|
||||
import com.thebrokenrail.slightlyvanilla.SlightlyVanilla;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.passive.AbstractTraderEntity;
|
||||
import net.minecraft.entity.passive.MerchantEntity;
|
||||
import net.minecraft.entity.passive.PassiveEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.world.World;
|
||||
@ -12,7 +12,7 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Mixin(AbstractTraderEntity.class)
|
||||
@Mixin(MerchantEntity.class)
|
||||
public abstract class MixinAbstractTraderEntity extends PassiveEntity {
|
||||
protected MixinAbstractTraderEntity(EntityType<? extends PassiveEntity> entityType, World world) {
|
||||
super(entityType, world);
|
||||
|
@ -0,0 +1,39 @@
|
||||
package com.thebrokenrail.slightlyvanilla.mixin;
|
||||
|
||||
import com.thebrokenrail.slightlyvanilla.SlightlyVanilla;
|
||||
import com.thebrokenrail.slightlyvanilla.client.screen.NoteBlockScreen;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import net.minecraft.client.network.ClientPlayerInteractionManager;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.screen.ScreenHandlerContext;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
@Mixin(ClientPlayerInteractionManager.class)
|
||||
public class MixinClientPlayerInteractionManager {
|
||||
@Shadow
|
||||
@Final
|
||||
private MinecraftClient client;
|
||||
|
||||
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;getStackInHand(Lnet/minecraft/util/Hand;)Lnet/minecraft/item/ItemStack;", ordinal = 0), method = "interactBlock", cancellable = true)
|
||||
public void interactBlock(ClientPlayerEntity player, ClientWorld world, Hand hand, BlockHitResult hitResult, CallbackInfoReturnable<ActionResult> info) {
|
||||
if (!player.isSpectator() && SlightlyVanilla.getConfig().noteBlockScreen && world.getBlockState(hitResult.getBlockPos()).getBlock() == Blocks.NOTE_BLOCK) {
|
||||
NoteBlockScreen screen = new NoteBlockScreen(ScreenHandlerContext.create(world, hitResult.getBlockPos()));
|
||||
client.openScreen(screen);
|
||||
|
||||
info.setReturnValue(ActionResult.SUCCESS);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,25 +1,22 @@
|
||||
package com.thebrokenrail.slightlyvanilla.mixin;
|
||||
|
||||
import com.thebrokenrail.slightlyvanilla.SlightlyVanilla;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.NetherPortalBlock;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.dimension.AreaHelper;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Mixin(NetherPortalBlock.AreaHelper.class)
|
||||
@Mixin(AreaHelper.class)
|
||||
public class MixinNetherPortalBlockAreaHelper {
|
||||
@SuppressWarnings("UnresolvedMixinReference")
|
||||
@Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;getBlock()Lnet/minecraft/block/Block;"), method = "*")
|
||||
public Block redirectBlock(BlockState state) {
|
||||
Block block = state.getBlock();
|
||||
if (block.isIn(SlightlyVanilla.EXTRA_PORTAL_BLOCKS_TAG) && SlightlyVanilla.getConfig().cryingObsidianNetherPortal) {
|
||||
return Blocks.OBSIDIAN;
|
||||
} else {
|
||||
return block;
|
||||
@Inject(at = @At("HEAD"), method = "method_30487", cancellable = true)
|
||||
private static void isValidFrameBlock(BlockState state, BlockView world, BlockPos pos, CallbackInfoReturnable<Boolean> info) {
|
||||
if (SlightlyVanilla.getConfig().cryingObsidianNetherPortal) {
|
||||
info.setReturnValue(state.isIn(SlightlyVanilla.NETHER_PORTAL_FRAME_BLOCKS_TAG));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,21 +2,31 @@ package com.thebrokenrail.slightlyvanilla.mixin;
|
||||
|
||||
import com.thebrokenrail.slightlyvanilla.SlightlyVanilla;
|
||||
import net.minecraft.block.RespawnAnchorBlock;
|
||||
import net.minecraft.world.dimension.Dimension;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
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.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@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")
|
||||
public DimensionType getDimension(Dimension dimension) {
|
||||
@Inject(at = @At("HEAD"), method = "isNether", cancellable = true)
|
||||
private static void isNether(World world, CallbackInfoReturnable<Boolean> info) {
|
||||
if (SlightlyVanilla.getConfig().useRespawnAnchorInAnyDimension) {
|
||||
return DimensionType.THE_NETHER;
|
||||
info.setReturnValue(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayerEntity;getSpawnPointPosition()Lnet/minecraft/util/math/BlockPos;"), method = "onUse")
|
||||
public BlockPos getSpawnPointPosition(ServerPlayerEntity serverPlayerEntity) {
|
||||
if (SlightlyVanilla.getConfig().useRespawnAnchorInAnyDimension && serverPlayerEntity.getSpawnPointPosition() == null) {
|
||||
return new BlockPos(0, 512, 0);
|
||||
} else {
|
||||
return dimension.getType();
|
||||
return serverPlayerEntity.getSpawnPointPosition();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,20 @@
|
||||
package com.thebrokenrail.slightlyvanilla.mixin;
|
||||
|
||||
import com.thebrokenrail.slightlyvanilla.SlightlyVanilla;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.registry.RegistryKey;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(ServerPlayerEntity.class)
|
||||
public class MixinServerPlayerEntity {
|
||||
@Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayerEntity;setSpawnPoint(Lnet/minecraft/util/registry/RegistryKey;Lnet/minecraft/util/math/BlockPos;FZZ)V"), method = "trySleep")
|
||||
public void setSpawnPoint(ServerPlayerEntity obj, RegistryKey<World> dimension, BlockPos pos, float angle, boolean spawnPointSet, boolean bl) {
|
||||
if (SlightlyVanilla.getConfig().bedsSetSpawn) {
|
||||
obj.setSpawnPoint(dimension, pos, angle, spawnPointSet, bl);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.thebrokenrail.slightlyvanilla.mixin;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.screen.ScreenHandler;
|
||||
import net.minecraft.screen.ScreenHandlerContext;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
@Mixin(ScreenHandler.class)
|
||||
public interface ScreenHandlerAccessor {
|
||||
@Invoker
|
||||
static boolean callCanUse(ScreenHandlerContext context, PlayerEntity player, Block block) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
@ -12,6 +12,34 @@
|
||||
"text.autoconfig.slightlyvanilla.option.cryingObsidianNetherPortal": "Crying Obsidian Nether Portal",
|
||||
"text.autoconfig.slightlyvanilla.option.allowLeashingVillagers": "Allow Leashing Villagers",
|
||||
"text.autoconfig.slightlyvanilla.option.disableInstantNetherPortalInCreative": "Disable Instant Nether Portal In Creative",
|
||||
"text.autoconfig.slightlyvanilla.option.noteBlockScreen": "Add Note Block Screen",
|
||||
"text.autoconfig.slightlyvanilla.option.bedsSetSpawn": "Beds Set Spawn",
|
||||
"entity.slightlyvanilla.slimeball": "Slimeball",
|
||||
"entity.slightlyvanilla.spawn_egg": "Spawn Egg"
|
||||
"entity.slightlyvanilla.spawn_egg": "Spawn Egg",
|
||||
"text.slightlyvanilla.noteblock_screen_slider": "Note: %s (%s)",
|
||||
"text.slightlyvanilla.noteblock_note.0": "F#",
|
||||
"text.slightlyvanilla.noteblock_note.1": "G",
|
||||
"text.slightlyvanilla.noteblock_note.2": "G#",
|
||||
"text.slightlyvanilla.noteblock_note.3": "A",
|
||||
"text.slightlyvanilla.noteblock_note.4": "A#",
|
||||
"text.slightlyvanilla.noteblock_note.5": "B",
|
||||
"text.slightlyvanilla.noteblock_note.6": "C",
|
||||
"text.slightlyvanilla.noteblock_note.7": "C#",
|
||||
"text.slightlyvanilla.noteblock_note.8": "D",
|
||||
"text.slightlyvanilla.noteblock_note.9": "D#",
|
||||
"text.slightlyvanilla.noteblock_note.10": "E",
|
||||
"text.slightlyvanilla.noteblock_note.11": "F",
|
||||
"text.slightlyvanilla.noteblock_note.12": "F#",
|
||||
"text.slightlyvanilla.noteblock_note.13": "G",
|
||||
"text.slightlyvanilla.noteblock_note.14": "G#",
|
||||
"text.slightlyvanilla.noteblock_note.15": "A",
|
||||
"text.slightlyvanilla.noteblock_note.16": "A#",
|
||||
"text.slightlyvanilla.noteblock_note.17": "B",
|
||||
"text.slightlyvanilla.noteblock_note.18": "C",
|
||||
"text.slightlyvanilla.noteblock_note.19": "C#",
|
||||
"text.slightlyvanilla.noteblock_note.20": "D",
|
||||
"text.slightlyvanilla.noteblock_note.21": "D#",
|
||||
"text.slightlyvanilla.noteblock_note.22": "E",
|
||||
"text.slightlyvanilla.noteblock_note.23": "F",
|
||||
"text.slightlyvanilla.noteblock_note.24": "F#"
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 8.5 KiB |
@ -1,6 +1,7 @@
|
||||
{
|
||||
"replace": false,
|
||||
"values": [
|
||||
"minecraft:obsidian",
|
||||
"minecraft:crying_obsidian"
|
||||
]
|
||||
}
|
@ -23,7 +23,7 @@
|
||||
"com.thebrokenrail.slightlyvanilla.client.SlightlyVanillaClient"
|
||||
],
|
||||
"modmenu": [
|
||||
"com.thebrokenrail.slightlyvanilla.client.SlightlyVanillaClient"
|
||||
"com.thebrokenrail.slightlyvanilla.client.ModMenu"
|
||||
]
|
||||
},
|
||||
"mixins": [
|
||||
@ -33,5 +33,11 @@
|
||||
"fabricloader": ">=0.7.4",
|
||||
"fabric": "*",
|
||||
"minecraft": "1.16.x"
|
||||
},
|
||||
"custom": {
|
||||
"modupdater": {
|
||||
"strategy": "curseforge",
|
||||
"projectID": 368420
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,16 +3,19 @@
|
||||
"package": "com.thebrokenrail.slightlyvanilla.mixin",
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"client": [
|
||||
"MixinClientPlayNetworkHandler"
|
||||
"MixinClientPlayerInteractionManager",
|
||||
"MixinClientPlayNetworkHandler",
|
||||
"ScreenHandlerAccessor"
|
||||
],
|
||||
"mixins": [
|
||||
"MixinRespawnAnchorBlock",
|
||||
"MixinPlayerEntity",
|
||||
"MixinAbstractTraderEntity",
|
||||
"MixinItem",
|
||||
"MixinSpawnEggItem",
|
||||
"MixinLootableContainerBlockEntity",
|
||||
"MixinNetherPortalBlockAreaHelper",
|
||||
"MixinAbstractTraderEntity"
|
||||
"MixinPlayerEntity",
|
||||
"MixinRespawnAnchorBlock",
|
||||
"MixinServerPlayerEntity",
|
||||
"MixinSpawnEggItem"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
Reference in New Issue
Block a user