Bookshelves mixins, textures & lang
This commit is contained in:
parent
0a8e73d9d9
commit
92f95d6c0f
13 changed files with 221 additions and 3 deletions
|
@ -29,6 +29,7 @@ import ru.betterend.blocks.basis.BlockTrapdoor;
|
|||
import ru.betterend.blocks.basis.BlockWoodenButton;
|
||||
import ru.betterend.recipe.builders.GridRecipe;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
import ru.betterend.registry.EndTags;
|
||||
import ru.betterend.util.TagHelper;
|
||||
|
||||
public class WoodenMaterial {
|
||||
|
@ -99,6 +100,7 @@ public class WoodenMaterial {
|
|||
GridRecipe.make(name + "_sign", sign).setOutputCount(3).setShape("###", "###", " I ").addMaterial('#', planks).addMaterial('I', Items.STICK).setGroup("end_signs").build();
|
||||
GridRecipe.make(name + "_chest", chest).setShape("###", "# #", "###").addMaterial('#', planks).setGroup("end_chests").build();
|
||||
GridRecipe.make(name + "_barrel", barrel).setShape("#S#", "# #", "#S#").addMaterial('#', planks).addMaterial('S', slab).setGroup("end_barrels").build();
|
||||
GridRecipe.make(name + "_bookshelf", shelf).setShape("###", "PPP", "###").addMaterial('#', planks).addMaterial('P', Items.PAPER).setGroup("end_bookshelves").build();
|
||||
|
||||
// Item Tags //
|
||||
TagHelper.addTag(ItemTags.PLANKS, planks);
|
||||
|
@ -125,6 +127,7 @@ public class WoodenMaterial {
|
|||
TagHelper.addTags(slab, BlockTags.WOODEN_SLABS, BlockTags.SLABS);
|
||||
TagHelper.addTags(stairs, BlockTags.WOODEN_STAIRS, BlockTags.STAIRS);
|
||||
TagHelper.addTags(trapdoor, BlockTags.WOODEN_TRAPDOORS, BlockTags.TRAPDOORS);
|
||||
TagHelper.addTag(EndTags.BOOKSHELVES, shelf);
|
||||
}
|
||||
|
||||
public boolean isTreeLog(Block block) {
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
package ru.betterend.mixin.client;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
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.CallbackInfo;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.EnchantingTableBlock;
|
||||
import net.minecraft.particle.ParticleTypes;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import ru.betterend.registry.EndTags;
|
||||
|
||||
@Mixin(EnchantingTableBlock.class)
|
||||
public abstract class EnchantingTableBlockMixin extends Block {
|
||||
public EnchantingTableBlockMixin(Settings settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
||||
@Inject(method = "randomDisplayTick", at = @At(value = "TAIL"))
|
||||
private void beOnRandomDisplayTick(BlockState state, World world, BlockPos pos, Random random, CallbackInfo info) {
|
||||
for (int px = -2; px <= 2; ++px) {
|
||||
for (int pz = -2; pz <= 2; ++pz) {
|
||||
if (px > -2 && px < 2 && pz == -1) {
|
||||
pz = 2;
|
||||
}
|
||||
if (random.nextInt(16) == 0) {
|
||||
for (int py = 0; py <= 1; ++py) {
|
||||
BlockPos blockPos = pos.add(px, py, pz);
|
||||
if (world.getBlockState(blockPos).isIn(EndTags.BOOKSHELVES)) {
|
||||
if (!world.isAir(pos.add(px / 2, 0, pz / 2))) {
|
||||
break;
|
||||
}
|
||||
world.addParticle(ParticleTypes.ENCHANT, pos.getX() + 0.5, pos.getY() + 2.0, pos.getZ() + 0.5, px + random.nextFloat() - 0.5, py - random.nextFloat() - 1.0, pz + random.nextFloat() - 0.5);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,140 @@
|
|||
package ru.betterend.mixin.common;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
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.CallbackInfo;
|
||||
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.enchantment.EnchantmentLevelEntry;
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.screen.EnchantmentScreenHandler;
|
||||
import net.minecraft.screen.Property;
|
||||
import net.minecraft.screen.ScreenHandler;
|
||||
import net.minecraft.screen.ScreenHandlerContext;
|
||||
import net.minecraft.screen.ScreenHandlerType;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import ru.betterend.registry.EndTags;
|
||||
|
||||
@Mixin(EnchantmentScreenHandler.class)
|
||||
public abstract class EnchantmentScreenHandlerMixin extends ScreenHandler {
|
||||
@Shadow
|
||||
@Final
|
||||
private Inventory inventory;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private ScreenHandlerContext context;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private Random random;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private Property seed;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
public int[] enchantmentPower;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
public int[] enchantmentId;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
public int[] enchantmentLevel;
|
||||
|
||||
protected EnchantmentScreenHandlerMixin(ScreenHandlerType<?> type, int syncId) {
|
||||
super(type, syncId);
|
||||
}
|
||||
|
||||
@Inject(method = "onContentChanged", at = @At("HEAD"), cancellable = true)
|
||||
private void beOnContentChanged(Inventory inventory, CallbackInfo info) {
|
||||
if (inventory == this.inventory) {
|
||||
ItemStack itemStack = inventory.getStack(0);
|
||||
if (!itemStack.isEmpty() && itemStack.isEnchantable()) {
|
||||
this.context.run((world, blockPos) -> {
|
||||
int i = 0;
|
||||
|
||||
int j;
|
||||
for (j = -1; j <= 1; ++j) {
|
||||
for (int k = -1; k <= 1; ++k) {
|
||||
if ((j != 0 || k != 0) && world.isAir(blockPos.add(k, 0, j)) && world.isAir(blockPos.add(k, 1, j))) {
|
||||
if (world.getBlockState(blockPos.add(k * 2, 0, j * 2)).isIn(EndTags.BOOKSHELVES)) {
|
||||
++i;
|
||||
}
|
||||
|
||||
if (world.getBlockState(blockPos.add(k * 2, 1, j * 2)).isIn(EndTags.BOOKSHELVES)) {
|
||||
++i;
|
||||
}
|
||||
|
||||
if (k != 0 && j != 0) {
|
||||
if (world.getBlockState(blockPos.add(k * 2, 0, j)).isIn(EndTags.BOOKSHELVES)) {
|
||||
++i;
|
||||
}
|
||||
|
||||
if (world.getBlockState(blockPos.add(k * 2, 1, j)).isIn(EndTags.BOOKSHELVES)) {
|
||||
++i;
|
||||
}
|
||||
|
||||
if (world.getBlockState(blockPos.add(k, 0, j * 2)).isIn(EndTags.BOOKSHELVES)) {
|
||||
++i;
|
||||
}
|
||||
|
||||
if (world.getBlockState(blockPos.add(k, 1, j * 2)).isIn(EndTags.BOOKSHELVES)) {
|
||||
++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.random.setSeed((long) this.seed.get());
|
||||
|
||||
for (j = 0; j < 3; ++j) {
|
||||
this.enchantmentPower[j] = EnchantmentHelper.calculateRequiredExperienceLevel(this.random, j, i, itemStack);
|
||||
this.enchantmentId[j] = -1;
|
||||
this.enchantmentLevel[j] = -1;
|
||||
if (this.enchantmentPower[j] < j + 1) {
|
||||
this.enchantmentPower[j] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
for (j = 0; j < 3; ++j) {
|
||||
if (this.enchantmentPower[j] > 0) {
|
||||
List<EnchantmentLevelEntry> list = this.generateEnchantments(itemStack, j, this.enchantmentPower[j]);
|
||||
if (list != null && !list.isEmpty()) {
|
||||
EnchantmentLevelEntry enchantmentLevelEntry = (EnchantmentLevelEntry) list.get(this.random.nextInt(list.size()));
|
||||
this.enchantmentId[j] = Registry.ENCHANTMENT.getRawId(enchantmentLevelEntry.enchantment);
|
||||
this.enchantmentLevel[j] = enchantmentLevelEntry.level;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.sendContentUpdates();
|
||||
});
|
||||
}
|
||||
else {
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
this.enchantmentPower[i] = 0;
|
||||
this.enchantmentId[i] = -1;
|
||||
this.enchantmentLevel[i] = -1;
|
||||
}
|
||||
}
|
||||
info.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Shadow
|
||||
private List<EnchantmentLevelEntry> generateEnchantments(ItemStack stack, int slot, int level) {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -25,12 +25,21 @@ public class EndTags {
|
|||
// Block Tags
|
||||
public static final Tag.Identified<Block> END_GROUND = makeTag("end_ground");
|
||||
public static final Tag.Identified<Block> GEN_TERRAIN = makeTag("gen_terrain");
|
||||
public static final Tag.Identified<Block> BOOKSHELVES = makeCommonTag("bookshelves");
|
||||
|
||||
// Item Tags
|
||||
public final static Tag<Item> HAMMERS = registerFabricItemTag("hammers");
|
||||
|
||||
private static Tag.Identified<Block> makeTag(String name) {
|
||||
return (Identified<Block>) TagRegistry.block(BetterEnd.makeID(name));
|
||||
Identifier id = BetterEnd.makeID(name);
|
||||
Tag<Block> tag = BlockTags.getTagGroup().getTag(id);
|
||||
return tag == null ? (Identified<Block>) TagRegistry.block(id) : (Identified<Block>) tag;
|
||||
}
|
||||
|
||||
private static Tag.Identified<Block> makeCommonTag(String name) {
|
||||
Identifier id = new Identifier("c", name);
|
||||
Tag<Block> tag = BlockTags.getTagGroup().getTag(id);
|
||||
return tag == null ? (Identified<Block>) TagRegistry.block(id) : (Identified<Block>) tag;
|
||||
}
|
||||
|
||||
public static void register() {
|
||||
|
|
|
@ -259,5 +259,11 @@
|
|||
"block.betterend.dragon_tree_sapling": "Dragon Tree Sapling",
|
||||
"block.betterend.shadow_grass": "Shadow Grass",
|
||||
"block.betterend.shadow_grass_path": "Shadow Grass Path",
|
||||
"block.betterend.shadow_plant": "Shadow Plant"
|
||||
"block.betterend.shadow_plant": "Shadow Plant",
|
||||
|
||||
"block.betterend.dragon_tree_bookshelf": "Dragon Tree Bookshelf",
|
||||
"block.betterend.end_lotus_bookshelf": "End Lotus Bookshelf",
|
||||
"block.betterend.lacugrove_bookshelf": "Lacugrove Bookshelf",
|
||||
"block.betterend.mossy_glowshroom_bookshelf": "Mossy Glowshroom Bookshelf",
|
||||
"block.betterend.pythadendron_bookshelf": "Pythadendron Bookshelf"
|
||||
}
|
|
@ -261,5 +261,11 @@
|
|||
"block.betterend.dragon_tree_sapling": "Саженец драконова древа",
|
||||
"block.betterend.shadow_grass": "Теневая трава",
|
||||
"block.betterend.shadow_grass_path": "Тропа из теневой травы",
|
||||
"block.betterend.shadow_plant": "Теневое растение"
|
||||
"block.betterend.shadow_plant": "Теневое растение",
|
||||
|
||||
"block.betterend.dragon_tree_bookshelf": "Книжные полки из драконова древа",
|
||||
"block.betterend.end_lotus_bookshelf": "Книжные полки из лотоса края",
|
||||
"block.betterend.lacugrove_bookshelf": "Книжные полки из оземангра",
|
||||
"block.betterend.mossy_glowshroom_bookshelf": "Книжные полки из мшистого светогриба",
|
||||
"block.betterend.pythadendron_bookshelf": "Книжные полки из пифадендрона"
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 728 B |
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
Binary file not shown.
After Width: | Height: | Size: 694 B |
Binary file not shown.
After Width: | Height: | Size: 697 B |
|
@ -8,6 +8,7 @@
|
|||
"ClientPlayNetworkHandlerMixin",
|
||||
"NamespaceResourceManagerMixin",
|
||||
"DeserializationContextMixin",
|
||||
"EnchantingTableBlockMixin",
|
||||
"BackgroundRendererMixin",
|
||||
"ClientRecipeBookMixin",
|
||||
"ModelVariantMapMixin",
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
"compatibilityLevel": "JAVA_8",
|
||||
"mixins": [
|
||||
"ServerPlayNetworkHandlerMixin",
|
||||
"EnchantmentScreenHandlerMixin",
|
||||
"CraftingScreenHandlerMixin",
|
||||
"GenerationSettingsAccessor",
|
||||
"AnvilScreenHandlerMixin",
|
||||
|
|
6
src/main/resources/data/c/tags/blocks/bookshelves.json
Normal file
6
src/main/resources/data/c/tags/blocks/bookshelves.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"replace": "false",
|
||||
"values": [
|
||||
"minecraft:bookshelf"
|
||||
]
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue