Compare commits

..

10 commits

Author SHA1 Message Date
Ell
29b067d294 fixed particle rendering 2021-12-19 19:33:44 +01:00
Ell
8f62c01cc3 fixed ender crate model offset 2021-12-19 18:49:05 +01:00
Ell
5c04244e00 bring back model rendering 2021-12-19 18:47:50 +01:00
Ell
1469e4ca5f added back overlay rendering 2021-12-19 18:24:54 +01:00
Ell
5b7df8bd45 re-added JEI compat 2021-12-19 17:14:56 +01:00
Ell
5db697abb1 register features more 2021-12-19 16:51:20 +01:00
Ell
c0bf5f0d93 bring back curios compat 2021-12-19 16:35:03 +01:00
Ell
f8d3d022fd fixed effect powders being weird 2021-12-19 16:26:31 +01:00
Ell
2b6b42e091 matches is areItemStacksEqual, isSame is areItemsEqual
obviously
2021-12-19 15:40:53 +01:00
Ell
198a4d359a made stuff tick 2021-12-19 15:32:45 +01:00
103 changed files with 596 additions and 578 deletions

View file

@ -24,7 +24,7 @@ if (System.getenv('BUILD_NUMBER') != null) {
java.toolchain.languageVersion = JavaLanguageVersion.of(17) java.toolchain.languageVersion = JavaLanguageVersion.of(17)
minecraft { minecraft {
mappings channel: 'official', version: '1.18' mappings channel: 'official', version: '1.18.1'
runs { runs {
client { client {
@ -102,18 +102,16 @@ repositories {
} }
dependencies { dependencies {
minecraft 'net.minecraftforge:forge:1.18-38.0.14' minecraft 'net.minecraftforge:forge:1.18.1-39.0.5'
// TODO JEI compileOnly fg.deobf("mezz.jei:jei-1.18.1:9.1.0.47:api")
/* compileOnly fg.deobf("mezz.jei:jei-1.16.5:7.6.1.75:api") runtimeOnly fg.deobf("mezz.jei:jei-1.18.1:9.1.0.47")
runtimeOnly fg.deobf("mezz.jei:jei-1.16.5:7.6.1.75")*/
compileOnly fg.deobf("vazkii.patchouli:Patchouli:1.18.1-61:api") compileOnly fg.deobf("vazkii.patchouli:Patchouli:1.18.1-61:api")
runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:1.18.1-61") runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:1.18.1-61")
// TODO Curios runtimeOnly fg.deobf("top.theillusivec4.curios:curios-forge:1.18.1-5.0.3.0")
/* runtimeOnly fg.deobf("top.theillusivec4.curios:curios-forge:1.16.5-4.0.5.0") compileOnly fg.deobf("top.theillusivec4.curios:curios-forge:1.18.1-5.0.3.0:api")
compileOnly fg.deobf("top.theillusivec4.curios:curios-forge:1.16.5-4.0.5.0:api")*/
// TODO Enchantability // TODO Enchantability
/* compile fg.deobf("quarris.enchantability:Enchantability:11.0.48")*/ /* compile fg.deobf("quarris.enchantability:Enchantability:11.0.48")*/

View file

@ -1,12 +1,15 @@
package de.ellpeck.naturesaura; package de.ellpeck.naturesaura;
import com.mojang.blaze3d.systems.RenderSystem;
import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.aura.container.IAuraContainer; import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
import de.ellpeck.naturesaura.api.aura.item.IAuraRecharge; import de.ellpeck.naturesaura.api.aura.item.IAuraRecharge;
import de.ellpeck.naturesaura.api.misc.ILevelData; import de.ellpeck.naturesaura.api.misc.ILevelData;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityImpl; import de.ellpeck.naturesaura.blocks.tiles.BlockEntityImpl;
import de.ellpeck.naturesaura.chunk.AuraChunk; import de.ellpeck.naturesaura.chunk.AuraChunk;
import de.ellpeck.naturesaura.compat.Compat;
import de.ellpeck.naturesaura.misc.LevelData; import de.ellpeck.naturesaura.misc.LevelData;
import net.minecraft.client.Minecraft;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
@ -39,7 +42,8 @@ import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.IForgeRegistry; import net.minecraftforge.registries.IForgeRegistry;
import net.minecraftforge.registries.IForgeRegistryEntry; import net.minecraftforge.registries.IForgeRegistryEntry;
import org.lwjgl.opengl.GL11; import org.apache.commons.lang3.tuple.ImmutableTriple;
import top.theillusivec4.curios.api.CuriosApi;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -113,6 +117,19 @@ public final class Helper {
return !nbt || ItemStack.tagMatches(first, second); return !nbt || ItemStack.tagMatches(first, second);
} }
@OnlyIn(Dist.CLIENT)
public static void renderItemInGui(ItemStack stack, int x, int y, float scale) {
var poseStack = RenderSystem.getModelViewStack();
poseStack.pushPose();
poseStack.translate(x, y, 0);
poseStack.scale(scale, scale, scale);
RenderSystem.applyModelViewMatrix();
Minecraft.getInstance().getItemRenderer().renderGuiItem(stack, 0, 0);
Minecraft.getInstance().getItemRenderer().renderGuiItemDecorations(Minecraft.getInstance().font, stack, 0, 0, null);
poseStack.popPose();
RenderSystem.applyModelViewMatrix();
}
public static InteractionResult putStackOnTile(Player player, InteractionHand hand, BlockPos pos, int slot, boolean sound) { public static InteractionResult putStackOnTile(Player player, InteractionHand hand, BlockPos pos, int slot, boolean sound) {
var tile = player.level.getBlockEntity(pos); var tile = player.level.getBlockEntity(pos);
if (tile instanceof BlockEntityImpl) { if (tile instanceof BlockEntityImpl) {
@ -121,7 +138,7 @@ public final class Helper {
var handStack = player.getItemInHand(hand); var handStack = player.getItemInHand(hand);
if (!handStack.isEmpty()) { if (!handStack.isEmpty()) {
var remain = handler.insertItem(slot, handStack, player.level.isClientSide); var remain = handler.insertItem(slot, handStack, player.level.isClientSide);
if (!ItemStack.isSame(remain, handStack)) { if (!ItemStack.matches(remain, handStack)) {
if (sound) if (sound)
player.level.playSound(player, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, player.level.playSound(player, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5,
SoundEvents.ITEM_FRAME_ADD_ITEM, SoundSource.PLAYERS, 0.75F, 1F); SoundEvents.ITEM_FRAME_ADD_ITEM, SoundSource.PLAYERS, 0.75F, 1F);
@ -223,34 +240,6 @@ public final class Helper {
return highestAmount; return highestAmount;
} }
@OnlyIn(Dist.CLIENT)
public static void renderWeirdBox(double x, double y, double z, double width, double height, double depth) {
GL11.glVertex3d(x, y + height, z);
GL11.glVertex3d(x + width, y + height, z);
GL11.glVertex3d(x + width, y, z);
GL11.glVertex3d(x, y, z);
GL11.glVertex3d(x + width, y, z + depth);
GL11.glVertex3d(x + width, y, z);
GL11.glVertex3d(x + width, y + height, z);
GL11.glVertex3d(x + width, y + height, z + depth);
GL11.glVertex3d(x + width, y + height, z + depth);
GL11.glVertex3d(x, y + height, z + depth);
GL11.glVertex3d(x, y, z + depth);
GL11.glVertex3d(x + width, y, z + depth);
GL11.glVertex3d(x, y + height, z + depth);
GL11.glVertex3d(x, y + height, z);
GL11.glVertex3d(x, y, z);
GL11.glVertex3d(x, y, z + depth);
GL11.glVertex3d(x, y + height, z);
GL11.glVertex3d(x, y + height, z + depth);
GL11.glVertex3d(x + width, y + height, z + depth);
GL11.glVertex3d(x + width, y + height, z);
GL11.glVertex3d(x + width, y, z);
GL11.glVertex3d(x + width, y, z + depth);
GL11.glVertex3d(x, y, z + depth);
GL11.glVertex3d(x, y, z);
}
public static boolean isHoldingItem(Player player, Item item) { public static boolean isHoldingItem(Player player, Item item) {
for (var hand : InteractionHand.values()) { for (var hand : InteractionHand.values()) {
var stack = player.getItemInHand(hand); var stack = player.getItemInHand(hand);
@ -290,12 +279,11 @@ public final class Helper {
} }
public static ItemStack getEquippedItem(Predicate<ItemStack> predicate, Player player) { public static ItemStack getEquippedItem(Predicate<ItemStack> predicate, Player player) {
// TODO Curios if (Compat.hasCompat("curios")) {
/* if (Compat.hasCompat("curios")) { var stack = CuriosApi.getCuriosHelper().findEquippedCurio(predicate, player).map(ImmutableTriple::getRight);
Optional<ItemStack> stack = CuriosApi.getCuriosHelper().findEquippedCurio(predicate, player).map(ImmutableTriple::getRight);
if (stack.isPresent()) if (stack.isPresent())
return stack.get(); return stack.get();
}*/ }
for (var i = 0; i < player.getInventory().getContainerSize(); i++) { for (var i = 0; i < player.getInventory().getContainerSize(); i++) {
var slot = player.getInventory().getItem(i); var slot = player.getInventory().getItem(i);
if (!slot.isEmpty() && predicate.test(slot)) if (!slot.isEmpty() && predicate.test(slot))

View file

@ -20,7 +20,7 @@ public class BlockAnimalContainer extends BlockContainerImpl implements IVisuali
private static final VoxelShape SHAPE = box(5, 0, 5, 11, 13, 11); private static final VoxelShape SHAPE = box(5, 0, 5, 11, 13, 11);
public BlockAnimalContainer() { public BlockAnimalContainer() {
super("animal_container", BlockEntityAnimalContainer::new, Properties.copy(Blocks.STONE)); super("animal_container", BlockEntityAnimalContainer.class, Properties.copy(Blocks.STONE));
} }
@Override @Override

View file

@ -9,9 +9,7 @@ import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticles; import de.ellpeck.naturesaura.packet.PacketParticles;
import de.ellpeck.naturesaura.reg.ICustomBlockState; import de.ellpeck.naturesaura.reg.ICustomBlockState;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.animal.Animal; import net.minecraft.world.entity.animal.Animal;
import net.minecraft.world.entity.npc.Npc; import net.minecraft.world.entity.npc.Npc;
@ -31,7 +29,7 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
public class BlockAnimalGenerator extends BlockContainerImpl implements IVisualizable, ICustomBlockState { public class BlockAnimalGenerator extends BlockContainerImpl implements IVisualizable, ICustomBlockState {
public BlockAnimalGenerator() { public BlockAnimalGenerator() {
super("animal_generator", BlockEntityAnimalGenerator::new, Properties.of(Material.STONE).strength(3F).sound(SoundType.STONE)); super("animal_generator", BlockEntityAnimalGenerator.class, Properties.of(Material.STONE).strength(3F).sound(SoundType.STONE));
MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(this);
} }

View file

@ -7,6 +7,6 @@ import net.minecraft.world.level.material.Material;
public class BlockAnimalSpawner extends BlockContainerImpl { public class BlockAnimalSpawner extends BlockContainerImpl {
public BlockAnimalSpawner() { public BlockAnimalSpawner() {
super("animal_spawner", BlockEntityAnimalSpawner::new, Properties.of(Material.STONE).strength(2F).sound(SoundType.STONE)); super("animal_spawner", BlockEntityAnimalSpawner.class, Properties.of(Material.STONE).strength(2F).sound(SoundType.STONE));
} }
} }

View file

@ -1,6 +1,8 @@
package de.ellpeck.naturesaura.blocks; package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityAuraBloom; import de.ellpeck.naturesaura.blocks.tiles.BlockEntityAuraBloom;
import de.ellpeck.naturesaura.blocks.tiles.ITickableBlockEntity;
import de.ellpeck.naturesaura.blocks.tiles.ModBlockEntities;
import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.data.ItemModelGenerator; import de.ellpeck.naturesaura.data.ItemModelGenerator;
import de.ellpeck.naturesaura.reg.*; import de.ellpeck.naturesaura.reg.*;
@ -16,11 +18,13 @@ import net.minecraft.world.level.block.BushBlock;
import net.minecraft.world.level.block.EntityBlock; import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityTicker;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material; import net.minecraft.world.level.material.Material;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShape;
import org.jetbrains.annotations.Nullable;
import java.util.Arrays; import java.util.Arrays;
import java.util.function.Supplier; import java.util.function.Supplier;
@ -86,4 +90,10 @@ public class BlockAuraBloom extends BushBlock implements IModItem, ICustomBlockS
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) { public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
return new BlockEntityAuraBloom(pos, state); return new BlockEntityAuraBloom(pos, state);
} }
@Nullable
@Override
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState state, BlockEntityType<T> type) {
return ITickableBlockEntity.createTickerHelper(type, ModBlockEntities.AURA_BLOOM);
}
} }

View file

@ -4,14 +4,13 @@ import de.ellpeck.naturesaura.blocks.tiles.BlockEntityAuraDetector;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material; import net.minecraft.world.level.material.Material;
public class BlockAuraDetector extends BlockContainerImpl { public class BlockAuraDetector extends BlockContainerImpl {
public BlockAuraDetector() { public BlockAuraDetector() {
super("aura_detector", BlockEntityAuraDetector::new, Properties.of(Material.STONE).strength(2F).sound(SoundType.STONE)); super("aura_detector", BlockEntityAuraDetector.class, Properties.of(Material.STONE).strength(2F).sound(SoundType.STONE));
} }
@Override @Override

View file

@ -2,7 +2,7 @@ package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityAuraTimer; import de.ellpeck.naturesaura.blocks.tiles.BlockEntityAuraTimer;
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities; import de.ellpeck.naturesaura.blocks.tiles.ModBlockEntities;
import de.ellpeck.naturesaura.blocks.tiles.render.RenderAuraTimer; import de.ellpeck.naturesaura.blocks.tiles.render.RenderAuraTimer;
import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.reg.ICustomBlockState; import de.ellpeck.naturesaura.reg.ICustomBlockState;
@ -35,7 +35,7 @@ public class BlockAuraTimer extends BlockContainerImpl implements ICustomBlockSt
private static final VoxelShape SHAPE = box(1, 0, 1, 15, 15, 15); private static final VoxelShape SHAPE = box(1, 0, 1, 15, 15, 15);
public BlockAuraTimer() { public BlockAuraTimer() {
super("aura_timer", BlockEntityAuraTimer::new, Properties.copy(Blocks.SMOOTH_STONE)); super("aura_timer", BlockEntityAuraTimer.class, Properties.copy(Blocks.SMOOTH_STONE));
this.registerDefaultState(this.defaultBlockState().setValue(BlockStateProperties.POWERED, false)); this.registerDefaultState(this.defaultBlockState().setValue(BlockStateProperties.POWERED, false));
} }
@ -83,6 +83,6 @@ public class BlockAuraTimer extends BlockContainerImpl implements ICustomBlockSt
@Override @Override
public void registerTESR() { public void registerTESR() {
BlockEntityRenderers.register(ModTileEntities.AURA_TIMER, RenderAuraTimer::new); BlockEntityRenderers.register(ModBlockEntities.AURA_TIMER, RenderAuraTimer::new);
} }
} }

View file

@ -17,7 +17,7 @@ public class BlockAutoCrafter extends BlockContainerImpl implements ICustomBlock
public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING; public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING;
public BlockAutoCrafter() { public BlockAutoCrafter() {
super("auto_crafter", BlockEntityAutoCrafter::new, Properties.of(Material.WOOD).strength(1.5F).sound(SoundType.WOOD)); super("auto_crafter", BlockEntityAutoCrafter.class, Properties.of(Material.WOOD).strength(1.5F).sound(SoundType.WOOD));
} }
@Override @Override

View file

@ -22,7 +22,7 @@ public class BlockBlastFurnaceBooster extends BlockContainerImpl implements ICus
private static final VoxelShape SHAPE = Shapes.create(1 / 16F, 0, 1 / 16F, 15 / 16F, 1, 15 / 16F); private static final VoxelShape SHAPE = Shapes.create(1 / 16F, 0, 1 / 16F, 15 / 16F, 1, 15 / 16F);
public BlockBlastFurnaceBooster() { public BlockBlastFurnaceBooster() {
super("blast_furnace_booster", BlockEntityBlastFurnaceBooster::new, Block.Properties.copy(Blocks.BLAST_FURNACE).lightLevel(s -> 0)); super("blast_furnace_booster", BlockEntityBlastFurnaceBooster.class, Block.Properties.copy(Blocks.BLAST_FURNACE).lightLevel(s -> 0));
} }
@Override @Override

View file

@ -8,7 +8,7 @@ import net.minecraft.world.level.block.Blocks;
public class BlockChorusGenerator extends BlockContainerImpl implements ICustomBlockState { public class BlockChorusGenerator extends BlockContainerImpl implements ICustomBlockState {
public BlockChorusGenerator() { public BlockChorusGenerator() {
super("chorus_generator", BlockEntityChorusGenerator::new, Properties.copy(Blocks.END_STONE)); super("chorus_generator", BlockEntityChorusGenerator.class, Properties.copy(Blocks.END_STONE));
} }
@Override @Override

View file

@ -12,7 +12,6 @@ import net.minecraft.util.Mth;
import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material; import net.minecraft.world.level.material.Material;
import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.AABB;
@ -28,7 +27,7 @@ public class BlockChunkLoader extends BlockContainerImpl implements IVisualizabl
private static final VoxelShape SHAPE = box(4, 4, 4, 12, 12, 12); private static final VoxelShape SHAPE = box(4, 4, 4, 12, 12, 12);
public BlockChunkLoader() { public BlockChunkLoader() {
super("chunk_loader", BlockEntityChunkLoader::new, Properties.of(Material.STONE).strength(3F).sound(SoundType.STONE)); super("chunk_loader", BlockEntityChunkLoader.class, Properties.of(Material.STONE).strength(3F).sound(SoundType.STONE));
} }
@Override @Override

View file

@ -1,6 +1,7 @@
package de.ellpeck.naturesaura.blocks; package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityImpl; import de.ellpeck.naturesaura.blocks.tiles.BlockEntityImpl;
import de.ellpeck.naturesaura.blocks.tiles.ITickableBlockEntity;
import de.ellpeck.naturesaura.reg.IModItem; import de.ellpeck.naturesaura.reg.IModItem;
import de.ellpeck.naturesaura.reg.ModRegistry; import de.ellpeck.naturesaura.reg.ModRegistry;
import de.ellpeck.naturesaura.reg.ModTileType; import de.ellpeck.naturesaura.reg.ModTileType;
@ -19,6 +20,7 @@ import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.RenderShape; import net.minecraft.world.level.block.RenderShape;
import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityTicker;
import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.StateDefinition;
@ -29,19 +31,22 @@ import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.parameters.LootContextParams; import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.lang.reflect.InvocationTargetException;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
public class BlockContainerImpl extends BaseEntityBlock implements IModItem { public class BlockContainerImpl extends BaseEntityBlock implements IModItem {
private final String baseName; private final String baseName;
private final ModTileType<BlockEntity> tileType; private final Class<? extends BlockEntity> tileClass;
private final ModTileType<? extends BlockEntity> tileType;
public BlockContainerImpl(String baseName, BlockEntityType.BlockEntitySupplier<BlockEntity> tileSupplier, Block.Properties properties) { public BlockContainerImpl(String baseName, Class<? extends BlockEntity> tileClass, Block.Properties properties) {
super(properties); super(properties);
this.baseName = baseName; this.baseName = baseName;
this.tileType = new ModTileType<>(tileSupplier, this); this.tileClass = tileClass;
this.tileType = new ModTileType<>(this::createBlockEntity, this);
ModRegistry.add(this); ModRegistry.add(this);
ModRegistry.add(this.tileType); ModRegistry.add(this.tileType);
@ -85,7 +90,14 @@ public class BlockContainerImpl extends BaseEntityBlock implements IModItem {
@org.jetbrains.annotations.Nullable @org.jetbrains.annotations.Nullable
@Override @Override
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) { public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
return this.tileType.type.create(pos, state); return this.createBlockEntity(pos, state);
}
@Override
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState state, BlockEntityType<T> type) {
if (ITickableBlockEntity.class.isAssignableFrom(this.tileClass))
return ITickableBlockEntity.createTickerHelper(type, this.tileType.type);
return null;
} }
@Override @Override
@ -164,4 +176,12 @@ public class BlockContainerImpl extends BaseEntityBlock implements IModItem {
} }
} }
} }
private BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
try {
return this.tileClass.getConstructor(BlockPos.class, BlockState.class).newInstance(pos, state);
} catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
throw new IllegalStateException("Cannot construct block entity from class " + this.tileClass, e);
}
}
} }

View file

@ -1,13 +1,14 @@
package de.ellpeck.naturesaura.blocks; package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityEndFlower; import de.ellpeck.naturesaura.blocks.tiles.BlockEntityEndFlower;
import de.ellpeck.naturesaura.blocks.tiles.ITickableBlockEntity;
import de.ellpeck.naturesaura.blocks.tiles.ModBlockEntities;
import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.data.ItemModelGenerator; import de.ellpeck.naturesaura.data.ItemModelGenerator;
import de.ellpeck.naturesaura.reg.*; import de.ellpeck.naturesaura.reg.*;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.NonNullList; import net.minecraft.core.NonNullList;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.boss.enderdragon.EnderDragon; import net.minecraft.world.entity.boss.enderdragon.EnderDragon;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
@ -19,13 +20,14 @@ import net.minecraft.world.level.block.BushBlock;
import net.minecraft.world.level.block.EntityBlock; import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityTicker;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.Heightmap; import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraft.world.level.material.FluidState; import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.Material; import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.storage.loot.LootContext; import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.parameters.LootContextParams; import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
@ -89,6 +91,12 @@ public class BlockEndFlower extends BushBlock implements IModItem, ICustomBlockS
return new BlockEntityEndFlower(pos, state); return new BlockEntityEndFlower(pos, state);
} }
@org.jetbrains.annotations.Nullable
@Override
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState state, BlockEntityType<T> type) {
return ITickableBlockEntity.createTickerHelper(type, ModBlockEntities.END_FLOWER);
}
@Override @Override
public boolean onDestroyedByPlayer(BlockState state, Level level, BlockPos pos, Player player, boolean willHarvest, FluidState fluid) { public boolean onDestroyedByPlayer(BlockState state, Level level, BlockPos pos, Player player, boolean willHarvest, FluidState fluid) {
return willHarvest || super.onDestroyedByPlayer(state, level, pos, player, willHarvest, fluid); return willHarvest || super.onDestroyedByPlayer(state, level, pos, player, willHarvest, fluid);

View file

@ -3,7 +3,7 @@ package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.misc.ILevelData; import de.ellpeck.naturesaura.api.misc.ILevelData;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityEnderCrate; import de.ellpeck.naturesaura.blocks.tiles.BlockEntityEnderCrate;
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities; import de.ellpeck.naturesaura.blocks.tiles.ModBlockEntities;
import de.ellpeck.naturesaura.blocks.tiles.render.RenderEnderCrate; import de.ellpeck.naturesaura.blocks.tiles.render.RenderEnderCrate;
import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.items.ModItems; import de.ellpeck.naturesaura.items.ModItems;
@ -43,7 +43,7 @@ import java.util.Random;
public class BlockEnderCrate extends BlockContainerImpl implements ITESRProvider<BlockEntityEnderCrate>, ICustomBlockState { public class BlockEnderCrate extends BlockContainerImpl implements ITESRProvider<BlockEntityEnderCrate>, ICustomBlockState {
public BlockEnderCrate() { public BlockEnderCrate() {
super("ender_crate", BlockEntityEnderCrate::new, Properties.of(Material.STONE).strength(5F).lightLevel(s -> 7).sound(SoundType.STONE)); super("ender_crate", BlockEntityEnderCrate.class, Properties.of(Material.STONE).strength(5F).lightLevel(s -> 7).sound(SoundType.STONE));
MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(this);
} }
@ -131,6 +131,6 @@ public class BlockEnderCrate extends BlockContainerImpl implements ITESRProvider
@Override @Override
public void registerTESR() { public void registerTESR() {
BlockEntityRenderers.register(ModTileEntities.ENDER_CRATE, RenderEnderCrate::new); BlockEntityRenderers.register(ModBlockEntities.ENDER_CRATE, RenderEnderCrate::new);
} }
} }

View file

@ -8,14 +8,12 @@ import de.ellpeck.naturesaura.reg.ICustomBlockState;
import de.ellpeck.naturesaura.reg.ICustomRenderType; import de.ellpeck.naturesaura.reg.ICustomRenderType;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult; import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material; import net.minecraft.world.level.material.Material;
import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.BlockHitResult;
@ -28,7 +26,7 @@ import java.util.function.Supplier;
public class BlockFieldCreator extends BlockContainerImpl implements ICustomBlockState, ICustomRenderType { public class BlockFieldCreator extends BlockContainerImpl implements ICustomBlockState, ICustomRenderType {
public BlockFieldCreator() { public BlockFieldCreator() {
super("field_creator", BlockEntityFieldCreator::new, Properties.of(Material.STONE).strength(2F).noCollission().sound(SoundType.STONE)); super("field_creator", BlockEntityFieldCreator.class, Properties.of(Material.STONE).strength(2F).noCollission().sound(SoundType.STONE));
} }
@Override @Override

View file

@ -15,7 +15,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
public class BlockFireworkGenerator extends BlockContainerImpl implements IVisualizable, ICustomBlockState { public class BlockFireworkGenerator extends BlockContainerImpl implements IVisualizable, ICustomBlockState {
public BlockFireworkGenerator() { public BlockFireworkGenerator() {
super("firework_generator", BlockEntityFireworkGenerator::new, Properties.of(Material.STONE).strength(3F).sound(SoundType.STONE)); super("firework_generator", BlockEntityFireworkGenerator.class, Properties.of(Material.STONE).strength(3F).sound(SoundType.STONE));
} }
@Override @Override

View file

@ -15,7 +15,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
public class BlockFlowerGenerator extends BlockContainerImpl implements IVisualizable, ICustomBlockState { public class BlockFlowerGenerator extends BlockContainerImpl implements IVisualizable, ICustomBlockState {
public BlockFlowerGenerator() { public BlockFlowerGenerator() {
super("flower_generator", BlockEntityFlowerGenerator::new, Properties.of(Material.WOOD).sound(SoundType.WOOD).strength(2F)); super("flower_generator", BlockEntityFlowerGenerator.class, Properties.of(Material.WOOD).sound(SoundType.WOOD).strength(2F));
} }
@Override @Override

View file

@ -37,7 +37,7 @@ public class BlockFurnaceHeater extends BlockContainerImpl implements ICustomBlo
}; };
public BlockFurnaceHeater() { public BlockFurnaceHeater() {
super("furnace_heater", BlockEntityFurnaceHeater::new, Properties.of(Material.STONE).strength(3F)); super("furnace_heater", BlockEntityFurnaceHeater.class, Properties.of(Material.STONE).strength(3F));
} }
@Override @Override

View file

@ -1,7 +1,7 @@
package de.ellpeck.naturesaura.blocks; package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityGeneratorLimitRemover; import de.ellpeck.naturesaura.blocks.tiles.BlockEntityGeneratorLimitRemover;
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities; import de.ellpeck.naturesaura.blocks.tiles.ModBlockEntities;
import de.ellpeck.naturesaura.blocks.tiles.render.RenderGeneratorLimitRemover; import de.ellpeck.naturesaura.blocks.tiles.render.RenderGeneratorLimitRemover;
import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.reg.ICustomBlockState; import de.ellpeck.naturesaura.reg.ICustomBlockState;
@ -13,7 +13,7 @@ import net.minecraft.world.level.material.Material;
public class BlockGeneratorLimitRemover extends BlockContainerImpl implements ITESRProvider<BlockEntityGeneratorLimitRemover>, ICustomBlockState { public class BlockGeneratorLimitRemover extends BlockContainerImpl implements ITESRProvider<BlockEntityGeneratorLimitRemover>, ICustomBlockState {
public BlockGeneratorLimitRemover() { public BlockGeneratorLimitRemover() {
super("generator_limit_remover", BlockEntityGeneratorLimitRemover::new, Properties.of(Material.STONE).strength(2F).sound(SoundType.STONE)); super("generator_limit_remover", BlockEntityGeneratorLimitRemover.class, Properties.of(Material.STONE).strength(2F).sound(SoundType.STONE));
} }
@Override @Override
@ -26,6 +26,6 @@ public class BlockGeneratorLimitRemover extends BlockContainerImpl implements IT
@Override @Override
public void registerTESR() { public void registerTESR() {
BlockEntityRenderers.register(ModTileEntities.GENERATOR_LIMIT_REMOVER, RenderGeneratorLimitRemover::new); BlockEntityRenderers.register(ModBlockEntities.GENERATOR_LIMIT_REMOVER, RenderGeneratorLimitRemover::new);
} }
} }

View file

@ -11,7 +11,6 @@ import net.minecraft.util.Mth;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult; import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.context.BlockPlaceContext; import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
@ -19,7 +18,6 @@ import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.HopperBlock; import net.minecraft.world.level.block.HopperBlock;
import net.minecraft.world.level.block.RenderShape; import net.minecraft.world.level.block.RenderShape;
import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.Hopper; import net.minecraft.world.level.block.entity.Hopper;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.StateDefinition;
@ -53,7 +51,7 @@ public class BlockGratedChute extends BlockContainerImpl implements ICustomBlock
private static final VoxelShape WEST_RAYTRACE_SHAPE = Shapes.or(Hopper.INSIDE, box(0.0D, 8.0D, 6.0D, 4.0D, 10.0D, 10.0D)); private static final VoxelShape WEST_RAYTRACE_SHAPE = Shapes.or(Hopper.INSIDE, box(0.0D, 8.0D, 6.0D, 4.0D, 10.0D, 10.0D));
public BlockGratedChute() { public BlockGratedChute() {
super("grated_chute", BlockEntityGratedChute::new, Properties.of(Material.METAL).strength(3.0F, 8.0F).sound(SoundType.METAL)); super("grated_chute", BlockEntityGratedChute.class, Properties.of(Material.METAL).strength(3.0F, 8.0F).sound(SoundType.METAL));
} }
@Override @Override

View file

@ -13,7 +13,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
public class BlockHopperUpgrade extends BlockContainerImpl implements IVisualizable { public class BlockHopperUpgrade extends BlockContainerImpl implements IVisualizable {
public BlockHopperUpgrade() { public BlockHopperUpgrade() {
super("hopper_upgrade", BlockEntityHopperUpgrade::new, Properties.of(Material.METAL).strength(2.5F).sound(SoundType.METAL)); super("hopper_upgrade", BlockEntityHopperUpgrade.class, Properties.of(Material.METAL).strength(2.5F).sound(SoundType.METAL));
} }
@Override @Override

View file

@ -9,14 +9,13 @@ import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.BlockHitResult;
public class BlockItemDistributor extends BlockContainerImpl implements ICustomBlockState { public class BlockItemDistributor extends BlockContainerImpl implements ICustomBlockState {
public BlockItemDistributor() { public BlockItemDistributor() {
super("item_distributor", BlockEntityItemDistributor::new, Properties.copy(Blocks.STONE_BRICKS)); super("item_distributor", BlockEntityItemDistributor.class, Properties.copy(Blocks.STONE_BRICKS));
} }
@Override @Override

View file

@ -13,7 +13,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
public class BlockMossGenerator extends BlockContainerImpl implements IVisualizable { public class BlockMossGenerator extends BlockContainerImpl implements IVisualizable {
public BlockMossGenerator() { public BlockMossGenerator() {
super("moss_generator", BlockEntityMossGenerator::new, Properties.of(Material.STONE).strength(2.5F).sound(SoundType.STONE)); super("moss_generator", BlockEntityMossGenerator.class, Properties.of(Material.STONE).strength(2.5F).sound(SoundType.STONE));
} }
@Override @Override

View file

@ -4,7 +4,7 @@ import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.aura.type.IAuraType; import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityNatureAltar; import de.ellpeck.naturesaura.blocks.tiles.BlockEntityNatureAltar;
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities; import de.ellpeck.naturesaura.blocks.tiles.ModBlockEntities;
import de.ellpeck.naturesaura.blocks.tiles.render.RenderNatureAltar; import de.ellpeck.naturesaura.blocks.tiles.render.RenderNatureAltar;
import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.reg.ICustomBlockState; import de.ellpeck.naturesaura.reg.ICustomBlockState;
@ -35,7 +35,7 @@ public class BlockNatureAltar extends BlockContainerImpl implements ITESRProvide
public static final BooleanProperty NETHER = BooleanProperty.create("nether"); public static final BooleanProperty NETHER = BooleanProperty.create("nether");
public BlockNatureAltar() { public BlockNatureAltar() {
super("nature_altar", BlockEntityNatureAltar::new, Block.Properties.of(Material.STONE).strength(4F)); super("nature_altar", BlockEntityNatureAltar.class, Block.Properties.of(Material.STONE).strength(4F));
this.registerDefaultState(this.defaultBlockState().setValue(NETHER, false)); this.registerDefaultState(this.defaultBlockState().setValue(NETHER, false));
} }
@ -75,6 +75,6 @@ public class BlockNatureAltar extends BlockContainerImpl implements ITESRProvide
@Override @Override
public void registerTESR() { public void registerTESR() {
BlockEntityRenderers.register(ModTileEntities.NATURE_ALTAR, RenderNatureAltar::new); BlockEntityRenderers.register(ModBlockEntities.NATURE_ALTAR, RenderNatureAltar::new);
} }
} }

View file

@ -19,12 +19,10 @@ import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.world.SaplingGrowTreeEvent; import net.minecraftforge.event.world.SaplingGrowTreeEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import java.util.Random;
public class BlockOakGenerator extends BlockContainerImpl implements IVisualizable, ICustomBlockState { public class BlockOakGenerator extends BlockContainerImpl implements IVisualizable, ICustomBlockState {
public BlockOakGenerator() { public BlockOakGenerator() {
super("oak_generator", BlockEntityOakGenerator::new, Properties.of(Material.WOOD).strength(2F).sound(SoundType.WOOD)); super("oak_generator", BlockEntityOakGenerator.class, Properties.of(Material.WOOD).strength(2F).sound(SoundType.WOOD));
MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(this);
} }

View file

@ -2,7 +2,7 @@ package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityOfferingTable; import de.ellpeck.naturesaura.blocks.tiles.BlockEntityOfferingTable;
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities; import de.ellpeck.naturesaura.blocks.tiles.ModBlockEntities;
import de.ellpeck.naturesaura.blocks.tiles.render.RenderOfferingTable; import de.ellpeck.naturesaura.blocks.tiles.render.RenderOfferingTable;
import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.reg.ICustomBlockState; import de.ellpeck.naturesaura.reg.ICustomBlockState;
@ -27,7 +27,7 @@ public class BlockOfferingTable extends BlockContainerImpl implements ITESRProvi
private static final VoxelShape SHAPE = Shapes.create(2 / 16F, 0F, 2 / 16F, 14 / 16F, 1F, 14 / 16F); private static final VoxelShape SHAPE = Shapes.create(2 / 16F, 0F, 2 / 16F, 14 / 16F, 1F, 14 / 16F);
public BlockOfferingTable() { public BlockOfferingTable() {
super("offering_table", BlockEntityOfferingTable::new, Properties.of(Material.WOOD).strength(2F).sound(SoundType.WOOD)); super("offering_table", BlockEntityOfferingTable.class, Properties.of(Material.WOOD).strength(2F).sound(SoundType.WOOD));
} }
@Override @Override
@ -52,6 +52,6 @@ public class BlockOfferingTable extends BlockContainerImpl implements ITESRProvi
@Override @Override
public void registerTESR() { public void registerTESR() {
BlockEntityRenderers.register(ModTileEntities.OFFERING_TABLE, RenderOfferingTable::new); BlockEntityRenderers.register(ModBlockEntities.OFFERING_TABLE, RenderOfferingTable::new);
} }
} }

View file

@ -8,11 +8,8 @@ import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticles; import de.ellpeck.naturesaura.packet.PacketParticles;
import de.ellpeck.naturesaura.reg.ICustomBlockState; import de.ellpeck.naturesaura.reg.ICustomBlockState;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.material.Material; import net.minecraft.world.level.material.Material;
import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.AABB;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
@ -24,7 +21,7 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
public class BlockPickupStopper extends BlockContainerImpl implements IVisualizable, ICustomBlockState { public class BlockPickupStopper extends BlockContainerImpl implements IVisualizable, ICustomBlockState {
public BlockPickupStopper() { public BlockPickupStopper() {
super("pickup_stopper", BlockEntityPickupStopper::new, Properties.of(Material.STONE).strength(2F).sound(SoundType.STONE)); super("pickup_stopper", BlockEntityPickupStopper.class, Properties.of(Material.STONE).strength(2F).sound(SoundType.STONE));
MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(this);
} }

View file

@ -15,7 +15,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
public class BlockPlacer extends BlockContainerImpl implements IVisualizable, ICustomBlockState { public class BlockPlacer extends BlockContainerImpl implements IVisualizable, ICustomBlockState {
public BlockPlacer() { public BlockPlacer() {
super("placer", BlockEntityPlacer::new, Properties.of(Material.STONE).strength(2.5F).sound(SoundType.STONE)); super("placer", BlockEntityPlacer.class, Properties.of(Material.STONE).strength(2.5F).sound(SoundType.STONE));
} }
@Override @Override

View file

@ -8,7 +8,7 @@ import net.minecraft.world.level.material.Material;
public class BlockPotionGenerator extends BlockContainerImpl implements ICustomBlockState { public class BlockPotionGenerator extends BlockContainerImpl implements ICustomBlockState {
public BlockPotionGenerator() { public BlockPotionGenerator() {
super("potion_generator", BlockEntityPotionGenerator::new, Properties.of(Material.STONE).strength(5F)); super("potion_generator", BlockEntityPotionGenerator.class, Properties.of(Material.STONE).strength(5F));
} }
@Override @Override

View file

@ -17,7 +17,7 @@ public class BlockPowderPlacer extends BlockContainerImpl implements ICustomBloc
private static final VoxelShape SHAPE = Shapes.create(0F, 0F, 0F, 1F, 4 / 16F, 1F); private static final VoxelShape SHAPE = Shapes.create(0F, 0F, 0F, 1F, 4 / 16F, 1F);
public BlockPowderPlacer() { public BlockPowderPlacer() {
super("powder_placer", BlockEntityPowderPlacer::new, Properties.of(Material.STONE).strength(2, 5F).sound(SoundType.STONE)); super("powder_placer", BlockEntityPowderPlacer.class, Properties.of(Material.STONE).strength(2, 5F).sound(SoundType.STONE));
} }
@Override @Override

View file

@ -2,7 +2,7 @@ package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityProjectileGenerator; import de.ellpeck.naturesaura.blocks.tiles.BlockEntityProjectileGenerator;
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities; import de.ellpeck.naturesaura.blocks.tiles.ModBlockEntities;
import de.ellpeck.naturesaura.blocks.tiles.render.RenderProjectileGenerator; import de.ellpeck.naturesaura.blocks.tiles.render.RenderProjectileGenerator;
import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.packet.PacketHandler; import de.ellpeck.naturesaura.packet.PacketHandler;
@ -10,12 +10,10 @@ import de.ellpeck.naturesaura.packet.PacketParticles;
import de.ellpeck.naturesaura.reg.ICustomBlockState; import de.ellpeck.naturesaura.reg.ICustomBlockState;
import de.ellpeck.naturesaura.reg.ITESRProvider; import de.ellpeck.naturesaura.reg.ITESRProvider;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderers; import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Position; import net.minecraft.core.Position;
import net.minecraft.core.dispenser.AbstractProjectileDispenseBehavior; import net.minecraft.core.dispenser.AbstractProjectileDispenseBehavior;
import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource; import net.minecraft.sounds.SoundSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.projectile.AbstractArrow; import net.minecraft.world.entity.projectile.AbstractArrow;
import net.minecraft.world.entity.projectile.Projectile; import net.minecraft.world.entity.projectile.Projectile;
@ -26,10 +24,8 @@ import net.minecraft.world.item.Items;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.DispenserBlock; import net.minecraft.world.level.block.DispenserBlock;
import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.material.Material; import net.minecraft.world.level.material.Material;
import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.HitResult;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.ProjectileImpactEvent; import net.minecraftforge.event.entity.ProjectileImpactEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
@ -38,7 +34,7 @@ import net.minecraftforge.fml.util.ObfuscationReflectionHelper;
public class BlockProjectileGenerator extends BlockContainerImpl implements ITESRProvider<BlockEntityProjectileGenerator>, ICustomBlockState { public class BlockProjectileGenerator extends BlockContainerImpl implements ITESRProvider<BlockEntityProjectileGenerator>, ICustomBlockState {
public BlockProjectileGenerator() { public BlockProjectileGenerator() {
super("projectile_generator", BlockEntityProjectileGenerator::new, Properties.of(Material.STONE).strength(2.5F).sound(SoundType.STONE)); super("projectile_generator", BlockEntityProjectileGenerator.class, Properties.of(Material.STONE).strength(2.5F).sound(SoundType.STONE));
MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(this);
DispenserBlock.registerBehavior(Items.ENDER_PEARL, new AbstractProjectileDispenseBehavior() { DispenserBlock.registerBehavior(Items.ENDER_PEARL, new AbstractProjectileDispenseBehavior() {
@ -55,7 +51,7 @@ public class BlockProjectileGenerator extends BlockContainerImpl implements ITES
protected Projectile getProjectile(Level levelIn, Position position, ItemStack stackIn) { protected Projectile getProjectile(Level levelIn, Position position, ItemStack stackIn) {
var ret = new ThrownTrident(EntityType.TRIDENT, levelIn); var ret = new ThrownTrident(EntityType.TRIDENT, levelIn);
ret.setPos(position.x(), position.y(), position.z()); ret.setPos(position.x(), position.y(), position.z());
ObfuscationReflectionHelper.setPrivateValue(ThrownTrident.class, ret, stackIn.copy(), "tridentItem"); ObfuscationReflectionHelper.setPrivateValue(ThrownTrident.class, ret, stackIn.copy(), "f_37555_");
ret.pickup = AbstractArrow.Pickup.ALLOWED; ret.pickup = AbstractArrow.Pickup.ALLOWED;
return ret; return ret;
} }
@ -106,6 +102,6 @@ public class BlockProjectileGenerator extends BlockContainerImpl implements ITES
@Override @Override
public void registerTESR() { public void registerTESR() {
BlockEntityRenderers.register(ModTileEntities.PROJECTILE_GENERATOR, RenderProjectileGenerator::new); BlockEntityRenderers.register(ModBlockEntities.PROJECTILE_GENERATOR, RenderProjectileGenerator::new);
} }
} }

View file

@ -9,7 +9,7 @@ import net.minecraft.world.level.material.Material;
public class BlockRFConverter extends BlockContainerImpl { public class BlockRFConverter extends BlockContainerImpl {
public BlockRFConverter() { public BlockRFConverter() {
super("rf_converter", BlockEntityRFConverter::new, Properties.of(Material.STONE).sound(SoundType.STONE).strength(3)); super("rf_converter", BlockEntityRFConverter.class, Properties.of(Material.STONE).sound(SoundType.STONE).strength(3));
} }
@Override @Override

View file

@ -6,7 +6,6 @@ import de.ellpeck.naturesaura.blocks.tiles.BlockEntitySlimeSplitGenerator;
import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.reg.ICustomBlockState; import de.ellpeck.naturesaura.reg.ICustomBlockState;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.monster.Slime; import net.minecraft.world.entity.monster.Slime;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
@ -20,7 +19,7 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
public class BlockSlimeSplitGenerator extends BlockContainerImpl implements IVisualizable, ICustomBlockState { public class BlockSlimeSplitGenerator extends BlockContainerImpl implements IVisualizable, ICustomBlockState {
public BlockSlimeSplitGenerator() { public BlockSlimeSplitGenerator() {
super("slime_split_generator", BlockEntitySlimeSplitGenerator::new, Properties.copy(Blocks.SLIME_BLOCK).strength(2)); super("slime_split_generator", BlockEntitySlimeSplitGenerator.class, Properties.copy(Blocks.SLIME_BLOCK).strength(2));
MinecraftForge.EVENT_BUS.register(new Events()); MinecraftForge.EVENT_BUS.register(new Events());
} }

View file

@ -7,7 +7,6 @@ import de.ellpeck.naturesaura.reg.ICustomBlockState;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.AABB;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
@ -15,7 +14,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
public class BlockSnowCreator extends BlockContainerImpl implements IVisualizable, ICustomBlockState { public class BlockSnowCreator extends BlockContainerImpl implements IVisualizable, ICustomBlockState {
public BlockSnowCreator() { public BlockSnowCreator() {
super("snow_creator", BlockEntitySnowCreator::new, Properties.copy(Blocks.STONE_BRICKS)); super("snow_creator", BlockEntitySnowCreator.class, Properties.copy(Blocks.STONE_BRICKS));
} }
@Override @Override

View file

@ -16,9 +16,7 @@ import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.Mob;
import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material; import net.minecraft.world.level.material.Material;
import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.AABB;
@ -40,7 +38,7 @@ public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizable,
private static final VoxelShape SHAPE = Shapes.create(4 / 16F, 0F, 4 / 16F, 12 / 16F, 13 / 16F, 12 / 16F); private static final VoxelShape SHAPE = Shapes.create(4 / 16F, 0F, 4 / 16F, 12 / 16F, 13 / 16F, 12 / 16F);
public BlockSpawnLamp() { public BlockSpawnLamp() {
super("spawn_lamp", BlockEntitySpawnLamp::new, Properties.of(Material.METAL).strength(3F).lightLevel(s -> 15).sound(SoundType.METAL)); super("spawn_lamp", BlockEntitySpawnLamp.class, Properties.of(Material.METAL).strength(3F).lightLevel(s -> 15).sound(SoundType.METAL));
MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(this);
} }

View file

@ -19,7 +19,6 @@ import net.minecraft.world.item.Items;
import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.BucketPickup; import net.minecraft.world.level.block.BucketPickup;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Fluids; import net.minecraft.world.level.material.Fluids;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
@ -31,7 +30,7 @@ import java.util.function.Supplier;
public class BlockSpring extends BlockContainerImpl implements ICustomBlockState, IColorProvidingBlock, IColorProvidingItem, BucketPickup, ICustomRenderType { public class BlockSpring extends BlockContainerImpl implements ICustomBlockState, IColorProvidingBlock, IColorProvidingItem, BucketPickup, ICustomRenderType {
public BlockSpring() { public BlockSpring() {
super("spring", BlockEntitySpring::new, Properties.copy(Blocks.STONE_BRICKS)); super("spring", BlockEntitySpring.class, Properties.copy(Blocks.STONE_BRICKS));
} }
@Override @Override

View file

@ -9,7 +9,7 @@ import net.minecraft.world.level.material.Material;
public class BlockTimeChanger extends BlockContainerImpl implements ICustomBlockState { public class BlockTimeChanger extends BlockContainerImpl implements ICustomBlockState {
public BlockTimeChanger() { public BlockTimeChanger() {
super("time_changer", BlockEntityTimeChanger::new, Properties.of(Material.STONE).strength(2.5F).sound(SoundType.STONE)); super("time_changer", BlockEntityTimeChanger.class, Properties.of(Material.STONE).strength(2.5F).sound(SoundType.STONE));
} }
@Override @Override

View file

@ -8,7 +8,7 @@ import net.minecraft.world.level.block.Blocks;
public class BlockWeatherChanger extends BlockContainerImpl implements ICustomBlockState { public class BlockWeatherChanger extends BlockContainerImpl implements ICustomBlockState {
public BlockWeatherChanger() { public BlockWeatherChanger() {
super("weather_changer", BlockEntityWeatherChanger::new, Properties.copy(Blocks.STONE_BRICKS)); super("weather_changer", BlockEntityWeatherChanger.class, Properties.copy(Blocks.STONE_BRICKS));
} }
@Override @Override

View file

@ -3,11 +3,10 @@ package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.blocks.multi.Multiblocks; import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityWoodStand; import de.ellpeck.naturesaura.blocks.tiles.BlockEntityWoodStand;
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities; import de.ellpeck.naturesaura.blocks.tiles.ModBlockEntities;
import de.ellpeck.naturesaura.blocks.tiles.render.RenderWoodStand; import de.ellpeck.naturesaura.blocks.tiles.render.RenderWoodStand;
import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.recipes.ModRecipes; import de.ellpeck.naturesaura.recipes.ModRecipes;
import de.ellpeck.naturesaura.recipes.TreeRitualRecipe;
import de.ellpeck.naturesaura.reg.ICustomBlockState; import de.ellpeck.naturesaura.reg.ICustomBlockState;
import de.ellpeck.naturesaura.reg.ITESRProvider; import de.ellpeck.naturesaura.reg.ITESRProvider;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderers; import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
@ -15,13 +14,10 @@ import net.minecraft.core.BlockPos;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult; import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material; import net.minecraft.world.level.material.Material;
import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.BlockHitResult;
@ -42,7 +38,7 @@ public class BlockWoodStand extends BlockContainerImpl implements ITESRProvider<
private static final VoxelShape SHAPE = Shapes.create(3 / 16F, 0F, 3 / 16F, 13 / 16F, 13 / 16F, 13 / 16F); private static final VoxelShape SHAPE = Shapes.create(3 / 16F, 0F, 3 / 16F, 13 / 16F, 13 / 16F, 13 / 16F);
public BlockWoodStand() { public BlockWoodStand() {
super("wood_stand", BlockEntityWoodStand::new, Properties.of(Material.WOOD).strength(1.5F).sound(SoundType.WOOD)); super("wood_stand", BlockEntityWoodStand.class, Properties.of(Material.WOOD).strength(1.5F).sound(SoundType.WOOD));
MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(this);
} }
@ -115,6 +111,6 @@ public class BlockWoodStand extends BlockContainerImpl implements ITESRProvider<
@Override @Override
public void registerTESR() { public void registerTESR() {
BlockEntityRenderers.register(ModTileEntities.WOOD_STAND, RenderWoodStand::new); BlockEntityRenderers.register(ModBlockEntities.WOOD_STAND, RenderWoodStand::new);
} }
} }

View file

@ -26,7 +26,7 @@ public class BlockEntityAncientLeaves extends BlockEntityImpl {
}; };
public BlockEntityAncientLeaves(BlockPos pos, BlockState state) { public BlockEntityAncientLeaves(BlockPos pos, BlockState state) {
super(ModTileEntities.ANCIENT_LEAVES, pos, state); super(ModBlockEntities.ANCIENT_LEAVES, pos, state);
} }
@Override @Override

View file

@ -13,7 +13,7 @@ import java.util.Set;
public class BlockEntityAnimalContainer extends BlockEntityImpl implements ITickableBlockEntity { public class BlockEntityAnimalContainer extends BlockEntityImpl implements ITickableBlockEntity {
public BlockEntityAnimalContainer(BlockPos pos, BlockState state) { public BlockEntityAnimalContainer(BlockPos pos, BlockState state) {
super(ModTileEntities.ANIMAL_CONTAINER, pos, state); super(ModBlockEntities.ANIMAL_CONTAINER, pos, state);
} }
public int getRadius() { public int getRadius() {

View file

@ -11,7 +11,7 @@ public class BlockEntityAnimalGenerator extends BlockEntityImpl implements ITick
private int amountToRelease; private int amountToRelease;
public BlockEntityAnimalGenerator(BlockPos pos, BlockState state) { public BlockEntityAnimalGenerator(BlockPos pos, BlockState state) {
super(ModTileEntities.ANIMAL_GENERATOR, pos, state); super(ModBlockEntities.ANIMAL_GENERATOR, pos, state);
} }
@Override @Override

View file

@ -15,7 +15,6 @@ import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.AABB;
@ -33,7 +32,7 @@ public class BlockEntityAnimalSpawner extends BlockEntityImpl implements ITickab
private Entity entityClient; private Entity entityClient;
public BlockEntityAnimalSpawner(BlockPos pos, BlockState state) { public BlockEntityAnimalSpawner(BlockPos pos, BlockState state) {
super(ModTileEntities.ANIMAL_SPAWNER, pos, state); super(ModBlockEntities.ANIMAL_SPAWNER, pos, state);
} }
@Override @Override

View file

@ -10,7 +10,7 @@ public class BlockEntityAuraBloom extends BlockEntityImpl implements ITickableBl
public boolean justGenerated; public boolean justGenerated;
public BlockEntityAuraBloom(BlockPos pos, BlockState state) { public BlockEntityAuraBloom(BlockPos pos, BlockState state) {
this(ModTileEntities.AURA_BLOOM, pos, state); this(ModBlockEntities.AURA_BLOOM, pos, state);
} }
protected BlockEntityAuraBloom(BlockEntityType<BlockEntityAuraBloom> type, BlockPos pos, BlockState state) { protected BlockEntityAuraBloom(BlockEntityType<BlockEntityAuraBloom> type, BlockPos pos, BlockState state) {

View file

@ -10,7 +10,7 @@ public class BlockEntityAuraDetector extends BlockEntityImpl implements ITickabl
public int redstonePower; public int redstonePower;
public BlockEntityAuraDetector(BlockPos pos, BlockState state) { public BlockEntityAuraDetector(BlockPos pos, BlockState state) {
super(ModTileEntities.AURA_DETECTOR, pos, state); super(ModBlockEntities.AURA_DETECTOR, pos, state);
} }
@Override @Override

View file

@ -31,7 +31,7 @@ public class BlockEntityAuraTimer extends BlockEntityImpl implements ITickableBl
private int timer; private int timer;
public BlockEntityAuraTimer(BlockPos pos, BlockState state) { public BlockEntityAuraTimer(BlockPos pos, BlockState state) {
super(ModTileEntities.AURA_TIMER, pos, state); super(ModBlockEntities.AURA_TIMER, pos, state);
} }
@Override @Override

View file

@ -5,7 +5,6 @@ import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
import de.ellpeck.naturesaura.packet.PacketHandler; import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticles; import de.ellpeck.naturesaura.packet.PacketParticles;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.entity.EntitySelector; import net.minecraft.world.entity.EntitySelector;
import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
@ -25,7 +24,7 @@ public class BlockEntityAutoCrafter extends BlockEntityImpl implements ITickable
}, 3, 3); }, 3, 3);
public BlockEntityAutoCrafter(BlockPos pos, BlockState state) { public BlockEntityAutoCrafter(BlockPos pos, BlockState state) {
super(ModTileEntities.AUTO_CRAFTER, pos, state); super(ModBlockEntities.AUTO_CRAFTER, pos, state);
} }
@Override @Override

View file

@ -5,15 +5,12 @@ import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticles; import de.ellpeck.naturesaura.packet.PacketParticles;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.world.inventory.ContainerData;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.item.crafting.Recipe; import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.level.block.entity.BlastFurnaceBlockEntity; import net.minecraft.world.level.block.entity.BlastFurnaceBlockEntity;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.IItemHandlerModifiable;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
@ -22,7 +19,7 @@ import java.util.List;
public class BlockEntityBlastFurnaceBooster extends BlockEntityImpl implements ITickableBlockEntity { public class BlockEntityBlastFurnaceBooster extends BlockEntityImpl implements ITickableBlockEntity {
public BlockEntityBlastFurnaceBooster(BlockPos pos, BlockState state) { public BlockEntityBlastFurnaceBooster(BlockPos pos, BlockState state) {
super(ModTileEntities.BLAST_FURNACE_BOOSTER, pos, state); super(ModBlockEntities.BLAST_FURNACE_BOOSTER, pos, state);
} }
@Override @Override

View file

@ -23,7 +23,7 @@ public class BlockEntityChorusGenerator extends BlockEntityImpl implements ITick
private int auraPerBlock; private int auraPerBlock;
public BlockEntityChorusGenerator(BlockPos pos, BlockState state) { public BlockEntityChorusGenerator(BlockPos pos, BlockState state) {
super(ModTileEntities.CHORUS_GENERATOR, pos, state); super(ModBlockEntities.CHORUS_GENERATOR, pos, state);
} }
@Override @Override

View file

@ -20,7 +20,7 @@ public class BlockEntityChunkLoader extends BlockEntityImpl implements ITickable
private boolean firstTick = true; private boolean firstTick = true;
public BlockEntityChunkLoader(BlockPos pos, BlockState state) { public BlockEntityChunkLoader(BlockPos pos, BlockState state) {
super(ModTileEntities.CHUNK_LOADER, pos, state); super(ModBlockEntities.CHUNK_LOADER, pos, state);
} }
@Override @Override

View file

@ -9,14 +9,11 @@ import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items; import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.AABB;
import java.util.List;
public class BlockEntityEndFlower extends BlockEntityImpl implements ITickableBlockEntity { public class BlockEntityEndFlower extends BlockEntityImpl implements ITickableBlockEntity {
private final BasicAuraContainer container = new BasicAuraContainer(null, 500000) { private final BasicAuraContainer container = new BasicAuraContainer(null, 500000) {
@ -46,7 +43,7 @@ public class BlockEntityEndFlower extends BlockEntityImpl implements ITickableBl
public boolean isDrainMode; public boolean isDrainMode;
public BlockEntityEndFlower(BlockPos pos, BlockState state) { public BlockEntityEndFlower(BlockPos pos, BlockState state) {
super(ModTileEntities.END_FLOWER, pos, state); super(ModBlockEntities.END_FLOWER, pos, state);
} }
@Override @Override

View file

@ -76,7 +76,7 @@ public class BlockEntityEnderCrate extends BlockEntityImpl implements MenuProvid
}; };
public BlockEntityEnderCrate(BlockPos pos, BlockState state) { public BlockEntityEnderCrate(BlockPos pos, BlockState state) {
super(ModTileEntities.ENDER_CRATE, pos, state); super(ModBlockEntities.ENDER_CRATE, pos, state);
} }
@Override @Override

View file

@ -10,22 +10,17 @@ import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.world.entity.decoration.ItemFrame;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items; import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.storage.loot.LootContext; import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.parameters.LootContextParams; import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.common.util.FakePlayerFactory; import net.minecraftforge.common.util.FakePlayerFactory;
import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.event.world.BlockEvent;
import java.util.List;
public class BlockEntityFieldCreator extends BlockEntityImpl implements ITickableBlockEntity { public class BlockEntityFieldCreator extends BlockEntityImpl implements ITickableBlockEntity {
public BlockPos connectionOffset; public BlockPos connectionOffset;
@ -34,7 +29,7 @@ public class BlockEntityFieldCreator extends BlockEntityImpl implements ITickabl
private int chargeTimer; private int chargeTimer;
public BlockEntityFieldCreator(BlockPos pos, BlockState state) { public BlockEntityFieldCreator(BlockPos pos, BlockState state) {
super(ModTileEntities.FIELD_CREATOR, pos, state); super(ModBlockEntities.FIELD_CREATOR, pos, state);
} }
@Override @Override

View file

@ -5,8 +5,6 @@ import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticles; import de.ellpeck.naturesaura.packet.PacketParticles;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.Tag;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.item.ItemEntity;
@ -29,7 +27,7 @@ public class BlockEntityFireworkGenerator extends BlockEntityImpl implements ITi
private int releaseTimer; private int releaseTimer;
public BlockEntityFireworkGenerator(BlockPos pos, BlockState state) { public BlockEntityFireworkGenerator(BlockPos pos, BlockState state) {
super(ModTileEntities.FIREWORK_GENERATOR, pos, state); super(ModBlockEntities.FIREWORK_GENERATOR, pos, state);
} }
@Override @Override

View file

@ -9,10 +9,8 @@ import de.ellpeck.naturesaura.packet.PacketParticles;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag; import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.Tag;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BlockTags; import net.minecraft.tags.BlockTags;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.ForgeRegistries;
import org.apache.commons.lang3.mutable.MutableInt; import org.apache.commons.lang3.mutable.MutableInt;
@ -27,7 +25,7 @@ public class BlockEntityFlowerGenerator extends BlockEntityImpl implements ITick
private final Map<BlockState, MutableInt> consumedRecently = new HashMap<>(); private final Map<BlockState, MutableInt> consumedRecently = new HashMap<>();
public BlockEntityFlowerGenerator(BlockPos pos, BlockState state) { public BlockEntityFlowerGenerator(BlockPos pos, BlockState state) {
super(ModTileEntities.FLOWER_GENERATOR, pos, state); super(ModBlockEntities.FLOWER_GENERATOR, pos, state);
} }
@Override @Override

View file

@ -8,17 +8,14 @@ import de.ellpeck.naturesaura.blocks.BlockFurnaceHeater;
import de.ellpeck.naturesaura.packet.PacketHandler; import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticleStream; import de.ellpeck.naturesaura.packet.PacketParticleStream;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.world.inventory.ContainerData; import net.minecraft.world.inventory.ContainerData;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.AbstractCookingRecipe; import net.minecraft.world.item.crafting.AbstractCookingRecipe;
import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.item.crafting.RecipeType;
import net.minecraft.world.level.block.AbstractFurnaceBlock; import net.minecraft.world.level.block.AbstractFurnaceBlock;
import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity; import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity;
import net.minecraft.world.level.block.entity.BlastFurnaceBlockEntity; import net.minecraft.world.level.block.entity.BlastFurnaceBlockEntity;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.SmokerBlockEntity; import net.minecraft.world.level.block.entity.SmokerBlockEntity;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.fml.util.ObfuscationReflectionHelper; import net.minecraftforge.fml.util.ObfuscationReflectionHelper;
@ -27,11 +24,11 @@ import java.lang.reflect.Field;
public class BlockEntityFurnaceHeater extends BlockEntityImpl implements ITickableBlockEntity { public class BlockEntityFurnaceHeater extends BlockEntityImpl implements ITickableBlockEntity {
private static final Field FURNACE_DATA_FIELD = ObfuscationReflectionHelper.findField(AbstractFurnaceBlockEntity.class, "dataAccess"); private static final Field FURNACE_DATA_FIELD = ObfuscationReflectionHelper.findField(AbstractFurnaceBlockEntity.class, "f_58311_");
public boolean isActive; public boolean isActive;
public BlockEntityFurnaceHeater(BlockPos pos, BlockState state) { public BlockEntityFurnaceHeater(BlockPos pos, BlockState state) {
super(ModTileEntities.FURNACE_HEATER, pos, state); super(ModBlockEntities.FURNACE_HEATER, pos, state);
} }
public static ContainerData getFurnaceData(AbstractFurnaceBlockEntity tile) { public static ContainerData getFurnaceData(AbstractFurnaceBlockEntity tile) {

View file

@ -9,7 +9,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
public class BlockEntityGeneratorLimitRemover extends BlockEntityImpl { public class BlockEntityGeneratorLimitRemover extends BlockEntityImpl {
public BlockEntityGeneratorLimitRemover(BlockPos pos, BlockState state) { public BlockEntityGeneratorLimitRemover(BlockPos pos, BlockState state) {
super(ModTileEntities.GENERATOR_LIMIT_REMOVER, pos, state); super(ModBlockEntities.GENERATOR_LIMIT_REMOVER, pos, state);
} }
@Override @Override

View file

@ -5,18 +5,13 @@ import de.ellpeck.naturesaura.blocks.BlockGratedChute;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.entity.decoration.ItemFrame;
import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.AABB;
import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.IItemHandlerModifiable;
import java.util.List;
public class BlockEntityGratedChute extends BlockEntityImpl implements ITickableBlockEntity { public class BlockEntityGratedChute extends BlockEntityImpl implements ITickableBlockEntity {
public boolean isBlacklist; public boolean isBlacklist;
@ -34,7 +29,7 @@ public class BlockEntityGratedChute extends BlockEntityImpl implements ITickable
private int cooldown; private int cooldown;
public BlockEntityGratedChute(BlockPos pos, BlockState state) { public BlockEntityGratedChute(BlockPos pos, BlockState state) {
super(ModTileEntities.GRATED_CHUTE, pos, state); super(ModBlockEntities.GRATED_CHUTE, pos, state);
} }
@Override @Override
@ -80,7 +75,7 @@ public class BlockEntityGratedChute extends BlockEntityImpl implements ITickable
if (stack.isEmpty()) if (stack.isEmpty())
continue; continue;
var left = this.items.insertItem(0, stack, false); var left = this.items.insertItem(0, stack, false);
if (!ItemStack.isSame(stack, left)) { if (!ItemStack.matches(stack, left)) {
if (left.isEmpty()) { if (left.isEmpty()) {
item.kill(); item.kill();
} else { } else {

View file

@ -13,14 +13,11 @@ import net.minecraft.world.level.block.entity.HopperBlockEntity;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.AABB;
import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import java.util.List;
public class BlockEntityHopperUpgrade extends BlockEntityImpl implements ITickableBlockEntity { public class BlockEntityHopperUpgrade extends BlockEntityImpl implements ITickableBlockEntity {
public BlockEntityHopperUpgrade(BlockPos pos, BlockState state) { public BlockEntityHopperUpgrade(BlockPos pos, BlockState state) {
super(ModTileEntities.HOPPER_UPGRADE, pos, state); super(ModBlockEntities.HOPPER_UPGRADE, pos, state);
} }
private static boolean isValidHopper(BlockEntity tile) { private static boolean isValidHopper(BlockEntity tile) {
@ -62,7 +59,7 @@ public class BlockEntityHopperUpgrade extends BlockEntityImpl implements ITickab
} }
} }
if (!ItemStack.isSame(stack, copy)) { if (!ItemStack.matches(stack, copy)) {
item.setItem(copy); item.setItem(copy);
if (copy.isEmpty()) if (copy.isEmpty())
item.kill(); item.kill();

View file

@ -4,7 +4,6 @@ import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
@ -19,7 +18,7 @@ public class BlockEntityItemDistributor extends BlockEntityImpl implements ITick
public boolean isRandomMode; public boolean isRandomMode;
public BlockEntityItemDistributor(BlockPos pos, BlockState state) { public BlockEntityItemDistributor(BlockPos pos, BlockState state) {
super(ModTileEntities.ITEM_DISTRIBUTOR, pos, state); super(ModBlockEntities.ITEM_DISTRIBUTOR, pos, state);
} }
@Override @Override
@ -44,7 +43,7 @@ public class BlockEntityItemDistributor extends BlockEntityImpl implements ITick
continue; continue;
for (var j = 0; j < dest.getSlots(); j++) { for (var j = 0; j < dest.getSlots(); j++) {
var remain = dest.insertItem(j, stack, false); var remain = dest.insertItem(j, stack, false);
if (!ItemStack.isSame(remain, stack)) { if (!ItemStack.matches(remain, stack)) {
above.extractItem(i, 1, false); above.extractItem(i, 1, false);
this.cooldown = 3; this.cooldown = 3;
return; return;

View file

@ -15,7 +15,7 @@ import java.util.List;
public class BlockEntityMossGenerator extends BlockEntityImpl implements ITickableBlockEntity { public class BlockEntityMossGenerator extends BlockEntityImpl implements ITickableBlockEntity {
public BlockEntityMossGenerator(BlockPos pos, BlockState state) { public BlockEntityMossGenerator(BlockPos pos, BlockState state) {
super(ModTileEntities.MOSS_GENERATOR, pos, state); super(ModBlockEntities.MOSS_GENERATOR, pos, state);
} }
@Override @Override

View file

@ -65,7 +65,7 @@ public class BlockEntityNatureAltar extends BlockEntityImpl implements ITickable
private boolean firstTick = true; private boolean firstTick = true;
public BlockEntityNatureAltar(BlockPos pos, BlockState state) { public BlockEntityNatureAltar(BlockPos pos, BlockState state) {
super(ModTileEntities.NATURE_ALTAR, pos, state); super(ModBlockEntities.NATURE_ALTAR, pos, state);
} }
@Override @Override

View file

@ -14,7 +14,7 @@ public class BlockEntityOakGenerator extends BlockEntityImpl implements ITickabl
public Queue<BlockPos> scheduledBigTrees = new ArrayDeque<>(); public Queue<BlockPos> scheduledBigTrees = new ArrayDeque<>();
public BlockEntityOakGenerator(BlockPos pos, BlockState state) { public BlockEntityOakGenerator(BlockPos pos, BlockState state) {
super(ModTileEntities.OAK_GENERATOR, pos, state); super(ModBlockEntities.OAK_GENERATOR, pos, state);
} }
@Override @Override

View file

@ -9,9 +9,7 @@ import de.ellpeck.naturesaura.recipes.OfferingRecipe;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag; import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.Tag;
import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LightningBolt;
import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items; import net.minecraft.world.item.Items;
@ -23,7 +21,6 @@ import net.minecraftforge.items.IItemHandlerModifiable;
import net.minecraftforge.items.ItemStackHandler; import net.minecraftforge.items.ItemStackHandler;
import java.util.ArrayDeque; import java.util.ArrayDeque;
import java.util.List;
import java.util.Queue; import java.util.Queue;
public class BlockEntityOfferingTable extends BlockEntityImpl implements ITickableBlockEntity { public class BlockEntityOfferingTable extends BlockEntityImpl implements ITickableBlockEntity {
@ -37,7 +34,7 @@ public class BlockEntityOfferingTable extends BlockEntityImpl implements ITickab
private final Queue<ItemStack> itemsToSpawn = new ArrayDeque<>(); private final Queue<ItemStack> itemsToSpawn = new ArrayDeque<>();
public BlockEntityOfferingTable(BlockPos pos, BlockState state) { public BlockEntityOfferingTable(BlockPos pos, BlockState state) {
super(ModTileEntities.OFFERING_TABLE, pos, state); super(ModBlockEntities.OFFERING_TABLE, pos, state);
} }
private OfferingRecipe getRecipe(ItemStack input) { private OfferingRecipe getRecipe(ItemStack input) {

View file

@ -6,7 +6,7 @@ import net.minecraft.world.level.block.state.BlockState;
public class BlockEntityPickupStopper extends BlockEntityImpl { public class BlockEntityPickupStopper extends BlockEntityImpl {
public BlockEntityPickupStopper(BlockPos pos, BlockState state) { public BlockEntityPickupStopper(BlockPos pos, BlockState state) {
super(ModTileEntities.PICKUP_STOPPER, pos, state); super(ModBlockEntities.PICKUP_STOPPER, pos, state);
} }
public float getRadius() { public float getRadius() {

View file

@ -13,15 +13,12 @@ import net.minecraft.world.entity.decoration.ItemFrame;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.context.UseOnContext; import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.common.util.FakePlayerFactory; import net.minecraftforge.common.util.FakePlayerFactory;
import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -29,7 +26,7 @@ import java.util.List;
public class BlockEntityPlacer extends BlockEntityImpl implements ITickableBlockEntity { public class BlockEntityPlacer extends BlockEntityImpl implements ITickableBlockEntity {
public BlockEntityPlacer(BlockPos pos, BlockState state) { public BlockEntityPlacer(BlockPos pos, BlockState state) {
super(ModTileEntities.PLACER, pos, state); super(ModBlockEntities.PLACER, pos, state);
} }
@Override @Override
@ -71,7 +68,7 @@ public class BlockEntityPlacer extends BlockEntityImpl implements ITickableBlock
var pos = validPositions.get(this.level.random.nextInt(validPositions.size())); var pos = validPositions.get(this.level.random.nextInt(validPositions.size()));
var left = this.tryPlace(stack.copy(), pos); var left = this.tryPlace(stack.copy(), pos);
if (ItemStack.isSame(stack, left)) if (ItemStack.matches(stack, left))
continue; continue;
handler.extractItem(i, 1, false); handler.extractItem(i, 1, false);

View file

@ -4,20 +4,15 @@ import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
import de.ellpeck.naturesaura.packet.PacketHandler; import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticles; import de.ellpeck.naturesaura.packet.PacketParticles;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.AreaEffectCloud; import net.minecraft.world.entity.AreaEffectCloud;
import net.minecraft.world.item.alchemy.Potion;
import net.minecraft.world.item.alchemy.PotionUtils; import net.minecraft.world.item.alchemy.PotionUtils;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.AABB;
import java.util.List;
public class BlockEntityPotionGenerator extends BlockEntityImpl implements ITickableBlockEntity { public class BlockEntityPotionGenerator extends BlockEntityImpl implements ITickableBlockEntity {
public BlockEntityPotionGenerator(BlockPos pos, BlockState state) { public BlockEntityPotionGenerator(BlockPos pos, BlockState state) {
super(ModTileEntities.POTION_GENERATOR, pos, state); super(ModBlockEntities.POTION_GENERATOR, pos, state);
} }
@Override @Override

View file

@ -5,19 +5,14 @@ import de.ellpeck.naturesaura.items.ModItems;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.AABB;
import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import java.util.List;
public class BlockEntityPowderPlacer extends BlockEntityImpl { public class BlockEntityPowderPlacer extends BlockEntityImpl {
public BlockEntityPowderPlacer(BlockPos pos, BlockState state) { public BlockEntityPowderPlacer(BlockPos pos, BlockState state) {
super(ModTileEntities.POWDER_PLACER, pos, state); super(ModBlockEntities.POWDER_PLACER, pos, state);
} }
@Override @Override

View file

@ -10,7 +10,7 @@ public class BlockEntityProjectileGenerator extends BlockEntityImpl {
public Direction nextSide = Direction.NORTH; public Direction nextSide = Direction.NORTH;
public BlockEntityProjectileGenerator(BlockPos pos, BlockState state) { public BlockEntityProjectileGenerator(BlockPos pos, BlockState state) {
super(ModTileEntities.PROJECTILE_GENERATOR, pos, state); super(ModBlockEntities.PROJECTILE_GENERATOR, pos, state);
} }
@Override @Override

View file

@ -9,7 +9,6 @@ import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.common.util.LazyOptional;
@ -26,7 +25,7 @@ public class BlockEntityRFConverter extends BlockEntityImpl implements ITickable
private int lastEnergy; private int lastEnergy;
public BlockEntityRFConverter(BlockPos pos, BlockState state) { public BlockEntityRFConverter(BlockPos pos, BlockState state) {
super(ModTileEntities.RF_CONVERTER, pos, state); super(ModBlockEntities.RF_CONVERTER, pos, state);
} }
@Override @Override

View file

@ -15,7 +15,7 @@ public class BlockEntitySlimeSplitGenerator extends BlockEntityImpl implements I
private int color; private int color;
public BlockEntitySlimeSplitGenerator(BlockPos pos, BlockState state) { public BlockEntitySlimeSplitGenerator(BlockPos pos, BlockState state) {
super(ModTileEntities.SLIME_SPLIT_GENERATOR, pos, state); super(ModBlockEntities.SLIME_SPLIT_GENERATOR, pos, state);
} }
@Override @Override

View file

@ -13,7 +13,6 @@ import net.minecraft.world.entity.animal.SnowGolem;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.Heightmap; import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.level.material.Fluids; import net.minecraft.world.level.material.Fluids;
public class BlockEntitySnowCreator extends BlockEntityImpl implements ITickableBlockEntity { public class BlockEntitySnowCreator extends BlockEntityImpl implements ITickableBlockEntity {
@ -21,7 +20,7 @@ public class BlockEntitySnowCreator extends BlockEntityImpl implements ITickable
private int snowmanCount; private int snowmanCount;
public BlockEntitySnowCreator(BlockPos pos, BlockState state) { public BlockEntitySnowCreator(BlockPos pos, BlockState state) {
super(ModTileEntities.SNOW_CREATOR, pos, state); super(ModBlockEntities.SNOW_CREATOR, pos, state);
} }
public int getRange() { public int getRange() {

View file

@ -8,7 +8,7 @@ import net.minecraft.world.level.block.state.BlockState;
public class BlockEntitySpawnLamp extends BlockEntityImpl { public class BlockEntitySpawnLamp extends BlockEntityImpl {
public BlockEntitySpawnLamp(BlockPos pos, BlockState state) { public BlockEntitySpawnLamp(BlockPos pos, BlockState state) {
super(ModTileEntities.SPAWN_LAMP, pos, state); super(ModBlockEntities.SPAWN_LAMP, pos, state);
} }
public int getRadius() { public int getRadius() {

View file

@ -11,7 +11,6 @@ import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.Fluids; import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.AABB;
import net.minecraftforge.common.FarmlandWaterManager; import net.minecraftforge.common.FarmlandWaterManager;
@ -30,7 +29,7 @@ public class BlockEntitySpring extends BlockEntityImpl implements ITickableBlock
private AABBTicket waterTicket; private AABBTicket waterTicket;
public BlockEntitySpring(BlockPos pos, BlockState state) { public BlockEntitySpring(BlockPos pos, BlockState state) {
super(ModTileEntities.SPRING, pos, state); super(ModBlockEntities.SPRING, pos, state);
} }
@Override @Override

View file

@ -9,26 +9,21 @@ import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.protocol.game.ClientboundSetTimePacket; import net.minecraft.network.protocol.game.ClientboundSetTimePacket;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.players.PlayerList;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.decoration.ItemFrame;
import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items; import net.minecraft.world.item.Items;
import net.minecraft.world.level.GameRules; import net.minecraft.world.level.GameRules;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.storage.ServerLevelData; import net.minecraft.world.level.storage.ServerLevelData;
import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.AABB;
import java.util.List;
public class BlockEntityTimeChanger extends BlockEntityImpl implements ITickableBlockEntity { public class BlockEntityTimeChanger extends BlockEntityImpl implements ITickableBlockEntity {
private long goalTime; private long goalTime;
public BlockEntityTimeChanger(BlockPos pos, BlockState state) { public BlockEntityTimeChanger(BlockPos pos, BlockState state) {
super(ModTileEntities.TIME_CHANGER, pos, state); super(ModBlockEntities.TIME_CHANGER, pos, state);
} }
@Override @Override

View file

@ -14,9 +14,6 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.AABB;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
import java.util.List;
import java.util.Map;
public class BlockEntityWeatherChanger extends BlockEntityImpl implements ITickableBlockEntity { public class BlockEntityWeatherChanger extends BlockEntityImpl implements ITickableBlockEntity {
private int processTime; private int processTime;
@ -24,7 +21,7 @@ public class BlockEntityWeatherChanger extends BlockEntityImpl implements ITicka
private int itemAmount; private int itemAmount;
public BlockEntityWeatherChanger(BlockPos pos, BlockState state) { public BlockEntityWeatherChanger(BlockPos pos, BlockState state) {
super(ModTileEntities.WEATHER_CHANGER, pos, state); super(ModBlockEntities.WEATHER_CHANGER, pos, state);
} }
@Override @Override

View file

@ -17,7 +17,6 @@ import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.LeavesBlock; import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.IItemHandlerModifiable;
import net.minecraftforge.items.ItemStackHandler; import net.minecraftforge.items.ItemStackHandler;
@ -40,7 +39,7 @@ public class BlockEntityWoodStand extends BlockEntityImpl implements ITickableBl
private int timer; private int timer;
public BlockEntityWoodStand(BlockPos pos, BlockState state) { public BlockEntityWoodStand(BlockPos pos, BlockState state) {
super(ModTileEntities.WOOD_STAND, pos, state); super(ModBlockEntities.WOOD_STAND, pos, state);
} }
public void setRitual(BlockPos pos, TreeRitualRecipe recipe) { public void setRitual(BlockPos pos, TreeRitualRecipe recipe) {

View file

@ -1,8 +1,14 @@
package de.ellpeck.naturesaura.blocks.tiles; package de.ellpeck.naturesaura.blocks.tiles;
// TODO actually call this from the base entity block thing, and possibly others if not all use the base one! import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityTicker;
import net.minecraft.world.level.block.entity.BlockEntityType;
public interface ITickableBlockEntity { public interface ITickableBlockEntity {
void tick(); void tick();
static <E extends BlockEntity, A extends BlockEntity> BlockEntityTicker<A> createTickerHelper(BlockEntityType<A> actual, BlockEntityType<E> expected) {
return expected == actual ? (l, p, s, e) -> ((ITickableBlockEntity) e).tick() : null;
}
} }

View file

@ -3,7 +3,7 @@ package de.ellpeck.naturesaura.blocks.tiles;
import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.entity.BlockEntityType;
@SuppressWarnings("FieldNamingConvention") @SuppressWarnings("FieldNamingConvention")
public final class ModTileEntities { public final class ModBlockEntities {
public static BlockEntityType<BlockEntityAncientLeaves> ANCIENT_LEAVES; public static BlockEntityType<BlockEntityAncientLeaves> ANCIENT_LEAVES;
public static BlockEntityType<BlockEntityAnimalGenerator> ANIMAL_GENERATOR; public static BlockEntityType<BlockEntityAnimalGenerator> ANIMAL_GENERATOR;

View file

@ -1,23 +1,31 @@
package de.ellpeck.naturesaura.blocks.tiles.render; package de.ellpeck.naturesaura.blocks.tiles.render;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.aura.type.IAuraType; import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityAuraTimer; import de.ellpeck.naturesaura.blocks.tiles.BlockEntityAuraTimer;
import de.ellpeck.naturesaura.items.ItemAuraBottle; import de.ellpeck.naturesaura.items.ItemAuraBottle;
import net.minecraft.client.model.Model;
import net.minecraft.client.model.geom.ModelLayers;
import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.client.model.geom.PartPose;
import net.minecraft.client.model.geom.builders.*;
import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import java.util.List;
public class RenderAuraTimer implements BlockEntityRenderer<BlockEntityAuraTimer> { public class RenderAuraTimer implements BlockEntityRenderer<BlockEntityAuraTimer> {
private static final ResourceLocation RES = new ResourceLocation(NaturesAura.MOD_ID, "textures/models/aura_timer_aura.png"); private static final ResourceLocation RES = new ResourceLocation(NaturesAura.MOD_ID, "textures/models/aura_timer_aura.png");
// private final AuraModel model = new AuraModel(); private final AuraModel model = new AuraModel();
public RenderAuraTimer(BlockEntityRendererProvider.Context context) { public RenderAuraTimer(BlockEntityRendererProvider.Context context) {
} }
@Override @Override
@ -35,26 +43,26 @@ public class RenderAuraTimer implements BlockEntityRenderer<BlockEntityAuraTimer
var r = (type.getColor() >> 16 & 255) / 255F; var r = (type.getColor() >> 16 & 255) / 255F;
var g = (type.getColor() >> 8 & 255) / 255F; var g = (type.getColor() >> 8 & 255) / 255F;
var b = (type.getColor() & 255) / 255F; var b = (type.getColor() & 255) / 255F;
//this.model.render(stack, buffer.getBuffer(this.model.getRenderType(RES)), combinedLightIn, combinedOverlayIn, r, g, b, 0.75F); this.model.renderToBuffer(stack, buffer.getBuffer(this.model.renderType(RES)), combinedLightIn, combinedOverlayIn, r, g, b, 0.75F);
stack.popPose(); stack.popPose();
} }
// TODO model rendering private static class AuraModel extends Model {
/* private static class AuraModel extends Model {
private final ModelRenderer box; private final ModelPart model;
public AuraModel() { public AuraModel() {
super(RenderType::getEntityTranslucent); super(RenderType::entityTranslucent);
this.box = new ModelRenderer(this, 0, 0); var mesh = new MeshDefinition();
this.box.setTextureSize(64, 64); var part = mesh.getRoot();
this.box.addBox(0, 0, 0, 16, 16, 16); part.addOrReplaceChild("main", new CubeListBuilder().addBox(0, 0, 0, 16, 16, 16), PartPose.ZERO);
this.model = LayerDefinition.create(mesh, 64, 64).bakeRoot();
} }
@Override @Override
public void render(MatrixStack matrixStackIn, IVertexBuilder bufferIn, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float alpha) { public void renderToBuffer(PoseStack matrixStackIn, VertexConsumer bufferIn, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float alpha) {
this.box.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn, red, green, blue, alpha); this.model.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn, red, green, blue, alpha);
} }
}*/ }
} }

View file

@ -11,7 +11,6 @@ import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
// TODO get the 1-pixel border around the ender overlay back
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public class RenderEnderCrate implements BlockEntityRenderer<BlockEntityEnderCrate> { public class RenderEnderCrate implements BlockEntityRenderer<BlockEntityEnderCrate> {
@ -27,10 +26,10 @@ public class RenderEnderCrate implements BlockEntityRenderer<BlockEntityEnderCra
} }
private static void renderFace(Matrix4f p_173696_, VertexConsumer p_173697_, float p_173700_, float p_173701_) { private static void renderFace(Matrix4f p_173696_, VertexConsumer p_173697_, float p_173700_, float p_173701_) {
p_173697_.vertex(p_173696_, (float) 0.0, p_173700_, (float) 1.0).endVertex(); p_173697_.vertex(p_173696_, (float) 1 / 16F, p_173700_, (float) 15 / 16F).endVertex();
p_173697_.vertex(p_173696_, (float) 1.0, p_173700_, (float) 1.0).endVertex(); p_173697_.vertex(p_173696_, (float) 15 / 16F, p_173700_, (float) 15 / 16F).endVertex();
p_173697_.vertex(p_173696_, (float) 1.0, p_173701_, (float) 0.0).endVertex(); p_173697_.vertex(p_173696_, (float) 15 / 16F, p_173701_, (float) 1 / 16F).endVertex();
p_173697_.vertex(p_173696_, (float) 0.0, p_173701_, (float) 0.0).endVertex(); p_173697_.vertex(p_173696_, (float) 1 / 16F, p_173701_, (float) 1 / 16F).endVertex();
} }
private static float getOffsetUp() { private static float getOffsetUp() {

View file

@ -1,11 +1,19 @@
package de.ellpeck.naturesaura.blocks.tiles.render; package de.ellpeck.naturesaura.blocks.tiles.render;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.math.Vector3f; import com.mojang.math.Vector3f;
import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityGeneratorLimitRemover; import de.ellpeck.naturesaura.blocks.tiles.BlockEntityGeneratorLimitRemover;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityImpl; import de.ellpeck.naturesaura.blocks.tiles.BlockEntityImpl;
import net.minecraft.client.model.Model;
import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.client.model.geom.PartPose;
import net.minecraft.client.model.geom.builders.CubeListBuilder;
import net.minecraft.client.model.geom.builders.LayerDefinition;
import net.minecraft.client.model.geom.builders.MeshDefinition;
import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
@ -17,7 +25,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
public class RenderGeneratorLimitRemover implements BlockEntityRenderer<BlockEntityGeneratorLimitRemover> { public class RenderGeneratorLimitRemover implements BlockEntityRenderer<BlockEntityGeneratorLimitRemover> {
private static final ResourceLocation RES = new ResourceLocation(NaturesAura.MOD_ID, "textures/models/generator_limit_remover_glint.png"); private static final ResourceLocation RES = new ResourceLocation(NaturesAura.MOD_ID, "textures/models/generator_limit_remover_glint.png");
//private final ModelLimitRemoverGlint model = new ModelLimitRemoverGlint(); private final ModelLimitRemoverGlint model = new ModelLimitRemoverGlint();
public RenderGeneratorLimitRemover(BlockEntityRendererProvider.Context context) { public RenderGeneratorLimitRemover(BlockEntityRendererProvider.Context context) {
@ -39,25 +47,25 @@ public class RenderGeneratorLimitRemover implements BlockEntityRenderer<BlockEnt
stack.translate(-0.001F, yOff + 1 + 0.001F, 1 + 0.001F); stack.translate(-0.001F, yOff + 1 + 0.001F, 1 + 0.001F);
stack.mulPose(Vector3f.XP.rotationDegrees(180F)); stack.mulPose(Vector3f.XP.rotationDegrees(180F));
stack.scale(1.002F, 1.002F, 1.002F); stack.scale(1.002F, 1.002F, 1.002F);
//this.model.render(stack, buffer.getBuffer(this.model.getRenderType(RES)), brightness, combinedOverlayIn, 1, 1, 1, alpha); this.model.renderToBuffer(stack, buffer.getBuffer(this.model.renderType(RES)), brightness, combinedOverlayIn, 1, 1, 1, alpha);
stack.popPose(); stack.popPose();
} }
// TODO model rendering private static class ModelLimitRemoverGlint extends Model {
/* private static class ModelLimitRemoverGlint extends Model {
private final ModelRenderer box; private final ModelPart model;
public ModelLimitRemoverGlint() { public ModelLimitRemoverGlint() {
super(RenderType::getEntityTranslucent); super(RenderType::entityTranslucent);
this.box = new ModelRenderer(this, 0, 0); var mesh = new MeshDefinition();
this.box.setTextureSize(64, 64); var part = mesh.getRoot();
this.box.addBox(0, 0, 0, 16, 16, 16); part.addOrReplaceChild("main", new CubeListBuilder().addBox(0, 0, 0, 16, 16, 16), PartPose.ZERO);
this.model = LayerDefinition.create(mesh, 64, 64).bakeRoot();
} }
@Override @Override
public void render(MatrixStack matrixStack, IVertexBuilder iVertexBuilder, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float alpha) { public void renderToBuffer(PoseStack matrixStackIn, VertexConsumer bufferIn, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float alpha) {
this.box.render(matrixStack, iVertexBuilder, packedLightIn, packedOverlayIn, red, green, blue, alpha); this.model.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn, red, green, blue, alpha);
} }
}*/ }
} }

View file

@ -1,10 +1,18 @@
package de.ellpeck.naturesaura.blocks.tiles.render; package de.ellpeck.naturesaura.blocks.tiles.render;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.math.Vector3f; import com.mojang.math.Vector3f;
import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityProjectileGenerator; import de.ellpeck.naturesaura.blocks.tiles.BlockEntityProjectileGenerator;
import net.minecraft.client.model.Model;
import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.client.model.geom.PartPose;
import net.minecraft.client.model.geom.builders.CubeListBuilder;
import net.minecraft.client.model.geom.builders.LayerDefinition;
import net.minecraft.client.model.geom.builders.MeshDefinition;
import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
@ -16,7 +24,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
public class RenderProjectileGenerator implements BlockEntityRenderer<BlockEntityProjectileGenerator> { public class RenderProjectileGenerator implements BlockEntityRenderer<BlockEntityProjectileGenerator> {
private static final ResourceLocation RES = new ResourceLocation(NaturesAura.MOD_ID, "textures/models/projectile_generator_overlay.png"); private static final ResourceLocation RES = new ResourceLocation(NaturesAura.MOD_ID, "textures/models/projectile_generator_overlay.png");
//private final ModelOverlay model = new ModelOverlay(); private final ModelOverlay model = new ModelOverlay();
public RenderProjectileGenerator(BlockEntityRendererProvider.Context context) { public RenderProjectileGenerator(BlockEntityRendererProvider.Context context) {
@ -38,25 +46,25 @@ public class RenderProjectileGenerator implements BlockEntityRenderer<BlockEntit
stack.translate(-0.002F, 0, 0); stack.translate(-0.002F, 0, 0);
} }
var brightness = 15 << 20 | 15 << 4; var brightness = 15 << 20 | 15 << 4;
//this.model.render(stack, buffer.getBuffer(this.model.getRenderType(RES)), brightness, combinedOverlayIn, 1, 1, 1, 1); this.model.renderToBuffer(stack, buffer.getBuffer(this.model.renderType(RES)), brightness, combinedOverlayIn, 1, 1, 1, 1);
stack.popPose(); stack.popPose();
} }
// TODO model rendering private static class ModelOverlay extends Model {
/* private static class ModelOverlay extends Model {
private final ModelPart box; private final ModelPart model;
public ModelOverlay() { public ModelOverlay() {
super(RenderType::entityTranslucent); super(RenderType::entityTranslucent);
this.box = new ModelPart(this, 0, 0); var mesh = new MeshDefinition();
this.box.setTextureSize(64, 64); var part = mesh.getRoot();
this.box.(0, 0, 0, 16, 16, 16); part.addOrReplaceChild("main", new CubeListBuilder().addBox(0, 0, 0, 16, 16, 16), PartPose.ZERO);
this.model = LayerDefinition.create(mesh, 64, 64).bakeRoot();
} }
@Override @Override
public void render(MatrixStack matrixStackIn, IVertexBuilder bufferIn, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float alpha) { public void renderToBuffer(PoseStack matrixStackIn, VertexConsumer bufferIn, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float alpha) {
this.box.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn, red, green, blue, alpha); this.model.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn, red, green, blue, alpha);
} }
}*/ }
} }

View file

@ -16,8 +16,8 @@ public final class Compat {
private static final Map<String, Supplier<ICompat>> MODULE_TYPES = ImmutableMap.<String, Supplier<ICompat>>builder() private static final Map<String, Supplier<ICompat>> MODULE_TYPES = ImmutableMap.<String, Supplier<ICompat>>builder()
.put("patchouli", PatchouliCompat::new) .put("patchouli", PatchouliCompat::new)
/* .put("curios", CuriosCompat::new) .put("curios", CuriosCompat::new)
.put("enchantability", EnchantibilityCompat::new)*/ //.put("enchantability", EnchantibilityCompat::new)
.build(); .build();
private static final Map<String, ICompat> MODULES = new HashMap<>(); private static final Map<String, ICompat> MODULES = new HashMap<>();

View file

@ -1,18 +1,14 @@
// TODO Curios
/*
package de.ellpeck.naturesaura.compat; package de.ellpeck.naturesaura.compat;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.data.ItemTagProvider; import de.ellpeck.naturesaura.data.ItemTagProvider;
import de.ellpeck.naturesaura.items.ModItems; import de.ellpeck.naturesaura.items.ModItems;
import net.minecraft.entity.LivingEntity; import net.minecraft.core.Direction;
import net.minecraft.item.Item; import net.minecraft.resources.ResourceLocation;
import net.minecraft.item.ItemStack;
import net.minecraft.tags.ITag;
import net.minecraft.tags.ItemTags; import net.minecraft.tags.ItemTags;
import net.minecraft.util.Direction; import net.minecraft.world.item.Item;
import net.minecraft.util.ResourceLocation; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ICapabilityProvider; import net.minecraftforge.common.capabilities.ICapabilityProvider;
@ -58,14 +54,18 @@ public class CuriosCompat implements ICompat {
} }
private void onCapabilitiesAttach(AttachCapabilitiesEvent<ItemStack> event) { private void onCapabilitiesAttach(AttachCapabilitiesEvent<ItemStack> event) {
ItemStack stack = event.getObject(); var stack = event.getObject();
if (TYPES.containsKey(stack.getItem())) { if (TYPES.containsKey(stack.getItem())) {
event.addCapability(new ResourceLocation(NaturesAura.MOD_ID, "curios"), new ICapabilityProvider() { event.addCapability(new ResourceLocation(NaturesAura.MOD_ID, "curios"), new ICapabilityProvider() {
private final LazyOptional<ICurio> curio = LazyOptional.of(() -> new ICurio() { private final LazyOptional<ICurio> curio = LazyOptional.of(() -> new ICurio() {
@Override @Override
public void curioTick(String identifier, int index, LivingEntity livingEntity) { public void curioTick(SlotContext slotContext) {
stack.getItem().inventoryTick(stack, livingEntity.level, livingEntity, -1, false); stack.getItem().inventoryTick(stack, slotContext.entity().level, slotContext.entity(), -1, false);
}
@Override
public ItemStack getStack() {
return stack;
} }
@Override @Override
@ -74,7 +74,7 @@ public class CuriosCompat implements ICompat {
} }
@Override @Override
public boolean canSync(String identifier, int index, LivingEntity livingEntity) { public boolean canSync(SlotContext slotContext) {
return true; return true;
} }
}); });
@ -92,10 +92,9 @@ public class CuriosCompat implements ICompat {
@Override @Override
public void addItemTags(ItemTagProvider provider) { public void addItemTags(ItemTagProvider provider) {
for (Map.Entry<Item, String> entry : TYPES.entrySet()) { for (var entry : TYPES.entrySet()) {
ITag.INamedTag<Item> tag = ItemTags.createOptional(new ResourceLocation("curios", entry.getValue())); var tag = ItemTags.createOptional(new ResourceLocation("curios", entry.getValue()));
provider.getOrCreateBuilder(tag).add(entry.getKey()); provider.tag(tag).add(entry.getKey());
} }
} }
} }
*/

View file

@ -1,4 +1,3 @@
// TODO Enchantability
/* /*
package de.ellpeck.naturesaura.compat.enchantibility; package de.ellpeck.naturesaura.compat.enchantibility;

View file

@ -1,4 +1,3 @@
// TODO Enchantability
/* /*
package de.ellpeck.naturesaura.compat.enchantibility; package de.ellpeck.naturesaura.compat.enchantibility;

View file

@ -1,4 +1,3 @@
/*
package de.ellpeck.naturesaura.compat.jei; package de.ellpeck.naturesaura.compat.jei;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
@ -8,14 +7,14 @@ import de.ellpeck.naturesaura.recipes.AltarRecipe;
import mezz.jei.api.constants.VanillaTypes; import mezz.jei.api.constants.VanillaTypes;
import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.gui.drawable.IDrawable; import mezz.jei.api.gui.drawable.IDrawable;
import mezz.jei.api.gui.ingredient.IGuiItemStackGroup;
import mezz.jei.api.helpers.IGuiHelper; import mezz.jei.api.helpers.IGuiHelper;
import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.category.IRecipeCategory; import mezz.jei.api.recipe.category.IRecipeCategory;
import net.minecraft.client.resources.I18n; import net.minecraft.network.chat.Component;
import net.minecraft.item.ItemStack; import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.item.crafting.Ingredient; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.ResourceLocation; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Ingredient;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
@ -40,8 +39,8 @@ public class AltarCategory implements IRecipeCategory<AltarRecipe> {
} }
@Override @Override
public String getTitle() { public Component getTitle() {
return I18n.format("container." + JEINaturesAuraPlugin.ALTAR + ".name"); return new TranslatableComponent("container." + JEINaturesAuraPlugin.ALTAR + ".name");
} }
@Override @Override
@ -57,9 +56,9 @@ public class AltarCategory implements IRecipeCategory<AltarRecipe> {
@Override @Override
public void setIngredients(AltarRecipe altarRecipe, IIngredients iIngredients) { public void setIngredients(AltarRecipe altarRecipe, IIngredients iIngredients) {
ImmutableList.Builder<ItemStack> builder = ImmutableList.builder(); ImmutableList.Builder<ItemStack> builder = ImmutableList.builder();
builder.add(altarRecipe.input.getMatchingStacks()); builder.add(altarRecipe.input.getItems());
if (altarRecipe.catalyst != Ingredient.EMPTY) if (altarRecipe.catalyst != Ingredient.EMPTY)
builder.add(altarRecipe.catalyst.getMatchingStacks()); builder.add(altarRecipe.catalyst.getItems());
if (altarRecipe.requiredType != null) if (altarRecipe.requiredType != null)
builder.add(altarRecipe.getDimensionBottle()); builder.add(altarRecipe.getDimensionBottle());
iIngredients.setInputs(VanillaTypes.ITEM, builder.build()); iIngredients.setInputs(VanillaTypes.ITEM, builder.build());
@ -68,17 +67,16 @@ public class AltarCategory implements IRecipeCategory<AltarRecipe> {
@Override @Override
public void setRecipe(IRecipeLayout iRecipeLayout, AltarRecipe recipe, IIngredients iIngredients) { public void setRecipe(IRecipeLayout iRecipeLayout, AltarRecipe recipe, IIngredients iIngredients) {
IGuiItemStackGroup group = iRecipeLayout.getItemStacks(); var group = iRecipeLayout.getItemStacks();
group.init(0, true, 0, 18); group.init(0, true, 0, 18);
group.set(0, Arrays.asList(recipe.input.getMatchingStacks())); group.set(0, Arrays.asList(recipe.input.getItems()));
group.init(1, false, 80, 18); group.init(1, false, 80, 18);
group.set(1, recipe.output); group.set(1, recipe.output);
group.init(2, true, 26, 18); group.init(2, true, 26, 18);
group.set(2, recipe.catalyst == Ingredient.EMPTY ? group.set(2, recipe.catalyst == Ingredient.EMPTY ?
Collections.singletonList(this.altar) : Arrays.asList(recipe.catalyst.getMatchingStacks())); Collections.singletonList(this.altar) : Arrays.asList(recipe.catalyst.getItems()));
group.init(3, true, 51, 18); group.init(3, true, 51, 18);
if (recipe.requiredType != null) if (recipe.requiredType != null)
group.set(3, recipe.getDimensionBottle()); group.set(3, recipe.getDimensionBottle());
} }
} }
*/

View file

@ -1,32 +1,28 @@
/*
package de.ellpeck.naturesaura.compat.jei; package de.ellpeck.naturesaura.compat.jei;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.platform.Lighting;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Vector3f;
import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.recipes.AnimalSpawnerRecipe; import de.ellpeck.naturesaura.recipes.AnimalSpawnerRecipe;
import mezz.jei.api.constants.VanillaTypes; import mezz.jei.api.constants.VanillaTypes;
import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.gui.drawable.IDrawable; import mezz.jei.api.gui.drawable.IDrawable;
import mezz.jei.api.gui.ingredient.IGuiItemStackGroup;
import mezz.jei.api.helpers.IGuiHelper; import mezz.jei.api.helpers.IGuiHelper;
import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.category.IRecipeCategory; import mezz.jei.api.recipe.category.IRecipeCategory;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.core.BlockPos;
import net.minecraft.client.renderer.entity.EntityRendererManager; import net.minecraft.network.chat.Component;
import net.minecraft.client.resources.I18n; import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.entity.Entity; import net.minecraft.resources.ResourceLocation;
import net.minecraft.entity.EntityType; import net.minecraft.world.entity.Entity;
import net.minecraft.entity.LivingEntity; import net.minecraft.world.entity.EntityType;
import net.minecraft.item.ItemStack; import net.minecraft.world.entity.LivingEntity;
import net.minecraft.item.SpawnEggItem; import net.minecraft.world.item.ItemStack;
import net.minecraft.item.crafting.Ingredient; import net.minecraftforge.common.ForgeSpawnEggItem;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.vector.Quaternion;
import net.minecraft.util.math.vector.Vector3f;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
@ -35,48 +31,53 @@ import java.util.Map;
public class AnimalSpawnerCategory implements IRecipeCategory<AnimalSpawnerRecipe> { public class AnimalSpawnerCategory implements IRecipeCategory<AnimalSpawnerRecipe> {
private final IDrawable background; private final IDrawable background;
private final Map<EntityType, Entity> entityCache = new HashMap<>(); private final Map<EntityType<?>, Entity> entityCache = new HashMap<>();
public AnimalSpawnerCategory(IGuiHelper helper) { public AnimalSpawnerCategory(IGuiHelper helper) {
this.background = helper.createDrawable(new ResourceLocation(NaturesAura.MOD_ID, "textures/gui/jei/animal_spawner.png"), 0, 0, 72, 86); this.background = helper.createDrawable(new ResourceLocation(NaturesAura.MOD_ID, "textures/gui/jei/animal_spawner.png"), 0, 0, 72, 86);
} }
private static void renderEntity(MatrixStack matrixstack, int x, int y, float scale, float yaw, float pitch, LivingEntity entity) { private static void renderEntity(PoseStack matrixstack, int x, int y, float scale, float yaw, float pitch, LivingEntity entity) {
float f = (float) Math.atan(yaw / 40.0F); var f = (float) Math.atan(yaw / 40.0F);
float f1 = (float) Math.atan(pitch / 40.0F); var f1 = (float) Math.atan(pitch / 40.0F);
RenderSystem.pushMatrix(); var posestack = RenderSystem.getModelViewStack();
RenderSystem.translatef((float) x, (float) y, 1050.0F); posestack.pushPose();
RenderSystem.scalef(1.0F, 1.0F, -1.0F); posestack.translate(x, y, 1050.0D);
posestack.scale(1.0F, 1.0F, -1.0F);
RenderSystem.applyModelViewMatrix();
matrixstack.translate(0.0D, 0.0D, 1000.0D); matrixstack.translate(0.0D, 0.0D, 1000.0D);
matrixstack.scale(scale, scale, scale); matrixstack.scale(scale, scale, scale);
Quaternion quaternion = Vector3f.ZP.rotationDegrees(180.0F); var quaternion = Vector3f.ZP.rotationDegrees(180.0F);
Quaternion quaternion1 = Vector3f.XP.rotationDegrees(f1 * 20.0F); var quaternion1 = Vector3f.XP.rotationDegrees(f1 * 20.0F);
quaternion.multiply(quaternion1); quaternion.mul(quaternion1);
matrixstack.rotate(quaternion); matrixstack.mulPose(quaternion);
float f2 = entity.renderYawOffset; var f2 = entity.yBodyRot;
float f3 = entity.rotationYaw; var f3 = entity.getYRot();
float f4 = entity.rotationPitch; var f4 = entity.getXRot();
float f5 = entity.prevRotationYawHead; var f5 = entity.yHeadRotO;
float f6 = entity.rotationYawHead; var f6 = entity.yHeadRot;
entity.renderYawOffset = 180.0F + f * 20.0F; entity.yBodyRot = 180.0F + f * 20.0F;
entity.rotationYaw = 180.0F + f * 40.0F; entity.setYRot(180.0F + f * 40.0F);
entity.rotationPitch = -f1 * 20.0F; entity.setXRot(-f1 * 20.0F);
entity.rotationYawHead = entity.rotationYaw; entity.yHeadRot = entity.getYRot();
entity.prevRotationYawHead = entity.rotationYaw; entity.yHeadRotO = entity.getYRot();
EntityRendererManager entityrenderermanager = Minecraft.getInstance().getRenderManager(); Lighting.setupForEntityInInventory();
quaternion1.conjugate(); var entityrenderermanager = Minecraft.getInstance().getEntityRenderDispatcher();
entityrenderermanager.setCameraOrientation(quaternion1); quaternion1.conj();
entityrenderermanager.overrideCameraOrientation(quaternion1);
entityrenderermanager.setRenderShadow(false); entityrenderermanager.setRenderShadow(false);
IRenderTypeBuffer.Impl buff = Minecraft.getInstance().getRenderTypeBuffers().getBufferSource(); var buff = Minecraft.getInstance().renderBuffers().bufferSource();
entityrenderermanager.renderEntityStatic(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F, matrixstack, buff, 15728880); entityrenderermanager.render(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F, matrixstack, buff, 15728880);
buff.finish(); buff.endBatch();
entityrenderermanager.setRenderShadow(true); entityrenderermanager.setRenderShadow(true);
entity.renderYawOffset = f2; entity.yBodyRot = f2;
entity.rotationYaw = f3; entity.setYRot(f3);
entity.rotationPitch = f4; entity.setXRot(f4);
entity.prevRotationYawHead = f5; entity.yHeadRotO = f5;
entity.rotationYawHead = f6; entity.yHeadRot = f6;
RenderSystem.popMatrix(); posestack.popPose();
RenderSystem.applyModelViewMatrix();
Lighting.setupFor3DItems();
} }
@Override @Override
@ -90,8 +91,8 @@ public class AnimalSpawnerCategory implements IRecipeCategory<AnimalSpawnerRecip
} }
@Override @Override
public String getTitle() { public Component getTitle() {
return I18n.format("container." + JEINaturesAuraPlugin.SPAWNER + ".name"); return new TranslatableComponent("container." + JEINaturesAuraPlugin.SPAWNER + ".name");
} }
@Override @Override
@ -107,38 +108,37 @@ public class AnimalSpawnerCategory implements IRecipeCategory<AnimalSpawnerRecip
@Override @Override
public void setIngredients(AnimalSpawnerRecipe animalSpawnerRecipe, IIngredients iIngredients) { public void setIngredients(AnimalSpawnerRecipe animalSpawnerRecipe, IIngredients iIngredients) {
ImmutableList.Builder<ItemStack> builder = ImmutableList.builder(); ImmutableList.Builder<ItemStack> builder = ImmutableList.builder();
for (Ingredient ing : animalSpawnerRecipe.ingredients) for (var ing : animalSpawnerRecipe.ingredients)
builder.add(ing.getMatchingStacks()); builder.add(ing.getItems());
iIngredients.setInputs(VanillaTypes.ITEM, builder.build()); iIngredients.setInputs(VanillaTypes.ITEM, builder.build());
iIngredients.setOutput(VanillaTypes.ITEM, new ItemStack(SpawnEggItem.getEgg(animalSpawnerRecipe.entity))); iIngredients.setOutput(VanillaTypes.ITEM, new ItemStack(ForgeSpawnEggItem.fromEntityType(animalSpawnerRecipe.entity)));
} }
@Override @Override
public void setRecipe(IRecipeLayout iRecipeLayout, AnimalSpawnerRecipe recipe, IIngredients iIngredients) { public void setRecipe(IRecipeLayout iRecipeLayout, AnimalSpawnerRecipe recipe, IIngredients iIngredients) {
IGuiItemStackGroup group = iRecipeLayout.getItemStacks(); var group = iRecipeLayout.getItemStacks();
for (int i = 0; i < recipe.ingredients.length; i++) { for (var i = 0; i < recipe.ingredients.length; i++) {
group.init(i, true, i * 18, 68); group.init(i, true, i * 18, 68);
group.set(i, Arrays.asList(recipe.ingredients[i].getMatchingStacks())); group.set(i, Arrays.asList(recipe.ingredients[i].getItems()));
} }
} }
@Override @Override
public void draw(AnimalSpawnerRecipe recipe, MatrixStack matrixStack, double mouseX, double mouseY) { public void draw(AnimalSpawnerRecipe recipe, PoseStack matrixStack, double mouseX, double mouseY) {
Minecraft minecraft = Minecraft.getInstance(); var minecraft = Minecraft.getInstance();
Entity entity = this.entityCache.get(recipe.entity); var entity = this.entityCache.get(recipe.entity);
if (entity == null) { if (entity == null) {
entity = recipe.makeEntity(minecraft.level, BlockPos.ZERO); entity = recipe.makeEntity(minecraft.level, BlockPos.ZERO);
this.entityCache.put(recipe.entity, entity); this.entityCache.put(recipe.entity, entity);
} }
matrixStack.push(); matrixStack.pushPose();
float size = Math.max(1F, Math.max(recipe.entity.getWidth(), recipe.entity.getHeight())); var size = Math.max(1F, Math.max(recipe.entity.getWidth(), recipe.entity.getHeight()));
renderEntity(matrixStack, 35, 55, 100F / size * 0.4F, 40, size * 0.5F, (LivingEntity) entity); renderEntity(matrixStack, 35, 55, 100F / size * 0.4F, 40, size * 0.5F, (LivingEntity) entity);
matrixStack.pop(); matrixStack.popPose();
String name = recipe.entity.getName().getString(); var name = recipe.entity.getDescription().getString();
minecraft.fontRenderer.drawStringWithShadow(matrixStack, name, 36 - minecraft.fontRenderer.getStringWidth(name) / 2F, 55, 0xFFFFFF); minecraft.font.drawShadow(matrixStack, name, 36 - minecraft.font.width(name) / 2F, 55, 0xFFFFFF);
} }
} }
*/

View file

@ -1,9 +1,7 @@
/*
package de.ellpeck.naturesaura.compat.jei; package de.ellpeck.naturesaura.compat.jei;
import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
import de.ellpeck.naturesaura.blocks.ModBlocks; import de.ellpeck.naturesaura.blocks.ModBlocks;
import de.ellpeck.naturesaura.items.ItemAuraBottle; import de.ellpeck.naturesaura.items.ItemAuraBottle;
import de.ellpeck.naturesaura.items.ItemEffectPowder; import de.ellpeck.naturesaura.items.ItemEffectPowder;
@ -11,16 +9,14 @@ import de.ellpeck.naturesaura.items.ModItems;
import de.ellpeck.naturesaura.recipes.ModRecipes; import de.ellpeck.naturesaura.recipes.ModRecipes;
import mezz.jei.api.IModPlugin; import mezz.jei.api.IModPlugin;
import mezz.jei.api.JeiPlugin; import mezz.jei.api.JeiPlugin;
import mezz.jei.api.helpers.IGuiHelper; import mezz.jei.api.ingredients.subtypes.IIngredientSubtypeInterpreter;
import mezz.jei.api.ingredients.subtypes.ISubtypeInterpreter;
import mezz.jei.api.registration.IRecipeCatalystRegistration; import mezz.jei.api.registration.IRecipeCatalystRegistration;
import mezz.jei.api.registration.IRecipeCategoryRegistration; import mezz.jei.api.registration.IRecipeCategoryRegistration;
import mezz.jei.api.registration.IRecipeRegistration; import mezz.jei.api.registration.IRecipeRegistration;
import mezz.jei.api.registration.ISubtypeRegistration; import mezz.jei.api.registration.ISubtypeRegistration;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack; import net.minecraft.resources.ResourceLocation;
import net.minecraft.item.crafting.RecipeManager; import net.minecraft.world.item.ItemStack;
import net.minecraft.util.ResourceLocation;
@JeiPlugin @JeiPlugin
public class JEINaturesAuraPlugin implements IModPlugin { public class JEINaturesAuraPlugin implements IModPlugin {
@ -37,7 +33,7 @@ public class JEINaturesAuraPlugin implements IModPlugin {
@Override @Override
public void registerCategories(IRecipeCategoryRegistration registry) { public void registerCategories(IRecipeCategoryRegistration registry) {
IGuiHelper helper = registry.getJeiHelpers().getGuiHelper(); var helper = registry.getJeiHelpers().getGuiHelper();
registry.addRecipeCategories( registry.addRecipeCategories(
new TreeRitualCategory(helper), new TreeRitualCategory(helper),
new AltarCategory(helper), new AltarCategory(helper),
@ -48,14 +44,14 @@ public class JEINaturesAuraPlugin implements IModPlugin {
@Override @Override
public void registerItemSubtypes(ISubtypeRegistration registration) { public void registerItemSubtypes(ISubtypeRegistration registration) {
registration.registerSubtypeInterpreter(ModItems.EFFECT_POWDER, stack -> ItemEffectPowder.getEffect(stack).toString()); registration.registerSubtypeInterpreter(ModItems.EFFECT_POWDER, (stack, context) -> ItemEffectPowder.getEffect(stack).toString());
registration.registerSubtypeInterpreter(ModItems.AURA_BOTTLE, stack -> ItemAuraBottle.getType(stack).getName().toString()); registration.registerSubtypeInterpreter(ModItems.AURA_BOTTLE, (stack, context) -> ItemAuraBottle.getType(stack).getName().toString());
ISubtypeInterpreter auraInterpreter = stack -> { var auraInterpreter = (IIngredientSubtypeInterpreter<ItemStack>) (stack, context) -> {
IAuraContainer container = stack.getCapability(NaturesAuraAPI.capAuraContainer).orElse(null); var container = stack.getCapability(NaturesAuraAPI.capAuraContainer).orElse(null);
if (container != null) if (container != null)
return String.valueOf(container.getStoredAura()); return String.valueOf(container.getStoredAura());
return ISubtypeInterpreter.NONE; return IIngredientSubtypeInterpreter.NONE;
}; };
registration.registerSubtypeInterpreter(ModItems.AURA_CACHE, auraInterpreter); registration.registerSubtypeInterpreter(ModItems.AURA_CACHE, auraInterpreter);
registration.registerSubtypeInterpreter(ModItems.AURA_TROVE, auraInterpreter); registration.registerSubtypeInterpreter(ModItems.AURA_TROVE, auraInterpreter);
@ -72,11 +68,10 @@ public class JEINaturesAuraPlugin implements IModPlugin {
@Override @Override
public void registerRecipes(IRecipeRegistration registration) { public void registerRecipes(IRecipeRegistration registration) {
RecipeManager manager = Minecraft.getInstance().level.getRecipeManager(); var manager = Minecraft.getInstance().level.getRecipeManager();
registration.addRecipes(manager.getRecipes(ModRecipes.TREE_RITUAL_TYPE, null, null), TREE_RITUAL); registration.addRecipes(manager.getAllRecipesFor(ModRecipes.TREE_RITUAL_TYPE), TREE_RITUAL);
registration.addRecipes(manager.getRecipes(ModRecipes.ALTAR_TYPE, null, null), ALTAR); registration.addRecipes(manager.getAllRecipesFor(ModRecipes.ALTAR_TYPE), ALTAR);
registration.addRecipes(manager.getRecipes(ModRecipes.OFFERING_TYPE, null, null), OFFERING); registration.addRecipes(manager.getAllRecipesFor(ModRecipes.OFFERING_TYPE), OFFERING);
registration.addRecipes(manager.getRecipes(ModRecipes.ANIMAL_SPAWNER_TYPE, null, null), SPAWNER); registration.addRecipes(manager.getAllRecipesFor(ModRecipes.ANIMAL_SPAWNER_TYPE), SPAWNER);
} }
} }
*/

View file

@ -1,4 +1,3 @@
/*
package de.ellpeck.naturesaura.compat.jei; package de.ellpeck.naturesaura.compat.jei;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
@ -11,9 +10,10 @@ import mezz.jei.api.gui.ingredient.IGuiItemStackGroup;
import mezz.jei.api.helpers.IGuiHelper; import mezz.jei.api.helpers.IGuiHelper;
import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.category.IRecipeCategory; import mezz.jei.api.recipe.category.IRecipeCategory;
import net.minecraft.client.resources.I18n; import net.minecraft.network.chat.Component;
import net.minecraft.item.ItemStack; import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.util.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import java.util.Arrays; import java.util.Arrays;
@ -36,8 +36,8 @@ public class OfferingCategory implements IRecipeCategory<OfferingRecipe> {
} }
@Override @Override
public String getTitle() { public Component getTitle() {
return I18n.format("container." + JEINaturesAuraPlugin.OFFERING + ".name"); return new TranslatableComponent("container." + JEINaturesAuraPlugin.OFFERING + ".name");
} }
@Override @Override
@ -53,8 +53,8 @@ public class OfferingCategory implements IRecipeCategory<OfferingRecipe> {
@Override @Override
public void setIngredients(OfferingRecipe offeringRecipe, IIngredients iIngredients) { public void setIngredients(OfferingRecipe offeringRecipe, IIngredients iIngredients) {
iIngredients.setInputs(VanillaTypes.ITEM, ImmutableList.<ItemStack>builder() iIngredients.setInputs(VanillaTypes.ITEM, ImmutableList.<ItemStack>builder()
.add(offeringRecipe.input.getMatchingStacks()) .add(offeringRecipe.input.getItems())
.add(offeringRecipe.startItem.getMatchingStacks()).build()); .add(offeringRecipe.startItem.getItems()).build());
iIngredients.setOutput(VanillaTypes.ITEM, offeringRecipe.output); iIngredients.setOutput(VanillaTypes.ITEM, offeringRecipe.output);
} }
@ -62,11 +62,10 @@ public class OfferingCategory implements IRecipeCategory<OfferingRecipe> {
public void setRecipe(IRecipeLayout recipeLayout, OfferingRecipe recipe, IIngredients ingredients) { public void setRecipe(IRecipeLayout recipeLayout, OfferingRecipe recipe, IIngredients ingredients) {
IGuiItemStackGroup group = recipeLayout.getItemStacks(); IGuiItemStackGroup group = recipeLayout.getItemStacks();
group.init(0, true, 0, 14); group.init(0, true, 0, 14);
group.set(0, Arrays.asList(recipe.input.getMatchingStacks())); group.set(0, Arrays.asList(recipe.input.getItems()));
group.init(1, false, 65, 14); group.init(1, false, 65, 14);
group.set(1, recipe.output); group.set(1, recipe.output);
group.init(2, true, 27, 0); group.init(2, true, 27, 0);
group.set(2, Arrays.asList(recipe.startItem.getMatchingStacks())); group.set(2, Arrays.asList(recipe.startItem.getItems()));
} }
} }
*/

View file

@ -1,4 +1,3 @@
/*
package de.ellpeck.naturesaura.compat.jei; package de.ellpeck.naturesaura.compat.jei;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
@ -7,14 +6,13 @@ import de.ellpeck.naturesaura.recipes.TreeRitualRecipe;
import mezz.jei.api.constants.VanillaTypes; import mezz.jei.api.constants.VanillaTypes;
import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.gui.drawable.IDrawable; import mezz.jei.api.gui.drawable.IDrawable;
import mezz.jei.api.gui.ingredient.IGuiItemStackGroup;
import mezz.jei.api.helpers.IGuiHelper; import mezz.jei.api.helpers.IGuiHelper;
import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.category.IRecipeCategory; import mezz.jei.api.recipe.category.IRecipeCategory;
import net.minecraft.client.resources.I18n; import net.minecraft.network.chat.Component;
import net.minecraft.item.ItemStack; import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.item.crafting.Ingredient; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.ResourceLocation; import net.minecraft.world.item.ItemStack;
import java.util.Arrays; import java.util.Arrays;
@ -37,8 +35,8 @@ public class TreeRitualCategory implements IRecipeCategory<TreeRitualRecipe> {
} }
@Override @Override
public String getTitle() { public Component getTitle() {
return I18n.format("container." + JEINaturesAuraPlugin.TREE_RITUAL + ".name"); return new TranslatableComponent("container." + JEINaturesAuraPlugin.TREE_RITUAL + ".name");
} }
@Override @Override
@ -54,28 +52,27 @@ public class TreeRitualCategory implements IRecipeCategory<TreeRitualRecipe> {
@Override @Override
public void setIngredients(TreeRitualRecipe treeRitualRecipe, IIngredients iIngredients) { public void setIngredients(TreeRitualRecipe treeRitualRecipe, IIngredients iIngredients) {
ImmutableList.Builder<ItemStack> builder = ImmutableList.builder(); ImmutableList.Builder<ItemStack> builder = ImmutableList.builder();
for (Ingredient ing : treeRitualRecipe.ingredients) for (var ing : treeRitualRecipe.ingredients)
builder.add(ing.getMatchingStacks()); builder.add(ing.getItems());
builder.add(treeRitualRecipe.saplingType.getMatchingStacks()); builder.add(treeRitualRecipe.saplingType.getItems());
iIngredients.setInputs(VanillaTypes.ITEM, builder.build()); iIngredients.setInputs(VanillaTypes.ITEM, builder.build());
iIngredients.setOutput(VanillaTypes.ITEM, treeRitualRecipe.result); iIngredients.setOutput(VanillaTypes.ITEM, treeRitualRecipe.result);
} }
@Override @Override
public void setRecipe(IRecipeLayout iRecipeLayout, TreeRitualRecipe treeRitualRecipe, IIngredients iIngredients) { public void setRecipe(IRecipeLayout iRecipeLayout, TreeRitualRecipe treeRitualRecipe, IIngredients iIngredients) {
IGuiItemStackGroup group = iRecipeLayout.getItemStacks(); var group = iRecipeLayout.getItemStacks();
group.init(0, true, 34, 34); group.init(0, true, 34, 34);
group.set(0, Arrays.asList(treeRitualRecipe.saplingType.getMatchingStacks())); group.set(0, Arrays.asList(treeRitualRecipe.saplingType.getItems()));
group.init(1, true, 124, 34); group.init(1, true, 124, 34);
group.set(1, treeRitualRecipe.result); group.set(1, treeRitualRecipe.result);
int[][] positions = new int[][]{{35, 1}, {35, 69}, {1, 35}, {69, 35}, {12, 12}, {58, 58}, {58, 12}, {12, 58}}; var positions = new int[][]{{35, 1}, {35, 69}, {1, 35}, {69, 35}, {12, 12}, {58, 58}, {58, 12}, {12, 58}};
for (int i = 0; i < treeRitualRecipe.ingredients.length; i++) { for (var i = 0; i < treeRitualRecipe.ingredients.length; i++) {
group.init(i + 2, true, positions[i][0] - 1, positions[i][1] - 1); group.init(i + 2, true, positions[i][0] - 1, positions[i][1] - 1);
group.set(i + 2, Arrays.asList(treeRitualRecipe.ingredients[i].getMatchingStacks())); group.set(i + 2, Arrays.asList(treeRitualRecipe.ingredients[i].getItems()));
} }
} }
} }
*/

View file

@ -138,8 +138,7 @@ public class PatchouliCompat implements ICompat {
var r = ((info.color() >> 16) & 255) / 255F; var r = ((info.color() >> 16) & 255) / 255F;
var g = ((info.color() >> 8) & 255) / 255F; var g = ((info.color() >> 8) & 255) / 255F;
var b = (info.color() & 255) / 255F; var b = (info.color() & 255) / 255F;
// TODO apply leaf color? RenderSystem.setShaderColor(r, g, b, 1);
//RenderSystem.color3f(r, g, b);
Screen.blit(event.getPoseStack(), x, y, 496 - 32, 44, 16, 18, 512, 256); Screen.blit(event.getPoseStack(), x, y, 496 - 32, 44, 16, 18, 512, 256);
} }

View file

@ -8,6 +8,8 @@ import net.minecraft.data.tags.BlockTagsProvider;
import net.minecraft.data.tags.ItemTagsProvider; import net.minecraft.data.tags.ItemTagsProvider;
import net.minecraft.tags.BlockTags; import net.minecraft.tags.BlockTags;
import net.minecraft.tags.ItemTags; import net.minecraft.tags.ItemTags;
import net.minecraft.tags.Tag;
import net.minecraft.world.item.Item;
import net.minecraftforge.common.Tags; import net.minecraftforge.common.Tags;
import net.minecraftforge.common.data.ExistingFileHelper; import net.minecraftforge.common.data.ExistingFileHelper;
@ -31,4 +33,9 @@ public class ItemTagProvider extends ItemTagsProvider {
Compat.addItemTags(this); Compat.addItemTags(this);
} }
@Override
public TagAppender<Item> tag(Tag.Named<Item> p_126549_) {
// super is protected, but CuriosCompat needs this
return super.tag(p_126549_);
}
} }

View file

@ -19,14 +19,15 @@ import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.damagesource.EntityDamageSource; import net.minecraft.world.damagesource.EntityDamageSource;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.AABB;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.network.NetworkHooks; import net.minecraftforge.network.NetworkHooks;
import org.jetbrains.annotations.Nullable;
// TODO these behave very weirdly in-world
public class EntityEffectInhibitor extends Entity implements IVisualizable { public class EntityEffectInhibitor extends Entity implements IVisualizable {
private static final EntityDataAccessor<String> INHIBITED_EFFECT = SynchedEntityData.defineId(EntityEffectInhibitor.class, EntityDataSerializers.STRING); private static final EntityDataAccessor<String> INHIBITED_EFFECT = SynchedEntityData.defineId(EntityEffectInhibitor.class, EntityDataSerializers.STRING);
@ -108,11 +109,6 @@ public class EntityEffectInhibitor extends Entity implements IVisualizable {
} }
} }
@Override
public boolean canBeCollidedWith() {
return true;
}
@Override @Override
protected void readAdditionalSaveData(CompoundTag compound) { protected void readAdditionalSaveData(CompoundTag compound) {
this.setInhibitedEffect(new ResourceLocation(compound.getString("effect"))); this.setInhibitedEffect(new ResourceLocation(compound.getString("effect")));
@ -132,14 +128,32 @@ public class EntityEffectInhibitor extends Entity implements IVisualizable {
return NetworkHooks.getEntitySpawningPacket(this); return NetworkHooks.getEntitySpawningPacket(this);
} }
@Override
public boolean skipAttackInteraction(Entity entity) {
return entity instanceof Player player && (!this.level.mayInteract(player, this.blockPosition()) || this.hurt(DamageSource.playerAttack(player), 0.0F));
}
@Override @Override
public boolean hurt(DamageSource source, float amount) { public boolean hurt(DamageSource source, float amount) {
if (source instanceof EntityDamageSource && !this.level.isClientSide) { if (source instanceof EntityDamageSource && !this.level.isClientSide) {
this.kill(); this.kill();
this.spawnAtLocation(this.getDrop(), 0F); this.spawnAtLocation(this.getDrop(), 0F);
return true; return true;
} else } else {
return super.hurt(source, amount); return super.hurt(source, amount);
}
}
@Override
public boolean isPickable() {
// SOMEHOW, this actually means "is raytraceable" IN GENERAL even though getPickResult is about middle-clicking, jesus fucking christ mojang
return true;
}
@Nullable
@Override
public ItemStack getPickResult() {
return this.getDrop();
} }
public ItemStack getDrop() { public ItemStack getDrop() {

View file

@ -1,13 +1,22 @@
package de.ellpeck.naturesaura.entities.render; package de.ellpeck.naturesaura.entities.render;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.math.Vector3f; import com.mojang.math.Vector3f;
import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.entities.EntityMoverMinecart; import de.ellpeck.naturesaura.entities.EntityMoverMinecart;
import net.minecraft.client.model.Model;
import net.minecraft.client.model.geom.ModelLayers; import net.minecraft.client.model.geom.ModelLayers;
import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.client.model.geom.PartPose;
import net.minecraft.client.model.geom.builders.CubeListBuilder;
import net.minecraft.client.model.geom.builders.LayerDefinition;
import net.minecraft.client.model.geom.builders.MeshDefinition;
import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.entity.EntityRendererProvider; import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.client.renderer.entity.MinecartRenderer; import net.minecraft.client.renderer.entity.MinecartRenderer;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
@ -18,7 +27,8 @@ public class RenderMoverMinecart extends MinecartRenderer<EntityMoverMinecart> {
public RenderMoverMinecart(EntityRendererProvider.Context p_174300_) { public RenderMoverMinecart(EntityRendererProvider.Context p_174300_) {
super(p_174300_, ModelLayers.MINECART); super(p_174300_, ModelLayers.MINECART);
} }
//private final ModelMoverMinecart model = new ModelMoverMinecart();
private final ModelMoverMinecart model = new ModelMoverMinecart();
@Override @Override
protected void renderMinecartContents(EntityMoverMinecart entityIn, float partialTicks, BlockState stateIn, PoseStack matrixStackIn, MultiBufferSource bufferIn, int packedLightIn) { protected void renderMinecartContents(EntityMoverMinecart entityIn, float partialTicks, BlockState stateIn, PoseStack matrixStackIn, MultiBufferSource bufferIn, int packedLightIn) {
@ -26,25 +36,25 @@ public class RenderMoverMinecart extends MinecartRenderer<EntityMoverMinecart> {
matrixStackIn.translate(0, 22 / 16F, 0); matrixStackIn.translate(0, 22 / 16F, 0);
matrixStackIn.translate(0, 0, 1); matrixStackIn.translate(0, 0, 1);
matrixStackIn.mulPose(Vector3f.XP.rotationDegrees(180)); matrixStackIn.mulPose(Vector3f.XP.rotationDegrees(180));
//this.model.render(matrixStackIn, bufferIn.getBuffer(this.model.getRenderType(RES)), packedLightIn, OverlayTexture.NO_OVERLAY, 1, 1, 1, 1); this.model.renderToBuffer(matrixStackIn, bufferIn.getBuffer(this.model.renderType(RES)), packedLightIn, OverlayTexture.NO_OVERLAY, 1, 1, 1, 1);
matrixStackIn.popPose(); matrixStackIn.popPose();
} }
// TODO model rendering private static class ModelMoverMinecart extends Model {
/* private static class ModelMoverMinecart extends Model {
private final ModelRenderer box; private final ModelPart model;
public ModelMoverMinecart() { public ModelMoverMinecart() {
super(RenderType::getEntityCutout); super(RenderType::entityCutout);
this.box = new ModelRenderer(this, 0, 0); var mesh = new MeshDefinition();
this.box.setTextureSize(64, 64); var part = mesh.getRoot();
this.box.addBox(0, 0, 0, 16, 24, 16); part.addOrReplaceChild("main", new CubeListBuilder().addBox(0, 0, 0, 16, 24, 16), PartPose.ZERO);
this.model = LayerDefinition.create(mesh, 64, 64).bakeRoot();
} }
@Override @Override
public void render(MatrixStack matrixStackIn, IVertexBuilder bufferIn, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float alpha) { public void renderToBuffer(PoseStack matrixStackIn, VertexConsumer bufferIn, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float alpha) {
this.box.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn, red, green, blue, alpha); this.model.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn, red, green, blue, alpha);
} }
}*/ }
} }

View file

@ -1,32 +1,44 @@
package de.ellpeck.naturesaura.events; package de.ellpeck.naturesaura.events;
import com.mojang.blaze3d.platform.Window;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.ModConfig; import de.ellpeck.naturesaura.ModConfig;
import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
import de.ellpeck.naturesaura.api.aura.type.IAuraType; import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import de.ellpeck.naturesaura.blocks.tiles.*;
import de.ellpeck.naturesaura.items.ItemAuraCache; import de.ellpeck.naturesaura.items.ItemAuraCache;
import de.ellpeck.naturesaura.items.ItemRangeVisualizer; import de.ellpeck.naturesaura.items.ItemRangeVisualizer;
import de.ellpeck.naturesaura.items.ModItems; import de.ellpeck.naturesaura.items.ModItems;
import de.ellpeck.naturesaura.packet.PacketAuraChunk; import de.ellpeck.naturesaura.packet.PacketAuraChunk;
import net.minecraft.ChatFormatting; import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.ChatScreen;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.renderer.BiomeColors; import net.minecraft.client.renderer.BiomeColors;
import net.minecraft.client.resources.language.I18n;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.util.Tuple; import net.minecraft.util.Tuple;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items; import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.*; import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.BonemealableBlock;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.block.MyceliumBlock;
import net.minecraft.world.level.levelgen.Heightmap; import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.client.event.RenderLevelLastEvent; import net.minecraftforge.client.event.RenderLevelLastEvent;
import net.minecraftforge.common.IPlantable; import net.minecraftforge.common.IPlantable;
import net.minecraftforge.energy.EnergyStorage;
import net.minecraftforge.event.TickEvent; import net.minecraftforge.event.TickEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import org.apache.commons.lang3.mutable.MutableInt; import org.apache.commons.lang3.mutable.MutableInt;
@ -236,131 +248,132 @@ public class ClientEvents {
@SubscribeEvent @SubscribeEvent
public void onOverlayRender(RenderGameOverlayEvent.Post event) { public void onOverlayRender(RenderGameOverlayEvent.Post event) {
// TODO raw rendering bleh, should be easy enough to convert to PoseStack stuff var mc = Minecraft.getInstance();
/*Minecraft mc = Minecraft.getInstance(); var stack = event.getMatrixStack();
PoseStack stack = event.getMatrixStack(); if (event.getType() == RenderGameOverlayEvent.ElementType.ALL) {
if (event.getType() == ElementType.ALL) {
var res = event.getWindow(); var res = event.getWindow();
if (mc.player != null) { if (mc.player != null) {
if (!heldCache.isEmpty()) { if (!heldCache.isEmpty()) {
IAuraContainer container = heldCache.getCapability(NaturesAuraAPI.capAuraContainer, null).orElse(null); var container = heldCache.getCapability(NaturesAuraAPI.capAuraContainer, null).orElse(null);
int width = Mth.ceil(container.getStoredAura() / (float) container.getMaxAura() * 80); var width = Mth.ceil(container.getStoredAura() / (float) container.getMaxAura() * 80);
int conf = ModConfig.instance.cacheBarLocation.get(); int conf = ModConfig.instance.cacheBarLocation.get();
int x = res.getGuiScaledWidth() / 2 + (conf == 0 ? -173 - (mc.player.getOffhandItem().isEmpty() ? 0 : 29) : 93); var x = res.getGuiScaledWidth() / 2 + (conf == 0 ? -173 - (mc.player.getOffhandItem().isEmpty() ? 0 : 29) : 93);
int y = res.getScreenHeight() - 8; var y = res.getGuiScaledHeight() - 8;
RenderSystem.pushMatrix(); stack.pushPose();
int color = container.getAuraColor(); var color = container.getAuraColor();
RenderSystem.color4f((color >> 16 & 255) / 255F, (color >> 8 & 255) / 255F, (color & 255) / 255F, 1); RenderSystem.setShaderColor((color >> 16 & 255) / 255F, (color >> 8 & 255) / 255F, (color & 255) / 255F, 1);
mc.getTextureManager().bindTexture(OVERLAYS); RenderSystem.setShaderTexture(0, OVERLAYS);
if (width < 80) if (width < 80)
AbstractGui.blit(stack, x + width, y, width, 0, 80 - width, 6, 256, 256); Screen.blit(stack, x + width, y, width, 0, 80 - width, 6, 256, 256);
if (width > 0) if (width > 0)
AbstractGui.blit(stack, x, y, 0, 6, width, 6, 256, 256); Screen.blit(stack, x, y, 0, 6, width, 6, 256, 256);
float scale = 0.75F; var scale = 0.75F;
RenderSystem.scalef(scale, scale, scale); stack.pushPose();
String s = heldCache.getDisplayName().getString(); stack.scale(scale, scale, scale);
mc.fontRenderer.drawStringWithShadow(stack, s, conf == 1 ? x / scale : (x + 80) / scale - mc.fontRenderer.getStringWidth(s), (y - 7) / scale, color); var s = heldCache.getDisplayName().getString();
mc.font.drawShadow(stack, s, conf == 1 ? x / scale : (x + 80) / scale - mc.font.width(s), (y - 7) / scale, color);
stack.popPose();
RenderSystem.color4f(1F, 1F, 1F, 1); RenderSystem.setShaderColor(1F, 1F, 1F, 1);
RenderSystem.popMatrix(); stack.pushPose();
} }
if (!heldEye.isEmpty() || !heldOcular.isEmpty()) { if (!heldEye.isEmpty() || !heldOcular.isEmpty()) {
RenderSystem.pushMatrix(); stack.pushPose();
mc.getTextureManager().bindTexture(OVERLAYS); RenderSystem.setShaderTexture(0, OVERLAYS);
int conf = ModConfig.instance.auraBarLocation.get(); int conf = ModConfig.instance.auraBarLocation.get();
if (!mc.gameSettings.showDebugInfo && (conf != 2 || !(mc.currentScreen instanceof ChatScreen))) { if (!mc.options.renderDebug && (conf != 2 || !(mc.screen instanceof ChatScreen))) {
int color = IAuraType.forLevel(mc.level).getColor(); var color = IAuraType.forLevel(mc.level).getColor();
RenderSystem.color4f((color >> 16 & 0xFF) / 255F, (color >> 8 & 0xFF) / 255F, (color & 0xFF) / 255F, 1); RenderSystem.setShaderColor((color >> 16 & 0xFF) / 255F, (color >> 8 & 0xFF) / 255F, (color & 0xFF) / 255F, 1);
int totalAmount = IAuraChunk.triangulateAuraInArea(mc.level, mc.player.getPosition(), 35); var totalAmount = IAuraChunk.triangulateAuraInArea(mc.level, mc.player.blockPosition(), 35);
float totalPercentage = totalAmount / (IAuraChunk.DEFAULT_AURA * 2F); var totalPercentage = totalAmount / (IAuraChunk.DEFAULT_AURA * 2F);
String text = I18n.format("info." + NaturesAura.MOD_ID + ".aura_in_area"); var text = I18n.get("info." + NaturesAura.MOD_ID + ".aura_in_area");
float textScale = 0.75F; var textScale = 0.75F;
int startX = conf % 2 == 0 ? 3 : res.getScaledWidth() - 3 - 6; var startX = conf % 2 == 0 ? 3 : res.getGuiScaledWidth() - 3 - 6;
int startY = conf < 2 ? 10 : (!heldOcular.isEmpty() && (totalPercentage > 1F || totalPercentage < 0) ? -26 : 0) + res.getScaledHeight() - 60; var startY = conf < 2 ? 10 : (!heldOcular.isEmpty() && (totalPercentage > 1F || totalPercentage < 0) ? -26 : 0) + res.getGuiScaledHeight() - 60;
float plusOffX = conf % 2 == 0 ? 7 : -1 - 6; float plusOffX = conf % 2 == 0 ? 7 : -1 - 6;
float textX = conf % 2 == 0 ? 3 : res.getScaledWidth() - 3 - mc.fontRenderer.getStringWidth(text) * textScale; var textX = conf % 2 == 0 ? 3 : res.getGuiScaledWidth() - 3 - mc.font.width(text) * textScale;
float textY = conf < 2 ? 3 : res.getScaledHeight() - 3 - 6; float textY = conf < 2 ? 3 : res.getGuiScaledHeight() - 3 - 6;
int tHeight = Mth.ceil(Mth.clamp(totalPercentage, 0F, 1F) * 50); var tHeight = Mth.ceil(Mth.clamp(totalPercentage, 0F, 1F) * 50);
int y = !heldOcular.isEmpty() && totalPercentage > 1F ? startY + 26 : startY; var y = !heldOcular.isEmpty() && totalPercentage > 1F ? startY + 26 : startY;
if (tHeight < 50) if (tHeight < 50)
AbstractGui.blit(stack, startX, y, 6, 12, 6, 50 - tHeight, 256, 256); Screen.blit(stack, startX, y, 6, 12, 6, 50 - tHeight, 256, 256);
if (tHeight > 0) if (tHeight > 0)
AbstractGui.blit(stack, startX, y + 50 - tHeight, 0, 12 + 50 - tHeight, 6, tHeight, 256, 256); Screen.blit(stack, startX, y + 50 - tHeight, 0, 12 + 50 - tHeight, 6, tHeight, 256, 256);
if (!heldOcular.isEmpty()) { if (!heldOcular.isEmpty()) {
int topHeight = Mth.ceil(Mth.clamp((totalPercentage - 1F) * 2F, 0F, 1F) * 25); var topHeight = Mth.ceil(Mth.clamp((totalPercentage - 1F) * 2F, 0F, 1F) * 25);
if (topHeight > 0) { if (topHeight > 0) {
if (topHeight < 25) if (topHeight < 25)
AbstractGui.blit(stack, startX, startY, 18, 12, 6, 25 - topHeight, 256, 256); Screen.blit(stack, startX, startY, 18, 12, 6, 25 - topHeight, 256, 256);
AbstractGui.blit(stack, startX, startY + 25 - topHeight, 12, 12 + 25 - topHeight, 6, topHeight, 256, 256); Screen.blit(stack, startX, startY + 25 - topHeight, 12, 12 + 25 - topHeight, 6, topHeight, 256, 256);
} }
int bottomHeight = Mth.floor(Mth.clamp((totalPercentage + 1F) * 2F - 1F, 0F, 1F) * 25); var bottomHeight = Mth.floor(Mth.clamp((totalPercentage + 1F) * 2F - 1F, 0F, 1F) * 25);
if (bottomHeight < 25) { if (bottomHeight < 25) {
AbstractGui.blit(stack, startX, startY + 51, 18, 12, 6, 25 - bottomHeight, 256, 256); Screen.blit(stack, startX, startY + 51, 18, 12, 6, 25 - bottomHeight, 256, 256);
if (bottomHeight > 0) if (bottomHeight > 0)
AbstractGui.blit(stack, startX, startY + 51 + 25 - bottomHeight, 12, 12 + 25 - bottomHeight, 6, bottomHeight, 256, 256); Screen.blit(stack, startX, startY + 51 + 25 - bottomHeight, 12, 12 + 25 - bottomHeight, 6, bottomHeight, 256, 256);
} }
} }
if (totalPercentage > (heldOcular.isEmpty() ? 1F : 1.5F)) if (totalPercentage > (heldOcular.isEmpty() ? 1F : 1.5F))
mc.fontRenderer.drawStringWithShadow(stack, "+", startX + plusOffX, startY - 0.5F, color); mc.font.drawShadow(stack, "+", startX + plusOffX, startY - 0.5F, color);
if (totalPercentage < (heldOcular.isEmpty() ? 0F : -0.5F)) if (totalPercentage < (heldOcular.isEmpty() ? 0F : -0.5F))
mc.fontRenderer.drawStringWithShadow(stack, "-", startX + plusOffX, startY - 0.5F + (heldOcular.isEmpty() ? 44 : 70), color); mc.font.drawShadow(stack, "-", startX + plusOffX, startY - 0.5F + (heldOcular.isEmpty() ? 44 : 70), color);
RenderSystem.pushMatrix(); stack.pushPose();
RenderSystem.scalef(textScale, textScale, textScale); stack.scale(textScale, textScale, textScale);
mc.fontRenderer.drawStringWithShadow(stack, text, textX / textScale, textY / textScale, color); mc.font.drawShadow(stack, text, textX / textScale, textY / textScale, color);
RenderSystem.popMatrix(); stack.popPose();
if (!heldOcular.isEmpty()) { if (!heldOcular.isEmpty()) {
float scale = 0.75F; var scale = 0.75F;
RenderSystem.pushMatrix(); stack.pushPose();
RenderSystem.scalef(scale, scale, scale); stack.scale(scale, scale, scale);
int stackX = conf % 2 == 0 ? 10 : res.getScaledWidth() - 22; var stackX = conf % 2 == 0 ? 10 : res.getGuiScaledWidth() - 22;
int stackY = conf < 2 ? 15 : res.getScaledHeight() - 55; var stackY = conf < 2 ? 15 : res.getGuiScaledHeight() - 55;
for (Tuple<ItemStack, Boolean> effect : SHOWING_EFFECTS.values()) { for (var effect : SHOWING_EFFECTS.values()) {
int theX = (int) (stackX / scale); var theX = (int) (stackX / scale);
int theY = (int) (stackY / scale); var theY = (int) (stackY / scale);
ItemStack itemStack = effect.getA(); var itemStack = effect.getA();
Helper.renderItemInGui(itemStack, theX, theY, 1F); Helper.renderItemInGui(itemStack, theX, theY, 1F);
if (effect.getB()) { if (effect.getB()) {
GlStateManager.disableDepthTest(); RenderSystem.disableDepthTest();
mc.getTextureManager().bindTexture(OVERLAYS); RenderSystem.setShaderTexture(0, OVERLAYS);
AbstractGui.blit(stack, theX, theY, 240, 0, 16, 16, 256, 256); Screen.blit(stack, theX, theY, 240, 0, 16, 16, 256, 256);
GlStateManager.enableDepthTest(); RenderSystem.enableDepthTest();
} }
stackY += 8; stackY += 8;
} }
RenderSystem.popMatrix(); stack.popPose();
} }
} }
if (mc.objectMouseOver instanceof BlockRayTraceResult) { if (mc.hitResult instanceof BlockHitResult blockHitResult) {
BlockPos pos = ((BlockRayTraceResult) mc.objectMouseOver).getPos(); var pos = blockHitResult.getBlockPos();
if (pos != null) { if (pos != null) {
BlockEntity tile = mc.level.getBlockEntity(pos); var tile = mc.level.getBlockEntity(pos);
IAuraContainer container; IAuraContainer container;
int x = res.getScaledWidth() / 2; var x = res.getGuiScaledWidth() / 2;
int y = res.getScaledHeight() / 2; var y = res.getGuiScaledHeight() / 2;
if (tile != null && (container = tile.getCapability(NaturesAuraAPI.capAuraContainer, null).orElse(null)) != null) { if (tile != null && (container = tile.getCapability(NaturesAuraAPI.capAuraContainer, null).orElse(null)) != null) {
BlockState state = mc.level.getBlockState(pos); var state = mc.level.getBlockState(pos);
ItemStack blockStack = state.getBlock().getPickBlock(state, mc.objectMouseOver, mc.level, pos, mc.player); var blockStack = state.getBlock().getCloneItemStack(state, blockHitResult, mc.level, pos, mc.player);
this.drawContainerInfo(stack, container.getStoredAura(), container.getMaxAura(), container.getAuraColor(), this.drawContainerInfo(stack, container.getStoredAura(), container.getMaxAura(), container.getAuraColor(),
mc, res, 35, blockStack.getDisplayName().getString(), null); mc, res, 35, blockStack.getDisplayName().getString(), null);
if (tile instanceof BlockEntityNatureAltar) { if (tile instanceof BlockEntityNatureAltar) {
ItemStack tileStack = ((BlockEntityNatureAltar) tile).getItemHandler().getStackInSlot(0); var tileStack = ((BlockEntityNatureAltar) tile).getItemHandler().getStackInSlot(0);
if (!tileStack.isEmpty()) { if (!tileStack.isEmpty()) {
IAuraContainer stackCont = tileStack.getCapability(NaturesAuraAPI.capAuraContainer, null).orElse(null); var stackCont = tileStack.getCapability(NaturesAuraAPI.capAuraContainer, null).orElse(null);
if (stackCont != null) { if (stackCont != null) {
this.drawContainerInfo(stack, stackCont.getStoredAura(), stackCont.getMaxAura(), stackCont.getAuraColor(), this.drawContainerInfo(stack, stackCont.getStoredAura(), stackCont.getMaxAura(), stackCont.getAuraColor(),
mc, res, 55, tileStack.getDisplayName().getString(), null); mc, res, 55, tileStack.getDisplayName().getString(), null);
@ -370,50 +383,48 @@ public class ClientEvents {
} else if (tile instanceof BlockEntityRFConverter) { } else if (tile instanceof BlockEntityRFConverter) {
EnergyStorage storage = ((BlockEntityRFConverter) tile).storage; EnergyStorage storage = ((BlockEntityRFConverter) tile).storage;
this.drawContainerInfo(stack, storage.getEnergyStored(), storage.getMaxEnergyStored(), 0xcc4916, this.drawContainerInfo(stack, storage.getEnergyStored(), storage.getMaxEnergyStored(), 0xcc4916,
mc, res, 35, I18n.format("block.naturesaura.rf_converter"), mc, res, 35, I18n.get("block.naturesaura.rf_converter"),
storage.getEnergyStored() + " / " + storage.getMaxEnergyStored() + " RF"); storage.getEnergyStored() + " / " + storage.getMaxEnergyStored() + " RF");
} else if (tile instanceof BlockEntityGratedChute) { } else if (tile instanceof BlockEntityGratedChute chute) {
BlockEntityGratedChute chute = (BlockEntityGratedChute) tile; var itemStack = chute.getItemHandler().getStackInSlot(0);
ItemStack itemStack = chute.getItemHandler().getStackInSlot(0);
if (itemStack.isEmpty()) if (itemStack.isEmpty()) {
mc.fontRenderer.drawStringWithShadow(stack, mc.font.drawShadow(stack,
TextFormatting.GRAY.toString() + TextFormatting.ITALIC + I18n.format("info.naturesaura.empty"), ChatFormatting.GRAY.toString() + ChatFormatting.ITALIC + I18n.get("info.naturesaura.empty"),
x + 5, y - 11, 0xFFFFFF); x + 5, y - 11, 0xFFFFFF);
else } else {
Helper.renderItemInGui(itemStack, x + 2, y - 18, 1F); Helper.renderItemInGui(itemStack, x + 2, y - 18, 1F);
}
Helper.renderItemInGui(ITEM_FRAME, x - 24, y - 24, 1F); Helper.renderItemInGui(ITEM_FRAME, x - 24, y - 24, 1F);
mc.getTextureManager().bindTexture(OVERLAYS); RenderSystem.setShaderTexture(0, OVERLAYS);
int u = chute.isBlacklist ? 240 : 224; var u = chute.isBlacklist ? 240 : 224;
GlStateManager.disableDepthTest(); RenderSystem.disableDepthTest();
AbstractGui.blit(stack, x - 18, y - 18, u, 0, 16, 16, 256, 256); Screen.blit(stack, x - 18, y - 18, u, 0, 16, 16, 256, 256);
GlStateManager.enableDepthTest(); RenderSystem.enableDepthTest();
} else if (tile instanceof BlockEntityItemDistributor) { } else if (tile instanceof BlockEntityItemDistributor distributor) {
BlockEntityItemDistributor distributor = (BlockEntityItemDistributor) tile;
Helper.renderItemInGui(DISPENSER, x - 24, y - 24, 1F); Helper.renderItemInGui(DISPENSER, x - 24, y - 24, 1F);
mc.getTextureManager().bindTexture(OVERLAYS); RenderSystem.setShaderTexture(0, OVERLAYS);
int u = !distributor.isRandomMode ? 240 : 224; var u = !distributor.isRandomMode ? 240 : 224;
GlStateManager.disableDepthTest(); RenderSystem.disableDepthTest();
AbstractGui.blit(stack, x - 18, y - 18, u, 0, 16, 16, 256, 256); Screen.blit(stack, x - 18, y - 18, u, 0, 16, 16, 256, 256);
GlStateManager.enableDepthTest(); RenderSystem.enableDepthTest();
} else if (tile instanceof BlockEntityAuraTimer) { } else if (tile instanceof BlockEntityAuraTimer timer) {
BlockEntityAuraTimer timer = (BlockEntityAuraTimer) tile; var itemStack = timer.getItemHandler().getStackInSlot(0);
ItemStack itemStack = timer.getItemHandler().getStackInSlot(0);
if (!itemStack.isEmpty()) { if (!itemStack.isEmpty()) {
Helper.renderItemInGui(itemStack, x - 20, y - 20, 1); Helper.renderItemInGui(itemStack, x - 20, y - 20, 1);
mc.fontRenderer.drawStringWithShadow(stack, TextFormatting.GRAY + this.createTimeString(timer.getTotalTime()), x + 5, y - 11, 0xFFFFFF); mc.font.drawShadow(stack, ChatFormatting.GRAY + this.createTimeString(timer.getTotalTime()), x + 5, y - 11, 0xFFFFFF);
mc.fontRenderer.drawStringWithShadow(stack, TextFormatting.GRAY + I18n.format("info.naturesaura.remaining", this.createTimeString(timer.getTimeLeft())), x + 5, y + 3, 0xFFFFFF); mc.font.drawShadow(stack, ChatFormatting.GRAY + I18n.get("info.naturesaura.remaining", this.createTimeString(timer.getTimeLeft())), x + 5, y + 3, 0xFFFFFF);
} }
} }
} }
} }
RenderSystem.color4f(1F, 1F, 1F, 1); RenderSystem.setShaderColor(1F, 1F, 1F, 1);
RenderSystem.popMatrix(); stack.popPose();
} }
} }
}*/ }
} }
private String createTimeString(int totalTicks) { private String createTimeString(int totalTicks) {
@ -424,22 +435,22 @@ public class ClientEvents {
return String.format("%02d:%02d:%02d.%02d", hours, minutes, seconds, ticks); return String.format("%02d:%02d:%02d.%02d", hours, minutes, seconds, ticks);
} }
/* private void drawContainerInfo(PoseStack stack, int stored, int max, int color, Minecraft mc, MainWindow res, int yOffset, String name, String textBelow) { private void drawContainerInfo(PoseStack stack, int stored, int max, int color, Minecraft mc, Window res, int yOffset, String name, String textBelow) {
RenderSystem.color3f((color >> 16 & 255) / 255F, (color >> 8 & 255) / 255F, (color & 255) / 255F); RenderSystem.setShaderColor((color >> 16 & 255) / 255F, (color >> 8 & 255) / 255F, (color & 255) / 255F, 1);
int x = res.getScaledWidth() / 2 - 40; var x = res.getGuiScaledWidth() / 2 - 40;
int y = res.getScaledHeight() / 2 + yOffset; var y = res.getGuiScaledHeight() / 2 + yOffset;
int width = Mth.ceil(stored / (float) max * 80); var width = Mth.ceil(stored / (float) max * 80);
mc.getTextureManager().bindTexture(OVERLAYS); RenderSystem.setShaderTexture(0, OVERLAYS);
if (width < 80) if (width < 80)
AbstractGui.blit(stack, x + width, y, width, 0, 80 - width, 6, 256, 256); Screen.blit(stack, x + width, y, width, 0, 80 - width, 6, 256, 256);
if (width > 0) if (width > 0)
AbstractGui.blit(stack, x, y, 0, 6, width, 6, 256, 256); Screen.blit(stack, x, y, 0, 6, width, 6, 256, 256);
mc.fontRenderer.drawStringWithShadow(stack, name, x + 40 - mc.fontRenderer.getStringWidth(name) / 2F, y - 9, color); mc.font.drawShadow(stack, name, x + 40 - mc.font.width(name) / 2F, y - 9, color);
if (textBelow != null) if (textBelow != null)
mc.fontRenderer.drawStringWithShadow(stack, textBelow, x + 40 - mc.fontRenderer.getStringWidth(textBelow) / 2F, y + 7, color); mc.font.drawShadow(stack, textBelow, x + 40 - mc.font.width(textBelow) / 2F, y + 7, color);
}*/ }
} }

View file

@ -19,11 +19,8 @@ import net.minecraft.server.level.ChunkHolder;
import net.minecraft.server.level.ChunkMap; import net.minecraft.server.level.ChunkMap;
import net.minecraft.server.level.ServerChunkCache; import net.minecraft.server.level.ServerChunkCache;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraftforge.event.AttachCapabilitiesEvent; import net.minecraftforge.event.AttachCapabilitiesEvent;
import net.minecraftforge.event.TickEvent; import net.minecraftforge.event.TickEvent;
@ -37,28 +34,26 @@ import net.minecraftforge.fml.util.ObfuscationReflectionHelper;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.List;
import java.util.UUID; import java.util.UUID;
import static net.minecraft.world.level.levelgen.GenerationStep.Decoration; import static net.minecraft.world.level.levelgen.GenerationStep.Decoration;
public class CommonEvents { public class CommonEvents {
private static final Method GET_LOADED_CHUNKS_METHOD = ObfuscationReflectionHelper.findMethod(ChunkMap.class, "getChunks"); private static final Method GET_LOADED_CHUNKS_METHOD = ObfuscationReflectionHelper.findMethod(ChunkMap.class, "m_140416_");
private static final ListMultimap<UUID, ChunkPos> PENDING_AURA_CHUNKS = ArrayListMultimap.create(); private static final ListMultimap<UUID, ChunkPos> PENDING_AURA_CHUNKS = ArrayListMultimap.create();
@SubscribeEvent @SubscribeEvent
public void onBiomeLoad(BiomeLoadingEvent event) { public void onBiomeLoad(BiomeLoadingEvent event) {
if (ModConfig.instance.auraBlooms.get()) { if (ModConfig.instance.auraBlooms.get()) {
// TODO features might have to be registered *AGAIN* now because .placed() is another thing again oh my God event.getGeneration().addFeature(Decoration.VEGETAL_DECORATION, ModFeatures.Placed.AURA_BLOOM);
event.getGeneration().addFeature(Decoration.VEGETAL_DECORATION, ModFeatures.Configured.AURA_BLOOM.placed());
switch (event.getCategory()) { switch (event.getCategory()) {
case DESERT -> event.getGeneration().addFeature(Decoration.VEGETAL_DECORATION, ModFeatures.Configured.AURA_CACTUS.placed()); case DESERT -> event.getGeneration().addFeature(Decoration.VEGETAL_DECORATION, ModFeatures.Placed.AURA_CACTUS);
case NETHER -> { case NETHER -> {
event.getGeneration().addFeature(Decoration.VEGETAL_DECORATION, ModFeatures.Configured.CRIMSON_AURA_MUSHROOM.placed()); event.getGeneration().addFeature(Decoration.VEGETAL_DECORATION, ModFeatures.Placed.CRIMSON_AURA_MUSHROOM);
event.getGeneration().addFeature(Decoration.VEGETAL_DECORATION, ModFeatures.Configured.WARPED_AURA_MUSHROOM.placed()); event.getGeneration().addFeature(Decoration.VEGETAL_DECORATION, ModFeatures.Placed.WARPED_AURA_MUSHROOM);
} }
case MUSHROOM -> event.getGeneration().addFeature(Decoration.VEGETAL_DECORATION, ModFeatures.Configured.AURA_MUSHROOM.placed()); case MUSHROOM -> event.getGeneration().addFeature(Decoration.VEGETAL_DECORATION, ModFeatures.Placed.AURA_MUSHROOM);
} }
} }
} }

View file

@ -5,6 +5,7 @@ import net.minecraft.world.level.levelgen.feature.Feature;
import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration; import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration; import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.levelgen.feature.configurations.TreeConfiguration; import net.minecraft.world.level.levelgen.feature.configurations.TreeConfiguration;
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
@SuppressWarnings("FieldNamingConvention") @SuppressWarnings("FieldNamingConvention")
public final class ModFeatures { public final class ModFeatures {
@ -20,7 +21,6 @@ public final class ModFeatures {
public static final class Configured { public static final class Configured {
public static final ConfiguredFeature<TreeConfiguration, ?> ANCIENT_TREE = ModFeatures.ANCIENT_TREE.configured(new TreeConfiguration.TreeConfigurationBuilder(null, null, null, null, null).build()); public static final ConfiguredFeature<TreeConfiguration, ?> ANCIENT_TREE = ModFeatures.ANCIENT_TREE.configured(new TreeConfiguration.TreeConfigurationBuilder(null, null, null, null, null).build());
public static final ConfiguredFeature<NoneFeatureConfiguration, ?> NETHER_WART_MUSHROOM = ModFeatures.NETHER_WART_MUSHROOM.configured(FeatureConfiguration.NONE);
public static final ConfiguredFeature<NoneFeatureConfiguration, ?> AURA_BLOOM = ModFeatures.AURA_BLOOM.configured(FeatureConfiguration.NONE); public static final ConfiguredFeature<NoneFeatureConfiguration, ?> AURA_BLOOM = ModFeatures.AURA_BLOOM.configured(FeatureConfiguration.NONE);
public static final ConfiguredFeature<NoneFeatureConfiguration, ?> AURA_CACTUS = ModFeatures.AURA_CACTUS.configured(FeatureConfiguration.NONE); public static final ConfiguredFeature<NoneFeatureConfiguration, ?> AURA_CACTUS = ModFeatures.AURA_CACTUS.configured(FeatureConfiguration.NONE);
public static final ConfiguredFeature<NoneFeatureConfiguration, ?> WARPED_AURA_MUSHROOM = ModFeatures.WARPED_AURA_MUSHROOM.configured(FeatureConfiguration.NONE); public static final ConfiguredFeature<NoneFeatureConfiguration, ?> WARPED_AURA_MUSHROOM = ModFeatures.WARPED_AURA_MUSHROOM.configured(FeatureConfiguration.NONE);
@ -28,4 +28,14 @@ public final class ModFeatures {
public static final ConfiguredFeature<NoneFeatureConfiguration, ?> AURA_MUSHROOM = ModFeatures.AURA_MUSHROOM.configured(FeatureConfiguration.NONE); public static final ConfiguredFeature<NoneFeatureConfiguration, ?> AURA_MUSHROOM = ModFeatures.AURA_MUSHROOM.configured(FeatureConfiguration.NONE);
} }
public static final class Placed {
public static final PlacedFeature AURA_BLOOM = ModFeatures.Configured.AURA_BLOOM.placed();
public static final PlacedFeature AURA_CACTUS = ModFeatures.Configured.AURA_CACTUS.placed();
public static final PlacedFeature WARPED_AURA_MUSHROOM = ModFeatures.Configured.WARPED_AURA_MUSHROOM.placed();
public static final PlacedFeature CRIMSON_AURA_MUSHROOM = ModFeatures.Configured.CRIMSON_AURA_MUSHROOM.placed();
public static final PlacedFeature AURA_MUSHROOM = ModFeatures.Configured.AURA_MUSHROOM.placed();
}
} }

Some files were not shown because too many files have changed in this diff Show more